1 // Copyright 2013 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.
5 #include "base/basictypes.h"
6 #include "base/command_line.h"
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/test/integration/apps_helper.h"
11 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
12 #include "chrome/browser/sync/test/integration/sync_app_list_helper.h"
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
14 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "chrome/browser/ui/app_list/app_list_prefs.h"
16 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
17 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
18 #include "content/public/browser/notification_service.h"
19 #include "content/public/test/test_utils.h"
20 #include "extensions/browser/extension_prefs.h"
21 #include "extensions/browser/extension_system.h"
22 #include "ui/app_list/app_list_item.h"
23 #include "ui/app_list/app_list_model.h"
24 #include "ui/app_list/app_list_switches.h"
26 using apps_helper::DisableApp;
27 using apps_helper::EnableApp;
28 using apps_helper::HasSameAppsAsVerifier;
29 using apps_helper::IncognitoDisableApp;
30 using apps_helper::IncognitoEnableApp;
31 using apps_helper::InstallApp;
32 using apps_helper::InstallAppsPendingForSync;
33 using apps_helper::UninstallApp;
34 using sync_integration_test_util::AwaitCommitActivityCompletion;
38 const size_t kNumDefaultApps = 2;
40 bool AllProfilesHaveSameAppListAsVerifier() {
41 return SyncAppListHelper::GetInstance()->
42 AllProfilesHaveSameAppListAsVerifier();
45 const app_list::AppListSyncableService::SyncItem* GetSyncItem(
47 const std::string& app_id) {
48 app_list::AppListSyncableService* service =
49 app_list::AppListSyncableServiceFactory::GetForProfile(profile);
50 return service->GetSyncItem(app_id);
53 // Checks that the synced changes are mirrored in AppListPrefs.
54 void CheckAppInfoInPrefs(Profile* profile,
55 const std::vector<std::string>& expected_ids) {
56 app_list::AppListSyncableService* service =
57 app_list::AppListSyncableServiceFactory::GetForProfile(profile);
59 app_list::AppListPrefs::AppListInfoMap infos;
61 app_list::AppListPrefs::Get(profile)->GetAllAppListInfos(&infos);
62 EXPECT_EQ(expected_ids.size(), infos.size());
64 for (auto id : expected_ids) {
65 app_list::AppListItem* item =
66 service->model()->top_level_item_list()->FindItem(id);
68 // Ensure local prefs matches the model data.
69 scoped_ptr<app_list::AppListPrefs::AppListInfo> info =
70 app_list::AppListPrefs::Get(profile)->GetAppListInfo(id);
72 EXPECT_EQ(item->name(), info->name);
73 EXPECT_TRUE(item->position().Equals(info->position));
74 EXPECT_EQ(item->folder_id(), info->parent_id);
80 class TwoClientAppListSyncTest : public SyncTest {
82 TwoClientAppListSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {}
84 ~TwoClientAppListSyncTest() override {}
87 void SetUpCommandLine(CommandLine* command_line) override {
88 SyncTest::SetUpCommandLine(command_line);
89 command_line->AppendSwitch(app_list::switches::kEnableSyncAppList);
92 bool SetupClients() override {
93 if (!SyncTest::SetupClients())
96 // Init SyncAppListHelper to ensure that the extension system is initialized
98 SyncAppListHelper::GetInstance();
102 bool SetupSync() override {
103 if (!SyncTest::SetupSync())
105 WaitForExtensionServicesToLoad();
110 void WaitForExtensionServicesToLoad() {
111 for (int i = 0; i < num_clients(); ++i)
112 WaitForExtensionsServiceToLoadForProfile(GetProfile(i));
113 WaitForExtensionsServiceToLoadForProfile(verifier());
116 void WaitForExtensionsServiceToLoadForProfile(Profile* profile) {
117 ExtensionService* extension_service =
118 extensions::ExtensionSystem::Get(profile)->extension_service();
119 if (extension_service && extension_service->is_ready())
121 content::WindowedNotificationObserver extensions_loaded_observer(
122 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
123 content::NotificationService::AllSources());
124 extensions_loaded_observer.Wait();
127 DISALLOW_COPY_AND_ASSIGN(TwoClientAppListSyncTest);
130 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, StartWithNoApps) {
131 ASSERT_TRUE(SetupSync());
133 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
136 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, StartWithSameApps) {
137 ASSERT_TRUE(SetupClients());
139 const int kNumApps = 5;
140 for (int i = 0; i < kNumApps; ++i) {
141 InstallApp(GetProfile(0), i);
142 InstallApp(GetProfile(1), i);
143 InstallApp(verifier(), i);
146 ASSERT_TRUE(SetupSync());
148 ASSERT_TRUE(AwaitQuiescence());
150 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
153 // Install some apps on both clients, some on only one client, some on only the
154 // other, and sync. Both clients should end up with all apps, and the app and
155 // page ordinals should be identical.
156 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, StartWithDifferentApps) {
157 ASSERT_TRUE(SetupClients());
161 const int kNumCommonApps = 5;
162 for (int j = 0; j < kNumCommonApps; ++i, ++j) {
163 InstallApp(GetProfile(0), i);
164 InstallApp(GetProfile(1), i);
165 InstallApp(verifier(), i);
168 const int kNumProfile0Apps = 10;
169 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) {
170 std::string id = InstallApp(GetProfile(0), i);
171 InstallApp(verifier(), i);
172 SyncAppListHelper::GetInstance()->CopyOrdinalsToVerifier(GetProfile(0), id);
175 const int kNumProfile1Apps = 10;
176 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) {
177 std::string id = InstallApp(GetProfile(1), i);
178 InstallApp(verifier(), i);
179 SyncAppListHelper::GetInstance()->CopyOrdinalsToVerifier(GetProfile(1), id);
182 ASSERT_TRUE(SetupSync());
184 ASSERT_TRUE(AwaitQuiescence());
186 InstallAppsPendingForSync(GetProfile(0));
187 InstallAppsPendingForSync(GetProfile(1));
189 // Verify the app lists, but ignore absolute position values, checking only
190 // relative positions (see note in app_list_syncable_service.h).
191 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
194 // Install some apps on both clients, then sync. Then install some apps on only
195 // one client, some on only the other, and then sync again. Both clients should
196 // end up with all apps, and the app and page ordinals should be identical.
197 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, InstallDifferentApps) {
198 ASSERT_TRUE(SetupClients());
202 const int kNumCommonApps = 5;
203 for (int j = 0; j < kNumCommonApps; ++i, ++j) {
204 InstallApp(GetProfile(0), i);
205 InstallApp(GetProfile(1), i);
206 InstallApp(verifier(), i);
209 ASSERT_TRUE(SetupSync());
211 ASSERT_TRUE(AwaitQuiescence());
213 const int kNumProfile0Apps = 10;
214 for (int j = 0; j < kNumProfile0Apps; ++i, ++j) {
215 std::string id = InstallApp(GetProfile(0), i);
216 InstallApp(verifier(), i);
217 SyncAppListHelper::GetInstance()->CopyOrdinalsToVerifier(GetProfile(0), id);
220 const int kNumProfile1Apps = 10;
221 for (int j = 0; j < kNumProfile1Apps; ++i, ++j) {
222 std::string id = InstallApp(GetProfile(1), i);
223 InstallApp(verifier(), i);
224 SyncAppListHelper::GetInstance()->CopyOrdinalsToVerifier(GetProfile(1), id);
227 ASSERT_TRUE(AwaitQuiescence());
229 InstallAppsPendingForSync(GetProfile(0));
230 InstallAppsPendingForSync(GetProfile(1));
232 // Verify the app lists, but ignore absolute position values, checking only
233 // relative positions (see note in app_list_syncable_service.h).
234 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
237 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, Install) {
238 ASSERT_TRUE(SetupSync());
239 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
241 InstallApp(GetProfile(0), 0);
242 InstallApp(verifier(), 0);
243 ASSERT_TRUE(AwaitQuiescence());
245 InstallAppsPendingForSync(GetProfile(0));
246 InstallAppsPendingForSync(GetProfile(1));
247 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
250 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, Uninstall) {
251 ASSERT_TRUE(SetupSync());
252 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
254 InstallApp(GetProfile(0), 0);
255 InstallApp(verifier(), 0);
256 ASSERT_TRUE(AwaitQuiescence());
258 InstallAppsPendingForSync(GetProfile(0));
259 InstallAppsPendingForSync(GetProfile(1));
260 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
262 UninstallApp(GetProfile(0), 0);
263 UninstallApp(verifier(), 0);
264 ASSERT_TRUE(AwaitQuiescence());
265 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
268 // Install an app on one client, then sync. Then uninstall the app on the first
269 // client and sync again. Now install a new app on the first client and sync.
270 // Both client should only have the second app, with identical app and page
272 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, UninstallThenInstall) {
273 ASSERT_TRUE(SetupSync());
274 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
276 InstallApp(GetProfile(0), 0);
277 InstallApp(verifier(), 0);
278 ASSERT_TRUE(AwaitQuiescence());
280 InstallAppsPendingForSync(GetProfile(0));
281 InstallAppsPendingForSync(GetProfile(1));
282 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
284 UninstallApp(GetProfile(0), 0);
285 UninstallApp(verifier(), 0);
286 ASSERT_TRUE(AwaitQuiescence());
287 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
289 InstallApp(GetProfile(0), 1);
290 InstallApp(verifier(), 1);
291 ASSERT_TRUE(AwaitQuiescence());
292 InstallAppsPendingForSync(GetProfile(0));
293 InstallAppsPendingForSync(GetProfile(1));
294 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
297 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, Merge) {
298 ASSERT_TRUE(SetupSync());
299 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
301 InstallApp(GetProfile(0), 0);
302 InstallApp(GetProfile(1), 0);
303 ASSERT_TRUE(AwaitQuiescence());
305 UninstallApp(GetProfile(0), 0);
306 InstallApp(GetProfile(0), 1);
307 InstallApp(verifier(), 1);
309 InstallApp(GetProfile(0), 2);
310 InstallApp(GetProfile(1), 2);
311 InstallApp(verifier(), 2);
313 InstallApp(GetProfile(1), 3);
314 InstallApp(verifier(), 3);
316 ASSERT_TRUE(AwaitQuiescence());
317 InstallAppsPendingForSync(GetProfile(0));
318 InstallAppsPendingForSync(GetProfile(1));
319 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
322 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, UpdateEnableDisableApp) {
323 ASSERT_TRUE(SetupSync());
324 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
326 InstallApp(GetProfile(0), 0);
327 InstallApp(GetProfile(1), 0);
328 InstallApp(verifier(), 0);
329 ASSERT_TRUE(AwaitQuiescence());
330 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
332 DisableApp(GetProfile(0), 0);
333 DisableApp(verifier(), 0);
334 ASSERT_TRUE(HasSameAppsAsVerifier(0));
335 ASSERT_FALSE(HasSameAppsAsVerifier(1));
337 ASSERT_TRUE(AwaitQuiescence());
338 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
340 EnableApp(GetProfile(1), 0);
341 EnableApp(verifier(), 0);
342 ASSERT_TRUE(HasSameAppsAsVerifier(1));
343 ASSERT_FALSE(HasSameAppsAsVerifier(0));
345 ASSERT_TRUE(AwaitQuiescence());
346 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
349 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, UpdateIncognitoEnableDisable) {
350 ASSERT_TRUE(SetupSync());
351 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
353 InstallApp(GetProfile(0), 0);
354 InstallApp(GetProfile(1), 0);
355 InstallApp(verifier(), 0);
356 ASSERT_TRUE(AwaitQuiescence());
357 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
359 IncognitoEnableApp(GetProfile(0), 0);
360 IncognitoEnableApp(verifier(), 0);
361 ASSERT_TRUE(HasSameAppsAsVerifier(0));
362 ASSERT_FALSE(HasSameAppsAsVerifier(1));
364 ASSERT_TRUE(AwaitQuiescence());
365 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
367 IncognitoDisableApp(GetProfile(1), 0);
368 IncognitoDisableApp(verifier(), 0);
369 ASSERT_TRUE(HasSameAppsAsVerifier(1));
370 ASSERT_FALSE(HasSameAppsAsVerifier(0));
372 ASSERT_TRUE(AwaitQuiescence());
373 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
376 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, DisableApps) {
377 ASSERT_TRUE(SetupSync());
378 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
380 ASSERT_TRUE(GetClient(1)->DisableSyncForDatatype(syncer::APP_LIST));
381 InstallApp(GetProfile(0), 0);
382 InstallApp(verifier(), 0);
383 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
384 ASSERT_TRUE(HasSameAppsAsVerifier(0));
385 ASSERT_FALSE(HasSameAppsAsVerifier(1));
387 ASSERT_TRUE(GetClient(1)->EnableSyncForDatatype(syncer::APP_LIST));
388 ASSERT_TRUE(AwaitQuiescence());
390 InstallAppsPendingForSync(GetProfile(0));
391 InstallAppsPendingForSync(GetProfile(1));
392 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
395 // Disable sync for the second client and then install an app on the first
396 // client, then enable sync on the second client. Both clients should have the
397 // same app with identical app and page ordinals.
398 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, DisableSync) {
399 ASSERT_TRUE(SetupSync());
400 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
402 ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
403 InstallApp(GetProfile(0), 0);
404 InstallApp(verifier(), 0);
405 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
406 ASSERT_TRUE(HasSameAppsAsVerifier(0));
407 ASSERT_FALSE(HasSameAppsAsVerifier(1));
409 ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
410 ASSERT_TRUE(AwaitQuiescence());
412 InstallAppsPendingForSync(GetProfile(0));
413 InstallAppsPendingForSync(GetProfile(1));
414 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
417 // Install some apps on both clients, then sync. Move an app on one client
418 // and sync. Both clients should have the updated position for the app.
419 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, Move) {
420 ASSERT_TRUE(SetupSync());
421 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
423 std::vector<std::string> app_ids;
424 // AppListPrefs should be empty since it only begins observing the model after
426 CheckAppInfoInPrefs(GetProfile(1), app_ids);
428 const int kNumApps = 5;
429 for (int i = 0; i < kNumApps; ++i) {
430 app_ids.push_back(InstallApp(GetProfile(0), i));
431 InstallApp(GetProfile(1), i);
432 InstallApp(verifier(), i);
434 ASSERT_TRUE(AwaitQuiescence());
435 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
437 // AppListPrefs should contain the newly installed apps.
438 CheckAppInfoInPrefs(GetProfile(1), app_ids);
440 size_t first = kNumDefaultApps;
441 SyncAppListHelper::GetInstance()->MoveApp(
442 GetProfile(0), first + 1, first + 2);
443 SyncAppListHelper::GetInstance()->MoveApp(
444 verifier(), first + 1, first + 2);
446 ASSERT_TRUE(AwaitQuiescence());
447 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
449 // AppListPrefs should reflect the apps being moved in the model.
450 CheckAppInfoInPrefs(GetProfile(1), app_ids);
453 // Install a Default App on both clients, then sync. Remove the app on one
454 // client and sync. Ensure that the app is removed on the other client and
455 // that a REMOVE_DEFAULT_APP entry exists.
456 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, RemoveDefault) {
457 ASSERT_TRUE(SetupClients());
458 ASSERT_TRUE(SetupSync());
460 // Install a non-default app.
461 InstallApp(GetProfile(0), 0);
462 InstallApp(GetProfile(1), 0);
463 InstallApp(verifier(), 0);
465 // Install a default app in Profile 0 only.
466 const int default_app_index = 1;
467 std::string default_app_id = InstallApp(GetProfile(0), default_app_index);
468 InstallApp(verifier(), default_app_index);
469 SyncAppListHelper::GetInstance()->CopyOrdinalsToVerifier(
470 GetProfile(0), default_app_id);
472 ASSERT_TRUE(AwaitQuiescence());
473 InstallAppsPendingForSync(GetProfile(0));
474 InstallAppsPendingForSync(GetProfile(1));
475 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
477 // Flag Default app in Profile 1.
478 extensions::ExtensionPrefs::Get(GetProfile(1))
479 ->UpdateExtensionPref(default_app_id,
480 "was_installed_by_default",
481 new base::FundamentalValue(true));
483 // Remove the default app in Profile 0 and verifier, ensure it was removed
485 UninstallApp(GetProfile(0), default_app_index);
486 UninstallApp(verifier(), default_app_index);
487 ASSERT_TRUE(AwaitQuiescence());
488 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
490 // Ensure that a REMOVE_DEFAULT_APP SyncItem entry exists in Profile 1.
491 const app_list::AppListSyncableService::SyncItem* sync_item =
492 GetSyncItem(GetProfile(1), default_app_id);
493 ASSERT_TRUE(sync_item);
494 ASSERT_EQ(sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP,
495 sync_item->item_type);
497 // Re-Install the same app in Profile 0.
498 std::string app_id2 = InstallApp(GetProfile(0), default_app_index);
499 EXPECT_EQ(default_app_id, app_id2);
500 InstallApp(verifier(), default_app_index);
501 sync_item = GetSyncItem(GetProfile(0), app_id2);
502 EXPECT_EQ(sync_pb::AppListSpecifics::TYPE_APP, sync_item->item_type);
504 ASSERT_TRUE(AwaitQuiescence());
505 InstallAppsPendingForSync(GetProfile(0));
506 InstallAppsPendingForSync(GetProfile(1));
507 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
509 // Ensure that the REMOVE_DEFAULT_APP SyncItem entry in Profile 1 is replaced
510 // with an APP entry after an install.
511 sync_item = GetSyncItem(GetProfile(1), app_id2);
512 ASSERT_TRUE(sync_item);
513 EXPECT_EQ(sync_pb::AppListSpecifics::TYPE_APP, sync_item->item_type);
516 #if !defined(OS_MACOSX)
518 class TwoClientAppListSyncFolderTest : public TwoClientAppListSyncTest {
520 TwoClientAppListSyncFolderTest() {}
521 ~TwoClientAppListSyncFolderTest() override {}
523 void SetUpCommandLine(CommandLine* command_line) override {
524 TwoClientAppListSyncTest::SetUpCommandLine(command_line);
527 bool SetupClients() override {
528 bool res = TwoClientAppListSyncTest::SetupClients();
529 app_list::AppListSyncableService* verifier_service =
530 app_list::AppListSyncableServiceFactory::GetForProfile(verifier());
531 verifier_service->model()->SetFoldersEnabled(true);
536 DISALLOW_COPY_AND_ASSIGN(TwoClientAppListSyncFolderTest);
539 // Install some apps on both clients, then sync. Move an app on one client
540 // to a folder and sync. The app lists, including folders, should match.
541 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncFolderTest, MoveToFolder) {
542 ASSERT_TRUE(SetupSync());
543 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
545 const int kNumApps = 5;
546 for (int i = 0; i < kNumApps; ++i) {
547 InstallApp(GetProfile(0), i);
548 InstallApp(GetProfile(1), i);
549 InstallApp(verifier(), i);
551 ASSERT_TRUE(AwaitQuiescence());
552 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
555 std::string folder_id = "Folder 0";
556 SyncAppListHelper::GetInstance()->MoveAppToFolder(
557 GetProfile(0), index, folder_id);
558 SyncAppListHelper::GetInstance()->MoveAppToFolder(
559 verifier(), index, folder_id);
561 ASSERT_TRUE(AwaitQuiescence());
562 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
565 IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncFolderTest, FolderAddRemove) {
566 ASSERT_TRUE(SetupSync());
567 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
569 const int kNumApps = 10;
570 for (int i = 0; i < kNumApps; ++i) {
571 InstallApp(GetProfile(0), i);
572 InstallApp(GetProfile(1), i);
573 InstallApp(verifier(), i);
575 ASSERT_TRUE(AwaitQuiescence());
576 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
578 // Move a few apps to a folder.
579 const size_t kNumAppsToMove = 3;
580 std::string folder_id = "Folder 0";
581 // The folder will be created at the end of the list; always move the
582 // first non default item in the list.
583 size_t item_index = kNumDefaultApps;
584 for (size_t i = 0; i < kNumAppsToMove; ++i) {
585 SyncAppListHelper::GetInstance()->MoveAppToFolder(
586 GetProfile(0), item_index, folder_id);
587 SyncAppListHelper::GetInstance()->MoveAppToFolder(
588 verifier(), item_index, folder_id);
590 ASSERT_TRUE(AwaitQuiescence());
591 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
593 // Remove one app from the folder.
594 SyncAppListHelper::GetInstance()->MoveAppFromFolder(
595 GetProfile(0), 0, folder_id);
596 SyncAppListHelper::GetInstance()->MoveAppFromFolder(
597 verifier(), 0, folder_id);
599 ASSERT_TRUE(AwaitQuiescence());
600 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
602 // Remove remaining apps from the folder (deletes folder).
603 for (size_t i = 1; i < kNumAppsToMove; ++i) {
604 SyncAppListHelper::GetInstance()->MoveAppFromFolder(
605 GetProfile(0), 0, folder_id);
606 SyncAppListHelper::GetInstance()->MoveAppFromFolder(
607 verifier(), 0, folder_id);
610 ASSERT_TRUE(AwaitQuiescence());
611 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
613 // Move apps back to a (new) folder.
614 for (size_t i = 0; i < kNumAppsToMove; ++i) {
615 SyncAppListHelper::GetInstance()->MoveAppToFolder(
616 GetProfile(0), item_index, folder_id);
617 SyncAppListHelper::GetInstance()->MoveAppToFolder(
618 verifier(), item_index, folder_id);
621 ASSERT_TRUE(AwaitQuiescence());
622 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
625 #endif // !defined(OS_MACOSX)