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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "components/policy/core/common/async_policy_provider.h" | 13 #include "components/policy/core/common/async_policy_provider.h" |
14 #include "components/policy/core/common/config_dir_policy_loader.h" | 14 #include "components/policy/core/common/config_dir_policy_loader.h" |
15 #include "components/policy/core/common/configuration_policy_provider_test.h" | 15 #include "components/policy/core/common/configuration_policy_provider_test.h" |
16 #include "components/policy/core/common/policy_bundle.h" | 16 #include "components/policy/core/common/policy_bundle.h" |
17 #include "components/policy/core/common/policy_map.h" | 17 #include "components/policy/core/common/policy_map.h" |
| 18 #include "components/policy/core/common/policy_types.h" |
18 | 19 |
19 namespace policy { | 20 namespace policy { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Subdirectory of the config dir that contains mandatory policies. | 24 // Subdirectory of the config dir that contains mandatory policies. |
24 const base::FilePath::CharType kMandatoryPath[] = FILE_PATH_LITERAL("managed"); | 25 const base::FilePath::CharType kMandatoryPath[] = FILE_PATH_LITERAL("managed"); |
25 | 26 |
26 class TestHarness : public PolicyProviderTestHarness { | 27 class TestHarness : public PolicyProviderTestHarness { |
27 public: | 28 public: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 static PolicyProviderTestHarness* Create(); | 62 static PolicyProviderTestHarness* Create(); |
62 | 63 |
63 private: | 64 private: |
64 base::ScopedTempDir test_dir_; | 65 base::ScopedTempDir test_dir_; |
65 int next_policy_file_index_; | 66 int next_policy_file_index_; |
66 | 67 |
67 DISALLOW_COPY_AND_ASSIGN(TestHarness); | 68 DISALLOW_COPY_AND_ASSIGN(TestHarness); |
68 }; | 69 }; |
69 | 70 |
70 TestHarness::TestHarness() | 71 TestHarness::TestHarness() |
71 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE), | 72 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, |
| 73 POLICY_SCOPE_MACHINE, |
| 74 POLICY_SOURCE_PLATFORM), |
72 next_policy_file_index_(100) {} | 75 next_policy_file_index_(100) {} |
73 | 76 |
74 TestHarness::~TestHarness() {} | 77 TestHarness::~TestHarness() {} |
75 | 78 |
76 void TestHarness::SetUp() { | 79 void TestHarness::SetUp() { |
77 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); | 80 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
78 } | 81 } |
79 | 82 |
80 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 83 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
81 SchemaRegistry* registry, | 84 SchemaRegistry* registry, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 harness_.WriteConfigFile(test_dict_foo, "9"); | 221 harness_.WriteConfigFile(test_dict_foo, "9"); |
219 for (unsigned int i = 5; i <= 8; ++i) | 222 for (unsigned int i = 5; i <= 8; ++i) |
220 harness_.WriteConfigFile(test_dict_bar, base::IntToString(i)); | 223 harness_.WriteConfigFile(test_dict_bar, base::IntToString(i)); |
221 | 224 |
222 ConfigDirPolicyLoader loader(loop_.task_runner(), harness_.test_dir(), | 225 ConfigDirPolicyLoader loader(loop_.task_runner(), harness_.test_dir(), |
223 POLICY_SCOPE_USER); | 226 POLICY_SCOPE_USER); |
224 scoped_ptr<PolicyBundle> bundle(loader.Load()); | 227 scoped_ptr<PolicyBundle> bundle(loader.Load()); |
225 ASSERT_TRUE(bundle.get()); | 228 ASSERT_TRUE(bundle.get()); |
226 PolicyBundle expected_bundle; | 229 PolicyBundle expected_bundle; |
227 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 230 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
228 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); | 231 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 232 POLICY_SOURCE_PLATFORM); |
229 EXPECT_TRUE(bundle->Equals(expected_bundle)); | 233 EXPECT_TRUE(bundle->Equals(expected_bundle)); |
230 } | 234 } |
231 | 235 |
232 } // namespace policy | 236 } // namespace policy |
OLD | NEW |