OLD | NEW |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(CheckPolicy(key::kDisabledSchemes, |
72 base::MakeUnique<base::FundamentalValue>(false))); | 72 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(CheckPolicy(key::kURLBlacklist, |
83 base::MakeUnique<base::FundamentalValue>(false))); | 83 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, |
99 base::MakeUnique<base::FundamentalValue>(false)); | 99 base::MakeUnique<base::Value>(false)); |
100 ApplyPolicies(); | 100 ApplyPolicies(); |
101 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); | 101 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); |
102 } | 102 } |
103 | 103 |
104 TEST_F(URLBlacklistPolicyHandlerTest, | 104 TEST_F(URLBlacklistPolicyHandlerTest, |
105 ApplyPolicySettings_URLBlacklistWrongType) { | 105 ApplyPolicySettings_URLBlacklistWrongType) { |
106 // The policy expects a list. Give it a boolean. | 106 // The policy expects a list. Give it a boolean. |
107 SetPolicy(key::kURLBlacklist, | 107 SetPolicy(key::kURLBlacklist, |
108 base::MakeUnique<base::FundamentalValue>(false)); | 108 base::MakeUnique<base::Value>(false)); |
109 ApplyPolicies(); | 109 ApplyPolicies(); |
110 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); | 110 EXPECT_FALSE(prefs_.GetValue(policy_prefs::kUrlBlacklist, NULL)); |
111 } | 111 } |
112 | 112 |
113 TEST_F(URLBlacklistPolicyHandlerTest, | 113 TEST_F(URLBlacklistPolicyHandlerTest, |
114 ApplyPolicySettings_DisabledSchemesEmpty) { | 114 ApplyPolicySettings_DisabledSchemesEmpty) { |
115 SetPolicy(key::kDisabledSchemes, base::WrapUnique(new base::ListValue)); | 115 SetPolicy(key::kDisabledSchemes, base::WrapUnique(new base::ListValue)); |
116 ApplyPolicies(); | 116 ApplyPolicies(); |
117 base::Value* out; | 117 base::Value* out; |
118 EXPECT_TRUE(prefs_.GetValue(policy_prefs::kUrlBlacklist, &out)); | 118 EXPECT_TRUE(prefs_.GetValue(policy_prefs::kUrlBlacklist, &out)); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 std::string out1; | 220 std::string out1; |
221 EXPECT_TRUE(out_list->GetString(0U, &out1)); | 221 EXPECT_TRUE(out_list->GetString(0U, &out1)); |
222 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1); | 222 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1); |
223 | 223 |
224 std::string out2; | 224 std::string out2; |
225 EXPECT_TRUE(out_list->GetString(1U, &out2)); | 225 EXPECT_TRUE(out_list->GetString(1U, &out2)); |
226 EXPECT_EQ(kTestBlacklistValue, out2); | 226 EXPECT_EQ(kTestBlacklistValue, out2); |
227 } | 227 } |
228 | 228 |
229 } // namespace policy | 229 } // namespace policy |
OLD | NEW |