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

Side by Side Diff: net/quic/core/quic_sent_packet_manager_test.cc

Issue 2236973002: Landing Recent QUIC changes until 4AM, Aug 7, 2016 UTC-4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flip quic_sequencer_buffer_retire_block_in_time to true Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/core/quic_sent_packet_manager.h" 5 #include "net/quic/core/quic_sent_packet_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8 #include "base/memory/ptr_util.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/quic/core/quic_flags.h" 10 #include "net/quic/core/quic_flags.h"
11 #include "net/quic/test_tools/quic_config_peer.h" 11 #include "net/quic/test_tools/quic_config_peer.h"
12 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" 12 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
13 #include "net/quic/test_tools/quic_test_utils.h" 13 #include "net/quic/test_tools/quic_test_utils.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using std::vector; 17 using std::vector;
18 using testing::AnyNumber; 18 using testing::AnyNumber;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 ExpectAckAndLoss(true, 5, 2); 527 ExpectAckAndLoss(true, 5, 2);
528 EXPECT_CALL(debug_delegate, OnPacketLoss(2, LOSS_RETRANSMISSION, _)); 528 EXPECT_CALL(debug_delegate, OnPacketLoss(2, LOSS_RETRANSMISSION, _));
529 manager_.OnIncomingAck(ack_frame, clock_.ApproximateNow()); 529 manager_.OnIncomingAck(ack_frame, clock_.ApproximateNow());
530 530
531 VerifyUnackedPackets(nullptr, 0); 531 VerifyUnackedPackets(nullptr, 0);
532 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); 532 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_));
533 EXPECT_EQ(2u, stats_.packets_spuriously_retransmitted); 533 EXPECT_EQ(2u, stats_.packets_spuriously_retransmitted);
534 } 534 }
535 535
536 TEST_P(QuicSentPacketManagerTest, AckOriginalTransmission) { 536 TEST_P(QuicSentPacketManagerTest, AckOriginalTransmission) {
537 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm(); 537 auto loss_algorithm = base::MakeUnique<MockLossAlgorithm>();
538 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm); 538 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm.get());
539 539
540 SendDataPacket(1); 540 SendDataPacket(1);
541 RetransmitAndSendPacket(1, 2); 541 RetransmitAndSendPacket(1, 2);
542 542
543 // Ack original transmission, but that wasn't lost via fast retransmit, 543 // Ack original transmission, but that wasn't lost via fast retransmit,
544 // so no call on OnSpuriousRetransmission is expected. 544 // so no call on OnSpuriousRetransmission is expected.
545 { 545 {
546 QuicAckFrame ack_frame = InitAckFrame(1); 546 QuicAckFrame ack_frame = InitAckFrame(1);
547 ExpectAck(1); 547 ExpectAck(1);
548 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _)); 548 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _));
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 for (int i = 0; i < 5; ++i) { 1339 for (int i = 0; i < 5; ++i) {
1340 EXPECT_EQ(delay, 1340 EXPECT_EQ(delay,
1341 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); 1341 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_));
1342 delay = delay + delay; 1342 delay = delay + delay;
1343 manager_.OnRetransmissionTimeout(); 1343 manager_.OnRetransmissionTimeout();
1344 RetransmitNextPacket(i + 2); 1344 RetransmitNextPacket(i + 2);
1345 } 1345 }
1346 } 1346 }
1347 1347
1348 TEST_P(QuicSentPacketManagerTest, GetLossDelay) { 1348 TEST_P(QuicSentPacketManagerTest, GetLossDelay) {
1349 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm(); 1349 auto loss_algorithm = base::MakeUnique<MockLossAlgorithm>();
1350 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm); 1350 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm.get());
1351 1351
1352 EXPECT_CALL(*loss_algorithm, GetLossTimeout()) 1352 EXPECT_CALL(*loss_algorithm, GetLossTimeout())
1353 .WillRepeatedly(Return(QuicTime::Zero())); 1353 .WillRepeatedly(Return(QuicTime::Zero()));
1354 SendDataPacket(1); 1354 SendDataPacket(1);
1355 SendDataPacket(2); 1355 SendDataPacket(2);
1356 1356
1357 // Handle an ack which causes the loss algorithm to be evaluated and 1357 // Handle an ack which causes the loss algorithm to be evaluated and
1358 // set the loss timeout. 1358 // set the loss timeout.
1359 ExpectAck(2); 1359 ExpectAck(2);
1360 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _)); 1360 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 // Send 5 packets, mark the first 4 for retransmission, and then cancel 1563 // Send 5 packets, mark the first 4 for retransmission, and then cancel
1564 // them when 1 is acked. 1564 // them when 1 is acked.
1565 EXPECT_CALL(*send_algorithm_, PacingRate(_)) 1565 EXPECT_CALL(*send_algorithm_, PacingRate(_))
1566 .WillRepeatedly(Return(QuicBandwidth::Zero())); 1566 .WillRepeatedly(Return(QuicBandwidth::Zero()));
1567 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) 1567 EXPECT_CALL(*send_algorithm_, GetCongestionWindow())
1568 .WillOnce(Return(10 * kDefaultTCPMSS)); 1568 .WillOnce(Return(10 * kDefaultTCPMSS));
1569 const size_t kNumSentPackets = 5; 1569 const size_t kNumSentPackets = 5;
1570 for (size_t i = 1; i <= kNumSentPackets; ++i) { 1570 for (size_t i = 1; i <= kNumSentPackets; ++i) {
1571 SendDataPacket(i); 1571 SendDataPacket(i);
1572 } 1572 }
1573 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm(); 1573 auto loss_algorithm = base::MakeUnique<MockLossAlgorithm>();
1574 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm); 1574 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm.get());
1575 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 1575 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
1576 EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); 1576 EXPECT_CALL(*network_change_visitor_, OnCongestionChange());
1577 SendAlgorithmInterface::CongestionVector lost_packets; 1577 SendAlgorithmInterface::CongestionVector lost_packets;
1578 for (size_t i = 1; i < kNumSentPackets; ++i) { 1578 for (size_t i = 1; i < kNumSentPackets; ++i) {
1579 lost_packets.push_back(std::make_pair(i, kMaxPacketSize)); 1579 lost_packets.push_back(std::make_pair(i, kMaxPacketSize));
1580 } 1580 }
1581 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _)) 1581 EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _))
1582 .WillOnce(SetArgPointee<4>(lost_packets)); 1582 .WillOnce(SetArgPointee<4>(lost_packets));
1583 QuicAckFrame ack_frame = InitAckFrame(kNumSentPackets); 1583 QuicAckFrame ack_frame = InitAckFrame(kNumSentPackets);
1584 NackPackets(1, kNumSentPackets, &ack_frame); 1584 NackPackets(1, kNumSentPackets, &ack_frame);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 ExpectAck(1); 1710 ExpectAck(1);
1711 EXPECT_CALL(*network_change_visitor_, 1711 EXPECT_CALL(*network_change_visitor_,
1712 OnPathMtuIncreased(kDefaultLength + 100)); 1712 OnPathMtuIncreased(kDefaultLength + 100));
1713 QuicAckFrame ack_frame = InitAckFrame(1); 1713 QuicAckFrame ack_frame = InitAckFrame(1);
1714 manager_.OnIncomingAck(ack_frame, clock_.Now()); 1714 manager_.OnIncomingAck(ack_frame, clock_.Now());
1715 } 1715 }
1716 1716
1717 } // namespace 1717 } // namespace
1718 } // namespace test 1718 } // namespace test
1719 } // namespace net 1719 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_sent_packet_manager_interface.h ('k') | net/quic/core/quic_server_session_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698