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/quic_stream_sequencer.h" | 5 #include "net/quic/quic_stream_sequencer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 char buffer[1024]; | 62 char buffer[1024]; |
63 ASSERT_GT(arraysize(buffer), num_bytes); | 63 ASSERT_GT(arraysize(buffer), num_bytes); |
64 struct iovec iov; | 64 struct iovec iov; |
65 iov.iov_base = buffer; | 65 iov.iov_base = buffer; |
66 iov.iov_len = num_bytes; | 66 iov.iov_len = num_bytes; |
67 ASSERT_EQ(static_cast<int>(num_bytes), sequencer_->Readv(&iov, 1)); | 67 ASSERT_EQ(static_cast<int>(num_bytes), sequencer_->Readv(&iov, 1)); |
68 } | 68 } |
69 | 69 |
70 protected: | 70 protected: |
71 QuicStreamSequencerTest() | 71 QuicStreamSequencerTest() |
72 : connection_(new MockConnection(&helper_, Perspective::IS_CLIENT)), | 72 : connection_(new MockConnection(&helper_, |
| 73 &alarm_factory_, |
| 74 Perspective::IS_CLIENT)), |
73 session_(connection_), | 75 session_(connection_), |
74 stream_(&session_, 1), | 76 stream_(&session_, 1), |
75 sequencer_(new QuicStreamSequencer(&stream_, &clock_)) {} | 77 sequencer_(new QuicStreamSequencer(&stream_, &clock_)) {} |
76 | 78 |
77 // Verify that the data in first region match with the expected[0]. | 79 // Verify that the data in first region match with the expected[0]. |
78 bool VerifyReadableRegion(const vector<string>& expected) { | 80 bool VerifyReadableRegion(const vector<string>& expected) { |
79 iovec iovecs[1]; | 81 iovec iovecs[1]; |
80 if (sequencer_->GetReadableRegions(iovecs, 1)) { | 82 if (sequencer_->GetReadableRegions(iovecs, 1)) { |
81 return (VerifyIovecs(iovecs, 1, vector<string>{expected[0]})); | 83 return (VerifyIovecs(iovecs, 1, vector<string>{expected[0]})); |
82 } | 84 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 frame.frame_length = strlen(data); | 141 frame.frame_length = strlen(data); |
140 frame.fin = false; | 142 frame.fin = false; |
141 sequencer_->OnStreamFrame(frame); | 143 sequencer_->OnStreamFrame(frame); |
142 } | 144 } |
143 | 145 |
144 size_t NumBufferedBytes() { | 146 size_t NumBufferedBytes() { |
145 return QuicStreamSequencerPeer::GetNumBufferedBytes(sequencer_.get()); | 147 return QuicStreamSequencerPeer::GetNumBufferedBytes(sequencer_.get()); |
146 } | 148 } |
147 | 149 |
148 MockConnectionHelper helper_; | 150 MockConnectionHelper helper_; |
| 151 MockAlarmFactory alarm_factory_; |
149 MockConnection* connection_; | 152 MockConnection* connection_; |
150 MockClock clock_; | 153 MockClock clock_; |
151 MockQuicSpdySession session_; | 154 MockQuicSpdySession session_; |
152 testing::StrictMock<MockStream> stream_; | 155 testing::StrictMock<MockStream> stream_; |
153 std::unique_ptr<QuicStreamSequencer> sequencer_; | 156 std::unique_ptr<QuicStreamSequencer> sequencer_; |
154 }; | 157 }; |
155 | 158 |
156 // TODO(rch): reorder these tests so they build on each other. | 159 // TODO(rch): reorder these tests so they build on each other. |
157 | 160 |
158 TEST_F(QuicStreamSequencerTest, RejectOldFrame) { | 161 TEST_F(QuicStreamSequencerTest, RejectOldFrame) { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 EXPECT_EQ(timestamp, t1); | 653 EXPECT_EQ(timestamp, t1); |
651 QuicStreamSequencerTest::ConsumeData(3); | 654 QuicStreamSequencerTest::ConsumeData(3); |
652 EXPECT_EQ(0u, NumBufferedBytes()); | 655 EXPECT_EQ(0u, NumBufferedBytes()); |
653 EXPECT_EQ(6u, sequencer_->NumBytesConsumed()); | 656 EXPECT_EQ(6u, sequencer_->NumBytesConsumed()); |
654 EXPECT_EQ(0u, sequencer_->NumBytesBuffered()); | 657 EXPECT_EQ(0u, sequencer_->NumBytesBuffered()); |
655 } | 658 } |
656 | 659 |
657 } // namespace | 660 } // namespace |
658 } // namespace test | 661 } // namespace test |
659 } // namespace net | 662 } // namespace net |
OLD | NEW |