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

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

Issue 1851243002: [Sync] Eliminate verifier profile from sync_integration_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not remove AwaitQuiescence() Created 4 years, 8 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/bookmark_app_helper.h" 10 #include "chrome/browser/extensions/bookmark_app_helper.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_sync_data.h" 12 #include "chrome/browser/extensions/extension_sync_data.h"
13 #include "chrome/browser/extensions/extension_sync_service.h" 13 #include "chrome/browser/extensions/extension_sync_service.h"
14 #include "chrome/browser/extensions/launch_util.h" 14 #include "chrome/browser/extensions/launch_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/sync/test/integration/apps_helper.h" 16 #include "chrome/browser/sync/test/integration/apps_helper.h"
17 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 17 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
18 #include "chrome/browser/sync/test/integration/sync_app_helper.h" 18 #include "chrome/browser/sync/test/integration/sync_app_helper.h"
19 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 19 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
20 #include "chrome/browser/sync/test/integration/sync_test.h" 20 #include "chrome/browser/sync/test/integration/sync_test.h"
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
23 #include "extensions/browser/app_sorting.h" 23 #include "extensions/browser/app_sorting.h"
24 #include "extensions/browser/extension_prefs.h" 24 #include "extensions/browser/extension_prefs.h"
25 #include "extensions/browser/extension_registry.h" 25 #include "extensions/browser/extension_registry.h"
26 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
27 #include "extensions/common/constants.h" 27 #include "extensions/common/constants.h"
28 #include "sync/api/string_ordinal.h" 28 #include "sync/api/string_ordinal.h"
29 29
30 using apps_helper::AllProfilesHaveSameAppsAsVerifier; 30 using apps_helper::AllProfilesHaveSameApps;
31 using apps_helper::CopyNTPOrdinals; 31 using apps_helper::CopyNTPOrdinals;
32 using apps_helper::DisableApp; 32 using apps_helper::DisableApp;
33 using apps_helper::EnableApp; 33 using apps_helper::EnableApp;
34 using apps_helper::FixNTPOrdinalCollisions; 34 using apps_helper::FixNTPOrdinalCollisions;
35 using apps_helper::GetAppLaunchOrdinalForApp; 35 using apps_helper::GetAppLaunchOrdinalForApp;
36 using apps_helper::HasSameAppsAsVerifier;
37 using apps_helper::IncognitoDisableApp; 36 using apps_helper::IncognitoDisableApp;
38 using apps_helper::IncognitoEnableApp; 37 using apps_helper::IncognitoEnableApp;
39 using apps_helper::InstallApp; 38 using apps_helper::InstallApp;
40 using apps_helper::InstallPlatformApp; 39 using apps_helper::InstallPlatformApp;
41 using apps_helper::SetAppLaunchOrdinalForApp; 40 using apps_helper::SetAppLaunchOrdinalForApp;
42 using apps_helper::SetPageOrdinalForApp; 41 using apps_helper::SetPageOrdinalForApp;
43 using apps_helper::UninstallApp; 42 using apps_helper::UninstallApp;
44 using apps_helper::AwaitAllProfilesHaveSameApps; 43 using apps_helper::AwaitAllProfilesHaveSameApps;
45 44
46 namespace { 45 namespace {
47 46
48 extensions::ExtensionRegistry* GetExtensionRegistry(Profile* profile) { 47 extensions::ExtensionRegistry* GetExtensionRegistry(Profile* profile) {
49 return extensions::ExtensionRegistry::Get(profile); 48 return extensions::ExtensionRegistry::Get(profile);
50 } 49 }
51 50
52 ExtensionService* GetExtensionService(Profile* profile) { 51 ExtensionService* GetExtensionService(Profile* profile) {
53 return extensions::ExtensionSystem::Get(profile)->extension_service(); 52 return extensions::ExtensionSystem::Get(profile)->extension_service();
54 } 53 }
55 54
56 } // namespace 55 } // namespace
57 56
58 class TwoClientAppsSyncTest : public SyncTest { 57 class TwoClientAppsSyncTest : public SyncTest {
59 public: 58 public:
60 TwoClientAppsSyncTest() : SyncTest(TWO_CLIENT) {} 59 TwoClientAppsSyncTest() : SyncTest(TWO_CLIENT) {
60 DisableVerifier();
61 }
61 62
62 ~TwoClientAppsSyncTest() override {} 63 ~TwoClientAppsSyncTest() override {}
63 64
64 bool TestUsesSelfNotifications() override { return false; } 65 bool TestUsesSelfNotifications() override { return false; }
65 66
66 private: 67 private:
67 DISALLOW_COPY_AND_ASSIGN(TwoClientAppsSyncTest); 68 DISALLOW_COPY_AND_ASSIGN(TwoClientAppsSyncTest);
68 }; 69 };
69 70
70 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(StartWithNoApps)) { 71 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(StartWithNoApps)) {
71 ASSERT_TRUE(SetupSync()); 72 ASSERT_TRUE(SetupSync());
72 73
73 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 74 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
74 } 75 }
75 76
76 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(StartWithSameApps)) { 77 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(StartWithSameApps)) {
77 DisableVerifier();
78 ASSERT_TRUE(SetupClients()); 78 ASSERT_TRUE(SetupClients());
79 79
80 const int kNumApps = 5; 80 const int kNumApps = 5;
81 for (int i = 0; i < kNumApps; ++i) { 81 for (int i = 0; i < kNumApps; ++i) {
82 InstallApp(GetProfile(0), i); 82 InstallApp(GetProfile(0), i);
83 InstallApp(GetProfile(1), i); 83 InstallApp(GetProfile(1), i);
84 } 84 }
85 85
86 ASSERT_TRUE(SetupSync()); 86 ASSERT_TRUE(SetupSync());
87 87
88 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 88 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
89 } 89 }
90 90
91 // Install some apps on both clients, some on only one client, some on only the 91 // Install some apps on both clients, some on only one client, some on only the
92 // other, and sync. Both clients should end up with all apps, and the app and 92 // other, and sync. Both clients should end up with all apps, and the app and
93 // page ordinals should be identical. 93 // page ordinals should be identical.
94 // Disabled, see http://crbug.com/434438 for details. 94 // Disabled, see http://crbug.com/434438 for details.
95 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, DISABLED_StartWithDifferentApps) { 95 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, DISABLED_StartWithDifferentApps) {
96 ASSERT_TRUE(SetupClients()); 96 ASSERT_TRUE(SetupClients());
97 97
98 int i = 0; 98 int i = 0;
99 99
100 const int kNumCommonApps = 5; 100 const int kNumCommonApps = 5;
101 for (int j = 0; j < kNumCommonApps; ++i, ++j) { 101 for (int j = 0; j < kNumCommonApps; ++i, ++j) {
102 InstallApp(GetProfile(0), i); 102 InstallApp(GetProfile(0), i);
103 InstallApp(GetProfile(1), i); 103 InstallApp(GetProfile(1), i);
104 InstallApp(verifier(), i);
105 } 104 }
106 105
107 const int kNumProfile0Apps = 10; 106 const int kNumProfile0Apps = 10;
108 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) { 107 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) {
109 InstallApp(GetProfile(0), i); 108 InstallApp(GetProfile(0), i);
110 InstallApp(verifier(), i);
111 CopyNTPOrdinals(GetProfile(0), verifier(), i);
112 } 109 }
113 110
114 const int kNumProfile1Apps = 10; 111 const int kNumProfile1Apps = 10;
115 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) { 112 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) {
116 InstallApp(GetProfile(1), i); 113 InstallApp(GetProfile(1), i);
117 InstallApp(verifier(), i);
118 CopyNTPOrdinals(GetProfile(1), verifier(), i);
119 } 114 }
120 115
121 const int kNumPlatformApps = 5; 116 const int kNumPlatformApps = 5;
122 for (int j = 0; j < kNumPlatformApps; ++i, ++j) { 117 for (int j = 0; j < kNumPlatformApps; ++i, ++j) {
123 InstallPlatformApp(GetProfile(1), i); 118 InstallPlatformApp(GetProfile(1), i);
124 InstallPlatformApp(verifier(), i);
125 CopyNTPOrdinals(GetProfile(1), verifier(), i);
126 } 119 }
127
128 FixNTPOrdinalCollisions(verifier());
129
130 ASSERT_TRUE(SetupSync()); 120 ASSERT_TRUE(SetupSync());
131 121
132 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 122 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
133 } 123 }
134 124
135 // Install some apps on both clients, then sync. Then install some apps on only 125 // Install some apps on both clients, then sync. Then install some apps on only
136 // one client, some on only the other, and then sync again. Both clients should 126 // one client, some on only the other, and then sync again. Both clients should
137 // end up with all apps, and the app and page ordinals should be identical. 127 // end up with all apps, and the app and page ordinals should be identical.
138 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, 128 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
139 E2E_ENABLED(InstallDifferentApps)) { 129 E2E_ENABLED(InstallDifferentApps)) {
140 DisableVerifier();
141 ASSERT_TRUE(SetupClients()); 130 ASSERT_TRUE(SetupClients());
142 131
143 int i = 0; 132 int i = 0;
144 133
145 const int kNumCommonApps = 5; 134 const int kNumCommonApps = 5;
146 for (int j = 0; j < kNumCommonApps; ++i, ++j) { 135 for (int j = 0; j < kNumCommonApps; ++i, ++j) {
147 InstallApp(GetProfile(0), i); 136 InstallApp(GetProfile(0), i);
148 InstallApp(GetProfile(1), i); 137 InstallApp(GetProfile(1), i);
149 } 138 }
150 139
151 ASSERT_TRUE(SetupSync()); 140 ASSERT_TRUE(SetupSync());
152 141
153 const int kNumProfile0Apps = 10; 142 const int kNumProfile0Apps = 10;
154 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) { 143 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) {
155 InstallApp(GetProfile(0), i); 144 InstallApp(GetProfile(0), i);
156 } 145 }
157 146
158 const int kNumProfile1Apps = 10; 147 const int kNumProfile1Apps = 10;
159 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) { 148 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) {
160 InstallApp(GetProfile(1), i); 149 InstallApp(GetProfile(1), i);
161 } 150 }
162 151
163 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 152 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
164 } 153 }
165 154
166 // TCM ID - 3711279. 155 // TCM ID - 3711279.
167 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Add)) { 156 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Add)) {
168 DisableVerifier();
169 ASSERT_TRUE(SetupSync()); 157 ASSERT_TRUE(SetupSync());
170 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 158 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
171 159
172 InstallApp(GetProfile(0), 0); 160 InstallApp(GetProfile(0), 0);
173 161
174 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 162 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
175 } 163 }
176 164
177 // TCM ID - 3706267. 165 // TCM ID - 3706267.
178 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Uninstall)) { 166 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Uninstall)) {
179 DisableVerifier();
180 ASSERT_TRUE(SetupSync()); 167 ASSERT_TRUE(SetupSync());
181 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 168 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
182 169
183 InstallApp(GetProfile(0), 0); 170 InstallApp(GetProfile(0), 0);
184 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 171 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
185 172
186 UninstallApp(GetProfile(0), 0); 173 UninstallApp(GetProfile(0), 0);
187 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 174 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
188 } 175 }
189 176
190 // Install an app on one client, then sync. Then uninstall the app on the first 177 // Install an app on one client, then sync. Then uninstall the app on the first
191 // client and sync again. Now install a new app on the first client and sync. 178 // client and sync again. Now install a new app on the first client and sync.
192 // Both client should only have the second app, with identical app and page 179 // Both client should only have the second app, with identical app and page
193 // ordinals. 180 // ordinals.
194 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, 181 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
195 E2E_ENABLED(UninstallThenInstall)) { 182 E2E_ENABLED(UninstallThenInstall)) {
196 DisableVerifier();
197 ASSERT_TRUE(SetupSync()); 183 ASSERT_TRUE(SetupSync());
198 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 184 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
199 185
200 InstallApp(GetProfile(0), 0); 186 InstallApp(GetProfile(0), 0);
201 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 187 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
202 188
203 UninstallApp(GetProfile(0), 0); 189 UninstallApp(GetProfile(0), 0);
204 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 190 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
205 191
206 InstallApp(GetProfile(0), 1); 192 InstallApp(GetProfile(0), 1);
207 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 193 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
208 } 194 }
209 195
210 // TCM ID - 3699295. 196 // TCM ID - 3699295.
211 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Merge)) { 197 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Merge)) {
212 DisableVerifier();
213 ASSERT_TRUE(SetupSync()); 198 ASSERT_TRUE(SetupSync());
214 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 199 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
215 200
216 InstallApp(GetProfile(0), 0); 201 InstallApp(GetProfile(0), 0);
217 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 202 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
218 203
219 UninstallApp(GetProfile(0), 0); 204 UninstallApp(GetProfile(0), 0);
220 205
221 InstallApp(GetProfile(0), 1); 206 InstallApp(GetProfile(0), 1);
222 InstallApp(GetProfile(0), 2); 207 InstallApp(GetProfile(0), 2);
223 208
224 InstallApp(GetProfile(1), 2); 209 InstallApp(GetProfile(1), 2);
225 InstallApp(GetProfile(1), 3); 210 InstallApp(GetProfile(1), 3);
226 211
227 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 212 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
228 } 213 }
229 214
230 // TCM ID - 7723126. 215 // TCM ID - 7723126.
231 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, 216 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
232 E2E_ENABLED(UpdateEnableDisableApp)) { 217 E2E_ENABLED(UpdateEnableDisableApp)) {
233 DisableVerifier();
234 ASSERT_TRUE(SetupSync()); 218 ASSERT_TRUE(SetupSync());
235 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 219 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
236 220
237 InstallApp(GetProfile(0), 0); 221 InstallApp(GetProfile(0), 0);
238 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 222 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
239 223
240 DisableApp(GetProfile(0), 0); 224 DisableApp(GetProfile(0), 0);
241 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 225 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
242 226
243 EnableApp(GetProfile(1), 0); 227 EnableApp(GetProfile(1), 0);
244 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 228 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
245 } 229 }
246 230
247 // TCM ID - 7706637. 231 // TCM ID - 7706637.
248 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, 232 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
249 E2E_ENABLED(UpdateIncognitoEnableDisable)) { 233 E2E_ENABLED(UpdateIncognitoEnableDisable)) {
250 DisableVerifier();
251 ASSERT_TRUE(SetupSync()); 234 ASSERT_TRUE(SetupSync());
252 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 235 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
253 236
254 InstallApp(GetProfile(0), 0); 237 InstallApp(GetProfile(0), 0);
255 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 238 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
256 239
257 IncognitoEnableApp(GetProfile(0), 0); 240 IncognitoEnableApp(GetProfile(0), 0);
258 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 241 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
259 242
260 IncognitoDisableApp(GetProfile(1), 0); 243 IncognitoDisableApp(GetProfile(1), 0);
261 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 244 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
262 } 245 }
263 246
264 // Install the same app on both clients, then sync. Change the page ordinal on 247 // Install the same app on both clients, then sync. Change the page ordinal on
265 // one client and sync. Both clients should have the updated page ordinal for 248 // one client and sync. Both clients should have the updated page ordinal for
266 // the app. 249 // the app.
267 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdatePageOrdinal)) { 250 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdatePageOrdinal)) {
268 DisableVerifier();
269 ASSERT_TRUE(SetupSync()); 251 ASSERT_TRUE(SetupSync());
270 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 252 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
271 253
272 syncer::StringOrdinal initial_page = 254 syncer::StringOrdinal initial_page =
273 syncer::StringOrdinal::CreateInitialOrdinal(); 255 syncer::StringOrdinal::CreateInitialOrdinal();
274 InstallApp(GetProfile(0), 0); 256 InstallApp(GetProfile(0), 0);
275 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 257 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
276 258
277 syncer::StringOrdinal second_page = initial_page.CreateAfter(); 259 syncer::StringOrdinal second_page = initial_page.CreateAfter();
278 SetPageOrdinalForApp(GetProfile(0), 0, second_page); 260 SetPageOrdinalForApp(GetProfile(0), 0, second_page);
279 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 261 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
280 } 262 }
281 263
282 // Install the same app on both clients, then sync. Change the app launch 264 // Install the same app on both clients, then sync. Change the app launch
283 // ordinal on one client and sync. Both clients should have the updated app 265 // ordinal on one client and sync. Both clients should have the updated app
284 // launch ordinal for the app. 266 // launch ordinal for the app.
285 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, 267 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
286 E2E_ENABLED(UpdateAppLaunchOrdinal)) { 268 E2E_ENABLED(UpdateAppLaunchOrdinal)) {
287 DisableVerifier();
288 ASSERT_TRUE(SetupSync()); 269 ASSERT_TRUE(SetupSync());
289 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 270 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
290 271
291 InstallApp(GetProfile(0), 0); 272 InstallApp(GetProfile(0), 0);
292 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 273 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
293 274
294 syncer::StringOrdinal initial_position = 275 syncer::StringOrdinal initial_position =
295 GetAppLaunchOrdinalForApp(GetProfile(0), 0); 276 GetAppLaunchOrdinalForApp(GetProfile(0), 0);
296 277
297 syncer::StringOrdinal second_position = initial_position.CreateAfter(); 278 syncer::StringOrdinal second_position = initial_position.CreateAfter();
298 SetAppLaunchOrdinalForApp(GetProfile(0), 0, second_position); 279 SetAppLaunchOrdinalForApp(GetProfile(0), 0, second_position);
299 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 280 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
300 } 281 }
301 282
302 // Adjust the CWS location within a page on the first client and sync. Adjust 283 // Adjust the CWS location within a page on the first client and sync. Adjust
303 // which page the CWS appears on and sync. Both clients should have the same 284 // which page the CWS appears on and sync. Both clients should have the same
304 // page and app launch ordinal values for the CWS. 285 // page and app launch ordinal values for the CWS.
305 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateCWSOrdinals)) { 286 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateCWSOrdinals)) {
306 DisableVerifier();
307 ASSERT_TRUE(SetupSync()); 287 ASSERT_TRUE(SetupSync());
308 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 288 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
309 289
310 // Change the app launch ordinal. 290 // Change the app launch ordinal.
311 syncer::StringOrdinal cws_app_launch_ordinal = 291 syncer::StringOrdinal cws_app_launch_ordinal =
312 extensions::ExtensionSystem::Get(GetProfile(0)) 292 extensions::ExtensionSystem::Get(GetProfile(0))
313 ->app_sorting() 293 ->app_sorting()
314 ->GetAppLaunchOrdinal(extensions::kWebStoreAppId); 294 ->GetAppLaunchOrdinal(extensions::kWebStoreAppId);
315 extensions::ExtensionSystem::Get(GetProfile(0)) 295 extensions::ExtensionSystem::Get(GetProfile(0))
316 ->app_sorting() 296 ->app_sorting()
317 ->SetAppLaunchOrdinal(extensions::kWebStoreAppId, 297 ->SetAppLaunchOrdinal(extensions::kWebStoreAppId,
318 cws_app_launch_ordinal.CreateAfter()); 298 cws_app_launch_ordinal.CreateAfter());
319 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 299 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
320 300
321 // Change the page ordinal. 301 // Change the page ordinal.
322 syncer::StringOrdinal cws_page_ordinal = 302 syncer::StringOrdinal cws_page_ordinal =
323 extensions::ExtensionSystem::Get(GetProfile(1)) 303 extensions::ExtensionSystem::Get(GetProfile(1))
324 ->app_sorting() 304 ->app_sorting()
325 ->GetPageOrdinal(extensions::kWebStoreAppId); 305 ->GetPageOrdinal(extensions::kWebStoreAppId);
326 extensions::ExtensionSystem::Get(GetProfile(1)) 306 extensions::ExtensionSystem::Get(GetProfile(1))
327 ->app_sorting() 307 ->app_sorting()
328 ->SetPageOrdinal(extensions::kWebStoreAppId, 308 ->SetPageOrdinal(extensions::kWebStoreAppId,
329 cws_page_ordinal.CreateAfter()); 309 cws_page_ordinal.CreateAfter());
330 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 310 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
331 } 311 }
332 312
333 // Adjust the launch type on the first client and sync. Both clients should 313 // Adjust the launch type on the first client and sync. Both clients should
334 // have the same launch type values for the CWS. 314 // have the same launch type values for the CWS.
335 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateLaunchType)) { 315 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateLaunchType)) {
336 DisableVerifier();
337 ASSERT_TRUE(SetupSync()); 316 ASSERT_TRUE(SetupSync());
338 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 317 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
339 318
340 // Change the launch type to window. 319 // Change the launch type to window.
341 extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId, 320 extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
342 extensions::LAUNCH_TYPE_WINDOW); 321 extensions::LAUNCH_TYPE_WINDOW);
343 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 322 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
344 ASSERT_EQ( 323 ASSERT_EQ(
345 extensions::GetLaunchTypePrefValue( 324 extensions::GetLaunchTypePrefValue(
346 extensions::ExtensionPrefs::Get(GetProfile(0)), 325 extensions::ExtensionPrefs::Get(GetProfile(0)),
347 extensions::kWebStoreAppId), 326 extensions::kWebStoreAppId),
348 extensions::LAUNCH_TYPE_WINDOW); 327 extensions::LAUNCH_TYPE_WINDOW);
349 328
350 // Change the launch type to regular tab. 329 // Change the launch type to regular tab.
351 extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId, 330 extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
352 extensions::LAUNCH_TYPE_REGULAR); 331 extensions::LAUNCH_TYPE_REGULAR);
353 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 332 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
354 333
355 ASSERT_EQ( 334 ASSERT_EQ(
356 extensions::GetLaunchTypePrefValue( 335 extensions::GetLaunchTypePrefValue(
357 extensions::ExtensionPrefs::Get(GetProfile(0)), 336 extensions::ExtensionPrefs::Get(GetProfile(0)),
358 extensions::kWebStoreAppId), 337 extensions::kWebStoreAppId),
359 extensions::LAUNCH_TYPE_REGULAR); 338 extensions::LAUNCH_TYPE_REGULAR);
360 } 339 }
361 340
362 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) { 341 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) {
363 ASSERT_TRUE(SetupSync()); 342 ASSERT_TRUE(SetupSync());
364 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); 343 ASSERT_TRUE(AllProfilesHaveSameApps());
365 344
366 extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId, 345 extensions::SetLaunchType(GetProfile(1), extensions::kWebStoreAppId,
367 extensions::LAUNCH_TYPE_REGULAR); 346 extensions::LAUNCH_TYPE_REGULAR);
368 extensions::SetLaunchType(verifier(), extensions::kWebStoreAppId,
369 extensions::LAUNCH_TYPE_REGULAR);
370 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 347 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
371 348
372 const extensions::Extension* extension = 349 const extensions::Extension* extension =
373 GetExtensionRegistry(GetProfile(1))->GetExtensionById( 350 GetExtensionRegistry(GetProfile(1))->GetExtensionById(
374 extensions::kWebStoreAppId, 351 extensions::kWebStoreAppId,
375 extensions::ExtensionRegistry::EVERYTHING); 352 extensions::ExtensionRegistry::EVERYTHING);
376 ASSERT_TRUE(extension); 353 ASSERT_TRUE(extension);
377 354
378 ExtensionSyncService* extension_sync_service = 355 ExtensionSyncService* extension_sync_service =
379 ExtensionSyncService::Get(GetProfile(1)); 356 ExtensionSyncService::Get(GetProfile(1));
(...skipping 15 matching lines...) Expand all
395 original_data.page_ordinal(), 372 original_data.page_ordinal(),
396 extensions::NUM_LAUNCH_TYPES); 373 extensions::NUM_LAUNCH_TYPES);
397 extension_sync_service->ApplySyncData(invalid_launch_type_data); 374 extension_sync_service->ApplySyncData(invalid_launch_type_data);
398 375
399 // The launch type should remain the same. 376 // The launch type should remain the same.
400 ASSERT_TRUE(AwaitAllProfilesHaveSameApps()); 377 ASSERT_TRUE(AwaitAllProfilesHaveSameApps());
401 } 378 }
402 379
403 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkApp) { 380 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkApp) {
404 ASSERT_TRUE(SetupSync()); 381 ASSERT_TRUE(SetupSync());
405 ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier()); 382 ASSERT_TRUE(AllProfilesHaveSameApps());
406 383
407 size_t num_extensions = 384 size_t num_extensions =
408 GetExtensionRegistry(GetProfile(0))->enabled_extensions().size(); 385 GetExtensionRegistry(GetProfile(0))->enabled_extensions().size();
409 386
410 WebApplicationInfo web_app_info; 387 WebApplicationInfo web_app_info;
411 web_app_info.app_url = GURL("http://www.chromium.org"); 388 web_app_info.app_url = GURL("http://www.chromium.org");
412 web_app_info.title = base::UTF8ToUTF16("Test name"); 389 web_app_info.title = base::UTF8ToUTF16("Test name");
413 web_app_info.description = base::UTF8ToUTF16("Test description"); 390 web_app_info.description = base::UTF8ToUTF16("Test description");
414 ++num_extensions; 391 ++num_extensions;
415 { 392 {
416 content::WindowedNotificationObserver windowed_observer( 393 content::WindowedNotificationObserver windowed_observer(
417 extensions::NOTIFICATION_CRX_INSTALLER_DONE, 394 extensions::NOTIFICATION_CRX_INSTALLER_DONE,
418 content::NotificationService::AllSources()); 395 content::NotificationService::AllSources());
419 extensions::CreateOrUpdateBookmarkApp(GetExtensionService(GetProfile(0)), 396 extensions::CreateOrUpdateBookmarkApp(GetExtensionService(GetProfile(0)),
420 &web_app_info); 397 &web_app_info);
421 windowed_observer.Wait(); 398 windowed_observer.Wait();
422 EXPECT_EQ(num_extensions, 399 EXPECT_EQ(num_extensions,
423 GetExtensionRegistry(GetProfile(0))->enabled_extensions().size()); 400 GetExtensionRegistry(GetProfile(0))->enabled_extensions().size());
424 } 401 }
425 { 402 {
426 content::WindowedNotificationObserver windowed_observer(
427 extensions::NOTIFICATION_CRX_INSTALLER_DONE,
428 content::NotificationService::AllSources());
429 extensions::CreateOrUpdateBookmarkApp(GetExtensionService(verifier()),
430 &web_app_info);
431 windowed_observer.Wait();
432 EXPECT_EQ(num_extensions,
433 GetExtensionRegistry(verifier())->enabled_extensions().size());
434 }
435 {
436 // Wait for the synced app to install. 403 // Wait for the synced app to install.
437 content::WindowedNotificationObserver windowed_observer( 404 content::WindowedNotificationObserver windowed_observer(
438 extensions::NOTIFICATION_CRX_INSTALLER_DONE, 405 extensions::NOTIFICATION_CRX_INSTALLER_DONE,
439 base::Bind(&AllProfilesHaveSameAppsAsVerifier)); 406 base::Bind(&AllProfilesHaveSameApps));
440 windowed_observer.Wait(); 407 windowed_observer.Wait();
441 } 408 }
442 } 409 }
443 410
444 // TODO(akalin): Add tests exercising: 411 // TODO(akalin): Add tests exercising:
445 // - Offline installation/uninstallation behavior 412 // - Offline installation/uninstallation behavior
446 // - App-specific properties 413 // - App-specific properties
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698