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

Unified Diff: net/quic/quic_connection_test.cc

Issue 786123002: Update from https://crrev.com/307330 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection_test.cc
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 32d7544f6bdb705cc1b4629c3c2675820e807ccf..cb46bd9a8b80d93e7d5e30f93f3f7944f043e907 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -31,6 +31,7 @@
using base::StringPiece;
using std::map;
+using std::string;
using std::vector;
using testing::AnyNumber;
using testing::AtLeast;
@@ -2987,6 +2988,7 @@ TEST_P(QuicConnectionTest, TimeoutAfterSend) {
EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
QuicConfig config;
connection_.SetFromConfig(config);
+ EXPECT_FALSE(QuicConnectionPeer::IsSilentCloseEnabled(&connection_));
const QuicTime::Delta initial_idle_timeout =
QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1);
@@ -3021,6 +3023,67 @@ TEST_P(QuicConnectionTest, TimeoutAfterSend) {
EXPECT_FALSE(connection_.connected());
}
+TEST_P(QuicConnectionTest, TimeoutAfterSendSilentClose) {
+ // Same test as above, but complete a handshake which enables silent close,
+ // causing no connection close packet to be sent.
+ ValueRestore<bool> old_flag(&FLAGS_quic_allow_silent_close, true);
+ EXPECT_TRUE(connection_.connected());
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
+ QuicConfig config;
+
+ // Create a handshake message that also enables silent close.
+ CryptoHandshakeMessage msg;
+ string error_details;
+ QuicConfig client_config;
+ client_config.SetInitialFlowControlWindowToSend(
+ kInitialSessionFlowControlWindowForTest);
+ client_config.SetInitialStreamFlowControlWindowToSend(
+ kInitialStreamFlowControlWindowForTest);
+ client_config.SetInitialSessionFlowControlWindowToSend(
+ kInitialSessionFlowControlWindowForTest);
+ client_config.SetIdleConnectionStateLifetime(
+ QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs),
+ QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs));
+ client_config.ToHandshakeMessage(&msg);
+ const QuicErrorCode error =
+ config.ProcessPeerHello(msg, CLIENT, &error_details);
+ EXPECT_EQ(QUIC_NO_ERROR, error);
+
+ connection_.SetFromConfig(config);
+ EXPECT_TRUE(QuicConnectionPeer::IsSilentCloseEnabled(&connection_));
+
+ const QuicTime::Delta default_idle_timeout =
+ QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs - 1);
+ const QuicTime::Delta five_ms = QuicTime::Delta::FromMilliseconds(5);
+ QuicTime default_timeout = clock_.ApproximateNow().Add(default_idle_timeout);
+
+ // When we send a packet, the timeout will change to 5ms +
+ // kInitialIdleTimeoutSecs.
+ clock_.AdvanceTime(five_ms);
+
+ // Send an ack so we don't set the retransmission alarm.
+ SendAckPacketToPeer();
+ EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
+
+ // The original alarm will fire. We should not time out because we had a
+ // network event at t=5ms. The alarm will reregister.
+ clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms));
+ EXPECT_EQ(default_timeout, clock_.ApproximateNow());
+ connection_.GetTimeoutAlarm()->Fire();
+ EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
+ EXPECT_TRUE(connection_.connected());
+ EXPECT_EQ(default_timeout.Add(five_ms),
+ connection_.GetTimeoutAlarm()->deadline());
+
+ // This time, we should time out.
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false));
+ clock_.AdvanceTime(five_ms);
+ EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow());
+ connection_.GetTimeoutAlarm()->Fire();
+ EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
+ EXPECT_FALSE(connection_.connected());
+}
+
TEST_P(QuicConnectionTest, SendScheduler) {
// Test that if we send a packet without delay, it is not queued.
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698