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

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

Issue 23597045: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged QuicPriority to RequestPriority changes Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_stream_sequencer.cc ('k') | net/quic/quic_utils.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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }; 64 };
65 65
66 class MockStream : public ReliableQuicStream { 66 class MockStream : public ReliableQuicStream {
67 public: 67 public:
68 MockStream(QuicSession* session, QuicStreamId id) 68 MockStream(QuicSession* session, QuicStreamId id)
69 : ReliableQuicStream(id, session) { 69 : ReliableQuicStream(id, session) {
70 } 70 }
71 71
72 MOCK_METHOD1(TerminateFromPeer, void(bool half_close)); 72 MOCK_METHOD1(TerminateFromPeer, void(bool half_close));
73 MOCK_METHOD2(ProcessData, uint32(const char* data, uint32 data_len)); 73 MOCK_METHOD2(ProcessData, uint32(const char* data, uint32 data_len));
74 MOCK_METHOD2(ConnectionClose, void(QuicErrorCode error, bool from_peer));
74 MOCK_METHOD1(Close, void(QuicRstStreamErrorCode error)); 75 MOCK_METHOD1(Close, void(QuicRstStreamErrorCode error));
75 MOCK_METHOD0(OnCanWrite, void()); 76 MOCK_METHOD0(OnCanWrite, void());
76 }; 77 };
77 78
78 namespace { 79 namespace {
79 80
80 static const char kPayload[] = 81 static const char kPayload[] =
81 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 82 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
82 83
83 class QuicStreamSequencerTest : public ::testing::Test { 84 class QuicStreamSequencerTest : public ::testing::Test {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 176
176 TEST_F(QuicStreamSequencerTest, FullFrameConsumed) { 177 TEST_F(QuicStreamSequencerTest, FullFrameConsumed) {
177 EXPECT_CALL(stream_, ProcessData(StrEq("abc"), 3)).WillOnce(Return(3)); 178 EXPECT_CALL(stream_, ProcessData(StrEq("abc"), 3)).WillOnce(Return(3));
178 179
179 EXPECT_TRUE(sequencer_->OnFrame(0, "abc")); 180 EXPECT_TRUE(sequencer_->OnFrame(0, "abc"));
180 EXPECT_EQ(0u, sequencer_->frames()->size()); 181 EXPECT_EQ(0u, sequencer_->frames()->size());
181 EXPECT_EQ(3u, sequencer_->num_bytes_consumed()); 182 EXPECT_EQ(3u, sequencer_->num_bytes_consumed());
182 } 183 }
183 184
184 TEST_F(QuicStreamSequencerTest, EmptyFrame) { 185 TEST_F(QuicStreamSequencerTest, EmptyFrame) {
185 EXPECT_TRUE(sequencer_->OnFrame(0, "")); 186 EXPECT_CALL(stream_, ConnectionClose(QUIC_INVALID_STREAM_FRAME, false));
187 EXPECT_FALSE(sequencer_->OnFrame(0, ""));
186 EXPECT_EQ(0u, sequencer_->frames()->size()); 188 EXPECT_EQ(0u, sequencer_->frames()->size());
187 EXPECT_EQ(0u, sequencer_->num_bytes_consumed()); 189 EXPECT_EQ(0u, sequencer_->num_bytes_consumed());
188 } 190 }
189 191
190 TEST_F(QuicStreamSequencerTest, EmptyFinFrame) { 192 TEST_F(QuicStreamSequencerTest, EmptyFinFrame) {
191 EXPECT_CALL(stream_, TerminateFromPeer(true)); 193 EXPECT_CALL(stream_, TerminateFromPeer(true));
192 EXPECT_TRUE(sequencer_->OnFinFrame(0, "")); 194 EXPECT_TRUE(sequencer_->OnFinFrame(0, ""));
193 EXPECT_EQ(0u, sequencer_->frames()->size()); 195 EXPECT_EQ(0u, sequencer_->frames()->size());
194 EXPECT_EQ(0u, sequencer_->num_bytes_consumed()); 196 EXPECT_EQ(0u, sequencer_->num_bytes_consumed());
195 } 197 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 EXPECT_TRUE(sequencer_->OnFrame(0, "abc")); 394 EXPECT_TRUE(sequencer_->OnFrame(0, "abc"));
393 EXPECT_TRUE(sequencer_->OnFrame(9, "jklmnopqrstuvwxyz")); 395 EXPECT_TRUE(sequencer_->OnFrame(9, "jklmnopqrstuvwxyz"));
394 396
395 // Peek into the data. Only the first chunk should be readable 397 // Peek into the data. Only the first chunk should be readable
396 // because of the missing data. 398 // because of the missing data.
397 const char* expected[] = {"abc"}; 399 const char* expected[] = {"abc"};
398 ASSERT_TRUE(VerifyReadableRegions(expected, arraysize(expected))); 400 ASSERT_TRUE(VerifyReadableRegions(expected, arraysize(expected)));
399 401
400 // Now, attempt to mark consumed more data than was readable 402 // Now, attempt to mark consumed more data than was readable
401 // and expect the stream to be closed. 403 // and expect the stream to be closed.
402 EXPECT_CALL(stream_, Close(QUIC_SERVER_ERROR_PROCESSING_STREAM)); 404 EXPECT_CALL(stream_, Close(QUIC_ERROR_PROCESSING_STREAM));
403 EXPECT_DFATAL(sequencer_->MarkConsumed(4), 405 EXPECT_DFATAL(sequencer_->MarkConsumed(4),
404 "Invalid argument to MarkConsumed. num_bytes_consumed_: 3 " 406 "Invalid argument to MarkConsumed. num_bytes_consumed_: 3 "
405 "end_offset: 4 offset: 9 length: 17"); 407 "end_offset: 4 offset: 9 length: 17");
406 */ 408 */
407 } 409 }
408 410
409 TEST_F(QuicStreamSequencerTest, MarkConsumedWithMissingPacket) { 411 TEST_F(QuicStreamSequencerTest, MarkConsumedWithMissingPacket) {
410 InSequence s; 412 InSequence s;
411 EXPECT_CALL(stream_, ProcessData(StrEq("abc"), 3)).WillOnce(Return(0)); 413 EXPECT_CALL(stream_, ProcessData(StrEq("abc"), 3)).WillOnce(Return(0));
412 414
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 567
566 if (acked) { 568 if (acked) {
567 list_.erase(list_.begin() + index); 569 list_.erase(list_.begin() + index);
568 } 570 }
569 } 571 }
570 } 572 }
571 573
572 } // namespace 574 } // namespace
573 } // namespace test 575 } // namespace test
574 } // namespace net 576 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_sequencer.cc ('k') | net/quic/quic_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698