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

Unified Diff: sync/notifier/invalidation_notifier_unittest.cc

Issue 10824252: Revert 150990 - [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/notifier/invalidation_notifier.cc ('k') | sync/notifier/non_blocking_invalidation_notifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « sync/notifier/invalidation_notifier.cc ('k') | sync/notifier/non_blocking_invalidation_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698