OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 "chrome/browser/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "chrome/browser/configuration_policy_pref_store.h" | 9 #include "chrome/browser/configuration_policy_pref_store.h" |
10 #include "chrome/browser/pref_value_store.h" | 10 #include "chrome/browser/pref_value_store.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "net/proxy/proxy_config.h" | 12 #include "net/proxy/proxy_config.h" |
13 #include "net/proxy/proxy_config_service_common_unittest.h" | 13 #include "net/proxy/proxy_config_service_common_unittest.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 // Builds an identifier for each test in an array. | 16 // Builds an identifier for each test in an array. |
17 #define TEST_DESC(desc) StringPrintf("at line %d <%s>", __LINE__, desc) | 17 #define TEST_DESC(desc) StringPrintf("at line %d <%s>", __LINE__, desc) |
18 | 18 |
19 TEST(ChromeURLRequestContextTest, CreateProxyConfigTest) { | 19 TEST(ChromeURLRequestContextTest, CreateProxyConfigTest) { |
20 FilePath unused_path(FILE_PATH_LITERAL("foo.exe")); | 20 FilePath unused_path(FILE_PATH_LITERAL("foo.exe")); |
21 // Build the input command lines here. | 21 // Build the input command lines here. |
22 CommandLine empty(unused_path); | 22 CommandLine empty(unused_path); |
23 CommandLine no_proxy(unused_path); | 23 CommandLine no_proxy(unused_path); |
24 no_proxy.AppendSwitch(switches::kNoProxyServer); | 24 no_proxy.AppendSwitch(switches::kNoProxyServer); |
25 CommandLine no_proxy_extra_params(unused_path); | 25 CommandLine no_proxy_extra_params(unused_path); |
26 no_proxy_extra_params.AppendSwitch(switches::kNoProxyServer); | 26 no_proxy_extra_params.AppendSwitch(switches::kNoProxyServer); |
27 no_proxy_extra_params.AppendSwitchWithValue(switches::kProxyServer, | 27 no_proxy_extra_params.AppendSwitchASCII(switches::kProxyServer, |
28 "http://proxy:8888"); | 28 "http://proxy:8888"); |
29 CommandLine single_proxy(unused_path); | 29 CommandLine single_proxy(unused_path); |
30 single_proxy.AppendSwitchWithValue(switches::kProxyServer, | 30 single_proxy.AppendSwitchASCII(switches::kProxyServer, "http://proxy:8888"); |
31 "http://proxy:8888"); | |
32 CommandLine per_scheme_proxy(unused_path); | 31 CommandLine per_scheme_proxy(unused_path); |
33 per_scheme_proxy.AppendSwitchWithValue(switches::kProxyServer, | 32 per_scheme_proxy.AppendSwitchASCII(switches::kProxyServer, |
| 33 "http=httpproxy:8888;ftp=ftpproxy:8889"); |
| 34 CommandLine per_scheme_proxy_bypass(unused_path); |
| 35 per_scheme_proxy_bypass.AppendSwitchASCII( |
| 36 switches::kProxyServer, |
34 "http=httpproxy:8888;ftp=ftpproxy:8889"); | 37 "http=httpproxy:8888;ftp=ftpproxy:8889"); |
35 CommandLine per_scheme_proxy_bypass(unused_path); | 38 per_scheme_proxy_bypass.AppendSwitchASCII( |
36 per_scheme_proxy_bypass.AppendSwitchWithValue(switches::kProxyServer, | |
37 "http=httpproxy:8888;ftp=ftpproxy:8889"); | |
38 per_scheme_proxy_bypass.AppendSwitchWithValue( | |
39 switches::kProxyBypassList, | 39 switches::kProxyBypassList, |
40 ".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); | 40 ".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); |
41 CommandLine with_pac_url(unused_path); | 41 CommandLine with_pac_url(unused_path); |
42 with_pac_url.AppendSwitchWithValue(switches::kProxyPacUrl, | 42 with_pac_url.AppendSwitchASCII(switches::kProxyPacUrl, "http://wpad/wpad.dat")
; |
43 "http://wpad/wpad.dat"); | 43 with_pac_url.AppendSwitchASCII( |
44 with_pac_url.AppendSwitchWithValue( | |
45 switches::kProxyBypassList, | 44 switches::kProxyBypassList, |
46 ".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); | 45 ".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8"); |
47 CommandLine with_auto_detect(unused_path); | 46 CommandLine with_auto_detect(unused_path); |
48 with_auto_detect.AppendSwitch(switches::kProxyAutoDetect); | 47 with_auto_detect.AppendSwitch(switches::kProxyAutoDetect); |
49 | 48 |
50 // Inspired from proxy_config_service_win_unittest.cc. | 49 // Inspired from proxy_config_service_win_unittest.cc. |
51 const struct { | 50 const struct { |
52 // Short description to identify the test | 51 // Short description to identify the test |
53 std::string description; | 52 std::string description; |
54 | 53 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 EXPECT_TRUE(config == NULL); | 167 EXPECT_TRUE(config == NULL); |
169 } else { | 168 } else { |
170 EXPECT_TRUE(config != NULL); | 169 EXPECT_TRUE(config != NULL); |
171 EXPECT_EQ(tests[i].auto_detect, config->auto_detect()); | 170 EXPECT_EQ(tests[i].auto_detect, config->auto_detect()); |
172 EXPECT_EQ(tests[i].pac_url, config->pac_url()); | 171 EXPECT_EQ(tests[i].pac_url, config->pac_url()); |
173 EXPECT_TRUE(tests[i].proxy_rules.Matches(config->proxy_rules())); | 172 EXPECT_TRUE(tests[i].proxy_rules.Matches(config->proxy_rules())); |
174 } | 173 } |
175 } | 174 } |
176 } | 175 } |
177 | 176 |
OLD | NEW |