Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / two_client_preferences_sync_test.cc
blob3ba4e4b01e7bb8e23c3543b24891084321130619
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/prefs/pref_service.h"
6 #include "chrome/browser/sync/test/integration/preferences_helper.h"
7 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
8 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
9 #include "chrome/browser/sync/test/integration/sync_test.h"
10 #include "chrome/common/pref_names.h"
12 using preferences_helper::AwaitBooleanPrefMatches;
13 using preferences_helper::AwaitIntegerPrefMatches;
14 using preferences_helper::AwaitListPrefMatches;
15 using preferences_helper::AwaitStringPrefMatches;
16 using preferences_helper::BooleanPrefMatches;
17 using preferences_helper::ChangeBooleanPref;
18 using preferences_helper::ChangeIntegerPref;
19 using preferences_helper::ChangeListPref;
20 using preferences_helper::ChangeStringPref;
21 using preferences_helper::GetPrefs;
23 class TwoClientPreferencesSyncTest : public SyncTest {
24 public:
25 TwoClientPreferencesSyncTest() : SyncTest(TWO_CLIENT) {}
26 ~TwoClientPreferencesSyncTest() override {}
28 bool TestUsesSelfNotifications() override { return false; }
30 private:
31 DISALLOW_COPY_AND_ASSIGN(TwoClientPreferencesSyncTest);
34 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, BooleanPref) {
35 ASSERT_TRUE(SetupSync());
36 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kHomePageIsNewTabPage));
38 ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
39 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kHomePageIsNewTabPage));
42 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, Bidirectional) {
43 ASSERT_TRUE(SetupSync());
45 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
47 ChangeStringPref(0, prefs::kHomePage, "http://www.google.com/0");
48 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
49 EXPECT_EQ("http://www.google.com/0", GetPrefs(0)->GetString(prefs::kHomePage));
51 ChangeStringPref(1, prefs::kHomePage, "http://www.google.com/1");
52 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
53 EXPECT_EQ("http://www.google.com/1", GetPrefs(0)->GetString(prefs::kHomePage));
56 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, UnsyncableBooleanPref) {
57 ASSERT_TRUE(SetupSync());
58 DisableVerifier();
59 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
60 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kCheckDefaultBrowser));
62 // This pref is not syncable.
63 ChangeBooleanPref(0, prefs::kCheckDefaultBrowser);
65 // This pref is syncable.
66 ChangeStringPref(0, prefs::kHomePage, "http://news.google.com");
68 // Wait until the syncable pref is synced, then expect that the non-syncable
69 // one is still out of sync.
70 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
71 ASSERT_FALSE(BooleanPrefMatches(prefs::kCheckDefaultBrowser));
74 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, StringPref) {
75 ASSERT_TRUE(SetupSync());
76 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
78 ChangeStringPref(0, prefs::kHomePage, "http://news.google.com");
79 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
82 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest, ComplexPrefs) {
83 ASSERT_TRUE(SetupSync());
84 ASSERT_TRUE(AwaitIntegerPrefMatches(prefs::kRestoreOnStartup));
85 ASSERT_TRUE(AwaitListPrefMatches(prefs::kURLsToRestoreOnStartup));
87 ChangeIntegerPref(0, prefs::kRestoreOnStartup, 0);
88 ASSERT_TRUE(AwaitIntegerPrefMatches(prefs::kRestoreOnStartup));
90 base::ListValue urls;
91 urls.Append(new base::StringValue("http://www.google.com/"));
92 urls.Append(new base::StringValue("http://www.flickr.com/"));
93 ChangeIntegerPref(0, prefs::kRestoreOnStartup, 4);
94 ChangeListPref(0, prefs::kURLsToRestoreOnStartup, urls);
95 ASSERT_TRUE(AwaitIntegerPrefMatches(prefs::kRestoreOnStartup));
96 ASSERT_TRUE(AwaitListPrefMatches(prefs::kURLsToRestoreOnStartup));
99 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
100 SingleClientEnabledEncryptionBothChanged) {
101 ASSERT_TRUE(SetupSync());
102 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kHomePageIsNewTabPage));
103 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
105 ASSERT_TRUE(EnableEncryption(0));
106 ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
107 ChangeStringPref(1, prefs::kHomePage, "http://www.google.com/1");
108 ASSERT_TRUE(AwaitEncryptionComplete(0));
109 ASSERT_TRUE(AwaitEncryptionComplete(1));
110 ASSERT_TRUE(AwaitStringPrefMatches(prefs::kHomePage));
111 ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage));
114 IN_PROC_BROWSER_TEST_F(TwoClientPreferencesSyncTest,
115 BothClientsEnabledEncryptionAndChangedMultipleTimes) {
116 ASSERT_TRUE(SetupSync());
117 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kHomePageIsNewTabPage));
119 ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage);
120 ASSERT_TRUE(EnableEncryption(0));
121 ASSERT_TRUE(EnableEncryption(1));
122 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kHomePageIsNewTabPage));
124 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kShowHomeButton));
125 ChangeBooleanPref(0, prefs::kShowHomeButton);
126 ASSERT_TRUE(AwaitBooleanPrefMatches(prefs::kShowHomeButton));