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/file_util.h" | 6 #include "base/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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 class TestHarness : public PolicyProviderTestHarness { | 28 class TestHarness : public PolicyProviderTestHarness { |
29 public: | 29 public: |
30 TestHarness(); | 30 TestHarness(); |
31 virtual ~TestHarness(); | 31 virtual ~TestHarness(); |
32 | 32 |
33 virtual void SetUp() OVERRIDE; | 33 virtual void SetUp() OVERRIDE; |
34 | 34 |
35 virtual ConfigurationPolicyProvider* CreateProvider( | 35 virtual ConfigurationPolicyProvider* CreateProvider( |
36 SchemaRegistry* registry, | 36 SchemaRegistry* registry, |
37 scoped_refptr<base::SequencedTaskRunner> task_runner, | 37 scoped_refptr<base::SequencedTaskRunner> task_runner) OVERRIDE; |
38 const PolicyDefinitionList* policy_definition_list) OVERRIDE; | |
39 | 38 |
40 virtual void InstallEmptyPolicy() OVERRIDE; | 39 virtual void InstallEmptyPolicy() OVERRIDE; |
41 virtual void InstallStringPolicy(const std::string& policy_name, | 40 virtual void InstallStringPolicy(const std::string& policy_name, |
42 const std::string& policy_value) OVERRIDE; | 41 const std::string& policy_value) OVERRIDE; |
43 virtual void InstallIntegerPolicy(const std::string& policy_name, | 42 virtual void InstallIntegerPolicy(const std::string& policy_name, |
44 int policy_value) OVERRIDE; | 43 int policy_value) OVERRIDE; |
45 virtual void InstallBooleanPolicy(const std::string& policy_name, | 44 virtual void InstallBooleanPolicy(const std::string& policy_name, |
46 bool policy_value) OVERRIDE; | 45 bool policy_value) OVERRIDE; |
47 virtual void InstallStringListPolicy( | 46 virtual void InstallStringListPolicy( |
48 const std::string& policy_name, | 47 const std::string& policy_name, |
(...skipping 28 matching lines...) Expand all Loading... |
77 next_policy_file_index_(100) {} | 76 next_policy_file_index_(100) {} |
78 | 77 |
79 TestHarness::~TestHarness() {} | 78 TestHarness::~TestHarness() {} |
80 | 79 |
81 void TestHarness::SetUp() { | 80 void TestHarness::SetUp() { |
82 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); | 81 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
83 } | 82 } |
84 | 83 |
85 ConfigurationPolicyProvider* TestHarness::CreateProvider( | 84 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
86 SchemaRegistry* registry, | 85 SchemaRegistry* registry, |
87 scoped_refptr<base::SequencedTaskRunner> task_runner, | 86 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
88 const PolicyDefinitionList* policy_definition_list) { | |
89 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( | 87 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( |
90 task_runner, test_dir(), POLICY_SCOPE_MACHINE)); | 88 task_runner, test_dir(), POLICY_SCOPE_MACHINE)); |
91 return new AsyncPolicyProvider(registry, loader.Pass()); | 89 return new AsyncPolicyProvider(registry, loader.Pass()); |
92 } | 90 } |
93 | 91 |
94 void TestHarness::InstallEmptyPolicy() { | 92 void TestHarness::InstallEmptyPolicy() { |
95 base::DictionaryValue dict; | 93 base::DictionaryValue dict; |
96 WriteConfigFile(dict, NextConfigFileName()); | 94 WriteConfigFile(dict, NextConfigFileName()); |
97 } | 95 } |
98 | 96 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 loop_.message_loop_proxy(), harness_.test_dir(), POLICY_SCOPE_USER); | 227 loop_.message_loop_proxy(), harness_.test_dir(), POLICY_SCOPE_USER); |
230 scoped_ptr<PolicyBundle> bundle(loader.Load()); | 228 scoped_ptr<PolicyBundle> bundle(loader.Load()); |
231 ASSERT_TRUE(bundle.get()); | 229 ASSERT_TRUE(bundle.get()); |
232 PolicyBundle expected_bundle; | 230 PolicyBundle expected_bundle; |
233 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 231 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
234 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); | 232 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); |
235 EXPECT_TRUE(bundle->Equals(expected_bundle)); | 233 EXPECT_TRUE(bundle->Equals(expected_bundle)); |
236 } | 234 } |
237 | 235 |
238 } // namespace policy | 236 } // namespace policy |
OLD | NEW |