| Index: sync/internal_api/syncapi_unittest.cc
|
| diff --git a/sync/internal_api/syncapi_unittest.cc b/sync/internal_api/syncapi_unittest.cc
|
| index 3a384693e0b5195a45a914f824bda21b4eab874a..9d000c6a61bd49f3c48f4cd5ef1a49b3154006c2 100644
|
| --- a/sync/internal_api/syncapi_unittest.cc
|
| +++ b/sync/internal_api/syncapi_unittest.cc
|
| @@ -694,14 +694,12 @@ class SyncManagerObserverMock : public SyncManager::Observer {
|
|
|
| class SyncNotifierMock : public syncer::SyncNotifier {
|
| public:
|
| - MOCK_METHOD1(AddObserver, void(syncer::SyncNotifierObserver*));
|
| - MOCK_METHOD1(RemoveObserver, void(syncer::SyncNotifierObserver*));
|
| + MOCK_METHOD2(UpdateRegisteredIds, void(SyncNotifierObserver*,
|
| + const ObjectIdSet&));
|
| MOCK_METHOD1(SetUniqueId, void(const std::string&));
|
| MOCK_METHOD1(SetStateDeprecated, void(const std::string&));
|
| MOCK_METHOD2(UpdateCredentials,
|
| void(const std::string&, const std::string&));
|
| - MOCK_METHOD1(UpdateEnabledTypes,
|
| - void(syncer::ModelTypeSet));
|
| MOCK_METHOD1(SendNotification, void(syncer::ModelTypeSet));
|
| };
|
|
|
| @@ -723,9 +721,7 @@ class SyncManagerTest : public testing::Test,
|
|
|
| SyncManagerTest()
|
| : sync_notifier_mock_(NULL),
|
| - sync_manager_("Test sync manager"),
|
| - sync_notifier_observer_(NULL),
|
| - update_enabled_types_call_count_(0) {}
|
| + sync_manager_("Test sync manager") {}
|
|
|
| virtual ~SyncManagerTest() {
|
| EXPECT_FALSE(sync_notifier_mock_);
|
| @@ -740,23 +736,15 @@ class SyncManagerTest : public testing::Test,
|
| credentials.sync_token = "sometoken";
|
|
|
| sync_notifier_mock_ = new StrictMock<SyncNotifierMock>();
|
| - EXPECT_CALL(*sync_notifier_mock_, AddObserver(_)).
|
| - WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierAddObserver));
|
| EXPECT_CALL(*sync_notifier_mock_, SetUniqueId(_));
|
| EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated(""));
|
| EXPECT_CALL(*sync_notifier_mock_,
|
| UpdateCredentials(credentials.email, credentials.sync_token));
|
| - EXPECT_CALL(*sync_notifier_mock_, UpdateEnabledTypes(_)).
|
| - WillRepeatedly(
|
| - Invoke(this, &SyncManagerTest::SyncNotifierUpdateEnabledTypes));
|
| - EXPECT_CALL(*sync_notifier_mock_, RemoveObserver(_)).
|
| - WillOnce(Invoke(this, &SyncManagerTest::SyncNotifierRemoveObserver));
|
|
|
| sync_manager_.AddObserver(&observer_);
|
| EXPECT_CALL(observer_, OnInitializationComplete(_, _)).
|
| WillOnce(SaveArg<0>(&js_backend_));
|
|
|
| - EXPECT_FALSE(sync_notifier_observer_);
|
| EXPECT_FALSE(js_backend_.IsInitialized());
|
|
|
| std::vector<ModelSafeWorker*> workers;
|
| @@ -780,11 +768,8 @@ class SyncManagerTest : public testing::Test,
|
| &handler_,
|
| NULL);
|
|
|
| - EXPECT_TRUE(sync_notifier_observer_);
|
| EXPECT_TRUE(js_backend_.IsInitialized());
|
|
|
| - EXPECT_EQ(0, update_enabled_types_call_count_);
|
| -
|
| for (ModelSafeRoutingInfo::iterator i = routing_info.begin();
|
| i != routing_info.end(); ++i) {
|
| type_roots_[i->first] = MakeServerNodeForType(
|
| @@ -795,9 +780,10 @@ class SyncManagerTest : public testing::Test,
|
|
|
| void TearDown() {
|
| sync_manager_.RemoveObserver(&observer_);
|
| + EXPECT_CALL(*sync_notifier_mock_,
|
| + UpdateRegisteredIds(_, ObjectIdSet()));
|
| sync_manager_.ShutdownOnSyncThread();
|
| sync_notifier_mock_ = NULL;
|
| - EXPECT_FALSE(sync_notifier_observer_);
|
| PumpLoop();
|
| }
|
|
|
| @@ -858,26 +844,6 @@ class SyncManagerTest : public testing::Test,
|
| return type_roots_[type];
|
| }
|
|
|
| - void SyncNotifierAddObserver(
|
| - syncer::SyncNotifierObserver* sync_notifier_observer) {
|
| - EXPECT_EQ(NULL, sync_notifier_observer_);
|
| - sync_notifier_observer_ = sync_notifier_observer;
|
| - }
|
| -
|
| - void SyncNotifierRemoveObserver(
|
| - syncer::SyncNotifierObserver* sync_notifier_observer) {
|
| - EXPECT_EQ(sync_notifier_observer_, sync_notifier_observer);
|
| - sync_notifier_observer_ = NULL;
|
| - }
|
| -
|
| - void SyncNotifierUpdateEnabledTypes(syncer::ModelTypeSet types) {
|
| - ModelSafeRoutingInfo routes;
|
| - GetModelSafeRoutingInfo(&routes);
|
| - const syncer::ModelTypeSet expected_types = GetRoutingInfoTypes(routes);
|
| - EXPECT_TRUE(types.Equals(expected_types));
|
| - ++update_enabled_types_call_count_;
|
| - }
|
| -
|
| void PumpLoop() {
|
| message_loop_.RunAllPending();
|
| }
|
| @@ -925,27 +891,24 @@ class SyncManagerTest : public testing::Test,
|
| // Sync Id's for the roots of the enabled datatypes.
|
| std::map<ModelType, int64> type_roots_;
|
| FakeExtensionsActivityMonitor extensions_activity_monitor_;
|
| - StrictMock<SyncNotifierMock>* sync_notifier_mock_;
|
|
|
| protected:
|
| FakeEncryptor encryptor_;
|
| TestUnrecoverableErrorHandler handler_;
|
| + StrictMock<SyncNotifierMock>* sync_notifier_mock_;
|
| SyncManagerImpl sync_manager_;
|
| WeakHandle<JsBackend> js_backend_;
|
| StrictMock<SyncManagerObserverMock> observer_;
|
| - syncer::SyncNotifierObserver* sync_notifier_observer_;
|
| - int update_enabled_types_call_count_;
|
| };
|
|
|
| TEST_F(SyncManagerTest, UpdateEnabledTypes) {
|
| - EXPECT_EQ(0, update_enabled_types_call_count_);
|
| -
|
| ModelSafeRoutingInfo routes;
|
| GetModelSafeRoutingInfo(&routes);
|
| const syncer::ModelTypeSet enabled_types = GetRoutingInfoTypes(routes);
|
|
|
| + EXPECT_CALL(*sync_notifier_mock_,
|
| + UpdateRegisteredIds(_, ModelTypeSetToObjectIdSet(enabled_types)));
|
| sync_manager_.UpdateEnabledTypes(enabled_types);
|
| - EXPECT_EQ(1, update_enabled_types_call_count_);
|
| }
|
|
|
| TEST_F(SyncManagerTest, ProcessJsMessage) {
|
|
|