Chromium Code Reviews| Index: webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc |
| diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc b/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bf20ef2610021310b31129e42fbc1c78f7759ed1 |
| --- /dev/null |
| +++ b/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc |
| @@ -0,0 +1,84 @@ |
| +/* |
| + * 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/audio_coding/audio_network_adaptor/dtx_controller.h" |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace webrtc { |
| + |
| +namespace { |
| + |
| +constexpr int kDtxEnablingBandwidthBps = 55000; |
| +constexpr int kDtxDisablingBandwidthBps = 65000; |
| + |
| +void CheckDtxControllersDecision(DtxController* controller, |
| + const Controller::NetworkMetrics& metrics, |
| + bool expected_dtx_enabled) { |
| + AudioNetworkAdaptor::EncoderRuntimeConfig config; |
| + controller->MakeDecision(metrics, &config); |
| + EXPECT_EQ(rtc::Optional<bool>(expected_dtx_enabled), config.enable_dtx); |
| +} |
| + |
| +} // namespace |
| + |
| +TEST(DtxControllerTest, OutputInitValueWhenUplinkBandwidthUnknown) { |
| + constexpr bool kInitialDtxEnabled = true; |
| + DtxController controller(DtxController::Config( |
| + kInitialDtxEnabled, kDtxEnablingBandwidthBps, kDtxDisablingBandwidthBps)); |
| + Controller::NetworkMetrics metrics; |
| + CheckDtxControllersDecision(&controller, metrics, kInitialDtxEnabled); |
| +} |
| + |
| +TEST(DtxControllerTest, TurnOnDtxForLowUplinkBandwidth) { |
| + // Set initial DTX off. |
| + DtxController controller(DtxController::Config( |
| + false, kDtxEnablingBandwidthBps, kDtxDisablingBandwidthBps)); |
| + Controller::NetworkMetrics metrics; |
| + |
| + metrics.uplink_bandwidth_bps = rtc::Optional<int>(kDtxEnablingBandwidthBps); |
| + CheckDtxControllersDecision(&controller, metrics, true); |
| +} |
| + |
| +TEST(DtxControllerTest, TurnOffDtxForHighUplinkBandwidth) { |
| + // Set initial DTX on. |
| + DtxController controller(DtxController::Config(true, kDtxEnablingBandwidthBps, |
| + kDtxDisablingBandwidthBps)); |
| + Controller::NetworkMetrics metrics; |
| + |
| + metrics.uplink_bandwidth_bps = rtc::Optional<int>(kDtxDisablingBandwidthBps); |
| + CheckDtxControllersDecision(&controller, metrics, false); |
| +} |
| + |
| +TEST(DtxControllerTest, MaintainDtxOffForMediumUplinkBandwidth) { |
| + // Set initial DTX off. |
| + DtxController controller(DtxController::Config( |
| + false, kDtxEnablingBandwidthBps, kDtxDisablingBandwidthBps)); |
| + Controller::NetworkMetrics metrics; |
| + |
| + constexpr int kBandwidth = |
| + (kDtxEnablingBandwidthBps + kDtxDisablingBandwidthBps) / 2; |
| + metrics.uplink_bandwidth_bps = rtc::Optional<int>(kBandwidth); |
| + CheckDtxControllersDecision(&controller, metrics, false); |
| +} |
| + |
| +TEST(DtxControllerTest, MaintainDtxOnForMediumUplinkBandwidth) { |
| + // Set initial DTX on. |
| + DtxController controller(DtxController::Config(true, kDtxEnablingBandwidthBps, |
| + kDtxDisablingBandwidthBps)); |
| + Controller::NetworkMetrics metrics; |
| + |
| + constexpr int kBandwidth = |
| + (kDtxEnablingBandwidthBps + kDtxDisablingBandwidthBps) / 2; |
| + metrics.uplink_bandwidth_bps = rtc::Optional<int>(kBandwidth); |
| + CheckDtxControllersDecision(&controller, metrics, true); |
| +} |
| + |
|
hlundin-webrtc
2016/09/09 11:11:37
None of the tests exercise the DtxController with
|
| +} // namespace webrtc |