| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/proxy/proxy_config.h" | 5 #include "net/proxy/proxy_config.h" |
| 6 #include "net/proxy/proxy_config_service_common_unittest.h" | 6 #include "net/proxy/proxy_config_service_common_unittest.h" |
| 7 #include "net/proxy/proxy_info.h" | 7 #include "net/proxy/proxy_info.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 TEST(ProxyConfigTest, ParseProxyRules) { | 98 TEST(ProxyConfigTest, ParseProxyRules) { |
| 99 const struct { | 99 const struct { |
| 100 const char* proxy_rules; | 100 const char* proxy_rules; |
| 101 | 101 |
| 102 ProxyConfig::ProxyRules::Type type; | 102 ProxyConfig::ProxyRules::Type type; |
| 103 const char* single_proxy; | 103 const char* single_proxy; |
| 104 const char* proxy_for_http; | 104 const char* proxy_for_http; |
| 105 const char* proxy_for_https; | 105 const char* proxy_for_https; |
| 106 const char* proxy_for_ftp; | 106 const char* proxy_for_ftp; |
| 107 const char* socks_proxy; | 107 const char* fallback_proxy; |
| 108 } tests[] = { | 108 } tests[] = { |
| 109 // One HTTP proxy for all schemes. | 109 // One HTTP proxy for all schemes. |
| 110 { | 110 { |
| 111 "myproxy:80", | 111 "myproxy:80", |
| 112 | 112 |
| 113 ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY, | 113 ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY, |
| 114 "myproxy:80", | 114 "myproxy:80", |
| 115 NULL, | 115 NULL, |
| 116 NULL, | 116 NULL, |
| 117 NULL, | 117 NULL, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 EXPECT_EQ(tests[i].type, config.proxy_rules().type); | 240 EXPECT_EQ(tests[i].type, config.proxy_rules().type); |
| 241 ExpectProxyServerEquals(tests[i].single_proxy, | 241 ExpectProxyServerEquals(tests[i].single_proxy, |
| 242 config.proxy_rules().single_proxy); | 242 config.proxy_rules().single_proxy); |
| 243 ExpectProxyServerEquals(tests[i].proxy_for_http, | 243 ExpectProxyServerEquals(tests[i].proxy_for_http, |
| 244 config.proxy_rules().proxy_for_http); | 244 config.proxy_rules().proxy_for_http); |
| 245 ExpectProxyServerEquals(tests[i].proxy_for_https, | 245 ExpectProxyServerEquals(tests[i].proxy_for_https, |
| 246 config.proxy_rules().proxy_for_https); | 246 config.proxy_rules().proxy_for_https); |
| 247 ExpectProxyServerEquals(tests[i].proxy_for_ftp, | 247 ExpectProxyServerEquals(tests[i].proxy_for_ftp, |
| 248 config.proxy_rules().proxy_for_ftp); | 248 config.proxy_rules().proxy_for_ftp); |
| 249 ExpectProxyServerEquals(tests[i].socks_proxy, | 249 ExpectProxyServerEquals(tests[i].fallback_proxy, |
| 250 config.proxy_rules().socks_proxy); | 250 config.proxy_rules().fallback_proxy); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 TEST(ProxyConfigTest, ToString) { | 254 TEST(ProxyConfigTest, ToString) { |
| 255 // Manual proxy. | 255 // Manual proxy. |
| 256 { | 256 { |
| 257 ProxyConfig config; | 257 ProxyConfig config; |
| 258 config.set_auto_detect(false); | 258 config.set_auto_detect(false); |
| 259 config.proxy_rules().ParseFromString("http://single-proxy:81"); | 259 config.proxy_rules().ParseFromString("http://single-proxy:81"); |
| 260 | 260 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 config.set_auto_detect(false); | 328 config.set_auto_detect(false); |
| 329 config.proxy_rules().ParseFromString( | 329 config.proxy_rules().ParseFromString( |
| 330 "http=http://proxy-for-http:1801; socks=socks-server:6083"); | 330 "http=http://proxy-for-http:1801; socks=socks-server:6083"); |
| 331 | 331 |
| 332 EXPECT_EQ("Automatic settings:\n" | 332 EXPECT_EQ("Automatic settings:\n" |
| 333 " Auto-detect: No\n" | 333 " Auto-detect: No\n" |
| 334 " Custom PAC script: [None]\n" | 334 " Custom PAC script: [None]\n" |
| 335 "Manual settings:\n" | 335 "Manual settings:\n" |
| 336 " Proxy server: \n" | 336 " Proxy server: \n" |
| 337 " HTTP: proxy-for-http:1801\n" | 337 " HTTP: proxy-for-http:1801\n" |
| 338 " SOCKS: socks4://socks-server:6083\n" | 338 " (fallback): socks4://socks-server:6083\n" |
| 339 " Bypass list: [None]", | 339 " Bypass list: [None]", |
| 340 config.ToString()); | 340 config.ToString()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 // No proxy. | 343 // No proxy. |
| 344 { | 344 { |
| 345 ProxyConfig config; | 345 ProxyConfig config; |
| 346 config.set_auto_detect(false); | 346 config.set_auto_detect(false); |
| 347 | 347 |
| 348 EXPECT_EQ("Automatic settings:\n" | 348 EXPECT_EQ("Automatic settings:\n" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 EXPECT_TRUE(info[1].is_direct()); | 421 EXPECT_TRUE(info[1].is_direct()); |
| 422 | 422 |
| 423 config.proxy_rules().Apply(url2, &info[2]); | 423 config.proxy_rules().Apply(url2, &info[2]); |
| 424 EXPECT_EQ("single-proxy:81", info[2].proxy_server().ToURI()); | 424 EXPECT_EQ("single-proxy:81", info[2].proxy_server().ToURI()); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace | 428 } // namespace |
| 429 } // namespace net | 429 } // namespace net |
| 430 | 430 |
| OLD | NEW |