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

Side by Side Diff: net/quic/quic_headers_stream_test.cc

Issue 1572013002: relnote: QUIC header streams support to receive PUSH_PROMISE. Protected by --quic_supports_push_pr… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@14_CL_111507546
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_headers_stream.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_headers_stream.h" 5 #include "net/quic/quic_headers_stream.h"
6 6
7 #include "net/quic/quic_utils.h" 7 #include "net/quic/quic_utils.h"
8 #include "net/quic/spdy_utils.h" 8 #include "net/quic/spdy_utils.h"
9 #include "net/quic/test_tools/quic_connection_peer.h" 9 #include "net/quic/test_tools/quic_connection_peer.h"
10 #include "net/quic/test_tools/quic_spdy_session_peer.h" 10 #include "net/quic/test_tools/quic_spdy_session_peer.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 QuicVersion version() { return GetParam().version; } 218 QuicVersion version() { return GetParam().version; }
219 219
220 QuicVersionVector GetVersion() { 220 QuicVersionVector GetVersion() {
221 QuicVersionVector versions; 221 QuicVersionVector versions;
222 versions.push_back(version()); 222 versions.push_back(version());
223 return versions; 223 return versions;
224 } 224 }
225 225
226 void CloseConnection() { QuicConnectionPeer::CloseConnection(connection_); } 226 void CloseConnection() { QuicConnectionPeer::CloseConnection(connection_); }
227 227
228 QuicStreamId NextPromisedStreamId() { return next_promised_stream_id_++; } 228 QuicStreamId NextPromisedStreamId() { return next_promised_stream_id_ += 2; }
229 229
230 static const bool kFrameComplete = true; 230 static const bool kFrameComplete = true;
231 static const bool kHasPriority = true; 231 static const bool kHasPriority = true;
232 232
233 MockConnectionHelper helper_; 233 MockConnectionHelper helper_;
234 StrictMock<MockConnection>* connection_; 234 StrictMock<MockConnection>* connection_;
235 StrictMock<MockQuicSpdySession> session_; 235 StrictMock<MockQuicSpdySession> session_;
236 QuicHeadersStream* headers_stream_; 236 QuicHeadersStream* headers_stream_;
237 SpdyHeaderBlock headers_; 237 SpdyHeaderBlock headers_;
238 string body_; 238 string body_;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 stream_frame_.frame_buffer = frame->data(); 331 stream_frame_.frame_buffer = frame->data();
332 stream_frame_.frame_length = frame->size(); 332 stream_frame_.frame_length = frame->size();
333 headers_stream_->OnStreamFrame(stream_frame_); 333 headers_stream_->OnStreamFrame(stream_frame_);
334 stream_frame_.offset += frame->size(); 334 stream_frame_.offset += frame->size();
335 CheckHeaders(); 335 CheckHeaders();
336 } 336 }
337 } 337 }
338 } 338 }
339 } 339 }
340 340
341 TEST_P(QuicHeadersStreamTest, ProcessPushPromise) {
342 FLAGS_quic_supports_push_promise = true;
343 for (QuicStreamId stream_id = kClientDataStreamId1;
344 stream_id < kClientDataStreamId3; stream_id += 2) {
345 QuicStreamId promised_stream_id = NextPromisedStreamId();
346 scoped_ptr<SpdySerializedFrame> frame;
347 SpdyPushPromiseIR push_promise(stream_id, promised_stream_id);
348 push_promise.set_header_block(headers_);
349 frame.reset(framer_.SerializeFrame(push_promise));
350 if (perspective() == Perspective::IS_SERVER) {
351 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(
352 QUIC_INVALID_HEADERS_STREAM_DATA,
353 "PUSH_PROMISE not supported."))
354 .WillRepeatedly(
355 InvokeWithoutArgs(this, &QuicHeadersStreamTest::CloseConnection));
356 } else {
357 EXPECT_CALL(session_, OnPromiseHeaders(stream_id, _))
358 .WillRepeatedly(WithArgs<1>(
359 Invoke(this, &QuicHeadersStreamTest::SaveHeaderDataStringPiece)));
360 EXPECT_CALL(session_, OnPromiseHeadersComplete(
361 stream_id, promised_stream_id, frame->size()));
362 }
363 stream_frame_.frame_buffer = frame->data();
364 stream_frame_.frame_length = frame->size();
365 headers_stream_->OnStreamFrame(stream_frame_);
366 if (perspective() == Perspective::IS_CLIENT) {
367 stream_frame_.offset += frame->size();
368 CheckHeaders();
369 }
370 }
371 }
372
373 TEST_P(QuicHeadersStreamTest, PushPromiseOutOfOrder) {
374 FLAGS_quic_supports_push_promise = true;
375 if (perspective() == Perspective::IS_SERVER) {
376 return;
377 }
378
379 QuicStreamId promised_stream_id = NextPromisedStreamId();
380 QuicStreamId stream_id = kClientDataStreamId1;
381
382 scoped_ptr<SpdySerializedFrame> frame;
383 SpdyPushPromiseIR push_promise(stream_id, promised_stream_id);
384 push_promise.set_header_block(headers_);
385 frame.reset(framer_.SerializeFrame(push_promise));
386 EXPECT_CALL(session_, OnPromiseHeaders(stream_id, _))
387 .WillRepeatedly(WithArgs<1>(
388 Invoke(this, &QuicHeadersStreamTest::SaveHeaderDataStringPiece)));
389 EXPECT_CALL(session_, OnPromiseHeadersComplete(stream_id, promised_stream_id,
390 frame->size()));
391 stream_frame_.frame_buffer = frame->data();
392 stream_frame_.frame_length = frame->size();
393 headers_stream_->OnStreamFrame(stream_frame_);
394 if (perspective() == Perspective::IS_CLIENT) {
395 stream_frame_.offset += frame->size();
396 CheckHeaders();
397 }
398
399 stream_id += 2;
400 push_promise.set_stream_id(stream_id);
401 frame.reset(framer_.SerializeFrame(push_promise));
402 EXPECT_CALL(session_, OnPromiseHeaders(stream_id, _))
403 .WillRepeatedly(WithArgs<1>(
404 Invoke(this, &QuicHeadersStreamTest::SaveHeaderDataStringPiece)));
405 EXPECT_CALL(session_, OnPromiseHeadersComplete(stream_id, promised_stream_id,
406 frame->size()));
407 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(
408 QUIC_INVALID_STREAM_ID,
409 "Received push stream id lesser or equal to the"
410 " last accepted before"))
411 .WillRepeatedly(
412 InvokeWithoutArgs(this, &QuicHeadersStreamTest::CloseConnection));
413 stream_frame_.frame_buffer = frame->data();
414 stream_frame_.frame_length = frame->size();
415 headers_stream_->OnStreamFrame(stream_frame_);
416 }
417
341 TEST_P(QuicHeadersStreamTest, EmptyHeaderHOLBlockedTime) { 418 TEST_P(QuicHeadersStreamTest, EmptyHeaderHOLBlockedTime) {
342 EXPECT_CALL(session_, OnHeadersHeadOfLineBlocking(_)).Times(0); 419 EXPECT_CALL(session_, OnHeadersHeadOfLineBlocking(_)).Times(0);
343 testing::InSequence seq; 420 testing::InSequence seq;
344 bool fin = true; 421 bool fin = true;
345 for (int stream_num = 0; stream_num < 10; stream_num++) { 422 for (int stream_num = 0; stream_num < 10; stream_num++) {
346 QuicStreamId stream_id = QuicClientDataStreamId(stream_num); 423 QuicStreamId stream_id = QuicClientDataStreamId(stream_num);
347 // Replace with "WriteHeadersAndSaveData" 424 // Replace with "WriteHeadersAndSaveData"
348 scoped_ptr<SpdySerializedFrame> frame; 425 scoped_ptr<SpdySerializedFrame> frame;
349 if (perspective() == Perspective::IS_SERVER) { 426 if (perspective() == Perspective::IS_SERVER) {
350 SpdyHeadersIR headers_frame(stream_id); 427 SpdyHeadersIR headers_frame(stream_id);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 625 }
549 626
550 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) { 627 TEST_P(QuicHeadersStreamTest, NoConnectionLevelFlowControl) {
551 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl( 628 EXPECT_FALSE(ReliableQuicStreamPeer::StreamContributesToConnectionFlowControl(
552 headers_stream_)); 629 headers_stream_));
553 } 630 }
554 631
555 } // namespace 632 } // namespace
556 } // namespace test 633 } // namespace test
557 } // namespace net 634 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_headers_stream.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698