blob: 91312a0f40132ae07e7dc6689345acf939254926 [file] [log] [blame]
Sam Zackrissona4c85142018-10-10 10:44:43 +02001/*
2 * Copyright 2018 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Sam Zackrissona4c85142018-10-10 10:44:43 +020011#include "api/audio/echo_canceller3_config.h"
Jonas Olssona4d87372019-07-05 19:08:33 +020012
Sam Zackrissona4c85142018-10-10 10:44:43 +020013#include "api/audio/echo_canceller3_config_json.h"
14#include "test/gtest.h"
15
16namespace webrtc {
17
18TEST(EchoCanceller3Config, ValidConfigIsNotModified) {
19 EchoCanceller3Config config;
20 EXPECT_TRUE(EchoCanceller3Config::Validate(&config));
21 EchoCanceller3Config default_config;
22 EXPECT_EQ(Aec3ConfigToJsonString(config),
23 Aec3ConfigToJsonString(default_config));
24}
25
26TEST(EchoCanceller3Config, InvalidConfigIsCorrected) {
27 // Change a parameter and validate.
28 EchoCanceller3Config config;
29 config.echo_model.min_noise_floor_power = -1600000.f;
30 EXPECT_FALSE(EchoCanceller3Config::Validate(&config));
31 EXPECT_GE(config.echo_model.min_noise_floor_power, 0.f);
32 // Verify remaining parameters are unchanged.
33 EchoCanceller3Config default_config;
34 config.echo_model.min_noise_floor_power =
35 default_config.echo_model.min_noise_floor_power;
36 EXPECT_EQ(Aec3ConfigToJsonString(config),
37 Aec3ConfigToJsonString(default_config));
38}
39
40TEST(EchoCanceller3Config, ValidatedConfigsAreValid) {
41 EchoCanceller3Config config;
42 config.delay.down_sampling_factor = 983;
43 EXPECT_FALSE(EchoCanceller3Config::Validate(&config));
44 EXPECT_TRUE(EchoCanceller3Config::Validate(&config));
45}
46} // namespace webrtc