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

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

Issue 1056633004: Update {virtual,override} to follow C++11 style in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix logo tracker unittest. Created 5 years, 8 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 "components/policy/core/common/policy_loader_win.h" 5 #include "components/policy/core/common/policy_loader_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <userenv.h> 8 #include <userenv.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 RegKey temp_hklm_hive_key_; 163 RegKey temp_hklm_hive_key_;
164 164
165 DISALLOW_COPY_AND_ASSIGN(ScopedGroupPolicyRegistrySandbox); 165 DISALLOW_COPY_AND_ASSIGN(ScopedGroupPolicyRegistrySandbox);
166 }; 166 };
167 167
168 // A test harness that feeds policy via the Chrome GPO registry subtree. 168 // A test harness that feeds policy via the Chrome GPO registry subtree.
169 class RegistryTestHarness : public PolicyProviderTestHarness, 169 class RegistryTestHarness : public PolicyProviderTestHarness,
170 public AppliedGPOListProvider { 170 public AppliedGPOListProvider {
171 public: 171 public:
172 RegistryTestHarness(HKEY hive, PolicyScope scope); 172 RegistryTestHarness(HKEY hive, PolicyScope scope);
173 virtual ~RegistryTestHarness(); 173 ~RegistryTestHarness() override;
174 174
175 // PolicyProviderTestHarness: 175 // PolicyProviderTestHarness:
176 virtual void SetUp() override; 176 void SetUp() override;
177 177
178 virtual ConfigurationPolicyProvider* CreateProvider( 178 ConfigurationPolicyProvider* CreateProvider(
179 SchemaRegistry* registry, 179 SchemaRegistry* registry,
180 scoped_refptr<base::SequencedTaskRunner> task_runner) override; 180 scoped_refptr<base::SequencedTaskRunner> task_runner) override;
181 181
182 virtual void InstallEmptyPolicy() override; 182 void InstallEmptyPolicy() override;
183 virtual void InstallStringPolicy(const std::string& policy_name, 183 void InstallStringPolicy(const std::string& policy_name,
184 const std::string& policy_value) override; 184 const std::string& policy_value) override;
185 virtual void InstallIntegerPolicy(const std::string& policy_name, 185 void InstallIntegerPolicy(const std::string& policy_name,
186 int policy_value) override; 186 int policy_value) override;
187 virtual void InstallBooleanPolicy(const std::string& policy_name, 187 void InstallBooleanPolicy(const std::string& policy_name,
188 bool policy_value) override; 188 bool policy_value) override;
189 virtual void InstallStringListPolicy( 189 void InstallStringListPolicy(const std::string& policy_name,
190 const std::string& policy_name, 190 const base::ListValue* policy_value) override;
191 const base::ListValue* policy_value) override; 191 void InstallDictionaryPolicy(
192 virtual void InstallDictionaryPolicy(
193 const std::string& policy_name, 192 const std::string& policy_name,
194 const base::DictionaryValue* policy_value) override; 193 const base::DictionaryValue* policy_value) override;
195 virtual void Install3rdPartyPolicy( 194 void Install3rdPartyPolicy(const base::DictionaryValue* policies) override;
196 const base::DictionaryValue* policies) override;
197 195
198 // AppliedGPOListProvider: 196 // AppliedGPOListProvider:
199 virtual DWORD GetAppliedGPOList(DWORD flags, 197 DWORD GetAppliedGPOList(DWORD flags,
200 LPCTSTR machine_name, 198 LPCTSTR machine_name,
201 PSID sid_user, 199 PSID sid_user,
202 GUID* extension_guid, 200 GUID* extension_guid,
203 PGROUP_POLICY_OBJECT* gpo_list) override; 201 PGROUP_POLICY_OBJECT* gpo_list) override;
204 virtual BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) override; 202 BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) override;
205 203
206 // Creates a harness instance that will install policy in HKCU or HKLM, 204 // Creates a harness instance that will install policy in HKCU or HKLM,
207 // respectively. 205 // respectively.
208 static PolicyProviderTestHarness* CreateHKCU(); 206 static PolicyProviderTestHarness* CreateHKCU();
209 static PolicyProviderTestHarness* CreateHKLM(); 207 static PolicyProviderTestHarness* CreateHKLM();
210 208
211 private: 209 private:
212 HKEY hive_; 210 HKEY hive_;
213 211
214 ScopedGroupPolicyRegistrySandbox registry_sandbox_; 212 ScopedGroupPolicyRegistrySandbox registry_sandbox_;
215 213
216 DISALLOW_COPY_AND_ASSIGN(RegistryTestHarness); 214 DISALLOW_COPY_AND_ASSIGN(RegistryTestHarness);
217 }; 215 };
218 216
219 // A test harness that generates PReg files for the provider to read. 217 // A test harness that generates PReg files for the provider to read.
220 class PRegTestHarness : public PolicyProviderTestHarness, 218 class PRegTestHarness : public PolicyProviderTestHarness,
221 public AppliedGPOListProvider { 219 public AppliedGPOListProvider {
222 public: 220 public:
223 PRegTestHarness(); 221 PRegTestHarness();
224 virtual ~PRegTestHarness(); 222 ~PRegTestHarness() override;
225 223
226 // PolicyProviderTestHarness: 224 // PolicyProviderTestHarness:
227 virtual void SetUp() override; 225 void SetUp() override;
228 226
229 virtual ConfigurationPolicyProvider* CreateProvider( 227 ConfigurationPolicyProvider* CreateProvider(
230 SchemaRegistry* registry, 228 SchemaRegistry* registry,
231 scoped_refptr<base::SequencedTaskRunner> task_runner) override; 229 scoped_refptr<base::SequencedTaskRunner> task_runner) override;
232 230
233 virtual void InstallEmptyPolicy() override; 231 void InstallEmptyPolicy() override;
234 virtual void InstallStringPolicy(const std::string& policy_name, 232 void InstallStringPolicy(const std::string& policy_name,
235 const std::string& policy_value) override; 233 const std::string& policy_value) override;
236 virtual void InstallIntegerPolicy(const std::string& policy_name, 234 void InstallIntegerPolicy(const std::string& policy_name,
237 int policy_value) override; 235 int policy_value) override;
238 virtual void InstallBooleanPolicy(const std::string& policy_name, 236 void InstallBooleanPolicy(const std::string& policy_name,
239 bool policy_value) override; 237 bool policy_value) override;
240 virtual void InstallStringListPolicy( 238 void InstallStringListPolicy(const std::string& policy_name,
241 const std::string& policy_name, 239 const base::ListValue* policy_value) override;
242 const base::ListValue* policy_value) override; 240 void InstallDictionaryPolicy(
243 virtual void InstallDictionaryPolicy(
244 const std::string& policy_name, 241 const std::string& policy_name,
245 const base::DictionaryValue* policy_value) override; 242 const base::DictionaryValue* policy_value) override;
246 virtual void Install3rdPartyPolicy( 243 void Install3rdPartyPolicy(const base::DictionaryValue* policies) override;
247 const base::DictionaryValue* policies) override;
248 244
249 // AppliedGPOListProvider: 245 // AppliedGPOListProvider:
250 virtual DWORD GetAppliedGPOList(DWORD flags, 246 DWORD GetAppliedGPOList(DWORD flags,
251 LPCTSTR machine_name, 247 LPCTSTR machine_name,
252 PSID sid_user, 248 PSID sid_user,
253 GUID* extension_guid, 249 GUID* extension_guid,
254 PGROUP_POLICY_OBJECT* gpo_list) override; 250 PGROUP_POLICY_OBJECT* gpo_list) override;
255 virtual BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) override; 251 BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) override;
256 252
257 // Creates a harness instance. 253 // Creates a harness instance.
258 static PolicyProviderTestHarness* Create(); 254 static PolicyProviderTestHarness* Create();
259 255
260 private: 256 private:
261 // Helper to append a base::string16 to an uint8 buffer. 257 // Helper to append a base::string16 to an uint8 buffer.
262 static void AppendChars(std::vector<uint8>* buffer, 258 static void AppendChars(std::vector<uint8>* buffer,
263 const base::string16& chars); 259 const base::string16& chars);
264 260
265 // Appends a record with the given fields to the PReg file. 261 // Appends a record with the given fields to the PReg file.
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 class PolicyLoaderWinTest : public PolicyTestBase, 689 class PolicyLoaderWinTest : public PolicyTestBase,
694 public AppliedGPOListProvider { 690 public AppliedGPOListProvider {
695 protected: 691 protected:
696 // The policy key this tests places data under. This must match the data 692 // The policy key this tests places data under. This must match the data
697 // files in chrome/test/data/policy/gpo. 693 // files in chrome/test/data/policy/gpo.
698 static const base::char16 kTestPolicyKey[]; 694 static const base::char16 kTestPolicyKey[];
699 695
700 PolicyLoaderWinTest() 696 PolicyLoaderWinTest()
701 : gpo_list_(NULL), 697 : gpo_list_(NULL),
702 gpo_list_status_(ERROR_ACCESS_DENIED) {} 698 gpo_list_status_(ERROR_ACCESS_DENIED) {}
703 virtual ~PolicyLoaderWinTest() {} 699 ~PolicyLoaderWinTest() override {}
704 700
705 virtual void SetUp() override { 701 void SetUp() override {
706 base::win::SetDomainStateForTesting(false); 702 base::win::SetDomainStateForTesting(false);
707 PolicyTestBase::SetUp(); 703 PolicyTestBase::SetUp();
708 704
709 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir_)); 705 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir_));
710 test_data_dir_ = test_data_dir_.AppendASCII("chrome") 706 test_data_dir_ = test_data_dir_.AppendASCII("chrome")
711 .AppendASCII("test") 707 .AppendASCII("test")
712 .AppendASCII("data") 708 .AppendASCII("data")
713 .AppendASCII("policy") 709 .AppendASCII("policy")
714 .AppendASCII("gpo"); 710 .AppendASCII("gpo");
715 711
716 gpo_list_provider_ = this; 712 gpo_list_provider_ = this;
717 } 713 }
718 714
719 // AppliedGPOListProvider: 715 // AppliedGPOListProvider:
720 virtual DWORD GetAppliedGPOList(DWORD flags, 716 DWORD GetAppliedGPOList(DWORD flags,
721 LPCTSTR machine_name, 717 LPCTSTR machine_name,
722 PSID sid_user, 718 PSID sid_user,
723 GUID* extension_guid, 719 GUID* extension_guid,
724 PGROUP_POLICY_OBJECT* gpo_list) override { 720 PGROUP_POLICY_OBJECT* gpo_list) override {
725 *gpo_list = gpo_list_; 721 *gpo_list = gpo_list_;
726 return gpo_list_status_; 722 return gpo_list_status_;
727 } 723 }
728 virtual BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) override { 724 BOOL FreeGPOList(PGROUP_POLICY_OBJECT gpo_list) override {
729 return TRUE; 725 return TRUE;
730 } 726 }
731 727
732 void InitGPO(GROUP_POLICY_OBJECT* gpo, 728 void InitGPO(GROUP_POLICY_OBJECT* gpo,
733 DWORD options, 729 DWORD options,
734 const base::FilePath& path, 730 const base::FilePath& path,
735 GROUP_POLICY_OBJECT* next, 731 GROUP_POLICY_OBJECT* next,
736 GROUP_POLICY_OBJECT* prev) { 732 GROUP_POLICY_OBJECT* prev) {
737 memset(gpo, 0, sizeof(GROUP_POLICY_OBJECT)); 733 memset(gpo, 0, sizeof(GROUP_POLICY_OBJECT));
738 gpo->dwOptions = options; 734 gpo->dwOptions = options;
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 PolicyMap& expected_policy = expected.Get(ns); 1219 PolicyMap& expected_policy = expected.Get(ns);
1224 expected_policy.Set("alternative_browser_path", 1220 expected_policy.Set("alternative_browser_path",
1225 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1221 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1226 new base::StringValue("c:\\legacy\\browser.exe"), NULL); 1222 new base::StringValue("c:\\legacy\\browser.exe"), NULL);
1227 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 1223 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
1228 list.DeepCopy(), NULL); 1224 list.DeepCopy(), NULL);
1229 EXPECT_TRUE(Matches(expected)); 1225 EXPECT_TRUE(Matches(expected));
1230 } 1226 }
1231 1227
1232 } // namespace policy 1228 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_win.cc ('k') | components/policy/core/common/policy_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698