| OLD | NEW |
| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 protected: | 62 protected: |
| 63 QuicStreamSequencerTest() | 63 QuicStreamSequencerTest() |
| 64 : connection_(new MockConnection(false)), | 64 : connection_(new MockConnection(false)), |
| 65 session_(connection_), | 65 session_(connection_), |
| 66 stream_(&session_, 1), | 66 stream_(&session_, 1), |
| 67 sequencer_(new QuicStreamSequencer(&stream_)), | 67 sequencer_(new QuicStreamSequencer(&stream_)), |
| 68 buffered_frames_( | 68 buffered_frames_( |
| 69 QuicStreamSequencerPeer::GetBufferedFrames(sequencer_.get())) { | 69 QuicStreamSequencerPeer::GetBufferedFrames(sequencer_.get())) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool VerifyIovecs(iovec* iovecs, | |
| 73 size_t num_iovecs, | |
| 74 const char** expected, | |
| 75 size_t num_expected) { | |
| 76 if (num_expected != num_iovecs) { | |
| 77 LOG(ERROR) << "Incorrect number of iovecs. Expected: " | |
| 78 << num_expected << " Actual: " << num_iovecs; | |
| 79 return false; | |
| 80 } | |
| 81 for (size_t i = 0; i < num_expected; ++i) { | |
| 82 if (!VerifyIovec(iovecs[i], expected[i])) { | |
| 83 return false; | |
| 84 } | |
| 85 } | |
| 86 return true; | |
| 87 } | |
| 88 | |
| 89 bool VerifyIovec(const iovec& iovec, StringPiece expected) { | 72 bool VerifyIovec(const iovec& iovec, StringPiece expected) { |
| 90 if (iovec.iov_len != expected.length()) { | 73 if (iovec.iov_len != expected.length()) { |
| 91 LOG(ERROR) << "Invalid length: " << iovec.iov_len | 74 LOG(ERROR) << "Invalid length: " << iovec.iov_len |
| 92 << " vs " << expected.length(); | 75 << " vs " << expected.length(); |
| 93 return false; | 76 return false; |
| 94 } | 77 } |
| 95 if (memcmp(iovec.iov_base, expected.data(), expected.length()) != 0) { | 78 if (memcmp(iovec.iov_base, expected.data(), expected.length()) != 0) { |
| 96 LOG(ERROR) << "Invalid data: " << static_cast<char*>(iovec.iov_base) | 79 LOG(ERROR) << "Invalid data: " << static_cast<char*>(iovec.iov_base) |
| 97 << " vs " << expected.data(); | 80 << " vs " << expected.data(); |
| 98 return false; | 81 return false; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 QuicStreamFrame frame2(kClientDataStreamId1, false, 2, MakeIOVector("hello")); | 415 QuicStreamFrame frame2(kClientDataStreamId1, false, 2, MakeIOVector("hello")); |
| 433 EXPECT_TRUE(sequencer_->FrameOverlapsBufferedData(frame2)); | 416 EXPECT_TRUE(sequencer_->FrameOverlapsBufferedData(frame2)); |
| 434 EXPECT_CALL(stream_, CloseConnectionWithDetails(QUIC_INVALID_STREAM_FRAME, _)) | 417 EXPECT_CALL(stream_, CloseConnectionWithDetails(QUIC_INVALID_STREAM_FRAME, _)) |
| 435 .Times(1); | 418 .Times(1); |
| 436 sequencer_->OnStreamFrame(frame2); | 419 sequencer_->OnStreamFrame(frame2); |
| 437 } | 420 } |
| 438 | 421 |
| 439 } // namespace | 422 } // namespace |
| 440 } // namespace test | 423 } // namespace test |
| 441 } // namespace net | 424 } // namespace net |
| OLD | NEW |