Index: chrome/browser/sync/test/integration/two_client_app_list_sync_test.cc |
diff --git a/chrome/browser/sync/test/integration/two_client_app_list_sync_test.cc b/chrome/browser/sync/test/integration/two_client_app_list_sync_test.cc |
index 322df28a87ae696adc84afc0935285de20ffdc86..191e42fd3d679ccdce998d3f8e961e5724adeca2 100644 |
--- a/chrome/browser/sync/test/integration/two_client_app_list_sync_test.cc |
+++ b/chrome/browser/sync/test/integration/two_client_app_list_sync_test.cc |
@@ -12,12 +12,14 @@ |
#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" |
@@ -48,6 +50,31 @@ const app_list::AppListSyncableService::SyncItem* GetSyncItem( |
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 { |
@@ -393,15 +420,23 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, Move) { |
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); |
@@ -410,6 +445,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppListSyncTest, Move) { |
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 |