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

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

Issue 399153003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added NET_EXPORT_PRIVATE Created 6 years, 5 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 | Annotate | Revision Log
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::ElementsAre; 17 using testing::ElementsAre;
17 using testing::Pair; 18 using testing::Pair;
18 using testing::Pointwise; 19 using testing::Pointwise;
19 using testing::Return; 20 using testing::Return;
20 using testing::StrictMock; 21 using testing::StrictMock;
21 using testing::_; 22 using testing::_;
22 23
23 namespace net { 24 namespace net {
24 namespace test { 25 namespace test {
25 namespace { 26 namespace {
(...skipping 10 matching lines...) Expand all
36 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate { 37 class MockDebugDelegate : public QuicSentPacketManager::DebugDelegate {
37 public: 38 public:
38 MOCK_METHOD2(OnSpuriousPacketRetransmition, 39 MOCK_METHOD2(OnSpuriousPacketRetransmition,
39 void(TransmissionType transmission_type, 40 void(TransmissionType transmission_type,
40 QuicByteCount byte_size)); 41 QuicByteCount byte_size));
41 }; 42 };
42 43
43 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> { 44 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> {
44 protected: 45 protected:
45 QuicSentPacketManagerTest() 46 QuicSentPacketManagerTest()
46 : manager_(true, &clock_, &stats_, kFixRate, kNack), 47 : manager_(true, &clock_, &stats_, kFixRateCongestionControl, kNack),
47 send_algorithm_(new StrictMock<MockSendAlgorithm>) { 48 send_algorithm_(new StrictMock<MockSendAlgorithm>),
49 network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) {
48 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_); 50 QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_);
49 // Disable tail loss probes for most tests. 51 // Disable tail loss probes for most tests.
50 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0); 52 QuicSentPacketManagerPeer::SetMaxTailLossProbes(&manager_, 0);
51 // Advance the time 1s so the send times are never QuicTime::Zero. 53 // Advance the time 1s so the send times are never QuicTime::Zero.
52 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); 54 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000));
55 manager_.set_network_change_visitor(network_change_visitor_.get());
53 } 56 }
54 57
55 virtual ~QuicSentPacketManagerTest() OVERRIDE { 58 virtual ~QuicSentPacketManagerTest() OVERRIDE {
56 STLDeleteElements(&packets_); 59 STLDeleteElements(&packets_);
57 } 60 }
58 61
59 QuicByteCount BytesInFlight() { 62 QuicByteCount BytesInFlight() {
60 return QuicSentPacketManagerPeer::GetBytesInFlight(&manager_); 63 return QuicSentPacketManagerPeer::GetBytesInFlight(&manager_);
61 } 64 }
62 void VerifyUnackedPackets(QuicPacketSequenceNumber* packets, 65 void VerifyUnackedPackets(QuicPacketSequenceNumber* packets,
(...skipping 19 matching lines...) Expand all
82 &manager_)); 85 &manager_));
83 for (size_t i = 0; i < num_packets; ++i) { 86 for (size_t i = 0; i < num_packets; ++i) {
84 EXPECT_TRUE(manager_.HasRetransmittableFrames(packets[i])) 87 EXPECT_TRUE(manager_.HasRetransmittableFrames(packets[i]))
85 << " packets[" << i << "]:" << packets[i]; 88 << " packets[" << i << "]:" << packets[i];
86 } 89 }
87 } 90 }
88 91
89 void ExpectAck(QuicPacketSequenceNumber largest_observed) { 92 void ExpectAck(QuicPacketSequenceNumber largest_observed) {
90 EXPECT_CALL(*send_algorithm_, OnCongestionEvent( 93 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(
91 true, _, ElementsAre(Pair(largest_observed, _)), _)); 94 true, _, ElementsAre(Pair(largest_observed, _)), _));
95 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
96 .WillOnce(Return(100 * kDefaultTCPMSS));
97 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
92 } 98 }
93 99
94 void ExpectUpdatedRtt(QuicPacketSequenceNumber largest_observed) { 100 void ExpectUpdatedRtt(QuicPacketSequenceNumber largest_observed) {
95 EXPECT_CALL(*send_algorithm_, 101 EXPECT_CALL(*send_algorithm_,
96 OnCongestionEvent(true, _, _, _)); 102 OnCongestionEvent(true, _, _, _));
103 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
104 .WillOnce(Return(100 * kDefaultTCPMSS));
105 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
97 } 106 }
98 107
99 void ExpectAckAndLoss(bool rtt_updated, 108 void ExpectAckAndLoss(bool rtt_updated,
100 QuicPacketSequenceNumber largest_observed, 109 QuicPacketSequenceNumber largest_observed,
101 QuicPacketSequenceNumber lost_packet) { 110 QuicPacketSequenceNumber lost_packet) {
102 EXPECT_CALL(*send_algorithm_, OnCongestionEvent( 111 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(
103 rtt_updated, _, ElementsAre(Pair(largest_observed, _)), 112 rtt_updated, _, ElementsAre(Pair(largest_observed, _)),
104 ElementsAre(Pair(lost_packet, _)))); 113 ElementsAre(Pair(lost_packet, _))));
114 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
115 .WillOnce(Return(100 * kDefaultTCPMSS));
116 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
105 } 117 }
106 118
107 // |packets_acked| and |packets_lost| should be in sequence number order. 119 // |packets_acked| and |packets_lost| should be in sequence number order.
108 void ExpectAcksAndLosses(bool rtt_updated, 120 void ExpectAcksAndLosses(bool rtt_updated,
109 QuicPacketSequenceNumber* packets_acked, 121 QuicPacketSequenceNumber* packets_acked,
110 size_t num_packets_acked, 122 size_t num_packets_acked,
111 QuicPacketSequenceNumber* packets_lost, 123 QuicPacketSequenceNumber* packets_lost,
112 size_t num_packets_lost) { 124 size_t num_packets_lost) {
113 vector<QuicPacketSequenceNumber> ack_vector; 125 vector<QuicPacketSequenceNumber> ack_vector;
114 for (size_t i = 0; i < num_packets_acked; ++i) { 126 for (size_t i = 0; i < num_packets_acked; ++i) {
115 ack_vector.push_back(packets_acked[i]); 127 ack_vector.push_back(packets_acked[i]);
116 } 128 }
117 vector<QuicPacketSequenceNumber> lost_vector; 129 vector<QuicPacketSequenceNumber> lost_vector;
118 for (size_t i = 0; i < num_packets_lost; ++i) { 130 for (size_t i = 0; i < num_packets_lost; ++i) {
119 lost_vector.push_back(packets_lost[i]); 131 lost_vector.push_back(packets_lost[i]);
120 } 132 }
121 EXPECT_CALL(*send_algorithm_, 133 EXPECT_CALL(*send_algorithm_,
122 OnCongestionEvent(rtt_updated, _, 134 OnCongestionEvent(rtt_updated, _,
123 Pointwise(KeyEq(), ack_vector), 135 Pointwise(KeyEq(), ack_vector),
124 Pointwise(KeyEq(), lost_vector))); 136 Pointwise(KeyEq(), lost_vector)));
137 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
138 .WillRepeatedly(Return(100 * kDefaultTCPMSS));
139 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_)).
140 Times(AnyNumber());
125 } 141 }
126 142
127 // Retransmits a packet as though it was a TLP retransmission, because TLP 143 // Retransmits a packet as though it was a TLP retransmission, because TLP
128 // leaves the |old_sequence_number| pending. 144 // leaves the |old_sequence_number| pending.
129 // TODO(ianswett): Test with transmission types besides TLP. 145 // TODO(ianswett): Test with transmission types besides TLP.
130 void RetransmitPacket(QuicPacketSequenceNumber old_sequence_number, 146 void RetransmitPacket(QuicPacketSequenceNumber old_sequence_number,
131 QuicPacketSequenceNumber new_sequence_number) { 147 QuicPacketSequenceNumber new_sequence_number) {
132 QuicSentPacketManagerPeer::MarkForRetransmission( 148 QuicSentPacketManagerPeer::MarkForRetransmission(
133 &manager_, old_sequence_number, TLP_RETRANSMISSION); 149 &manager_, old_sequence_number, TLP_RETRANSMISSION);
134 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 150 EXPECT_TRUE(manager_.HasPendingRetransmissions());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 manager_.OnPacketSent(retransmission_sequence_number, clock_.Now(), 262 manager_.OnPacketSent(retransmission_sequence_number, clock_.Now(),
247 kDefaultLength, pending.transmission_type, 263 kDefaultLength, pending.transmission_type,
248 HAS_RETRANSMITTABLE_DATA); 264 HAS_RETRANSMITTABLE_DATA);
249 } 265 }
250 266
251 QuicSentPacketManager manager_; 267 QuicSentPacketManager manager_;
252 vector<QuicPacket*> packets_; 268 vector<QuicPacket*> packets_;
253 MockClock clock_; 269 MockClock clock_;
254 QuicConnectionStats stats_; 270 QuicConnectionStats stats_;
255 MockSendAlgorithm* send_algorithm_; 271 MockSendAlgorithm* send_algorithm_;
272 scoped_ptr<MockNetworkChangeVisitor> network_change_visitor_;
256 }; 273 };
257 274
258 TEST_F(QuicSentPacketManagerTest, IsUnacked) { 275 TEST_F(QuicSentPacketManagerTest, IsUnacked) {
259 VerifyUnackedPackets(NULL, 0); 276 VerifyUnackedPackets(NULL, 0);
260 277
261 SerializedPacket serialized_packet(CreateDataPacket(1)); 278 SerializedPacket serialized_packet(CreateDataPacket(1));
262 279
263 manager_.OnSerializedPacket(serialized_packet); 280 manager_.OnSerializedPacket(serialized_packet);
264 281
265 QuicPacketSequenceNumber unacked[] = { 1 }; 282 QuicPacketSequenceNumber unacked[] = { 1 };
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // since there is no retransmittable data outstanding. 424 // since there is no retransmittable data outstanding.
408 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); 425 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
409 } 426 }
410 427
411 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckPreviousBeforeSend) { 428 TEST_F(QuicSentPacketManagerTest, RetransmitTwiceThenAckPreviousBeforeSend) {
412 SendDataPacket(1); 429 SendDataPacket(1);
413 RetransmitAndSendPacket(1, 2); 430 RetransmitAndSendPacket(1, 2);
414 431
415 // Fire the RTO, which will mark 2 for retransmission (but will not send it). 432 // Fire the RTO, which will mark 2 for retransmission (but will not send it).
416 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 433 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
434 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
435 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
436 .WillOnce(Return(2 * kDefaultTCPMSS));
417 manager_.OnRetransmissionTimeout(); 437 manager_.OnRetransmissionTimeout();
418 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 438 EXPECT_TRUE(manager_.HasPendingRetransmissions());
419 439
420 // Ack 1 but not 2, before 2 is able to be sent. 440 // Ack 1 but not 2, before 2 is able to be sent.
421 // Since 1 has been retransmitted, it has already been lost, and so the 441 // Since 1 has been retransmitted, it has already been lost, and so the
422 // send algorithm is not informed that it has been ACK'd. 442 // send algorithm is not informed that it has been ACK'd.
423 ReceivedPacketInfo received_info; 443 ReceivedPacketInfo received_info;
424 received_info.largest_observed = 1; 444 received_info.largest_observed = 1;
425 ExpectUpdatedRtt(1); 445 ExpectUpdatedRtt(1);
426 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout()); 446 EXPECT_CALL(*send_algorithm_, RevertRetransmissionTimeout());
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return( 885 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return(
866 QuicTime::Delta::Infinite())); 886 QuicTime::Delta::Infinite()));
867 EXPECT_EQ(QuicTime::Delta::Infinite(), 887 EXPECT_EQ(QuicTime::Delta::Infinite(),
868 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA)); 888 manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA));
869 889
870 // Advance the time enough to ensure all packets are RTO'd. 890 // Advance the time enough to ensure all packets are RTO'd.
871 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000)); 891 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1000));
872 892
873 // The final RTO abandons all of them. 893 // The final RTO abandons all of them.
874 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 894 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
895 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
896 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
897 .WillOnce(Return(2 * kDefaultTCPMSS));
875 manager_.OnRetransmissionTimeout(); 898 manager_.OnRetransmissionTimeout();
876 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 899 EXPECT_TRUE(manager_.HasPendingRetransmissions());
877 EXPECT_EQ(2u, stats_.tlp_count); 900 EXPECT_EQ(2u, stats_.tlp_count);
878 EXPECT_EQ(1u, stats_.rto_count); 901 EXPECT_EQ(1u, stats_.rto_count);
879 } 902 }
880 903
881 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeout) { 904 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeout) {
882 // Send 2 crypto packets and 3 data packets. 905 // Send 2 crypto packets and 3 data packets.
883 const size_t kNumSentCryptoPackets = 2; 906 const size_t kNumSentCryptoPackets = 2;
884 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) { 907 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } 1139 }
1117 1140
1118 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) { 1141 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) {
1119 // Send 100 packets and then ensure all are abandoned when the RTO fires. 1142 // Send 100 packets and then ensure all are abandoned when the RTO fires.
1120 const size_t kNumSentPackets = 100; 1143 const size_t kNumSentPackets = 100;
1121 for (size_t i = 1; i <= kNumSentPackets; ++i) { 1144 for (size_t i = 1; i <= kNumSentPackets; ++i) {
1122 SendDataPacket(i); 1145 SendDataPacket(i);
1123 } 1146 }
1124 1147
1125 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1148 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1149 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
1150 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1151 .WillOnce(Return(2 * kDefaultTCPMSS));
1126 EXPECT_FALSE(manager_.MaybeRetransmitTailLossProbe()); 1152 EXPECT_FALSE(manager_.MaybeRetransmitTailLossProbe());
1127 manager_.OnRetransmissionTimeout(); 1153 manager_.OnRetransmissionTimeout();
1128 } 1154 }
1129 1155
1130 TEST_F(QuicSentPacketManagerTest, GetTransmissionTime) { 1156 TEST_F(QuicSentPacketManagerTest, GetTransmissionTime) {
1131 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); 1157 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime());
1132 } 1158 }
1133 1159
1134 TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeCryptoHandshake) { 1160 TEST_F(QuicSentPacketManagerTest, GetTransmissionTimeCryptoHandshake) {
1135 SendCryptoPacket(1); 1161 SendCryptoPacket(1);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 SendDataPacket(3); 1233 SendDataPacket(3);
1208 SendDataPacket(4); 1234 SendDataPacket(4);
1209 1235
1210 QuicTime::Delta expected_rto_delay = QuicTime::Delta::FromMilliseconds(500); 1236 QuicTime::Delta expected_rto_delay = QuicTime::Delta::FromMilliseconds(500);
1211 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1237 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1212 .WillRepeatedly(Return(expected_rto_delay)); 1238 .WillRepeatedly(Return(expected_rto_delay));
1213 QuicTime expected_time = clock_.Now().Add(expected_rto_delay); 1239 QuicTime expected_time = clock_.Now().Add(expected_rto_delay);
1214 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime()); 1240 EXPECT_EQ(expected_time, manager_.GetRetransmissionTime());
1215 1241
1216 // Retransmit the packet by invoking the retransmission timeout. 1242 // Retransmit the packet by invoking the retransmission timeout.
1243 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
1244 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1245 .WillOnce(Return(2 * kDefaultTCPMSS));
1217 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1246 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1218 clock_.AdvanceTime(expected_rto_delay); 1247 clock_.AdvanceTime(expected_rto_delay);
1219 manager_.OnRetransmissionTimeout(); 1248 manager_.OnRetransmissionTimeout();
1220 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(&manager_)); 1249 EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetBytesInFlight(&manager_));
1221 RetransmitNextPacket(5); 1250 RetransmitNextPacket(5);
1222 RetransmitNextPacket(6); 1251 RetransmitNextPacket(6);
1223 EXPECT_EQ(2 * kDefaultLength, 1252 EXPECT_EQ(2 * kDefaultLength,
1224 QuicSentPacketManagerPeer::GetBytesInFlight(&manager_)); 1253 QuicSentPacketManagerPeer::GetBytesInFlight(&manager_));
1225 EXPECT_TRUE(manager_.HasPendingRetransmissions()); 1254 EXPECT_TRUE(manager_.HasPendingRetransmissions());
1226 1255
(...skipping 23 matching lines...) Expand all
1250 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1279 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1251 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1))); 1280 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1)));
1252 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(200); 1281 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(200);
1253 1282
1254 // If the delay is smaller than the min, ensure it exponentially backs off 1283 // If the delay is smaller than the min, ensure it exponentially backs off
1255 // from the min. 1284 // from the min.
1256 for (int i = 0; i < 5; ++i) { 1285 for (int i = 0; i < 5; ++i) {
1257 EXPECT_EQ(delay, 1286 EXPECT_EQ(delay,
1258 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1287 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1259 delay = delay.Add(delay); 1288 delay = delay.Add(delay);
1289 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
1290 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1291 .WillOnce(Return(2 * kDefaultTCPMSS));
1260 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1292 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1261 manager_.OnRetransmissionTimeout(); 1293 manager_.OnRetransmissionTimeout();
1262 RetransmitNextPacket(i + 2); 1294 RetransmitNextPacket(i + 2);
1263 } 1295 }
1264 } 1296 }
1265 1297
1266 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelayMax) { 1298 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelayMax) {
1267 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1299 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1268 .WillOnce(Return(QuicTime::Delta::FromSeconds(500))); 1300 .WillOnce(Return(QuicTime::Delta::FromSeconds(500)));
1269 1301
1270 EXPECT_EQ(QuicTime::Delta::FromSeconds(60), 1302 EXPECT_EQ(QuicTime::Delta::FromSeconds(60),
1271 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1303 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1272 } 1304 }
1273 1305
1274 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelay) { 1306 TEST_F(QuicSentPacketManagerTest, GetTransmissionDelay) {
1275 SendDataPacket(1); 1307 SendDataPacket(1);
1276 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500); 1308 QuicTime::Delta delay = QuicTime::Delta::FromMilliseconds(500);
1277 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 1309 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
1278 .WillRepeatedly(Return(delay)); 1310 .WillRepeatedly(Return(delay));
1279 1311
1280 // Delay should back off exponentially. 1312 // Delay should back off exponentially.
1281 for (int i = 0; i < 5; ++i) { 1313 for (int i = 0; i < 5; ++i) {
1282 EXPECT_EQ(delay, 1314 EXPECT_EQ(delay,
1283 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1315 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1284 delay = delay.Add(delay); 1316 delay = delay.Add(delay);
1317 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
1318 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1319 .WillOnce(Return(2 * kDefaultTCPMSS));
1285 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1320 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1286 manager_.OnRetransmissionTimeout(); 1321 manager_.OnRetransmissionTimeout();
1287 RetransmitNextPacket(i + 2); 1322 RetransmitNextPacket(i + 2);
1288 } 1323 }
1289 } 1324 }
1290 1325
1291 TEST_F(QuicSentPacketManagerTest, GetLossDelay) { 1326 TEST_F(QuicSentPacketManagerTest, GetLossDelay) {
1292 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm(); 1327 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm();
1293 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm); 1328 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm);
1294 1329
(...skipping 25 matching lines...) Expand all
1320 } 1355 }
1321 1356
1322 TEST_F(QuicSentPacketManagerTest, NegotiateTimeLossDetection) { 1357 TEST_F(QuicSentPacketManagerTest, NegotiateTimeLossDetection) {
1323 EXPECT_EQ(kNack, 1358 EXPECT_EQ(kNack,
1324 QuicSentPacketManagerPeer::GetLossAlgorithm( 1359 QuicSentPacketManagerPeer::GetLossAlgorithm(
1325 &manager_)->GetLossDetectionType()); 1360 &manager_)->GetLossDetectionType());
1326 1361
1327 QuicConfig config; 1362 QuicConfig config;
1328 QuicConfigPeer::SetReceivedLossDetection(&config, kTIME); 1363 QuicConfigPeer::SetReceivedLossDetection(&config, kTIME);
1329 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1364 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1365 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
1366 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1367 .WillOnce(Return(100 * kDefaultTCPMSS));
1330 manager_.SetFromConfig(config); 1368 manager_.SetFromConfig(config);
1331 1369
1332 EXPECT_EQ(kTime, 1370 EXPECT_EQ(kTime,
1333 QuicSentPacketManagerPeer::GetLossAlgorithm( 1371 QuicSentPacketManagerPeer::GetLossAlgorithm(
1334 &manager_)->GetLossDetectionType()); 1372 &manager_)->GetLossDetectionType());
1335 } 1373 }
1336 1374
1337 TEST_F(QuicSentPacketManagerTest, NegotiateTimeLossDetectionFromOptions) { 1375 TEST_F(QuicSentPacketManagerTest, NegotiateTimeLossDetectionFromOptions) {
1338 EXPECT_EQ(kNack, 1376 EXPECT_EQ(kNack,
1339 QuicSentPacketManagerPeer::GetLossAlgorithm( 1377 QuicSentPacketManagerPeer::GetLossAlgorithm(
1340 &manager_)->GetLossDetectionType()); 1378 &manager_)->GetLossDetectionType());
1341 1379
1342 QuicConfig config; 1380 QuicConfig config;
1343 QuicTagVector options; 1381 QuicTagVector options;
1344 options.push_back(kTIME); 1382 options.push_back(kTIME);
1345 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1383 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1346 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1384 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1385 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
1386 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1387 .WillOnce(Return(100 * kDefaultTCPMSS));
1347 manager_.SetFromConfig(config); 1388 manager_.SetFromConfig(config);
1348 1389
1349 EXPECT_EQ(kTime, 1390 EXPECT_EQ(kTime,
1350 QuicSentPacketManagerPeer::GetLossAlgorithm( 1391 QuicSentPacketManagerPeer::GetLossAlgorithm(
1351 &manager_)->GetLossDetectionType()); 1392 &manager_)->GetLossDetectionType());
1352 } 1393 }
1353 1394
1354 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) { 1395 TEST_F(QuicSentPacketManagerTest, NegotiatePacingFromOptions) {
1355 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); 1396 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
1356 EXPECT_FALSE(manager_.using_pacing()); 1397 EXPECT_FALSE(manager_.using_pacing());
1357 1398
1358 QuicConfig config; 1399 QuicConfig config;
1359 QuicTagVector options; 1400 QuicTagVector options;
1360 options.push_back(kPACE); 1401 options.push_back(kPACE);
1361 QuicConfigPeer::SetReceivedConnectionOptions(&config, options); 1402 QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
1403 EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange(_));
1404 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1405 .WillOnce(Return(100 * kDefaultTCPMSS));
1362 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 1406 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
1363 manager_.SetFromConfig(config); 1407 manager_.SetFromConfig(config);
1364 1408
1365 EXPECT_TRUE(manager_.using_pacing()); 1409 EXPECT_TRUE(manager_.using_pacing());
1366 } 1410 }
1367 1411
1368 } // namespace 1412 } // namespace
1369 } // namespace test 1413 } // namespace test
1370 } // namespace net 1414 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/test_tools/quic_sent_packet_manager_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698