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

Side by Side Diff: net/quic/core/quic_stream_sequencer_buffer_test.cc

Issue 2430973004: Landing Recent QUIC changes until 10:38 AM, Oct 17, 2016 UTC-4 (Closed)
Patch Set: Improving flagsaver logging Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 #include "net/quic/core/quic_stream_sequencer_buffer.h" 4 #include "net/quic/core/quic_stream_sequencer_buffer.h"
5 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <limits> 7 #include <limits>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 EXPECT_EQ(1824u, gaps.back().begin_offset); 130 EXPECT_EQ(1824u, gaps.back().begin_offset);
131 auto* frame_map = helper_->frame_arrival_time_map(); 131 auto* frame_map = helper_->frame_arrival_time_map();
132 EXPECT_EQ(1u, frame_map->size()); 132 EXPECT_EQ(1u, frame_map->size());
133 EXPECT_EQ(800u, frame_map->begin()->first); 133 EXPECT_EQ(800u, frame_map->begin()->first);
134 EXPECT_EQ(t, (*frame_map)[800].timestamp); 134 EXPECT_EQ(t, (*frame_map)[800].timestamp);
135 EXPECT_TRUE(helper_->CheckBufferInvariants()); 135 EXPECT_TRUE(helper_->CheckBufferInvariants());
136 EXPECT_TRUE(helper_->IsBufferAllocated()); 136 EXPECT_TRUE(helper_->IsBufferAllocated());
137 } 137 }
138 138
139 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataInvalidSource) { 139 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataInvalidSource) {
140 FLAGS_quic_stream_sequencer_buffer_debug = true;
141 // Pass in an invalid source, expects to return error. 140 // Pass in an invalid source, expects to return error.
142 StringPiece source; 141 StringPiece source;
143 source.set(nullptr, 1024); 142 source.set(nullptr, 1024);
144 size_t written; 143 size_t written;
145 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 144 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
146 QuicTime t = clock_.ApproximateNow(); 145 QuicTime t = clock_.ApproximateNow();
147 EXPECT_EQ(QUIC_STREAM_SEQUENCER_INVALID_STATE, 146 EXPECT_EQ(QUIC_STREAM_SEQUENCER_INVALID_STATE,
148 buffer_->OnStreamData(800, source, t, &written, &error_details_)); 147 buffer_->OnStreamData(800, source, t, &written, &error_details_));
149 EXPECT_EQ( 148 EXPECT_EQ(
150 0u, error_details_.find("QuicStreamSequencerBuffer error: OnStreamData()" 149 0u, error_details_.find("QuicStreamSequencerBuffer error: OnStreamData()"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 EXPECT_EQ(100u, read); 328 EXPECT_EQ(100u, read);
330 EXPECT_EQ(100u, buffer_->BytesConsumed()); 329 EXPECT_EQ(100u, buffer_->BytesConsumed());
331 EXPECT_EQ(source, string(dest, read)); 330 EXPECT_EQ(source, string(dest, read));
332 EXPECT_EQ(1u, helper_->frame_arrival_time_map()->size()); 331 EXPECT_EQ(1u, helper_->frame_arrival_time_map()->size());
333 // The first block should be released as its data has been read out. 332 // The first block should be released as its data has been read out.
334 EXPECT_EQ(nullptr, helper_->GetBlock(0)); 333 EXPECT_EQ(nullptr, helper_->GetBlock(0));
335 EXPECT_TRUE(helper_->CheckBufferInvariants()); 334 EXPECT_TRUE(helper_->CheckBufferInvariants());
336 } 335 }
337 336
338 TEST_F(QuicStreamSequencerBufferTest, ReadvError) { 337 TEST_F(QuicStreamSequencerBufferTest, ReadvError) {
339 FLAGS_quic_stream_sequencer_buffer_debug = true;
340 string source = string(100, 'b'); 338 string source = string(100, 'b');
341 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 339 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
342 QuicTime t1 = clock_.ApproximateNow(); 340 QuicTime t1 = clock_.ApproximateNow();
343 // Write something into [0, 100). 341 // Write something into [0, 100).
344 size_t written; 342 size_t written;
345 buffer_->OnStreamData(0, source, t1, &written, &error_details_); 343 buffer_->OnStreamData(0, source, t1, &written, &error_details_);
346 EXPECT_TRUE(helper_->GetBlock(0) != nullptr); 344 EXPECT_TRUE(helper_->GetBlock(0) != nullptr);
347 EXPECT_TRUE(buffer_->HasBytesToRead()); 345 EXPECT_TRUE(buffer_->HasBytesToRead());
348 // Read into a iovec array with total capacity of 120 bytes. 346 // Read into a iovec array with total capacity of 120 bytes.
349 iovec iov{nullptr, 120}; 347 iovec iov{nullptr, 120};
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " 1054 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: "
1057 << iterations; 1055 << iterations;
1058 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); 1056 EXPECT_LE(bytes_to_buffer_, total_bytes_written_);
1059 } 1057 }
1060 1058
1061 } // anonymous namespace 1059 } // anonymous namespace
1062 1060
1063 } // namespace test 1061 } // namespace test
1064 1062
1065 } // namespace net 1063 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_stream_sequencer_buffer.cc ('k') | net/quic/core/quic_stream_sequencer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698