OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/scoped_temp_dir.h" | 15 #include "base/scoped_temp_dir.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
20 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 20 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
21 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | 21 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
22 #include "chrome/browser/chromeos/gdata/drive_file_system.h" | 22 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
23 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 23 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
24 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
25 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" |
26 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
27 #include "chrome/browser/chromeos/gdata/mock_directory_change_observer.h" | 27 #include "chrome/browser/chromeos/gdata/mock_directory_change_observer.h" |
28 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" | 28 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" |
29 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" | 29 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" |
30 #include "chrome/browser/chromeos/gdata/mock_drive_web_apps_registry.h" | |
31 #include "chrome/browser/chromeos/gdata/mock_free_disk_space_getter.h" | |
30 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
32 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/test/test_browser_thread.h" | 35 #include "content/public/test/test_browser_thread.h" |
34 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
36 | 38 |
37 using ::testing::AtLeast; | 39 using ::testing::AtLeast; |
38 using ::testing::Eq; | 40 using ::testing::Eq; |
39 using ::testing::NotNull; | 41 using ::testing::NotNull; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 } | 100 } |
99 | 101 |
100 // Action used to set mock expectations for | 102 // Action used to set mock expectations for |
101 // DriveFileSystem::CopyDocument(). | 103 // DriveFileSystem::CopyDocument(). |
102 ACTION_P2(MockCopyDocument, status, value) { | 104 ACTION_P2(MockCopyDocument, status, value) { |
103 base::MessageLoopProxy::current()->PostTask( | 105 base::MessageLoopProxy::current()->PostTask( |
104 FROM_HERE, | 106 FROM_HERE, |
105 base::Bind(arg2, status, base::Passed(value))); | 107 base::Bind(arg2, status, base::Passed(value))); |
106 } | 108 } |
107 | 109 |
108 // Returns the absolute path for a test file stored under | |
109 // chrome/test/data/chromeos/gdata. | |
110 FilePath GetTestFilePath(const FilePath::StringType& base_name) { | |
111 FilePath path; | |
112 std::string error; | |
113 PathService::Get(chrome::DIR_TEST_DATA, &path); | |
114 path = path.AppendASCII("chromeos") | |
115 .AppendASCII("gdata") | |
116 .AppendASCII(base_name.c_str()); | |
117 EXPECT_TRUE(file_util::PathExists(path)) << | |
118 "Couldn't find " << path.value(); | |
119 return path; | |
120 } | |
121 | |
122 // Loads a test JSON file as a base::Value. | |
123 base::Value* LoadJSONFile(const std::string& base_name) { | |
124 FilePath path = GetTestFilePath(base_name); | |
125 | |
126 std::string error; | |
127 JSONFileValueSerializer serializer(path); | |
128 base::Value* value = serializer.Deserialize(NULL, &error); | |
129 EXPECT_TRUE(value) << | |
130 "Parse error " << path.value() << ": " << error; | |
131 return value; | |
132 } | |
133 | |
134 // Counts the number of files (not directories) in |entries|. | 110 // Counts the number of files (not directories) in |entries|. |
135 int CountFiles(const DriveEntryProtoVector& entries) { | 111 int CountFiles(const DriveEntryProtoVector& entries) { |
136 int num_files = 0; | 112 int num_files = 0; |
137 for (size_t i = 0; i < entries.size(); ++i) { | 113 for (size_t i = 0; i < entries.size(); ++i) { |
138 if (!entries[i].file_info().is_directory()) | 114 if (!entries[i].file_info().is_directory()) |
139 ++num_files; | 115 ++num_files; |
140 } | 116 } |
141 return num_files; | 117 return num_files; |
142 } | 118 } |
143 | 119 |
144 } // namespace | 120 } // namespace |
145 | 121 |
146 class MockFreeDiskSpaceGetter : public FreeDiskSpaceGetterInterface { | |
147 public: | |
148 virtual ~MockFreeDiskSpaceGetter() {} | |
149 MOCK_CONST_METHOD0(AmountOfFreeDiskSpace, int64()); | |
150 }; | |
151 | |
152 class MockGDataUploader : public GDataUploaderInterface { | 122 class MockGDataUploader : public GDataUploaderInterface { |
153 public: | 123 public: |
154 virtual ~MockGDataUploader() {} | 124 virtual ~MockGDataUploader() {} |
155 // This function is not mockable by gmock. | 125 // This function is not mockable by gmock. |
156 virtual int UploadNewFile( | 126 virtual int UploadNewFile( |
157 scoped_ptr<UploadFileInfo> upload_file_info) OVERRIDE { | 127 scoped_ptr<UploadFileInfo> upload_file_info) OVERRIDE { |
158 // Set a document entry for an uploaded file. | 128 // Set a document entry for an uploaded file. |
159 // Used for TransferFileFromLocalToRemote_RegularFile test. | 129 // Used for TransferFileFromLocalToRemote_RegularFile test. |
160 scoped_ptr<base::Value> value(LoadJSONFile("uploaded_file.json")); | 130 scoped_ptr<base::Value> value( |
131 test_util::LoadJSONFile("uploaded_file.json")); | |
161 scoped_ptr<DocumentEntry> document_entry( | 132 scoped_ptr<DocumentEntry> document_entry( |
162 DocumentEntry::ExtractAndParse(*value)); | 133 DocumentEntry::ExtractAndParse(*value)); |
163 upload_file_info->entry = document_entry.Pass(); | 134 upload_file_info->entry = document_entry.Pass(); |
164 | 135 |
165 // Run the completion callback. | 136 // Run the completion callback. |
166 const UploadFileInfo::UploadCompletionCallback callback = | 137 const UploadFileInfo::UploadCompletionCallback callback = |
167 upload_file_info->completion_callback; | 138 upload_file_info->completion_callback; |
168 if (!callback.is_null()) | 139 if (!callback.is_null()) |
169 callback.Run(DRIVE_FILE_OK, upload_file_info.Pass()); | 140 callback.Run(DRIVE_FILE_OK, upload_file_info.Pass()); |
170 | 141 |
(...skipping 11 matching lines...) Expand all Loading... | |
182 const FilePath& local_file_path, | 153 const FilePath& local_file_path, |
183 int64 file_size, | 154 int64 file_size, |
184 const std::string& content_type, | 155 const std::string& content_type, |
185 const UploadFileInfo::UploadCompletionCallback& callback)); | 156 const UploadFileInfo::UploadCompletionCallback& callback)); |
186 | 157 |
187 MOCK_METHOD2(UpdateUpload, void(int upload_id, | 158 MOCK_METHOD2(UpdateUpload, void(int upload_id, |
188 content::DownloadItem* download)); | 159 content::DownloadItem* download)); |
189 MOCK_CONST_METHOD1(GetUploadedBytes, int64(int upload_id)); | 160 MOCK_CONST_METHOD1(GetUploadedBytes, int64(int upload_id)); |
190 }; | 161 }; |
191 | 162 |
192 class MockDriveWebAppsRegistry : public DriveWebAppsRegistryInterface { | |
193 public: | |
194 virtual ~MockDriveWebAppsRegistry() {} | |
195 | |
196 MOCK_METHOD3(GetWebAppsForFile, void(const FilePath& file, | |
197 const std::string& mime_type, | |
198 ScopedVector<DriveWebAppInfo>* apps)); | |
199 MOCK_METHOD1(GetExtensionsForWebStoreApp, | |
200 std::set<std::string>(const std::string& web_store_id)); | |
201 MOCK_METHOD1(UpdateFromFeed, void(const AccountMetadataFeed& metadata)); | |
202 MOCK_METHOD1(UpdateFromApplicationList, void(const AppList& applist)); | |
203 }; | |
204 | |
205 class DriveFileSystemTest : public testing::Test { | 163 class DriveFileSystemTest : public testing::Test { |
206 protected: | 164 protected: |
207 DriveFileSystemTest() | 165 DriveFileSystemTest() |
208 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 166 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
209 io_thread_(content::BrowserThread::IO), | 167 io_thread_(content::BrowserThread::IO), |
210 cache_(NULL), | 168 cache_(NULL), |
211 file_system_(NULL), | 169 file_system_(NULL), |
212 mock_drive_service_(NULL), | 170 mock_drive_service_(NULL), |
213 mock_webapps_registry_(NULL), | 171 mock_webapps_registry_(NULL), |
214 num_callback_invocations_(0), | 172 num_callback_invocations_(0), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 chromeos::CrosLibrary::Shutdown(); | 242 chromeos::CrosLibrary::Shutdown(); |
285 } | 243 } |
286 | 244 |
287 // Loads test json file as root ("/drive") element. | 245 // Loads test json file as root ("/drive") element. |
288 void LoadRootFeedDocument(const std::string& filename) { | 246 void LoadRootFeedDocument(const std::string& filename) { |
289 LoadChangeFeed(filename, 0); | 247 LoadChangeFeed(filename, 0); |
290 } | 248 } |
291 | 249 |
292 void LoadChangeFeed(const std::string& filename, | 250 void LoadChangeFeed(const std::string& filename, |
293 int largest_changestamp) { | 251 int largest_changestamp) { |
294 std::string error; | 252 test_util::LoadChangeFeed(filename, |
295 scoped_ptr<Value> document(LoadJSONFile(filename)); | 253 file_system_, |
296 ASSERT_TRUE(document.get()); | 254 largest_changestamp, |
297 ASSERT_TRUE(document->GetType() == Value::TYPE_DICTIONARY); | 255 root_feed_changestamp_++); |
satorux1
2012/08/30 04:38:15
looks tricky. please increment outside the functio
yoshiki
2012/08/30 15:23:45
Done. https://chromiumcodereview.appspot.com/10905
| |
298 scoped_ptr<DocumentFeed> document_feed( | |
299 DocumentFeed::ExtractAndParse(*document)); | |
300 ASSERT_TRUE(document_feed.get()); | |
301 std::vector<DocumentFeed*> feed_list; | |
302 feed_list.push_back(document_feed.get()); | |
303 ASSERT_TRUE(UpdateContent(feed_list, largest_changestamp)); | |
304 } | 256 } |
305 | 257 |
306 void AddDirectoryFromFile(const FilePath& directory_path, | 258 void AddDirectoryFromFile(const FilePath& directory_path, |
307 const std::string& filename) { | 259 const std::string& filename) { |
308 scoped_ptr<Value> atom(LoadJSONFile(filename)); | 260 scoped_ptr<Value> atom(test_util::LoadJSONFile(filename)); |
309 ASSERT_TRUE(atom.get()); | 261 ASSERT_TRUE(atom.get()); |
310 ASSERT_TRUE(atom->GetType() == Value::TYPE_DICTIONARY); | 262 ASSERT_TRUE(atom->GetType() == Value::TYPE_DICTIONARY); |
311 | 263 |
312 DictionaryValue* dict_value = NULL; | 264 DictionaryValue* dict_value = NULL; |
313 Value* entry_value = NULL; | 265 Value* entry_value = NULL; |
314 ASSERT_TRUE(atom->GetAsDictionary(&dict_value)); | 266 ASSERT_TRUE(atom->GetAsDictionary(&dict_value)); |
315 ASSERT_TRUE(dict_value->Get("entry", &entry_value)); | 267 ASSERT_TRUE(dict_value->Get("entry", &entry_value)); |
316 | 268 |
317 DictionaryValue* entry_dict = NULL; | 269 DictionaryValue* entry_dict = NULL; |
318 ASSERT_TRUE(entry_value->GetAsDictionary(&entry_dict)); | 270 ASSERT_TRUE(entry_value->GetAsDictionary(&entry_dict)); |
319 | 271 |
320 // Tweak entry title to match the last segment of the directory path | 272 // Tweak entry title to match the last segment of the directory path |
321 // (new directory name). | 273 // (new directory name). |
322 std::vector<FilePath::StringType> dir_parts; | 274 std::vector<FilePath::StringType> dir_parts; |
323 directory_path.GetComponents(&dir_parts); | 275 directory_path.GetComponents(&dir_parts); |
324 entry_dict->SetString("title.$t", dir_parts[dir_parts.size() - 1]); | 276 entry_dict->SetString("title.$t", dir_parts[dir_parts.size() - 1]); |
325 | 277 |
326 DriveFileError error; | 278 DriveFileError error; |
327 DriveFileSystem::CreateDirectoryParams params(directory_path, | 279 DriveFileSystem::CreateDirectoryParams params(directory_path, |
328 directory_path, | 280 directory_path, |
329 false, // is_exclusive | 281 false, // is_exclusive |
330 false, // is_recursive | 282 false, // is_recursive |
331 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error)); | 283 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error)); |
332 file_system_->AddNewDirectory(params, HTTP_SUCCESS, atom.Pass()); | 284 file_system_->AddNewDirectory(params, HTTP_SUCCESS, atom.Pass()); |
333 test_util::RunBlockingPoolTask(); | 285 test_util::RunBlockingPoolTask(); |
334 EXPECT_EQ(DRIVE_FILE_OK, error); | 286 EXPECT_EQ(DRIVE_FILE_OK, error); |
335 } | 287 } |
336 | 288 |
337 // Updates the content of directory under |directory_path| with parsed feed | |
338 // |value|. | |
339 bool UpdateContent(const std::vector<DocumentFeed*>& list, | |
340 int largest_changestamp) { | |
341 GURL unused; | |
342 return file_system_->UpdateFromFeedForTesting( | |
343 list, | |
344 largest_changestamp, | |
345 root_feed_changestamp_++) == DRIVE_FILE_OK; | |
346 } | |
347 | |
348 bool RemoveEntry(const FilePath& file_path) { | 289 bool RemoveEntry(const FilePath& file_path) { |
349 file_system_->GetEntryInfoByPath( | 290 file_system_->GetEntryInfoByPath( |
350 file_path, | 291 file_path, |
351 base::Bind(&CallbackHelper::GetEntryInfoCallback, | 292 base::Bind(&CallbackHelper::GetEntryInfoCallback, |
352 callback_helper_.get())); | 293 callback_helper_.get())); |
353 test_util::RunBlockingPoolTask(); | 294 test_util::RunBlockingPoolTask(); |
354 | 295 |
355 if (callback_helper_->last_error_ != DRIVE_FILE_OK) | 296 if (callback_helper_->last_error_ != DRIVE_FILE_OK) |
356 return false; | 297 return false; |
357 | 298 |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 EXPECT_TRUE(EntryExists( | 1185 EXPECT_TRUE(EntryExists( |
1245 FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3")))); | 1186 FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3")))); |
1246 } | 1187 } |
1247 | 1188 |
1248 TEST_F(DriveFileSystemTest, CachedFeadLoadingThenServerFeedLoading) { | 1189 TEST_F(DriveFileSystemTest, CachedFeadLoadingThenServerFeedLoading) { |
1249 SaveTestFileSystem(); | 1190 SaveTestFileSystem(); |
1250 | 1191 |
1251 // SaveTestFileSystem and "account_metadata.json" have the same changestamp, | 1192 // SaveTestFileSystem and "account_metadata.json" have the same changestamp, |
1252 // so no request for new feeds (i.e., call to GetDocuments) should happen. | 1193 // so no request for new feeds (i.e., call to GetDocuments) should happen. |
1253 mock_drive_service_->set_account_metadata( | 1194 mock_drive_service_->set_account_metadata( |
1254 LoadJSONFile("account_metadata.json")); | 1195 test_util::LoadJSONFile("account_metadata.json")); |
1255 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); | 1196 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); |
1256 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); | 1197 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); |
1257 EXPECT_CALL(*mock_drive_service_, GetDocuments(_, _, _, _, _)).Times(0); | 1198 EXPECT_CALL(*mock_drive_service_, GetDocuments(_, _, _, _, _)).Times(0); |
1258 | 1199 |
1259 // Kicks loading of cached file system and query for server update. | 1200 // Kicks loading of cached file system and query for server update. |
1260 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); | 1201 EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1")))); |
1261 | 1202 |
1262 // Since the file system has verified that it holds the latest snapshot, | 1203 // Since the file system has verified that it holds the latest snapshot, |
1263 // it should change its state to FROM_SERVER, which admits periodic refresh. | 1204 // it should change its state to FROM_SERVER, which admits periodic refresh. |
1264 // To test it, call CheckForUpdates and verify it does try to check updates. | 1205 // To test it, call CheckForUpdates and verify it does try to check updates. |
1265 mock_drive_service_->set_account_metadata( | 1206 mock_drive_service_->set_account_metadata( |
1266 LoadJSONFile("account_metadata.json")); | 1207 test_util::LoadJSONFile("account_metadata.json")); |
1267 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); | 1208 EXPECT_CALL(*mock_drive_service_, GetAccountMetadata(_)).Times(1); |
1268 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); | 1209 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(_)).Times(1); |
1269 | 1210 |
1270 file_system_->CheckForUpdates(); | 1211 file_system_->CheckForUpdates(); |
1271 test_util::RunBlockingPoolTask(); | 1212 test_util::RunBlockingPoolTask(); |
1272 } | 1213 } |
1273 | 1214 |
1274 TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { | 1215 TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { |
1275 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 1216 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
1276 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); | 1217 .Times(AtLeast(1)).WillRepeatedly(Return(kLotsOfSpace)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1327 const FilePath remote_dest_file_path( | 1268 const FilePath remote_dest_file_path( |
1328 FILE_PATH_LITERAL("drive/Directory 1/Document 1.gdoc")); | 1269 FILE_PATH_LITERAL("drive/Directory 1/Document 1.gdoc")); |
1329 EXPECT_FALSE(EntryExists(remote_dest_file_path)); | 1270 EXPECT_FALSE(EntryExists(remote_dest_file_path)); |
1330 | 1271 |
1331 // We'll add a file to "Directory 1" directory on Drive. | 1272 // We'll add a file to "Directory 1" directory on Drive. |
1332 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( | 1273 EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
1333 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); | 1274 Eq(FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
1334 | 1275 |
1335 // We'll copy a hosted document using CopyDocument. | 1276 // We'll copy a hosted document using CopyDocument. |
1336 // ".gdoc" suffix should be stripped when copying. | 1277 // ".gdoc" suffix should be stripped when copying. |
1337 scoped_ptr<base::Value> document(LoadJSONFile("uploaded_document.json")); | 1278 scoped_ptr<base::Value> document( |
1279 test_util::LoadJSONFile("uploaded_document.json")); | |
1338 EXPECT_CALL(*mock_drive_service_, | 1280 EXPECT_CALL(*mock_drive_service_, |
1339 CopyDocument(kResourceId, | 1281 CopyDocument(kResourceId, |
1340 FILE_PATH_LITERAL("Document 1"), | 1282 FILE_PATH_LITERAL("Document 1"), |
1341 _)) | 1283 _)) |
1342 .WillOnce(MockCopyDocument(gdata::HTTP_SUCCESS, &document)); | 1284 .WillOnce(MockCopyDocument(gdata::HTTP_SUCCESS, &document)); |
1343 // We'll then add the hosted document to the destination directory. | 1285 // We'll then add the hosted document to the destination directory. |
1344 EXPECT_CALL(*mock_drive_service_, | 1286 EXPECT_CALL(*mock_drive_service_, |
1345 AddResourceToDirectory(_, _, _)).Times(1); | 1287 AddResourceToDirectory(_, _, _)).Times(1); |
1346 | 1288 |
1347 FileOperationCallback callback = | 1289 FileOperationCallback callback = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1380 | 1322 |
1381 // Pretend we have enough space. | 1323 // Pretend we have enough space. |
1382 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 1324 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
1383 .Times(2).WillRepeatedly(Return(file_size + kMinFreeSpace)); | 1325 .Times(2).WillRepeatedly(Return(file_size + kMinFreeSpace)); |
1384 | 1326 |
1385 const std::string remote_src_file_data = "Test file data"; | 1327 const std::string remote_src_file_data = "Test file data"; |
1386 mock_drive_service_->set_file_data(new std::string(remote_src_file_data)); | 1328 mock_drive_service_->set_file_data(new std::string(remote_src_file_data)); |
1387 | 1329 |
1388 // Before Download starts metadata from server will be fetched. | 1330 // Before Download starts metadata from server will be fetched. |
1389 // We will read content url from the result. | 1331 // We will read content url from the result. |
1390 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); | 1332 scoped_ptr<base::Value> document( |
1333 test_util::LoadJSONFile("document_to_download.json")); | |
1391 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); | 1334 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); |
1392 | 1335 |
1393 // The file is obtained with the mock DriveService. | 1336 // The file is obtained with the mock DriveService. |
1394 EXPECT_CALL(*mock_drive_service_, | 1337 EXPECT_CALL(*mock_drive_service_, |
1395 DownloadFile(remote_src_file_path, | 1338 DownloadFile(remote_src_file_path, |
1396 cache_file, | 1339 cache_file, |
1397 GURL("https://file_content_url_changed/"), | 1340 GURL("https://file_content_url_changed/"), |
1398 _, _)) | 1341 _, _)) |
1399 .Times(1); | 1342 .Times(1); |
1400 | 1343 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1994 entry_proto->resource_id(), | 1937 entry_proto->resource_id(), |
1995 entry_proto->file_specific_info().file_md5()); | 1938 entry_proto->file_specific_info().file_md5()); |
1996 const int64 file_size = entry_proto->file_info().size(); | 1939 const int64 file_size = entry_proto->file_info().size(); |
1997 | 1940 |
1998 // Pretend we have enough space. | 1941 // Pretend we have enough space. |
1999 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 1942 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
2000 .Times(2).WillRepeatedly(Return(file_size + kMinFreeSpace)); | 1943 .Times(2).WillRepeatedly(Return(file_size + kMinFreeSpace)); |
2001 | 1944 |
2002 // Before Download starts metadata from server will be fetched. | 1945 // Before Download starts metadata from server will be fetched. |
2003 // We will read content url from the result. | 1946 // We will read content url from the result. |
2004 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); | 1947 scoped_ptr<base::Value> document( |
1948 test_util::LoadJSONFile("document_to_download.json")); | |
2005 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); | 1949 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); |
2006 | 1950 |
2007 // The file is obtained with the mock DriveService. | 1951 // The file is obtained with the mock DriveService. |
2008 EXPECT_CALL(*mock_drive_service_, | 1952 EXPECT_CALL(*mock_drive_service_, |
2009 DownloadFile(file_in_root, | 1953 DownloadFile(file_in_root, |
2010 downloaded_file, | 1954 downloaded_file, |
2011 GURL("https://file_content_url_changed/"), | 1955 GURL("https://file_content_url_changed/"), |
2012 _, _)) | 1956 _, _)) |
2013 .Times(1); | 1957 .Times(1); |
2014 | 1958 |
(...skipping 19 matching lines...) Expand all Loading... | |
2034 FilePath downloaded_file = GetCachePathForFile( | 1978 FilePath downloaded_file = GetCachePathForFile( |
2035 entry_proto->resource_id(), | 1979 entry_proto->resource_id(), |
2036 entry_proto->file_specific_info().file_md5()); | 1980 entry_proto->file_specific_info().file_md5()); |
2037 | 1981 |
2038 // Pretend we have no space at all. | 1982 // Pretend we have no space at all. |
2039 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 1983 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
2040 .Times(2).WillRepeatedly(Return(0)); | 1984 .Times(2).WillRepeatedly(Return(0)); |
2041 | 1985 |
2042 // Before Download starts metadata from server will be fetched. | 1986 // Before Download starts metadata from server will be fetched. |
2043 // We will read content url from the result. | 1987 // We will read content url from the result. |
2044 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); | 1988 scoped_ptr<base::Value> document( |
1989 test_util::LoadJSONFile("document_to_download.json")); | |
2045 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); | 1990 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); |
2046 | 1991 |
2047 // The file is not obtained with the mock DriveService, because of no space. | 1992 // The file is not obtained with the mock DriveService, because of no space. |
2048 EXPECT_CALL(*mock_drive_service_, | 1993 EXPECT_CALL(*mock_drive_service_, |
2049 DownloadFile(file_in_root, | 1994 DownloadFile(file_in_root, |
2050 downloaded_file, | 1995 downloaded_file, |
2051 GURL("https://file_content_url_changed/"), | 1996 GURL("https://file_content_url_changed/"), |
2052 _, _)) | 1997 _, _)) |
2053 .Times(0); | 1998 .Times(0); |
2054 | 1999 |
(...skipping 24 matching lines...) Expand all Loading... | |
2079 // the disk space was freed up by removing temporary files. | 2024 // the disk space was freed up by removing temporary files. |
2080 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 2025 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
2081 .WillOnce(Return(file_size + kMinFreeSpace)) | 2026 .WillOnce(Return(file_size + kMinFreeSpace)) |
2082 .WillOnce(Return(0)) | 2027 .WillOnce(Return(0)) |
2083 .WillOnce(Return(file_size + kMinFreeSpace)) | 2028 .WillOnce(Return(file_size + kMinFreeSpace)) |
2084 .WillOnce(Return(file_size + kMinFreeSpace)); | 2029 .WillOnce(Return(file_size + kMinFreeSpace)); |
2085 | 2030 |
2086 // Store something in the temporary cache directory. | 2031 // Store something in the temporary cache directory. |
2087 TestStoreToCache("<resource_id>", | 2032 TestStoreToCache("<resource_id>", |
2088 "<md5>", | 2033 "<md5>", |
2089 GetTestFilePath("root_feed.json"), | 2034 test_util::GetTestFilePath("root_feed.json"), |
2090 DRIVE_FILE_OK, | 2035 DRIVE_FILE_OK, |
2091 test_util::TEST_CACHE_STATE_PRESENT, | 2036 test_util::TEST_CACHE_STATE_PRESENT, |
2092 DriveCache::CACHE_TYPE_TMP); | 2037 DriveCache::CACHE_TYPE_TMP); |
2093 ASSERT_TRUE(CacheEntryExists("<resource_id>", "<md5>")); | 2038 ASSERT_TRUE(CacheEntryExists("<resource_id>", "<md5>")); |
2094 ASSERT_TRUE(CacheFileExists("<resource_id>", "<md5>")); | 2039 ASSERT_TRUE(CacheFileExists("<resource_id>", "<md5>")); |
2095 | 2040 |
2096 // Before Download starts metadata from server will be fetched. | 2041 // Before Download starts metadata from server will be fetched. |
2097 // We will read content url from the result. | 2042 // We will read content url from the result. |
2098 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); | 2043 scoped_ptr<base::Value> document( |
2044 test_util::LoadJSONFile("document_to_download.json")); | |
2099 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); | 2045 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); |
2100 | 2046 |
2101 // The file is obtained with the mock DriveService, because of we freed up the | 2047 // The file is obtained with the mock DriveService, because of we freed up the |
2102 // space. | 2048 // space. |
2103 EXPECT_CALL(*mock_drive_service_, | 2049 EXPECT_CALL(*mock_drive_service_, |
2104 DownloadFile(file_in_root, | 2050 DownloadFile(file_in_root, |
2105 downloaded_file, | 2051 downloaded_file, |
2106 GURL("https://file_content_url_changed/"), | 2052 GURL("https://file_content_url_changed/"), |
2107 _, _)) | 2053 _, _)) |
2108 .Times(1); | 2054 .Times(1); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2140 // but then start reporting we have not enough space. This is to emulate that | 2086 // but then start reporting we have not enough space. This is to emulate that |
2141 // the disk space becomes full after the file is downloaded for some reason | 2087 // the disk space becomes full after the file is downloaded for some reason |
2142 // (ex. the actual file was larger than the expected size). | 2088 // (ex. the actual file was larger than the expected size). |
2143 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 2089 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
2144 .WillOnce(Return(file_size + kMinFreeSpace)) | 2090 .WillOnce(Return(file_size + kMinFreeSpace)) |
2145 .WillOnce(Return(kMinFreeSpace - 1)) | 2091 .WillOnce(Return(kMinFreeSpace - 1)) |
2146 .WillOnce(Return(kMinFreeSpace - 1)); | 2092 .WillOnce(Return(kMinFreeSpace - 1)); |
2147 | 2093 |
2148 // Before Download starts metadata from server will be fetched. | 2094 // Before Download starts metadata from server will be fetched. |
2149 // We will read content url from the result. | 2095 // We will read content url from the result. |
2150 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); | 2096 scoped_ptr<base::Value> document( |
2097 test_util::LoadJSONFile("document_to_download.json")); | |
2151 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); | 2098 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); |
2152 | 2099 |
2153 // The file is obtained with the mock DriveService. | 2100 // The file is obtained with the mock DriveService. |
2154 EXPECT_CALL(*mock_drive_service_, | 2101 EXPECT_CALL(*mock_drive_service_, |
2155 DownloadFile(file_in_root, | 2102 DownloadFile(file_in_root, |
2156 downloaded_file, | 2103 downloaded_file, |
2157 GURL("https://file_content_url_changed/"), | 2104 GURL("https://file_content_url_changed/"), |
2158 _, _)) | 2105 _, _)) |
2159 .Times(1); | 2106 .Times(1); |
2160 | 2107 |
(...skipping 17 matching lines...) Expand all Loading... | |
2178 | 2125 |
2179 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2126 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
2180 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 2127 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
2181 FilePath downloaded_file = GetCachePathForFile( | 2128 FilePath downloaded_file = GetCachePathForFile( |
2182 entry_proto->resource_id(), | 2129 entry_proto->resource_id(), |
2183 entry_proto->file_specific_info().file_md5()); | 2130 entry_proto->file_specific_info().file_md5()); |
2184 | 2131 |
2185 // Store something as cached version of this file. | 2132 // Store something as cached version of this file. |
2186 TestStoreToCache(entry_proto->resource_id(), | 2133 TestStoreToCache(entry_proto->resource_id(), |
2187 entry_proto->file_specific_info().file_md5(), | 2134 entry_proto->file_specific_info().file_md5(), |
2188 GetTestFilePath("root_feed.json"), | 2135 test_util::GetTestFilePath("root_feed.json"), |
2189 DRIVE_FILE_OK, | 2136 DRIVE_FILE_OK, |
2190 test_util::TEST_CACHE_STATE_PRESENT, | 2137 test_util::TEST_CACHE_STATE_PRESENT, |
2191 DriveCache::CACHE_TYPE_TMP); | 2138 DriveCache::CACHE_TYPE_TMP); |
2192 | 2139 |
2193 // Make sure we don't fetch metadata for downloading file. | 2140 // Make sure we don't fetch metadata for downloading file. |
2194 EXPECT_CALL(*mock_drive_service_, GetDocumentEntry(_, _)).Times(0); | 2141 EXPECT_CALL(*mock_drive_service_, GetDocumentEntry(_, _)).Times(0); |
2195 | 2142 |
2196 // Make sure we don't call downloads at all. | 2143 // Make sure we don't call downloads at all. |
2197 EXPECT_CALL(*mock_drive_service_, | 2144 EXPECT_CALL(*mock_drive_service_, |
2198 DownloadFile(file_in_root, | 2145 DownloadFile(file_in_root, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2245 callback_helper_.get()); | 2192 callback_helper_.get()); |
2246 | 2193 |
2247 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2194 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
2248 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 2195 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
2249 FilePath downloaded_file = GetCachePathForFile( | 2196 FilePath downloaded_file = GetCachePathForFile( |
2250 entry_proto->resource_id(), | 2197 entry_proto->resource_id(), |
2251 entry_proto->file_specific_info().file_md5()); | 2198 entry_proto->file_specific_info().file_md5()); |
2252 | 2199 |
2253 // Before Download starts metadata from server will be fetched. | 2200 // Before Download starts metadata from server will be fetched. |
2254 // We will read content url from the result. | 2201 // We will read content url from the result. |
2255 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); | 2202 scoped_ptr<base::Value> document( |
2203 test_util::LoadJSONFile("document_to_download.json")); | |
2256 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); | 2204 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); |
2257 | 2205 |
2258 // The file is obtained with the mock DriveService, because it's not stored in | 2206 // The file is obtained with the mock DriveService, because it's not stored in |
2259 // the cache. | 2207 // the cache. |
2260 EXPECT_CALL(*mock_drive_service_, | 2208 EXPECT_CALL(*mock_drive_service_, |
2261 DownloadFile(file_in_root, | 2209 DownloadFile(file_in_root, |
2262 downloaded_file, | 2210 downloaded_file, |
2263 GURL("https://file_content_url_changed/"), | 2211 GURL("https://file_content_url_changed/"), |
2264 _, _)) | 2212 _, _)) |
2265 .Times(1); | 2213 .Times(1); |
(...skipping 20 matching lines...) Expand all Loading... | |
2286 | 2234 |
2287 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); | 2235 FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
2288 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); | 2236 scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
2289 FilePath downloaded_file = GetCachePathForFile( | 2237 FilePath downloaded_file = GetCachePathForFile( |
2290 entry_proto->resource_id(), | 2238 entry_proto->resource_id(), |
2291 entry_proto->file_specific_info().file_md5()); | 2239 entry_proto->file_specific_info().file_md5()); |
2292 | 2240 |
2293 // Store something as cached version of this file. | 2241 // Store something as cached version of this file. |
2294 TestStoreToCache(entry_proto->resource_id(), | 2242 TestStoreToCache(entry_proto->resource_id(), |
2295 entry_proto->file_specific_info().file_md5(), | 2243 entry_proto->file_specific_info().file_md5(), |
2296 GetTestFilePath("root_feed.json"), | 2244 test_util::GetTestFilePath("root_feed.json"), |
2297 DRIVE_FILE_OK, | 2245 DRIVE_FILE_OK, |
2298 test_util::TEST_CACHE_STATE_PRESENT, | 2246 test_util::TEST_CACHE_STATE_PRESENT, |
2299 DriveCache::CACHE_TYPE_TMP); | 2247 DriveCache::CACHE_TYPE_TMP); |
2300 | 2248 |
2301 // The file is obtained from the cache. | 2249 // The file is obtained from the cache. |
2302 // Make sure we don't call downloads at all. | 2250 // Make sure we don't call downloads at all. |
2303 EXPECT_CALL(*mock_drive_service_, DownloadFile(_, _, _, _, _)) | 2251 EXPECT_CALL(*mock_drive_service_, DownloadFile(_, _, _, _, _)) |
2304 .Times(0); | 2252 .Times(0); |
2305 | 2253 |
2306 file_system_->GetFileByResourceId(entry_proto->resource_id(), | 2254 file_system_->GetFileByResourceId(entry_proto->resource_id(), |
(...skipping 26 matching lines...) Expand all Loading... | |
2333 DriveCache::CACHE_TYPE_TMP); | 2281 DriveCache::CACHE_TYPE_TMP); |
2334 | 2282 |
2335 // First store a file to cache. A cache file will be created at: | 2283 // First store a file to cache. A cache file will be created at: |
2336 // GCache/v1/persistent/<kResourceId>.<kMd5> | 2284 // GCache/v1/persistent/<kResourceId>.<kMd5> |
2337 const FilePath original_cache_file_path = | 2285 const FilePath original_cache_file_path = |
2338 DriveCache::GetCacheRootPath(profile_.get()) | 2286 DriveCache::GetCacheRootPath(profile_.get()) |
2339 .AppendASCII("persistent") | 2287 .AppendASCII("persistent") |
2340 .AppendASCII(kResourceId + "." + kMd5); | 2288 .AppendASCII(kResourceId + "." + kMd5); |
2341 TestStoreToCache(kResourceId, | 2289 TestStoreToCache(kResourceId, |
2342 kMd5, | 2290 kMd5, |
2343 GetTestFilePath("root_feed.json"), // Anything works. | 2291 // Anything works. |
2292 test_util::GetTestFilePath("root_feed.json"), | |
2344 DRIVE_FILE_OK, | 2293 DRIVE_FILE_OK, |
2345 test_util::TEST_CACHE_STATE_PRESENT | | 2294 test_util::TEST_CACHE_STATE_PRESENT | |
2346 test_util::TEST_CACHE_STATE_PINNED | | 2295 test_util::TEST_CACHE_STATE_PINNED | |
2347 test_util::TEST_CACHE_STATE_PERSISTENT, | 2296 test_util::TEST_CACHE_STATE_PERSISTENT, |
2348 DriveCache::CACHE_TYPE_PERSISTENT); | 2297 DriveCache::CACHE_TYPE_PERSISTENT); |
2349 ASSERT_TRUE(file_util::PathExists(original_cache_file_path)); | 2298 ASSERT_TRUE(file_util::PathExists(original_cache_file_path)); |
2350 | 2299 |
2351 // Add the dirty bit. The cache file will be renamed to | 2300 // Add the dirty bit. The cache file will be renamed to |
2352 // GCache/v1/persistent/<kResourceId>.local | 2301 // GCache/v1/persistent/<kResourceId>.local |
2353 TestMarkDirty(kResourceId, | 2302 TestMarkDirty(kResourceId, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2387 DriveCache::GetCacheRootPath(profile_.get()) | 2336 DriveCache::GetCacheRootPath(profile_.get()) |
2388 .AppendASCII("outgoing") | 2337 .AppendASCII("outgoing") |
2389 .AppendASCII(kResourceId); | 2338 .AppendASCII(kResourceId); |
2390 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path)); | 2339 ASSERT_TRUE(file_util::PathExists(dirty_cache_file_path)); |
2391 ASSERT_TRUE(file_util::PathExists(outgoing_symlink_path)); | 2340 ASSERT_TRUE(file_util::PathExists(outgoing_symlink_path)); |
2392 | 2341 |
2393 // Create a DocumentEntry, which is needed to mock | 2342 // Create a DocumentEntry, which is needed to mock |
2394 // GDataUploaderInterface::UploadExistingFile(). | 2343 // GDataUploaderInterface::UploadExistingFile(). |
2395 // TODO(satorux): This should be cleaned up. crbug.com/134240. | 2344 // TODO(satorux): This should be cleaned up. crbug.com/134240. |
2396 DocumentEntry* document_entry = NULL; | 2345 DocumentEntry* document_entry = NULL; |
2397 scoped_ptr<base::Value> value(LoadJSONFile("root_feed.json")); | 2346 scoped_ptr<base::Value> value(test_util::LoadJSONFile("root_feed.json")); |
2398 ASSERT_TRUE(value.get()); | 2347 ASSERT_TRUE(value.get()); |
2399 base::DictionaryValue* as_dict = NULL; | 2348 base::DictionaryValue* as_dict = NULL; |
2400 base::ListValue* entry_list = NULL; | 2349 base::ListValue* entry_list = NULL; |
2401 if (value->GetAsDictionary(&as_dict) && | 2350 if (value->GetAsDictionary(&as_dict) && |
2402 as_dict->GetList("feed.entry", &entry_list)) { | 2351 as_dict->GetList("feed.entry", &entry_list)) { |
2403 for (size_t i = 0; i < entry_list->GetSize(); ++i) { | 2352 for (size_t i = 0; i < entry_list->GetSize(); ++i) { |
2404 base::DictionaryValue* entry = NULL; | 2353 base::DictionaryValue* entry = NULL; |
2405 std::string resource_id; | 2354 std::string resource_id; |
2406 if (entry_list->GetDictionary(i, &entry) && | 2355 if (entry_list->GetDictionary(i, &entry) && |
2407 entry->GetString("gd$resourceId.$t", &resource_id) && | 2356 entry->GetString("gd$resourceId.$t", &resource_id) && |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2600 | 2549 |
2601 // Pretend we have enough space. | 2550 // Pretend we have enough space. |
2602 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) | 2551 EXPECT_CALL(*mock_free_disk_space_checker_, AmountOfFreeDiskSpace()) |
2603 .Times(2).WillRepeatedly(Return(file_size + kMinFreeSpace)); | 2552 .Times(2).WillRepeatedly(Return(file_size + kMinFreeSpace)); |
2604 | 2553 |
2605 const std::string kExpectedFileData = "test file data"; | 2554 const std::string kExpectedFileData = "test file data"; |
2606 mock_drive_service_->set_file_data(new std::string(kExpectedFileData)); | 2555 mock_drive_service_->set_file_data(new std::string(kExpectedFileData)); |
2607 | 2556 |
2608 // Before Download starts metadata from server will be fetched. | 2557 // Before Download starts metadata from server will be fetched. |
2609 // We will read content url from the result. | 2558 // We will read content url from the result. |
2610 scoped_ptr<base::Value> document(LoadJSONFile("document_to_download.json")); | 2559 scoped_ptr<base::Value> document( |
2560 test_util::LoadJSONFile("document_to_download.json")); | |
2611 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); | 2561 SetExpectationsForGetDocumentEntry(&document, "file:2_file_resource_id"); |
2612 | 2562 |
2613 // The file is obtained with the mock DriveService. | 2563 // The file is obtained with the mock DriveService. |
2614 EXPECT_CALL(*mock_drive_service_, | 2564 EXPECT_CALL(*mock_drive_service_, |
2615 DownloadFile(kFileInRoot, | 2565 DownloadFile(kFileInRoot, |
2616 downloaded_file, | 2566 downloaded_file, |
2617 GURL("https://file_content_url_changed/"), | 2567 GURL("https://file_content_url_changed/"), |
2618 _, _)) | 2568 _, _)) |
2619 .Times(1); | 2569 .Times(1); |
2620 | 2570 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2658 | 2608 |
2659 // Try to close the same file twice. | 2609 // Try to close the same file twice. |
2660 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2610 file_system_->CloseFile(kFileInRoot, close_file_callback); |
2661 message_loop_.Run(); | 2611 message_loop_.Run(); |
2662 | 2612 |
2663 // It must fail. | 2613 // It must fail. |
2664 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2614 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
2665 } | 2615 } |
2666 | 2616 |
2667 } // namespace gdata | 2617 } // namespace gdata |
OLD | NEW |