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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 } | 668 } |
669 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE { | 669 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE { |
670 delete static_cast<TestHttpPostProviderInterface*>(http); | 670 delete static_cast<TestHttpPostProviderInterface*>(http); |
671 } | 671 } |
672 }; | 672 }; |
673 | 673 |
674 class SyncManagerObserverMock : public SyncManager::Observer { | 674 class SyncManagerObserverMock : public SyncManager::Observer { |
675 public: | 675 public: |
676 MOCK_METHOD1(OnSyncCycleCompleted, | 676 MOCK_METHOD1(OnSyncCycleCompleted, |
677 void(const SyncSessionSnapshot&)); // NOLINT | 677 void(const SyncSessionSnapshot&)); // NOLINT |
678 MOCK_METHOD2(OnInitializationComplete, | 678 MOCK_METHOD3(OnInitializationComplete, |
679 void(const WeakHandle<JsBackend>&, bool)); // NOLINT | 679 void(const WeakHandle<JsBackend>&, bool, |
| 680 syncer::ModelTypeSet)); // NOLINT |
680 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT | 681 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT |
681 MOCK_METHOD2(OnPassphraseRequired, | 682 MOCK_METHOD2(OnPassphraseRequired, |
682 void(syncer::PassphraseRequiredReason, | 683 void(syncer::PassphraseRequiredReason, |
683 const sync_pb::EncryptedData&)); // NOLINT | 684 const sync_pb::EncryptedData&)); // NOLINT |
684 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT | 685 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT |
685 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT | 686 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT |
686 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT | 687 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT |
687 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT | 688 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT |
688 MOCK_METHOD2(OnEncryptedTypesChanged, | 689 MOCK_METHOD2(OnEncryptedTypesChanged, |
689 void(ModelTypeSet, bool)); // NOLINT | 690 void(ModelTypeSet, bool)); // NOLINT |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated("")); | 747 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated("")); |
747 EXPECT_CALL(*sync_notifier_mock_, | 748 EXPECT_CALL(*sync_notifier_mock_, |
748 UpdateCredentials(credentials.email, credentials.sync_token)); | 749 UpdateCredentials(credentials.email, credentials.sync_token)); |
749 EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)). | 750 EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)). |
750 WillRepeatedly( | 751 WillRepeatedly( |
751 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes)); | 752 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes)); |
752 EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)). | 753 EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)). |
753 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver)); | 754 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver)); |
754 | 755 |
755 sync_manager_.AddObserver(&observer_); | 756 sync_manager_.AddObserver(&observer_); |
756 EXPECT_CALL(observer_, OnInitializationComplete(_, _)). | 757 EXPECT_CALL(observer_, OnInitializationComplete(_, _, _)). |
757 WillOnce(SaveArg<0>(&js_backend_)); | 758 WillOnce(SaveArg<0>(&js_backend_)); |
758 | 759 |
759 EXPECT_FALSE(sync_notifier_observer_); | 760 EXPECT_FALSE(sync_notifier_observer_); |
760 EXPECT_FALSE(js_backend_.IsInitialized()); | 761 EXPECT_FALSE(js_backend_.IsInitialized()); |
761 | 762 |
762 std::vector<ModelSafeWorker*> workers; | 763 std::vector<ModelSafeWorker*> workers; |
763 ModelSafeRoutingInfo routing_info; | 764 ModelSafeRoutingInfo routing_info; |
764 GetModelSafeRoutingInfo(&routing_info); | 765 GetModelSafeRoutingInfo(&routing_info); |
765 | 766 |
766 // Takes ownership of |sync_notifier_mock_|. | 767 // Takes ownership of |sync_notifier_mock_|. |
767 sync_manager_.Init(temp_dir_.path(), | 768 sync_manager_.Init(temp_dir_.path(), |
768 WeakHandle<JsEventHandler>(), | 769 WeakHandle<JsEventHandler>(), |
769 "bogus", 0, false, | 770 "bogus", 0, false, |
770 base::MessageLoopProxy::current(), | 771 base::MessageLoopProxy::current(), |
771 scoped_ptr<HttpPostProviderFactory>( | 772 scoped_ptr<HttpPostProviderFactory>( |
772 new TestHttpPostProviderFactory()), | 773 new TestHttpPostProviderFactory()), |
773 routing_info, workers, | 774 workers, &extensions_activity_monitor_, this, |
774 &extensions_activity_monitor_, this, | |
775 credentials, | 775 credentials, |
776 scoped_ptr<SyncNotifier>(sync_notifier_mock_), | 776 scoped_ptr<SyncNotifier>(sync_notifier_mock_), |
777 "", | 777 "", |
778 syncer::SyncManager::TEST_IN_MEMORY, | 778 syncer::SyncManager::TEST_IN_MEMORY, |
779 &encryptor_, | 779 &encryptor_, |
780 &handler_, | 780 &handler_, |
781 NULL); | 781 NULL); |
782 | 782 |
783 EXPECT_TRUE(sync_notifier_observer_); | 783 EXPECT_TRUE(sync_notifier_observer_); |
784 EXPECT_TRUE(js_backend_.IsInitialized()); | 784 EXPECT_TRUE(js_backend_.IsInitialized()); |
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 // Ensure only bookmarks and nigori lost their progress marker. Preferences | 2606 // Ensure only bookmarks and nigori lost their progress marker. Preferences |
2607 // should still have it. | 2607 // should still have it. |
2608 partial_types = | 2608 partial_types = |
2609 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()); | 2609 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()); |
2610 EXPECT_TRUE(partial_types.Has(NIGORI)); | 2610 EXPECT_TRUE(partial_types.Has(NIGORI)); |
2611 EXPECT_TRUE(partial_types.Has(BOOKMARKS)); | 2611 EXPECT_TRUE(partial_types.Has(BOOKMARKS)); |
2612 EXPECT_FALSE(partial_types.Has(PREFERENCES)); | 2612 EXPECT_FALSE(partial_types.Has(PREFERENCES)); |
2613 } | 2613 } |
2614 | 2614 |
2615 } // namespace | 2615 } // namespace |
OLD | NEW |