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