webrtc/api/audio/test/echo_canceller3_config_json_unittest.cc
Sam Zackrisson 848273aa6a Revert "Increase coverage of AEC3 JSON config unit tests, fix bugs"
This reverts commit 8ee06a7b0c.

Reason for revert: ubsan triggers on config randomization

Original change's description:
> Increase coverage of AEC3 JSON config unit tests, fix bugs
> 
> The new test checks that json strings are unchanged when parsing to a
> config and back to a string. This ensures that everything in the json
> representations is parsed when created a config from the json.
> 
> This CL also adds the render_levels config substruct to the JSON parser.
> 
> Some issues were surfaced by the new test:
>  - Config validation clamping silently passed NaNs
>  - Config validation only fixed the first out-of-bounds parameter, and
>    not any subsequent ones
>  - Config validation did not check all values in the config
> 
> Bug: webrtc:9535
> Change-Id: Ie7b588731dc1fe26ba71d1eb2f177f3b3b8139e3
> Reviewed-on: https://webrtc-review.googlesource.com/c/107120
> Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> Reviewed-by: Per Åhgren <peah@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25310}

TBR=saza@webrtc.org,peah@webrtc.org

Change-Id: I12d4a6e35110241c51c13eff547ee5a640d141bc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9535
Reviewed-on: https://webrtc-review.googlesource.com/c/107624
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25313}
2018-10-23 12:14:08 +00:00

41 lines
1.7 KiB
C++

/*
* Copyright 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 "api/audio/echo_canceller3_config_json.h"
#include "api/audio/echo_canceller3_config.h"
#include "test/gtest.h"
namespace webrtc {
TEST(EchoCanceller3JsonHelpers, ToStringAndParseJson) {
EchoCanceller3Config cfg;
cfg.delay.down_sampling_factor = 1u;
cfg.filter.shadow_initial.length_blocks = 7u;
cfg.suppressor.normal_tuning.mask_hf.enr_suppress = .5f;
std::string json_string = Aec3ConfigToJsonString(cfg);
EchoCanceller3Config cfg_transformed = Aec3ConfigFromJsonString(json_string);
// Expect unchanged values to remain default.
EXPECT_EQ(cfg.filter.main.error_floor,
cfg_transformed.filter.main.error_floor);
EXPECT_EQ(cfg.ep_strength.default_len,
cfg_transformed.ep_strength.default_len);
EXPECT_EQ(cfg.suppressor.normal_tuning.mask_lf.enr_suppress,
cfg_transformed.suppressor.normal_tuning.mask_lf.enr_suppress);
// Expect changed values to carry through the transformation.
EXPECT_EQ(cfg.delay.down_sampling_factor,
cfg_transformed.delay.down_sampling_factor);
EXPECT_EQ(cfg.filter.shadow_initial.length_blocks,
cfg_transformed.filter.shadow_initial.length_blocks);
EXPECT_EQ(cfg.suppressor.normal_tuning.mask_hf.enr_suppress,
cfg_transformed.suppressor.normal_tuning.mask_hf.enr_suppress);
}
} // namespace webrtc