| Index: sync/notifier/invalidation_notifier_unittest.cc
|
| diff --git a/sync/notifier/invalidation_notifier_unittest.cc b/sync/notifier/invalidation_notifier_unittest.cc
|
| index 0329ad95861ac397726a527a72f5174cc7f2ebb9..ee08652dd394c68af0415a4f61854829dec0a01b 100644
|
| --- a/sync/notifier/invalidation_notifier_unittest.cc
|
| +++ b/sync/notifier/invalidation_notifier_unittest.cc
|
| @@ -24,6 +24,7 @@ namespace syncer {
|
| namespace {
|
|
|
| using ::testing::InSequence;
|
| +using ::testing::Return;
|
| using ::testing::StrictMock;
|
|
|
| class InvalidationNotifierTest : public testing::Test {
|
| @@ -50,11 +51,11 @@ class InvalidationNotifierTest : public testing::Test {
|
| initial_invalidation_state,
|
| syncer::MakeWeakHandle(mock_tracker_.AsWeakPtr()),
|
| "fake_client_info"));
|
| - invalidation_notifier_->AddObserver(&mock_observer_);
|
| + invalidation_notifier_->AddHandler(&mock_observer_);
|
| }
|
|
|
| void ResetNotifier() {
|
| - invalidation_notifier_->RemoveObserver(&mock_observer_);
|
| + invalidation_notifier_->RemoveHandler(&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.
|
| @@ -71,19 +72,28 @@ class InvalidationNotifierTest : public testing::Test {
|
| notifier::FakeBaseTask fake_base_task_;
|
| };
|
|
|
| +// TODO(dcheng): Need to add test cases testing attempts to add observers
|
| +// which register for the same object IDs as well as removing an observer
|
| +// clearing its object IDs.
|
| +
|
| TEST_F(InvalidationNotifierTest, Basic) {
|
| CreateAndObserveNotifier("fake_state");
|
| InSequence dummy;
|
|
|
| - syncer::ModelTypePayloadMap type_payloads;
|
| - type_payloads[syncer::PREFERENCES] = "payload";
|
| - type_payloads[syncer::BOOKMARKS] = "payload";
|
| - type_payloads[syncer::AUTOFILL] = "payload";
|
| + ModelTypeSet models(syncer::PREFERENCES,
|
| + syncer::BOOKMARKS,
|
| + syncer::AUTOFILL);
|
| + ModelTypePayloadMap type_payloads =
|
| + ModelTypePayloadMapFromEnumSet(models, "payload");
|
| +
|
| + EXPECT_CALL(mock_observer_, GetHandledIds())
|
| + .WillOnce(Return(ModelTypeSetToObjectIdSet(models)));
|
| + invalidation_notifier_->ReloadHandlers();
|
|
|
| EXPECT_CALL(mock_observer_, OnNotificationsEnabled());
|
| - EXPECT_CALL(mock_observer_,
|
| - OnIncomingNotification(type_payloads,
|
| - REMOTE_NOTIFICATION));
|
| + EXPECT_CALL(mock_observer_, OnIncomingNotification(
|
| + ModelTypePayloadMapToObjectIdPayloadMap(type_payloads),
|
| + REMOTE_NOTIFICATION));
|
| EXPECT_CALL(mock_observer_,
|
| OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR));
|
| EXPECT_CALL(mock_observer_,
|
| @@ -99,14 +109,8 @@ TEST_F(InvalidationNotifierTest, Basic) {
|
|
|
| invalidation_notifier_->OnNotificationsEnabled();
|
|
|
| - ObjectIdPayloadMap id_payloads;
|
| - for (syncer::ModelTypePayloadMap::const_iterator it = type_payloads.begin();
|
| - it != type_payloads.end(); ++it) {
|
| - invalidation::ObjectId id;
|
| - ASSERT_TRUE(RealModelTypeToObjectId(it->first, &id));
|
| - id_payloads[id] = "payload";
|
| - }
|
| - invalidation_notifier_->OnInvalidate(id_payloads);
|
| + invalidation_notifier_->OnInvalidate(
|
| + ModelTypePayloadMapToObjectIdPayloadMap(type_payloads));
|
|
|
| invalidation_notifier_->OnNotificationsDisabled(
|
| TRANSIENT_NOTIFICATION_ERROR);
|
|
|