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 "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" |
11 #include "components/policy/core/common/policy_pref_names.h" | 11 #include "components/policy/core/common/policy_pref_names.h" |
| 12 #include "components/policy/core/common/policy_types.h" |
12 #include "policy/policy_constants.h" | 13 #include "policy/policy_constants.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 // Note: this file should move to components/policy/core/browser, but the | 16 // Note: this file should move to components/policy/core/browser, but the |
16 // components_unittests runner does not load the ResourceBundle as | 17 // components_unittests runner does not load the ResourceBundle as |
17 // ChromeTestSuite::Initialize does, which leads to failures using | 18 // ChromeTestSuite::Initialize does, which leads to failures using |
18 // PolicyErrorMap. | 19 // PolicyErrorMap. |
19 | 20 |
20 namespace policy { | 21 namespace policy { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 const char kTestDisabledScheme[] = "kTestDisabledScheme"; | 25 const char kTestDisabledScheme[] = "kTestDisabledScheme"; |
25 const char kTestBlacklistValue[] = "kTestBlacklistValue"; | 26 const char kTestBlacklistValue[] = "kTestBlacklistValue"; |
26 | 27 |
27 } // namespace | 28 } // namespace |
28 | 29 |
29 class URLBlacklistPolicyHandlerTest : public testing::Test { | 30 class URLBlacklistPolicyHandlerTest : public testing::Test { |
30 protected: | 31 protected: |
31 void SetPolicy(const std::string& key, base::Value* value) { | 32 void SetPolicy(const std::string& key, base::Value* value) { |
32 policies_.Set(key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, value, NULL); | 33 policies_.Set(key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 34 POLICY_SOURCE_CLOUD, value, nullptr); |
33 } | 35 } |
34 bool CheckPolicy(const std::string& key, base::Value* value) { | 36 bool CheckPolicy(const std::string& key, base::Value* value) { |
35 SetPolicy(key, value); | 37 SetPolicy(key, value); |
36 return handler_.CheckPolicySettings(policies_, &errors_); | 38 return handler_.CheckPolicySettings(policies_, &errors_); |
37 } | 39 } |
38 void ApplyPolicies() { | 40 void ApplyPolicies() { |
39 handler_.ApplyPolicySettings(policies_, &prefs_); | 41 handler_.ApplyPolicySettings(policies_, &prefs_); |
40 } | 42 } |
41 | 43 |
42 URLBlacklistPolicyHandler handler_; | 44 URLBlacklistPolicyHandler handler_; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 std::string out1; | 212 std::string out1; |
211 EXPECT_TRUE(out_list->GetString(0U, &out1)); | 213 EXPECT_TRUE(out_list->GetString(0U, &out1)); |
212 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1); | 214 EXPECT_EQ(kTestDisabledScheme + std::string("://*"), out1); |
213 | 215 |
214 std::string out2; | 216 std::string out2; |
215 EXPECT_TRUE(out_list->GetString(1U, &out2)); | 217 EXPECT_TRUE(out_list->GetString(1U, &out2)); |
216 EXPECT_EQ(kTestBlacklistValue, out2); | 218 EXPECT_EQ(kTestBlacklistValue, out2); |
217 } | 219 } |
218 | 220 |
219 } // namespace policy | 221 } // namespace policy |
OLD | NEW |