Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/policy/config_dir_policy_loader_unittest.cc

Issue 56623005: Policy providers all get a SchemaRegistry to work with. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-9-purge-with-callback
Patch Set: rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
26 const base::FilePath::CharType kMandatoryPath[] = FILE_PATH_LITERAL("managed"); 26 const base::FilePath::CharType kMandatoryPath[] = FILE_PATH_LITERAL("managed");
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 scoped_refptr<base::SequencedTaskRunner> task_runner, 37 scoped_refptr<base::SequencedTaskRunner> task_runner,
37 const PolicyDefinitionList* policy_definition_list) OVERRIDE; 38 const PolicyDefinitionList* policy_definition_list) OVERRIDE;
38 39
39 virtual void InstallEmptyPolicy() OVERRIDE; 40 virtual void InstallEmptyPolicy() OVERRIDE;
40 virtual void InstallStringPolicy(const std::string& policy_name, 41 virtual void InstallStringPolicy(const std::string& policy_name,
41 const std::string& policy_value) OVERRIDE; 42 const std::string& policy_value) OVERRIDE;
42 virtual void InstallIntegerPolicy(const std::string& policy_name, 43 virtual void InstallIntegerPolicy(const std::string& policy_name,
43 int policy_value) OVERRIDE; 44 int policy_value) OVERRIDE;
44 virtual void InstallBooleanPolicy(const std::string& policy_name, 45 virtual void InstallBooleanPolicy(const std::string& policy_name,
45 bool policy_value) OVERRIDE; 46 bool policy_value) OVERRIDE;
(...skipping 29 matching lines...) Expand all
75 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE), 76 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE),
76 next_policy_file_index_(100) {} 77 next_policy_file_index_(100) {}
77 78
78 TestHarness::~TestHarness() {} 79 TestHarness::~TestHarness() {}
79 80
80 void TestHarness::SetUp() { 81 void TestHarness::SetUp() {
81 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); 82 ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
82 } 83 }
83 84
84 ConfigurationPolicyProvider* TestHarness::CreateProvider( 85 ConfigurationPolicyProvider* TestHarness::CreateProvider(
86 SchemaRegistry* registry,
85 scoped_refptr<base::SequencedTaskRunner> task_runner, 87 scoped_refptr<base::SequencedTaskRunner> task_runner,
86 const PolicyDefinitionList* policy_definition_list) { 88 const PolicyDefinitionList* policy_definition_list) {
87 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( 89 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader(
88 task_runner, test_dir(), POLICY_SCOPE_MACHINE)); 90 task_runner, test_dir(), POLICY_SCOPE_MACHINE));
89 return new AsyncPolicyProvider(loader.Pass()); 91 return new AsyncPolicyProvider(registry, loader.Pass());
90 } 92 }
91 93
92 void TestHarness::InstallEmptyPolicy() { 94 void TestHarness::InstallEmptyPolicy() {
93 base::DictionaryValue dict; 95 base::DictionaryValue dict;
94 WriteConfigFile(dict, NextConfigFileName()); 96 WriteConfigFile(dict, NextConfigFileName());
95 } 97 }
96 98
97 void TestHarness::InstallStringPolicy(const std::string& policy_name, 99 void TestHarness::InstallStringPolicy(const std::string& policy_name,
98 const std::string& policy_value) { 100 const std::string& policy_value) {
99 base::DictionaryValue dict; 101 base::DictionaryValue dict;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 loop_.message_loop_proxy(), harness_.test_dir(), POLICY_SCOPE_USER); 229 loop_.message_loop_proxy(), harness_.test_dir(), POLICY_SCOPE_USER);
228 scoped_ptr<PolicyBundle> bundle(loader.Load()); 230 scoped_ptr<PolicyBundle> bundle(loader.Load());
229 ASSERT_TRUE(bundle.get()); 231 ASSERT_TRUE(bundle.get());
230 PolicyBundle expected_bundle; 232 PolicyBundle expected_bundle;
231 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 233 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
232 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); 234 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);
233 EXPECT_TRUE(bundle->Equals(expected_bundle)); 235 EXPECT_TRUE(bundle->Equals(expected_bundle));
234 } 236 }
235 237
236 } // namespace policy 238 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698