Dismiss autofill popup on screen orientation change.
[chromium-blink-merge.git] / net / proxy / proxy_config_service_win_unittest.cc
blob911949d59944a753733875e48753a4327108e393
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/proxy/proxy_config_service_win.h"
7 #include "net/base/net_errors.h"
8 #include "net/proxy/proxy_config.h"
9 #include "net/proxy/proxy_config_service_common_unittest.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace net {
14 TEST(ProxyConfigServiceWinTest, SetFromIEConfig) {
15 const struct {
16 // Input.
17 WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ie_config;
19 // Expected outputs (fields of the ProxyConfig).
20 bool auto_detect;
21 GURL pac_url;
22 ProxyRulesExpectation proxy_rules;
23 const char* proxy_bypass_list; // newline separated
24 } tests[] = {
25 // Auto detect.
27 { // Input.
28 TRUE, // fAutoDetect
29 NULL, // lpszAutoConfigUrl
30 NULL, // lpszProxy
31 NULL, // lpszProxyBypass
34 // Expected result.
35 true, // auto_detect
36 GURL(), // pac_url
37 ProxyRulesExpectation::Empty(),
40 // Valid PAC url
42 { // Input.
43 FALSE, // fAutoDetect
44 L"http://wpad/wpad.dat", // lpszAutoConfigUrl
45 NULL, // lpszProxy
46 NULL, // lpszProxy_bypass
49 // Expected result.
50 false, // auto_detect
51 GURL("http://wpad/wpad.dat"), // pac_url
52 ProxyRulesExpectation::Empty(),
55 // Invalid PAC url string.
57 { // Input.
58 FALSE, // fAutoDetect
59 L"wpad.dat", // lpszAutoConfigUrl
60 NULL, // lpszProxy
61 NULL, // lpszProxy_bypass
64 // Expected result.
65 false, // auto_detect
66 GURL(), // pac_url
67 ProxyRulesExpectation::Empty(),
70 // Single-host in proxy list.
72 { // Input.
73 FALSE, // fAutoDetect
74 NULL, // lpszAutoConfigUrl
75 L"www.google.com", // lpszProxy
76 NULL, // lpszProxy_bypass
79 // Expected result.
80 false, // auto_detect
81 GURL(), // pac_url
82 ProxyRulesExpectation::Single(
83 "www.google.com:80", // single proxy
84 ""), // bypass rules
87 // Per-scheme proxy rules.
89 { // Input.
90 FALSE, // fAutoDetect
91 NULL, // lpszAutoConfigUrl
92 L"http=www.google.com:80;https=www.foo.com:110", // lpszProxy
93 NULL, // lpszProxy_bypass
96 // Expected result.
97 false, // auto_detect
98 GURL(), // pac_url
99 ProxyRulesExpectation::PerScheme(
100 "www.google.com:80", // http
101 "www.foo.com:110", // https
102 "", // ftp
103 ""), // bypass rules
106 // SOCKS proxy configuration.
108 { // Input.
109 FALSE, // fAutoDetect
110 NULL, // lpszAutoConfigUrl
111 L"http=www.google.com:80;https=www.foo.com:110;"
112 L"ftp=ftpproxy:20;socks=foopy:130", // lpszProxy
113 NULL, // lpszProxy_bypass
116 // Expected result.
117 // Note that "socks" is interprted as meaning "socks4", since that is how
118 // Internet Explorer applies the settings. For more details on this
119 // policy, see:
120 // http://code.google.com/p/chromium/issues/detail?id=55912#c2
121 false, // auto_detect
122 GURL(), // pac_url
123 ProxyRulesExpectation::PerSchemeWithSocks(
124 "www.google.com:80", // http
125 "www.foo.com:110", // https
126 "ftpproxy:20", // ftp
127 "socks4://foopy:130", // socks
128 ""), // bypass rules
131 // Bypass local names.
133 { // Input.
134 TRUE, // fAutoDetect
135 NULL, // lpszAutoConfigUrl
136 NULL, // lpszProxy
137 L"<local>", // lpszProxy_bypass
140 true, // auto_detect
141 GURL(), // pac_url
142 ProxyRulesExpectation::EmptyWithBypass("<local>"),
145 // Bypass "google.com" and local names, using semicolon as delimiter
146 // (ignoring white space).
148 { // Input.
149 TRUE, // fAutoDetect
150 NULL, // lpszAutoConfigUrl
151 NULL, // lpszProxy
152 L"<local> ; google.com", // lpszProxy_bypass
155 // Expected result.
156 true, // auto_detect
157 GURL(), // pac_url
158 ProxyRulesExpectation::EmptyWithBypass("<local>,google.com"),
161 // Bypass "foo.com" and "google.com", using lines as delimiter.
163 { // Input.
164 TRUE, // fAutoDetect
165 NULL, // lpszAutoConfigUrl
166 NULL, // lpszProxy
167 L"foo.com\r\ngoogle.com", // lpszProxy_bypass
170 // Expected result.
171 true, // auto_detect
172 GURL(), // pac_url
173 ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"),
176 // Bypass "foo.com" and "google.com", using commas as delimiter.
178 { // Input.
179 TRUE, // fAutoDetect
180 NULL, // lpszAutoConfigUrl
181 NULL, // lpszProxy
182 L"foo.com, google.com", // lpszProxy_bypass
185 // Expected result.
186 true, // auto_detect
187 GURL(), // pac_url
188 ProxyRulesExpectation::EmptyWithBypass("foo.com,google.com"),
192 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
193 ProxyConfig config;
194 ProxyConfigServiceWin::SetFromIEConfig(&config, tests[i].ie_config);
196 EXPECT_EQ(tests[i].auto_detect, config.auto_detect());
197 EXPECT_EQ(tests[i].pac_url, config.pac_url());
198 EXPECT_TRUE(tests[i].proxy_rules.Matches(config.proxy_rules()));
199 EXPECT_EQ(PROXY_CONFIG_SOURCE_SYSTEM, config.source());
203 } // namespace net