Commit 140cf0d9 authored by akalin@chromium.org's avatar akalin@chromium.org

[Sync] Make P2PNotifier emit a notification only if some enabled types changed

Relaxed some integrations tests that failed because of this.  A client
with type X disabled shouldn't be expected to quiesce with other clients
that with X enabled given a change to X.

Cleaned up indentation in preferences integration test.

BUG=138893
TEST=


Review URL: https://chromiumcodereview.appspot.com/10833004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148379 0039d316-1c4b-4281-b951-d872f2087c98
parent 54a37cdc
......@@ -295,7 +295,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, DisableApps) {
ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::APPS));
InstallApp(GetProfile(0), 0);
InstallApp(verifier(), 0);
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Installed an app."));
ASSERT_TRUE(HasSameAppsAsVerifier(0));
ASSERT_FALSE(HasSameAppsAsVerifier(1));
......
......@@ -1572,7 +1572,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, MC_DeleteBookmark) {
ASSERT_TRUE(AddURL(0, GetBookmarkBarNode(0), 0, L"bar", bar_url) != NULL);
ASSERT_TRUE(AddURL(0, GetOtherNode(0), 0, L"other", other_url) != NULL);
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Added a bookmark."));
ASSERT_TRUE(HasNodeWithURL(0, bar_url));
ASSERT_TRUE(HasNodeWithURL(0, other_url));
......@@ -1580,7 +1580,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest, MC_DeleteBookmark) {
ASSERT_FALSE(HasNodeWithURL(1, other_url));
Remove(0, GetBookmarkBarNode(0), 0);
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Removed a bookmark."));
ASSERT_FALSE(HasNodeWithURL(0, bar_url));
ASSERT_TRUE(HasNodeWithURL(0, other_url));
......
......@@ -247,7 +247,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest, DisableExtensions) {
ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::EXTENSIONS));
InstallExtension(GetProfile(0), 1);
InstallExtension(verifier(), 1);
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(
GetClient(0)->AwaitFullSyncCompletion("Installed an extension."));
ASSERT_FALSE(AllProfilesHaveSameExtensionsAsVerifier());
ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::EXTENSIONS));
......
......@@ -80,7 +80,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, DisablePasswords) {
AddLogin(GetPasswordStore(0), form);
ASSERT_EQ(1, GetPasswordCount(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Added a password."));
ASSERT_TRUE(ProfileContainsSamePasswordFormsAsVerifier(0));
ASSERT_FALSE(ProfileContainsSamePasswordFormsAsVerifier(1));
......
......@@ -202,7 +202,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DisableThemes) {
ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::THEMES));
UseCustomTheme(GetProfile(0), 0);
UseCustomTheme(verifier(), 0);
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Changed the theme."));
ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
......
......@@ -201,7 +201,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientTypedUrlsSyncTest, DisableEnableSync) {
GURL url2(kUrl2);
AddUrlToHistory(0, url1);
AddUrlToHistory(1, url2);
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(GetClient(1)->AwaitFullSyncCompletion("Added a typed url."));
// Make sure that no data was exchanged.
history::URLRows post_sync_urls = GetTypedUrlsFromClient(0);
......
......@@ -260,13 +260,14 @@ void P2PNotifier::OnIncomingNotification(
<< "not emitting notification";
return;
}
if (notification_data.GetChangedTypes().Empty()) {
DVLOG(1) << "No changed types -- not emitting notification";
const ModelTypeSet types_to_notify =
Intersection(enabled_types_, notification_data.GetChangedTypes());
if (types_to_notify.Empty()) {
DVLOG(1) << "No enabled and changed types -- not emitting notification";
return;
}
const ModelTypePayloadMap& type_payloads =
ModelTypePayloadMapFromEnumSet(
notification_data.GetChangedTypes(), std::string());
ModelTypePayloadMapFromEnumSet(types_to_notify, std::string());
FOR_EACH_OBSERVER(SyncNotifierObserver, observer_list_,
OnIncomingNotification(type_payloads, REMOTE_NOTIFICATION));
}
......
......@@ -182,12 +182,12 @@ TEST_F(P2PNotifierTest, NotificationsBasic) {
// target settings. The notifications received by the observer should
// be consistent with the target settings.
TEST_F(P2PNotifierTest, SendNotificationData) {
ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES);
ModelTypeSet enabled_types(BOOKMARKS, PREFERENCES, THEMES);
ModelTypeSet changed_types(THEMES, APPS);
ModelTypeSet expected_types(THEMES);
const ModelTypePayloadMap& changed_payload_map =
MakePayloadMap(changed_types);
const ModelTypePayloadMap& expected_payload_map =
MakePayloadMap(expected_types);
EXPECT_CALL(mock_observer_, OnNotificationsEnabled());
EXPECT_CALL(mock_observer_,
......@@ -211,7 +211,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_SELF, changed_types));
......@@ -240,7 +240,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_OTHERS, changed_types));
......@@ -256,7 +256,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender", NOTIFY_ALL, changed_types));
......@@ -265,7 +265,7 @@ TEST_F(P2PNotifierTest, SendNotificationData) {
// Should be propagated.
Mock::VerifyAndClearExpectations(&mock_observer_);
EXPECT_CALL(mock_observer_, OnIncomingNotification(changed_payload_map,
EXPECT_CALL(mock_observer_, OnIncomingNotification(expected_payload_map,
REMOTE_NOTIFICATION));
p2p_notifier_.SendNotificationDataForTest(
P2PNotificationData("sender2", NOTIFY_ALL, changed_types));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment