Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / two_client_themes_sync_test.cc
blobab660cec76e051c872010598ad6d34705d2867b9
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/basictypes.h"
6 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
7 #include "chrome/browser/sync/test/integration/sync_test.h"
8 #include "chrome/browser/sync/test/integration/themes_helper.h"
10 using themes_helper::GetCustomTheme;
11 using themes_helper::GetThemeID;
12 using themes_helper::HasOrWillHaveCustomTheme;
13 using themes_helper::ThemeIsPendingInstall;
14 using themes_helper::UseCustomTheme;
15 using themes_helper::UseDefaultTheme;
16 using themes_helper::UseNativeTheme;
17 using themes_helper::UsingCustomTheme;
18 using themes_helper::UsingDefaultTheme;
19 using themes_helper::UsingNativeTheme;
21 class TwoClientThemesSyncTest : public SyncTest {
22 public:
23 TwoClientThemesSyncTest() : SyncTest(TWO_CLIENT) {}
24 virtual ~TwoClientThemesSyncTest() {}
26 private:
27 DISALLOW_COPY_AND_ASSIGN(TwoClientThemesSyncTest);
30 // TODO(akalin): Add tests for model association (i.e., tests that
31 // start with SetupClients(), change the theme state, then call
32 // SetupSync()).
34 // TCM ID - 3667311.
35 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomTheme) {
36 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
38 ASSERT_FALSE(UsingCustomTheme(GetProfile(0)));
39 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
40 ASSERT_FALSE(UsingCustomTheme(verifier()));
42 UseCustomTheme(GetProfile(0), 0);
43 UseCustomTheme(verifier(), 0);
44 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
45 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
47 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
49 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
50 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
51 // TODO(akalin): Add functions to simulate when a pending extension
52 // is installed as well as when a pending extension fails to
53 // install.
54 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0)));
55 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
58 // TCM ID - 3599303.
59 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575.
60 // TODO(erg): Fails on linux_aura. See http://crbug.com/304554
61 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
62 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeTheme) {
63 #else
64 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeTheme) {
65 #endif // OS_CHROMEOS
66 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
68 UseCustomTheme(GetProfile(0), 0);
69 UseCustomTheme(GetProfile(1), 0);
70 UseCustomTheme(verifier(), 0);
72 ASSERT_TRUE(AwaitQuiescence());
74 UseNativeTheme(GetProfile(0));
75 UseNativeTheme(verifier());
76 ASSERT_TRUE(UsingNativeTheme(GetProfile(0)));
77 ASSERT_TRUE(UsingNativeTheme(verifier()));
79 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
81 ASSERT_TRUE(UsingNativeTheme(GetProfile(0)));
82 ASSERT_TRUE(UsingNativeTheme(GetProfile(1)));
83 ASSERT_TRUE(UsingNativeTheme(verifier()));
86 // TCM ID - 7247455.
87 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DefaultTheme) {
88 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
90 UseCustomTheme(GetProfile(0), 0);
91 UseCustomTheme(GetProfile(1), 0);
92 UseCustomTheme(verifier(), 0);
94 ASSERT_TRUE(AwaitQuiescence());
96 UseDefaultTheme(GetProfile(0));
97 UseDefaultTheme(verifier());
98 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0)));
99 ASSERT_TRUE(UsingDefaultTheme(verifier()));
101 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
103 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0)));
104 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1)));
105 ASSERT_TRUE(UsingDefaultTheme(verifier()));
108 // TCM ID - 7292065.
109 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575.
110 // TODO(erg): Fails on linux_aura. See http://crbug.com/304554
111 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
112 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeDefaultRace) {
113 #else
114 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeDefaultRace) {
115 #endif // OS_CHROMEOS
116 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
118 UseNativeTheme(GetProfile(0));
119 UseDefaultTheme(GetProfile(1));
120 ASSERT_TRUE(UsingNativeTheme(GetProfile(0)));
121 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1)));
123 ASSERT_TRUE(AwaitQuiescence());
125 // TODO(akalin): Add function that compares two profiles to see if
126 // they're at the same state.
128 ASSERT_EQ(UsingNativeTheme(GetProfile(0)),
129 UsingNativeTheme(GetProfile(1)));
130 ASSERT_EQ(UsingDefaultTheme(GetProfile(0)),
131 UsingDefaultTheme(GetProfile(1)));
134 // TCM ID - 7294077.
135 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575.
136 #if defined(OS_CHROMEOS)
137 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_CustomNativeRace) {
138 #else
139 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomNativeRace) {
140 #endif // OS_CHROMEOS
141 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
143 UseCustomTheme(GetProfile(0), 0);
144 UseNativeTheme(GetProfile(1));
145 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
146 ASSERT_TRUE(UsingNativeTheme(GetProfile(1)));
148 ASSERT_TRUE(AwaitQuiescence());
150 // TODO(akalin): Add function to wait for pending extensions to be
151 // installed.
153 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)),
154 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0)));
157 // TCM ID - 7307225.
158 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomDefaultRace) {
159 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
161 UseCustomTheme(GetProfile(0), 0);
162 UseDefaultTheme(GetProfile(1));
163 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
164 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1)));
166 ASSERT_TRUE(AwaitQuiescence());
168 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)),
169 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0)));
172 // TCM ID - 7264758.
173 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomCustomRace) {
174 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
176 // TODO(akalin): Generalize this to n clients.
178 UseCustomTheme(GetProfile(0), 0);
179 UseCustomTheme(GetProfile(1), 1);
180 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
181 ASSERT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(1)));
183 ASSERT_TRUE(AwaitQuiescence());
185 bool using_theme_0 =
186 (GetThemeID(GetProfile(0)) == GetCustomTheme(0)) &&
187 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0));
188 bool using_theme_1 =
189 HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(1)) &&
190 (GetThemeID(GetProfile(1)) == GetCustomTheme(1));
192 // Equivalent to using_theme_0 xor using_theme_1.
193 ASSERT_NE(using_theme_0, using_theme_1);
196 // TCM ID - 3723272.
197 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DisableThemes) {
198 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
200 ASSERT_FALSE(UsingCustomTheme(GetProfile(0)));
201 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
202 ASSERT_FALSE(UsingCustomTheme(verifier()));
204 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::THEMES));
205 UseCustomTheme(GetProfile(0), 0);
206 UseCustomTheme(verifier(), 0);
207 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion());
209 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
210 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
211 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
213 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::THEMES));
214 ASSERT_TRUE(AwaitQuiescence());
216 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
217 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
218 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0)));
219 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
222 // TCM ID - 3687288.
223 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DisableSync) {
224 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
226 ASSERT_FALSE(UsingCustomTheme(GetProfile(0)));
227 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
228 ASSERT_FALSE(UsingCustomTheme(verifier()));
230 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
231 UseCustomTheme(GetProfile(0), 0);
232 UseCustomTheme(verifier(), 0);
233 ASSERT_TRUE(
234 GetClient(0)->AwaitFullSyncCompletion());
236 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
237 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
238 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
240 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
241 ASSERT_TRUE(AwaitQuiescence());
243 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
244 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
245 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
246 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0)));