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

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

Issue 10817023: [Sync] Pass the correct set of enabled types to the sync notifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 a2054c2131732040062aaff821bf8fdfbae8578d..1b097ebab2eab9e148563651563360cf50ef2442 100644
--- a/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
+++ b/chrome/browser/sync/glue/chrome_sync_notification_bridge_unittest.cc
@@ -126,6 +126,49 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
ADD_FAILURE() << "Sync Observer did not receive proper notification.";
}
+ void VerifyAndDestroyObserver() {
+ ASSERT_TRUE(sync_thread_.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&ChromeSyncNotificationBridgeTest::
+ VerifyAndDestroyObserverOnSyncThread,
+ base::Unretained(this))));
+ BlockForSyncThread();
+ }
+
+ void CreateObserverWithExpectations(
+ syncer::ModelTypePayloadMap expected_payloads,
+ syncer::IncomingNotificationSource expected_source) {
+ ASSERT_TRUE(sync_thread_.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &ChromeSyncNotificationBridgeTest::CreateObserverOnSyncThread,
+ base::Unretained(this),
+ expected_payloads,
+ expected_source)));
+ BlockForSyncThread();
+ }
+
+ void UpdateBridgeEnabledTypes(syncer::ModelTypeSet enabled_types) {
+ ASSERT_TRUE(sync_thread_.message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &ChromeSyncNotificationBridgeTest::
+ UpdateBridgeEnabledTypesOnSyncThread,
+ base::Unretained(this),
+ enabled_types)));
+ BlockForSyncThread();
+ }
+
+ void TriggerRefreshNotification(
+ int type,
+ const syncer::ModelTypePayloadMap& payload_map) {
+ content::NotificationService::current()->Notify(
+ type,
+ content::Source<Profile>(&mock_profile_),
+ content::Details<const syncer::ModelTypePayloadMap>(&payload_map));
+ }
+
+ private:
void VerifyAndDestroyObserverOnSyncThread() {
DCHECK(sync_thread_.message_loop_proxy()->RunsTasksOnCurrentThread());
if (!sync_observer_) {
@@ -138,15 +181,6 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
}
}
- void VerifyAndDestroyObserver() {
- ASSERT_TRUE(sync_thread_.message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(&ChromeSyncNotificationBridgeTest::
- VerifyAndDestroyObserverOnSyncThread,
- base::Unretained(this))));
- BlockForSyncThread();
- }
-
void CreateObserverOnSyncThread(
syncer::ModelTypePayloadMap expected_payloads,
syncer::IncomingNotificationSource expected_source) {
@@ -158,17 +192,10 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
expected_source);
}
- void CreateObserverWithExpectations(
- syncer::ModelTypePayloadMap expected_payloads,
- syncer::IncomingNotificationSource expected_source) {
- ASSERT_TRUE(sync_thread_.message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(
- &ChromeSyncNotificationBridgeTest::CreateObserverOnSyncThread,
- base::Unretained(this),
- expected_payloads,
- expected_source)));
- BlockForSyncThread();
+ void UpdateBridgeEnabledTypesOnSyncThread(
+ syncer::ModelTypeSet enabled_types) {
+ DCHECK(sync_thread_.message_loop_proxy()->RunsTasksOnCurrentThread());
+ bridge_->UpdateEnabledTypes(enabled_types);
}
void SignalOnSyncThread() {
@@ -184,19 +211,9 @@ class ChromeSyncNotificationBridgeTest : public testing::Test {
base::Unretained(this))));
done_.TimedWait(TestTimeouts::action_timeout());
if (!done_.IsSignaled())
- ADD_FAILURE() << "Timed out waiting for IO thread.";
+ ADD_FAILURE() << "Timed out waiting for sync thread.";
}
- void TriggerRefreshNotification(
- int type,
- const syncer::ModelTypePayloadMap& payload_map) {
- content::NotificationService::current()->Notify(
- type,
- content::Source<Profile>(&mock_profile_),
- content::Details<const syncer::ModelTypePayloadMap>(&payload_map));
- }
-
- private:
content::TestBrowserThread ui_thread_;
base::Thread sync_thread_;
NiceMock<ProfileMock> mock_profile_;
@@ -241,8 +258,9 @@ TEST_F(ChromeSyncNotificationBridgeTest, LocalNotificationEmptyPayloadMap) {
syncer::ModelTypePayloadMapFromEnumSet(enabled_types, std::string());
CreateObserverWithExpectations(
enabled_types_payload_map, syncer::LOCAL_NOTIFICATION);
+ UpdateBridgeEnabledTypes(enabled_types);
TriggerRefreshNotification(chrome::NOTIFICATION_SYNC_REFRESH_LOCAL,
- enabled_types_payload_map);
+ syncer::ModelTypePayloadMap());
VerifyAndDestroyObserver();
}
@@ -256,8 +274,9 @@ TEST_F(ChromeSyncNotificationBridgeTest, RemoteNotificationEmptyPayloadMap) {
syncer::ModelTypePayloadMapFromEnumSet(enabled_types, std::string());
CreateObserverWithExpectations(
enabled_types_payload_map, syncer::REMOTE_NOTIFICATION);
+ UpdateBridgeEnabledTypes(enabled_types);
TriggerRefreshNotification(chrome::NOTIFICATION_SYNC_REFRESH_REMOTE,
- enabled_types_payload_map);
+ syncer::ModelTypePayloadMap());
VerifyAndDestroyObserver();
}

Powered by Google App Engine
This is Rietveld 408576698