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

Unified Diff: net/quic/quic_headers_stream_test.cc

Issue 1471583002: Add WritePushPromise() method in QuicHeadersStream for server push. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@107697347
Patch Set: 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
« net/quic/quic_connection_test.cc ('K') | « net/quic/quic_headers_stream.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 939b12e65142b0e990f024a02ff95555783cd64b..9a319c9d1cd0446f8d9f3256db96df3ba3d39609 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";
@@ -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,
@@ -268,6 +273,38 @@ 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) {
« net/quic/quic_connection_test.cc ('K') | « net/quic/quic_headers_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698