OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/config_dir_policy_loader.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
6 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
8 #include "base/json/json_string_value_serializer.h" | 12 #include "base/json/json_string_value_serializer.h" |
9 #include "base/macros.h" | 13 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
11 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
12 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
13 #include "base/values.h" | 17 #include "base/values.h" |
14 #include "components/policy/core/common/async_policy_provider.h" | 18 #include "components/policy/core/common/async_policy_provider.h" |
15 #include "components/policy/core/common/config_dir_policy_loader.h" | |
16 #include "components/policy/core/common/configuration_policy_provider_test.h" | 19 #include "components/policy/core/common/configuration_policy_provider_test.h" |
17 #include "components/policy/core/common/policy_bundle.h" | 20 #include "components/policy/core/common/policy_bundle.h" |
18 #include "components/policy/core/common/policy_map.h" | 21 #include "components/policy/core/common/policy_map.h" |
19 #include "components/policy/core/common/policy_types.h" | 22 #include "components/policy/core/common/policy_types.h" |
20 | 23 |
21 namespace policy { | 24 namespace policy { |
22 | 25 |
23 namespace { | 26 namespace { |
24 | 27 |
25 // Subdirectory of the config dir that contains mandatory policies. | 28 // Subdirectory of the config dir that contains mandatory policies. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 82 |
80 void TestHarness::SetUp() { | 83 void TestHarness::SetUp() { |
81 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); | 84 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
82 } | 85 } |
83 | 86 |
84 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 87 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
85 SchemaRegistry* registry, | 88 SchemaRegistry* registry, |
86 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 89 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
87 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( | 90 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( |
88 task_runner, test_dir(), POLICY_SCOPE_MACHINE)); | 91 task_runner, test_dir(), POLICY_SCOPE_MACHINE)); |
89 return new AsyncPolicyProvider(registry, loader.Pass()); | 92 return new AsyncPolicyProvider(registry, std::move(loader)); |
90 } | 93 } |
91 | 94 |
92 void TestHarness::InstallEmptyPolicy() { | 95 void TestHarness::InstallEmptyPolicy() { |
93 base::DictionaryValue dict; | 96 base::DictionaryValue dict; |
94 WriteConfigFile(dict, NextConfigFileName()); | 97 WriteConfigFile(dict, NextConfigFileName()); |
95 } | 98 } |
96 | 99 |
97 void TestHarness::InstallStringPolicy(const std::string& policy_name, | 100 void TestHarness::InstallStringPolicy(const std::string& policy_name, |
98 const std::string& policy_value) { | 101 const std::string& policy_value) { |
99 base::DictionaryValue dict; | 102 base::DictionaryValue dict; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 scoped_ptr<PolicyBundle> bundle(loader.Load()); | 231 scoped_ptr<PolicyBundle> bundle(loader.Load()); |
229 ASSERT_TRUE(bundle.get()); | 232 ASSERT_TRUE(bundle.get()); |
230 PolicyBundle expected_bundle; | 233 PolicyBundle expected_bundle; |
231 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 234 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
232 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 235 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
233 POLICY_SOURCE_PLATFORM); | 236 POLICY_SOURCE_PLATFORM); |
234 EXPECT_TRUE(bundle->Equals(expected_bundle)); | 237 EXPECT_TRUE(bundle->Equals(expected_bundle)); |
235 } | 238 } |
236 | 239 |
237 } // namespace policy | 240 } // namespace policy |
OLD | NEW |