| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate()) | 631 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate()) |
| 632 .Times(AnyNumber()); | 632 .Times(AnyNumber()); |
| 633 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) | 633 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) |
| 634 .Times(AnyNumber()) | 634 .Times(AnyNumber()) |
| 635 .WillRepeatedly(Return(QuicBandwidth::Zero())); | 635 .WillRepeatedly(Return(QuicBandwidth::Zero())); |
| 636 EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); | 636 EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); |
| 637 EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); | 637 EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); |
| 638 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber()); | 638 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber()); |
| 639 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); | 639 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); |
| 640 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); | 640 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); |
| 641 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); | 641 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) |
| 642 .WillRepeatedly(Return(false)); |
| 642 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); | 643 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); |
| 643 | 644 |
| 644 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) | 645 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) |
| 645 .WillRepeatedly(Return(QuicTime::Zero())); | 646 .WillRepeatedly(Return(QuicTime::Zero())); |
| 646 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | 647 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 647 .WillRepeatedly(Return(SequenceNumberSet())); | 648 .WillRepeatedly(Return(SequenceNumberSet())); |
| 648 } | 649 } |
| 649 | 650 |
| 650 QuicVersion version() { | 651 QuicVersion version() { |
| 651 return GetParam(); | 652 return GetParam(); |
| (...skipping 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3115 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); | 3116 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); |
| 3116 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3117 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 3117 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); | 3118 EXPECT_FALSE(connection_.GetFecAlarm()->IsSet()); |
| 3118 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); | 3119 EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet()); |
| 3119 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 3120 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 3120 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); | 3121 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet()); |
| 3121 } | 3122 } |
| 3122 | 3123 |
| 3123 TEST_P(QuicConnectionTest, PingAfterSend) { | 3124 TEST_P(QuicConnectionTest, PingAfterSend) { |
| 3124 EXPECT_TRUE(connection_.connected()); | 3125 EXPECT_TRUE(connection_.connected()); |
| 3125 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(true)); | 3126 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(true)); |
| 3126 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3127 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 3127 | 3128 |
| 3128 // Advance to 5ms, and send a packet to the peer, which will set | 3129 // Advance to 5ms, and send a packet to the peer, which will set |
| 3129 // the ping alarm. | 3130 // the ping alarm. |
| 3130 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 3131 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
| 3131 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); | 3132 EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); |
| 3132 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); | 3133 SendStreamDataToPeer(1, "GET /", 0, kFin, nullptr); |
| 3133 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); | 3134 EXPECT_TRUE(connection_.GetPingAlarm()->IsSet()); |
| 3134 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), | 3135 EXPECT_EQ(clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(15)), |
| 3135 connection_.GetPingAlarm()->deadline()); | 3136 connection_.GetPingAlarm()->deadline()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3148 .Subtract(QuicTime::Delta::FromMilliseconds(5)), | 3149 .Subtract(QuicTime::Delta::FromMilliseconds(5)), |
| 3149 connection_.GetPingAlarm()->deadline()); | 3150 connection_.GetPingAlarm()->deadline()); |
| 3150 | 3151 |
| 3151 writer_->Reset(); | 3152 writer_->Reset(); |
| 3152 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); | 3153 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); |
| 3153 connection_.GetPingAlarm()->Fire(); | 3154 connection_.GetPingAlarm()->Fire(); |
| 3154 EXPECT_EQ(1u, writer_->frame_count()); | 3155 EXPECT_EQ(1u, writer_->frame_count()); |
| 3155 ASSERT_EQ(1u, writer_->ping_frames().size()); | 3156 ASSERT_EQ(1u, writer_->ping_frames().size()); |
| 3156 writer_->Reset(); | 3157 writer_->Reset(); |
| 3157 | 3158 |
| 3158 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); | 3159 EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false)); |
| 3159 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); | 3160 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); |
| 3160 SendAckPacketToPeer(); | 3161 SendAckPacketToPeer(); |
| 3161 | 3162 |
| 3162 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); | 3163 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); |
| 3163 } | 3164 } |
| 3164 | 3165 |
| 3165 TEST_P(QuicConnectionTest, TimeoutAfterSend) { | 3166 TEST_P(QuicConnectionTest, TimeoutAfterSend) { |
| 3166 EXPECT_TRUE(connection_.connected()); | 3167 EXPECT_TRUE(connection_.connected()); |
| 3167 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); | 3168 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); |
| 3168 QuicConfig config; | 3169 QuicConfig config; |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4379 // Regression test for b/18594622 | 4380 // Regression test for b/18594622 |
| 4380 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 4381 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
| 4381 EXPECT_DFATAL( | 4382 EXPECT_DFATAL( |
| 4382 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), | 4383 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), |
| 4383 "Attempt to send empty stream frame"); | 4384 "Attempt to send empty stream frame"); |
| 4384 } | 4385 } |
| 4385 | 4386 |
| 4386 } // namespace | 4387 } // namespace |
| 4387 } // namespace test | 4388 } // namespace test |
| 4388 } // namespace net | 4389 } // namespace net |
| OLD | NEW |