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

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_BLOCK,
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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 &settings); 499 &settings);
483 ASSERT_TRUE(NULL != settings) << "Dictionary has no key: " 500 ASSERT_TRUE(NULL != settings) << "Dictionary has no key: "
484 << primary_pattern.ToString(); 501 << primary_pattern.ToString();
485 ASSERT_EQ(1U, settings->size()); 502 ASSERT_EQ(1U, settings->size());
486 settings->GetInteger("javascript", &setting_value); 503 settings->GetInteger("javascript", &setting_value);
487 EXPECT_EQ(setting_value, CONTENT_SETTING_ALLOW); 504 EXPECT_EQ(setting_value, CONTENT_SETTING_ALLOW);
488 505
489 provider.ShutdownOnUIThread(); 506 provider.ShutdownOnUIThread();
490 } 507 }
491 508
509 TEST_F(PrefProviderTest, AutoSubmitCertificateContentSetting) {
510 TestingProfile profile;
511 TestingPrefService* prefs = profile.GetTestingPrefService();
512 GURL primary_url("http://www.example.com");
513 GURL secondary_url("http://www.sample.com");
514
515 PrefProvider provider(prefs, false);
516
517 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
518 provider.GetContentSetting(
519 primary_url,
520 primary_url,
521 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
522 std::string()));
wtc 2011/08/11 18:33:55 Why is the expected value CONTENT_SETTING_DEFAULT
markusheintz_ 2011/08/15 19:09:04 We have two kinds of content settings provider: De
523
524 provider.SetContentSetting(
525 ContentSettingsPattern::FromURL(primary_url),
526 ContentSettingsPattern::Wildcard(),
527 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
528 std::string(),
529 CONTENT_SETTING_ALLOW);
530 EXPECT_EQ(CONTENT_SETTING_ALLOW,
531 provider.GetContentSetting(
532 primary_url,
533 secondary_url,
534 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE,
535 std::string()));
536 provider.ShutdownOnUIThread();
537 }
538
492 } // namespace content_settings 539 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698