Chromium Code Reviews

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

Issue 2574533002: Fix integer overflow in ProbeController. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « webrtc/modules/congestion_controller/probe_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 65 matching lines...)
76 76
77 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); 77 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _));
78 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 78 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
79 kMaxBitrateBps + 100); 79 kMaxBitrateBps + 100);
80 } 80 }
81 81
82 TEST_F(ProbeControllerTest, TestExponentialProbing) { 82 TEST_F(ProbeControllerTest, TestExponentialProbing) {
83 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 83 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
84 kMaxBitrateBps); 84 kMaxBitrateBps);
85 85
86 // Repeated probe should only be sent when estimated bitrate climbs above 4 * 86 // Repeated probe should only be sent when estimated bitrate climbs above
87 // kStartBitrateBps = 1200. 87 // 0.7 * 6 * kStartBitrateBps = 1260.
88 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(0); 88 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(0);
89 probe_controller_->SetEstimatedBitrate(1000); 89 probe_controller_->SetEstimatedBitrate(1000);
90 testing::Mock::VerifyAndClearExpectations(&pacer_); 90 testing::Mock::VerifyAndClearExpectations(&pacer_);
91 91
92 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)); 92 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _));
93 probe_controller_->SetEstimatedBitrate(1800); 93 probe_controller_->SetEstimatedBitrate(1800);
94 } 94 }
95 95
96 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { 96 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) {
97 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 97 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
(...skipping 55 matching lines...)
153 153
154 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(1); 154 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(1);
155 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) 155 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
156 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time))); 156 .WillRepeatedly(Return(rtc::Optional<int64_t>(start_time)));
157 clock_.AdvanceTimeMilliseconds(1000); 157 clock_.AdvanceTimeMilliseconds(1000);
158 probe_controller_->Process(); 158 probe_controller_->Process();
159 probe_controller_->SetEstimatedBitrate(500); 159 probe_controller_->SetEstimatedBitrate(500);
160 testing::Mock::VerifyAndClearExpectations(&pacer_); 160 testing::Mock::VerifyAndClearExpectations(&pacer_);
161 } 161 }
162 162
163 TEST_F(ProbeControllerTest, TestExponentialProbingOverflow) {
164 const int64_t kMbpsMultiplier = 1000000;
165 probe_controller_->SetBitrates(kMinBitrateBps, 10 * kMbpsMultiplier,
166 100 * kMbpsMultiplier);
167
168 // Verify that probe bitrate is capped at the specified max bitrate
169 EXPECT_CALL(pacer_, CreateProbeCluster(100 * kMbpsMultiplier, _));
170 probe_controller_->SetEstimatedBitrate(60 * kMbpsMultiplier);
171 testing::Mock::VerifyAndClearExpectations(&pacer_);
172
173 // Verify that repeated probes aren't sent.
174 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(0);
175 probe_controller_->SetEstimatedBitrate(100 * kMbpsMultiplier);
176 }
177
163 } // namespace test 178 } // namespace test
164 } // namespace webrtc 179 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/probe_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine