Commit a974891d authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Add plumbing and sync integration tests for pseudo-USS

A USS bridge has been recently introduced in
https://chromium-review.googlesource.com/c/chromium/src/+/1164742 to
allow integrating legacy SyncableService sync datatypes into the most
modern USS architecture.

In this patch, a controller is introduced to do the necessary plumbing
and use the new codepath behind feature toggles. We do this for a first
set of datatypes that are simplest, i.e. the ones that live in the UI
thread and without complex logic in their controllers. Follow-up
patches will add support for more.

Bug: 870624
Change-Id: Ibdcc01133103296bd9c53e165a37b63cc32dcb87
Reviewed-on: https://chromium-review.googlesource.com/1251102Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595036}
parent 2c6cdbef
......@@ -2927,6 +2927,8 @@ jumbo_split_static_library("browser") {
"status_icons/desktop_notification_balloon.h",
"sync/glue/extension_data_type_controller.cc",
"sync/glue/extension_data_type_controller.h",
"sync/glue/extension_model_type_controller.cc",
"sync/glue/extension_model_type_controller.h",
"sync/glue/extension_setting_data_type_controller.cc",
"sync/glue/extension_setting_data_type_controller.h",
"sync/glue/theme_data_type_controller.cc",
......
......@@ -68,10 +68,13 @@
#include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/driver/async_directory_type_controller.h"
#include "components/sync/driver/sync_api_component_factory.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/driver/sync_util.h"
#include "components/sync/driver/syncable_service_based_model_type_controller.h"
#include "components/sync/engine/passive_model_worker.h"
#include "components/sync/engine/sequenced_model_worker.h"
#include "components/sync/engine/ui_model_worker.h"
#include "components/sync/model/model_type_store_service.h"
#include "components/sync/user_events/user_event_service.h"
#include "components/sync_bookmarks/bookmark_sync_service.h"
#include "components/sync_preferences/pref_service_syncable.h"
......@@ -93,6 +96,7 @@
#include "chrome/browser/extensions/api/storage/settings_sync_util.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#include "chrome/browser/sync/glue/extension_data_type_controller.h"
#include "chrome/browser/sync/glue/extension_model_type_controller.h"
#include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
......@@ -124,6 +128,7 @@
using content::BrowserThread;
#if BUILDFLAG(ENABLE_EXTENSIONS)
using browser_sync::ExtensionDataTypeController;
using browser_sync::ExtensionModelTypeController;
using browser_sync::ExtensionSettingDataTypeController;
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
using browser_sync::SearchEngineDataTypeController;
......@@ -295,16 +300,32 @@ ChromeSyncClient::CreateDataTypeControllers(
// App sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::APPS)) {
if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSApps)) {
controllers.push_back(std::make_unique<ExtensionModelTypeController>(
syncer::APPS, GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&ChromeSyncClient::GetSyncableServiceForType,
base::Unretained(this), syncer::APPS),
profile_));
} else {
controllers.push_back(std::make_unique<ExtensionDataTypeController>(
syncer::APPS, error_callback, this, profile_));
}
}
// Extension sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::EXTENSIONS)) {
if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSExtensions)) {
controllers.push_back(std::make_unique<ExtensionModelTypeController>(
syncer::EXTENSIONS, GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&ChromeSyncClient::GetSyncableServiceForType,
base::Unretained(this), syncer::EXTENSIONS),
profile_));
} else {
controllers.push_back(std::make_unique<ExtensionDataTypeController>(
syncer::EXTENSIONS, error_callback, this, profile_));
}
}
// Extension setting sync is enabled by default. Register unless explicitly
// disabled.
......@@ -324,9 +345,17 @@ ChromeSyncClient::CreateDataTypeControllers(
#if !defined(OS_ANDROID)
// Theme sync is enabled by default. Register unless explicitly disabled.
if (!disabled_types.Has(syncer::THEMES)) {
if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSThemes)) {
controllers.push_back(std::make_unique<ExtensionModelTypeController>(
syncer::THEMES, GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&ChromeSyncClient::GetSyncableServiceForType,
base::Unretained(this), syncer::THEMES),
profile_));
} else {
controllers.push_back(std::make_unique<ThemeDataTypeController>(
error_callback, this, profile_));
}
}
// Search Engine sync is enabled by default. Register unless explicitly
// disabled.
......@@ -338,18 +367,34 @@ ChromeSyncClient::CreateDataTypeControllers(
#endif // !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_APP_LIST)
if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSAppList)) {
controllers.push_back(
std::make_unique<syncer::SyncableServiceBasedModelTypeController>(
syncer::APP_LIST, GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&ChromeSyncClient::GetSyncableServiceForType,
base::Unretained(this), syncer::APP_LIST)));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::APP_LIST, error_callback, this, syncer::GROUP_UI,
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})));
}
#endif // BUILDFLAG(ENABLE_APP_LIST)
#if defined(OS_LINUX) || defined(OS_WIN)
// Dictionary sync is enabled by default.
if (!disabled_types.Has(syncer::DICTIONARY)) {
if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSDictionary)) {
controllers.push_back(
std::make_unique<syncer::SyncableServiceBasedModelTypeController>(
syncer::DICTIONARY, GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&ChromeSyncClient::GetSyncableServiceForType,
base::Unretained(this), syncer::DICTIONARY)));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::DICTIONARY, error_callback, this, syncer::GROUP_UI,
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::UI})));
}
}
#endif // defined(OS_LINUX) || defined(OS_WIN)
#if defined(OS_CHROMEOS)
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/glue/extension_model_type_controller.h"
#include <utility>
#include "chrome/browser/profiles/profile.h"
#include "extensions/browser/extension_system.h"
namespace browser_sync {
ExtensionModelTypeController::ExtensionModelTypeController(
syncer::ModelType type,
syncer::OnceModelTypeStoreFactory store_factory,
SyncableServiceProvider syncable_service_provider,
Profile* profile)
: SyncableServiceBasedModelTypeController(
type,
std::move(store_factory),
std::move(syncable_service_provider)),
profile_(profile) {
DCHECK(type == syncer::EXTENSIONS || type == syncer::APPS ||
type == syncer::THEMES);
}
ExtensionModelTypeController::~ExtensionModelTypeController() {}
void ExtensionModelTypeController::LoadModels(
const syncer::ConfigureContext& configure_context,
const ModelLoadCallback& model_load_callback) {
DCHECK(CalledOnValidThread());
extensions::ExtensionSystem::Get(profile_)->InitForRegularProfile(
/*extensions_enabled=*/true);
ModelTypeController::LoadModels(configure_context, model_load_callback);
}
} // namespace browser_sync
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SYNC_GLUE_EXTENSION_MODEL_TYPE_CONTROLLER_H_
#define CHROME_BROWSER_SYNC_GLUE_EXTENSION_MODEL_TYPE_CONTROLLER_H_
#include "base/macros.h"
#include "components/sync/driver/syncable_service_based_model_type_controller.h"
class Profile;
namespace browser_sync {
// Controller with custom logic to start the extensions machinery when sync is
// starting. Analogous to ExtensionDataTypeController and
// ThemeDataTypeController.
class ExtensionModelTypeController
: public syncer::SyncableServiceBasedModelTypeController {
public:
ExtensionModelTypeController(
syncer::ModelType type,
syncer::OnceModelTypeStoreFactory store_factory,
SyncableServiceProvider syncable_service_provider,
Profile* profile);
~ExtensionModelTypeController() override;
// DataTypeController overrides.
void LoadModels(const syncer::ConfigureContext& configure_context,
const ModelLoadCallback& model_load_callback) override;
private:
Profile* const profile_;
DISALLOW_COPY_AND_ASSIGN(ExtensionModelTypeController);
};
} // namespace browser_sync
#endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_MODEL_TYPE_CONTROLLER_H_
......@@ -3,16 +3,36 @@
// found in the LICENSE file.
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/sync/test/integration/apps_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h"
namespace {
using apps_helper::AllProfilesHaveSameApps;
using apps_helper::InstallApp;
using apps_helper::InstallPlatformApp;
class SingleClientAppsSyncTest : public SyncTest {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(switches::kSyncPseudoUSSApps);
} else {
override_features_.InitAndDisableFeature(switches::kSyncPseudoUSSApps);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
class SingleClientAppsSyncTest : public UssSwitchToggler, public SyncTest {
public:
SingleClientAppsSyncTest() : SyncTest(SINGLE_CLIENT) {}
......@@ -22,12 +42,12 @@ class SingleClientAppsSyncTest : public SyncTest {
DISALLOW_COPY_AND_ASSIGN(SingleClientAppsSyncTest);
};
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithNoApps) {
IN_PROC_BROWSER_TEST_P(SingleClientAppsSyncTest, StartWithNoApps) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameApps());
}
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomeLegacyApps) {
IN_PROC_BROWSER_TEST_P(SingleClientAppsSyncTest, StartWithSomeLegacyApps) {
ASSERT_TRUE(SetupClients());
const int kNumApps = 5;
......@@ -40,7 +60,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomeLegacyApps) {
ASSERT_TRUE(AllProfilesHaveSameApps());
}
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomePlatformApps) {
IN_PROC_BROWSER_TEST_P(SingleClientAppsSyncTest, StartWithSomePlatformApps) {
ASSERT_TRUE(SetupClients());
const int kNumApps = 5;
......@@ -53,7 +73,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, StartWithSomePlatformApps) {
ASSERT_TRUE(AllProfilesHaveSameApps());
}
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeLegacyApps) {
IN_PROC_BROWSER_TEST_P(SingleClientAppsSyncTest, InstallSomeLegacyApps) {
ASSERT_TRUE(SetupSync());
const int kNumApps = 5;
......@@ -66,7 +86,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeLegacyApps) {
ASSERT_TRUE(AllProfilesHaveSameApps());
}
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomePlatformApps) {
IN_PROC_BROWSER_TEST_P(SingleClientAppsSyncTest, InstallSomePlatformApps) {
ASSERT_TRUE(SetupSync());
const int kNumApps = 5;
......@@ -79,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomePlatformApps) {
ASSERT_TRUE(AllProfilesHaveSameApps());
}
IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeApps) {
IN_PROC_BROWSER_TEST_P(SingleClientAppsSyncTest, InstallSomeApps) {
ASSERT_TRUE(SetupSync());
int i = 0;
......@@ -99,3 +119,9 @@ IN_PROC_BROWSER_TEST_F(SingleClientAppsSyncTest, InstallSomeApps) {
ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
ASSERT_TRUE(AllProfilesHaveSameApps());
}
INSTANTIATE_TEST_CASE_P(USS,
SingleClientAppsSyncTest,
::testing::Values(false, true));
} // namespace
......@@ -3,12 +3,35 @@
// found in the LICENSE file.
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/sync/test/integration/dictionary_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h"
class SingleClientDictionarySyncTest : public SyncTest {
namespace {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(
switches::kSyncPseudoUSSDictionary);
} else {
override_features_.InitAndDisableFeature(
switches::kSyncPseudoUSSDictionary);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
class SingleClientDictionarySyncTest : public UssSwitchToggler,
public SyncTest {
public:
SingleClientDictionarySyncTest() : SyncTest(SINGLE_CLIENT) {}
~SingleClientDictionarySyncTest() override {}
......@@ -17,7 +40,7 @@ class SingleClientDictionarySyncTest : public SyncTest {
DISALLOW_COPY_AND_ASSIGN(SingleClientDictionarySyncTest);
};
IN_PROC_BROWSER_TEST_F(SingleClientDictionarySyncTest, Sanity) {
IN_PROC_BROWSER_TEST_P(SingleClientDictionarySyncTest, Sanity) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
ASSERT_TRUE(dictionary_helper::DictionariesMatch());
......@@ -31,3 +54,9 @@ IN_PROC_BROWSER_TEST_F(SingleClientDictionarySyncTest, Sanity) {
ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
ASSERT_TRUE(dictionary_helper::DictionariesMatch());
}
INSTANTIATE_TEST_CASE_P(USS,
SingleClientDictionarySyncTest,
::testing::Values(false, true));
} // namespace
......@@ -3,20 +3,43 @@
// found in the LICENSE file.
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/sync/test/integration/await_match_status_change_checker.h"
#include "chrome/browser/sync/test/integration/extensions_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/test/fake_server/fake_server.h"
namespace {
using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier;
using extensions_helper::DisableExtension;
using extensions_helper::GetInstalledExtensions;
using extensions_helper::InstallExtension;
using extensions_helper::InstallExtensionForAllProfiles;
class SingleClientExtensionsSyncTest : public SyncTest {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(
switches::kSyncPseudoUSSExtensions);
} else {
override_features_.InitAndDisableFeature(
switches::kSyncPseudoUSSExtensions);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
class SingleClientExtensionsSyncTest : public UssSwitchToggler,
public SyncTest {
public:
SingleClientExtensionsSyncTest() : SyncTest(SINGLE_CLIENT) {}
......@@ -26,12 +49,12 @@ class SingleClientExtensionsSyncTest : public SyncTest {
DISALLOW_COPY_AND_ASSIGN(SingleClientExtensionsSyncTest);
};
IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, StartWithNoExtensions) {
IN_PROC_BROWSER_TEST_P(SingleClientExtensionsSyncTest, StartWithNoExtensions) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier());
}
IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(SingleClientExtensionsSyncTest,
StartWithSomeExtensions) {
ASSERT_TRUE(SetupClients());
......@@ -45,7 +68,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest,
ASSERT_TRUE(AllProfilesHaveSameExtensionsAsVerifier());
}
IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, InstallSomeExtensions) {
IN_PROC_BROWSER_TEST_P(SingleClientExtensionsSyncTest, InstallSomeExtensions) {
ASSERT_TRUE(SetupSync());
const int kNumExtensions = 5;
......@@ -66,7 +89,7 @@ static bool ExtensionCountCheck(Profile* profile, size_t expected_count) {
// Tests the case of an uninstall from the server conflicting with a local
// modification, which we expect to be resolved in favor of the uninstall.
IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, UninstallWinsConflicts) {
IN_PROC_BROWSER_TEST_P(SingleClientExtensionsSyncTest, UninstallWinsConflicts) {
ASSERT_TRUE(SetupClients());
// Start with an extension installed, and setup sync.
......@@ -102,3 +125,9 @@ IN_PROC_BROWSER_TEST_F(SingleClientExtensionsSyncTest, UninstallWinsConflicts) {
EXPECT_TRUE(checker.Wait());
EXPECT_TRUE(GetInstalledExtensions(GetProfile(0)).empty());
}
INSTANTIATE_TEST_CASE_P(USS,
SingleClientExtensionsSyncTest,
::testing::Values(false, true));
} // namespace
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
......@@ -11,6 +12,7 @@
#include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "content/public/test/test_utils.h"
using themes_helper::GetCustomTheme;
......@@ -23,7 +25,23 @@ using themes_helper::UsingSystemTheme;
namespace {
class SingleClientThemesSyncTest : public SyncTest {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(switches::kSyncPseudoUSSThemes);
} else {
override_features_.InitAndDisableFeature(switches::kSyncPseudoUSSThemes);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
class SingleClientThemesSyncTest : public UssSwitchToggler, public SyncTest {
public:
SingleClientThemesSyncTest() : SyncTest(SINGLE_CLIENT) {}
~SingleClientThemesSyncTest() override {}
......@@ -36,7 +54,7 @@ class SingleClientThemesSyncTest : public SyncTest {
// start with SetupClients(), change the theme state, then call
// SetupSync()).
IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, CustomTheme) {
IN_PROC_BROWSER_TEST_P(SingleClientThemesSyncTest, CustomTheme) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
EXPECT_FALSE(UsingCustomTheme(GetProfile(0)));
......@@ -55,9 +73,9 @@ IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, CustomTheme) {
// TODO(sync): Fails on Chrome OS. See http://crbug.com/84575.
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, DISABLED_NativeTheme) {
IN_PROC_BROWSER_TEST_P(SingleClientThemesSyncTest, DISABLED_NativeTheme) {
#else
IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, NativeTheme) {
IN_PROC_BROWSER_TEST_P(SingleClientThemesSyncTest, NativeTheme) {
#endif // OS_CHROMEOS
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
......@@ -79,7 +97,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, NativeTheme) {
EXPECT_TRUE(UsingSystemTheme(verifier()));
}
IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, DefaultTheme) {
IN_PROC_BROWSER_TEST_P(SingleClientThemesSyncTest, DefaultTheme) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
SetCustomTheme(GetProfile(0));
......@@ -100,4 +118,8 @@ IN_PROC_BROWSER_TEST_F(SingleClientThemesSyncTest, DefaultTheme) {
EXPECT_TRUE(UsingDefaultTheme(verifier()));
}
INSTANTIATE_TEST_CASE_P(USS,
SingleClientThemesSyncTest,
::testing::Values(false, true));
} // namespace
......@@ -6,6 +6,7 @@
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/bookmark_app_helper.h"
......@@ -22,6 +23,7 @@
#include "chrome/browser/web_applications/extensions/bookmark_app_util.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/extensions/manifest_handlers/app_theme_color_info.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/model/string_ordinal.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
......@@ -47,6 +49,22 @@ using apps_helper::UninstallApp;
namespace {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(switches::kSyncPseudoUSSApps);
} else {
override_features_.InitAndDisableFeature(switches::kSyncPseudoUSSApps);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
extensions::ExtensionRegistry* GetExtensionRegistry(Profile* profile) {
return extensions::ExtensionRegistry::Get(profile);
}
......@@ -57,7 +75,7 @@ extensions::ExtensionService* GetExtensionService(Profile* profile) {
} // namespace
class TwoClientAppsSyncTest : public SyncTest {
class TwoClientAppsSyncTest : public UssSwitchToggler, public SyncTest {
public:
TwoClientAppsSyncTest() : SyncTest(TWO_CLIENT) {
DisableVerifier();
......@@ -71,12 +89,12 @@ class TwoClientAppsSyncTest : public SyncTest {
DISALLOW_COPY_AND_ASSIGN(TwoClientAppsSyncTest);
};
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(StartWithNoApps)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(StartWithNoApps)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(StartWithSameApps)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(StartWithSameApps)) {
ASSERT_TRUE(SetupClients());
const int kNumApps = 5;
......@@ -98,7 +116,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(StartWithSameApps)) {
#else
#define MAYBE_StartWithDifferentApps StartWithDifferentApps
#endif
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, MAYBE_StartWithDifferentApps) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, MAYBE_StartWithDifferentApps) {
ASSERT_TRUE(SetupClients());
int i = 0;
......@@ -131,7 +149,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, MAYBE_StartWithDifferentApps) {
// Install some apps on both clients, then sync. Then install some apps on only
// one client, some on only the other, and then sync again. Both clients should
// end up with all apps, and the app and page ordinals should be identical.
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest,
E2E_ENABLED(InstallDifferentApps)) {
ASSERT_TRUE(SetupClients());
......@@ -158,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
ASSERT_TRUE(AppsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Add)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(Add)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -167,7 +185,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Add)) {
ASSERT_TRUE(AppsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Uninstall)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(Uninstall)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -182,7 +200,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Uninstall)) {
// client and sync again. Now install a new app on the first client and sync.
// Both client should only have the second app, with identical app and page
// ordinals.
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest,
E2E_ENABLED(UninstallThenInstall)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -197,7 +215,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
ASSERT_TRUE(AppsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Merge)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(Merge)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -215,7 +233,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(Merge)) {
ASSERT_TRUE(AppsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest,
E2E_ENABLED(UpdateEnableDisableApp)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -230,7 +248,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
ASSERT_TRUE(AppsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest,
E2E_ENABLED(UpdateIncognitoEnableDisable)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -248,7 +266,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
// Install the same app on both clients, then sync. Change the page ordinal on
// one client and sync. Both clients should have the updated page ordinal for
// the app.
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdatePageOrdinal)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(UpdatePageOrdinal)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -265,7 +283,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdatePageOrdinal)) {
// Install the same app on both clients, then sync. Change the app launch
// ordinal on one client and sync. Both clients should have the updated app
// launch ordinal for the app.
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest,
E2E_ENABLED(UpdateAppLaunchOrdinal)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -284,7 +302,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest,
// Adjust the CWS location within a page on the first client and sync. Adjust
// which page the CWS appears on and sync. Both clients should have the same
// page and app launch ordinal values for the CWS.
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateCWSOrdinals)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(UpdateCWSOrdinals)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -313,7 +331,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateCWSOrdinals)) {
// Adjust the launch type on the first client and sync. Both clients should
// have the same launch type values for the CWS.
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateLaunchType)) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, E2E_ENABLED(UpdateLaunchType)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AppsMatchChecker().Wait());
......@@ -339,7 +357,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, E2E_ENABLED(UpdateLaunchType)) {
extensions::LAUNCH_TYPE_REGULAR);
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, UnexpectedLaunchType) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameApps());
......@@ -378,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, UnexpectedLaunchType) {
ASSERT_TRUE(AppsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkAppBasic) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, BookmarkAppBasic) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameApps());
......@@ -411,7 +429,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkAppBasic) {
}
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkAppMinimal) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, BookmarkAppMinimal) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameApps());
......@@ -453,7 +471,7 @@ const extensions::Extension* GetAppByLaunchURL(const GURL& url,
return nullptr;
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkAppThemeColor) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, BookmarkAppThemeColor) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameApps());
......@@ -489,7 +507,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, BookmarkAppThemeColor) {
EXPECT_EQ(SK_ColorBLUE, theme_color.value());
}
IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, IsLocallyInstalled) {
IN_PROC_BROWSER_TEST_P(TwoClientAppsSyncTest, IsLocallyInstalled) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameApps());
......@@ -541,3 +559,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientAppsSyncTest, IsLocallyInstalled) {
// TODO(akalin): Add tests exercising:
// - Offline installation/uninstallation behavior
// - App-specific properties
INSTANTIATE_TEST_CASE_P(USS,
TwoClientAppsSyncTest,
::testing::Values(false, true));
......@@ -4,6 +4,7 @@
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/sync/test/integration/dictionary_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
......@@ -11,10 +12,31 @@
#include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h"
#include "components/spellcheck/common/spellcheck_common.h"
#include "components/sync/base/model_type.h"
#include "components/sync/driver/sync_driver_switches.h"
namespace {
using spellcheck::kMaxSyncableDictionaryWords;
class TwoClientDictionarySyncTest : public SyncTest {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(
switches::kSyncPseudoUSSDictionary);
} else {
override_features_.InitAndDisableFeature(
switches::kSyncPseudoUSSDictionary);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
class TwoClientDictionarySyncTest : public UssSwitchToggler, public SyncTest {
public:
TwoClientDictionarySyncTest() : SyncTest(TWO_CLIENT) {}
~TwoClientDictionarySyncTest() override {}
......@@ -25,7 +47,7 @@ class TwoClientDictionarySyncTest : public SyncTest {
DISALLOW_COPY_AND_ASSIGN(TwoClientDictionarySyncTest);
};
IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, E2E_ENABLED(Sanity)) {
IN_PROC_BROWSER_TEST_P(TwoClientDictionarySyncTest, E2E_ENABLED(Sanity)) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
ASSERT_TRUE(DictionaryMatchChecker().Wait());
......@@ -54,7 +76,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, E2E_ENABLED(Sanity)) {
ASSERT_EQ(words.size(), dictionary_helper::GetDictionarySize(0));
}
IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientDictionarySyncTest,
E2E_ENABLED(SimultaneousAdd)) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
......@@ -66,7 +88,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
ASSERT_EQ(1UL, dictionary_helper::GetDictionarySize(0));
}
IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientDictionarySyncTest,
E2E_ENABLED(SimultaneousRemove)) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
......@@ -83,7 +105,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
ASSERT_EQ(0UL, dictionary_helper::GetDictionarySize(0));
}
IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientDictionarySyncTest,
E2E_ENABLED(AddDifferentToEach)) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
......@@ -97,7 +119,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
static_cast<int>(dictionary_helper::GetDictionarySize(0)));
}
IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientDictionarySyncTest,
E2E_ENABLED(RemoveOnAAddOnB)) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
......@@ -118,7 +140,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest,
// Tests the case where a client has more words added than the
// kMaxSyncableDictionaryWords limit.
IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, Limit) {
IN_PROC_BROWSER_TEST_P(TwoClientDictionarySyncTest, Limit) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
dictionary_helper::LoadDictionaries();
ASSERT_TRUE(DictionaryMatchChecker().Wait());
......@@ -162,3 +184,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientDictionarySyncTest, Limit) {
ASSERT_TRUE(
NumDictionaryEntriesChecker(0, kMaxSyncableDictionaryWords).Wait());
}
INSTANTIATE_TEST_CASE_P(USS,
TwoClientDictionarySyncTest,
::testing::Values(false, true));
} // namespace
......@@ -3,11 +3,15 @@
// found in the LICENSE file.
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/sync/test/integration/extensions_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "components/sync/driver/sync_driver_switches.h"
namespace {
using extensions_helper::AllProfilesHaveSameExtensions;
using extensions_helper::DisableExtension;
......@@ -19,7 +23,25 @@ using extensions_helper::IncognitoEnableExtension;
using extensions_helper::InstallExtension;
using extensions_helper::UninstallExtension;
class TwoClientExtensionsSyncTest : public SyncTest {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(
switches::kSyncPseudoUSSExtensions);
} else {
override_features_.InitAndDisableFeature(
switches::kSyncPseudoUSSExtensions);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
class TwoClientExtensionsSyncTest : public UssSwitchToggler, public SyncTest {
public:
TwoClientExtensionsSyncTest() : SyncTest(TWO_CLIENT) { DisableVerifier(); }
......@@ -29,7 +51,7 @@ class TwoClientExtensionsSyncTest : public SyncTest {
DISALLOW_COPY_AND_ASSIGN(TwoClientExtensionsSyncTest);
};
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest,
E2E_ENABLED(StartWithNoExtensions)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(ExtensionsMatchChecker().Wait());
......@@ -48,7 +70,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
#else
#define MAYBE_StartWithSameExtensions StartWithSameExtensions
#endif
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest,
E2E_ENABLED(MAYBE_StartWithSameExtensions)) {
ASSERT_TRUE(SetupClients());
......@@ -70,7 +92,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
#else
#define MAYBE_StartWithDifferentExtensions StartWithDifferentExtensions
#endif
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest,
MAYBE_E2E(MAYBE_StartWithDifferentExtensions)) {
ASSERT_TRUE(SetupClients());
......@@ -99,7 +121,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
static_cast<int>(GetInstalledExtensions(GetProfile(0)).size()));
}
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest,
E2E_ENABLED(InstallDifferentExtensions)) {
ASSERT_TRUE(SetupClients());
......@@ -130,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
static_cast<int>(GetInstalledExtensions(GetProfile(0)).size()));
}
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest, MAYBE_E2E(Add)) {
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest, MAYBE_E2E(Add)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameExtensions());
......@@ -140,7 +162,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest, MAYBE_E2E(Add)) {
EXPECT_EQ(1u, GetInstalledExtensions(GetProfile(0)).size());
}
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest, MAYBE_E2E(Uninstall)) {
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest, MAYBE_E2E(Uninstall)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameExtensions());
......@@ -152,7 +174,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest, MAYBE_E2E(Uninstall)) {
EXPECT_TRUE(GetInstalledExtensions(GetProfile(0)).empty());
}
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest,
MAYBE_E2E(UpdateEnableDisableExtension)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameExtensions());
......@@ -171,7 +193,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
ASSERT_TRUE(ExtensionsMatchChecker().Wait());
}
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest,
E2E_ENABLED(UpdateIncognitoEnableDisable)) {
ASSERT_TRUE(SetupSync());
ASSERT_TRUE(AllProfilesHaveSameExtensions());
......@@ -192,7 +214,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
// Regression test for bug 104399: ensure that an extension installed prior to
// setting up sync, when uninstalled, is also uninstalled from sync.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientExtensionsSyncTest,
E2E_ENABLED(UninstallPreinstalledExtensions)) {
ASSERT_TRUE(SetupClients());
ASSERT_TRUE(AllProfilesHaveSameExtensions());
......@@ -212,3 +234,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientExtensionsSyncTest,
// TODO(akalin): Add tests exercising:
// - Offline installation/uninstallation behavior
INSTANTIATE_TEST_CASE_P(USS,
TwoClientExtensionsSyncTest,
::testing::Values(false, true));
} // namespace
......@@ -3,10 +3,14 @@
// found in the LICENSE file.
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/sync/test/integration/themes_helper.h"
#include "components/sync/driver/sync_driver_switches.h"
namespace {
using themes_helper::GetCustomTheme;
using themes_helper::GetThemeID;
......@@ -17,7 +21,23 @@ using themes_helper::UsingCustomTheme;
using themes_helper::UsingDefaultTheme;
using themes_helper::UsingSystemTheme;
class TwoClientThemesSyncTest : public SyncTest {
// Class that enables or disables USS based on test parameter. Must be the first
// base class of the test fixture.
class UssSwitchToggler : public testing::WithParamInterface<bool> {
public:
UssSwitchToggler() {
if (GetParam()) {
override_features_.InitAndEnableFeature(switches::kSyncPseudoUSSThemes);
} else {
override_features_.InitAndDisableFeature(switches::kSyncPseudoUSSThemes);
}
}
private:
base::test::ScopedFeatureList override_features_;
};
class TwoClientThemesSyncTest : public UssSwitchToggler, public SyncTest {
public:
TwoClientThemesSyncTest() : SyncTest(TWO_CLIENT) {}
~TwoClientThemesSyncTest() override {}
......@@ -31,7 +51,7 @@ class TwoClientThemesSyncTest : public SyncTest {
// Starts with default themes, then sets up sync and uses it to set all
// profiles to use a custom theme. Does not actually install any themes, but
// instead verifies the custom theme is pending for install.
IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientThemesSyncTest,
E2E_ENABLED(DefaultThenSyncCustom)) {
ASSERT_TRUE(SetupSync());
......@@ -53,7 +73,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest,
// Starts with custom themes, then sets up sync and uses it to set all profiles
// to the system theme.
IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientThemesSyncTest,
E2E_ENABLED(CustomThenSyncNative)) {
ASSERT_TRUE(SetupClients());
......@@ -73,7 +93,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest,
// Starts with custom themes, then sets up sync and uses it to set all profiles
// to the default theme.
IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest,
IN_PROC_BROWSER_TEST_P(TwoClientThemesSyncTest,
E2E_ENABLED(CustomThenSyncDefault)) {
ASSERT_TRUE(SetupClients());
......@@ -94,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest,
//
// Most other tests have significant coverage of model association. This test
// is intended to test steady-state scenarios.
IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, E2E_ENABLED(CycleOptions)) {
IN_PROC_BROWSER_TEST_P(TwoClientThemesSyncTest, E2E_ENABLED(CycleOptions)) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
SetCustomTheme(GetProfile(0));
......@@ -120,3 +140,9 @@ IN_PROC_BROWSER_TEST_F(TwoClientThemesSyncTest, E2E_ENABLED(CycleOptions)) {
ThemePendingInstallChecker(GetProfile(1), GetCustomTheme(1)).Wait());
EXPECT_EQ(GetCustomTheme(1), GetThemeID(GetProfile(0)));
}
INSTANTIATE_TEST_CASE_P(USS,
TwoClientThemesSyncTest,
::testing::Values(false, true));
} // namespace
......@@ -35,7 +35,9 @@
#include "components/sync/driver/proxy_data_type_controller.h"
#include "components/sync/driver/sync_client.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/driver/syncable_service_based_model_type_controller.h"
#include "components/sync/engine/sync_engine.h"
#include "components/sync/model/model_type_store_service.h"
#include "components/sync/model_impl/forwarding_model_type_controller_delegate.h"
#include "components/sync/model_impl/proxy_model_type_controller_delegate.h"
#include "components/sync_bookmarks/bookmark_change_processor.h"
......@@ -59,6 +61,7 @@ using syncer::DataTypeManagerImpl;
using syncer::DataTypeManagerObserver;
using syncer::ModelTypeController;
using syncer::ProxyDataTypeController;
using syncer::SyncableServiceBasedModelTypeController;
namespace browser_sync {
......@@ -266,7 +269,22 @@ ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers(
// Favicon sync is enabled by default. Register unless explicitly disabled.
if (!disabled_types.Has(syncer::FAVICON_IMAGES) &&
!disabled_types.Has(syncer::FAVICON_TRACKING)) {
// crbug/384552. We disable error uploading for this data types for now.
if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSFavicons)) {
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::FAVICON_IMAGES,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::FAVICON_IMAGES)));
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::FAVICON_TRACKING,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::FAVICON_TRACKING)));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::FAVICON_IMAGES, base::RepeatingClosure(), sync_client_,
syncer::GROUP_UI, ui_thread_));
......@@ -275,6 +293,7 @@ ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers(
syncer::GROUP_UI, ui_thread_));
}
}
}
// Password sync is enabled by default. Register unless explicitly
// disabled.
......@@ -285,21 +304,41 @@ ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers(
}
if (!disabled_types.Has(syncer::PREFERENCES)) {
if (!override_prefs_controller_to_uss_for_test_) {
if (override_prefs_controller_to_uss_for_test_) {
controllers.push_back(CreateModelTypeControllerForModelRunningOnUIThread(
syncer::PREFERENCES));
} else if (base::FeatureList::IsEnabled(
switches::kSyncPseudoUSSPreferences)) {
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::PREFERENCES,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::PREFERENCES)));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::PREFERENCES, error_callback, sync_client_, syncer::GROUP_UI,
ui_thread_));
} else {
controllers.push_back(CreateModelTypeControllerForModelRunningOnUIThread(
syncer::PREFERENCES));
}
}
if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) {
if (base::FeatureList::IsEnabled(
switches::kSyncPseudoUSSPriorityPreferences)) {
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::PRIORITY_PREFERENCES,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::PRIORITY_PREFERENCES)));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::PRIORITY_PREFERENCES, error_callback, sync_client_,
syncer::GROUP_UI, ui_thread_));
}
}
#if defined(OS_CHROMEOS)
if (!disabled_types.Has(syncer::PRINTERS)) {
......
......@@ -677,9 +677,6 @@ class ProfileSyncService : public syncer::SyncService,
// is decremented back to zero, Sync setup is marked no longer in progress.
int outstanding_setup_in_progress_handles_ = 0;
// List of available data type controllers.
syncer::DataTypeController::TypeMap data_type_controllers_;
// Whether the SyncEngine has been initialized.
bool engine_initialized_;
......@@ -737,6 +734,9 @@ class ProfileSyncService : public syncer::SyncService,
std::unique_ptr<syncer::DeviceInfoSyncBridge> device_info_sync_bridge_;
// List of available data type controllers.
syncer::DataTypeController::TypeMap data_type_controllers_;
std::unique_ptr<syncer::NetworkResources> network_resources_;
const StartBehavior start_behavior_;
......
......@@ -157,6 +157,8 @@ jumbo_static_library("sync") {
"driver/sync_type_preference_provider.h",
"driver/sync_util.cc",
"driver/sync_util.h",
"driver/syncable_service_based_model_type_controller.cc",
"driver/syncable_service_based_model_type_controller.h",
"driver/user_selectable_sync_type.h",
"engine/commit_queue.cc",
"engine/commit_queue.h",
......
......@@ -46,6 +46,25 @@ const base::Feature kSyncAllowWalletDataInTransportModeWithCustomPassphrase{
const base::Feature kSyncClearDataOnPassphraseEncryption{
"ClearSyncDataOnPassphraseEncryption", base::FEATURE_DISABLED_BY_DEFAULT};
// For each below, if enabled, the SyncableService implementation of the
// corresponding datatype(s) is wrapped within the USS architecture.
const base::Feature kSyncPseudoUSSAppList{"SyncPseudoUSSAppList",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSApps{"SyncPseudoUSSApps",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSDictionary{"SyncPseudoUSSDictionary",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSExtensions{"SyncPseudoUSSExtensions",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSFavicons{"SyncPseudoUSSFavicons",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSPreferences{
"SyncPseudoUSSPreferences", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSPriorityPreferences{
"SyncPseudoUSSPriorityPreferences", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncPseudoUSSThemes{"SyncPseudoUSSThemes",
base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, allows the Sync machinery ("transport layer") to start
// independently of Sync-the-feature.
const base::Feature kSyncStandaloneTransport{"SyncStandaloneTransport",
......
......@@ -23,6 +23,14 @@ extern const char kSyncShortNudgeDelayForTest[];
extern const base::Feature
kSyncAllowWalletDataInTransportModeWithCustomPassphrase;
extern const base::Feature kSyncClearDataOnPassphraseEncryption;
extern const base::Feature kSyncPseudoUSSAppList;
extern const base::Feature kSyncPseudoUSSApps;
extern const base::Feature kSyncPseudoUSSDictionary;
extern const base::Feature kSyncPseudoUSSExtensions;
extern const base::Feature kSyncPseudoUSSFavicons;
extern const base::Feature kSyncPseudoUSSPreferences;
extern const base::Feature kSyncPseudoUSSPriorityPreferences;
extern const base::Feature kSyncPseudoUSSThemes;
extern const base::Feature kSyncStandaloneTransport;
extern const base::Feature kSyncSupportSecondaryAccount;
extern const base::Feature kSyncUserEvents;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync/driver/syncable_service_based_model_type_controller.h"
#include <utility>
#include "components/sync/model_impl/client_tag_based_model_type_processor.h"
#include "components/sync/model_impl/forwarding_model_type_controller_delegate.h"
#include "components/sync/model_impl/syncable_service_based_bridge.h"
namespace syncer {
namespace {
// Similar to ForwardingModelTypeControllerDelegate, but allows evaluating the
// reference to SyncableService in a lazy way, which is convenient for tests.
class ControllerDelegate : public ModelTypeControllerDelegate {
public:
using SyncableServiceProvider =
SyncableServiceBasedModelTypeController::SyncableServiceProvider;
ControllerDelegate(ModelType type,
OnceModelTypeStoreFactory store_factory,
SyncableServiceProvider syncable_service_provider)
: type_(type),
store_factory_(std::move(store_factory)),
syncable_service_provider_(std::move(syncable_service_provider)) {
DCHECK(store_factory_);
DCHECK(syncable_service_provider_);
}
~ControllerDelegate() override {}
void OnSyncStarting(const DataTypeActivationRequest& request,
StartCallback callback) override {
BuildOrGetBridgeDelegate()->OnSyncStarting(request, std::move(callback));
}
void OnSyncStopping(SyncStopMetadataFate metadata_fate) override {
BuildOrGetBridgeDelegate()->OnSyncStopping(metadata_fate);
}
void GetAllNodesForDebugging(AllNodesCallback callback) override {
BuildOrGetBridgeDelegate()->GetAllNodesForDebugging(std::move(callback));
}
void GetStatusCountersForDebugging(StatusCountersCallback callback) override {
BuildOrGetBridgeDelegate()->GetStatusCountersForDebugging(
std::move(callback));
}
void RecordMemoryUsageAndCountsHistograms() override {
BuildOrGetBridgeDelegate()->RecordMemoryUsageAndCountsHistograms();
}
private:
ModelTypeControllerDelegate* BuildOrGetBridgeDelegate() {
if (!bridge_) {
base::WeakPtr<SyncableService> syncable_service =
std::move(syncable_service_provider_).Run();
DCHECK(syncable_service);
bridge_ = std::make_unique<SyncableServiceBasedBridge>(
type_, std::move(store_factory_),
std::make_unique<ClientTagBasedModelTypeProcessor>(
type_,
/*dump_stack=*/base::RepeatingClosure()),
syncable_service.get());
}
return bridge_->change_processor()->GetControllerDelegate().get();
}
const ModelType type_;
OnceModelTypeStoreFactory store_factory_;
SyncableServiceProvider syncable_service_provider_;
std::unique_ptr<ModelTypeSyncBridge> bridge_;
DISALLOW_COPY_AND_ASSIGN(ControllerDelegate);
};
} // namespace
SyncableServiceBasedModelTypeController::
SyncableServiceBasedModelTypeController(
ModelType type,
OnceModelTypeStoreFactory store_factory,
SyncableServiceProvider syncable_service_provider)
: ModelTypeController(type,
std::make_unique<ControllerDelegate>(
type,
std::move(store_factory),
std::move(syncable_service_provider))) {}
SyncableServiceBasedModelTypeController::
~SyncableServiceBasedModelTypeController() {}
} // namespace syncer
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SYNC_DRIVER_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_
#define COMPONENTS_SYNC_DRIVER_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_
#include <memory>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/sync/base/model_type.h"
#include "components/sync/driver/model_type_controller.h"
#include "components/sync/model/model_type_store.h"
namespace syncer {
class SyncableService;
// Controller responsible for integrating SyncableService implementations within
// a non-blocking datatype (USS).
class SyncableServiceBasedModelTypeController : public ModelTypeController {
public:
using SyncableServiceProvider =
base::OnceCallback<base::WeakPtr<syncer::SyncableService>()>;
SyncableServiceBasedModelTypeController(
ModelType type,
OnceModelTypeStoreFactory store_factory,
SyncableServiceProvider syncable_service_provider);
~SyncableServiceBasedModelTypeController() override;
private:
DISALLOW_COPY_AND_ASSIGN(SyncableServiceBasedModelTypeController);
};
} // namespace syncer
#endif // COMPONENTS_SYNC_DRIVER_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment