OLD | NEW |
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/core/quic_stream_sequencer.h" | 5 #include "net/quic/core/quic_stream_sequencer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 | 656 |
657 EXPECT_TRUE(sequencer_->GetReadableRegion(iovecs, ×tamp)); | 657 EXPECT_TRUE(sequencer_->GetReadableRegion(iovecs, ×tamp)); |
658 EXPECT_EQ(timestamp, t1); | 658 EXPECT_EQ(timestamp, t1); |
659 QuicStreamSequencerTest::ConsumeData(3); | 659 QuicStreamSequencerTest::ConsumeData(3); |
660 EXPECT_EQ(0u, NumBufferedBytes()); | 660 EXPECT_EQ(0u, NumBufferedBytes()); |
661 EXPECT_EQ(6u, sequencer_->NumBytesConsumed()); | 661 EXPECT_EQ(6u, sequencer_->NumBytesConsumed()); |
662 EXPECT_EQ(0u, sequencer_->NumBytesBuffered()); | 662 EXPECT_EQ(0u, sequencer_->NumBytesBuffered()); |
663 } | 663 } |
664 | 664 |
665 TEST_F(QuicStreamSequencerTest, OnStreamFrameWithNullSource) { | 665 TEST_F(QuicStreamSequencerTest, OnStreamFrameWithNullSource) { |
666 FLAGS_quic_stream_sequencer_buffer_debug = true; | |
667 // Pass in a frame with data pointing to null address, expect to close | 666 // Pass in a frame with data pointing to null address, expect to close |
668 // connection with error. | 667 // connection with error. |
669 StringPiece source(nullptr, 5u); | 668 StringPiece source(nullptr, 5u); |
670 QuicStreamFrame frame(kClientDataStreamId1, false, 1, source); | 669 QuicStreamFrame frame(kClientDataStreamId1, false, 1, source); |
671 EXPECT_CALL(stream_, CloseConnectionWithDetails( | 670 EXPECT_CALL(stream_, CloseConnectionWithDetails( |
672 QUIC_STREAM_SEQUENCER_INVALID_STATE, _)); | 671 QUIC_STREAM_SEQUENCER_INVALID_STATE, _)); |
673 sequencer_->OnStreamFrame(frame); | 672 sequencer_->OnStreamFrame(frame); |
674 } | 673 } |
675 | 674 |
676 TEST_F(QuicStreamSequencerTest, ReadvError) { | 675 TEST_F(QuicStreamSequencerTest, ReadvError) { |
677 FLAGS_quic_stream_sequencer_buffer_debug = true; | |
678 EXPECT_CALL(stream_, OnDataAvailable()); | 676 EXPECT_CALL(stream_, OnDataAvailable()); |
679 string source(100, 'a'); | 677 string source(100, 'a'); |
680 OnFrame(0u, source.data()); | 678 OnFrame(0u, source.data()); |
681 EXPECT_EQ(source.length(), sequencer_->NumBytesBuffered()); | 679 EXPECT_EQ(source.length(), sequencer_->NumBytesBuffered()); |
682 // Pass in a null iovec, expect to tear down connection. | 680 // Pass in a null iovec, expect to tear down connection. |
683 EXPECT_CALL(stream_, CloseConnectionWithDetails( | 681 EXPECT_CALL(stream_, CloseConnectionWithDetails( |
684 QUIC_STREAM_SEQUENCER_INVALID_STATE, _)); | 682 QUIC_STREAM_SEQUENCER_INVALID_STATE, _)); |
685 iovec iov{nullptr, 512}; | 683 iovec iov{nullptr, 512}; |
686 sequencer_->Readv(&iov, 1u); | 684 sequencer_->Readv(&iov, 1u); |
687 } | 685 } |
688 | 686 |
689 } // namespace | 687 } // namespace |
690 } // namespace test | 688 } // namespace test |
691 } // namespace net | 689 } // namespace net |
OLD | NEW |