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

Unified Diff: net/dns/dns_transaction_unittest.cc

Issue 15881008: DnsTransaction::RecordLostPacketsIfAny shouldn't crash if some attempts failed to connect and thus … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed lint error. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« net/dns/dns_transaction.cc ('K') | « net/dns/dns_transaction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_transaction_unittest.cc
diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc
index f6fb8e5d795e97366097615a7ff281d8980a1d5a..262e06cde07476321ed0e42505b15bed921c46be 100644
--- a/net/dns/dns_transaction_unittest.cc
+++ b/net/dns/dns_transaction_unittest.cc
@@ -185,8 +185,10 @@ class TestSocketFactory : public MockClientSocketFactory {
const RandIntCallback& rand_int_cb,
net::NetLog* net_log,
const net::NetLog::Source& source) OVERRIDE {
- if (create_failing_sockets_)
+ if (create_failing_sockets_) {
szym 2013/05/29 17:09:42 Suggest renaming this field to |fail_next_socket_|
mef 2013/05/29 17:24:04 Done.
+ create_failing_sockets_ = false;
return new FailingUDPClientSocket(&empty_data_, net_log);
+ }
SocketDataProvider* data_provider = mock_data().GetNext();
TestUDPClientSocket* socket = new TestUDPClientSocket(this,
data_provider,
@@ -865,6 +867,21 @@ TEST_F(DnsTransactionTest, ConnectFailure) {
EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
}
+TEST_F(DnsTransactionTest, ConnectFailureDoesntCrashInRecordLostPacketsIfAny) {
szym 2013/05/29 17:09:42 suggest just calling the test "ConnectFailureFollo
mef 2013/05/29 17:24:04 Done.
+ // Fallback on server failure.
szym 2013/05/29 17:09:42 suggest: "// Retry after failure."
mef 2013/05/29 17:24:04 Done.
+ config_.attempts = 2;
+ ConfigureFactory();
+ // First server connection attempt fails.
+ transaction_ids_.push_back(0); // Needed to make a DnsUDPAttempt.
+ socket_factory_->create_failing_sockets_ = true;
+ // Second DNS query succeeds.
+ AddAsyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
+ kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
+ TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
+ // Expect no crash here!
szym 2013/05/29 17:09:42 unnecessary comment
mef 2013/05/29 17:24:04 Done.
+ EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
+}
+
TEST_F(DnsTransactionTest, TCPLookup) {
AddAsyncQueryAndRcode(kT0HostName, kT0Qtype,
dns_protocol::kRcodeNOERROR | dns_protocol::kFlagTC);
« net/dns/dns_transaction.cc ('K') | « net/dns/dns_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698