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 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 connection_.GetTimeoutAlarm()->Fire(); | 2674 connection_.GetTimeoutAlarm()->Fire(); |
2675 | 2675 |
2676 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 2676 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
2677 EXPECT_FALSE(connection_.connected()); | 2677 EXPECT_FALSE(connection_.connected()); |
2678 | 2678 |
2679 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 2679 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
2680 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 2680 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
2681 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); | 2681 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
2682 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 2682 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
2683 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); | 2683 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
| 2684 } |
| 2685 |
| 2686 TEST_P(QuicConnectionTest, OverallTimeout) { |
| 2687 connection_.SetOverallConnectionTimeout( |
| 2688 QuicTime::Delta::FromSeconds(kDefaultMaxTimeForCryptoHandshakeSecs)); |
| 2689 EXPECT_TRUE(connection_.connected()); |
| 2690 EXPECT_CALL(visitor_, |
| 2691 OnConnectionClosed(QUIC_CONNECTION_OVERALL_TIMED_OUT, false)); |
| 2692 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); |
| 2693 |
| 2694 QuicTime overall_timeout = clock_.ApproximateNow().Add( |
| 2695 QuicTime::Delta::FromSeconds(kDefaultMaxTimeForCryptoHandshakeSecs)); |
| 2696 EXPECT_EQ(overall_timeout, connection_.GetTimeoutAlarm()->deadline()); |
| 2697 |
| 2698 EXPECT_TRUE(connection_.connected()); |
| 2699 SendStreamDataToPeer(1, "GET /", 0, kFin, NULL); |
| 2700 |
| 2701 clock_.AdvanceTime( |
| 2702 QuicTime::Delta::FromSeconds(2 * kDefaultInitialTimeoutSecs)); |
| 2703 |
| 2704 // Process an ack and see that the connection still times out. |
| 2705 QuicAckFrame frame = InitAckFrame(1); |
| 2706 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2707 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 2708 ProcessAckPacket(&frame); |
| 2709 |
| 2710 // Simulate the timeout alarm firing. |
| 2711 connection_.GetTimeoutAlarm()->Fire(); |
| 2712 |
2684 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); | 2713 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); |
| 2714 EXPECT_FALSE(connection_.connected()); |
| 2715 |
| 2716 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 2717 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 2718 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
| 2719 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 2720 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
2685 } | 2721 } |
2686 | 2722 |
2687 TEST_P(QuicConnectionTest, PingAfterSend) { | 2723 TEST_P(QuicConnectionTest, PingAfterSend) { |
2688 EXPECT_TRUE(connection_.connected()); | 2724 EXPECT_TRUE(connection_.connected()); |
2689 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(true)); | 2725 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(true)); |
2690 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 2726 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
2691 | 2727 |
2692 // Advance to 5ms, and send a packet to the peer, which will set | 2728 // Advance to 5ms, and send a packet to the peer, which will set |
2693 // the ping alarm. | 2729 // the ping alarm. |
2694 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 2730 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3906 QuicBlockedFrame blocked; | 3942 QuicBlockedFrame blocked; |
3907 blocked.stream_id = 3; | 3943 blocked.stream_id = 3; |
3908 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3944 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
3909 ProcessFramePacket(QuicFrame(&blocked)); | 3945 ProcessFramePacket(QuicFrame(&blocked)); |
3910 EXPECT_TRUE(ack_alarm->IsSet()); | 3946 EXPECT_TRUE(ack_alarm->IsSet()); |
3911 } | 3947 } |
3912 | 3948 |
3913 } // namespace | 3949 } // namespace |
3914 } // namespace test | 3950 } // namespace test |
3915 } // namespace net | 3951 } // namespace net |
OLD | NEW |