webrtc/modules/audio_processing/echo_cancellation_impl_unittest.cc
Jonas Olsson a4d873786f Format almost everything.
This CL was generated by running

git ls-files | grep -P "(\.h|\.cc)$" | grep -v 'sdk/' | grep -v 'rtc_base/ssl_' | \
grep -v 'fake_rtc_certificate_generator.h' | grep -v 'modules/audio_device/win/' | \
grep -v 'system_wrappers/source/clock.cc' | grep -v 'rtc_base/trace_event.h' | \
grep -v 'modules/audio_coding/codecs/ilbc/' | grep -v 'screen_capturer_mac.h' | \
grep -v 'spl_inl_mips.h' | grep -v 'data_size_unittest.cc' | grep -v 'timestamp_unittest.cc' \
| xargs clang-format -i ; git cl format

Most of these changes are clang-format grouping and reordering includes
differently.

Bug: webrtc:9340
Change-Id: Ic83ddbc169bfacd21883e381b5181c3dd4fe8a63
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144051
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28505}
2019-07-08 13:45:15 +00:00

111 lines
4.1 KiB
C++

/*
* Copyright (c) 2013 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/audio_processing/echo_cancellation_impl.h"
#include <memory>
#include "modules/audio_processing/aec/aec_core.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "rtc_base/critical_section.h"
#include "test/gtest.h"
namespace webrtc {
TEST(EchoCancellationInternalTest, ExtendedFilter) {
EchoCancellationImpl echo_canceller;
echo_canceller.Initialize(AudioProcessing::kSampleRate32kHz, 2, 2, 2);
AecCore* aec_core = echo_canceller.aec_core();
ASSERT_TRUE(aec_core != NULL);
// Disabled by default.
EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core));
Config config;
echo_canceller.SetExtraOptions(true, false, false);
EXPECT_EQ(1, WebRtcAec_extended_filter_enabled(aec_core));
// Retains setting after initialization.
echo_canceller.Initialize(AudioProcessing::kSampleRate16kHz, 2, 2, 2);
EXPECT_EQ(1, WebRtcAec_extended_filter_enabled(aec_core));
echo_canceller.SetExtraOptions(false, false, false);
EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core));
// Retains setting after initialization.
echo_canceller.Initialize(AudioProcessing::kSampleRate16kHz, 1, 1, 1);
EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core));
}
TEST(EchoCancellationInternalTest, DelayAgnostic) {
EchoCancellationImpl echo_canceller;
echo_canceller.Initialize(AudioProcessing::kSampleRate32kHz, 1, 1, 1);
AecCore* aec_core = echo_canceller.aec_core();
ASSERT_TRUE(aec_core != NULL);
// Enabled by default.
EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core));
Config config;
echo_canceller.SetExtraOptions(false, true, false);
EXPECT_EQ(1, WebRtcAec_delay_agnostic_enabled(aec_core));
// Retains setting after initialization.
echo_canceller.Initialize(AudioProcessing::kSampleRate32kHz, 2, 2, 2);
EXPECT_EQ(1, WebRtcAec_delay_agnostic_enabled(aec_core));
config.Set<DelayAgnostic>(new DelayAgnostic(false));
echo_canceller.SetExtraOptions(false, false, false);
EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core));
// Retains setting after initialization.
echo_canceller.Initialize(AudioProcessing::kSampleRate16kHz, 2, 2, 2);
EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core));
}
TEST(EchoCancellationInternalTest, InterfaceConfiguration) {
EchoCancellationImpl echo_canceller;
echo_canceller.Initialize(AudioProcessing::kSampleRate16kHz, 1, 1, 1);
EXPECT_EQ(0, echo_canceller.enable_drift_compensation(true));
EXPECT_TRUE(echo_canceller.is_drift_compensation_enabled());
EXPECT_EQ(0, echo_canceller.enable_drift_compensation(false));
EXPECT_FALSE(echo_canceller.is_drift_compensation_enabled());
EchoCancellationImpl::SuppressionLevel level[] = {
EchoCancellationImpl::kLowSuppression,
EchoCancellationImpl::kModerateSuppression,
EchoCancellationImpl::kHighSuppression,
};
for (size_t i = 0; i < arraysize(level); i++) {
EXPECT_EQ(0, echo_canceller.set_suppression_level(level[i]));
EXPECT_EQ(level[i], echo_canceller.suppression_level());
}
EchoCancellationImpl::Metrics metrics;
EXPECT_EQ(0, echo_canceller.enable_metrics(true));
EXPECT_TRUE(echo_canceller.are_metrics_enabled());
EXPECT_EQ(0, echo_canceller.enable_metrics(false));
EXPECT_FALSE(echo_canceller.are_metrics_enabled());
EXPECT_EQ(0, echo_canceller.enable_delay_logging(true));
EXPECT_TRUE(echo_canceller.is_delay_logging_enabled());
EXPECT_EQ(0, echo_canceller.enable_delay_logging(false));
EXPECT_FALSE(echo_canceller.is_delay_logging_enabled());
int median = 0;
int std = 0;
float poor_fraction = 0;
EXPECT_EQ(AudioProcessing::kNotEnabledError,
echo_canceller.GetDelayMetrics(&median, &std, &poor_fraction));
EXPECT_TRUE(echo_canceller.aec_core() != NULL);
}
} // namespace webrtc