- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / test / integration / two_client_preferences_sync_test.cc
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.
4
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"
11
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;
24
25 class TwoClientPreferencesSyncTest : public SyncTest {
26  public:
27   TwoClientPreferencesSyncTest() : SyncTest(TWO_CLIENT) {}
28   virtual ~TwoClientPreferencesSyncTest() {}
29
30  private:
31   DISALLOW_COPY_AND_ASSIGN(TwoClientPreferencesSyncTest);
32 };
33
34 // TCM ID - 7306186.
35 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
36                        kHomePageIsNewTabPage) {
37   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
38   ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
39
40   ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
41   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
42   ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
43 }
44
45 // TCM ID - 7260488.
46 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, Race) {
47   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
48   DisableVerifier();
49
50   ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
51
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));
56 }
57
58 // TCM ID - 3649278.
59 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
60                        kPasswordManagerEnabled) {
61   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
62   ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
63
64   ChangeBooleanPref(0, prefs::kPasswordManagerEnabled);
65   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
66   ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
67 }
68
69 // TCM ID - 3699293.
70 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
71                        kSyncKeepEverythingSynced) {
72   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
73   DisableVerifier();
74
75   ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced));
76   ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncThemes));
77
78   GetClient(0)->DisableSyncForDatatype(syncer::THEMES);
79   ASSERT_FALSE(BooleanPrefMatches(prefs::kSyncKeepEverythingSynced));
80 }
81
82 // TCM ID - 3661290.
83 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, DisablePreferences) {
84   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
85   DisableVerifier();
86
87   ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences));
88   ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
89
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));
94
95   GetClient(1)->EnableSyncForDatatype(syncer::PREFERENCES);
96   ASSERT_TRUE(AwaitQuiescence());
97   ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
98 }
99
100 // TCM ID - 3664292.
101 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, DisableSync) {
102   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
103   DisableVerifier();
104
105   ASSERT_TRUE(BooleanPrefMatches(prefs::kSyncPreferences));
106   ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
107   ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
108
109   GetClient(1)->DisableSyncForAllDatatypes();
110   ChangeBooleanPref(0, prefs::kPasswordManagerEnabled);
111   ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Changed a preference."));
112   ASSERT_FALSE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
113
114   ChangeBooleanPref(1, prefs::kShowHomeButton);
115   ASSERT_FALSE(BooleanPrefMatches(prefs::kShowHomeButton));
116
117   GetClient(1)->EnableSyncForAllDatatypes();
118   ASSERT_TRUE(AwaitQuiescence());
119   ASSERT_TRUE(BooleanPrefMatches(prefs::kPasswordManagerEnabled));
120   ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
121 }
122
123 // TCM ID - 3604297.
124 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, SignInDialog) {
125   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
126   DisableVerifier();
127
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));
134
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);
145
146   ASSERT_TRUE(AwaitQuiescence());
147
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));
154 }
155
156 // TCM ID - 3666296.
157 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kShowBookmarkBar) {
158   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
159   ASSERT_TRUE(BooleanPrefMatches(prefs::kShowBookmarkBar));
160
161   ChangeBooleanPref(0, prefs::kShowBookmarkBar);
162   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
163   ASSERT_TRUE(BooleanPrefMatches(prefs::kShowBookmarkBar));
164 }
165
166 // TCM ID - 3611311.
167 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kCheckDefaultBrowser) {
168   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
169   DisableVerifier();
170
171   ASSERT_TRUE(BooleanPrefMatches(prefs::kCheckDefaultBrowser));
172
173   ChangeBooleanPref(0, prefs::kCheckDefaultBrowser);
174   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
175   ASSERT_FALSE(BooleanPrefMatches(prefs::kCheckDefaultBrowser));
176 }
177
178 // TCM ID - 3628298.
179 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kHomePage) {
180   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
181   ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
182
183   ChangeStringPref(0, prefs::kHomePage, "http://news.google.com");
184   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
185   ASSERT_TRUE(StringPrefMatches(prefs::kHomePage));
186 }
187
188 // TCM ID - 7297269.
189 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kShowHomeButton) {
190   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
191   ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
192
193   ChangeBooleanPref(0, prefs::kShowHomeButton);
194   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
195   ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
196 }
197
198 // TCM ID - 3710285.
199 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kEnableTranslate) {
200   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
201   ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
202
203   ChangeBooleanPref(0, prefs::kEnableTranslate);
204   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
205   ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
206 }
207
208 // TCM ID - 3664293.
209 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kAutofillEnabled) {
210   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
211   ASSERT_TRUE(BooleanPrefMatches(autofill::prefs::kAutofillEnabled));
212
213   ChangeBooleanPref(0, autofill::prefs::kAutofillEnabled);
214   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
215   ASSERT_TRUE(BooleanPrefMatches(autofill::prefs::kAutofillEnabled));
216 }
217
218 // TCM ID - 3632259.
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));
224
225   ChangeIntegerPref(0, prefs::kRestoreOnStartup, 0);
226   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
227   ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
228
229   ListValue urls;
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));
237 }
238
239 // TCM ID - 3684287.
240 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kRestoreOnStartup) {
241   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
242   ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
243
244   ChangeIntegerPref(0, prefs::kRestoreOnStartup, 1);
245   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
246   ASSERT_TRUE(IntegerPrefMatches(prefs::kRestoreOnStartup));
247 }
248
249 // TCM ID - 3703314.
250 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, Privacy) {
251   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
252   DisableVerifier();
253
254   ASSERT_TRUE(BooleanPrefMatches(prefs::kAlternateErrorPagesEnabled));
255   ASSERT_TRUE(BooleanPrefMatches(prefs::kSearchSuggestEnabled));
256   ASSERT_TRUE(BooleanPrefMatches(prefs::kNetworkPredictionEnabled));
257   ASSERT_TRUE(BooleanPrefMatches(prefs::kSafeBrowsingEnabled));
258
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));
268 }
269
270 // TCM ID - 3649279.
271 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, ClearData) {
272   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
273   DisableVerifier();
274
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));
282
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));
298 }
299
300 // TCM ID - 3686300.
301 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
302                        kWebKitUsesUniversalDetector) {
303   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
304   ASSERT_TRUE(BooleanPrefMatches(prefs::kWebKitUsesUniversalDetector));
305
306   ChangeBooleanPref(0, prefs::kWebKitUsesUniversalDetector);
307   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
308   ASSERT_TRUE(BooleanPrefMatches(prefs::kWebKitUsesUniversalDetector));
309 }
310
311 // TCM ID - 3673298.
312 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kDefaultCharset) {
313   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
314   ASSERT_TRUE(StringPrefMatches(prefs::kDefaultCharset));
315
316   ChangeStringPref(0, prefs::kDefaultCharset, "Thai");
317   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
318   ASSERT_TRUE(StringPrefMatches(prefs::kDefaultCharset));
319 }
320
321 // TCM ID - 3653296.
322 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
323                        kBlockThirdPartyCookies) {
324   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
325   ASSERT_TRUE(BooleanPrefMatches(prefs::kBlockThirdPartyCookies));
326
327   ChangeBooleanPref(0, prefs::kBlockThirdPartyCookies);
328   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
329   ASSERT_TRUE(BooleanPrefMatches(prefs::kBlockThirdPartyCookies));
330 }
331
332 // TCM ID - 7297279.
333 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
334                        kClearSiteDataOnExit) {
335   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
336   ASSERT_TRUE(BooleanPrefMatches(prefs::kClearSiteDataOnExit));
337
338   ChangeBooleanPref(0, prefs::kClearSiteDataOnExit);
339   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
340   ASSERT_TRUE(BooleanPrefMatches(prefs::kClearSiteDataOnExit));
341 }
342
343 // TCM ID - 7306184.
344 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
345                        kSafeBrowsingEnabled) {
346   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
347   ASSERT_TRUE(BooleanPrefMatches(prefs::kSafeBrowsingEnabled));
348
349   ChangeBooleanPref(0, prefs::kSafeBrowsingEnabled);
350   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
351   ASSERT_TRUE(BooleanPrefMatches(prefs::kSafeBrowsingEnabled));
352 }
353
354 // TCM ID - 3624302.
355 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
356                        kAutofillAuxiliaryProfilesEnabled) {
357   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
358   DisableVerifier();
359
360   ASSERT_TRUE(
361       BooleanPrefMatches(autofill::prefs::kAutofillAuxiliaryProfilesEnabled));
362
363   ChangeBooleanPref(0, autofill::prefs::kAutofillAuxiliaryProfilesEnabled);
364   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
365
366   // kAutofillAuxiliaryProfilesEnabled is only synced on Mac.
367 #if defined(OS_MACOSX)
368   ASSERT_TRUE(
369       BooleanPrefMatches(autofill::prefs::kAutofillAuxiliaryProfilesEnabled));
370 #else
371   ASSERT_FALSE(
372       BooleanPrefMatches(autofill::prefs::kAutofillAuxiliaryProfilesEnabled));
373 #endif  // OS_MACOSX
374 }
375
376 // TCM ID - 3717298.
377 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kPromptForDownload) {
378   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
379   ASSERT_TRUE(BooleanPrefMatches(prefs::kPromptForDownload));
380
381   ChangeBooleanPref(0, prefs::kPromptForDownload);
382   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
383   ASSERT_TRUE(BooleanPrefMatches(prefs::kPromptForDownload));
384 }
385
386 // TCM ID - 3729263.
387 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
388                        kPrefTranslateLanguageBlacklist) {
389   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
390   ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
391
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"));
397
398   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
399   ASSERT_TRUE(translate_client1_prefs.IsBlockedLanguage("fr"));
400
401   translate_client0_prefs.UnblockLanguage("fr");
402   ASSERT_FALSE(translate_client0_prefs.IsBlockedLanguage("fr"));
403
404   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
405   ASSERT_FALSE(translate_client1_prefs.IsBlockedLanguage("fr"));
406 }
407
408 // TCM ID - 7307195.
409 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
410                        kPrefTranslateWhitelists) {
411   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
412   ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
413
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"));
419
420   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
421   ASSERT_TRUE(translate_client1_prefs.IsLanguagePairWhitelisted("en", "bg"));
422
423   translate_client0_prefs.RemoveLanguagePairFromWhitelist("en", "bg");
424   ASSERT_FALSE(translate_client0_prefs.IsLanguagePairWhitelisted("en", "bg"));
425
426   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
427   ASSERT_FALSE(translate_client1_prefs.IsLanguagePairWhitelisted("en", "bg"));
428 }
429
430 // TCM ID - 3625298.
431 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
432                        kPrefTranslateSiteBlacklist) {
433   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
434   ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableTranslate));
435
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));
443
444   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
445   ASSERT_TRUE(translate_client1_prefs.IsSiteBlacklisted(host));
446
447   translate_client0_prefs.RemoveSiteFromBlacklist(host);
448   ASSERT_FALSE(translate_client0_prefs.IsSiteBlacklisted(host));
449
450   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
451   ASSERT_FALSE(translate_client1_prefs.IsSiteBlacklisted(host));
452 }
453
454 // TCM ID - 6515252.
455 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
456                        kExtensionsUIDeveloperMode) {
457   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
458   ASSERT_TRUE(BooleanPrefMatches(prefs::kExtensionsUIDeveloperMode));
459
460   ChangeBooleanPref(0, prefs::kExtensionsUIDeveloperMode);
461   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
462   ASSERT_TRUE(BooleanPrefMatches(prefs::kExtensionsUIDeveloperMode));
463 }
464
465 // TCM ID - 7583816
466 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, kAcceptLanguages) {
467   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
468   DisableVerifier();
469   ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
470
471   AppendStringPref(0, prefs::kAcceptLanguages, ",ar");
472   AppendStringPref(1, prefs::kAcceptLanguages, ",fr");
473   ASSERT_TRUE(AwaitQuiescence());
474   ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
475
476   ChangeStringPref(0, prefs::kAcceptLanguages, "en-US");
477   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
478   ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
479
480   ChangeStringPref(0, prefs::kAcceptLanguages, "ar,en-US");
481   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
482   ASSERT_TRUE(StringPrefMatches(prefs::kAcceptLanguages));
483 }
484
485 // TCM ID - 7590682
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));
490
491   ChangeBooleanPref(0, prefs::kUsesSystemTheme);
492   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
493   ASSERT_FALSE(BooleanPrefMatches(prefs::kUsesSystemTheme));
494 }
495 #endif  // TOOLKIT_GTK
496
497 // TCM ID - 6473347.
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));
502
503   ChangeBooleanPref(0, prefs::kTapToClickEnabled);
504   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
505   ASSERT_TRUE(BooleanPrefMatches(prefs::kTapToClickEnabled));
506
507   ChangeBooleanPref(1, prefs::kTapToClickEnabled);
508   ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
509   ASSERT_TRUE(BooleanPrefMatches(prefs::kTapToClickEnabled));
510 }
511 #endif  // OS_CHROMEOS
512
513 // TCM ID - 6458824.
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));
518
519   ChangeBooleanPref(0, prefs::kEnableScreenLock);
520   ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
521   ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableScreenLock));
522
523   ChangeBooleanPref(1, prefs::kEnableScreenLock);
524   ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
525   ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableScreenLock));
526 }
527 #endif  // OS_CHROMEOS
528
529 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
530                        SingleClientEnabledEncryption) {
531   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
532
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));
537 }
538
539 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
540                        SingleClientEnabledEncryptionAndChanged) {
541   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
542   ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
543
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));
550 }
551
552 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
553                        BothClientsEnabledEncryption) {
554   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
555
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));
561 }
562
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));
568
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));
578 }
579
580 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
581                        SingleClientEnabledEncryptionAndChangedMultipleTimes) {
582   ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
583   ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
584
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));
591
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));
596 }