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

Side by Side Diff: components/policy/core/browser/url_blacklist_policy_handler_unittest.cc

Issue 397793002: Eliminate CreateBooleanValue from test files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad merge 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/prefs/pref_value_map.h" 6 #include "base/prefs/pref_value_map.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "components/policy/core/browser/policy_error_map.h" 8 #include "components/policy/core/browser/policy_error_map.h"
9 #include "components/policy/core/browser/url_blacklist_policy_handler.h" 9 #include "components/policy/core/browser/url_blacklist_policy_handler.h"
10 #include "components/policy/core/common/policy_map.h" 10 #include "components/policy/core/common/policy_map.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 TEST_F(URLBlacklistPolicyHandlerTest, 54 TEST_F(URLBlacklistPolicyHandlerTest,
55 CheckPolicySettings_URLBlacklistUnspecified) { 55 CheckPolicySettings_URLBlacklistUnspecified) {
56 EXPECT_TRUE(CheckPolicy(key::kDisabledSchemes, new base::ListValue)); 56 EXPECT_TRUE(CheckPolicy(key::kDisabledSchemes, new base::ListValue));
57 EXPECT_EQ(0U, errors_.size()); 57 EXPECT_EQ(0U, errors_.size());
58 } 58 }
59 59
60 TEST_F(URLBlacklistPolicyHandlerTest, 60 TEST_F(URLBlacklistPolicyHandlerTest,
61 CheckPolicySettings_DisabledSchemesWrongType) { 61 CheckPolicySettings_DisabledSchemesWrongType) {
62 // The policy expects a list. Give it a boolean. 62 // The policy expects a list. Give it a boolean.
63 EXPECT_TRUE(CheckPolicy(key::kDisabledSchemes, 63 EXPECT_TRUE(
64 base::Value::CreateBooleanValue(false))); 64 CheckPolicy(key::kDisabledSchemes, new base::FundamentalValue(false)));
65 EXPECT_EQ(1U, errors_.size()); 65 EXPECT_EQ(1U, errors_.size());
66 const std::string expected = key::kDisabledSchemes; 66 const std::string expected = key::kDisabledSchemes;
67 const std::string actual = errors_.begin()->first; 67 const std::string actual = errors_.begin()->first;
68 EXPECT_EQ(expected, actual); 68 EXPECT_EQ(expected, actual);
69 } 69 }
70 70
71 TEST_F(URLBlacklistPolicyHandlerTest, 71 TEST_F(URLBlacklistPolicyHandlerTest,
72 CheckPolicySettings_URLBlacklistWrongType) { 72 CheckPolicySettings_URLBlacklistWrongType) {
73 // The policy expects a list. Give it a boolean. 73 // The policy expects a list. Give it a boolean.
74 EXPECT_TRUE(CheckPolicy(key::kURLBlacklist, 74 EXPECT_TRUE(
75 base::Value::CreateBooleanValue(false))); 75 CheckPolicy(key::kURLBlacklist, new base::FundamentalValue(false)));
76 EXPECT_EQ(1U, errors_.size()); 76 EXPECT_EQ(1U, errors_.size());
77 const std::string expected = key::kURLBlacklist; 77 const std::string expected = key::kURLBlacklist;
78 const std::string actual = errors_.begin()->first; 78 const std::string actual = errors_.begin()->first;
79 EXPECT_EQ(expected, actual); 79 EXPECT_EQ(expected, actual);
80 } 80 }
81 81
82 TEST_F(URLBlacklistPolicyHandlerTest, ApplyPolicySettings_NothingSpecified) { 82 TEST_F(URLBlacklistPolicyHandlerTest, ApplyPolicySettings_NothingSpecified) {
83 ApplyPolicies(); 83 ApplyPolicies();
84 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); 84 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL));
85 } 85 }
86 86
87 TEST_F(URLBlacklistPolicyHandlerTest, 87 TEST_F(URLBlacklistPolicyHandlerTest,
88 ApplyPolicySettings_DisabledSchemesWrongType) { 88 ApplyPolicySettings_DisabledSchemesWrongType) {
89 // The policy expects a list. Give it a boolean. 89 // The policy expects a list. Give it a boolean.
90 SetPolicy(key::kDisabledSchemes, base::Value::CreateBooleanValue(false)); 90 SetPolicy(key::kDisabledSchemes, new base::FundamentalValue(false));
91 ApplyPolicies(); 91 ApplyPolicies();
92 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); 92 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL));
93 } 93 }
94 94
95 TEST_F(URLBlacklistPolicyHandlerTest, 95 TEST_F(URLBlacklistPolicyHandlerTest,
96 ApplyPolicySettings_URLBlacklistWrongType) { 96 ApplyPolicySettings_URLBlacklistWrongType) {
97 // The policy expects a list. Give it a boolean. 97 // The policy expects a list. Give it a boolean.
98 SetPolicy(key::kURLBlacklist, base::Value::CreateBooleanValue(false)); 98 SetPolicy(key::kURLBlacklist, new base::FundamentalValue(false));
99 ApplyPolicies(); 99 ApplyPolicies();
100 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); 100 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL));
101 } 101 }
102 102
103 TEST_F(URLBlacklistPolicyHandlerTest, 103 TEST_F(URLBlacklistPolicyHandlerTest,
104 ApplyPolicySettings_DisabledSchemesEmpty) { 104 ApplyPolicySettings_DisabledSchemesEmpty) {
105 SetPolicy(key::kDisabledSchemes, new base::ListValue); 105 SetPolicy(key::kDisabledSchemes, new base::ListValue);
106 ApplyPolicies(); 106 ApplyPolicies();
107 base::Value* out; 107 base::Value* out;
108 EXPECT_TRUE(prefs_.GetValue(policy_prefs::kUrlBlacklist, &out)); 108 EXPECT_TRUE(prefs_.GetValue(policy_prefs::kUrlBlacklist, &out));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 std::string out1; 210 std::string out1;
211 EXPECT_TRUE(out_list->GetString(0U, &out1)); 211 EXPECT_TRUE(out_list->GetString(0U, &out1));
212 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1); 212 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1);
213 213
214 std::string out2; 214 std::string out2;
215 EXPECT_TRUE(out_list->GetString(1U, &out2)); 215 EXPECT_TRUE(out_list->GetString(1U, &out2));
216 EXPECT_EQ(kTestBlacklistValue, out2); 216 EXPECT_EQ(kTestBlacklistValue, out2);
217 } 217 }
218 218
219 } // namespace policy 219 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698