| Index: net/quic/core/quic_session_test.cc
|
| diff --git a/net/quic/core/quic_session_test.cc b/net/quic/core/quic_session_test.cc
|
| index cd1e3b152d13a27a5bf587ab5698841202c8aa1e..d9f3fd8fd0d28d040a93295f621c53fae0d18170 100644
|
| --- a/net/quic/core/quic_session_test.cc
|
| +++ b/net/quic/core/quic_session_test.cc
|
| @@ -492,6 +492,8 @@ TEST_P(QuicSessionTestServer, TestBatchedWrites) {
|
| }
|
|
|
| TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) {
|
| + FLAGS_quic_enable_app_limited_check = true;
|
| +
|
| // Encryption needs to be established before data can be sent.
|
| CryptoHandshakeMessage msg;
|
| session_.GetCryptoStream()->OnHandshakeMessage(msg);
|
| @@ -533,11 +535,14 @@ TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) {
|
| EXPECT_CALL(*writer, WritePacket(_, _, _, _, _))
|
| .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
|
| EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _));
|
| + EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
|
| session_.OnCanWrite();
|
| EXPECT_FALSE(session_.WillingAndAbleToWrite());
|
| }
|
|
|
| TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) {
|
| + FLAGS_quic_enable_app_limited_check = true;
|
| +
|
| InSequence s;
|
|
|
| // Drive congestion control manually.
|
| @@ -578,10 +583,41 @@ TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) {
|
| EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
|
| .WillOnce(Return(QuicTime::Delta::Zero()));
|
| EXPECT_CALL(*stream4, OnCanWrite());
|
| + EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
|
| session_.OnCanWrite();
|
| EXPECT_FALSE(session_.WillingAndAbleToWrite());
|
| }
|
|
|
| +TEST_P(QuicSessionTestServer, OnCanWriteWriterBlocks) {
|
| + FLAGS_quic_enable_app_limited_check = true;
|
| +
|
| + // Drive congestion control manually in order to ensure that
|
| + // application-limited signaling is handled correctly.
|
| + MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
|
| + QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
|
| + send_algorithm);
|
| + EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
|
| + .WillRepeatedly(Return(QuicTime::Delta::Zero()));
|
| +
|
| + // Drive packet writer manually.
|
| + MockPacketWriter* writer = static_cast<MockPacketWriter*>(
|
| + QuicConnectionPeer::GetWriter(session_.connection()));
|
| + EXPECT_CALL(*writer, IsWriteBlocked()).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(*writer, IsWriteBlockedDataBuffered())
|
| + .WillRepeatedly(Return(true));
|
| + EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)).Times(0);
|
| +
|
| + TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
|
| +
|
| + session_.MarkConnectionLevelWriteBlocked(stream2->id());
|
| +
|
| + EXPECT_CALL(*stream2, OnCanWrite()).Times(0);
|
| + EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)).Times(0);
|
| +
|
| + session_.OnCanWrite();
|
| + EXPECT_TRUE(session_.WillingAndAbleToWrite());
|
| +}
|
| +
|
| TEST_P(QuicSessionTestServer, BufferedHandshake) {
|
| EXPECT_FALSE(session_.HasPendingHandshake()); // Default value.
|
|
|
| @@ -644,6 +680,16 @@ TEST_P(QuicSessionTestServer, OnCanWriteWithClosedStream) {
|
| }
|
|
|
| TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
|
| + FLAGS_quic_enable_app_limited_check = true;
|
| +
|
| + // Drive congestion control manually in order to ensure that
|
| + // application-limited signaling is handled correctly.
|
| + MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
|
| + QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
|
| + send_algorithm);
|
| + EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
|
| + .WillRepeatedly(Return(QuicTime::Delta::Zero()));
|
| +
|
| // Ensure connection level flow control blockage.
|
| QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0);
|
| EXPECT_TRUE(session_.flow_controller()->IsBlocked());
|
| @@ -669,6 +715,10 @@ TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
|
| QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream);
|
| EXPECT_CALL(*headers_stream, OnCanWrite());
|
|
|
| + // After the crypto and header streams perform a write, the connection will be
|
| + // blocked by the flow control, hence it should become application-limited.
|
| + EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
|
| +
|
| session_.OnCanWrite();
|
| EXPECT_FALSE(session_.WillingAndAbleToWrite());
|
| }
|
|
|