#include "chrome/browser/sync/test/integration/sync_app_list_helper.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
+#include "chrome/browser/ui/app_list/app_list_prefs.h"
#include "chrome/browser/ui/app_list/app_list_syncable_service.h"
#include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
+#include "ui/app_list/app_list_item.h"
#include "ui/app_list/app_list_model.h"
#include "ui/app_list/app_list_switches.h"
return service->GetSyncItem(app_id);
}
+// Checks that the synced changes are mirrored in AppListPrefs.
+void CheckAppInfoInPrefs(Profile* profile,
+ const std::vector<std::string>& expected_ids) {
+ app_list::AppListSyncableService* service =
+ app_list::AppListSyncableServiceFactory::GetForProfile(profile);
+
+ app_list::AppListPrefs::AppListInfoMap infos;
+
+ app_list::AppListPrefs::Get(profile)->GetAllAppListInfos(&infos);
+ EXPECT_EQ(expected_ids.size(), infos.size());
+
+ for (auto id : expected_ids) {
+ app_list::AppListItem* item =
+ service->model()->top_level_item_list()->FindItem(id);
+ ASSERT_TRUE(item);
+ // Ensure local prefs matches the model data.
+ scoped_ptr<app_list::AppListPrefs::AppListInfo> info =
+ app_list::AppListPrefs::Get(profile)->GetAppListInfo(id);
+ ASSERT_TRUE(info);
+ EXPECT_EQ(item->name(), info->name);
+ EXPECT_TRUE(item->position().Equals(info->position));
+ EXPECT_EQ(item->folder_id(), info->parent_id);
+ }
+}
+
} // namespace
class TwoClientAppListSyncTest : public SyncTest {
public:
TwoClientAppListSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {}
- virtual ~TwoClientAppListSyncTest() {}
+ ~TwoClientAppListSyncTest() override {}
// SyncTest
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ void SetUpCommandLine(CommandLine* command_line) override {
SyncTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(app_list::switches::kEnableSyncAppList);
}
- virtual bool SetupClients() OVERRIDE {
+ bool SetupClients() override {
if (!SyncTest::SetupClients())
return false;
return true;
}
- virtual bool SetupSync() OVERRIDE {
+ bool SetupSync() override {
if (!SyncTest::SetupSync())
return false;
WaitForExtensionServicesToLoad();
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
+ std::vector<std::string> app_ids;
+ // AppListPrefs should be empty since it only begins observing the model after
+ // sync starts.
+ CheckAppInfoInPrefs(GetProfile(1), app_ids);
+
const int kNumApps = 5;
for (int i = 0; i < kNumApps; ++i) {
- InstallApp(GetProfile(0), i);
+ app_ids.push_back(InstallApp(GetProfile(0), i));
InstallApp(GetProfile(1), i);
InstallApp(verifier(), i);
}
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
+ // AppListPrefs should contain the newly installed apps.
+ CheckAppInfoInPrefs(GetProfile(1), app_ids);
+
size_t first = kNumDefaultApps;
SyncAppListHelper::GetInstance()->MoveApp(
GetProfile(0), first + 1, first + 2);
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(AllProfilesHaveSameAppListAsVerifier());
+
+ // AppListPrefs should reflect the apps being moved in the model.
+ CheckAppInfoInPrefs(GetProfile(1), app_ids);
}
// Install a Default App on both clients, then sync. Remove the app on one
class TwoClientAppListSyncFolderTest : public TwoClientAppListSyncTest {
public:
TwoClientAppListSyncFolderTest() {}
- virtual ~TwoClientAppListSyncFolderTest() {}
+ ~TwoClientAppListSyncFolderTest() override {}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ void SetUpCommandLine(CommandLine* command_line) override {
TwoClientAppListSyncTest::SetUpCommandLine(command_line);
}
- virtual bool SetupClients() OVERRIDE {
+ bool SetupClients() override {
bool res = TwoClientAppListSyncTest::SetupClients();
app_list::AppListSyncableService* verifier_service =
app_list::AppListSyncableServiceFactory::GetForProfile(verifier());