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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map_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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "chrome/browser/content_settings/content_settings_details.h" 9 #include "chrome/browser/content_settings/content_settings_details.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
(...skipping 10 matching lines...) Expand all
21 #include "net/base/static_cookie_policy.h" 21 #include "net/base/static_cookie_policy.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 using ::testing::_; 24 using ::testing::_;
25 25
26 namespace { 26 namespace {
27 27
28 bool SettingsEqual(const ContentSettings& settings1, 28 bool SettingsEqual(const ContentSettings& settings1,
29 const ContentSettings& settings2) { 29 const ContentSettings& settings2) {
30 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 30 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
31 if (settings1.settings[i] != settings2.settings[i]) 31 if (settings1.settings[i] != settings2.settings[i]) {
32 LOG(ERROR) << "type: " << i
33 << " [expected: " << settings1.settings[i]
34 << " actual: " << settings2.settings[i] << "]";
32 return false; 35 return false;
36 }
33 } 37 }
34 return true; 38 return true;
35 } 39 }
36 40
37 } // namespace 41 } // namespace
38 42
39 class HostContentSettingsMapTest : public TestingBrowserProcessTest { 43 class HostContentSettingsMapTest : public TestingBrowserProcessTest {
40 public: 44 public:
41 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) { 45 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) {
42 } 46 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = 151 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
148 CONTENT_SETTING_ALLOW; 152 CONTENT_SETTING_ALLOW;
149 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] = 153 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] =
150 CONTENT_SETTING_BLOCK; 154 CONTENT_SETTING_BLOCK;
151 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] = 155 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] =
152 CONTENT_SETTING_ASK; 156 CONTENT_SETTING_ASK;
153 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] = 157 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] =
154 CONTENT_SETTING_ASK; 158 CONTENT_SETTING_ASK;
155 desired_settings.settings[CONTENT_SETTINGS_TYPE_INTENTS] = 159 desired_settings.settings[CONTENT_SETTINGS_TYPE_INTENTS] =
156 CONTENT_SETTING_ASK; 160 CONTENT_SETTING_ASK;
161 desired_settings.settings[CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE] =
162 CONTENT_SETTING_ASK;
157 ContentSettings settings = 163 ContentSettings settings =
158 host_content_settings_map->GetContentSettings(host, host); 164 host_content_settings_map->GetContentSettings(host, host);
159 EXPECT_TRUE(SettingsEqual(desired_settings, settings)); 165 EXPECT_TRUE(SettingsEqual(desired_settings, settings));
160 166
161 // Check returning all hosts for a setting. 167 // Check returning all hosts for a setting.
162 ContentSettingsPattern pattern2 = 168 ContentSettingsPattern pattern2 =
163 ContentSettingsPattern::FromString("[*.]example.org"); 169 ContentSettingsPattern::FromString("[*.]example.org");
164 host_content_settings_map->SetContentSetting( 170 host_content_settings_map->SetContentSetting(
165 pattern2, 171 pattern2,
166 ContentSettingsPattern::Wildcard(), 172 ContentSettingsPattern::Wildcard(),
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = 601 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
596 CONTENT_SETTING_BLOCK; 602 CONTENT_SETTING_BLOCK;
597 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] = 603 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] =
598 CONTENT_SETTING_BLOCK; 604 CONTENT_SETTING_BLOCK;
599 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] = 605 desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] =
600 CONTENT_SETTING_ASK; 606 CONTENT_SETTING_ASK;
601 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] = 607 desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] =
602 CONTENT_SETTING_ASK; 608 CONTENT_SETTING_ASK;
603 desired_settings.settings[CONTENT_SETTINGS_TYPE_INTENTS] = 609 desired_settings.settings[CONTENT_SETTINGS_TYPE_INTENTS] =
604 CONTENT_SETTING_ASK; 610 CONTENT_SETTING_ASK;
611 desired_settings.settings[CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE] =
612 CONTENT_SETTING_ASK;
605 ContentSettings settings = 613 ContentSettings settings =
606 host_content_settings_map->GetContentSettings(host, host); 614 host_content_settings_map->GetContentSettings(host, host);
607 EXPECT_TRUE(SettingsEqual(desired_settings, settings)); 615 EXPECT_TRUE(SettingsEqual(desired_settings, settings));
608 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES], 616 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES],
609 settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]); 617 settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]);
610 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES], 618 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES],
611 settings.settings[CONTENT_SETTINGS_TYPE_IMAGES]); 619 settings.settings[CONTENT_SETTINGS_TYPE_IMAGES]);
612 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS], 620 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS],
613 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS]); 621 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS]);
614 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS], 622 EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS],
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 TEST_F(HostContentSettingsMapTest, NonDefaultSettings) { 795 TEST_F(HostContentSettingsMapTest, NonDefaultSettings) {
788 TestingProfile profile; 796 TestingProfile profile;
789 HostContentSettingsMap* host_content_settings_map = 797 HostContentSettingsMap* host_content_settings_map =
790 profile.GetHostContentSettingsMap(); 798 profile.GetHostContentSettingsMap();
791 799
792 GURL host("http://example.com/"); 800 GURL host("http://example.com/");
793 ContentSettingsPattern pattern = 801 ContentSettingsPattern pattern =
794 ContentSettingsPattern::FromString("[*.]example.com"); 802 ContentSettingsPattern::FromString("[*.]example.com");
795 803
796 ContentSettings desired_settings(CONTENT_SETTING_DEFAULT); 804 ContentSettings desired_settings(CONTENT_SETTING_DEFAULT);
805 desired_settings.settings[CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE] =
806 CONTENT_SETTING_ASK;
797 ContentSettings settings = 807 ContentSettings settings =
798 host_content_settings_map->GetNonDefaultContentSettings(host, host); 808 host_content_settings_map->GetNonDefaultContentSettings(host, host);
799 EXPECT_TRUE(SettingsEqual(desired_settings, settings)); 809 EXPECT_TRUE(SettingsEqual(desired_settings, settings));
800 810
801 host_content_settings_map->SetContentSetting( 811 host_content_settings_map->SetContentSetting(
802 pattern, 812 pattern,
803 ContentSettingsPattern::Wildcard(), 813 ContentSettingsPattern::Wildcard(),
804 CONTENT_SETTINGS_TYPE_IMAGES, 814 CONTENT_SETTINGS_TYPE_IMAGES,
805 "", 815 "",
806 CONTENT_SETTING_BLOCK); 816 CONTENT_SETTING_BLOCK);
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 EXPECT_EQ(CONTENT_SETTING_ALLOW, 1268 EXPECT_EQ(CONTENT_SETTING_ALLOW,
1259 host_content_settings_map->GetCookieContentSetting( 1269 host_content_settings_map->GetCookieContentSetting(
1260 kAllowedSite, kFirstPartySite, true)); 1270 kAllowedSite, kFirstPartySite, true));
1261 EXPECT_EQ(CONTENT_SETTING_ALLOW, 1271 EXPECT_EQ(CONTENT_SETTING_ALLOW,
1262 host_content_settings_map->GetCookieContentSetting( 1272 host_content_settings_map->GetCookieContentSetting(
1263 kAllowedSite, kAllowedSite, false)); 1273 kAllowedSite, kAllowedSite, false));
1264 EXPECT_EQ(CONTENT_SETTING_ALLOW, 1274 EXPECT_EQ(CONTENT_SETTING_ALLOW,
1265 host_content_settings_map->GetCookieContentSetting( 1275 host_content_settings_map->GetCookieContentSetting(
1266 kAllowedSite, kAllowedSite, true)); 1276 kAllowedSite, kAllowedSite, true));
1267 } 1277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698