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

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

Issue 7537025: Add new Content settings type AUTO-SUBMIT-CERTIFICATE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 4 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_pref_provider.h" 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/browser/content_settings/content_settings_mock_observer.h" 9 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
10 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 // Change obsolete preference and test if it migrated correctly. 161 // Change obsolete preference and test if it migrated correctly.
162 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, 162 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting,
163 CONTENT_SETTING_BLOCK); 163 CONTENT_SETTING_BLOCK);
164 EXPECT_EQ(CONTENT_SETTING_BLOCK, 164 EXPECT_EQ(CONTENT_SETTING_BLOCK,
165 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); 165 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION));
166 166
167 provider.ShutdownOnUIThread(); 167 provider.ShutdownOnUIThread();
168 } 168 }
169 169
170 TEST_F(PrefDefaultProviderTest, AutoSubmitCertificateContentSetting) {
171 TestingProfile profile;
172 TestingPrefService* prefs = profile.GetTestingPrefService();
173
174 PrefDefaultProvider provider(prefs, false);
175
176 EXPECT_EQ(CONTENT_SETTING_ASK,
177 provider.ProvideDefaultSetting(
178 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE));
179 provider.UpdateDefaultSetting(
180 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE, CONTENT_SETTING_ALLOW);
181 EXPECT_EQ(CONTENT_SETTING_ALLOW,
182 provider.ProvideDefaultSetting(
183 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE));
184 provider.ShutdownOnUIThread();
185 }
186
170 // //////////////////////////////////////////////////////////////////////////// 187 // ////////////////////////////////////////////////////////////////////////////
171 // PrefProviderTest 188 // PrefProviderTest
172 // 189 //
173 190
174 bool SettingsEqual(const ContentSettings& settings1, 191 bool SettingsEqual(const ContentSettings& settings1,
175 const ContentSettings& settings2) { 192 const ContentSettings& settings2) {
176 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 193 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
177 if (settings1.settings[i] != settings2.settings[i]) 194 if (settings1.settings[i] != settings2.settings[i])
178 return false; 195 return false;
179 } 196 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 EXPECT_FALSE(patterns_dictionary->HasKey("http://www.foo.com,error*")); 565 EXPECT_FALSE(patterns_dictionary->HasKey("http://www.foo.com,error*"));
549 EXPECT_FALSE(patterns_dictionary->HasKey( 566 EXPECT_FALSE(patterns_dictionary->HasKey(
550 "http://www.foo.com,[*.]bar.com")); 567 "http://www.foo.com,[*.]bar.com"));
551 EXPECT_FALSE(patterns_dictionary->HasKey("http://www.example2.com,*")); 568 EXPECT_FALSE(patterns_dictionary->HasKey("http://www.example2.com,*"));
552 569
553 EXPECT_FALSE(patterns_dictionary->HasKey("http://www.broken.com*")); 570 EXPECT_FALSE(patterns_dictionary->HasKey("http://www.broken.com*"));
554 571
555 provider.ShutdownOnUIThread(); 572 provider.ShutdownOnUIThread();
556 } 573 }
557 574
575 TEST_F(PrefProviderTest, AutoSubmitCertificateContentSetting) {
576 TestingProfile profile;
577 TestingPrefService* prefs = profile.GetTestingPrefService();
578 GURL primary_url("https://www.example.com");
579 GURL secondary_url("https://www.sample.com");
580
581 PrefProvider provider(prefs, false);
582
583 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
584 provider.GetContentSetting(
585 primary_url,
586 primary_url,
587 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
588 std::string()));
589
590 provider.SetContentSetting(
591 ContentSettingsPattern::FromURL(primary_url),
592 ContentSettingsPattern::Wildcard(),
593 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
594 std::string(),
595 CONTENT_SETTING_ALLOW);
596 EXPECT_EQ(CONTENT_SETTING_ALLOW,
597 provider.GetContentSetting(
598 primary_url,
599 secondary_url,
600 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
601 std::string()));
602 provider.ShutdownOnUIThread();
603 }
604
558 } // namespace content_settings 605 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698