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_test.h"
11 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
12 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "ui/app_list/app_list_switches.h"
18 const size_t kNumDefaultApps = 2;
20 bool AllProfilesHaveSameAppListAsVerifier() {
21 return SyncAppListHelper::GetInstance()->
22 AllProfilesHaveSameAppListAsVerifier();
27 class SingleClientAppListSyncTest : public SyncTest {
29 SingleClientAppListSyncTest() : SyncTest(SINGLE_CLIENT) {}
31 virtual ~SingleClientAppListSyncTest() {}
34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
35 SyncTest::SetUpCommandLine(command_line);
36 command_line->AppendSwitch(switches::kEnableSyncAppList);
39 virtual bool SetupClients() OVERRIDE {
40 if (!SyncTest::SetupClients())
43 // Init SyncAppListHelper to ensure that the extension system is initialized
45 SyncAppListHelper::GetInstance();
50 DISALLOW_COPY_AND_ASSIGN(SingleClientAppListSyncTest);
53 IN_PROC_BROWSER_TEST_F(SingleClientAppListSyncTest, AppListEmpty) {
54 ASSERT_TRUE(SetupSync());
56 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
59 IN_PROC_BROWSER_TEST_F(SingleClientAppListSyncTest, AppListSomeApps) {
60 ASSERT_TRUE(SetupSync());
62 const size_t kNumApps = 5;
63 for (int i = 0; i < static_cast<int>(kNumApps); ++i) {
64 apps_helper::InstallApp(GetProfile(0), i);
65 apps_helper::InstallApp(verifier(), i);
68 app_list::AppListSyncableService* service =
69 app_list::AppListSyncableServiceFactory::GetForProfile(verifier());
70 ASSERT_EQ(kNumApps + kNumDefaultApps, service->GetNumSyncItemsForTest());
72 ASSERT_TRUE(GetClient(0)->AwaitCommitActivityCompletion());
73 ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());