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

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

Issue 1977153002: Rename various MockConnectionFoo classes to MockQuicConnectionFoo. No behavior change. This is cons… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@121576119
Patch Set: Created 4 years, 7 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_spdy_stream_test.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_, 75 : connection_(new MockQuicConnection(&helper_,
76 &alarm_factory_, 76 &alarm_factory_,
77 Perspective::IS_CLIENT)), 77 Perspective::IS_CLIENT)),
78 session_(connection_), 78 session_(connection_),
79 stream_(&session_, 1), 79 stream_(&session_, 1),
80 sequencer_(new QuicStreamSequencer(&stream_, &clock_)) {} 80 sequencer_(new QuicStreamSequencer(&stream_, &clock_)) {}
81 81
82 // 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].
83 bool VerifyReadableRegion(const vector<string>& expected) { 83 bool VerifyReadableRegion(const vector<string>& expected) {
84 iovec iovecs[1]; 84 iovec iovecs[1];
85 if (sequencer_->GetReadableRegions(iovecs, 1)) { 85 if (sequencer_->GetReadableRegions(iovecs, 1)) {
86 return (VerifyIovecs(iovecs, 1, vector<string>{expected[0]})); 86 return (VerifyIovecs(iovecs, 1, vector<string>{expected[0]}));
87 } 87 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 frame.frame_buffer = data; 143 frame.frame_buffer = data;
144 frame.frame_length = strlen(data); 144 frame.frame_length = strlen(data);
145 frame.fin = false; 145 frame.fin = false;
146 sequencer_->OnStreamFrame(frame); 146 sequencer_->OnStreamFrame(frame);
147 } 147 }
148 148
149 size_t NumBufferedBytes() { 149 size_t NumBufferedBytes() {
150 return QuicStreamSequencerPeer::GetNumBufferedBytes(sequencer_.get()); 150 return QuicStreamSequencerPeer::GetNumBufferedBytes(sequencer_.get());
151 } 151 }
152 152
153 MockConnectionHelper helper_; 153 MockQuicConnectionHelper helper_;
154 MockAlarmFactory alarm_factory_; 154 MockAlarmFactory alarm_factory_;
155 MockConnection* connection_; 155 MockQuicConnection* connection_;
156 MockClock clock_; 156 MockClock clock_;
157 MockQuicSpdySession session_; 157 MockQuicSpdySession session_;
158 testing::StrictMock<MockStream> stream_; 158 testing::StrictMock<MockStream> stream_;
159 std::unique_ptr<QuicStreamSequencer> sequencer_; 159 std::unique_ptr<QuicStreamSequencer> sequencer_;
160 }; 160 };
161 161
162 // TODO(rch): reorder these tests so they build on each other. 162 // TODO(rch): reorder these tests so they build on each other.
163 163
164 TEST_F(QuicStreamSequencerTest, RejectOldFrame) { 164 TEST_F(QuicStreamSequencerTest, RejectOldFrame) {
165 EXPECT_CALL(stream_, OnDataAvailable()) 165 EXPECT_CALL(stream_, OnDataAvailable())
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 EXPECT_EQ(timestamp, t1); 653 EXPECT_EQ(timestamp, t1);
654 QuicStreamSequencerTest::ConsumeData(3); 654 QuicStreamSequencerTest::ConsumeData(3);
655 EXPECT_EQ(0u, NumBufferedBytes()); 655 EXPECT_EQ(0u, NumBufferedBytes());
656 EXPECT_EQ(6u, sequencer_->NumBytesConsumed()); 656 EXPECT_EQ(6u, sequencer_->NumBytesConsumed());
657 EXPECT_EQ(0u, sequencer_->NumBytesBuffered()); 657 EXPECT_EQ(0u, sequencer_->NumBytesBuffered());
658 } 658 }
659 659
660 } // namespace 660 } // namespace
661 } // namespace test 661 } // namespace test
662 } // namespace net 662 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_spdy_stream_test.cc ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698