Fix build break
[chromium-blink-merge.git] / chrome / browser / google_apis / mock_drive_service.h
blob8d3bf0fafd2e27f70c8d3398407a413033e81a51
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.
5 // This file contains mocks for classes in drive_service_interface.h
7 #ifndef CHROME_BROWSER_GOOGLE_APIS_MOCK_DRIVE_SERVICE_H_
8 #define CHROME_BROWSER_GOOGLE_APIS_MOCK_DRIVE_SERVICE_H_
10 #include <string>
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/google_apis/drive_service_interface.h"
14 #include "net/base/io_buffer.h"
15 #include "testing/gmock/include/gmock/gmock.h"
17 namespace base {
18 class FilePath;
21 namespace google_apis {
23 class MockDriveService : public DriveServiceInterface {
24 public:
25 // DriveService is usually owned and created by DriveFileSystem.
26 MockDriveService();
27 virtual ~MockDriveService();
29 // DriveServiceInterface overrides.
30 MOCK_METHOD1(Initialize, void(Profile* profile));
31 MOCK_METHOD1(AddObserver, void(DriveServiceObserver* observer));
32 MOCK_METHOD1(RemoveObserver,
33 void(DriveServiceObserver* observer));
34 MOCK_CONST_METHOD0(CanStartOperation, bool());
35 MOCK_METHOD0(CancelAll, void(void));
36 MOCK_METHOD1(CancelForFilePath, bool(const base::FilePath& file_path));
37 MOCK_CONST_METHOD0(GetProgressStatusList,
38 OperationProgressStatusList());
39 MOCK_CONST_METHOD0(GetRootResourceId, std::string());
40 MOCK_METHOD1(GetAllResourceList,
41 void(const GetResourceListCallback& callback));
42 MOCK_METHOD2(GetResourceListInDirectory,
43 void(const std::string& directory_resource_id,
44 const GetResourceListCallback& callback));
45 MOCK_METHOD2(Search,
46 void(const std::string& search_query,
47 const GetResourceListCallback& callback));
48 MOCK_METHOD3(SearchInDirectory,
49 void(const std::string& search_query,
50 const std::string& directory_resource_id,
51 const GetResourceListCallback& callback));
52 MOCK_METHOD2(GetChangeList,
53 void(int64 start_changestamp,
54 const GetResourceListCallback& callback));
55 MOCK_METHOD2(ContinueGetResourceList,
56 void(const GURL& override_url,
57 const GetResourceListCallback& callback));
58 MOCK_METHOD2(GetResourceEntry,
59 void(const std::string& resource_id,
60 const GetResourceEntryCallback& callback));
61 MOCK_METHOD1(GetAccountMetadata,
62 void(const GetAccountMetadataCallback& callback));
63 MOCK_METHOD1(GetAboutResource,
64 void(const GetAboutResourceCallback& callback));
65 MOCK_METHOD1(GetAppList, void(const GetAppListCallback& callback));
66 MOCK_METHOD3(DeleteResource,
67 void(const std::string& resource_id,
68 const std::string& etag,
69 const EntryActionCallback& callback));
70 MOCK_METHOD3(CopyHostedDocument,
71 void(const std::string& resource_id,
72 const std::string& new_name,
73 const GetResourceEntryCallback& callback));
74 MOCK_METHOD3(RenameResource,
75 void(const std::string& resource_id,
76 const std::string& new_name,
77 const EntryActionCallback& callback));
78 MOCK_METHOD3(AddResourceToDirectory,
79 void(const std::string& parent_resource_id,
80 const std::string& resource_id,
81 const EntryActionCallback& callback));
82 MOCK_METHOD3(RemoveResourceFromDirectory,
83 void(const std::string& parent_resource_id,
84 const std::string& resource_id,
85 const EntryActionCallback& callback));
86 MOCK_METHOD3(AddNewDirectory,
87 void(const std::string& parent_resource_id,
88 const std::string& directory_name,
89 const GetResourceEntryCallback& callback));
90 MOCK_METHOD6(
91 DownloadFile,
92 void(const base::FilePath& virtual_path,
93 const base::FilePath& local_cache_path,
94 const GURL& download_url,
95 const DownloadActionCallback& donwload_action_callback,
96 const GetContentCallback& get_content_callback,
97 const ProgressCallback& progress_callback));
98 MOCK_METHOD6(InitiateUploadNewFile,
99 void(const base::FilePath& drive_file_path,
100 const std::string& content_type,
101 int64 content_length,
102 const std::string& parent_resource_id,
103 const std::string& title,
104 const InitiateUploadCallback& callback));
105 MOCK_METHOD6(InitiateUploadExistingFile,
106 void(const base::FilePath& drive_file_path,
107 const std::string& content_type,
108 int64 content_length,
109 const std::string& resource_id,
110 const std::string& etag,
111 const InitiateUploadCallback& callback));
112 MOCK_METHOD10(ResumeUpload,
113 void(UploadMode upload_mode,
114 const base::FilePath& drive_file_path,
115 const GURL& upload_url,
116 int64 start_position,
117 int64 end_position,
118 int64 content_length,
119 const std::string& content_type,
120 const scoped_refptr<net::IOBuffer>& buf,
121 const UploadRangeCallback& callback,
122 const ProgressCallback& progress_callback));
123 MOCK_METHOD5(GetUploadStatus,
124 void(UploadMode upload_mode,
125 const base::FilePath& drive_file_path,
126 const GURL& upload_url,
127 int64 content_length,
128 const UploadRangeCallback& callback));
129 MOCK_METHOD3(AuthorizeApp,
130 void(const std::string& resource_id,
131 const std::string& app_id,
132 const AuthorizeAppCallback& callback));
133 MOCK_CONST_METHOD0(HasAccessToken, bool());
134 MOCK_CONST_METHOD0(HasRefreshToken, bool());
135 MOCK_METHOD0(ClearAccessToken, void());
136 MOCK_METHOD0(ClearRefreshToken, void());
138 void set_file_data(std::string* file_data) {
139 file_data_.reset(file_data);
142 private:
143 // Helper stub methods for functions which take callbacks, so that
144 // the callbacks get called with testable results.
146 // Will call |callback| with HTTP_SUCCESS and a StringValue with the current
147 // value of |account_metadata_|.
148 void GetAccountMetadataStub(const GetAccountMetadataCallback& callback);
150 // Will call |callback| with HTTP_SUCCESS.
151 void DeleteResourceStub(const std::string& resource_id,
152 const std::string& etag,
153 const EntryActionCallback& callback);
155 // Will call |callback| with HTTP_SUCCESS and the current value of
156 // |document_data_|.
157 void CopyHostedDocumentStub(const std::string& resource_id,
158 const std::string& new_name,
159 const GetResourceEntryCallback& callback);
161 // Will call |callback| with HTTP_SUCCESS.
162 void RenameResourceStub(const std::string& resource_id,
163 const std::string& new_name,
164 const EntryActionCallback& callback);
166 // Will call |callback| with HTTP_SUCCESS.
167 void AddResourceToDirectoryStub(
168 const std::string& parent_resource_id,
169 const std::string& resource_id,
170 const EntryActionCallback& callback);
172 // Will call |callback| with HTTP_SUCCESS.
173 void RemoveResourceFromDirectoryStub(
174 const std::string& parent_resource_id,
175 const std::string& resource_id,
176 const EntryActionCallback& callback);
178 // Will call |callback| with HTTP_SUCCESS and the current value of
179 // |directory_data_|.
180 void CreateDirectoryStub(const std::string& parent_resource_id,
181 const std::string& directory_name,
182 const GetResourceEntryCallback& callback);
184 // Will call |callback| with HTTP_SUCCESS, the given URL, and the host+path
185 // portion of the URL as the temporary file path. If |file_data_| is not null,
186 // |file_data_| is written to the temporary file.
187 void DownloadFileStub(
188 const base::FilePath& virtual_path,
189 const base::FilePath& local_tmp_path,
190 const GURL& download_url,
191 const DownloadActionCallback& download_action_callback,
192 const GetContentCallback& get_content_callback,
193 const ProgressCallback& progress_callback);
195 // Account meta data to be returned from GetAccountMetadata.
196 scoped_ptr<base::Value> account_metadata_data_;
198 // JSON data to be returned from CreateDirectory.
199 scoped_ptr<base::Value> directory_data_;
201 // JSON data to be returned from CopyHostedDocument.
202 scoped_ptr<base::Value> document_data_;
204 // File data to be written to the local temporary file when
205 // DownloadFileStub is called.
206 scoped_ptr<std::string> file_data_;
209 } // namespace google_apis
211 #endif // CHROME_BROWSER_GOOGLE_APIS_MOCK_DRIVE_SERVICE_H_