Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 1 | /* |
| 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 Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 11 | #include "api/audio/echo_canceller3_config.h" |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 12 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 13 | #include "api/audio/echo_canceller3_config_json.h" |
| 14 | #include "test/gtest.h" |
| 15 | |
| 16 | namespace webrtc { |
| 17 | |
| 18 | TEST(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 | |
| 26 | TEST(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 | |
| 40 | TEST(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 |