summaryrefslogtreecommitdiffstats
path: root/chrome/browser/configuration_policy_provider_win_unittest.cc
diff options
context:
space:
mode:
authordanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 10:04:26 +0000
committerdanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-14 10:04:26 +0000
commitd0f4b0e5b86ef0ef181d0b23257f321ae2e9fc51 (patch)
treec938c616680c776d8f3bd854d7970a49b37f3baa /chrome/browser/configuration_policy_provider_win_unittest.cc
parentead270f14e86fbdae7e4f4151ad4838c5c738dec (diff)
downloadchromium_src-d0f4b0e5b86ef0ef181d0b23257f321ae2e9fc51.zip
chromium_src-d0f4b0e5b86ef0ef181d0b23257f321ae2e9fc51.tar.gz
chromium_src-d0f4b0e5b86ef0ef181d0b23257f321ae2e9fc51.tar.bz2
Implements policies to enable or disable the five Privacy checkboxes found in the Options dialog, in the Under the Hood section.
xib changes: added an enabled binding to the policy-controlled checkboxes in the "Under the Hood" preference pane so that they can be disabled when their value is overridden by policy. The methods for the bindings are in the preference window controller. BUG=44394 TEST=ConfigurationPolicyPrefStoreTest.* and ConfigurationPolicyProviderWinTest.* Manual tests: Set the policies externally. Check that the checkbox in Options/Under the Hood/Privacy/search suggest... are disabled. Also check that the check box is set/unset as done by the policy. Review URL: http://codereview.chromium.org/2746006 Patch from Jean-Luc Brouillet <jeanluc@google.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/configuration_policy_provider_win_unittest.cc')
-rwxr-xr-xchrome/browser/configuration_policy_provider_win_unittest.cc92
1 files changed, 65 insertions, 27 deletions
diff --git a/chrome/browser/configuration_policy_provider_win_unittest.cc b/chrome/browser/configuration_policy_provider_win_unittest.cc
index b4fc671..1451ede 100755
--- a/chrome/browser/configuration_policy_provider_win_unittest.cc
+++ b/chrome/browser/configuration_policy_provider_win_unittest.cc
@@ -35,7 +35,8 @@ class TestConfigurationPolicyProviderWin
void SetHomepageRegistryValue(HKEY hive, const wchar_t* value);
void SetHomepageRegistryValueWrongType(HKEY hive);
- void SetHomepageIsNewTabPage(HKEY hive, bool value);
+ void SetBooleanPolicy(ConfigurationPolicyStore::PolicyType type,
+ HKEY hive, bool value);
void SetCookiesMode(HKEY hive, uint32 value);
typedef std::vector<PolicyValueMapEntry> PolicyValueMap;
@@ -80,15 +81,13 @@ void TestConfigurationPolicyProviderWin::SetHomepageRegistryValueWrongType(
5));
}
-void TestConfigurationPolicyProviderWin::SetHomepageIsNewTabPage(
+void TestConfigurationPolicyProviderWin::SetBooleanPolicy(
+ ConfigurationPolicyStore::PolicyType type,
HKEY hive,
bool value) {
- RegKey key(hive,
- ConfigurationPolicyProviderWin::kPolicyRegistrySubKey,
+ RegKey key(hive, ConfigurationPolicyProviderWin::kPolicyRegistrySubKey,
KEY_ALL_ACCESS);
- EXPECT_TRUE(key.WriteValue(NameForPolicy(
- ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage).c_str(),
- value));
+ EXPECT_TRUE(key.WriteValue(NameForPolicy(type).c_str(), value));
}
void TestConfigurationPolicyProviderWin::SetCookiesMode(
@@ -123,6 +122,10 @@ class ConfigurationPolicyProviderWinTest : public testing::Test {
// Deletes the registry key created during the tests.
void DeleteRegistrySandbox();
+ void TestBooleanPolicyDefault(ConfigurationPolicyStore::PolicyType type);
+ void TestBooleanPolicyHKLM(ConfigurationPolicyStore::PolicyType type);
+ void TestBooleanPolicy(ConfigurationPolicyStore::PolicyType type);
+
private:
// Keys are created for the lifetime of a test to contain
// the sandboxed HKCU and HKLM hives, respectively.
@@ -178,6 +181,40 @@ void ConfigurationPolicyProviderWinTest::DeleteRegistrySandbox() {
RegKey key(HKEY_CURRENT_USER, kUnitTestRegistrySubKey, KEY_ALL_ACCESS);
key.DeleteKey(L"");
}
+
+void ConfigurationPolicyProviderWinTest::TestBooleanPolicyDefault(
+ ConfigurationPolicyStore::PolicyType type) {
+ MockConfigurationPolicyStore store;
+ TestConfigurationPolicyProviderWin provider;
+ provider.Provide(&store);
+
+ const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map());
+ MockConfigurationPolicyStore::PolicyMap::const_iterator i =
+ map.find(type);
+ EXPECT_TRUE(i == map.end());
+}
+
+void ConfigurationPolicyProviderWinTest::TestBooleanPolicyHKLM(
+ ConfigurationPolicyStore::PolicyType type) {
+ MockConfigurationPolicyStore store;
+ TestConfigurationPolicyProviderWin provider;
+ provider.SetBooleanPolicy(type, HKEY_LOCAL_MACHINE, true);
+ provider.Provide(&store);
+
+ const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map());
+ MockConfigurationPolicyStore::PolicyMap::const_iterator i = map.find(type);
+ EXPECT_TRUE(i != map.end());
+ bool value = false;
+ i->second->GetAsBoolean(&value);
+ EXPECT_EQ(true, value);
+}
+
+void ConfigurationPolicyProviderWinTest::TestBooleanPolicy(
+ ConfigurationPolicyStore::PolicyType type) {
+ TestBooleanPolicyDefault(type);
+ TestBooleanPolicyHKLM(type);
+}
+
TEST_F(ConfigurationPolicyProviderWinTest, TestHomePagePolicyDefault) {
MockConfigurationPolicyStore store;
TestConfigurationPolicyProviderWin provider;
@@ -257,33 +294,34 @@ TEST_F(ConfigurationPolicyProviderWinTest, TestHomePagePolicyHKLMOverHKCU) {
}
TEST_F(ConfigurationPolicyProviderWinTest,
- TestHomepageIsNewTabPagePolicyDefault) {
- MockConfigurationPolicyStore store;
- TestConfigurationPolicyProviderWin provider;
+ TestHomepageIsNewTabPagePolicy) {
+ TestBooleanPolicy(ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage);
+}
- provider.Provide(&store);
+TEST_F(ConfigurationPolicyProviderWinTest,
+ TestPolicyAlternateErrorPagesEnabled) {
+ TestBooleanPolicy(
+ ConfigurationPolicyStore::kPolicyAlternateErrorPagesEnabled);
+}
- const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map());
- MockConfigurationPolicyStore::PolicyMap::const_iterator i =
- map.find(ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage);
- EXPECT_TRUE(i == map.end());
+TEST_F(ConfigurationPolicyProviderWinTest,
+ TestPolicySearchSuggestEnabled) {
+ TestBooleanPolicy(ConfigurationPolicyStore::kPolicySearchSuggestEnabled);
}
TEST_F(ConfigurationPolicyProviderWinTest,
- TestHomepageIsNewTabPagePolicyHKLM) {
- MockConfigurationPolicyStore store;
- TestConfigurationPolicyProviderWin provider;
- provider.SetHomepageIsNewTabPage(HKEY_LOCAL_MACHINE, true);
+ TestPolicyDnsPrefetchingEnabled) {
+ TestBooleanPolicy(ConfigurationPolicyStore::kPolicyDnsPrefetchingEnabled);
+}
- provider.Provide(&store);
+TEST_F(ConfigurationPolicyProviderWinTest,
+ TestPolicySafeBrowsingEnabled) {
+ TestBooleanPolicy(ConfigurationPolicyStore::kPolicySafeBrowsingEnabled);
+}
- const MockConfigurationPolicyStore::PolicyMap& map(store.policy_map());
- MockConfigurationPolicyStore::PolicyMap::const_iterator i =
- map.find(ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage);
- EXPECT_TRUE(i != map.end());
- bool value = false;
- i->second->GetAsBoolean(&value);
- EXPECT_EQ(true, value);
+TEST_F(ConfigurationPolicyProviderWinTest,
+ TestPolicyMetricsReportingEnabled) {
+ TestBooleanPolicy(ConfigurationPolicyStore::kPolicyMetricsReportingEnabled);
}
TEST_F(ConfigurationPolicyProviderWinTest,