diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 13:51:11 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 13:51:11 +0000 |
commit | 1505fa2d80afe698db06150512b26c2d08d0e088 (patch) | |
tree | ec21823c3ab6ef62b4915df86a2ad719f207c3ae /chrome/browser/configuration_policy_provider_win_unittest.cc | |
parent | 0b68f1572eb3d1e75ee60c3d1e025aa6b7f06045 (diff) | |
download | chromium_src-1505fa2d80afe698db06150512b26c2d08d0e088.zip chromium_src-1505fa2d80afe698db06150512b26c2d08d0e088.tar.gz chromium_src-1505fa2d80afe698db06150512b26c2d08d0e088.tar.bz2 |
Reduce duplication across Linux/Windows policy providers, and unify names used therein.
BUG=http://crbug.com/45344
TEST=no change
Review URL: http://codereview.chromium.org/2387003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/configuration_policy_provider_win_unittest.cc')
-rwxr-xr-x | chrome/browser/configuration_policy_provider_win_unittest.cc | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/chrome/browser/configuration_policy_provider_win_unittest.cc b/chrome/browser/configuration_policy_provider_win_unittest.cc index a63c6dc..b4fc671 100755 --- a/chrome/browser/configuration_policy_provider_win_unittest.cc +++ b/chrome/browser/configuration_policy_provider_win_unittest.cc @@ -9,17 +9,21 @@ #include "base/logging.h" #include "base/registry.h" #include "base/scoped_ptr.h" +#include "base/string_piece.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/configuration_policy_provider_win.h" #include "chrome/browser/mock_configuration_policy_store.h" #include "chrome/common/pref_names.h" namespace { + const wchar_t kUnitTestRegistrySubKey[] = L"SOFTWARE\\Chromium Unit Tests"; const wchar_t kUnitTestMachineOverrideSubKey[] = L"SOFTWARE\\Chromium Unit Tests\\HKLM Override"; const wchar_t kUnitTestUserOverrideSubKey[] = L"SOFTWARE\\Chromium Unit Tests\\HKCU Override"; -} + +} // namespace // A subclass of |ConfigurationPolicyProviderWin| providing access to // internal protected constants without an orgy of FRIEND_TESTS. @@ -33,8 +37,28 @@ class TestConfigurationPolicyProviderWin void SetHomepageRegistryValueWrongType(HKEY hive); void SetHomepageIsNewTabPage(HKEY hive, bool value); void SetCookiesMode(HKEY hive, uint32 value); + + typedef std::vector<PolicyValueMapEntry> PolicyValueMap; + static const PolicyValueMap* PolicyValueMapping() { + return ConfigurationPolicyProvider::PolicyValueMapping(); + } }; +namespace { + +std::wstring NameForPolicy(ConfigurationPolicyStore::PolicyType policy) { + const TestConfigurationPolicyProviderWin::PolicyValueMap* mapping = + TestConfigurationPolicyProviderWin::PolicyValueMapping(); + for (TestConfigurationPolicyProviderWin::PolicyValueMap::const_iterator + current = mapping->begin(); current != mapping->end(); ++current) { + if (current->policy_type == policy) + return UTF8ToWide(current->name); + } + return NULL; +} + +} // namespace + void TestConfigurationPolicyProviderWin::SetHomepageRegistryValue( HKEY hive, const wchar_t* value) { @@ -42,7 +66,7 @@ void TestConfigurationPolicyProviderWin::SetHomepageRegistryValue( ConfigurationPolicyProviderWin::kPolicyRegistrySubKey, KEY_ALL_ACCESS); EXPECT_TRUE(key.WriteValue( - ConfigurationPolicyProviderWin::kHomepageRegistryValueName, + NameForPolicy(ConfigurationPolicyStore::kPolicyHomePage).c_str(), value)); } @@ -52,7 +76,7 @@ void TestConfigurationPolicyProviderWin::SetHomepageRegistryValueWrongType( ConfigurationPolicyProviderWin::kPolicyRegistrySubKey, KEY_ALL_ACCESS); EXPECT_TRUE(key.WriteValue( - ConfigurationPolicyProviderWin::kHomepageRegistryValueName, + NameForPolicy(ConfigurationPolicyStore::kPolicyHomePage).c_str(), 5)); } @@ -62,8 +86,8 @@ void TestConfigurationPolicyProviderWin::SetHomepageIsNewTabPage( RegKey key(hive, ConfigurationPolicyProviderWin::kPolicyRegistrySubKey, KEY_ALL_ACCESS); - EXPECT_TRUE(key.WriteValue( - ConfigurationPolicyProviderWin::kHomepageIsNewTabPageRegistryValueName, + EXPECT_TRUE(key.WriteValue(NameForPolicy( + ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage).c_str(), value)); } @@ -74,7 +98,7 @@ void TestConfigurationPolicyProviderWin::SetCookiesMode( ConfigurationPolicyProviderWin::kPolicyRegistrySubKey, KEY_ALL_ACCESS); EXPECT_TRUE(key.WriteValue( - ConfigurationPolicyProviderWin::kCookiesModeRegistryValueName, + NameForPolicy(ConfigurationPolicyStore::kPolicyCookiesMode).c_str(), value)); } |