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 "chrome/browser/drive/fake_drive_service.h" | 5 #include "chrome/browser/drive/fake_drive_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 | 1282 |
1283 GDataErrorCode error = GDATA_OTHER_ERROR; | 1283 GDataErrorCode error = GDATA_OTHER_ERROR; |
1284 fake_service_.RenameResource(kResourceId, | 1284 fake_service_.RenameResource(kResourceId, |
1285 "new title", | 1285 "new title", |
1286 test_util::CreateCopyResultCallback(&error)); | 1286 test_util::CreateCopyResultCallback(&error)); |
1287 base::RunLoop().RunUntilIdle(); | 1287 base::RunLoop().RunUntilIdle(); |
1288 | 1288 |
1289 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1289 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1290 } | 1290 } |
1291 | 1291 |
1292 TEST_F(FakeDriveServiceTest, TouchResource_ExistingFile) { | |
1293 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | |
1294 "gdata/root_feed.json")); | |
1295 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( | |
1296 "gdata/account_metadata.json")); | |
1297 | |
1298 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | |
1299 | |
1300 const std::string kResourceId = "file:2_file_resource_id"; | |
1301 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | |
1302 const base::Time::Exploded kLastViewedByMeDate = | |
1303 {2013, 7, 0, 19, 15, 59, 13, 123}; | |
1304 | |
1305 GDataErrorCode error = GDATA_OTHER_ERROR; | |
1306 scoped_ptr<ResourceEntry> entry; | |
1307 fake_service_.TouchResource( | |
1308 kResourceId, | |
1309 base::Time::FromUTCExploded(kModifiedDate), | |
1310 base::Time::FromUTCExploded(kLastViewedByMeDate), | |
1311 test_util::CreateCopyResultCallback(&error, &entry)); | |
1312 base::RunLoop().RunUntilIdle(); | |
1313 | |
1314 EXPECT_EQ(HTTP_SUCCESS, error); | |
1315 | |
1316 ASSERT_TRUE(entry); | |
1317 EXPECT_EQ(base::Time::FromUTCExploded(kModifiedDate), | |
1318 entry->updated_time()); | |
1319 EXPECT_EQ(base::Time::FromUTCExploded(kLastViewedByMeDate), | |
1320 entry->last_viewed_time()); | |
1321 | |
1322 // Should be incremented as a file was renamed. | |
1323 EXPECT_EQ(old_largest_change_id + 1, fake_service_.largest_changestamp()); | |
1324 EXPECT_EQ(old_largest_change_id + 1, GetLargestChangeByAboutResource()); | |
1325 } | |
1326 | |
1327 TEST_F(FakeDriveServiceTest, TouchResource_NonexistingFile) { | |
1328 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | |
1329 "gdata/root_feed.json")); | |
1330 | |
1331 const std::string kResourceId = "file:nonexisting_file"; | |
1332 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | |
1333 const base::Time::Exploded kLastViewedByMeDate = | |
1334 {2013, 7, 0, 19, 15, 59, 13, 123}; | |
1335 | |
1336 GDataErrorCode error = GDATA_OTHER_ERROR; | |
1337 scoped_ptr<ResourceEntry> entry; | |
1338 fake_service_.TouchResource( | |
1339 kResourceId, | |
1340 base::Time::FromUTCExploded(kModifiedDate), | |
1341 base::Time::FromUTCExploded(kLastViewedByMeDate), | |
1342 test_util::CreateCopyResultCallback(&error, &entry)); | |
1343 base::RunLoop().RunUntilIdle(); | |
1344 | |
1345 EXPECT_EQ(HTTP_NOT_FOUND, error); | |
1346 } | |
1347 | |
1348 TEST_F(FakeDriveServiceTest, TouchResource_Offline) { | |
1349 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | |
1350 "gdata/root_feed.json")); | |
1351 fake_service_.set_offline(true); | |
1352 | |
1353 const std::string kResourceId = "file:2_file_resource_id"; | |
1354 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | |
1355 const base::Time::Exploded kLastViewedByMeDate = | |
1356 {2013, 7, 0, 19, 15, 59, 13, 123}; | |
1357 | |
1358 GDataErrorCode error = GDATA_OTHER_ERROR; | |
1359 scoped_ptr<ResourceEntry> entry; | |
1360 fake_service_.TouchResource( | |
1361 kResourceId, | |
1362 base::Time::FromUTCExploded(kModifiedDate), | |
1363 base::Time::FromUTCExploded(kLastViewedByMeDate), | |
1364 test_util::CreateCopyResultCallback(&error, &entry)); | |
1365 base::RunLoop().RunUntilIdle(); | |
1366 | |
1367 EXPECT_EQ(GDATA_NO_CONNECTION, error); | |
1368 } | |
1369 | |
1370 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInRootDirectory) { | 1292 TEST_F(FakeDriveServiceTest, AddResourceToDirectory_FileInRootDirectory) { |
1371 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1293 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
1372 "gdata/root_feed.json")); | 1294 "gdata/root_feed.json")); |
1373 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( | 1295 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( |
1374 "gdata/account_metadata.json")); | 1296 "gdata/account_metadata.json")); |
1375 | 1297 |
1376 int64 old_largest_change_id = GetLargestChangeByAboutResource(); | 1298 int64 old_largest_change_id = GetLargestChangeByAboutResource(); |
1377 | 1299 |
1378 const std::string kResourceId = "file:2_file_resource_id"; | 1300 const std::string kResourceId = "file:2_file_resource_id"; |
1379 const std::string kOldParentResourceId = fake_service_.GetRootResourceId(); | 1301 const std::string kOldParentResourceId = fake_service_.GetRootResourceId(); |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 2252 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
2331 base::RunLoop().RunUntilIdle(); | 2253 base::RunLoop().RunUntilIdle(); |
2332 | 2254 |
2333 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 2255 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
2334 EXPECT_FALSE(resource_entry); | 2256 EXPECT_FALSE(resource_entry); |
2335 } | 2257 } |
2336 | 2258 |
2337 } // namespace | 2259 } // namespace |
2338 | 2260 |
2339 } // namespace drive | 2261 } // namespace drive |
OLD | NEW |