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

Unified Diff: net/quic/quic_session_test.cc

Issue 23587004: If the stream is being closed locally (for example in the case of a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 7 years, 4 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/quic_session.cc ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_session_test.cc
diff --git a/net/quic/quic_session_test.cc b/net/quic/quic_session_test.cc
index 4df7222c9248db740321a1e8ad5f30436f6f39d9..77234e1a1caa0697de2f6b70df0dba2fb8067601 100644
--- a/net/quic/quic_session_test.cc
+++ b/net/quic/quic_session_test.cc
@@ -13,6 +13,7 @@
#include "net/quic/quic_protocol.h"
#include "net/quic/test_tools/quic_connection_peer.h"
#include "net/quic/test_tools/quic_test_utils.h"
+#include "net/quic/test_tools/reliable_quic_stream_peer.h"
#include "net/spdy/spdy_framer.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,6 +23,7 @@ using std::set;
using std::vector;
using testing::_;
using testing::InSequence;
+using testing::StrictMock;
namespace net {
namespace test {
@@ -105,6 +107,33 @@ class QuicSessionTest : public ::testing::Test {
: guid_(1),
connection_(new MockConnection(guid_, IPEndPoint(), false)),
session_(connection_, true) {
+ headers_[":host"] = "www.google.com";
+ headers_[":path"] = "/index.hml";
+ headers_[":scheme"] = "http";
+ headers_["cookie"] =
+ "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; "
+ "__utmc=160408618; "
+ "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX"
+ "h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fbHhm3mVEXnyRW4ZuNOLFk"
+ "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn"
+ "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr"
+ "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo ";
}
void CheckClosedStreams() {
@@ -126,6 +155,7 @@ class QuicSessionTest : public ::testing::Test {
MockConnection* connection_;
TestSession session_;
set<QuicStreamId> closed_streams_;
+ SpdyHeaderBlock headers_;
};
TEST_F(QuicSessionTest, PeerAddress) {
@@ -149,8 +179,10 @@ TEST_F(QuicSessionTest, IsClosedStreamDefault) {
TEST_F(QuicSessionTest, IsClosedStreamLocallyCreated) {
TestStream* stream2 = session_.CreateOutgoingReliableStream();
EXPECT_EQ(2u, stream2->id());
+ ReliableQuicStreamPeer::SetHeadersDecompressed(stream2, true);
TestStream* stream4 = session_.CreateOutgoingReliableStream();
EXPECT_EQ(4u, stream4->id());
+ ReliableQuicStreamPeer::SetHeadersDecompressed(stream4, true);
CheckClosedStreams();
CloseStream(4);
@@ -160,15 +192,18 @@ TEST_F(QuicSessionTest, IsClosedStreamLocallyCreated) {
}
TEST_F(QuicSessionTest, IsClosedStreamPeerCreated) {
- session_.GetIncomingReliableStream(3);
- session_.GetIncomingReliableStream(5);
+ ReliableQuicStream* stream3 = session_.GetIncomingReliableStream(3);
+ ReliableQuicStreamPeer::SetHeadersDecompressed(stream3, true);
+ ReliableQuicStream* stream5 = session_.GetIncomingReliableStream(5);
+ ReliableQuicStreamPeer::SetHeadersDecompressed(stream5, true);
CheckClosedStreams();
CloseStream(3);
CheckClosedStreams();
CloseStream(5);
// Create stream id 9, and implicitly 7
- session_.GetIncomingReliableStream(9);
+ ReliableQuicStream* stream9 = session_.GetIncomingReliableStream(9);
+ ReliableQuicStreamPeer::SetHeadersDecompressed(stream9, true);
CheckClosedStreams();
// Close 9, but make sure 7 is still not closed
CloseStream(9);
@@ -229,10 +264,6 @@ TEST_F(QuicSessionTest, OnCanWriteWithClosedStream) {
// Regression test for http://crbug.com/248737
TEST_F(QuicSessionTest, OutOfOrderHeaders) {
QuicSpdyCompressor compressor;
- SpdyHeaderBlock headers;
- headers[":host"] = "www.google.com";
- headers[":path"] = "/index.hml";
- headers[":scheme"] = "http";
vector<QuicStreamFrame> frames;
QuicPacketHeader header;
header.public_header.guid = session_.guid();
@@ -243,11 +274,11 @@ TEST_F(QuicSessionTest, OutOfOrderHeaders) {
stream4->CloseWriteSide();
// Create frame with headers for stream2.
- string compressed_headers1 = compressor.CompressHeaders(headers);
+ string compressed_headers1 = compressor.CompressHeaders(headers_);
QuicStreamFrame frame1(stream2->id(), false, 0, compressed_headers1);
// Create frame with headers for stream4.
- string compressed_headers2 = compressor.CompressHeaders(headers);
+ string compressed_headers2 = compressor.CompressHeaders(headers_);
QuicStreamFrame frame2(stream4->id(), true, 0, compressed_headers2);
// Process the second frame first. This will cause the headers to
@@ -260,7 +291,7 @@ TEST_F(QuicSessionTest, OutOfOrderHeaders) {
session_.OnPacket(IPEndPoint(), IPEndPoint(), header, frames);
// Ensure that the streams actually close and we don't DCHECK.
- session_.ConnectionClose(QUIC_CONNECTION_TIMED_OUT, true);
+ connection_->CloseConnection(QUIC_CONNECTION_TIMED_OUT, true);
}
TEST_F(QuicSessionTest, SendGoAway) {
@@ -284,6 +315,40 @@ TEST_F(QuicSessionTest, IncreasedTimeoutAfterCryptoHandshake) {
QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
}
+TEST_F(QuicSessionTest, ZombieStream) {
+ StrictMock<MockConnection>* connection =
+ new StrictMock<MockConnection>(guid_, IPEndPoint(), false);
+ TestSession session(connection, /*is_server=*/ false);
+
+ TestStream* stream3 = session.CreateOutgoingReliableStream();
+ EXPECT_EQ(3u, stream3->id());
+ TestStream* stream5 = session.CreateOutgoingReliableStream();
+ EXPECT_EQ(5u, stream5->id());
+
+ // Reset the stream, but since the headers have not been decompressed
+ // it will become a zombie and will continue to process data
+ // until the headers are decompressed.
+ EXPECT_CALL(*connection, SendRstStream(3, QUIC_STREAM_CANCELLED));
+ session.SendRstStream(3, QUIC_STREAM_CANCELLED);
+
+ vector<QuicStreamFrame> frames;
+ QuicPacketHeader header;
+ header.public_header.guid = session_.guid();
+
+ // Create frame with headers for stream2.
+ QuicSpdyCompressor compressor;
+ string compressed_headers1 = compressor.CompressHeaders(headers_);
+ QuicStreamFrame frame1(stream3->id(), false, 0, compressed_headers1);
+
+ // Process the second frame first. This will cause the headers to
+ // be queued up and processed after the first frame is processed.
+ frames.push_back(frame1);
+ EXPECT_FALSE(stream3->headers_decompressed());
+ session.OnPacket(IPEndPoint(), IPEndPoint(), header, frames);
+
+ EXPECT_TRUE(connection->connected());
+}
+
} // namespace
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698