| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 probe_controller_->OnNetworkStateChanged(kNetworkUp); | 65 probe_controller_->OnNetworkStateChanged(kNetworkUp); |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { | 68 TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { |
| 69 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); | 69 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); |
| 70 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 70 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 71 kMaxBitrateBps); | 71 kMaxBitrateBps); |
| 72 // Long enough to time out exponential probing. | 72 // Long enough to time out exponential probing. |
| 73 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); | 73 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); |
| 74 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); | 74 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); |
| 75 probe_controller_->Process(); |
| 75 | 76 |
| 76 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); | 77 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); |
| 77 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 78 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 78 kMaxBitrateBps + 100); | 79 kMaxBitrateBps + 100); |
| 79 } | 80 } |
| 80 | 81 |
| 81 TEST_F(ProbeControllerTest, TestExponentialProbing) { | 82 TEST_F(ProbeControllerTest, TestExponentialProbing) { |
| 82 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 83 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 83 kMaxBitrateBps); | 84 kMaxBitrateBps); |
| 84 | 85 |
| 86 // Repeated probe should only be sent when estimated bitrate climbs above 4 * |
| 87 // kStartBitrateBps = 1200. |
| 88 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(0); |
| 89 probe_controller_->SetEstimatedBitrate(1000); |
| 90 testing::Mock::VerifyAndClearExpectations(&pacer_); |
| 91 |
| 85 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)); | 92 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)); |
| 86 probe_controller_->SetEstimatedBitrate(1800); | 93 probe_controller_->SetEstimatedBitrate(1800); |
| 87 } | 94 } |
| 88 | 95 |
| 89 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { | 96 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { |
| 90 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 97 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 91 kMaxBitrateBps); | 98 kMaxBitrateBps); |
| 92 | 99 |
| 93 // Advance far enough to cause a time out in waiting for probing result. | 100 // Advance far enough to cause a time out in waiting for probing result. |
| 94 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); | 101 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); |
| 95 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); | 102 probe_controller_->Process(); |
| 103 |
| 104 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(0); |
| 96 probe_controller_->SetEstimatedBitrate(1800); | 105 probe_controller_->SetEstimatedBitrate(1800); |
| 97 } | 106 } |
| 98 | 107 |
| 99 TEST_F(ProbeControllerTest, ProbeAfterEstimateDropInAlr) { | 108 TEST_F(ProbeControllerTest, ProbeAfterEstimateDropInAlr) { |
| 100 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(2); | 109 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(2); |
| 101 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 110 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 102 kMaxBitrateBps); | 111 kMaxBitrateBps); |
| 103 probe_controller_->SetEstimatedBitrate(500); | 112 probe_controller_->SetEstimatedBitrate(500); |
| 104 testing::Mock::VerifyAndClearExpectations(&pacer_); | 113 testing::Mock::VerifyAndClearExpectations(&pacer_); |
| 105 | 114 |
| 106 // When bandwidth estimate drops the controller should send a probe at the | 115 // When bandwidth estimate drops the controller should send a probe at the |
| 107 // previous bitrate. | 116 // previous bitrate. |
| 108 EXPECT_CALL(pacer_, CreateProbeCluster(500, _)).Times(1); | 117 EXPECT_CALL(pacer_, CreateProbeCluster(500, _)).Times(1); |
| 109 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) | 118 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) |
| 110 .WillRepeatedly( | 119 .WillRepeatedly( |
| 111 Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds()))); | 120 Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds()))); |
| 112 clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1); | 121 clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1); |
| 122 probe_controller_->Process(); |
| 113 probe_controller_->SetEstimatedBitrate(50); | 123 probe_controller_->SetEstimatedBitrate(50); |
| 114 } | 124 } |
| 115 | 125 |
| 116 TEST_F(ProbeControllerTest, PeriodicProbing) { | 126 TEST_F(ProbeControllerTest, PeriodicProbing) { |
| 117 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(2); | 127 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(2); |
| 118 probe_controller_->EnablePeriodicAlrProbing(true); | 128 probe_controller_->EnablePeriodicAlrProbing(true); |
| 119 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 129 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 120 kMaxBitrateBps); | 130 kMaxBitrateBps); |
| 121 probe_controller_->SetEstimatedBitrate(500); | 131 probe_controller_->SetEstimatedBitrate(500); |
| 122 testing::Mock::VerifyAndClearExpectations(&pacer_); | 132 testing::Mock::VerifyAndClearExpectations(&pacer_); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 145 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) | 155 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) |
| 146 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time))); | 156 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time))); |
| 147 clock_.AdvanceTimeMilliseconds(1000); | 157 clock_.AdvanceTimeMilliseconds(1000); |
| 148 probe_controller_->Process(); | 158 probe_controller_->Process(); |
| 149 probe_controller_->SetEstimatedBitrate(500); | 159 probe_controller_->SetEstimatedBitrate(500); |
| 150 testing::Mock::VerifyAndClearExpectations(&pacer_); | 160 testing::Mock::VerifyAndClearExpectations(&pacer_); |
| 151 } | 161 } |
| 152 | 162 |
| 153 } // namespace test | 163 } // namespace test |
| 154 } // namespace webrtc | 164 } // namespace webrtc |
| OLD | NEW |