OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 5231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5242 | 5242 |
5243 TEST_P(QuicConnectionTest, DoNotSendGoAwayTwice) { | 5243 TEST_P(QuicConnectionTest, DoNotSendGoAwayTwice) { |
5244 EXPECT_FALSE(connection_.goaway_sent()); | 5244 EXPECT_FALSE(connection_.goaway_sent()); |
5245 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 5245 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
5246 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); | 5246 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); |
5247 EXPECT_TRUE(connection_.goaway_sent()); | 5247 EXPECT_TRUE(connection_.goaway_sent()); |
5248 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 5248 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
5249 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); | 5249 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); |
5250 } | 5250 } |
5251 | 5251 |
| 5252 TEST_P(QuicConnectionTest, ReevaluateTimeUntilSendOnAck) { |
| 5253 FLAGS_quic_respect_send_alarm = true; |
| 5254 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 5255 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, |
| 5256 nullptr); |
| 5257 |
| 5258 // Evaluate CanWrite, and have it return a non-Zero value. |
| 5259 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) |
| 5260 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1))); |
| 5261 connection_.OnCanWrite(); |
| 5262 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); |
| 5263 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(1)), |
| 5264 connection_.GetSendAlarm()->deadline()); |
| 5265 |
| 5266 // Process an ack and the send alarm will be set to the new 2ms delay. |
| 5267 QuicAckFrame ack = InitAckFrame(1); |
| 5268 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)); |
| 5269 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 5270 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) |
| 5271 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2))); |
| 5272 ProcessAckPacket(&ack); |
| 5273 EXPECT_EQ(1u, writer_->frame_count()); |
| 5274 EXPECT_EQ(1u, writer_->stream_frames().size()); |
| 5275 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); |
| 5276 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)), |
| 5277 connection_.GetSendAlarm()->deadline()); |
| 5278 writer_->Reset(); |
| 5279 } |
| 5280 |
5252 } // namespace | 5281 } // namespace |
5253 } // namespace test | 5282 } // namespace test |
5254 } // namespace net | 5283 } // namespace net |
OLD | NEW |