/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "VtsHalAGC2ParamTest"
#include <android-base/logging.h>
#include <android/binder_enums.h>

#include "EffectHelper.h"

using namespace android;

using aidl::android::hardware::audio::effect::AutomaticGainControlV2;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::getEffectTypeUuidAutomaticGainControlV2;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::Parameter;
using android::hardware::audio::common::testing::detail::TestExecutionTracer;

enum ParamName {
    PARAM_INSTANCE_NAME,
    PARAM_DIGITAL_GAIN,
    PARAM_SATURATION_MARGIN,
    PARAM_LEVEL_ESTIMATOR
};
using AGC2ParamTestParam =
        std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int /* gain */,
                   int /* margin */, AutomaticGainControlV2::LevelEstimator>;

class AGC2ParamTest : public ::testing::TestWithParam<AGC2ParamTestParam>, public EffectHelper {
  public:
    AGC2ParamTest()
        : mGain(std::get<PARAM_DIGITAL_GAIN>(GetParam())),
          mMargin(std::get<PARAM_SATURATION_MARGIN>(GetParam())),
          mLevelEstimator(std::get<PARAM_LEVEL_ESTIMATOR>(GetParam())) {
        std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
    }

    void SetUp() override {
        ASSERT_NE(nullptr, mFactory);
        ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

        Parameter::Specific specific = getDefaultParamSpecific();
        Parameter::Common common = EffectHelper::createParamCommon(
                0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
                kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
        IEffect::OpenEffectReturn ret;
        ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
        ASSERT_NE(nullptr, mEffect);
    }

    void TearDown() override {
        ASSERT_NO_FATAL_FAILURE(close(mEffect));
        ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
    }

    Parameter::Specific getDefaultParamSpecific() {
        AutomaticGainControlV2 AGC2 =
                AutomaticGainControlV2::make<AutomaticGainControlV2::fixedDigitalGainMb>(0);
        Parameter::Specific specific =
                Parameter::Specific::make<Parameter::Specific::automaticGainControlV2>(AGC2);
        return specific;
    }

    static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
    std::shared_ptr<IFactory> mFactory;
    std::shared_ptr<IEffect> mEffect;
    Descriptor mDescriptor;
    int mGain;
    int mMargin;
    AutomaticGainControlV2::LevelEstimator mLevelEstimator;

    void SetAndGetParameters() {
        for (auto& it : mTags) {
            auto& tag = it.first;
            auto& AGC2 = it.second;

            // validate parameter
            Descriptor desc;
            ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
            const bool valid =
                    isParameterValid<AutomaticGainControlV2, Range::automaticGainControlV2>(AGC2,
                                                                                            desc);
            const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;

            // set parameter
            Parameter expectParam;
            Parameter::Specific specific;
            specific.set<Parameter::Specific::automaticGainControlV2>(AGC2);
            expectParam.set<Parameter::specific>(specific);
            EXPECT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();

            // only get if parameter in range and set success
            if (expected == EX_NONE) {
                Parameter getParam;
                Parameter::Id id;
                AutomaticGainControlV2::Id specificId;
                specificId.set<AutomaticGainControlV2::Id::commonTag>(tag);
                id.set<Parameter::Id::automaticGainControlV2Tag>(specificId);
                EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));

                EXPECT_EQ(expectParam, getParam) << "\nexpect:" << expectParam.toString()
                                                 << "\ngetParam:" << getParam.toString();
            }
        }
    }

    void addDigitalGainParam(int gain) {
        AutomaticGainControlV2 AGC2;
        AGC2.set<AutomaticGainControlV2::fixedDigitalGainMb>(gain);
        mTags.push_back({AutomaticGainControlV2::fixedDigitalGainMb, AGC2});
    }
    void addSaturationMarginParam(int margin) {
        AutomaticGainControlV2 AGC2;
        AGC2.set<AutomaticGainControlV2::saturationMarginMb>(margin);
        mTags.push_back({AutomaticGainControlV2::saturationMarginMb, AGC2});
    }
    void addLevelEstimatorParam(AutomaticGainControlV2::LevelEstimator levelEstimator) {
        AutomaticGainControlV2 AGC2;
        AGC2.set<AutomaticGainControlV2::levelEstimator>(levelEstimator);
        mTags.push_back({AutomaticGainControlV2::levelEstimator, AGC2});
    }

    static std::set<AutomaticGainControlV2::LevelEstimator> getLevelEstimatorValues() {
        return {ndk::enum_range<AutomaticGainControlV2::LevelEstimator>().begin(),
                ndk::enum_range<AutomaticGainControlV2::LevelEstimator>().end()};
    }

  private:
    std::vector<std::pair<AutomaticGainControlV2::Tag, AutomaticGainControlV2>> mTags;
    void CleanUp() { mTags.clear(); }
};

TEST_P(AGC2ParamTest, SetAndGetDigitalGainParam) {
    EXPECT_NO_FATAL_FAILURE(addDigitalGainParam(mGain));
    SetAndGetParameters();
}

TEST_P(AGC2ParamTest, SetAndGetSaturationMargin) {
    EXPECT_NO_FATAL_FAILURE(addSaturationMarginParam(mMargin));
    SetAndGetParameters();
}

TEST_P(AGC2ParamTest, SetAndGetLevelEstimator) {
    EXPECT_NO_FATAL_FAILURE(addLevelEstimatorParam(mLevelEstimator));
    SetAndGetParameters();
}

std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
        AGC2ParamTest, AGC2ParamTest,
        ::testing::Combine(
                testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
                                          IFactory::descriptor,
                                          getEffectTypeUuidAutomaticGainControlV2())),
                testing::ValuesIn(EffectHelper::getTestValueSet<
                                  AutomaticGainControlV2, int, Range::automaticGainControlV2,
                                  AutomaticGainControlV2::fixedDigitalGainMb>(
                        kDescPair, EffectHelper::expandTestValueBasic<int>)),
                testing::ValuesIn(EffectHelper::getTestValueSet<
                                  AutomaticGainControlV2, int, Range::automaticGainControlV2,
                                  AutomaticGainControlV2::saturationMarginMb>(
                        kDescPair, EffectHelper::expandTestValueBasic<int>)),
                testing::ValuesIn(AGC2ParamTest::getLevelEstimatorValues())),
        [](const testing::TestParamInfo<AGC2ParamTest::ParamType>& info) {
            auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
            std::string gain = std::to_string(std::get<PARAM_DIGITAL_GAIN>(info.param));
            std::string estimator = aidl::android::hardware::audio::effect::toString(
                    std::get<PARAM_LEVEL_ESTIMATOR>(info.param));
            std::string margin =
                    std::to_string(static_cast<int>(std::get<PARAM_SATURATION_MARGIN>(info.param)));

            std::string name = getPrefix(descriptor) + "_digital_gain_" + gain +
                               "_level_estimator_" + estimator + "_margin_" + margin;
            std::replace_if(
                    name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
            return name;
        });

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AGC2ParamTest);

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
    ABinderProcess_setThreadPoolMaxThreadCount(1);
    ABinderProcess_startThreadPool();
    return RUN_ALL_TESTS();
}
