| 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 <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 | 7 |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 DISALLOW_COPY_AND_ASSIGN(ScopedGroupPolicyRegistrySandbox); | 57 DISALLOW_COPY_AND_ASSIGN(ScopedGroupPolicyRegistrySandbox); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class TestHarness : public PolicyProviderTestHarness { | 60 class TestHarness : public PolicyProviderTestHarness { |
| 61 public: | 61 public: |
| 62 explicit TestHarness(HKEY hive, PolicyScope scope); | 62 explicit TestHarness(HKEY hive, PolicyScope scope); |
| 63 virtual ~TestHarness(); | 63 virtual ~TestHarness(); |
| 64 | 64 |
| 65 virtual void SetUp() OVERRIDE; | 65 virtual void SetUp() OVERRIDE; |
| 66 | 66 |
| 67 virtual AsynchronousPolicyProvider* CreateProvider( | 67 virtual ConfigurationPolicyProvider* CreateProvider( |
| 68 const PolicyDefinitionList* policy_definition_list) OVERRIDE; | 68 const PolicyDefinitionList* policy_definition_list) OVERRIDE; |
| 69 | 69 |
| 70 virtual void InstallEmptyPolicy() OVERRIDE; | 70 virtual void InstallEmptyPolicy() OVERRIDE; |
| 71 virtual void InstallStringPolicy(const std::string& policy_name, | 71 virtual void InstallStringPolicy(const std::string& policy_name, |
| 72 const std::string& policy_value) OVERRIDE; | 72 const std::string& policy_value) OVERRIDE; |
| 73 virtual void InstallIntegerPolicy(const std::string& policy_name, | 73 virtual void InstallIntegerPolicy(const std::string& policy_name, |
| 74 int policy_value) OVERRIDE; | 74 int policy_value) OVERRIDE; |
| 75 virtual void InstallBooleanPolicy(const std::string& policy_name, | 75 virtual void InstallBooleanPolicy(const std::string& policy_name, |
| 76 bool policy_value) OVERRIDE; | 76 bool policy_value) OVERRIDE; |
| 77 virtual void InstallStringListPolicy( | 77 virtual void InstallStringListPolicy( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 key.DeleteKey(L""); | 132 key.DeleteKey(L""); |
| 133 } | 133 } |
| 134 | 134 |
| 135 TestHarness::TestHarness(HKEY hive, PolicyScope scope) | 135 TestHarness::TestHarness(HKEY hive, PolicyScope scope) |
| 136 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, scope), hive_(hive) {} | 136 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, scope), hive_(hive) {} |
| 137 | 137 |
| 138 TestHarness::~TestHarness() {} | 138 TestHarness::~TestHarness() {} |
| 139 | 139 |
| 140 void TestHarness::SetUp() {} | 140 void TestHarness::SetUp() {} |
| 141 | 141 |
| 142 AsynchronousPolicyProvider* TestHarness::CreateProvider( | 142 ConfigurationPolicyProvider* TestHarness::CreateProvider( |
| 143 const PolicyDefinitionList* policy_definition_list) { | 143 const PolicyDefinitionList* policy_definition_list) { |
| 144 return new ConfigurationPolicyProviderWin(policy_definition_list); | 144 return new ConfigurationPolicyProviderWin(policy_definition_list); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void TestHarness::InstallEmptyPolicy() {} | 147 void TestHarness::InstallEmptyPolicy() {} |
| 148 | 148 |
| 149 void TestHarness::InstallStringPolicy(const std::string& policy_name, | 149 void TestHarness::InstallStringPolicy(const std::string& policy_name, |
| 150 const std::string& policy_value) { | 150 const std::string& policy_value) { |
| 151 RegKey key(hive_, policy::kRegistryMandatorySubKey, KEY_ALL_ACCESS); | 151 RegKey key(hive_, policy::kRegistryMandatorySubKey, KEY_ALL_ACCESS); |
| 152 key.WriteValue(UTF8ToUTF16(policy_name).c_str(), | 152 key.WriteValue(UTF8ToUTF16(policy_name).c_str(), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 PolicyBundle expected_bundle; | 243 PolicyBundle expected_bundle; |
| 244 expected_bundle.Get(POLICY_DOMAIN_CHROME, "") | 244 expected_bundle.Get(POLICY_DOMAIN_CHROME, "") |
| 245 .Set(test_policy_definitions::kKeyString, | 245 .Set(test_policy_definitions::kKeyString, |
| 246 POLICY_LEVEL_MANDATORY, | 246 POLICY_LEVEL_MANDATORY, |
| 247 POLICY_SCOPE_MACHINE, | 247 POLICY_SCOPE_MACHINE, |
| 248 base::Value::CreateStringValue("hklm")); | 248 base::Value::CreateStringValue("hklm")); |
| 249 EXPECT_TRUE(provider_.policies().Equals(expected_bundle)); | 249 EXPECT_TRUE(provider_.policies().Equals(expected_bundle)); |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace policy | 252 } // namespace policy |
| OLD | NEW |