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

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

Issue 385263004: Get rid of some uses of CreateIntegerValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 scoped_ptr<RuleIterator> rule_iterator( 55 scoped_ptr<RuleIterator> rule_iterator(
56 provider.GetRuleIterator( 56 provider.GetRuleIterator(
57 CONTENT_SETTINGS_TYPE_GEOLOCATION, 57 CONTENT_SETTINGS_TYPE_GEOLOCATION,
58 std::string(), 58 std::string(),
59 false)); 59 false));
60 EXPECT_FALSE(rule_iterator->HasNext()); 60 EXPECT_FALSE(rule_iterator->HasNext());
61 61
62 // Change the managed value of the default geolocation setting 62 // Change the managed value of the default geolocation setting
63 prefs->SetManagedPref(prefs::kManagedDefaultGeolocationSetting, 63 prefs->SetManagedPref(prefs::kManagedDefaultGeolocationSetting,
64 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 64 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
65 65
66 rule_iterator.reset( 66 rule_iterator.reset(
67 provider.GetRuleIterator( 67 provider.GetRuleIterator(
68 CONTENT_SETTINGS_TYPE_GEOLOCATION, 68 CONTENT_SETTINGS_TYPE_GEOLOCATION,
69 std::string(), 69 std::string(),
70 false)); 70 false));
71 EXPECT_TRUE(rule_iterator->HasNext()); 71 EXPECT_TRUE(rule_iterator->HasNext());
72 Rule rule = rule_iterator->Next(); 72 Rule rule = rule_iterator->Next();
73 EXPECT_FALSE(rule_iterator->HasNext()); 73 EXPECT_FALSE(rule_iterator->HasNext());
74 74
75 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.primary_pattern); 75 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.primary_pattern);
76 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.secondary_pattern); 76 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.secondary_pattern);
77 EXPECT_EQ(CONTENT_SETTING_BLOCK, ValueToContentSetting(rule.value.get())); 77 EXPECT_EQ(CONTENT_SETTING_BLOCK, ValueToContentSetting(rule.value.get()));
78 78
79 provider.ShutdownOnUIThread(); 79 provider.ShutdownOnUIThread();
80 } 80 }
81 81
82 TEST_F(PolicyProviderTest, ManagedDefaultContentSettings) { 82 TEST_F(PolicyProviderTest, ManagedDefaultContentSettings) {
83 TestingProfile profile; 83 TestingProfile profile;
84 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); 84 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
85 PolicyProvider provider(prefs); 85 PolicyProvider provider(prefs);
86 86
87 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, 87 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting,
88 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 88 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
89 89
90 scoped_ptr<RuleIterator> rule_iterator( 90 scoped_ptr<RuleIterator> rule_iterator(
91 provider.GetRuleIterator( 91 provider.GetRuleIterator(
92 CONTENT_SETTINGS_TYPE_PLUGINS, 92 CONTENT_SETTINGS_TYPE_PLUGINS,
93 std::string(), 93 std::string(),
94 false)); 94 false));
95 EXPECT_TRUE(rule_iterator->HasNext()); 95 EXPECT_TRUE(rule_iterator->HasNext());
96 Rule rule = rule_iterator->Next(); 96 Rule rule = rule_iterator->Next();
97 EXPECT_FALSE(rule_iterator->HasNext()); 97 EXPECT_FALSE(rule_iterator->HasNext());
98 98
(...skipping 15 matching lines...) Expand all
114 MockObserver mock_observer; 114 MockObserver mock_observer;
115 EXPECT_CALL(mock_observer, 115 EXPECT_CALL(mock_observer,
116 OnContentSettingChanged(_, 116 OnContentSettingChanged(_,
117 _, 117 _,
118 CONTENT_SETTINGS_TYPE_DEFAULT, 118 CONTENT_SETTINGS_TYPE_DEFAULT,
119 "")); 119 ""));
120 provider.AddObserver(&mock_observer); 120 provider.AddObserver(&mock_observer);
121 121
122 // Set the managed default-content-setting. 122 // Set the managed default-content-setting.
123 prefs->SetManagedPref(prefs::kManagedDefaultImagesSetting, 123 prefs->SetManagedPref(prefs::kManagedDefaultImagesSetting,
124 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 124 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
125 ::testing::Mock::VerifyAndClearExpectations(&mock_observer); 125 ::testing::Mock::VerifyAndClearExpectations(&mock_observer);
126 EXPECT_CALL(mock_observer, 126 EXPECT_CALL(mock_observer,
127 OnContentSettingChanged(_, 127 OnContentSettingChanged(_,
128 _, 128 _,
129 CONTENT_SETTINGS_TYPE_DEFAULT, 129 CONTENT_SETTINGS_TYPE_DEFAULT,
130 "")); 130 ""));
131 // Remove the managed default-content-setting. 131 // Remove the managed default-content-setting.
132 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); 132 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting);
133 provider.ShutdownOnUIThread(); 133 provider.ShutdownOnUIThread();
134 } 134 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 false)); 180 false));
181 181
182 int int_value = -1; 182 int int_value = -1;
183 value_ptr->GetAsInteger(&int_value); 183 value_ptr->GetAsInteger(&int_value);
184 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value)); 184 EXPECT_EQ(CONTENT_SETTING_BLOCK, IntToContentSetting(int_value));
185 185
186 // The PolicyProvider does not allow setting content settings as they are 186 // The PolicyProvider does not allow setting content settings as they are
187 // enforced via policies and not set by the user or extension. So a call to 187 // enforced via policies and not set by the user or extension. So a call to
188 // SetWebsiteSetting does nothing. 188 // SetWebsiteSetting does nothing.
189 scoped_ptr<base::Value> value_block( 189 scoped_ptr<base::Value> value_block(
190 base::Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); 190 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
191 bool owned = provider.SetWebsiteSetting(yt_url_pattern, 191 bool owned = provider.SetWebsiteSetting(yt_url_pattern,
192 yt_url_pattern, 192 yt_url_pattern,
193 CONTENT_SETTINGS_TYPE_COOKIES, 193 CONTENT_SETTINGS_TYPE_COOKIES,
194 std::string(), 194 std::string(),
195 value_block.get()); 195 value_block.get());
196 EXPECT_FALSE(owned); 196 EXPECT_FALSE(owned);
197 EXPECT_EQ(CONTENT_SETTING_DEFAULT, 197 EXPECT_EQ(CONTENT_SETTING_DEFAULT,
198 GetContentSetting(&provider, 198 GetContentSetting(&provider,
199 youtube_url, 199 youtube_url,
200 youtube_url, 200 youtube_url,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType()); 287 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType());
288 base::DictionaryValue* dict_value = 288 base::DictionaryValue* dict_value =
289 static_cast<base::DictionaryValue*>(cert_filter.get()); 289 static_cast<base::DictionaryValue*>(cert_filter.get());
290 std::string actual_common_name; 290 std::string actual_common_name;
291 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name)); 291 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name));
292 EXPECT_EQ("issuer name", actual_common_name); 292 EXPECT_EQ("issuer name", actual_common_name);
293 provider.ShutdownOnUIThread(); 293 provider.ShutdownOnUIThread();
294 } 294 }
295 295
296 } // namespace content_settings 296 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698