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

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

Issue 1785853002: Remove is_fec_packet from TransmissionInfo and SerializedPacket. No functional change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116411121
Patch Set: Merge from 116555910 Created 4 years, 9 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_unacked_packet_map.cc » ('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"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 SerializedPacket packet(kDefaultPathId, packet_number, 199 SerializedPacket packet(kDefaultPathId, packet_number,
200 PACKET_6BYTE_PACKET_NUMBER, nullptr, kDefaultLength, 200 PACKET_6BYTE_PACKET_NUMBER, nullptr, kDefaultLength,
201 0u, false, false); 201 0u, false, false);
202 if (retransmittable) { 202 if (retransmittable) {
203 packet.retransmittable_frames.push_back( 203 packet.retransmittable_frames.push_back(
204 QuicFrame(new QuicStreamFrame(kStreamId, false, 0, StringPiece()))); 204 QuicFrame(new QuicStreamFrame(kStreamId, false, 0, StringPiece())));
205 } 205 }
206 return packet; 206 return packet;
207 } 207 }
208 208
209 SerializedPacket CreateFecPacket(QuicPacketNumber packet_number) {
210 SerializedPacket serialized(kDefaultPathId, packet_number,
211 PACKET_6BYTE_PACKET_NUMBER, nullptr,
212 kDefaultLength, 0u, false, false);
213 serialized.is_fec_packet = true;
214 return serialized;
215 }
216
217 void SendDataPacket(QuicPacketNumber packet_number) { 209 void SendDataPacket(QuicPacketNumber packet_number) {
218 EXPECT_CALL(*send_algorithm_, 210 EXPECT_CALL(*send_algorithm_,
219 OnPacketSent(_, BytesInFlight(), packet_number, _, _)) 211 OnPacketSent(_, BytesInFlight(), packet_number, _, _))
220 .Times(1) 212 .Times(1)
221 .WillOnce(Return(true)); 213 .WillOnce(Return(true));
222 SerializedPacket packet(CreateDataPacket(packet_number)); 214 SerializedPacket packet(CreateDataPacket(packet_number));
223 manager_.OnPacketSent(&packet, 0, clock_.Now(), NOT_RETRANSMISSION, 215 manager_.OnPacketSent(&packet, 0, clock_.Now(), NOT_RETRANSMISSION,
224 HAS_RETRANSMITTABLE_DATA); 216 HAS_RETRANSMITTABLE_DATA);
225 } 217 }
226 218
227 void SendCryptoPacket(QuicPacketNumber packet_number) { 219 void SendCryptoPacket(QuicPacketNumber packet_number) {
228 EXPECT_CALL(*send_algorithm_, 220 EXPECT_CALL(*send_algorithm_,
229 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength, 221 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength,
230 HAS_RETRANSMITTABLE_DATA)) 222 HAS_RETRANSMITTABLE_DATA))
231 .Times(1) 223 .Times(1)
232 .WillOnce(Return(true)); 224 .WillOnce(Return(true));
233 SerializedPacket packet(CreateDataPacket(packet_number)); 225 SerializedPacket packet(CreateDataPacket(packet_number));
234 packet.retransmittable_frames.push_back( 226 packet.retransmittable_frames.push_back(
235 QuicFrame(new QuicStreamFrame(1, false, 0, StringPiece()))); 227 QuicFrame(new QuicStreamFrame(1, false, 0, StringPiece())));
236 packet.has_crypto_handshake = IS_HANDSHAKE; 228 packet.has_crypto_handshake = IS_HANDSHAKE;
237 manager_.OnPacketSent(&packet, 0, clock_.Now(), NOT_RETRANSMISSION, 229 manager_.OnPacketSent(&packet, 0, clock_.Now(), NOT_RETRANSMISSION,
238 HAS_RETRANSMITTABLE_DATA); 230 HAS_RETRANSMITTABLE_DATA);
239 } 231 }
240 232
241 void SendFecPacket(QuicPacketNumber packet_number) {
242 EXPECT_CALL(*send_algorithm_,
243 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength,
244 HAS_RETRANSMITTABLE_DATA))
245 .Times(1)
246 .WillOnce(Return(true));
247 SerializedPacket packet(CreateFecPacket(packet_number));
248 manager_.OnPacketSent(&packet, 0, clock_.Now(), NOT_RETRANSMISSION,
249 NO_RETRANSMITTABLE_DATA);
250 }
251
252 void SendAckPacket(QuicPacketNumber packet_number) { 233 void SendAckPacket(QuicPacketNumber packet_number) {
253 EXPECT_CALL(*send_algorithm_, 234 EXPECT_CALL(*send_algorithm_,
254 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength, 235 OnPacketSent(_, BytesInFlight(), packet_number, kDefaultLength,
255 NO_RETRANSMITTABLE_DATA)) 236 NO_RETRANSMITTABLE_DATA))
256 .Times(1) 237 .Times(1)
257 .WillOnce(Return(false)); 238 .WillOnce(Return(false));
258 SerializedPacket packet(CreatePacket(packet_number, false)); 239 SerializedPacket packet(CreatePacket(packet_number, false));
259 manager_.OnPacketSent(&packet, 0, clock_.Now(), NOT_RETRANSMISSION, 240 manager_.OnPacketSent(&packet, 0, clock_.Now(), NOT_RETRANSMISSION,
260 NO_RETRANSMITTABLE_DATA); 241 NO_RETRANSMITTABLE_DATA);
261 } 242 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 522
542 TEST_F(QuicSentPacketManagerTest, GetLeastUnacked) { 523 TEST_F(QuicSentPacketManagerTest, GetLeastUnacked) {
543 EXPECT_EQ(1u, manager_.GetLeastUnacked()); 524 EXPECT_EQ(1u, manager_.GetLeastUnacked());
544 } 525 }
545 526
546 TEST_F(QuicSentPacketManagerTest, GetLeastUnackedUnacked) { 527 TEST_F(QuicSentPacketManagerTest, GetLeastUnackedUnacked) {
547 SendDataPacket(1); 528 SendDataPacket(1);
548 EXPECT_EQ(1u, manager_.GetLeastUnacked()); 529 EXPECT_EQ(1u, manager_.GetLeastUnacked());
549 } 530 }
550 531
551 TEST_F(QuicSentPacketManagerTest, GetLeastUnackedUnackedFec) {
552 SendFecPacket(1);
553 EXPECT_EQ(1u, manager_.GetLeastUnacked());
554 }
555
556 TEST_F(QuicSentPacketManagerTest, GetLeastUnackedAndDiscard) {
557 VerifyUnackedPackets(nullptr, 0);
558
559 SendFecPacket(1);
560 EXPECT_EQ(1u, manager_.GetLeastUnacked());
561
562 SendFecPacket(2);
563 EXPECT_EQ(1u, manager_.GetLeastUnacked());
564
565 SendFecPacket(3);
566 EXPECT_EQ(1u, manager_.GetLeastUnacked());
567
568 QuicPacketNumber unacked[] = {1, 2, 3};
569 VerifyUnackedPackets(unacked, arraysize(unacked));
570 VerifyRetransmittablePackets(nullptr, 0);
571
572 // Ack 2, so there's an rtt update.
573 ExpectAck(2);
574 QuicAckFrame ack_frame;
575 ack_frame.largest_observed = 2;
576 ack_frame.missing_packets.Add(1);
577 manager_.OnIncomingAck(ack_frame, clock_.Now());
578
579 EXPECT_EQ(1u, manager_.GetLeastUnacked());
580 }
581
582 TEST_F(QuicSentPacketManagerTest, GetSentTime) {
583 VerifyUnackedPackets(nullptr, 0);
584
585 QuicTime sent_time = clock_.Now();
586 SendFecPacket(1);
587 QuicTime sent_time2 = clock_.Now();
588 SendFecPacket(2);
589 QuicPacketNumber unacked[] = {1, 2};
590 VerifyUnackedPackets(unacked, arraysize(unacked));
591 VerifyRetransmittablePackets(nullptr, 0);
592
593 EXPECT_TRUE(manager_.HasUnackedPackets());
594 EXPECT_EQ(sent_time, QuicSentPacketManagerPeer::GetSentTime(&manager_, 1));
595 EXPECT_EQ(sent_time2, QuicSentPacketManagerPeer::GetSentTime(&manager_, 2));
596 }
597
598 TEST_F(QuicSentPacketManagerTest, AckAckAndUpdateRtt) { 532 TEST_F(QuicSentPacketManagerTest, AckAckAndUpdateRtt) {
599 SendDataPacket(1); 533 SendDataPacket(1);
600 SendAckPacket(2); 534 SendAckPacket(2);
601 535
602 // Now ack the ack and expect an RTT update. 536 // Now ack the ack and expect an RTT update.
603 QuicAckFrame ack_frame; 537 QuicAckFrame ack_frame;
604 ack_frame.largest_observed = 2; 538 ack_frame.largest_observed = 2;
605 ack_frame.ack_delay_time = QuicTime::Delta::FromMilliseconds(5); 539 ack_frame.ack_delay_time = QuicTime::Delta::FromMilliseconds(5);
606 540
607 ExpectAck(1); 541 ExpectAck(1);
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 manager_.OnConnectionMigration(PORT_CHANGE); 1634 manager_.OnConnectionMigration(PORT_CHANGE);
1701 1635
1702 EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt_us()); 1636 EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt_us());
1703 EXPECT_EQ(1u, manager_.consecutive_rto_count()); 1637 EXPECT_EQ(1u, manager_.consecutive_rto_count());
1704 EXPECT_EQ(2u, manager_.consecutive_tlp_count()); 1638 EXPECT_EQ(2u, manager_.consecutive_tlp_count());
1705 } 1639 }
1706 1640
1707 } // namespace 1641 } // namespace
1708 } // namespace test 1642 } // namespace test
1709 } // namespace net 1643 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_unacked_packet_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698