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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(1); | 169 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(1); |
170 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) | 170 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) |
171 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time))); | 171 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time))); |
172 clock_.AdvanceTimeMilliseconds(1000); | 172 clock_.AdvanceTimeMilliseconds(1000); |
173 probe_controller_->Process(); | 173 probe_controller_->Process(); |
174 probe_controller_->SetEstimatedBitrate(500); | 174 probe_controller_->SetEstimatedBitrate(500); |
175 testing::Mock::VerifyAndClearExpectations(&pacer_); | 175 testing::Mock::VerifyAndClearExpectations(&pacer_); |
176 } | 176 } |
177 | 177 |
| 178 TEST_F(ProbeControllerTest, PeriodicProbingAfterReset) { |
| 179 testing::StrictMock<MockPacedSender> local_pacer; |
| 180 probe_controller_.reset(new ProbeController(&local_pacer, &clock_)); |
| 181 int64_t alr_start_time = clock_.TimeInMilliseconds(); |
| 182 EXPECT_CALL(local_pacer, GetApplicationLimitedRegionStartTime()) |
| 183 .WillRepeatedly( |
| 184 Return(rtc::Optional<int64_t>(alr_start_time))); |
| 185 |
| 186 EXPECT_CALL(local_pacer, CreateProbeCluster(_)).Times(2); |
| 187 probe_controller_->EnablePeriodicAlrProbing(true); |
| 188 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 189 kMaxBitrateBps); |
| 190 probe_controller_->Reset(); |
| 191 |
| 192 clock_.AdvanceTimeMilliseconds(10000); |
| 193 probe_controller_->Process(); |
| 194 |
| 195 EXPECT_CALL(local_pacer, CreateProbeCluster(_)).Times(2); |
| 196 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 197 kMaxBitrateBps); |
| 198 |
| 199 // Make sure we use |kStartBitrateBps| as the estimated bitrate |
| 200 // until SetEstimatedBitrate is called with an updated estimate. |
| 201 clock_.AdvanceTimeMilliseconds(10000); |
| 202 EXPECT_CALL(local_pacer, CreateProbeCluster(kStartBitrateBps*2)); |
| 203 probe_controller_->Process(); |
| 204 } |
| 205 |
178 TEST_F(ProbeControllerTest, TestExponentialProbingOverflow) { | 206 TEST_F(ProbeControllerTest, TestExponentialProbingOverflow) { |
179 const int64_t kMbpsMultiplier = 1000000; | 207 const int64_t kMbpsMultiplier = 1000000; |
180 probe_controller_->SetBitrates(kMinBitrateBps, 10 * kMbpsMultiplier, | 208 probe_controller_->SetBitrates(kMinBitrateBps, 10 * kMbpsMultiplier, |
181 100 * kMbpsMultiplier); | 209 100 * kMbpsMultiplier); |
182 | 210 |
183 // Verify that probe bitrate is capped at the specified max bitrate | 211 // Verify that probe bitrate is capped at the specified max bitrate |
184 EXPECT_CALL(pacer_, CreateProbeCluster(100 * kMbpsMultiplier)); | 212 EXPECT_CALL(pacer_, CreateProbeCluster(100 * kMbpsMultiplier)); |
185 probe_controller_->SetEstimatedBitrate(60 * kMbpsMultiplier); | 213 probe_controller_->SetEstimatedBitrate(60 * kMbpsMultiplier); |
186 testing::Mock::VerifyAndClearExpectations(&pacer_); | 214 testing::Mock::VerifyAndClearExpectations(&pacer_); |
187 | 215 |
188 // Verify that repeated probes aren't sent. | 216 // Verify that repeated probes aren't sent. |
189 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0); | 217 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0); |
190 probe_controller_->SetEstimatedBitrate(100 * kMbpsMultiplier); | 218 probe_controller_->SetEstimatedBitrate(100 * kMbpsMultiplier); |
191 } | 219 } |
192 | 220 |
193 } // namespace test | 221 } // namespace test |
194 } // namespace webrtc | 222 } // namespace webrtc |
OLD | NEW |