| 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> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "net/quic/platform/api/quic_str_cat.h" |
| 15 #include "net/quic/test_tools/mock_clock.h" | 16 #include "net/quic/test_tools/mock_clock.h" |
| 16 #include "net/quic/test_tools/quic_stream_sequencer_buffer_peer.h" | 17 #include "net/quic/test_tools/quic_stream_sequencer_buffer_peer.h" |
| 17 #include "net/quic/test_tools/quic_test_utils.h" | 18 #include "net/quic/test_tools/quic_test_utils.h" |
| 18 #include "net/test/gtest_util.h" | 19 #include "net/test/gtest_util.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gmock_mutant.h" | 21 #include "testing/gmock_mutant.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| 23 using std::string; | 24 using std::string; |
| 24 | 25 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 138 |
| 138 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataInvalidSource) { | 139 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataInvalidSource) { |
| 139 // Pass in an invalid source, expects to return error. | 140 // Pass in an invalid source, expects to return error. |
| 140 StringPiece source; | 141 StringPiece source; |
| 141 source = StringPiece(nullptr, 1024); | 142 source = StringPiece(nullptr, 1024); |
| 142 size_t written; | 143 size_t written; |
| 143 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 144 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 144 QuicTime t = clock_.ApproximateNow(); | 145 QuicTime t = clock_.ApproximateNow(); |
| 145 EXPECT_EQ(QUIC_STREAM_SEQUENCER_INVALID_STATE, | 146 EXPECT_EQ(QUIC_STREAM_SEQUENCER_INVALID_STATE, |
| 146 buffer_->OnStreamData(800, source, t, &written, &error_details_)); | 147 buffer_->OnStreamData(800, source, t, &written, &error_details_)); |
| 147 EXPECT_EQ( | 148 EXPECT_EQ(0u, error_details_.find(QuicStrCat( |
| 148 0u, error_details_.find("QuicStreamSequencerBuffer error: OnStreamData()" | 149 "QuicStreamSequencerBuffer error: OnStreamData() " |
| 149 " dest == nullptr: false" | 150 "dest == nullptr: ", |
| 150 " source == nullptr: true")); | 151 false, " source == nullptr: ", true))); |
| 151 } | 152 } |
| 152 | 153 |
| 153 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithOverlap) { | 154 TEST_F(QuicStreamSequencerBufferTest, OnStreamDataWithOverlap) { |
| 154 string source(1024, 'a'); | 155 string source(1024, 'a'); |
| 155 // Write something into [800, 1824) | 156 // Write something into [800, 1824) |
| 156 size_t written; | 157 size_t written; |
| 157 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 158 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 158 QuicTime t1 = clock_.ApproximateNow(); | 159 QuicTime t1 = clock_.ApproximateNow(); |
| 159 EXPECT_EQ(QUIC_NO_ERROR, | 160 EXPECT_EQ(QUIC_NO_ERROR, |
| 160 buffer_->OnStreamData(800, source, t1, &written, &error_details_)); | 161 buffer_->OnStreamData(800, source, t1, &written, &error_details_)); |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " | 1034 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " |
| 1034 << iterations; | 1035 << iterations; |
| 1035 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); | 1036 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 } // anonymous namespace | 1039 } // anonymous namespace |
| 1039 | 1040 |
| 1040 } // namespace test | 1041 } // namespace test |
| 1041 | 1042 |
| 1042 } // namespace net | 1043 } // namespace net |
| OLD | NEW |