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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
7 | 8 |
8 namespace { | 9 namespace { |
9 static void ExpectProxyServerEquals(const char* expectation, | 10 static void ExpectProxyServerEquals(const char* expectation, |
10 const net::ProxyServer& proxy_server) { | 11 const net::ProxyServer& proxy_server) { |
11 if (expectation == NULL) { | 12 if (expectation == NULL) { |
12 EXPECT_FALSE(proxy_server.is_valid()); | 13 EXPECT_FALSE(proxy_server.is_valid()); |
13 } else { | 14 } else { |
14 EXPECT_EQ(expectation, proxy_server.ToURI()); | 15 EXPECT_EQ(expectation, proxy_server.ToURI()); |
15 } | 16 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ExpectProxyServerEquals(tests[i].single_proxy, | 191 ExpectProxyServerEquals(tests[i].single_proxy, |
191 config.proxy_rules.single_proxy); | 192 config.proxy_rules.single_proxy); |
192 ExpectProxyServerEquals(tests[i].proxy_for_http, | 193 ExpectProxyServerEquals(tests[i].proxy_for_http, |
193 config.proxy_rules.proxy_for_http); | 194 config.proxy_rules.proxy_for_http); |
194 ExpectProxyServerEquals(tests[i].proxy_for_https, | 195 ExpectProxyServerEquals(tests[i].proxy_for_https, |
195 config.proxy_rules.proxy_for_https); | 196 config.proxy_rules.proxy_for_https); |
196 ExpectProxyServerEquals(tests[i].proxy_for_ftp, | 197 ExpectProxyServerEquals(tests[i].proxy_for_ftp, |
197 config.proxy_rules.proxy_for_ftp); | 198 config.proxy_rules.proxy_for_ftp); |
198 } | 199 } |
199 } | 200 } |
| 201 |
| 202 TEST(ProxyConfigTest, ParseProxyBypassList) { |
| 203 struct bypass_test { |
| 204 const char* proxy_bypass_input; |
| 205 const char* flattened_output; |
| 206 }; |
| 207 |
| 208 const struct { |
| 209 const char* proxy_bypass_input; |
| 210 const char* flattened_output; |
| 211 } tests[] = { |
| 212 { |
| 213 "*", |
| 214 "*\n" |
| 215 }, |
| 216 { |
| 217 ".google.com, .foo.com:42", |
| 218 "*.google.com\n*.foo.com:42\n" |
| 219 }, |
| 220 { |
| 221 ".google.com, foo.com:99, 1.2.3.4:22, 127.0.0.1/8", |
| 222 "*.google.com\n*foo.com:99\n1.2.3.4:22\n127.0.0.1/8\n" |
| 223 } |
| 224 }; |
| 225 |
| 226 net::ProxyConfig config; |
| 227 |
| 228 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 229 config.ParseNoProxyList(tests[i].proxy_bypass_input); |
| 230 EXPECT_EQ(tests[i].flattened_output, |
| 231 net::FlattenProxyBypass(config.proxy_bypass)); |
| 232 } |
| 233 } |
OLD | NEW |