OLD | NEW |
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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 EXPECT_TRUE(buffer_->HasBytesToRead()); | 396 EXPECT_TRUE(buffer_->HasBytesToRead()); |
397 EXPECT_EQ(2u, helper_->frame_arrival_time_map()->size()); | 397 EXPECT_EQ(2u, helper_->frame_arrival_time_map()->size()); |
398 // Read into a iovec array with total capacity of 120 bytes. | 398 // Read into a iovec array with total capacity of 120 bytes. |
399 char dest[120]; | 399 char dest[120]; |
400 iovec iovecs[3]{iovec{dest, 40}, iovec{dest + 40, 40}, iovec{dest + 80, 40}}; | 400 iovec iovecs[3]{iovec{dest, 40}, iovec{dest + 40, 40}, iovec{dest + 80, 40}}; |
401 size_t read = buffer_->Readv(iovecs, 3); | 401 size_t read = buffer_->Readv(iovecs, 3); |
402 EXPECT_EQ(100u, read); | 402 EXPECT_EQ(100u, read); |
403 EXPECT_EQ(100u, buffer_->BytesConsumed()); | 403 EXPECT_EQ(100u, buffer_->BytesConsumed()); |
404 EXPECT_EQ(source, string(dest, read)); | 404 EXPECT_EQ(source, string(dest, read)); |
405 EXPECT_EQ(1u, helper_->frame_arrival_time_map()->size()); | 405 EXPECT_EQ(1u, helper_->frame_arrival_time_map()->size()); |
| 406 if (FLAGS_quic_sequencer_buffer_retire_block_in_time) { |
| 407 // The first block should be released as its data has been read out. |
| 408 EXPECT_EQ(nullptr, helper_->GetBlock(0)); |
| 409 } |
406 EXPECT_TRUE(helper_->CheckBufferInvariants()); | 410 EXPECT_TRUE(helper_->CheckBufferInvariants()); |
407 } | 411 } |
408 | 412 |
409 TEST_F(QuicStreamSequencerBufferTest, ReadvAcrossBlocks) { | 413 TEST_F(QuicStreamSequencerBufferTest, ReadvAcrossBlocks) { |
410 string source(kBlockSizeBytes + 50, 'a'); | 414 string source(kBlockSizeBytes + 50, 'a'); |
411 // Write 1st block to full and extand 50 bytes to next block. | 415 // Write 1st block to full and extand 50 bytes to next block. |
412 size_t written; | 416 size_t written; |
413 buffer_->OnStreamData(0, source, clock_.ApproximateNow(), &written, | 417 buffer_->OnStreamData(0, source, clock_.ApproximateNow(), &written, |
414 &error_details_); | 418 &error_details_); |
415 EXPECT_EQ(source.size(), helper_->ReadableBytes()); | 419 EXPECT_EQ(source.size(), helper_->ReadableBytes()); |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " | 1055 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " |
1052 << iterations; | 1056 << iterations; |
1053 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); | 1057 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); |
1054 } | 1058 } |
1055 | 1059 |
1056 } // anonymous namespace | 1060 } // anonymous namespace |
1057 | 1061 |
1058 } // namespace test | 1062 } // namespace test |
1059 | 1063 |
1060 } // namespace net | 1064 } // namespace net |
OLD | NEW |