Index: sync/notifier/invalidation_notifier_unittest.cc |
=================================================================== |
--- sync/notifier/invalidation_notifier_unittest.cc (revision 150991) |
+++ sync/notifier/invalidation_notifier_unittest.cc (working copy) |
@@ -33,10 +33,11 @@ |
ResetNotifier(); |
} |
- // 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( |
+ // 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( |
const std::string& initial_invalidation_state) { |
notifier::NotifierOptions notifier_options; |
// Note: URLRequestContextGetters are ref-counted. |
@@ -49,11 +50,10 @@ |
initial_invalidation_state, |
MakeWeakHandle(fake_tracker_.AsWeakPtr()), |
"fake_client_info")); |
- invalidation_notifier_->RegisterHandler(&mock_observer_); |
} |
void ResetNotifier() { |
- invalidation_notifier_->UnregisterHandler(&mock_observer_); |
+ invalidation_notifier_->UpdateRegisteredIds(&mock_observer_, ObjectIdSet()); |
// 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,11 +79,13 @@ |
}; |
TEST_F(InvalidationNotifierTest, Basic) { |
+ CreateAndObserveNotifier("fake_state"); |
InSequence dummy; |
- CreateNotifier("fake_state"); |
+ ModelTypeSet models(PREFERENCES, BOOKMARKS, AUTOFILL); |
+ invalidation_notifier_->UpdateRegisteredIds( |
+ &mock_observer_, ModelTypeSetToObjectIdSet(models)); |
- const ModelTypeSet models(PREFERENCES, BOOKMARKS, AUTOFILL); |
const ModelTypePayloadMap& type_payloads = |
ModelTypePayloadMapFromEnumSet(models, "payload"); |
EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); |
@@ -95,9 +97,6 @@ |
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"); |
@@ -119,7 +118,7 @@ |
} |
TEST_F(InvalidationNotifierTest, MigrateState) { |
- CreateNotifier(std::string()); |
+ CreateAndObserveNotifier(std::string()); |
SetStateDeprecated("fake_state"); |
EXPECT_EQ("fake_state", fake_tracker_.GetInvalidationState()); |
@@ -131,7 +130,7 @@ |
// Pretend Chrome shut down. |
ResetNotifier(); |
- CreateNotifier("fake_state"); |
+ CreateAndObserveNotifier("fake_state"); |
// Should do nothing. |
SetStateDeprecated("more_spurious_fake_state"); |
EXPECT_EQ("fake_state", fake_tracker_.GetInvalidationState()); |