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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline()); | 3156 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline()); |
3157 // Simulate delayed ack alarm firing. | 3157 // Simulate delayed ack alarm firing. |
3158 connection_.GetAckAlarm()->Fire(); | 3158 connection_.GetAckAlarm()->Fire(); |
3159 // Check that ack is sent and that delayed ack alarm is reset. | 3159 // Check that ack is sent and that delayed ack alarm is reset. |
3160 EXPECT_EQ(2u, writer_->frame_count()); | 3160 EXPECT_EQ(2u, writer_->frame_count()); |
3161 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3161 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
3162 EXPECT_FALSE(writer_->ack_frames().empty()); | 3162 EXPECT_FALSE(writer_->ack_frames().empty()); |
3163 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3163 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3164 } | 3164 } |
3165 | 3165 |
3166 TEST_P(QuicConnectionTest, SendEarlyDelayedAckForCrypto) { | 3166 TEST_P(QuicConnectionTest, SendDelayedAckOnHandshakeConfirmed) { |
3167 QuicTime ack_time = clock_.ApproximateNow(); | |
3168 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3167 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3169 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | |
3170 // Process a packet from the crypto stream, which is frame1_'s default. | |
3171 ProcessPacket(1); | 3168 ProcessPacket(1); |
3172 // Check if delayed ack timer is running for the expected interval. | 3169 // Check that ack is sent and that delayed ack alarm is set. |
| 3170 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); |
| 3171 QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime()); |
| 3172 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline()); |
| 3173 |
| 3174 // Completing the handshake as the server does nothing. |
| 3175 QuicConnectionPeer::SetIsServer(&connection_, true); |
| 3176 connection_.OnHandshakeComplete(); |
3173 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); | 3177 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); |
3174 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline()); | 3178 EXPECT_EQ(ack_time, connection_.GetAckAlarm()->deadline()); |
3175 // Simulate delayed ack alarm firing. | 3179 |
3176 connection_.GetAckAlarm()->Fire(); | 3180 // Complete the handshake as the client decreases the delayed ack time to 0ms. |
3177 // Check that ack is sent and that delayed ack alarm is reset. | 3181 QuicConnectionPeer::SetIsServer(&connection_, false); |
3178 EXPECT_EQ(2u, writer_->frame_count()); | 3182 connection_.OnHandshakeComplete(); |
3179 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3183 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); |
3180 EXPECT_FALSE(writer_->ack_frames().empty()); | 3184 EXPECT_EQ(clock_.ApproximateNow(), connection_.GetAckAlarm()->deadline()); |
3181 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | |
3182 } | 3185 } |
3183 | 3186 |
3184 TEST_P(QuicConnectionTest, SendDelayedAckOnSecondPacket) { | 3187 TEST_P(QuicConnectionTest, SendDelayedAckOnSecondPacket) { |
3185 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3188 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3186 ProcessPacket(1); | 3189 ProcessPacket(1); |
3187 ProcessPacket(2); | 3190 ProcessPacket(2); |
3188 // Check that ack is sent and that delayed ack alarm is reset. | 3191 // Check that ack is sent and that delayed ack alarm is reset. |
3189 EXPECT_EQ(2u, writer_->frame_count()); | 3192 EXPECT_EQ(2u, writer_->frame_count()); |
3190 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3193 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
3191 EXPECT_FALSE(writer_->ack_frames().empty()); | 3194 EXPECT_FALSE(writer_->ack_frames().empty()); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4189 QuicBlockedFrame blocked; | 4192 QuicBlockedFrame blocked; |
4190 blocked.stream_id = 3; | 4193 blocked.stream_id = 3; |
4191 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4194 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
4192 ProcessFramePacket(QuicFrame(&blocked)); | 4195 ProcessFramePacket(QuicFrame(&blocked)); |
4193 EXPECT_TRUE(ack_alarm->IsSet()); | 4196 EXPECT_TRUE(ack_alarm->IsSet()); |
4194 } | 4197 } |
4195 | 4198 |
4196 } // namespace | 4199 } // namespace |
4197 } // namespace test | 4200 } // namespace test |
4198 } // namespace net | 4201 } // namespace net |
OLD | NEW |