| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 NiceMock<MockPacedSender> pacer_; | 44 NiceMock<MockPacedSender> pacer_; |
| 45 std::unique_ptr<ProbeController> probe_controller_; | 45 std::unique_ptr<ProbeController> probe_controller_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 TEST_F(ProbeControllerTest, InitiatesProbingAtStart) { | 48 TEST_F(ProbeControllerTest, InitiatesProbingAtStart) { |
| 49 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); | 49 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); |
| 50 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 50 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 51 kMaxBitrateBps); | 51 kMaxBitrateBps); |
| 52 } | 52 } |
| 53 | 53 |
| 54 TEST_F(ProbeControllerTest, ProbeOnlyWhenNetworkIsUp) { |
| 55 probe_controller_->OnNetworkStateChanged(kNetworkDown); |
| 56 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(0); |
| 57 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 58 kMaxBitrateBps); |
| 59 |
| 60 testing::Mock::VerifyAndClearExpectations(&pacer_); |
| 61 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); |
| 62 probe_controller_->OnNetworkStateChanged(kNetworkUp); |
| 63 } |
| 64 |
| 54 TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { | 65 TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { |
| 55 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); | 66 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); |
| 56 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 67 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| 57 kMaxBitrateBps); | 68 kMaxBitrateBps); |
| 58 // Long enough to time out exponential probing. | 69 // Long enough to time out exponential probing. |
| 59 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); | 70 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); |
| 60 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); | 71 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); |
| 61 | 72 |
| 62 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); | 73 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); |
| 63 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 74 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 79 kMaxBitrateBps); | 90 kMaxBitrateBps); |
| 80 | 91 |
| 81 // Advance far enough to cause a time out in waiting for probing result. | 92 // Advance far enough to cause a time out in waiting for probing result. |
| 82 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); | 93 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); |
| 83 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); | 94 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); |
| 84 probe_controller_->SetEstimatedBitrate(1800); | 95 probe_controller_->SetEstimatedBitrate(1800); |
| 85 } | 96 } |
| 86 | 97 |
| 87 } // namespace test | 98 } // namespace test |
| 88 } // namespace webrtc | 99 } // namespace webrtc |
| OLD | NEW |