| Index: net/quic/quic_connection_test.cc
|
| diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
|
| index e57e7aea192ca469dd7c518e30e26b40565578b8..147d8bc7cd100b441aebadeae17637fd884e7b9c 100644
|
| --- a/net/quic/quic_connection_test.cc
|
| +++ b/net/quic/quic_connection_test.cc
|
| @@ -389,6 +389,15 @@ class TestConnection : public QuicConnection {
|
| QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
|
| }
|
|
|
| + QuicConsumedData SendStreamData(QuicStreamId id,
|
| + StringPiece data,
|
| + QuicStreamOffset offset,
|
| + bool fin) {
|
| + struct iovec iov = {const_cast<char*>(data.data()),
|
| + static_cast<size_t>(data.size())};
|
| + return SendvStreamData(id, &iov, 1, offset, fin);
|
| + }
|
| +
|
| QuicConsumedData SendStreamData3() {
|
| return SendStreamData(kStreamId3, "food", 0, !kFin);
|
| }
|
| @@ -403,7 +412,11 @@ class TestConnection : public QuicConnection {
|
| // split needlessly across packet boundaries). As a result, we have separate
|
| // tests for some cases for this stream.
|
| QuicConsumedData SendCryptoStreamData() {
|
| - return SendStreamData(kCryptoStreamId, "chlo", 0, !kFin);
|
| + this->Flush();
|
| + QuicConsumedData consumed =
|
| + SendStreamData(kCryptoStreamId, "chlo", 0, !kFin);
|
| + this->Flush();
|
| + return consumed;
|
| }
|
|
|
| bool is_server() {
|
| @@ -467,13 +480,15 @@ class QuicConnectionTest : public ::testing::Test {
|
| QuicTime::Delta::Zero()));
|
| EXPECT_CALL(*receive_algorithm_,
|
| RecordIncomingPacket(_, _, _, _)).Times(AnyNumber());
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(AnyNumber());
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(AnyNumber());
|
| EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
|
| Return(QuicTime::Delta::Zero()));
|
| EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(Return(
|
| QuicBandwidth::FromKBitsPerSecond(100)));
|
| EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillRepeatedly(Return(
|
| QuicTime::Delta::FromMilliseconds(100)));
|
| + ON_CALL(*send_algorithm_, SentPacket(_, _, _, _, _))
|
| + .WillByDefault(Return(true));
|
| // TODO(rch): remove this.
|
| QuicConnection::g_acks_do_not_instigate_acks = true;
|
| }
|
| @@ -630,21 +645,21 @@ class QuicConnectionTest : public ::testing::Test {
|
| QuicStreamOffset offset, bool fin,
|
| QuicPacketSequenceNumber* last_packet) {
|
| QuicByteCount packet_size;
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).WillOnce(
|
| - SaveArg<2>(&packet_size));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _))
|
| + .WillOnce(DoAll(SaveArg<2>(&packet_size), Return(true)));
|
| connection_.SendStreamData(id, data, offset, fin);
|
| if (last_packet != NULL) {
|
| *last_packet =
|
| QuicConnectionPeer::GetPacketCreator(&connection_)->sequence_number();
|
| }
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(AnyNumber());
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(AnyNumber());
|
| return packet_size;
|
| }
|
|
|
| void SendAckPacketToPeer() {
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(1);
|
| connection_.SendAck();
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(AnyNumber());
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(AnyNumber());
|
| }
|
|
|
| QuicPacketEntropyHash ProcessAckPacket(QuicAckFrame* frame,
|
| @@ -741,6 +756,8 @@ class QuicConnectionTest : public ::testing::Test {
|
| };
|
|
|
| TEST_F(QuicConnectionTest, PacketsInOrder) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessPacket(1);
|
| EXPECT_EQ(1u, outgoing_ack()->received_info.largest_observed);
|
| EXPECT_EQ(0u, outgoing_ack()->received_info.missing_packets.size());
|
| @@ -755,6 +772,8 @@ TEST_F(QuicConnectionTest, PacketsInOrder) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, PacketsRejected) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessPacket(1);
|
| EXPECT_EQ(1u, outgoing_ack()->received_info.largest_observed);
|
| EXPECT_EQ(0u, outgoing_ack()->received_info.missing_packets.size());
|
| @@ -767,6 +786,8 @@ TEST_F(QuicConnectionTest, PacketsRejected) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, PacketsOutOfOrder) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessPacket(3);
|
| EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed);
|
| EXPECT_TRUE(IsMissing(2));
|
| @@ -784,6 +805,8 @@ TEST_F(QuicConnectionTest, PacketsOutOfOrder) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, DuplicatePacket) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessPacket(3);
|
| EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed);
|
| EXPECT_TRUE(IsMissing(2));
|
| @@ -798,6 +821,8 @@ TEST_F(QuicConnectionTest, DuplicatePacket) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessPacket(3);
|
| EXPECT_EQ(3u, outgoing_ack()->received_info.largest_observed);
|
| EXPECT_TRUE(IsMissing(2));
|
| @@ -833,6 +858,7 @@ TEST_F(QuicConnectionTest, RejectPacketTooFarOut) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, TruncatedAck) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(visitor_, OnAck(_)).Times(testing::AnyNumber());
|
| EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(2);
|
| EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1);
|
| @@ -861,6 +887,8 @@ TEST_F(QuicConnectionTest, TruncatedAck) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessPacket(1);
|
| // Delay sending, then queue up an ack.
|
| EXPECT_CALL(*send_algorithm_,
|
| @@ -880,11 +908,13 @@ TEST_F(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, AckReceiptCausesAckSend) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1);
|
| QuicPacketSequenceNumber largest_observed;
|
| QuicByteCount packet_size;
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION))
|
| - .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size)));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _))
|
| + .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size),
|
| + Return(true)));
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(1, _)).Times(1);
|
| connection_.SendStreamData(1, "foo", 0, !kFin);
|
| QuicAckFrame frame(1, QuicTime::Zero(), largest_observed);
|
| @@ -895,13 +925,13 @@ TEST_F(QuicConnectionTest, AckReceiptCausesAckSend) {
|
| ProcessAckPacket(&frame, true);
|
| // Third nack should retransmit the largest observed packet.
|
| EXPECT_CALL(*send_algorithm_, SentPacket(_, _, packet_size - kQuicVersionSize,
|
| - IS_RETRANSMISSION));
|
| + IS_RETRANSMISSION, _));
|
| ProcessAckPacket(&frame, true);
|
|
|
| // Now if the peer sends an ack which still reports the retransmitted packet
|
| // as missing, then that will count as a packet which instigates an ack.
|
| ProcessAckPacket(&frame, true);
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _));
|
| ProcessAckPacket(&frame, true);
|
|
|
| // But an ack with no new missing packest will not send an ack.
|
| @@ -911,6 +941,8 @@ TEST_F(QuicConnectionTest, AckReceiptCausesAckSend) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, LeastUnackedLower) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| SendStreamDataToPeer(1, "foo", 0, !kFin, NULL);
|
| SendStreamDataToPeer(1, "bar", 3, !kFin, NULL);
|
| SendStreamDataToPeer(1, "eep", 6, !kFin, NULL);
|
| @@ -930,12 +962,14 @@ TEST_F(QuicConnectionTest, LeastUnackedLower) {
|
| // Now claim it's one, but set the ordering so it was sent "after" the first
|
| // one. This should cause a connection error.
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| creator_.set_sequence_number(7);
|
| ProcessAckPacket(&frame2, false);
|
| }
|
|
|
| TEST_F(QuicConnectionTest, LargestObservedLower) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| SendStreamDataToPeer(1, "foo", 0, !kFin, NULL);
|
| SendStreamDataToPeer(1, "bar", 3, !kFin, NULL);
|
| SendStreamDataToPeer(1, "eep", 6, !kFin, NULL);
|
| @@ -955,8 +989,9 @@ TEST_F(QuicConnectionTest, LargestObservedLower) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, LeastUnackedGreaterThanPacketSequenceNumber) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| // Create an ack with least_unacked is 2 in packet number 1.
|
| creator_.set_sequence_number(0);
|
| QuicAckFrame frame(0, QuicTime::Zero(), 2);
|
| @@ -965,12 +1000,14 @@ TEST_F(QuicConnectionTest, LeastUnackedGreaterThanPacketSequenceNumber) {
|
|
|
| TEST_F(QuicConnectionTest,
|
| NackSequenceNumberGreaterThanLargestReceived) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| SendStreamDataToPeer(1, "foo", 0, !kFin, NULL);
|
| SendStreamDataToPeer(1, "bar", 3, !kFin, NULL);
|
| SendStreamDataToPeer(1, "eep", 6, !kFin, NULL);
|
|
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| QuicAckFrame frame(0, QuicTime::Zero(), 1);
|
| frame.received_info.missing_packets.insert(3);
|
| ProcessAckPacket(&frame, false);
|
| @@ -979,12 +1016,14 @@ TEST_F(QuicConnectionTest,
|
| TEST_F(QuicConnectionTest, AckUnsentData) {
|
| // Ack a packet which has not been sent.
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_INVALID_ACK_DATA, false));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| QuicAckFrame frame(1, QuicTime::Zero(), 0);
|
| ProcessAckPacket(&frame, false);
|
| }
|
|
|
| TEST_F(QuicConnectionTest, AckAll) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessPacket(1);
|
|
|
| creator_.set_sequence_number(1);
|
| @@ -1093,6 +1132,7 @@ TEST_F(QuicConnectionTest, SendingDifferentSequenceNumberLengthsUnackedDelta) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, BasicSending) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(6);
|
| QuicPacketSequenceNumber last_packet;
|
| SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
|
| @@ -1162,7 +1202,7 @@ TEST_F(QuicConnectionTest, FECSending) {
|
| connection_.options()->max_packets_per_fec_group = 2;
|
|
|
| // Send 4 data packets and 2 FEC packets.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(6);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(6);
|
| // The first stream frame will consume 2 fewer bytes than the other three.
|
| const string payload(payload_length * 4 - 6, 'a');
|
| connection_.SendStreamData(1, payload, 0, !kFin);
|
| @@ -1192,7 +1232,7 @@ TEST_F(QuicConnectionTest, FECQueueing) {
|
| TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) {
|
| connection_.options()->max_packets_per_fec_group = 1;
|
| // 1 Data and 1 FEC packet.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(2);
|
| connection_.SendStreamData(1, "foo", 0, !kFin);
|
|
|
| // Larger timeout for FEC bytes to expire.
|
| @@ -1201,7 +1241,7 @@ TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) {
|
| clock_.AdvanceTime(retransmission_time);
|
|
|
| // Send only data packet.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(1);
|
| // Abandon both FEC and data packet.
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(2);
|
|
|
| @@ -1209,12 +1249,13 @@ TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, DontAbandonAckedFEC) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| connection_.options()->max_packets_per_fec_group = 1;
|
| const QuicPacketSequenceNumber sequence_number =
|
| QuicConnectionPeer::GetPacketCreator(&connection_)->sequence_number() + 1;
|
|
|
| // 1 Data and 1 FEC packet.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(2);
|
| connection_.SendStreamData(1, "foo", 0, !kFin);
|
|
|
| QuicAckFrame ack_fec(2, QuicTime::Zero(), 1);
|
| @@ -1235,7 +1276,7 @@ TEST_F(QuicConnectionTest, DontAbandonAckedFEC) {
|
| // Abandon only data packet, FEC has been acked.
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(sequence_number, _)).Times(1);
|
| // Send only data packet.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(1);
|
| connection_.OnRetransmissionTimeout();
|
| }
|
|
|
| @@ -1256,7 +1297,7 @@ TEST_F(QuicConnectionTest, FramePacking) {
|
| // Unblock the connection.
|
| connection_.GetSendAlarm()->Cancel();
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, NOT_RETRANSMISSION))
|
| + SentPacket(_, _, _, NOT_RETRANSMISSION, _))
|
| .Times(1);
|
| connection_.OnCanWrite();
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| @@ -1289,7 +1330,7 @@ TEST_F(QuicConnectionTest, FramePackingNonCryptoThenCrypto) {
|
| // Unblock the connection.
|
| connection_.GetSendAlarm()->Cancel();
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, NOT_RETRANSMISSION))
|
| + SentPacket(_, _, _, NOT_RETRANSMISSION, _))
|
| .Times(2);
|
| connection_.OnCanWrite();
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| @@ -1320,7 +1361,7 @@ TEST_F(QuicConnectionTest, FramePackingCryptoThenNonCrypto) {
|
| // Unblock the connection.
|
| connection_.GetSendAlarm()->Cancel();
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, NOT_RETRANSMISSION))
|
| + SentPacket(_, _, _, NOT_RETRANSMISSION, _))
|
| .Times(3);
|
| connection_.OnCanWrite();
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| @@ -1352,7 +1393,7 @@ TEST_F(QuicConnectionTest, FramePackingFEC) {
|
| // Unblock the connection.
|
| connection_.GetSendAlarm()->Cancel();
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, NOT_RETRANSMISSION)).Times(2);
|
| + SentPacket(_, _, _, NOT_RETRANSMISSION, _)).Times(2);
|
| connection_.OnCanWrite();
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| EXPECT_FALSE(connection_.HasQueuedData());
|
| @@ -1362,6 +1403,76 @@ TEST_F(QuicConnectionTest, FramePackingFEC) {
|
| EXPECT_EQ(0u, helper_->frame_count());
|
| }
|
|
|
| +TEST_F(QuicConnectionTest, FramePackingSendv) {
|
| + // Send two stream frames in 1 packet by using writev.
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _));
|
| +
|
| + char data[] = "ABCD";
|
| + iovec iov[2] = { {static_cast<void*>(data), 2},
|
| + {static_cast<void*>(data + 2), 2} };
|
| + connection_.SendvStreamData(1, iov, 2, 0, !kFin);
|
| +
|
| + EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| + EXPECT_FALSE(connection_.HasQueuedData());
|
| +
|
| + // Parse the last packet and ensure it's two stream frames from one stream.
|
| + // TODO(ianswett): Ideally this would arrive in one frame in the future.
|
| + EXPECT_EQ(2u, helper_->frame_count());
|
| + EXPECT_EQ(2u, helper_->stream_frames()->size());
|
| + EXPECT_EQ(1u, (*helper_->stream_frames())[0].stream_id);
|
| + EXPECT_EQ(1u, (*helper_->stream_frames())[1].stream_id);
|
| +}
|
| +
|
| +TEST_F(QuicConnectionTest, FramePackingSendvQueued) {
|
| + // Try to send two stream frames in 1 packet by using writev.
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _));
|
| +
|
| + helper_->set_blocked(true);
|
| + char data[] = "ABCD";
|
| + iovec iov[2] = { {static_cast<void*>(data), 2},
|
| + {static_cast<void*>(data + 2), 2} };
|
| + connection_.SendvStreamData(1, iov, 2, 0, !kFin);
|
| +
|
| + EXPECT_EQ(1u, connection_.NumQueuedPackets());
|
| + EXPECT_TRUE(connection_.HasQueuedData());
|
| +
|
| + // Attempt to send all packets, but since we're actually still
|
| + // blocked, they should all remain queued.
|
| + EXPECT_FALSE(connection_.OnCanWrite());
|
| + EXPECT_EQ(1u, connection_.NumQueuedPackets());
|
| +
|
| + // Unblock the writes and actually send.
|
| + helper_->set_blocked(false);
|
| + EXPECT_CALL(visitor_, OnCanWrite());
|
| + EXPECT_TRUE(connection_.OnCanWrite());
|
| + EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| +
|
| + // Parse the last packet and ensure it's two stream frames from one stream.
|
| + // TODO(ianswett): Ideally this would arrive in one frame in the future.
|
| + EXPECT_EQ(2u, helper_->frame_count());
|
| + EXPECT_EQ(2u, helper_->stream_frames()->size());
|
| + EXPECT_EQ(1u, (*helper_->stream_frames())[0].stream_id);
|
| + EXPECT_EQ(1u, (*helper_->stream_frames())[1].stream_id);
|
| +}
|
| +
|
| +TEST_F(QuicConnectionTest, SendingZeroBytes) {
|
| + // Send a zero byte write with a fin using writev.
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _));
|
| +
|
| + iovec iov[1];
|
| + connection_.SendvStreamData(1, iov, 0, 0, kFin);
|
| +
|
| + EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| + EXPECT_FALSE(connection_.HasQueuedData());
|
| +
|
| + // Parse the last packet and ensure it's two stream frames from one stream.
|
| + // TODO(ianswett): Ideally this would arrive in one frame in the future.
|
| + EXPECT_EQ(1u, helper_->frame_count());
|
| + EXPECT_EQ(1u, helper_->stream_frames()->size());
|
| + EXPECT_EQ(1u, (*helper_->stream_frames())[0].stream_id);
|
| + EXPECT_TRUE((*helper_->stream_frames())[0].fin);
|
| +}
|
| +
|
| TEST_F(QuicConnectionTest, OnCanWrite) {
|
| // Visitor's OnCanWill send data, but will return false.
|
| EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
|
| @@ -1399,6 +1510,7 @@ TEST_F(QuicConnectionTest, RetransmitOnNack) {
|
| SequenceNumberSet expected_acks;
|
| expected_acks.insert(1);
|
| EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks)));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
|
|
| // Peer acks one but not two or three. Right now we only retransmit on
|
| // explicit nack, so it should not trigger a retransimission.
|
| @@ -1427,16 +1539,18 @@ TEST_F(QuicConnectionTest, RetransmitOnNack) {
|
| // The third nack should trigger a retransimission.
|
| EXPECT_CALL(*send_algorithm_,
|
| SentPacket(_, _, second_packet_size - kQuicVersionSize,
|
| - IS_RETRANSMISSION)).Times(1);
|
| + IS_RETRANSMISSION, _)).Times(1);
|
| ProcessAckPacket(&nack_two, true);
|
| }
|
|
|
| TEST_F(QuicConnectionTest, RetransmitNackedLargestObserved) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1);
|
| QuicPacketSequenceNumber largest_observed;
|
| QuicByteCount packet_size;
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION))
|
| - .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size)));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _))
|
| + .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size),
|
| + Return(true)));
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(1, _)).Times(1);
|
| connection_.SendStreamData(1, "foo", 0, !kFin);
|
| QuicAckFrame frame(1, QuicTime::Zero(), largest_observed);
|
| @@ -1447,13 +1561,13 @@ TEST_F(QuicConnectionTest, RetransmitNackedLargestObserved) {
|
| ProcessAckPacket(&frame, true);
|
| // Third nack should retransmit the largest observed packet.
|
| EXPECT_CALL(*send_algorithm_, SentPacket(_, _, packet_size - kQuicVersionSize,
|
| - IS_RETRANSMISSION));
|
| + IS_RETRANSMISSION, _));
|
| ProcessAckPacket(&frame, true);
|
| }
|
|
|
| TEST_F(QuicConnectionTest, RetransmitNackedPacketsOnTruncatedAck) {
|
| for (int i = 0; i < 200; ++i) {
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(1);
|
| connection_.SendStreamData(1, "foo", i * 3, !kFin);
|
| }
|
|
|
| @@ -1468,6 +1582,7 @@ TEST_F(QuicConnectionTest, RetransmitNackedPacketsOnTruncatedAck) {
|
| EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1);
|
| EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1);
|
| EXPECT_CALL(visitor_, OnAck(_)).Times(1);
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessAckPacket(&frame, true);
|
| EXPECT_TRUE(QuicConnectionPeer::GetReceivedTruncatedAck(&connection_));
|
|
|
| @@ -1475,7 +1590,7 @@ TEST_F(QuicConnectionTest, RetransmitNackedPacketsOnTruncatedAck) {
|
| clock_.AdvanceTime(DefaultRetransmissionTime());
|
| // Only packets that are less than largest observed should be retransmitted.
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(192);
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(192);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(192);
|
| connection_.OnRetransmissionTimeout();
|
|
|
| clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(
|
| @@ -1483,11 +1598,12 @@ TEST_F(QuicConnectionTest, RetransmitNackedPacketsOnTruncatedAck) {
|
| // Retransmit already retransmitted packets event though the sequence number
|
| // greater than the largest observed.
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(192);
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(192);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(192);
|
| connection_.OnRetransmissionTimeout();
|
| }
|
|
|
| TEST_F(QuicConnectionTest, LimitPacketsPerNack) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(*send_algorithm_, OnIncomingAck(12, _, _)).Times(1);
|
| EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1);
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(11);
|
| @@ -1515,11 +1631,11 @@ TEST_F(QuicConnectionTest, LimitPacketsPerNack) {
|
| ProcessAckPacket(&nack, true);
|
| ProcessAckPacket(&nack, true);
|
| // The third call should trigger retransmitting 10 packets.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(10);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(10);
|
| ProcessAckPacket(&nack, true);
|
|
|
| // The fourth call should trigger retransmitting the 11th packet.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(1);
|
| ProcessAckPacket(&nack, true);
|
| }
|
|
|
| @@ -1556,6 +1672,8 @@ TEST_F(QuicConnectionTest, MultipleAcks) {
|
| expected_acks.insert(5);
|
|
|
| EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks)));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessAckPacket(&frame1, true);
|
|
|
| // Now the client implicitly acks 2, and explicitly acks 6
|
| @@ -1582,6 +1700,7 @@ TEST_F(QuicConnectionTest, DontLatchUnackedPacket) {
|
| expected_acks.insert(1);
|
| // Peer acks packet 1.
|
| EXPECT_CALL(visitor_, OnAck(ContainerEq(expected_acks)));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| QuicAckFrame frame(1, QuicTime::Zero(), 0);
|
| frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash(
|
| &connection_, 1);
|
| @@ -1606,12 +1725,16 @@ TEST_F(QuicConnectionTest, DontLatchUnackedPacket) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, ReviveMissingPacketAfterFecPacket) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| // Don't send missing packet 1.
|
| ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL);
|
| EXPECT_FALSE(revived_header_.entropy_flag);
|
| }
|
|
|
| TEST_F(QuicConnectionTest, ReviveMissingPacketAfterDataPacketThenFecPacket) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessFecProtectedPacket(1, false, kEntropyFlag);
|
| // Don't send missing packet 2.
|
| ProcessFecPacket(3, 1, true, !kEntropyFlag, NULL);
|
| @@ -1619,6 +1742,8 @@ TEST_F(QuicConnectionTest, ReviveMissingPacketAfterDataPacketThenFecPacket) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, ReviveMissingPacketAfterDataPacketsThenFecPacket) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessFecProtectedPacket(1, false, !kEntropyFlag);
|
| // Don't send missing packet 2.
|
| ProcessFecProtectedPacket(3, false, !kEntropyFlag);
|
| @@ -1627,6 +1752,8 @@ TEST_F(QuicConnectionTest, ReviveMissingPacketAfterDataPacketsThenFecPacket) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, ReviveMissingPacketAfterDataPacket) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| // Don't send missing packet 1.
|
| ProcessFecPacket(3, 1, false, !kEntropyFlag, NULL);
|
| // out of order
|
| @@ -1635,6 +1762,8 @@ TEST_F(QuicConnectionTest, ReviveMissingPacketAfterDataPacket) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, ReviveMissingPacketAfterDataPackets) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| ProcessFecProtectedPacket(1, false, !kEntropyFlag);
|
| // Don't send missing packet 2.
|
| ProcessFecPacket(6, 1, false, kEntropyFlag, NULL);
|
| @@ -1655,7 +1784,7 @@ TEST_F(QuicConnectionTest, TestRetransmit) {
|
| connection_.GetRetransmissionAlarm()->deadline());
|
| // Simulate the retransimission alarm firing
|
| clock_.AdvanceTime(DefaultRetransmissionTime());
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(1, _)).Times(1);
|
| connection_.RetransmitPacket(1);
|
| EXPECT_EQ(2u, last_header()->packet_sequence_number);
|
| @@ -1684,12 +1813,12 @@ TEST_F(QuicConnectionTest, RetransmitWithSameEncryptionLevel) {
|
| clock_.AdvanceTime(DefaultRetransmissionTime());
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(2);
|
|
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| connection_.RetransmitPacket(1);
|
| // Packet should have been sent with ENCRYPTION_NONE.
|
| EXPECT_EQ(0x01010101u, final_bytes_of_last_packet());
|
|
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| connection_.RetransmitPacket(2);
|
| // Packet should have been sent with ENCRYPTION_INITIAL.
|
| EXPECT_EQ(0x02020202u, final_bytes_of_last_packet());
|
| @@ -1706,7 +1835,7 @@ TEST_F(QuicConnectionTest,
|
| new TaggingEncrypter(0x02));
|
| connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
|
|
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(0);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(0);
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(sequence_number, _)).Times(1);
|
|
|
| QuicTime default_retransmission_time = clock_.ApproximateNow().Add(
|
| @@ -1731,13 +1860,14 @@ TEST_F(QuicConnectionTest, RetransmitPacketsWithInitialEncryption) {
|
|
|
| SendStreamDataToPeer(2, "bar", 0, !kFin, NULL);
|
|
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(1);
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(1);
|
|
|
| connection_.RetransmitUnackedPackets(QuicConnection::INITIAL_ENCRYPTION_ONLY);
|
| }
|
|
|
| TEST_F(QuicConnectionTest, BufferNonDecryptablePackets) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| use_tagging_decrypter();
|
|
|
| const uint8 tag = 0x07;
|
| @@ -1765,14 +1895,14 @@ TEST_F(QuicConnectionTest, BufferNonDecryptablePackets) {
|
|
|
| TEST_F(QuicConnectionTest, TestRetransmitOrder) {
|
| QuicByteCount first_packet_size;
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).WillOnce(
|
| - SaveArg<2>(&first_packet_size));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).WillOnce(
|
| + DoAll(SaveArg<2>(&first_packet_size), Return(true)));
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(2);
|
|
|
| connection_.SendStreamData(1, "first_packet", 0, !kFin);
|
| QuicByteCount second_packet_size;
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).WillOnce(
|
| - SaveArg<2>(&second_packet_size));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).WillOnce(
|
| + DoAll(SaveArg<2>(&second_packet_size), Return(true)));
|
| connection_.SendStreamData(1, "second_packet", 12, !kFin);
|
| EXPECT_NE(first_packet_size, second_packet_size);
|
| // Advance the clock by huge time to make sure packets will be retransmitted.
|
| @@ -1780,20 +1910,20 @@ TEST_F(QuicConnectionTest, TestRetransmitOrder) {
|
| {
|
| InSequence s;
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, first_packet_size, _));
|
| + SentPacket(_, _, first_packet_size, _, _));
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, second_packet_size, _));
|
| + SentPacket(_, _, second_packet_size, _, _));
|
| }
|
| connection_.OnRetransmissionTimeout();
|
| }
|
|
|
| TEST_F(QuicConnectionTest, TestRetransmissionCountCalculation) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1);
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(2);
|
| QuicPacketSequenceNumber original_sequence_number;
|
| - EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, NOT_RETRANSMISSION))
|
| - .WillOnce(SaveArg<1>(&original_sequence_number));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _))
|
| + .WillOnce(DoAll(SaveArg<1>(&original_sequence_number), Return(true)));
|
| connection_.SendStreamData(1, "foo", 0, !kFin);
|
| EXPECT_TRUE(QuicConnectionPeer::IsSavedForRetransmission(
|
| &connection_, original_sequence_number));
|
| @@ -1802,9 +1932,8 @@ TEST_F(QuicConnectionTest, TestRetransmissionCountCalculation) {
|
| // Force retransmission due to RTO.
|
| clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10));
|
| QuicPacketSequenceNumber rto_sequence_number;
|
| - EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, IS_RETRANSMISSION))
|
| - .WillOnce(SaveArg<1>(&rto_sequence_number));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, IS_RETRANSMISSION, _))
|
| + .WillOnce(DoAll(SaveArg<1>(&rto_sequence_number), Return(true)));
|
| connection_.OnRetransmissionTimeout();
|
| EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission(
|
| &connection_, original_sequence_number));
|
| @@ -1816,10 +1945,10 @@ TEST_F(QuicConnectionTest, TestRetransmissionCountCalculation) {
|
| QuicPacketSequenceNumber nack_sequence_number;
|
| // Ack packets might generate some other packets, which are not
|
| // retransmissions. (More ack packets).
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION))
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, NOT_RETRANSMISSION, _))
|
| .Times(AnyNumber());
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, IS_RETRANSMISSION))
|
| - .WillOnce(SaveArg<1>(&nack_sequence_number));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, IS_RETRANSMISSION, _))
|
| + .WillOnce(DoAll(SaveArg<1>(&nack_sequence_number), Return(true)));
|
| QuicAckFrame ack(rto_sequence_number, QuicTime::Zero(), 0);
|
| // Ack the retransmitted packet.
|
| ack.received_info.missing_packets.insert(rto_sequence_number);
|
| @@ -1868,6 +1997,7 @@ TEST_F(QuicConnectionTest, TestQueued) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, CloseFecGroup) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| // Don't send missing packet 1
|
| // Don't send missing packet 2
|
| ProcessFecProtectedPacket(3, false, !kEntropyFlag);
|
| @@ -1900,10 +2030,12 @@ TEST_F(QuicConnectionTest, WithQuicCongestionFeedbackFrame) {
|
| TEST_F(QuicConnectionTest, UpdateQuicCongestionFeedbackFrame) {
|
| SendAckPacketToPeer();
|
| EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _, _));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessPacket(1);
|
| }
|
|
|
| TEST_F(QuicConnectionTest, DontUpdateQuicCongestionFeedbackFrameForRevived) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| SendAckPacketToPeer();
|
| // Process an FEC packet, and revive the missing data packet
|
| // but only contact the receive_algorithm once.
|
| @@ -1914,7 +2046,7 @@ TEST_F(QuicConnectionTest, DontUpdateQuicCongestionFeedbackFrameForRevived) {
|
| TEST_F(QuicConnectionTest, InitialTimeout) {
|
| EXPECT_TRUE(connection_.connected());
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, false));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
|
|
| QuicTime default_timeout = clock_.ApproximateNow().Add(
|
| QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs));
|
| @@ -1953,7 +2085,7 @@ TEST_F(QuicConnectionTest, TimeoutAfterSend) {
|
|
|
| // This time, we should time out.
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, false));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
|
| EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)),
|
| clock_.ApproximateNow());
|
| @@ -1968,7 +2100,7 @@ TEST_F(QuicConnectionTest, SendScheduler) {
|
| EXPECT_CALL(*send_algorithm_,
|
| TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillOnce(
|
| testing::Return(QuicTime::Delta::Zero()));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| connection_.SendOrQueuePacket(
|
| ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| @@ -1980,7 +2112,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelay) {
|
| EXPECT_CALL(*send_algorithm_,
|
| TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillOnce(
|
| testing::Return(QuicTime::Delta::FromMicroseconds(1)));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, _)).Times(0);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, _, _)).Times(0);
|
| connection_.SendOrQueuePacket(
|
| ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
|
| EXPECT_EQ(1u, connection_.NumQueuedPackets());
|
| @@ -1991,7 +2123,7 @@ TEST_F(QuicConnectionTest, SendSchedulerForce) {
|
| QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
|
| EXPECT_CALL(*send_algorithm_,
|
| TimeUntilSend(_, IS_RETRANSMISSION, _, _)).Times(0);
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| connection_.SendOrQueuePacket(
|
| ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
|
| // XXX: fixme. was: connection_.SendOrQueuePacket(1, packet, kForce);
|
| @@ -2004,7 +2136,7 @@ TEST_F(QuicConnectionTest, SendSchedulerEAGAIN) {
|
| EXPECT_CALL(*send_algorithm_,
|
| TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillOnce(
|
| testing::Return(QuicTime::Delta::Zero()));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, _)).Times(0);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, _, _)).Times(0);
|
| connection_.SendOrQueuePacket(
|
| ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
|
| EXPECT_EQ(1u, connection_.NumQueuedPackets());
|
| @@ -2027,7 +2159,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenSend) {
|
| testing::Return(QuicTime::Delta::Zero()));
|
| clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1));
|
| connection_.GetSendAlarm()->Cancel();
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _));
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _));
|
| EXPECT_CALL(visitor_, OnCanWrite());
|
| connection_.OnCanWrite();
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| @@ -2038,7 +2170,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
|
| .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(1, _)).Times(1);
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, 1, _, NOT_RETRANSMISSION));
|
| + SentPacket(_, 1, _, NOT_RETRANSMISSION, _));
|
| connection_.SendStreamData(1, "foo", 0, !kFin);
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| // Advance the time for retransmission of lost packet.
|
| @@ -2058,7 +2190,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
|
|
|
| // Ensure the scheduler is notified this is a retransmit.
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, IS_RETRANSMISSION));
|
| + SentPacket(_, _, _, IS_RETRANSMISSION, _));
|
| clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1));
|
| connection_.GetSendAlarm()->Cancel();
|
| EXPECT_CALL(visitor_, OnCanWrite());
|
| @@ -2083,6 +2215,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayAndQueue) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
|
| EXPECT_CALL(*send_algorithm_,
|
| TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillOnce(
|
| @@ -2098,7 +2231,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
|
| TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillRepeatedly(
|
| testing::Return(QuicTime::Delta::Zero()));
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, _));
|
| + SentPacket(_, _, _, _, _));
|
| ProcessAckPacket(&frame, true);
|
|
|
| EXPECT_EQ(0u, connection_.NumQueuedPackets());
|
| @@ -2107,6 +2240,7 @@ TEST_F(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
|
| EXPECT_CALL(*send_algorithm_,
|
| TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillOnce(
|
| @@ -2168,7 +2302,7 @@ TEST_F(QuicConnectionTest, LoopThroughSendingPackets) {
|
| NOT_IN_FEC_GROUP, &payload_length);
|
|
|
| // Queue the first packet.
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(7);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(7);
|
| // The first stream frame will consume 2 fewer bytes than the other six.
|
| const string payload(payload_length * 7 - 12, 'a');
|
| EXPECT_EQ(payload.size(),
|
| @@ -2176,10 +2310,11 @@ TEST_F(QuicConnectionTest, LoopThroughSendingPackets) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, NoAckForClose) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessPacket(1);
|
| EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(0);
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true));
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(0);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(0);
|
| ProcessClosePacket(2, 0);
|
| }
|
|
|
| @@ -2189,7 +2324,7 @@ TEST_F(QuicConnectionTest, SendWhenDisconnected) {
|
| connection_.CloseConnection(QUIC_PEER_GOING_AWAY, false);
|
| EXPECT_FALSE(connection_.connected());
|
| QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, _)).Times(0);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, _, _)).Times(0);
|
| connection_.SendOrQueuePacket(
|
| ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
|
| }
|
| @@ -2207,6 +2342,8 @@ TEST_F(QuicConnectionTest, PublicReset) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, GoAway) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| QuicGoAwayFrame goaway;
|
| goaway.last_good_stream_id = 1;
|
| goaway.error_code = QUIC_PEER_GOING_AWAY;
|
| @@ -2219,12 +2356,14 @@ TEST_F(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) {
|
| QuicAckFrame ack(0, QuicTime::Zero(), 4);
|
| // Set the sequence number of the ack packet to be least unacked (4)
|
| creator_.set_sequence_number(3);
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessAckPacket(&ack, true);
|
| EXPECT_TRUE(outgoing_ack()->received_info.missing_packets.empty());
|
| }
|
|
|
| TEST_F(QuicConnectionTest, ReceivedEntropyHashCalculation) {
|
| EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessDataPacket(1, 1, kEntropyFlag);
|
| ProcessDataPacket(4, 1, kEntropyFlag);
|
| ProcessDataPacket(3, 1, !kEntropyFlag);
|
| @@ -2234,6 +2373,7 @@ TEST_F(QuicConnectionTest, ReceivedEntropyHashCalculation) {
|
|
|
| TEST_F(QuicConnectionTest, UpdateEntropyForReceivedPackets) {
|
| EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessDataPacket(1, 1, kEntropyFlag);
|
| ProcessDataPacket(5, 1, kEntropyFlag);
|
| ProcessDataPacket(4, 1, !kEntropyFlag);
|
| @@ -2254,6 +2394,7 @@ TEST_F(QuicConnectionTest, UpdateEntropyForReceivedPackets) {
|
|
|
| TEST_F(QuicConnectionTest, UpdateEntropyHashUptoCurrentPacket) {
|
| EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| ProcessDataPacket(1, 1, kEntropyFlag);
|
| ProcessDataPacket(5, 1, !kEntropyFlag);
|
| ProcessDataPacket(22, 1, kEntropyFlag);
|
| @@ -2273,6 +2414,7 @@ TEST_F(QuicConnectionTest, UpdateEntropyHashUptoCurrentPacket) {
|
|
|
| TEST_F(QuicConnectionTest, EntropyCalculationForTruncatedAck) {
|
| EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| QuicPacketEntropyHash entropy[51];
|
| entropy[0] = 0;
|
| for (int i = 1; i < 51; ++i) {
|
| @@ -2397,6 +2539,7 @@ TEST_F(QuicConnectionTest, ClientHandlesVersionNegotiation) {
|
| framer_.BuildUnsizedDataPacket(header, frames).packet);
|
| encrypted.reset(framer_.EncryptPacket(ENCRYPTION_NONE, 12, *packet));
|
| EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
|
|
|
| ASSERT_FALSE(QuicPacketCreatorPeer::SendVersionInPacket(
|
| @@ -2431,18 +2574,18 @@ TEST_F(QuicConnectionTest, BadVersionNegotiation) {
|
| TEST_F(QuicConnectionTest, CheckSendStats) {
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(_, _)).Times(3);
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, NOT_RETRANSMISSION));
|
| + SentPacket(_, _, _, NOT_RETRANSMISSION, _));
|
| connection_.SendStreamData(1u, "first", 0, !kFin);
|
| size_t first_packet_size = last_sent_packet_size();
|
|
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, NOT_RETRANSMISSION));
|
| + SentPacket(_, _, _, NOT_RETRANSMISSION, _));
|
| connection_.SendStreamData(1u, "second", 0, !kFin);
|
| size_t second_packet_size = last_sent_packet_size();
|
|
|
| // 2 retransmissions due to rto, 1 due to explicit nack.
|
| EXPECT_CALL(*send_algorithm_,
|
| - SentPacket(_, _, _, IS_RETRANSMISSION)).Times(3);
|
| + SentPacket(_, _, _, IS_RETRANSMISSION, _)).Times(3);
|
|
|
| // Retransmit due to RTO.
|
| clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10));
|
| @@ -2460,6 +2603,7 @@ TEST_F(QuicConnectionTest, CheckSendStats) {
|
| EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(1);
|
| EXPECT_CALL(*send_algorithm_, OnIncomingLoss(_)).Times(1);
|
| EXPECT_CALL(visitor_, OnCanWrite()).Times(3).WillRepeatedly(Return(true));
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
|
|
| ProcessFramePacket(frame);
|
| ProcessFramePacket(frame);
|
| @@ -2481,6 +2625,8 @@ TEST_F(QuicConnectionTest, CheckSendStats) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, CheckReceiveStats) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| size_t received_bytes = 0;
|
| received_bytes += ProcessFecProtectedPacket(1, false, !kEntropyFlag);
|
| received_bytes += ProcessFecProtectedPacket(3, false, !kEntropyFlag);
|
| @@ -2550,6 +2696,7 @@ TEST_F(QuicConnectionTest, DontProcessFramesIfPacketClosedConnection) {
|
|
|
| EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true));
|
| EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).Times(0);
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
|
|
| connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
|
| }
|
| @@ -2622,6 +2769,8 @@ TEST_F(QuicConnectionTest, ConnectionCloseWhenNothingPending) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, AckNotifierTriggerCallback) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| // Create a delegate which we expect to be called.
|
| MockAckNotifierDelegate delegate;
|
| EXPECT_CALL(delegate, OnAckNotification()).Times(1);;
|
| @@ -2637,6 +2786,8 @@ TEST_F(QuicConnectionTest, AckNotifierTriggerCallback) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| // Create a delegate which we don't expect to be called.
|
| MockAckNotifierDelegate delegate;
|
| EXPECT_CALL(delegate, OnAckNotification()).Times(0);;
|
| @@ -2661,6 +2812,8 @@ TEST_F(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
|
| }
|
|
|
| TEST_F(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| +
|
| // Create a delegate which we expect to be called.
|
| MockAckNotifierDelegate delegate;
|
| EXPECT_CALL(delegate, OnAckNotification()).Times(1);;
|
| @@ -2688,7 +2841,7 @@ TEST_F(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
|
| // Advance time to trigger RTO, for packet 2 (which should be retransmitted as
|
| // packet 5).
|
| EXPECT_CALL(*send_algorithm_, AbandoningPacket(2, _)).Times(1);
|
| - EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(1);
|
| + EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _, _)).Times(1);
|
|
|
| clock_.AdvanceTime(DefaultRetransmissionTime());
|
| connection_.OnRetransmissionTimeout();
|
| @@ -2702,6 +2855,7 @@ TEST_F(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
|
| // TODO(rjshade): Add a similar test that FEC recovery on peer (and resulting
|
| // ACK) triggers notification on our end.
|
| TEST_F(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
|
| + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
|
| EXPECT_CALL(visitor_, OnCanWrite()).Times(1).WillOnce(Return(true));
|
|
|
| // Create a delegate which we expect to be called.
|
| @@ -2723,8 +2877,7 @@ TEST_F(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
|
| frames.push_back(QuicFrame(&ack_frame));
|
|
|
| // Dummy stream frame to satisfy expectations set elsewhere.
|
| - QuicFrame frame(&frame1_);
|
| - frames.push_back(frame);
|
| + frames.push_back(QuicFrame(&frame1_));
|
|
|
| QuicPacketHeader ack_header;
|
| ack_header.public_header.guid = guid_;
|
|
|