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/sync/test/integration/apps_helper.h"
8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
9 #include "chrome/browser/sync/test/integration/sync_app_list_helper.h"
10 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
11 #include "chrome/browser/sync/test/integration/sync_test.h"
12 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
13 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
14 #include "ui/app_list/app_list_switches.h"
16 using sync_integration_test_util::AwaitCommitActivityCompletion;
20 const size_t kNumDefaultApps = 2;
22 bool AllProfilesHaveSameAppListAsVerifier() {
23 return SyncAppListHelper::GetInstance()->
24 AllProfilesHaveSameAppListAsVerifier();
29 class SingleClientAppListSyncTest : public SyncTest {
31 SingleClientAppListSyncTest() : SyncTest(SINGLE_CLIENT) {}
33 virtual ~SingleClientAppListSyncTest() {}
36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
37 SyncTest::SetUpCommandLine(command_line);
38 command_line->AppendSwitch(app_list::switches::kEnableSyncAppList);
41 virtual bool SetupClients() OVERRIDE {
42 if (!SyncTest::SetupClients())
45 // Init SyncAppListHelper to ensure that the extension system is initialized
47 SyncAppListHelper::GetInstance();
52 DISALLOW_COPY_AND_ASSIGN(SingleClientAppListSyncTest);
55 IN_PROC_BROWSER_TEST_F(SingleClientAppListSyncTest, AppListEmpty) {
56 ASSERT_TRUE(SetupSync());
58 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
61 IN_PROC_BROWSER_TEST_F(SingleClientAppListSyncTest, AppListSomeApps) {
62 ASSERT_TRUE(SetupSync());
64 const size_t kNumApps = 5;
65 for (int i = 0; i < static_cast<int>(kNumApps); ++i) {
66 apps_helper::InstallApp(GetProfile(0), i);
67 apps_helper::InstallApp(verifier(), i);
70 app_list::AppListSyncableService* service =
71 app_list::AppListSyncableServiceFactory::GetForProfile(verifier());
72 ASSERT_EQ(kNumApps + kNumDefaultApps, service->GetNumSyncItemsForTest());
74 ASSERT_TRUE(AwaitCommitActivityCompletion(GetClient(0)->service()));
75 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());