chromium/third_party/webrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_unittest.cc

/*
 *  Copyright (c) 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 "modules/audio_processing/agc2/adaptive_digital_gain_controller.h"

#include <algorithm>
#include <memory>

#include "api/audio/audio_processing.h"
#include "common_audio/include/audio_util.h"
#include "modules/audio_processing/agc2/agc2_common.h"
#include "modules/audio_processing/agc2/vector_float_frame.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/gunit.h"

namespace webrtc {
namespace {

constexpr int kMono =;
constexpr int kStereo =;
constexpr int kFrameLen10ms8kHz =;
constexpr int kFrameLen10ms48kHz =;

constexpr float kMaxSpeechProbability =;

// Constants used in place of estimated noise levels.
constexpr float kNoNoiseDbfs =;
constexpr float kWithNoiseDbfs =;

// Number of additional frames to process in the tests to ensure that the tested
// adaptation processes have converged.
constexpr int kNumExtraFrames =;

constexpr float GetMaxGainChangePerFrameDb(
    float max_gain_change_db_per_second) {}

AdaptiveDigitalConfig;

constexpr AdaptiveDigitalConfig kDefaultConfig{};

// Helper to create initialized `AdaptiveDigitalGainController` objects.
struct GainApplierHelper {};

// Returns a `FrameInfo` sample to simulate noiseless speech detected with
// maximum probability and with level, headroom and limiter envelope chosen
// so that the resulting gain equals the default initial adaptive digital gain
// i.e., no gain adaptation is expected.
AdaptiveDigitalGainController::FrameInfo GetFrameInfoToNotAdapt(
    const AdaptiveDigitalConfig& config) {}

TEST(GainController2AdaptiveDigitalGainControllerTest,
     GainApplierShouldNotCrash) {}

// Checks that the maximum allowed gain is applied.
TEST(GainController2AdaptiveDigitalGainControllerTest, MaxGainApplied) {}

TEST(GainController2AdaptiveDigitalGainControllerTest, GainDoesNotChangeFast) {}

TEST(GainController2AdaptiveDigitalGainControllerTest, GainIsRampedInAFrame) {}

TEST(GainController2AdaptiveDigitalGainControllerTest, NoiseLimitsGain) {}

TEST(GainController2AdaptiveDigitalGainControllerTest,
     CanHandlePositiveSpeechLevels) {}

TEST(GainController2AdaptiveDigitalGainControllerTest, AudioLevelLimitsGain) {}

class AdaptiveDigitalGainControllerParametrizedTest
    : public ::testing::TestWithParam<int> {};

TEST_P(AdaptiveDigitalGainControllerParametrizedTest,
       DoNotIncreaseGainWithTooFewSpeechFrames) {}

TEST_P(AdaptiveDigitalGainControllerParametrizedTest,
       IncreaseGainWithEnoughSpeechFrames) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace
}  // namespace webrtc