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 19 matching lines...) Expand all Loading... | |
30 const uint32 kDefaultLength = 1000; | 30 const uint32 kDefaultLength = 1000; |
31 | 31 |
32 // Matcher to check the key of the key-value pair it receives as first argument | 32 // Matcher to check the key of the key-value pair it receives as first argument |
33 // equals its second argument. | 33 // equals its second argument. |
34 MATCHER(KeyEq, "") { | 34 MATCHER(KeyEq, "") { |
35 return std::tr1::get<0>(arg).first == std::tr1::get<1>(arg); | 35 return std::tr1::get<0>(arg).first == std::tr1::get<1>(arg); |
36 } | 36 } |
37 | 37 |
38 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate { | 38 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate { |
39 public: | 39 public: |
40 MOCK_METHOD2(OnSpuriousPacketRetransmition, | 40 MOCK_METHOD2(OnSpuriousPacketRetransmission, |
41 void(TransmissionType transmission_type, | 41 void(TransmissionType transmission_type, |
42 QuicByteCount byte_size)); | 42 QuicByteCount byte_size)); |
43 }; | 43 }; |
44 | 44 |
45 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> { | 45 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> { |
46 protected: | 46 protected: |
47 QuicSentPacketManagerTest() | 47 QuicSentPacketManagerTest() |
48 : manager_(true, &clock_, &stats_, kCubic, kNack, false), | 48 : manager_(true, &clock_, &stats_, kCubic, kNack, false), |
49 send_algorithm_(new StrictMock<MockSendAlgorithm>), | 49 send_algorithm_(new StrictMock<MockSendAlgorithm>), |
50 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) { | 50 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) { |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); | 409 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); |
410 VerifyRetransmittablePackets(nullptr, 0); | 410 VerifyRetransmittablePackets(nullptr, 0); |
411 | 411 |
412 // Verify that the retransmission alarm would not fire, | 412 // Verify that the retransmission alarm would not fire, |
413 // since there is no retransmittable data outstanding. | 413 // since there is no retransmittable data outstanding. |
414 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); | 414 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); |
415 } | 415 } |
416 | 416 |
417 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckFirst) { | 417 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckFirst) { |
418 StrictMock<MockDebugDelegate> debug_delegate; | 418 StrictMock<MockDebugDelegate> debug_delegate; |
419 EXPECT_CALL(debug_delegate, OnSpuriousPacketRetransmition( | 419 EXPECT_CALL(debug_delegate, OnSpuriousPacketRetransmission( |
420 TLP_RETRANSMISSION, kDefaultLength)).Times(2); | 420 TLP_RETRANSMISSION, kDefaultLength)).Times(2); |
ramant (doing other things)
2015/01/14 02:13:07
nit: not 100% why this format is preferred.
Jana
2015/01/14 02:16:32
Maybe rch knows. I've mostly given up on trying to
ramant (doing other things)
2015/01/14 02:17:40
I meant to say, old format seems to be reasonable.
Jana
2015/01/14 02:22:53
Actually, this seems off, since there's a Times(2)
| |
421 manager_.set_debug_delegate(&debug_delegate); | 421 manager_.set_debug_delegate(&debug_delegate); |
422 | 422 |
423 SendDataPacket(1); | 423 SendDataPacket(1); |
424 RetransmitAndSendPacket(1, 2); | 424 RetransmitAndSendPacket(1, 2); |
425 RetransmitAndSendPacket(2, 3); | 425 RetransmitAndSendPacket(2, 3); |
426 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); | 426 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); |
427 clock_.AdvanceTime(rtt); | 427 clock_.AdvanceTime(rtt); |
428 | 428 |
429 // Ack 1 but not 2 or 3. | 429 // Ack 1 but not 2 or 3. |
430 ExpectAck(1); | 430 ExpectAck(1); |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1503 | 1503 |
1504 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_)); | 1504 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_)); |
1505 manager_.ResumeConnectionState(cached_network_params); | 1505 manager_.ResumeConnectionState(cached_network_params); |
1506 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, | 1506 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, |
1507 static_cast<uint64>(manager_.GetRttStats()->initial_rtt_us())); | 1507 static_cast<uint64>(manager_.GetRttStats()->initial_rtt_us())); |
1508 } | 1508 } |
1509 | 1509 |
1510 } // namespace | 1510 } // namespace |
1511 } // namespace test | 1511 } // namespace test |
1512 } // namespace net | 1512 } // namespace net |
OLD | NEW |