OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // This file contains mocks for classes in gdata.h | |
6 | |
7 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_MOCK_H_ | |
8 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_MOCK_H_ | |
9 #pragma once | |
10 | |
11 #include "base/platform_file.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "chrome/browser/chromeos/gdata/gdata.h" | |
14 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | |
15 #include "testing/gmock/include/gmock/gmock.h" | |
16 | |
17 class FilePath; | |
18 | |
19 namespace gdata { | |
20 | |
21 class MockDocumentsService : public DocumentsServiceInterface { | |
22 public: | |
23 // DocumentsService is usually owned and created by GDataFileSystem. | |
24 MockDocumentsService(); | |
25 virtual ~MockDocumentsService(); | |
26 | |
27 // DocumentServiceInterface overrides. | |
28 MOCK_METHOD1(Initialize, void(Profile*)); | |
29 MOCK_METHOD0(CancelAll, void(void)); | |
30 MOCK_METHOD1(Authenticate, void(const AuthStatusCallback& callback)); | |
31 MOCK_METHOD2(GetDocuments, void(const GURL& feed_url, | |
32 const GetDataCallback& callback)); | |
33 MOCK_METHOD2(DeleteDocument, void(const GURL& document_url, | |
34 const EntryActionCallback& callback)); | |
35 MOCK_METHOD3(DownloadDocument, void(const GURL& content_url, | |
36 DocumentExportFormat format, | |
37 const DownloadActionCallback& callback)); | |
38 MOCK_METHOD3(CreateDirectory, | |
39 void(const GURL& parent_content_url, | |
40 const FilePath::StringType& directory_name, | |
41 const GetDataCallback& callback)); | |
42 MOCK_METHOD2(DownloadFile, void(const GURL& content_url, | |
43 const DownloadActionCallback& callback)); | |
44 MOCK_METHOD2(InitiateUpload, | |
45 void(const InitiateUploadParams& upload_file_info, | |
46 const InitiateUploadCallback& callback)); | |
47 MOCK_METHOD2(ResumeUpload, void(const ResumeUploadParams& upload_file_info, | |
48 const ResumeUploadCallback& callback)); | |
49 | |
50 // Helper stub methods for functions which take callbacks, so that | |
51 // the callbacks get called with testable results. | |
52 | |
53 // Will call |callback| with HTTP_SUCCESS and the token "test_auth_token" | |
54 // as the token. | |
55 void AuthenticateStub(const AuthStatusCallback& callback); | |
56 | |
57 // Will call |callback| with HTTP_SUCCESS and a StringValue with the current | |
58 // value of |feed_data_|. | |
59 void GetDocumentsStub(const GURL& feed_url, | |
60 const GetDataCallback& callback); | |
61 | |
62 // Will call |callback| with HTTP_SUCCESS and the |document_url|. | |
63 void DeleteDocumentStub(const GURL& document_url, | |
64 const EntryActionCallback& callback); | |
65 | |
66 // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path | |
67 // portion of the URL as the temporary file path. | |
68 void DownloadDocumentStub(const GURL& content_url, | |
69 DocumentExportFormat format, | |
70 const DownloadActionCallback& callback); | |
71 | |
72 // Will call |callback| with HTTP_SUCCESS and the current value of | |
73 // |directory_data_|. | |
74 void CreateDirectoryStub(const GURL& parent_content_url, | |
75 const FilePath::StringType& directory_name, | |
76 const GetDataCallback& callback); | |
77 | |
78 // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path | |
79 // portion of the URL as the temporary file path. | |
80 void DownloadFileStub(const GURL& content_url, | |
81 const DownloadActionCallback& callback); | |
82 | |
83 void set_feed_data(base::Value* document_data) { | |
84 feed_data_.reset(document_data); | |
85 } | |
86 | |
87 void set_directory_data(base::Value* document_data) { | |
88 directory_data_.reset(document_data); | |
89 } | |
satorux1
2012/03/08 01:48:37
nit: blank line here.
Greg Spencer (Chromium)
2012/03/08 19:06:35
Done.
| |
90 private: | |
91 // Feed data to be returned from GetDocuments. | |
92 scoped_ptr<base::Value> feed_data_; | |
93 | |
94 // Feed data to be returned from CreateDirectory. | |
95 scoped_ptr<base::Value> directory_data_; | |
96 }; | |
97 | |
98 } // namespace gdata | |
99 | |
100 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_MOCK_H_ | |
OLD | NEW |