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

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

Issue 1814843002: Remove the unused has_retransmittable_data argument from QuicSendAlgorithm::TimeUntilSend. No func… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116887287
Patch Set: Created 4 years, 9 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
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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 frame2_(1, false, 3, StringPiece(data2)), 654 frame2_(1, false, 3, StringPiece(data2)),
655 packet_number_length_(PACKET_6BYTE_PACKET_NUMBER), 655 packet_number_length_(PACKET_6BYTE_PACKET_NUMBER),
656 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { 656 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) {
657 connection_.set_defer_send_in_response_to_packets(GetParam().ack_response == 657 connection_.set_defer_send_in_response_to_packets(GetParam().ack_response ==
658 AckResponse::kDefer); 658 AckResponse::kDefer);
659 FLAGS_quic_always_log_bugs_for_tests = true; 659 FLAGS_quic_always_log_bugs_for_tests = true;
660 connection_.set_visitor(&visitor_); 660 connection_.set_visitor(&visitor_);
661 connection_.SetSendAlgorithm(send_algorithm_); 661 connection_.SetSendAlgorithm(send_algorithm_);
662 connection_.SetLossAlgorithm(loss_algorithm_); 662 connection_.SetLossAlgorithm(loss_algorithm_);
663 framer_.set_received_entropy_calculator(&entropy_calculator_); 663 framer_.set_received_entropy_calculator(&entropy_calculator_);
664 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 664 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
665 .WillRepeatedly(Return(QuicTime::Delta::Zero())); 665 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
666 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 666 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
667 .Times(AnyNumber()); 667 .Times(AnyNumber());
668 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()) 668 EXPECT_CALL(*send_algorithm_, RetransmissionDelay())
669 .WillRepeatedly(Return(QuicTime::Delta::Zero())); 669 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
670 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 670 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
671 .WillRepeatedly(Return(kDefaultTCPMSS)); 671 .WillRepeatedly(Return(kDefaultTCPMSS));
672 EXPECT_CALL(*send_algorithm_, PacingRate()) 672 EXPECT_CALL(*send_algorithm_, PacingRate())
673 .WillRepeatedly(Return(QuicBandwidth::Zero())); 673 .WillRepeatedly(Return(QuicBandwidth::Zero()));
674 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 674 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 void BlockOnNextWrite() { 974 void BlockOnNextWrite() {
975 writer_->BlockOnNextWrite(); 975 writer_->BlockOnNextWrite();
976 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1)); 976 EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(1));
977 } 977 }
978 978
979 void SetWritePauseTimeDelta(QuicTime::Delta delta) { 979 void SetWritePauseTimeDelta(QuicTime::Delta delta) {
980 writer_->SetWritePauseTimeDelta(delta); 980 writer_->SetWritePauseTimeDelta(delta);
981 } 981 }
982 982
983 void CongestionBlockWrites() { 983 void CongestionBlockWrites() {
984 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 984 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
985 .WillRepeatedly(testing::Return(QuicTime::Delta::FromSeconds(1))); 985 .WillRepeatedly(testing::Return(QuicTime::Delta::FromSeconds(1)));
986 } 986 }
987 987
988 void CongestionUnblockWrites() { 988 void CongestionUnblockWrites() {
989 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 989 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
990 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); 990 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
991 } 991 }
992 992
993 QuicConnectionId connection_id_; 993 QuicConnectionId connection_id_;
994 QuicFramer framer_; 994 QuicFramer framer_;
995 MockEntropyCalculator entropy_calculator_; 995 MockEntropyCalculator entropy_calculator_;
996 996
997 MockSendAlgorithm* send_algorithm_; 997 MockSendAlgorithm* send_algorithm_;
998 MockLossAlgorithm* loss_algorithm_; 998 MockLossAlgorithm* loss_algorithm_;
999 MockClock clock_; 999 MockClock clock_;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 1312
1313 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) { 1313 TEST_P(QuicConnectionTest, AckReceiptCausesAckSendBadEntropy) {
1314 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1314 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1315 1315
1316 ProcessPacket(kDefaultPathId, 1); 1316 ProcessPacket(kDefaultPathId, 1);
1317 // Delay sending, then queue up an ack. 1317 // Delay sending, then queue up an ack.
1318 QuicConnectionPeer::SendAck(&connection_); 1318 QuicConnectionPeer::SendAck(&connection_);
1319 1319
1320 // Process an ack with a least unacked of the received ack. 1320 // Process an ack with a least unacked of the received ack.
1321 // This causes an ack to be sent when TimeUntilSend returns 0. 1321 // This causes an ack to be sent when TimeUntilSend returns 0.
1322 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 1322 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
1323 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); 1323 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
1324 // Skip a packet and then record an ack. 1324 // Skip a packet and then record an ack.
1325 QuicAckFrame frame = InitAckFrame(0); 1325 QuicAckFrame frame = InitAckFrame(0);
1326 ProcessAckPacket(3, &frame); 1326 ProcessAckPacket(3, &frame);
1327 } 1327 }
1328 1328
1329 TEST_P(QuicConnectionTest, OutOfOrderReceiptCausesAckSend) { 1329 TEST_P(QuicConnectionTest, OutOfOrderReceiptCausesAckSend) {
1330 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1330 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1331 1331
1332 ProcessPacket(kDefaultPathId, 3); 1332 ProcessPacket(kDefaultPathId, 3);
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 } 1890 }
1891 1891
1892 TEST_P(QuicConnectionTest, OnCanWrite) { 1892 TEST_P(QuicConnectionTest, OnCanWrite) {
1893 // Visitor's OnCanWrite will send data, but will have more pending writes. 1893 // Visitor's OnCanWrite will send data, but will have more pending writes.
1894 EXPECT_CALL(visitor_, OnCanWrite()) 1894 EXPECT_CALL(visitor_, OnCanWrite())
1895 .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs( 1895 .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs(
1896 &connection_, &TestConnection::SendStreamData3)), 1896 &connection_, &TestConnection::SendStreamData3)),
1897 IgnoreResult(InvokeWithoutArgs( 1897 IgnoreResult(InvokeWithoutArgs(
1898 &connection_, &TestConnection::SendStreamData5)))); 1898 &connection_, &TestConnection::SendStreamData5))));
1899 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillOnce(Return(true)); 1899 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillOnce(Return(true));
1900 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 1900 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
1901 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); 1901 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
1902 1902
1903 connection_.OnCanWrite(); 1903 connection_.OnCanWrite();
1904 1904
1905 // Parse the last packet and ensure it's the two stream frames from 1905 // Parse the last packet and ensure it's the two stream frames from
1906 // two different streams. 1906 // two different streams.
1907 EXPECT_EQ(2u, writer_->frame_count()); 1907 EXPECT_EQ(2u, writer_->frame_count());
1908 EXPECT_EQ(2u, writer_->stream_frames().size()); 1908 EXPECT_EQ(2u, writer_->stream_frames().size());
1909 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0]->stream_id); 1909 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0]->stream_id);
1910 EXPECT_EQ(kClientDataStreamId2, writer_->stream_frames()[1]->stream_id); 1910 EXPECT_EQ(kClientDataStreamId2, writer_->stream_frames()[1]->stream_id);
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); 2498 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
2499 } 2499 }
2500 2500
2501 TEST_P(QuicConnectionTest, SendHandshakeMessages) { 2501 TEST_P(QuicConnectionTest, SendHandshakeMessages) {
2502 use_tagging_decrypter(); 2502 use_tagging_decrypter();
2503 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at 2503 // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at
2504 // the end of the packet. We can test this to check which encrypter was used. 2504 // the end of the packet. We can test this to check which encrypter was used.
2505 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01)); 2505 connection_.SetEncrypter(ENCRYPTION_NONE, new TaggingEncrypter(0x01));
2506 2506
2507 // Attempt to send a handshake message and have the socket block. 2507 // Attempt to send a handshake message and have the socket block.
2508 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 2508 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
2509 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); 2509 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
2510 BlockOnNextWrite(); 2510 BlockOnNextWrite();
2511 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr); 2511 connection_.SendStreamDataWithString(1, "foo", 0, !kFin, nullptr);
2512 // The packet should be serialized, but not queued. 2512 // The packet should be serialized, but not queued.
2513 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 2513 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2514 2514
2515 // Switch to the new encrypter. 2515 // Switch to the new encrypter.
2516 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02)); 2516 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(0x02));
2517 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); 2517 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
2518 2518
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 3419
3420 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { 3420 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) {
3421 // All packets carry version info till version is negotiated. 3421 // All packets carry version info till version is negotiated.
3422 size_t payload_length; 3422 size_t payload_length;
3423 size_t length = GetPacketLengthForOneStream( 3423 size_t length = GetPacketLengthForOneStream(
3424 connection_.version(), kIncludeVersion, !kIncludePathId, 3424 connection_.version(), kIncludeVersion, !kIncludePathId,
3425 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_PACKET_NUMBER, &payload_length); 3425 PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_PACKET_NUMBER, &payload_length);
3426 connection_.SetMaxPacketLength(length); 3426 connection_.SetMaxPacketLength(length);
3427 3427
3428 // Queue the first packet. 3428 // Queue the first packet.
3429 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 3429 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
3430 .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(10))); 3430 .WillOnce(testing::Return(QuicTime::Delta::FromMicroseconds(10)));
3431 const string payload(payload_length, 'a'); 3431 const string payload(payload_length, 'a');
3432 EXPECT_EQ(0u, 3432 EXPECT_EQ(0u,
3433 connection_.SendStreamDataWithString(3, payload, 0, !kFin, nullptr) 3433 connection_.SendStreamDataWithString(3, payload, 0, !kFin, nullptr)
3434 .bytes_consumed); 3434 .bytes_consumed);
3435 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 3435 EXPECT_EQ(0u, connection_.NumQueuedPackets());
3436 } 3436 }
3437 3437
3438 TEST_P(QuicConnectionTest, LoopThroughSendingPackets) { 3438 TEST_P(QuicConnectionTest, LoopThroughSendingPackets) {
3439 // All packets carry version info till version is negotiated. 3439 // All packets carry version info till version is negotiated.
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4566 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); 4566 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
4567 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); 4567 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away.");
4568 } 4568 }
4569 4569
4570 TEST_P(QuicConnectionTest, ReevaluateTimeUntilSendOnAck) { 4570 TEST_P(QuicConnectionTest, ReevaluateTimeUntilSendOnAck) {
4571 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4571 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4572 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin, 4572 connection_.SendStreamDataWithString(kClientDataStreamId1, "foo", 0, !kFin,
4573 nullptr); 4573 nullptr);
4574 4574
4575 // Evaluate CanWrite, and have it return a non-Zero value. 4575 // Evaluate CanWrite, and have it return a non-Zero value.
4576 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 4576 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
4577 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1))); 4577 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(1)));
4578 connection_.OnCanWrite(); 4578 connection_.OnCanWrite();
4579 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); 4579 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet());
4580 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(1)), 4580 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(1)),
4581 connection_.GetSendAlarm()->deadline()); 4581 connection_.GetSendAlarm()->deadline());
4582 4582
4583 // Process an ack and the send alarm will be set to the new 2ms delay. 4583 // Process an ack and the send alarm will be set to the new 2ms delay.
4584 QuicAckFrame ack = InitAckFrame(1); 4584 QuicAckFrame ack = InitAckFrame(1);
4585 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _)); 4585 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _));
4586 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 4586 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
4587 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)) 4587 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
4588 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2))); 4588 .WillRepeatedly(Return(QuicTime::Delta::FromMilliseconds(2)));
4589 ProcessAckPacket(&ack); 4589 ProcessAckPacket(&ack);
4590 EXPECT_EQ(1u, writer_->frame_count()); 4590 EXPECT_EQ(1u, writer_->frame_count());
4591 EXPECT_EQ(1u, writer_->stream_frames().size()); 4591 EXPECT_EQ(1u, writer_->stream_frames().size());
4592 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet()); 4592 EXPECT_TRUE(connection_.GetSendAlarm()->IsSet());
4593 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)), 4593 EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(2)),
4594 connection_.GetSendAlarm()->deadline()); 4594 connection_.GetSendAlarm()->deadline());
4595 writer_->Reset(); 4595 writer_->Reset();
4596 } 4596 }
4597 4597
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 // result in multiple attempts to close the connection - it will be marked as 4697 // result in multiple attempts to close the connection - it will be marked as
4698 // disconnected after the first call. 4698 // disconnected after the first call.
4699 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1); 4699 EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(1);
4700 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); 4700 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason");
4701 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason"); 4701 connection_.SendConnectionCloseWithDetails(QUIC_NO_ERROR, "no reason");
4702 } 4702 }
4703 4703
4704 } // namespace 4704 } // namespace
4705 } // namespace test 4705 } // namespace test
4706 } // namespace net 4706 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender_packets_test.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698