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

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

Issue 2789233005: Move BWE period calculation from ProbingIntervalEstimator to AimdRateControl. (Closed)
Patch Set: Nits Created 3 years, 8 months 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <memory>
12 #include <utility>
13
14 #include "webrtc/modules/congestion_controller/probing_interval_estimator.h"
15 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_aimd_rate_co ntrol.h"
16 #include "webrtc/test/gmock.h"
17 #include "webrtc/test/gtest.h"
18
19 using ::testing::Return;
20
21 namespace webrtc {
22
23 namespace {
24
25 constexpr int kMinIntervalMs = 2000;
26 constexpr int kMaxIntervalMs = 50000;
27 constexpr int kDefaultIntervalMs = 3000;
28
29 struct ProbingIntervalEstimatorStates {
30 std::unique_ptr<ProbingIntervalEstimator> probing_interval_estimator;
31 std::unique_ptr<MockAimdRateControl> aimd_rate_control;
32 };
33
34 ProbingIntervalEstimatorStates CreateProbingIntervalEstimatorStates() {
35 ProbingIntervalEstimatorStates states;
36 states.aimd_rate_control.reset(new MockAimdRateControl());
37 states.probing_interval_estimator.reset(new ProbingIntervalEstimator(
38 kMinIntervalMs, kMaxIntervalMs, kDefaultIntervalMs,
39 states.aimd_rate_control.get()));
40 return states;
41 }
42 } // namespace
43
44 TEST(ProbingIntervalEstimatorTest, DefaultIntervalUntillWeHaveDrop) {
45 auto states = CreateProbingIntervalEstimatorStates();
46
47 EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
48 .WillOnce(Return(rtc::Optional<int>()))
49 .WillOnce(Return(rtc::Optional<int>(5000)));
50 EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
51 .WillOnce(Return(4000))
52 .WillOnce(Return(4000));
53
54 EXPECT_EQ(kDefaultIntervalMs,
55 states.probing_interval_estimator->GetIntervalMs());
56 EXPECT_NE(kDefaultIntervalMs,
57 states.probing_interval_estimator->GetIntervalMs());
58 }
59
60 TEST(ProbingIntervalEstimatorTest, CalcInterval) {
61 auto states = CreateProbingIntervalEstimatorStates();
62 EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
63 .WillOnce(Return(rtc::Optional<int>(20000)));
64 EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
65 .WillOnce(Return(5000));
66 EXPECT_EQ(4000, states.probing_interval_estimator->GetIntervalMs());
67 }
68
69 TEST(ProbingIntervalEstimatorTest, IntervalDoesNotExceedMin) {
70 auto states = CreateProbingIntervalEstimatorStates();
71 EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
72 .WillOnce(Return(rtc::Optional<int>(1000)));
73 EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
74 .WillOnce(Return(5000));
75 EXPECT_EQ(kMinIntervalMs, states.probing_interval_estimator->GetIntervalMs());
76 }
77
78 TEST(ProbingIntervalEstimatorTest, IntervalDoesNotExceedMax) {
79 auto states = CreateProbingIntervalEstimatorStates();
80 EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
81 .WillOnce(Return(rtc::Optional<int>(50000)));
82 EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
83 .WillOnce(Return(100));
84 EXPECT_EQ(kMaxIntervalMs, states.probing_interval_estimator->GetIntervalMs());
85 }
86 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698