Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2493)

Unified Diff: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc

Issue 1865803002: [Policy Experimental] Add policies to allow Cookies and Pop-ups exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compiling issuese; another round of renaming; code cleanup. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6b1204d60f4bb31e0a5bdb8933f577ad329c7057 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(CONTENT_SETTING_DEFAULT,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+
+ // Set value.
+ prefs->SetManagedPref(type_info.pref_exception_setting,
+ new base::FundamentalValue(CONTENT_SETTING_ALLOW));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+
+ // Clear value.
+ prefs->RemoveManagedPref(type_info.pref_exception_setting);
+ EXPECT_EQ(CONTENT_SETTING_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(CONTENT_SETTING_DEFAULT,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+
+ // Set to another value in manage pref, and leave it lingering around.
+ prefs->SetManagedPref(type_info.pref_exception_setting,
+ new base::FundamentalValue(CONTENT_SETTING_BLOCK));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ provider.GetUserExceptionsUsageSettingForType(
+ type_info.content_type));
+ }
+
+ provider.ShutdownOnUIThread();
+}
+
} // namespace content_settings

Powered by Google App Engine
This is Rietveld 408576698