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

Side by Side Diff: components/policy/core/common/config_dir_policy_loader_unittest.cc

Issue 1348903007: Revert of Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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/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"
19 18
20 namespace policy { 19 namespace policy {
21 20
22 namespace { 21 namespace {
23 22
24 // Subdirectory of the config dir that contains mandatory policies. 23 // Subdirectory of the config dir that contains mandatory policies.
25 const base::FilePath::CharType kMandatoryPath[] = FILE_PATH_LITERAL("managed"); 24 const base::FilePath::CharType kMandatoryPath[] = FILE_PATH_LITERAL("managed");
26 25
27 class TestHarness : public PolicyProviderTestHarness { 26 class TestHarness : public PolicyProviderTestHarness {
28 public: 27 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 static PolicyProviderTestHarness* Create(); 61 static PolicyProviderTestHarness* Create();
63 62
64 private: 63 private:
65 base::ScopedTempDir test_dir_; 64 base::ScopedTempDir test_dir_;
66 int next_policy_file_index_; 65 int next_policy_file_index_;
67 66
68 DISALLOW_COPY_AND_ASSIGN(TestHarness); 67 DISALLOW_COPY_AND_ASSIGN(TestHarness);
69 }; 68 };
70 69
71 TestHarness::TestHarness() 70 TestHarness::TestHarness()
72 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, 71 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE),
73 POLICY_SCOPE_MACHINE,
74 POLICY_SOURCE_PLATFORM),
75 next_policy_file_index_(100) {} 72 next_policy_file_index_(100) {}
76 73
77 TestHarness::~TestHarness() {} 74 TestHarness::~TestHarness() {}
78 75
79 void TestHarness::SetUp() { 76 void TestHarness::SetUp() {
80 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); 77 ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
81 } 78 }
82 79
83 ConfigurationPolicyProvider* TestHarness::CreateProvider( 80 ConfigurationPolicyProvider* TestHarness::CreateProvider(
84 SchemaRegistry* registry, 81 SchemaRegistry* registry,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 harness_.WriteConfigFile(test_dict_foo, "9"); 218 harness_.WriteConfigFile(test_dict_foo, "9");
222 for (unsigned int i = 5; i <= 8; ++i) 219 for (unsigned int i = 5; i <= 8; ++i)
223 harness_.WriteConfigFile(test_dict_bar, base::IntToString(i)); 220 harness_.WriteConfigFile(test_dict_bar, base::IntToString(i));
224 221
225 ConfigDirPolicyLoader loader(loop_.task_runner(), harness_.test_dir(), 222 ConfigDirPolicyLoader loader(loop_.task_runner(), harness_.test_dir(),
226 POLICY_SCOPE_USER); 223 POLICY_SCOPE_USER);
227 scoped_ptr<PolicyBundle> bundle(loader.Load()); 224 scoped_ptr<PolicyBundle> bundle(loader.Load());
228 ASSERT_TRUE(bundle.get()); 225 ASSERT_TRUE(bundle.get());
229 PolicyBundle expected_bundle; 226 PolicyBundle expected_bundle;
230 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) 227 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
231 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 228 .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);
232 POLICY_SOURCE_PLATFORM);
233 EXPECT_TRUE(bundle->Equals(expected_bundle)); 229 EXPECT_TRUE(bundle->Equals(expected_bundle));
234 } 230 }
235 231
236 } // namespace policy 232 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698