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

Unified Diff: net/quic/quic_connection_test.cc

Issue 180783003: QUIC test cleanup to always use MockLossAlgorithm in QuicConnectionTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection_test.cc
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index e4418c34ae8e147608737d70a647499816603cd0..72244bfab5a0b953f1e99ddcc52f976f95787baf 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -545,7 +545,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
framer_(SupportedVersions(version()), QuicTime::Zero(), false),
creator_(guid_, &framer_, &random_generator_, false),
send_algorithm_(new StrictMock<MockSendAlgorithm>),
- loss_algorithm_(NULL),
+ loss_algorithm_(new MockLossAlgorithm()),
helper_(new TestConnectionHelper(&clock_, &random_generator_)),
writer_(new TestPacketWriter(version())),
connection_(guid_, IPEndPoint(), helper_.get(), writer_.get(),
@@ -555,6 +555,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
accept_packet_(true) {
connection_.set_visitor(&visitor_);
connection_.SetSendAlgorithm(send_algorithm_);
+ connection_.SetLossAlgorithm(loss_algorithm_);
framer_.set_received_entropy_calculator(&entropy_calculator_);
// Simplify tests by not sending feedback unless specifically configured.
SetFeedback(NULL);
@@ -576,11 +577,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber());
EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber());
EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber());
- }
- void SetUpMockLossAlgorithm() {
- loss_algorithm_ = new MockLossAlgorithm();
- connection_.SetLossAlgorithm(loss_algorithm_);
EXPECT_CALL(*loss_algorithm_, GetLossTimeout())
.WillRepeatedly(Return(QuicTime::Zero()));
EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
@@ -1055,10 +1052,16 @@ TEST_P(QuicConnectionTest, TruncatedAck) {
}
QuicAckFrame frame = InitAckFrame(num_packets, 1);
+ SequenceNumberSet lost_packets;
// Create an ack with 256 nacks, none adjacent to one another.
for (QuicPacketSequenceNumber i = 1; i <= 256; ++i) {
NackPacket(i * 2, &frame);
+ if (i < 256) { // Last packet is nacked, but not lost.
+ lost_packets.insert(i * 2);
+ }
}
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(entropy_calculator_,
EntropyHash(511)).WillOnce(testing::Return(0));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
@@ -1077,6 +1080,8 @@ TEST_P(QuicConnectionTest, TruncatedAck) {
// Removing one missing packet allows us to ack 192 and one more range, but
// 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_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
ProcessAckPacket(&frame);
@@ -1126,7 +1131,6 @@ TEST_P(QuicConnectionTest, OutOfOrderReceiptCausesAckSend) {
}
TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
- SetUpMockLossAlgorithm();
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
QuicPacketSequenceNumber original;
@@ -1551,6 +1555,10 @@ TEST_P(QuicConnectionTest, AbandonAllFEC) {
NackPacket(4, &ack_fec);
// Lose the first FEC packet and ack the three data packets.
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(2);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(3);
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _));
@@ -1816,7 +1824,6 @@ TEST_P(QuicConnectionTest, OnCanWrite) {
}
TEST_P(QuicConnectionTest, RetransmitOnNack) {
- SetUpMockLossAlgorithm();
QuicPacketSequenceNumber last_packet;
QuicByteCount second_packet_size;
SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 1
@@ -1850,7 +1857,6 @@ TEST_P(QuicConnectionTest, RetransmitOnNack) {
}
TEST_P(QuicConnectionTest, DiscardRetransmit) {
- SetUpMockLossAlgorithm();
QuicPacketSequenceNumber last_packet;
SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
@@ -1894,7 +1900,6 @@ TEST_P(QuicConnectionTest, DiscardRetransmit) {
}
TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) {
- SetUpMockLossAlgorithm();
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
QuicPacketSequenceNumber largest_observed;
QuicByteCount packet_size;
@@ -2014,7 +2019,6 @@ TEST_P(QuicConnectionTest, AlarmsWhenWriteBlocked) {
}
TEST_P(QuicConnectionTest, NoLimitPacketsPerNack) {
- SetUpMockLossAlgorithm();
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
int offset = 0;
// Send packets 1 to 15.
@@ -2395,8 +2399,12 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
EXPECT_TRUE(QuicConnectionPeer::IsRetransmission(
&connection_, rto_sequence_number));
// Once by explicit nack.
- EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(3);
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(rto_sequence_number);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
+ .WillOnce(Return(lost_packets));
+ EXPECT_CALL(*send_algorithm_, UpdateRtt(_)).Times(1);
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(rto_sequence_number, _)).Times(1);
EXPECT_CALL(*send_algorithm_,
OnPacketAbandoned(rto_sequence_number, _)).Times(1);
QuicPacketSequenceNumber nack_sequence_number = 0;
@@ -2407,12 +2415,11 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NACK_RETRANSMISSION, _))
.WillOnce(DoAll(SaveArg<1>(&nack_sequence_number), Return(true)));
QuicAckFrame ack = InitAckFrame(rto_sequence_number, 0);
- // Ack the retransmitted packet.
+ // Nack the retransmitted packet.
NackPacket(original_sequence_number, &ack);
NackPacket(rto_sequence_number, &ack);
- for (int i = 0; i < 3; i++) {
- ProcessAckPacket(&ack);
- }
+ ProcessAckPacket(&ack);
+
ASSERT_NE(0u, nack_sequence_number);
EXPECT_FALSE(QuicConnectionPeer::IsSavedForRetransmission(
&connection_, rto_sequence_number));
@@ -2903,7 +2910,6 @@ TEST_P(QuicConnectionTest, DontSendDelayedAckOnOutgoingCryptoPacket) {
}
TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) {
- SetUpMockLossAlgorithm();
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
connection_.SendStreamDataWithString(kStreamId3, "foo", 0, !kFin, NULL);
connection_.SendStreamDataWithString(kStreamId3, "foo", 3, !kFin, NULL);
@@ -3397,16 +3403,17 @@ TEST_P(QuicConnectionTest, CheckSendStats) {
QuicAckFrame nack_three = InitAckFrame(4, 0);
NackPacket(3, &nack_three);
NackPacket(1, &nack_three);
- QuicFrame frame(&nack_three);
+ SequenceNumberSet lost_packets;
+ lost_packets.insert(1);
+ lost_packets.insert(3);
+ EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
+ .WillOnce(Return(lost_packets));
EXPECT_CALL(*send_algorithm_, UpdateRtt(_));
- EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)).Times(1);
- EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(1);
- EXPECT_CALL(visitor_, OnCanWrite()).Times(4);
+ EXPECT_CALL(*send_algorithm_, OnPacketAcked(4, _)).Times(1);
+ EXPECT_CALL(*send_algorithm_, OnPacketLost(_, _)).Times(2);
+ EXPECT_CALL(visitor_, OnCanWrite()).Times(2);
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
-
- ProcessFramePacket(frame);
- ProcessFramePacket(frame);
- ProcessFramePacket(frame);
+ ProcessAckPacket(&nack_three);
EXPECT_CALL(*send_algorithm_, SmoothedRtt()).WillOnce(
Return(QuicTime::Delta::Zero()));
@@ -3610,7 +3617,6 @@ TEST_P(QuicConnectionTest, AckNotifierTriggerCallback) {
}
TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
- SetUpMockLossAlgorithm();
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
// Create a delegate which we don't expect to be called.
@@ -3642,7 +3648,6 @@ TEST_P(QuicConnectionTest, AckNotifierFailToTriggerCallback) {
}
TEST_P(QuicConnectionTest, AckNotifierCallbackAfterRetransmission) {
- SetUpMockLossAlgorithm();
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
// Create a delegate which we expect to be called.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698