Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: webrtc/modules/congestion_controller/probe_controller_unittest.cc

Issue 2504023002: Implement periodic bandwidth probing in application-limited region. (Closed)
Patch Set: address feedback Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 using testing::Return;
22 23
23 namespace webrtc { 24 namespace webrtc {
24 namespace test { 25 namespace test {
25 26
26 namespace { 27 namespace {
27 28
28 constexpr int kMinBitrateBps = 100; 29 constexpr int kMinBitrateBps = 100;
29 constexpr int kStartBitrateBps = 300; 30 constexpr int kStartBitrateBps = 300;
30 constexpr int kMaxBitrateBps = 10000; 31 constexpr int kMaxBitrateBps = 10000;
31 32
32 constexpr int kExponentialProbingTimeoutMs = 5000; 33 constexpr int kExponentialProbingTimeoutMs = 5000;
33 34
35 constexpr int kAlrProbeInterval = 5000;
36
34 } // namespace 37 } // namespace
35 38
36 class ProbeControllerTest : public ::testing::Test { 39 class ProbeControllerTest : public ::testing::Test {
37 protected: 40 protected:
38 ProbeControllerTest() : clock_(0) { 41 ProbeControllerTest() : clock_(100000000L) {
39 probe_controller_.reset(new ProbeController(&pacer_, &clock_)); 42 probe_controller_.reset(new ProbeController(&pacer_, &clock_));
40 } 43 }
41 ~ProbeControllerTest() override {} 44 ~ProbeControllerTest() override {}
42 45
43 SimulatedClock clock_; 46 SimulatedClock clock_;
44 NiceMock<MockPacedSender> pacer_; 47 NiceMock<MockPacedSender> pacer_;
45 std::unique_ptr<ProbeController> probe_controller_; 48 std::unique_ptr<ProbeController> probe_controller_;
46 }; 49 };
47 50
48 TEST_F(ProbeControllerTest, InitiatesProbingAtStart) { 51 TEST_F(ProbeControllerTest, InitiatesProbingAtStart) {
(...skipping 23 matching lines...) Expand all
72 75
73 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); 76 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _));
74 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 77 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
75 kMaxBitrateBps + 100); 78 kMaxBitrateBps + 100);
76 } 79 }
77 80
78 TEST_F(ProbeControllerTest, TestExponentialProbing) { 81 TEST_F(ProbeControllerTest, TestExponentialProbing) {
79 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 82 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
80 kMaxBitrateBps); 83 kMaxBitrateBps);
81 84
82
83
84 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)); 85 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _));
85 probe_controller_->SetEstimatedBitrate(1800); 86 probe_controller_->SetEstimatedBitrate(1800);
86 } 87 }
87 88
88 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { 89 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) {
89 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 90 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
90 kMaxBitrateBps); 91 kMaxBitrateBps);
91 92
92 // Advance far enough to cause a time out in waiting for probing result. 93 // Advance far enough to cause a time out in waiting for probing result.
93 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); 94 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs);
94 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); 95 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0);
95 probe_controller_->SetEstimatedBitrate(1800); 96 probe_controller_->SetEstimatedBitrate(1800);
96 } 97 }
97 98
99 TEST_F(ProbeControllerTest, ProbeAfterEstimateDropInAlr) {
100 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(2);
101 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
102 kMaxBitrateBps);
103 probe_controller_->SetEstimatedBitrate(500);
104 testing::Mock::VerifyAndClearExpectations(&pacer_);
105
106 // When bandwidth estimate drops the controller should send a probe at the
107 // previous bitrate.
108 EXPECT_CALL(pacer_, CreateProbeCluster(500, _)).Times(1);
109 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
110 .WillRepeatedly(
111 Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds())));
112 clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
113 probe_controller_->SetEstimatedBitrate(50);
114 }
115
116 TEST_F(ProbeControllerTest, PeriodicProbing) {
117 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(2);
118 probe_controller_->EnablePeriodicAlrProbing(true);
119 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
120 kMaxBitrateBps);
121 probe_controller_->SetEstimatedBitrate(500);
122 testing::Mock::VerifyAndClearExpectations(&pacer_);
123
124 int64_t start_time = clock_.TimeInMilliseconds();
125
126 // Expect the controller to send a new probe after 5s has passed.
127 EXPECT_CALL(pacer_, CreateProbeCluster(1000, _)).Times(1);
128 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
129 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time)));
130 clock_.AdvanceTimeMilliseconds(5000);
131 probe_controller_->Process();
132 probe_controller_->SetEstimatedBitrate(500);
133 testing::Mock::VerifyAndClearExpectations(&pacer_);
134
135 // The following probe should be sent at 10s into ALR.
136 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(0);
137 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
138 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time)));
139 clock_.AdvanceTimeMilliseconds(4000);
140 probe_controller_->Process();
141 probe_controller_->SetEstimatedBitrate(500);
142 testing::Mock::VerifyAndClearExpectations(&pacer_);
143
144 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(1);
145 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
146 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time)));
147 clock_.AdvanceTimeMilliseconds(1000);
148 probe_controller_->Process();
149 probe_controller_->SetEstimatedBitrate(500);
150 testing::Mock::VerifyAndClearExpectations(&pacer_);
151 }
152
98 } // namespace test 153 } // namespace test
99 } // namespace webrtc 154 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/probe_controller.cc ('k') | webrtc/modules/pacing/alr_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698