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 <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 return params; | 669 return params; |
670 } | 670 } |
671 | 671 |
672 class QuicConnectionTest : public ::testing::TestWithParam<TestParams> { | 672 class QuicConnectionTest : public ::testing::TestWithParam<TestParams> { |
673 protected: | 673 protected: |
674 QuicConnectionTest() | 674 QuicConnectionTest() |
675 : connection_id_(42), | 675 : connection_id_(42), |
676 framer_(SupportedVersions(version()), | 676 framer_(SupportedVersions(version()), |
677 QuicTime::Zero(), | 677 QuicTime::Zero(), |
678 Perspective::IS_CLIENT), | 678 Perspective::IS_CLIENT), |
679 peer_creator_(connection_id_, &framer_, &random_generator_), | 679 peer_creator_(connection_id_, |
680 &framer_, | |
681 &random_generator_, | |
682 /*delegate=*/nullptr), | |
680 send_algorithm_(new StrictMock<MockSendAlgorithm>), | 683 send_algorithm_(new StrictMock<MockSendAlgorithm>), |
681 loss_algorithm_(new MockLossAlgorithm()), | 684 loss_algorithm_(new MockLossAlgorithm()), |
682 helper_(new TestConnectionHelper(&clock_, &random_generator_)), | 685 helper_(new TestConnectionHelper(&clock_, &random_generator_)), |
683 writer_(new TestPacketWriter(version(), &clock_)), | 686 writer_(new TestPacketWriter(version(), &clock_)), |
684 factory_(writer_.get()), | 687 factory_(writer_.get()), |
685 connection_(connection_id_, | 688 connection_(connection_id_, |
686 kPeerAddress, | 689 kPeerAddress, |
687 helper_.get(), | 690 helper_.get(), |
688 factory_, | 691 factory_, |
689 Perspective::IS_CLIENT, | 692 Perspective::IS_CLIENT, |
(...skipping 4552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5242 | 5245 |
5243 TEST_P(QuicConnectionTest, DoNotSendGoAwayTwice) { | 5246 TEST_P(QuicConnectionTest, DoNotSendGoAwayTwice) { |
5244 EXPECT_FALSE(connection_.goaway_sent()); | 5247 EXPECT_FALSE(connection_.goaway_sent()); |
5245 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); | 5248 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); |
5246 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); | 5249 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); |
5247 EXPECT_TRUE(connection_.goaway_sent()); | 5250 EXPECT_TRUE(connection_.goaway_sent()); |
5248 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 5251 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
5249 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); | 5252 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); |
5250 } | 5253 } |
5251 | 5254 |
5255 TEST_P(QuicConnectionTest, ReevaluateTimeUntilSendOnAck) { | |
5256 FLAGS_quic_respect_send_alarm = true; | |
5257 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | |
5258 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, | |
5259 nullptr); | |
5260 | |
5261 // Evaluate CanWrite, and have it return a non-Zero value. | |
5262 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) | |
5263 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1))); | |
5264 connection_.OnCanWrite(); | |
5265 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); | |
5266 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(1)), | |
5267 connection_.GetSendAlarm()->deadline()); | |
5268 | |
5269 // Process an ack and the send alarm will be set to the new 2ms delay. | |
5270 QuicAckFrame ack = InitAckFrame(1); | |
5271 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) | |
5272 .WillOnce(Return(PacketNumberSet())); | |
Ryan Hamilton
2015/11/23 20:30:07
This wasn't part of the internal CL 107699435, was
Ryan Hamilton
2015/11/23 20:51:11
Do you understand why it changed as part of the CL
| |
5273 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | |
5274 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) | |
5275 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2))); | |
5276 ProcessAckPacket(&ack); | |
5277 EXPECT_EQ(1u, writer_->frame_count()); | |
5278 EXPECT_EQ(1u, writer_->stream_frames().size()); | |
5279 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); | |
5280 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)), | |
5281 connection_.GetSendAlarm()->deadline()); | |
5282 writer_->Reset(); | |
5283 } | |
5284 | |
5252 } // namespace | 5285 } // namespace |
5253 } // namespace test | 5286 } // namespace test |
5254 } // namespace net | 5287 } // namespace net |
OLD | NEW |