Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/net/proxy_policy_handler_unittest.cc

Issue 1296663003: Componentize proxy code from chrome/browser/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updating for win p/f Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/net/proxy_policy_handler.cc ('k') | chrome/browser/net/proxy_service_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "components/policy/core/browser/configuration_policy_pref_store.h" 10 #include "components/policy/core/browser/configuration_policy_pref_store.h"
12 #include "components/policy/core/browser/configuration_policy_pref_store_test.h" 11 #include "components/policy/core/browser/configuration_policy_pref_store_test.h"
13 #include "components/policy/core/common/policy_service_impl.h" 12 #include "components/policy/core/common/policy_service_impl.h"
14 #include "components/proxy_config/proxy_config_dictionary.h" 13 #include "components/proxy_config/proxy_config_dictionary.h"
15 #include "components/proxy_config/proxy_prefs.h" 14 #include "components/proxy_config/proxy_config_pref_names.h"
16 #include "policy/policy_constants.h" 15 #include "policy/policy_constants.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 17
19 namespace policy { 18 namespace policy {
20 19
21 // Test cases for the proxy policy settings. 20 // Test cases for the proxy policy settings.
22 class ProxyPolicyHandlerTest 21 class ProxyPolicyHandlerTest
23 : public ConfigurationPolicyPrefStoreTest { 22 : public ConfigurationPolicyPrefStoreTest {
24 public: 23 public:
25 void SetUp() override { 24 void SetUp() override {
(...skipping 10 matching lines...) Expand all
36 } 35 }
37 36
38 protected: 37 protected:
39 // Verify that all the proxy prefs are set to the specified expected values. 38 // Verify that all the proxy prefs are set to the specified expected values.
40 void VerifyProxyPrefs( 39 void VerifyProxyPrefs(
41 const std::string& expected_proxy_server, 40 const std::string& expected_proxy_server,
42 const std::string& expected_proxy_pac_url, 41 const std::string& expected_proxy_pac_url,
43 const std::string& expected_proxy_bypass_list, 42 const std::string& expected_proxy_bypass_list,
44 const ProxyPrefs::ProxyMode& expected_proxy_mode) { 43 const ProxyPrefs::ProxyMode& expected_proxy_mode) {
45 const base::Value* value = NULL; 44 const base::Value* value = NULL;
46 ASSERT_TRUE(store_->GetValue(prefs::kProxy, &value)); 45 ASSERT_TRUE(store_->GetValue(proxy_config::prefs::kProxy, &value));
47 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); 46 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType());
48 ProxyConfigDictionary dict( 47 ProxyConfigDictionary dict(
49 static_cast<const base::DictionaryValue*>(value)); 48 static_cast<const base::DictionaryValue*>(value));
50 std::string s; 49 std::string s;
51 if (expected_proxy_server.empty()) { 50 if (expected_proxy_server.empty()) {
52 EXPECT_FALSE(dict.GetProxyServer(&s)); 51 EXPECT_FALSE(dict.GetProxyServer(&s));
53 } else { 52 } else {
54 ASSERT_TRUE(dict.GetProxyServer(&s)); 53 ASSERT_TRUE(dict.GetProxyServer(&s));
55 EXPECT_EQ(expected_proxy_server, s); 54 EXPECT_EQ(expected_proxy_server, s);
56 } 55 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 policy.Set( 130 policy.Set(
132 key::kProxyServerMode, 131 key::kProxyServerMode,
133 POLICY_LEVEL_MANDATORY, 132 POLICY_LEVEL_MANDATORY,
134 POLICY_SCOPE_USER, 133 POLICY_SCOPE_USER,
135 new base::FundamentalValue( 134 new base::FundamentalValue(
136 ProxyPolicyHandler::PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE), 135 ProxyPolicyHandler::PROXY_MANUALLY_CONFIGURED_PROXY_SERVER_MODE),
137 NULL); 136 NULL);
138 UpdateProviderPolicy(policy); 137 UpdateProviderPolicy(policy);
139 138
140 const base::Value* value = NULL; 139 const base::Value* value = NULL;
141 EXPECT_FALSE(store_->GetValue(prefs::kProxy, &value)); 140 EXPECT_FALSE(store_->GetValue(proxy_config::prefs::kProxy, &value));
142 } 141 }
143 142
144 TEST_F(ProxyPolicyHandlerTest, NoProxyServerMode) { 143 TEST_F(ProxyPolicyHandlerTest, NoProxyServerMode) {
145 PolicyMap policy; 144 PolicyMap policy;
146 policy.Set(key::kProxyServerMode, 145 policy.Set(key::kProxyServerMode,
147 POLICY_LEVEL_MANDATORY, 146 POLICY_LEVEL_MANDATORY,
148 POLICY_SCOPE_USER, 147 POLICY_SCOPE_USER,
149 new base::FundamentalValue(ProxyPolicyHandler::PROXY_SERVER_MODE), 148 new base::FundamentalValue(ProxyPolicyHandler::PROXY_SERVER_MODE),
150 NULL); 149 NULL);
151 UpdateProviderPolicy(policy); 150 UpdateProviderPolicy(policy);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 214
216 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeInvalid) { 215 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeInvalid) {
217 PolicyMap policy; 216 PolicyMap policy;
218 policy.Set(key::kProxyMode, 217 policy.Set(key::kProxyMode,
219 POLICY_LEVEL_MANDATORY, 218 POLICY_LEVEL_MANDATORY,
220 POLICY_SCOPE_USER, 219 POLICY_SCOPE_USER,
221 new base::StringValue(ProxyPrefs::kPacScriptProxyModeName), 220 new base::StringValue(ProxyPrefs::kPacScriptProxyModeName),
222 NULL); 221 NULL);
223 UpdateProviderPolicy(policy); 222 UpdateProviderPolicy(policy);
224 const base::Value* value = NULL; 223 const base::Value* value = NULL;
225 EXPECT_FALSE(store_->GetValue(prefs::kProxy, &value)); 224 EXPECT_FALSE(store_->GetValue(proxy_config::prefs::kProxy, &value));
226 } 225 }
227 226
228 // Regression test for http://crbug.com/78016, CPanel returns empty strings 227 // Regression test for http://crbug.com/78016, CPanel returns empty strings
229 // for unset properties. 228 // for unset properties.
230 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeBug78016) { 229 TEST_F(ProxyPolicyHandlerTest, PacScriptProxyModeBug78016) {
231 PolicyMap policy; 230 PolicyMap policy;
232 policy.Set(key::kProxyServer, 231 policy.Set(key::kProxyServer,
233 POLICY_LEVEL_MANDATORY, 232 POLICY_LEVEL_MANDATORY,
234 POLICY_SCOPE_USER, 233 POLICY_SCOPE_USER,
235 new base::StringValue(std::string()), 234 new base::StringValue(std::string()),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 new base::StringValue("chromium.org"), 314 new base::StringValue("chromium.org"),
316 NULL); 315 NULL);
317 for (int i = 0; i < ProxyPolicyHandler::MODE_COUNT; ++i) { 316 for (int i = 0; i < ProxyPolicyHandler::MODE_COUNT; ++i) {
318 policy.Set(key::kProxyServerMode, 317 policy.Set(key::kProxyServerMode,
319 POLICY_LEVEL_MANDATORY, 318 POLICY_LEVEL_MANDATORY,
320 POLICY_SCOPE_USER, 319 POLICY_SCOPE_USER,
321 new base::FundamentalValue(i), 320 new base::FundamentalValue(i),
322 NULL); 321 NULL);
323 UpdateProviderPolicy(policy); 322 UpdateProviderPolicy(policy);
324 const base::Value* value = NULL; 323 const base::Value* value = NULL;
325 EXPECT_FALSE(store_->GetValue(prefs::kProxy, &value)); 324 EXPECT_FALSE(store_->GetValue(proxy_config::prefs::kProxy, &value));
326 } 325 }
327 } 326 }
328 327
329 } // namespace policy 328 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/net/proxy_policy_handler.cc ('k') | chrome/browser/net/proxy_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698