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 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1512 | 1512 |
1513 proc_->SignalMultiple(requests_.size()); | 1513 proc_->SignalMultiple(requests_.size()); |
1514 | 1514 |
1515 for (size_t i = 0; i < 2; ++i) | 1515 for (size_t i = 0; i < 2; ++i) |
1516 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[i]->WaitForResult()) << i; | 1516 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[i]->WaitForResult()) << i; |
1517 | 1517 |
1518 for (size_t i = 2; i < requests_.size(); ++i) | 1518 for (size_t i = 2; i < requests_.size(); ++i) |
1519 EXPECT_EQ(OK, requests_[i]->WaitForResult()) << i; | 1519 EXPECT_EQ(OK, requests_[i]->WaitForResult()) << i; |
1520 } | 1520 } |
1521 | 1521 |
1522 TEST_F(HostResolverImplDnsTest, SystemOnlyBypassesDnsTask) { | |
1523 ChangeDnsConfig(CreateValidDnsConfig()); | |
1524 | |
1525 proc_->AddRuleForAllFamilies(std::string(), std::string()); | |
1526 | |
1527 HostResolver::RequestInfo info_native(HostPortPair("ok", 80)); | |
szym
2013/09/17 19:24:23
suggest info_bypass
| |
1528 info_native.set_host_resolver_flags(HOST_RESOLVER_SYSTEM_ONLY); | |
1529 EXPECT_EQ(ERR_IO_PENDING, CreateRequest(info_native, MEDIUM)->Resolve()); | |
1530 | |
1531 HostResolver::RequestInfo info(HostPortPair("ok", 80)); | |
1532 EXPECT_EQ(ERR_IO_PENDING, CreateRequest(info, MEDIUM)->Resolve()); | |
1533 | |
1534 proc_->SignalMultiple(requests_.size()); | |
1535 | |
1536 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[0]->WaitForResult()); | |
1537 EXPECT_EQ(OK, requests_[1]->WaitForResult()); | |
1538 } | |
1539 | |
1522 TEST_F(HostResolverImplDnsTest, DisableDnsClientOnPersistentFailure) { | 1540 TEST_F(HostResolverImplDnsTest, DisableDnsClientOnPersistentFailure) { |
1523 ChangeDnsConfig(CreateValidDnsConfig()); | 1541 ChangeDnsConfig(CreateValidDnsConfig()); |
1524 | 1542 |
1525 proc_->AddRuleForAllFamilies(std::string(), | 1543 proc_->AddRuleForAllFamilies(std::string(), |
1526 std::string()); // Default to failures. | 1544 std::string()); // Default to failures. |
1527 | 1545 |
1528 // Check that DnsTask works. | 1546 // Check that DnsTask works. |
1529 Request* req = CreateRequest("ok_1", 80); | 1547 Request* req = CreateRequest("ok_1", 80); |
1530 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 1548 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
1531 EXPECT_EQ(OK, req->WaitForResult()); | 1549 EXPECT_EQ(OK, req->WaitForResult()); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1642 ChangeDnsConfig(config); | 1660 ChangeDnsConfig(config); |
1643 req = CreateRequest(info, DEFAULT_PRIORITY); | 1661 req = CreateRequest(info, DEFAULT_PRIORITY); |
1644 // Expect synchronous resolution from DnsHosts. | 1662 // Expect synchronous resolution from DnsHosts. |
1645 EXPECT_EQ(OK, req->Resolve()); | 1663 EXPECT_EQ(OK, req->Resolve()); |
1646 | 1664 |
1647 EXPECT_EQ(saw_ipv4, req->HasAddress("127.0.0.1", 80)); | 1665 EXPECT_EQ(saw_ipv4, req->HasAddress("127.0.0.1", 80)); |
1648 EXPECT_EQ(saw_ipv6, req->HasAddress("::1", 80)); | 1666 EXPECT_EQ(saw_ipv6, req->HasAddress("::1", 80)); |
1649 } | 1667 } |
1650 | 1668 |
1651 } // namespace net | 1669 } // namespace net |
OLD | NEW |