Chromium Code Reviews| Index: sync/notifier/invalidation_notifier_unittest.cc |
| diff --git a/sync/notifier/invalidation_notifier_unittest.cc b/sync/notifier/invalidation_notifier_unittest.cc |
| index 4a076789b5501237b9b4c63c19a405ea45de2ffe..5da5eed4fa263a5debc8868058e3592c47623f9c 100644 |
| --- a/sync/notifier/invalidation_notifier_unittest.cc |
| +++ b/sync/notifier/invalidation_notifier_unittest.cc |
| @@ -26,6 +26,8 @@ namespace { |
| using ::testing::InSequence; |
| using ::testing::StrictMock; |
| +const char kHandlerName[] = "MockObserver"; |
| + |
| class InvalidationNotifierTest : public testing::Test { |
| protected: |
| virtual void TearDown() { |
| @@ -33,12 +35,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( |
| - const std::string& initial_invalidation_state) { |
| + // Constructs an InvalidationNotifier and places it in |
|
msw
2012/08/03 23:30:46
nit: line breaks :)
akalin
2012/08/07 07:25:19
Done.
|
| + // |invalidation_notifier_|. 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. |
| notifier_options.request_context_getter = |
| @@ -53,7 +53,7 @@ class InvalidationNotifierTest : public testing::Test { |
| } |
| void ResetNotifier() { |
| - invalidation_notifier_->UpdateRegisteredIds(&mock_observer_, ObjectIdSet()); |
| + invalidation_notifier_->SetHandler(kHandlerName, NULL); |
| // 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. |
| @@ -71,13 +71,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()); |
| @@ -88,6 +86,12 @@ TEST_F(InvalidationNotifierTest, Basic) { |
| OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR)); |
| EXPECT_CALL(mock_observer_, |
| OnNotificationsDisabled(NOTIFICATION_CREDENTIALS_REJECTED)); |
| + |
| + invalidation_notifier_->SetHandler(kHandlerName, &mock_observer_); |
| + |
| + invalidation_notifier_->UpdateRegisteredIds( |
| + kHandlerName, ModelTypeSetToObjectIdSet(models)); |
| + |
| // Note no expectation on mock_tracker_, as we initialized with |
| // non-empty initial_invalidation_state above. |
| @@ -109,9 +113,10 @@ TEST_F(InvalidationNotifierTest, Basic) { |
| } |
| TEST_F(InvalidationNotifierTest, MigrateState) { |
| - CreateAndObserveNotifier(std::string()); |
| InSequence dummy; |
| + CreateNotifier(std::string()); |
| + |
| EXPECT_CALL(mock_tracker_, SetInvalidationState("fake_state")); |
| invalidation_notifier_->SetStateDeprecated("fake_state"); |
| @@ -121,7 +126,7 @@ TEST_F(InvalidationNotifierTest, MigrateState) { |
| // Pretend Chrome shut down. |
| ResetNotifier(); |
| - CreateAndObserveNotifier("fake_state"); |
| + CreateNotifier("fake_state"); |
| // Should do nothing. |
| invalidation_notifier_->SetStateDeprecated("more_spurious_fake_state"); |
| } |