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

Unified Diff: net/quic/quic_connection_test.cc

Issue 331573002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compiler error - use push_back to initialize vectors Created 6 years, 6 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 | « net/quic/quic_connection.cc ('k') | net/quic/quic_data_stream_test.cc » ('j') | 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 ff50b01010615909a57b43f97e0e5b34e2cf678b..43c324b8167597e0b495991148708a5aa6b7ed58 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -22,7 +22,6 @@
#include "net/quic/test_tools/quic_connection_peer.h"
#include "net/quic/test_tools/quic_framer_peer.h"
#include "net/quic/test_tools/quic_packet_creator_peer.h"
-#include "net/quic/test_tools/quic_packet_generator_peer.h"
#include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
#include "net/quic/test_tools/quic_test_utils.h"
#include "net/quic/test_tools/simple_quic_framer.h"
@@ -461,11 +460,33 @@ class TestConnection : public QuicConnection {
QuicStreamOffset offset,
bool fin,
QuicAckNotifier::DelegateInterface* delegate) {
+ return SendStreamDataWithStringHelper(id, data, offset, fin,
+ MAY_FEC_PROTECT, delegate);
+ }
+
+ QuicConsumedData SendStreamDataWithStringWithFec(
+ QuicStreamId id,
+ StringPiece data,
+ QuicStreamOffset offset,
+ bool fin,
+ QuicAckNotifier::DelegateInterface* delegate) {
+ return SendStreamDataWithStringHelper(id, data, offset, fin,
+ MUST_FEC_PROTECT, delegate);
+ }
+
+ QuicConsumedData SendStreamDataWithStringHelper(
+ QuicStreamId id,
+ StringPiece data,
+ QuicStreamOffset offset,
+ bool fin,
+ FecProtection fec_protection,
+ QuicAckNotifier::DelegateInterface* delegate) {
IOVector data_iov;
if (!data.empty()) {
data_iov.Append(const_cast<char*>(data.data()), data.size());
}
- return QuicConnection::SendStreamData(id, data_iov, offset, fin, delegate);
+ return QuicConnection::SendStreamData(id, data_iov, offset, fin,
+ fec_protection, delegate);
}
QuicConsumedData SendStreamData3() {
@@ -473,11 +494,20 @@ class TestConnection : public QuicConnection {
NULL);
}
+ QuicConsumedData SendStreamData3WithFec() {
+ return SendStreamDataWithStringWithFec(kClientDataStreamId1, "food", 0,
+ !kFin, NULL);
+ }
+
QuicConsumedData SendStreamData5() {
return SendStreamDataWithString(kClientDataStreamId2, "food2", 0,
!kFin, NULL);
}
+ QuicConsumedData SendStreamData5WithFec() {
+ return SendStreamDataWithStringWithFec(kClientDataStreamId2, "food2", 0,
+ !kFin, NULL);
+ }
// Ensures the connection can write stream data before writing.
QuicConsumedData EnsureWritableAndSendStreamData5() {
EXPECT_TRUE(CanWriteStreamData());
@@ -512,8 +542,6 @@ class TestConnection : public QuicConnection {
void set_is_server(bool is_server) {
writer_->set_is_server(is_server);
- QuicPacketCreatorPeer::SetIsServer(
- QuicConnectionPeer::GetPacketCreator(this), is_server);
QuicConnectionPeer::SetIsServer(this, is_server);
}
@@ -578,7 +606,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
QuicConnectionTest()
: connection_id_(42),
framer_(SupportedVersions(version()), QuicTime::Zero(), false),
- peer_creator_(connection_id_, &framer_, &random_generator_, false),
+ peer_creator_(connection_id_, &framer_, &random_generator_),
send_algorithm_(new StrictMock<MockSendAlgorithm>),
loss_algorithm_(new MockLossAlgorithm()),
helper_(new TestConnectionHelper(&clock_, &random_generator_)),
@@ -1460,18 +1488,17 @@ TEST_P(QuicConnectionTest, FECSending) {
IN_FEC_GROUP, &payload_length);
creator->set_max_packet_length(length);
- // And send FEC every two packets.
- QuicPacketGeneratorPeer::SwitchFecProtectionOn(
- QuicConnectionPeer::GetPacketGenerator(&connection_), 2);
+ // Enable FEC.
+ creator->set_max_packets_per_fec_group(2);
- // Send 4 data packets and 2 FEC packets.
+ // Send 4 protected data packets, which will also trigger 2 FEC packets.
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
// The first stream frame will have 2 fewer overhead bytes than the other 3.
const string payload(payload_length * 4 + 2, 'a');
- connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL);
// Expect the FEC group to be closed after SendStreamDataWithString.
- EXPECT_FALSE(creator->ShouldSendFec(true));
- EXPECT_TRUE(creator->IsFecProtected());
+ EXPECT_FALSE(creator->IsFecGroupOpen());
+ EXPECT_FALSE(creator->IsFecProtected());
}
TEST_P(QuicConnectionTest, FECQueueing) {
@@ -1483,27 +1510,27 @@ TEST_P(QuicConnectionTest, FECQueueing) {
connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
IN_FEC_GROUP, &payload_length);
creator->set_max_packet_length(length);
- // And send FEC every two packets.
- QuicPacketGeneratorPeer::SwitchFecProtectionOn(
- QuicConnectionPeer::GetPacketGenerator(&connection_), 1);
+ // Enable FEC.
+ creator->set_max_packets_per_fec_group(1);
EXPECT_EQ(0u, connection_.NumQueuedPackets());
BlockOnNextWrite();
const string payload(payload_length, 'a');
- connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL);
- EXPECT_FALSE(creator->ShouldSendFec(true));
- EXPECT_TRUE(creator->IsFecProtected());
+ connection_.SendStreamDataWithStringWithFec(1, payload, 0, !kFin, NULL);
+ EXPECT_FALSE(creator->IsFecGroupOpen());
+ EXPECT_FALSE(creator->IsFecProtected());
// Expect the first data packet and the fec packet to be queued.
EXPECT_EQ(2u, connection_.NumQueuedPackets());
}
TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) {
- QuicPacketGeneratorPeer::SwitchFecProtectionOn(
- QuicConnectionPeer::GetPacketGenerator(&connection_), 1);
+ // Enable FEC.
+ QuicConnectionPeer::GetPacketCreator(
+ &connection_)->set_max_packets_per_fec_group(1);
// 1 Data and 1 FEC packet.
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
- connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL);
const QuicTime::Delta retransmission_time =
QuicTime::Delta::FromMilliseconds(5000);
@@ -1518,15 +1545,16 @@ TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) {
TEST_P(QuicConnectionTest, DontAbandonAckedFEC) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- QuicPacketGeneratorPeer::SwitchFecProtectionOn(
- QuicConnectionPeer::GetPacketGenerator(&connection_), 1);
+ // Enable FEC.
+ QuicConnectionPeer::GetPacketCreator(
+ &connection_)->set_max_packets_per_fec_group(1);
// 1 Data and 1 FEC packet.
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
- connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL);
// Send some more data afterwards to ensure early retransmit doesn't trigger.
- connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
- connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL);
QuicAckFrame ack_fec = InitAckFrame(2, 1);
// Data packet missing.
@@ -1546,17 +1574,18 @@ TEST_P(QuicConnectionTest, DontAbandonAckedFEC) {
TEST_P(QuicConnectionTest, AbandonAllFEC) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- QuicPacketGeneratorPeer::SwitchFecProtectionOn(
- QuicConnectionPeer::GetPacketGenerator(&connection_), 1);
+ // Enable FEC.
+ QuicConnectionPeer::GetPacketCreator(
+ &connection_)->set_max_packets_per_fec_group(1);
// 1 Data and 1 FEC packet.
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
- connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(3, "foo", 0, !kFin, NULL);
// Send some more data afterwards to ensure early retransmit doesn't trigger.
- connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(3, "foo", 3, !kFin, NULL);
// Advance the time so not all the FEC packets are abandoned.
clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1));
- connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL);
+ connection_.SendStreamDataWithStringWithFec(3, "foo", 6, !kFin, NULL);
QuicAckFrame ack_fec = InitAckFrame(5, 1);
// Ack all data packets, but no fec packets.
@@ -1662,28 +1691,29 @@ TEST_P(QuicConnectionTest, FramePackingCryptoThenNonCrypto) {
}
TEST_P(QuicConnectionTest, FramePackingFEC) {
- // Enable fec.
- QuicPacketGeneratorPeer::SwitchFecProtectionOn(
- QuicConnectionPeer::GetPacketGenerator(&connection_), 6);
+ // Enable FEC.
+ QuicConnectionPeer::GetPacketCreator(
+ &connection_)->set_max_packets_per_fec_group(6);
CongestionBlockWrites();
- // Send an ack and two stream frames in 1 packet by queueing them.
- connection_.SendAck();
+ // Queue an ack and two stream frames. Ack gets flushed when FEC is turned on
+ // for sending protected data; two stream frames are packing in 1 packet.
EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData3)),
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData5))));
+ IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData3WithFec)),
+ IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData5WithFec))));
+ connection_.SendAck();
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3);
CongestionUnblockWrites();
connection_.GetSendAlarm()->Fire();
EXPECT_EQ(0u, connection_.NumQueuedPackets());
EXPECT_FALSE(connection_.HasQueuedData());
// Parse the last packet and ensure it's in an fec group.
- EXPECT_EQ(1u, writer_->header().fec_group);
+ EXPECT_EQ(2u, writer_->header().fec_group);
EXPECT_EQ(0u, writer_->frame_count());
}
@@ -1732,7 +1762,7 @@ TEST_P(QuicConnectionTest, FramePackingSendv) {
IOVector data_iov;
data_iov.AppendNoCoalesce(data, 2);
data_iov.AppendNoCoalesce(data + 2, 2);
- connection_.SendStreamData(1, data_iov, 0, !kFin, NULL);
+ connection_.SendStreamData(1, data_iov, 0, !kFin, MAY_FEC_PROTECT, NULL);
EXPECT_EQ(0u, connection_.NumQueuedPackets());
EXPECT_FALSE(connection_.HasQueuedData());
@@ -1757,7 +1787,7 @@ TEST_P(QuicConnectionTest, FramePackingSendvQueued) {
IOVector data_iov;
data_iov.AppendNoCoalesce(data, 2);
data_iov.AppendNoCoalesce(data + 2, 2);
- connection_.SendStreamData(1, data_iov, 0, !kFin, NULL);
+ connection_.SendStreamData(1, data_iov, 0, !kFin, MAY_FEC_PROTECT, NULL);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
EXPECT_TRUE(connection_.HasQueuedData());
@@ -1777,7 +1807,7 @@ TEST_P(QuicConnectionTest, SendingZeroBytes) {
// Send a zero byte write with a fin using writev.
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
IOVector empty_iov;
- connection_.SendStreamData(1, empty_iov, 0, kFin, NULL);
+ connection_.SendStreamData(1, empty_iov, 0, kFin, MAY_FEC_PROTECT, NULL);
EXPECT_EQ(0u, connection_.NumQueuedPackets());
EXPECT_FALSE(connection_.HasQueuedData());
@@ -2139,8 +2169,7 @@ TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) {
sequence_number_length_ = lengths[i];
fec_packet += 2;
// Don't send missing packet, but send fec packet right after it.
- ProcessFecPacket(/*seq_num=*/fec_packet, /*fec_group=*/fec_packet - 1,
- true, !kEntropyFlag, NULL);
+ ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL);
// Sequence number length in the revived header should be the same as
// in the original data/fec packet headers.
EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header().
@@ -2168,8 +2197,7 @@ TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) {
connection_id_length_ = lengths[i];
fec_packet += 2;
// Don't send missing packet, but send fec packet right after it.
- ProcessFecPacket(/*seq_num=*/fec_packet, /*fec_group=*/fec_packet - 1,
- true, !kEntropyFlag, NULL);
+ ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL);
// Connection id length in the revived header should be the same as
// in the original data/fec packet headers.
EXPECT_EQ(connection_id_length_,
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_data_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698