Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: chrome/browser/chromeos/gdata/mock_documents_service.h

Issue 10828385: Rename DocumentsServiceInterface to DriveServiceInterface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_documents_service.h
6
7 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_MOCK_DOCUMENTS_SERVICE_H_
8 #define CHROME_BROWSER_CHROMEOS_GDATA_MOCK_DOCUMENTS_SERVICE_H_
9
10 #include <string>
11
12 #include "base/platform_file.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/chromeos/gdata/documents_service_interface.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* profile));
29 MOCK_CONST_METHOD0(operation_registry, GDataOperationRegistry*());
30 MOCK_METHOD0(CancelAll, void(void));
31 MOCK_METHOD1(Authenticate, void(const AuthStatusCallback& callback));
32 MOCK_METHOD5(GetDocuments, void(const GURL& feed_url,
33 int64 start_changestamp,
34 const std::string& search_string,
35 const std::string& directory_resource_id,
36 const GetDataCallback& callback));
37 MOCK_METHOD2(GetDocumentEntry, void(const std::string& resource_id,
38 const GetDataCallback& callback));
39 MOCK_METHOD1(GetAccountMetadata, void(const GetDataCallback& callback));
40 MOCK_METHOD1(GetApplicationInfo, void(const GetDataCallback& callback));
41 MOCK_METHOD2(DeleteDocument, void(const GURL& document_url,
42 const EntryActionCallback& callback));
43 MOCK_METHOD5(DownloadDocument, void(const FilePath& virtual_path,
44 const FilePath& local_cache_path,
45 const GURL& content_url,
46 DocumentExportFormat format,
47 const DownloadActionCallback& callback));
48 MOCK_METHOD3(CopyDocument, void(const std::string& resource_id,
49 const FilePath::StringType& new_name,
50 const GetDataCallback& callback));
51 MOCK_METHOD3(RenameResource, void(const GURL& resource_url,
52 const FilePath::StringType& new_name,
53 const EntryActionCallback& callback));
54 MOCK_METHOD3(AddResourceToDirectory,
55 void(const GURL& parent_content_url,
56 const GURL& resource_url,
57 const EntryActionCallback& callback));
58 MOCK_METHOD4(RemoveResourceFromDirectory,
59 void(const GURL& parent_content_url,
60 const GURL& resource_url,
61 const std::string& resource_id,
62 const EntryActionCallback& callback));
63 MOCK_METHOD3(CreateDirectory,
64 void(const GURL& parent_content_url,
65 const FilePath::StringType& directory_name,
66 const GetDataCallback& callback));
67 MOCK_METHOD5(DownloadFile,
68 void(const FilePath& virtual_path,
69 const FilePath& local_cache_path,
70 const GURL& content_url,
71 const DownloadActionCallback& donwload_action_callback,
72 const GetContentCallback& get_content_callback));
73 MOCK_METHOD2(InitiateUpload,
74 void(const InitiateUploadParams& upload_file_info,
75 const InitiateUploadCallback& callback));
76 MOCK_METHOD2(ResumeUpload, void(const ResumeUploadParams& upload_file_info,
77 const ResumeUploadCallback& callback));
78 MOCK_METHOD3(AuthorizeApp, void(const GURL& resource_url,
79 const std::string& app_ids,
80 const GetDataCallback& callback));
81 MOCK_CONST_METHOD0(HasAccessToken, bool());
82 MOCK_CONST_METHOD0(HasRefreshToken, bool());
83
84 void set_account_metadata(base::Value* account_metadata) {
85 account_metadata_.reset(account_metadata);
86 }
87
88 void set_feed_data(base::Value* feed_data) {
89 feed_data_.reset(feed_data);
90 }
91
92 void set_directory_data(base::Value* directory_data) {
93 directory_data_.reset(directory_data);
94 }
95
96 void set_file_data(std::string* file_data) {
97 file_data_.reset(file_data);
98 }
99
100 void set_search_result(const std::string& search_result_feed);
101
102 private:
103 // Helper stub methods for functions which take callbacks, so that
104 // the callbacks get called with testable results.
105
106 // Will call |callback| with HTTP_SUCCESS and the token "test_auth_token"
107 // as the token.
108 void AuthenticateStub(const AuthStatusCallback& callback);
109
110 // Will call |callback| with HTTP_SUCCESS and a StringValue with the current
111 // value of |feed_data_|.
112 void GetDocumentsStub(const GURL& feed_url,
113 int64 start_changestamp,
114 const std::string& search_string,
115 const std::string& directory_resource_id,
116 const GetDataCallback& callback);
117
118 // Will call |callback| with HTTP_SUCCESS and a StringValue with the current
119 // value of |account_metadata_|.
120 void GetAccountMetadataStub(const GetDataCallback& callback);
121
122 // Will call |callback| with HTTP_SUCCESS and the |document_url|.
123 void DeleteDocumentStub(const GURL& document_url,
124 const EntryActionCallback& callback);
125
126 // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path
127 // portion of the URL as the temporary file path.
128 void DownloadDocumentStub(const FilePath& virtual_path,
129 const FilePath& local_tmp_path,
130 const GURL& content_url,
131 DocumentExportFormat format,
132 const DownloadActionCallback& callback);
133
134 // Will call |callback| with HTTP_SUCCESS and the current value of
135 // |document_data_|.
136 void CopyDocumentStub(const std::string& resource_id,
137 const FilePath::StringType& new_name,
138 const GetDataCallback& callback);
139
140 // Will call |callback| with HTTP_SUCCESS and the |document_url|.
141 void RenameResourceStub(const GURL& document_url,
142 const FilePath::StringType& new_name,
143 const EntryActionCallback& callback);
144
145 // Will call |callback| with HTTP_SUCCESS and the |resource_url|.
146 void AddResourceToDirectoryStub(const GURL& parent_content_url,
147 const GURL& resource_url,
148 const EntryActionCallback& callback);
149
150 // Will call |callback| with HTTP_SUCCESS and the |resource_url|.
151 void RemoveResourceFromDirectoryStub(const GURL& parent_content_url,
152 const GURL& resource_url,
153 const std::string& resource_id,
154 const EntryActionCallback& callback);
155
156 // Will call |callback| with HTTP_SUCCESS and the current value of
157 // |directory_data_|.
158 void CreateDirectoryStub(const GURL& parent_content_url,
159 const FilePath::StringType& directory_name,
160 const GetDataCallback& callback);
161
162 // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path
163 // portion of the URL as the temporary file path. If |file_data_| is not null,
164 // |file_data_| is written to the temporary file.
165 void DownloadFileStub(
166 const FilePath& virtual_path,
167 const FilePath& local_tmp_path,
168 const GURL& content_url,
169 const DownloadActionCallback& download_action_callback,
170 const GetContentCallback& get_content_callback);
171
172 // Account meta data to be returned from GetAccountMetadata.
173 scoped_ptr<base::Value> account_metadata_;
174
175 // Feed data to be returned from GetDocuments.
176 scoped_ptr<base::Value> feed_data_;
177
178 // Feed data to be returned from CreateDirectory.
179 scoped_ptr<base::Value> directory_data_;
180
181 // Feed data to be returned from CopyDocument.
182 scoped_ptr<base::Value> document_data_;
183
184 // Feed data to be returned from GetDocuments if the search path is specified.
185 // The feed contains subset of the root_feed.
186 scoped_ptr<base::Value> search_result_;
187
188 // File data to be written to the local temporary file when
189 // DownloadDocumentStub is called.
190 scoped_ptr<std::string> file_data_;
191 };
192
193 } // namespace gdata
194
195 #endif // CHROME_BROWSER_CHROMEOS_GDATA_MOCK_DOCUMENTS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698