#include "components/unified_consent/unified_consent_service.h"
#include <map>
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/sync/base/features.h"
#include "components/sync/base/user_selectable_type.h"
#include "components/sync/service/sync_prefs.h"
#include "components/sync/test/test_sync_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/unified_consent/pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace unified_consent {
class UnifiedConsentServiceTest : public testing::Test { … };
TEST_F(UnifiedConsentServiceTest, DefaultValuesWhenSignedOut) { … }
TEST_F(UnifiedConsentServiceTest, EnableUrlKeyedAnonymizedDataCollection) { … }
TEST_F(UnifiedConsentServiceTest,
ReplaceSync_InitializeNoChangeToUrlKeyedAnonymizedDataCollection) { … }
TEST_F(UnifiedConsentServiceTest, ReplaceSync_HistorySyncIgnoredForSyncUsers) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(UnifiedConsentServiceTest,
ReplaceSync_SyncUserMovesToSigninWithHistorySyncEnabled) { … }
#endif
TEST_F(UnifiedConsentServiceTest,
ReplaceSync_HistorySyncEnablesUrlKeyedAnonymizedDataCollection) { … }
TEST_F(UnifiedConsentServiceTest, ReplaceSync_StateTransitions) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(UnifiedConsentServiceTest, Migration_UpdateSettings) {
SignIn(signin::ConsentLevel::kSync);
EXPECT_FALSE(pref_service()->GetBoolean(
prefs::kUrlKeyedAnonymizedDataCollectionEnabled));
CreateConsentService();
EXPECT_EQ(GetMigrationState(), unified_consent::MigrationState::kCompleted);
EXPECT_TRUE(pref_service()->GetBoolean(
prefs::kUrlKeyedAnonymizedDataCollectionEnabled));
}
TEST_F(UnifiedConsentServiceTest, Migration_NotSignedIn) {
base::HistogramTester histogram_tester;
CreateConsentService();
EXPECT_EQ(GetMigrationState(), unified_consent::MigrationState::kCompleted);
}
#else
TEST_F(UnifiedConsentServiceTest, ClearPrimaryAccountDisablesSomeServices) { … }
#endif
}