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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_METHOD0(OnNotificationsEnabled, void()); | 61 MOCK_METHOD0(OnNotificationsEnabled, void()); |
62 MOCK_METHOD1(OnNotificationsDisabled, | 62 MOCK_METHOD1(OnNotificationsDisabled, |
63 void(syncer::NotificationsDisabledReason)); | 63 void(syncer::NotificationsDisabledReason)); |
64 MOCK_METHOD2(OnIncomingNotification, | 64 MOCK_METHOD2(OnIncomingNotification, |
65 void(const syncer::ObjectIdPayloadMap&, | 65 void(const syncer::ObjectIdStateMap&, |
66 syncer::IncomingNotificationSource)); | 66 syncer::IncomingNotificationSource)); |
67 MOCK_METHOD2(OnBackendInitialized, | 67 MOCK_METHOD2(OnBackendInitialized, |
68 void(const syncer::WeakHandle<syncer::JsBackend>&, bool)); | 68 void(const syncer::WeakHandle<syncer::JsBackend>&, bool)); |
69 MOCK_METHOD0(OnSyncCycleCompleted, void()); | 69 MOCK_METHOD0(OnSyncCycleCompleted, void()); |
70 MOCK_METHOD1(OnConnectionStatusChange, | 70 MOCK_METHOD1(OnConnectionStatusChange, |
71 void(syncer::ConnectionStatus status)); | 71 void(syncer::ConnectionStatus status)); |
72 MOCK_METHOD0(OnStopSyncingPermanently, void()); | 72 MOCK_METHOD0(OnStopSyncingPermanently, void()); |
73 MOCK_METHOD0(OnClearServerDataSucceeded, void()); | 73 MOCK_METHOD0(OnClearServerDataSucceeded, void()); |
74 MOCK_METHOD0(OnClearServerDataFailed, void()); | 74 MOCK_METHOD0(OnClearServerDataFailed, void()); |
75 MOCK_METHOD2(OnPassphraseRequired, | 75 MOCK_METHOD2(OnPassphraseRequired, |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 } | 577 } |
578 | 578 |
579 // Register for some IDs and trigger an invalidation. This should | 579 // Register for some IDs and trigger an invalidation. This should |
580 // propagate all the way to the frontend. | 580 // propagate all the way to the frontend. |
581 TEST_F(SyncBackendHostTest, Invalidate) { | 581 TEST_F(SyncBackendHostTest, Invalidate) { |
582 InitializeBackend(); | 582 InitializeBackend(); |
583 | 583 |
584 syncer::ObjectIdSet ids; | 584 syncer::ObjectIdSet ids; |
585 ids.insert(invalidation::ObjectId(1, "id1")); | 585 ids.insert(invalidation::ObjectId(1, "id1")); |
586 ids.insert(invalidation::ObjectId(2, "id2")); | 586 ids.insert(invalidation::ObjectId(2, "id2")); |
587 const syncer::ObjectIdPayloadMap& id_payloads = | 587 const syncer::ObjectIdStateMap& id_state_map = |
588 syncer::ObjectIdSetToPayloadMap(ids, "payload"); | 588 syncer::ObjectIdSetToStateMap(ids, "payload"); |
589 | 589 |
590 EXPECT_CALL( | 590 EXPECT_CALL( |
591 mock_frontend_, | 591 mock_frontend_, |
592 OnIncomingNotification(id_payloads, syncer::REMOTE_NOTIFICATION)) | 592 OnIncomingNotification(id_state_map, syncer::REMOTE_NOTIFICATION)) |
593 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 593 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
594 | 594 |
595 backend_->UpdateRegisteredInvalidationIds(ids); | 595 backend_->UpdateRegisteredInvalidationIds(ids); |
596 fake_manager_->Invalidate(id_payloads, syncer::REMOTE_NOTIFICATION); | 596 fake_manager_->Invalidate(id_state_map, syncer::REMOTE_NOTIFICATION); |
597 ui_loop_.PostDelayedTask( | 597 ui_loop_.PostDelayedTask( |
598 FROM_HERE, ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); | 598 FROM_HERE, ui_loop_.QuitClosure(), TestTimeouts::action_timeout()); |
599 ui_loop_.Run(); | 599 ui_loop_.Run(); |
600 } | 600 } |
601 | 601 |
602 // Register for some IDs and turn on notifications. This should | 602 // Register for some IDs and turn on notifications. This should |
603 // propagate all the way to the frontend. | 603 // propagate all the way to the frontend. |
604 TEST_F(SyncBackendHostTest, EnableNotifications) { | 604 TEST_F(SyncBackendHostTest, EnableNotifications) { |
605 InitializeBackend(); | 605 InitializeBackend(); |
606 | 606 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 642 |
643 syncer::ObjectIdSet ids; | 643 syncer::ObjectIdSet ids; |
644 ids.insert(invalidation::ObjectId(5, "id5")); | 644 ids.insert(invalidation::ObjectId(5, "id5")); |
645 backend_->UpdateRegisteredInvalidationIds(ids); | 645 backend_->UpdateRegisteredInvalidationIds(ids); |
646 | 646 |
647 backend_->StopSyncingForShutdown(); | 647 backend_->StopSyncingForShutdown(); |
648 | 648 |
649 // Should not trigger anything. | 649 // Should not trigger anything. |
650 fake_manager_->DisableNotifications(syncer::TRANSIENT_NOTIFICATION_ERROR); | 650 fake_manager_->DisableNotifications(syncer::TRANSIENT_NOTIFICATION_ERROR); |
651 fake_manager_->EnableNotifications(); | 651 fake_manager_->EnableNotifications(); |
652 const syncer::ObjectIdPayloadMap& id_payloads = | 652 const syncer::ObjectIdStateMap& id_state_map = |
653 syncer::ObjectIdSetToPayloadMap(ids, "payload"); | 653 syncer::ObjectIdSetToStateMap(ids, "payload"); |
654 fake_manager_->Invalidate(id_payloads, syncer::REMOTE_NOTIFICATION); | 654 fake_manager_->Invalidate(id_state_map, syncer::REMOTE_NOTIFICATION); |
655 | 655 |
656 // Make sure the above calls take effect before we continue. | 656 // Make sure the above calls take effect before we continue. |
657 fake_manager_->WaitForSyncThread(); | 657 fake_manager_->WaitForSyncThread(); |
658 | 658 |
659 backend_->Shutdown(false); | 659 backend_->Shutdown(false); |
660 backend_.reset(); | 660 backend_.reset(); |
661 | 661 |
662 TearDown(); | 662 TearDown(); |
663 SetUp(); | 663 SetUp(); |
664 } | 664 } |
665 | 665 |
666 } // namespace | 666 } // namespace |
667 | 667 |
668 } // namespace browser_sync | 668 } // namespace browser_sync |
OLD | NEW |