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/core/quic_sent_packet_manager.h" | 5 #include "net/quic/core/quic_sent_packet_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "net/quic/core/quic_pending_retransmission.h" | 9 #include "net/quic/core/quic_pending_retransmission.h" |
10 #include "net/quic/platform/api/quic_flags.h" | 10 #include "net/quic/platform/api/quic_flags.h" |
11 #include "net/quic/platform/api/quic_ptr_util.h" | 11 #include "net/quic/platform/api/quic_ptr_util.h" |
12 #include "net/quic/platform/api/quic_string_piece.h" | 12 #include "net/quic/platform/api/quic_string_piece.h" |
| 13 #include "net/quic/platform/api/quic_test.h" |
13 #include "net/quic/test_tools/quic_config_peer.h" | 14 #include "net/quic/test_tools/quic_config_peer.h" |
14 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 15 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
15 #include "net/quic/test_tools/quic_test_utils.h" | 16 #include "net/quic/test_tools/quic_test_utils.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | |
18 | 17 |
19 using testing::AnyNumber; | 18 using testing::AnyNumber; |
20 using testing::ElementsAre; | 19 using testing::ElementsAre; |
21 using testing::IsEmpty; | 20 using testing::IsEmpty; |
22 using testing::Not; | 21 using testing::Not; |
23 using testing::Pair; | 22 using testing::Pair; |
24 using testing::Pointwise; | 23 using testing::Pointwise; |
25 using testing::Return; | 24 using testing::Return; |
26 using testing::SetArgPointee; | 25 using testing::SetArgPointee; |
27 using testing::StrictMock; | 26 using testing::StrictMock; |
(...skipping 21 matching lines...) Expand all Loading... |
49 public: | 48 public: |
50 MOCK_METHOD2(OnSpuriousPacketRetransmission, | 49 MOCK_METHOD2(OnSpuriousPacketRetransmission, |
51 void(TransmissionType transmission_type, | 50 void(TransmissionType transmission_type, |
52 QuicByteCount byte_size)); | 51 QuicByteCount byte_size)); |
53 MOCK_METHOD3(OnPacketLoss, | 52 MOCK_METHOD3(OnPacketLoss, |
54 void(QuicPacketNumber lost_packet_number, | 53 void(QuicPacketNumber lost_packet_number, |
55 TransmissionType transmission_type, | 54 TransmissionType transmission_type, |
56 QuicTime detection_time)); | 55 QuicTime detection_time)); |
57 }; | 56 }; |
58 | 57 |
59 class QuicSentPacketManagerTest : public ::testing::Test { | 58 class QuicSentPacketManagerTest : public QuicTest { |
60 protected: | 59 protected: |
61 QuicSentPacketManagerTest() | 60 QuicSentPacketManagerTest() |
62 : manager_(Perspective::IS_SERVER, &clock_, &stats_, kCubicBytes, kNack), | 61 : manager_(Perspective::IS_SERVER, &clock_, &stats_, kCubicBytes, kNack), |
63 send_algorithm_(new StrictMock<MockSendAlgorithm>), | 62 send_algorithm_(new StrictMock<MockSendAlgorithm>), |
64 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) { | 63 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) { |
65 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_); | 64 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_); |
66 // Disable tail loss probes for most tests. | 65 // Disable tail loss probes for most tests. |
67 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0); | 66 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0); |
68 // 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. |
69 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); | 68 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 return frame; | 262 return frame; |
264 } | 263 } |
265 | 264 |
266 // Explicitly nack packet [lower, higher). | 265 // Explicitly nack packet [lower, higher). |
267 void NackPackets(QuicPacketNumber lower, | 266 void NackPackets(QuicPacketNumber lower, |
268 QuicPacketNumber higher, | 267 QuicPacketNumber higher, |
269 QuicAckFrame* frame) { | 268 QuicAckFrame* frame) { |
270 frame->packets.Remove(lower, higher); | 269 frame->packets.Remove(lower, higher); |
271 } | 270 } |
272 | 271 |
273 QuicFlagSaver flags_; // Save/restore all QUIC flag values. | |
274 QuicSentPacketManager manager_; | 272 QuicSentPacketManager manager_; |
275 MockClock clock_; | 273 MockClock clock_; |
276 QuicConnectionStats stats_; | 274 QuicConnectionStats stats_; |
277 MockSendAlgorithm* send_algorithm_; | 275 MockSendAlgorithm* send_algorithm_; |
278 std::unique_ptr<MockNetworkChangeVisitor> network_change_visitor_; | 276 std::unique_ptr<MockNetworkChangeVisitor> network_change_visitor_; |
279 }; | 277 }; |
280 | 278 |
281 TEST_F(QuicSentPacketManagerTest, IsUnacked) { | 279 TEST_F(QuicSentPacketManagerTest, IsUnacked) { |
282 VerifyUnackedPackets(nullptr, 0); | 280 VerifyUnackedPackets(nullptr, 0); |
283 SendDataPacket(1); | 281 SendDataPacket(1); |
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 ExpectAck(1); | 1729 ExpectAck(1); |
1732 EXPECT_CALL(*network_change_visitor_, | 1730 EXPECT_CALL(*network_change_visitor_, |
1733 OnPathMtuIncreased(kDefaultLength + 100)); | 1731 OnPathMtuIncreased(kDefaultLength + 100)); |
1734 QuicAckFrame ack_frame = InitAckFrame(1); | 1732 QuicAckFrame ack_frame = InitAckFrame(1); |
1735 manager_.OnIncomingAck(ack_frame, clock_.Now()); | 1733 manager_.OnIncomingAck(ack_frame, clock_.Now()); |
1736 } | 1734 } |
1737 | 1735 |
1738 } // namespace | 1736 } // namespace |
1739 } // namespace test | 1737 } // namespace test |
1740 } // namespace net | 1738 } // namespace net |
OLD | NEW |