| Index: webrtc/modules/congestion_controller/probing_calculator_unittest.cc
|
| diff --git a/webrtc/modules/congestion_controller/probing_calculator_unittest.cc b/webrtc/modules/congestion_controller/probing_calculator_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..01dc0c264b0a05fbcdc44dd5e606640b20fa0326
|
| --- /dev/null
|
| +++ b/webrtc/modules/congestion_controller/probing_calculator_unittest.cc
|
| @@ -0,0 +1,109 @@
|
| +/*
|
| + * 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 "webrtc/modules/congestion_controller/probing_calculator.h"
|
| +
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
|
| +
|
| +namespace webrtc {
|
| +
|
| +class MockAimdRateControl : public AimdRateControl {
|
| + public:
|
| + MOCK_METHOD2(SetEstimate, void(int bitrate_bps, int64_t now_ms));
|
| +};
|
| +
|
| +class TestProbingCalculator : public ::testing::Test {
|
| + public:
|
| + TestProbingCalculator() : probing_calculator_(&rate_controller_) {}
|
| +
|
| + void AddPacketFeedback(int probe_cluster_id,
|
| + size_t size,
|
| + int64_t send_time_ms,
|
| + int64_t arrival_time_ms) {
|
| + PacketInfo info(arrival_time_ms, send_time_ms, 0, size, probe_cluster_id);
|
| + probing_calculator_.PacketFeedback(info);
|
| + }
|
| +
|
| + protected:
|
| + testing::StrictMock<MockAimdRateControl> rate_controller_;
|
| + ProbingCalculator probing_calculator_;
|
| +};
|
| +
|
| +TEST_F(TestProbingCalculator, OneCluster) {
|
| + EXPECT_CALL(rate_controller_, SetEstimate(100000, 50));
|
| + AddPacketFeedback(0, 1000, 0, 10);
|
| + AddPacketFeedback(0, 1000, 10, 20);
|
| + AddPacketFeedback(0, 1000, 20, 30);
|
| + AddPacketFeedback(0, 1000, 40, 50);
|
| +}
|
| +
|
| +TEST_F(TestProbingCalculator, FastReceive) {
|
| + EXPECT_CALL(rate_controller_, SetEstimate(100000, 50));
|
| + AddPacketFeedback(0, 1000, 0, 15);
|
| + AddPacketFeedback(0, 1000, 10, 30);
|
| + AddPacketFeedback(0, 1000, 20, 40);
|
| + AddPacketFeedback(0, 1000, 40, 50);
|
| +}
|
| +
|
| +TEST_F(TestProbingCalculator, TooFastReceive) {
|
| + AddPacketFeedback(0, 1000, 0, 19);
|
| + AddPacketFeedback(0, 1000, 10, 30);
|
| + AddPacketFeedback(0, 1000, 20, 40);
|
| + AddPacketFeedback(0, 1000, 40, 50);
|
| +}
|
| +
|
| +TEST_F(TestProbingCalculator, SlowReceive) {
|
| + EXPECT_CALL(rate_controller_, SetEstimate(40000, 110));
|
| + AddPacketFeedback(0, 1000, 0, 10);
|
| + AddPacketFeedback(0, 1000, 10, 40);
|
| + AddPacketFeedback(0, 1000, 20, 70);
|
| + AddPacketFeedback(0, 1000, 40, 110);
|
| +}
|
| +
|
| +TEST_F(TestProbingCalculator, BurstReceive) {
|
| + AddPacketFeedback(0, 1000, 0, 50);
|
| + AddPacketFeedback(0, 1000, 10, 50);
|
| + AddPacketFeedback(0, 1000, 20, 50);
|
| + AddPacketFeedback(0, 1000, 40, 50);
|
| +}
|
| +
|
| +TEST_F(TestProbingCalculator, MultipleClusters) {
|
| + EXPECT_CALL(rate_controller_, SetEstimate(80000, 60));
|
| + EXPECT_CALL(rate_controller_, SetEstimate(100000, 60));
|
| + AddPacketFeedback(0, 1000, 0, 10);
|
| + AddPacketFeedback(0, 1000, 10, 20);
|
| + AddPacketFeedback(0, 1000, 20, 30);
|
| + AddPacketFeedback(0, 1000, 40, 60);
|
| + AddPacketFeedback(0, 1000, 50, 60);
|
| +
|
| + EXPECT_CALL(rate_controller_, SetEstimate(200000, 90));
|
| + AddPacketFeedback(1, 1000, 60, 70);
|
| + AddPacketFeedback(1, 1000, 65, 77);
|
| + AddPacketFeedback(1, 1000, 70, 84);
|
| + AddPacketFeedback(1, 1000, 75, 90);
|
| +}
|
| +
|
| +TEST_F(TestProbingCalculator, OldProbe) {
|
| + AddPacketFeedback(0, 1000, 0, 10);
|
| + AddPacketFeedback(0, 1000, 10, 20);
|
| + AddPacketFeedback(0, 1000, 20, 30);
|
| +
|
| + EXPECT_CALL(rate_controller_, SetEstimate(200000, 90));
|
| + AddPacketFeedback(1, 1000, 60, 70);
|
| + AddPacketFeedback(1, 1000, 65, 77);
|
| + AddPacketFeedback(1, 1000, 70, 84);
|
| + AddPacketFeedback(1, 1000, 75, 90);
|
| +
|
| + AddPacketFeedback(0, 1000, 40, 60);
|
| +}
|
| +
|
| +} // namespace webrtc
|
|
|