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/base/host_resolver_impl.h" | 5 #include "net/base/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 25 matching lines...) Expand all Loading... | |
36 PrioritizedDispatcher::Limits DefaultLimits() { | 36 PrioritizedDispatcher::Limits DefaultLimits() { |
37 PrioritizedDispatcher::Limits limits(NUM_PRIORITIES, kMaxJobs); | 37 PrioritizedDispatcher::Limits limits(NUM_PRIORITIES, kMaxJobs); |
38 return limits; | 38 return limits; |
39 } | 39 } |
40 | 40 |
41 HostResolverImpl::ProcTaskParams DefaultParams( | 41 HostResolverImpl::ProcTaskParams DefaultParams( |
42 HostResolverProc* resolver_proc) { | 42 HostResolverProc* resolver_proc) { |
43 return HostResolverImpl::ProcTaskParams(resolver_proc, kMaxRetryAttempts); | 43 return HostResolverImpl::ProcTaskParams(resolver_proc, kMaxRetryAttempts); |
44 } | 44 } |
45 | 45 |
46 HostResolverImpl* CreateHostResolverImpl(HostResolverProc* resolver_proc) { | |
47 return new HostResolverImpl( | |
48 HostCache::CreateDefaultCache(), | |
49 DefaultLimits(), | |
50 DefaultParams(resolver_proc), | |
51 scoped_ptr<DnsConfigService>(NULL), | |
52 scoped_ptr<DnsClient>(NULL), | |
53 NULL); | |
54 } | |
55 | |
56 HostResolverImpl* CreateHostResolverImplWithDnsClient( | |
57 HostResolverProc* resolver_proc, | |
58 scoped_ptr<DnsConfigService> dns_config_service) { | |
59 // Initially with empty DnsConfig. Use |dns_config_service| to update it. | |
60 return new HostResolverImpl( | |
61 HostCache::CreateDefaultCache(), | |
62 DefaultLimits(), | |
63 DefaultParams(resolver_proc), | |
64 dns_config_service.Pass(), | |
65 CreateMockDnsClient(DnsConfig()), | |
66 NULL); | |
67 } | |
68 | |
69 // This HostResolverImpl will only allow 1 outstanding resolve at a time. | |
70 HostResolverImpl* CreateSerialHostResolverImpl( | |
71 HostResolverProc* resolver_proc) { | |
72 HostResolverImpl::ProcTaskParams params = DefaultParams(resolver_proc); | |
73 params.max_retry_attempts = 0u; | |
74 | |
75 PrioritizedDispatcher::Limits limits(NUM_PRIORITIES, 1); | |
76 | |
77 return new HostResolverImpl( | |
78 HostCache::CreateDefaultCache(), | |
79 limits, | |
80 params, | |
81 scoped_ptr<DnsConfigService>(NULL), | |
82 scoped_ptr<DnsClient>(NULL), | |
83 NULL); | |
84 } | |
85 | |
86 // A HostResolverProc that pushes each host mapped into a list and allows | 46 // A HostResolverProc that pushes each host mapped into a list and allows |
87 // waiting for a specific number of requests. Unlike RuleBasedHostResolverProc | 47 // waiting for a specific number of requests. Unlike RuleBasedHostResolverProc |
88 // it never calls SystemHostResolverProc. By default resolves all hostnames to | 48 // it never calls SystemHostResolverProc. By default resolves all hostnames to |
89 // "127.0.0.1". After AddRule(), it resolves only names explicitly specified. | 49 // "127.0.0.1". After AddRule(), it resolves only names explicitly specified. |
90 class MockHostResolverProc : public HostResolverProc { | 50 class MockHostResolverProc : public HostResolverProc { |
91 public: | 51 public: |
92 struct ResolveKey { | 52 struct ResolveKey { |
93 ResolveKey(const std::string& hostname, AddressFamily address_family) | 53 ResolveKey(const std::string& hostname, AddressFamily address_family) |
94 : hostname(hostname), address_family(address_family) {} | 54 : hostname(hostname), address_family(address_family) {} |
95 bool operator<(const ResolveKey& other) const { | 55 bool operator<(const ResolveKey& other) const { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 base::ConditionVariable all_done_; | 400 base::ConditionVariable all_done_; |
441 }; | 401 }; |
442 | 402 |
443 } // namespace | 403 } // namespace |
444 | 404 |
445 class HostResolverImplTest : public testing::Test { | 405 class HostResolverImplTest : public testing::Test { |
446 public: | 406 public: |
447 static const int kDefaultPort = 80; | 407 static const int kDefaultPort = 80; |
448 | 408 |
449 HostResolverImplTest() | 409 HostResolverImplTest() |
450 : proc_(new MockHostResolverProc()), | 410 : proc_(new MockHostResolverProc()) { |
mmenke
2012/06/07 18:32:34
nit: Think this can all fit on one line now.
| |
451 resolver_(CreateHostResolverImpl(proc_)) { | |
452 } | 411 } |
453 | 412 |
454 protected: | 413 protected: |
455 // A Request::Handler which is a proxy to the HostResolverImplTest fixture. | 414 // A Request::Handler which is a proxy to the HostResolverImplTest fixture. |
456 struct Handler : public Request::Handler { | 415 struct Handler : public Request::Handler { |
457 virtual ~Handler() {} | 416 virtual ~Handler() {} |
458 | 417 |
459 // Proxy functions so that classes derived from Handler can access them. | 418 // Proxy functions so that classes derived from Handler can access them. |
460 Request* CreateRequest(const HostResolver::RequestInfo& info) { | 419 Request* CreateRequest(const HostResolver::RequestInfo& info) { |
461 return test->CreateRequest(info); | 420 return test->CreateRequest(info); |
462 } | 421 } |
463 Request* CreateRequest(const std::string& hostname, int port) { | 422 Request* CreateRequest(const std::string& hostname, int port) { |
464 return test->CreateRequest(hostname, port); | 423 return test->CreateRequest(hostname, port); |
465 } | 424 } |
466 Request* CreateRequest(const std::string& hostname) { | 425 Request* CreateRequest(const std::string& hostname) { |
467 return test->CreateRequest(hostname); | 426 return test->CreateRequest(hostname); |
468 } | 427 } |
469 ScopedVector<Request>& requests() { return test->requests_; } | 428 ScopedVector<Request>& requests() { return test->requests_; } |
470 | 429 |
471 void DeleteResolver() { test->resolver_.reset(); } | 430 void DeleteResolver() { test->resolver_.reset(); } |
472 | 431 |
473 HostResolverImplTest* test; | 432 HostResolverImplTest* test; |
474 }; | 433 }; |
475 | 434 |
435 void CreateResolver() { | |
436 resolver_.reset(new HostResolverImpl( | |
437 HostCache::CreateDefaultCache(), | |
438 DefaultLimits(), | |
439 DefaultParams(proc_), | |
440 scoped_ptr<DnsConfigService>(NULL), | |
441 scoped_ptr<DnsClient>(NULL), | |
442 NULL)); | |
443 } | |
444 | |
445 // This HostResolverImpl will only allow 1 outstanding resolve at a time and | |
446 // perform no retries. | |
476 void CreateSerialResolver() { | 447 void CreateSerialResolver() { |
477 resolver_.reset(CreateSerialHostResolverImpl(proc_)); | 448 HostResolverImpl::ProcTaskParams params = DefaultParams(proc_); |
449 params.max_retry_attempts = 0u; | |
450 PrioritizedDispatcher::Limits limits(NUM_PRIORITIES, 1); | |
451 resolver_.reset(new HostResolverImpl( | |
452 HostCache::CreateDefaultCache(), | |
453 limits, | |
454 params, | |
455 scoped_ptr<DnsConfigService>(NULL), | |
456 scoped_ptr<DnsClient>(NULL), | |
457 NULL)); | |
478 } | 458 } |
479 | 459 |
480 // The Request will not be made until a call to |Resolve()|, and the Job will | 460 // The Request will not be made until a call to |Resolve()|, and the Job will |
481 // not start until released by |proc_->SignalXXX|. | 461 // not start until released by |proc_->SignalXXX|. |
482 Request* CreateRequest(const HostResolver::RequestInfo& info) { | 462 Request* CreateRequest(const HostResolver::RequestInfo& info) { |
483 Request* req = new Request(info, requests_.size(), resolver_.get(), | 463 Request* req = new Request(info, requests_.size(), resolver_.get(), |
484 handler_.get()); | 464 handler_.get()); |
485 requests_.push_back(req); | 465 requests_.push_back(req); |
486 return req; | 466 return req; |
487 } | 467 } |
(...skipping 15 matching lines...) Expand all Loading... | |
503 } | 483 } |
504 | 484 |
505 Request* CreateRequest(const std::string& hostname, int port) { | 485 Request* CreateRequest(const std::string& hostname, int port) { |
506 return CreateRequest(hostname, port, MEDIUM); | 486 return CreateRequest(hostname, port, MEDIUM); |
507 } | 487 } |
508 | 488 |
509 Request* CreateRequest(const std::string& hostname) { | 489 Request* CreateRequest(const std::string& hostname) { |
510 return CreateRequest(hostname, kDefaultPort); | 490 return CreateRequest(hostname, kDefaultPort); |
511 } | 491 } |
512 | 492 |
513 void TearDown() OVERRIDE { | 493 virtual void SetUp() OVERRIDE { |
494 CreateResolver(); | |
495 } | |
496 | |
497 virtual void TearDown() OVERRIDE { | |
514 if (resolver_.get()) | 498 if (resolver_.get()) |
515 EXPECT_EQ(0u, resolver_->num_running_jobs_for_tests()); | 499 EXPECT_EQ(0u, resolver_->num_running_jobs_for_tests()); |
516 EXPECT_FALSE(proc_->HasBlockedRequests()); | 500 EXPECT_FALSE(proc_->HasBlockedRequests()); |
517 } | 501 } |
518 | 502 |
519 void set_handler(Handler* handler) { | 503 void set_handler(Handler* handler) { |
520 handler_.reset(handler); | 504 handler_.reset(handler); |
521 handler_->test = this; | 505 handler_->test = this; |
522 } | 506 } |
523 | 507 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 EXPECT_EQ(ERR_IO_PENDING, req0->Resolve()); | 550 EXPECT_EQ(ERR_IO_PENDING, req0->Resolve()); |
567 | 551 |
568 EXPECT_TRUE(proc_->WaitFor(1u)); | 552 EXPECT_TRUE(proc_->WaitFor(1u)); |
569 | 553 |
570 // Resolver is destroyed while job is running on WorkerPool. | 554 // Resolver is destroyed while job is running on WorkerPool. |
571 resolver_.reset(); | 555 resolver_.reset(); |
572 | 556 |
573 proc_->SignalAll(); | 557 proc_->SignalAll(); |
574 | 558 |
575 // To ensure there was no spurious callback, complete with a new resolver. | 559 // To ensure there was no spurious callback, complete with a new resolver. |
576 resolver_.reset(CreateHostResolverImpl(proc_)); | 560 CreateResolver(); |
577 Request* req1 = CreateRequest("just.testing", 80); | 561 Request* req1 = CreateRequest("just.testing", 80); |
578 EXPECT_EQ(ERR_IO_PENDING, req1->Resolve()); | 562 EXPECT_EQ(ERR_IO_PENDING, req1->Resolve()); |
579 | 563 |
580 proc_->SignalMultiple(2u); | 564 proc_->SignalMultiple(2u); |
581 | 565 |
582 EXPECT_EQ(OK, req1->WaitForResult()); | 566 EXPECT_EQ(OK, req1->WaitForResult()); |
583 | 567 |
584 // This request was canceled. | 568 // This request was canceled. |
585 EXPECT_FALSE(req0->completed()); | 569 EXPECT_FALSE(req0->completed()); |
586 } | 570 } |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1243 IPAddressNumber dns_ip; | 1227 IPAddressNumber dns_ip; |
1244 bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip); | 1228 bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip); |
1245 EXPECT_TRUE(rv); | 1229 EXPECT_TRUE(rv); |
1246 | 1230 |
1247 DnsConfig config; | 1231 DnsConfig config; |
1248 config.nameservers.push_back(IPEndPoint(dns_ip, dns_protocol::kDefaultPort)); | 1232 config.nameservers.push_back(IPEndPoint(dns_ip, dns_protocol::kDefaultPort)); |
1249 EXPECT_TRUE(config.IsValid()); | 1233 EXPECT_TRUE(config.IsValid()); |
1250 return config; | 1234 return config; |
1251 } | 1235 } |
1252 | 1236 |
1237 // Specialized fixture for tests of DnsTask. | |
1238 class HostResolverImplDnsTest : public HostResolverImplTest { | |
1239 protected: | |
1240 virtual void SetUp() OVERRIDE { | |
1241 config_service_ = new MockDnsConfigService(); | |
1242 resolver_.reset(new HostResolverImpl( | |
1243 HostCache::CreateDefaultCache(), | |
1244 DefaultLimits(), | |
1245 DefaultParams(proc_), | |
1246 scoped_ptr<DnsConfigService>(config_service_), | |
1247 CreateMockDnsClient(DnsConfig()), | |
1248 NULL)); | |
1249 } | |
1250 | |
1251 void ChangeDnsConfig(const DnsConfig& config) { | |
1252 config_service_->ChangeConfig(config); | |
1253 config_service_->ChangeHosts(config.hosts); | |
1254 } | |
1255 | |
1256 // Owned by |resolver_|. | |
1257 MockDnsConfigService* config_service_; | |
1258 }; | |
1259 | |
1253 // TODO(szym): Test AbortAllInProgressJobs due to DnsConfig change. | 1260 // TODO(szym): Test AbortAllInProgressJobs due to DnsConfig change. |
1254 | 1261 |
1255 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. | 1262 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. |
1256 | 1263 |
1257 // Test successful and fallback resolutions in HostResolverImpl::DnsTask. | 1264 // Test successful and fallback resolutions in HostResolverImpl::DnsTask. |
1258 TEST_F(HostResolverImplTest, DnsTask) { | 1265 TEST_F(HostResolverImplDnsTest, DnsTask) { |
1259 // Initially, there's DnsConfigService, but no DnsConfig. | 1266 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_IPV4); |
1260 // Note, |config_service| will be owned by |resolver_|. | |
1261 MockDnsConfigService* config_service = new MockDnsConfigService(); | |
1262 resolver_.reset( | |
1263 CreateHostResolverImplWithDnsClient( | |
1264 proc_, | |
1265 scoped_ptr<DnsConfigService>(config_service))); | |
1266 | 1267 |
1267 proc_->AddRuleForAllFamilies("er_succeed", "192.168.1.101"); | 1268 proc_->AddRuleForAllFamilies("er_succeed", "192.168.1.101"); |
1268 proc_->AddRuleForAllFamilies("nx_succeed", "192.168.1.102"); | 1269 proc_->AddRuleForAllFamilies("nx_succeed", "192.168.1.102"); |
1269 // All other hostnames will fail in proc_. | 1270 // All other hostnames will fail in proc_. |
1270 | 1271 |
1271 // Initially there is no config, so client should not be invoked. | 1272 // Initially there is no config, so client should not be invoked. |
1272 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("ok_fail", 80)->Resolve()); | 1273 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("ok_fail", 80)->Resolve()); |
1273 proc_->SignalMultiple(requests_->size()); | 1274 proc_->SignalMultiple(requests_->size()); |
1274 | 1275 |
1275 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[0]->WaitForResult()); | 1276 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[0]->WaitForResult()); |
1276 | 1277 |
1277 DnsConfig config = CreateValidDnsConfig(); | 1278 ChangeDnsConfig(CreateValidDnsConfig()); |
1278 config_service->ChangeHosts(config.hosts); | |
1279 config_service->ChangeConfig(config); | |
1280 | 1279 |
1281 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("ok_fail", 80)->Resolve()); | 1280 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("ok_fail", 80)->Resolve()); |
1282 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("er_fail", 80)->Resolve()); | 1281 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("er_fail", 80)->Resolve()); |
1283 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("nx_fail", 80)->Resolve()); | 1282 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("nx_fail", 80)->Resolve()); |
1284 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("er_succeed", 80)->Resolve()); | 1283 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("er_succeed", 80)->Resolve()); |
1285 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("nx_succeed", 80)->Resolve()); | 1284 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("nx_succeed", 80)->Resolve()); |
1286 | 1285 |
1287 proc_->SignalMultiple(requests_.size()); | 1286 proc_->SignalMultiple(requests_.size()); |
1288 | 1287 |
1289 for (size_t i = 0; i < requests_.size(); ++i) { | 1288 for (size_t i = 0; i < requests_.size(); ++i) { |
1290 EXPECT_NE(ERR_UNEXPECTED, requests_[i]->WaitForResult()) << 1; | 1289 EXPECT_NE(ERR_UNEXPECTED, requests_[i]->WaitForResult()) << 1; |
1291 } | 1290 } |
1292 | 1291 |
1293 EXPECT_EQ(OK, requests_[1]->result()); | 1292 EXPECT_EQ(OK, requests_[1]->result()); |
1294 // Resolved by MockDnsClient. | 1293 // Resolved by MockDnsClient. |
1295 EXPECT_TRUE(requests_[1]->HasOneAddress("127.0.0.1", 80)); | 1294 EXPECT_TRUE(requests_[1]->HasOneAddress("127.0.0.1", 80)); |
1296 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[2]->result()); | 1295 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[2]->result()); |
1297 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[3]->result()); | 1296 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, requests_[3]->result()); |
1298 EXPECT_EQ(OK, requests_[4]->result()); | 1297 EXPECT_EQ(OK, requests_[4]->result()); |
1299 EXPECT_TRUE(requests_[4]->HasOneAddress("192.168.1.101", 80)); | 1298 EXPECT_TRUE(requests_[4]->HasOneAddress("192.168.1.101", 80)); |
1300 EXPECT_EQ(OK, requests_[5]->result()); | 1299 EXPECT_EQ(OK, requests_[5]->result()); |
1301 EXPECT_TRUE(requests_[5]->HasOneAddress("192.168.1.102", 80)); | 1300 EXPECT_TRUE(requests_[5]->HasOneAddress("192.168.1.102", 80)); |
1302 } | 1301 } |
1303 | 1302 |
1304 TEST_F(HostResolverImplTest, ServeFromHosts) { | 1303 TEST_F(HostResolverImplDnsTest, DnsTaskDual) { |
1305 // Note, |config_service| will be owned by |resolver_|. | 1304 ChangeDnsConfig(CreateValidDnsConfig()); |
1306 MockDnsConfigService* config_service = new MockDnsConfigService(); | 1305 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("ok_fail", 80)->Resolve()); |
mmenke
2012/06/07 18:32:34
I think "ok_fail" is a somewhat strange name for a
| |
1307 resolver_.reset( | |
1308 CreateHostResolverImplWithDnsClient( | |
1309 proc_, | |
1310 scoped_ptr<DnsConfigService>(config_service))); | |
1311 | 1306 |
1307 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | |
1308 EXPECT_TRUE(requests_[0]->HasAddress("127.0.0.1", 80)); | |
1309 EXPECT_TRUE(requests_[0]->HasAddress("::1", 80)); | |
1310 EXPECT_EQ(2u, requests_[0]->NumberOfAddresses()); | |
1311 } | |
mmenke
2012/06/07 18:32:34
I'd like to see test where the MockDnsTransaction
| |
1312 | |
1313 TEST_F(HostResolverImplDnsTest, ServeFromHosts) { | |
1312 // Initially, use empty HOSTS file. | 1314 // Initially, use empty HOSTS file. |
1313 DnsConfig config = CreateValidDnsConfig(); | 1315 ChangeDnsConfig(CreateValidDnsConfig()); |
1314 config_service->ChangeHosts(DnsHosts()); | |
1315 config_service->ChangeConfig(config); | |
1316 | 1316 |
1317 proc_->AddRuleForAllFamilies("", "0.0.0.0"); // Default to failures. | 1317 proc_->AddRuleForAllFamilies("", "0.0.0.0"); // Default to failures. |
1318 proc_->SignalMultiple(1u); // For the first request which misses. | 1318 proc_->SignalMultiple(1u); // For the first request which misses. |
1319 | 1319 |
1320 Request* req0 = CreateRequest("er_ipv4", 80); | 1320 Request* req0 = CreateRequest("er_ipv4", 80); |
1321 EXPECT_EQ(ERR_IO_PENDING, req0->Resolve()); | 1321 EXPECT_EQ(ERR_IO_PENDING, req0->Resolve()); |
1322 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req0->WaitForResult()); | 1322 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req0->WaitForResult()); |
1323 | 1323 |
1324 IPAddressNumber local_ipv4, local_ipv6; | 1324 IPAddressNumber local_ipv4, local_ipv6; |
1325 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &local_ipv4)); | 1325 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &local_ipv4)); |
1326 ASSERT_TRUE(ParseIPLiteralToNumber("::1", &local_ipv6)); | 1326 ASSERT_TRUE(ParseIPLiteralToNumber("::1", &local_ipv6)); |
1327 | 1327 |
1328 DnsHosts hosts; | 1328 DnsHosts hosts; |
1329 hosts[DnsHostsKey("er_ipv4", ADDRESS_FAMILY_IPV4)] = local_ipv4; | 1329 hosts[DnsHostsKey("er_ipv4", ADDRESS_FAMILY_IPV4)] = local_ipv4; |
1330 hosts[DnsHostsKey("er_ipv6", ADDRESS_FAMILY_IPV6)] = local_ipv6; | 1330 hosts[DnsHostsKey("er_ipv6", ADDRESS_FAMILY_IPV6)] = local_ipv6; |
1331 hosts[DnsHostsKey("er_both", ADDRESS_FAMILY_IPV4)] = local_ipv4; | 1331 hosts[DnsHostsKey("er_both", ADDRESS_FAMILY_IPV4)] = local_ipv4; |
1332 hosts[DnsHostsKey("er_both", ADDRESS_FAMILY_IPV6)] = local_ipv6; | 1332 hosts[DnsHostsKey("er_both", ADDRESS_FAMILY_IPV6)] = local_ipv6; |
1333 | 1333 |
1334 // Update HOSTS file. | 1334 // Update HOSTS file. |
1335 config_service->ChangeConfig(config); | 1335 config_service_->ChangeHosts(hosts); |
1336 config_service->ChangeHosts(hosts); | |
1337 | 1336 |
1338 Request* req1 = CreateRequest("er_ipv4", 80); | 1337 Request* req1 = CreateRequest("er_ipv4", 80); |
1339 EXPECT_EQ(OK, req1->Resolve()); | 1338 EXPECT_EQ(OK, req1->Resolve()); |
1340 EXPECT_TRUE(req1->HasOneAddress("127.0.0.1", 80)); | 1339 EXPECT_TRUE(req1->HasOneAddress("127.0.0.1", 80)); |
1341 | 1340 |
1342 Request* req2 = CreateRequest("er_ipv6", 80); | 1341 Request* req2 = CreateRequest("er_ipv6", 80); |
1343 EXPECT_EQ(OK, req2->Resolve()); | 1342 EXPECT_EQ(OK, req2->Resolve()); |
1344 EXPECT_TRUE(req2->HasOneAddress("::1", 80)); | 1343 EXPECT_TRUE(req2->HasOneAddress("::1", 80)); |
1345 | 1344 |
1346 Request* req3 = CreateRequest("er_both", 80); | 1345 Request* req3 = CreateRequest("er_both", 80); |
(...skipping 10 matching lines...) Expand all Loading... | |
1357 EXPECT_EQ(OK, req5->Resolve()); | 1356 EXPECT_EQ(OK, req5->Resolve()); |
1358 EXPECT_TRUE(req5->HasOneAddress("::1", 80)); | 1357 EXPECT_TRUE(req5->HasOneAddress("::1", 80)); |
1359 | 1358 |
1360 // Request with upper case. | 1359 // Request with upper case. |
1361 Request* req6 = CreateRequest("er_IPV4", 80); | 1360 Request* req6 = CreateRequest("er_IPV4", 80); |
1362 EXPECT_EQ(OK, req6->Resolve()); | 1361 EXPECT_EQ(OK, req6->Resolve()); |
1363 EXPECT_TRUE(req6->HasOneAddress("127.0.0.1", 80)); | 1362 EXPECT_TRUE(req6->HasOneAddress("127.0.0.1", 80)); |
1364 } | 1363 } |
1365 | 1364 |
1366 } // namespace net | 1365 } // namespace net |
OLD | NEW |