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 | |
65 TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { | 54 TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { |
66 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); | 55 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); |
67 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 56 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
68 kMaxBitrateBps); | 57 kMaxBitrateBps); |
69 // Long enough to time out exponential probing. | 58 // Long enough to time out exponential probing. |
70 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); | 59 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); |
71 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); | 60 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); |
72 | 61 |
73 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); | 62 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); |
74 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 63 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
(...skipping 15 matching lines...) Expand all Loading... |
90 kMaxBitrateBps); | 79 kMaxBitrateBps); |
91 | 80 |
92 // Advance far enough to cause a time out in waiting for probing result. | 81 // Advance far enough to cause a time out in waiting for probing result. |
93 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); | 82 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); |
94 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); | 83 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); |
95 probe_controller_->SetEstimatedBitrate(1800); | 84 probe_controller_->SetEstimatedBitrate(1800); |
96 } | 85 } |
97 | 86 |
98 } // namespace test | 87 } // namespace test |
99 } // namespace webrtc | 88 } // namespace webrtc |
OLD | NEW |