OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 6 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
7 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 7 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
8 #include "chrome/browser/sync/test/integration/sync_test.h" | 8 #include "chrome/browser/sync/test/integration/sync_test.h" |
9 #include "chrome/browser/sync/test/integration/themes_helper.h" | 9 #include "chrome/browser/sync/test/integration/themes_helper.h" |
10 | 10 |
11 using sync_integration_test_util::AwaitCommitActivityCompletion; | 11 using themes_helper::AwaitThemeIsPendingInstall; |
12 using themes_helper::AwaitUsingSystemTheme; | |
13 using themes_helper::AwaitUsingDefaultTheme; | |
12 using themes_helper::GetCustomTheme; | 14 using themes_helper::GetCustomTheme; |
13 using themes_helper::GetThemeID; | 15 using themes_helper::GetThemeID; |
14 using themes_helper::HasOrWillHaveCustomTheme; | |
15 using themes_helper::ThemeIsPendingInstall; | |
16 using themes_helper::UseCustomTheme; | 16 using themes_helper::UseCustomTheme; |
17 using themes_helper::UseDefaultTheme; | 17 using themes_helper::UseDefaultTheme; |
18 using themes_helper::UseSystemTheme; | 18 using themes_helper::UseSystemTheme; |
19 using themes_helper::UsingCustomTheme; | 19 using themes_helper::UsingCustomTheme; |
20 using themes_helper::UsingDefaultTheme; | 20 using themes_helper::UsingDefaultTheme; |
21 using themes_helper::UsingSystemTheme; | 21 using themes_helper::UsingSystemTheme; |
22 | 22 |
23 class TwoClientThemesSyncTest : public SyncTest { | 23 class TwoClientThemesSyncTest : public SyncTest { |
24 public: | 24 public: |
25 TwoClientThemesSyncTest() : SyncTest(TWO_CLIENT) {} | 25 TwoClientThemesSyncTest() : SyncTest(TWO_CLIENT) {} |
26 virtual ~TwoClientThemesSyncTest() {} | 26 virtual ~TwoClientThemesSyncTest() {} |
27 | 27 |
28 private: | 28 private: |
29 DISALLOW_COPY_AND_ASSIGN(TwoClientThemesSyncTest); | 29 DISALLOW_COPY_AND_ASSIGN(TwoClientThemesSyncTest); |
30 }; | 30 }; |
31 | 31 |
32 class LegacyTwoClientThemesSyncTest : public SyncTest { | 32 class LegacyTwoClientThemesSyncTest : public SyncTest { |
pval...(no longer on Chromium)
2014/07/15 20:34:47
remove this (woo)
rlarocque
2014/07/15 20:47:01
Done.
| |
33 public: | 33 public: |
34 LegacyTwoClientThemesSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {} | 34 LegacyTwoClientThemesSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {} |
35 virtual ~LegacyTwoClientThemesSyncTest() {} | 35 virtual ~LegacyTwoClientThemesSyncTest() {} |
36 | 36 |
37 private: | 37 private: |
38 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientThemesSyncTest); | 38 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientThemesSyncTest); |
39 }; | 39 }; |
40 | 40 |
41 // TODO(akalin): Add tests for model association (i.e., tests that | 41 // Starts with default themes, then sets up sync and uses it to set all |
42 // start with SetupClients(), change the theme state, then call | 42 // profiles to use a custom theme. Does not actually install any themes, but |
43 // SetupSync()). | 43 // instead verifies the custom theme is pending for install. |
44 | 44 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DefaultThenSyncCustom) { |
45 // TCM ID - 3667311. | 45 ASSERT_TRUE(SetupSync()); |
46 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomTheme) { | |
47 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
48 | 46 |
49 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | 47 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); |
50 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | 48 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); |
51 ASSERT_FALSE(UsingCustomTheme(verifier())); | 49 ASSERT_FALSE(UsingCustomTheme(verifier())); |
52 | 50 |
53 UseCustomTheme(GetProfile(0), 0); | 51 UseCustomTheme(GetProfile(0), 0); |
54 UseCustomTheme(verifier(), 0); | 52 UseCustomTheme(verifier(), 0); |
55 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | 53 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); |
56 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | 54 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); |
57 | 55 |
58 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 56 // TODO(sync): Add functions to simulate when a pending extension |
pval...(no longer on Chromium)
2014/07/15 20:34:47
it may not have been exactly what akalin had in mi
rlarocque
2014/07/15 20:47:01
No, not really.
Custom themes are implemented as
pval...(no longer on Chromium)
2014/07/16 00:03:46
K; makes sense.
| |
59 | |
60 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
61 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
62 // TODO(akalin): Add functions to simulate when a pending extension | |
63 // is installed as well as when a pending extension fails to | 57 // is installed as well as when a pending extension fails to |
64 // install. | 58 // install. |
65 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | 59 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); |
66 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | 60 |
61 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
62 EXPECT_FALSE(UsingCustomTheme(GetProfile(1))); | |
63 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
67 } | 64 } |
68 | 65 |
69 // TCM ID - 3599303. | 66 // Starts with custom themes, then sets up sync and uses it to set all profiles |
70 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | 67 // to the system theme. |
71 #if defined(OS_CHROMEOS) | 68 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomThenSyncNative) { |
72 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeTheme) { | 69 ASSERT_TRUE(SetupClients()); |
73 #else | |
74 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeTheme) { | |
75 #endif // OS_CHROMEOS | |
76 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
77 | 70 |
78 UseCustomTheme(GetProfile(0), 0); | 71 UseCustomTheme(GetProfile(0), 0); |
79 UseCustomTheme(GetProfile(1), 0); | 72 UseCustomTheme(GetProfile(1), 0); |
80 UseCustomTheme(verifier(), 0); | 73 UseCustomTheme(verifier(), 0); |
81 | 74 |
82 ASSERT_TRUE(AwaitQuiescence()); | 75 ASSERT_TRUE(SetupSync()); |
83 | 76 |
84 UseSystemTheme(GetProfile(0)); | 77 UseSystemTheme(GetProfile(0)); |
85 UseSystemTheme(verifier()); | 78 UseSystemTheme(verifier()); |
86 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); | 79 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); |
87 ASSERT_TRUE(UsingSystemTheme(verifier())); | 80 ASSERT_TRUE(UsingSystemTheme(verifier())); |
88 | 81 |
89 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 82 ASSERT_TRUE(AwaitUsingSystemTheme(GetProfile(1))); |
90 | 83 |
91 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); | 84 EXPECT_TRUE(UsingSystemTheme(GetProfile(0))); |
92 ASSERT_TRUE(UsingSystemTheme(GetProfile(1))); | 85 EXPECT_TRUE(UsingSystemTheme(GetProfile(1))); |
93 ASSERT_TRUE(UsingSystemTheme(verifier())); | 86 EXPECT_TRUE(UsingSystemTheme(verifier())); |
94 } | 87 } |
95 | 88 |
96 // TCM ID - 7247455. | 89 // Starts with custom themes, then sets up sync and uses it to set all profiles |
97 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DefaultTheme) { | 90 // to the default theme. |
98 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 91 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomThenSyncDefault) { |
92 ASSERT_TRUE(SetupClients()); | |
99 | 93 |
100 UseCustomTheme(GetProfile(0), 0); | 94 UseCustomTheme(GetProfile(0), 0); |
101 UseCustomTheme(GetProfile(1), 0); | 95 UseCustomTheme(GetProfile(1), 0); |
102 UseCustomTheme(verifier(), 0); | 96 UseCustomTheme(verifier(), 0); |
103 | 97 |
104 ASSERT_TRUE(AwaitQuiescence()); | 98 ASSERT_TRUE(SetupSync()); |
105 | 99 |
106 UseDefaultTheme(GetProfile(0)); | 100 UseDefaultTheme(GetProfile(0)); |
107 UseDefaultTheme(verifier()); | 101 UseDefaultTheme(verifier()); |
108 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 102 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); |
109 ASSERT_TRUE(UsingDefaultTheme(verifier())); | 103 EXPECT_TRUE(UsingDefaultTheme(verifier())); |
110 | 104 |
111 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 105 ASSERT_TRUE(AwaitUsingDefaultTheme(GetProfile(1))); |
112 | 106 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); |
113 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); | 107 EXPECT_TRUE(UsingDefaultTheme(GetProfile(1))); |
114 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | 108 EXPECT_TRUE(UsingDefaultTheme(verifier())); |
115 ASSERT_TRUE(UsingDefaultTheme(verifier())); | |
116 } | 109 } |
117 | 110 |
118 // TCM ID - 7292065. | 111 // Cycles through a set of options. |
119 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | 112 // |
120 // TODO(erg): Fails on linux_aura. See http://crbug.com/304554 | 113 // Most other tests have significant coverage of model association. This test |
121 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 114 // is intended to test steady-state scenarios. |
122 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeDefaultRace) { | 115 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CycleOptions) { |
123 #else | |
124 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeDefaultRace) { | |
125 #endif // OS_CHROMEOS | |
126 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
127 | |
128 UseSystemTheme(GetProfile(0)); | |
129 UseDefaultTheme(GetProfile(1)); | |
130 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); | |
131 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
132 | |
133 ASSERT_TRUE(AwaitQuiescence()); | |
134 | |
135 // TODO(akalin): Add function that compares two profiles to see if | |
136 // they're at the same state. | |
137 | |
138 ASSERT_EQ(UsingSystemTheme(GetProfile(0)), | |
139 UsingSystemTheme(GetProfile(1))); | |
140 ASSERT_EQ(UsingDefaultTheme(GetProfile(0)), | |
141 UsingDefaultTheme(GetProfile(1))); | |
142 } | |
143 | |
144 // TCM ID - 7294077. | |
145 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. | |
146 #if defined(OS_CHROMEOS) | |
147 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_CustomNativeRace) { | |
148 #else | |
149 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomNativeRace) { | |
150 #endif // OS_CHROMEOS | |
151 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 116 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
152 | 117 |
153 UseCustomTheme(GetProfile(0), 0); | 118 UseCustomTheme(GetProfile(0), 0); |
154 UseSystemTheme(GetProfile(1)); | 119 UseCustomTheme(verifier(), 0); |
155 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
156 ASSERT_TRUE(UsingSystemTheme(GetProfile(1))); | |
157 | 120 |
158 ASSERT_TRUE(AwaitQuiescence()); | 121 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); |
122 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
123 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
159 | 124 |
160 // TODO(akalin): Add function to wait for pending extensions to be | 125 UseSystemTheme(GetProfile(0)); |
161 // installed. | 126 UseSystemTheme(verifier()); |
162 | 127 |
163 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)), | 128 ASSERT_TRUE(AwaitUsingSystemTheme(GetProfile(1))); |
164 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0))); | 129 EXPECT_TRUE(UsingSystemTheme(GetProfile(0))); |
130 EXPECT_TRUE(UsingSystemTheme(GetProfile(1))); | |
131 EXPECT_TRUE(UsingSystemTheme(verifier())); | |
132 | |
133 UseDefaultTheme(GetProfile(0)); | |
134 UseDefaultTheme(verifier()); | |
135 | |
136 ASSERT_TRUE(AwaitUsingDefaultTheme(GetProfile(1))); | |
137 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0))); | |
138 EXPECT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
139 EXPECT_TRUE(UsingDefaultTheme(verifier())); | |
140 | |
141 UseCustomTheme(GetProfile(0), 1); | |
142 UseCustomTheme(verifier(), 1); | |
143 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(1))); | |
144 EXPECT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(0))); | |
145 EXPECT_EQ(GetCustomTheme(1), GetThemeID(verifier())); | |
165 } | 146 } |
166 | |
167 // TCM ID - 7307225. | |
168 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomDefaultRace) { | |
169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
170 | |
171 UseCustomTheme(GetProfile(0), 0); | |
172 UseDefaultTheme(GetProfile(1)); | |
173 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
174 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); | |
175 | |
176 ASSERT_TRUE(AwaitQuiescence()); | |
177 | |
178 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)), | |
179 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0))); | |
180 } | |
181 | |
182 // TCM ID - 7264758. | |
183 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomCustomRace) { | |
184 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
185 | |
186 // TODO(akalin): Generalize this to n clients. | |
187 | |
188 UseCustomTheme(GetProfile(0), 0); | |
189 UseCustomTheme(GetProfile(1), 1); | |
190 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
191 ASSERT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(1))); | |
192 | |
193 ASSERT_TRUE(AwaitQuiescence()); | |
194 | |
195 bool using_theme_0 = | |
196 (GetThemeID(GetProfile(0)) == GetCustomTheme(0)) && | |
197 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0)); | |
198 bool using_theme_1 = | |
199 HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(1)) && | |
200 (GetThemeID(GetProfile(1)) == GetCustomTheme(1)); | |
201 | |
202 // Equivalent to using_theme_0 xor using_theme_1. | |
203 ASSERT_NE(using_theme_0, using_theme_1); | |
204 } | |
205 | |
206 // TCM ID - 3723272. | |
207 IN_PROC_BROWSER_TEST_F(LegacyTwoClientThemesSyncTest, DisableThemes) { | |
208 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
209 | |
210 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | |
211 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
212 ASSERT_FALSE(UsingCustomTheme(verifier())); | |
213 | |
214 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::THEMES)); | |
215 UseCustomTheme(GetProfile(0), 0); | |
216 UseCustomTheme(verifier(), 0); | |
217 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | |
218 | |
219 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
220 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
221 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
222 | |
223 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::THEMES)); | |
224 ASSERT_TRUE(AwaitQuiescence()); | |
225 | |
226 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
227 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
228 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | |
229 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
230 } | |
231 | |
232 // TCM ID - 3687288. | |
233 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DisableSync) { | |
234 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
235 | |
236 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); | |
237 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
238 ASSERT_FALSE(UsingCustomTheme(verifier())); | |
239 | |
240 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); | |
241 UseCustomTheme(GetProfile(0), 0); | |
242 UseCustomTheme(verifier(), 0); | |
243 ASSERT_TRUE( | |
244 AwaitCommitActivityCompletion(GetSyncService((0)))); | |
245 | |
246 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
247 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
248 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
249 | |
250 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); | |
251 ASSERT_TRUE(AwaitQuiescence()); | |
252 | |
253 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); | |
254 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); | |
255 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); | |
256 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); | |
257 } | |
OLD | NEW |