diff options
Diffstat (limited to 'net/quic/reliable_quic_stream_test.cc')
| -rw-r--r-- | net/quic/reliable_quic_stream_test.cc | 167 |
1 files changed, 38 insertions, 129 deletions
diff --git a/net/quic/reliable_quic_stream_test.cc b/net/quic/reliable_quic_stream_test.cc index b006895..8de1863 100644 --- a/net/quic/reliable_quic_stream_test.cc +++ b/net/quic/reliable_quic_stream_test.cc @@ -141,7 +141,6 @@ class ReliableQuicStreamTest : public ::testing::TestWithParam<bool> { QuicIOVector /*iov*/, QuicStreamOffset /*offset*/, bool /*fin*/, - FecProtection /*fec_protection*/, QuicAckListenerInterface* /*ack_notifier_delegate*/) { session_->CloseStream(id); return QuicConsumedData(1, false); @@ -163,13 +162,12 @@ class ReliableQuicStreamTest : public ::testing::TestWithParam<bool> { TEST_F(ReliableQuicStreamTest, WriteAllData) { Initialize(kShouldProcessData); - size_t length = - 1 + QuicPacketCreator::StreamFramePacketOverhead( - PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, !kIncludePathId, - PACKET_6BYTE_PACKET_NUMBER, 0u, NOT_IN_FEC_GROUP); + size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( + PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, + !kIncludePathId, PACKET_6BYTE_PACKET_NUMBER, 0u); connection_->SetMaxPacketLength(length); - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(kDataLen, true))); stream_->WriteOrBufferData(kData1, false, nullptr); EXPECT_FALSE(HasWriteBlockedStreams()); @@ -189,7 +187,7 @@ TEST_F(ReliableQuicStreamTest, BlockIfOnlySomeDataConsumed) { // Write some data and no fin. If we consume some but not all of the data, // we should be write blocked a not all the data was consumed. - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(1, false))); stream_->WriteOrBufferData(StringPiece(kData1, 2), false, nullptr); ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); @@ -203,7 +201,7 @@ TEST_F(ReliableQuicStreamTest, BlockIfFinNotConsumedWithData) { // we should be write blocked because the fin was not consumed. // (This should never actually happen as the fin should be sent out with the // last data) - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(2, false))); stream_->WriteOrBufferData(StringPiece(kData1, 2), true, nullptr); ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); @@ -214,7 +212,7 @@ TEST_F(ReliableQuicStreamTest, BlockIfSoloFinNotConsumed) { // Write no data and a fin. If we consume nothing we should be write blocked, // as the fin was not consumed. - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(0, false))); stream_->WriteOrBufferData(StringPiece(), true, nullptr); ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); @@ -226,7 +224,7 @@ TEST_F(ReliableQuicStreamTest, CloseOnPartialWrite) { // Write some data and no fin. However, while writing the data // close the stream and verify that MarkConnectionLevelWriteBlocked does not // crash with an unknown stream. - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Invoke(this, &ReliableQuicStreamTest::CloseStreamOnWriteError)); stream_->WriteOrBufferData(StringPiece(kData1, 2), false, nullptr); ASSERT_EQ(0u, write_blocked_list_->NumBlockedStreams()); @@ -236,13 +234,12 @@ TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { Initialize(kShouldProcessData); EXPECT_FALSE(HasWriteBlockedStreams()); - size_t length = - 1 + QuicPacketCreator::StreamFramePacketOverhead( - PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, !kIncludePathId, - PACKET_6BYTE_PACKET_NUMBER, 0u, NOT_IN_FEC_GROUP); + size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( + PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, + !kIncludePathId, PACKET_6BYTE_PACKET_NUMBER, 0u); connection_->SetMaxPacketLength(length); - EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) .WillOnce(Return(QuicConsumedData(kDataLen - 1, false))); stream_->WriteOrBufferData(kData1, false, nullptr); EXPECT_TRUE(HasWriteBlockedStreams()); @@ -252,86 +249,14 @@ TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { // Make sure we get the tail of the first write followed by the bytes_consumed InSequence s; - EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) .WillOnce(Return(QuicConsumedData(1, false))); - EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) .WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); stream_->OnCanWrite(); // And finally the end of the bytes_consumed. - EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) - .WillOnce(Return(QuicConsumedData(2, true))); - stream_->OnCanWrite(); -} - -TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectAlways) { - Initialize(kShouldProcessData); - - // Set FEC policy on stream. - ReliableQuicStreamPeer::SetFecPolicy(stream_, FEC_PROTECT_ALWAYS); - - EXPECT_FALSE(HasWriteBlockedStreams()); - size_t length = - 1 + QuicPacketCreator::StreamFramePacketOverhead( - PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, !kIncludePathId, - PACKET_6BYTE_PACKET_NUMBER, 0u, IN_FEC_GROUP); - connection_->SetMaxPacketLength(length); - - // Write first data onto stream, which will cause one session write. - EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)) - .WillOnce(Return(QuicConsumedData(kDataLen - 1, false))); - stream_->WriteOrBufferData(kData1, false, nullptr); - EXPECT_TRUE(HasWriteBlockedStreams()); - - // Queue a bytes_consumed write. - stream_->WriteOrBufferData(kData2, false, nullptr); - - // Make sure we get the tail of the first write followed by the bytes_consumed - InSequence s; - EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)) - .WillOnce(Return(QuicConsumedData(1, false))); - EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)) - .WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); - stream_->OnCanWrite(); - - // And finally the end of the bytes_consumed. - EXPECT_CALL(*session_, WritevData(_, _, _, _, MUST_FEC_PROTECT, _)) - .WillOnce(Return(QuicConsumedData(2, true))); - stream_->OnCanWrite(); -} - -TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithFecProtectOptional) { - Initialize(kShouldProcessData); - - // Set FEC policy on stream. - ReliableQuicStreamPeer::SetFecPolicy(stream_, FEC_PROTECT_OPTIONAL); - - EXPECT_FALSE(HasWriteBlockedStreams()); - size_t length = - 1 + QuicPacketCreator::StreamFramePacketOverhead( - PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, !kIncludePathId, - PACKET_6BYTE_PACKET_NUMBER, 0u, NOT_IN_FEC_GROUP); - connection_->SetMaxPacketLength(length); - - // Write first data onto stream, which will cause one session write. - EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)) - .WillOnce(Return(QuicConsumedData(kDataLen - 1, false))); - stream_->WriteOrBufferData(kData1, false, nullptr); - EXPECT_TRUE(HasWriteBlockedStreams()); - - // Queue a bytes_consumed write. - stream_->WriteOrBufferData(kData2, false, nullptr); - - // Make sure we get the tail of the first write followed by the bytes_consumed - InSequence s; - EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)) - .WillOnce(Return(QuicConsumedData(1, false))); - EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)) - .WillOnce(Return(QuicConsumedData(kDataLen - 2, false))); - stream_->OnCanWrite(); - - // And finally the end of the bytes_consumed. - EXPECT_CALL(*session_, WritevData(_, _, _, _, MAY_FEC_PROTECT, _)) + EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) .WillOnce(Return(QuicConsumedData(2, true))); stream_->OnCanWrite(); } @@ -359,7 +284,7 @@ TEST_F(ReliableQuicStreamTest, RstAlwaysSentIfNoFinSent) { EXPECT_FALSE(rst_sent()); // Write some data, with no FIN. - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(1, false))); stream_->WriteOrBufferData(StringPiece(kData1, 1), false, nullptr); EXPECT_FALSE(fin_sent()); @@ -382,7 +307,7 @@ TEST_F(ReliableQuicStreamTest, RstNotSentIfFinSent) { EXPECT_FALSE(rst_sent()); // Write some data, with FIN. - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(1, true))); stream_->WriteOrBufferData(StringPiece(kData1, 1), true, nullptr); EXPECT_TRUE(fin_sent()); @@ -476,26 +401,23 @@ TEST_F(ReliableQuicStreamTest, WriteOrBufferDataWithQuicAckNotifier) { scoped_refptr<QuicAckListenerInterface> ack_listener; - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(DoAll( - WithArgs<5>(Invoke(CreateFunctor(SaveAckListener, &ack_listener))), + WithArgs<4>(Invoke(CreateFunctor(SaveAckListener, &ack_listener))), Return(QuicConsumedData(kFirstWriteSize, false)))); stream_->WriteOrBufferData(kData, false, delegate.get()); EXPECT_TRUE(HasWriteBlockedStreams()); - EXPECT_CALL(*session_, - WritevData(kTestStreamId, _, _, _, _, ack_listener.get())) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, ack_listener.get())) .WillOnce(Return(QuicConsumedData(kSecondWriteSize, false))); stream_->OnCanWrite(); // No ack expected for an empty write. - EXPECT_CALL(*session_, - WritevData(kTestStreamId, _, _, _, _, ack_listener.get())) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, ack_listener.get())) .WillOnce(Return(QuicConsumedData(0, false))); stream_->OnCanWrite(); - EXPECT_CALL(*session_, - WritevData(kTestStreamId, _, _, _, _, ack_listener.get())) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, ack_listener.get())) .WillOnce(Return(QuicConsumedData(kLastWriteSize, false))); stream_->OnCanWrite(); } @@ -518,16 +440,16 @@ TEST_F(ReliableQuicStreamTest, WriteOrBufferDataAckNotificationBeforeFlush) { scoped_refptr<QuicAckListenerInterface> proxy_delegate; - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(DoAll( - WithArgs<5>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), + WithArgs<4>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), Return(QuicConsumedData(kInitialWriteSize, false)))); stream_->WriteOrBufferData(kData, false, ack_listener.get()); EXPECT_TRUE(HasWriteBlockedStreams()); - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(DoAll( - WithArgs<5>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), + WithArgs<4>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), Return(QuicConsumedData(kDataSize - kInitialWriteSize, false)))); stream_->OnCanWrite(); } @@ -540,9 +462,9 @@ TEST_F(ReliableQuicStreamTest, WriteAndBufferDataWithAckNotiferNoBuffer) { scoped_refptr<QuicAckListenerInterface> proxy_delegate; - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(DoAll( - WithArgs<5>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), + WithArgs<4>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), Return(QuicConsumedData(kDataLen, true)))); stream_->WriteOrBufferData(kData1, true, delegate.get()); EXPECT_FALSE(HasWriteBlockedStreams()); @@ -556,14 +478,14 @@ TEST_F(ReliableQuicStreamTest, BufferOnWriteAndBufferDataWithAckNotifer) { scoped_refptr<QuicAckListenerInterface> proxy_delegate; - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(0, false))); stream_->WriteOrBufferData(kData1, true, delegate.get()); EXPECT_TRUE(HasWriteBlockedStreams()); - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(DoAll( - WithArgs<5>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), + WithArgs<4>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), Return(QuicConsumedData(kDataLen, true)))); stream_->OnCanWrite(); } @@ -577,16 +499,16 @@ TEST_F(ReliableQuicStreamTest, WriteAndBufferDataWithAckNotiferOnlyFinRemains) { scoped_refptr<QuicAckListenerInterface> proxy_delegate; - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(DoAll( - WithArgs<5>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), + WithArgs<4>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), Return(QuicConsumedData(kDataLen, false)))); stream_->WriteOrBufferData(kData1, true, delegate.get()); EXPECT_TRUE(HasWriteBlockedStreams()); - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(DoAll( - WithArgs<5>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), + WithArgs<4>(Invoke(CreateFunctor(SaveAckListener, &proxy_delegate))), Return(QuicConsumedData(0, true)))); stream_->OnCanWrite(); } @@ -678,7 +600,7 @@ TEST_F(ReliableQuicStreamTest, SetDrainingIncomingOutgoing) { EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); // Outgoing data with FIN. - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(2, true))); stream_->WriteOrBufferData(StringPiece(kData1, 2), true, nullptr); EXPECT_TRUE(stream_->write_side_closed()); @@ -693,7 +615,7 @@ TEST_F(ReliableQuicStreamTest, SetDrainingOutgoingIncoming) { Initialize(kShouldNotProcessData); // Outgoing data with FIN. - EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) .WillOnce(Return(QuicConsumedData(2, true))); stream_->WriteOrBufferData(StringPiece(kData1, 2), true, nullptr); EXPECT_TRUE(stream_->write_side_closed()); @@ -714,26 +636,13 @@ TEST_F(ReliableQuicStreamTest, SetDrainingOutgoingIncoming) { EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); } -TEST_F(ReliableQuicStreamTest, FecSendPolicyReceivedConnectionOption) { - Initialize(kShouldProcessData); - - // Test ReceivedConnectionOptions. - QuicConfig* config = session_->config(); - QuicTagVector copt; - copt.push_back(kFSTR); - QuicConfigPeer::SetReceivedConnectionOptions(config, copt); - EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream_->fec_policy()); - stream_->SetFromConfig(); - EXPECT_EQ(FEC_PROTECT_ALWAYS, stream_->fec_policy()); -} - TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) { // Verify that if the server completes the response before reading the end of // the request, the received FIN is recorded. Initialize(kShouldProcessData); EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0); - EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) + EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); // Receive data for the request. |
