Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / net / tools / quic / quic_server_session_test.cc
index 1b2cb3f..b8e6d56 100644 (file)
@@ -7,6 +7,7 @@
 #include "net/quic/crypto/quic_crypto_server_config.h"
 #include "net/quic/crypto/quic_random.h"
 #include "net/quic/quic_connection.h"
+#include "net/quic/quic_utils.h"
 #include "net/quic/test_tools/quic_connection_peer.h"
 #include "net/quic/test_tools/quic_data_stream_peer.h"
 #include "net/quic/test_tools/quic_test_utils.h"
@@ -109,6 +110,8 @@ class QuicServerSessionTest : public ::testing::TestWithParam<QuicVersion> {
     QuicDataStreamPeer::SetHeadersDecompressed(stream, true);
   }
 
+  QuicVersion version() const { return connection_->version(); }
+
   StrictMock<MockQuicServerSessionVisitor> owner_;
   StrictMock<MockConnection>* connection_;
   QuicConfig config_;
@@ -121,7 +124,7 @@ INSTANTIATE_TEST_CASE_P(Tests, QuicServerSessionTest,
                         ::testing::ValuesIn(QuicSupportedVersions()));
 
 TEST_P(QuicServerSessionTest, CloseStreamDueToReset) {
-  QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+  QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
   // Open a stream, then reset it.
   // Send two bytes of payload to open it.
   QuicStreamFrame data1(stream_id, false, 0, MakeIOVector("HT"));
@@ -134,8 +137,12 @@ TEST_P(QuicServerSessionTest, CloseStreamDueToReset) {
   // compression context' state.
   MarkHeadersReadForStream(stream_id);
 
-  // Send a reset.
-  QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR);
+  // Send a reset (and expect the peer to send a RST in response).
+  QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0);
+  if (version() > QUIC_VERSION_13) {
+    EXPECT_CALL(*connection_,
+                SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0));
+  }
   visitor_->OnRstStream(rst1);
   EXPECT_EQ(0u, session_->GetNumOpenStreams());
 
@@ -147,9 +154,14 @@ TEST_P(QuicServerSessionTest, CloseStreamDueToReset) {
 }
 
 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) {
-  QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
-  // Send a reset.
-  QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR);
+  QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
+
+  // Send a reset (and expect the peer to send a RST in response).
+  QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0);
+  if (version() > QUIC_VERSION_13) {
+    EXPECT_CALL(*connection_,
+                SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0));
+  }
   visitor_->OnRstStream(rst1);
   EXPECT_EQ(0u, session_->GetNumOpenStreams());
 
@@ -158,7 +170,7 @@ TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) {
   vector<QuicStreamFrame> frames;
   frames.push_back(data1);
 
-  if (connection_->version() > QUIC_VERSION_12) {
+  if (version() > QUIC_VERSION_12) {
     EXPECT_TRUE(visitor_->OnStreamFrames(frames));
   } else {
     // When we get data for the closed stream, it implies the far side has
@@ -174,8 +186,8 @@ TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) {
 }
 
 TEST_P(QuicServerSessionTest, GoOverPrematureClosedStreamLimit) {
-  QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
-  if (connection_->version() > QUIC_VERSION_12) {
+  QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
+  if (version() > QUIC_VERSION_12) {
     // The prematurely closed stream limit is v12 specific.
     return;
   }
@@ -193,7 +205,7 @@ TEST_P(QuicServerSessionTest, GoOverPrematureClosedStreamLimit) {
 }
 
 TEST_P(QuicServerSessionTest, AcceptClosedStream) {
-  QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+  QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
   vector<QuicStreamFrame> frames;
   // Send (empty) compressed headers followed by two bytes of data.
   frames.push_back(QuicStreamFrame(stream_id, false, 0,
@@ -206,8 +218,12 @@ TEST_P(QuicServerSessionTest, AcceptClosedStream) {
   // compression context' state.
   MarkHeadersReadForStream(stream_id);
 
-  // Send a reset.
-  QuicRstStreamFrame rst(stream_id, QUIC_STREAM_NO_ERROR);
+  // Send a reset (and expect the peer to send a RST in response).
+  QuicRstStreamFrame rst(stream_id, QUIC_STREAM_NO_ERROR, 0);
+  if (version() > QUIC_VERSION_13) {
+    EXPECT_CALL(*connection_,
+                SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0));
+  }
   visitor_->OnRstStream(rst);
 
   // If we were tracking, we'd probably want to reject this because it's data
@@ -221,7 +237,7 @@ TEST_P(QuicServerSessionTest, AcceptClosedStream) {
 }
 
 TEST_P(QuicServerSessionTest, MaxNumConnections) {
-  QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+  QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
   EXPECT_EQ(0u, session_->GetNumOpenStreams());
   EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(),
                                                            stream_id));
@@ -235,7 +251,7 @@ TEST_P(QuicServerSessionTest, MaxNumConnections) {
 }
 
 TEST_P(QuicServerSessionTest, MaxNumConnectionsImplicit) {
-  QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+  QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
   EXPECT_EQ(0u, session_->GetNumOpenStreams());
   EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(),
                                                            stream_id));