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

Unified Diff: chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc

Issue 10702074: Refactor sync-specific parts out of SyncNotifier/SyncNotifierObserver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to HEAD Created 8 years, 5 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 | « chrome/browser/sync/glue/chrome_sync_notification_bridge.cc ('k') | sync/internal_api/sync_manager_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1b097ebab2eab9e148563651563360cf50ef2442..acf0898f554ec057eaeadb9fbfa0cb05e2c1d00b 100644
--- a/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
+++ b/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
@@ -44,7 +44,7 @@ class FakeSyncNotifierObserver : public syncer::SyncNotifierObserver {
FakeSyncNotifierObserver(
const scoped_refptr<base::SequencedTaskRunner>& sync_task_runner,
ChromeSyncNotificationBridge* bridge,
- const syncer::ModelTypePayloadMap& expected_payloads,
+ const syncer::ObjectIdPayloadMap& expected_payloads,
syncer::IncomingNotificationSource expected_source)
: sync_task_runner_(sync_task_runner),
bridge_(bridge),
@@ -53,17 +53,23 @@ class FakeSyncNotifierObserver : public syncer::SyncNotifierObserver {
expected_payloads_(expected_payloads),
expected_source_(expected_source) {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- bridge_->AddObserver(this);
+ // TODO(dcheng): We might want a function to go from ObjectIdPayloadMap ->
+ // ObjectIdSet to avoid this rather long incantation...
+ const syncer::ObjectIdSet& ids = syncer::ModelTypeSetToObjectIdSet(
+ syncer::ModelTypePayloadMapToEnumSet(
+ syncer::ObjectIdPayloadMapToModelTypePayloadMap(
+ expected_payloads)));
+ bridge_->UpdateRegisteredIds(this, ids);
}
virtual ~FakeSyncNotifierObserver() {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- 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(sync_task_runner_->RunsTasksOnCurrentThread());
notification_count_++;
@@ -71,7 +77,7 @@ class FakeSyncNotifierObserver : public syncer::SyncNotifierObserver {
LOG(ERROR) << "Received notification with wrong source";
received_improper_notification_ = true;
}
- if (expected_payloads_ != type_payloads) {
+ if (expected_payloads_ != id_payloads) {
LOG(ERROR) << "Received wrong payload";
received_improper_notification_ = true;
}
@@ -94,7 +100,7 @@ class FakeSyncNotifierObserver : public syncer::SyncNotifierObserver {
ChromeSyncNotificationBridge* const bridge_;
bool received_improper_notification_;
size_t notification_count_;
- const syncer::ModelTypePayloadMap expected_payloads_;
+ const syncer::ObjectIdPayloadMap expected_payloads_;
const syncer::IncomingNotificationSource expected_source_;
};
@@ -136,14 +142,16 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
}
void CreateObserverWithExpectations(
- syncer::ModelTypePayloadMap expected_payloads,
+ const syncer::ModelTypePayloadMap& expected_payloads,
syncer::IncomingNotificationSource expected_source) {
+ const syncer::ObjectIdPayloadMap& expected_id_payloads =
+ syncer::ModelTypePayloadMapToObjectIdPayloadMap(expected_payloads);
ASSERT_TRUE(sync_thread_.message_loop_proxy()->PostTask(
FROM_HERE,
base::Bind(
&ChromeSyncNotificationBridgeTest::CreateObserverOnSyncThread,
base::Unretained(this),
- expected_payloads,
+ expected_id_payloads,
expected_source)));
BlockForSyncThread();
}
@@ -182,7 +190,7 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
}
void CreateObserverOnSyncThread(
- syncer::ModelTypePayloadMap expected_payloads,
+ const syncer::ObjectIdPayloadMap& expected_payloads,
syncer::IncomingNotificationSource expected_source) {
DCHECK(sync_thread_.message_loop_proxy()->RunsTasksOnCurrentThread());
sync_observer_ = new FakeSyncNotifierObserver(
« no previous file with comments | « chrome/browser/sync/glue/chrome_sync_notification_bridge.cc ('k') | sync/internal_api/sync_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698