Chromium Code Reviews| Index: webrtc/modules/congestion_controller/probing_interval_estimator_unittest.cc |
| diff --git a/webrtc/modules/congestion_controller/probing_interval_estimator_unittest.cc b/webrtc/modules/congestion_controller/probing_interval_estimator_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1caa32b00ff52c6a51fe3ff46e836b706cb5a389 |
| --- /dev/null |
| +++ b/webrtc/modules/congestion_controller/probing_interval_estimator_unittest.cc |
| @@ -0,0 +1,81 @@ |
| +/* |
| + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include <memory> |
| +#include <utility> |
| + |
| +#include "webrtc/modules/congestion_controller/probing_interval_estimator.h" |
| +#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_aimd_rate_control.h" |
| +#include "webrtc/test/gmock.h" |
| +#include "webrtc/test/gtest.h" |
| + |
| +using ::testing::Return; |
| + |
| +namespace webrtc { |
| + |
| +namespace { |
| + |
| +constexpr int kMinIntervalMs = 2000; |
| +constexpr int kMaxIntervalMs = 50000; |
| + |
| +struct ProbingIntervalEstimatorStates { |
| + std::unique_ptr<ProbingIntervalEstimator> probing_interval_estimator; |
| + std::unique_ptr<MockAimdRateControl> aimd_rate_control; |
| +}; |
| + |
| +ProbingIntervalEstimatorStates CreateProbingIntervalEstimatorStates() { |
| + ProbingIntervalEstimatorStates states; |
| + states.aimd_rate_control.reset(new MockAimdRateControl()); |
| + states.probing_interval_estimator.reset(new ProbingIntervalEstimator( |
| + kMinIntervalMs, kMaxIntervalMs, states.aimd_rate_control.get())); |
| + return states; |
| +} |
| +} // namespace |
| + |
| +TEST(ProbingIntervalEstimatorTest, NoIntervalTillWeHaveDrop) { |
|
minyue-webrtc
2016/11/14 16:50:42
Till -> Untill
and good to add a case that when G
michaelt
2016/11/15 09:41:59
Done.
|
| + auto states = CreateProbingIntervalEstimatorStates(); |
| + EXPECT_CALL(*states.aimd_rate_control, GetLastDecrease()) |
| + .WillOnce(Return(rtc::Optional<int>())); |
| + EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps()) |
| + .WillOnce(Return(4000)); |
| + EXPECT_EQ(rtc::Optional<int>(), |
| + states.probing_interval_estimator->GetIntervalMs()); |
| +} |
| + |
| +TEST(ProbingIntervalEstimatorTest, CalcInterval) { |
| + auto states = CreateProbingIntervalEstimatorStates(); |
| + EXPECT_CALL(*states.aimd_rate_control, GetLastDecrease()) |
| + .WillOnce(Return(rtc::Optional<int>(20000))); |
| + EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps()) |
| + .WillOnce(Return(5000)); |
| + EXPECT_EQ(rtc::Optional<int>(4000), |
| + states.probing_interval_estimator->GetIntervalMs()); |
| +} |
| + |
| +TEST(ProbingIntervalEstimatorTest, IntervalNotExceedMin) { |
|
minyue-webrtc
2016/11/14 16:50:42
Not->DoesNot
michaelt
2016/11/15 09:41:59
Done.
|
| + auto states = CreateProbingIntervalEstimatorStates(); |
| + EXPECT_CALL(*states.aimd_rate_control, GetLastDecrease()) |
| + .WillOnce(Return(rtc::Optional<int>(1000))); |
| + EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps()) |
| + .WillOnce(Return(5000)); |
| + EXPECT_EQ(rtc::Optional<int>(kMinIntervalMs), |
| + states.probing_interval_estimator->GetIntervalMs()); |
| +} |
| + |
| +TEST(ProbingIntervalEstimatorTest, IntervalNotExceedMax) { |
|
minyue-webrtc
2016/11/14 16:50:42
Not->DoesNot
michaelt
2016/11/15 09:41:59
Done.
|
| + auto states = CreateProbingIntervalEstimatorStates(); |
| + EXPECT_CALL(*states.aimd_rate_control, GetLastDecrease()) |
| + .WillOnce(Return(rtc::Optional<int>(50000))); |
| + EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps()) |
| + .WillOnce(Return(100)); |
| + EXPECT_EQ(rtc::Optional<int>(kMaxIntervalMs), |
| + states.probing_interval_estimator->GetIntervalMs()); |
| +} |
| +} // namespace webrtc |