Index: sync/notifier/invalidation_notifier_unittest.cc |
diff --git a/sync/notifier/invalidation_notifier_unittest.cc b/sync/notifier/invalidation_notifier_unittest.cc |
index ded6bab0d838f994fb880e70f0ba309021c96537..973c26f95a394d5a21b1819808c0ea481e6845a0 100644 |
--- a/sync/notifier/invalidation_notifier_unittest.cc |
+++ b/sync/notifier/invalidation_notifier_unittest.cc |
@@ -33,11 +33,10 @@ class InvalidationNotifierTest : public testing::Test { |
ResetNotifier(); |
} |
- // Constructs an InvalidationNotifier, places it in |
- // |invalidation_notifier_|, and adds |mock_observer_| as an observer. This |
- // remains in place until either TearDown (automatic) or ResetNotifier |
- // (manual) is called. |
- void CreateAndObserveNotifier( |
+ // Constructs an InvalidationNotifier, places it in |invalidation_notifier_|, |
+ // and registers |mock_observer_| as a handler. This remains in place until |
+ // either TearDown (automatic) or ResetNotifier (manual) is called. |
+ void CreateNotifier( |
const std::string& initial_invalidation_state) { |
notifier::NotifierOptions notifier_options; |
// Note: URLRequestContextGetters are ref-counted. |
@@ -50,10 +49,11 @@ class InvalidationNotifierTest : public testing::Test { |
initial_invalidation_state, |
MakeWeakHandle(fake_tracker_.AsWeakPtr()), |
"fake_client_info")); |
+ invalidation_notifier_->RegisterHandler(&mock_observer_); |
} |
void ResetNotifier() { |
- invalidation_notifier_->UpdateRegisteredIds(&mock_observer_, ObjectIdSet()); |
+ invalidation_notifier_->UnregisterHandler(&mock_observer_); |
// Stopping the invalidation notifier stops its scheduler, which deletes any |
// pending tasks without running them. Some tasks "run and delete" another |
// task, so they must be run in order to avoid leaking the inner task. |
@@ -79,13 +79,11 @@ class InvalidationNotifierTest : public testing::Test { |
}; |
TEST_F(InvalidationNotifierTest, Basic) { |
- CreateAndObserveNotifier("fake_state"); |
InSequence dummy; |
- ModelTypeSet models(PREFERENCES, BOOKMARKS, AUTOFILL); |
- invalidation_notifier_->UpdateRegisteredIds( |
- &mock_observer_, ModelTypeSetToObjectIdSet(models)); |
+ CreateNotifier("fake_state"); |
+ const ModelTypeSet models(PREFERENCES, BOOKMARKS, AUTOFILL); |
const ModelTypePayloadMap& type_payloads = |
ModelTypePayloadMapFromEnumSet(models, "payload"); |
EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); |
@@ -97,6 +95,9 @@ TEST_F(InvalidationNotifierTest, Basic) { |
EXPECT_CALL(mock_observer_, |
OnNotificationsDisabled(NOTIFICATION_CREDENTIALS_REJECTED)); |
+ invalidation_notifier_->UpdateRegisteredIds( |
+ &mock_observer_, ModelTypeSetToObjectIdSet(models)); |
+ |
// TODO(tim): This call should be a no-op, Remove once bug 124140 and |
// associated issues are fixed. |
invalidation_notifier_->SetStateDeprecated("fake_state"); |
@@ -118,7 +119,7 @@ TEST_F(InvalidationNotifierTest, Basic) { |
} |
TEST_F(InvalidationNotifierTest, MigrateState) { |
- CreateAndObserveNotifier(std::string()); |
+ CreateNotifier(std::string()); |
SetStateDeprecated("fake_state"); |
EXPECT_EQ("fake_state", fake_tracker_.GetInvalidationState()); |
@@ -130,7 +131,7 @@ TEST_F(InvalidationNotifierTest, MigrateState) { |
// Pretend Chrome shut down. |
ResetNotifier(); |
- CreateAndObserveNotifier("fake_state"); |
+ CreateNotifier("fake_state"); |
// Should do nothing. |
SetStateDeprecated("more_spurious_fake_state"); |
EXPECT_EQ("fake_state", fake_tracker_.GetInvalidationState()); |