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

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

Issue 2296393005: Revert of Quic: add unittests for reduced PING Timeout (Closed)
Patch Set: Created 4 years, 3 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/core/quic_connection.h ('k') | no next file » | 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/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
(...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2925 ASSERT_EQ(1u, writer_->ping_frames().size()); 2925 ASSERT_EQ(1u, writer_->ping_frames().size());
2926 writer_->Reset(); 2926 writer_->Reset();
2927 2927
2928 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false)); 2928 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false));
2929 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); 2929 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
2930 SendAckPacketToPeer(); 2930 SendAckPacketToPeer();
2931 2931
2932 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); 2932 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
2933 } 2933 }
2934 2934
2935 TEST_P(QuicConnectionTest, ReducedPingTimeout) {
2936 EXPECT_TRUE(connection_.connected());
2937 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(true));
2938 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
2939
2940 // Use a reduced ping timeout for this connection.
2941 connection_.set_ping_timeout(QuicTime::Delta::FromSeconds(10));
2942
2943 // Advance to 5ms, and send a packet to the peer, which will set
2944 // the ping alarm.
2945 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
2946 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
2947 SendStreamDataToPeer(kHeadersStreamId, "GET /", 0, kFin, nullptr);
2948 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet());
2949 EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(10),
2950 connection_.GetPingAlarm()->deadline());
2951
2952 // Now recevie and ACK of the previous packet, which will move the
2953 // ping alarm forward.
2954 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
2955 QuicAckFrame frame = InitAckFrame(1);
2956 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2957 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2958 ProcessAckPacket(&frame);
2959 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet());
2960 // The ping timer is set slightly less than 10 seconds in the future, because
2961 // of the 1s ping timer alarm granularity.
2962 EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(10) -
2963 QuicTime::Delta::FromMilliseconds(5),
2964 connection_.GetPingAlarm()->deadline());
2965
2966 writer_->Reset();
2967 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10));
2968 connection_.GetPingAlarm()->Fire();
2969 EXPECT_EQ(1u, writer_->frame_count());
2970 ASSERT_EQ(1u, writer_->ping_frames().size());
2971 writer_->Reset();
2972
2973 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false));
2974 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
2975 SendAckPacketToPeer();
2976
2977 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
2978 }
2979
2980 // Tests whether sending an MTU discovery packet to peer successfully causes the 2935 // Tests whether sending an MTU discovery packet to peer successfully causes the
2981 // maximum packet size to increase. 2936 // maximum packet size to increase.
2982 TEST_P(QuicConnectionTest, SendMtuDiscoveryPacket) { 2937 TEST_P(QuicConnectionTest, SendMtuDiscoveryPacket) {
2983 EXPECT_TRUE(connection_.connected()); 2938 EXPECT_TRUE(connection_.connected());
2984 2939
2985 // Send an MTU probe. 2940 // Send an MTU probe.
2986 const size_t new_mtu = kDefaultMaxPacketSize + 100; 2941 const size_t new_mtu = kDefaultMaxPacketSize + 100;
2987 QuicByteCount mtu_probe_size; 2942 QuicByteCount mtu_probe_size;
2988 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 2943 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2989 .WillOnce(DoAll(SaveArg<3>(&mtu_probe_size), Return(true))); 2944 .WillOnce(DoAll(SaveArg<3>(&mtu_probe_size), Return(true)));
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after
5250 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 5205 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5251 EXPECT_EQ(1u, writer_->frame_count()); 5206 EXPECT_EQ(1u, writer_->frame_count());
5252 EXPECT_FALSE(writer_->connection_close_frames().empty()); 5207 EXPECT_FALSE(writer_->connection_close_frames().empty());
5253 // Ack frame is not bundled in connection close packet. 5208 // Ack frame is not bundled in connection close packet.
5254 EXPECT_TRUE(writer_->ack_frames().empty()); 5209 EXPECT_TRUE(writer_->ack_frames().empty());
5255 } 5210 }
5256 5211
5257 } // namespace 5212 } // namespace
5258 } // namespace test 5213 } // namespace test
5259 } // namespace net 5214 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698