OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_sent_packet_manager.h" | 5 #include "net/quic/quic_sent_packet_manager.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/quic_flags.h" | 8 #include "net/quic/quic_flags.h" |
9 #include "net/quic/test_tools/quic_config_peer.h" | 9 #include "net/quic/test_tools/quic_config_peer.h" |
10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 10 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate { | 42 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate { |
43 public: | 43 public: |
44 MOCK_METHOD2(OnSpuriousPacketRetransmission, | 44 MOCK_METHOD2(OnSpuriousPacketRetransmission, |
45 void(TransmissionType transmission_type, | 45 void(TransmissionType transmission_type, |
46 QuicByteCount byte_size)); | 46 QuicByteCount byte_size)); |
47 }; | 47 }; |
48 | 48 |
49 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> { | 49 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> { |
50 protected: | 50 protected: |
51 QuicSentPacketManagerTest() | 51 QuicSentPacketManagerTest() |
52 : manager_(Perspective::IS_SERVER, &clock_, &stats_, kCubic, kNack), | 52 : manager_(Perspective::IS_SERVER, |
| 53 kDefaultPathId, |
| 54 &clock_, |
| 55 &stats_, |
| 56 kCubic, |
| 57 kNack), |
53 send_algorithm_(new StrictMock<MockSendAlgorithm>), | 58 send_algorithm_(new StrictMock<MockSendAlgorithm>), |
54 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) { | 59 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) { |
55 // These tests only work with pacing enabled. | 60 // These tests only work with pacing enabled. |
56 saved_FLAGS_quic_disable_pacing_ = FLAGS_quic_disable_pacing; | 61 saved_FLAGS_quic_disable_pacing_ = FLAGS_quic_disable_pacing; |
57 FLAGS_quic_disable_pacing = false; | 62 FLAGS_quic_disable_pacing = false; |
58 | 63 |
59 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_); | 64 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_); |
60 // Disable tail loss probes for most tests. | 65 // Disable tail loss probes for most tests. |
61 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0); | 66 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0); |
62 // Advance the time 1s so the send times are never QuicTime::Zero. | 67 // Advance the time 1s so the send times are never QuicTime::Zero. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 189 |
185 SerializedPacket CreatePacket(QuicPacketNumber packet_number, | 190 SerializedPacket CreatePacket(QuicPacketNumber packet_number, |
186 bool retransmittable) { | 191 bool retransmittable) { |
187 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength)); | 192 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength)); |
188 RetransmittableFrames* frames = nullptr; | 193 RetransmittableFrames* frames = nullptr; |
189 if (retransmittable) { | 194 if (retransmittable) { |
190 frames = new RetransmittableFrames(); | 195 frames = new RetransmittableFrames(); |
191 frames->AddFrame( | 196 frames->AddFrame( |
192 QuicFrame(new QuicStreamFrame(kStreamId, false, 0, StringPiece()))); | 197 QuicFrame(new QuicStreamFrame(kStreamId, false, 0, StringPiece()))); |
193 } | 198 } |
194 return SerializedPacket(packet_number, PACKET_6BYTE_PACKET_NUMBER, | 199 return SerializedPacket(kDefaultPathId, packet_number, |
195 packets_.back(), 0u, frames, false, false); | 200 PACKET_6BYTE_PACKET_NUMBER, packets_.back(), 0u, |
| 201 frames, false, false); |
196 } | 202 } |
197 | 203 |
198 SerializedPacket CreateFecPacket(QuicPacketNumber packet_number) { | 204 SerializedPacket CreateFecPacket(QuicPacketNumber packet_number) { |
199 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength)); | 205 packets_.push_back(new QuicEncryptedPacket(nullptr, kDefaultLength)); |
200 SerializedPacket serialized(packet_number, PACKET_6BYTE_PACKET_NUMBER, | 206 SerializedPacket serialized(kDefaultPathId, packet_number, |
201 packets_.back(), 0u, nullptr, false, false); | 207 PACKET_6BYTE_PACKET_NUMBER, packets_.back(), 0u, |
| 208 nullptr, false, false); |
202 serialized.is_fec_packet = true; | 209 serialized.is_fec_packet = true; |
203 return serialized; | 210 return serialized; |
204 } | 211 } |
205 | 212 |
206 void SendDataPacket(QuicPacketNumber packet_number) { | 213 void SendDataPacket(QuicPacketNumber packet_number) { |
207 EXPECT_CALL(*send_algorithm_, | 214 EXPECT_CALL(*send_algorithm_, |
208 OnPacketSent(_, BytesInFlight(), packet_number, _, _)) | 215 OnPacketSent(_, BytesInFlight(), packet_number, _, _)) |
209 .Times(1) | 216 .Times(1) |
210 .WillOnce(Return(true)); | 217 .WillOnce(Return(true)); |
211 SerializedPacket packet(CreateDataPacket(packet_number)); | 218 SerializedPacket packet(CreateDataPacket(packet_number)); |
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 | 1685 |
1679 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_, false)); | 1686 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_, false)); |
1680 manager_.ResumeConnectionState(cached_network_params, false); | 1687 manager_.ResumeConnectionState(cached_network_params, false); |
1681 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, | 1688 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, |
1682 static_cast<uint64_t>(manager_.GetRttStats()->initial_rtt_us())); | 1689 static_cast<uint64_t>(manager_.GetRttStats()->initial_rtt_us())); |
1683 } | 1690 } |
1684 | 1691 |
1685 } // namespace | 1692 } // namespace |
1686 } // namespace test | 1693 } // namespace test |
1687 } // namespace net | 1694 } // namespace net |
OLD | NEW |