Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "chrome/browser/policy/configuration_policy_handler.h" | |
| 7 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 8 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 8 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 9 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
| 9 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 10 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 10 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 11 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 11 #include "chrome/common/content_settings.h" | 12 #include "chrome/common/content_settings.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/pref_store_observer_mock.h" | 14 #include "chrome/common/pref_store_observer_mock.h" |
| 15 #include "policy/policy_constants.h" | |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 18 |
| 17 using testing::_; | 19 using testing::_; |
| 18 using testing::Mock; | 20 using testing::Mock; |
| 19 | 21 |
| 20 namespace policy { | 22 namespace policy { |
| 21 | 23 |
| 22 // Holds a set of test parameters, consisting of pref name and policy type. | 24 // Holds a set of test parameters, consisting of pref name and policy name. |
| 23 class TypeAndName { | 25 class PolicyAndPref { |
| 24 public: | 26 public: |
| 25 TypeAndName(ConfigurationPolicyType type, const char* pref_name) | 27 PolicyAndPref(const char* policy_name, const char* pref_name) |
| 26 : type_(type), | 28 : policy_name_(policy_name), |
| 27 pref_name_(pref_name) {} | 29 pref_name_(pref_name) {} |
| 28 | 30 |
| 29 ConfigurationPolicyType type() const { return type_; } | 31 const char* policy_name() const { return policy_name_; } |
| 30 const char* pref_name() const { return pref_name_; } | 32 const char* pref_name() const { return pref_name_; } |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 ConfigurationPolicyType type_; | 35 const char* policy_name_; |
| 34 const char* pref_name_; | 36 const char* pref_name_; |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 template<typename TESTBASE> | 39 template<typename TESTBASE> |
| 38 class ConfigurationPolicyPrefStoreTestBase : public TESTBASE { | 40 class ConfigurationPolicyPrefStoreTestBase : public TESTBASE { |
| 39 protected: | 41 protected: |
| 40 ConfigurationPolicyPrefStoreTestBase() | 42 ConfigurationPolicyPrefStoreTestBase() |
| 41 : provider_(), | 43 : provider_(), |
| 42 store_(new ConfigurationPolicyPrefStore(&provider_)) {} | 44 store_(new ConfigurationPolicyPrefStore(&provider_)) {} |
| 43 | 45 |
| 44 MockConfigurationPolicyProvider provider_; | 46 MockConfigurationPolicyProvider provider_; |
| 45 scoped_refptr<ConfigurationPolicyPrefStore> store_; | 47 scoped_refptr<ConfigurationPolicyPrefStore> store_; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 // Test cases for list-valued policy settings. | 50 // Test cases for list-valued policy settings. |
| 49 class ConfigurationPolicyPrefStoreListTest | 51 class ConfigurationPolicyPrefStoreListTest |
| 50 : public ConfigurationPolicyPrefStoreTestBase< | 52 : public ConfigurationPolicyPrefStoreTestBase< |
| 51 testing::TestWithParam<TypeAndName> > { | 53 testing::TestWithParam<PolicyAndPref> > { |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 TEST_P(ConfigurationPolicyPrefStoreListTest, GetDefault) { | 56 TEST_P(ConfigurationPolicyPrefStoreListTest, GetDefault) { |
| 55 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 57 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 56 store_->GetValue(GetParam().pref_name(), NULL)); | 58 store_->GetValue(GetParam().pref_name(), NULL)); |
| 57 } | 59 } |
| 58 | 60 |
| 59 TEST_P(ConfigurationPolicyPrefStoreListTest, SetValue) { | 61 TEST_P(ConfigurationPolicyPrefStoreListTest, SetValue) { |
| 60 ListValue* in_value = new ListValue(); | 62 ListValue* in_value = new ListValue(); |
| 61 in_value->Append(Value::CreateStringValue("test1")); | 63 in_value->Append(Value::CreateStringValue("test1")); |
| 62 in_value->Append(Value::CreateStringValue("test2,")); | 64 in_value->Append(Value::CreateStringValue("test2,")); |
| 63 provider_.AddPolicy(GetParam().type(), in_value); | 65 provider_.AddMandatoryPolicy(GetParam().policy_name(), in_value); |
| 64 store_->OnUpdatePolicy(&provider_); | 66 store_->OnUpdatePolicy(&provider_); |
| 65 const Value* value = NULL; | 67 const Value* value = NULL; |
| 66 EXPECT_EQ(PrefStore::READ_OK, | 68 EXPECT_EQ(PrefStore::READ_OK, |
| 67 store_->GetValue(GetParam().pref_name(), &value)); | 69 store_->GetValue(GetParam().pref_name(), &value)); |
| 68 ASSERT_TRUE(value); | 70 ASSERT_TRUE(value); |
| 69 EXPECT_TRUE(in_value->Equals(value)); | 71 EXPECT_TRUE(in_value->Equals(value)); |
| 70 } | 72 } |
| 71 | 73 |
| 72 INSTANTIATE_TEST_CASE_P( | 74 INSTANTIATE_TEST_CASE_P( |
| 73 ConfigurationPolicyPrefStoreListTestInstance, | 75 ConfigurationPolicyPrefStoreListTestInstance, |
| 74 ConfigurationPolicyPrefStoreListTest, | 76 ConfigurationPolicyPrefStoreListTest, |
| 75 testing::Values( | 77 testing::Values( |
| 76 TypeAndName(kPolicyRestoreOnStartupURLs, | 78 PolicyAndPref(key::kRestoreOnStartupURLs, |
| 77 prefs::kURLsToRestoreOnStartup), | 79 prefs::kURLsToRestoreOnStartup), |
| 78 TypeAndName(kPolicyExtensionInstallWhitelist, | 80 PolicyAndPref(key::kExtensionInstallWhitelist, |
| 79 prefs::kExtensionInstallAllowList), | 81 prefs::kExtensionInstallAllowList), |
| 80 TypeAndName(kPolicyExtensionInstallBlacklist, | 82 PolicyAndPref(key::kExtensionInstallBlacklist, |
| 81 prefs::kExtensionInstallDenyList), | 83 prefs::kExtensionInstallDenyList), |
| 82 TypeAndName(kPolicyDisabledPlugins, | 84 PolicyAndPref(key::kDisabledPlugins, |
| 83 prefs::kPluginsDisabledPlugins), | 85 prefs::kPluginsDisabledPlugins), |
| 84 TypeAndName(kPolicyDisabledPluginsExceptions, | 86 PolicyAndPref(key::kDisabledPluginsExceptions, |
| 85 prefs::kPluginsDisabledPluginsExceptions), | 87 prefs::kPluginsDisabledPluginsExceptions), |
| 86 TypeAndName(kPolicyEnabledPlugins, | 88 PolicyAndPref(key::kEnabledPlugins, |
| 87 prefs::kPluginsEnabledPlugins), | 89 prefs::kPluginsEnabledPlugins), |
| 88 TypeAndName(kPolicyDisabledSchemes, | 90 PolicyAndPref(key::kDisabledSchemes, |
| 89 prefs::kDisabledSchemes), | 91 prefs::kDisabledSchemes), |
| 90 TypeAndName(kPolicyAutoSelectCertificateForUrls, | 92 PolicyAndPref(key::kAutoSelectCertificateForUrls, |
| 91 prefs::kManagedAutoSelectCertificateForUrls), | 93 prefs::kManagedAutoSelectCertificateForUrls), |
| 92 TypeAndName(kPolicyURLBlacklist, | 94 PolicyAndPref(key::kURLBlacklist, |
| 93 prefs::kUrlBlacklist), | 95 prefs::kUrlBlacklist), |
| 94 TypeAndName(kPolicyURLWhitelist, | 96 PolicyAndPref(key::kURLWhitelist, |
| 95 prefs::kUrlWhitelist))); | 97 prefs::kUrlWhitelist))); |
| 96 | 98 |
| 97 // Test cases for string-valued policy settings. | 99 // Test cases for string-valued policy settings. |
| 98 class ConfigurationPolicyPrefStoreStringTest | 100 class ConfigurationPolicyPrefStoreStringTest |
| 99 : public ConfigurationPolicyPrefStoreTestBase< | 101 : public ConfigurationPolicyPrefStoreTestBase< |
| 100 testing::TestWithParam<TypeAndName> > { | 102 testing::TestWithParam<PolicyAndPref> > { |
| 101 }; | 103 }; |
| 102 | 104 |
| 103 TEST_P(ConfigurationPolicyPrefStoreStringTest, GetDefault) { | 105 TEST_P(ConfigurationPolicyPrefStoreStringTest, GetDefault) { |
| 104 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 106 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 105 store_->GetValue(GetParam().pref_name(), NULL)); | 107 store_->GetValue(GetParam().pref_name(), NULL)); |
| 106 } | 108 } |
| 107 | 109 |
| 108 TEST_P(ConfigurationPolicyPrefStoreStringTest, SetValue) { | 110 TEST_P(ConfigurationPolicyPrefStoreStringTest, SetValue) { |
| 109 provider_.AddPolicy(GetParam().type(), | 111 provider_.AddMandatoryPolicy(GetParam().policy_name(), |
| 110 Value::CreateStringValue("http://chromium.org")); | 112 Value::CreateStringValue("http://chromium.org")); |
| 111 store_->OnUpdatePolicy(&provider_); | 113 store_->OnUpdatePolicy(&provider_); |
| 112 const Value* value = NULL; | 114 const Value* value = NULL; |
| 113 EXPECT_EQ(PrefStore::READ_OK, | 115 EXPECT_EQ(PrefStore::READ_OK, |
| 114 store_->GetValue(GetParam().pref_name(), &value)); | 116 store_->GetValue(GetParam().pref_name(), &value)); |
| 115 ASSERT_TRUE(value); | 117 ASSERT_TRUE(value); |
| 116 EXPECT_TRUE(StringValue("http://chromium.org").Equals(value)); | 118 EXPECT_TRUE(StringValue("http://chromium.org").Equals(value)); |
| 117 } | 119 } |
| 118 | 120 |
| 119 INSTANTIATE_TEST_CASE_P( | 121 INSTANTIATE_TEST_CASE_P( |
| 120 ConfigurationPolicyPrefStoreStringTestInstance, | 122 ConfigurationPolicyPrefStoreStringTestInstance, |
| 121 ConfigurationPolicyPrefStoreStringTest, | 123 ConfigurationPolicyPrefStoreStringTest, |
| 122 testing::Values( | 124 testing::Values( |
| 123 TypeAndName(kPolicyHomepageLocation, | 125 PolicyAndPref(key::kHomepageLocation, |
| 124 prefs::kHomePage), | 126 prefs::kHomePage), |
| 125 TypeAndName(kPolicyApplicationLocaleValue, | 127 PolicyAndPref(key::kApplicationLocaleValue, |
| 126 prefs::kApplicationLocale), | 128 prefs::kApplicationLocale), |
| 127 TypeAndName(kPolicyApplicationLocaleValue, | 129 PolicyAndPref(key::kAuthSchemes, |
| 128 prefs::kApplicationLocale), | 130 prefs::kAuthSchemes), |
| 129 TypeAndName(kPolicyAuthSchemes, | 131 PolicyAndPref(key::kAuthServerWhitelist, |
| 130 prefs::kAuthSchemes), | 132 prefs::kAuthServerWhitelist), |
| 131 TypeAndName(kPolicyAuthServerWhitelist, | 133 PolicyAndPref(key::kAuthNegotiateDelegateWhitelist, |
| 132 prefs::kAuthServerWhitelist), | 134 prefs::kAuthNegotiateDelegateWhitelist), |
| 133 TypeAndName(kPolicyAuthNegotiateDelegateWhitelist, | 135 PolicyAndPref(key::kGSSAPILibraryName, |
| 134 prefs::kAuthNegotiateDelegateWhitelist), | 136 prefs::kGSSAPILibraryName), |
| 135 TypeAndName(kPolicyGSSAPILibraryName, | 137 PolicyAndPref(key::kDiskCacheDir, |
| 136 prefs::kGSSAPILibraryName), | 138 prefs::kDiskCacheDir))); |
| 137 TypeAndName(kPolicyDiskCacheDir, | |
| 138 prefs::kDiskCacheDir))); | |
| 139 | 139 |
| 140 #if !defined(OS_CHROMEOS) | 140 #if !defined(OS_CHROMEOS) |
| 141 INSTANTIATE_TEST_CASE_P( | 141 INSTANTIATE_TEST_CASE_P( |
| 142 ConfigurationPolicyPrefStoreDownloadDirectoryInstance, | 142 ConfigurationPolicyPrefStoreDownloadDirectoryInstance, |
| 143 ConfigurationPolicyPrefStoreStringTest, | 143 ConfigurationPolicyPrefStoreStringTest, |
| 144 testing::Values(TypeAndName(kPolicyDownloadDirectory, | 144 testing::Values(PolicyAndPref(key::kDownloadDirectory, |
| 145 prefs::kDownloadDefaultDirectory))); | 145 prefs::kDownloadDefaultDirectory))); |
| 146 #endif // !defined(OS_CHROMEOS) | 146 #endif // !defined(OS_CHROMEOS) |
| 147 | 147 |
| 148 // Test cases for boolean-valued policy settings. | 148 // Test cases for boolean-valued policy settings. |
| 149 class ConfigurationPolicyPrefStoreBooleanTest | 149 class ConfigurationPolicyPrefStoreBooleanTest |
| 150 : public ConfigurationPolicyPrefStoreTestBase< | 150 : public ConfigurationPolicyPrefStoreTestBase< |
| 151 testing::TestWithParam<TypeAndName> > { | 151 testing::TestWithParam<PolicyAndPref> > { |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 TEST_P(ConfigurationPolicyPrefStoreBooleanTest, GetDefault) { | 154 TEST_P(ConfigurationPolicyPrefStoreBooleanTest, GetDefault) { |
| 155 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 155 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 156 store_->GetValue(GetParam().pref_name(), NULL)); | 156 store_->GetValue(GetParam().pref_name(), NULL)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 TEST_P(ConfigurationPolicyPrefStoreBooleanTest, SetValue) { | 159 TEST_P(ConfigurationPolicyPrefStoreBooleanTest, SetValue) { |
| 160 provider_.AddPolicy(GetParam().type(), Value::CreateBooleanValue(false)); | 160 provider_.AddMandatoryPolicy(GetParam().policy_name(), |
| 161 Value::CreateBooleanValue(false)); | |
| 161 store_->OnUpdatePolicy(&provider_); | 162 store_->OnUpdatePolicy(&provider_); |
| 162 const Value* value = NULL; | 163 const Value* value = NULL; |
| 163 EXPECT_EQ(PrefStore::READ_OK, | 164 EXPECT_EQ(PrefStore::READ_OK, |
| 164 store_->GetValue(GetParam().pref_name(), &value)); | 165 store_->GetValue(GetParam().pref_name(), &value)); |
| 165 ASSERT_TRUE(value); | 166 ASSERT_TRUE(value); |
| 166 bool boolean_value = true; | 167 bool boolean_value = true; |
| 167 bool result = value->GetAsBoolean(&boolean_value); | 168 bool result = value->GetAsBoolean(&boolean_value); |
| 168 ASSERT_TRUE(result); | 169 ASSERT_TRUE(result); |
| 169 EXPECT_FALSE(boolean_value); | 170 EXPECT_FALSE(boolean_value); |
| 170 | 171 |
| 171 provider_.AddPolicy(GetParam().type(), Value::CreateBooleanValue(true)); | 172 provider_.AddMandatoryPolicy(GetParam().policy_name(), |
| 173 Value::CreateBooleanValue(true)); | |
| 172 store_->OnUpdatePolicy(&provider_); | 174 store_->OnUpdatePolicy(&provider_); |
| 173 value = NULL; | 175 value = NULL; |
| 174 EXPECT_EQ(PrefStore::READ_OK, | 176 EXPECT_EQ(PrefStore::READ_OK, |
| 175 store_->GetValue(GetParam().pref_name(), &value)); | 177 store_->GetValue(GetParam().pref_name(), &value)); |
| 176 boolean_value = false; | 178 boolean_value = false; |
| 177 result = value->GetAsBoolean(&boolean_value); | 179 result = value->GetAsBoolean(&boolean_value); |
| 178 ASSERT_TRUE(result); | 180 ASSERT_TRUE(result); |
| 179 EXPECT_TRUE(boolean_value); | 181 EXPECT_TRUE(boolean_value); |
| 180 } | 182 } |
| 181 | 183 |
| 182 INSTANTIATE_TEST_CASE_P( | 184 INSTANTIATE_TEST_CASE_P( |
| 183 ConfigurationPolicyPrefStoreBooleanTestInstance, | 185 ConfigurationPolicyPrefStoreBooleanTestInstance, |
| 184 ConfigurationPolicyPrefStoreBooleanTest, | 186 ConfigurationPolicyPrefStoreBooleanTest, |
| 185 testing::Values( | 187 testing::Values( |
| 186 TypeAndName(kPolicyHomepageIsNewTabPage, | 188 PolicyAndPref(key::kHomepageIsNewTabPage, |
| 187 prefs::kHomePageIsNewTabPage), | 189 prefs::kHomePageIsNewTabPage), |
| 188 TypeAndName(kPolicyAlternateErrorPagesEnabled, | 190 PolicyAndPref(key::kAlternateErrorPagesEnabled, |
| 189 prefs::kAlternateErrorPagesEnabled), | 191 prefs::kAlternateErrorPagesEnabled), |
| 190 TypeAndName(kPolicySearchSuggestEnabled, | 192 PolicyAndPref(key::kSearchSuggestEnabled, |
| 191 prefs::kSearchSuggestEnabled), | 193 prefs::kSearchSuggestEnabled), |
| 192 TypeAndName(kPolicyDnsPrefetchingEnabled, | 194 PolicyAndPref(key::kDnsPrefetchingEnabled, |
| 193 prefs::kNetworkPredictionEnabled), | 195 prefs::kNetworkPredictionEnabled), |
| 194 TypeAndName(kPolicyDisableSpdy, | 196 PolicyAndPref(key::kDisableSpdy, |
| 195 prefs::kDisableSpdy), | 197 prefs::kDisableSpdy), |
| 196 TypeAndName(kPolicySafeBrowsingEnabled, | 198 PolicyAndPref(key::kSafeBrowsingEnabled, |
| 197 prefs::kSafeBrowsingEnabled), | 199 prefs::kSafeBrowsingEnabled), |
| 198 TypeAndName(kPolicyMetricsReportingEnabled, | 200 PolicyAndPref(key::kMetricsReportingEnabled, |
| 199 prefs::kMetricsReportingEnabled), | 201 prefs::kMetricsReportingEnabled), |
| 200 TypeAndName(kPolicyPasswordManagerEnabled, | 202 PolicyAndPref(key::kPasswordManagerEnabled, |
| 201 prefs::kPasswordManagerEnabled), | 203 prefs::kPasswordManagerEnabled), |
| 202 TypeAndName(kPolicyPasswordManagerAllowShowPasswords, | 204 PolicyAndPref(key::kPasswordManagerAllowShowPasswords, |
| 203 prefs::kPasswordManagerAllowShowPasswords), | 205 prefs::kPasswordManagerAllowShowPasswords), |
| 204 TypeAndName(kPolicyShowHomeButton, | 206 PolicyAndPref(key::kShowHomeButton, |
| 205 prefs::kShowHomeButton), | 207 prefs::kShowHomeButton), |
| 206 TypeAndName(kPolicyPrintingEnabled, | 208 PolicyAndPref(key::kPrintingEnabled, |
| 207 prefs::kPrintingEnabled), | 209 prefs::kPrintingEnabled), |
| 208 TypeAndName(kPolicyRemoteAccessHostFirewallTraversal, | 210 PolicyAndPref(key::kRemoteAccessHostFirewallTraversal, |
| 209 prefs::kRemoteAccessHostFirewallTraversal), | 211 prefs::kRemoteAccessHostFirewallTraversal), |
| 210 TypeAndName(kPolicyCloudPrintProxyEnabled, | 212 PolicyAndPref(key::kCloudPrintProxyEnabled, |
| 211 prefs::kCloudPrintProxyEnabled), | 213 prefs::kCloudPrintProxyEnabled), |
| 212 TypeAndName(kPolicyCloudPrintSubmitEnabled, | 214 PolicyAndPref(key::kCloudPrintSubmitEnabled, |
| 213 prefs::kCloudPrintSubmitEnabled), | 215 prefs::kCloudPrintSubmitEnabled), |
| 214 TypeAndName(kPolicySavingBrowserHistoryDisabled, | 216 PolicyAndPref(key::kSavingBrowserHistoryDisabled, |
| 215 prefs::kSavingBrowserHistoryDisabled), | 217 prefs::kSavingBrowserHistoryDisabled), |
| 216 TypeAndName(kPolicySavingBrowserHistoryDisabled, | 218 PolicyAndPref(key::kEnableOriginBoundCerts, |
| 217 prefs::kSavingBrowserHistoryDisabled), | 219 prefs::kEnableOriginBoundCerts), |
| 218 TypeAndName(kPolicyEnableOriginBoundCerts, | 220 PolicyAndPref(key::kDisableAuthNegotiateCnameLookup, |
| 219 prefs::kEnableOriginBoundCerts), | 221 prefs::kDisableAuthNegotiateCnameLookup), |
| 220 TypeAndName(kPolicyDisableAuthNegotiateCnameLookup, | 222 PolicyAndPref(key::kEnableAuthNegotiatePort, |
| 221 prefs::kDisableAuthNegotiateCnameLookup), | 223 prefs::kEnableAuthNegotiatePort), |
| 222 TypeAndName(kPolicyEnableAuthNegotiatePort, | 224 PolicyAndPref(key::kInstantEnabled, |
| 223 prefs::kEnableAuthNegotiatePort), | 225 prefs::kInstantEnabled), |
| 224 TypeAndName(kPolicyInstantEnabled, | 226 PolicyAndPref(key::kDisablePluginFinder, |
| 225 prefs::kInstantEnabled), | 227 prefs::kDisablePluginFinder), |
| 226 TypeAndName(kPolicyDisablePluginFinder, | 228 PolicyAndPref(key::kClearSiteDataOnExit, |
| 227 prefs::kDisablePluginFinder), | 229 prefs::kClearSiteDataOnExit), |
| 228 TypeAndName(kPolicyClearSiteDataOnExit, | 230 PolicyAndPref(key::kDefaultBrowserSettingEnabled, |
| 229 prefs::kClearSiteDataOnExit), | 231 prefs::kDefaultBrowserSettingEnabled), |
| 230 TypeAndName(kPolicyDefaultBrowserSettingEnabled, | 232 PolicyAndPref(key::kDisable3DAPIs, |
| 231 prefs::kDefaultBrowserSettingEnabled), | 233 prefs::kDisable3DAPIs), |
| 232 TypeAndName(kPolicyDisable3DAPIs, | 234 PolicyAndPref(key::kTranslateEnabled, |
| 233 prefs::kDisable3DAPIs), | 235 prefs::kEnableTranslate), |
| 234 TypeAndName(kPolicyTranslateEnabled, | 236 PolicyAndPref(key::kAllowOutdatedPlugins, |
| 235 prefs::kEnableTranslate), | 237 prefs::kPluginsAllowOutdated), |
| 236 TypeAndName(kPolicyAllowOutdatedPlugins, | 238 PolicyAndPref(key::kAlwaysAuthorizePlugins, |
| 237 prefs::kPluginsAllowOutdated), | 239 prefs::kPluginsAlwaysAuthorize), |
| 238 TypeAndName(kPolicyAlwaysAuthorizePlugins, | 240 PolicyAndPref(key::kBookmarkBarEnabled, |
| 239 prefs::kPluginsAlwaysAuthorize), | 241 prefs::kShowBookmarkBar), |
| 240 TypeAndName(kPolicyBookmarkBarEnabled, | 242 PolicyAndPref(key::kEditBookmarksEnabled, |
| 241 prefs::kShowBookmarkBar), | 243 prefs::kEditBookmarksEnabled), |
| 242 TypeAndName(kPolicyEditBookmarksEnabled, | 244 PolicyAndPref(key::kAllowFileSelectionDialogs, |
| 243 prefs::kEditBookmarksEnabled), | 245 prefs::kAllowFileSelectionDialogs), |
| 244 TypeAndName(kPolicyAllowFileSelectionDialogs, | 246 PolicyAndPref(key::kAllowCrossOriginAuthPrompt, |
| 245 prefs::kAllowFileSelectionDialogs), | 247 prefs::kAllowCrossOriginAuthPrompt), |
| 246 TypeAndName(kPolicyAllowCrossOriginAuthPrompt, | 248 PolicyAndPref(key::kImportBookmarks, |
| 247 prefs::kAllowCrossOriginAuthPrompt), | 249 prefs::kImportBookmarks), |
| 248 TypeAndName(kPolicyImportBookmarks, | 250 PolicyAndPref(key::kImportHistory, |
| 249 prefs::kImportBookmarks), | 251 prefs::kImportHistory), |
| 250 TypeAndName(kPolicyImportHistory, | 252 PolicyAndPref(key::kImportHomepage, |
| 251 prefs::kImportHistory), | 253 prefs::kImportHomepage), |
| 252 TypeAndName(kPolicyImportHomepage, | 254 PolicyAndPref(key::kImportSearchEngine, |
| 253 prefs::kImportHomepage), | 255 prefs::kImportSearchEngine), |
| 254 TypeAndName(kPolicyImportSearchEngine, | 256 PolicyAndPref(key::kImportSavedPasswords, |
| 255 prefs::kImportSearchEngine), | 257 prefs::kImportSavedPasswords), |
| 256 TypeAndName(kPolicyImportSavedPasswords, | 258 PolicyAndPref(key::kEnableMemoryInfo, |
| 257 prefs::kImportSavedPasswords), | 259 prefs::kEnableMemoryInfo), |
| 258 TypeAndName(kPolicyEnableMemoryInfo, | 260 PolicyAndPref(key::kDeveloperToolsDisabled, |
| 259 prefs::kEnableMemoryInfo), | 261 prefs::kDevToolsDisabled))); |
| 260 TypeAndName(kPolicyDeveloperToolsDisabled, | |
| 261 prefs::kDevToolsDisabled))); | |
| 262 | 262 |
| 263 #if defined(OS_CHROMEOS) | 263 #if defined(OS_CHROMEOS) |
| 264 INSTANTIATE_TEST_CASE_P( | 264 INSTANTIATE_TEST_CASE_P( |
| 265 CrosConfigurationPolicyPrefStoreBooleanTestInstance, | 265 CrosConfigurationPolicyPrefStoreBooleanTestInstance, |
| 266 ConfigurationPolicyPrefStoreBooleanTest, | 266 ConfigurationPolicyPrefStoreBooleanTest, |
| 267 testing::Values( | 267 testing::Values( |
| 268 TypeAndName(kPolicyChromeOsLockOnIdleSuspend, | 268 PolicyAndPref(key::kChromeOsLockOnIdleSuspend, |
| 269 prefs::kEnableScreenLock))); | 269 prefs::kEnableScreenLock))); |
| 270 #endif // defined(OS_CHROMEOS) | 270 #endif // defined(OS_CHROMEOS) |
| 271 | 271 |
| 272 // Test cases for integer-valued policy settings. | 272 // Test cases for integer-valued policy settings. |
| 273 class ConfigurationPolicyPrefStoreIntegerTest | 273 class ConfigurationPolicyPrefStoreIntegerTest |
| 274 : public ConfigurationPolicyPrefStoreTestBase< | 274 : public ConfigurationPolicyPrefStoreTestBase< |
| 275 testing::TestWithParam<TypeAndName> > { | 275 testing::TestWithParam<PolicyAndPref> > { |
| 276 }; | 276 }; |
| 277 | 277 |
| 278 TEST_P(ConfigurationPolicyPrefStoreIntegerTest, GetDefault) { | 278 TEST_P(ConfigurationPolicyPrefStoreIntegerTest, GetDefault) { |
| 279 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 279 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 280 store_->GetValue(GetParam().pref_name(), NULL)); | 280 store_->GetValue(GetParam().pref_name(), NULL)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 TEST_P(ConfigurationPolicyPrefStoreIntegerTest, SetValue) { | 283 TEST_P(ConfigurationPolicyPrefStoreIntegerTest, SetValue) { |
| 284 provider_.AddPolicy(GetParam().type(), Value::CreateIntegerValue(2)); | 284 provider_.AddMandatoryPolicy(GetParam().policy_name(), |
| 285 Value::CreateIntegerValue(2)); | |
| 285 store_->OnUpdatePolicy(&provider_); | 286 store_->OnUpdatePolicy(&provider_); |
| 286 const Value* value = NULL; | 287 const Value* value = NULL; |
| 287 EXPECT_EQ(PrefStore::READ_OK, | 288 EXPECT_EQ(PrefStore::READ_OK, |
| 288 store_->GetValue(GetParam().pref_name(), &value)); | 289 store_->GetValue(GetParam().pref_name(), &value)); |
| 289 EXPECT_TRUE(base::FundamentalValue(2).Equals(value)); | 290 EXPECT_TRUE(base::FundamentalValue(2).Equals(value)); |
| 290 } | 291 } |
| 291 | 292 |
| 292 INSTANTIATE_TEST_CASE_P( | 293 INSTANTIATE_TEST_CASE_P( |
| 293 ConfigurationPolicyPrefStoreIntegerTestInstance, | 294 ConfigurationPolicyPrefStoreIntegerTestInstance, |
| 294 ConfigurationPolicyPrefStoreIntegerTest, | 295 ConfigurationPolicyPrefStoreIntegerTest, |
| 295 testing::Values( | 296 testing::Values( |
| 296 TypeAndName(kPolicyDefaultCookiesSetting, | 297 PolicyAndPref(key::kDefaultCookiesSetting, |
| 297 prefs::kManagedDefaultCookiesSetting), | 298 prefs::kManagedDefaultCookiesSetting), |
| 298 TypeAndName(kPolicyDefaultImagesSetting, | 299 PolicyAndPref(key::kDefaultImagesSetting, |
| 299 prefs::kManagedDefaultImagesSetting), | 300 prefs::kManagedDefaultImagesSetting), |
| 300 TypeAndName(kPolicyDefaultPluginsSetting, | 301 PolicyAndPref(key::kDefaultPluginsSetting, |
| 301 prefs::kManagedDefaultPluginsSetting), | 302 prefs::kManagedDefaultPluginsSetting), |
| 302 TypeAndName(kPolicyDefaultPopupsSetting, | 303 PolicyAndPref(key::kDefaultPopupsSetting, |
| 303 prefs::kManagedDefaultPopupsSetting), | 304 prefs::kManagedDefaultPopupsSetting), |
| 304 TypeAndName(kPolicyDefaultNotificationsSetting, | 305 PolicyAndPref(key::kDefaultNotificationsSetting, |
| 305 prefs::kManagedDefaultNotificationsSetting), | 306 prefs::kManagedDefaultNotificationsSetting), |
| 306 TypeAndName(kPolicyDefaultGeolocationSetting, | 307 PolicyAndPref(key::kDefaultGeolocationSetting, |
| 307 prefs::kManagedDefaultGeolocationSetting), | 308 prefs::kManagedDefaultGeolocationSetting), |
| 308 TypeAndName(kPolicyRestoreOnStartup, | 309 PolicyAndPref(key::kRestoreOnStartup, |
| 309 prefs::kRestoreOnStartup), | 310 prefs::kRestoreOnStartup), |
| 310 TypeAndName(kPolicyDiskCacheSize, | 311 PolicyAndPref(key::kDiskCacheSize, |
| 311 prefs::kDiskCacheSize), | 312 prefs::kDiskCacheSize), |
| 312 TypeAndName(kPolicyMediaCacheSize, | 313 PolicyAndPref(key::kMediaCacheSize, |
| 313 prefs::kMediaCacheSize), | 314 prefs::kMediaCacheSize), |
| 314 TypeAndName(kPolicyPolicyRefreshRate, | 315 PolicyAndPref(key::kPolicyRefreshRate, |
| 315 prefs::kUserPolicyRefreshRate), | 316 prefs::kUserPolicyRefreshRate), |
| 316 TypeAndName(kPolicyMaxConnectionsPerProxy, | 317 PolicyAndPref(key::kMaxConnectionsPerProxy, |
| 317 prefs::kMaxConnectionsPerProxy))); | 318 prefs::kMaxConnectionsPerProxy))); |
| 318 | 319 |
| 319 // Test cases for the proxy policy settings. | 320 // Test cases for the proxy policy settings. |
| 320 class ConfigurationPolicyPrefStoreProxyTest : public testing::Test { | 321 class ConfigurationPolicyPrefStoreProxyTest : public testing::Test { |
| 321 protected: | 322 protected: |
| 322 // Verify that all the proxy prefs are set to the specified expected values. | 323 // Verify that all the proxy prefs are set to the specified expected values. |
| 323 static void VerifyProxyPrefs( | 324 static void VerifyProxyPrefs( |
| 324 const ConfigurationPolicyPrefStore& store, | 325 const ConfigurationPolicyPrefStore& store, |
| 325 const std::string& expected_proxy_server, | 326 const std::string& expected_proxy_server, |
| 326 const std::string& expected_proxy_pac_url, | 327 const std::string& expected_proxy_pac_url, |
| 327 const std::string& expected_proxy_bypass_list, | 328 const std::string& expected_proxy_bypass_list, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 351 EXPECT_EQ(expected_proxy_bypass_list, s); | 352 EXPECT_EQ(expected_proxy_bypass_list, s); |
| 352 } | 353 } |
| 353 ProxyPrefs::ProxyMode mode; | 354 ProxyPrefs::ProxyMode mode; |
| 354 ASSERT_TRUE(dict.GetMode(&mode)); | 355 ASSERT_TRUE(dict.GetMode(&mode)); |
| 355 EXPECT_EQ(expected_proxy_mode, mode); | 356 EXPECT_EQ(expected_proxy_mode, mode); |
| 356 } | 357 } |
| 357 }; | 358 }; |
| 358 | 359 |
| 359 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptions) { | 360 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptions) { |
| 360 MockConfigurationPolicyProvider provider; | 361 MockConfigurationPolicyProvider provider; |
| 361 provider.AddPolicy(kPolicyProxyBypassList, | 362 provider.AddMandatoryPolicy( |
| 362 Value::CreateStringValue("http://chromium.org/override")); | 363 key::kProxyBypassList, |
| 363 provider.AddPolicy(kPolicyProxyServer, | 364 Value::CreateStringValue("http://chromium.org/override")); |
| 364 Value::CreateStringValue("chromium.org")); | 365 provider.AddMandatoryPolicy(key::kProxyServer, |
| 365 provider.AddPolicy(kPolicyProxyServerMode, | 366 Value::CreateStringValue("chromium.org")); |
| 366 Value::CreateIntegerValue( | 367 provider.AddMandatoryPolicy( |
| 367 kPolicyManuallyConfiguredProxyServerMode)); | 368 key::kProxyServerMode, |
| 369 Value::CreateIntegerValue( | |
| 370 ProxyPolicyHandler::PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE)); | |
| 368 | 371 |
| 369 scoped_refptr<ConfigurationPolicyPrefStore> store( | 372 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 370 new ConfigurationPolicyPrefStore(&provider)); | 373 new ConfigurationPolicyPrefStore(&provider)); |
| 371 VerifyProxyPrefs( | 374 VerifyProxyPrefs( |
| 372 *store, "chromium.org", "", "http://chromium.org/override", | 375 *store, "chromium.org", "", "http://chromium.org/override", |
| 373 ProxyPrefs::MODE_FIXED_SERVERS); | 376 ProxyPrefs::MODE_FIXED_SERVERS); |
| 374 } | 377 } |
| 375 | 378 |
| 376 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsReversedApplyOrder) { | 379 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsReversedApplyOrder) { |
| 377 MockConfigurationPolicyProvider provider; | 380 MockConfigurationPolicyProvider provider; |
| 378 provider.AddPolicy(kPolicyProxyServerMode, | 381 provider.AddMandatoryPolicy( |
| 379 Value::CreateIntegerValue( | 382 key::kProxyServerMode, |
| 380 kPolicyManuallyConfiguredProxyServerMode)); | 383 Value::CreateIntegerValue( |
| 381 provider.AddPolicy(kPolicyProxyBypassList, | 384 ProxyPolicyHandler::PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE)); |
| 382 Value::CreateStringValue("http://chromium.org/override")); | 385 provider.AddMandatoryPolicy( |
| 383 provider.AddPolicy(kPolicyProxyServer, | 386 key::kProxyBypassList, |
| 384 Value::CreateStringValue("chromium.org")); | 387 Value::CreateStringValue("http://chromium.org/override")); |
| 388 provider.AddMandatoryPolicy( | |
| 389 key::kProxyServer, | |
| 390 Value::CreateStringValue("chromium.org")); | |
| 385 scoped_refptr<ConfigurationPolicyPrefStore> store( | 391 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 386 new ConfigurationPolicyPrefStore(&provider)); | 392 new ConfigurationPolicyPrefStore(&provider)); |
| 387 VerifyProxyPrefs( | 393 VerifyProxyPrefs( |
| 388 *store, "chromium.org", "", "http://chromium.org/override", | 394 *store, "chromium.org", "", "http://chromium.org/override", |
| 389 ProxyPrefs::MODE_FIXED_SERVERS); | 395 ProxyPrefs::MODE_FIXED_SERVERS); |
| 390 } | 396 } |
| 391 | 397 |
| 392 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsInvalid) { | 398 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsInvalid) { |
| 393 MockConfigurationPolicyProvider provider; | 399 MockConfigurationPolicyProvider provider; |
| 394 provider.AddPolicy(kPolicyProxyServerMode, | 400 provider.AddMandatoryPolicy( |
| 395 Value::CreateIntegerValue( | 401 key::kProxyServerMode, |
| 396 kPolicyManuallyConfiguredProxyServerMode)); | 402 Value::CreateIntegerValue( |
| 403 ProxyPolicyHandler::PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE)); | |
| 397 | 404 |
| 398 scoped_refptr<ConfigurationPolicyPrefStore> store( | 405 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 399 new ConfigurationPolicyPrefStore(&provider)); | 406 new ConfigurationPolicyPrefStore(&provider)); |
| 400 const Value* value = NULL; | 407 const Value* value = NULL; |
| 401 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value)); | 408 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value)); |
| 402 } | 409 } |
| 403 | 410 |
| 404 | 411 |
| 405 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyServerMode) { | 412 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyServerMode) { |
| 406 MockConfigurationPolicyProvider provider; | 413 MockConfigurationPolicyProvider provider; |
| 407 provider.AddPolicy(kPolicyProxyServerMode, | 414 provider.AddMandatoryPolicy( |
| 408 Value::CreateIntegerValue(kPolicyNoProxyServerMode)); | 415 key::kProxyServerMode, |
| 416 Value::CreateIntegerValue(ProxyPolicyHandler::PROXY_SERVER_MODE)); | |
| 409 | 417 |
| 410 scoped_refptr<ConfigurationPolicyPrefStore> store( | 418 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 411 new ConfigurationPolicyPrefStore(&provider)); | 419 new ConfigurationPolicyPrefStore(&provider)); |
| 412 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT); | 420 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT); |
| 413 } | 421 } |
| 414 | 422 |
| 415 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyModeName) { | 423 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyModeName) { |
| 416 MockConfigurationPolicyProvider provider; | 424 MockConfigurationPolicyProvider provider; |
| 417 provider.AddPolicy( | 425 provider.AddMandatoryPolicy( |
| 418 kPolicyProxyMode, | 426 key::kProxyMode, |
| 419 Value::CreateStringValue(ProxyPrefs::kDirectProxyModeName)); | 427 Value::CreateStringValue(ProxyPrefs::kDirectProxyModeName)); |
| 420 | 428 |
| 421 scoped_refptr<ConfigurationPolicyPrefStore> store( | 429 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 422 new ConfigurationPolicyPrefStore(&provider)); | 430 new ConfigurationPolicyPrefStore(&provider)); |
| 423 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT); | 431 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT); |
| 424 } | 432 } |
| 425 | 433 |
| 426 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyServerMode) { | 434 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyServerMode) { |
| 427 MockConfigurationPolicyProvider provider; | 435 MockConfigurationPolicyProvider provider; |
| 428 provider.AddPolicy( | 436 provider.AddMandatoryPolicy( |
| 429 kPolicyProxyServerMode, | 437 key::kProxyServerMode, |
| 430 Value::CreateIntegerValue(kPolicyAutoDetectProxyServerMode)); | 438 Value::CreateIntegerValue( |
| 439 ProxyPolicyHandler::PROXY_AUTO_DETECT_PROXY_SERVER_MODE)); | |
| 431 | 440 |
| 432 scoped_refptr<ConfigurationPolicyPrefStore> store( | 441 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 433 new ConfigurationPolicyPrefStore(&provider)); | 442 new ConfigurationPolicyPrefStore(&provider)); |
| 434 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); | 443 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); |
| 435 } | 444 } |
| 436 | 445 |
| 437 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyModeName) { | 446 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyModeName) { |
| 438 MockConfigurationPolicyProvider provider; | 447 MockConfigurationPolicyProvider provider; |
| 439 provider.AddPolicy( | 448 provider.AddMandatoryPolicy( |
| 440 kPolicyProxyMode, | 449 key::kProxyMode, |
| 441 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName)); | 450 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName)); |
| 442 | 451 |
| 443 scoped_refptr<ConfigurationPolicyPrefStore> store( | 452 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 444 new ConfigurationPolicyPrefStore(&provider)); | 453 new ConfigurationPolicyPrefStore(&provider)); |
| 445 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); | 454 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); |
| 446 } | 455 } |
| 447 | 456 |
| 448 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyMode) { | 457 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyMode) { |
| 449 MockConfigurationPolicyProvider provider; | 458 MockConfigurationPolicyProvider provider; |
| 450 provider.AddPolicy(kPolicyProxyPacUrl, | 459 provider.AddMandatoryPolicy( |
| 451 Value::CreateStringValue("http://short.org/proxy.pac")); | 460 key::kProxyPacUrl, |
| 452 provider.AddPolicy( | 461 Value::CreateStringValue("http://short.org/proxy.pac")); |
| 453 kPolicyProxyMode, | 462 provider.AddMandatoryPolicy( |
| 463 key::kProxyMode, | |
| 454 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); | 464 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); |
| 455 | 465 |
| 456 scoped_refptr<ConfigurationPolicyPrefStore> store( | 466 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 457 new ConfigurationPolicyPrefStore(&provider)); | 467 new ConfigurationPolicyPrefStore(&provider)); |
| 458 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "", | 468 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "", |
| 459 ProxyPrefs::MODE_PAC_SCRIPT); | 469 ProxyPrefs::MODE_PAC_SCRIPT); |
| 460 } | 470 } |
| 461 | 471 |
| 462 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeInvalid) { | 472 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeInvalid) { |
| 463 MockConfigurationPolicyProvider provider; | 473 MockConfigurationPolicyProvider provider; |
| 464 provider.AddPolicy( | 474 provider.AddMandatoryPolicy( |
| 465 kPolicyProxyMode, | 475 key::kProxyMode, |
| 466 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); | 476 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); |
| 467 | 477 |
| 468 scoped_refptr<ConfigurationPolicyPrefStore> store( | 478 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 469 new ConfigurationPolicyPrefStore(&provider)); | 479 new ConfigurationPolicyPrefStore(&provider)); |
| 470 const Value* value = NULL; | 480 const Value* value = NULL; |
| 471 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value)); | 481 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value)); |
| 472 } | 482 } |
| 473 | 483 |
| 474 // Regression test for http://crbug.com/78016, CPanel returns empty strings | 484 // Regression test for http://crbug.com/78016, CPanel returns empty strings |
| 475 // for unset properties. | 485 // for unset properties. |
| 476 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeBug78016) { | 486 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeBug78016) { |
| 477 MockConfigurationPolicyProvider provider; | 487 MockConfigurationPolicyProvider provider; |
| 478 provider.AddPolicy(kPolicyProxyServer, | 488 provider.AddMandatoryPolicy(key::kProxyServer, |
| 479 Value::CreateStringValue("")); | 489 Value::CreateStringValue("")); |
| 480 provider.AddPolicy(kPolicyProxyPacUrl, | 490 provider.AddMandatoryPolicy( |
| 481 Value::CreateStringValue("http://short.org/proxy.pac")); | 491 key::kProxyPacUrl, |
| 482 provider.AddPolicy( | 492 Value::CreateStringValue("http://short.org/proxy.pac")); |
| 483 kPolicyProxyMode, | 493 provider.AddMandatoryPolicy( |
| 494 key::kProxyMode, | |
| 484 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); | 495 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); |
| 485 | 496 |
| 486 scoped_refptr<ConfigurationPolicyPrefStore> store( | 497 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 487 new ConfigurationPolicyPrefStore(&provider)); | 498 new ConfigurationPolicyPrefStore(&provider)); |
| 488 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "", | 499 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "", |
| 489 ProxyPrefs::MODE_PAC_SCRIPT); | 500 ProxyPrefs::MODE_PAC_SCRIPT); |
| 490 } | 501 } |
| 491 | 502 |
| 492 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyServerMode) { | 503 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyServerMode) { |
| 493 MockConfigurationPolicyProvider provider; | 504 MockConfigurationPolicyProvider provider; |
| 494 provider.AddPolicy( | 505 provider.AddMandatoryPolicy( |
| 495 kPolicyProxyServerMode, | 506 key::kProxyServerMode, |
| 496 Value::CreateIntegerValue(kPolicyUseSystemProxyServerMode)); | 507 Value::CreateIntegerValue( |
| 508 ProxyPolicyHandler::PROXY_USE_SYSTEM_PROXY_SERVER_MODE)); | |
| 497 | 509 |
| 498 scoped_refptr<ConfigurationPolicyPrefStore> store( | 510 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 499 new ConfigurationPolicyPrefStore(&provider)); | 511 new ConfigurationPolicyPrefStore(&provider)); |
| 500 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM); | 512 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM); |
| 501 } | 513 } |
| 502 | 514 |
| 503 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyMode) { | 515 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyMode) { |
| 504 MockConfigurationPolicyProvider provider; | 516 MockConfigurationPolicyProvider provider; |
| 505 provider.AddPolicy( | 517 provider.AddMandatoryPolicy( |
| 506 kPolicyProxyMode, | 518 key::kProxyMode, |
| 507 Value::CreateStringValue(ProxyPrefs::kSystemProxyModeName)); | 519 Value::CreateStringValue(ProxyPrefs::kSystemProxyModeName)); |
| 508 | 520 |
| 509 scoped_refptr<ConfigurationPolicyPrefStore> store( | 521 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 510 new ConfigurationPolicyPrefStore(&provider)); | 522 new ConfigurationPolicyPrefStore(&provider)); |
| 511 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM); | 523 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM); |
| 512 } | 524 } |
| 513 | 525 |
| 514 TEST_F(ConfigurationPolicyPrefStoreProxyTest, | 526 TEST_F(ConfigurationPolicyPrefStoreProxyTest, |
| 515 ProxyModeOverridesProxyServerMode) { | 527 ProxyModeOverridesProxyServerMode) { |
| 516 MockConfigurationPolicyProvider provider; | 528 MockConfigurationPolicyProvider provider; |
| 517 provider.AddPolicy(kPolicyProxyServerMode, | 529 provider.AddMandatoryPolicy( |
| 518 Value::CreateIntegerValue(kPolicyNoProxyServerMode)); | 530 key::kProxyServerMode, |
| 519 provider.AddPolicy( | 531 Value::CreateIntegerValue(ProxyPolicyHandler::PROXY_SERVER_MODE)); |
| 520 kPolicyProxyMode, | 532 provider.AddMandatoryPolicy( |
| 533 key::kProxyMode, | |
| 521 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName)); | 534 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName)); |
| 522 | 535 |
| 523 scoped_refptr<ConfigurationPolicyPrefStore> store( | 536 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 524 new ConfigurationPolicyPrefStore(&provider)); | 537 new ConfigurationPolicyPrefStore(&provider)); |
| 525 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); | 538 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); |
| 526 } | 539 } |
| 527 | 540 |
| 528 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ProxyInvalid) { | 541 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ProxyInvalid) { |
| 529 for (int i = 0; i < MODE_COUNT; ++i) { | 542 for (int i = 0; i < ProxyPolicyHandler::MODE_COUNT; ++i) { |
| 530 MockConfigurationPolicyProvider provider; | 543 MockConfigurationPolicyProvider provider; |
| 531 provider.AddPolicy(kPolicyProxyServerMode, Value::CreateIntegerValue(i)); | 544 provider.AddMandatoryPolicy(key::kProxyServerMode, |
| 545 Value::CreateIntegerValue(i)); | |
| 532 // No mode expects all three parameters being set. | 546 // No mode expects all three parameters being set. |
| 533 provider.AddPolicy(kPolicyProxyPacUrl, | 547 provider.AddMandatoryPolicy( |
| 534 Value::CreateStringValue("http://short.org/proxy.pac")); | 548 key::kProxyPacUrl, |
| 535 provider.AddPolicy(kPolicyProxyBypassList, | 549 Value::CreateStringValue("http://short.org/proxy.pac")); |
| 536 Value::CreateStringValue( | 550 provider.AddMandatoryPolicy( |
| 537 "http://chromium.org/override")); | 551 key::kProxyBypassList, |
| 538 provider.AddPolicy(kPolicyProxyServer, | 552 Value::CreateStringValue("http://chromium.org/override")); |
| 539 Value::CreateStringValue("chromium.org")); | 553 provider.AddMandatoryPolicy(key::kProxyServer, |
| 554 Value::CreateStringValue("chromium.org")); | |
| 540 | 555 |
| 541 scoped_refptr<ConfigurationPolicyPrefStore> store( | 556 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 542 new ConfigurationPolicyPrefStore(&provider)); | 557 new ConfigurationPolicyPrefStore(&provider)); |
| 543 const Value* value = NULL; | 558 const Value* value = NULL; |
| 544 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 559 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 545 store->GetValue(prefs::kProxy, &value)); | 560 store->GetValue(prefs::kProxy, &value)); |
| 546 } | 561 } |
| 547 } | 562 } |
| 548 | 563 |
| 564 TEST_F(ConfigurationPolicyPrefStoreProxyTest, MergePoliciesDifferentLevels) { | |
| 565 MockConfigurationPolicyProvider provider; | |
| 566 provider.AddMandatoryPolicy( | |
| 567 key::kProxyServerMode, | |
| 568 Value::CreateIntegerValue(ProxyPolicyHandler::PROXY_SERVER_MODE)); | |
| 569 | |
| 570 // Both these policies should be ignored, since there's a higher priority | |
| 571 // policy available. | |
| 572 provider.AddRecommendedPolicy( | |
| 573 key::kProxyMode, | |
| 574 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); | |
| 575 provider.AddRecommendedPolicy( | |
| 576 key::kProxyPacUrl, | |
| 577 Value::CreateStringValue("http://proxy.example.com/wpad.dat")); | |
| 578 | |
| 579 scoped_refptr<ConfigurationPolicyPrefStore> store( | |
| 580 new ConfigurationPolicyPrefStore(&provider)); | |
|
Mattias Nissler (ping if slow)
2012/01/19 12:58:36
Hm, this does a lot more than just testing the mer
Joao da Silva
2012/01/19 16:21:41
PolicyMap is meant to be more generic, as discusse
| |
| 581 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT); | |
| 582 } | |
| 583 | |
| 549 class ConfigurationPolicyPrefStoreDefaultSearchTest : public testing::Test { | 584 class ConfigurationPolicyPrefStoreDefaultSearchTest : public testing::Test { |
| 550 }; | 585 }; |
| 551 | 586 |
| 552 // Checks that if the policy for default search is valid, i.e. there's a | 587 // Checks that if the policy for default search is valid, i.e. there's a |
| 553 // search URL, that all the elements have been given proper defaults. | 588 // search URL, that all the elements have been given proper defaults. |
| 554 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) { | 589 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) { |
| 555 const char* const search_url = "http://test.com/search?t={searchTerms}"; | 590 const char* const search_url = "http://test.com/search?t={searchTerms}"; |
| 556 MockConfigurationPolicyProvider provider; | 591 MockConfigurationPolicyProvider provider; |
| 557 provider.AddPolicy(kPolicyDefaultSearchProviderEnabled, | 592 provider.AddMandatoryPolicy(key::kDefaultSearchProviderEnabled, |
| 558 Value::CreateBooleanValue(true)); | 593 Value::CreateBooleanValue(true)); |
| 559 provider.AddPolicy(kPolicyDefaultSearchProviderSearchURL, | 594 provider.AddMandatoryPolicy(key::kDefaultSearchProviderSearchURL, |
| 560 Value::CreateStringValue(search_url)); | 595 Value::CreateStringValue(search_url)); |
| 561 | 596 |
| 562 scoped_refptr<ConfigurationPolicyPrefStore> store( | 597 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 563 new ConfigurationPolicyPrefStore(&provider)); | 598 new ConfigurationPolicyPrefStore(&provider)); |
| 564 | 599 |
| 565 const Value* value = NULL; | 600 const Value* value = NULL; |
| 566 EXPECT_EQ(PrefStore::READ_OK, | 601 EXPECT_EQ(PrefStore::READ_OK, |
| 567 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value)); | 602 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value)); |
| 568 EXPECT_TRUE(StringValue(search_url).Equals(value)); | 603 EXPECT_TRUE(StringValue(search_url).Equals(value)); |
| 569 | 604 |
| 570 EXPECT_EQ(PrefStore::READ_OK, | 605 EXPECT_EQ(PrefStore::READ_OK, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 597 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, FullyDefined) { | 632 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, FullyDefined) { |
| 598 const char* const search_url = "http://test.com/search?t={searchTerms}"; | 633 const char* const search_url = "http://test.com/search?t={searchTerms}"; |
| 599 const char* const suggest_url = "http://test.com/sugg?={searchTerms}"; | 634 const char* const suggest_url = "http://test.com/sugg?={searchTerms}"; |
| 600 const char* const icon_url = "http://test.com/icon.jpg"; | 635 const char* const icon_url = "http://test.com/icon.jpg"; |
| 601 const char* const name = "MyName"; | 636 const char* const name = "MyName"; |
| 602 const char* const keyword = "MyKeyword"; | 637 const char* const keyword = "MyKeyword"; |
| 603 ListValue* encodings = new ListValue(); | 638 ListValue* encodings = new ListValue(); |
| 604 encodings->Append(Value::CreateStringValue("UTF-16")); | 639 encodings->Append(Value::CreateStringValue("UTF-16")); |
| 605 encodings->Append(Value::CreateStringValue("UTF-8")); | 640 encodings->Append(Value::CreateStringValue("UTF-8")); |
| 606 MockConfigurationPolicyProvider provider; | 641 MockConfigurationPolicyProvider provider; |
| 607 provider.AddPolicy(kPolicyDefaultSearchProviderEnabled, | 642 provider.AddMandatoryPolicy(key::kDefaultSearchProviderEnabled, |
| 608 Value::CreateBooleanValue(true)); | 643 Value::CreateBooleanValue(true)); |
| 609 provider.AddPolicy(kPolicyDefaultSearchProviderSearchURL, | 644 provider.AddMandatoryPolicy(key::kDefaultSearchProviderSearchURL, |
| 610 Value::CreateStringValue(search_url)); | 645 Value::CreateStringValue(search_url)); |
| 611 provider.AddPolicy(kPolicyDefaultSearchProviderName, | 646 provider.AddMandatoryPolicy(key::kDefaultSearchProviderName, |
| 612 Value::CreateStringValue(name)); | 647 Value::CreateStringValue(name)); |
| 613 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword, | 648 provider.AddMandatoryPolicy(key::kDefaultSearchProviderKeyword, |
| 614 Value::CreateStringValue(keyword)); | 649 Value::CreateStringValue(keyword)); |
| 615 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL, | 650 provider.AddMandatoryPolicy(key::kDefaultSearchProviderSuggestURL, |
| 616 Value::CreateStringValue(suggest_url)); | 651 Value::CreateStringValue(suggest_url)); |
| 617 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL, | 652 provider.AddMandatoryPolicy(key::kDefaultSearchProviderIconURL, |
| 618 Value::CreateStringValue(icon_url)); | 653 Value::CreateStringValue(icon_url)); |
| 619 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings); | 654 provider.AddMandatoryPolicy(key::kDefaultSearchProviderEncodings, encodings); |
| 620 | 655 |
| 621 scoped_refptr<ConfigurationPolicyPrefStore> store( | 656 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 622 new ConfigurationPolicyPrefStore(&provider)); | 657 new ConfigurationPolicyPrefStore(&provider)); |
| 623 | 658 |
| 624 const Value* value = NULL; | 659 const Value* value = NULL; |
| 625 EXPECT_EQ(PrefStore::READ_OK, | 660 EXPECT_EQ(PrefStore::READ_OK, |
| 626 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value)); | 661 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value)); |
| 627 EXPECT_TRUE(StringValue(search_url).Equals(value)); | 662 EXPECT_TRUE(StringValue(search_url).Equals(value)); |
| 628 | 663 |
| 629 EXPECT_EQ(PrefStore::READ_OK, | 664 EXPECT_EQ(PrefStore::READ_OK, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 651 // default search policy will be present. | 686 // default search policy will be present. |
| 652 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MissingUrl) { | 687 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MissingUrl) { |
| 653 const char* const suggest_url = "http://test.com/sugg?t={searchTerms}"; | 688 const char* const suggest_url = "http://test.com/sugg?t={searchTerms}"; |
| 654 const char* const icon_url = "http://test.com/icon.jpg"; | 689 const char* const icon_url = "http://test.com/icon.jpg"; |
| 655 const char* const name = "MyName"; | 690 const char* const name = "MyName"; |
| 656 const char* const keyword = "MyKeyword"; | 691 const char* const keyword = "MyKeyword"; |
| 657 ListValue* encodings = new ListValue(); | 692 ListValue* encodings = new ListValue(); |
| 658 encodings->Append(Value::CreateStringValue("UTF-16")); | 693 encodings->Append(Value::CreateStringValue("UTF-16")); |
| 659 encodings->Append(Value::CreateStringValue("UTF-8")); | 694 encodings->Append(Value::CreateStringValue("UTF-8")); |
| 660 MockConfigurationPolicyProvider provider; | 695 MockConfigurationPolicyProvider provider; |
| 661 provider.AddPolicy(kPolicyDefaultSearchProviderEnabled, | 696 provider.AddMandatoryPolicy(key::kDefaultSearchProviderEnabled, |
| 662 Value::CreateBooleanValue(true)); | 697 Value::CreateBooleanValue(true)); |
| 663 provider.AddPolicy(kPolicyDefaultSearchProviderName, | 698 provider.AddMandatoryPolicy(key::kDefaultSearchProviderName, |
| 664 Value::CreateStringValue(name)); | 699 Value::CreateStringValue(name)); |
| 665 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword, | 700 provider.AddMandatoryPolicy(key::kDefaultSearchProviderKeyword, |
| 666 Value::CreateStringValue(keyword)); | 701 Value::CreateStringValue(keyword)); |
| 667 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL, | 702 provider.AddMandatoryPolicy(key::kDefaultSearchProviderSuggestURL, |
| 668 Value::CreateStringValue(suggest_url)); | 703 Value::CreateStringValue(suggest_url)); |
| 669 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL, | 704 provider.AddMandatoryPolicy(key::kDefaultSearchProviderIconURL, |
| 670 Value::CreateStringValue(icon_url)); | 705 Value::CreateStringValue(icon_url)); |
| 671 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings); | 706 provider.AddMandatoryPolicy(key::kDefaultSearchProviderEncodings, encodings); |
| 672 | 707 |
| 673 scoped_refptr<ConfigurationPolicyPrefStore> store( | 708 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 674 new ConfigurationPolicyPrefStore(&provider)); | 709 new ConfigurationPolicyPrefStore(&provider)); |
| 675 | 710 |
| 676 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 711 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 677 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL)); | 712 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL)); |
| 678 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 713 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 679 store->GetValue(prefs::kDefaultSearchProviderName, NULL)); | 714 store->GetValue(prefs::kDefaultSearchProviderName, NULL)); |
| 680 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 715 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 681 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL)); | 716 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 692 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, Invalid) { | 727 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, Invalid) { |
| 693 const char* const bad_search_url = "http://test.com/noSearchTerms"; | 728 const char* const bad_search_url = "http://test.com/noSearchTerms"; |
| 694 const char* const suggest_url = "http://test.com/sugg?t={searchTerms}"; | 729 const char* const suggest_url = "http://test.com/sugg?t={searchTerms}"; |
| 695 const char* const icon_url = "http://test.com/icon.jpg"; | 730 const char* const icon_url = "http://test.com/icon.jpg"; |
| 696 const char* const name = "MyName"; | 731 const char* const name = "MyName"; |
| 697 const char* const keyword = "MyKeyword"; | 732 const char* const keyword = "MyKeyword"; |
| 698 ListValue* encodings = new ListValue(); | 733 ListValue* encodings = new ListValue(); |
| 699 encodings->Append(Value::CreateStringValue("UTF-16")); | 734 encodings->Append(Value::CreateStringValue("UTF-16")); |
| 700 encodings->Append(Value::CreateStringValue("UTF-8")); | 735 encodings->Append(Value::CreateStringValue("UTF-8")); |
| 701 MockConfigurationPolicyProvider provider; | 736 MockConfigurationPolicyProvider provider; |
| 702 provider.AddPolicy(kPolicyDefaultSearchProviderEnabled, | 737 provider.AddMandatoryPolicy(key::kDefaultSearchProviderEnabled, |
| 703 Value::CreateBooleanValue(true)); | 738 Value::CreateBooleanValue(true)); |
| 704 provider.AddPolicy(kPolicyDefaultSearchProviderSearchURL, | 739 provider.AddMandatoryPolicy(key::kDefaultSearchProviderSearchURL, |
| 705 Value::CreateStringValue(bad_search_url)); | 740 Value::CreateStringValue(bad_search_url)); |
| 706 provider.AddPolicy(kPolicyDefaultSearchProviderName, | 741 provider.AddMandatoryPolicy(key::kDefaultSearchProviderName, |
| 707 Value::CreateStringValue(name)); | 742 Value::CreateStringValue(name)); |
| 708 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword, | 743 provider.AddMandatoryPolicy(key::kDefaultSearchProviderKeyword, |
| 709 Value::CreateStringValue(keyword)); | 744 Value::CreateStringValue(keyword)); |
| 710 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL, | 745 provider.AddMandatoryPolicy(key::kDefaultSearchProviderSuggestURL, |
| 711 Value::CreateStringValue(suggest_url)); | 746 Value::CreateStringValue(suggest_url)); |
| 712 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL, | 747 provider.AddMandatoryPolicy(key::kDefaultSearchProviderIconURL, |
| 713 Value::CreateStringValue(icon_url)); | 748 Value::CreateStringValue(icon_url)); |
| 714 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings); | 749 provider.AddMandatoryPolicy(key::kDefaultSearchProviderEncodings, encodings); |
| 715 | 750 |
| 716 scoped_refptr<ConfigurationPolicyPrefStore> store( | 751 scoped_refptr<ConfigurationPolicyPrefStore> store( |
| 717 new ConfigurationPolicyPrefStore(&provider)); | 752 new ConfigurationPolicyPrefStore(&provider)); |
| 718 | 753 |
| 719 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 754 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 720 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL)); | 755 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL)); |
| 721 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 756 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 722 store->GetValue(prefs::kDefaultSearchProviderName, NULL)); | 757 store->GetValue(prefs::kDefaultSearchProviderName, NULL)); |
| 723 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 758 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 724 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL)); | 759 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL)); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 737 | 772 |
| 738 enum ObsoleteIncognitoEnabledValue { | 773 enum ObsoleteIncognitoEnabledValue { |
| 739 INCOGNITO_ENABLED_UNKNOWN, | 774 INCOGNITO_ENABLED_UNKNOWN, |
| 740 INCOGNITO_ENABLED_TRUE, | 775 INCOGNITO_ENABLED_TRUE, |
| 741 INCOGNITO_ENABLED_FALSE | 776 INCOGNITO_ENABLED_FALSE |
| 742 }; | 777 }; |
| 743 | 778 |
| 744 void SetPolicies(ObsoleteIncognitoEnabledValue incognito_enabled, | 779 void SetPolicies(ObsoleteIncognitoEnabledValue incognito_enabled, |
| 745 int availability) { | 780 int availability) { |
| 746 if (incognito_enabled != INCOGNITO_ENABLED_UNKNOWN) { | 781 if (incognito_enabled != INCOGNITO_ENABLED_UNKNOWN) { |
| 747 provider_.AddPolicy(kPolicyIncognitoEnabled, | 782 provider_.AddMandatoryPolicy( |
| 748 Value::CreateBooleanValue( | 783 key::kIncognitoEnabled, |
| 749 incognito_enabled == INCOGNITO_ENABLED_TRUE)); | 784 Value::CreateBooleanValue( |
| 785 incognito_enabled == INCOGNITO_ENABLED_TRUE)); | |
| 750 } | 786 } |
| 751 if (availability >= 0) { | 787 if (availability >= 0) { |
| 752 provider_.AddPolicy(kPolicyIncognitoModeAvailability, | 788 provider_.AddMandatoryPolicy(key::kIncognitoModeAvailability, |
| 753 Value::CreateIntegerValue(availability)); | 789 Value::CreateIntegerValue(availability)); |
| 754 } | 790 } |
| 755 store_ = new ConfigurationPolicyPrefStore(&provider_); | 791 store_ = new ConfigurationPolicyPrefStore(&provider_); |
| 756 } | 792 } |
| 757 | 793 |
| 758 void VerifyValues(IncognitoModePrefs::Availability availability) { | 794 void VerifyValues(IncognitoModePrefs::Availability availability) { |
| 759 const Value* value = NULL; | 795 const Value* value = NULL; |
| 760 EXPECT_EQ(PrefStore::READ_OK, | 796 EXPECT_EQ(PrefStore::READ_OK, |
| 761 store_->GetValue(prefs::kIncognitoModeAvailability, &value)); | 797 store_->GetValue(prefs::kIncognitoModeAvailability, &value)); |
| 762 EXPECT_TRUE(base::FundamentalValue(availability).Equals(value)); | 798 EXPECT_TRUE(base::FundamentalValue(availability).Equals(value)); |
| 763 } | 799 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 826 class ConfigurationPolicyPrefStoreSyncTest | 862 class ConfigurationPolicyPrefStoreSyncTest |
| 827 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { | 863 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { |
| 828 }; | 864 }; |
| 829 | 865 |
| 830 TEST_F(ConfigurationPolicyPrefStoreSyncTest, Default) { | 866 TEST_F(ConfigurationPolicyPrefStoreSyncTest, Default) { |
| 831 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 867 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 832 store_->GetValue(prefs::kSyncManaged, NULL)); | 868 store_->GetValue(prefs::kSyncManaged, NULL)); |
| 833 } | 869 } |
| 834 | 870 |
| 835 TEST_F(ConfigurationPolicyPrefStoreSyncTest, Enabled) { | 871 TEST_F(ConfigurationPolicyPrefStoreSyncTest, Enabled) { |
| 836 provider_.AddPolicy(kPolicySyncDisabled, Value::CreateBooleanValue(false)); | 872 provider_.AddMandatoryPolicy(key::kSyncDisabled, |
| 873 Value::CreateBooleanValue(false)); | |
| 837 store_->OnUpdatePolicy(&provider_); | 874 store_->OnUpdatePolicy(&provider_); |
| 838 // Enabling Sync should not set the pref. | 875 // Enabling Sync should not set the pref. |
| 839 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 876 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 840 store_->GetValue(prefs::kSyncManaged, NULL)); | 877 store_->GetValue(prefs::kSyncManaged, NULL)); |
| 841 } | 878 } |
| 842 | 879 |
| 843 TEST_F(ConfigurationPolicyPrefStoreSyncTest, Disabled) { | 880 TEST_F(ConfigurationPolicyPrefStoreSyncTest, Disabled) { |
| 844 provider_.AddPolicy(kPolicySyncDisabled, Value::CreateBooleanValue(true)); | 881 provider_.AddMandatoryPolicy(key::kSyncDisabled, |
| 882 Value::CreateBooleanValue(true)); | |
| 845 store_->OnUpdatePolicy(&provider_); | 883 store_->OnUpdatePolicy(&provider_); |
| 846 // Sync should be flagged as managed. | 884 // Sync should be flagged as managed. |
| 847 const Value* value = NULL; | 885 const Value* value = NULL; |
| 848 EXPECT_EQ(PrefStore::READ_OK, store_->GetValue(prefs::kSyncManaged, &value)); | 886 EXPECT_EQ(PrefStore::READ_OK, store_->GetValue(prefs::kSyncManaged, &value)); |
| 849 ASSERT_TRUE(value); | 887 ASSERT_TRUE(value); |
| 850 bool sync_managed = false; | 888 bool sync_managed = false; |
| 851 bool result = value->GetAsBoolean(&sync_managed); | 889 bool result = value->GetAsBoolean(&sync_managed); |
| 852 ASSERT_TRUE(result); | 890 ASSERT_TRUE(result); |
| 853 EXPECT_TRUE(sync_managed); | 891 EXPECT_TRUE(sync_managed); |
| 854 } | 892 } |
| 855 | 893 |
| 856 // Test cases for how the DownloadDirectory and AllowFileSelectionDialogs policy | 894 // Test cases for how the DownloadDirectory and AllowFileSelectionDialogs policy |
| 857 // influence the PromptForDownload preference. | 895 // influence the PromptForDownload preference. |
| 858 class ConfigurationPolicyPrefStorePromptDownloadTest | 896 class ConfigurationPolicyPrefStorePromptDownloadTest |
| 859 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { | 897 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { |
| 860 }; | 898 }; |
| 861 | 899 |
| 862 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, Default) { | 900 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, Default) { |
| 863 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 901 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 864 store_->GetValue(prefs::kPromptForDownload, NULL)); | 902 store_->GetValue(prefs::kPromptForDownload, NULL)); |
| 865 } | 903 } |
| 866 | 904 |
| 867 #if !defined(OS_CHROMEOS) | 905 #if !defined(OS_CHROMEOS) |
| 868 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, SetDownloadDirectory) { | 906 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, SetDownloadDirectory) { |
| 869 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 907 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 870 store_->GetValue(prefs::kPromptForDownload, NULL)); | 908 store_->GetValue(prefs::kPromptForDownload, NULL)); |
| 871 provider_.AddPolicy(kPolicyDownloadDirectory, Value::CreateStringValue("")); | 909 provider_.AddMandatoryPolicy(key::kDownloadDirectory, |
| 910 Value::CreateStringValue("")); | |
| 872 store_->OnUpdatePolicy(&provider_); | 911 store_->OnUpdatePolicy(&provider_); |
| 873 | 912 |
| 874 // Setting a DownloadDirectory should disable the PromptForDownload pref. | 913 // Setting a DownloadDirectory should disable the PromptForDownload pref. |
| 875 const Value* value = NULL; | 914 const Value* value = NULL; |
| 876 EXPECT_EQ(PrefStore::READ_OK, store_->GetValue(prefs::kPromptForDownload, | 915 EXPECT_EQ(PrefStore::READ_OK, store_->GetValue(prefs::kPromptForDownload, |
| 877 &value)); | 916 &value)); |
| 878 ASSERT_TRUE(value); | 917 ASSERT_TRUE(value); |
| 879 bool prompt_for_download = true; | 918 bool prompt_for_download = true; |
| 880 bool result = value->GetAsBoolean(&prompt_for_download); | 919 bool result = value->GetAsBoolean(&prompt_for_download); |
| 881 ASSERT_TRUE(result); | 920 ASSERT_TRUE(result); |
| 882 EXPECT_FALSE(prompt_for_download); | 921 EXPECT_FALSE(prompt_for_download); |
| 883 } | 922 } |
| 884 #endif // !defined(OS_CHROMEOS) | 923 #endif // !defined(OS_CHROMEOS) |
| 885 | 924 |
| 886 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, | 925 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, |
| 887 EnableFileSelectionDialogs) { | 926 EnableFileSelectionDialogs) { |
| 888 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 927 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 889 store_->GetValue(prefs::kPromptForDownload, NULL)); | 928 store_->GetValue(prefs::kPromptForDownload, NULL)); |
| 890 provider_.AddPolicy(kPolicyAllowFileSelectionDialogs, | 929 provider_.AddMandatoryPolicy(key::kAllowFileSelectionDialogs, |
| 891 Value::CreateBooleanValue(true)); | 930 Value::CreateBooleanValue(true)); |
| 892 store_->OnUpdatePolicy(&provider_); | 931 store_->OnUpdatePolicy(&provider_); |
| 893 | 932 |
| 894 // Allowing file-selection dialogs should not influence the PromptForDownload | 933 // Allowing file-selection dialogs should not influence the PromptForDownload |
| 895 // pref. | 934 // pref. |
| 896 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 935 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 897 store_->GetValue(prefs::kPromptForDownload, NULL)); | 936 store_->GetValue(prefs::kPromptForDownload, NULL)); |
| 898 } | 937 } |
| 899 | 938 |
| 900 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, | 939 TEST_F(ConfigurationPolicyPrefStorePromptDownloadTest, |
| 901 DisableFileSelectionDialogs) { | 940 DisableFileSelectionDialogs) { |
| 902 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 941 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 903 store_->GetValue(prefs::kPromptForDownload, NULL)); | 942 store_->GetValue(prefs::kPromptForDownload, NULL)); |
| 904 provider_.AddPolicy(kPolicyAllowFileSelectionDialogs, | 943 provider_.AddMandatoryPolicy(key::kAllowFileSelectionDialogs, |
| 905 Value::CreateBooleanValue(false)); | 944 Value::CreateBooleanValue(false)); |
| 906 store_->OnUpdatePolicy(&provider_); | 945 store_->OnUpdatePolicy(&provider_); |
| 907 | 946 |
| 908 // Disabling file-selection dialogs should disable the PromptForDownload pref. | 947 // Disabling file-selection dialogs should disable the PromptForDownload pref. |
| 909 const Value* value = NULL; | 948 const Value* value = NULL; |
| 910 EXPECT_EQ(PrefStore::READ_OK, store_->GetValue(prefs::kPromptForDownload, | 949 EXPECT_EQ(PrefStore::READ_OK, store_->GetValue(prefs::kPromptForDownload, |
| 911 &value)); | 950 &value)); |
| 912 ASSERT_TRUE(value); | 951 ASSERT_TRUE(value); |
| 913 bool prompt_for_download = true; | 952 bool prompt_for_download = true; |
| 914 bool result = value->GetAsBoolean(&prompt_for_download); | 953 bool result = value->GetAsBoolean(&prompt_for_download); |
| 915 ASSERT_TRUE(result); | 954 ASSERT_TRUE(result); |
| 916 EXPECT_FALSE(prompt_for_download); | 955 EXPECT_FALSE(prompt_for_download); |
| 917 } | 956 } |
| 918 | 957 |
| 919 // Test cases for the Autofill policy setting. | 958 // Test cases for the Autofill policy setting. |
| 920 class ConfigurationPolicyPrefStoreAutofillTest | 959 class ConfigurationPolicyPrefStoreAutofillTest |
| 921 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { | 960 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { |
| 922 }; | 961 }; |
| 923 | 962 |
| 924 TEST_F(ConfigurationPolicyPrefStoreAutofillTest, Default) { | 963 TEST_F(ConfigurationPolicyPrefStoreAutofillTest, Default) { |
| 925 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 964 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 926 store_->GetValue(prefs::kAutofillEnabled, NULL)); | 965 store_->GetValue(prefs::kAutofillEnabled, NULL)); |
| 927 } | 966 } |
| 928 | 967 |
| 929 TEST_F(ConfigurationPolicyPrefStoreAutofillTest, Enabled) { | 968 TEST_F(ConfigurationPolicyPrefStoreAutofillTest, Enabled) { |
| 930 provider_.AddPolicy(kPolicyAutoFillEnabled, Value::CreateBooleanValue(true)); | 969 provider_.AddMandatoryPolicy(key::kAutoFillEnabled, |
| 970 Value::CreateBooleanValue(true)); | |
| 931 store_->OnUpdatePolicy(&provider_); | 971 store_->OnUpdatePolicy(&provider_); |
| 932 // Enabling Autofill should not set the pref. | 972 // Enabling Autofill should not set the pref. |
| 933 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 973 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 934 store_->GetValue(prefs::kAutofillEnabled, NULL)); | 974 store_->GetValue(prefs::kAutofillEnabled, NULL)); |
| 935 } | 975 } |
| 936 | 976 |
| 937 TEST_F(ConfigurationPolicyPrefStoreAutofillTest, Disabled) { | 977 TEST_F(ConfigurationPolicyPrefStoreAutofillTest, Disabled) { |
| 938 provider_.AddPolicy(kPolicyAutoFillEnabled, Value::CreateBooleanValue(false)); | 978 provider_.AddMandatoryPolicy(key::kAutoFillEnabled, |
| 979 Value::CreateBooleanValue(false)); | |
| 939 store_->OnUpdatePolicy(&provider_); | 980 store_->OnUpdatePolicy(&provider_); |
| 940 // Disabling Autofill should switch the pref to managed. | 981 // Disabling Autofill should switch the pref to managed. |
| 941 const Value* value = NULL; | 982 const Value* value = NULL; |
| 942 EXPECT_EQ(PrefStore::READ_OK, | 983 EXPECT_EQ(PrefStore::READ_OK, |
| 943 store_->GetValue(prefs::kAutofillEnabled, &value)); | 984 store_->GetValue(prefs::kAutofillEnabled, &value)); |
| 944 ASSERT_TRUE(value); | 985 ASSERT_TRUE(value); |
| 945 bool autofill_enabled = true; | 986 bool autofill_enabled = true; |
| 946 bool result = value->GetAsBoolean(&autofill_enabled); | 987 bool result = value->GetAsBoolean(&autofill_enabled); |
| 947 ASSERT_TRUE(result); | 988 ASSERT_TRUE(result); |
| 948 EXPECT_FALSE(autofill_enabled); | 989 EXPECT_FALSE(autofill_enabled); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 962 | 1003 |
| 963 PrefStoreObserverMock observer_; | 1004 PrefStoreObserverMock observer_; |
| 964 }; | 1005 }; |
| 965 | 1006 |
| 966 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { | 1007 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Refresh) { |
| 967 const Value* value = NULL; | 1008 const Value* value = NULL; |
| 968 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 1009 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 969 store_->GetValue(prefs::kHomePage, NULL)); | 1010 store_->GetValue(prefs::kHomePage, NULL)); |
| 970 | 1011 |
| 971 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); | 1012 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); |
| 972 provider_.AddPolicy(kPolicyHomepageLocation, | 1013 provider_.AddMandatoryPolicy( |
| 973 Value::CreateStringValue("http://www.chromium.org")); | 1014 key::kHomepageLocation, |
| 1015 Value::CreateStringValue("http://www.chromium.org")); | |
| 974 store_->OnUpdatePolicy(&provider_); | 1016 store_->OnUpdatePolicy(&provider_); |
| 975 Mock::VerifyAndClearExpectations(&observer_); | 1017 Mock::VerifyAndClearExpectations(&observer_); |
| 976 EXPECT_EQ(PrefStore::READ_OK, | 1018 EXPECT_EQ(PrefStore::READ_OK, |
| 977 store_->GetValue(prefs::kHomePage, &value)); | 1019 store_->GetValue(prefs::kHomePage, &value)); |
| 978 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value)); | 1020 EXPECT_TRUE(StringValue("http://www.chromium.org").Equals(value)); |
| 979 | 1021 |
| 980 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0); | 1022 EXPECT_CALL(observer_, OnPrefValueChanged(_)).Times(0); |
| 981 store_->OnUpdatePolicy(&provider_); | 1023 store_->OnUpdatePolicy(&provider_); |
| 982 Mock::VerifyAndClearExpectations(&observer_); | 1024 Mock::VerifyAndClearExpectations(&observer_); |
| 983 | 1025 |
| 984 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); | 1026 EXPECT_CALL(observer_, OnPrefValueChanged(prefs::kHomePage)).Times(1); |
| 985 provider_.RemovePolicy(kPolicyHomepageLocation); | 1027 provider_.RemovePolicy(key::kHomepageLocation); |
| 986 store_->OnUpdatePolicy(&provider_); | 1028 store_->OnUpdatePolicy(&provider_); |
| 987 Mock::VerifyAndClearExpectations(&observer_); | 1029 Mock::VerifyAndClearExpectations(&observer_); |
| 988 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 1030 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 989 store_->GetValue(prefs::kHomePage, NULL)); | 1031 store_->GetValue(prefs::kHomePage, NULL)); |
| 990 } | 1032 } |
| 991 | 1033 |
| 992 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) { | 1034 TEST_F(ConfigurationPolicyPrefStoreRefreshTest, Initialization) { |
| 993 EXPECT_FALSE(store_->IsInitializationComplete()); | 1035 EXPECT_FALSE(store_->IsInitializationComplete()); |
| 994 | 1036 |
| 995 EXPECT_CALL(observer_, OnInitializationCompleted(true)).Times(1); | 1037 EXPECT_CALL(observer_, OnInitializationCompleted(true)).Times(1); |
| 996 | 1038 |
| 997 provider_.SetInitializationComplete(true); | 1039 provider_.SetInitializationComplete(true); |
| 998 EXPECT_FALSE(store_->IsInitializationComplete()); | 1040 EXPECT_FALSE(store_->IsInitializationComplete()); |
| 999 | 1041 |
| 1000 store_->OnUpdatePolicy(&provider_); | 1042 store_->OnUpdatePolicy(&provider_); |
| 1001 Mock::VerifyAndClearExpectations(&observer_); | 1043 Mock::VerifyAndClearExpectations(&observer_); |
| 1002 EXPECT_TRUE(store_->IsInitializationComplete()); | 1044 EXPECT_TRUE(store_->IsInitializationComplete()); |
| 1003 } | 1045 } |
| 1004 | 1046 |
| 1005 // Tests for policies that don't quite fit the previous patterns. | 1047 // Tests for policies that don't quite fit the previous patterns. |
| 1006 class ConfigurationPolicyPrefStoreOthersTest | 1048 class ConfigurationPolicyPrefStoreOthersTest |
| 1007 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { | 1049 : public ConfigurationPolicyPrefStoreTestBase<testing::Test> { |
| 1008 }; | 1050 }; |
| 1009 | 1051 |
| 1010 TEST_F(ConfigurationPolicyPrefStoreOthersTest, JavascriptEnabled) { | 1052 TEST_F(ConfigurationPolicyPrefStoreOthersTest, JavascriptEnabled) { |
| 1011 // This is a boolean policy, but affects an integer preference. | 1053 // This is a boolean policy, but affects an integer preference. |
| 1012 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 1054 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 1013 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); | 1055 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); |
| 1014 provider_.AddPolicy(kPolicyJavascriptEnabled, | 1056 provider_.AddMandatoryPolicy(key::kJavascriptEnabled, |
| 1015 Value::CreateBooleanValue(true)); | 1057 Value::CreateBooleanValue(true)); |
| 1016 store_->OnUpdatePolicy(&provider_); | 1058 store_->OnUpdatePolicy(&provider_); |
| 1017 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 1059 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 1018 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); | 1060 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); |
| 1019 provider_.AddPolicy(kPolicyJavascriptEnabled, | 1061 provider_.AddMandatoryPolicy(key::kJavascriptEnabled, |
| 1020 Value::CreateBooleanValue(false)); | 1062 Value::CreateBooleanValue(false)); |
| 1021 store_->OnUpdatePolicy(&provider_); | 1063 store_->OnUpdatePolicy(&provider_); |
| 1022 const Value* value = NULL; | 1064 const Value* value = NULL; |
| 1023 EXPECT_EQ(PrefStore::READ_OK, | 1065 EXPECT_EQ(PrefStore::READ_OK, |
| 1024 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value)); | 1066 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value)); |
| 1025 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value)); | 1067 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value)); |
| 1026 } | 1068 } |
| 1027 | 1069 |
| 1028 TEST_F(ConfigurationPolicyPrefStoreOthersTest, JavascriptEnabledOverridden) { | 1070 TEST_F(ConfigurationPolicyPrefStoreOthersTest, JavascriptEnabledOverridden) { |
| 1029 EXPECT_EQ(PrefStore::READ_NO_VALUE, | 1071 EXPECT_EQ(PrefStore::READ_NO_VALUE, |
| 1030 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); | 1072 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, NULL)); |
| 1031 provider_.AddPolicy(kPolicyJavascriptEnabled, | 1073 provider_.AddMandatoryPolicy(key::kJavascriptEnabled, |
| 1032 Value::CreateBooleanValue(false)); | 1074 Value::CreateBooleanValue(false)); |
| 1033 store_->OnUpdatePolicy(&provider_); | 1075 store_->OnUpdatePolicy(&provider_); |
| 1034 const Value* value = NULL; | 1076 const Value* value = NULL; |
| 1035 EXPECT_EQ(PrefStore::READ_OK, | 1077 EXPECT_EQ(PrefStore::READ_OK, |
| 1036 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value)); | 1078 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value)); |
| 1037 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value)); | 1079 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_BLOCK).Equals(value)); |
| 1038 // DefaultJavaScriptSetting overrides JavascriptEnabled. | 1080 // DefaultJavaScriptSetting overrides JavascriptEnabled. |
| 1039 provider_.AddPolicy(kPolicyDefaultJavaScriptSetting, | 1081 provider_.AddMandatoryPolicy( |
| 1040 Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); | 1082 key::kDefaultJavaScriptSetting, |
| 1083 Value::CreateIntegerValue(CONTENT_SETTING_ALLOW)); | |
| 1041 store_->OnUpdatePolicy(&provider_); | 1084 store_->OnUpdatePolicy(&provider_); |
| 1042 EXPECT_EQ(PrefStore::READ_OK, | 1085 EXPECT_EQ(PrefStore::READ_OK, |
| 1043 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value)); | 1086 store_->GetValue(prefs::kManagedDefaultJavaScriptSetting, &value)); |
| 1044 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_ALLOW).Equals(value)); | 1087 EXPECT_TRUE(base::FundamentalValue(CONTENT_SETTING_ALLOW).Equals(value)); |
| 1045 } | 1088 } |
| 1046 | 1089 |
| 1047 } // namespace policy | 1090 } // namespace policy |
| OLD | NEW |