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