| 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 #include <tuple> | 9 #include <tuple> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 | 666 |
| 667 Request* req4 = CreateRequest("localhost", 80, MEDIUM, ADDRESS_FAMILY_IPV4); | 667 Request* req4 = CreateRequest("localhost", 80, MEDIUM, ADDRESS_FAMILY_IPV4); |
| 668 EXPECT_EQ(OK, req4->Resolve()); | 668 EXPECT_EQ(OK, req4->Resolve()); |
| 669 EXPECT_TRUE(req4->HasOneAddress("127.0.0.1", 80)); | 669 EXPECT_TRUE(req4->HasOneAddress("127.0.0.1", 80)); |
| 670 | 670 |
| 671 Request* req5 = CreateRequest("localhost", 80, MEDIUM, ADDRESS_FAMILY_IPV6); | 671 Request* req5 = CreateRequest("localhost", 80, MEDIUM, ADDRESS_FAMILY_IPV6); |
| 672 EXPECT_EQ(OK, req5->Resolve()); | 672 EXPECT_EQ(OK, req5->Resolve()); |
| 673 EXPECT_TRUE(req5->HasOneAddress("::1", 80)); | 673 EXPECT_TRUE(req5->HasOneAddress("::1", 80)); |
| 674 } | 674 } |
| 675 | 675 |
| 676 TEST_F(HostResolverImplTest, ResolveIPLiteralWithHostResolverSystemOnly) { |
| 677 const char kIpLiteral[] = "178.78.32.1"; |
| 678 // Add a mapping to tell if the resolver proc was called (if it was called, |
| 679 // then the result will be the remapped value. Otherwise it will be the IP |
| 680 // literal). |
| 681 proc_->AddRuleForAllFamilies(kIpLiteral, "183.45.32.1"); |
| 682 |
| 683 HostResolver::RequestInfo info_bypass(HostPortPair(kIpLiteral, 80)); |
| 684 info_bypass.set_host_resolver_flags(HOST_RESOLVER_SYSTEM_ONLY); |
| 685 |
| 686 Request* req = CreateRequest(info_bypass, MEDIUM); |
| 687 EXPECT_EQ(OK, req->Resolve()); |
| 688 |
| 689 EXPECT_TRUE(req->HasAddress(kIpLiteral, 80)); |
| 690 } |
| 691 |
| 676 TEST_F(HostResolverImplTest, EmptyListMeansNameNotResolved) { | 692 TEST_F(HostResolverImplTest, EmptyListMeansNameNotResolved) { |
| 677 proc_->AddRuleForAllFamilies("just.testing", ""); | 693 proc_->AddRuleForAllFamilies("just.testing", ""); |
| 678 proc_->SignalMultiple(1u); | 694 proc_->SignalMultiple(1u); |
| 679 | 695 |
| 680 Request* req = CreateRequest("just.testing", 80); | 696 Request* req = CreateRequest("just.testing", 80); |
| 681 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 697 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
| 682 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult()); | 698 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult()); |
| 683 EXPECT_EQ(0u, req->NumberOfAddresses()); | 699 EXPECT_EQ(0u, req->NumberOfAddresses()); |
| 684 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); | 700 EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname); |
| 685 } | 701 } |
| (...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 EXPECT_FALSE(ResolveLocalHostname("::1:1", kLocalhostLookupPort, &addresses)); | 2287 EXPECT_FALSE(ResolveLocalHostname("::1:1", kLocalhostLookupPort, &addresses)); |
| 2272 EXPECT_FALSE(ResolveLocalHostname("0:0:0:0:0:0:0:0:1", kLocalhostLookupPort, | 2288 EXPECT_FALSE(ResolveLocalHostname("0:0:0:0:0:0:0:0:1", kLocalhostLookupPort, |
| 2273 &addresses)); | 2289 &addresses)); |
| 2274 EXPECT_FALSE(ResolveLocalHostname("foo.localhost.com", kLocalhostLookupPort, | 2290 EXPECT_FALSE(ResolveLocalHostname("foo.localhost.com", kLocalhostLookupPort, |
| 2275 &addresses)); | 2291 &addresses)); |
| 2276 EXPECT_FALSE( | 2292 EXPECT_FALSE( |
| 2277 ResolveLocalHostname("foo.localhoste", kLocalhostLookupPort, &addresses)); | 2293 ResolveLocalHostname("foo.localhoste", kLocalhostLookupPort, &addresses)); |
| 2278 } | 2294 } |
| 2279 | 2295 |
| 2280 } // namespace net | 2296 } // namespace net |
| OLD | NEW |