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

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

Issue 2566943003: rel-note: automated rollback of internal change 138108562 (Closed)
Patch Set: Created 4 years 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 TEST_F(QuicStreamSequencerBufferTest, OnStreamData0length) { 104 TEST_F(QuicStreamSequencerBufferTest, OnStreamData0length) {
105 size_t written; 105 size_t written;
106 QuicErrorCode error = buffer_->OnStreamData(800, "", clock_.ApproximateNow(), 106 QuicErrorCode error = buffer_->OnStreamData(800, "", clock_.ApproximateNow(),
107 &written, &error_details_); 107 &written, &error_details_);
108 EXPECT_EQ(error, QUIC_EMPTY_STREAM_FRAME_NO_FIN); 108 EXPECT_EQ(error, QUIC_EMPTY_STREAM_FRAME_NO_FIN);
109 EXPECT_TRUE(helper_->CheckBufferInvariants()); 109 EXPECT_TRUE(helper_->CheckBufferInvariants());
110 } 110 }
111 111
112 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithinBlock) { 112 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithinBlock) {
113 EXPECT_FALSE(helper_->IsBufferAllocated()); 113 if (FLAGS_quic_reduce_sequencer_buffer_memory_life_time) { // NOLINT
114 EXPECT_FALSE(helper_->IsBufferAllocated());
115 }
114 string source(1024, 'a'); 116 string source(1024, 'a');
115 size_t written; 117 size_t written;
116 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 118 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
117 QuicTime t = clock_.ApproximateNow(); 119 QuicTime t = clock_.ApproximateNow();
118 EXPECT_EQ(QUIC_NO_ERROR, 120 EXPECT_EQ(QUIC_NO_ERROR,
119 buffer_->OnStreamData(800, source, t, &written, &error_details_)); 121 buffer_->OnStreamData(800, source, t, &written, &error_details_));
120 BufferBlock* block_ptr = helper_->GetBlock(0); 122 BufferBlock* block_ptr = helper_->GetBlock(0);
121 for (size_t i = 0; i < source.size(); ++i) { 123 for (size_t i = 0; i < source.size(); ++i) {
122 ASSERT_EQ('a', block_ptr->buffer[helper_->GetInBlockOffset(800) + i]); 124 ASSERT_EQ('a', block_ptr->buffer[helper_->GetInBlockOffset(800) + i]);
123 } 125 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 TEST_F(QuicStreamSequencerBufferTest, GetReadableRegionsEmpty) { 464 TEST_F(QuicStreamSequencerBufferTest, GetReadableRegionsEmpty) {
463 iovec iovs[2]; 465 iovec iovs[2];
464 int iov_count = buffer_->GetReadableRegions(iovs, 2); 466 int iov_count = buffer_->GetReadableRegions(iovs, 2);
465 EXPECT_EQ(0, iov_count); 467 EXPECT_EQ(0, iov_count);
466 EXPECT_EQ(nullptr, iovs[iov_count].iov_base); 468 EXPECT_EQ(nullptr, iovs[iov_count].iov_base);
467 EXPECT_EQ(0u, iovs[iov_count].iov_len); 469 EXPECT_EQ(0u, iovs[iov_count].iov_len);
468 } 470 }
469 471
470 TEST_F(QuicStreamSequencerBufferTest, ReleaseWholeBuffer) { 472 TEST_F(QuicStreamSequencerBufferTest, ReleaseWholeBuffer) {
471 // Tests that buffer is not deallocated unless ReleaseWholeBuffer() is called. 473 // Tests that buffer is not deallocated unless ReleaseWholeBuffer() is called.
474 if (!FLAGS_quic_reduce_sequencer_buffer_memory_life_time) { // NOLINT
475 // Won't release buffer when flag is off.
476 return;
477 }
472 478
473 string source(100, 'b'); 479 string source(100, 'b');
474 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 480 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
475 QuicTime t1 = clock_.ApproximateNow(); 481 QuicTime t1 = clock_.ApproximateNow();
476 // Write something into [0, 100). 482 // Write something into [0, 100).
477 size_t written; 483 size_t written;
478 buffer_->OnStreamData(0, source, t1, &written, &error_details_); 484 buffer_->OnStreamData(0, source, t1, &written, &error_details_);
479 EXPECT_TRUE(buffer_->HasBytesToRead()); 485 EXPECT_TRUE(buffer_->HasBytesToRead());
480 char dest[120]; 486 char dest[120];
481 iovec iovecs[3]{iovec{dest, 40}, iovec{dest + 40, 40}, iovec{dest + 80, 40}}; 487 iovec iovecs[3]{iovec{dest, 40}, iovec{dest + 40, 40}, iovec{dest + 80, 40}};
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " 1033 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: "
1028 << iterations; 1034 << iterations;
1029 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); 1035 EXPECT_LE(bytes_to_buffer_, total_bytes_written_);
1030 } 1036 }
1031 1037
1032 } // anonymous namespace 1038 } // anonymous namespace
1033 1039
1034 } // namespace test 1040 } // namespace test
1035 1041
1036 } // namespace net 1042 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_stream_sequencer_buffer.cc ('k') | net/quic/test_tools/quic_stream_sequencer_buffer_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698