1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/values.h"
6 #include "chrome/browser/sync/profile_sync_service_harness.h"
7 #include "chrome/browser/sync/test/integration/preferences_helper.h"
8 #include "chrome/browser/sync/test/integration/sync_test.h"
9 #include "chrome/browser/translate/translate_prefs.h"
10 #include "chrome/common/pref_names.h"
12 using preferences_helper::AppendStringPref;
13 using preferences_helper::BooleanPrefMatches;
14 using preferences_helper::ChangeBooleanPref;
15 using preferences_helper::ChangeIntegerPref;
16 using preferences_helper::ChangeInt64Pref;
17 using preferences_helper::ChangeListPref;
18 using preferences_helper::ChangeStringPref;
19 using preferences_helper::GetPrefs;
20 using preferences_helper::IntegerPrefMatches;
21 using preferences_helper::Int64PrefMatches;
22 using preferences_helper::ListPrefMatches;
23 using preferences_helper::StringPrefMatches;
25 class TwoClientPreferencesSyncTest : public SyncTest {
27 TwoClientPreferencesSyncTest() : SyncTest(TWO_CLIENT) {}
28 virtual ~TwoClientPreferencesSyncTest() {}
31 DISALLOW_COPY_AND_ASSIGN(TwoClientPreferencesSyncTest);
35 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
36 kHomePageIsNewTabPage) {
37 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
38 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
40 ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
41 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
42 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
46 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, Race) {
47 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
50 ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
52 ChangeStringPref(0, prefs::kHomePage, "http://www.google.com/0");
53 ChangeStringPref(1, prefs::kHomePage,"http://www.google.com/1");
54 ASSERT_TRUE(AwaitQuiescence());
55 ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
59 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
60 kPasswordManagerEnabled) {
61 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
62 ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
64 ChangeBooleanPref(0, prefs::kPasswordManagerEnabled);
65 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
66 ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
70 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
71 kSyncKeepEverythingSynced) {
72 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
75 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced));
76 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncThemes));
78 GetClient(0)->DisableSyncForDatatype(syncer::THEMES);
79 ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced));
83 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, DisablePreferences) {
84 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
87 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences));
88 ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
90 GetClient(1)->DisableSyncForDatatype(syncer::PREFERENCES);
91 ChangeBooleanPref(0, prefs::kPasswordManagerEnabled);
92 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Changed a preference."));
93 ASSERT_FALSE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
95 GetClient(1)->EnableSyncForDatatype(syncer::PREFERENCES);
96 ASSERT_TRUE(AwaitQuiescence());
97 ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
101 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, DisableSync) {
102 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
105 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences));
106 ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
107 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
109 GetClient(1)->DisableSyncForAllDatatypes();
110 ChangeBooleanPref(0, prefs::kPasswordManagerEnabled);
111 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Changed a preference."));
112 ASSERT_FALSE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
114 ChangeBooleanPref(1, prefs::kShowHomeButton);
115 ASSERT_FALSE(BooleanPrefMatches(prefs::kShowHomeButton));
117 GetClient(1)->EnableSyncForAllDatatypes();
118 ASSERT_TRUE(AwaitQuiescence());
119 ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
120 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
124 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, SignInDialog) {
125 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
128 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences));
129 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncBookmarks));
130 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncThemes));
131 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncExtensions));
132 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncAutofill));
133 ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced));
135 GetClient(0)->DisableSyncForDatatype(syncer::PREFERENCES);
136 GetClient(1)->EnableSyncForDatatype(syncer::PREFERENCES);
137 GetClient(0)->DisableSyncForDatatype(syncer::AUTOFILL);
138 GetClient(1)->EnableSyncForDatatype(syncer::AUTOFILL);
139 GetClient(0)->DisableSyncForDatatype(syncer::BOOKMARKS);
140 GetClient(1)->EnableSyncForDatatype(syncer::BOOKMARKS);
141 GetClient(0)->DisableSyncForDatatype(syncer::EXTENSIONS);
142 GetClient(1)->EnableSyncForDatatype(syncer::EXTENSIONS);
143 GetClient(0)->DisableSyncForDatatype(syncer::THEMES);
144 GetClient(1)->EnableSyncForDatatype(syncer::THEMES);
146 ASSERT_TRUE(AwaitQuiescence());
148 ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncPreferences));
149 ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncBookmarks));
150 ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncThemes));
151 ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncExtensions));
152 ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncAutofill));
153 ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced));
157 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kShowBookmarkBar) {
158 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
159 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowBookmarkBar));
161 ChangeBooleanPref(0, prefs::kShowBookmarkBar);
162 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
163 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowBookmarkBar));
167 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kCheckDefaultBrowser) {
168 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
171 ASSERT_TRUE(BooleanPrefMatches(prefs::kCheckDefaultBrowser));
173 ChangeBooleanPref(0, prefs::kCheckDefaultBrowser);
174 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
175 ASSERT_FALSE(BooleanPrefMatches(prefs::kCheckDefaultBrowser));
179 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kHomePage) {
180 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
181 ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
183 ChangeStringPref(0, prefs::kHomePage, "http://news.google.com");
184 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
185 ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
189 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kShowHomeButton) {
190 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
191 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
193 ChangeBooleanPref(0, prefs::kShowHomeButton);
194 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
195 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
199 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kEnableTranslate) {
200 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
201 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
203 ChangeBooleanPref(0, prefs::kEnableTranslate);
204 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
205 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
209 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kAutofillEnabled) {
210 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
211 ASSERT_TRUE(BooleanPrefMatches(autofill::prefs::kAutofillEnabled));
213 ChangeBooleanPref(0, autofill::prefs::kAutofillEnabled);
214 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
215 ASSERT_TRUE(BooleanPrefMatches(autofill::prefs::kAutofillEnabled));
219 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
220 kURLsToRestoreOnStartup) {
221 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
222 ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
223 ASSERT_TRUE(ListPrefMatches(prefs::kURLsToRestoreOnStartup));
225 ChangeIntegerPref(0, prefs::kRestoreOnStartup, 0);
226 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
227 ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
230 urls.Append(Value::CreateStringValue("http://www.google.com/"));
231 urls.Append(Value::CreateStringValue("http://www.flickr.com/"));
232 ChangeIntegerPref(0, prefs::kRestoreOnStartup, 4);
233 ChangeListPref(0, prefs::kURLsToRestoreOnStartup, urls);
234 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
235 ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
236 ASSERT_TRUE(ListPrefMatches(prefs::kURLsToRestoreOnStartup));
240 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kRestoreOnStartup) {
241 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
242 ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
244 ChangeIntegerPref(0, prefs::kRestoreOnStartup, 1);
245 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
246 ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
250 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, Privacy) {
251 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
254 ASSERT_TRUE(BooleanPrefMatches(prefs::kAlternateErrorPagesEnabled));
255 ASSERT_TRUE(BooleanPrefMatches(prefs::kSearchSuggestEnabled));
256 ASSERT_TRUE(BooleanPrefMatches(prefs::kNetworkPredictionEnabled));
257 ASSERT_TRUE(BooleanPrefMatches(prefs::kSafeBrowsingEnabled));
259 ChangeBooleanPref(0, prefs::kAlternateErrorPagesEnabled);
260 ChangeBooleanPref(0, prefs::kSearchSuggestEnabled);
261 ChangeBooleanPref(0, prefs::kNetworkPredictionEnabled);
262 ChangeBooleanPref(0, prefs::kSafeBrowsingEnabled);
263 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
264 ASSERT_TRUE(BooleanPrefMatches(prefs::kAlternateErrorPagesEnabled));
265 ASSERT_TRUE(BooleanPrefMatches(prefs::kSearchSuggestEnabled));
266 ASSERT_TRUE(BooleanPrefMatches(prefs::kNetworkPredictionEnabled));
267 ASSERT_TRUE(BooleanPrefMatches(prefs::kSafeBrowsingEnabled));
271 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, ClearData) {
272 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
275 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteBrowsingHistory));
276 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteDownloadHistory));
277 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteCache));
278 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteCookies));
279 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeletePasswords));
280 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteFormData));
281 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteHostedAppsData));
283 ChangeBooleanPref(0, prefs::kDeleteBrowsingHistory);
284 ChangeBooleanPref(0, prefs::kDeleteDownloadHistory);
285 ChangeBooleanPref(0, prefs::kDeleteCache);
286 ChangeBooleanPref(0, prefs::kDeleteCookies);
287 ChangeBooleanPref(0, prefs::kDeletePasswords);
288 ChangeBooleanPref(0, prefs::kDeleteFormData);
289 ChangeBooleanPref(0, prefs::kDeleteHostedAppsData);
290 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
291 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteBrowsingHistory));
292 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteDownloadHistory));
293 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteCache));
294 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteCookies));
295 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeletePasswords));
296 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteFormData));
297 ASSERT_TRUE(BooleanPrefMatches(prefs::kDeleteHostedAppsData));
301 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
302 kWebKitUsesUniversalDetector) {
303 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
304 ASSERT_TRUE(BooleanPrefMatches(prefs::kWebKitUsesUniversalDetector));
306 ChangeBooleanPref(0, prefs::kWebKitUsesUniversalDetector);
307 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
308 ASSERT_TRUE(BooleanPrefMatches(prefs::kWebKitUsesUniversalDetector));
312 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kDefaultCharset) {
313 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
314 ASSERT_TRUE(StringPrefMatches(prefs::kDefaultCharset));
316 ChangeStringPref(0, prefs::kDefaultCharset, "Thai");
317 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
318 ASSERT_TRUE(StringPrefMatches(prefs::kDefaultCharset));
322 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
323 kBlockThirdPartyCookies) {
324 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
325 ASSERT_TRUE(BooleanPrefMatches(prefs::kBlockThirdPartyCookies));
327 ChangeBooleanPref(0, prefs::kBlockThirdPartyCookies);
328 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
329 ASSERT_TRUE(BooleanPrefMatches(prefs::kBlockThirdPartyCookies));
333 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
334 kClearSiteDataOnExit) {
335 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
336 ASSERT_TRUE(BooleanPrefMatches(prefs::kClearSiteDataOnExit));
338 ChangeBooleanPref(0, prefs::kClearSiteDataOnExit);
339 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
340 ASSERT_TRUE(BooleanPrefMatches(prefs::kClearSiteDataOnExit));
344 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
345 kSafeBrowsingEnabled) {
346 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
347 ASSERT_TRUE(BooleanPrefMatches(prefs::kSafeBrowsingEnabled));
349 ChangeBooleanPref(0, prefs::kSafeBrowsingEnabled);
350 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
351 ASSERT_TRUE(BooleanPrefMatches(prefs::kSafeBrowsingEnabled));
355 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
356 kAutofillAuxiliaryProfilesEnabled) {
357 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
361 BooleanPrefMatches(autofill::prefs::kAutofillAuxiliaryProfilesEnabled));
363 ChangeBooleanPref(0, autofill::prefs::kAutofillAuxiliaryProfilesEnabled);
364 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
366 // kAutofillAuxiliaryProfilesEnabled is only synced on Mac.
367 #if defined(OS_MACOSX)
369 BooleanPrefMatches(autofill::prefs::kAutofillAuxiliaryProfilesEnabled));
372 BooleanPrefMatches(autofill::prefs::kAutofillAuxiliaryProfilesEnabled));
377 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kPromptForDownload) {
378 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
379 ASSERT_TRUE(BooleanPrefMatches(prefs::kPromptForDownload));
381 ChangeBooleanPref(0, prefs::kPromptForDownload);
382 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
383 ASSERT_TRUE(BooleanPrefMatches(prefs::kPromptForDownload));
387 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
388 kPrefTranslateLanguageBlacklist) {
389 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
390 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
392 TranslatePrefs translate_client0_prefs(GetPrefs(0));
393 TranslatePrefs translate_client1_prefs(GetPrefs(1));
394 ASSERT_FALSE(translate_client0_prefs.IsBlockedLanguage("fr"));
395 translate_client0_prefs.BlockLanguage("fr");
396 ASSERT_TRUE(translate_client0_prefs.IsBlockedLanguage("fr"));
398 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
399 ASSERT_TRUE(translate_client1_prefs.IsBlockedLanguage("fr"));
401 translate_client0_prefs.UnblockLanguage("fr");
402 ASSERT_FALSE(translate_client0_prefs.IsBlockedLanguage("fr"));
404 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
405 ASSERT_FALSE(translate_client1_prefs.IsBlockedLanguage("fr"));
409 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
410 kPrefTranslateWhitelists) {
411 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
412 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
414 TranslatePrefs translate_client0_prefs(GetPrefs(0));
415 TranslatePrefs translate_client1_prefs(GetPrefs(1));
416 ASSERT_FALSE(translate_client0_prefs.IsLanguagePairWhitelisted("en", "bg"));
417 translate_client0_prefs.WhitelistLanguagePair("en", "bg");
418 ASSERT_TRUE(translate_client0_prefs.IsLanguagePairWhitelisted("en", "bg"));
420 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
421 ASSERT_TRUE(translate_client1_prefs.IsLanguagePairWhitelisted("en", "bg"));
423 translate_client0_prefs.RemoveLanguagePairFromWhitelist("en", "bg");
424 ASSERT_FALSE(translate_client0_prefs.IsLanguagePairWhitelisted("en", "bg"));
426 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
427 ASSERT_FALSE(translate_client1_prefs.IsLanguagePairWhitelisted("en", "bg"));
431 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
432 kPrefTranslateSiteBlacklist) {
433 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
434 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
436 GURL url("http://www.google.com");
437 std::string host(url.host());
438 TranslatePrefs translate_client0_prefs(GetPrefs(0));
439 TranslatePrefs translate_client1_prefs(GetPrefs(1));
440 ASSERT_FALSE(translate_client0_prefs.IsSiteBlacklisted(host));
441 translate_client0_prefs.BlacklistSite(host);
442 ASSERT_TRUE(translate_client0_prefs.IsSiteBlacklisted(host));
444 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
445 ASSERT_TRUE(translate_client1_prefs.IsSiteBlacklisted(host));
447 translate_client0_prefs.RemoveSiteFromBlacklist(host);
448 ASSERT_FALSE(translate_client0_prefs.IsSiteBlacklisted(host));
450 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
451 ASSERT_FALSE(translate_client1_prefs.IsSiteBlacklisted(host));
455 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
456 kExtensionsUIDeveloperMode) {
457 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
458 ASSERT_TRUE(BooleanPrefMatches(prefs::kExtensionsUIDeveloperMode));
460 ChangeBooleanPref(0, prefs::kExtensionsUIDeveloperMode);
461 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
462 ASSERT_TRUE(BooleanPrefMatches(prefs::kExtensionsUIDeveloperMode));
466 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kAcceptLanguages) {
467 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
469 ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
471 AppendStringPref(0, prefs::kAcceptLanguages, ",ar");
472 AppendStringPref(1, prefs::kAcceptLanguages, ",fr");
473 ASSERT_TRUE(AwaitQuiescence());
474 ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
476 ChangeStringPref(0, prefs::kAcceptLanguages, "en-US");
477 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
478 ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
480 ChangeStringPref(0, prefs::kAcceptLanguages, "ar,en-US");
481 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
482 ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
486 #if defined(TOOLKIT_GTK)
487 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kUsesSystemTheme) {
488 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
489 ASSERT_TRUE(BooleanPrefMatches(prefs::kUsesSystemTheme));
491 ChangeBooleanPref(0, prefs::kUsesSystemTheme);
492 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
493 ASSERT_FALSE(BooleanPrefMatches(prefs::kUsesSystemTheme));
495 #endif // TOOLKIT_GTK
498 #if defined(OS_CHROMEOS)
499 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kTapToClickEnabled) {
500 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
501 ASSERT_TRUE(BooleanPrefMatches(prefs::kTapToClickEnabled));
503 ChangeBooleanPref(0, prefs::kTapToClickEnabled);
504 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
505 ASSERT_TRUE(BooleanPrefMatches(prefs::kTapToClickEnabled));
507 ChangeBooleanPref(1, prefs::kTapToClickEnabled);
508 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
509 ASSERT_TRUE(BooleanPrefMatches(prefs::kTapToClickEnabled));
511 #endif // OS_CHROMEOS
514 #if defined(OS_CHROMEOS)
515 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kEnableScreenLock) {
516 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
517 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableScreenLock));
519 ChangeBooleanPref(0, prefs::kEnableScreenLock);
520 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
521 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableScreenLock));
523 ChangeBooleanPref(1, prefs::kEnableScreenLock);
524 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
525 ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableScreenLock));
527 #endif // OS_CHROMEOS
529 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
530 SingleClientEnabledEncryption) {
531 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
533 ASSERT_TRUE(EnableEncryption(0, syncer::PREFERENCES));
534 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
535 ASSERT_TRUE(IsEncrypted(0, syncer::PREFERENCES));
536 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES));
539 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
540 SingleClientEnabledEncryptionAndChanged) {
541 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
542 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
544 ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
545 ASSERT_TRUE(EnableEncryption(0, syncer::PREFERENCES));
546 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
547 ASSERT_TRUE(IsEncrypted(0, syncer::PREFERENCES));
548 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES));
549 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
552 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
553 BothClientsEnabledEncryption) {
554 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
556 ASSERT_TRUE(EnableEncryption(0, syncer::PREFERENCES));
557 ASSERT_TRUE(EnableEncryption(1, syncer::PREFERENCES));
558 ASSERT_TRUE(AwaitQuiescence());
559 ASSERT_TRUE(IsEncrypted(0, syncer::PREFERENCES));
560 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES));
563 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
564 SingleClientEnabledEncryptionBothChanged) {
565 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
566 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
567 ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
569 ASSERT_TRUE(EnableEncryption(0, syncer::PREFERENCES));
570 ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
571 ChangeStringPref(1, prefs::kHomePage, "http://www.google.com/1");
572 ASSERT_TRUE(AwaitQuiescence());
573 ASSERT_TRUE(IsEncrypted(0, syncer::PREFERENCES));
574 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES));
575 ASSERT_TRUE(BooleanPrefMatches(
576 prefs::kHomePageIsNewTabPage));
577 ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
580 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
581 SingleClientEnabledEncryptionAndChangedMultipleTimes) {
582 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
583 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
585 ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
586 ASSERT_TRUE(EnableEncryption(0, syncer::PREFERENCES));
587 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
588 ASSERT_TRUE(IsEncrypted(0, syncer::PREFERENCES));
589 ASSERT_TRUE(IsEncrypted(1, syncer::PREFERENCES));
590 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
592 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
593 ChangeBooleanPref(0, prefs::kShowHomeButton);
594 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
595 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));