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

Unified Diff: net/quic/quic_headers_stream_test.cc

Issue 1470713003: Landing Recent QUIC changes until and including Mon Nov 16 14:15:48 2015 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding NET_EXPORT_PRIVATE to DelegateInterface. Created 5 years, 1 month 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
Index: net/quic/quic_headers_stream_test.cc
diff --git a/net/quic/quic_headers_stream_test.cc b/net/quic/quic_headers_stream_test.cc
index 95c923df5df2ff3b4d71bcdab91f9ed8d8021d33..9cad397c44dcf3bf6a96bdd1579fbb28f8dbd80e 100644
--- a/net/quic/quic_headers_stream_test.cc
+++ b/net/quic/quic_headers_stream_test.cc
@@ -13,6 +13,7 @@
#include "net/spdy/spdy_alt_svc_wire_format.h"
#include "net/spdy/spdy_protocol.h"
#include "net/spdy/spdy_test_utils.h"
+#include "net/test/gtest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::StringPiece;
@@ -126,7 +127,8 @@ class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> {
headers_stream_(QuicSpdySessionPeer::GetHeadersStream(&session_)),
body_("hello world"),
framer_(HTTP2),
- stream_frame_(kHeadersStreamId, /*fin=*/false, /*offset=*/0, "") {
+ stream_frame_(kHeadersStreamId, /*fin=*/false, /*offset=*/0, ""),
+ next_promised_stream_id_(2) {
headers_[":version"] = "HTTP/1.1";
headers_[":status"] = "200 Ok";
headers_["content-length"] = "11";
@@ -157,7 +159,7 @@ class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> {
void WriteHeadersAndExpectSynStream(QuicStreamId stream_id,
bool fin,
- QuicPriority priority) {
+ SpdyPriority priority) {
WriteHeadersAndCheckData(stream_id, fin, priority, SYN_STREAM);
}
@@ -168,7 +170,7 @@ class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> {
void WriteHeadersAndCheckData(QuicStreamId stream_id,
bool fin,
- QuicPriority priority,
+ SpdyPriority priority,
SpdyFrameType type) {
// Write the headers and capture the outgoing data
EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, _, nullptr))
@@ -224,6 +226,8 @@ class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> {
QuicConnectionPeer::CloseConnection(connection_);
}
+ QuicStreamId NextPromisedStreamId() { return next_promised_stream_id_++; }
+
static const bool kFrameComplete = true;
static const bool kHasPriority = true;
@@ -238,6 +242,7 @@ class QuicHeadersStreamTest : public ::testing::TestWithParam<TestParams> {
SpdyFramer framer_;
StrictMock<MockVisitor> visitor_;
QuicStreamFrame stream_frame_;
+ QuicStreamId next_promised_stream_id_;
};
INSTANTIATE_TEST_CASE_P(Tests,
@@ -248,8 +253,8 @@ TEST_P(QuicHeadersStreamTest, StreamId) {
EXPECT_EQ(3u, headers_stream_->id());
}
-TEST_P(QuicHeadersStreamTest, EffectivePriority) {
- EXPECT_EQ(0u, headers_stream_->EffectivePriority());
+TEST_P(QuicHeadersStreamTest, Priority) {
+ EXPECT_EQ(0u, headers_stream_->Priority());
}
TEST_P(QuicHeadersStreamTest, WriteHeaders) {
@@ -259,7 +264,7 @@ TEST_P(QuicHeadersStreamTest, WriteHeaders) {
if (perspective() == Perspective::IS_SERVER) {
WriteHeadersAndExpectSynReply(stream_id, fin);
} else {
- for (QuicPriority priority = 0; priority < 7; ++priority) {
+ for (SpdyPriority priority = 0; priority < 7; ++priority) {
// TODO(rch): implement priorities correctly.
WriteHeadersAndExpectSynStream(stream_id, fin, 0);
}
@@ -268,11 +273,42 @@ TEST_P(QuicHeadersStreamTest, WriteHeaders) {
}
}
+TEST_P(QuicHeadersStreamTest, WritePushPromises) {
+ for (QuicStreamId stream_id = kClientDataStreamId1;
+ stream_id < kClientDataStreamId3; stream_id += 2) {
+ QuicStreamId promised_stream_id = NextPromisedStreamId();
+ if (perspective() == Perspective::IS_SERVER) {
+ // Write the headers and capture the outgoing data
+ EXPECT_CALL(session_,
+ WritevData(kHeadersStreamId, _, _, false, _, nullptr))
+ .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov)));
+ headers_stream_->WritePushPromise(stream_id, promised_stream_id, headers_,
+ nullptr);
+
+ // Parse the outgoing data and check that it matches was was written.
+ EXPECT_CALL(visitor_,
+ OnPushPromise(stream_id, promised_stream_id, kFrameComplete));
+ EXPECT_CALL(visitor_, OnControlFrameHeaderData(stream_id, _, _))
+ .WillRepeatedly(WithArgs<1, 2>(
+ Invoke(this, &QuicHeadersStreamTest::SaveHeaderData)));
+ framer_.ProcessInput(saved_data_.data(), saved_data_.length());
+ EXPECT_FALSE(framer_.HasError())
+ << SpdyFramer::ErrorCodeToString(framer_.error_code());
+ CheckHeaders();
+ saved_data_.clear();
+ } else {
+ EXPECT_DFATAL(headers_stream_->WritePushPromise(
+ stream_id, promised_stream_id, headers_, nullptr),
+ "Client shouldn't send PUSH_PROMISE");
+ }
+ }
+}
+
TEST_P(QuicHeadersStreamTest, ProcessRawData) {
for (QuicStreamId stream_id = kClientDataStreamId1;
stream_id < kClientDataStreamId3; stream_id += 2) {
- for (bool fin : kFins) {
- for (QuicPriority priority = 0; priority < 7; ++priority) {
+ for (bool fin : {false, true}) {
+ for (SpdyPriority priority = 0; priority < 7; ++priority) {
// Replace with "WriteHeadersAndSaveData"
scoped_ptr<SpdySerializedFrame> frame;
if (perspective() == Perspective::IS_SERVER) {
@@ -389,8 +425,8 @@ TEST_P(QuicHeadersStreamTest, ProcessLargeRawData) {
headers_["key2"] = string(1 << 13, '.');
for (QuicStreamId stream_id = kClientDataStreamId1;
stream_id < kClientDataStreamId3; stream_id += 2) {
- for (bool fin : kFins) {
- for (QuicPriority priority = 0; priority < 7; ++priority) {
+ for (bool fin : {false, true}) {
+ for (SpdyPriority priority = 0; priority < 7; ++priority) {
// Replace with "WriteHeadersAndSaveData"
scoped_ptr<SpdySerializedFrame> frame;
if (perspective() == Perspective::IS_SERVER) {

Powered by Google App Engine
This is Rietveld 408576698