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

Unified Diff: net/quic/quic_connection_test.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
Index: net/quic/quic_connection_test.cc
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 3a0c172754504510c78a7ca3a05564e5ebc61d1d..a93905465995ed1fd950c83ffc71d1d6721f7ab0 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -67,8 +67,7 @@ const QuicStreamId kStreamId5 = 5;
class TestReceiveAlgorithm : public ReceiveAlgorithmInterface {
public:
explicit TestReceiveAlgorithm(QuicCongestionFeedbackFrame* feedback)
- : feedback_(feedback) {
- }
+ : feedback_(feedback) {}
bool GenerateCongestionFeedback(
QuicCongestionFeedbackFrame* congestion_feedback) {
@@ -91,9 +90,7 @@ class TestReceiveAlgorithm : public ReceiveAlgorithmInterface {
// TaggingEncrypter appends kTagSize bytes of |tag| to the end of each message.
class TaggingEncrypter : public QuicEncrypter {
public:
- explicit TaggingEncrypter(uint8 tag)
- : tag_(tag) {
- }
+ explicit TaggingEncrypter(uint8 tag) : tag_(tag) {}
virtual ~TaggingEncrypter() {}
@@ -133,13 +130,9 @@ class TaggingEncrypter : public QuicEncrypter {
return plaintext_size + kTagSize;
}
- virtual StringPiece GetKey() const OVERRIDE {
- return StringPiece();
- }
+ virtual StringPiece GetKey() const OVERRIDE { return StringPiece(); }
- virtual StringPiece GetNoncePrefix() const OVERRIDE {
- return StringPiece();
- }
+ virtual StringPiece GetNoncePrefix() const OVERRIDE { return StringPiece(); }
private:
enum {
@@ -191,8 +184,8 @@ class TaggingDecrypter : public QuicDecrypter {
const size_t len = ciphertext.size() - kTagSize;
uint8* buf = new uint8[len];
memcpy(buf, ciphertext.data(), len);
- return new QuicData(reinterpret_cast<char*>(buf), len,
- true /* owns buffer */);
+ return new QuicData(
+ reinterpret_cast<char*>(buf), len, true /* owns buffer */);
}
virtual StringPiece GetKey() const OVERRIDE { return StringPiece(); }
@@ -200,7 +193,7 @@ class TaggingDecrypter : public QuicDecrypter {
protected:
virtual uint8 GetTag(StringPiece ciphertext) {
- return ciphertext.data()[ciphertext.size()-1];
+ return ciphertext.data()[ciphertext.size() - 1];
}
private:
@@ -227,9 +220,7 @@ class StrictTaggingDecrypter : public TaggingDecrypter {
virtual ~StrictTaggingDecrypter() {}
// TaggingQuicDecrypter
- virtual uint8 GetTag(StringPiece ciphertext) OVERRIDE {
- return tag_;
- }
+ virtual uint8 GetTag(StringPiece ciphertext) OVERRIDE { return tag_; }
private:
const uint8 tag_;
@@ -239,9 +230,7 @@ class TestConnectionHelper : public QuicConnectionHelperInterface {
public:
class TestAlarm : public QuicAlarm {
public:
- explicit TestAlarm(QuicAlarm::Delegate* delegate)
- : QuicAlarm(delegate) {
- }
+ explicit TestAlarm(QuicAlarm::Delegate* delegate) : QuicAlarm(delegate) {}
virtual void SetImpl() OVERRIDE {}
virtual void CancelImpl() OVERRIDE {}
@@ -249,15 +238,12 @@ class TestConnectionHelper : public QuicConnectionHelperInterface {
};
TestConnectionHelper(MockClock* clock, MockRandom* random_generator)
- : clock_(clock),
- random_generator_(random_generator) {
+ : clock_(clock), random_generator_(random_generator) {
clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
}
// QuicConnectionHelperInterface
- virtual const QuicClock* GetClock() const OVERRIDE {
- return clock_;
- }
+ virtual const QuicClock* GetClock() const OVERRIDE { return clock_; }
virtual QuicRandom* GetRandomGenerator() OVERRIDE {
return random_generator_;
@@ -286,20 +272,20 @@ class TestPacketWriter : public QuicPacketWriter {
final_bytes_of_last_packet_(0),
final_bytes_of_previous_packet_(0),
use_tagging_decrypter_(false),
- packets_write_attempts_(0) {
- }
+ packets_write_attempts_(0) {}
// QuicPacketWriter interface
- virtual WriteResult WritePacket(
- const char* buffer, size_t buf_len,
- const IPAddressNumber& self_address,
- const IPEndPoint& peer_address) OVERRIDE {
+ virtual WriteResult WritePacket(const char* buffer,
+ size_t buf_len,
+ const IPAddressNumber& self_address,
+ const IPEndPoint& peer_address) OVERRIDE {
QuicEncryptedPacket packet(buffer, buf_len);
++packets_write_attempts_;
if (packet.length() >= sizeof(final_bytes_of_last_packet_)) {
final_bytes_of_previous_packet_ = final_bytes_of_last_packet_;
- memcpy(&final_bytes_of_last_packet_, packet.data() + packet.length() - 4,
+ memcpy(&final_bytes_of_last_packet_,
+ packet.data() + packet.length() - 4,
sizeof(final_bytes_of_last_packet_));
}
@@ -356,9 +342,7 @@ class TestPacketWriter : public QuicPacketWriter {
return framer_.ping_frames();
}
- size_t last_packet_size() {
- return last_packet_size_;
- }
+ size_t last_packet_size() { return last_packet_size_; }
const QuicVersionNegotiationPacket* version_negotiation_packet() {
return framer_.version_negotiation_packet();
@@ -385,9 +369,7 @@ class TestPacketWriter : public QuicPacketWriter {
return final_bytes_of_previous_packet_;
}
- void use_tagging_decrypter() {
- use_tagging_decrypter_ = true;
- }
+ void use_tagging_decrypter() { use_tagging_decrypter_ = true; }
uint32 packets_write_attempts() { return packets_write_attempts_; }
@@ -421,7 +403,11 @@ class TestConnection : public QuicConnection {
bool is_server,
QuicVersion version,
uint32 flow_control_send_window)
- : QuicConnection(connection_id, address, helper, writer, is_server,
+ : QuicConnection(connection_id,
+ address,
+ helper,
+ writer,
+ is_server,
SupportedVersions(version),
flow_control_send_window),
writer_(writer) {
@@ -431,12 +417,10 @@ class TestConnection : public QuicConnection {
writer_->set_is_server(is_server);
}
- void SendAck() {
- QuicConnectionPeer::SendAck(this);
- }
+ void SendAck() { QuicConnectionPeer::SendAck(this); }
void SetReceiveAlgorithm(TestReceiveAlgorithm* receive_algorithm) {
- QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm);
+ QuicConnectionPeer::SetReceiveAlgorithm(this, receive_algorithm);
}
void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
@@ -454,11 +438,14 @@ class TestConnection : public QuicConnection {
QuicPacketEntropyHash entropy_hash,
HasRetransmittableData retransmittable) {
RetransmittableFrames* retransmittable_frames =
- retransmittable == HAS_RETRANSMITTABLE_DATA ?
- new RetransmittableFrames() : NULL;
- OnSerializedPacket(
- SerializedPacket(sequence_number, PACKET_6BYTE_SEQUENCE_NUMBER,
- packet, entropy_hash, retransmittable_frames));
+ retransmittable == HAS_RETRANSMITTABLE_DATA
+ ? new RetransmittableFrames()
+ : NULL;
+ OnSerializedPacket(SerializedPacket(sequence_number,
+ PACKET_6BYTE_SEQUENCE_NUMBER,
+ packet,
+ entropy_hash,
+ retransmittable_frames));
}
QuicConsumedData SendStreamDataWithString(
@@ -501,9 +488,7 @@ class TestConnection : public QuicConnection {
return consumed;
}
- bool is_server() {
- return QuicConnectionPeer::IsServer(this);
- }
+ bool is_server() { return QuicConnectionPeer::IsServer(this); }
void set_version(QuicVersion version) {
QuicConnectionPeer::GetFramer(this)->set_version(version);
@@ -569,9 +554,7 @@ class FecQuicConnectionDebugVisitor
}
// Public accessor method.
- QuicPacketHeader revived_header() const {
- return revived_header_;
- }
+ QuicPacketHeader revived_header() const { return revived_header_; }
private:
QuicPacketHeader revived_header_;
@@ -587,8 +570,12 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
loss_algorithm_(new MockLossAlgorithm()),
helper_(new TestConnectionHelper(&clock_, &random_generator_)),
writer_(new TestPacketWriter(version())),
- connection_(connection_id_, IPEndPoint(), helper_.get(),
- writer_.get(), false, version(),
+ connection_(connection_id_,
+ IPEndPoint(),
+ helper_.get(),
+ writer_.get(),
+ false,
+ version(),
kDefaultFlowControlSendWindow),
frame1_(1, false, 0, MakeIOVector(data1)),
frame2_(1, false, 3, MakeIOVector(data2)),
@@ -600,17 +587,15 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
framer_.set_received_entropy_calculator(&entropy_calculator_);
// Simplify tests by not sending feedback unless specifically configured.
SetFeedback(NULL);
- EXPECT_CALL(
- *send_algorithm_, TimeUntilSend(_, _)).WillRepeatedly(Return(
- QuicTime::Delta::Zero()));
- EXPECT_CALL(*receive_algorithm_,
- RecordIncomingPacket(_, _, _)).Times(AnyNumber());
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillRepeatedly(Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*receive_algorithm_, RecordIncomingPacket(_, _, _))
.Times(AnyNumber());
- EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
- Return(QuicTime::Delta::Zero()));
- EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
- Return(kMaxPacketSize));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(AnyNumber());
+ EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
+ .WillRepeatedly(Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
+ .WillRepeatedly(Return(kMaxPacketSize));
ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
.WillByDefault(Return(true));
EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber());
@@ -624,9 +609,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
.WillRepeatedly(Return(SequenceNumberSet()));
}
- QuicVersion version() {
- return GetParam();
- }
+ QuicVersion version() { return GetParam(); }
QuicAckFrame* outgoing_ack() {
outgoing_ack_.reset(QuicConnectionPeer::CreateAckFrame(&connection_));
@@ -646,9 +629,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
return writer_->stop_waiting_frames()[0].least_unacked;
}
- void use_tagging_decrypter() {
- writer_->use_tagging_decrypter();
- }
+ void use_tagging_decrypter() { writer_->use_tagging_decrypter(); }
void ProcessPacket(QuicPacketSequenceNumber number) {
EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1);
@@ -662,9 +643,8 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
connection_.is_server());
SerializedPacket serialized_packet = creator_.SerializeAllFrames(frames);
scoped_ptr<QuicPacket> packet(serialized_packet.packet);
- scoped_ptr<QuicEncryptedPacket> encrypted(
- framer_.EncryptPacket(ENCRYPTION_NONE,
- serialized_packet.sequence_number, *packet));
+ scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
+ ENCRYPTION_NONE, serialized_packet.sequence_number, *packet));
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
return serialized_packet.entropy_hash;
}
@@ -672,18 +652,18 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
size_t ProcessDataPacket(QuicPacketSequenceNumber number,
QuicFecGroupNumber fec_group,
bool entropy_flag) {
- return ProcessDataPacketAtLevel(number, fec_group, entropy_flag,
- ENCRYPTION_NONE);
+ return ProcessDataPacketAtLevel(
+ number, fec_group, entropy_flag, ENCRYPTION_NONE);
}
size_t ProcessDataPacketAtLevel(QuicPacketSequenceNumber number,
QuicFecGroupNumber fec_group,
bool entropy_flag,
EncryptionLevel level) {
- scoped_ptr<QuicPacket> packet(ConstructDataPacket(number, fec_group,
- entropy_flag));
- scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
- level, number, *packet));
+ scoped_ptr<QuicPacket> packet(
+ ConstructDataPacket(number, fec_group, entropy_flag));
+ scoped_ptr<QuicEncryptedPacket> encrypted(
+ framer_.EncryptPacket(level, number, *packet));
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
return encrypted->length();
}
@@ -691,18 +671,18 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
void ProcessClosePacket(QuicPacketSequenceNumber number,
QuicFecGroupNumber fec_group) {
scoped_ptr<QuicPacket> packet(ConstructClosePacket(number, fec_group));
- scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
- ENCRYPTION_NONE, number, *packet));
+ scoped_ptr<QuicEncryptedPacket> encrypted(
+ framer_.EncryptPacket(ENCRYPTION_NONE, number, *packet));
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
}
size_t ProcessFecProtectedPacket(QuicPacketSequenceNumber number,
- bool expect_revival, bool entropy_flag) {
+ bool expect_revival,
+ bool entropy_flag) {
if (expect_revival) {
EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1);
}
- EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1).
- RetiresOnSaturation();
+ EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1).RetiresOnSaturation();
return ProcessDataPacket(number, 1, entropy_flag);
}
@@ -748,7 +728,8 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
header_.public_header.connection_id_length,
header_.public_header.version_flag,
header_.public_header.sequence_number_length);
- i < data_packet->length(); ++i) {
+ i < data_packet->length();
+ ++i) {
data_packet->mutable_data()[i] ^= data_packet->data()[i];
}
}
@@ -776,16 +757,14 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
*last_packet =
QuicConnectionPeer::GetPacketCreator(&connection_)->sequence_number();
}
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .Times(AnyNumber());
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(AnyNumber());
return packet_size;
}
void SendAckPacketToPeer() {
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(1);
connection_.SendAck();
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .Times(AnyNumber());
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(AnyNumber());
}
QuicPacketEntropyHash ProcessAckPacket(QuicAckFrame* frame) {
@@ -821,8 +800,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
QuicFrames frames;
QuicFrame frame(&frame1_);
frames.push_back(frame);
- QuicPacket* packet =
- framer_.BuildUnsizedDataPacket(header_, frames).packet;
+ QuicPacket* packet = framer_.BuildUnsizedDataPacket(header_, frames).packet;
EXPECT_TRUE(packet != NULL);
return packet;
}
@@ -844,8 +822,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
QuicFrames frames;
QuicFrame frame(&qccf);
frames.push_back(frame);
- QuicPacket* packet =
- framer_.BuildUnsizedDataPacket(header_, frames).packet;
+ QuicPacket* packet = framer_.BuildUnsizedDataPacket(header_, frames).packet;
EXPECT_TRUE(packet != NULL);
return packet;
}
@@ -860,7 +837,7 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
}
QuicTime::Delta DefaultDelayedAckTime() {
- return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2);
+ return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs / 2);
}
// Initialize a frame acknowledging all packets up to largest_observed.
@@ -868,8 +845,8 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
QuicPacketSequenceNumber least_unacked) {
QuicAckFrame frame(MakeAckFrame(largest_observed, least_unacked));
if (largest_observed > 0) {
- frame.received_info.entropy_hash =
- QuicConnectionPeer::GetSentEntropyHash(&connection_, largest_observed);
+ frame.received_info.entropy_hash = QuicConnectionPeer::GetSentEntropyHash(
+ &connection_, largest_observed);
}
return frame;
}
@@ -884,10 +861,10 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
void NackPacket(QuicPacketSequenceNumber missing, QuicAckFrame* frame) {
frame->received_info.missing_packets.insert(missing);
frame->received_info.entropy_hash ^=
- QuicConnectionPeer::GetSentEntropyHash(&connection_, missing);
+ QuicConnectionPeer::GetSentEntropyHash(&connection_, missing);
if (missing > 1) {
frame->received_info.entropy_hash ^=
- QuicConnectionPeer::GetSentEntropyHash(&connection_, missing - 1);
+ QuicConnectionPeer::GetSentEntropyHash(&connection_, missing - 1);
}
}
@@ -896,10 +873,10 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
EXPECT_THAT(frame->received_info.missing_packets, Contains(arrived));
frame->received_info.missing_packets.erase(arrived);
frame->received_info.entropy_hash ^=
- QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived);
+ QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived);
if (arrived > 1) {
frame->received_info.entropy_hash ^=
- QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived - 1);
+ QuicConnectionPeer::GetSentEntropyHash(&connection_, arrived - 1);
}
}
@@ -910,8 +887,8 @@ class QuicConnectionTest : public ::testing::TestWithParam<QuicVersion> {
// Call ProcessDataPacket rather than ProcessPacket, as we should not get a
// packet call to the visitor.
ProcessDataPacket(6000, 0, !kEntropyFlag);
- EXPECT_FALSE(
- QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL);
+ EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) ==
+ NULL);
}
void BlockOnNextWrite() {
@@ -1032,24 +1009,23 @@ TEST_P(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) {
}
TEST_P(QuicConnectionTest, RejectPacketTooFarOut) {
- EXPECT_CALL(visitor_,
- OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
// Call ProcessDataPacket rather than ProcessPacket, as we should not get a
// packet call to the visitor.
ProcessDataPacket(6000, 0, !kEntropyFlag);
- EXPECT_FALSE(
- QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL);
+ EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) ==
+ NULL);
}
TEST_P(QuicConnectionTest, RejectUnencryptedStreamData) {
// Process an unencrypted packet from the non-crypto stream.
frame1_.stream_id = 3;
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA,
- false));
+ EXPECT_CALL(visitor_,
+ OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, false));
ProcessDataPacket(1, 0, !kEntropyFlag);
- EXPECT_FALSE(
- QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL);
+ EXPECT_FALSE(QuicConnectionPeer::GetConnectionClosePacket(&connection_) ==
+ NULL);
const vector<QuicConnectionCloseFrame>& connection_close_frames =
writer_->connection_close_frames();
EXPECT_EQ(1u, connection_close_frames.size());
@@ -1075,8 +1051,8 @@ TEST_P(QuicConnectionTest, TruncatedAck) {
}
EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
.WillOnce(Return(lost_packets));
- EXPECT_CALL(entropy_calculator_,
- EntropyHash(511)).WillOnce(testing::Return(0));
+ 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);
@@ -1107,16 +1083,14 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) {
ProcessPacket(1);
// Delay sending, then queue up an ack.
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(1)));
+ EXPECT_CALL(*send_algorithm_, 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(
- testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
// Skip a packet and then record an ack.
creator_.set_sequence_number(2);
QuicAckFrame frame = InitAckFrame(0, 3);
@@ -1148,9 +1122,8 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
QuicPacketSequenceNumber original;
QuicByteCount packet_size;
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .WillOnce(DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size),
- Return(true)));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).WillOnce(
+ DoAll(SaveArg<1>(&original), SaveArg<2>(&packet_size), Return(true)));
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
QuicAckFrame frame = InitAckFrame(original, 1);
NackPacket(original, &frame);
@@ -1180,8 +1153,8 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
// Now if the peer sends an ack which still reports the retransmitted packet
// as missing, that will bundle an ack with data after two acks in a row
// indicate the high water mark needs to be raised.
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _,
- HAS_RETRANSMITTABLE_DATA));
+ EXPECT_CALL(*send_algorithm_,
+ OnPacketSent(_, _, _, HAS_RETRANSMITTABLE_DATA));
connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
// No ack sent.
EXPECT_EQ(1u, writer_->frame_count());
@@ -1191,8 +1164,8 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) {
EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
.WillRepeatedly(Return(SequenceNumberSet()));
ProcessAckPacket(&frame2);
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _,
- HAS_RETRANSMITTABLE_DATA));
+ EXPECT_CALL(*send_algorithm_,
+ OnPacketSent(_, _, _, HAS_RETRANSMITTABLE_DATA));
connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
// Ack bundled.
if (version() > QUIC_VERSION_15) {
@@ -1304,8 +1277,8 @@ TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsBandwidth) {
EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER,
writer_->header().public_header.sequence_number_length);
- EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
- Return(kMaxPacketSize * 256));
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
+ .WillRepeatedly(Return(kMaxPacketSize * 256));
SendStreamDataToPeer(1, "bar", 3, !kFin, &last_packet);
EXPECT_EQ(2u, last_packet);
@@ -1316,8 +1289,8 @@ TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsBandwidth) {
EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER,
writer_->header().public_header.sequence_number_length);
- EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
- Return(kMaxPacketSize * 256 * 256));
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
+ .WillRepeatedly(Return(kMaxPacketSize * 256 * 256));
SendStreamDataToPeer(1, "foo", 6, !kFin, &last_packet);
EXPECT_EQ(3u, last_packet);
@@ -1326,8 +1299,8 @@ TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsBandwidth) {
EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER,
writer_->header().public_header.sequence_number_length);
- EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
- Return(kMaxPacketSize * 256 * 256 * 256));
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
+ .WillRepeatedly(Return(kMaxPacketSize * 256 * 256 * 256));
SendStreamDataToPeer(1, "bar", 9, !kFin, &last_packet);
EXPECT_EQ(4u, last_packet);
@@ -1336,8 +1309,8 @@ TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsBandwidth) {
EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER,
writer_->header().public_header.sequence_number_length);
- EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
- Return(kMaxPacketSize * 256 * 256 * 256 * 256));
+ EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
+ .WillRepeatedly(Return(kMaxPacketSize * 256 * 256 * 256 * 256));
SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet);
EXPECT_EQ(5u, last_packet);
@@ -1364,8 +1337,8 @@ TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsUnackedDelta) {
EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER,
writer_->header().public_header.sequence_number_length);
- QuicConnectionPeer::GetPacketCreator(&connection_)->set_sequence_number(
- 100 * 256);
+ QuicConnectionPeer::GetPacketCreator(&connection_)
+ ->set_sequence_number(100 * 256);
SendStreamDataToPeer(1, "foo", 6, !kFin, &last_packet);
EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER,
@@ -1373,8 +1346,8 @@ TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsUnackedDelta) {
EXPECT_EQ(PACKET_2BYTE_SEQUENCE_NUMBER,
writer_->header().public_header.sequence_number_length);
- QuicConnectionPeer::GetPacketCreator(&connection_)->set_sequence_number(
- 100 * 256 * 256);
+ QuicConnectionPeer::GetPacketCreator(&connection_)
+ ->set_sequence_number(100 * 256 * 256);
SendStreamDataToPeer(1, "bar", 9, !kFin, &last_packet);
EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER,
@@ -1382,8 +1355,8 @@ TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsUnackedDelta) {
EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER,
writer_->header().public_header.sequence_number_length);
- QuicConnectionPeer::GetPacketCreator(&connection_)->set_sequence_number(
- 100 * 256 * 256 * 256);
+ QuicConnectionPeer::GetPacketCreator(&connection_)
+ ->set_sequence_number(100 * 256 * 256 * 256);
SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet);
EXPECT_EQ(PACKET_6BYTE_SEQUENCE_NUMBER,
@@ -1452,9 +1425,11 @@ TEST_P(QuicConnectionTest, FECSending) {
// All packets carry version info till version is negotiated.
size_t payload_length;
connection_.options()->max_packet_length =
- GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
- IN_FEC_GROUP, &payload_length);
+ GetPacketLengthForOneStream(connection_.version(),
+ kIncludeVersion,
+ PACKET_1BYTE_SEQUENCE_NUMBER,
+ IN_FEC_GROUP,
+ &payload_length);
// And send FEC every two packets.
connection_.options()->max_packets_per_fec_group = 2;
@@ -1474,9 +1449,11 @@ TEST_P(QuicConnectionTest, FECQueueing) {
// All packets carry version info till version is negotiated.
size_t payload_length;
connection_.options()->max_packet_length =
- GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
- IN_FEC_GROUP, &payload_length);
+ GetPacketLengthForOneStream(connection_.version(),
+ kIncludeVersion,
+ PACKET_1BYTE_SEQUENCE_NUMBER,
+ IN_FEC_GROUP,
+ &payload_length);
// And send FEC every two packets.
connection_.options()->max_packets_per_fec_group = 2;
@@ -1591,11 +1568,11 @@ TEST_P(QuicConnectionTest, FramePacking) {
// Send an ack and two stream frames in 1 packet by queueing them.
connection_.SendAck();
- EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData3)),
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData5))));
+ EXPECT_CALL(visitor_, OnCanWrite())
+ .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData3)),
+ IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData5))));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(1);
// Unblock the connection.
@@ -1626,8 +1603,8 @@ TEST_P(QuicConnectionTest, FramePackingNonCryptoThenCrypto) {
// packets by queueing them.
connection_.SendAck();
EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData3)),
+ IgnoreResult(
+ InvokeWithoutArgs(&connection_, &TestConnection::SendStreamData3)),
IgnoreResult(InvokeWithoutArgs(&connection_,
&TestConnection::SendCryptoStreamData))));
@@ -1651,11 +1628,11 @@ TEST_P(QuicConnectionTest, FramePackingCryptoThenNonCrypto) {
// Send an ack and two stream frames (one crypto, then one non-crypto) in 3
// packets by queueing them.
connection_.SendAck();
- EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendCryptoStreamData)),
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData3))));
+ EXPECT_CALL(visitor_, OnCanWrite())
+ .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendCryptoStreamData)),
+ IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData3))));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(3);
// Unblock the connection.
@@ -1681,11 +1658,11 @@ TEST_P(QuicConnectionTest, FramePackingFEC) {
// Send an ack and two stream frames in 1 packet by queueing them.
connection_.SendAck();
- EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData3)),
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData5))));
+ EXPECT_CALL(visitor_, OnCanWrite())
+ .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData3)),
+ IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData5))));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(2);
// Unblock the connection.
@@ -1704,11 +1681,11 @@ TEST_P(QuicConnectionTest, FramePackingAckResponse) {
EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1);
ProcessDataPacket(1, 1, kEntropyFlag);
- EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData3)),
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData5))));
+ EXPECT_CALL(visitor_, OnCanWrite())
+ .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData3)),
+ IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData5))));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(1);
@@ -1754,9 +1731,9 @@ TEST_P(QuicConnectionTest, FramePackingSendv) {
EXPECT_EQ(1u, writer_->stream_frames().size());
QuicStreamFrame frame = writer_->stream_frames()[0];
EXPECT_EQ(1u, frame.stream_id);
- EXPECT_EQ("ABCD", string(static_cast<char*>
- (frame.data.iovec()[0].iov_base),
- (frame.data.iovec()[0].iov_len)));
+ EXPECT_EQ("ABCD",
+ string(static_cast<char*>(frame.data.iovec()[0].iov_base),
+ (frame.data.iovec()[0].iov_len)));
}
TEST_P(QuicConnectionTest, FramePackingSendvQueued) {
@@ -1802,15 +1779,14 @@ TEST_P(QuicConnectionTest, SendingZeroBytes) {
TEST_P(QuicConnectionTest, OnCanWrite) {
// Visitor's OnCanWrite will send data, but will have more pending writes.
- EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData3)),
- IgnoreResult(InvokeWithoutArgs(&connection_,
- &TestConnection::SendStreamData5))));
+ EXPECT_CALL(visitor_, OnCanWrite())
+ .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData3)),
+ IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::SendStreamData5))));
EXPECT_CALL(visitor_, HasPendingWrites()).WillOnce(Return(true));
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillRepeatedly(
- testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
connection_.OnCanWrite();
@@ -1828,7 +1804,7 @@ TEST_P(QuicConnectionTest, RetransmitOnNack) {
SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 1
second_packet_size =
SendStreamDataToPeer(3, "foos", 3, !kFin, &last_packet); // Packet 2
- SendStreamDataToPeer(3, "fooos", 7, !kFin, &last_packet); // Packet 3
+ SendStreamDataToPeer(3, "fooos", 7, !kFin, &last_packet); // Packet 3
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
@@ -1850,15 +1826,15 @@ TEST_P(QuicConnectionTest, RetransmitOnNack) {
EXPECT_CALL(*send_algorithm_, OnPacketLost(2, _)).Times(1);
EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(2, _)).Times(1);
EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, second_packet_size - kQuicVersionSize, _)).
- Times(1);
+ OnPacketSent(_, _, second_packet_size - kQuicVersionSize, _))
+ .Times(1);
ProcessAckPacket(&nack_two);
}
TEST_P(QuicConnectionTest, DiscardRetransmit) {
QuicPacketSequenceNumber last_packet;
- SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
- SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
+ SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
+ SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
@@ -1889,8 +1865,7 @@ TEST_P(QuicConnectionTest, DiscardRetransmit) {
// Unblock the socket and attempt to send the queued packets. However,
// since the previous transmission has been acked, we will not
// send the retransmission.
- EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, _, _)).Times(0);
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(0);
writer_->SetWritable();
connection_.OnCanWrite();
@@ -1902,9 +1877,8 @@ TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
QuicPacketSequenceNumber largest_observed;
QuicByteCount packet_size;
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .WillOnce(DoAll(SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size),
- Return(true)));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).WillOnce(DoAll(
+ SaveArg<1>(&largest_observed), SaveArg<2>(&packet_size), Return(true)));
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
QuicAckFrame frame = InitAckFrame(1, largest_observed);
@@ -2052,7 +2026,7 @@ TEST_P(QuicConnectionTest, MultipleAcks) {
EXPECT_EQ(1u, last_packet);
SendStreamDataToPeer(3, "foo", 0, !kFin, &last_packet); // Packet 2
EXPECT_EQ(2u, last_packet);
- SendAckPacketToPeer(); // Packet 3
+ SendAckPacketToPeer(); // Packet 3
SendStreamDataToPeer(5, "foo", 0, !kFin, &last_packet); // Packet 4
EXPECT_EQ(4u, last_packet);
SendStreamDataToPeer(1, "foo", 3, !kFin, &last_packet); // Packet 5
@@ -2081,7 +2055,7 @@ TEST_P(QuicConnectionTest, DontLatchUnackedPacket) {
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(_, _, _, _))
- .WillByDefault(Return(false));
+ .WillByDefault(Return(false));
SendAckPacketToPeer(); // Packet 2
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
@@ -2112,18 +2086,18 @@ TEST_P(QuicConnectionTest, DontLatchUnackedPacket) {
ProcessAckPacket(&frame);
ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .WillByDefault(Return(true));
+ .WillByDefault(Return(true));
SendStreamDataToPeer(1, "bar", 3, false, NULL); // Packet 4
EXPECT_EQ(4u, outgoing_ack()->sent_info.least_unacked);
ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .WillByDefault(Return(false));
+ .WillByDefault(Return(false));
SendAckPacketToPeer(); // Packet 5
EXPECT_EQ(4u, least_unacked());
// Send two data packets at the end, and ensure if the last one is acked,
// the least unacked is raised above the ack packets.
ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .WillByDefault(Return(true));
+ .WillByDefault(Return(true));
SendStreamDataToPeer(1, "bar", 6, false, NULL); // Packet 6
SendStreamDataToPeer(1, "bar", 9, false, NULL); // Packet 7
@@ -2156,15 +2130,14 @@ TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
// Set up a debug visitor to the connection.
- scoped_ptr<FecQuicConnectionDebugVisitor>
- fec_visitor(new FecQuicConnectionDebugVisitor);
+ scoped_ptr<FecQuicConnectionDebugVisitor> fec_visitor(
+ new FecQuicConnectionDebugVisitor);
connection_.set_debug_visitor(fec_visitor.get());
QuicPacketSequenceNumber fec_packet = 0;
- QuicSequenceNumberLength lengths[] = {PACKET_6BYTE_SEQUENCE_NUMBER,
- PACKET_4BYTE_SEQUENCE_NUMBER,
- PACKET_2BYTE_SEQUENCE_NUMBER,
- PACKET_1BYTE_SEQUENCE_NUMBER};
+ QuicSequenceNumberLength lengths[] = {
+ PACKET_6BYTE_SEQUENCE_NUMBER, PACKET_4BYTE_SEQUENCE_NUMBER,
+ PACKET_2BYTE_SEQUENCE_NUMBER, PACKET_1BYTE_SEQUENCE_NUMBER};
// For each sequence number length size, revive a packet and check sequence
// number length in the revived packet.
for (size_t i = 0; i < arraysize(lengths); ++i) {
@@ -2172,12 +2145,16 @@ 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(/*seq_num=*/fec_packet,
+ /*fec_group=*/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().
- public_header.sequence_number_length);
+ EXPECT_EQ(
+ sequence_number_length_,
+ fec_visitor->revived_header().public_header.sequence_number_length);
}
}
@@ -2188,15 +2165,14 @@ TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
// Set up a debug visitor to the connection.
- scoped_ptr<FecQuicConnectionDebugVisitor>
- fec_visitor(new FecQuicConnectionDebugVisitor);
+ scoped_ptr<FecQuicConnectionDebugVisitor> fec_visitor(
+ new FecQuicConnectionDebugVisitor);
connection_.set_debug_visitor(fec_visitor.get());
QuicPacketSequenceNumber fec_packet = 0;
- QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID,
- PACKET_4BYTE_CONNECTION_ID,
- PACKET_1BYTE_CONNECTION_ID,
- PACKET_0BYTE_CONNECTION_ID};
+ QuicConnectionIdLength lengths[] = {
+ PACKET_8BYTE_CONNECTION_ID, PACKET_4BYTE_CONNECTION_ID,
+ PACKET_1BYTE_CONNECTION_ID, PACKET_0BYTE_CONNECTION_ID};
// For each connection id length size, revive a packet and check connection
// id length in the revived packet.
for (size_t i = 0; i < arraysize(lengths); ++i) {
@@ -2204,8 +2180,11 @@ 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(/*seq_num=*/fec_packet,
+ /*fec_group=*/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_,
@@ -2273,8 +2252,8 @@ TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPackets) {
}
TEST_P(QuicConnectionTest, RTO) {
- QuicTime default_retransmission_time = clock_.ApproximateNow().Add(
- DefaultRetransmissionTime());
+ QuicTime default_retransmission_time =
+ clock_.ApproximateNow().Add(DefaultRetransmissionTime());
SendStreamDataToPeer(3, "foo", 0, !kFin, NULL);
EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked);
@@ -2292,8 +2271,8 @@ TEST_P(QuicConnectionTest, RTO) {
}
TEST_P(QuicConnectionTest, RTOWithSameEncryptionLevel) {
- QuicTime default_retransmission_time = clock_.ApproximateNow().Add(
- DefaultRetransmissionTime());
+ QuicTime default_retransmission_time =
+ clock_.ApproximateNow().Add(DefaultRetransmissionTime());
use_tagging_decrypter();
// A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at
@@ -2334,9 +2313,8 @@ TEST_P(QuicConnectionTest, SendHandshakeMessages) {
connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01));
// Attempt to send a handshake message and have the socket block.
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillRepeatedly(
- testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
BlockOnNextWrite();
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL);
// The packet should be serialized, but not queued.
@@ -2370,8 +2348,8 @@ TEST_P(QuicConnectionTest,
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(0);
- QuicTime default_retransmission_time = clock_.ApproximateNow().Add(
- DefaultRetransmissionTime());
+ QuicTime default_retransmission_time =
+ clock_.ApproximateNow().Add(DefaultRetransmissionTime());
EXPECT_EQ(default_retransmission_time,
connection_.GetRetransmissionAlarm()->deadline());
@@ -2412,8 +2390,7 @@ TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) {
// Transition to the new encryption state and process another
// encrypted packet which should result in the original packet being
// processed.
- connection_.SetDecrypter(new StrictTaggingDecrypter(tag),
- ENCRYPTION_INITIAL);
+ connection_.SetDecrypter(new StrictTaggingDecrypter(tag), ENCRYPTION_INITIAL);
connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(2);
@@ -2427,13 +2404,13 @@ TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) {
TEST_P(QuicConnectionTest, TestRetransmitOrder) {
QuicByteCount first_packet_size;
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).WillOnce(
- DoAll(SaveArg<2>(&first_packet_size), Return(true)));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&first_packet_size), Return(true)));
connection_.SendStreamDataWithString(3, "first_packet", 0, !kFin, NULL);
QuicByteCount second_packet_size;
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).WillOnce(
- DoAll(SaveArg<2>(&second_packet_size), Return(true)));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
+ .WillOnce(DoAll(SaveArg<2>(&second_packet_size), Return(true)));
connection_.SendStreamDataWithString(3, "second_packet", 12, !kFin, NULL);
EXPECT_NE(first_packet_size, second_packet_size);
// Advance the clock by huge time to make sure packets will be retransmitted.
@@ -2441,10 +2418,8 @@ TEST_P(QuicConnectionTest, TestRetransmitOrder) {
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
{
InSequence s;
- EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, first_packet_size, _));
- EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, second_packet_size, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, first_packet_size, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, second_packet_size, _));
}
connection_.GetRetransmissionAlarm()->Fire();
@@ -2453,10 +2428,8 @@ TEST_P(QuicConnectionTest, TestRetransmitOrder) {
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
{
InSequence s;
- EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, first_packet_size, _));
- EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, second_packet_size, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, first_packet_size, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, second_packet_size, _));
}
connection_.GetRetransmissionAlarm()->Fire();
}
@@ -2470,8 +2443,8 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
EXPECT_TRUE(QuicConnectionPeer::IsSavedForRetransmission(
&connection_, original_sequence_number));
- EXPECT_FALSE(QuicConnectionPeer::IsRetransmission(
- &connection_, original_sequence_number));
+ EXPECT_FALSE(QuicConnectionPeer::IsRetransmission(&connection_,
+ original_sequence_number));
// Force retransmission due to RTO.
clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10));
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
@@ -2483,8 +2456,8 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
&connection_, original_sequence_number));
ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission(
&connection_, rto_sequence_number));
- EXPECT_TRUE(QuicConnectionPeer::IsRetransmission(
- &connection_, rto_sequence_number));
+ EXPECT_TRUE(
+ QuicConnectionPeer::IsRetransmission(&connection_, rto_sequence_number));
// Once by explicit nack.
SequenceNumberSet lost_packets;
lost_packets.insert(rto_sequence_number);
@@ -2492,13 +2465,12 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
.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_, OnPacketAbandoned(rto_sequence_number, _))
+ .Times(1);
QuicPacketSequenceNumber nack_sequence_number = 0;
// Ack packets might generate some other packets, which are not
// retransmissions. (More ack packets).
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .Times(AnyNumber());
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(AnyNumber());
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
.WillOnce(DoAll(SaveArg<1>(&nack_sequence_number), Return(true)));
QuicAckFrame ack = InitAckFrame(rto_sequence_number, 0);
@@ -2512,8 +2484,8 @@ TEST_P(QuicConnectionTest, RetransmissionCountCalculation) {
&connection_, rto_sequence_number));
ASSERT_TRUE(QuicConnectionPeer::IsSavedForRetransmission(
&connection_, nack_sequence_number));
- EXPECT_TRUE(QuicConnectionPeer::IsRetransmission(
- &connection_, nack_sequence_number));
+ EXPECT_TRUE(
+ QuicConnectionPeer::IsRetransmission(&connection_, nack_sequence_number));
}
TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) {
@@ -2530,8 +2502,7 @@ TEST_P(QuicConnectionTest, SetRTOAfterWritingToSocket) {
TEST_P(QuicConnectionTest, DelayRTOWithAckReceipt) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
- EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _))
- .Times(2);
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).Times(2);
connection_.SendStreamDataWithString(2, "foo", 0, !kFin, NULL);
connection_.SendStreamDataWithString(3, "bar", 0, !kFin, NULL);
QuicAlarm* retransmission_alarm = connection_.GetRetransmissionAlarm();
@@ -2648,8 +2619,7 @@ TEST_P(QuicConnectionTest, InitialTimeout) {
EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
// Simulate the timeout alarm firing.
- clock_.AdvanceTime(
- QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs));
+ clock_.AdvanceTime(QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs));
connection_.GetTimeoutAlarm()->Fire();
EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
EXPECT_FALSE(connection_.connected());
@@ -2747,9 +2717,8 @@ TEST_P(QuicConnectionTest, TimeoutAfterSend) {
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(
- testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::Zero()));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _));
connection_.SendPacket(
ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
@@ -2759,9 +2728,8 @@ TEST_P(QuicConnectionTest, SendScheduler) {
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(
- testing::Return(QuicTime::Delta::FromMicroseconds(1)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(1)));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 1, _, _)).Times(0);
connection_.SendPacket(
ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
@@ -2771,9 +2739,8 @@ TEST_P(QuicConnectionTest, SendSchedulerDelay) {
TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) {
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
BlockOnNextWrite();
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::Zero()));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 1, _, _)).Times(0);
connection_.SendPacket(
ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
@@ -2783,18 +2750,16 @@ TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) {
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(
- testing::Return(QuicTime::Delta::FromMicroseconds(1)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(1)));
connection_.SendPacket(
- ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
+ ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
// Advance the clock to fire the alarm, and configure the scheduler
// to permit the packet to be sent.
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillRepeatedly(
- testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1));
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _));
connection_.GetSendAlarm()->Fire();
@@ -2812,17 +2777,15 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
// Test that if we send a retransmit with a delay, it ends up queued in the
// sent packet manager, but not yet serialized.
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(1)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(1)));
connection_.GetRetransmissionAlarm()->Fire();
EXPECT_EQ(0u, connection_.NumQueuedPackets());
// 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).
- WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)).Times(3).WillRepeatedly(
+ testing::Return(QuicTime::Delta::Zero()));
// Ensure the scheduler is notified this is a retransmit.
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _));
@@ -2833,9 +2796,8 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
TEST_P(QuicConnectionTest, SendSchedulerDelayAndQueue) {
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(1)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(1)));
connection_.SendPacket(
ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
@@ -2850,9 +2812,8 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayAndQueue) {
TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(10)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(10)));
connection_.SendPacket(
ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
@@ -2860,11 +2821,9 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
// Now send non-retransmitting information, that we're not going to
// retransmit 3. The far end should stop waiting for it.
QuicAckFrame frame = InitAckFrame(0, 1);
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillRepeatedly(
- testing::Return(QuicTime::Delta::Zero()));
- EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, _, _));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _));
ProcessAckPacket(&frame);
EXPECT_EQ(0u, connection_.NumQueuedPackets());
@@ -2875,9 +2834,8 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(10)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(10)));
connection_.SendPacket(
ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
@@ -2885,9 +2843,8 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) {
// Now send non-retransmitting information, that we're not going to
// retransmit 3. The far end should stop waiting for it.
QuicAckFrame frame = InitAckFrame(0, 1);
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(1)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(1)));
ProcessAckPacket(&frame);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
@@ -2897,9 +2854,8 @@ TEST_P(QuicConnectionTest, SendSchedulerDelayThenOnCanWrite) {
// TODO(ianswett): This test is unrealistic, because we would not serialize
// new data if the send algorithm said not to.
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(10)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(10)));
connection_.SendPacket(
ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
EXPECT_EQ(1u, connection_.NumQueuedPackets());
@@ -2914,18 +2870,19 @@ TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) {
// All packets carry version info till version is negotiated.
size_t payload_length;
connection_.options()->max_packet_length =
- GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
- NOT_IN_FEC_GROUP, &payload_length);
+ GetPacketLengthForOneStream(connection_.version(),
+ kIncludeVersion,
+ PACKET_1BYTE_SEQUENCE_NUMBER,
+ NOT_IN_FEC_GROUP,
+ &payload_length);
// Queue the first packet.
- EXPECT_CALL(*send_algorithm_,
- TimeUntilSend(_, _)).WillOnce(
- testing::Return(QuicTime::Delta::FromMicroseconds(10)));
+ EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
+ .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(10)));
const string payload(payload_length, 'a');
EXPECT_EQ(0u,
- connection_.SendStreamDataWithString(3, payload, 0,
- !kFin, NULL).bytes_consumed);
+ connection_.SendStreamDataWithString(3, payload, 0, !kFin, NULL)
+ .bytes_consumed);
EXPECT_EQ(0u, connection_.NumQueuedPackets());
}
@@ -2933,17 +2890,19 @@ TEST_P(QuicConnectionTest, LoopThroughSendingPackets) {
// All packets carry version info till version is negotiated.
size_t payload_length;
connection_.options()->max_packet_length =
- GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
- NOT_IN_FEC_GROUP, &payload_length);
+ GetPacketLengthForOneStream(connection_.version(),
+ kIncludeVersion,
+ PACKET_1BYTE_SEQUENCE_NUMBER,
+ NOT_IN_FEC_GROUP,
+ &payload_length);
// Queue the first packet.
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _)).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(),
- connection_.SendStreamDataWithString(1, payload, 0,
- !kFin, NULL).bytes_consumed);
+ connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL)
+ .bytes_consumed);
}
TEST_P(QuicConnectionTest, SendDelayedAck) {
@@ -2951,8 +2910,7 @@ TEST_P(QuicConnectionTest, SendDelayedAck) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
const uint8 tag = 0x07;
- connection_.SetDecrypter(new StrictTaggingDecrypter(tag),
- ENCRYPTION_INITIAL);
+ connection_.SetDecrypter(new StrictTaggingDecrypter(tag), ENCRYPTION_INITIAL);
framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
// Process a packet from the non-crypto stream.
frame1_.stream_id = 3;
@@ -3107,10 +3065,8 @@ TEST_P(QuicConnectionTest, BundleAckWithDataOnIncomingAck) {
NackPacket(1, &ack);
EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
.WillOnce(Return(SequenceNumberSet()));
- EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(
- IgnoreResult(InvokeWithoutArgs(
- &connection_,
- &TestConnection::EnsureWritableAndSendStreamData5)));
+ EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(IgnoreResult(InvokeWithoutArgs(
+ &connection_, &TestConnection::EnsureWritableAndSendStreamData5)));
ProcessAckPacket(&ack);
// Check that ack is bundled with outgoing data and the delayed ack
@@ -3189,8 +3145,7 @@ TEST_P(QuicConnectionTest, Blocked) {
}
TEST_P(QuicConnectionTest, InvalidPacket) {
- EXPECT_CALL(visitor_,
- OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
+ EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
QuicEncryptedPacket encrypted(NULL, 0);
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), encrypted);
// The connection close packet should have error details.
@@ -3314,8 +3269,8 @@ TEST_P(QuicConnectionTest, EntropyCalculationForTruncatedAck) {
}
// Till 50 since 50th packet is not sent.
for (int i = 1; i < 50; ++i) {
- EXPECT_EQ(entropy[i], QuicConnectionPeer::ReceivedEntropyHash(
- &connection_, i));
+ EXPECT_EQ(entropy[i],
+ QuicConnectionPeer::ReceivedEntropyHash(&connection_, i));
}
}
@@ -3332,11 +3287,13 @@ TEST_P(QuicConnectionTest, CheckSentEntropyHash) {
packet_entropy_hash = 1 << (i % 8);
}
QuicPacket* packet = ConstructDataPacket(i, 0, entropy_flag);
- connection_.SendPacket(
- ENCRYPTION_NONE, i, packet, packet_entropy_hash,
- HAS_RETRANSMITTABLE_DATA);
+ connection_.SendPacket(ENCRYPTION_NONE,
+ i,
+ packet,
+ packet_entropy_hash,
+ HAS_RETRANSMITTABLE_DATA);
- if (is_missing) {
+ if (is_missing) {
missing_packets.insert(i);
continue;
}
@@ -3463,8 +3420,8 @@ TEST_P(QuicConnectionTest,
TEST_P(QuicConnectionTest, ClientHandlesVersionNegotiation) {
// Start out with some unsupported version.
- QuicConnectionPeer::GetFramer(&connection_)->set_version_for_tests(
- QUIC_VERSION_UNSUPPORTED);
+ QuicConnectionPeer::GetFramer(&connection_)
+ ->set_version_for_tests(QUIC_VERSION_UNSUPPORTED);
QuicPacketHeader header;
header.public_header.connection_id = connection_id_;
@@ -3482,8 +3439,8 @@ TEST_P(QuicConnectionTest, ClientHandlesVersionNegotiation) {
// Send a version negotiation packet.
scoped_ptr<QuicEncryptedPacket> encrypted(
- framer_.BuildVersionNegotiationPacket(
- header.public_header, supported_versions));
+ framer_.BuildVersionNegotiationPacket(header.public_header,
+ supported_versions));
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
// Now force another packet. The connection should transition into
@@ -3520,12 +3477,12 @@ TEST_P(QuicConnectionTest, BadVersionNegotiation) {
// Send a version negotiation packet with the version the client started with.
// It should be rejected.
- EXPECT_CALL(visitor_,
- OnConnectionClosed(QUIC_INVALID_VERSION_NEGOTIATION_PACKET,
- false));
+ EXPECT_CALL(
+ visitor_,
+ OnConnectionClosed(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, false));
scoped_ptr<QuicEncryptedPacket> encrypted(
- framer_.BuildVersionNegotiationPacket(
- header.public_header, supported_versions));
+ framer_.BuildVersionNegotiationPacket(header.public_header,
+ supported_versions));
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
}
@@ -3534,8 +3491,7 @@ TEST_P(QuicConnectionTest, CheckSendStats) {
connection_.SendStreamDataWithString(3, "first", 0, !kFin, NULL);
size_t first_packet_size = writer_->last_packet_size();
- EXPECT_CALL(*send_algorithm_,
- OnPacketSent(_, _, _, _));
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _));
connection_.SendStreamDataWithString(5, "second", 0, !kFin, NULL);
size_t second_packet_size = writer_->last_packet_size();
@@ -3564,8 +3520,8 @@ TEST_P(QuicConnectionTest, CheckSendStats) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
ProcessAckPacket(&nack_three);
- EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce(
- Return(QuicBandwidth::Zero()));
+ EXPECT_CALL(*send_algorithm_, BandwidthEstimate())
+ .WillOnce(Return(QuicBandwidth::Zero()));
const QuicConnectionStats& stats = connection_.GetStats();
EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - kQuicVersionSize,
@@ -3590,8 +3546,8 @@ TEST_P(QuicConnectionTest, CheckReceiveStats) {
received_bytes += ProcessDataPacket(3, 1, !kEntropyFlag);
received_bytes += ProcessFecPacket(4, 1, true, !kEntropyFlag, NULL);
- EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillOnce(
- Return(QuicBandwidth::Zero()));
+ EXPECT_CALL(*send_algorithm_, BandwidthEstimate())
+ .WillOnce(Return(QuicBandwidth::Zero()));
const QuicConnectionStats& stats = connection_.GetStats();
EXPECT_EQ(received_bytes, stats.bytes_received);
@@ -3644,8 +3600,8 @@ TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) {
scoped_ptr<QuicPacket> packet(
framer_.BuildUnsizedDataPacket(header_, frames).packet);
EXPECT_TRUE(NULL != packet.get());
- scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
- ENCRYPTION_NONE, 1, *packet));
+ scoped_ptr<QuicEncryptedPacket> encrypted(
+ framer_.EncryptPacket(ENCRYPTION_NONE, 1, *packet));
EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true));
EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1);
@@ -3808,8 +3764,8 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackForAckAfterRTO) {
scoped_refptr<MockAckNotifierDelegate> delegate(
new StrictMock<MockAckNotifierDelegate>);
- QuicTime default_retransmission_time = clock_.ApproximateNow().Add(
- DefaultRetransmissionTime());
+ QuicTime default_retransmission_time =
+ clock_.ApproximateNow().Add(DefaultRetransmissionTime());
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, delegate.get());
EXPECT_EQ(1u, outgoing_ack()->sent_info.least_unacked);
@@ -3897,8 +3853,7 @@ TEST_P(QuicConnectionTest, AckNotifierFECTriggerCallback) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
// Create a delegate which we expect to be called.
- scoped_refptr<MockAckNotifierDelegate> delegate(
- new MockAckNotifierDelegate);
+ scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
EXPECT_CALL(*delegate, OnAckNotification(_, _, _, _, _)).Times(1);
// Send some data, which will register the delegate to be notified.
@@ -3966,8 +3921,7 @@ TEST_P(QuicConnectionTest, AckNotifierCallbackAfterFECRecovery) {
class MockQuicConnectionDebugVisitor
: public QuicConnectionDebugVisitorInterface {
public:
- MOCK_METHOD1(OnFrameAddedToPacket,
- void(const QuicFrame&));
+ MOCK_METHOD1(OnFrameAddedToPacket, void(const QuicFrame&));
MOCK_METHOD5(OnPacketSent,
void(QuicPacketSequenceNumber,
@@ -3977,40 +3931,31 @@ class MockQuicConnectionDebugVisitor
WriteResult));
MOCK_METHOD2(OnPacketRetransmitted,
- void(QuicPacketSequenceNumber,
- QuicPacketSequenceNumber));
+ void(QuicPacketSequenceNumber, QuicPacketSequenceNumber));
MOCK_METHOD3(OnPacketReceived,
void(const IPEndPoint&,
const IPEndPoint&,
const QuicEncryptedPacket&));
- MOCK_METHOD1(OnProtocolVersionMismatch,
- void(QuicVersion));
+ MOCK_METHOD1(OnProtocolVersionMismatch, void(QuicVersion));
- MOCK_METHOD1(OnPacketHeader,
- void(const QuicPacketHeader& header));
+ MOCK_METHOD1(OnPacketHeader, void(const QuicPacketHeader& header));
- MOCK_METHOD1(OnStreamFrame,
- void(const QuicStreamFrame&));
+ MOCK_METHOD1(OnStreamFrame, void(const QuicStreamFrame&));
- MOCK_METHOD1(OnAckFrame,
- void(const QuicAckFrame& frame));
+ MOCK_METHOD1(OnAckFrame, void(const QuicAckFrame& frame));
MOCK_METHOD1(OnCongestionFeedbackFrame,
void(const QuicCongestionFeedbackFrame&));
- MOCK_METHOD1(OnStopWaitingFrame,
- void(const QuicStopWaitingFrame&));
+ MOCK_METHOD1(OnStopWaitingFrame, void(const QuicStopWaitingFrame&));
- MOCK_METHOD1(OnRstStreamFrame,
- void(const QuicRstStreamFrame&));
+ MOCK_METHOD1(OnRstStreamFrame, void(const QuicRstStreamFrame&));
- MOCK_METHOD1(OnConnectionCloseFrame,
- void(const QuicConnectionCloseFrame&));
+ MOCK_METHOD1(OnConnectionCloseFrame, void(const QuicConnectionCloseFrame&));
- MOCK_METHOD1(OnPublicResetPacket,
- void(const QuicPublicResetPacket&));
+ MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket&));
MOCK_METHOD1(OnVersionNegotiationPacket,
void(const QuicVersionNegotiationPacket&));
@@ -4022,8 +3967,8 @@ class MockQuicConnectionDebugVisitor
TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) {
QuicPacketHeader header;
- scoped_ptr<MockQuicConnectionDebugVisitor>
- debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>);
+ scoped_ptr<MockQuicConnectionDebugVisitor> debug_visitor(
+ new StrictMock<MockQuicConnectionDebugVisitor>);
connection_.set_debug_visitor(debug_visitor.get());
EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1);
connection_.OnPacketHeader(header);
@@ -4032,11 +3977,19 @@ TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) {
TEST_P(QuicConnectionTest, Pacing) {
ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
- TestConnection server(connection_id_, IPEndPoint(), helper_.get(),
- writer_.get(), true, version(),
+ TestConnection server(connection_id_,
+ IPEndPoint(),
+ helper_.get(),
+ writer_.get(),
+ true,
+ version(),
kDefaultFlowControlSendWindow);
- TestConnection client(connection_id_, IPEndPoint(), helper_.get(),
- writer_.get(), false, version(),
+ TestConnection client(connection_id_,
+ IPEndPoint(),
+ helper_.get(),
+ writer_.get(),
+ false,
+ version(),
kDefaultFlowControlSendWindow);
EXPECT_TRUE(client.sent_packet_manager().using_pacing());
EXPECT_FALSE(server.sent_packet_manager().using_pacing());
@@ -4069,8 +4022,12 @@ TEST_P(QuicConnectionTest, InvalidFlowControlWindow) {
ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
const uint32 kSmallerFlowControlWindow = kDefaultFlowControlSendWindow - 1;
- TestConnection connection(connection_id_, IPEndPoint(), helper_.get(),
- writer_.get(), true, version(),
+ TestConnection connection(connection_id_,
+ IPEndPoint(),
+ helper_.get(),
+ writer_.get(),
+ true,
+ version(),
kSmallerFlowControlWindow);
EXPECT_EQ(kDefaultFlowControlSendWindow,
connection.max_flow_control_receive_window_bytes());

Powered by Google App Engine
This is Rietveld 408576698