Index: webrtc/modules/congestion_controller/probe_controller_unittest.cc |
diff --git a/webrtc/modules/congestion_controller/probe_controller_unittest.cc b/webrtc/modules/congestion_controller/probe_controller_unittest.cc |
index 9fc0f5508849869ad2b2ad57ea0fbc3eb2f262a4..e0a040f3a1fa2852e45c9f9af5180ffcaab7bf6e 100644 |
--- a/webrtc/modules/congestion_controller/probe_controller_unittest.cc |
+++ b/webrtc/modules/congestion_controller/probe_controller_unittest.cc |
@@ -33,6 +33,8 @@ constexpr int kMaxBitrateBps = 10000; |
constexpr int kExponentialProbingTimeoutMs = 5000; |
constexpr int kAlrProbeInterval = 5000; |
+constexpr int kAlrEndedTimeoutMs = 3000; |
+constexpr int kBitrateDropTimeoutMs = 5000; |
} // namespace |
@@ -120,22 +122,71 @@ TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { |
probe_controller_->SetEstimatedBitrate(1800); |
} |
-TEST_F(ProbeControllerTest, ProbeAfterEstimateDropInAlr) { |
+TEST_F(ProbeControllerTest, RequestProbeInAlr) { |
EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2); |
probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
kMaxBitrateBps); |
probe_controller_->SetEstimatedBitrate(500); |
testing::Mock::VerifyAndClearExpectations(&pacer_); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(0.85 * 500)).Times(1); |
+ EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) |
+ .WillRepeatedly( |
+ Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds()))); |
+ clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1); |
+ probe_controller_->Process(); |
+ probe_controller_->SetEstimatedBitrate(250); |
+ probe_controller_->RequestProbe(); |
+} |
- // When bandwidth estimate drops the controller should send a probe at the |
- // previous bitrate. |
- EXPECT_CALL(pacer_, CreateProbeCluster(500)).Times(1); |
+TEST_F(ProbeControllerTest, RequestProbeWhenAlrEndedRecently) { |
+ EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2); |
+ probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
+ kMaxBitrateBps); |
+ probe_controller_->SetEstimatedBitrate(500); |
+ testing::Mock::VerifyAndClearExpectations(&pacer_); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(0.85 * 500)).Times(1); |
+ EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) |
+ .WillRepeatedly(Return(rtc::Optional<int64_t>())); |
+ clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1); |
+ probe_controller_->Process(); |
+ probe_controller_->SetEstimatedBitrate(250); |
+ probe_controller_->SetAlrEndedTimeMs(clock_.TimeInMilliseconds()); |
+ clock_.AdvanceTimeMilliseconds(kAlrEndedTimeoutMs - 1); |
+ probe_controller_->RequestProbe(); |
+} |
+ |
+TEST_F(ProbeControllerTest, RequestProbeWhenAlrNotEndedRecently) { |
+ EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2); |
+ probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
+ kMaxBitrateBps); |
+ probe_controller_->SetEstimatedBitrate(500); |
+ testing::Mock::VerifyAndClearExpectations(&pacer_); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0); |
+ EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) |
+ .WillRepeatedly(Return(rtc::Optional<int64_t>())); |
+ clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1); |
+ probe_controller_->Process(); |
+ probe_controller_->SetEstimatedBitrate(250); |
+ probe_controller_->SetAlrEndedTimeMs(clock_.TimeInMilliseconds()); |
+ clock_.AdvanceTimeMilliseconds(kAlrEndedTimeoutMs + 1); |
+ probe_controller_->RequestProbe(); |
+} |
+ |
+TEST_F(ProbeControllerTest, RequestProbeWhenBweDropNotRecent) { |
+ EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2); |
+ probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
+ kMaxBitrateBps); |
+ probe_controller_->SetEstimatedBitrate(500); |
+ testing::Mock::VerifyAndClearExpectations(&pacer_); |
+ EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0); |
EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) |
.WillRepeatedly( |
Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds()))); |
clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1); |
probe_controller_->Process(); |
- probe_controller_->SetEstimatedBitrate(50); |
+ probe_controller_->SetEstimatedBitrate(250); |
+ clock_.AdvanceTimeMilliseconds(kBitrateDropTimeoutMs + 1); |
+ probe_controller_->RequestProbe(); |
} |
TEST_F(ProbeControllerTest, PeriodicProbing) { |