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

Side by Side Diff: chrome/browser/sync/engine/syncapi_unittest.cc

Issue 6794005: Move sync notifier contruction out of syncer thread. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase Created 9 years, 8 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
« no previous file with comments | « chrome/browser/sync/engine/syncapi.cc ('k') | chrome/browser/sync/glue/sync_backend_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <map> 9 #include <map>
10 10
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 update_enabled_types_call_count_(0) {} 646 update_enabled_types_call_count_(0) {}
647 647
648 // Test implementation. 648 // Test implementation.
649 void SetUp() { 649 void SetUp() {
650 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 650 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
651 651
652 SyncCredentials credentials; 652 SyncCredentials credentials;
653 credentials.email = "foo@bar.com"; 653 credentials.email = "foo@bar.com";
654 credentials.sync_token = "sometoken"; 654 credentials.sync_token = "sometoken";
655 655
656 scoped_ptr<StrictMock<SyncNotifierMock> > sync_notifier_mock( 656 sync_notifier_mock_.reset(new StrictMock<SyncNotifierMock>());
657 new StrictMock<SyncNotifierMock>()); 657 EXPECT_CALL(*sync_notifier_mock_, AddObserver(_)).
658 EXPECT_CALL(*sync_notifier_mock, AddObserver(_)).
659 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierAddObserver)); 658 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierAddObserver));
660 EXPECT_CALL(*sync_notifier_mock, SetState("")); 659 EXPECT_CALL(*sync_notifier_mock_, SetState(""));
661 EXPECT_CALL(*sync_notifier_mock, 660 EXPECT_CALL(*sync_notifier_mock_,
662 UpdateCredentials(credentials.email, credentials.sync_token)); 661 UpdateCredentials(credentials.email, credentials.sync_token));
663 EXPECT_CALL(*sync_notifier_mock, UpdateEnabledTypes(_)). 662 EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)).
664 Times(AtLeast(1)). 663 Times(AtLeast(1)).
665 WillRepeatedly( 664 WillRepeatedly(
666 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes)); 665 Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes));
667 EXPECT_CALL(*sync_notifier_mock, RemoveObserver(_)). 666 EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)).
668 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver)); 667 WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver));
669 668
670 EXPECT_FALSE(sync_notifier_observer_); 669 EXPECT_FALSE(sync_notifier_observer_);
671 670
672 sync_manager_.Init(temp_dir_.path(), "bogus", 0, false, 671 sync_manager_.Init(temp_dir_.path(), "bogus", 0, false,
673 new TestHttpPostProviderFactory(), this, "bogus", 672 new TestHttpPostProviderFactory(), this, "bogus",
674 credentials, sync_notifier_mock.release(), "", 673 credentials, sync_notifier_mock_.get(), "",
675 true /* setup_for_test_mode */); 674 true /* setup_for_test_mode */);
676 675
677 EXPECT_TRUE(sync_notifier_observer_); 676 EXPECT_TRUE(sync_notifier_observer_);
678 sync_manager_.AddObserver(&observer_); 677 sync_manager_.AddObserver(&observer_);
679 678
680 EXPECT_EQ(1, update_enabled_types_call_count_); 679 EXPECT_EQ(1, update_enabled_types_call_count_);
681 680
682 ModelSafeRoutingInfo routes; 681 ModelSafeRoutingInfo routes;
683 GetModelSafeRoutingInfo(&routes); 682 GetModelSafeRoutingInfo(&routes);
684 for (ModelSafeRoutingInfo::iterator i = routes.begin(); i != routes.end(); 683 for (ModelSafeRoutingInfo::iterator i = routes.begin(); i != routes.end();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 766
768 private: 767 private:
769 // Needed by |ui_thread_|. 768 // Needed by |ui_thread_|.
770 MessageLoopForUI ui_loop_; 769 MessageLoopForUI ui_loop_;
771 // Needed by |sync_manager_|. 770 // Needed by |sync_manager_|.
772 BrowserThread ui_thread_; 771 BrowserThread ui_thread_;
773 // Needed by |sync_manager_|. 772 // Needed by |sync_manager_|.
774 ScopedTempDir temp_dir_; 773 ScopedTempDir temp_dir_;
775 // Sync Id's for the roots of the enabled datatypes. 774 // Sync Id's for the roots of the enabled datatypes.
776 std::map<ModelType, int64> type_roots_; 775 std::map<ModelType, int64> type_roots_;
776 scoped_ptr<StrictMock<SyncNotifierMock> > sync_notifier_mock_;
777 777
778 protected: 778 protected:
779 SyncManager sync_manager_; 779 SyncManager sync_manager_;
780 StrictMock<SyncManagerObserverMock> observer_; 780 StrictMock<SyncManagerObserverMock> observer_;
781 sync_notifier::SyncNotifierObserver* sync_notifier_observer_; 781 sync_notifier::SyncNotifierObserver* sync_notifier_observer_;
782 int update_enabled_types_call_count_; 782 int update_enabled_types_call_count_;
783 }; 783 };
784 784
785 TEST_F(SyncManagerTest, UpdateEnabledTypes) { 785 TEST_F(SyncManagerTest, UpdateEnabledTypes) {
786 EXPECT_EQ(1, update_enabled_types_call_count_); 786 EXPECT_EQ(1, update_enabled_types_call_count_);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 true /* is encrypted */)); 1135 true /* is encrypted */));
1136 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), 1136 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(),
1137 syncable::THEMES, 1137 syncable::THEMES,
1138 false /* not encrypted */)); 1138 false /* not encrypted */));
1139 } 1139 }
1140 } 1140 }
1141 1141
1142 } // namespace 1142 } // namespace
1143 1143
1144 } // namespace browser_sync 1144 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi.cc ('k') | chrome/browser/sync/glue/sync_backend_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698