| 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 EXPECT_EQ(3u, sequencer_->NumBytesBuffered()); | 652 EXPECT_EQ(3u, sequencer_->NumBytesBuffered()); |
| 653 | 653 |
| 654 EXPECT_TRUE(sequencer_->GetReadableRegion(iovecs, ×tamp)); | 654 EXPECT_TRUE(sequencer_->GetReadableRegion(iovecs, ×tamp)); |
| 655 EXPECT_EQ(timestamp, t1); | 655 EXPECT_EQ(timestamp, t1); |
| 656 QuicStreamSequencerTest::ConsumeData(3); | 656 QuicStreamSequencerTest::ConsumeData(3); |
| 657 EXPECT_EQ(0u, NumBufferedBytes()); | 657 EXPECT_EQ(0u, NumBufferedBytes()); |
| 658 EXPECT_EQ(6u, sequencer_->NumBytesConsumed()); | 658 EXPECT_EQ(6u, sequencer_->NumBytesConsumed()); |
| 659 EXPECT_EQ(0u, sequencer_->NumBytesBuffered()); | 659 EXPECT_EQ(0u, sequencer_->NumBytesBuffered()); |
| 660 } | 660 } |
| 661 | 661 |
| 662 // TODO(danzh): Figure out the way to implement this test case without the use | |
| 663 // of unsupported StringPiece constructor. | |
| 664 #if 0 | |
| 665 TEST_F(QuicStreamSequencerTest, OnStreamFrameWithNullSource) { | 662 TEST_F(QuicStreamSequencerTest, OnStreamFrameWithNullSource) { |
| 666 // Pass in a frame with data pointing to null address, expect to close | 663 // Pass in a frame with data pointing to null address, expect to close |
| 667 // connection with error. | 664 // connection with error. |
| 668 StringPiece source(nullptr, 5u); | 665 StringPiece source; |
| 666 source.set(nullptr, 5u); |
| 669 QuicStreamFrame frame(kClientDataStreamId1, false, 1, source); | 667 QuicStreamFrame frame(kClientDataStreamId1, false, 1, source); |
| 670 EXPECT_CALL(stream_, CloseConnectionWithDetails( | 668 EXPECT_CALL(stream_, CloseConnectionWithDetails( |
| 671 QUIC_STREAM_SEQUENCER_INVALID_STATE, _)); | 669 QUIC_STREAM_SEQUENCER_INVALID_STATE, _)); |
| 672 sequencer_->OnStreamFrame(frame); | 670 sequencer_->OnStreamFrame(frame); |
| 673 } | 671 } |
| 674 #endif | |
| 675 | |
| 676 TEST_F(QuicStreamSequencerTest, ReadvError) { | |
| 677 EXPECT_CALL(stream_, OnDataAvailable()); | |
| 678 string source(100, 'a'); | |
| 679 OnFrame(0u, source.data()); | |
| 680 EXPECT_EQ(source.length(), sequencer_->NumBytesBuffered()); | |
| 681 // Pass in a null iovec, expect to tear down connection. | |
| 682 EXPECT_CALL(stream_, CloseConnectionWithDetails( | |
| 683 QUIC_STREAM_SEQUENCER_INVALID_STATE, _)); | |
| 684 iovec iov{nullptr, 512}; | |
| 685 sequencer_->Readv(&iov, 1u); | |
| 686 } | |
| 687 | 672 |
| 688 } // namespace | 673 } // namespace |
| 689 } // namespace test | 674 } // namespace test |
| 690 } // namespace net | 675 } // namespace net |
| OLD | NEW |