Index: net/quic/quic_connection_test.cc |
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc |
index c3524629d82859e51ac59983dca16a91d63890d3..4444a0ab08dab4086ebe2cff29d47ea2bb527c84 100644 |
--- a/net/quic/quic_connection_test.cc |
+++ b/net/quic/quic_connection_test.cc |
@@ -31,6 +31,7 @@ using std::map; |
using std::vector; |
using testing::_; |
using testing::AnyNumber; |
+using testing::AtLeast; |
using testing::ContainerEq; |
using testing::Contains; |
using testing::DoAll; |
@@ -274,7 +275,7 @@ class TestPacketWriter : public QuicPacketWriter { |
TestPacketWriter() |
: last_packet_size_(0), |
write_blocked_(false), |
- block_next_write_(false), |
+ block_on_next_write_(false), |
is_write_blocked_data_buffered_(false), |
is_server_(true), |
final_bytes_of_last_packet_(0), |
@@ -305,9 +306,9 @@ class TestPacketWriter : public QuicPacketWriter { |
visitor_.Reset(); |
framer.set_visitor(&visitor_); |
EXPECT_TRUE(framer.ProcessPacket(packet)); |
- if (block_next_write_) { |
+ if (block_on_next_write_) { |
write_blocked_ = true; |
- block_next_write_ = false; |
+ block_on_next_write_ = false; |
} |
if (IsWriteBlocked()) { |
return WriteResult(WRITE_STATUS_BLOCKED, -1); |
@@ -324,7 +325,7 @@ class TestPacketWriter : public QuicPacketWriter { |
virtual void SetWritable() OVERRIDE { write_blocked_ = false; } |
- void BlockNextWrite() { block_next_write_ = true; } |
+ void BlockOnNextWrite() { block_on_next_write_ = true; } |
// Resets the visitor's state by clearing out the headers and frames. |
void Reset() { |
@@ -380,7 +381,7 @@ class TestPacketWriter : public QuicPacketWriter { |
FramerVisitorCapturingFrames visitor_; |
size_t last_packet_size_; |
bool write_blocked_; |
- bool block_next_write_; |
+ bool block_on_next_write_; |
bool is_write_blocked_data_buffered_; |
bool is_server_; |
uint32 final_bytes_of_last_packet_; |
@@ -472,7 +473,7 @@ class TestConnection : public QuicConnection { |
} |
void set_version(QuicVersion version) { |
- framer_.set_version(version); |
+ QuicConnectionPeer::GetFramer(this)->set_version(version); |
} |
void set_is_server(bool is_server) { |
@@ -841,6 +842,11 @@ class QuicConnectionTest : public ::testing::TestWithParam<bool> { |
QuicConnectionPeer::GetConnectionClosePacket(&connection_) == NULL); |
} |
+ void BlockOnNextWrite() { |
+ writer_->BlockOnNextWrite(); |
+ EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1)); |
+ } |
+ |
QuicGuid guid_; |
QuicFramer framer_; |
QuicPacketCreator creator_; |
@@ -1339,7 +1345,7 @@ TEST_F(QuicConnectionTest, FECQueueing) { |
connection_.options()->max_packets_per_fec_group = 2; |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
const string payload(payload_length, 'a'); |
connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL); |
EXPECT_FALSE(creator_.ShouldSendFec(true)); |
@@ -1609,7 +1615,7 @@ TEST_F(QuicConnectionTest, FramePackingSendvQueued) { |
// Try to send two stream frames in 1 packet by using writev. |
EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, NOT_RETRANSMISSION, _)); |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
char data[] = "ABCD"; |
IOVector data_iov; |
data_iov.AppendNoCoalesce(data, 2); |
@@ -1728,10 +1734,9 @@ TEST_F(QuicConnectionTest, DiscardRetransmit) { |
NackPacket(2, &nack_two); |
// The first nack should trigger a fast retransmission, but we'll be |
// write blocked, so the packet will be queued. |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
EXPECT_CALL(*send_algorithm_, OnPacketAcked(_, _)); |
- |
ProcessAckPacket(&nack_two); |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
@@ -1778,7 +1783,7 @@ TEST_F(QuicConnectionTest, QueueAfterTwoRTOs) { |
} |
// Block the congestion window and ensure they're queued. |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
clock_.AdvanceTime(DefaultRetransmissionTime()); |
// Only one packet should be retransmitted. |
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
@@ -1797,9 +1802,8 @@ TEST_F(QuicConnectionTest, QueueAfterTwoRTOs) { |
} |
TEST_F(QuicConnectionTest, WriteBlockedThenSent) { |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
writer_->set_is_write_blocked_data_buffered(true); |
- |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
@@ -1810,8 +1814,7 @@ TEST_F(QuicConnectionTest, WriteBlockedThenSent) { |
TEST_F(QuicConnectionTest, WriteBlockedAckedThenSent) { |
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
- writer_->BlockNextWrite(); |
- |
+ BlockOnNextWrite(); |
writer_->set_is_write_blocked_data_buffered(true); |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
@@ -1831,9 +1834,8 @@ TEST_F(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) { |
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
writer_->set_is_write_blocked_data_buffered(true); |
- |
// Simulate the retransmission alarm firing. |
EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(_)); |
clock_.AdvanceTime(DefaultRetransmissionTime()); |
@@ -1851,7 +1853,7 @@ TEST_F(QuicConnectionTest, RetransmitWriteBlockedAckedOriginalThenSent) { |
TEST_F(QuicConnectionTest, ResumptionAlarmWhenWriteBlocked) { |
// Block the connection. |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); |
EXPECT_EQ(1u, writer_->packets_write_attempts()); |
EXPECT_TRUE(writer_->IsWriteBlocked()); |
@@ -2254,7 +2256,7 @@ TEST_F(QuicConnectionTest, RetransmissionCountCalculation) { |
} |
TEST_F(QuicConnectionTest, SetRTOAfterWritingToSocket) { |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
// Make sure that RTO is not started when the packet is queued. |
EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
@@ -2305,7 +2307,7 @@ TEST_F(QuicConnectionTest, DelayRTOWithAckReceipt) { |
TEST_F(QuicConnectionTest, TestQueued) { |
EXPECT_EQ(0u, connection_.NumQueuedPackets()); |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
@@ -2460,7 +2462,7 @@ TEST_F(QuicConnectionTest, SendSchedulerForce) { |
TEST_F(QuicConnectionTest, SendSchedulerEAGAIN) { |
QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
EXPECT_CALL(*send_algorithm_, |
TimeUntilSend(_, NOT_RETRANSMISSION, _, _)).WillOnce( |
testing::Return(QuicTime::Delta::Zero())); |
@@ -2935,7 +2937,7 @@ TEST_F(QuicConnectionTest, ServerSendsVersionNegotiationPacketSocketBlocked) { |
framer_.set_version(QuicVersionMax()); |
connection_.set_is_server(true); |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
EXPECT_EQ(0u, writer_->last_packet_size()); |
EXPECT_TRUE(connection_.HasQueuedData()); |
@@ -2979,7 +2981,7 @@ TEST_F(QuicConnectionTest, |
framer_.set_version(QuicVersionMax()); |
connection_.set_is_server(true); |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
writer_->set_is_write_blocked_data_buffered(true); |
connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); |
EXPECT_EQ(0u, writer_->last_packet_size()); |
@@ -3257,14 +3259,14 @@ TEST_F(QuicConnectionTest, ConnectionCloseWhenWritable) { |
} |
TEST_F(QuicConnectionTest, ConnectionCloseGettingWriteBlocked) { |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
TriggerConnectionClose(); |
EXPECT_EQ(1u, writer_->packets_write_attempts()); |
EXPECT_TRUE(writer_->IsWriteBlocked()); |
} |
TEST_F(QuicConnectionTest, ConnectionCloseWhenWriteBlocked) { |
- writer_->BlockNextWrite(); |
+ BlockOnNextWrite(); |
connection_.SendStreamDataWithString(1, "foo", 0, !kFin, NULL); |
EXPECT_EQ(1u, connection_.NumQueuedPackets()); |
EXPECT_EQ(1u, writer_->packets_write_attempts()); |