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

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

Issue 1905843003: Split out QuicAlarm creation from QuicConnectionHelper to new QuicAlarmFactory. No behavior change,… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119753783
Patch Set: Rebase Created 4 years, 8 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.cc ('k') | net/quic/reliable_quic_stream_test.cc » ('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) 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 <algorithm> 7 #include <algorithm>
8 #include <cstdint> 8 #include <cstdint>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 char buffer[1024]; 65 char buffer[1024];
66 ASSERT_GT(arraysize(buffer), num_bytes); 66 ASSERT_GT(arraysize(buffer), num_bytes);
67 struct iovec iov; 67 struct iovec iov;
68 iov.iov_base = buffer; 68 iov.iov_base = buffer;
69 iov.iov_len = num_bytes; 69 iov.iov_len = num_bytes;
70 ASSERT_EQ(static_cast<int>(num_bytes), sequencer_->Readv(&iov, 1)); 70 ASSERT_EQ(static_cast<int>(num_bytes), sequencer_->Readv(&iov, 1));
71 } 71 }
72 72
73 protected: 73 protected:
74 QuicStreamSequencerTest() 74 QuicStreamSequencerTest()
75 : connection_(new MockConnection(&helper_, Perspective::IS_CLIENT)), 75 : connection_(new MockConnection(&helper_,
76 &alarm_factory_,
77 Perspective::IS_CLIENT)),
76 session_(connection_), 78 session_(connection_),
77 stream_(&session_, 1), 79 stream_(&session_, 1),
78 sequencer_(new QuicStreamSequencer(&stream_, &clock_)) {} 80 sequencer_(new QuicStreamSequencer(&stream_, &clock_)) {}
79 81
80 // Verify that the data in first region match with the expected[0]. 82 // Verify that the data in first region match with the expected[0].
81 bool VerifyReadableRegion(const vector<string>& expected) { 83 bool VerifyReadableRegion(const vector<string>& expected) {
82 iovec iovecs[1]; 84 iovec iovecs[1];
83 if (sequencer_->GetReadableRegions(iovecs, 1)) { 85 if (sequencer_->GetReadableRegions(iovecs, 1)) {
84 return (VerifyIovecs(iovecs, 1, vector<string>{expected[0]})); 86 return (VerifyIovecs(iovecs, 1, vector<string>{expected[0]}));
85 } 87 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 frame.frame_length = strlen(data); 144 frame.frame_length = strlen(data);
143 frame.fin = false; 145 frame.fin = false;
144 sequencer_->OnStreamFrame(frame); 146 sequencer_->OnStreamFrame(frame);
145 } 147 }
146 148
147 size_t NumBufferedBytes() { 149 size_t NumBufferedBytes() {
148 return QuicStreamSequencerPeer::GetNumBufferedBytes(sequencer_.get()); 150 return QuicStreamSequencerPeer::GetNumBufferedBytes(sequencer_.get());
149 } 151 }
150 152
151 MockConnectionHelper helper_; 153 MockConnectionHelper helper_;
154 MockAlarmFactory alarm_factory_;
152 MockConnection* connection_; 155 MockConnection* connection_;
153 MockClock clock_; 156 MockClock clock_;
154 MockQuicSpdySession session_; 157 MockQuicSpdySession session_;
155 testing::StrictMock<MockStream> stream_; 158 testing::StrictMock<MockStream> stream_;
156 std::unique_ptr<QuicStreamSequencer> sequencer_; 159 std::unique_ptr<QuicStreamSequencer> sequencer_;
157 }; 160 };
158 161
159 // TODO(rch): reorder these tests so they build on each other. 162 // TODO(rch): reorder these tests so they build on each other.
160 163
161 TEST_F(QuicStreamSequencerTest, RejectOldFrame) { 164 TEST_F(QuicStreamSequencerTest, RejectOldFrame) {
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.cc ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698