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 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 | 1556 |
1557 proc_->SignalMultiple(requests_.size()); | 1557 proc_->SignalMultiple(requests_.size()); |
1558 | 1558 |
1559 for (size_t i = 0; i < 2; ++i) | 1559 for (size_t i = 0; i < 2; ++i) |
1560 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[i]->WaitForResult()) << i; | 1560 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[i]->WaitForResult()) << i; |
1561 | 1561 |
1562 for (size_t i = 2; i < requests_.size(); ++i) | 1562 for (size_t i = 2; i < requests_.size(); ++i) |
1563 EXPECT_EQ(OK, requests_[i]->WaitForResult()) << i; | 1563 EXPECT_EQ(OK, requests_[i]->WaitForResult()) << i; |
1564 } | 1564 } |
1565 | 1565 |
| 1566 TEST_F(HostResolverImplDnsTest, SystemOnlyBypassesDnsTask) { |
| 1567 ChangeDnsConfig(CreateValidDnsConfig()); |
| 1568 |
| 1569 proc_->AddRuleForAllFamilies(std::string(), std::string()); |
| 1570 |
| 1571 HostResolver::RequestInfo info_bypass(HostPortPair("ok", 80)); |
| 1572 info_bypass.set_host_resolver_flags(HOST_RESOLVER_SYSTEM_ONLY); |
| 1573 EXPECT_EQ(ERR_IO_PENDING, CreateRequest(info_bypass, MEDIUM)->Resolve()); |
| 1574 |
| 1575 HostResolver::RequestInfo info(HostPortPair("ok", 80)); |
| 1576 EXPECT_EQ(ERR_IO_PENDING, CreateRequest(info, MEDIUM)->Resolve()); |
| 1577 |
| 1578 proc_->SignalMultiple(requests_.size()); |
| 1579 |
| 1580 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[0]->WaitForResult()); |
| 1581 EXPECT_EQ(OK, requests_[1]->WaitForResult()); |
| 1582 } |
| 1583 |
1566 TEST_F(HostResolverImplDnsTest, DisableDnsClientOnPersistentFailure) { | 1584 TEST_F(HostResolverImplDnsTest, DisableDnsClientOnPersistentFailure) { |
1567 ChangeDnsConfig(CreateValidDnsConfig()); | 1585 ChangeDnsConfig(CreateValidDnsConfig()); |
1568 | 1586 |
1569 proc_->AddRuleForAllFamilies(std::string(), | 1587 proc_->AddRuleForAllFamilies(std::string(), |
1570 std::string()); // Default to failures. | 1588 std::string()); // Default to failures. |
1571 | 1589 |
1572 // Check that DnsTask works. | 1590 // Check that DnsTask works. |
1573 Request* req = CreateRequest("ok_1", 80); | 1591 Request* req = CreateRequest("ok_1", 80); |
1574 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 1592 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
1575 EXPECT_EQ(OK, req->WaitForResult()); | 1593 EXPECT_EQ(OK, req->WaitForResult()); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 | 2047 |
2030 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 2048 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
2031 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); | 2049 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); |
2032 EXPECT_EQ(OK, requests_[1]->WaitForResult()); | 2050 EXPECT_EQ(OK, requests_[1]->WaitForResult()); |
2033 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); | 2051 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); |
2034 EXPECT_EQ(OK, requests_[2]->WaitForResult()); | 2052 EXPECT_EQ(OK, requests_[2]->WaitForResult()); |
2035 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); | 2053 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); |
2036 } | 2054 } |
2037 | 2055 |
2038 } // namespace net | 2056 } // namespace net |
OLD | NEW |