| 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 524 |
| 525 Request* req = CreateRequest("just.testing", 80); | 525 Request* req = CreateRequest("just.testing", 80); |
| 526 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 526 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
| 527 EXPECT_EQ(OK, req->WaitForResult()); | 527 EXPECT_EQ(OK, req->WaitForResult()); |
| 528 | 528 |
| 529 EXPECT_TRUE(req->HasOneAddress("192.168.1.42", 80)); | 529 EXPECT_TRUE(req->HasOneAddress("192.168.1.42", 80)); |
| 530 | 530 |
| 531 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); | 531 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); |
| 532 } | 532 } |
| 533 | 533 |
| 534 TEST_F(HostResolverImplTest, EmptyListMeansNameNotResolved) { |
| 535 proc_->AddRuleForAllFamilies("just.testing", ""); |
| 536 proc_->SignalMultiple(1u); |
| 537 |
| 538 Request* req = CreateRequest("just.testing", 80); |
| 539 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
| 540 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult()); |
| 541 EXPECT_EQ(0u, req->NumberOfAddresses()); |
| 542 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); |
| 543 } |
| 544 |
| 534 TEST_F(HostResolverImplTest, FailedAsynchronousLookup) { | 545 TEST_F(HostResolverImplTest, FailedAsynchronousLookup) { |
| 535 proc_->AddRuleForAllFamilies(std::string(), | 546 proc_->AddRuleForAllFamilies(std::string(), |
| 536 "0.0.0.0"); // Default to failures. | 547 "0.0.0.0"); // Default to failures. |
| 537 proc_->SignalMultiple(1u); | 548 proc_->SignalMultiple(1u); |
| 538 | 549 |
| 539 Request* req = CreateRequest("just.testing", 80); | 550 Request* req = CreateRequest("just.testing", 80); |
| 540 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 551 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
| 541 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult()); | 552 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult()); |
| 542 | 553 |
| 543 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); | 554 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 ChangeDnsConfig(config); | 1555 ChangeDnsConfig(config); |
| 1545 req = CreateRequest(info); | 1556 req = CreateRequest(info); |
| 1546 // Expect synchronous resolution from DnsHosts. | 1557 // Expect synchronous resolution from DnsHosts. |
| 1547 EXPECT_EQ(OK, req->Resolve()); | 1558 EXPECT_EQ(OK, req->Resolve()); |
| 1548 | 1559 |
| 1549 EXPECT_EQ(saw_ipv4, req->HasAddress("127.0.0.1", 80)); | 1560 EXPECT_EQ(saw_ipv4, req->HasAddress("127.0.0.1", 80)); |
| 1550 EXPECT_EQ(saw_ipv6, req->HasAddress("::1", 80)); | 1561 EXPECT_EQ(saw_ipv6, req->HasAddress("::1", 80)); |
| 1551 } | 1562 } |
| 1552 | 1563 |
| 1553 } // namespace net | 1564 } // namespace net |
| OLD | NEW |