Commit e8f8623d authored by vitaliii's avatar vitaliii Committed by Commit Bot

[Sync::Consent] Enable separate datatype by default.

Bug: 851433
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I3f9d06fcab5d9a48febc72a5de2554b7bf526dfa
Reviewed-on: https://chromium-review.googlesource.com/1131183Reviewed-by: default avatarMarkus Heintz <markusheintz@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: vitaliii <vitaliii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576059}
parent 7dee8e54
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "components/sync/driver/sync_driver_switches.h" #include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/model/fake_model_type_controller_delegate.h" #include "components/sync/model/fake_model_type_controller_delegate.h"
#include "components/sync/user_events/fake_user_event_service.h" #include "components/sync/user_events/fake_user_event_service.h"
#include "components/variations/variations_params_manager.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using sync_pb::UserConsentSpecifics; using sync_pb::UserConsentSpecifics;
...@@ -108,7 +107,11 @@ class ConsentAuditorImplTest : public testing::Test { ...@@ -108,7 +107,11 @@ class ConsentAuditorImplTest : public testing::Test {
public: public:
void SetUp() override { void SetUp() override {
pref_service_ = std::make_unique<TestingPrefServiceSimple>(); pref_service_ = std::make_unique<TestingPrefServiceSimple>();
user_event_service_ = std::make_unique<syncer::FakeUserEventService>(); if (base::FeatureList::IsEnabled(switches::kSyncUserConsentSeparateType)) {
consent_sync_bridge_ = std::make_unique<FakeConsentSyncBridge>();
} else {
user_event_service_ = std::make_unique<syncer::FakeUserEventService>();
}
ConsentAuditorImpl::RegisterProfilePrefs(pref_service_->registry()); ConsentAuditorImpl::RegisterProfilePrefs(pref_service_->registry());
app_version_ = kCurrentAppVersion; app_version_ = kCurrentAppVersion;
app_locale_ = kCurrentAppLocale; app_locale_ = kCurrentAppLocale;
...@@ -138,16 +141,8 @@ class ConsentAuditorImplTest : public testing::Test { ...@@ -138,16 +141,8 @@ class ConsentAuditorImplTest : public testing::Test {
} }
void SetIsSeparateConsentTypeEnabledFeature(bool new_value) { void SetIsSeparateConsentTypeEnabledFeature(bool new_value) {
// VariationParamsManager supports only one feature_list_.InitWithFeatureState(switches::kSyncUserConsentSeparateType,
// |SetVariationParamsWithFeatureAssociations| at a time, so we clear new_value);
// previous settings first to make this explicit.
params_manager_.ClearAllVariationParams();
if (new_value) {
params_manager_.SetVariationParamsWithFeatureAssociations(
/*trial_name=*/switches::kSyncUserConsentSeparateType.name,
/*param_values=*/std::map<std::string, std::string>(),
{switches::kSyncUserConsentSeparateType.name});
}
} }
ConsentAuditorImpl* consent_auditor() { return consent_auditor_.get(); } ConsentAuditorImpl* consent_auditor() { return consent_auditor_.get(); }
...@@ -165,12 +160,15 @@ class ConsentAuditorImplTest : public testing::Test { ...@@ -165,12 +160,15 @@ class ConsentAuditorImplTest : public testing::Test {
std::string app_locale_; std::string app_locale_;
std::unique_ptr<syncer::ConsentSyncBridge> consent_sync_bridge_; std::unique_ptr<syncer::ConsentSyncBridge> consent_sync_bridge_;
variations::testing::VariationParamsManager params_manager_; base::test::ScopedFeatureList feature_list_;
}; };
TEST_F(ConsentAuditorImplTest, LocalConsentPrefRepresentation) { TEST_F(ConsentAuditorImplTest, LocalConsentPrefRepresentation) {
SetIsSeparateConsentTypeEnabledFeature(true);
SetAppVersion(kCurrentAppVersion); SetAppVersion(kCurrentAppVersion);
SetAppLocale(kCurrentAppLocale); SetAppLocale(kCurrentAppLocale);
SetConsentSyncBridge(std::make_unique<FakeConsentSyncBridge>());
SetUserEventService(nullptr);
BuildConsentAuditorImpl(); BuildConsentAuditorImpl();
// No consents are written at first. // No consents are written at first.
...@@ -221,6 +219,8 @@ TEST_F(ConsentAuditorImplTest, LocalConsentPrefRepresentation) { ...@@ -221,6 +219,8 @@ TEST_F(ConsentAuditorImplTest, LocalConsentPrefRepresentation) {
const std::string kFeature2NewAppLocale = "de"; const std::string kFeature2NewAppLocale = "de";
SetAppVersion(kFeature2NewAppVersion); SetAppVersion(kFeature2NewAppVersion);
SetAppLocale(kFeature2NewAppLocale); SetAppLocale(kFeature2NewAppLocale);
SetConsentSyncBridge(std::make_unique<FakeConsentSyncBridge>());
SetUserEventService(nullptr);
// We rebuild consent auditor to emulate restarting Chrome. This is the only // We rebuild consent auditor to emulate restarting Chrome. This is the only
// way to change app version or app locale. // way to change app version or app locale.
BuildConsentAuditorImpl(); BuildConsentAuditorImpl();
...@@ -240,6 +240,9 @@ TEST_F(ConsentAuditorImplTest, LocalConsentPrefRepresentation) { ...@@ -240,6 +240,9 @@ TEST_F(ConsentAuditorImplTest, LocalConsentPrefRepresentation) {
TEST_F(ConsentAuditorImplTest, RecordingEnabled) { TEST_F(ConsentAuditorImplTest, RecordingEnabled) {
SetIsSeparateConsentTypeEnabledFeature(false); SetIsSeparateConsentTypeEnabledFeature(false);
SetConsentSyncBridge(nullptr);
SetUserEventService(std::make_unique<syncer::FakeUserEventService>());
BuildConsentAuditorImpl();
consent_auditor()->RecordGaiaConsent(kAccountId, Feature::CHROME_SYNC, {}, 0, consent_auditor()->RecordGaiaConsent(kAccountId, Feature::CHROME_SYNC, {}, 0,
ConsentStatus::GIVEN); ConsentStatus::GIVEN);
...@@ -249,6 +252,9 @@ TEST_F(ConsentAuditorImplTest, RecordingEnabled) { ...@@ -249,6 +252,9 @@ TEST_F(ConsentAuditorImplTest, RecordingEnabled) {
TEST_F(ConsentAuditorImplTest, RecordingDisabled) { TEST_F(ConsentAuditorImplTest, RecordingDisabled) {
SetIsSeparateConsentTypeEnabledFeature(false); SetIsSeparateConsentTypeEnabledFeature(false);
SetConsentSyncBridge(nullptr);
SetUserEventService(std::make_unique<syncer::FakeUserEventService>());
BuildConsentAuditorImpl();
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(switches::kSyncUserConsentEvents); scoped_feature_list.InitAndDisableFeature(switches::kSyncUserConsentEvents);
...@@ -261,6 +267,7 @@ TEST_F(ConsentAuditorImplTest, RecordingDisabled) { ...@@ -261,6 +267,7 @@ TEST_F(ConsentAuditorImplTest, RecordingDisabled) {
TEST_F(ConsentAuditorImplTest, RecordGaiaConsentAsUserEvent) { TEST_F(ConsentAuditorImplTest, RecordGaiaConsentAsUserEvent) {
SetIsSeparateConsentTypeEnabledFeature(false); SetIsSeparateConsentTypeEnabledFeature(false);
SetConsentSyncBridge(nullptr); SetConsentSyncBridge(nullptr);
SetUserEventService(std::make_unique<syncer::FakeUserEventService>());
SetAppVersion(kCurrentAppVersion); SetAppVersion(kCurrentAppVersion);
SetAppLocale(kCurrentAppLocale); SetAppLocale(kCurrentAppLocale);
BuildConsentAuditorImpl(); BuildConsentAuditorImpl();
...@@ -295,7 +302,6 @@ TEST_F(ConsentAuditorImplTest, RecordGaiaConsentAsUserConsent) { ...@@ -295,7 +302,6 @@ TEST_F(ConsentAuditorImplTest, RecordGaiaConsentAsUserConsent) {
auto wrapped_fake_bridge = std::make_unique<FakeConsentSyncBridge>(); auto wrapped_fake_bridge = std::make_unique<FakeConsentSyncBridge>();
FakeConsentSyncBridge* fake_bridge = wrapped_fake_bridge.get(); FakeConsentSyncBridge* fake_bridge = wrapped_fake_bridge.get();
SetIsSeparateConsentTypeEnabledFeature(true);
SetConsentSyncBridge(std::move(wrapped_fake_bridge)); SetConsentSyncBridge(std::move(wrapped_fake_bridge));
SetUserEventService(nullptr); SetUserEventService(nullptr);
SetAppVersion(kCurrentAppVersion); SetAppVersion(kCurrentAppVersion);
...@@ -333,6 +339,7 @@ TEST_F(ConsentAuditorImplTest, RecordGaiaConsentAsUserConsent) { ...@@ -333,6 +339,7 @@ TEST_F(ConsentAuditorImplTest, RecordGaiaConsentAsUserConsent) {
TEST_F(ConsentAuditorImplTest, ShouldReturnNoSyncDelegateWhenNoBridge) { TEST_F(ConsentAuditorImplTest, ShouldReturnNoSyncDelegateWhenNoBridge) {
SetIsSeparateConsentTypeEnabledFeature(false); SetIsSeparateConsentTypeEnabledFeature(false);
SetConsentSyncBridge(nullptr); SetConsentSyncBridge(nullptr);
SetUserEventService(std::make_unique<syncer::FakeUserEventService>());
BuildConsentAuditorImpl(); BuildConsentAuditorImpl();
// There is no bridge (i.e. separate sync type for consents is disabled), // There is no bridge (i.e. separate sync type for consents is disabled),
......
...@@ -52,7 +52,7 @@ const base::Feature kSyncUserConsentEvents{"SyncUserConsentEvents", ...@@ -52,7 +52,7 @@ const base::Feature kSyncUserConsentEvents{"SyncUserConsentEvents",
// Emit user consents through a separate sync type USER_CONSENTS instead of // Emit user consents through a separate sync type USER_CONSENTS instead of
// USER_EVENTS. This feature does not override kSyncUserConsentEvents. // USER_EVENTS. This feature does not override kSyncUserConsentEvents.
const base::Feature kSyncUserConsentSeparateType{ const base::Feature kSyncUserConsentSeparateType{
"SyncUserConsentSeparateType", base::FEATURE_DISABLED_BY_DEFAULT}; "SyncUserConsentSeparateType", base::FEATURE_ENABLED_BY_DEFAULT};
// Gates registration for user language detection events. // Gates registration for user language detection events.
const base::Feature kSyncUserLanguageDetectionEvents{ const base::Feature kSyncUserLanguageDetectionEvents{
......
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