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

Side by Side Diff: net/quic/core/congestion_control/pacing_sender_test.cc

Issue 2228613002: Rollback of internal changelist 128865569. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129053230
Patch Set: 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
« no previous file with comments | « net/quic/core/congestion_control/pacing_sender.cc ('k') | net/quic/core/quic_flags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/congestion_control/pacing_sender.h" 5 #include "net/quic/core/congestion_control/pacing_sender.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/quic/core/quic_protocol.h" 10 #include "net/quic/core/quic_protocol.h"
(...skipping 11 matching lines...) Expand all
22 const QuicByteCount kBytesInFlight = 1024; 22 const QuicByteCount kBytesInFlight = 1024;
23 const int kInitialBurstPackets = 10; 23 const int kInitialBurstPackets = 10;
24 24
25 class PacingSenderTest : public ::testing::Test { 25 class PacingSenderTest : public ::testing::Test {
26 protected: 26 protected:
27 PacingSenderTest() 27 PacingSenderTest()
28 : zero_time_(QuicTime::Delta::Zero()), 28 : zero_time_(QuicTime::Delta::Zero()),
29 infinite_time_(QuicTime::Delta::Infinite()), 29 infinite_time_(QuicTime::Delta::Infinite()),
30 packet_number_(1), 30 packet_number_(1),
31 mock_sender_(new StrictMock<MockSendAlgorithm>()), 31 mock_sender_(new StrictMock<MockSendAlgorithm>()),
32 pacing_sender_(new PacingSender) { 32 pacing_sender_(new PacingSender(mock_sender_,
33 pacing_sender_->SetSender(mock_sender_, true); 33 QuicTime::Delta::FromMilliseconds(1),
34 0)) {
34 // Pick arbitrary time. 35 // Pick arbitrary time.
35 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(9)); 36 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(9));
36 } 37 }
37 38
38 ~PacingSenderTest() override {} 39 ~PacingSenderTest() override {}
39 40
40 void InitPacingRate(QuicPacketCount burst_size, QuicBandwidth bandwidth) { 41 void InitPacingRate(QuicPacketCount burst_size, QuicBandwidth bandwidth) {
42 pacing_sender_.reset();
41 mock_sender_ = new StrictMock<MockSendAlgorithm>(); 43 mock_sender_ = new StrictMock<MockSendAlgorithm>();
42 pacing_sender_.reset(new PacingSender); 44 pacing_sender_.reset(new PacingSender(
43 pacing_sender_->SetSender(mock_sender_, true); 45 mock_sender_, QuicTime::Delta::FromMilliseconds(1), burst_size));
44 EXPECT_CALL(*mock_sender_, PacingRate(_)).WillRepeatedly(Return(bandwidth)); 46 EXPECT_CALL(*mock_sender_, PacingRate(_)).WillRepeatedly(Return(bandwidth));
45 if (burst_size == 0) {
46 EXPECT_CALL(*mock_sender_, OnCongestionEvent(_, _, _, _));
47 SendAlgorithmInterface::CongestionVector lost_packets;
48 lost_packets.push_back(std::make_pair(1, kMaxPacketSize));
49 SendAlgorithmInterface::CongestionVector empty;
50 pacing_sender_->OnCongestionEvent(true, 1234, empty, lost_packets);
51 } else if (burst_size != kInitialBurstPackets) {
52 LOG(FATAL) << "Unsupported burst_size specificied.";
53 }
54 } 47 }
55 48
56 void CheckPacketIsSentImmediately(HasRetransmittableData retransmittable_data, 49 void CheckPacketIsSentImmediately(HasRetransmittableData retransmittable_data,
57 QuicByteCount bytes_in_flight, 50 QuicByteCount bytes_in_flight,
58 bool in_recovery) { 51 bool in_recovery) {
59 // In order for the packet to be sendable, the underlying sender must 52 // In order for the packet to be sendable, the underlying sender must
60 // permit it to be sent immediately. 53 // permit it to be sent immediately.
61 for (int i = 0; i < 2; ++i) { 54 for (int i = 0; i < 2; ++i) {
62 EXPECT_CALL(*mock_sender_, TimeUntilSend(clock_.Now(), bytes_in_flight)) 55 EXPECT_CALL(*mock_sender_, TimeUntilSend(clock_.Now(), bytes_in_flight))
63 .WillOnce(Return(zero_time_)); 56 .WillOnce(Return(zero_time_));
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 330
338 UpdateRtt(); 331 UpdateRtt();
339 332
340 // Ensure only one packet is sent immediately and the rest are paced. 333 // Ensure only one packet is sent immediately and the rest are paced.
341 CheckPacketIsSentImmediately(HAS_RETRANSMITTABLE_DATA, 0, true); 334 CheckPacketIsSentImmediately(HAS_RETRANSMITTABLE_DATA, 0, true);
342 CheckPacketIsSentImmediately(); 335 CheckPacketIsSentImmediately();
343 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); 336 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2));
344 } 337 }
345 338
346 TEST_F(PacingSenderTest, VerifyInnerSenderCalled) { 339 TEST_F(PacingSenderTest, VerifyInnerSenderCalled) {
347 // Configure pacing rate of 1 packet per 1 ms with no burst tokens.
348 InitPacingRate(0, QuicBandwidth::FromBytesAndTimeDelta(
349 kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1)));
350 QuicBandwidth kBandwidth = QuicBandwidth::FromBitsPerSecond(1000); 340 QuicBandwidth kBandwidth = QuicBandwidth::FromBitsPerSecond(1000);
351 QuicTime kTime = QuicTime::Infinite(); 341 QuicTime kTime = QuicTime::Infinite();
352 QuicTime::Delta kTimeDelta = QuicTime::Delta::Infinite(); 342 QuicTime::Delta kTimeDelta = QuicTime::Delta::Infinite();
353 QuicByteCount kBytes = 12345u; 343 QuicByteCount kBytes = 12345u;
354 344
355 EXPECT_CALL(*mock_sender_, SetFromConfig(_, Perspective::IS_SERVER)); 345 EXPECT_CALL(*mock_sender_, SetFromConfig(_, Perspective::IS_SERVER));
356 QuicConfig config; 346 QuicConfig config;
357 pacing_sender_->SetFromConfig(config, Perspective::IS_SERVER); 347 pacing_sender_->SetFromConfig(config, Perspective::IS_SERVER);
358 348
359 EXPECT_CALL(*mock_sender_, ResumeConnectionState(_, true)); 349 EXPECT_CALL(*mock_sender_, ResumeConnectionState(_, true));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 EXPECT_CALL(*mock_sender_, GetSlowStartThreshold()).WillOnce(Return(kBytes)); 395 EXPECT_CALL(*mock_sender_, GetSlowStartThreshold()).WillOnce(Return(kBytes));
406 EXPECT_EQ(kBytes, pacing_sender_->GetSlowStartThreshold()); 396 EXPECT_EQ(kBytes, pacing_sender_->GetSlowStartThreshold());
407 397
408 EXPECT_CALL(*mock_sender_, GetCongestionControlType()) 398 EXPECT_CALL(*mock_sender_, GetCongestionControlType())
409 .WillOnce(Return(kReno)); 399 .WillOnce(Return(kReno));
410 EXPECT_EQ(kReno, pacing_sender_->GetCongestionControlType()); 400 EXPECT_EQ(kReno, pacing_sender_->GetCongestionControlType());
411 } 401 }
412 402
413 } // namespace test 403 } // namespace test
414 } // namespace net 404 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/congestion_control/pacing_sender.cc ('k') | net/quic/core/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698