Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1079)

Unified Diff: net/proxy/proxy_resolver_v8_unittest.cc

Issue 333006: Add three of the six extensions to PAC that Internet Explorer supports. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address more of wtc's comments Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/proxy/proxy_resolver_v8.cc ('K') | « net/proxy/proxy_resolver_v8.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_v8_unittest.cc
===================================================================
--- net/proxy/proxy_resolver_v8_unittest.cc (revision 29974)
+++ net/proxy/proxy_resolver_v8_unittest.cc (working copy)
@@ -21,7 +21,7 @@
// list, for later verification.
class MockJSBindings : public ProxyResolverJSBindings {
public:
- MockJSBindings() : my_ip_address_count(0) {}
+ MockJSBindings() : my_ip_address_count(0), my_ip_address_ex_count(0) {}
virtual void Alert(const std::string& message) {
LOG(INFO) << "PAC-alert: " << message; // Helpful when debugging.
@@ -33,11 +33,21 @@
return my_ip_address_result;
}
+ virtual std::string MyIpAddressEx() {
+ my_ip_address_ex_count++;
+ return my_ip_address_ex_result;
+ }
+
virtual std::string DnsResolve(const std::string& host) {
dns_resolves.push_back(host);
return dns_resolve_result;
}
+ virtual std::string DnsResolveEx(const std::string& host) {
+ dns_resolves_ex.push_back(host);
+ return dns_resolve_ex_result;
+ }
+
virtual void OnError(int line_number, const std::string& message) {
// Helpful when debugging.
LOG(INFO) << "PAC-error: [" << line_number << "] " << message;
@@ -48,14 +58,18 @@
// Mock values to return.
std::string my_ip_address_result;
+ std::string my_ip_address_ex_result;
std::string dns_resolve_result;
+ std::string dns_resolve_ex_result;
// Inputs we got called with.
std::vector<std::string> alerts;
std::vector<std::string> errors;
std::vector<int> errors_line_number;
std::vector<std::string> dns_resolves;
+ std::vector<std::string> dns_resolves_ex;
int my_ip_address_count;
+ int my_ip_address_ex_count;
};
// This is the same as ProxyResolverV8, but it uses mock bindings in place of
@@ -391,6 +405,14 @@
// MyIpAddress was called two times.
EXPECT_EQ(2, bindings->my_ip_address_count);
+
+ // MyIpAddressEx was called once.
+ EXPECT_EQ(1, bindings->my_ip_address_ex_count);
+
+ // DnsResolveEx was called 2 times.
+ ASSERT_EQ(2U, bindings->dns_resolves_ex.size());
+ EXPECT_EQ("is_resolvable", bindings->dns_resolves_ex[0]);
+ EXPECT_EQ("foobar", bindings->dns_resolves_ex[1]);
}
// Test that calls to the myIpAddress() and dnsResolve() bindings get
@@ -464,5 +486,22 @@
EXPECT_EQ("success:3", proxy_info.proxy_server().ToURI());
}
+// Test the return values from myIpAddress(), myIpAddressEx(), dnsResolve(),
+// dnsResolveEx(), isResolvable(), isResolvableEx(), when the the binding
+// returns empty string (failure). This simulates the return values from
+// those functions when the underlying DNS resolution fails.
+TEST(ProxyResolverV8Test, DNSResolutionFailure) {
+ ProxyResolverV8WithMockBindings resolver;
+ int result = resolver.SetPacScriptFromDisk("dns_fail.js");
+ EXPECT_EQ(OK, result);
+
+ ProxyInfo proxy_info;
+ result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL);
+
+ EXPECT_EQ(OK, result);
+ EXPECT_FALSE(proxy_info.is_direct());
+ EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI());
+}
+
} // namespace
} // namespace net
« net/proxy/proxy_resolver_v8.cc ('K') | « net/proxy/proxy_resolver_v8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698