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

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

Issue 2318223002: Remove EmptyRuleIterators with nullptrs. (Closed)
Patch Set: Fix failing unit test Created 4 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
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 "components/content_settings/core/browser/content_settings_policy_provi der.h" 5 #include "components/content_settings/core/browser/content_settings_policy_provi der.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 23 matching lines...) Expand all
34 class PolicyProviderTest : public testing::Test { 34 class PolicyProviderTest : public testing::Test {
35 content::TestBrowserThreadBundle thread_bundle_; 35 content::TestBrowserThreadBundle thread_bundle_;
36 }; 36 };
37 37
38 TEST_F(PolicyProviderTest, DefaultGeolocationContentSetting) { 38 TEST_F(PolicyProviderTest, DefaultGeolocationContentSetting) {
39 TestingProfile profile; 39 TestingProfile profile;
40 syncable_prefs::TestingPrefServiceSyncable* prefs = 40 syncable_prefs::TestingPrefServiceSyncable* prefs =
41 profile.GetTestingPrefService(); 41 profile.GetTestingPrefService();
42 PolicyProvider provider(prefs); 42 PolicyProvider provider(prefs);
43 43
44 Rules rules;
45
46 std::unique_ptr<RuleIterator> rule_iterator(provider.GetRuleIterator( 44 std::unique_ptr<RuleIterator> rule_iterator(provider.GetRuleIterator(
47 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string(), false)); 45 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string(), false));
48 EXPECT_FALSE(rule_iterator->HasNext()); 46 EXPECT_FALSE(rule_iterator);
49 47
50 // Change the managed value of the default geolocation setting 48 // Change the managed value of the default geolocation setting
51 prefs->SetManagedPref(prefs::kManagedDefaultGeolocationSetting, 49 prefs->SetManagedPref(prefs::kManagedDefaultGeolocationSetting,
52 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); 50 new base::FundamentalValue(CONTENT_SETTING_BLOCK));
53 51
54 rule_iterator = provider.GetRuleIterator(CONTENT_SETTINGS_TYPE_GEOLOCATION, 52 rule_iterator = provider.GetRuleIterator(CONTENT_SETTINGS_TYPE_GEOLOCATION,
55 std::string(), false); 53 std::string(), false);
54 ASSERT_TRUE(rule_iterator);
56 EXPECT_TRUE(rule_iterator->HasNext()); 55 EXPECT_TRUE(rule_iterator->HasNext());
57 Rule rule = rule_iterator->Next(); 56 Rule rule = rule_iterator->Next();
58 EXPECT_FALSE(rule_iterator->HasNext()); 57 EXPECT_FALSE(rule_iterator->HasNext());
59 58
60 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.primary_pattern); 59 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.primary_pattern);
61 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.secondary_pattern); 60 EXPECT_EQ(ContentSettingsPattern::Wildcard(), rule.secondary_pattern);
62 EXPECT_EQ(CONTENT_SETTING_BLOCK, ValueToContentSetting(rule.value.get())); 61 EXPECT_EQ(CONTENT_SETTING_BLOCK, ValueToContentSetting(rule.value.get()));
63 62
64 provider.ShutdownOnUIThread(); 63 provider.ShutdownOnUIThread();
65 } 64 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType()); 240 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType());
242 base::DictionaryValue* dict_value = 241 base::DictionaryValue* dict_value =
243 static_cast<base::DictionaryValue*>(cert_filter.get()); 242 static_cast<base::DictionaryValue*>(cert_filter.get());
244 std::string actual_common_name; 243 std::string actual_common_name;
245 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name)); 244 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name));
246 EXPECT_EQ("issuer name", actual_common_name); 245 EXPECT_EQ("issuer name", actual_common_name);
247 provider.ShutdownOnUIThread(); 246 provider.ShutdownOnUIThread();
248 } 247 }
249 248
250 } // namespace content_settings 249 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698