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

Side by Side Diff: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc

Issue 7828022: Add a method to the HostContentSettings map to return the |Value| of a content setting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
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 "chrome/browser/content_settings/content_settings_policy_provider.h" 5 #include "chrome/browser/content_settings/content_settings_policy_provider.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"
11 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 12 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
12 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/testing_pref_service.h" 17 #include "chrome/test/base/testing_pref_service.h"
17 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
18 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 provider.ShutdownOnUIThread(); 249 provider.ShutdownOnUIThread();
249 } 250 }
250 251
251 TEST_F(PolicyProviderTest, AutoSelectCertificateList) { 252 TEST_F(PolicyProviderTest, AutoSelectCertificateList) {
252 TestingProfile profile; 253 TestingProfile profile;
253 TestingPrefService* prefs = profile.GetTestingPrefService(); 254 TestingPrefService* prefs = profile.GetTestingPrefService();
254 255
255 PolicyProvider provider(prefs, NULL); 256 PolicyProvider provider(prefs, NULL);
256 GURL google_url("https://mail.google.com"); 257 GURL google_url("https://mail.google.com");
257 // Tests the default setting for auto selecting certificates 258 // Tests the default setting for auto selecting certificates
258 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 259 EXPECT_EQ(NULL,
259 provider.GetContentSetting( 260 provider.GetContentSettingValue(
260 google_url, 261 google_url,
261 google_url, 262 google_url,
262 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 263 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
263 std::string())); 264 std::string()));
264 265
265 // Set the content settings pattern list for origins to auto select 266 // Set the content settings pattern list for origins to auto select
266 // certificates. 267 // certificates.
267 ListValue* value = new ListValue(); 268 ListValue* value = new ListValue();
268 value->Append(Value::CreateStringValue("[*.]google.com")); 269 value->Append(Value::CreateStringValue(
270 "[*.]google.com|{\"issuer\":{\"CN\":\"issuer name\"}}"));
269 prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls, 271 prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls,
270 value); 272 value);
271 GURL youtube_url("https://www.youtube.com"); 273 GURL youtube_url("https://www.youtube.com");
272 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 274 EXPECT_EQ(NULL,
273 provider.GetContentSetting( 275 provider.GetContentSettingValue(
274 youtube_url, 276 youtube_url,
275 youtube_url, 277 youtube_url,
276 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 278 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
277 std::string())); 279 std::string()));
278 EXPECT_EQ(CONTENT_SETTING_ALLOW, 280 scoped_ptr<Value> cert_filter(provider.GetContentSettingValue(
279 provider.GetContentSetting( 281 google_url,
280 google_url, 282 google_url,
281 google_url, 283 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
282 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 284 std::string()));
283 std::string())); 285
286 ASSERT_EQ(Value::TYPE_DICTIONARY, cert_filter->GetType());
287 EXPECT_TRUE(
288 static_cast<DictionaryValue*>(cert_filter.get())->HasKey("issuer"));
Pam (message me for reviews) 2011/09/02 11:05:29 Can you test at more detail than this, i.e. look a
markusheintz_ 2011/09/02 14:55:59 Done.
284 289
285 provider.ShutdownOnUIThread(); 290 provider.ShutdownOnUIThread();
286 } 291 }
292
287 } // namespace content_settings 293 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698