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

Side by Side 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: Add another test to exercise main logic; renames from review. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/content_settings/core/browser/content_settings_policy_provi der.h" 5 #include "components/content_settings/core/browser/content_settings_policy_provi der.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType()); 248 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType());
249 base::DictionaryValue* dict_value = 249 base::DictionaryValue* dict_value =
250 static_cast<base::DictionaryValue*>(cert_filter.get()); 250 static_cast<base::DictionaryValue*>(cert_filter.get());
251 std::string actual_common_name; 251 std::string actual_common_name;
252 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name)); 252 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name));
253 EXPECT_EQ("issuer name", actual_common_name); 253 EXPECT_EQ("issuer name", actual_common_name);
254 provider.ShutdownOnUIThread(); 254 provider.ShutdownOnUIThread();
255 } 255 }
256 256
257 TEST_F(PolicyProviderTest, AllowUserExceptionsForType) {
258 struct {
259 ContentSettingsType content_type;
260 const char* pref_exception_setting;
261 } kTypeInfos[] = {
262 {CONTENT_SETTINGS_TYPE_COOKIES, prefs::kPrefExceptionsUsageCookies},
263 {CONTENT_SETTINGS_TYPE_POPUPS, prefs::kPrefExceptionsUsagePopups},
264 };
265
266 TestingProfile profile;
267 syncable_prefs::TestingPrefServiceSyncable* prefs =
268 profile.GetTestingPrefService();
269 PolicyProvider provider(prefs);
270
271 for (const auto& type_info : kTypeInfos) {
272 // Initially not set.
273 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
274 provider.AllowUserExceptionsForType(type_info.content_type));
275
276 // Set value.
277 prefs->SetManagedPref(type_info.pref_exception_setting,
278 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
279 EXPECT_EQ(CONTENT_SETTING_ALLOW,
280 provider.AllowUserExceptionsForType(type_info.content_type));
281
282 // Clear value.
283 prefs->RemoveManagedPref(type_info.pref_exception_setting);
284 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
285 provider.AllowUserExceptionsForType(type_info.content_type));
286
287 // Try to set as user pref: Should have no effect.
288 prefs->SetUserPref(type_info.pref_exception_setting,
289 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
290 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
291 provider.AllowUserExceptionsForType(type_info.content_type));
292
293 // Set to another value in manage pref, and leave it lingering around.
294 prefs->SetManagedPref(type_info.pref_exception_setting,
295 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
296 EXPECT_EQ(CONTENT_SETTING_BLOCK,
297 provider.AllowUserExceptionsForType(type_info.content_type));
298 }
299
300 provider.ShutdownOnUIThread();
301 }
302
257 } // namespace content_settings 303 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698