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

Unified Diff: net/quic/quic_packet_generator_test.cc

Issue 20227003: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Land Recent QUIC changes Created 7 years, 5 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_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_generator_test.cc
diff --git a/net/quic/quic_packet_generator_test.cc b/net/quic/quic_packet_generator_test.cc
index c3c4fc1966efce8f6a3d31d3164c89ebedae514e..45112512b4574ddfced6884c4cea8b0b2aa27fa3 100644
--- a/net/quic/quic_packet_generator_test.cc
+++ b/net/quic/quic_packet_generator_test.cc
@@ -39,9 +39,26 @@ class MockDelegate : public QuicPacketGenerator::DelegateInterface {
MOCK_METHOD0(CreateFeedbackFrame, QuicCongestionFeedbackFrame*());
MOCK_METHOD1(OnSerializedPacket, bool(const SerializedPacket& packet));
- void SetCanWrite(bool can_write) {
+ void SetCanWriteAnything() {
EXPECT_CALL(*this, CanWrite(NOT_RETRANSMISSION, _))
- .WillRepeatedly(Return(can_write));
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*this, CanWrite(NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA))
+ .WillRepeatedly(Return(true));
+ }
+
+ void SetCanNotWrite() {
+ EXPECT_CALL(*this, CanWrite(NOT_RETRANSMISSION, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*this, CanWrite(NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA))
+ .WillRepeatedly(Return(false));
+ }
+
+ // Use this when only ack and feedback frames should be allowed to be written.
+ void SetCanWriteOnlyNonRetransmittable() {
+ EXPECT_CALL(*this, CanWrite(NOT_RETRANSMISSION, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*this, CanWrite(NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA))
+ .WillRepeatedly(Return(true));
}
private:
@@ -77,7 +94,7 @@ struct PacketContents {
class QuicPacketGeneratorTest : public ::testing::Test {
protected:
QuicPacketGeneratorTest()
- : framer_(kQuicVersion1, QuicTime::Zero(), false),
+ : framer_(QuicVersionMax(), QuicTime::Zero(), false),
creator_(42, &framer_, &random_, false),
generator_(&delegate_, NULL, &creator_),
packet_(0, NULL, 0, NULL),
@@ -194,14 +211,14 @@ class QuicPacketGeneratorTest : public ::testing::Test {
};
TEST_F(QuicPacketGeneratorTest, ShouldSendAck_NotWritable) {
- delegate_.SetCanWrite(false);
+ delegate_.SetCanNotWrite();
generator_.SetShouldSendAck(false);
EXPECT_TRUE(generator_.HasQueuedFrames());
}
TEST_F(QuicPacketGeneratorTest, ShouldSendAck_WritableAndShouldNotFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteOnlyNonRetransmittable();
generator_.StartBatchOperations();
EXPECT_CALL(delegate_, CreateAckFrame()).WillOnce(Return(CreateAckFrame()));
@@ -211,7 +228,7 @@ TEST_F(QuicPacketGeneratorTest, ShouldSendAck_WritableAndShouldNotFlush) {
}
TEST_F(QuicPacketGeneratorTest, ShouldSendAck_WritableAndShouldFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteOnlyNonRetransmittable();
EXPECT_CALL(delegate_, CreateAckFrame()).WillOnce(Return(CreateAckFrame()));
EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
@@ -227,7 +244,7 @@ TEST_F(QuicPacketGeneratorTest, ShouldSendAck_WritableAndShouldFlush) {
TEST_F(QuicPacketGeneratorTest,
ShouldSendAckWithFeedback_WritableAndShouldNotFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteOnlyNonRetransmittable();
generator_.StartBatchOperations();
EXPECT_CALL(delegate_, CreateAckFrame()).WillOnce(Return(CreateAckFrame()));
@@ -240,7 +257,7 @@ TEST_F(QuicPacketGeneratorTest,
TEST_F(QuicPacketGeneratorTest,
ShouldSendAckWithFeedback_WritableAndShouldFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteOnlyNonRetransmittable();
EXPECT_CALL(delegate_, CreateAckFrame()).WillOnce(Return(CreateAckFrame()));
EXPECT_CALL(delegate_, CreateFeedbackFrame()).WillOnce(
@@ -259,14 +276,21 @@ TEST_F(QuicPacketGeneratorTest,
}
TEST_F(QuicPacketGeneratorTest, AddControlFrame_NotWritable) {
- delegate_.SetCanWrite(false);
+ delegate_.SetCanNotWrite();
+
+ generator_.AddControlFrame(QuicFrame(CreateRstStreamFrame()));
+ EXPECT_TRUE(generator_.HasQueuedFrames());
+}
+
+TEST_F(QuicPacketGeneratorTest, AddControlFrame_OnlyAckWritable) {
+ delegate_.SetCanWriteOnlyNonRetransmittable();
generator_.AddControlFrame(QuicFrame(CreateRstStreamFrame()));
EXPECT_TRUE(generator_.HasQueuedFrames());
}
TEST_F(QuicPacketGeneratorTest, AddControlFrame_WritableAndShouldNotFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
generator_.StartBatchOperations();
generator_.AddControlFrame(QuicFrame(CreateRstStreamFrame()));
@@ -274,7 +298,7 @@ TEST_F(QuicPacketGeneratorTest, AddControlFrame_WritableAndShouldNotFlush) {
}
TEST_F(QuicPacketGeneratorTest, AddControlFrame_WritableAndShouldFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
DoAll(SaveArg<0>(&packet_), Return(true)));
@@ -288,7 +312,7 @@ TEST_F(QuicPacketGeneratorTest, AddControlFrame_WritableAndShouldFlush) {
}
TEST_F(QuicPacketGeneratorTest, ConsumeData_NotWritable) {
- delegate_.SetCanWrite(false);
+ delegate_.SetCanNotWrite();
QuicConsumedData consumed = generator_.ConsumeData(1, "foo", 2, true);
EXPECT_EQ(0u, consumed.bytes_consumed);
@@ -297,7 +321,7 @@ TEST_F(QuicPacketGeneratorTest, ConsumeData_NotWritable) {
}
TEST_F(QuicPacketGeneratorTest, ConsumeData_WritableAndShouldNotFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
generator_.StartBatchOperations();
QuicConsumedData consumed = generator_.ConsumeData(1, "foo", 2, true);
@@ -307,7 +331,7 @@ TEST_F(QuicPacketGeneratorTest, ConsumeData_WritableAndShouldNotFlush) {
}
TEST_F(QuicPacketGeneratorTest, ConsumeData_WritableAndShouldFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
DoAll(SaveArg<0>(&packet_), Return(true)));
@@ -323,7 +347,7 @@ TEST_F(QuicPacketGeneratorTest, ConsumeData_WritableAndShouldFlush) {
TEST_F(QuicPacketGeneratorTest,
ConsumeDataMultipleTimes_WritableAndShouldNotFlush) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
generator_.StartBatchOperations();
generator_.ConsumeData(1, "foo", 2, true);
@@ -334,7 +358,7 @@ TEST_F(QuicPacketGeneratorTest,
}
TEST_F(QuicPacketGeneratorTest, ConsumeData_BatchOperations) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
generator_.StartBatchOperations();
generator_.ConsumeData(1, "foo", 2, true);
@@ -355,7 +379,7 @@ TEST_F(QuicPacketGeneratorTest, ConsumeData_BatchOperations) {
}
TEST_F(QuicPacketGeneratorTest, ConsumeDataFEC) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
// Send FEC every two packets.
creator_.options()->max_packets_per_fec_group = 2;
@@ -391,7 +415,7 @@ TEST_F(QuicPacketGeneratorTest, ConsumeDataFEC) {
}
TEST_F(QuicPacketGeneratorTest, ConsumeDataSendsFecAtEnd) {
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
// Send FEC every six packets.
creator_.options()->max_packets_per_fec_group = 6;
@@ -420,13 +444,13 @@ TEST_F(QuicPacketGeneratorTest, ConsumeDataSendsFecAtEnd) {
}
TEST_F(QuicPacketGeneratorTest, NotWritableThenBatchOperations) {
- delegate_.SetCanWrite(false);
+ delegate_.SetCanNotWrite();
generator_.SetShouldSendAck(true);
generator_.AddControlFrame(QuicFrame(CreateRstStreamFrame()));
EXPECT_TRUE(generator_.HasQueuedFrames());
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
generator_.StartBatchOperations();
@@ -456,13 +480,13 @@ TEST_F(QuicPacketGeneratorTest, NotWritableThenBatchOperations) {
}
TEST_F(QuicPacketGeneratorTest, NotWritableThenBatchOperations2) {
- delegate_.SetCanWrite(false);
+ delegate_.SetCanNotWrite();
generator_.SetShouldSendAck(true);
generator_.AddControlFrame(QuicFrame(CreateRstStreamFrame()));
EXPECT_TRUE(generator_.HasQueuedFrames());
- delegate_.SetCanWrite(true);
+ delegate_.SetCanWriteAnything();
generator_.StartBatchOperations();
« no previous file with comments | « net/quic/quic_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698