Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: net/dns/dns_transaction_unittest.cc

Issue 10692155: Switch to TimeDelta interfaces for process waiting functions in net and ipc. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/dns_transaction.h" 5 #include "net/dns/dns_transaction.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 503
504 TransactionHelper helper0(kT0HostName, 504 TransactionHelper helper0(kT0HostName,
505 kT0Qtype, 505 kT0Qtype,
506 ERR_NAME_NOT_RESOLVED); 506 ERR_NAME_NOT_RESOLVED);
507 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); 507 EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
508 } 508 }
509 509
510 TEST_F(DnsTransactionTest, Timeout) { 510 TEST_F(DnsTransactionTest, Timeout) {
511 config_.attempts = 3; 511 config_.attempts = 3;
512 // Use short timeout to speed up the test. 512 // Use short timeout to speed up the test.
513 config_.timeout = base::TimeDelta::FromMilliseconds( 513 config_.timeout = TestTimeouts::tiny_timeout();
514 TestTimeouts::tiny_timeout_ms());
515 ConfigureFactory(); 514 ConfigureFactory();
516 515
517 AddTimeout(kT0HostName, kT0Qtype); 516 AddTimeout(kT0HostName, kT0Qtype);
518 AddTimeout(kT0HostName, kT0Qtype); 517 AddTimeout(kT0HostName, kT0Qtype);
519 AddTimeout(kT0HostName, kT0Qtype); 518 AddTimeout(kT0HostName, kT0Qtype);
520 PrepareSockets(); 519 PrepareSockets();
521 520
522 TransactionHelper helper0(kT0HostName, 521 TransactionHelper helper0(kT0HostName,
523 kT0Qtype, 522 kT0Qtype,
524 ERR_DNS_TIMED_OUT); 523 ERR_DNS_TIMED_OUT);
525 EXPECT_TRUE(helper0.RunUntilDone(transaction_factory_.get())); 524 EXPECT_TRUE(helper0.RunUntilDone(transaction_factory_.get()));
526 MessageLoop::current()->AssertIdle(); 525 MessageLoop::current()->AssertIdle();
527 } 526 }
528 527
529 TEST_F(DnsTransactionTest, ServerFallbackAndRotate) { 528 TEST_F(DnsTransactionTest, ServerFallbackAndRotate) {
530 // Test that we fallback on both server failure and timeout. 529 // Test that we fallback on both server failure and timeout.
531 config_.attempts = 2; 530 config_.attempts = 2;
532 // The next request should start from the next server. 531 // The next request should start from the next server.
533 config_.rotate = true; 532 config_.rotate = true;
534 ConfigureNumServers(3); 533 ConfigureNumServers(3);
535 // Use short timeout to speed up the test. 534 // Use short timeout to speed up the test.
536 config_.timeout = base::TimeDelta::FromMilliseconds( 535 config_.timeout = TestTimeouts::tiny_timeout();
537 TestTimeouts::tiny_timeout_ms());
538 ConfigureFactory(); 536 ConfigureFactory();
539 537
540 // Responses for first request. 538 // Responses for first request.
541 AddTimeout(kT0HostName, kT0Qtype); 539 AddTimeout(kT0HostName, kT0Qtype);
542 AddAsyncRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeSERVFAIL); 540 AddAsyncRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeSERVFAIL);
543 AddTimeout(kT0HostName, kT0Qtype); 541 AddTimeout(kT0HostName, kT0Qtype);
544 AddAsyncRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeSERVFAIL); 542 AddAsyncRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeSERVFAIL);
545 AddAsyncRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeNXDOMAIN); 543 AddAsyncRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeNXDOMAIN);
546 // Responses for second request. 544 // Responses for second request.
547 AddAsyncRcode(kT1HostName, kT1Qtype, dns_protocol::kRcodeSERVFAIL); 545 AddAsyncRcode(kT1HostName, kT1Qtype, dns_protocol::kRcodeSERVFAIL);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 781
784 TransactionHelper helper0("www", 782 TransactionHelper helper0("www",
785 kT2Qtype, 783 kT2Qtype,
786 kT2RecordCount); 784 kT2RecordCount);
787 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); 785 EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
788 } 786 }
789 787
790 } // namespace 788 } // namespace
791 789
792 } // namespace net 790 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698