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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 543 |
544 Request* req = CreateRequest("just.testing", 80); | 544 Request* req = CreateRequest("just.testing", 80); |
545 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 545 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
546 EXPECT_EQ(OK, req->WaitForResult()); | 546 EXPECT_EQ(OK, req->WaitForResult()); |
547 | 547 |
548 EXPECT_TRUE(req->HasOneAddress("192.168.1.42", 80)); | 548 EXPECT_TRUE(req->HasOneAddress("192.168.1.42", 80)); |
549 | 549 |
550 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); | 550 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); |
551 } | 551 } |
552 | 552 |
| 553 TEST_F(HostResolverImplTest, LocalhostLookup) { |
| 554 proc_->SignalMultiple(1u); |
| 555 Request* req = CreateRequest("foo.localhost", 80); |
| 556 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
| 557 EXPECT_EQ(OK, req->WaitForResult()); |
| 558 |
| 559 EXPECT_TRUE(req->HasOneAddress("127.0.0.1", 80)); |
| 560 |
| 561 EXPECT_EQ("localhost.", proc_->GetCaptureList()[0].hostname); |
| 562 } |
| 563 |
553 TEST_F(HostResolverImplTest, EmptyListMeansNameNotResolved) { | 564 TEST_F(HostResolverImplTest, EmptyListMeansNameNotResolved) { |
554 proc_->AddRuleForAllFamilies("just.testing", ""); | 565 proc_->AddRuleForAllFamilies("just.testing", ""); |
555 proc_->SignalMultiple(1u); | 566 proc_->SignalMultiple(1u); |
556 | 567 |
557 Request* req = CreateRequest("just.testing", 80); | 568 Request* req = CreateRequest("just.testing", 80); |
558 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 569 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
559 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult()); | 570 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult()); |
560 EXPECT_EQ(0u, req->NumberOfAddresses()); | 571 EXPECT_EQ(0u, req->NumberOfAddresses()); |
561 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); | 572 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); |
562 } | 573 } |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 | 2107 |
2097 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 2108 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
2098 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); | 2109 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); |
2099 EXPECT_EQ(OK, requests_[1]->WaitForResult()); | 2110 EXPECT_EQ(OK, requests_[1]->WaitForResult()); |
2100 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); | 2111 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); |
2101 EXPECT_EQ(OK, requests_[2]->WaitForResult()); | 2112 EXPECT_EQ(OK, requests_[2]->WaitForResult()); |
2102 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); | 2113 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); |
2103 } | 2114 } |
2104 | 2115 |
2105 } // namespace net | 2116 } // namespace net |
OLD | NEW |