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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // waiting for a specific number of requests. Unlike RuleBasedHostResolverProc | 49 // waiting for a specific number of requests. Unlike RuleBasedHostResolverProc |
50 // it never calls SystemHostResolverCall. By default resolves all hostnames to | 50 // it never calls SystemHostResolverCall. By default resolves all hostnames to |
51 // "127.0.0.1". After AddRule(), it resolves only names explicitly specified. | 51 // "127.0.0.1". After AddRule(), it resolves only names explicitly specified. |
52 class MockHostResolverProc : public HostResolverProc { | 52 class MockHostResolverProc : public HostResolverProc { |
53 public: | 53 public: |
54 struct ResolveKey { | 54 struct ResolveKey { |
55 ResolveKey(const std::string& hostname, AddressFamily address_family) | 55 ResolveKey(const std::string& hostname, AddressFamily address_family) |
56 : hostname(hostname), address_family(address_family) {} | 56 : hostname(hostname), address_family(address_family) {} |
57 bool operator<(const ResolveKey& other) const { | 57 bool operator<(const ResolveKey& other) const { |
58 return address_family < other.address_family || | 58 return address_family < other.address_family || |
59 (address_family == other.address_family && hostname < other.hostname); | 59 (address_family == other.address_family && |
| 60 hostname < other.hostname); |
60 } | 61 } |
61 std::string hostname; | 62 std::string hostname; |
62 AddressFamily address_family; | 63 AddressFamily address_family; |
63 }; | 64 }; |
64 | 65 |
65 typedef std::vector<ResolveKey> CaptureList; | 66 typedef std::vector<ResolveKey> CaptureList; |
66 | 67 |
67 MockHostResolverProc() | 68 MockHostResolverProc() |
68 : HostResolverProc(NULL), | 69 : HostResolverProc(NULL), |
69 num_requests_waiting_(0), | 70 num_requests_waiting_(0), |
70 num_slots_available_(0), | 71 num_slots_available_(0), |
71 requests_waiting_(&lock_), | 72 requests_waiting_(&lock_), |
72 slots_available_(&lock_) { | 73 slots_available_(&lock_) {} |
73 } | |
74 | 74 |
75 // Waits until |count| calls to |Resolve| are blocked. Returns false when | 75 // Waits until |count| calls to |Resolve| are blocked. Returns false when |
76 // timed out. | 76 // timed out. |
77 bool WaitFor(unsigned count) { | 77 bool WaitFor(unsigned count) { |
78 base::AutoLock lock(lock_); | 78 base::AutoLock lock(lock_); |
79 base::Time start_time = base::Time::Now(); | 79 base::Time start_time = base::Time::Now(); |
80 while (num_requests_waiting_ < count) { | 80 while (num_requests_waiting_ < count) { |
81 requests_waiting_.TimedWait(TestTimeouts::action_timeout()); | 81 requests_waiting_.TimedWait(TestTimeouts::action_timeout()); |
82 if (base::Time::Now() > start_time + TestTimeouts::action_timeout()) | 82 if (base::Time::Now() > start_time + TestTimeouts::action_timeout()) |
83 return false; | 83 return false; |
84 } | 84 } |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 // Signals |count| waiting calls to |Resolve|. First come first served. | 88 // Signals |count| waiting calls to |Resolve|. First come first served. |
89 void SignalMultiple(unsigned count) { | 89 void SignalMultiple(unsigned count) { |
90 base::AutoLock lock(lock_); | 90 base::AutoLock lock(lock_); |
91 num_slots_available_ += count; | 91 num_slots_available_ += count; |
92 slots_available_.Broadcast(); | 92 slots_available_.Broadcast(); |
93 } | 93 } |
94 | 94 |
95 // Signals all waiting calls to |Resolve|. Beware of races. | 95 // Signals all waiting calls to |Resolve|. Beware of races. |
96 void SignalAll() { | 96 void SignalAll() { |
97 base::AutoLock lock(lock_); | 97 base::AutoLock lock(lock_); |
98 num_slots_available_ = num_requests_waiting_; | 98 num_slots_available_ = num_requests_waiting_; |
99 slots_available_.Broadcast(); | 99 slots_available_.Broadcast(); |
100 } | 100 } |
101 | 101 |
102 void AddRule(const std::string& hostname, AddressFamily family, | 102 void AddRule(const std::string& hostname, |
| 103 AddressFamily family, |
103 const AddressList& result) { | 104 const AddressList& result) { |
104 base::AutoLock lock(lock_); | 105 base::AutoLock lock(lock_); |
105 rules_[ResolveKey(hostname, family)] = result; | 106 rules_[ResolveKey(hostname, family)] = result; |
106 } | 107 } |
107 | 108 |
108 void AddRule(const std::string& hostname, AddressFamily family, | 109 void AddRule(const std::string& hostname, |
| 110 AddressFamily family, |
109 const std::string& ip_list) { | 111 const std::string& ip_list) { |
110 AddressList result; | 112 AddressList result; |
111 int rv = ParseAddressList(ip_list, std::string(), &result); | 113 int rv = ParseAddressList(ip_list, std::string(), &result); |
112 DCHECK_EQ(OK, rv); | 114 DCHECK_EQ(OK, rv); |
113 AddRule(hostname, family, result); | 115 AddRule(hostname, family, result); |
114 } | 116 } |
115 | 117 |
116 void AddRuleForAllFamilies(const std::string& hostname, | 118 void AddRuleForAllFamilies(const std::string& hostname, |
117 const std::string& ip_list) { | 119 const std::string& ip_list) { |
118 AddressList result; | 120 AddressList result; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 std::map<ResolveKey, AddressList> rules_; | 173 std::map<ResolveKey, AddressList> rules_; |
172 CaptureList capture_list_; | 174 CaptureList capture_list_; |
173 unsigned num_requests_waiting_; | 175 unsigned num_requests_waiting_; |
174 unsigned num_slots_available_; | 176 unsigned num_slots_available_; |
175 base::ConditionVariable requests_waiting_; | 177 base::ConditionVariable requests_waiting_; |
176 base::ConditionVariable slots_available_; | 178 base::ConditionVariable slots_available_; |
177 | 179 |
178 DISALLOW_COPY_AND_ASSIGN(MockHostResolverProc); | 180 DISALLOW_COPY_AND_ASSIGN(MockHostResolverProc); |
179 }; | 181 }; |
180 | 182 |
181 bool AddressListContains(const AddressList& list, const std::string& address, | 183 bool AddressListContains(const AddressList& list, |
| 184 const std::string& address, |
182 int port) { | 185 int port) { |
183 IPAddressNumber ip; | 186 IPAddressNumber ip; |
184 bool rv = ParseIPLiteralToNumber(address, &ip); | 187 bool rv = ParseIPLiteralToNumber(address, &ip); |
185 DCHECK(rv); | 188 DCHECK(rv); |
186 return std::find(list.begin(), | 189 return std::find(list.begin(), list.end(), IPEndPoint(ip, port)) != |
187 list.end(), | 190 list.end(); |
188 IPEndPoint(ip, port)) != list.end(); | |
189 } | 191 } |
190 | 192 |
191 // A wrapper for requests to a HostResolver. | 193 // A wrapper for requests to a HostResolver. |
192 class Request { | 194 class Request { |
193 public: | 195 public: |
194 // Base class of handlers to be executed on completion of requests. | 196 // Base class of handlers to be executed on completion of requests. |
195 struct Handler { | 197 struct Handler { |
196 virtual ~Handler() {} | 198 virtual ~Handler() {} |
197 virtual void Handle(Request* request) = 0; | 199 virtual void Handle(Request* request) = 0; |
198 }; | 200 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 const AddressList& list() const { return list_; } | 247 const AddressList& list() const { return list_; } |
246 int result() const { return result_; } | 248 int result() const { return result_; } |
247 bool completed() const { return result_ != ERR_IO_PENDING; } | 249 bool completed() const { return result_ != ERR_IO_PENDING; } |
248 bool pending() const { return handle_ != NULL; } | 250 bool pending() const { return handle_ != NULL; } |
249 | 251 |
250 bool HasAddress(const std::string& address, int port) const { | 252 bool HasAddress(const std::string& address, int port) const { |
251 return AddressListContains(list_, address, port); | 253 return AddressListContains(list_, address, port); |
252 } | 254 } |
253 | 255 |
254 // Returns the number of addresses in |list_|. | 256 // Returns the number of addresses in |list_|. |
255 unsigned NumberOfAddresses() const { | 257 unsigned NumberOfAddresses() const { return list_.size(); } |
256 return list_.size(); | |
257 } | |
258 | 258 |
259 bool HasOneAddress(const std::string& address, int port) const { | 259 bool HasOneAddress(const std::string& address, int port) const { |
260 return HasAddress(address, port) && (NumberOfAddresses() == 1u); | 260 return HasAddress(address, port) && (NumberOfAddresses() == 1u); |
261 } | 261 } |
262 | 262 |
263 // Returns ERR_UNEXPECTED if timed out. | 263 // Returns ERR_UNEXPECTED if timed out. |
264 int WaitForResult() { | 264 int WaitForResult() { |
265 if (completed()) | 265 if (completed()) |
266 return result_; | 266 return result_; |
267 base::CancelableClosure closure(base::MessageLoop::QuitClosure()); | 267 base::CancelableClosure closure(base::MessageLoop::QuitClosure()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 public: | 317 public: |
318 LookupAttemptHostResolverProc(HostResolverProc* previous, | 318 LookupAttemptHostResolverProc(HostResolverProc* previous, |
319 int attempt_number_to_resolve, | 319 int attempt_number_to_resolve, |
320 int total_attempts) | 320 int total_attempts) |
321 : HostResolverProc(previous), | 321 : HostResolverProc(previous), |
322 attempt_number_to_resolve_(attempt_number_to_resolve), | 322 attempt_number_to_resolve_(attempt_number_to_resolve), |
323 current_attempt_number_(0), | 323 current_attempt_number_(0), |
324 total_attempts_(total_attempts), | 324 total_attempts_(total_attempts), |
325 total_attempts_resolved_(0), | 325 total_attempts_resolved_(0), |
326 resolved_attempt_number_(0), | 326 resolved_attempt_number_(0), |
327 all_done_(&lock_) { | 327 all_done_(&lock_) {} |
328 } | |
329 | 328 |
330 // Test harness will wait for all attempts to finish before checking the | 329 // Test harness will wait for all attempts to finish before checking the |
331 // results. | 330 // results. |
332 void WaitForAllAttemptsToFinish(const base::TimeDelta& wait_time) { | 331 void WaitForAllAttemptsToFinish(const base::TimeDelta& wait_time) { |
333 base::TimeTicks end_time = base::TimeTicks::Now() + wait_time; | 332 base::TimeTicks end_time = base::TimeTicks::Now() + wait_time; |
334 { | 333 { |
335 base::AutoLock auto_lock(lock_); | 334 base::AutoLock auto_lock(lock_); |
336 while (total_attempts_resolved_ != total_attempts_ && | 335 while (total_attempts_resolved_ != total_attempts_ && |
337 base::TimeTicks::Now() < end_time) { | 336 base::TimeTicks::Now() < end_time) { |
338 all_done_.TimedWait(end_time - base::TimeTicks::Now()); | 337 all_done_.TimedWait(end_time - base::TimeTicks::Now()); |
339 } | 338 } |
340 } | 339 } |
341 } | 340 } |
342 | 341 |
343 // All attempts will wait for an attempt to resolve the host. | 342 // All attempts will wait for an attempt to resolve the host. |
344 void WaitForAnAttemptToComplete() { | 343 void WaitForAnAttemptToComplete() { |
345 base::TimeDelta wait_time = base::TimeDelta::FromSeconds(60); | 344 base::TimeDelta wait_time = base::TimeDelta::FromSeconds(60); |
346 base::TimeTicks end_time = base::TimeTicks::Now() + wait_time; | 345 base::TimeTicks end_time = base::TimeTicks::Now() + wait_time; |
347 { | 346 { |
(...skipping 23 matching lines...) Expand all Loading... |
371 if (current_attempt_number_ == attempt_number_to_resolve_) { | 370 if (current_attempt_number_ == attempt_number_to_resolve_) { |
372 resolved_attempt_number_ = current_attempt_number_; | 371 resolved_attempt_number_ = current_attempt_number_; |
373 wait_for_right_attempt_to_complete = false; | 372 wait_for_right_attempt_to_complete = false; |
374 } | 373 } |
375 } | 374 } |
376 | 375 |
377 if (wait_for_right_attempt_to_complete) | 376 if (wait_for_right_attempt_to_complete) |
378 // Wait for the attempt_number_to_resolve_ attempt to resolve. | 377 // Wait for the attempt_number_to_resolve_ attempt to resolve. |
379 WaitForAnAttemptToComplete(); | 378 WaitForAnAttemptToComplete(); |
380 | 379 |
381 int result = ResolveUsingPrevious(host, address_family, host_resolver_flags, | 380 int result = ResolveUsingPrevious( |
382 addrlist, os_error); | 381 host, address_family, host_resolver_flags, addrlist, os_error); |
383 | 382 |
384 { | 383 { |
385 base::AutoLock auto_lock(lock_); | 384 base::AutoLock auto_lock(lock_); |
386 ++total_attempts_resolved_; | 385 ++total_attempts_resolved_; |
387 } | 386 } |
388 | 387 |
389 all_done_.Broadcast(); // Tell all attempts to proceed. | 388 all_done_.Broadcast(); // Tell all attempts to proceed. |
390 | 389 |
391 // Since any negative number is considered a network error, with -1 having | 390 // Since any negative number is considered a network error, with -1 having |
392 // special meaning (ERR_IO_PENDING). We could return the attempt that has | 391 // special meaning (ERR_IO_PENDING). We could return the attempt that has |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 return test->CreateRequest(hostname); | 451 return test->CreateRequest(hostname); |
453 } | 452 } |
454 ScopedVector<Request>& requests() { return test->requests_; } | 453 ScopedVector<Request>& requests() { return test->requests_; } |
455 | 454 |
456 void DeleteResolver() { test->resolver_.reset(); } | 455 void DeleteResolver() { test->resolver_.reset(); } |
457 | 456 |
458 HostResolverImplTest* test; | 457 HostResolverImplTest* test; |
459 }; | 458 }; |
460 | 459 |
461 // testing::Test implementation: | 460 // testing::Test implementation: |
462 virtual void SetUp() OVERRIDE { | 461 virtual void SetUp() OVERRIDE { CreateResolver(); } |
463 CreateResolver(); | |
464 } | |
465 | 462 |
466 virtual void TearDown() OVERRIDE { | 463 virtual void TearDown() OVERRIDE { |
467 if (resolver_.get()) | 464 if (resolver_.get()) |
468 EXPECT_EQ(0u, resolver_->num_running_dispatcher_jobs_for_tests()); | 465 EXPECT_EQ(0u, resolver_->num_running_dispatcher_jobs_for_tests()); |
469 EXPECT_FALSE(proc_->HasBlockedRequests()); | 466 EXPECT_FALSE(proc_->HasBlockedRequests()); |
470 } | 467 } |
471 | 468 |
472 virtual void CreateResolverWithLimitsAndParams( | 469 virtual void CreateResolverWithLimitsAndParams( |
473 const PrioritizedDispatcher::Limits& limits, | 470 const PrioritizedDispatcher::Limits& limits, |
474 const HostResolverImpl::ProcTaskParams& params) { | 471 const HostResolverImpl::ProcTaskParams& params) { |
475 resolver_.reset(new HostResolverImpl(HostCache::CreateDefaultCache(), | 472 resolver_.reset(new HostResolverImpl( |
476 limits, params, NULL)); | 473 HostCache::CreateDefaultCache(), limits, params, NULL)); |
477 } | 474 } |
478 | 475 |
479 // The Request will not be made until a call to |Resolve()|, and the Job will | 476 // The Request will not be made until a call to |Resolve()|, and the Job will |
480 // not start until released by |proc_->SignalXXX|. | 477 // not start until released by |proc_->SignalXXX|. |
481 Request* CreateRequest(const HostResolver::RequestInfo& info, | 478 Request* CreateRequest(const HostResolver::RequestInfo& info, |
482 RequestPriority priority) { | 479 RequestPriority priority) { |
483 Request* req = new Request( | 480 Request* req = new Request( |
484 info, priority, requests_.size(), resolver_.get(), handler_.get()); | 481 info, priority, requests_.size(), resolver_.get(), handler_.get()); |
485 requests_.push_back(req); | 482 requests_.push_back(req); |
486 return req; | 483 return req; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 new LookupAttemptHostResolverProc( | 1262 new LookupAttemptHostResolverProc( |
1266 NULL, kAttemptNumberToResolve, kTotalAttempts)); | 1263 NULL, kAttemptNumberToResolve, kTotalAttempts)); |
1267 | 1264 |
1268 HostResolverImpl::ProcTaskParams params = DefaultParams(resolver_proc.get()); | 1265 HostResolverImpl::ProcTaskParams params = DefaultParams(resolver_proc.get()); |
1269 | 1266 |
1270 // Specify smaller interval for unresponsive_delay_ for HostResolverImpl so | 1267 // Specify smaller interval for unresponsive_delay_ for HostResolverImpl so |
1271 // that unit test runs faster. For example, this test finishes in 1.5 secs | 1268 // that unit test runs faster. For example, this test finishes in 1.5 secs |
1272 // (500ms * 3). | 1269 // (500ms * 3). |
1273 params.unresponsive_delay = base::TimeDelta::FromMilliseconds(500); | 1270 params.unresponsive_delay = base::TimeDelta::FromMilliseconds(500); |
1274 | 1271 |
1275 resolver_.reset( | 1272 resolver_.reset(new HostResolverImpl( |
1276 new HostResolverImpl(HostCache::CreateDefaultCache(), | 1273 HostCache::CreateDefaultCache(), DefaultLimits(), params, NULL)); |
1277 DefaultLimits(), | |
1278 params, | |
1279 NULL)); | |
1280 | 1274 |
1281 // Resolve "host1". | 1275 // Resolve "host1". |
1282 HostResolver::RequestInfo info(HostPortPair("host1", 70)); | 1276 HostResolver::RequestInfo info(HostPortPair("host1", 70)); |
1283 Request* req = CreateRequest(info, DEFAULT_PRIORITY); | 1277 Request* req = CreateRequest(info, DEFAULT_PRIORITY); |
1284 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); | 1278 EXPECT_EQ(ERR_IO_PENDING, req->Resolve()); |
1285 | 1279 |
1286 // Resolve returns -4 to indicate that 3rd attempt has resolved the host. | 1280 // Resolve returns -4 to indicate that 3rd attempt has resolved the host. |
1287 EXPECT_EQ(-4, req->WaitForResult()); | 1281 EXPECT_EQ(-4, req->WaitForResult()); |
1288 | 1282 |
1289 resolver_proc->WaitForAllAttemptsToFinish( | 1283 resolver_proc->WaitForAllAttemptsToFinish( |
(...skipping 27 matching lines...) Expand all Loading... |
1317 AddDnsRule("nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); | 1311 AddDnsRule("nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); |
1318 AddDnsRule("ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1312 AddDnsRule("ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
1319 AddDnsRule("ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); | 1313 AddDnsRule("ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); |
1320 AddDnsRule("4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1314 AddDnsRule("4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
1321 AddDnsRule("4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); | 1315 AddDnsRule("4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); |
1322 AddDnsRule("6ok", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); | 1316 AddDnsRule("6ok", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); |
1323 AddDnsRule("6ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); | 1317 AddDnsRule("6ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); |
1324 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1318 AddDnsRule("4nx", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
1325 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); | 1319 AddDnsRule("4nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, false); |
1326 AddDnsRule("empty", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); | 1320 AddDnsRule("empty", dns_protocol::kTypeA, MockDnsClientRule::EMPTY, false); |
1327 AddDnsRule("empty", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, | 1321 AddDnsRule( |
1328 false); | 1322 "empty", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); |
1329 | 1323 |
1330 AddDnsRule("slow_nx", dns_protocol::kTypeA, MockDnsClientRule::FAIL, true); | 1324 AddDnsRule("slow_nx", dns_protocol::kTypeA, MockDnsClientRule::FAIL, true); |
1331 AddDnsRule("slow_nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, | 1325 AddDnsRule( |
1332 true); | 1326 "slow_nx", dns_protocol::kTypeAAAA, MockDnsClientRule::FAIL, true); |
1333 | 1327 |
1334 AddDnsRule("4slow_ok", dns_protocol::kTypeA, MockDnsClientRule::OK, true); | 1328 AddDnsRule("4slow_ok", dns_protocol::kTypeA, MockDnsClientRule::OK, true); |
1335 AddDnsRule("4slow_ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, | 1329 AddDnsRule( |
| 1330 "4slow_ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, false); |
| 1331 AddDnsRule("6slow_ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); |
| 1332 AddDnsRule( |
| 1333 "6slow_ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, true); |
| 1334 AddDnsRule("4slow_4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, true); |
| 1335 AddDnsRule( |
| 1336 "4slow_4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, false); |
| 1337 AddDnsRule("4slow_4timeout", |
| 1338 dns_protocol::kTypeA, |
| 1339 MockDnsClientRule::TIMEOUT, |
| 1340 true); |
| 1341 AddDnsRule("4slow_4timeout", |
| 1342 dns_protocol::kTypeAAAA, |
| 1343 MockDnsClientRule::OK, |
1336 false); | 1344 false); |
1337 AddDnsRule("6slow_ok", dns_protocol::kTypeA, MockDnsClientRule::OK, false); | 1345 AddDnsRule( |
1338 AddDnsRule("6slow_ok", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, | 1346 "4slow_6timeout", dns_protocol::kTypeA, MockDnsClientRule::OK, true); |
1339 true); | 1347 AddDnsRule("4slow_6timeout", |
1340 AddDnsRule("4slow_4ok", dns_protocol::kTypeA, MockDnsClientRule::OK, true); | 1348 dns_protocol::kTypeAAAA, |
1341 AddDnsRule("4slow_4ok", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY, | 1349 MockDnsClientRule::TIMEOUT, |
1342 false); | 1350 false); |
1343 AddDnsRule("4slow_4timeout", dns_protocol::kTypeA, | |
1344 MockDnsClientRule::TIMEOUT, true); | |
1345 AddDnsRule("4slow_4timeout", dns_protocol::kTypeAAAA, MockDnsClientRule::OK, | |
1346 false); | |
1347 AddDnsRule("4slow_6timeout", dns_protocol::kTypeA, | |
1348 MockDnsClientRule::OK, true); | |
1349 AddDnsRule("4slow_6timeout", dns_protocol::kTypeAAAA, | |
1350 MockDnsClientRule::TIMEOUT, false); | |
1351 CreateResolver(); | 1351 CreateResolver(); |
1352 } | 1352 } |
1353 | 1353 |
1354 // HostResolverImplTest implementation: | 1354 // HostResolverImplTest implementation: |
1355 virtual void CreateResolverWithLimitsAndParams( | 1355 virtual void CreateResolverWithLimitsAndParams( |
1356 const PrioritizedDispatcher::Limits& limits, | 1356 const PrioritizedDispatcher::Limits& limits, |
1357 const HostResolverImpl::ProcTaskParams& params) OVERRIDE { | 1357 const HostResolverImpl::ProcTaskParams& params) OVERRIDE { |
1358 resolver_.reset(new HostResolverImpl(HostCache::CreateDefaultCache(), | 1358 resolver_.reset(new HostResolverImpl( |
1359 limits, | 1359 HostCache::CreateDefaultCache(), limits, params, NULL)); |
1360 params, | |
1361 NULL)); | |
1362 // Disable IPv6 support probing. | 1360 // Disable IPv6 support probing. |
1363 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); | 1361 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); |
1364 dns_client_ = new MockDnsClient(DnsConfig(), dns_rules_); | 1362 dns_client_ = new MockDnsClient(DnsConfig(), dns_rules_); |
1365 resolver_->SetDnsClient(scoped_ptr<DnsClient>(dns_client_)); | 1363 resolver_->SetDnsClient(scoped_ptr<DnsClient>(dns_client_)); |
1366 } | 1364 } |
1367 | 1365 |
1368 // Adds a rule to |dns_rules_|. Must be followed by |CreateResolver| to apply. | 1366 // Adds a rule to |dns_rules_|. Must be followed by |CreateResolver| to apply. |
1369 void AddDnsRule(const std::string& prefix, | 1367 void AddDnsRule(const std::string& prefix, |
1370 uint16 qtype, | 1368 uint16 qtype, |
1371 MockDnsClientRule::Result result, | 1369 MockDnsClientRule::Result result, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 Request* req1 = CreateRequest("nx_ipv4", 80); | 1550 Request* req1 = CreateRequest("nx_ipv4", 80); |
1553 EXPECT_EQ(OK, req1->Resolve()); | 1551 EXPECT_EQ(OK, req1->Resolve()); |
1554 EXPECT_TRUE(req1->HasOneAddress("127.0.0.1", 80)); | 1552 EXPECT_TRUE(req1->HasOneAddress("127.0.0.1", 80)); |
1555 | 1553 |
1556 Request* req2 = CreateRequest("nx_ipv6", 80); | 1554 Request* req2 = CreateRequest("nx_ipv6", 80); |
1557 EXPECT_EQ(OK, req2->Resolve()); | 1555 EXPECT_EQ(OK, req2->Resolve()); |
1558 EXPECT_TRUE(req2->HasOneAddress("::1", 80)); | 1556 EXPECT_TRUE(req2->HasOneAddress("::1", 80)); |
1559 | 1557 |
1560 Request* req3 = CreateRequest("nx_both", 80); | 1558 Request* req3 = CreateRequest("nx_both", 80); |
1561 EXPECT_EQ(OK, req3->Resolve()); | 1559 EXPECT_EQ(OK, req3->Resolve()); |
1562 EXPECT_TRUE(req3->HasAddress("127.0.0.1", 80) && | 1560 EXPECT_TRUE(req3->HasAddress("127.0.0.1", 80) && req3->HasAddress("::1", 80)); |
1563 req3->HasAddress("::1", 80)); | |
1564 | 1561 |
1565 // Requests with specified AddressFamily. | 1562 // Requests with specified AddressFamily. |
1566 Request* req4 = CreateRequest("nx_ipv4", 80, MEDIUM, ADDRESS_FAMILY_IPV4); | 1563 Request* req4 = CreateRequest("nx_ipv4", 80, MEDIUM, ADDRESS_FAMILY_IPV4); |
1567 EXPECT_EQ(OK, req4->Resolve()); | 1564 EXPECT_EQ(OK, req4->Resolve()); |
1568 EXPECT_TRUE(req4->HasOneAddress("127.0.0.1", 80)); | 1565 EXPECT_TRUE(req4->HasOneAddress("127.0.0.1", 80)); |
1569 | 1566 |
1570 Request* req5 = CreateRequest("nx_ipv6", 80, MEDIUM, ADDRESS_FAMILY_IPV6); | 1567 Request* req5 = CreateRequest("nx_ipv6", 80, MEDIUM, ADDRESS_FAMILY_IPV6); |
1571 EXPECT_EQ(OK, req5->Resolve()); | 1568 EXPECT_EQ(OK, req5->Resolve()); |
1572 EXPECT_TRUE(req5->HasOneAddress("::1", 80)); | 1569 EXPECT_TRUE(req5->HasOneAddress("::1", 80)); |
1573 | 1570 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 resolver_.reset(new HostResolverImpl(HostCache::CreateDefaultCache(), | 1688 resolver_.reset(new HostResolverImpl(HostCache::CreateDefaultCache(), |
1692 DefaultLimits(), | 1689 DefaultLimits(), |
1693 DefaultParams(proc.get()), | 1690 DefaultParams(proc.get()), |
1694 NULL)); | 1691 NULL)); |
1695 resolver_->SetDnsClient( | 1692 resolver_->SetDnsClient( |
1696 scoped_ptr<DnsClient>(new MockDnsClient(DnsConfig(), dns_rules_))); | 1693 scoped_ptr<DnsClient>(new MockDnsClient(DnsConfig(), dns_rules_))); |
1697 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_IPV4); | 1694 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_IPV4); |
1698 | 1695 |
1699 // Get the expected output. | 1696 // Get the expected output. |
1700 AddressList addrlist; | 1697 AddressList addrlist; |
1701 int rv = proc->Resolve("localhost", ADDRESS_FAMILY_UNSPECIFIED, 0, &addrlist, | 1698 int rv = proc->Resolve( |
1702 NULL); | 1699 "localhost", ADDRESS_FAMILY_UNSPECIFIED, 0, &addrlist, NULL); |
1703 if (rv != OK) | 1700 if (rv != OK) |
1704 return; | 1701 return; |
1705 | 1702 |
1706 for (unsigned i = 0; i < addrlist.size(); ++i) | 1703 for (unsigned i = 0; i < addrlist.size(); ++i) |
1707 LOG(WARNING) << addrlist[i].ToString(); | 1704 LOG(WARNING) << addrlist[i].ToString(); |
1708 | 1705 |
1709 bool saw_ipv4 = AddressListContains(addrlist, "127.0.0.1", 0); | 1706 bool saw_ipv4 = AddressListContains(addrlist, "127.0.0.1", 0); |
1710 bool saw_ipv6 = AddressListContains(addrlist, "::1", 0); | 1707 bool saw_ipv6 = AddressListContains(addrlist, "::1", 0); |
1711 if (!saw_ipv4 && !saw_ipv6) | 1708 if (!saw_ipv4 && !saw_ipv6) |
1712 return; | 1709 return; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 TEST_F(HostResolverImplDnsTest, DeleteWithActiveTransactions) { | 1784 TEST_F(HostResolverImplDnsTest, DeleteWithActiveTransactions) { |
1788 // At most 10 Jobs active at once. | 1785 // At most 10 Jobs active at once. |
1789 CreateResolverWithLimitsAndParams( | 1786 CreateResolverWithLimitsAndParams( |
1790 PrioritizedDispatcher::Limits(NUM_PRIORITIES, 10u), | 1787 PrioritizedDispatcher::Limits(NUM_PRIORITIES, 10u), |
1791 DefaultParams(proc_.get())); | 1788 DefaultParams(proc_.get())); |
1792 | 1789 |
1793 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); | 1790 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); |
1794 ChangeDnsConfig(CreateValidDnsConfig()); | 1791 ChangeDnsConfig(CreateValidDnsConfig()); |
1795 | 1792 |
1796 // First active job is an IPv4 request. | 1793 // First active job is an IPv4 request. |
1797 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("ok", 80, MEDIUM, | 1794 EXPECT_EQ(ERR_IO_PENDING, |
1798 ADDRESS_FAMILY_IPV4)->Resolve()); | 1795 CreateRequest("ok", 80, MEDIUM, ADDRESS_FAMILY_IPV4)->Resolve()); |
1799 | 1796 |
1800 // Add 10 more DNS lookups for different hostnames. First 4 should have two | 1797 // Add 10 more DNS lookups for different hostnames. First 4 should have two |
1801 // active jobs, next one has a single active job, and one pending. Others | 1798 // active jobs, next one has a single active job, and one pending. Others |
1802 // should all be queued. | 1799 // should all be queued. |
1803 for (int i = 0; i < 10; ++i) { | 1800 for (int i = 0; i < 10; ++i) { |
1804 EXPECT_EQ(ERR_IO_PENDING, CreateRequest( | 1801 EXPECT_EQ(ERR_IO_PENDING, |
1805 base::StringPrintf("ok%i", i))->Resolve()); | 1802 CreateRequest(base::StringPrintf("ok%i", i))->Resolve()); |
1806 } | 1803 } |
1807 EXPECT_EQ(10u, num_running_dispatcher_jobs()); | 1804 EXPECT_EQ(10u, num_running_dispatcher_jobs()); |
1808 | 1805 |
1809 resolver_.reset(); | 1806 resolver_.reset(); |
1810 } | 1807 } |
1811 | 1808 |
1812 // Cancel a request with only the IPv6 transaction active. | 1809 // Cancel a request with only the IPv6 transaction active. |
1813 TEST_F(HostResolverImplDnsTest, CancelWithIPv6TransactionActive) { | 1810 TEST_F(HostResolverImplDnsTest, CancelWithIPv6TransactionActive) { |
1814 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); | 1811 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); |
1815 ChangeDnsConfig(CreateValidDnsConfig()); | 1812 ChangeDnsConfig(CreateValidDnsConfig()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 // Test the case where the AAAA query is started when another transaction | 1896 // Test the case where the AAAA query is started when another transaction |
1900 // completes. | 1897 // completes. |
1901 TEST_F(HostResolverImplDnsTest, AAAAStartsAfterOtherJobFinishes) { | 1898 TEST_F(HostResolverImplDnsTest, AAAAStartsAfterOtherJobFinishes) { |
1902 CreateResolverWithLimitsAndParams( | 1899 CreateResolverWithLimitsAndParams( |
1903 PrioritizedDispatcher::Limits(NUM_PRIORITIES, 2), | 1900 PrioritizedDispatcher::Limits(NUM_PRIORITIES, 2), |
1904 DefaultParams(proc_.get())); | 1901 DefaultParams(proc_.get())); |
1905 set_fallback_to_proctask(false); | 1902 set_fallback_to_proctask(false); |
1906 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); | 1903 resolver_->SetDefaultAddressFamily(ADDRESS_FAMILY_UNSPECIFIED); |
1907 ChangeDnsConfig(CreateValidDnsConfig()); | 1904 ChangeDnsConfig(CreateValidDnsConfig()); |
1908 | 1905 |
1909 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("ok", 80, MEDIUM, | |
1910 ADDRESS_FAMILY_IPV4)->Resolve()); | |
1911 EXPECT_EQ(ERR_IO_PENDING, | 1906 EXPECT_EQ(ERR_IO_PENDING, |
1912 CreateRequest("4slow_ok", 80, MEDIUM)->Resolve()); | 1907 CreateRequest("ok", 80, MEDIUM, ADDRESS_FAMILY_IPV4)->Resolve()); |
| 1908 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("4slow_ok", 80, MEDIUM)->Resolve()); |
1913 // An IPv4 request should have been started pending for each job. | 1909 // An IPv4 request should have been started pending for each job. |
1914 EXPECT_EQ(2u, num_running_dispatcher_jobs()); | 1910 EXPECT_EQ(2u, num_running_dispatcher_jobs()); |
1915 | 1911 |
1916 // Request 0's IPv4 request should complete, starting Request 1's IPv6 | 1912 // Request 0's IPv4 request should complete, starting Request 1's IPv6 |
1917 // request, which should also complete. | 1913 // request, which should also complete. |
1918 base::RunLoop().RunUntilIdle(); | 1914 base::RunLoop().RunUntilIdle(); |
1919 EXPECT_EQ(1u, num_running_dispatcher_jobs()); | 1915 EXPECT_EQ(1u, num_running_dispatcher_jobs()); |
1920 EXPECT_TRUE(requests_[0]->completed()); | 1916 EXPECT_TRUE(requests_[0]->completed()); |
1921 EXPECT_FALSE(requests_[1]->completed()); | 1917 EXPECT_FALSE(requests_[1]->completed()); |
1922 | 1918 |
1923 dns_client_->CompleteDelayedTransactions(); | 1919 dns_client_->CompleteDelayedTransactions(); |
1924 EXPECT_TRUE(requests_[1]->completed()); | 1920 EXPECT_TRUE(requests_[1]->completed()); |
1925 EXPECT_EQ(OK, requests_[1]->result()); | 1921 EXPECT_EQ(OK, requests_[1]->result()); |
1926 EXPECT_EQ(2u, requests_[1]->NumberOfAddresses()); | 1922 EXPECT_EQ(2u, requests_[1]->NumberOfAddresses()); |
1927 EXPECT_TRUE(requests_[1]->HasAddress("127.0.0.1", 80)); | 1923 EXPECT_TRUE(requests_[1]->HasAddress("127.0.0.1", 80)); |
1928 EXPECT_TRUE(requests_[1]->HasAddress("::1", 80)); | 1924 EXPECT_TRUE(requests_[1]->HasAddress("::1", 80)); |
1929 } | 1925 } |
1930 | 1926 |
1931 // Tests the case that a Job with a single transaction receives an empty address | 1927 // Tests the case that a Job with a single transaction receives an empty address |
1932 // list, triggering fallback to ProcTask. | 1928 // list, triggering fallback to ProcTask. |
1933 TEST_F(HostResolverImplDnsTest, IPv4EmptyFallback) { | 1929 TEST_F(HostResolverImplDnsTest, IPv4EmptyFallback) { |
1934 ChangeDnsConfig(CreateValidDnsConfig()); | 1930 ChangeDnsConfig(CreateValidDnsConfig()); |
1935 proc_->AddRuleForAllFamilies("empty_fallback", "192.168.0.1"); | 1931 proc_->AddRuleForAllFamilies("empty_fallback", "192.168.0.1"); |
1936 proc_->SignalMultiple(1u); | 1932 proc_->SignalMultiple(1u); |
1937 EXPECT_EQ(ERR_IO_PENDING, | 1933 EXPECT_EQ(ERR_IO_PENDING, |
1938 CreateRequest("empty_fallback", 80, MEDIUM, | 1934 CreateRequest("empty_fallback", 80, MEDIUM, ADDRESS_FAMILY_IPV4) |
1939 ADDRESS_FAMILY_IPV4)->Resolve()); | 1935 ->Resolve()); |
1940 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 1936 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
1941 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); | 1937 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); |
1942 } | 1938 } |
1943 | 1939 |
1944 // Tests the case that a Job with two transactions receives two empty address | 1940 // Tests the case that a Job with two transactions receives two empty address |
1945 // lists, triggering fallback to ProcTask. | 1941 // lists, triggering fallback to ProcTask. |
1946 TEST_F(HostResolverImplDnsTest, UnspecEmptyFallback) { | 1942 TEST_F(HostResolverImplDnsTest, UnspecEmptyFallback) { |
1947 ChangeDnsConfig(CreateValidDnsConfig()); | 1943 ChangeDnsConfig(CreateValidDnsConfig()); |
1948 proc_->AddRuleForAllFamilies("empty_fallback", "192.168.0.1"); | 1944 proc_->AddRuleForAllFamilies("empty_fallback", "192.168.0.1"); |
1949 proc_->SignalMultiple(1u); | 1945 proc_->SignalMultiple(1u); |
1950 EXPECT_EQ(ERR_IO_PENDING, | 1946 EXPECT_EQ( |
1951 CreateRequest("empty_fallback", 80, MEDIUM, | 1947 ERR_IO_PENDING, |
1952 ADDRESS_FAMILY_UNSPECIFIED)->Resolve()); | 1948 CreateRequest("empty_fallback", 80, MEDIUM, ADDRESS_FAMILY_UNSPECIFIED) |
| 1949 ->Resolve()); |
1953 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 1950 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
1954 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); | 1951 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); |
1955 } | 1952 } |
1956 | 1953 |
1957 // Tests getting a new invalid DnsConfig while there are active DnsTasks. | 1954 // Tests getting a new invalid DnsConfig while there are active DnsTasks. |
1958 TEST_F(HostResolverImplDnsTest, InvalidDnsConfigWithPendingRequests) { | 1955 TEST_F(HostResolverImplDnsTest, InvalidDnsConfigWithPendingRequests) { |
1959 // At most 3 jobs active at once. This number is important, since we want to | 1956 // At most 3 jobs active at once. This number is important, since we want to |
1960 // make sure that aborting the first HostResolverImpl::Job does not trigger | 1957 // make sure that aborting the first HostResolverImpl::Job does not trigger |
1961 // another DnsTransaction on the second Job when it releases its second | 1958 // another DnsTransaction on the second Job when it releases its second |
1962 // prioritized dispatcher slot. | 1959 // prioritized dispatcher slot. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 proc_->AddRuleForAllFamilies("slow_ok3", "192.168.0.4"); | 2024 proc_->AddRuleForAllFamilies("slow_ok3", "192.168.0.4"); |
2028 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("slow_ok3")->Resolve()); | 2025 EXPECT_EQ(ERR_IO_PENDING, CreateRequest("slow_ok3")->Resolve()); |
2029 proc_->SignalMultiple(maximum_dns_failures() + 3); | 2026 proc_->SignalMultiple(maximum_dns_failures() + 3); |
2030 | 2027 |
2031 for (size_t i = 0u; i < maximum_dns_failures(); ++i) { | 2028 for (size_t i = 0u; i < maximum_dns_failures(); ++i) { |
2032 EXPECT_EQ(OK, requests_[i]->WaitForResult()); | 2029 EXPECT_EQ(OK, requests_[i]->WaitForResult()); |
2033 EXPECT_TRUE(requests_[i]->HasOneAddress("192.168.0.1", 80)); | 2030 EXPECT_TRUE(requests_[i]->HasOneAddress("192.168.0.1", 80)); |
2034 } | 2031 } |
2035 | 2032 |
2036 EXPECT_EQ(OK, requests_[maximum_dns_failures()]->WaitForResult()); | 2033 EXPECT_EQ(OK, requests_[maximum_dns_failures()]->WaitForResult()); |
2037 EXPECT_TRUE(requests_[maximum_dns_failures()]->HasOneAddress( | 2034 EXPECT_TRUE( |
2038 "192.168.0.2", 80)); | 2035 requests_[maximum_dns_failures()]->HasOneAddress("192.168.0.2", 80)); |
2039 EXPECT_EQ(OK, requests_[maximum_dns_failures() + 1]->WaitForResult()); | 2036 EXPECT_EQ(OK, requests_[maximum_dns_failures() + 1]->WaitForResult()); |
2040 EXPECT_TRUE(requests_[maximum_dns_failures() + 1]->HasOneAddress( | 2037 EXPECT_TRUE(requests_[maximum_dns_failures() + 1]->HasOneAddress( |
2041 "192.168.0.3", 80)); | 2038 "192.168.0.3", 80)); |
2042 EXPECT_EQ(OK, requests_[maximum_dns_failures() + 2]->WaitForResult()); | 2039 EXPECT_EQ(OK, requests_[maximum_dns_failures() + 2]->WaitForResult()); |
2043 EXPECT_TRUE(requests_[maximum_dns_failures() + 2]->HasOneAddress( | 2040 EXPECT_TRUE(requests_[maximum_dns_failures() + 2]->HasOneAddress( |
2044 "192.168.0.4", 80)); | 2041 "192.168.0.4", 80)); |
2045 requests_.clear(); | 2042 requests_.clear(); |
2046 } | 2043 } |
2047 } | 2044 } |
2048 | 2045 |
2049 // Tests a call to SetDnsClient while there are active DnsTasks. | 2046 // Tests a call to SetDnsClient while there are active DnsTasks. |
2050 TEST_F(HostResolverImplDnsTest, ManuallyDisableDnsClientWithPendingRequests) { | 2047 TEST_F(HostResolverImplDnsTest, ManuallyDisableDnsClientWithPendingRequests) { |
2051 // At most 3 jobs active at once. This number is important, since we want to | 2048 // At most 3 jobs active at once. This number is important, since we want to |
2052 // make sure that aborting the first HostResolverImpl::Job does not trigger | 2049 // make sure that aborting the first HostResolverImpl::Job does not trigger |
2053 // another DnsTransaction on the second Job when it releases its second | 2050 // another DnsTransaction on the second Job when it releases its second |
2054 // prioritized dispatcher slot. | 2051 // prioritized dispatcher slot. |
(...skipping 27 matching lines...) Expand all Loading... |
2082 | 2079 |
2083 EXPECT_EQ(OK, requests_[0]->WaitForResult()); | 2080 EXPECT_EQ(OK, requests_[0]->WaitForResult()); |
2084 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); | 2081 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); |
2085 EXPECT_EQ(OK, requests_[1]->WaitForResult()); | 2082 EXPECT_EQ(OK, requests_[1]->WaitForResult()); |
2086 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); | 2083 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); |
2087 EXPECT_EQ(OK, requests_[2]->WaitForResult()); | 2084 EXPECT_EQ(OK, requests_[2]->WaitForResult()); |
2088 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); | 2085 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); |
2089 } | 2086 } |
2090 | 2087 |
2091 } // namespace net | 2088 } // namespace net |
OLD | NEW |