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 <vector> |
| 6 |
5 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
6 #include "base/bind.h" | 8 #include "base/bind.h" |
7 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
8 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
9 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
10 #include "chrome/browser/sync_file_system/local_file_sync_service.h" | 12 #include "chrome/browser/sync_file_system/local_file_sync_service.h" |
11 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" | 13 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" |
12 #include "chrome/browser/sync_file_system/sync_event_observer.h" | 14 #include "chrome/browser/sync_file_system/sync_event_observer.h" |
13 #include "chrome/browser/sync_file_system/sync_file_system_service.h" | 15 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
14 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" | 16 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 base::RunLoop run_loop; | 479 base::RunLoop run_loop; |
478 | 480 |
479 // We expect a set of method calls for starting a remote sync. | 481 // We expect a set of method calls for starting a remote sync. |
480 EXPECT_CALL(*mock_remote_service(), GetCurrentState()) | 482 EXPECT_CALL(*mock_remote_service(), GetCurrentState()) |
481 .Times(AtLeast(2)) | 483 .Times(AtLeast(2)) |
482 .WillRepeatedly(Return(REMOTE_SERVICE_OK)); | 484 .WillRepeatedly(Return(REMOTE_SERVICE_OK)); |
483 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _)) | 485 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _)) |
484 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 486 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
485 | 487 |
486 // This should trigger a remote sync. | 488 // This should trigger a remote sync. |
487 mock_remote_service()->NotifyRemoteChangeAvailable(1); | 489 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); |
488 | 490 |
489 run_loop.Run(); | 491 run_loop.Run(); |
490 } | 492 } |
491 | 493 |
492 TEST_F(SyncFileSystemServiceTest, SimpleSyncFlowWithFileBusy) { | 494 TEST_F(SyncFileSystemServiceTest, SimpleSyncFlowWithFileBusy) { |
493 InitializeApp(); | 495 InitializeApp(); |
494 | 496 |
495 StrictMock<MockLocalChangeProcessor> local_change_processor; | 497 StrictMock<MockLocalChangeProcessor> local_change_processor; |
496 | 498 |
497 sync_service_->set_auto_sync_enabled(true); | 499 sync_service_->set_auto_sync_enabled(true); |
(...skipping 25 matching lines...) Expand all Loading... |
523 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _)) | 525 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _)) |
524 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 526 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
525 } | 527 } |
526 | 528 |
527 // We might also see an activity for local sync as we're going to make | 529 // We might also see an activity for local sync as we're going to make |
528 // a local write operation on kFile. | 530 // a local write operation on kFile. |
529 EXPECT_CALL(local_change_processor, ApplyLocalChange(_, _, _, kFile, _)) | 531 EXPECT_CALL(local_change_processor, ApplyLocalChange(_, _, _, kFile, _)) |
530 .Times(AnyNumber()); | 532 .Times(AnyNumber()); |
531 | 533 |
532 // This should trigger a remote sync. | 534 // This should trigger a remote sync. |
533 mock_remote_service()->NotifyRemoteChangeAvailable(1); | 535 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); |
534 | 536 |
535 // Start a local operation on the same file (to make it BUSY). | 537 // Start a local operation on the same file (to make it BUSY). |
536 base::WaitableEvent event(false, false); | 538 base::WaitableEvent event(false, false); |
537 thread_helper_.io_task_runner()->PostTask( | 539 thread_helper_.io_task_runner()->PostTask( |
538 FROM_HERE, base::Bind(&fileapi::CannedSyncableFileSystem::DoCreateFile, | 540 FROM_HERE, base::Bind(&fileapi::CannedSyncableFileSystem::DoCreateFile, |
539 base::Unretained(file_system_.get()), | 541 base::Unretained(file_system_.get()), |
540 kFile, base::Bind(&VerifyFileError, &event))); | 542 kFile, base::Bind(&VerifyFileError, &event))); |
541 | 543 |
542 run_loop.Run(); | 544 run_loop.Run(); |
543 | 545 |
544 mock_remote_service()->NotifyRemoteChangeAvailable(0); | 546 mock_remote_service()->NotifyRemoteChangeQueueUpdated(0); |
545 | 547 |
546 event.Wait(); | 548 event.Wait(); |
547 } | 549 } |
548 | 550 |
549 TEST_F(SyncFileSystemServiceTest, GetFileSyncStatus) { | 551 TEST_F(SyncFileSystemServiceTest, GetFileSyncStatus) { |
550 InitializeApp(); | 552 InitializeApp(); |
551 | 553 |
552 const FileSystemURL kFile(file_system_->URL("foo")); | 554 const FileSystemURL kFile(file_system_->URL("foo")); |
553 | 555 |
554 fileapi::SyncStatusCode status; | 556 fileapi::SyncStatusCode status; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 base::Bind(&AssignValueAndQuit<fileapi::SyncFileStatus>, | 628 base::Bind(&AssignValueAndQuit<fileapi::SyncFileStatus>, |
627 &run_loop, &status, &sync_file_status)); | 629 &run_loop, &status, &sync_file_status)); |
628 run_loop.Run(); | 630 run_loop.Run(); |
629 | 631 |
630 EXPECT_EQ(fileapi::SYNC_STATUS_OK, status); | 632 EXPECT_EQ(fileapi::SYNC_STATUS_OK, status); |
631 EXPECT_EQ(fileapi::SYNC_FILE_STATUS_CONFLICTING, sync_file_status); | 633 EXPECT_EQ(fileapi::SYNC_FILE_STATUS_CONFLICTING, sync_file_status); |
632 } | 634 } |
633 } | 635 } |
634 | 636 |
635 } // namespace sync_file_system | 637 } // namespace sync_file_system |
OLD | NEW |