Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/browser/sync/test/integration/two_client_themes_sync_test.cc

Issue 395503004: sync: Refactor themes sync integration tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address some review comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/test/integration/themes_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
rlarocque 2014/07/15 23:41:16 I just noticed that I forgot to set the flag to di
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 // Starts with default themes, then sets up sync and uses it to set all
33 public: 33 // profiles to use a custom theme. Does not actually install any themes, but
34 LegacyTwoClientThemesSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {} 34 // instead verifies the custom theme is pending for install.
35 virtual ~LegacyTwoClientThemesSyncTest() {} 35 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DefaultThenSyncCustom) {
36 36 ASSERT_TRUE(SetupSync());
37 private:
38 DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientThemesSyncTest);
39 };
40
41 // TODO(akalin): Add tests for model association (i.e., tests that
42 // start with SetupClients(), change the theme state, then call
43 // SetupSync()).
44
45 // TCM ID - 3667311.
46 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomTheme) {
47 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
48 37
49 ASSERT_FALSE(UsingCustomTheme(GetProfile(0))); 38 ASSERT_FALSE(UsingCustomTheme(GetProfile(0)));
50 ASSERT_FALSE(UsingCustomTheme(GetProfile(1))); 39 ASSERT_FALSE(UsingCustomTheme(GetProfile(1)));
51 ASSERT_FALSE(UsingCustomTheme(verifier())); 40 ASSERT_FALSE(UsingCustomTheme(verifier()));
52 41
53 UseCustomTheme(GetProfile(0), 0); 42 UseCustomTheme(GetProfile(0), 0);
54 UseCustomTheme(verifier(), 0); 43 UseCustomTheme(verifier(), 0);
55 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0))); 44 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
56 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); 45 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
57 46
58 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 47 // TODO(sync): Add functions to simulate when a pending extension
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 48 // is installed as well as when a pending extension fails to
64 // install. 49 // install.
65 ASSERT_TRUE(ThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0))); 50 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0)));
66 ASSERT_EQ(GetCustomTheme(0), GetThemeID(verifier())); 51
52 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
53 EXPECT_FALSE(UsingCustomTheme(GetProfile(1)));
54 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
67 } 55 }
68 56
69 // TCM ID - 3599303. 57 // 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. 58 // to the system theme.
71 #if defined(OS_CHROMEOS) 59 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomThenSyncNative) {
72 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeTheme) { 60 ASSERT_TRUE(SetupClients());
73 #else
74 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, NativeTheme) {
75 #endif // OS_CHROMEOS
76 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
77 61
78 UseCustomTheme(GetProfile(0), 0); 62 UseCustomTheme(GetProfile(0), 0);
79 UseCustomTheme(GetProfile(1), 0); 63 UseCustomTheme(GetProfile(1), 0);
80 UseCustomTheme(verifier(), 0); 64 UseCustomTheme(verifier(), 0);
81 65
82 ASSERT_TRUE(AwaitQuiescence()); 66 ASSERT_TRUE(SetupSync());
83 67
84 UseSystemTheme(GetProfile(0)); 68 UseSystemTheme(GetProfile(0));
85 UseSystemTheme(verifier()); 69 UseSystemTheme(verifier());
86 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); 70 ASSERT_TRUE(UsingSystemTheme(GetProfile(0)));
87 ASSERT_TRUE(UsingSystemTheme(verifier())); 71 ASSERT_TRUE(UsingSystemTheme(verifier()));
88 72
89 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 73 ASSERT_TRUE(AwaitUsingSystemTheme(GetProfile(1)));
90 74
91 ASSERT_TRUE(UsingSystemTheme(GetProfile(0))); 75 EXPECT_TRUE(UsingSystemTheme(GetProfile(0)));
92 ASSERT_TRUE(UsingSystemTheme(GetProfile(1))); 76 EXPECT_TRUE(UsingSystemTheme(GetProfile(1)));
93 ASSERT_TRUE(UsingSystemTheme(verifier())); 77 EXPECT_TRUE(UsingSystemTheme(verifier()));
94 } 78 }
95 79
96 // TCM ID - 7247455. 80 // Starts with custom themes, then sets up sync and uses it to set all profiles
97 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DefaultTheme) { 81 // to the default theme.
98 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 82 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, CustomThenSyncDefault) {
83 ASSERT_TRUE(SetupClients());
99 84
100 UseCustomTheme(GetProfile(0), 0); 85 UseCustomTheme(GetProfile(0), 0);
101 UseCustomTheme(GetProfile(1), 0); 86 UseCustomTheme(GetProfile(1), 0);
102 UseCustomTheme(verifier(), 0); 87 UseCustomTheme(verifier(), 0);
103 88
104 ASSERT_TRUE(AwaitQuiescence()); 89 ASSERT_TRUE(SetupSync());
105 90
106 UseDefaultTheme(GetProfile(0)); 91 UseDefaultTheme(GetProfile(0));
107 UseDefaultTheme(verifier()); 92 UseDefaultTheme(verifier());
108 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); 93 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0)));
109 ASSERT_TRUE(UsingDefaultTheme(verifier())); 94 EXPECT_TRUE(UsingDefaultTheme(verifier()));
110 95
111 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 96 ASSERT_TRUE(AwaitUsingDefaultTheme(GetProfile(1)));
112 97 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0)));
113 ASSERT_TRUE(UsingDefaultTheme(GetProfile(0))); 98 EXPECT_TRUE(UsingDefaultTheme(GetProfile(1)));
114 ASSERT_TRUE(UsingDefaultTheme(GetProfile(1))); 99 EXPECT_TRUE(UsingDefaultTheme(verifier()));
115 ASSERT_TRUE(UsingDefaultTheme(verifier()));
116 } 100 }
117 101
118 // TCM ID - 7292065. 102 // Cycles through a set of options.
119 // TODO(sync): Fails on Chrome OS. See http://crbug.com/84575. 103 //
120 // TODO(erg): Fails on linux_aura. See http://crbug.com/304554 104 // Most other tests have significant coverage of model association. This test
121 #if defined(OS_CHROMEOS) || defined(OS_LINUX) 105 // is intended to test steady-state scenarios.
122 IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, DISABLED_NativeDefaultRace) { 106 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."; 107 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
152 108
153 UseCustomTheme(GetProfile(0), 0); 109 UseCustomTheme(GetProfile(0), 0);
154 UseSystemTheme(GetProfile(1)); 110 UseCustomTheme(verifier(), 0);
155 ASSERT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
156 ASSERT_TRUE(UsingSystemTheme(GetProfile(1)));
157 111
158 ASSERT_TRUE(AwaitQuiescence()); 112 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(0)));
113 EXPECT_EQ(GetCustomTheme(0), GetThemeID(GetProfile(0)));
114 EXPECT_EQ(GetCustomTheme(0), GetThemeID(verifier()));
159 115
160 // TODO(akalin): Add function to wait for pending extensions to be 116 UseSystemTheme(GetProfile(0));
161 // installed. 117 UseSystemTheme(verifier());
162 118
163 ASSERT_EQ(HasOrWillHaveCustomTheme(GetProfile(0), GetCustomTheme(0)), 119 ASSERT_TRUE(AwaitUsingSystemTheme(GetProfile(1)));
164 HasOrWillHaveCustomTheme(GetProfile(1), GetCustomTheme(0))); 120 EXPECT_TRUE(UsingSystemTheme(GetProfile(0)));
121 EXPECT_TRUE(UsingSystemTheme(GetProfile(1)));
122 EXPECT_TRUE(UsingSystemTheme(verifier()));
123
124 UseDefaultTheme(GetProfile(0));
125 UseDefaultTheme(verifier());
126
127 ASSERT_TRUE(AwaitUsingDefaultTheme(GetProfile(1)));
128 EXPECT_TRUE(UsingDefaultTheme(GetProfile(0)));
129 EXPECT_TRUE(UsingDefaultTheme(GetProfile(1)));
130 EXPECT_TRUE(UsingDefaultTheme(verifier()));
131
132 UseCustomTheme(GetProfile(0), 1);
133 UseCustomTheme(verifier(), 1);
134 ASSERT_TRUE(AwaitThemeIsPendingInstall(GetProfile(1), GetCustomTheme(1)));
135 EXPECT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(0)));
136 EXPECT_EQ(GetCustomTheme(1), GetThemeID(verifier()));
165 } 137 }
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 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/themes_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698