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

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

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 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 "components/policy/core/browser/url_blacklist_policy_handler.h" 5 #include "components/policy/core/browser/url_blacklist_policy_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 TEST_F(URLBlacklistPolicyHandlerTest, 61 TEST_F(URLBlacklistPolicyHandlerTest,
62 CheckPolicySettings_URLBlacklistUnspecified) { 62 CheckPolicySettings_URLBlacklistUnspecified) {
63 EXPECT_TRUE(CheckPolicy(key::kDisabledSchemes, 63 EXPECT_TRUE(CheckPolicy(key::kDisabledSchemes,
64 base::WrapUnique(new base::ListValue))); 64 base::WrapUnique(new base::ListValue)));
65 EXPECT_EQ(0U, errors_.size()); 65 EXPECT_EQ(0U, errors_.size());
66 } 66 }
67 67
68 TEST_F(URLBlacklistPolicyHandlerTest, 68 TEST_F(URLBlacklistPolicyHandlerTest,
69 CheckPolicySettings_DisabledSchemesWrongType) { 69 CheckPolicySettings_DisabledSchemesWrongType) {
70 // The policy expects a list. Give it a boolean. 70 // The policy expects a list. Give it a boolean.
71 EXPECT_TRUE(CheckPolicy(key::kDisabledSchemes, 71 EXPECT_TRUE(
72 base::MakeUnique<base::FundamentalValue>(false))); 72 CheckPolicy(key::kDisabledSchemes, base::MakeUnique<base::Value>(false)));
73 EXPECT_EQ(1U, errors_.size()); 73 EXPECT_EQ(1U, errors_.size());
74 const std::string expected = key::kDisabledSchemes; 74 const std::string expected = key::kDisabledSchemes;
75 const std::string actual = errors_.begin()->first; 75 const std::string actual = errors_.begin()->first;
76 EXPECT_EQ(expected, actual); 76 EXPECT_EQ(expected, actual);
77 } 77 }
78 78
79 TEST_F(URLBlacklistPolicyHandlerTest, 79 TEST_F(URLBlacklistPolicyHandlerTest,
80 CheckPolicySettings_URLBlacklistWrongType) { 80 CheckPolicySettings_URLBlacklistWrongType) {
81 // The policy expects a list. Give it a boolean. 81 // The policy expects a list. Give it a boolean.
82 EXPECT_TRUE(CheckPolicy(key::kURLBlacklist, 82 EXPECT_TRUE(
83 base::MakeUnique<base::FundamentalValue>(false))); 83 CheckPolicy(key::kURLBlacklist, base::MakeUnique<base::Value>(false)));
84 EXPECT_EQ(1U, errors_.size()); 84 EXPECT_EQ(1U, errors_.size());
85 const std::string expected = key::kURLBlacklist; 85 const std::string expected = key::kURLBlacklist;
86 const std::string actual = errors_.begin()->first; 86 const std::string actual = errors_.begin()->first;
87 EXPECT_EQ(expected, actual); 87 EXPECT_EQ(expected, actual);
88 } 88 }
89 89
90 TEST_F(URLBlacklistPolicyHandlerTest, ApplyPolicySettings_NothingSpecified) { 90 TEST_F(URLBlacklistPolicyHandlerTest, ApplyPolicySettings_NothingSpecified) {
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_DisabledSchemesWrongType) { 96 ApplyPolicySettings_DisabledSchemesWrongType) {
97 // The policy expects a list. Give it a boolean. 97 // The policy expects a list. Give it a boolean.
98 SetPolicy(key::kDisabledSchemes, 98 SetPolicy(key::kDisabledSchemes, base::MakeUnique<base::Value>(false));
99 base::MakeUnique<base::FundamentalValue>(false));
100 ApplyPolicies(); 99 ApplyPolicies();
101 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); 100 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL));
102 } 101 }
103 102
104 TEST_F(URLBlacklistPolicyHandlerTest, 103 TEST_F(URLBlacklistPolicyHandlerTest,
105 ApplyPolicySettings_URLBlacklistWrongType) { 104 ApplyPolicySettings_URLBlacklistWrongType) {
106 // The policy expects a list. Give it a boolean. 105 // The policy expects a list. Give it a boolean.
107 SetPolicy(key::kURLBlacklist, 106 SetPolicy(key::kURLBlacklist, base::MakeUnique<base::Value>(false));
108 base::MakeUnique<base::FundamentalValue>(false));
109 ApplyPolicies(); 107 ApplyPolicies();
110 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); 108 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL));
111 } 109 }
112 110
113 TEST_F(URLBlacklistPolicyHandlerTest, 111 TEST_F(URLBlacklistPolicyHandlerTest,
114 ApplyPolicySettings_DisabledSchemesEmpty) { 112 ApplyPolicySettings_DisabledSchemesEmpty) {
115 SetPolicy(key::kDisabledSchemes, base::WrapUnique(new base::ListValue)); 113 SetPolicy(key::kDisabledSchemes, base::WrapUnique(new base::ListValue));
116 ApplyPolicies(); 114 ApplyPolicies();
117 base::Value* out; 115 base::Value* out;
118 EXPECT_TRUE(prefs_.GetValue(policy_prefs::kUrlBlacklist, &out)); 116 EXPECT_TRUE(prefs_.GetValue(policy_prefs::kUrlBlacklist, &out));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 std::string out1; 218 std::string out1;
221 EXPECT_TRUE(out_list->GetString(0U, &out1)); 219 EXPECT_TRUE(out_list->GetString(0U, &out1));
222 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1); 220 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1);
223 221
224 std::string out2; 222 std::string out2;
225 EXPECT_TRUE(out_list->GetString(1U, &out2)); 223 EXPECT_TRUE(out_list->GetString(1U, &out2));
226 EXPECT_EQ(kTestBlacklistValue, out2); 224 EXPECT_EQ(kTestBlacklistValue, out2);
227 } 225 }
228 226
229 } // namespace policy 227 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698