OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 temp_hklm_hive_key_.Create(HKEY_CURRENT_USER, | 186 temp_hklm_hive_key_.Create(HKEY_CURRENT_USER, |
187 kUnitTestMachineOverrideSubKey, | 187 kUnitTestMachineOverrideSubKey, |
188 KEY_ALL_ACCESS); | 188 KEY_ALL_ACCESS); |
189 temp_hkcu_hive_key_.Create(HKEY_CURRENT_USER, | 189 temp_hkcu_hive_key_.Create(HKEY_CURRENT_USER, |
190 kUnitTestUserOverrideSubKey, | 190 kUnitTestUserOverrideSubKey, |
191 KEY_ALL_ACCESS); | 191 KEY_ALL_ACCESS); |
192 | 192 |
193 ActivateOverrides(); | 193 ActivateOverrides(); |
194 | 194 |
195 provider_.reset(new ConfigurationPolicyProviderWin( | 195 provider_.reset(new ConfigurationPolicyProviderWin( |
196 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList())); | 196 GetChromePolicyDefinitionList())); |
197 } | 197 } |
198 | 198 |
199 void ConfigurationPolicyProviderWinTest::TearDown() { | 199 void ConfigurationPolicyProviderWinTest::TearDown() { |
200 DeactivateOverrides(); | 200 DeactivateOverrides(); |
201 DeleteRegistrySandbox(); | 201 DeleteRegistrySandbox(); |
202 loop_.RunAllPending(); | 202 loop_.RunAllPending(); |
203 } | 203 } |
204 | 204 |
205 void ConfigurationPolicyProviderWinTest::ActivateOverrides() { | 205 void ConfigurationPolicyProviderWinTest::ActivateOverrides() { |
206 HRESULT result = RegOverridePredefKey(HKEY_LOCAL_MACHINE, | 206 HRESULT result = RegOverridePredefKey(HKEY_LOCAL_MACHINE, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 GetParam().hkcu_value()); | 348 GetParam().hkcu_value()); |
349 provider_->loader()->Reload(); | 349 provider_->loader()->Reload(); |
350 loop_.RunAllPending(); | 350 loop_.RunAllPending(); |
351 PolicyMap policy_map; | 351 PolicyMap policy_map; |
352 provider_->Provide(&policy_map); | 352 provider_->Provide(&policy_map); |
353 const Value* value = policy_map.Get(GetParam().type()); | 353 const Value* value = policy_map.Get(GetParam().type()); |
354 ASSERT_TRUE(value); | 354 ASSERT_TRUE(value); |
355 EXPECT_TRUE(value->Equals(GetParam().hklm_value())); | 355 EXPECT_TRUE(value->Equals(GetParam().hklm_value())); |
356 } | 356 } |
357 | 357 |
358 // Instantiate the test case for all supported policies. | 358 // Test parameters for all supported policies. testing::Values() has a limit of |
| 359 // 50 parameters which is reached in this instantiation; new policies should go |
| 360 // in the next instantiation after this one. |
359 INSTANTIATE_TEST_CASE_P( | 361 INSTANTIATE_TEST_CASE_P( |
360 ConfigurationPolicyProviderWinTestInstance, | 362 ConfigurationPolicyProviderWinTestInstance, |
361 ConfigurationPolicyProviderWinTest, | 363 ConfigurationPolicyProviderWinTest, |
362 testing::Values( | 364 testing::Values( |
363 PolicyTestParams::ForStringPolicy( | 365 PolicyTestParams::ForStringPolicy( |
364 kPolicyHomepageLocation, | 366 kPolicyHomepageLocation, |
365 key::kHomepageLocation), | 367 key::kHomepageLocation), |
366 PolicyTestParams::ForBooleanPolicy( | 368 PolicyTestParams::ForBooleanPolicy( |
367 kPolicyHomepageIsNewTabPage, | 369 kPolicyHomepageIsNewTabPage, |
368 key::kHomepageIsNewTabPage), | 370 key::kHomepageIsNewTabPage), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 key::kExtensionInstallWhitelist), | 454 key::kExtensionInstallWhitelist), |
453 PolicyTestParams::ForListPolicy( | 455 PolicyTestParams::ForListPolicy( |
454 kPolicyExtensionInstallBlacklist, | 456 kPolicyExtensionInstallBlacklist, |
455 key::kExtensionInstallBlacklist), | 457 key::kExtensionInstallBlacklist), |
456 PolicyTestParams::ForBooleanPolicy( | 458 PolicyTestParams::ForBooleanPolicy( |
457 kPolicyShowHomeButton, | 459 kPolicyShowHomeButton, |
458 key::kShowHomeButton), | 460 key::kShowHomeButton), |
459 PolicyTestParams::ForBooleanPolicy( | 461 PolicyTestParams::ForBooleanPolicy( |
460 kPolicyPrintingEnabled, | 462 kPolicyPrintingEnabled, |
461 key::kPrintingEnabled), | 463 key::kPrintingEnabled), |
462 PolicyTestParams::ForIntegerPolicy( | |
463 kPolicyPolicyRefreshRate, | |
464 key::kPolicyRefreshRate), | |
465 PolicyTestParams::ForBooleanPolicy( | 464 PolicyTestParams::ForBooleanPolicy( |
466 kPolicyInstantEnabled, | 465 kPolicyInstantEnabled, |
467 key::kInstantEnabled), | 466 key::kInstantEnabled), |
468 PolicyTestParams::ForIntegerPolicy( | 467 PolicyTestParams::ForIntegerPolicy( |
469 kPolicyIncognitoModeAvailability, | 468 kPolicyIncognitoModeAvailability, |
470 key::kIncognitoModeAvailability), | 469 key::kIncognitoModeAvailability), |
471 PolicyTestParams::ForBooleanPolicy( | 470 PolicyTestParams::ForBooleanPolicy( |
472 kPolicyDisablePluginFinder, | 471 kPolicyDisablePluginFinder, |
473 key::kDisablePluginFinder), | 472 key::kDisablePluginFinder), |
474 PolicyTestParams::ForBooleanPolicy( | 473 PolicyTestParams::ForBooleanPolicy( |
(...skipping 27 matching lines...) Expand all Loading... |
502 kPolicyAllowFileSelectionDialogs, | 501 kPolicyAllowFileSelectionDialogs, |
503 key::kAllowFileSelectionDialogs), | 502 key::kAllowFileSelectionDialogs), |
504 PolicyTestParams::ForListPolicy( | 503 PolicyTestParams::ForListPolicy( |
505 kPolicyDisabledSchemes, | 504 kPolicyDisabledSchemes, |
506 key::kDisabledSchemes), | 505 key::kDisabledSchemes), |
507 PolicyTestParams::ForStringPolicy( | 506 PolicyTestParams::ForStringPolicy( |
508 kPolicyDiskCacheDir, | 507 kPolicyDiskCacheDir, |
509 key::kDiskCacheDir), | 508 key::kDiskCacheDir), |
510 PolicyTestParams::ForIntegerPolicy( | 509 PolicyTestParams::ForIntegerPolicy( |
511 kPolicyMaxConnectionsPerProxy, | 510 kPolicyMaxConnectionsPerProxy, |
512 key::kMaxConnectionsPerProxy))); | 511 key::kMaxConnectionsPerProxy), |
| 512 PolicyTestParams::ForListPolicy( |
| 513 kPolicyURLBlacklist, |
| 514 key::kURLBlacklist))); |
513 | 515 |
514 // testing::Values has a limit of 50 test templates, which is reached by the | 516 // testing::Values has a limit of 50 test templates, which is reached by the |
515 // instantiations above. Add tests for new policies here: | 517 // instantiations above. Add tests for new policies here: |
516 INSTANTIATE_TEST_CASE_P( | 518 INSTANTIATE_TEST_CASE_P( |
517 ConfigurationPolicyProviderWinTestInstance2, | 519 ConfigurationPolicyProviderWinTestInstance2, |
518 ConfigurationPolicyProviderWinTest, | 520 ConfigurationPolicyProviderWinTest, |
519 testing::Values( | 521 testing::Values( |
520 PolicyTestParams::ForListPolicy( | 522 PolicyTestParams::ForListPolicy( |
521 kPolicyURLBlacklist, | |
522 key::kURLBlacklist), | |
523 PolicyTestParams::ForListPolicy( | |
524 kPolicyURLWhitelist, | 523 kPolicyURLWhitelist, |
525 key::kURLWhitelist))); | 524 key::kURLWhitelist))); |
526 | 525 |
527 } // namespace policy | 526 } // namespace policy |
OLD | NEW |