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 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 // The ping timer is set slightly less than 15 seconds in the future, because | 2806 // The ping timer is set slightly less than 15 seconds in the future, because |
2807 // of the 1s ping timer alarm granularity. | 2807 // of the 1s ping timer alarm granularity. |
2808 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)) | 2808 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)) |
2809 .Subtract(QuicTime::Delta::FromMilliseconds(5)), | 2809 .Subtract(QuicTime::Delta::FromMilliseconds(5)), |
2810 connection_.GetPingAlarm()->deadline()); | 2810 connection_.GetPingAlarm()->deadline()); |
2811 | 2811 |
2812 writer_->Reset(); | 2812 writer_->Reset(); |
2813 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); | 2813 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); |
2814 connection_.GetPingAlarm()->Fire(); | 2814 connection_.GetPingAlarm()->Fire(); |
2815 EXPECT_EQ(1u, writer_->frame_count()); | 2815 EXPECT_EQ(1u, writer_->frame_count()); |
2816 if (version() >= QUIC_VERSION_18) { | 2816 ASSERT_EQ(1u, writer_->ping_frames().size()); |
2817 ASSERT_EQ(1u, writer_->ping_frames().size()); | |
2818 } else { | |
2819 ASSERT_EQ(1u, writer_->stream_frames().size()); | |
2820 EXPECT_EQ(kCryptoStreamId, writer_->stream_frames()[0].stream_id); | |
2821 EXPECT_EQ(0u, writer_->stream_frames()[0].offset); | |
2822 } | |
2823 writer_->Reset(); | 2817 writer_->Reset(); |
2824 | 2818 |
2825 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); | 2819 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); |
2826 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2820 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
2827 SendAckPacketToPeer(); | 2821 SendAckPacketToPeer(); |
2828 | 2822 |
2829 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 2823 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
2830 } | 2824 } |
2831 | 2825 |
2832 TEST_P(QuicConnectionTest, TimeoutAfterSend) { | 2826 TEST_P(QuicConnectionTest, TimeoutAfterSend) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3014 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3008 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3015 ProcessPacket(1); | 3009 ProcessPacket(1); |
3016 ProcessPacket(2); | 3010 ProcessPacket(2); |
3017 // Check that ack is sent and that delayed ack alarm is reset. | 3011 // Check that ack is sent and that delayed ack alarm is reset. |
3018 EXPECT_EQ(2u, writer_->frame_count()); | 3012 EXPECT_EQ(2u, writer_->frame_count()); |
3019 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); | 3013 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); |
3020 EXPECT_FALSE(writer_->ack_frames().empty()); | 3014 EXPECT_FALSE(writer_->ack_frames().empty()); |
3021 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3015 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
3022 } | 3016 } |
3023 | 3017 |
3024 TEST_P(QuicConnectionTest, SendDelayedAckForPing) { | |
3025 if (version() < QUIC_VERSION_18) { | |
3026 return; | |
3027 } | |
3028 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | |
3029 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | |
3030 ProcessPingPacket(1); | |
3031 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); | |
3032 } | |
3033 | |
3034 TEST_P(QuicConnectionTest, NoAckOnOldNacks) { | 3018 TEST_P(QuicConnectionTest, NoAckOnOldNacks) { |
3035 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 3019 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
3036 // Drop one packet, triggering a sequence of acks. | 3020 // Drop one packet, triggering a sequence of acks. |
3037 ProcessPacket(2); | 3021 ProcessPacket(2); |
3038 size_t frames_per_ack = 2; | 3022 size_t frames_per_ack = 2; |
3039 EXPECT_EQ(frames_per_ack, writer_->frame_count()); | 3023 EXPECT_EQ(frames_per_ack, writer_->frame_count()); |
3040 EXPECT_FALSE(writer_->ack_frames().empty()); | 3024 EXPECT_FALSE(writer_->ack_frames().empty()); |
3041 writer_->Reset(); | 3025 writer_->Reset(); |
3042 ProcessPacket(3); | 3026 ProcessPacket(3); |
3043 EXPECT_EQ(frames_per_ack, writer_->frame_count()); | 3027 EXPECT_EQ(frames_per_ack, writer_->frame_count()); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4041 QuicBlockedFrame blocked; | 4025 QuicBlockedFrame blocked; |
4042 blocked.stream_id = 3; | 4026 blocked.stream_id = 3; |
4043 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4027 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
4044 ProcessFramePacket(QuicFrame(&blocked)); | 4028 ProcessFramePacket(QuicFrame(&blocked)); |
4045 EXPECT_TRUE(ack_alarm->IsSet()); | 4029 EXPECT_TRUE(ack_alarm->IsSet()); |
4046 } | 4030 } |
4047 | 4031 |
4048 } // namespace | 4032 } // namespace |
4049 } // namespace test | 4033 } // namespace test |
4050 } // namespace net | 4034 } // namespace net |
OLD | NEW |