| Index: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| diff --git a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| index 5ed0ab45775a952f54b2299dba18aba5a7e9795b..62356bcc971175b8619a4b76b6e83652668a036b 100644
|
| --- a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| +++ b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| @@ -254,4 +254,55 @@ TEST_F(PolicyProviderTest, AutoSelectCertificateList) {
|
| provider.ShutdownOnUIThread();
|
| }
|
|
|
| +TEST_F(PolicyProviderTest, GetUserExceptionsUsageSettingForType) {
|
| + struct {
|
| + ContentSettingsType content_type;
|
| + const char* pref_exception_setting;
|
| + } kTypeInfos[] = {
|
| + {CONTENT_SETTINGS_TYPE_COOKIES, prefs::kUserCookiesExceptionsUsage},
|
| + {CONTENT_SETTINGS_TYPE_POPUPS, prefs::kUserPopupsExceptionsUsage},
|
| + };
|
| +
|
| + TestingProfile profile;
|
| + syncable_prefs::TestingPrefServiceSyncable* prefs =
|
| + profile.GetTestingPrefService();
|
| + PolicyProvider provider(prefs);
|
| +
|
| + for (const auto& type_info : kTypeInfos) {
|
| + // Initially not set.
|
| + EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
|
| + provider.GetUserExceptionsUsageSettingForType(
|
| + type_info.content_type));
|
| +
|
| + // Set value.
|
| + prefs->SetManagedPref(type_info.pref_exception_setting,
|
| + new base::FundamentalValue(CONTENT_SETTING_ALLOW));
|
| + EXPECT_EQ(USER_EXCEPTIONS_ALLOW,
|
| + provider.GetUserExceptionsUsageSettingForType(
|
| + type_info.content_type));
|
| +
|
| + // Clear value.
|
| + prefs->RemoveManagedPref(type_info.pref_exception_setting);
|
| + EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
|
| + provider.GetUserExceptionsUsageSettingForType(
|
| + type_info.content_type));
|
| +
|
| + // Try to set as user pref: Should have no effect.
|
| + prefs->SetUserPref(type_info.pref_exception_setting,
|
| + new base::FundamentalValue(CONTENT_SETTING_ALLOW));
|
| + EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
|
| + provider.GetUserExceptionsUsageSettingForType(
|
| + type_info.content_type));
|
| +
|
| + // Set value again and leave it lingering around.
|
| + prefs->SetManagedPref(type_info.pref_exception_setting,
|
| + new base::FundamentalValue(CONTENT_SETTING_ALLOW));
|
| + EXPECT_EQ(USER_EXCEPTIONS_ALLOW,
|
| + provider.GetUserExceptionsUsageSettingForType(
|
| + type_info.content_type));
|
| + }
|
| +
|
| + provider.ShutdownOnUIThread();
|
| +}
|
| +
|
| } // namespace content_settings
|
|
|