Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: net/quic/quic_sent_packet_manager_test.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_stream_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "net/quic/test_tools/quic_test_utils.h" 11 #include "net/quic/test_tools/quic_test_utils.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using std::vector; 15 using std::vector;
16 using testing::AnyNumber; 16 using testing::AnyNumber;
17 using testing::ElementsAre; 17 using testing::ElementsAre;
18 using testing::IsEmpty; 18 using testing::IsEmpty;
19 using testing::Not;
19 using testing::Pair; 20 using testing::Pair;
20 using testing::Pointwise; 21 using testing::Pointwise;
21 using testing::Return; 22 using testing::Return;
22 using testing::StrictMock; 23 using testing::StrictMock;
23 using testing::_; 24 using testing::_;
24 25
25 namespace net { 26 namespace net {
26 namespace test { 27 namespace test {
27 namespace { 28 namespace {
28 29
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 } 1121 }
1121 RetransmitNextPacket(101); 1122 RetransmitNextPacket(101);
1122 RetransmitNextPacket(102); 1123 RetransmitNextPacket(102);
1123 if (FLAGS_quic_use_new_rto) { 1124 if (FLAGS_quic_use_new_rto) {
1124 EXPECT_FALSE(manager_.HasPendingRetransmissions()); 1125 EXPECT_FALSE(manager_.HasPendingRetransmissions());
1125 } else { 1126 } else {
1126 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 1127 EXPECT_TRUE(manager_.HasPendingRetransmissions());
1127 } 1128 }
1128 1129
1129 // Ack a retransmission. 1130 // Ack a retransmission.
1130 if (FLAGS_quic_use_new_rto) {
1131 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1132 }
1133 QuicAckFrame ack_frame; 1131 QuicAckFrame ack_frame;
1134 ack_frame.delta_time_largest_observed = QuicTime::Delta::Zero(); 1132 ack_frame.delta_time_largest_observed = QuicTime::Delta::Zero();
1135 ack_frame.largest_observed = 102; 1133 ack_frame.largest_observed = 102;
1136 for (int i = 0; i < 102; ++i) { 1134 for (int i = 0; i < 102; ++i) {
1137 ack_frame.missing_packets.insert(i); 1135 ack_frame.missing_packets.insert(i);
1138 } 1136 }
1137 // Ensure no packets are lost.
1139 EXPECT_CALL(*send_algorithm_, 1138 EXPECT_CALL(*send_algorithm_,
1140 OnCongestionEvent(true, _, ElementsAre(Pair(102, _)), _)); 1139 OnCongestionEvent(true, _, ElementsAre(Pair(102, _)),
1140 /*lost_packets=*/IsEmpty()));
1141 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1142 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1143 if (FLAGS_quic_use_new_rto) {
1144 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1145 }
1146 manager_.OnIncomingAck(ack_frame, clock_.Now());
1147 }
1148
1149 TEST_F(QuicSentPacketManagerTest, NewRetransmissionTimeout) {
1150 ValueRestore<bool> old_flag(&FLAGS_quic_use_new_rto, true);
1151 QuicConfig client_config;
1152 QuicTagVector options;
1153 options.push_back(kNRTO);
1154 QuicSentPacketManagerPeer::SetIsServer(&manager_, false);
1155 client_config.SetConnectionOptionsToSend(options);
1156 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1157 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1158 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1159 manager_.SetFromConfig(client_config);
1160 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1161
1162 // Send 100 packets.
1163 const size_t kNumSentPackets = 100;
1164 for (size_t i = 1; i <= kNumSentPackets; ++i) {
1165 SendDataPacket(i);
1166 }
1167
1168 EXPECT_FALSE(manager_.MaybeRetransmitTailLossProbe());
1169 manager_.OnRetransmissionTimeout();
1170 EXPECT_TRUE(manager_.HasPendingRetransmissions());
1171 EXPECT_EQ(100 * kDefaultLength,
1172 QuicSentPacketManagerPeer::GetBytesInFlight(&manager_));
1173 RetransmitNextPacket(101);
1174 RetransmitNextPacket(102);
1175 EXPECT_FALSE(manager_.HasPendingRetransmissions());
1176
1177 // Ack a retransmission and expect no call to OnRetransmissionTimeout.
1178 QuicAckFrame ack_frame;
1179 ack_frame.delta_time_largest_observed = QuicTime::Delta::Zero();
1180 ack_frame.largest_observed = 102;
1181 for (int i = 0; i < 102; ++i) {
1182 ack_frame.missing_packets.insert(i);
1183 }
1184 // This will include packets in the lost packet map.
1185 EXPECT_CALL(*send_algorithm_,
1186 OnCongestionEvent(true, _, ElementsAre(Pair(102, _)),
1187 /*lost_packets=*/Not(IsEmpty())));
1141 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1188 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1142 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1189 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1143 manager_.OnIncomingAck(ack_frame, clock_.Now()); 1190 manager_.OnIncomingAck(ack_frame, clock_.Now());
1144 } 1191 }
1145 1192
1146 TEST_F(QuicSentPacketManagerTest, TwoRetransmissionTimeoutsAckSecond) { 1193 TEST_F(QuicSentPacketManagerTest, TwoRetransmissionTimeoutsAckSecond) {
1147 // Send 1 packet. 1194 // Send 1 packet.
1148 SendDataPacket(1); 1195 SendDataPacket(1);
1149 1196
1150 if (!FLAGS_quic_use_new_rto) { 1197 if (!FLAGS_quic_use_new_rto) {
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 options.push_back(kNTLP); 1649 options.push_back(kNTLP);
1603 QuicSentPacketManagerPeer::SetIsServer(&manager_, false); 1650 QuicSentPacketManagerPeer::SetIsServer(&manager_, false);
1604 client_config.SetConnectionOptionsToSend(options); 1651 client_config.SetConnectionOptionsToSend(options);
1605 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1652 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1606 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1653 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1607 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 1654 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1608 manager_.SetFromConfig(client_config); 1655 manager_.SetFromConfig(client_config);
1609 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_)); 1656 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_));
1610 } 1657 }
1611 1658
1659 TEST_F(QuicSentPacketManagerTest, NegotiateNewRTOFromOptionsAtServer) {
1660 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1661 QuicConfig config;
1662 QuicTagVector options;
1663
1664 options.push_back(kNRTO);
1665 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1666 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1667 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1668 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1669 manager_.SetFromConfig(config);
1670 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1671 }
1672
1673 TEST_F(QuicSentPacketManagerTest, NegotiateNewRTOFromOptionsAtClient) {
1674 EXPECT_FALSE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1675 QuicConfig client_config;
1676 QuicTagVector options;
1677
1678 options.push_back(kNRTO);
1679 QuicSentPacketManagerPeer::SetIsServer(&manager_, false);
1680 client_config.SetConnectionOptionsToSend(options);
1681 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1682 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1683 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
1684 manager_.SetFromConfig(client_config);
1685 EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_));
1686 }
1687
1612 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) { 1688 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) {
1613 EXPECT_FALSE(manager_.using_pacing()); 1689 EXPECT_FALSE(manager_.using_pacing());
1614 1690
1615 QuicConfig config; 1691 QuicConfig config;
1616 QuicTagVector options; 1692 QuicTagVector options;
1617 options.push_back(kPACE); 1693 options.push_back(kPACE);
1618 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1694 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1619 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); 1695 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
1620 EXPECT_CALL(*network_change_visitor_, OnRttChange()); 1696 EXPECT_CALL(*network_change_visitor_, OnRttChange());
1621 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, /*using_pacing=*/true)); 1697 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, /*using_pacing=*/true));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 1793
1718 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_)); 1794 EXPECT_CALL(*send_algorithm_, ResumeConnectionState(_));
1719 manager_.ResumeConnectionState(cached_network_params); 1795 manager_.ResumeConnectionState(cached_network_params);
1720 EXPECT_EQ(kRttMs * kNumMicrosPerMilli, 1796 EXPECT_EQ(kRttMs * kNumMicrosPerMilli,
1721 static_cast<uint64>(manager_.GetRttStats()->initial_rtt_us())); 1797 static_cast<uint64>(manager_.GetRttStats()->initial_rtt_us()));
1722 } 1798 }
1723 1799
1724 } // namespace 1800 } // namespace
1725 } // namespace test 1801 } // namespace test
1726 } // namespace net 1802 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_stream_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698