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

Unified Diff: net/quic/core/quic_stream_test.cc

Issue 2915873003: This QUIC change includes: (Closed)
Patch Set: Created 3 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
« no previous file with comments | « net/quic/core/quic_stream.cc ('k') | net/quic/core/quic_unacked_packet_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_stream_test.cc
diff --git a/net/quic/core/quic_stream_test.cc b/net/quic/core/quic_stream_test.cc
index 6e83daec66f51e476e4bd0eb5d1edb22dccd16fe..c00f2b2b629aea4119a6f0eeb13c4382d7afd2e2 100644
--- a/net/quic/core/quic_stream_test.cc
+++ b/net/quic/core/quic_stream_test.cc
@@ -62,6 +62,7 @@ class TestStream : public QuicStream {
using QuicStream::WriteOrBufferData;
using QuicStream::CloseWriteSide;
using QuicStream::OnClose;
+ using QuicStream::SetIsDeletable;
private:
bool should_process_data_;
@@ -714,6 +715,103 @@ TEST_F(QuicStreamTest, EarlyResponseFinHandling) {
EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
}
+TEST_F(QuicStreamTest, StreamIsDeletable) {
+ Initialize(kShouldProcessData);
+ if (!session_->use_stream_notifier()) {
+ return;
+ }
+ EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _))
+ .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData));
+ // Stream is deletable initially.
+ EXPECT_TRUE(stream_->is_deletable());
+
+ // Send kData1.
+ stream_->WriteOrBufferData(kData1, false, nullptr);
+ EXPECT_FALSE(stream_->is_deletable());
+ QuicStreamFrame frame1(stream_->id(), false, 0, kData1);
+ stream_->OnStreamFrameAcked(frame1, QuicTime::Delta::Zero());
+ // Stream is deletable as all sent data is acked.
+ EXPECT_TRUE(stream_->is_deletable());
+
+ // Send kData2.
+ stream_->WriteOrBufferData(kData2, false, nullptr);
+ EXPECT_FALSE(stream_->is_deletable());
+ // Send FIN.
+ stream_->WriteOrBufferData("", true, nullptr);
+
+ // kData2 is acked.
+ QuicStreamFrame frame2(stream_->id(), false, 9, kData2);
+ stream_->OnStreamFrameAcked(frame2, QuicTime::Delta::Zero());
+ // Stream is not deletable as FIN is not acked.
+ EXPECT_FALSE(stream_->is_deletable());
+
+ // FIN is acked.
+ QuicStreamFrame frame3(stream_->id(), true, 18, "");
+ stream_->OnStreamFrameAcked(frame3, QuicTime::Delta::Zero());
+ EXPECT_TRUE(stream_->is_deletable());
+}
+
+TEST_F(QuicStreamTest, CancelStream) {
+ Initialize(kShouldProcessData);
+ if (!session_->use_stream_notifier()) {
+ return;
+ }
+
+ EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _))
+ .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData));
+ EXPECT_TRUE(stream_->is_deletable());
+
+ stream_->WriteOrBufferData(kData1, false, nullptr);
+ EXPECT_FALSE(stream_->is_deletable());
+ // Cancel stream.
+ stream_->Reset(QUIC_STREAM_NO_ERROR);
+ // stream is not deletable as the error code is QUIC_STREAM_NO_ERROR, and data
+ // is going to be retransmitted.
+ EXPECT_FALSE(stream_->is_deletable());
+ stream_->Reset(QUIC_STREAM_CANCELLED);
+ // Stream is deletable as data is not going to be retransmitted.
+ EXPECT_TRUE(stream_->is_deletable());
+}
+
+TEST_F(QuicStreamTest, RstFrameReceived) {
+ Initialize(kShouldProcessData);
+ if (!session_->use_stream_notifier()) {
+ return;
+ }
+
+ EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _))
+ .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData));
+ EXPECT_TRUE(stream_->is_deletable());
+
+ stream_->WriteOrBufferData(kData1, false, nullptr);
+ EXPECT_FALSE(stream_->is_deletable());
+
+ // RST_STREAM received.
+ QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234);
+ stream_->OnStreamReset(rst_frame);
+ // Stream is not deletable as it has outstanding data.
+ EXPECT_FALSE(stream_->is_deletable());
+}
+
+TEST_F(QuicStreamTest, ConnectionClosed) {
+ Initialize(kShouldProcessData);
+ if (!session_->use_stream_notifier()) {
+ return;
+ }
+
+ EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _))
+ .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData));
+ EXPECT_TRUE(stream_->is_deletable());
+
+ stream_->WriteOrBufferData(kData1, false, nullptr);
+ EXPECT_FALSE(stream_->is_deletable());
+
+ stream_->OnConnectionClosed(QUIC_INTERNAL_ERROR,
+ ConnectionCloseSource::FROM_SELF);
+ // Stream is deletable as connection is closed.
+ EXPECT_TRUE(stream_->is_deletable());
+}
+
} // namespace
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/core/quic_stream.cc ('k') | net/quic/core/quic_unacked_packet_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698