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/chromeos/gdata/gdata_sync_client.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_sync_client.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
20 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 20 #include "chrome/browser/chromeos/cros/mock_network_library.h" |
21 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 21 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
22 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 22 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
23 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 23 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
24 #include "chrome/browser/chromeos/gdata/mock_gdata_file_system.h" | 24 #include "chrome/browser/chromeos/gdata/mock_drive_file_system.h" |
25 #include "chrome/browser/prefs/pref_service.h" | 25 #include "chrome/browser/prefs/pref_service.h" |
26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
29 #include "content/public/test/test_browser_thread.h" | 29 #include "content/public/test/test_browser_thread.h" |
30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
32 | 32 |
33 using ::testing::AnyNumber; | 33 using ::testing::AnyNumber; |
34 using ::testing::DoAll; | 34 using ::testing::DoAll; |
(...skipping 19 matching lines...) Expand all Loading... |
54 entry_proto->mutable_file_specific_info()->set_file_md5(md5); | 54 entry_proto->mutable_file_specific_info()->set_file_md5(md5); |
55 arg1.Run(error, FilePath(), entry_proto.Pass()); | 55 arg1.Run(error, FilePath(), entry_proto.Pass()); |
56 } | 56 } |
57 | 57 |
58 class GDataSyncClientTest : public testing::Test { | 58 class GDataSyncClientTest : public testing::Test { |
59 public: | 59 public: |
60 GDataSyncClientTest() | 60 GDataSyncClientTest() |
61 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 61 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
62 io_thread_(content::BrowserThread::IO), | 62 io_thread_(content::BrowserThread::IO), |
63 profile_(new TestingProfile), | 63 profile_(new TestingProfile), |
64 mock_file_system_(new StrictMock<MockGDataFileSystem>), | 64 mock_file_system_(new StrictMock<MockDriveFileSystem>), |
65 mock_network_library_(NULL) { | 65 mock_network_library_(NULL) { |
66 } | 66 } |
67 | 67 |
68 virtual void SetUp() OVERRIDE { | 68 virtual void SetUp() OVERRIDE { |
69 chromeos::CrosLibrary::Initialize(true /* use_stub */); | 69 chromeos::CrosLibrary::Initialize(true /* use_stub */); |
70 | 70 |
71 // CrosLibrary takes ownership of MockNetworkLibrary. | 71 // CrosLibrary takes ownership of MockNetworkLibrary. |
72 mock_network_library_ = new chromeos::MockNetworkLibrary; | 72 mock_network_library_ = new chromeos::MockNetworkLibrary; |
73 chromeos::CrosLibrary::Get()->GetTestApi()->SetNetworkLibrary( | 73 chromeos::CrosLibrary::Get()->GetTestApi()->SetNetworkLibrary( |
74 mock_network_library_, true); | 74 mock_network_library_, true); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 file_util::CreateSymbolicLink( | 210 file_util::CreateSymbolicLink( |
211 dirty_file_path, | 211 dirty_file_path, |
212 outgoing_dir.AppendASCII("resource_id_dirty"))); | 212 outgoing_dir.AppendASCII("resource_id_dirty"))); |
213 // Create a symlink in the pinned directory to the dirty file. | 213 // Create a symlink in the pinned directory to the dirty file. |
214 ASSERT_TRUE( | 214 ASSERT_TRUE( |
215 file_util::CreateSymbolicLink( | 215 file_util::CreateSymbolicLink( |
216 dirty_file_path, | 216 dirty_file_path, |
217 pinned_dir.AppendASCII("resource_id_dirty"))); | 217 pinned_dir.AppendASCII("resource_id_dirty"))); |
218 } | 218 } |
219 | 219 |
220 // Sets the expectation for MockGDataFileSystem::GetFileByResourceId(), | 220 // Sets the expectation for MockDriveFileSystem::GetFileByResourceId(), |
221 // that simulates successful retrieval of a file for the given resource ID. | 221 // that simulates successful retrieval of a file for the given resource ID. |
222 void SetExpectationForGetFileByResourceId(const std::string& resource_id) { | 222 void SetExpectationForGetFileByResourceId(const std::string& resource_id) { |
223 EXPECT_CALL(*mock_file_system_, | 223 EXPECT_CALL(*mock_file_system_, |
224 GetFileByResourceId(resource_id, _, _)) | 224 GetFileByResourceId(resource_id, _, _)) |
225 .WillOnce(MockGetFileByResourceId( | 225 .WillOnce(MockGetFileByResourceId( |
226 DRIVE_FILE_OK, | 226 DRIVE_FILE_OK, |
227 FilePath::FromUTF8Unsafe("local_path_does_not_matter"), | 227 FilePath::FromUTF8Unsafe("local_path_does_not_matter"), |
228 std::string("mime_type_does_not_matter"), | 228 std::string("mime_type_does_not_matter"), |
229 REGULAR_FILE)); | 229 REGULAR_FILE)); |
230 } | 230 } |
231 | 231 |
232 // Sets the expectation for MockGDataFileSystem::UpdateFileByResourceId(), | 232 // Sets the expectation for MockDriveFileSystem::UpdateFileByResourceId(), |
233 // that simulates successful uploading of a file for the given resource ID. | 233 // that simulates successful uploading of a file for the given resource ID. |
234 void SetExpectationForUpdateFileByResourceId( | 234 void SetExpectationForUpdateFileByResourceId( |
235 const std::string& resource_id) { | 235 const std::string& resource_id) { |
236 EXPECT_CALL(*mock_file_system_, | 236 EXPECT_CALL(*mock_file_system_, |
237 UpdateFileByResourceId(resource_id, _)) | 237 UpdateFileByResourceId(resource_id, _)) |
238 .WillOnce(MockUpdateFileByResourceId(DRIVE_FILE_OK)); | 238 .WillOnce(MockUpdateFileByResourceId(DRIVE_FILE_OK)); |
239 } | 239 } |
240 | 240 |
241 // Sets the expectation for MockGDataFileSystem::GetFileInfoByResourceId(), | 241 // Sets the expectation for MockDriveFileSystem::GetFileInfoByResourceId(), |
242 // that simulates successful retrieval of file info for the given resource | 242 // that simulates successful retrieval of file info for the given resource |
243 // ID. | 243 // ID. |
244 // | 244 // |
245 // This is used for testing StartCheckingExistingPinnedFiles(), hence we | 245 // This is used for testing StartCheckingExistingPinnedFiles(), hence we |
246 // are only interested in the MD5 value in DriveEntryProto. | 246 // are only interested in the MD5 value in DriveEntryProto. |
247 void SetExpectationForGetFileInfoByResourceId( | 247 void SetExpectationForGetFileInfoByResourceId( |
248 const std::string& resource_id, | 248 const std::string& resource_id, |
249 const std::string& new_md5) { | 249 const std::string& new_md5) { |
250 EXPECT_CALL(*mock_file_system_, | 250 EXPECT_CALL(*mock_file_system_, |
251 GetEntryInfoByResourceId(resource_id, _)) | 251 GetEntryInfoByResourceId(resource_id, _)) |
(...skipping 24 matching lines...) Expand all Loading... |
276 sync_client_->AddResourceIdForTesting(GDataSyncClient::UPLOAD, | 276 sync_client_->AddResourceIdForTesting(GDataSyncClient::UPLOAD, |
277 resource_id); | 277 resource_id); |
278 } | 278 } |
279 | 279 |
280 protected: | 280 protected: |
281 MessageLoopForUI message_loop_; | 281 MessageLoopForUI message_loop_; |
282 content::TestBrowserThread ui_thread_; | 282 content::TestBrowserThread ui_thread_; |
283 content::TestBrowserThread io_thread_; | 283 content::TestBrowserThread io_thread_; |
284 ScopedTempDir temp_dir_; | 284 ScopedTempDir temp_dir_; |
285 scoped_ptr<TestingProfile> profile_; | 285 scoped_ptr<TestingProfile> profile_; |
286 scoped_ptr<StrictMock<MockGDataFileSystem> > mock_file_system_; | 286 scoped_ptr<StrictMock<MockDriveFileSystem> > mock_file_system_; |
287 DriveCache* cache_; | 287 DriveCache* cache_; |
288 scoped_ptr<GDataSyncClient> sync_client_; | 288 scoped_ptr<GDataSyncClient> sync_client_; |
289 chromeos::MockNetworkLibrary* mock_network_library_; | 289 chromeos::MockNetworkLibrary* mock_network_library_; |
290 scoped_ptr<chromeos::Network> active_network_; | 290 scoped_ptr<chromeos::Network> active_network_; |
291 }; | 291 }; |
292 | 292 |
293 TEST_F(GDataSyncClientTest, StartInitialScan) { | 293 TEST_F(GDataSyncClientTest, StartInitialScan) { |
294 SetUpTestFiles(); | 294 SetUpTestFiles(); |
295 // Connect to no network, so the sync loop won't spin. | 295 // Connect to no network, so the sync loop won't spin. |
296 ConnectToNone(); | 296 ConnectToNone(); |
(...skipping 26 matching lines...) Expand all Loading... |
323 | 323 |
324 TEST_F(GDataSyncClientTest, StartSyncLoop) { | 324 TEST_F(GDataSyncClientTest, StartSyncLoop) { |
325 SetUpTestFiles(); | 325 SetUpTestFiles(); |
326 ConnectToWifi(); | 326 ConnectToWifi(); |
327 | 327 |
328 AddResourceIdToFetch("resource_id_not_fetched_foo"); | 328 AddResourceIdToFetch("resource_id_not_fetched_foo"); |
329 AddResourceIdToFetch("resource_id_not_fetched_bar"); | 329 AddResourceIdToFetch("resource_id_not_fetched_bar"); |
330 AddResourceIdToFetch("resource_id_not_fetched_baz"); | 330 AddResourceIdToFetch("resource_id_not_fetched_baz"); |
331 AddResourceIdToUpload("resource_id_dirty"); | 331 AddResourceIdToUpload("resource_id_dirty"); |
332 | 332 |
333 // These files will be fetched or uploaded by GDataFileSystem, once | 333 // These files will be fetched or uploaded by DriveFileSystem, once |
334 // StartSyncLoop() starts. | 334 // StartSyncLoop() starts. |
335 SetExpectationForGetFileByResourceId("resource_id_not_fetched_foo"); | 335 SetExpectationForGetFileByResourceId("resource_id_not_fetched_foo"); |
336 SetExpectationForGetFileByResourceId("resource_id_not_fetched_bar"); | 336 SetExpectationForGetFileByResourceId("resource_id_not_fetched_bar"); |
337 SetExpectationForGetFileByResourceId("resource_id_not_fetched_baz"); | 337 SetExpectationForGetFileByResourceId("resource_id_not_fetched_baz"); |
338 SetExpectationForUpdateFileByResourceId("resource_id_dirty"); | 338 SetExpectationForUpdateFileByResourceId("resource_id_dirty"); |
339 | 339 |
340 sync_client_->StartSyncLoop(); | 340 sync_client_->StartSyncLoop(); |
341 } | 341 } |
342 | 342 |
343 TEST_F(GDataSyncClientTest, StartSyncLoop_Offline) { | 343 TEST_F(GDataSyncClientTest, StartSyncLoop_Offline) { |
344 SetUpTestFiles(); | 344 SetUpTestFiles(); |
345 ConnectToNone(); | 345 ConnectToNone(); |
346 | 346 |
347 AddResourceIdToFetch("resource_id_not_fetched_foo"); | 347 AddResourceIdToFetch("resource_id_not_fetched_foo"); |
348 AddResourceIdToFetch("resource_id_not_fetched_bar"); | 348 AddResourceIdToFetch("resource_id_not_fetched_bar"); |
349 AddResourceIdToFetch("resource_id_not_fetched_baz"); | 349 AddResourceIdToFetch("resource_id_not_fetched_baz"); |
350 AddResourceIdToUpload("resource_id_dirty"); | 350 AddResourceIdToUpload("resource_id_dirty"); |
351 | 351 |
352 // These files will be neither fetched nor uploaded not by GDataFileSystem, | 352 // These files will be neither fetched nor uploaded not by DriveFileSystem, |
353 // as network is not connected. | 353 // as network is not connected. |
354 | 354 |
355 sync_client_->StartSyncLoop(); | 355 sync_client_->StartSyncLoop(); |
356 } | 356 } |
357 | 357 |
358 TEST_F(GDataSyncClientTest, StartSyncLoop_ResumedConnection) { | 358 TEST_F(GDataSyncClientTest, StartSyncLoop_ResumedConnection) { |
359 const std::string resource_id("resource_id_not_fetched_foo"); | 359 const std::string resource_id("resource_id_not_fetched_foo"); |
360 const FilePath file_path( | 360 const FilePath file_path( |
361 FilePath::FromUTF8Unsafe("local_path_does_not_matter")); | 361 FilePath::FromUTF8Unsafe("local_path_does_not_matter")); |
362 const std::string mime_type("mime_type_does_not_matter"); | 362 const std::string mime_type("mime_type_does_not_matter"); |
(...skipping 22 matching lines...) Expand all Loading... |
385 | 385 |
386 TEST_F(GDataSyncClientTest, StartSyncLoop_CelluarDisabled) { | 386 TEST_F(GDataSyncClientTest, StartSyncLoop_CelluarDisabled) { |
387 SetUpTestFiles(); | 387 SetUpTestFiles(); |
388 ConnectToWifi(); // First connect to Wifi. | 388 ConnectToWifi(); // First connect to Wifi. |
389 | 389 |
390 AddResourceIdToFetch("resource_id_not_fetched_foo"); | 390 AddResourceIdToFetch("resource_id_not_fetched_foo"); |
391 AddResourceIdToFetch("resource_id_not_fetched_bar"); | 391 AddResourceIdToFetch("resource_id_not_fetched_bar"); |
392 AddResourceIdToFetch("resource_id_not_fetched_baz"); | 392 AddResourceIdToFetch("resource_id_not_fetched_baz"); |
393 AddResourceIdToUpload("resource_id_dirty"); | 393 AddResourceIdToUpload("resource_id_dirty"); |
394 | 394 |
395 // These files will be neither fetched nor uploaded not by GDataFileSystem, | 395 // These files will be neither fetched nor uploaded not by DriveFileSystem, |
396 // as fetching over cellular network is disabled by default. | 396 // as fetching over cellular network is disabled by default. |
397 | 397 |
398 // Then connect to cellular. This will kick off StartSyncLoop(). | 398 // Then connect to cellular. This will kick off StartSyncLoop(). |
399 ConnectToCellular(); | 399 ConnectToCellular(); |
400 } | 400 } |
401 | 401 |
402 TEST_F(GDataSyncClientTest, StartSyncLoop_CelluarEnabled) { | 402 TEST_F(GDataSyncClientTest, StartSyncLoop_CelluarEnabled) { |
403 SetUpTestFiles(); | 403 SetUpTestFiles(); |
404 ConnectToWifi(); // First connect to Wifi. | 404 ConnectToWifi(); // First connect to Wifi. |
405 | 405 |
406 // Enable fetching over cellular network. | 406 // Enable fetching over cellular network. |
407 profile_->GetPrefs()->SetBoolean(prefs::kDisableGDataOverCellular, false); | 407 profile_->GetPrefs()->SetBoolean(prefs::kDisableGDataOverCellular, false); |
408 | 408 |
409 AddResourceIdToFetch("resource_id_not_fetched_foo"); | 409 AddResourceIdToFetch("resource_id_not_fetched_foo"); |
410 AddResourceIdToFetch("resource_id_not_fetched_bar"); | 410 AddResourceIdToFetch("resource_id_not_fetched_bar"); |
411 AddResourceIdToFetch("resource_id_not_fetched_baz"); | 411 AddResourceIdToFetch("resource_id_not_fetched_baz"); |
412 AddResourceIdToUpload("resource_id_dirty"); | 412 AddResourceIdToUpload("resource_id_dirty"); |
413 | 413 |
414 // These files will be fetched or uploaded by GDataFileSystem, as syncing | 414 // These files will be fetched or uploaded by DriveFileSystem, as syncing |
415 // over cellular network is explicitly enabled. | 415 // over cellular network is explicitly enabled. |
416 SetExpectationForGetFileByResourceId("resource_id_not_fetched_foo"); | 416 SetExpectationForGetFileByResourceId("resource_id_not_fetched_foo"); |
417 SetExpectationForGetFileByResourceId("resource_id_not_fetched_bar"); | 417 SetExpectationForGetFileByResourceId("resource_id_not_fetched_bar"); |
418 SetExpectationForGetFileByResourceId("resource_id_not_fetched_baz"); | 418 SetExpectationForGetFileByResourceId("resource_id_not_fetched_baz"); |
419 SetExpectationForUpdateFileByResourceId("resource_id_dirty"); | 419 SetExpectationForUpdateFileByResourceId("resource_id_dirty"); |
420 | 420 |
421 // Then connect to cellular. This will kick off StartSyncLoop(). | 421 // Then connect to cellular. This will kick off StartSyncLoop(). |
422 ConnectToCellular(); | 422 ConnectToCellular(); |
423 } | 423 } |
424 | 424 |
425 TEST_F(GDataSyncClientTest, StartSyncLoop_WimaxDisabled) { | 425 TEST_F(GDataSyncClientTest, StartSyncLoop_WimaxDisabled) { |
426 SetUpTestFiles(); | 426 SetUpTestFiles(); |
427 ConnectToWifi(); // First connect to Wifi. | 427 ConnectToWifi(); // First connect to Wifi. |
428 | 428 |
429 AddResourceIdToFetch("resource_id_not_fetched_foo"); | 429 AddResourceIdToFetch("resource_id_not_fetched_foo"); |
430 AddResourceIdToFetch("resource_id_not_fetched_bar"); | 430 AddResourceIdToFetch("resource_id_not_fetched_bar"); |
431 AddResourceIdToFetch("resource_id_not_fetched_baz"); | 431 AddResourceIdToFetch("resource_id_not_fetched_baz"); |
432 AddResourceIdToUpload("resource_id_dirty"); | 432 AddResourceIdToUpload("resource_id_dirty"); |
433 | 433 |
434 // These files will be neither fetched nor uploaded not by GDataFileSystem, | 434 // These files will be neither fetched nor uploaded not by DriveFileSystem, |
435 // as syncing over wimax network is disabled by default. | 435 // as syncing over wimax network is disabled by default. |
436 | 436 |
437 // Then connect to wimax. This will kick off StartSyncLoop(). | 437 // Then connect to wimax. This will kick off StartSyncLoop(). |
438 ConnectToWimax(); | 438 ConnectToWimax(); |
439 } | 439 } |
440 | 440 |
441 TEST_F(GDataSyncClientTest, StartSyncLoop_CelluarEnabledWithWimax) { | 441 TEST_F(GDataSyncClientTest, StartSyncLoop_CelluarEnabledWithWimax) { |
442 SetUpTestFiles(); | 442 SetUpTestFiles(); |
443 ConnectToWifi(); // First connect to Wifi. | 443 ConnectToWifi(); // First connect to Wifi. |
444 | 444 |
445 // Enable fetching over cellular network. This includes wimax. | 445 // Enable fetching over cellular network. This includes wimax. |
446 profile_->GetPrefs()->SetBoolean(prefs::kDisableGDataOverCellular, false); | 446 profile_->GetPrefs()->SetBoolean(prefs::kDisableGDataOverCellular, false); |
447 | 447 |
448 AddResourceIdToFetch("resource_id_not_fetched_foo"); | 448 AddResourceIdToFetch("resource_id_not_fetched_foo"); |
449 AddResourceIdToFetch("resource_id_not_fetched_bar"); | 449 AddResourceIdToFetch("resource_id_not_fetched_bar"); |
450 AddResourceIdToFetch("resource_id_not_fetched_baz"); | 450 AddResourceIdToFetch("resource_id_not_fetched_baz"); |
451 AddResourceIdToUpload("resource_id_dirty"); | 451 AddResourceIdToUpload("resource_id_dirty"); |
452 | 452 |
453 // These files will be fetched or uploaded by GDataFileSystem, as syncing | 453 // These files will be fetched or uploaded by DriveFileSystem, as syncing |
454 // over cellular network, which includes wimax, is explicitly enabled. | 454 // over cellular network, which includes wimax, is explicitly enabled. |
455 SetExpectationForGetFileByResourceId("resource_id_not_fetched_foo"); | 455 SetExpectationForGetFileByResourceId("resource_id_not_fetched_foo"); |
456 SetExpectationForGetFileByResourceId("resource_id_not_fetched_bar"); | 456 SetExpectationForGetFileByResourceId("resource_id_not_fetched_bar"); |
457 SetExpectationForGetFileByResourceId("resource_id_not_fetched_baz"); | 457 SetExpectationForGetFileByResourceId("resource_id_not_fetched_baz"); |
458 SetExpectationForUpdateFileByResourceId("resource_id_dirty"); | 458 SetExpectationForUpdateFileByResourceId("resource_id_dirty"); |
459 | 459 |
460 // Then connect to wimax. This will kick off StartSyncLoop(). | 460 // Then connect to wimax. This will kick off StartSyncLoop(). |
461 ConnectToWimax(); | 461 ConnectToWimax(); |
462 } | 462 } |
463 | 463 |
464 TEST_F(GDataSyncClientTest, StartSyncLoop_GDataDisabled) { | 464 TEST_F(GDataSyncClientTest, StartSyncLoop_GDataDisabled) { |
465 SetUpTestFiles(); | 465 SetUpTestFiles(); |
466 ConnectToWifi(); | 466 ConnectToWifi(); |
467 | 467 |
468 // Disable the GData feature. | 468 // Disable the GData feature. |
469 profile_->GetPrefs()->SetBoolean(prefs::kDisableGData, true); | 469 profile_->GetPrefs()->SetBoolean(prefs::kDisableGData, true); |
470 | 470 |
471 AddResourceIdToFetch("resource_id_not_fetched_foo"); | 471 AddResourceIdToFetch("resource_id_not_fetched_foo"); |
472 AddResourceIdToFetch("resource_id_not_fetched_bar"); | 472 AddResourceIdToFetch("resource_id_not_fetched_bar"); |
473 AddResourceIdToFetch("resource_id_not_fetched_baz"); | 473 AddResourceIdToFetch("resource_id_not_fetched_baz"); |
474 AddResourceIdToUpload("resource_id_dirty"); | 474 AddResourceIdToUpload("resource_id_dirty"); |
475 | 475 |
476 // These files will be neither fetched nor uploaded not by GDataFileSystem, | 476 // These files will be neither fetched nor uploaded not by DriveFileSystem, |
477 // as the GData feature is disabled. | 477 // as the GData feature is disabled. |
478 | 478 |
479 sync_client_->StartSyncLoop(); | 479 sync_client_->StartSyncLoop(); |
480 } | 480 } |
481 | 481 |
482 TEST_F(GDataSyncClientTest, OnCachePinned) { | 482 TEST_F(GDataSyncClientTest, OnCachePinned) { |
483 SetUpTestFiles(); | 483 SetUpTestFiles(); |
484 ConnectToWifi(); | 484 ConnectToWifi(); |
485 | 485 |
486 // This file will be fetched by GetFileByResourceId() as OnCachePinned() | 486 // This file will be fetched by GetFileByResourceId() as OnCachePinned() |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 534 |
535 TEST_F(GDataSyncClientTest, ExistingPinnedFiles) { | 535 TEST_F(GDataSyncClientTest, ExistingPinnedFiles) { |
536 SetUpTestFiles(); | 536 SetUpTestFiles(); |
537 // Connect to no network, so the sync loop won't spin. | 537 // Connect to no network, so the sync loop won't spin. |
538 ConnectToNone(); | 538 ConnectToNone(); |
539 | 539 |
540 // Kick off the cache initialization. This will scan the contents in the | 540 // Kick off the cache initialization. This will scan the contents in the |
541 // test cache directory. | 541 // test cache directory. |
542 cache_->RequestInitializeOnUIThread(); | 542 cache_->RequestInitializeOnUIThread(); |
543 | 543 |
544 // Set the expectation so that the MockGDataFileSystem returns "new_md5" | 544 // Set the expectation so that the MockDriveFileSystem returns "new_md5" |
545 // for "resource_id_fetched". This simulates that the file is updated on | 545 // for "resource_id_fetched". This simulates that the file is updated on |
546 // the server side, and the new MD5 is obtained from the server (i.e. the | 546 // the server side, and the new MD5 is obtained from the server (i.e. the |
547 // local cach file is stale). | 547 // local cach file is stale). |
548 SetExpectationForGetFileInfoByResourceId("resource_id_fetched", | 548 SetExpectationForGetFileInfoByResourceId("resource_id_fetched", |
549 "new_md5"); | 549 "new_md5"); |
550 // Set the expectation so that the MockGDataFileSystem returns "some_md5" | 550 // Set the expectation so that the MockDriveFileSystem returns "some_md5" |
551 // for "resource_id_dirty". The MD5 on the server is always different from | 551 // for "resource_id_dirty". The MD5 on the server is always different from |
552 // the MD5 of a dirty file, which is set to "local". We should not collect | 552 // the MD5 of a dirty file, which is set to "local". We should not collect |
553 // this by StartCheckingExistingPinnedFiles(). | 553 // this by StartCheckingExistingPinnedFiles(). |
554 SetExpectationForGetFileInfoByResourceId("resource_id_dirty", | 554 SetExpectationForGetFileInfoByResourceId("resource_id_dirty", |
555 "some_md5"); | 555 "some_md5"); |
556 | 556 |
557 // Start checking the existing pinned files. This will collect the resource | 557 // Start checking the existing pinned files. This will collect the resource |
558 // IDs of pinned files, with stale local cache files. | 558 // IDs of pinned files, with stale local cache files. |
559 sync_client_->StartCheckingExistingPinnedFiles(); | 559 sync_client_->StartCheckingExistingPinnedFiles(); |
560 test_util::RunBlockingPoolTask(); | 560 test_util::RunBlockingPoolTask(); |
561 | 561 |
562 // Check the contents of the queue for fetching. | 562 // Check the contents of the queue for fetching. |
563 std::vector<std::string> resource_ids = | 563 std::vector<std::string> resource_ids = |
564 GetResourceIdsToBeFetched(); | 564 GetResourceIdsToBeFetched(); |
565 ASSERT_EQ(1U, resource_ids.size()); | 565 ASSERT_EQ(1U, resource_ids.size()); |
566 EXPECT_EQ("resource_id_fetched", resource_ids[0]); | 566 EXPECT_EQ("resource_id_fetched", resource_ids[0]); |
567 // resource_id_dirty is not collected in the queue. | 567 // resource_id_dirty is not collected in the queue. |
568 | 568 |
569 // Check the contents of the queue for uploading. | 569 // Check the contents of the queue for uploading. |
570 resource_ids = GetResourceIdsToBeUploaded(); | 570 resource_ids = GetResourceIdsToBeUploaded(); |
571 ASSERT_TRUE(resource_ids.empty()); | 571 ASSERT_TRUE(resource_ids.empty()); |
572 } | 572 } |
573 | 573 |
574 } // namespace gdata | 574 } // namespace gdata |
OLD | NEW |