Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: sync/internal_api/syncapi_unittest.cc

Issue 10804039: Make SyncBackendRegistrar aware of loaded data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More init changes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 669 }
670 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE { 670 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE {
671 delete static_cast<TestHttpPostProviderInterface*>(http); 671 delete static_cast<TestHttpPostProviderInterface*>(http);
672 } 672 }
673 }; 673 };
674 674
675 class SyncManagerObserverMock : public SyncManager::Observer { 675 class SyncManagerObserverMock : public SyncManager::Observer {
676 public: 676 public:
677 MOCK_METHOD1(OnSyncCycleCompleted, 677 MOCK_METHOD1(OnSyncCycleCompleted,
678 void(const SyncSessionSnapshot&)); // NOLINT 678 void(const SyncSessionSnapshot&)); // NOLINT
679 MOCK_METHOD2(OnInitializationComplete, 679 MOCK_METHOD3(OnInitializationComplete,
680 void(const WeakHandle<JsBackend>&, bool)); // NOLINT 680 void(const WeakHandle<JsBackend>&, bool,
681 syncer::ModelTypeSet)); // NOLINT
681 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT 682 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT
682 MOCK_METHOD2(OnPassphraseRequired, 683 MOCK_METHOD2(OnPassphraseRequired,
683 void(PassphraseRequiredReason, 684 void(PassphraseRequiredReason,
684 const sync_pb::EncryptedData&)); // NOLINT 685 const sync_pb::EncryptedData&)); // NOLINT
685 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT 686 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT
686 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT 687 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT
687 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT 688 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT
688 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT 689 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT
689 MOCK_METHOD2(OnEncryptedTypesChanged, 690 MOCK_METHOD2(OnEncryptedTypesChanged,
690 void(ModelTypeSet, bool)); // NOLINT 691 void(ModelTypeSet, bool)); // NOLINT
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated("")); 748 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated(""));
748 EXPECT_CALL(*sync_notifier_mock_, 749 EXPECT_CALL(*sync_notifier_mock_,
749 UpdateCredentials(credentials.email, credentials.sync_token)); 750 UpdateCredentials(credentials.email, credentials.sync_token));
750 EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)). 751 EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)).
751 WillRepeatedly( 752 WillRepeatedly(
752 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes)); 753 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes));
753 EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)). 754 EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)).
754 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver)); 755 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver));
755 756
756 sync_manager_.AddObserver(&observer_); 757 sync_manager_.AddObserver(&observer_);
757 EXPECT_CALL(observer_, OnInitializationComplete(_, _)). 758 EXPECT_CALL(observer_, OnInitializationComplete(_, _, _)).
758 WillOnce(SaveArg<0>(&js_backend_)); 759 WillOnce(SaveArg<0>(&js_backend_));
759 760
760 EXPECT_FALSE(sync_notifier_observer_); 761 EXPECT_FALSE(sync_notifier_observer_);
761 EXPECT_FALSE(js_backend_.IsInitialized()); 762 EXPECT_FALSE(js_backend_.IsInitialized());
762 763
763 std::vector<ModelSafeWorker*> workers; 764 std::vector<ModelSafeWorker*> workers;
764 ModelSafeRoutingInfo routing_info; 765 ModelSafeRoutingInfo routing_info;
765 GetModelSafeRoutingInfo(&routing_info); 766 GetModelSafeRoutingInfo(&routing_info);
766 767
767 // Takes ownership of |sync_notifier_mock_|. 768 // Takes ownership of |sync_notifier_mock_|.
768 sync_manager_.Init(temp_dir_.path(), 769 sync_manager_.Init(temp_dir_.path(),
769 WeakHandle<JsEventHandler>(), 770 WeakHandle<JsEventHandler>(),
770 "bogus", 0, false, 771 "bogus", 0, false,
771 base::MessageLoopProxy::current(), 772 base::MessageLoopProxy::current(),
772 scoped_ptr<HttpPostProviderFactory>( 773 scoped_ptr<HttpPostProviderFactory>(
773 new TestHttpPostProviderFactory()), 774 new TestHttpPostProviderFactory()),
774 routing_info, workers, 775 workers, &extensions_activity_monitor_, this,
775 &extensions_activity_monitor_, this,
776 credentials, 776 credentials,
777 scoped_ptr<SyncNotifier>(sync_notifier_mock_), 777 scoped_ptr<SyncNotifier>(sync_notifier_mock_),
778 "", 778 "",
779 scoped_ptr<InternalComponentsFactory>(GetFactory()), 779 scoped_ptr<InternalComponentsFactory>(GetFactory()),
780 &encryptor_, 780 &encryptor_,
781 &handler_, 781 &handler_,
782 NULL); 782 NULL);
783 783
784 EXPECT_TRUE(sync_notifier_observer_); 784 EXPECT_TRUE(sync_notifier_observer_);
785 EXPECT_TRUE(js_backend_.IsInitialized()); 785 EXPECT_TRUE(js_backend_.IsInitialized());
(...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 // Ensure only bookmarks and nigori lost their progress marker. Preferences 2628 // Ensure only bookmarks and nigori lost their progress marker. Preferences
2629 // should still have it. 2629 // should still have it.
2630 partial_types = 2630 partial_types =
2631 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()); 2631 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All());
2632 EXPECT_TRUE(partial_types.Has(NIGORI)); 2632 EXPECT_TRUE(partial_types.Has(NIGORI));
2633 EXPECT_TRUE(partial_types.Has(BOOKMARKS)); 2633 EXPECT_TRUE(partial_types.Has(BOOKMARKS));
2634 EXPECT_FALSE(partial_types.Has(PREFERENCES)); 2634 EXPECT_FALSE(partial_types.Has(PREFERENCES));
2635 } 2635 }
2636 2636
2637 } // namespace 2637 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698