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

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

Issue 504953003: Remove implicit conversions from scoped_refptr to T* in net/quic/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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_stream_factory_test.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/reliable_quic_stream.h" 5 #include "net/quic/reliable_quic_stream.h"
6 6
7 #include "net/quic/quic_ack_notifier.h" 7 #include "net/quic/quic_ack_notifier.h"
8 #include "net/quic/quic_connection.h" 8 #include "net/quic/quic_connection.h"
9 #include "net/quic/quic_utils.h" 9 #include "net/quic/quic_utils.h"
10 #include "net/quic/quic_write_blocked_list.h" 10 #include "net/quic/quic_write_blocked_list.h"
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 .WillOnce(Return(QuicConsumedData(kLastWriteSize, false))); 497 .WillOnce(Return(QuicConsumedData(kLastWriteSize, false)));
498 stream_->OnCanWrite(); 498 stream_->OnCanWrite();
499 499
500 // There were two writes, so OnAckNotification is not propagated 500 // There were two writes, so OnAckNotification is not propagated
501 // until the third Ack arrives. 501 // until the third Ack arrives.
502 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); 502 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_);
503 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); 503 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_);
504 504
505 // The arguments to delegate->OnAckNotification are the sum of the 505 // The arguments to delegate->OnAckNotification are the sum of the
506 // arguments to proxy_delegate OnAckNotification calls. 506 // arguments to proxy_delegate OnAckNotification calls.
507 EXPECT_CALL(*delegate, OnAckNotification(111, 222, 333, 444, zero_)); 507 EXPECT_CALL(*delegate.get(), OnAckNotification(111, 222, 333, 444, zero_));
508 proxy_delegate->OnAckNotification(100, 200, 300, 400, zero_); 508 proxy_delegate->OnAckNotification(100, 200, 300, 400, zero_);
509 } 509 }
510 510
511 // Verify delegate behavior when packets are acked before the 511 // Verify delegate behavior when packets are acked before the
512 // WritevData call that sends out the last byte. 512 // WritevData call that sends out the last byte.
513 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataAckNotificationBeforeFlush) { 513 TEST_F(ReliableQuicStreamTest, WriteOrBufferDataAckNotificationBeforeFlush) {
514 Initialize(kShouldProcessData); 514 Initialize(kShouldProcessData);
515 515
516 scoped_refptr<MockAckNotifierDelegate> delegate( 516 scoped_refptr<MockAckNotifierDelegate> delegate(
517 new StrictMock<MockAckNotifierDelegate>); 517 new StrictMock<MockAckNotifierDelegate>);
(...skipping 20 matching lines...) Expand all
538 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); 538 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_);
539 proxy_delegate = NULL; 539 proxy_delegate = NULL;
540 540
541 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce( 541 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)).WillOnce(
542 DoAll(WithArgs<5>(Invoke(CreateFunctor( 542 DoAll(WithArgs<5>(Invoke(CreateFunctor(
543 &SaveProxyAckNotifierDelegate, &proxy_delegate))), 543 &SaveProxyAckNotifierDelegate, &proxy_delegate))),
544 Return(QuicConsumedData(kDataSize - kInitialWriteSize, false)))); 544 Return(QuicConsumedData(kDataSize - kInitialWriteSize, false))));
545 stream_->OnCanWrite(); 545 stream_->OnCanWrite();
546 546
547 // Handle the ack for the second write. 547 // Handle the ack for the second write.
548 EXPECT_CALL(*delegate, OnAckNotification(101, 202, 303, 404, zero_)); 548 EXPECT_CALL(*delegate.get(), OnAckNotification(101, 202, 303, 404, zero_));
549 proxy_delegate->OnAckNotification(100, 200, 300, 400, zero_); 549 proxy_delegate->OnAckNotification(100, 200, 300, 400, zero_);
550 } 550 }
551 551
552 // Verify delegate behavior when WriteOrBufferData does not buffer. 552 // Verify delegate behavior when WriteOrBufferData does not buffer.
553 TEST_F(ReliableQuicStreamTest, WriteAndBufferDataWithAckNotiferNoBuffer) { 553 TEST_F(ReliableQuicStreamTest, WriteAndBufferDataWithAckNotiferNoBuffer) {
554 Initialize(kShouldProcessData); 554 Initialize(kShouldProcessData);
555 555
556 scoped_refptr<MockAckNotifierDelegate> delegate( 556 scoped_refptr<MockAckNotifierDelegate> delegate(
557 new StrictMock<MockAckNotifierDelegate>); 557 new StrictMock<MockAckNotifierDelegate>);
558 558
559 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; 559 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate;
560 560
561 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 561 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
562 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( 562 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor(
563 &SaveProxyAckNotifierDelegate, &proxy_delegate))), 563 &SaveProxyAckNotifierDelegate, &proxy_delegate))),
564 Return(QuicConsumedData(kDataLen, true)))); 564 Return(QuicConsumedData(kDataLen, true))));
565 stream_->WriteOrBufferData(kData1, true, delegate.get()); 565 stream_->WriteOrBufferData(kData1, true, delegate.get());
566 EXPECT_FALSE(HasWriteBlockedStreams()); 566 EXPECT_FALSE(HasWriteBlockedStreams());
567 567
568 // Handle the ack. 568 // Handle the ack.
569 EXPECT_CALL(*delegate, OnAckNotification(1, 2, 3, 4, zero_)); 569 EXPECT_CALL(*delegate.get(), OnAckNotification(1, 2, 3, 4, zero_));
570 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); 570 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_);
571 } 571 }
572 572
573 // Verify delegate behavior when WriteOrBufferData buffers all the data. 573 // Verify delegate behavior when WriteOrBufferData buffers all the data.
574 TEST_F(ReliableQuicStreamTest, BufferOnWriteAndBufferDataWithAckNotifer) { 574 TEST_F(ReliableQuicStreamTest, BufferOnWriteAndBufferDataWithAckNotifer) {
575 Initialize(kShouldProcessData); 575 Initialize(kShouldProcessData);
576 576
577 scoped_refptr<MockAckNotifierDelegate> delegate( 577 scoped_refptr<MockAckNotifierDelegate> delegate(
578 new StrictMock<MockAckNotifierDelegate>); 578 new StrictMock<MockAckNotifierDelegate>);
579 579
580 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; 580 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate;
581 581
582 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 582 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
583 .WillOnce(Return(QuicConsumedData(0, false))); 583 .WillOnce(Return(QuicConsumedData(0, false)));
584 stream_->WriteOrBufferData(kData1, true, delegate.get()); 584 stream_->WriteOrBufferData(kData1, true, delegate.get());
585 EXPECT_TRUE(HasWriteBlockedStreams()); 585 EXPECT_TRUE(HasWriteBlockedStreams());
586 586
587 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 587 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
588 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( 588 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor(
589 &SaveProxyAckNotifierDelegate, &proxy_delegate))), 589 &SaveProxyAckNotifierDelegate, &proxy_delegate))),
590 Return(QuicConsumedData(kDataLen, true)))); 590 Return(QuicConsumedData(kDataLen, true))));
591 stream_->OnCanWrite(); 591 stream_->OnCanWrite();
592 592
593 // Handle the ack. 593 // Handle the ack.
594 EXPECT_CALL(*delegate, OnAckNotification(1, 2, 3, 4, zero_)); 594 EXPECT_CALL(*delegate.get(), OnAckNotification(1, 2, 3, 4, zero_));
595 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); 595 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_);
596 } 596 }
597 597
598 // Verify delegate behavior when WriteOrBufferData when the FIN is 598 // Verify delegate behavior when WriteOrBufferData when the FIN is
599 // sent out in a different packet. 599 // sent out in a different packet.
600 TEST_F(ReliableQuicStreamTest, WriteAndBufferDataWithAckNotiferOnlyFinRemains) { 600 TEST_F(ReliableQuicStreamTest, WriteAndBufferDataWithAckNotiferOnlyFinRemains) {
601 Initialize(kShouldProcessData); 601 Initialize(kShouldProcessData);
602 602
603 scoped_refptr<MockAckNotifierDelegate> delegate( 603 scoped_refptr<MockAckNotifierDelegate> delegate(
604 new StrictMock<MockAckNotifierDelegate>); 604 new StrictMock<MockAckNotifierDelegate>);
605 605
606 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; 606 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate;
607 607
608 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 608 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
609 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( 609 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor(
610 &SaveProxyAckNotifierDelegate, &proxy_delegate))), 610 &SaveProxyAckNotifierDelegate, &proxy_delegate))),
611 Return(QuicConsumedData(kDataLen, false)))); 611 Return(QuicConsumedData(kDataLen, false))));
612 stream_->WriteOrBufferData(kData1, true, delegate.get()); 612 stream_->WriteOrBufferData(kData1, true, delegate.get());
613 EXPECT_TRUE(HasWriteBlockedStreams()); 613 EXPECT_TRUE(HasWriteBlockedStreams());
614 614
615 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) 615 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _))
616 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( 616 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor(
617 &SaveProxyAckNotifierDelegate, &proxy_delegate))), 617 &SaveProxyAckNotifierDelegate, &proxy_delegate))),
618 Return(QuicConsumedData(0, true)))); 618 Return(QuicConsumedData(0, true))));
619 stream_->OnCanWrite(); 619 stream_->OnCanWrite();
620 620
621 // Handle the acks. 621 // Handle the acks.
622 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); 622 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_);
623 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); 623 EXPECT_CALL(*delegate.get(), OnAckNotification(11, 22, 33, 44, zero_));
624 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); 624 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_);
625 } 625 }
626 626
627 // Verify that when we receive a packet which violates flow control (i.e. sends 627 // Verify that when we receive a packet which violates flow control (i.e. sends
628 // too much data on the stream) that the stream sequencer never sees this frame, 628 // too much data on the stream) that the stream sequencer never sees this frame,
629 // as we check for violation and close the connection early. 629 // as we check for violation and close the connection early.
630 TEST_F(ReliableQuicStreamTest, 630 TEST_F(ReliableQuicStreamTest,
631 StreamSequencerNeverSeesPacketsViolatingFlowControl) { 631 StreamSequencerNeverSeesPacketsViolatingFlowControl) {
632 Initialize(kShouldProcessData); 632 Initialize(kShouldProcessData);
633 633
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 666
667 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); 667 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset());
668 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); 668 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234);
669 stream_->OnStreamReset(rst_frame); 669 stream_->OnStreamReset(rst_frame);
670 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); 670 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
671 } 671 }
672 672
673 } // namespace 673 } // namespace
674 } // namespace test 674 } // namespace test
675 } // namespace net 675 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698