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

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 667763003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
3222 3206
3223 TEST_P(QuicConnectionTest, Blocked) { 3207 TEST_P(QuicConnectionTest, Blocked) {
3224 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3208 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3225 3209
3226 QuicBlockedFrame blocked; 3210 QuicBlockedFrame blocked;
3227 blocked.stream_id = 3; 3211 blocked.stream_id = 3;
3228 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3212 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3229 ProcessFramePacket(QuicFrame(&blocked)); 3213 ProcessFramePacket(QuicFrame(&blocked));
3230 } 3214 }
3231 3215
3232 TEST_P(QuicConnectionTest, InvalidPacket) { 3216 TEST_P(QuicConnectionTest, ZeroBytePacket) {
3233 EXPECT_CALL(visitor_, 3217 // Don't close the connection for zero byte packets.
3234 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); 3218 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(0);
3235 QuicEncryptedPacket encrypted(nullptr, 0); 3219 QuicEncryptedPacket encrypted(nullptr, 0);
3236 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), encrypted); 3220 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), encrypted);
3237 // The connection close packet should have error details.
3238 ASSERT_FALSE(writer_->connection_close_frames().empty());
3239 EXPECT_EQ("Unable to read public flags.",
3240 writer_->connection_close_frames()[0].error_details);
3241 } 3221 }
3242 3222
3243 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { 3223 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) {
3244 // Set the sequence number of the ack packet to be least unacked (4). 3224 // Set the sequence number of the ack packet to be least unacked (4).
3245 peer_creator_.set_sequence_number(3); 3225 peer_creator_.set_sequence_number(3);
3246 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3226 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3247 QuicStopWaitingFrame frame = InitStopWaitingFrame(4); 3227 QuicStopWaitingFrame frame = InitStopWaitingFrame(4);
3248 ProcessStopWaitingPacket(&frame); 3228 ProcessStopWaitingPacket(&frame);
3249 EXPECT_TRUE(outgoing_ack()->missing_packets.empty()); 3229 EXPECT_TRUE(outgoing_ack()->missing_packets.empty());
3250 } 3230 }
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
4041 QuicBlockedFrame blocked; 4021 QuicBlockedFrame blocked;
4042 blocked.stream_id = 3; 4022 blocked.stream_id = 3;
4043 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 4023 EXPECT_CALL(visitor_, OnBlockedFrames(_));
4044 ProcessFramePacket(QuicFrame(&blocked)); 4024 ProcessFramePacket(QuicFrame(&blocked));
4045 EXPECT_TRUE(ack_alarm->IsSet()); 4025 EXPECT_TRUE(ack_alarm->IsSet());
4046 } 4026 }
4047 4027
4048 } // namespace 4028 } // namespace
4049 } // namespace test 4029 } // namespace test
4050 } // namespace net 4030 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698