OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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/basictypes.h" | |
6 #include "chrome/browser/sync/profile_sync_service_harness.h" | |
7 #include "chrome/browser/sync/test/live_sync/apps_helper.h" | |
8 #include "chrome/browser/sync/test/live_sync/live_sync_test.h" | |
9 | |
10 using apps_helper::AllProfilesHaveSameAppsAsVerifier; | |
11 using apps_helper::DisableApp; | |
12 using apps_helper::EnableApp; | |
13 using apps_helper::HasSameAppsAsVerifier; | |
14 using apps_helper::IncognitoDisableApp; | |
15 using apps_helper::IncognitoEnableApp; | |
16 using apps_helper::InstallApp; | |
17 using apps_helper::InstallAppsPendingForSync; | |
18 using apps_helper::UninstallApp; | |
19 | |
20 class TwoClientAppsSyncTest : public LiveSyncTest { | |
21 public: | |
22 TwoClientAppsSyncTest() : LiveSyncTest(TWO_CLIENT) {} | |
23 | |
24 virtual ~TwoClientAppsSyncTest() {} | |
25 | |
26 private: | |
27 DISALLOW_COPY_AND_ASSIGN(TwoClientAppsSyncTest); | |
28 }; | |
29 | |
30 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithNoApps) { | |
31 ASSERT_TRUE(SetupSync()); | |
32 | |
33 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
34 } | |
35 | |
36 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithSameApps) { | |
37 ASSERT_TRUE(SetupClients()); | |
38 | |
39 const int kNumApps = 5; | |
40 for (int i = 0; i < kNumApps; ++i) { | |
41 InstallApp(GetProfile(0), i); | |
42 InstallApp(GetProfile(1), i); | |
43 InstallApp(verifier(), i); | |
44 } | |
45 | |
46 ASSERT_TRUE(SetupSync()); | |
47 | |
48 ASSERT_TRUE(AwaitQuiescence()); | |
49 | |
50 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
51 } | |
52 | |
53 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithDifferentApps) { | |
54 ASSERT_TRUE(SetupClients()); | |
55 | |
56 int i = 0; | |
57 | |
58 const int kNumCommonApps = 5; | |
59 for (int j = 0; j < kNumCommonApps; ++i, ++j) { | |
60 InstallApp(GetProfile(0), i); | |
61 InstallApp(GetProfile(1), i); | |
62 InstallApp(verifier(), i); | |
63 } | |
64 | |
65 const int kNumProfile0Apps = 10; | |
66 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) { | |
67 InstallApp(GetProfile(0), i); | |
68 InstallApp(verifier(), i); | |
69 } | |
70 | |
71 const int kNumProfile1Apps = 10; | |
72 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) { | |
73 InstallApp(GetProfile(1), i); | |
74 InstallApp(verifier(), i); | |
75 } | |
76 | |
77 ASSERT_TRUE(SetupSync()); | |
78 | |
79 ASSERT_TRUE(AwaitQuiescence()); | |
80 | |
81 InstallAppsPendingForSync(GetProfile(0)); | |
82 InstallAppsPendingForSync(GetProfile(1)); | |
83 | |
84 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
85 } | |
86 | |
87 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, InstallDifferentApps) { | |
88 ASSERT_TRUE(SetupClients()); | |
89 | |
90 int i = 0; | |
91 | |
92 const int kNumCommonApps = 5; | |
93 for (int j = 0; j < kNumCommonApps; ++i, ++j) { | |
94 InstallApp(GetProfile(0), i); | |
95 InstallApp(GetProfile(1), i); | |
96 InstallApp(verifier(), i); | |
97 } | |
98 | |
99 ASSERT_TRUE(SetupSync()); | |
100 | |
101 ASSERT_TRUE(AwaitQuiescence()); | |
102 | |
103 const int kNumProfile0Apps = 10; | |
104 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) { | |
105 InstallApp(GetProfile(0), i); | |
106 InstallApp(verifier(), i); | |
107 } | |
108 | |
109 const int kNumProfile1Apps = 10; | |
110 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) { | |
111 InstallApp(GetProfile(1), i); | |
112 InstallApp(verifier(), i); | |
113 } | |
114 | |
115 ASSERT_TRUE(AwaitQuiescence()); | |
116 | |
117 InstallAppsPendingForSync(GetProfile(0)); | |
118 InstallAppsPendingForSync(GetProfile(1)); | |
119 | |
120 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
121 } | |
122 | |
123 // TCM ID - 3711279. | |
124 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, Add) { | |
125 ASSERT_TRUE(SetupSync()); | |
126 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
127 | |
128 InstallApp(GetProfile(0), 0); | |
129 InstallApp(verifier(), 0); | |
130 ASSERT_TRUE(AwaitQuiescence()); | |
131 | |
132 InstallAppsPendingForSync(GetProfile(0)); | |
133 InstallAppsPendingForSync(GetProfile(1)); | |
134 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
135 } | |
136 | |
137 // TCM ID - 3706267. | |
138 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, Uninstall) { | |
139 ASSERT_TRUE(SetupSync()); | |
140 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
141 | |
142 InstallApp(GetProfile(0), 0); | |
143 InstallApp(verifier(), 0); | |
144 ASSERT_TRUE(AwaitQuiescence()); | |
145 | |
146 InstallAppsPendingForSync(GetProfile(0)); | |
147 InstallAppsPendingForSync(GetProfile(1)); | |
148 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
149 | |
150 UninstallApp(GetProfile(0), 0); | |
151 UninstallApp(verifier(), 0); | |
152 ASSERT_TRUE(AwaitQuiescence()); | |
153 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
154 } | |
155 | |
156 // TCM ID - 3699295. | |
157 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, Merge) { | |
158 ASSERT_TRUE(SetupSync()); | |
159 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
160 | |
161 InstallApp(GetProfile(0), 0); | |
162 InstallApp(GetProfile(1), 0); | |
163 ASSERT_TRUE(AwaitQuiescence()); | |
164 | |
165 UninstallApp(GetProfile(0), 0); | |
166 InstallApp(GetProfile(0), 1); | |
167 InstallApp(verifier(), 1); | |
168 | |
169 InstallApp(GetProfile(0), 2); | |
170 InstallApp(GetProfile(1), 2); | |
171 InstallApp(verifier(), 2); | |
172 | |
173 InstallApp(GetProfile(1), 3); | |
174 InstallApp(verifier(), 3); | |
175 | |
176 ASSERT_TRUE(AwaitQuiescence()); | |
177 InstallAppsPendingForSync(GetProfile(0)); | |
178 InstallAppsPendingForSync(GetProfile(1)); | |
179 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
180 } | |
181 | |
182 // TCM ID - 7723126. | |
183 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateEnableDisableApp) { | |
184 ASSERT_TRUE(SetupSync()); | |
185 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
186 | |
187 InstallApp(GetProfile(0), 0); | |
188 InstallApp(GetProfile(1), 0); | |
189 InstallApp(verifier(), 0); | |
190 ASSERT_TRUE(AwaitQuiescence()); | |
191 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
192 | |
193 DisableApp(GetProfile(0), 0); | |
194 DisableApp(verifier(), 0); | |
195 ASSERT_TRUE(HasSameAppsAsVerifier(0)); | |
196 ASSERT_FALSE(HasSameAppsAsVerifier(1)); | |
197 | |
198 ASSERT_TRUE(AwaitQuiescence()); | |
199 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
200 | |
201 EnableApp(GetProfile(1), 0); | |
202 EnableApp(verifier(), 0); | |
203 ASSERT_TRUE(HasSameAppsAsVerifier(1)); | |
204 ASSERT_FALSE(HasSameAppsAsVerifier(0)); | |
205 | |
206 ASSERT_TRUE(AwaitQuiescence()); | |
207 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
208 } | |
209 | |
210 // TCM ID - 7706637. | |
211 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateIncognitoEnableDisable) { | |
212 ASSERT_TRUE(SetupSync()); | |
213 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
214 | |
215 InstallApp(GetProfile(0), 0); | |
216 InstallApp(GetProfile(1), 0); | |
217 InstallApp(verifier(), 0); | |
218 ASSERT_TRUE(AwaitQuiescence()); | |
219 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
220 | |
221 IncognitoEnableApp(GetProfile(0), 0); | |
222 IncognitoEnableApp(verifier(), 0); | |
223 ASSERT_TRUE(HasSameAppsAsVerifier(0)); | |
224 ASSERT_FALSE(HasSameAppsAsVerifier(1)); | |
225 | |
226 ASSERT_TRUE(AwaitQuiescence()); | |
227 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
228 | |
229 IncognitoDisableApp(GetProfile(1), 0); | |
230 IncognitoDisableApp(verifier(), 0); | |
231 ASSERT_TRUE(HasSameAppsAsVerifier(1)); | |
232 ASSERT_FALSE(HasSameAppsAsVerifier(0)); | |
233 | |
234 ASSERT_TRUE(AwaitQuiescence()); | |
235 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
236 } | |
237 | |
238 // TCM ID - 3718276. | |
239 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, DisableApps) { | |
240 ASSERT_TRUE(SetupSync()); | |
241 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
242 | |
243 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncable::APPS)); | |
244 InstallApp(GetProfile(0), 0); | |
245 InstallApp(verifier(), 0); | |
246 ASSERT_TRUE(AwaitQuiescence()); | |
247 ASSERT_TRUE(HasSameAppsAsVerifier(0)); | |
248 ASSERT_FALSE(HasSameAppsAsVerifier(1)); | |
249 | |
250 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncable::APPS)); | |
251 ASSERT_TRUE(AwaitQuiescence()); | |
252 | |
253 InstallAppsPendingForSync(GetProfile(0)); | |
254 InstallAppsPendingForSync(GetProfile(1)); | |
255 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
256 } | |
257 | |
258 // TCM ID - 3720303. | |
259 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, DisableSync) { | |
260 ASSERT_TRUE(SetupSync()); | |
261 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
262 | |
263 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes()); | |
264 InstallApp(GetProfile(0), 0); | |
265 InstallApp(verifier(), 0); | |
266 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Installed an app.")); | |
267 ASSERT_TRUE(HasSameAppsAsVerifier(0)); | |
268 ASSERT_FALSE(HasSameAppsAsVerifier(1)); | |
269 | |
270 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes()); | |
271 ASSERT_TRUE(AwaitQuiescence()); | |
272 | |
273 InstallAppsPendingForSync(GetProfile(0)); | |
274 InstallAppsPendingForSync(GetProfile(1)); | |
275 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); | |
276 } | |
277 | |
278 // TODO(akalin): Add tests exercising: | |
279 // - Offline installation/uninstallation behavior | |
280 // - App-specific properties | |
OLD | NEW |