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/sync/glue/sync_backend_host.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void QuitMessageLoop() { | 53 void QuitMessageLoop() { |
54 MessageLoop::current()->Quit(); | 54 MessageLoop::current()->Quit(); |
55 } | 55 } |
56 | 56 |
57 class MockSyncFrontend : public SyncFrontend { | 57 class MockSyncFrontend : public SyncFrontend { |
58 public: | 58 public: |
59 virtual ~MockSyncFrontend() {} | 59 virtual ~MockSyncFrontend() {} |
60 | 60 |
61 MOCK_METHOD1(OnInvalidatorStateChange, | 61 MOCK_METHOD1(OnInvalidatorStateChange, |
62 void(syncer::InvalidatorState)); | 62 void(syncer::InvalidatorState)); |
63 MOCK_METHOD2(OnIncomingInvalidation, | 63 MOCK_METHOD1(OnIncomingInvalidation, |
64 void(const syncer::ObjectIdInvalidationMap&, | 64 void(const syncer::ObjectIdInvalidationMap&)); |
65 syncer::IncomingInvalidationSource)); | |
66 MOCK_METHOD3( | 65 MOCK_METHOD3( |
67 OnBackendInitialized, | 66 OnBackendInitialized, |
68 void(const syncer::WeakHandle<syncer::JsBackend>&, | 67 void(const syncer::WeakHandle<syncer::JsBackend>&, |
69 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&, | 68 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&, |
70 bool)); | 69 bool)); |
71 MOCK_METHOD0(OnSyncCycleCompleted, void()); | 70 MOCK_METHOD0(OnSyncCycleCompleted, void()); |
72 MOCK_METHOD1(OnConnectionStatusChange, | 71 MOCK_METHOD1(OnConnectionStatusChange, |
73 void(syncer::ConnectionStatus status)); | 72 void(syncer::ConnectionStatus status)); |
74 MOCK_METHOD0(OnStopSyncingPermanently, void()); | 73 MOCK_METHOD0(OnStopSyncingPermanently, void()); |
75 MOCK_METHOD0(OnClearServerDataSucceeded, void()); | 74 MOCK_METHOD0(OnClearServerDataSucceeded, void()); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 InitializeBackend(true); | 594 InitializeBackend(true); |
596 | 595 |
597 syncer::ObjectIdSet ids; | 596 syncer::ObjectIdSet ids; |
598 ids.insert(invalidation::ObjectId(1, "id1")); | 597 ids.insert(invalidation::ObjectId(1, "id1")); |
599 ids.insert(invalidation::ObjectId(2, "id2")); | 598 ids.insert(invalidation::ObjectId(2, "id2")); |
600 const syncer::ObjectIdInvalidationMap& invalidation_map = | 599 const syncer::ObjectIdInvalidationMap& invalidation_map = |
601 syncer::ObjectIdSetToInvalidationMap(ids, "payload"); | 600 syncer::ObjectIdSetToInvalidationMap(ids, "payload"); |
602 | 601 |
603 EXPECT_CALL( | 602 EXPECT_CALL( |
604 mock_frontend_, | 603 mock_frontend_, |
605 OnIncomingInvalidation(invalidation_map, syncer::REMOTE_INVALIDATION)) | 604 OnIncomingInvalidation(invalidation_map)) |
606 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 605 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
607 | 606 |
608 backend_->UpdateRegisteredInvalidationIds(ids); | 607 backend_->UpdateRegisteredInvalidationIds(ids); |
609 fake_manager_->Invalidate(invalidation_map, syncer::REMOTE_INVALIDATION); | 608 fake_manager_->Invalidate(invalidation_map); |
610 ui_loop_.PostDelayedTask( | 609 ui_loop_.PostDelayedTask( |
611 FROM_HERE, ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); | 610 FROM_HERE, ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); |
612 ui_loop_.Run(); | 611 ui_loop_.Run(); |
613 } | 612 } |
614 | 613 |
615 // Register for some IDs and update the invalidator state. This | 614 // Register for some IDs and update the invalidator state. This |
616 // should propagate all the way to the frontend. | 615 // should propagate all the way to the frontend. |
617 TEST_F(SyncBackendHostTest, UpdateInvalidatorState) { | 616 TEST_F(SyncBackendHostTest, UpdateInvalidatorState) { |
618 InitializeBackend(true); | 617 InitializeBackend(true); |
619 | 618 |
(...skipping 20 matching lines...) Expand all Loading... |
640 ids.insert(invalidation::ObjectId(5, "id5")); | 639 ids.insert(invalidation::ObjectId(5, "id5")); |
641 backend_->UpdateRegisteredInvalidationIds(ids); | 640 backend_->UpdateRegisteredInvalidationIds(ids); |
642 | 641 |
643 backend_->StopSyncingForShutdown(); | 642 backend_->StopSyncingForShutdown(); |
644 | 643 |
645 // Should not trigger anything. | 644 // Should not trigger anything. |
646 fake_manager_->UpdateInvalidatorState(syncer::TRANSIENT_INVALIDATION_ERROR); | 645 fake_manager_->UpdateInvalidatorState(syncer::TRANSIENT_INVALIDATION_ERROR); |
647 fake_manager_->UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED); | 646 fake_manager_->UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED); |
648 const syncer::ObjectIdInvalidationMap& invalidation_map = | 647 const syncer::ObjectIdInvalidationMap& invalidation_map = |
649 syncer::ObjectIdSetToInvalidationMap(ids, "payload"); | 648 syncer::ObjectIdSetToInvalidationMap(ids, "payload"); |
650 fake_manager_->Invalidate(invalidation_map, syncer::REMOTE_INVALIDATION); | 649 fake_manager_->Invalidate(invalidation_map); |
651 | 650 |
652 // Make sure the above calls take effect before we continue. | 651 // Make sure the above calls take effect before we continue. |
653 fake_manager_->WaitForSyncThread(); | 652 fake_manager_->WaitForSyncThread(); |
654 | 653 |
655 backend_->Shutdown(false); | 654 backend_->Shutdown(false); |
656 backend_.reset(); | 655 backend_.reset(); |
657 | 656 |
658 TearDown(); | 657 TearDown(); |
659 SetUp(); | 658 SetUp(); |
660 } | 659 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 fake_manager_->WaitForSyncThread(); | 741 fake_manager_->WaitForSyncThread(); |
743 EXPECT_FALSE(types.Equals(fake_manager_->GetLastRefreshRequestTypes())); | 742 EXPECT_FALSE(types.Equals(fake_manager_->GetLastRefreshRequestTypes())); |
744 | 743 |
745 backend_->Shutdown(false); | 744 backend_->Shutdown(false); |
746 backend_.reset(); | 745 backend_.reset(); |
747 } | 746 } |
748 | 747 |
749 } // namespace | 748 } // namespace |
750 | 749 |
751 } // namespace browser_sync | 750 } // namespace browser_sync |
OLD | NEW |