| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dns/host_resolver_impl.h" | 5 #include "net/dns/host_resolver_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 return test->CreateRequest(hostname); | 453 return test->CreateRequest(hostname); |
| 454 } | 454 } |
| 455 ScopedVector<Request>& requests() { return test->requests_; } | 455 ScopedVector<Request>& requests() { return test->requests_; } |
| 456 | 456 |
| 457 void DeleteResolver() { test->resolver_.reset(); } | 457 void DeleteResolver() { test->resolver_.reset(); } |
| 458 | 458 |
| 459 HostResolverImplTest* test; | 459 HostResolverImplTest* test; |
| 460 }; | 460 }; |
| 461 | 461 |
| 462 // testing::Test implementation: | 462 // testing::Test implementation: |
| 463 virtual void SetUp() override { | 463 void SetUp() override { CreateResolver(); } |
| 464 CreateResolver(); | |
| 465 } | |
| 466 | 464 |
| 467 virtual void TearDown() override { | 465 void TearDown() override { |
| 468 if (resolver_.get()) | 466 if (resolver_.get()) |
| 469 EXPECT_EQ(0u, resolver_->num_running_dispatcher_jobs_for_tests()); | 467 EXPECT_EQ(0u, resolver_->num_running_dispatcher_jobs_for_tests()); |
| 470 EXPECT_FALSE(proc_->HasBlockedRequests()); | 468 EXPECT_FALSE(proc_->HasBlockedRequests()); |
| 471 } | 469 } |
| 472 | 470 |
| 473 virtual void CreateResolverWithLimitsAndParams( | 471 virtual void CreateResolverWithLimitsAndParams( |
| 474 size_t max_concurrent_resolves, | 472 size_t max_concurrent_resolves, |
| 475 const HostResolverImpl::ProcTaskParams& params) { | 473 const HostResolverImpl::ProcTaskParams& params) { |
| 476 HostResolverImpl::Options options = DefaultOptions(); | 474 HostResolverImpl::Options options = DefaultOptions(); |
| 477 options.max_concurrent_resolves = max_concurrent_resolves; | 475 options.max_concurrent_resolves = max_concurrent_resolves; |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 return config; | 1330 return config; |
| 1333 } | 1331 } |
| 1334 | 1332 |
| 1335 // Specialized fixture for tests of DnsTask. | 1333 // Specialized fixture for tests of DnsTask. |
| 1336 class HostResolverImplDnsTest : public HostResolverImplTest { | 1334 class HostResolverImplDnsTest : public HostResolverImplTest { |
| 1337 public: | 1335 public: |
| 1338 HostResolverImplDnsTest() : dns_client_(NULL) {} | 1336 HostResolverImplDnsTest() : dns_client_(NULL) {} |
| 1339 | 1337 |
| 1340 protected: | 1338 protected: |
| 1341 // testing::Test implementation: | 1339 // testing::Test implementation: |
| 1342 virtual void SetUp() override { | 1340 void SetUp() override { |
| 1343 AddDnsRule("nx", dns_protocol::kTypeA, MockDnsClientRule::FAIL, false); | 1341 AddDnsRule("nx", dns_protocol::kTypeA, MockDnsClientRule::FAIL, false); |
| 1344 AddDnsRule("nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); | 1342 AddDnsRule("nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); |
| 1345 AddDnsRule("ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1343 AddDnsRule("ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
| 1346 AddDnsRule("ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); | 1344 AddDnsRule("ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); |
| 1347 AddDnsRule("4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1345 AddDnsRule("4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
| 1348 AddDnsRule("4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); | 1346 AddDnsRule("4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); |
| 1349 AddDnsRule("6ok", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); | 1347 AddDnsRule("6ok", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); |
| 1350 AddDnsRule("6ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); | 1348 AddDnsRule("6ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); |
| 1351 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1349 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
| 1352 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); | 1350 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 | 2096 |
| 2099 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 2097 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
| 2100 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); | 2098 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); |
| 2101 EXPECT_EQ(OK, requests_[1]->WaitForResult()); | 2099 EXPECT_EQ(OK, requests_[1]->WaitForResult()); |
| 2102 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); | 2100 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); |
| 2103 EXPECT_EQ(OK, requests_[2]->WaitForResult()); | 2101 EXPECT_EQ(OK, requests_[2]->WaitForResult()); |
| 2104 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); | 2102 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); |
| 2105 } | 2103 } |
| 2106 | 2104 |
| 2107 } // namespace net | 2105 } // namespace net |
| OLD | NEW |