| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/net/proxy_policy_handler.h" | 9 #include "chrome/browser/net/proxy_policy_handler.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 // Verify that all the proxy prefs are set to the specified expected values. | 39 // Verify that all the proxy prefs are set to the specified expected values. |
| 40 void VerifyProxyPrefs( | 40 void VerifyProxyPrefs( |
| 41 const std::string& expected_proxy_server, | 41 const std::string& expected_proxy_server, |
| 42 const std::string& expected_proxy_pac_url, | 42 const std::string& expected_proxy_pac_url, |
| 43 const std::string& expected_proxy_bypass_list, | 43 const std::string& expected_proxy_bypass_list, |
| 44 const ProxyPrefs::ProxyMode& expected_proxy_mode) { | 44 const ProxyPrefs::ProxyMode& expected_proxy_mode) { |
| 45 const base::Value* value = NULL; | 45 const base::Value* value = NULL; |
| 46 ASSERT_TRUE(store_->GetValue(prefs::kProxy, &value)); | 46 ASSERT_TRUE(store_->GetValue(ProxyPrefs::kProxy, &value)); |
| 47 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); | 47 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); |
| 48 ProxyConfigDictionary dict( | 48 ProxyConfigDictionary dict( |
| 49 static_cast<const base::DictionaryValue*>(value)); | 49 static_cast<const base::DictionaryValue*>(value)); |
| 50 std::string s; | 50 std::string s; |
| 51 if (expected_proxy_server.empty()) { | 51 if (expected_proxy_server.empty()) { |
| 52 EXPECT_FALSE(dict.GetProxyServer(&s)); | 52 EXPECT_FALSE(dict.GetProxyServer(&s)); |
| 53 } else { | 53 } else { |
| 54 ASSERT_TRUE(dict.GetProxyServer(&s)); | 54 ASSERT_TRUE(dict.GetProxyServer(&s)); |
| 55 EXPECT_EQ(expected_proxy_server, s); | 55 EXPECT_EQ(expected_proxy_server, s); |
| 56 } | 56 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 policy.Set( | 131 policy.Set( |
| 132 key::kProxyServerMode, | 132 key::kProxyServerMode, |
| 133 POLICY_LEVEL_MANDATORY, | 133 POLICY_LEVEL_MANDATORY, |
| 134 POLICY_SCOPE_USER, | 134 POLICY_SCOPE_USER, |
| 135 new base::FundamentalValue( | 135 new base::FundamentalValue( |
| 136 ProxyPolicyHandler::PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE), | 136 ProxyPolicyHandler::PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE), |
| 137 NULL); | 137 NULL); |
| 138 UpdateProviderPolicy(policy); | 138 UpdateProviderPolicy(policy); |
| 139 | 139 |
| 140 const base::Value* value = NULL; | 140 const base::Value* value = NULL; |
| 141 EXPECT_FALSE(store_->GetValue(prefs::kProxy, &value)); | 141 EXPECT_FALSE(store_->GetValue(ProxyPrefs::kProxy, &value)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST_F(ProxyPolicyHandlerTest, NoProxyServerMode) { | 144 TEST_F(ProxyPolicyHandlerTest, NoProxyServerMode) { |
| 145 PolicyMap policy; | 145 PolicyMap policy; |
| 146 policy.Set(key::kProxyServerMode, | 146 policy.Set(key::kProxyServerMode, |
| 147 POLICY_LEVEL_MANDATORY, | 147 POLICY_LEVEL_MANDATORY, |
| 148 POLICY_SCOPE_USER, | 148 POLICY_SCOPE_USER, |
| 149 new base::FundamentalValue(ProxyPolicyHandler::PROXY_SERVER_MODE), | 149 new base::FundamentalValue(ProxyPolicyHandler::PROXY_SERVER_MODE), |
| 150 NULL); | 150 NULL); |
| 151 UpdateProviderPolicy(policy); | 151 UpdateProviderPolicy(policy); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 215 |
| 216 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeInvalid) { | 216 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeInvalid) { |
| 217 PolicyMap policy; | 217 PolicyMap policy; |
| 218 policy.Set(key::kProxyMode, | 218 policy.Set(key::kProxyMode, |
| 219 POLICY_LEVEL_MANDATORY, | 219 POLICY_LEVEL_MANDATORY, |
| 220 POLICY_SCOPE_USER, | 220 POLICY_SCOPE_USER, |
| 221 new base::StringValue(ProxyPrefs::kPacScriptProxyModeName), | 221 new base::StringValue(ProxyPrefs::kPacScriptProxyModeName), |
| 222 NULL); | 222 NULL); |
| 223 UpdateProviderPolicy(policy); | 223 UpdateProviderPolicy(policy); |
| 224 const base::Value* value = NULL; | 224 const base::Value* value = NULL; |
| 225 EXPECT_FALSE(store_->GetValue(prefs::kProxy, &value)); | 225 EXPECT_FALSE(store_->GetValue(ProxyPrefs::kProxy, &value)); |
| 226 } | 226 } |
| 227 | 227 |
| 228 // Regression test for http://crbug.com/78016, CPanel returns empty strings | 228 // Regression test for http://crbug.com/78016, CPanel returns empty strings |
| 229 // for unset properties. | 229 // for unset properties. |
| 230 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeBug78016) { | 230 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeBug78016) { |
| 231 PolicyMap policy; | 231 PolicyMap policy; |
| 232 policy.Set(key::kProxyServer, | 232 policy.Set(key::kProxyServer, |
| 233 POLICY_LEVEL_MANDATORY, | 233 POLICY_LEVEL_MANDATORY, |
| 234 POLICY_SCOPE_USER, | 234 POLICY_SCOPE_USER, |
| 235 new base::StringValue(std::string()), | 235 new base::StringValue(std::string()), |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 new base::StringValue("chromium.org"), | 315 new base::StringValue("chromium.org"), |
| 316 NULL); | 316 NULL); |
| 317 for (int i = 0; i < ProxyPolicyHandler::MODE_COUNT; ++i) { | 317 for (int i = 0; i < ProxyPolicyHandler::MODE_COUNT; ++i) { |
| 318 policy.Set(key::kProxyServerMode, | 318 policy.Set(key::kProxyServerMode, |
| 319 POLICY_LEVEL_MANDATORY, | 319 POLICY_LEVEL_MANDATORY, |
| 320 POLICY_SCOPE_USER, | 320 POLICY_SCOPE_USER, |
| 321 new base::FundamentalValue(i), | 321 new base::FundamentalValue(i), |
| 322 NULL); | 322 NULL); |
| 323 UpdateProviderPolicy(policy); | 323 UpdateProviderPolicy(policy); |
| 324 const base::Value* value = NULL; | 324 const base::Value* value = NULL; |
| 325 EXPECT_FALSE(store_->GetValue(prefs::kProxy, &value)); | 325 EXPECT_FALSE(store_->GetValue(ProxyPrefs::kProxy, &value)); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace policy | 329 } // namespace policy |
| OLD | NEW |