| 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 10 matching lines...) Expand all Loading... |
| 21 using testing::Pointwise; | 21 using testing::Pointwise; |
| 22 using testing::Return; | 22 using testing::Return; |
| 23 using testing::StrictMock; | 23 using testing::StrictMock; |
| 24 using testing::_; | 24 using testing::_; |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 namespace test { | 27 namespace test { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Default packet length. | 30 // Default packet length. |
| 31 const uint32 kDefaultLength = 1000; | 31 const uint32_t kDefaultLength = 1000; |
| 32 | 32 |
| 33 // Stream ID for data sent in CreatePacket(). | 33 // Stream ID for data sent in CreatePacket(). |
| 34 const QuicStreamId kStreamId = 7; | 34 const QuicStreamId kStreamId = 7; |
| 35 | 35 |
| 36 // Matcher to check the key of the key-value pair it receives as first argument | 36 // Matcher to check the key of the key-value pair it receives as first argument |
| 37 // equals its second argument. | 37 // equals its second argument. |
| 38 MATCHER(KeyEq, "") { | 38 MATCHER(KeyEq, "") { |
| 39 return std::tr1::get<0>(arg).first == std::tr1::get<1>(arg); | 39 return std::tr1::get<0>(arg).first == std::tr1::get<1>(arg); |
| 40 } | 40 } |
| 41 | 41 |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 manager_.OnPacketSent(&packet, 0, clock_.Now(), 1024, NOT_RETRANSMISSION, | 1647 manager_.OnPacketSent(&packet, 0, clock_.Now(), 1024, NOT_RETRANSMISSION, |
| 1648 HAS_RETRANSMITTABLE_DATA); | 1648 HAS_RETRANSMITTABLE_DATA); |
| 1649 } | 1649 } |
| 1650 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) | 1650 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) |
| 1651 .WillOnce(Return(QuicTime::Delta::Infinite())); | 1651 .WillOnce(Return(QuicTime::Delta::Infinite())); |
| 1652 EXPECT_EQ(QuicTime::Delta::Infinite(), | 1652 EXPECT_EQ(QuicTime::Delta::Infinite(), |
| 1653 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA)); | 1653 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA)); |
| 1654 } | 1654 } |
| 1655 | 1655 |
| 1656 TEST_F(QuicSentPacketManagerTest, UseInitialRoundTripTimeToSend) { | 1656 TEST_F(QuicSentPacketManagerTest, UseInitialRoundTripTimeToSend) { |
| 1657 uint32 initial_rtt_us = 325000; | 1657 uint32_t initial_rtt_us = 325000; |
| 1658 EXPECT_NE(initial_rtt_us, | 1658 EXPECT_NE(initial_rtt_us, |
| 1659 manager_.GetRttStats()->smoothed_rtt().ToMicroseconds()); | 1659 manager_.GetRttStats()->smoothed_rtt().ToMicroseconds()); |
| 1660 | 1660 |
| 1661 QuicConfig config; | 1661 QuicConfig config; |
| 1662 config.SetInitialRoundTripTimeUsToSend(initial_rtt_us); | 1662 config.SetInitialRoundTripTimeUsToSend(initial_rtt_us); |
| 1663 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | 1663 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 1664 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); | 1664 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); |
| 1665 EXPECT_CALL(*network_change_visitor_, OnRttChange()); | 1665 EXPECT_CALL(*network_change_visitor_, OnRttChange()); |
| 1666 manager_.SetFromConfig(config); | 1666 manager_.SetFromConfig(config); |
| 1667 | 1667 |
| 1668 EXPECT_EQ(0, manager_.GetRttStats()->smoothed_rtt().ToMicroseconds()); | 1668 EXPECT_EQ(0, manager_.GetRttStats()->smoothed_rtt().ToMicroseconds()); |
| 1669 EXPECT_EQ(initial_rtt_us, manager_.GetRttStats()->initial_rtt_us()); | 1669 EXPECT_EQ(initial_rtt_us, manager_.GetRttStats()->initial_rtt_us()); |
| 1670 } | 1670 } |
| 1671 | 1671 |
| 1672 TEST_F(QuicSentPacketManagerTest, ResumeConnectionState) { | 1672 TEST_F(QuicSentPacketManagerTest, ResumeConnectionState) { |
| 1673 // The sent packet manager should use the RTT from CachedNetworkParameters if | 1673 // The sent packet manager should use the RTT from CachedNetworkParameters if |
| 1674 // it is provided. | 1674 // it is provided. |
| 1675 const int kRttMs = 1234; | 1675 const int kRttMs = 1234; |
| 1676 CachedNetworkParameters cached_network_params; | 1676 CachedNetworkParameters cached_network_params; |
| 1677 cached_network_params.set_min_rtt_ms(kRttMs); | 1677 cached_network_params.set_min_rtt_ms(kRttMs); |
| 1678 | 1678 |
| 1679 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_, false)); | 1679 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_, false)); |
| 1680 manager_.ResumeConnectionState(cached_network_params, false); | 1680 manager_.ResumeConnectionState(cached_network_params, false); |
| 1681 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, | 1681 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, |
| 1682 static_cast<uint64>(manager_.GetRttStats()->initial_rtt_us())); | 1682 static_cast<uint64_t>(manager_.GetRttStats()->initial_rtt_us())); |
| 1683 } | 1683 } |
| 1684 | 1684 |
| 1685 } // namespace | 1685 } // namespace |
| 1686 } // namespace test | 1686 } // namespace test |
| 1687 } // namespace net | 1687 } // namespace net |
| OLD | NEW |