diff options
Diffstat (limited to 'net/proxy/proxy_config_service_win_unittest.cc')
-rw-r--r-- | net/proxy/proxy_config_service_win_unittest.cc | 115 |
1 files changed, 80 insertions, 35 deletions
diff --git a/net/proxy/proxy_config_service_win_unittest.cc b/net/proxy/proxy_config_service_win_unittest.cc index 8d88eb3..f77ac16 100644 --- a/net/proxy/proxy_config_service_win_unittest.cc +++ b/net/proxy/proxy_config_service_win_unittest.cc @@ -10,6 +10,34 @@ namespace net { +static ProxyConfig::ProxyRules MakeProxyRules( + ProxyConfig::ProxyRules::Type type, + const char* single_proxy, + const char* proxy_for_http, + const char* proxy_for_https, + const char* proxy_for_ftp) { + ProxyConfig::ProxyRules rules; + rules.type = type; + rules.single_proxy = ProxyServer::FromURI(single_proxy); + rules.proxy_for_http = ProxyServer::FromURI(proxy_for_http); + rules.proxy_for_https = ProxyServer::FromURI(proxy_for_https); + rules.proxy_for_ftp = ProxyServer::FromURI(proxy_for_ftp); + return rules; +} + +static ProxyConfig::ProxyRules MakeSingleProxyRules(const char* single_proxy) { + return MakeProxyRules(ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY, + single_proxy, "", "", ""); +} + +static ProxyConfig::ProxyRules MakeProxyPerSchemeRules( + const char* proxy_http, + const char* proxy_https, + const char* proxy_ftp) { + return MakeProxyRules(ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME, + "", proxy_http, proxy_https, proxy_ftp); +} + TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { const struct { // Input. @@ -18,7 +46,7 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { // Expected outputs (fields of the ProxyConfig). bool auto_detect; GURL pac_url; - const char* proxy_rules; + ProxyConfig::ProxyRules proxy_rules; const char* proxy_bypass_list; // newline separated bool bypass_local_names; } tests[] = { @@ -32,11 +60,11 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { }, // Expected result. - true, // auto_detect - GURL(), // pac_url - "", // proxy_rules - "", // proxy_bypass_list - false, // bypass_local_names + true, // auto_detect + GURL(), // pac_url + ProxyConfig::ProxyRules(), // proxy_rules + "", // proxy_bypass_list + false, // bypass_local_names }, // Valid PAC url @@ -51,7 +79,7 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { // Expected result. false, // auto_detect GURL("http://wpad/wpad.dat"), // pac_url - "", // proxy_rules + ProxyConfig::ProxyRules(), // proxy_rules "", // proxy_bypass_list false, // bypass_local_names }, @@ -66,11 +94,11 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { }, // Expected result. - false, // auto_detect - GURL(), // pac_url - "", // proxy_rules - "", // proxy_bypass_list - false, // bypass_local_names + false, // auto_detect + GURL(), // pac_url + ProxyConfig::ProxyRules(), // proxy_rules + "", // proxy_bypass_list + false, // bypass_local_names }, // Single-host in proxy list. @@ -83,11 +111,28 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { }, // Expected result. - false, // auto_detect - GURL(), // pac_url - "www.google.com", // proxy_rules - "", // proxy_bypass_list - false, // bypass_local_names + false, // auto_detect + GURL(), // pac_url + MakeSingleProxyRules("www.google.com"), // proxy_rules + "", // proxy_bypass_list + false, // bypass_local_names + }, + + // Per-scheme proxy rules. + { + { // Input. + FALSE, // fAutoDetect + NULL, // lpszAutoConfigUrl + L"http=www.google.com:80;https=www.foo.com:110", // lpszProxy + NULL, // lpszProxy_bypass + }, + + // Expected result. + false, // auto_detect + GURL(), // pac_url + MakeProxyPerSchemeRules("www.google.com:80", "www.foo.com:110", ""), + "", // proxy_bypass_list + false, // bypass_local_names }, // Bypass local names. @@ -96,14 +141,14 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { TRUE, // fAutoDetect NULL, // lpszAutoConfigUrl NULL, // lpszProxy - L"<local>", // lpszProxy_bypass + L"<local>", // lpszProxy_bypass }, - true, // auto_detect - GURL(), // pac_url - "", // proxy_rules - "", // proxy_bypass_list - true, // bypass_local_names + true, // auto_detect + GURL(), // pac_url + ProxyConfig::ProxyRules(), // proxy_rules + "", // proxy_bypass_list + true, // bypass_local_names }, // Bypass "google.com" and local names, using semicolon as delimeter @@ -113,15 +158,15 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { TRUE, // fAutoDetect NULL, // lpszAutoConfigUrl NULL, // lpszProxy - L"<local> ; google.com", // lpszProxy_bypass + L"<local> ; google.com", // lpszProxy_bypass }, // Expected result. - true, // auto_detect - GURL(), // pac_url - "", // proxy_rules - "google.com\n", // proxy_bypass_list - true, // bypass_local_names + true, // auto_detect + GURL(), // pac_url + ProxyConfig::ProxyRules(), // proxy_rules + "google.com\n", // proxy_bypass_list + true, // bypass_local_names }, // Bypass "foo.com" and "google.com", using lines as delimeter. @@ -134,11 +179,11 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { }, // Expected result. - true, // auto_detect - GURL(), // pac_url - "", // proxy_rules - "foo.com\ngoogle.com\n", // proxy_bypass_list - false, // bypass_local_names + true, // auto_detect + GURL(), // pac_url + ProxyConfig::ProxyRules(), // proxy_rules + "foo.com\ngoogle.com\n", // proxy_bypass_list + false, // bypass_local_names }, }; @@ -159,7 +204,7 @@ TEST(ProxyConfigServiceWinTest, SetFromIEConfig) { EXPECT_EQ(tests[i].proxy_bypass_list, flattened_proxy_bypass); EXPECT_EQ(tests[i].bypass_local_names, config.proxy_bypass_local_names); - EXPECT_EQ(tests[i].proxy_rules, config.proxy_rules); + EXPECT_TRUE(tests[i].proxy_rules == config.proxy_rules); } } |