| Index: net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
|
| diff --git a/net/proxy/proxy_resolver_v8_tracing_unittest.cc b/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
|
| similarity index 85%
|
| copy from net/proxy/proxy_resolver_v8_tracing_unittest.cc
|
| copy to net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
|
| index 296853c29bd9fcfca02f398ce50675640d256e7e..7a77b8243eb8ff72b49b04028d65da0093fa8421 100644
|
| --- a/net/proxy/proxy_resolver_v8_tracing_unittest.cc
|
| +++ b/net/proxy/proxy_resolver_v8_tracing_wrapper_unittest.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "net/proxy/proxy_resolver_v8_tracing.h"
|
| +#include "net/proxy/proxy_resolver_v8_tracing_wrapper.h"
|
|
|
| #include <string>
|
|
|
| @@ -33,7 +33,7 @@ namespace net {
|
|
|
| namespace {
|
|
|
| -class ProxyResolverV8TracingTest : public testing::Test {
|
| +class ProxyResolverV8TracingWrapperTest : public testing::Test {
|
| public:
|
| void TearDown() override {
|
| // Drain any pending messages, which may be left over from cancellation.
|
| @@ -73,8 +73,8 @@ scoped_ptr<ProxyResolver> CreateResolver(
|
| scoped_ptr<ProxyResolverErrorObserver> error_observer,
|
| const char* filename) {
|
| scoped_ptr<ProxyResolver> resolver;
|
| - ProxyResolverFactoryV8Tracing factory(
|
| - host_resolver, net_log, ProxyResolver::LoadStateChangedCallback(),
|
| + ProxyResolverFactoryV8TracingWrapper factory(
|
| + host_resolver, net_log,
|
| base::Bind(&ReturnErrorObserver, base::Passed(&error_observer)));
|
| TestCompletionCallback callback;
|
| scoped_ptr<ProxyResolverFactory::Request> request;
|
| @@ -104,9 +104,7 @@ class MockErrorObserver : public ProxyResolverErrorObserver {
|
| return output;
|
| }
|
|
|
| - void WaitForOutput() {
|
| - event_.Wait();
|
| - }
|
| + void WaitForOutput() { event_.Wait(); }
|
|
|
| private:
|
| base::Lock lock_;
|
| @@ -115,7 +113,7 @@ class MockErrorObserver : public ProxyResolverErrorObserver {
|
| base::WaitableEvent event_;
|
| };
|
|
|
| -TEST_F(ProxyResolverV8TracingTest, Simple) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, Simple) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -146,7 +144,7 @@ TEST_F(ProxyResolverV8TracingTest, Simple) {
|
| EXPECT_EQ(0u, request_log.GetSize());
|
| }
|
|
|
| -TEST_F(ProxyResolverV8TracingTest, JavascriptError) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, JavascriptError) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -167,8 +165,10 @@ TEST_F(ProxyResolverV8TracingTest, JavascriptError) {
|
|
|
| EXPECT_EQ(0u, host_resolver.num_resolve());
|
|
|
| - EXPECT_EQ("Error: line 5: Uncaught TypeError: Cannot read property 'split' "
|
| - "of null\n", error_observer->GetOutput());
|
| + EXPECT_EQ(
|
| + "Error: line 5: Uncaught TypeError: Cannot read property 'split' "
|
| + "of null\n",
|
| + error_observer->GetOutput());
|
|
|
| // Check the NetLogs -- there was 1 alert and 1 javascript error, and they
|
| // were output to both the global log, and per-request log.
|
| @@ -179,20 +179,20 @@ TEST_F(ProxyResolverV8TracingTest, JavascriptError) {
|
| for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
|
| const TestNetLogEntry::List& entries = entries_list[list_i];
|
| EXPECT_EQ(2u, entries.size());
|
| - EXPECT_TRUE(
|
| - LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| - NetLog::PHASE_NONE));
|
| - EXPECT_TRUE(
|
| - LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ERROR,
|
| - NetLog::PHASE_NONE));
|
| + EXPECT_TRUE(LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| + NetLog::PHASE_NONE));
|
| + EXPECT_TRUE(LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ERROR,
|
| + NetLog::PHASE_NONE));
|
|
|
| EXPECT_EQ("{\"message\":\"Prepare to DIE!\"}", entries[0].GetParamsJson());
|
| - EXPECT_EQ("{\"line_number\":5,\"message\":\"Uncaught TypeError: Cannot "
|
| - "read property 'split' of null\"}", entries[1].GetParamsJson());
|
| + EXPECT_EQ(
|
| + "{\"line_number\":5,\"message\":\"Uncaught TypeError: Cannot "
|
| + "read property 'split' of null\"}",
|
| + entries[1].GetParamsJson());
|
| }
|
| }
|
|
|
| -TEST_F(ProxyResolverV8TracingTest, TooManyAlerts) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, TooManyAlerts) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -232,16 +232,15 @@ TEST_F(ProxyResolverV8TracingTest, TooManyAlerts) {
|
| const TestNetLogEntry::List& entries = entries_list[list_i];
|
| EXPECT_EQ(50u, entries.size());
|
| for (size_t i = 0; i < entries.size(); ++i) {
|
| - ASSERT_TRUE(
|
| - LogContainsEvent(entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| - NetLog::PHASE_NONE));
|
| + ASSERT_TRUE(LogContainsEvent(
|
| + entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, NetLog::PHASE_NONE));
|
| }
|
| }
|
| }
|
|
|
| // Verify that buffered alerts cannot grow unboundedly, even when the message is
|
| // empty string.
|
| -TEST_F(ProxyResolverV8TracingTest, TooManyEmptyAlerts) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, TooManyEmptyAlerts) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -278,9 +277,8 @@ TEST_F(ProxyResolverV8TracingTest, TooManyEmptyAlerts) {
|
| const TestNetLogEntry::List& entries = entries_list[list_i];
|
| EXPECT_EQ(1000u, entries.size());
|
| for (size_t i = 0; i < entries.size(); ++i) {
|
| - ASSERT_TRUE(
|
| - LogContainsEvent(entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| - NetLog::PHASE_NONE));
|
| + ASSERT_TRUE(LogContainsEvent(
|
| + entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, NetLog::PHASE_NONE));
|
| }
|
| }
|
| }
|
| @@ -288,22 +286,22 @@ TEST_F(ProxyResolverV8TracingTest, TooManyEmptyAlerts) {
|
| // This test runs a PAC script that issues a sequence of DNS resolves. The test
|
| // verifies the final result, and that the underlying DNS resolver received
|
| // the correct set of queries.
|
| -TEST_F(ProxyResolverV8TracingTest, Dns) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, Dns) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| - host_resolver.rules()->AddRuleForAddressFamily(
|
| - "host1", ADDRESS_FAMILY_IPV4, "166.155.144.44");
|
| - host_resolver.rules()
|
| - ->AddIPLiteralRule("host1", "::1,192.168.1.1", std::string());
|
| + host_resolver.rules()->AddRuleForAddressFamily("host1", ADDRESS_FAMILY_IPV4,
|
| + "166.155.144.44");
|
| + host_resolver.rules()->AddIPLiteralRule("host1", "::1,192.168.1.1",
|
| + std::string());
|
| host_resolver.rules()->AddSimulatedFailure("host2");
|
| host_resolver.rules()->AddRule("host3", "166.155.144.33");
|
| host_resolver.rules()->AddRule("host5", "166.155.144.55");
|
| host_resolver.rules()->AddSimulatedFailure("host6");
|
| - host_resolver.rules()->AddRuleForAddressFamily(
|
| - "*", ADDRESS_FAMILY_IPV4, "122.133.144.155");
|
| + host_resolver.rules()->AddRuleForAddressFamily("*", ADDRESS_FAMILY_IPV4,
|
| + "122.133.144.155");
|
| host_resolver.rules()->AddRule("*", "133.122.100.200");
|
|
|
| scoped_ptr<ProxyResolver> resolver = CreateResolver(
|
| @@ -323,20 +321,20 @@ TEST_F(ProxyResolverV8TracingTest, Dns) {
|
| EXPECT_EQ(7u, host_resolver.num_resolve());
|
|
|
| const char* kExpectedResult =
|
| - "122.133.144.155-" // myIpAddress()
|
| - "null-" // dnsResolve('')
|
| - "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| - "null-" // dnsResolve('host2')
|
| - "166.155.144.33-" // dnsResolve('host3')
|
| - "122.133.144.155-" // myIpAddress()
|
| - "166.155.144.33-" // dnsResolve('host3')
|
| - "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| - "122.133.144.155-" // myIpAddress()
|
| - "null-" // dnsResolve('host2')
|
| - "-" // dnsResolveEx('host6')
|
| - "133.122.100.200-" // myIpAddressEx()
|
| - "166.155.144.44" // dnsResolve('host1')
|
| - ":99";
|
| + "122.133.144.155-" // myIpAddress()
|
| + "null-" // dnsResolve('')
|
| + "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| + "null-" // dnsResolve('host2')
|
| + "166.155.144.33-" // dnsResolve('host3')
|
| + "122.133.144.155-" // myIpAddress()
|
| + "166.155.144.33-" // dnsResolve('host3')
|
| + "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| + "122.133.144.155-" // myIpAddress()
|
| + "null-" // dnsResolve('host2')
|
| + "-" // dnsResolveEx('host6')
|
| + "133.122.100.200-" // myIpAddressEx()
|
| + "166.155.144.44" // dnsResolve('host1')
|
| + ":99";
|
|
|
| EXPECT_EQ(kExpectedResult, proxy_info.proxy_server().ToURI());
|
|
|
| @@ -352,9 +350,8 @@ TEST_F(ProxyResolverV8TracingTest, Dns) {
|
| for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
|
| const TestNetLogEntry::List& entries = entries_list[list_i];
|
| EXPECT_EQ(1u, entries.size());
|
| - EXPECT_TRUE(
|
| - LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| - NetLog::PHASE_NONE));
|
| + EXPECT_TRUE(LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| + NetLog::PHASE_NONE));
|
| EXPECT_EQ("{\"message\":\"iteration: 7\"}", entries[0].GetParamsJson());
|
| }
|
| }
|
| @@ -362,7 +359,7 @@ TEST_F(ProxyResolverV8TracingTest, Dns) {
|
| // This test runs a PAC script that does "myIpAddress()" followed by
|
| // "dnsResolve()". This requires 2 restarts. However once the HostResolver's
|
| // cache is warmed, subsequent calls should take 0 restarts.
|
| -TEST_F(ProxyResolverV8TracingTest, DnsChecksCache) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, DnsChecksCache) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -413,7 +410,7 @@ TEST_F(ProxyResolverV8TracingTest, DnsChecksCache) {
|
| // This test runs a weird PAC script that was designed to defeat the DNS tracing
|
| // optimization. The proxy resolver should detect the inconsistency and
|
| // fall-back to synchronous mode execution.
|
| -TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous1) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, FallBackToSynchronous1) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -456,9 +453,8 @@ TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous1) {
|
| for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
|
| const TestNetLogEntry::List& entries = entries_list[list_i];
|
| EXPECT_EQ(1u, entries.size());
|
| - EXPECT_TRUE(
|
| - LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| - NetLog::PHASE_NONE));
|
| + EXPECT_TRUE(LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| + NetLog::PHASE_NONE));
|
| EXPECT_EQ("{\"message\":\"iteration: 4\"}", entries[0].GetParamsJson());
|
| }
|
| }
|
| @@ -466,7 +462,7 @@ TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous1) {
|
| // This test runs a weird PAC script that was designed to defeat the DNS tracing
|
| // optimization. The proxy resolver should detect the inconsistency and
|
| // fall-back to synchronous mode execution.
|
| -TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous2) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, FallBackToSynchronous2) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -507,7 +503,7 @@ TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous2) {
|
| // of DNS resolves when restarting. Running it will hit the maximum
|
| // DNS resolves per request limit (20) after which every DNS resolve will
|
| // fail.
|
| -TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, InfiniteDNSSequence) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -537,7 +533,8 @@ TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence) {
|
| "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
|
| "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
|
| "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
|
| - "null:21", proxy_info.proxy_server().ToURI());
|
| + "null:21",
|
| + proxy_info.proxy_server().ToURI());
|
|
|
| // No errors.
|
| EXPECT_EQ("", error_observer->GetOutput());
|
| @@ -551,7 +548,7 @@ TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence) {
|
| // of DNS resolves when restarting. Running it will hit the maximum
|
| // DNS resolves per request limit (20) after which every DNS resolve will
|
| // fail.
|
| -TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence2) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, InfiniteDNSSequence2) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -630,19 +627,17 @@ void DnsDuringInitHelper(bool synchronous_host_resolver) {
|
| log.GetEntries(&entries);
|
|
|
| ASSERT_EQ(2u, entries.size());
|
| - EXPECT_TRUE(
|
| - LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| - NetLog::PHASE_NONE));
|
| - EXPECT_TRUE(
|
| - LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| - NetLog::PHASE_NONE));
|
| + EXPECT_TRUE(LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| + NetLog::PHASE_NONE));
|
| + EXPECT_TRUE(LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
|
| + NetLog::PHASE_NONE));
|
|
|
| EXPECT_EQ("{\"message\":\"Watsup\"}", entries[0].GetParamsJson());
|
| EXPECT_EQ("{\"message\":\"Watsup2\"}", entries[1].GetParamsJson());
|
| }
|
|
|
| // Tests a PAC script which does DNS resolves during initialization.
|
| -TEST_F(ProxyResolverV8TracingTest, DnsDuringInit) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, DnsDuringInit) {
|
| // Test with both both a host resolver that always completes asynchronously,
|
| // and then again with one that completes synchronously.
|
| DnsDuringInitHelper(false);
|
| @@ -658,7 +653,7 @@ void CrashCallback(int) {
|
| // Note the execution order for this test can vary. Since multiple
|
| // threads are involved, the cancellation may be received a different
|
| // times.
|
| -TEST_F(ProxyResolverV8TracingTest, CancelAll) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, CancelAll) {
|
| MockCachingHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| @@ -686,7 +681,7 @@ TEST_F(ProxyResolverV8TracingTest, CancelAll) {
|
| // Note the execution order for this test can vary. Since multiple
|
| // threads are involved, the cancellation may be received a different
|
| // times.
|
| -TEST_F(ProxyResolverV8TracingTest, CancelSome) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, CancelSome) {
|
| MockCachingHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| @@ -717,7 +712,7 @@ TEST_F(ProxyResolverV8TracingTest, CancelSome) {
|
|
|
| // Cancel a request after it has finished running on the worker thread, and has
|
| // posted a task the completion task back to origin thread.
|
| -TEST_F(ProxyResolverV8TracingTest, CancelWhilePendingCompletionTask) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhilePendingCompletionTask) {
|
| MockCachingHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| @@ -761,8 +756,7 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhilePendingCompletionTask) {
|
|
|
| EXPECT_EQ(OK, callback.WaitForResult());
|
|
|
| - EXPECT_EQ("i-approve-this-message:42",
|
| - proxy_info3.proxy_server().ToURI());
|
| + EXPECT_EQ("i-approve-this-message:42", proxy_info3.proxy_server().ToURI());
|
| }
|
|
|
| // This implementation of HostResolver allows blocking until a resolve request
|
| @@ -810,9 +804,7 @@ class BlockableHostResolver : public HostResolver {
|
| num_cancelled_requests_++;
|
| }
|
|
|
| - void SetAction(const base::Callback<void(void)>& action) {
|
| - action_ = action;
|
| - }
|
| + void SetAction(const base::Callback<void(void)>& action) { action_ = action; }
|
|
|
| // Waits until Resolve() has been called.
|
| void WaitUntilRequestIsReceived() {
|
| @@ -822,9 +814,7 @@ class BlockableHostResolver : public HostResolver {
|
| waiting_for_resolve_ = false;
|
| }
|
|
|
| - int num_cancelled_requests() const {
|
| - return num_cancelled_requests_;
|
| - }
|
| + int num_cancelled_requests() const { return num_cancelled_requests_; }
|
|
|
| private:
|
| int num_cancelled_requests_;
|
| @@ -834,7 +824,8 @@ class BlockableHostResolver : public HostResolver {
|
|
|
| // This cancellation test exercises a more predictable cancellation codepath --
|
| // when the request has an outstanding DNS request in flight.
|
| -TEST_F(ProxyResolverV8TracingTest, CancelWhileOutstandingNonBlockingDns) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest,
|
| + CancelWhileOutstandingNonBlockingDns) {
|
| BlockableHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| @@ -885,7 +876,7 @@ void CancelRequestAndPause(ProxyResolver* resolver,
|
| // In non-blocking mode, the worker thread actually does block for
|
| // a short time to see if the result is in the DNS cache. Test
|
| // cancellation while the worker thread is waiting on this event.
|
| -TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns) {
|
| BlockableHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| @@ -914,7 +905,7 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns) {
|
|
|
| // Cancel the request while there is a pending DNS request, however before
|
| // the request is sent to the host resolver.
|
| -TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns2) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, CancelWhileBlockedInNonBlockingDns2) {
|
| MockCachingHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| @@ -939,13 +930,13 @@ TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns2) {
|
| EXPECT_EQ(0u, host_resolver.num_resolve());
|
| }
|
|
|
| -TEST_F(ProxyResolverV8TracingTest,
|
| +TEST_F(ProxyResolverV8TracingWrapperTest,
|
| CancelCreateResolverWhileOutstandingBlockingDns) {
|
| BlockableHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| - ProxyResolverFactoryV8Tracing factory(
|
| - &host_resolver, nullptr, ProxyResolver::LoadStateChangedCallback(),
|
| + ProxyResolverFactoryV8TracingWrapper factory(
|
| + &host_resolver, nullptr,
|
| base::Bind(&ReturnErrorObserver,
|
| base::Passed(make_scoped_ptr(error_observer))));
|
|
|
| @@ -962,15 +953,16 @@ TEST_F(ProxyResolverV8TracingTest,
|
| EXPECT_EQ(1, host_resolver.num_cancelled_requests());
|
| }
|
|
|
| -TEST_F(ProxyResolverV8TracingTest, DeleteFactoryWhileOutstandingBlockingDns) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest,
|
| + DeleteFactoryWhileOutstandingBlockingDns) {
|
| BlockableHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| scoped_ptr<ProxyResolver> resolver;
|
| scoped_ptr<ProxyResolverFactory::Request> request;
|
| {
|
| - ProxyResolverFactoryV8Tracing factory(
|
| - &host_resolver, nullptr, ProxyResolver::LoadStateChangedCallback(),
|
| + ProxyResolverFactoryV8TracingWrapper factory(
|
| + &host_resolver, nullptr,
|
| base::Bind(&ReturnErrorObserver,
|
| base::Passed(make_scoped_ptr(error_observer))));
|
|
|
| @@ -983,12 +975,12 @@ TEST_F(ProxyResolverV8TracingTest, DeleteFactoryWhileOutstandingBlockingDns) {
|
| EXPECT_EQ(1, host_resolver.num_cancelled_requests());
|
| }
|
|
|
| -TEST_F(ProxyResolverV8TracingTest, ErrorLoadingScript) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, ErrorLoadingScript) {
|
| BlockableHostResolver host_resolver;
|
| MockErrorObserver* error_observer = new MockErrorObserver;
|
|
|
| - ProxyResolverFactoryV8Tracing factory(
|
| - &host_resolver, nullptr, ProxyResolver::LoadStateChangedCallback(),
|
| + ProxyResolverFactoryV8TracingWrapper factory(
|
| + &host_resolver, nullptr,
|
| base::Bind(&ReturnErrorObserver,
|
| base::Passed(make_scoped_ptr(error_observer))));
|
|
|
| @@ -1005,7 +997,7 @@ TEST_F(ProxyResolverV8TracingTest, ErrorLoadingScript) {
|
|
|
| // This tests that the execution of a PAC script is terminated when the DNS
|
| // dependencies are missing. If the test fails, then it will hang.
|
| -TEST_F(ProxyResolverV8TracingTest, Terminate) {
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, Terminate) {
|
| TestNetLog log;
|
| BoundTestNetLog request_log;
|
| MockCachingHostResolver host_resolver;
|
| @@ -1039,25 +1031,26 @@ TEST_F(ProxyResolverV8TracingTest, Terminate) {
|
| EXPECT_EQ(0u, request_log.GetSize());
|
| }
|
|
|
| -// Tests that multiple instances of ProxyResolverV8Tracing can coexist and run
|
| -// correctly at the same time. This is relevant because at the moment (time
|
| -// this test was written) each ProxyResolverV8Tracing creates its own thread to
|
| -// run V8 on, however each thread is operating on the same v8::Isolate.
|
| -TEST_F(ProxyResolverV8TracingTest, MultipleResolvers) {
|
| +// Tests that multiple instances of ProxyResolverV8TracingWrapper can coexist
|
| +// and run correctly at the same time. This is relevant because at the moment
|
| +// (time this test was written) each ProxyResolverV8TracingWrapper creates its
|
| +// own thread to run V8 on, however each thread is operating on the same
|
| +// v8::Isolate.
|
| +TEST_F(ProxyResolverV8TracingWrapperTest, MultipleResolvers) {
|
| // ------------------------
|
| // Setup resolver0
|
| // ------------------------
|
| MockHostResolver host_resolver0;
|
| - host_resolver0.rules()->AddRuleForAddressFamily(
|
| - "host1", ADDRESS_FAMILY_IPV4, "166.155.144.44");
|
| - host_resolver0.rules()
|
| - ->AddIPLiteralRule("host1", "::1,192.168.1.1", std::string());
|
| + host_resolver0.rules()->AddRuleForAddressFamily("host1", ADDRESS_FAMILY_IPV4,
|
| + "166.155.144.44");
|
| + host_resolver0.rules()->AddIPLiteralRule("host1", "::1,192.168.1.1",
|
| + std::string());
|
| host_resolver0.rules()->AddSimulatedFailure("host2");
|
| host_resolver0.rules()->AddRule("host3", "166.155.144.33");
|
| host_resolver0.rules()->AddRule("host5", "166.155.144.55");
|
| host_resolver0.rules()->AddSimulatedFailure("host6");
|
| - host_resolver0.rules()->AddRuleForAddressFamily(
|
| - "*", ADDRESS_FAMILY_IPV4, "122.133.144.155");
|
| + host_resolver0.rules()->AddRuleForAddressFamily("*", ADDRESS_FAMILY_IPV4,
|
| + "122.133.144.155");
|
| host_resolver0.rules()->AddRule("*", "133.122.100.200");
|
| scoped_ptr<ProxyResolver> resolver0 =
|
| CreateResolver(nullptr, &host_resolver0,
|
| @@ -1113,20 +1106,20 @@ TEST_F(ProxyResolverV8TracingTest, MultipleResolvers) {
|
| // ------------------------
|
|
|
| const char* kExpectedForDnsJs =
|
| - "122.133.144.155-" // myIpAddress()
|
| - "null-" // dnsResolve('')
|
| - "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| - "null-" // dnsResolve('host2')
|
| - "166.155.144.33-" // dnsResolve('host3')
|
| - "122.133.144.155-" // myIpAddress()
|
| - "166.155.144.33-" // dnsResolve('host3')
|
| - "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| - "122.133.144.155-" // myIpAddress()
|
| - "null-" // dnsResolve('host2')
|
| - "-" // dnsResolveEx('host6')
|
| - "133.122.100.200-" // myIpAddressEx()
|
| - "166.155.144.44" // dnsResolve('host1')
|
| - ":99";
|
| + "122.133.144.155-" // myIpAddress()
|
| + "null-" // dnsResolve('')
|
| + "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| + "null-" // dnsResolve('host2')
|
| + "166.155.144.33-" // dnsResolve('host3')
|
| + "122.133.144.155-" // myIpAddress()
|
| + "166.155.144.33-" // dnsResolve('host3')
|
| + "__1_192.168.1.1-" // dnsResolveEx('host1')
|
| + "122.133.144.155-" // myIpAddress()
|
| + "null-" // dnsResolve('host2')
|
| + "-" // dnsResolveEx('host6')
|
| + "133.122.100.200-" // myIpAddressEx()
|
| + "166.155.144.44" // dnsResolve('host1')
|
| + ":99";
|
|
|
| for (size_t i = 0; i < kNumResults; ++i) {
|
| size_t resolver_i = i % kNumResolvers;
|
|
|