diff options
Diffstat (limited to 'net/quic/quic_connection_test.cc')
-rw-r--r-- | net/quic/quic_connection_test.cc | 204 |
1 files changed, 60 insertions, 144 deletions
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc index 3a0c172..9b775f8 100644 --- a/net/quic/quic_connection_test.cc +++ b/net/quic/quic_connection_test.cc @@ -601,7 +601,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> { // Simplify tests by not sending feedback unless specifically configured. SetFeedback(NULL); EXPECT_CALL( - *send_algorithm_, TimeUntilSend(_, _)).WillRepeatedly(Return( + *send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return( QuicTime::Delta::Zero())); EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _)).Times(AnyNumber()); @@ -1023,7 +1023,8 @@ TEST_P(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) { // awaiting' is 4. The connection should then realize 1 will not be // retransmitted, and will remove it from the missing list. creator_.set_sequence_number(5); - QuicAckFrame frame = InitAckFrame(0, 4); + QuicAckFrame frame = InitAckFrame(1, 4); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _)); ProcessAckPacket(&frame); // Force an ack to be sent. @@ -1077,10 +1078,7 @@ TEST_P(QuicConnectionTest, TruncatedAck) { .WillOnce(Return(lost_packets)); EXPECT_CALL(entropy_calculator_, EntropyHash(511)).WillOnce(testing::Return(0)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(256); - EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(255); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(255); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&frame); QuicReceivedPacketManager* received_packet_manager = @@ -1095,8 +1093,7 @@ TEST_P(QuicConnectionTest, TruncatedAck) { // 192 has already been declared lost, so it doesn't register as an ack. EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(SequenceNumberSet())); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&frame); EXPECT_EQ(num_packets, received_packet_manager->peer_largest_observed_packet()); @@ -1108,14 +1105,14 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { ProcessPacket(1); // Delay sending, then queue up an ack. EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(1))); QuicConnectionPeer::SendAck(&connection_); // Process an ack with a least unacked of the received ack. // This causes an ack to be sent when TimeUntilSend returns 0. EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillRepeatedly( + TimeUntilSend(_, _, _)).WillRepeatedly( testing::Return(QuicTime::Delta::Zero())); // Skip a packet and then record an ack. creator_.set_sequence_number(2); @@ -1159,9 +1156,7 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { lost_packets.insert(1); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicPacketSequenceNumber retransmission; EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, packet_size - kQuicVersionSize, _)) @@ -1171,8 +1166,7 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { QuicAckFrame frame2 = InitAckFrame(retransmission, 1); NackPacket(original, &frame2); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(SequenceNumberSet())); ProcessAckPacket(&frame2); @@ -1262,8 +1256,7 @@ TEST_P(QuicConnectionTest, LargestObservedLower) { SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); // Start out saying the largest observed is 2. QuicAckFrame frame1 = InitAckFrame(1, 0); @@ -1409,8 +1402,7 @@ TEST_P(QuicConnectionTest, BasicSending) { SendAckPacketToPeer(); // Packet 5 EXPECT_EQ(1u, least_unacked()); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); // Peer acks up to packet 3. QuicAckFrame frame = InitAckFrame(3, 0); @@ -1421,8 +1413,7 @@ TEST_P(QuicConnectionTest, BasicSending) { // ack for 4. EXPECT_EQ(4u, least_unacked()); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); // Peer acks up to packet 4, the last packet. QuicAckFrame frame2 = InitAckFrame(6, 0); @@ -1446,9 +1437,6 @@ TEST_P(QuicConnectionTest, BasicSending) { } TEST_P(QuicConnectionTest, FECSending) { - if (version() < QUIC_VERSION_15) { - return; - } // All packets carry version info till version is negotiated. size_t payload_length; connection_.options()->max_packet_length = @@ -1468,9 +1456,6 @@ TEST_P(QuicConnectionTest, FECSending) { } TEST_P(QuicConnectionTest, FECQueueing) { - if (version() < QUIC_VERSION_15) { - return; - } // All packets carry version info till version is negotiated. size_t payload_length; connection_.options()->max_packet_length = @@ -1490,9 +1475,6 @@ TEST_P(QuicConnectionTest, FECQueueing) { } TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { - if (version() < QUIC_VERSION_15) { - return; - } connection_.options()->max_packets_per_fec_group = 1; // 1 Data and 1 FEC packet. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(2); @@ -1510,9 +1492,6 @@ TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { } TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { - if (version() < QUIC_VERSION_15) { - return; - } EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); connection_.options()->max_packets_per_fec_group = 1; @@ -1528,9 +1507,7 @@ TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was // received, it would cause the covered packet to be acked as well. NackPacket(1, &ack_fec); - - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&ack_fec); clock_.AdvanceTime(DefaultRetransmissionTime()); @@ -1542,9 +1519,6 @@ TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { } TEST_P(QuicConnectionTest, AbandonAllFEC) { - if (version() < QUIC_VERSION_15) { - return; - } EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); connection_.options()->max_packets_per_fec_group = 1; @@ -1567,10 +1541,7 @@ TEST_P(QuicConnectionTest, AbandonAllFEC) { lost_packets.insert(2); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); - EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&ack_fec); clock_.AdvanceTime(DefaultRetransmissionTime().Subtract( @@ -1809,7 +1780,7 @@ TEST_P(QuicConnectionTest, OnCanWrite) { &TestConnection::SendStreamData5)))); EXPECT_CALL(visitor_, HasPendingWrites()).WillOnce(Return(true)); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillRepeatedly( + TimeUntilSend(_, _, _)).WillRepeatedly( testing::Return(QuicTime::Delta::Zero())); connection_.OnCanWrite(); @@ -1833,8 +1804,7 @@ TEST_P(QuicConnectionTest, RetransmitOnNack) { EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); // Don't lose a packet on an ack, and nothing is retransmitted. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame ack_one = InitAckFrame(1, 0); ProcessAckPacket(&ack_one); @@ -1845,10 +1815,7 @@ TEST_P(QuicConnectionTest, RetransmitOnNack) { lost_packets.insert(2); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)); - EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, second_packet_size - kQuicVersionSize, _)). Times(1); @@ -1873,10 +1840,7 @@ TEST_P(QuicConnectionTest, DiscardRetransmit) { lost_packets.insert(2); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); - EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&nack_two); EXPECT_EQ(1u, connection_.NumQueuedPackets()); @@ -1914,9 +1878,7 @@ TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { lost_packets.insert(1); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, packet_size - kQuicVersionSize, _)); ProcessAckPacket(&frame); @@ -1989,8 +1951,8 @@ TEST_P(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) { // Ack the sent packet before the callback returns, which happens in // rare circumstances with write blocked sockets. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); QuicAckFrame ack = InitAckFrame(1, 0); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&ack); connection_.OnPacketSent(WriteResult(WRITE_STATUS_OK, 0)); @@ -2037,10 +1999,7 @@ TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) { // the retransmission rate in the case of burst losses. EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(15, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(14); - EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(14); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(14); ProcessAckPacket(&nack); } @@ -2061,23 +2020,19 @@ TEST_P(QuicConnectionTest, MultipleAcks) { EXPECT_EQ(6u, last_packet); // Client will ack packets 1, 2, [!3], 4, 5. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(4); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame frame1 = InitAckFrame(5, 0); NackPacket(3, &frame1); EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); ProcessAckPacket(&frame1); // Now the client implicitly acks 3, and explicitly acks 6. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame frame2 = InitAckFrame(6, 0); ProcessAckPacket(&frame2); } TEST_P(QuicConnectionTest, DontLatchUnackedPacket) { - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); // Packet 1; // From now on, we send acks, so the send algorithm won't mark them pending. ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)) @@ -2085,6 +2040,7 @@ TEST_P(QuicConnectionTest, DontLatchUnackedPacket) { SendAckPacketToPeer(); // Packet 2 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame frame = InitAckFrame(1, 0); ProcessAckPacket(&frame); @@ -2092,7 +2048,7 @@ TEST_P(QuicConnectionTest, DontLatchUnackedPacket) { // waiting for a potential ack for 2. EXPECT_EQ(2u, outgoing_ack()->sent_info.least_unacked); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); frame = InitAckFrame(2, 0); ProcessAckPacket(&frame); EXPECT_EQ(3u, outgoing_ack()->sent_info.least_unacked); @@ -2107,7 +2063,7 @@ TEST_P(QuicConnectionTest, DontLatchUnackedPacket) { EXPECT_EQ(3u, least_unacked()); // Ack the ack, which updates the rtt and raises the least unacked. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); frame = InitAckFrame(3, 0); ProcessAckPacket(&frame); @@ -2127,8 +2083,7 @@ TEST_P(QuicConnectionTest, DontLatchUnackedPacket) { SendStreamDataToPeer(1, "bar", 6, false, NULL); // Packet 6 SendStreamDataToPeer(1, "bar", 9, false, NULL); // Packet 7 - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); frame = InitAckFrame(7, 0); NackPacket(5, &frame); NackPacket(6, &frame); @@ -2335,7 +2290,7 @@ TEST_P(QuicConnectionTest, SendHandshakeMessages) { // Attempt to send a handshake message and have the socket block. EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillRepeatedly( + TimeUntilSend(_, _, _)).WillRepeatedly( testing::Return(QuicTime::Delta::Zero())); BlockOnNextWrite(); connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); @@ -2391,9 +2346,7 @@ TEST_P(QuicConnectionTest, RetransmitPacketsWithInitialEncryption) { connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); SendStreamDataToPeer(2, "bar", 0, !kFin, NULL); - EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(1); connection_.RetransmitUnackedPackets(INITIAL_ENCRYPTION_ONLY); } @@ -2490,10 +2443,7 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) { lost_packets.insert(rto_sequence_number); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketLost(rto_sequence_number, _)).Times(1); - EXPECT_CALL(*send_algorithm_, - OnPacketAbandoned(rto_sequence_number, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicPacketSequenceNumber nack_sequence_number = 0; // Ack packets might generate some other packets, which are not // retransmissions. (More ack packets). @@ -2542,8 +2492,7 @@ TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) { // Advance the time right before the RTO, then receive an ack for the first // packet to delay the RTO. clock_.AdvanceTime(DefaultRetransmissionTime()); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame ack = InitAckFrame(1, 0); ProcessAckPacket(&ack); EXPECT_TRUE(retransmission_alarm->IsSet()); @@ -2681,8 +2630,7 @@ TEST_P(QuicConnectionTest, PingAfterSend) { clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); QuicAckFrame frame = InitAckFrame(1, 0); EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&frame); EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), @@ -2748,7 +2696,7 @@ TEST_P(QuicConnectionTest, SendScheduler) { // Test that if we send a packet without delay, it is not queued. QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::Zero())); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)); connection_.SendPacket( @@ -2760,7 +2708,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelay) { // Test that if we send a packet with a delay, it ends up queued. QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(1))); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 1, _, _)).Times(0); connection_.SendPacket( @@ -2772,7 +2720,7 @@ TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) { QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); BlockOnNextWrite(); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::Zero())); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 1, _, _)).Times(0); connection_.SendPacket( @@ -2784,7 +2732,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenSend) { // Test that if we send a packet with a delay, it ends up queued. QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(1))); connection_.SendPacket( ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); @@ -2793,7 +2741,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenSend) { // Advance the clock to fire the alarm, and configure the scheduler // to permit the packet to be sent. EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillRepeatedly( + TimeUntilSend(_, _, _)).WillRepeatedly( testing::Return(QuicTime::Delta::Zero())); clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)); @@ -2802,7 +2750,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenSend) { } TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) { - EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) + EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 1, _, _)); connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); @@ -2813,7 +2761,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) { // sent packet manager, but not yet serialized. EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(1))); connection_.GetRetransmissionAlarm()->Fire(); EXPECT_EQ(0u, connection_.NumQueuedPackets()); @@ -2821,7 +2769,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) { // Advance the clock to fire the alarm, and configure the scheduler // to permit the packet to be sent. EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).Times(3). + TimeUntilSend(_, _, _)).Times(3). WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); // Ensure the scheduler is notified this is a retransmit. @@ -2834,7 +2782,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) { TEST_P(QuicConnectionTest, SendSchedulerDelayAndQueue) { QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(1))); connection_.SendPacket( ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); @@ -2851,7 +2799,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) { EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(10))); connection_.SendPacket( ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); @@ -2861,7 +2809,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) { // retransmit 3. The far end should stop waiting for it. QuicAckFrame frame = InitAckFrame(0, 1); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillRepeatedly( + TimeUntilSend(_, _, _)).WillRepeatedly( testing::Return(QuicTime::Delta::Zero())); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)); @@ -2876,7 +2824,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) { EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(10))); connection_.SendPacket( ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); @@ -2886,7 +2834,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) { // retransmit 3. The far end should stop waiting for it. QuicAckFrame frame = InitAckFrame(0, 1); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(1))); ProcessAckPacket(&frame); @@ -2898,7 +2846,7 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenOnCanWrite) { // new data if the send algorithm said not to. QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(10))); connection_.SendPacket( ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); @@ -2920,7 +2868,7 @@ TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { // Queue the first packet. EXPECT_CALL(*send_algorithm_, - TimeUntilSend(_, _)).WillOnce( + TimeUntilSend(_, _, _)).WillOnce( testing::Return(QuicTime::Delta::FromMicroseconds(10))); const string payload(payload_length, 'a'); EXPECT_EQ(0u, @@ -3078,10 +3026,7 @@ TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { lost_packets.insert(1); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&ack); EXPECT_EQ(1u, writer_->frame_count()); EXPECT_EQ(1u, writer_->stream_frames().size()); @@ -3093,8 +3038,7 @@ TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { NackPacket(1, &ack); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(SequenceNumberSet())); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&ack); // Check that no packet is sent and the ack alarm isn't set. @@ -3126,10 +3070,9 @@ TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) { EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); } -TEST_P(QuicConnectionTest, NoAckForClose) { +TEST_P(QuicConnectionTest, NoAckSentForClose) { EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); ProcessPacket(1); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(0); EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(0); ProcessClosePacket(2, 0); @@ -3542,7 +3485,6 @@ TEST_P(QuicConnectionTest, CheckSendStats) { // 2 retransmissions due to rto, 1 due to explicit nack. EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(3); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(1); // Retransmit due to RTO. clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); @@ -3557,9 +3499,7 @@ TEST_P(QuicConnectionTest, CheckSendStats) { lost_packets.insert(3); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)).Times(1); - EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); EXPECT_CALL(visitor_, OnCanWrite()).Times(2); EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); ProcessAckPacket(&nack_three); @@ -3724,8 +3664,7 @@ TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) { connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); // Process an ACK from the server which should trigger the callback. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame frame = InitAckFrame(1, 0); ProcessAckPacket(&frame); } @@ -3737,9 +3676,6 @@ TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) { scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _, _)).Times(0); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(2); - // Send some data, which will register the delegate to be notified. This will // not be ACKed and so the delegate should never be called. connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); @@ -3756,8 +3692,7 @@ TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) { lost_packets.insert(1); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnPacketLost(1, _)); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(1, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); ProcessAckPacket(&frame); } @@ -3781,10 +3716,7 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { lost_packets.insert(2); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3); - EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)); ProcessAckPacket(&frame); @@ -3792,8 +3724,7 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) { // trigger the callback. EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillRepeatedly(Return(SequenceNumberSet())); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame second_ack_frame = InitAckFrame(5, 0); ProcessAckPacket(&second_ack_frame); } @@ -3827,14 +3758,13 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) { // Ack the original packet. EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); EXPECT_CALL(*delegate, OnAckNotification(1, _, 1, _, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame ack_frame = InitAckFrame(1, 0); ProcessAckPacket(&ack_frame); // Delegate is not notified again when the retransmit is acked. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame second_ack_frame = InitAckFrame(2, 0); ProcessAckPacket(&second_ack_frame); } @@ -3861,14 +3791,9 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackForAckOfNackedPacket) { SequenceNumberSet lost_packets; lost_packets.insert(2); EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(3, _)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(lost_packets)); - EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)); - EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)); ProcessAckPacket(&frame); @@ -3882,18 +3807,14 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackForAckOfNackedPacket) { // Verify that the delegate is not notified again when the // retransmit is acked. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(5, _)); EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) .WillOnce(Return(no_lost_packets)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame third_ack_frame = InitAckFrame(5, 0); ProcessAckPacket(&third_ack_frame); } TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) { - if (version() < QUIC_VERSION_15) { - return; - } EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); // Create a delegate which we expect to be called. @@ -3907,8 +3828,7 @@ TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) { // Process an ACK from the server with a revived packet, which should trigger // the callback. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); QuicAckFrame frame = InitAckFrame(2, 0); NackPacket(1, &frame); frame.received_info.revived_packets.insert(1); @@ -3918,9 +3838,6 @@ TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) { } TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { - if (version() < QUIC_VERSION_15) { - return; - } EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); EXPECT_CALL(visitor_, OnCanWrite()); @@ -3929,8 +3846,7 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) { EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _, _)).Times(1); // Expect ACKs for 1 packet. - EXPECT_CALL(*send_algorithm_, OnRttUpdated(_)); - EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); // Send one packet, and register to be notified on ACK. connection_.SendStreamDataWithString(1, "foo", 0, !kFin, delegate.get()); |