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

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

Issue 1667583004: Landing Recent QUIC changes until 01/31/2016 05:22 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0203
Patch Set: Rebase Created 4 years, 10 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_client_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 <ostream> 7 #include <ostream>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 HasRetransmittableData retransmittable, 458 HasRetransmittableData retransmittable,
459 bool has_ack, 459 bool has_ack,
460 bool has_pending_frames) { 460 bool has_pending_frames) {
461 char buffer[kMaxPacketSize]; 461 char buffer[kMaxPacketSize];
462 size_t encrypted_length = 462 size_t encrypted_length =
463 QuicConnectionPeer::GetFramer(this)->EncryptPayload( 463 QuicConnectionPeer::GetFramer(this)->EncryptPayload(
464 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer, 464 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer,
465 kMaxPacketSize); 465 kMaxPacketSize);
466 delete packet; 466 delete packet;
467 SerializedPacket serialized_packet( 467 SerializedPacket serialized_packet(
468 kDefaultPathId, packet_number, PACKET_6BYTE_PACKET_NUMBER, 468 kDefaultPathId, packet_number, PACKET_6BYTE_PACKET_NUMBER, buffer,
469 new QuicEncryptedPacket(buffer, encrypted_length, false), entropy_hash, 469 encrypted_length, entropy_hash, has_ack, has_pending_frames);
470 has_ack, has_pending_frames);
471 if (retransmittable == HAS_RETRANSMITTABLE_DATA) { 470 if (retransmittable == HAS_RETRANSMITTABLE_DATA) {
472 serialized_packet.retransmittable_frames.push_back( 471 serialized_packet.retransmittable_frames.push_back(
473 QuicFrame(new QuicStreamFrame())); 472 QuicFrame(new QuicStreamFrame()));
474 } 473 }
475 OnSerializedPacket(&serialized_packet); 474 OnSerializedPacket(&serialized_packet);
476 } 475 }
477 476
478 QuicConsumedData SendStreamDataWithString( 477 QuicConsumedData SendStreamDataWithString(
479 QuicStreamId id, 478 QuicStreamId id,
480 StringPiece data, 479 StringPiece data,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 QuicPacketEntropyHash ProcessFramePacket(QuicFrame frame) { 765 QuicPacketEntropyHash ProcessFramePacket(QuicFrame frame) {
767 QuicFrames frames; 766 QuicFrames frames;
768 frames.push_back(QuicFrame(frame)); 767 frames.push_back(QuicFrame(frame));
769 QuicPacketCreatorPeer::SetSendVersionInPacket( 768 QuicPacketCreatorPeer::SetSendVersionInPacket(
770 &peer_creator_, connection_.perspective() == Perspective::IS_SERVER); 769 &peer_creator_, connection_.perspective() == Perspective::IS_SERVER);
771 770
772 char buffer[kMaxPacketSize]; 771 char buffer[kMaxPacketSize];
773 SerializedPacket serialized_packet = 772 SerializedPacket serialized_packet =
774 QuicPacketCreatorPeer::SerializeAllFrames(&peer_creator_, frames, 773 QuicPacketCreatorPeer::SerializeAllFrames(&peer_creator_, frames,
775 buffer, kMaxPacketSize); 774 buffer, kMaxPacketSize);
776 scoped_ptr<QuicEncryptedPacket> encrypted(serialized_packet.packet); 775 connection_.ProcessUdpPacket(
777 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *encrypted); 776 kSelfAddress, kPeerAddress,
777 QuicEncryptedPacket(serialized_packet.encrypted_buffer,
778 serialized_packet.encrypted_length));
778 return serialized_packet.entropy_hash; 779 return serialized_packet.entropy_hash;
779 } 780 }
780 781
781 QuicPacketEntropyHash ProcessFramePacketAtLevel(QuicPathId path_id, 782 QuicPacketEntropyHash ProcessFramePacketAtLevel(QuicPathId path_id,
782 QuicPacketNumber number, 783 QuicPacketNumber number,
783 QuicFrame frame, 784 QuicFrame frame,
784 EncryptionLevel level) { 785 EncryptionLevel level) {
785 QuicPacketHeader header; 786 QuicPacketHeader header;
786 header.public_header.connection_id = connection_id_; 787 header.public_header.connection_id = connection_id_;
787 header.public_header.packet_number_length = packet_number_length_; 788 header.public_header.packet_number_length = packet_number_length_;
(...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 3512
3512 // SetFromConfig sets the initial timeouts before negotiation. 3513 // SetFromConfig sets the initial timeouts before negotiation.
3513 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 3514 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3514 QuicConfig config; 3515 QuicConfig config;
3515 connection_.SetFromConfig(config); 3516 connection_.SetFromConfig(config);
3516 // Subtract a second from the idle timeout on the client side. 3517 // Subtract a second from the idle timeout on the client side.
3517 QuicTime default_timeout = clock_.ApproximateNow().Add( 3518 QuicTime default_timeout = clock_.ApproximateNow().Add(
3518 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); 3519 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1));
3519 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); 3520 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
3520 3521
3521 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 3522 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false));
3522 // Simulate the timeout alarm firing. 3523 // Simulate the timeout alarm firing.
3523 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); 3524 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1));
3524 connection_.GetTimeoutAlarm()->Fire(); 3525 connection_.GetTimeoutAlarm()->Fire();
3525 3526
3526 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3527 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3527 EXPECT_FALSE(connection_.connected()); 3528 EXPECT_FALSE(connection_.connected());
3528 3529
3529 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 3530 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
3530 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); 3531 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
3531 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); 3532 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet());
3532 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); 3533 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet());
3533 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); 3534 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
3534 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); 3535 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet());
3535 EXPECT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet()); 3536 EXPECT_FALSE(connection_.GetMtuDiscoveryAlarm()->IsSet());
3536 } 3537 }
3537 3538
3538 TEST_P(QuicConnectionTest, OverallTimeout) { 3539 TEST_P(QuicConnectionTest, HandshakeTimeout) {
3539 // Use a shorter overall connection timeout than idle timeout for this test. 3540 // Use a shorter handshake timeout than idle timeout for this test.
3540 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5); 3541 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(5);
3541 connection_.SetNetworkTimeouts(timeout, timeout); 3542 connection_.SetNetworkTimeouts(timeout, timeout);
3542 EXPECT_TRUE(connection_.connected()); 3543 EXPECT_TRUE(connection_.connected());
3543 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); 3544 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber());
3544 3545
3545 QuicTime overall_timeout = clock_.ApproximateNow().Add(timeout).Subtract( 3546 QuicTime handshake_timeout = clock_.ApproximateNow().Add(timeout).Subtract(
3546 QuicTime::Delta::FromSeconds(1)); 3547 QuicTime::Delta::FromSeconds(1));
3547 EXPECT_EQ(overall_timeout, connection_.GetTimeoutAlarm()->deadline()); 3548 EXPECT_EQ(handshake_timeout, connection_.GetTimeoutAlarm()->deadline());
3548 EXPECT_TRUE(connection_.connected()); 3549 EXPECT_TRUE(connection_.connected());
3549 3550
3550 // Send and ack new data 3 seconds later to lengthen the idle timeout. 3551 // Send and ack new data 3 seconds later to lengthen the idle timeout.
3551 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); 3552 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr);
3552 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3)); 3553 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(3));
3553 QuicAckFrame frame = InitAckFrame(1); 3554 QuicAckFrame frame = InitAckFrame(1);
3554 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3555 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3555 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 3556 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
3556 ProcessAckPacket(&frame); 3557 ProcessAckPacket(&frame);
3557 3558
3558 // Fire early to verify it wouldn't timeout yet. 3559 // Fire early to verify it wouldn't timeout yet.
3559 connection_.GetTimeoutAlarm()->Fire(); 3560 connection_.GetTimeoutAlarm()->Fire();
3560 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); 3561 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
3561 EXPECT_TRUE(connection_.connected()); 3562 EXPECT_TRUE(connection_.connected());
3562 3563
3563 clock_.AdvanceTime(timeout.Subtract(QuicTime::Delta::FromSeconds(2))); 3564 clock_.AdvanceTime(timeout.Subtract(QuicTime::Delta::FromSeconds(2)));
3564 3565
3565 EXPECT_CALL(visitor_, 3566 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_HANDSHAKE_TIMEOUT, false));
3566 OnConnectionClosed(QUIC_CONNECTION_OVERALL_TIMED_OUT, false));
3567 // Simulate the timeout alarm firing. 3567 // Simulate the timeout alarm firing.
3568 connection_.GetTimeoutAlarm()->Fire(); 3568 connection_.GetTimeoutAlarm()->Fire();
3569 3569
3570 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3570 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3571 EXPECT_FALSE(connection_.connected()); 3571 EXPECT_FALSE(connection_.connected());
3572 3572
3573 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 3573 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
3574 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); 3574 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
3575 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); 3575 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet());
3576 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); 3576 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet());
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 // network event at t=5ms. The alarm will reregister. 3877 // network event at t=5ms. The alarm will reregister.
3878 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); 3878 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms));
3879 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); 3879 EXPECT_EQ(default_timeout, clock_.ApproximateNow());
3880 connection_.GetTimeoutAlarm()->Fire(); 3880 connection_.GetTimeoutAlarm()->Fire();
3881 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); 3881 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
3882 EXPECT_TRUE(connection_.connected()); 3882 EXPECT_TRUE(connection_.connected());
3883 EXPECT_EQ(default_timeout.Add(five_ms), 3883 EXPECT_EQ(default_timeout.Add(five_ms),
3884 connection_.GetTimeoutAlarm()->deadline()); 3884 connection_.GetTimeoutAlarm()->deadline());
3885 3885
3886 // This time, we should time out. 3886 // This time, we should time out.
3887 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 3887 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false));
3888 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 3888 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
3889 clock_.AdvanceTime(five_ms); 3889 clock_.AdvanceTime(five_ms);
3890 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); 3890 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow());
3891 connection_.GetTimeoutAlarm()->Fire(); 3891 connection_.GetTimeoutAlarm()->Fire();
3892 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3892 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3893 EXPECT_FALSE(connection_.connected()); 3893 EXPECT_FALSE(connection_.connected());
3894 } 3894 }
3895 3895
3896 TEST_P(QuicConnectionTest, OldTimeoutAfterSendSilentClose) { 3896 TEST_P(QuicConnectionTest, OldTimeoutAfterSendSilentClose) {
3897 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, false); 3897 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, false);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 // network event at t=5ms. The alarm will reregister. 3937 // network event at t=5ms. The alarm will reregister.
3938 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms)); 3938 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms));
3939 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); 3939 EXPECT_EQ(default_timeout, clock_.ApproximateNow());
3940 connection_.GetTimeoutAlarm()->Fire(); 3940 connection_.GetTimeoutAlarm()->Fire();
3941 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); 3941 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
3942 EXPECT_TRUE(connection_.connected()); 3942 EXPECT_TRUE(connection_.connected());
3943 EXPECT_EQ(default_timeout.Add(five_ms), 3943 EXPECT_EQ(default_timeout.Add(five_ms),
3944 connection_.GetTimeoutAlarm()->deadline()); 3944 connection_.GetTimeoutAlarm()->deadline());
3945 3945
3946 // This time, we should time out. 3946 // This time, we should time out.
3947 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 3947 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false));
3948 clock_.AdvanceTime(five_ms); 3948 clock_.AdvanceTime(five_ms);
3949 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); 3949 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow());
3950 connection_.GetTimeoutAlarm()->Fire(); 3950 connection_.GetTimeoutAlarm()->Fire();
3951 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3951 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3952 EXPECT_FALSE(connection_.connected()); 3952 EXPECT_FALSE(connection_.connected());
3953 } 3953 }
3954 3954
3955 TEST_P(QuicConnectionTest, TimeoutAfterSend) { 3955 TEST_P(QuicConnectionTest, TimeoutAfterSend) {
3956 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); 3956 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true);
3957 EXPECT_TRUE(connection_.connected()); 3957 EXPECT_TRUE(connection_.connected());
(...skipping 23 matching lines...) Expand all
3981 // network event at t=5ms. The alarm will reregister. 3981 // network event at t=5ms. The alarm will reregister.
3982 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms).Subtract(five_ms)); 3982 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms).Subtract(five_ms));
3983 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); 3983 EXPECT_EQ(default_timeout, clock_.ApproximateNow());
3984 connection_.GetTimeoutAlarm()->Fire(); 3984 connection_.GetTimeoutAlarm()->Fire();
3985 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); 3985 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
3986 EXPECT_TRUE(connection_.connected()); 3986 EXPECT_TRUE(connection_.connected());
3987 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms), 3987 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms),
3988 connection_.GetTimeoutAlarm()->deadline()); 3988 connection_.GetTimeoutAlarm()->deadline());
3989 3989
3990 // This time, we should time out. 3990 // This time, we should time out.
3991 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 3991 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false));
3992 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 3992 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
3993 clock_.AdvanceTime(five_ms); 3993 clock_.AdvanceTime(five_ms);
3994 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); 3994 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow());
3995 connection_.GetTimeoutAlarm()->Fire(); 3995 connection_.GetTimeoutAlarm()->Fire();
3996 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3996 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3997 EXPECT_FALSE(connection_.connected()); 3997 EXPECT_FALSE(connection_.connected());
3998 } 3998 }
3999 3999
4000 TEST_P(QuicConnectionTest, NewTimeoutAfterSendSilentClose) { 4000 TEST_P(QuicConnectionTest, NewTimeoutAfterSendSilentClose) {
4001 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); 4001 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4045 // network event at t=5ms. The alarm will reregister. 4045 // network event at t=5ms. The alarm will reregister.
4046 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms).Subtract(five_ms)); 4046 clock_.AdvanceTime(default_idle_timeout.Subtract(five_ms).Subtract(five_ms));
4047 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); 4047 EXPECT_EQ(default_timeout, clock_.ApproximateNow());
4048 connection_.GetTimeoutAlarm()->Fire(); 4048 connection_.GetTimeoutAlarm()->Fire();
4049 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); 4049 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
4050 EXPECT_TRUE(connection_.connected()); 4050 EXPECT_TRUE(connection_.connected());
4051 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms), 4051 EXPECT_EQ(default_timeout.Add(five_ms).Add(five_ms),
4052 connection_.GetTimeoutAlarm()->deadline()); 4052 connection_.GetTimeoutAlarm()->deadline());
4053 4053
4054 // This time, we should time out. 4054 // This time, we should time out.
4055 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 4055 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false));
4056 clock_.AdvanceTime(five_ms); 4056 clock_.AdvanceTime(five_ms);
4057 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); 4057 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow());
4058 connection_.GetTimeoutAlarm()->Fire(); 4058 connection_.GetTimeoutAlarm()->Fire();
4059 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 4059 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
4060 EXPECT_FALSE(connection_.connected()); 4060 EXPECT_FALSE(connection_.connected());
4061 } 4061 }
4062 4062
4063 TEST_P(QuicConnectionTest, TimeoutAfterReceive) { 4063 TEST_P(QuicConnectionTest, TimeoutAfterReceive) {
4064 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4064 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4065 EXPECT_TRUE(connection_.connected()); 4065 EXPECT_TRUE(connection_.connected());
(...skipping 25 matching lines...) Expand all
4091 // network event at t=5ms. The alarm will reregister. 4091 // network event at t=5ms. The alarm will reregister.
4092 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); 4092 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms));
4093 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); 4093 EXPECT_EQ(default_timeout, clock_.ApproximateNow());
4094 connection_.GetTimeoutAlarm()->Fire(); 4094 connection_.GetTimeoutAlarm()->Fire();
4095 EXPECT_TRUE(connection_.connected()); 4095 EXPECT_TRUE(connection_.connected());
4096 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); 4096 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
4097 EXPECT_EQ(default_timeout.Add(five_ms), 4097 EXPECT_EQ(default_timeout.Add(five_ms),
4098 connection_.GetTimeoutAlarm()->deadline()); 4098 connection_.GetTimeoutAlarm()->deadline());
4099 4099
4100 // This time, we should time out. 4100 // This time, we should time out.
4101 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 4101 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false));
4102 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 4102 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
4103 clock_.AdvanceTime(five_ms); 4103 clock_.AdvanceTime(five_ms);
4104 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); 4104 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow());
4105 connection_.GetTimeoutAlarm()->Fire(); 4105 connection_.GetTimeoutAlarm()->Fire();
4106 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 4106 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
4107 EXPECT_FALSE(connection_.connected()); 4107 EXPECT_FALSE(connection_.connected());
4108 } 4108 }
4109 4109
4110 TEST_P(QuicConnectionTest, TimeoutAfterReceiveNotSendWhenUnacked) { 4110 TEST_P(QuicConnectionTest, TimeoutAfterReceiveNotSendWhenUnacked) {
4111 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true); 4111 ValueRestore<bool> old_flags(&FLAGS_quic_use_new_idle_timeout, true);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4146 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms)); 4146 clock_.AdvanceTime(initial_idle_timeout.Subtract(five_ms));
4147 EXPECT_EQ(default_timeout, clock_.ApproximateNow()); 4147 EXPECT_EQ(default_timeout, clock_.ApproximateNow());
4148 connection_.GetTimeoutAlarm()->Fire(); 4148 connection_.GetTimeoutAlarm()->Fire();
4149 EXPECT_TRUE(connection_.connected()); 4149 EXPECT_TRUE(connection_.connected());
4150 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet()); 4150 EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
4151 EXPECT_EQ(default_timeout.Add(five_ms), 4151 EXPECT_EQ(default_timeout.Add(five_ms),
4152 connection_.GetTimeoutAlarm()->deadline()); 4152 connection_.GetTimeoutAlarm()->deadline());
4153 4153
4154 // Now, send packets while advancing the time and verify that the connection 4154 // Now, send packets while advancing the time and verify that the connection
4155 // eventually times out. 4155 // eventually times out.
4156 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 4156 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_NETWORK_IDLE_TIMEOUT, false));
4157 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); 4157 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber());
4158 for (int i = 0; i < 100 && connection_.connected(); ++i) { 4158 for (int i = 0; i < 100 && connection_.connected(); ++i) {
4159 VLOG(1) << "sending data packet"; 4159 VLOG(1) << "sending data packet";
4160 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, 4160 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin,
4161 nullptr); 4161 nullptr);
4162 connection_.GetTimeoutAlarm()->Fire(); 4162 connection_.GetTimeoutAlarm()->Fire();
4163 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); 4163 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1));
4164 } 4164 }
4165 EXPECT_FALSE(connection_.connected()); 4165 EXPECT_FALSE(connection_.connected());
4166 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 4166 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
5506 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece()); 5506 QuicStreamFrame stream_frame(1u, false, 0u, StringPiece());
5507 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)), 5507 EXPECT_DFATAL(ProcessFramePacket(QuicFrame(&stream_frame)),
5508 "Received a packet with multipath flag on when multipath is " 5508 "Received a packet with multipath flag on when multipath is "
5509 "not enabled."); 5509 "not enabled.");
5510 EXPECT_FALSE(connection_.connected()); 5510 EXPECT_FALSE(connection_.connected());
5511 } 5511 }
5512 5512
5513 } // namespace 5513 } // namespace
5514 } // namespace test 5514 } // namespace test
5515 } // namespace net 5515 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698