| 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 64de93ec0ccafa13f8e113ec5d0ad13a36c67317..0399e2b78db255c2f5df8baa1fd9806fdf41b73e 100644
|
| --- a/net/quic/core/quic_session_test.cc
|
| +++ b/net/quic/core/quic_session_test.cc
|
| @@ -119,6 +119,8 @@ class TestSession : public QuicSpdySession {
|
| Initialize();
|
| }
|
|
|
| + ~TestSession() override { delete connection(); }
|
| +
|
| TestCryptoStream* GetCryptoStream() override { return &crypto_stream_; }
|
|
|
| TestStream* CreateOutgoingDynamicStream(SpdyPriority priority) override {
|
| @@ -280,7 +282,7 @@ class QuicSessionTestServer : public QuicSessionTestBase {
|
|
|
| INSTANTIATE_TEST_CASE_P(Tests,
|
| QuicSessionTestServer,
|
| - ::testing::ValuesIn(QuicSupportedVersions()));
|
| + ::testing::ValuesIn(AllSupportedVersions()));
|
|
|
| TEST_P(QuicSessionTestServer, PeerAddress) {
|
| EXPECT_EQ(IPEndPoint(Loopback4(), kTestPort), session_.peer_address());
|
| @@ -490,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);
|
| @@ -511,6 +515,7 @@ TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) {
|
| .WillRepeatedly(Return(QuicTime::Delta::Zero()));
|
| EXPECT_CALL(*send_algorithm, GetCongestionWindow())
|
| .WillRepeatedly(Return(kMaxPacketSize * 10));
|
| + EXPECT_CALL(*send_algorithm, InRecovery()).WillRepeatedly(Return(false));
|
| EXPECT_CALL(*stream2, OnCanWrite())
|
| .WillOnce(testing::IgnoreResult(
|
| Invoke(CreateFunctor(&TestSession::SendStreamData,
|
| @@ -531,11 +536,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.
|
| @@ -576,10 +584,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.
|
|
|
| @@ -642,6 +681,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());
|
| @@ -667,6 +716,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());
|
| }
|
| @@ -1127,7 +1180,7 @@ class QuicSessionTestClient : public QuicSessionTestBase {
|
|
|
| INSTANTIATE_TEST_CASE_P(Tests,
|
| QuicSessionTestClient,
|
| - ::testing::ValuesIn(QuicSupportedVersions()));
|
| + ::testing::ValuesIn(AllSupportedVersions()));
|
|
|
| TEST_P(QuicSessionTestClient, AvailableStreamsClient) {
|
| ASSERT_TRUE(session_.GetOrCreateDynamicStream(6) != nullptr);
|
|
|