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

Side by Side Diff: net/tools/quic/quic_simple_server_stream_test.cc

Issue 2875333002: Landing Recent QUIC changes until Mon May 8 21:42:46 2017 +0000 (Closed)
Patch Set: Created 3 years, 7 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/tools/quic/quic_simple_server_stream.cc ('k') | net/tools/quic/quic_spdy_client_stream.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/tools/quic/quic_simple_server_stream.h" 5 #include "net/tools/quic/quic_simple_server_stream.h"
6 6
7 #include <list> 7 #include <list>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 InSequence s; 320 InSequence s;
321 EXPECT_CALL(session_, WriteHeadersMock(stream_->id(), _, false, _, _)); 321 EXPECT_CALL(session_, WriteHeadersMock(stream_->id(), _, false, _, _));
322 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)) 322 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _))
323 .Times(1) 323 .Times(1)
324 .WillOnce(Return(QuicConsumedData( 324 .WillOnce(Return(QuicConsumedData(
325 strlen(QuicSimpleServerStream::kErrorResponseBody), true))); 325 strlen(QuicSimpleServerStream::kErrorResponseBody), true)));
326 326
327 QuicSimpleServerStreamPeer::SendResponse(stream_); 327 QuicSimpleServerStreamPeer::SendResponse(stream_);
328 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); 328 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_));
329 if (!FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
330 EXPECT_TRUE(stream_->reading_stopped());
331 }
332 EXPECT_TRUE(stream_->write_side_closed()); 329 EXPECT_TRUE(stream_->write_side_closed());
333 } 330 }
334 331
335 TEST_P(QuicSimpleServerStreamTest, SendResponseWithIllegalResponseStatus2) { 332 TEST_P(QuicSimpleServerStreamTest, SendResponseWithIllegalResponseStatus2) {
336 // Send an illegal response with response status not supported by HTTP/2. 333 // Send an illegal response with response status not supported by HTTP/2.
337 SpdyHeaderBlock* request_headers = stream_->mutable_headers(); 334 SpdyHeaderBlock* request_headers = stream_->mutable_headers();
338 (*request_headers)[":path"] = "/bar"; 335 (*request_headers)[":path"] = "/bar";
339 (*request_headers)[":authority"] = "www.google.com"; 336 (*request_headers)[":authority"] = "www.google.com";
340 (*request_headers)[":version"] = "HTTP/1.1"; 337 (*request_headers)[":version"] = "HTTP/1.1";
341 (*request_headers)[":method"] = "GET"; 338 (*request_headers)[":method"] = "GET";
(...skipping 10 matching lines...) Expand all
352 349
353 InSequence s; 350 InSequence s;
354 EXPECT_CALL(session_, WriteHeadersMock(stream_->id(), _, false, _, _)); 351 EXPECT_CALL(session_, WriteHeadersMock(stream_->id(), _, false, _, _));
355 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)) 352 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _))
356 .Times(1) 353 .Times(1)
357 .WillOnce(Return(QuicConsumedData( 354 .WillOnce(Return(QuicConsumedData(
358 strlen(QuicSimpleServerStream::kErrorResponseBody), true))); 355 strlen(QuicSimpleServerStream::kErrorResponseBody), true)));
359 356
360 QuicSimpleServerStreamPeer::SendResponse(stream_); 357 QuicSimpleServerStreamPeer::SendResponse(stream_);
361 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); 358 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_));
362 if (!FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
363 EXPECT_TRUE(stream_->reading_stopped());
364 }
365 EXPECT_TRUE(stream_->write_side_closed()); 359 EXPECT_TRUE(stream_->write_side_closed());
366 } 360 }
367 361
368 TEST_P(QuicSimpleServerStreamTest, SendPushResponseWith404Response) { 362 TEST_P(QuicSimpleServerStreamTest, SendPushResponseWith404Response) {
369 // Create a new promised stream with even id(). 363 // Create a new promised stream with even id().
370 QuicSimpleServerStreamPeer* promised_stream = 364 QuicSimpleServerStreamPeer* promised_stream =
371 new QuicSimpleServerStreamPeer(2, &session_, &response_cache_); 365 new QuicSimpleServerStreamPeer(2, &session_, &response_cache_);
372 session_.ActivateStream(QuicWrapUnique(promised_stream)); 366 session_.ActivateStream(QuicWrapUnique(promised_stream));
373 367
374 // Send a push response with response status 404, which will be regarded as 368 // Send a push response with response status 404, which will be regarded as
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 stream_->set_fin_received(true); 404 stream_->set_fin_received(true);
411 405
412 InSequence s; 406 InSequence s;
413 EXPECT_CALL(session_, WriteHeadersMock(stream_->id(), _, false, _, _)); 407 EXPECT_CALL(session_, WriteHeadersMock(stream_->id(), _, false, _, _));
414 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)) 408 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _))
415 .Times(1) 409 .Times(1)
416 .WillOnce(Return(QuicConsumedData(body.length(), true))); 410 .WillOnce(Return(QuicConsumedData(body.length(), true)));
417 411
418 QuicSimpleServerStreamPeer::SendResponse(stream_); 412 QuicSimpleServerStreamPeer::SendResponse(stream_);
419 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); 413 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_));
420 if (!FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
421 EXPECT_TRUE(stream_->reading_stopped());
422 }
423 EXPECT_TRUE(stream_->write_side_closed()); 414 EXPECT_TRUE(stream_->write_side_closed());
424 } 415 }
425 416
426 TEST_P(QuicSimpleServerStreamTest, SendReponseWithPushResources) { 417 TEST_P(QuicSimpleServerStreamTest, SendReponseWithPushResources) {
427 // Tests that if a reponse has push resources to be send, SendResponse() will 418 // Tests that if a reponse has push resources to be send, SendResponse() will
428 // call PromisePushResources() to handle these resources. 419 // call PromisePushResources() to handle these resources.
429 420
430 // Add a request and response with valid headers into cache. 421 // Add a request and response with valid headers into cache.
431 string host = "www.google.com"; 422 string host = "www.google.com";
432 string request_path = "/foo"; 423 string request_path = "/foo";
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 stream_->set_fin_received(true); 508 stream_->set_fin_received(true);
518 509
519 InSequence s; 510 InSequence s;
520 EXPECT_CALL(session_, WriteHeadersMock(_, _, _, _, _)); 511 EXPECT_CALL(session_, WriteHeadersMock(_, _, _, _, _));
521 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)) 512 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _))
522 .Times(1) 513 .Times(1)
523 .WillOnce(Return(QuicConsumedData(3, true))); 514 .WillOnce(Return(QuicConsumedData(3, true)));
524 515
525 QuicSimpleServerStreamPeer::SendErrorResponse(stream_); 516 QuicSimpleServerStreamPeer::SendErrorResponse(stream_);
526 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); 517 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_));
527 if (!FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
528 EXPECT_TRUE(stream_->reading_stopped());
529 }
530 EXPECT_TRUE(stream_->write_side_closed()); 518 EXPECT_TRUE(stream_->write_side_closed());
531 } 519 }
532 520
533 TEST_P(QuicSimpleServerStreamTest, InvalidMultipleContentLength) { 521 TEST_P(QuicSimpleServerStreamTest, InvalidMultipleContentLength) {
534 EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _)).Times(0); 522 EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _)).Times(0);
535 523
536 SpdyHeaderBlock request_headers; 524 SpdyHeaderBlock request_headers;
537 // \000 is a way to write the null byte when followed by a literal digit. 525 // \000 is a way to write the null byte when followed by a literal digit.
538 header_list_.OnHeader("content-length", QuicStringPiece("11\00012", 5)); 526 header_list_.OnHeader("content-length", QuicStringPiece("11\00012", 5));
539 527
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 headers_string_ = SpdyUtils::SerializeUncompressedHeaders(request_headers); 566 headers_string_ = SpdyUtils::SerializeUncompressedHeaders(request_headers);
579 567
580 stream_->OnStreamHeaderList(false, kFakeFrameLen, header_list_); 568 stream_->OnStreamHeaderList(false, kFakeFrameLen, header_list_);
581 569
582 EXPECT_EQ(11, QuicSimpleServerStreamPeer::content_length(stream_)); 570 EXPECT_EQ(11, QuicSimpleServerStreamPeer::content_length(stream_));
583 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_)); 571 EXPECT_FALSE(QuicStreamPeer::read_side_closed(stream_));
584 EXPECT_FALSE(stream_->reading_stopped()); 572 EXPECT_FALSE(stream_->reading_stopped());
585 EXPECT_FALSE(stream_->write_side_closed()); 573 EXPECT_FALSE(stream_->write_side_closed());
586 } 574 }
587 575
588 TEST_P(QuicSimpleServerStreamTest, SendQuicRstStreamNoErrorWithEarlyResponse) {
589 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
590 return;
591 }
592 InSequence s;
593 EXPECT_CALL(session_, WriteHeadersMock(stream_->id(), _, false, _, _));
594 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _))
595 .Times(1)
596 .WillOnce(Return(QuicConsumedData(3, true)));
597 EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _)).Times(1);
598 EXPECT_FALSE(stream_->fin_received());
599 QuicSimpleServerStreamPeer::SendErrorResponse(stream_);
600 EXPECT_TRUE(stream_->reading_stopped());
601 EXPECT_TRUE(stream_->write_side_closed());
602 }
603
604 TEST_P(QuicSimpleServerStreamTest, 576 TEST_P(QuicSimpleServerStreamTest,
605 DoNotSendQuicRstStreamNoErrorWithRstReceived) { 577 DoNotSendQuicRstStreamNoErrorWithRstReceived) {
606 InSequence s; 578 InSequence s;
607 EXPECT_FALSE(stream_->reading_stopped()); 579 EXPECT_FALSE(stream_->reading_stopped());
608 580
609 EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _)).Times(0); 581 EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _)).Times(0);
610 EXPECT_CALL(session_, SendRstStream(_, QUIC_RST_ACKNOWLEDGEMENT, _)).Times(1); 582 EXPECT_CALL(session_, SendRstStream(_, QUIC_RST_ACKNOWLEDGEMENT, _)).Times(1);
611 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); 583 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234);
612 stream_->OnStreamReset(rst_frame); 584 stream_->OnStreamReset(rst_frame);
613 585
(...skipping 27 matching lines...) Expand all
641 }; 613 };
642 QuicStringPiece data(arr, arraysize(arr)); 614 QuicStringPiece data(arr, arraysize(arr));
643 QuicStreamFrame frame(stream_->id(), true, 0, data); 615 QuicStreamFrame frame(stream_->id(), true, 0, data);
644 // Verify that we don't crash when we get a invalid headers in stream frame. 616 // Verify that we don't crash when we get a invalid headers in stream frame.
645 stream_->OnStreamFrame(frame); 617 stream_->OnStreamFrame(frame);
646 } 618 }
647 619
648 } // namespace 620 } // namespace
649 } // namespace test 621 } // namespace test
650 } // namespace net 622 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_stream.cc ('k') | net/tools/quic/quic_spdy_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698