Index: webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
diff --git a/webrtc/modules/congestion_controller/congestion_controller_unittest.cc b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
index e8eef8c707d949d13848fd5e47c4e9b7cb7284c8..7bd27293b83221bcb274ad8787aa6be0e639f6ba 100644 |
--- a/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
+++ b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
@@ -63,30 +63,27 @@ class CongestionControllerTest : public ::testing::Test { |
~CongestionControllerTest() override {} |
void SetUp() override { |
- pacer_ = new NiceMock<MockPacedSender>(); |
- std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership. |
- controller_.reset(new CongestionController( |
- &clock_, &observer_, &remote_bitrate_observer_, &event_log_, |
- &packet_router_, std::move(pacer))); |
+ controller_.reset( |
+ new CongestionController(&clock_, &observer_, &remote_bitrate_observer_, |
+ &event_log_, &packet_router_, &pacer_)); |
bandwidth_observer_.reset( |
controller_->GetBitrateController()->CreateRtcpBandwidthObserver()); |
// Set the initial bitrate estimate and expect the |observer| and |pacer_| |
// to be updated. |
EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); |
- EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 3)); |
- EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 5)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps)); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 3)); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 5)); |
controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); |
} |
// Custom setup - use an observer that tracks the target bitrate, without |
// prescribing on which iterations it must change (like a mock would). |
void TargetBitrateTrackingSetup() { |
- std::unique_ptr<PacedSender> pacer(new NiceMock<MockPacedSender>()); |
controller_.reset(new CongestionController( |
&clock_, &target_bitrate_observer_, &remote_bitrate_observer_, |
- &event_log_, &packet_router_, std::move(pacer))); |
+ &event_log_, &packet_router_, &pacer_)); |
controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); |
} |
@@ -149,11 +146,11 @@ class CongestionControllerTest : public ::testing::Test { |
SimulatedClock clock_; |
StrictMock<MockCongestionObserver> observer_; |
TargetBitrateObserver target_bitrate_observer_; |
- NiceMock<MockPacedSender>* pacer_; |
NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; |
NiceMock<MockRtcEventLog> event_log_; |
std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; |
PacketRouter packet_router_; |
+ NiceMock<MockPacedSender> pacer_; |
std::unique_ptr<CongestionController> controller_; |
rtc::Optional<uint32_t> target_bitrate_bps_; |
@@ -165,27 +162,27 @@ TEST_F(CongestionControllerTest, OnNetworkChanged) { |
controller_->Process(); |
EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); |
bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); |
clock_.AdvanceTimeMilliseconds(25); |
controller_->Process(); |
EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps)); |
bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps); |
clock_.AdvanceTimeMilliseconds(25); |
controller_->Process(); |
} |
TEST_F(CongestionControllerTest, OnSendQueueFull) { |
- EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
+ EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) |
.WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); |
EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); |
controller_->Process(); |
// Let the pacer not be full next time the controller checks. |
- EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
+ EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) |
.WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); |
EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); |
@@ -193,23 +190,23 @@ TEST_F(CongestionControllerTest, OnSendQueueFull) { |
} |
TEST_F(CongestionControllerTest, OnSendQueueFullAndEstimateChange) { |
- EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
+ EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) |
.WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); |
EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); |
controller_->Process(); |
// Receive new estimate but let the queue still be full. |
bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); |
- EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
+ EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) |
.WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); |
// The send pacer should get the new estimate though. |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); |
clock_.AdvanceTimeMilliseconds(25); |
controller_->Process(); |
// Let the pacer not be full next time the controller checks. |
// |OnNetworkChanged| should be called with the new estimate. |
- EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
+ EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) |
.WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); |
EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); |
clock_.AdvanceTimeMilliseconds(25); |
@@ -229,9 +226,9 @@ TEST_F(CongestionControllerTest, SignalNetworkState) { |
TEST_F(CongestionControllerTest, OnNetworkRouteChanged) { |
int new_bitrate = 200000; |
- testing::Mock::VerifyAndClearExpectations(pacer_); |
+ testing::Mock::VerifyAndClearExpectations(&pacer_); |
EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _)); |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(new_bitrate)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(new_bitrate)); |
rtc::NetworkRoute route; |
route.local_network_id = 1; |
controller_->OnNetworkRouteChanged(route, new_bitrate, -1, -1); |
@@ -241,7 +238,7 @@ TEST_F(CongestionControllerTest, OnNetworkRouteChanged) { |
EXPECT_CALL( |
observer_, |
OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); |
- EXPECT_CALL(*pacer_, |
+ EXPECT_CALL(pacer_, |
SetEstimatedBitrate(congestion_controller::GetMinBitrateBps())); |
route.local_network_id = 2; |
controller_->OnNetworkRouteChanged(route, -1, -1, -1); |
@@ -249,9 +246,9 @@ TEST_F(CongestionControllerTest, OnNetworkRouteChanged) { |
TEST_F(CongestionControllerTest, OldFeedback) { |
int new_bitrate = 200000; |
- testing::Mock::VerifyAndClearExpectations(pacer_); |
+ testing::Mock::VerifyAndClearExpectations(&pacer_); |
EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _)); |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(new_bitrate)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(new_bitrate)); |
// Send a few packets on the first network route. |
std::vector<PacketFeedback> packets; |
@@ -284,7 +281,7 @@ TEST_F(CongestionControllerTest, OldFeedback) { |
EXPECT_CALL( |
observer_, |
OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); |
- EXPECT_CALL(*pacer_, |
+ EXPECT_CALL(pacer_, |
SetEstimatedBitrate(congestion_controller::GetMinBitrateBps())); |
route.local_network_id = 2; |
controller_->OnNetworkRouteChanged(route, -1, -1, -1); |
@@ -293,7 +290,7 @@ TEST_F(CongestionControllerTest, OldFeedback) { |
TEST_F(CongestionControllerTest, |
SignalNetworkStateAndQueueIsFullAndEstimateChange) { |
// Send queue is full |
- EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
+ EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) |
.WillRepeatedly(Return(PacedSender::kMaxQueueLengthMs + 1)); |
EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); |
controller_->Process(); |
@@ -307,13 +304,13 @@ TEST_F(CongestionControllerTest, |
controller_->Process(); |
// Receive new estimate but let the queue still be full. |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); |
bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); |
clock_.AdvanceTimeMilliseconds(25); |
controller_->Process(); |
// Let the pacer not be full next time the controller checks. |
- EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
+ EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) |
.WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); |
EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); |
controller_->Process(); |
@@ -323,7 +320,7 @@ TEST_F(CongestionControllerTest, GetPacerQueuingDelayMs) { |
EXPECT_CALL(observer_, OnNetworkChanged(_, _, _, _)).Times(AtLeast(1)); |
const int64_t kQueueTimeMs = 123; |
- EXPECT_CALL(*pacer_, QueueInMs()).WillRepeatedly(Return(kQueueTimeMs)); |
+ EXPECT_CALL(pacer_, QueueInMs()).WillRepeatedly(Return(kQueueTimeMs)); |
EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs()); |
// Expect zero pacer delay when network is down. |
@@ -340,7 +337,7 @@ TEST_F(CongestionControllerTest, GetProbingInterval) { |
controller_->Process(); |
EXPECT_CALL(observer_, OnNetworkChanged(_, _, _, testing::Ne(0))); |
- EXPECT_CALL(*pacer_, SetEstimatedBitrate(_)); |
+ EXPECT_CALL(pacer_, SetEstimatedBitrate(_)); |
bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); |
clock_.AdvanceTimeMilliseconds(25); |
controller_->Process(); |
@@ -373,9 +370,9 @@ TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) { |
} |
TEST_F(CongestionControllerTest, ProbeOnRouteChange) { |
- testing::Mock::VerifyAndClearExpectations(pacer_); |
- EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 6)); |
- EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 12)); |
+ testing::Mock::VerifyAndClearExpectations(&pacer_); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 6)); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 12)); |
EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); |
rtc::NetworkRoute route; |
route.local_network_id = 1; |