Chromium Code Reviews| Index: net/proxy/proxy_resolver_v8_unittest.cc |
| diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc |
| index b93d4f3e43fe16d0fc0afa2d2b905acf1fb5cbed..f523e0fc0d4061c985cbd617b8ac83f7e3aecc96 100644 |
| --- a/net/proxy/proxy_resolver_v8_unittest.cc |
| +++ b/net/proxy/proxy_resolver_v8_unittest.cc |
| @@ -12,7 +12,6 @@ |
| #include "net/base/net_errors.h" |
| #include "net/base/net_log_unittest.h" |
| #include "net/proxy/proxy_info.h" |
| -#include "net/proxy/proxy_resolver_js_bindings.h" |
| #include "net/proxy/proxy_resolver_v8.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -22,7 +21,7 @@ namespace { |
| // Javascript bindings for ProxyResolverV8, which returns mock values. |
| // Each time one of the bindings is called into, we push the input into a |
| // list, for later verification. |
| -class MockJSBindings : public ProxyResolverJSBindings { |
| +class MockJSBindings : public ProxyResolverV8::JSBindings { |
| public: |
| MockJSBindings() : my_ip_address_count(0), my_ip_address_ex_count(0) {} |
| @@ -31,30 +30,35 @@ class MockJSBindings : public ProxyResolverJSBindings { |
| alerts.push_back(UTF16ToUTF8(message)); |
| } |
| - virtual bool MyIpAddress(std::string* ip_address) OVERRIDE { |
| - my_ip_address_count++; |
| - *ip_address = my_ip_address_result; |
| - return !my_ip_address_result.empty(); |
| - } |
| + virtual bool ResolveDns(const std::string& host, |
| + ResolveDnsOperation op, |
| + std::string* output) OVERRIDE { |
| + if (op == MY_IP_ADDRESS) { |
| + my_ip_address_count++; |
| + *output = my_ip_address_result; |
| + return !my_ip_address_result.empty(); |
| + } |
| - virtual bool MyIpAddressEx(std::string* ip_address_list) OVERRIDE { |
| - my_ip_address_ex_count++; |
| - *ip_address_list = my_ip_address_ex_result; |
| - return !my_ip_address_ex_result.empty(); |
| - } |
| + if (op == MY_IP_ADDRESS_EX) { |
| + my_ip_address_ex_count++; |
| + *output = my_ip_address_ex_result; |
| + return !my_ip_address_ex_result.empty(); |
| + } |
| - virtual bool DnsResolve(const std::string& host, std::string* ip_address) |
| - OVERRIDE { |
| - dns_resolves.push_back(host); |
| - *ip_address = dns_resolve_result; |
| - return !dns_resolve_result.empty(); |
| - } |
| + if (op == DNS_RESOLVE) { |
| + dns_resolves.push_back(host); |
| + *output = dns_resolve_result; |
| + return !dns_resolve_result.empty(); |
| + } |
| - virtual bool DnsResolveEx(const std::string& host, |
| - std::string* ip_address_list) OVERRIDE { |
| - dns_resolves_ex.push_back(host); |
| - *ip_address_list = dns_resolve_ex_result; |
| - return !dns_resolve_ex_result.empty(); |
| + if (op == DNS_RESOLVE_EX) { |
| + dns_resolves_ex.push_back(host); |
| + *output = dns_resolve_ex_result; |
| + return !dns_resolve_ex_result.empty(); |
| + } |
| + |
| + CHECK(false); |
| + return false; |
| } |
| virtual void OnError(int line_number, const string16& message) OVERRIDE { |
| @@ -65,8 +69,6 @@ class MockJSBindings : public ProxyResolverJSBindings { |
| errors_line_number.push_back(line_number); |
| } |
| - virtual void Shutdown() OVERRIDE {} |
| - |
| // Mock values to return. |
| std::string my_ip_address_result; |
| std::string my_ip_address_ex_result; |
| @@ -88,10 +90,13 @@ class MockJSBindings : public ProxyResolverJSBindings { |
| // disk. |
| class ProxyResolverV8WithMockBindings : public ProxyResolverV8 { |
| public: |
| - ProxyResolverV8WithMockBindings() : ProxyResolverV8(new MockJSBindings()) {} |
| + ProxyResolverV8WithMockBindings() { |
| + mock_js_bindings_.reset(new MockJSBindings()); |
| + set_js_bindings(mock_js_bindings_.get()); |
| + } |
| MockJSBindings* mock_js_bindings() const { |
| - return reinterpret_cast<MockJSBindings*>(js_bindings()); |
| + return mock_js_bindings_.get(); |
| } |
| // Initialize with the PAC script data at |filename|. |
| @@ -117,13 +122,15 @@ class ProxyResolverV8WithMockBindings : public ProxyResolverV8 { |
| return SetPacScript(ProxyResolverScriptData::FromUTF8(file_contents), |
| CompletionCallback()); |
| } |
| + |
| + private: |
| + scoped_ptr<MockJSBindings> mock_js_bindings_; |
|
mmenke
2013/01/29 20:19:08
nit: Don't think this needs to be a scoped pointe
eroman
2013/01/29 22:51:23
Done.
|
| }; |
| // Doesn't really matter what these values are for many of the tests. |
| const GURL kQueryUrl("http://www.google.com"); |
| const GURL kPacUrl; |
| - |
| TEST(ProxyResolverV8Test, Direct) { |
| ProxyResolverV8WithMockBindings resolver; |
| int result = resolver.SetPacScriptFromDisk("direct.js"); |