mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 06:10:40 +01:00

Bug: None Change-Id: I3c6da916ce5f4a32ff47bfb0894b00f11fbf7823 Reviewed-on: https://webrtc-review.googlesource.com/86605 Commit-Queue: Ying Wang <yinwa@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24008}
65 lines
2.2 KiB
C++
65 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2018 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 "modules/congestion_controller/congestion_window_pushback_controller.h"
|
|
#include "test/gmock.h"
|
|
#include "test/gtest.h"
|
|
|
|
using testing::_;
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
|
|
class CongestionWindowPushbackControllerTest : public ::testing::Test {
|
|
protected:
|
|
CongestionWindowPushbackController cwnd_controller_;
|
|
};
|
|
|
|
TEST_F(CongestionWindowPushbackControllerTest, FullCongestionWindow) {
|
|
cwnd_controller_.UpdateOutstandingData(100000);
|
|
cwnd_controller_.UpdateMaxOutstandingData(50000);
|
|
|
|
uint32_t bitrate_bps = 80000;
|
|
bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps);
|
|
EXPECT_EQ(72000u, bitrate_bps);
|
|
|
|
cwnd_controller_.UpdateMaxOutstandingData(50000);
|
|
bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps);
|
|
EXPECT_EQ(static_cast<uint32_t>(72000 * 0.9 * 0.9), bitrate_bps);
|
|
}
|
|
|
|
TEST_F(CongestionWindowPushbackControllerTest, NormalCongestionWindow) {
|
|
cwnd_controller_.UpdateOutstandingData(100000);
|
|
cwnd_controller_.SetDataWindow(DataSize::bytes(200000));
|
|
|
|
uint32_t bitrate_bps = 80000;
|
|
bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps);
|
|
EXPECT_EQ(80000u, bitrate_bps);
|
|
|
|
cwnd_controller_.UpdateMaxOutstandingData(20000);
|
|
bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps);
|
|
EXPECT_EQ(80000u, bitrate_bps);
|
|
}
|
|
|
|
TEST_F(CongestionWindowPushbackControllerTest, LowBitrate) {
|
|
cwnd_controller_.UpdateOutstandingData(100000);
|
|
cwnd_controller_.SetDataWindow(DataSize::bytes(50000));
|
|
|
|
uint32_t bitrate_bps = 35000;
|
|
bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps);
|
|
EXPECT_EQ(static_cast<uint32_t>(35000 * 0.9), bitrate_bps);
|
|
|
|
cwnd_controller_.UpdateMaxOutstandingData(20000);
|
|
bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps);
|
|
EXPECT_EQ(30000u, bitrate_bps);
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|