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> |
11 | 11 |
12 #include "webrtc/base/logging.h" | 12 #include "webrtc/base/logging.h" |
13 #include "webrtc/modules/congestion_controller/probe_controller.h" | 13 #include "webrtc/modules/congestion_controller/probe_controller.h" |
14 #include "webrtc/modules/pacing/mock/mock_paced_sender.h" | 14 #include "webrtc/modules/pacing/mock/mock_paced_sender.h" |
15 #include "webrtc/system_wrappers/include/clock.h" | 15 #include "webrtc/system_wrappers/include/clock.h" |
16 #include "webrtc/test/gmock.h" | 16 #include "webrtc/test/gmock.h" |
17 #include "webrtc/test/gtest.h" | 17 #include "webrtc/test/gtest.h" |
18 | 18 |
19 using testing::_; | 19 using testing::_; |
20 using testing::AtLeast; | 20 using testing::AtLeast; |
21 using testing::NiceMock; | 21 using testing::NiceMock; |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 namespace test { | 24 namespace test { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 constexpr int kMinBitrateBps = 100; | 28 constexpr int kMinBitrateBps = 100; |
29 constexpr int kStartBitrateBps = 300; | 29 constexpr int kStartBitrateBps = 300; |
30 constexpr int kMaxBitrateBps = 1000; | 30 constexpr int kMaxBitrateBps = 10000; |
31 | 31 |
32 constexpr int kExponentialProbingTimeoutMs = 5000; | 32 constexpr int kExponentialProbingTimeoutMs = 5000; |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 class ProbeControllerTest : public ::testing::Test { | 36 class ProbeControllerTest : public ::testing::Test { |
37 protected: | 37 protected: |
38 ProbeControllerTest() : clock_(0) { | 38 ProbeControllerTest() : clock_(0) { |
39 probe_controller_.reset(new ProbeController(&pacer_, &clock_)); | 39 probe_controller_.reset(new ProbeController(&pacer_, &clock_)); |
40 } | 40 } |
(...skipping 19 matching lines...) Expand all Loading... |
60 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); | 60 probe_controller_->SetEstimatedBitrate(kStartBitrateBps); |
61 | 61 |
62 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); | 62 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); |
63 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 63 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
64 kMaxBitrateBps + 100); | 64 kMaxBitrateBps + 100); |
65 } | 65 } |
66 | 66 |
67 TEST_F(ProbeControllerTest, TestExponentialProbing) { | 67 TEST_F(ProbeControllerTest, TestExponentialProbing) { |
68 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 68 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
69 kMaxBitrateBps); | 69 kMaxBitrateBps); |
| 70 |
| 71 |
| 72 |
70 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)); | 73 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)); |
71 probe_controller_->SetEstimatedBitrate(1800); | 74 probe_controller_->SetEstimatedBitrate(1800); |
72 } | 75 } |
73 | 76 |
74 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { | 77 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { |
75 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, | 78 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, |
76 kMaxBitrateBps); | 79 kMaxBitrateBps); |
77 | 80 |
78 // 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. |
79 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); | 82 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); |
80 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); | 83 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); |
81 probe_controller_->SetEstimatedBitrate(1800); | 84 probe_controller_->SetEstimatedBitrate(1800); |
82 } | 85 } |
83 | 86 |
84 } // namespace test | 87 } // namespace test |
85 } // namespace webrtc | 88 } // namespace webrtc |
OLD | NEW |