| Index: chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
|
| diff --git a/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc b/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
|
| index ffd42fd6eea1e76ee1bbe028c166f802de0ecf31..667f5df01a485d8ad07d94c6ad80281b10aa3a49 100644
|
| --- a/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
|
| +++ b/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
|
| @@ -48,16 +48,18 @@ class FakeSyncNotifierObserverIO
|
| notification_count_(0),
|
| expected_payloads_(expected_payloads) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - bridge_->AddObserver(this);
|
| + bridge_->UpdateRegisteredIds(
|
| + this, ModelTypeSetToObjectIdSet(
|
| + ModelTypePayloadMapToEnumSet(expected_payloads)));
|
| }
|
| virtual ~FakeSyncNotifierObserverIO() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - bridge_->RemoveObserver(this);
|
| + bridge_->UpdateRegisteredIds(this, syncer::ObjectIdSet());
|
| }
|
|
|
| // SyncNotifierObserver implementation.
|
| virtual void OnIncomingNotification(
|
| - const syncer::ModelTypePayloadMap& type_payloads,
|
| + const syncer::ObjectIdPayloadMap& id_payloads,
|
| syncer::IncomingNotificationSource source) OVERRIDE {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| notification_count_++;
|
| @@ -65,7 +67,9 @@ class FakeSyncNotifierObserverIO
|
| LOG(ERROR) << "Received notification with wrong source.";
|
| received_improper_notification_ = true;
|
| }
|
| - if (expected_payloads_ != type_payloads) {
|
| + const syncer::ModelTypePayloadMap& actual_payloads =
|
| + syncer::ObjectIdPayloadMapToModelTypePayloadMap(id_payloads);
|
| + if (expected_payloads_ != actual_payloads) {
|
| LOG(ERROR) << "Received wrong payload.";
|
| received_improper_notification_ = true;
|
| }
|
| @@ -190,13 +194,14 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
|
| // Adds an observer on the UI thread, triggers a local refresh notification, and
|
| // ensures the bridge posts a LOCAL_NOTIFICATION with the proper payload to it.
|
| TEST_F(ChromeSyncNotificationBridgeTest, LocalNotification) {
|
| - syncer::ModelTypePayloadMap payload_map;
|
| - payload_map[syncer::SESSIONS] = "";
|
| + syncer::ModelTypeSet models(syncer::SESSIONS);
|
| + syncer::ModelTypePayloadMap payload_map =
|
| + ModelTypePayloadMapFromEnumSet(models, "payload");
|
| StrictMock<syncer::MockSyncNotifierObserver> observer;
|
| - EXPECT_CALL(observer,
|
| - OnIncomingNotification(payload_map,
|
| - syncer::LOCAL_NOTIFICATION));
|
| - bridge_.AddObserver(&observer);
|
| + EXPECT_CALL(observer, OnIncomingNotification(
|
| + ModelTypePayloadMapToObjectIdPayloadMap(payload_map),
|
| + syncer::LOCAL_NOTIFICATION));
|
| + bridge_.UpdateRegisteredIds(&observer, ModelTypeSetToObjectIdSet(models));
|
| TriggerRefreshNotification(chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
|
| payload_map);
|
| ui_loop_.RunAllPending();
|
| @@ -207,13 +212,14 @@ TEST_F(ChromeSyncNotificationBridgeTest, LocalNotification) {
|
| // and ensures the bridge posts a REMOTE_NOTIFICATION with the proper payload
|
| // to it.
|
| TEST_F(ChromeSyncNotificationBridgeTest, RemoteNotification) {
|
| - syncer::ModelTypePayloadMap payload_map;
|
| - payload_map[syncer::BOOKMARKS] = "";
|
| + syncer::ModelTypeSet models(syncer::BOOKMARKS);
|
| + syncer::ModelTypePayloadMap payload_map =
|
| + ModelTypePayloadMapFromEnumSet(models, "payload");
|
| StrictMock<syncer::MockSyncNotifierObserver> observer;
|
| - EXPECT_CALL(observer,
|
| - OnIncomingNotification(payload_map,
|
| - syncer::REMOTE_NOTIFICATION));
|
| - bridge_.AddObserver(&observer);
|
| + EXPECT_CALL(observer, OnIncomingNotification(
|
| + ModelTypePayloadMapToObjectIdPayloadMap(payload_map),
|
| + syncer::REMOTE_NOTIFICATION));
|
| + bridge_.UpdateRegisteredIds(&observer, ModelTypeSetToObjectIdSet(models));
|
| TriggerRefreshNotification(chrome::NOTIFICATION_SYNC_REFRESH_REMOTE,
|
| payload_map);
|
| ui_loop_.RunAllPending();
|
| @@ -230,10 +236,11 @@ TEST_F(ChromeSyncNotificationBridgeTest, LocalNotificationEmptyPayloadMap) {
|
| syncer::ModelTypePayloadMapFromEnumSet(enabled_types, std::string());
|
|
|
| StrictMock<syncer::MockSyncNotifierObserver> observer;
|
| - EXPECT_CALL(observer,
|
| - OnIncomingNotification(enabled_types_payload_map,
|
| - syncer::LOCAL_NOTIFICATION));
|
| - bridge_.AddObserver(&observer);
|
| + EXPECT_CALL(observer, OnIncomingNotification(
|
| + ModelTypePayloadMapToObjectIdPayloadMap(enabled_types_payload_map),
|
| + syncer::LOCAL_NOTIFICATION));
|
| + bridge_.UpdateRegisteredIds(&observer,
|
| + ModelTypeSetToObjectIdSet(enabled_types));
|
| // Set enabled types on the bridge.
|
| bridge_.UpdateEnabledTypes(enabled_types);
|
| TriggerRefreshNotification(chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
|
| @@ -252,10 +259,11 @@ TEST_F(ChromeSyncNotificationBridgeTest, RemoteNotificationEmptyPayloadMap) {
|
| syncer::ModelTypePayloadMapFromEnumSet(enabled_types, std::string());
|
|
|
| StrictMock<syncer::MockSyncNotifierObserver> observer;
|
| - EXPECT_CALL(observer,
|
| - OnIncomingNotification(enabled_types_payload_map,
|
| - syncer::REMOTE_NOTIFICATION));
|
| - bridge_.AddObserver(&observer);
|
| + EXPECT_CALL(observer, OnIncomingNotification(
|
| + ModelTypePayloadMapToObjectIdPayloadMap(enabled_types_payload_map),
|
| + syncer::REMOTE_NOTIFICATION));
|
| + bridge_.UpdateRegisteredIds(&observer,
|
| + ModelTypeSetToObjectIdSet(enabled_types));
|
| // Set enabled types on the bridge.
|
| bridge_.UpdateEnabledTypes(enabled_types);
|
| TriggerRefreshNotification(chrome::NOTIFICATION_SYNC_REFRESH_REMOTE,
|
|
|