Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / test / integration / two_client_apps_sync_test.cc
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.
4
5 #include "base/basictypes.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/bookmark_app_helper.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/launch_util.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sync/test/integration/apps_helper.h"
13 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
14 #include "chrome/browser/sync/test/integration/sync_app_helper.h"
15 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
16 #include "chrome/browser/sync/test/integration/sync_test.h"
17 #include "chrome/common/extensions/extension_constants.h"
18 #include "content/public/browser/notification_service.h"
19 #include "content/public/test/test_utils.h"
20 #include "extensions/browser/app_sorting.h"
21 #include "extensions/browser/extension_prefs.h"
22 #include "extensions/browser/extension_registry.h"
23 #include "sync/api/string_ordinal.h"
24
25 using apps_helper::AllProfilesHaveSameAppsAsVerifier;
26 using apps_helper::CopyNTPOrdinals;
27 using apps_helper::DisableApp;
28 using apps_helper::EnableApp;
29 using apps_helper::FixNTPOrdinalCollisions;
30 using apps_helper::GetAppLaunchOrdinalForApp;
31 using apps_helper::HasSameAppsAsVerifier;
32 using apps_helper::IncognitoDisableApp;
33 using apps_helper::IncognitoEnableApp;
34 using apps_helper::InstallApp;
35 using apps_helper::InstallAppsPendingForSync;
36 using apps_helper::InstallPlatformApp;
37 using apps_helper::SetAppLaunchOrdinalForApp;
38 using apps_helper::SetPageOrdinalForApp;
39 using apps_helper::UninstallApp;
40 using sync_integration_test_util::AwaitCommitActivityCompletion;
41
42 class TwoClientAppsSyncTest : public SyncTest {
43  public:
44   TwoClientAppsSyncTest() : SyncTest(TWO_CLIENT) {}
45
46   virtual ~TwoClientAppsSyncTest() {}
47
48  private:
49   DISALLOW_COPY_AND_ASSIGN(TwoClientAppsSyncTest);
50 };
51
52 class LegacyTwoClientAppsSyncTest : public SyncTest {
53  public:
54   LegacyTwoClientAppsSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {}
55
56   virtual ~LegacyTwoClientAppsSyncTest() {}
57
58  private:
59   DISALLOW_COPY_AND_ASSIGN(LegacyTwoClientAppsSyncTest);
60 };
61
62 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithNoApps) {
63   ASSERT_TRUE(SetupSync());
64
65   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
66 }
67
68 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithSameApps) {
69   ASSERT_TRUE(SetupClients());
70
71   const int kNumApps = 5;
72   for (int i = 0; i < kNumApps; ++i) {
73     InstallApp(GetProfile(0), i);
74     InstallApp(GetProfile(1), i);
75     InstallApp(verifier(), i);
76   }
77
78   ASSERT_TRUE(SetupSync());
79
80   ASSERT_TRUE(AwaitQuiescence());
81
82   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
83 }
84
85 // Install some apps on both clients, some on only one client, some on only the
86 // other, and sync.  Both clients should end up with all apps, and the app and
87 // page ordinals should be identical.
88 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, StartWithDifferentApps) {
89   ASSERT_TRUE(SetupClients());
90
91   int i = 0;
92
93   const int kNumCommonApps = 5;
94   for (int j = 0; j < kNumCommonApps; ++i, ++j) {
95     InstallApp(GetProfile(0), i);
96     InstallApp(GetProfile(1), i);
97     InstallApp(verifier(), i);
98   }
99
100   const int kNumProfile0Apps = 10;
101   for (int j = 0; j < kNumProfile0Apps; ++i, ++j) {
102     InstallApp(GetProfile(0), i);
103     InstallApp(verifier(), i);
104     CopyNTPOrdinals(GetProfile(0), verifier(), i);
105   }
106
107   const int kNumProfile1Apps = 10;
108   for (int j = 0; j < kNumProfile1Apps; ++i, ++j) {
109     InstallApp(GetProfile(1), i);
110     InstallApp(verifier(), i);
111     CopyNTPOrdinals(GetProfile(1), verifier(), i);
112   }
113
114   const int kNumPlatformApps = 5;
115   for (int j = 0; j < kNumPlatformApps; ++i, ++j) {
116     InstallPlatformApp(GetProfile(1), i);
117     InstallPlatformApp(verifier(), i);
118     CopyNTPOrdinals(GetProfile(1), verifier(), i);
119   }
120
121   FixNTPOrdinalCollisions(verifier());
122
123   ASSERT_TRUE(SetupSync());
124
125   ASSERT_TRUE(AwaitQuiescence());
126
127   InstallAppsPendingForSync(GetProfile(0));
128   InstallAppsPendingForSync(GetProfile(1));
129
130   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
131 }
132
133 // Install some apps on both clients, then sync.  Then install some apps on only
134 // one client, some on only the other, and then sync again.  Both clients should
135 // end up with all apps, and the app and page ordinals should be identical.
136 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, InstallDifferentApps) {
137   ASSERT_TRUE(SetupClients());
138
139   int i = 0;
140
141   const int kNumCommonApps = 5;
142   for (int j = 0; j < kNumCommonApps; ++i, ++j) {
143     InstallApp(GetProfile(0), i);
144     InstallApp(GetProfile(1), i);
145     InstallApp(verifier(), i);
146   }
147
148   ASSERT_TRUE(SetupSync());
149
150   ASSERT_TRUE(AwaitQuiescence());
151
152   const int kNumProfile0Apps = 10;
153   for (int j = 0; j < kNumProfile0Apps; ++i, ++j) {
154     InstallApp(GetProfile(0), i);
155     InstallApp(verifier(), i);
156     CopyNTPOrdinals(GetProfile(0), verifier(), i);
157   }
158
159   const int kNumProfile1Apps = 10;
160   for (int j = 0; j < kNumProfile1Apps; ++i, ++j) {
161     InstallApp(GetProfile(1), i);
162     InstallApp(verifier(), i);
163     CopyNTPOrdinals(GetProfile(1), verifier(), i);
164   }
165
166   FixNTPOrdinalCollisions(verifier());
167
168   ASSERT_TRUE(AwaitQuiescence());
169
170   InstallAppsPendingForSync(GetProfile(0));
171   InstallAppsPendingForSync(GetProfile(1));
172
173   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
174 }
175
176 // TCM ID - 3711279.
177 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, Add) {
178   ASSERT_TRUE(SetupSync());
179   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
180
181   InstallApp(GetProfile(0), 0);
182   InstallApp(verifier(), 0);
183   ASSERT_TRUE(AwaitQuiescence());
184
185   InstallAppsPendingForSync(GetProfile(0));
186   InstallAppsPendingForSync(GetProfile(1));
187   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
188 }
189
190 // TCM ID - 3706267.
191 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, Uninstall) {
192   ASSERT_TRUE(SetupSync());
193   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
194
195   InstallApp(GetProfile(0), 0);
196   InstallApp(verifier(), 0);
197   ASSERT_TRUE(AwaitQuiescence());
198
199   InstallAppsPendingForSync(GetProfile(0));
200   InstallAppsPendingForSync(GetProfile(1));
201   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
202
203   UninstallApp(GetProfile(0), 0);
204   UninstallApp(verifier(), 0);
205   ASSERT_TRUE(AwaitQuiescence());
206   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
207 }
208
209 // Install an app on one client, then sync. Then uninstall the app on the first
210 // client and sync again. Now install a new app on the first client and sync.
211 // Both client should only have the second app, with identical app and page
212 // ordinals.
213 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UninstallThenInstall) {
214   ASSERT_TRUE(SetupSync());
215   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
216
217   InstallApp(GetProfile(0), 0);
218   InstallApp(verifier(), 0);
219   ASSERT_TRUE(AwaitQuiescence());
220
221   InstallAppsPendingForSync(GetProfile(0));
222   InstallAppsPendingForSync(GetProfile(1));
223   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
224
225   UninstallApp(GetProfile(0), 0);
226   UninstallApp(verifier(), 0);
227   ASSERT_TRUE(AwaitQuiescence());
228   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
229
230   InstallApp(GetProfile(0), 1);
231   InstallApp(verifier(), 1);
232   ASSERT_TRUE(AwaitQuiescence());
233   InstallAppsPendingForSync(GetProfile(0));
234   InstallAppsPendingForSync(GetProfile(1));
235   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
236 }
237
238 // TCM ID - 3699295.
239 // Flaky: http://crbug.com/226055
240 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, DISABLED_Merge) {
241   ASSERT_TRUE(SetupSync());
242   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
243
244   InstallApp(GetProfile(0), 0);
245   InstallApp(GetProfile(1), 0);
246   ASSERT_TRUE(AwaitQuiescence());
247
248   UninstallApp(GetProfile(0), 0);
249   InstallApp(GetProfile(0), 1);
250   InstallApp(verifier(), 1);
251
252   InstallApp(GetProfile(0), 2);
253   InstallApp(GetProfile(1), 2);
254   InstallApp(verifier(), 2);
255
256   InstallApp(GetProfile(1), 3);
257   InstallApp(verifier(), 3);
258
259   ASSERT_TRUE(AwaitQuiescence());
260   InstallAppsPendingForSync(GetProfile(0));
261   InstallAppsPendingForSync(GetProfile(1));
262   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
263 }
264
265 // TCM ID - 7723126.
266 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateEnableDisableApp) {
267   ASSERT_TRUE(SetupSync());
268   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
269
270   InstallApp(GetProfile(0), 0);
271   InstallApp(GetProfile(1), 0);
272   InstallApp(verifier(), 0);
273   ASSERT_TRUE(AwaitQuiescence());
274   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
275
276   DisableApp(GetProfile(0), 0);
277   DisableApp(verifier(), 0);
278   ASSERT_TRUE(HasSameAppsAsVerifier(0));
279   ASSERT_FALSE(HasSameAppsAsVerifier(1));
280
281   ASSERT_TRUE(AwaitQuiescence());
282   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
283
284   EnableApp(GetProfile(1), 0);
285   EnableApp(verifier(), 0);
286   ASSERT_TRUE(HasSameAppsAsVerifier(1));
287   ASSERT_FALSE(HasSameAppsAsVerifier(0));
288
289   ASSERT_TRUE(AwaitQuiescence());
290   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
291 }
292
293 // TCM ID - 7706637.
294 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateIncognitoEnableDisable) {
295   ASSERT_TRUE(SetupSync());
296   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
297
298   InstallApp(GetProfile(0), 0);
299   InstallApp(GetProfile(1), 0);
300   InstallApp(verifier(), 0);
301   ASSERT_TRUE(AwaitQuiescence());
302   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
303
304   IncognitoEnableApp(GetProfile(0), 0);
305   IncognitoEnableApp(verifier(), 0);
306   ASSERT_TRUE(HasSameAppsAsVerifier(0));
307   ASSERT_FALSE(HasSameAppsAsVerifier(1));
308
309   ASSERT_TRUE(AwaitQuiescence());
310   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
311
312   IncognitoDisableApp(GetProfile(1), 0);
313   IncognitoDisableApp(verifier(), 0);
314   ASSERT_TRUE(HasSameAppsAsVerifier(1));
315   ASSERT_FALSE(HasSameAppsAsVerifier(0));
316
317   ASSERT_TRUE(AwaitQuiescence());
318   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
319 }
320
321 // TCM ID - 3718276.
322 IN_PROC_BROWSER_TEST_F(LegacyTwoClientAppsSyncTest, DisableApps) {
323   ASSERT_TRUE(SetupSync());
324   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
325
326   ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::APPS));
327   InstallApp(GetProfile(0), 0);
328   InstallApp(verifier(), 0);
329   ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
330   ASSERT_TRUE(HasSameAppsAsVerifier(0));
331   ASSERT_FALSE(HasSameAppsAsVerifier(1));
332
333   ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::APPS));
334   ASSERT_TRUE(AwaitQuiescence());
335
336   InstallAppsPendingForSync(GetProfile(0));
337   InstallAppsPendingForSync(GetProfile(1));
338   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
339 }
340
341 // Disable sync for the second client and then install an app on the first
342 // client, then enable sync on the second client. Both clients should have the
343 // same app with identical app and page ordinals.
344 // TCM ID - 3720303.
345 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, DisableSync) {
346   ASSERT_TRUE(SetupSync());
347   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
348
349   ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
350   InstallApp(GetProfile(0), 0);
351   InstallApp(verifier(), 0);
352   ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
353   ASSERT_TRUE(HasSameAppsAsVerifier(0));
354   ASSERT_FALSE(HasSameAppsAsVerifier(1));
355
356   ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
357   ASSERT_TRUE(AwaitQuiescence());
358
359   InstallAppsPendingForSync(GetProfile(0));
360   InstallAppsPendingForSync(GetProfile(1));
361   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
362 }
363
364 // Install the same app on both clients, then sync. Change the page ordinal on
365 // one client and sync. Both clients should have the updated page ordinal for
366 // the app.
367 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdatePageOrdinal) {
368   ASSERT_TRUE(SetupSync());
369   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
370
371   syncer::StringOrdinal initial_page =
372       syncer::StringOrdinal::CreateInitialOrdinal();
373   InstallApp(GetProfile(0), 0);
374   InstallApp(GetProfile(1), 0);
375   InstallApp(verifier(), 0);
376   ASSERT_TRUE(AwaitQuiescence());
377   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
378
379   syncer::StringOrdinal second_page = initial_page.CreateAfter();
380   SetPageOrdinalForApp(GetProfile(0), 0, second_page);
381   SetPageOrdinalForApp(verifier(), 0, second_page);
382   ASSERT_TRUE(AwaitQuiescence());
383   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
384 }
385
386 // Install the same app on both clients, then sync. Change the app launch
387 // ordinal on one client and sync. Both clients should have the updated app
388 // launch ordinal for the app.
389 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateAppLaunchOrdinal) {
390   ASSERT_TRUE(SetupSync());
391   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
392
393   InstallApp(GetProfile(0), 0);
394   InstallApp(GetProfile(1), 0);
395   InstallApp(verifier(), 0);
396   ASSERT_TRUE(AwaitQuiescence());
397   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
398
399   syncer::StringOrdinal initial_position =
400       GetAppLaunchOrdinalForApp(GetProfile(0), 0);
401
402   syncer::StringOrdinal second_position = initial_position.CreateAfter();
403   SetAppLaunchOrdinalForApp(GetProfile(0), 0, second_position);
404   SetAppLaunchOrdinalForApp(verifier(), 0, second_position);
405   ASSERT_TRUE(AwaitQuiescence());
406   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
407 }
408
409 // Adjust the CWS location within a page on the first client and sync. Adjust
410 // which page the CWS appears on and sync. Both clients should have the same
411 // page and app launch ordinal values for the CWS.
412 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateCWSOrdinals) {
413   ASSERT_TRUE(SetupSync());
414   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
415
416   // Change the app launch ordinal.
417   syncer::StringOrdinal cws_app_launch_ordinal =
418       extensions::ExtensionPrefs::Get(GetProfile(0))
419           ->app_sorting()
420           ->GetAppLaunchOrdinal(extension_misc::kWebStoreAppId);
421   extensions::ExtensionPrefs::Get(GetProfile(0))
422       ->app_sorting()
423       ->SetAppLaunchOrdinal(extension_misc::kWebStoreAppId,
424                             cws_app_launch_ordinal.CreateAfter());
425   extensions::ExtensionPrefs::Get(verifier())
426       ->app_sorting()
427       ->SetAppLaunchOrdinal(extension_misc::kWebStoreAppId,
428                             cws_app_launch_ordinal.CreateAfter());
429   ASSERT_TRUE(AwaitQuiescence());
430   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
431
432   // Change the page ordinal.
433   syncer::StringOrdinal cws_page_ordinal =
434       extensions::ExtensionPrefs::Get(GetProfile(1))
435           ->app_sorting()
436           ->GetPageOrdinal(extension_misc::kWebStoreAppId);
437   extensions::ExtensionPrefs::Get(GetProfile(1))->app_sorting()->SetPageOrdinal(
438       extension_misc::kWebStoreAppId, cws_page_ordinal.CreateAfter());
439   extensions::ExtensionPrefs::Get(verifier())->app_sorting()->SetPageOrdinal(
440       extension_misc::kWebStoreAppId, cws_page_ordinal.CreateAfter());
441   ASSERT_TRUE(AwaitQuiescence());
442   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
443 }
444
445 // Adjust the launch type on the first client and sync. Both clients should
446 // have the same launch type values for the CWS.
447 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UpdateLaunchType) {
448   ASSERT_TRUE(SetupSync());
449   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
450
451   // Change the launch type to window.
452   extensions::SetLaunchType(GetProfile(1)->GetExtensionService(),
453                             extension_misc::kWebStoreAppId,
454                             extensions::LAUNCH_TYPE_WINDOW);
455   extensions::SetLaunchType(verifier()->GetExtensionService(),
456                             extension_misc::kWebStoreAppId,
457                             extensions::LAUNCH_TYPE_WINDOW);
458   ASSERT_TRUE(AwaitQuiescence());
459   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
460
461   // Change the launch type to regular tab.
462   extensions::SetLaunchType(GetProfile(1)->GetExtensionService(),
463                             extension_misc::kWebStoreAppId,
464                             extensions::LAUNCH_TYPE_REGULAR);
465   ASSERT_FALSE(HasSameAppsAsVerifier(1));
466   extensions::SetLaunchType(verifier()->GetExtensionService(),
467                             extension_misc::kWebStoreAppId,
468                             extensions::LAUNCH_TYPE_REGULAR);
469   ASSERT_TRUE(AwaitQuiescence());
470   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
471 }
472
473 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) {
474   ASSERT_TRUE(SetupSync());
475   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
476
477   extensions::SetLaunchType(GetProfile(1)->GetExtensionService(),
478                             extension_misc::kWebStoreAppId,
479                             extensions::LAUNCH_TYPE_REGULAR);
480   extensions::SetLaunchType(verifier()->GetExtensionService(),
481                             extension_misc::kWebStoreAppId,
482                             extensions::LAUNCH_TYPE_REGULAR);
483   ASSERT_TRUE(AwaitQuiescence());
484   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
485
486   const extensions::Extension* extension =
487       GetProfile(1)->GetExtensionService()->
488           GetInstalledExtension(extension_misc::kWebStoreAppId);
489   ASSERT_TRUE(extension);
490
491   ExtensionSyncService* extension_sync_service =
492       ExtensionSyncService::Get(GetProfile(1));
493
494   extensions::AppSyncData original_data(
495       extension_sync_service->GetAppSyncData(*extension));
496
497   // Create an invalid launch type and ensure it doesn't get down-synced. This
498   // simulates the case of a future launch type being added which old versions
499   // don't yet understand.
500   extensions::AppSyncData invalid_launch_type_data(
501       *extension,
502       original_data.extension_sync_data().enabled(),
503       original_data.extension_sync_data().incognito_enabled(),
504       original_data.app_launch_ordinal(),
505       original_data.page_ordinal(),
506       extensions::NUM_LAUNCH_TYPES);
507   extension_sync_service->ProcessAppSyncData(invalid_launch_type_data);
508
509   // The launch type should remain the same.
510   ASSERT_TRUE(AwaitQuiescence());
511   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
512 }
513
514 IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkApp) {
515   ASSERT_TRUE(SetupSync());
516   ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
517
518   size_t num_extensions =
519       GetProfile(0)->GetExtensionService()->extensions()->size();
520
521   WebApplicationInfo web_app_info;
522   web_app_info.app_url = GURL("http://www.chromium.org");
523   web_app_info.title = base::UTF8ToUTF16("Test name");
524   web_app_info.description = base::UTF8ToUTF16("Test description");
525   ++num_extensions;
526   {
527     content::WindowedNotificationObserver windowed_observer(
528         chrome::NOTIFICATION_CRX_INSTALLER_DONE,
529         content::NotificationService::AllSources());
530     extensions::CreateOrUpdateBookmarkApp(GetProfile(0)->GetExtensionService(),
531                                           web_app_info);
532     windowed_observer.Wait();
533     EXPECT_EQ(num_extensions,
534               extensions::ExtensionRegistry::Get(GetProfile(0))
535                   ->enabled_extensions()
536                   .size());
537   }
538   {
539     content::WindowedNotificationObserver windowed_observer(
540         chrome::NOTIFICATION_CRX_INSTALLER_DONE,
541         content::NotificationService::AllSources());
542     extensions::CreateOrUpdateBookmarkApp(verifier()->GetExtensionService(),
543                                           web_app_info);
544     windowed_observer.Wait();
545     EXPECT_EQ(num_extensions,
546               extensions::ExtensionRegistry::Get(verifier())
547                   ->enabled_extensions()
548                   .size());
549   }
550   {
551     // Wait for the synced app to install.
552     content::WindowedNotificationObserver windowed_observer(
553         chrome::NOTIFICATION_CRX_INSTALLER_DONE,
554         content::NotificationService::AllSources());
555     ASSERT_TRUE(AwaitQuiescence());
556     windowed_observer.Wait();
557     ASSERT_TRUE(AllProfilesHaveSameAppsAsVerifier());
558   }
559 }
560 // TODO(akalin): Add tests exercising:
561 //   - Offline installation/uninstallation behavior
562 //   - App-specific properties