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

Unified Diff: sync/notifier/invalidation_notifier_unittest.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work around brittle unit test 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
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());
« 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