Merge "EnvironmentalReverbTest: Add Tests to Validate Environmental Reverb Effect" into main

This commit is contained in:
Treehugger Robot 2024-05-29 18:27:25 +00:00 committed by Gerrit Code Review
commit 56e050362d
3 changed files with 334 additions and 413 deletions

View file

@ -77,7 +77,6 @@
<effect name="dynamics_processing" library="dynamics_processing" uuid="e0e6539b-1781-7261-676f-6d7573696340"/>
<effect name="haptic_generator" library="haptic_generator" uuid="97c4acd1-8b82-4f2f-832e-c2fe5d7a9931"/>
<effect name="loudness_enhancer" library="loudness_enhancer" uuid="fa415329-2034-4bea-b5dc-5b381c8d1e2c"/>
<effect name="env_reverb" library="env_reverbsw" uuid="fa819886-588b-11ed-9b6a-0242ac120002"/>
<effect name="reverb_env_aux" library="reverb" uuid="4a387fc0-8ab3-11df-8bad-0002a5d5c51b"/>
<effect name="reverb_env_ins" library="reverb" uuid="c7a511a0-a3bb-11df-860e-0002a5d5c51b"/>
<effect name="reverb_pre_aux" library="reverb" uuid="f29a1400-a3bb-11df-8ddc-0002a5d5c51b"/>

View file

@ -121,6 +121,9 @@ cc_test {
name: "VtsHalEnvironmentalReverbTargetTest",
defaults: ["VtsHalAudioEffectTargetTestDefaults"],
srcs: ["VtsHalEnvironmentalReverbTargetTest.cpp"],
shared_libs: [
"libaudioutils",
],
}
cc_test {

View file

@ -16,28 +16,132 @@
#define LOG_TAG "VtsHalEnvironmentalReverbTest"
#include <android-base/logging.h>
#include <audio_utils/power.h>
#include <system/audio.h>
#include "EffectHelper.h"
using namespace android;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::EnvironmentalReverb;
using aidl::android::hardware::audio::effect::getEffectTypeUuidEnvReverb;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::Parameter;
using namespace aidl::android::hardware::audio::effect;
using aidl::android::hardware::audio::common::getChannelCount;
using android::hardware::audio::common::testing::detail::TestExecutionTracer;
using TagVectorPair = std::pair<EnvironmentalReverb::Tag, std::vector<int>>;
using TagValuePair = std::pair<EnvironmentalReverb::Tag, int>;
static constexpr int kMaxRoomLevel = 0;
static constexpr int kMinRoomLevel = -6000;
static constexpr int kMinRoomHfLevel = -4000;
static constexpr int kMinDecayTime = 0;
static constexpr int kMinHfRatio = 100;
static constexpr int kMinLevel = -6000;
static constexpr int kMinDensity = 0;
static constexpr int kMinDiffusion = 0;
static constexpr int kMinDelay = 0;
static const std::vector<TagVectorPair> kParamsIncreasingVector = {
{EnvironmentalReverb::roomLevelMb, {-3500, -2800, -2100, -1400, -700, 0}},
{EnvironmentalReverb::roomHfLevelMb, {-4000, -3200, -2400, -1600, -800, 0}},
{EnvironmentalReverb::decayTimeMs, {800, 1600, 2400, 3200, 4000}},
{EnvironmentalReverb::decayHfRatioPm, {100, 600, 1100, 1600, 2000}},
{EnvironmentalReverb::levelMb, {-3500, -2800, -2100, -1400, -700, 0}},
};
static const std::vector<TagValuePair> kParamsMinimumValue = {
{EnvironmentalReverb::roomLevelMb, kMinRoomLevel},
{EnvironmentalReverb::decayTimeMs, kMinDecayTime},
{EnvironmentalReverb::levelMb, kMinLevel}};
std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
using Maker = std::set<int> (*)();
static const std::array<Maker, static_cast<int>(EnvironmentalReverb::bypass) + 1>
kTestValueSetMaker = {
nullptr,
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::roomLevelMb>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::roomHfLevelMb>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::decayTimeMs>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::decayHfRatioPm>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
nullptr,
nullptr,
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::levelMb>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::delayMs>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::diffusionPm>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::densityPm>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
[]() -> std::set<int> {
return EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::bypass>(
kDescPair, EffectHelper::expandTestValueBasic<int>);
},
};
static std::vector<TagValuePair> buildSetAndGetTestParams() {
std::vector<TagValuePair> valueTag;
for (EnvironmentalReverb::Tag tag : ndk::enum_range<EnvironmentalReverb::Tag>()) {
std::set<int> values;
int intTag = static_cast<int>(tag);
if (intTag <= static_cast<int>(EnvironmentalReverb::bypass) &&
kTestValueSetMaker[intTag] != nullptr) {
values = kTestValueSetMaker[intTag]();
}
for (const auto& value : values) {
valueTag.push_back(std::make_pair(tag, value));
}
}
return valueTag;
}
/**
* Here we focus on specific parameter checking, general IEffect interfaces testing performed in
* VtsAudioEffectTargetTest.
* Testing parameter range, assuming the parameter supported by effect is in this range.
* This range is verified with IEffect.getDescriptor() and range defined in the documentation, for
* any index supported value test expects EX_NONE from IEffect.setParameter(), otherwise expects
* EX_ILLEGAL_ARGUMENT.
* Tests do the following:
* - Testing parameter range supported by the effect. Range is verified with IEffect.getDescriptor()
* and range defined in the documentation.
* - Validating the effect by comparing the outputs of the supported parameters.
*/
enum ParamName { DESCRIPTOR_INDEX, TAG_VALUE_PAIR };
class EnvironmentalReverbHelper : public EffectHelper {
public:
EnvironmentalReverbHelper(std::pair<std::shared_ptr<IFactory>, Descriptor> pair) {
@ -51,8 +155,7 @@ class EnvironmentalReverbHelper : public EffectHelper {
Parameter::Specific specific = getDefaultParamSpecific();
Parameter::Common common = createParamCommon(
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
mFrameCount /* iFrameCount */, mFrameCount /* oFrameCount */);
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
ASSERT_NE(nullptr, mEffect);
}
@ -63,475 +166,291 @@ class EnvironmentalReverbHelper : public EffectHelper {
}
Parameter::Specific getDefaultParamSpecific() {
EnvironmentalReverb er = EnvironmentalReverb::make<EnvironmentalReverb::roomLevelMb>(-6000);
EnvironmentalReverb er =
EnvironmentalReverb::make<EnvironmentalReverb::roomLevelMb>(kMaxRoomLevel);
Parameter::Specific specific =
Parameter::Specific::make<Parameter::Specific::environmentalReverb>(er);
return specific;
}
static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
bool isParamValid(EnvironmentalReverb env) {
return isParameterValid<EnvironmentalReverb, Range::environmentalReverb>(env, mDescriptor);
}
Parameter createParam(EnvironmentalReverb env) {
return Parameter::make<Parameter::specific>(
Parameter::Specific::make<Parameter::Specific::environmentalReverb>(env));
}
void setAndVerifyParam(binder_exception_t expected, EnvironmentalReverb env,
EnvironmentalReverb::Tag tag) {
auto expectedParam = createParam(env);
EXPECT_STATUS(expected, mEffect->setParameter(expectedParam)) << expectedParam.toString();
if (expected == EX_NONE) {
auto erId = EnvironmentalReverb::Id::make<EnvironmentalReverb::Id::commonTag>(
EnvironmentalReverb::Tag(tag));
auto id = Parameter::Id::make<Parameter::Id::environmentalReverbTag>(erId);
// get parameter
Parameter getParam;
EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
EXPECT_EQ(expectedParam, getParam) << "\nexpectedParam:" << expectedParam.toString()
<< "\ngetParam:" << getParam.toString();
}
}
bool isAuxiliary() {
return mDescriptor.common.flags.type ==
aidl::android::hardware::audio::effect::Flags::Type::AUXILIARY;
}
float computeOutputEnergy(const std::vector<float>& input, std::vector<float> output) {
if (!isAuxiliary()) {
// Extract auxiliary output
for (size_t i = 0; i < output.size(); i++) {
output[i] -= input[i];
}
}
return audio_utils_compute_energy_mono(output.data(), AUDIO_FORMAT_PCM_FLOAT,
output.size());
}
void generateSineWaveInput(std::vector<float>& input) {
int frequency = 1000;
size_t kSamplingFrequency = 44100;
for (size_t i = 0; i < input.size(); i++) {
input[i] = sin(2 * M_PI * frequency * i / kSamplingFrequency);
}
}
using Maker = EnvironmentalReverb (*)(int);
static constexpr std::array<Maker, static_cast<int>(EnvironmentalReverb::bypass) + 1>
kEnvironmentalReverbParamMaker = {
nullptr,
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::roomLevelMb>(value);
},
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::roomHfLevelMb>(value);
},
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::decayTimeMs>(value);
},
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::decayHfRatioPm>(
value);
},
nullptr,
nullptr,
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::levelMb>(value);
},
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::delayMs>(value);
},
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::diffusionPm>(value);
},
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::densityPm>(value);
},
[](int value) -> EnvironmentalReverb {
return EnvironmentalReverb::make<EnvironmentalReverb::bypass>(value);
}};
void createEnvParam(EnvironmentalReverb::Tag tag, int paramValue) {
int intTag = static_cast<int>(tag);
if (intTag <= static_cast<int>(EnvironmentalReverb::bypass) &&
kEnvironmentalReverbParamMaker[intTag] != NULL) {
mEnvParam = kEnvironmentalReverbParamMaker[intTag](paramValue);
} else {
GTEST_SKIP() << "Invalid parameter, skipping the test\n";
}
}
void setParameterAndProcess(std::vector<float>& input, std::vector<float>& output, int val,
EnvironmentalReverb::Tag tag) {
createEnvParam(tag, val);
if (isParamValid(mEnvParam)) {
ASSERT_NO_FATAL_FAILURE(setAndVerifyParam(EX_NONE, mEnvParam, tag));
ASSERT_NO_FATAL_FAILURE(processAndWriteToOutput(input, output, mEffect, &ret));
}
}
static constexpr int kSamplingFrequency = 44100;
static constexpr int kDurationMilliSec = 500;
static constexpr int kBufferSize = kSamplingFrequency * kDurationMilliSec / 1000;
int mStereoChannelCount =
getChannelCount(AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
AudioChannelLayout::LAYOUT_STEREO));
int mFrameCount = kBufferSize / mStereoChannelCount;
std::shared_ptr<IFactory> mFactory;
std::shared_ptr<IEffect> mEffect;
IEffect::OpenEffectReturn ret;
Descriptor mDescriptor;
int mRoomLevel = -6000;
int mRoomHfLevel = 0;
int mDecayTime = 1000;
int mDecayHfRatio = 500;
int mLevel = -6000;
int mDelay = 40;
int mDiffusion = 1000;
int mDensity = 1000;
bool mBypass = false;
void SetAndGetReverbParameters() {
for (auto& it : mTags) {
auto& tag = it.first;
auto& er = it.second;
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
const bool valid = isParameterValid<EnvironmentalReverb, Range::environmentalReverb>(
it.second, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set
Parameter expectParam;
Parameter::Specific specific;
specific.set<Parameter::Specific::environmentalReverb>(er);
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;
EnvironmentalReverb::Id erId;
erId.set<EnvironmentalReverb::Id::commonTag>(tag);
id.set<Parameter::Id::environmentalReverbTag>(erId);
// if set success, then get should match
EXPECT_STATUS(expected, mEffect->getParameter(id, &getParam));
EXPECT_EQ(expectParam, getParam);
}
}
}
void addRoomLevelParam() {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::roomLevelMb>(mRoomLevel);
mTags.push_back({EnvironmentalReverb::roomLevelMb, er});
}
void addRoomHfLevelParam(int roomHfLevel) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::roomHfLevelMb>(roomHfLevel);
mTags.push_back({EnvironmentalReverb::roomHfLevelMb, er});
}
void addDecayTimeParam(int decayTime) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::decayTimeMs>(decayTime);
mTags.push_back({EnvironmentalReverb::decayTimeMs, er});
}
void addDecayHfRatioParam(int decayHfRatio) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::decayHfRatioPm>(decayHfRatio);
mTags.push_back({EnvironmentalReverb::decayHfRatioPm, er});
}
void addLevelParam(int level) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::levelMb>(level);
mTags.push_back({EnvironmentalReverb::levelMb, er});
}
void addDelayParam(int delay) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::delayMs>(delay);
mTags.push_back({EnvironmentalReverb::delayMs, er});
}
void addDiffusionParam(int diffusion) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::diffusionPm>(diffusion);
mTags.push_back({EnvironmentalReverb::diffusionPm, er});
}
void addDensityParam(int density) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::densityPm>(density);
mTags.push_back({EnvironmentalReverb::densityPm, er});
}
void addBypassParam(bool bypass) {
EnvironmentalReverb er;
er.set<EnvironmentalReverb::bypass>(bypass);
mTags.push_back({EnvironmentalReverb::bypass, er});
}
private:
std::vector<std::pair<EnvironmentalReverb::Tag, EnvironmentalReverb>> mTags;
void CleanUp() { mTags.clear(); }
EnvironmentalReverb mEnvParam;
};
class EnvironmentalReverbRoomLevelTest
class EnvironmentalReverbParamTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, TagValuePair>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbRoomLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mRoomLevel = std::get<1>(GetParam());
EnvironmentalReverbParamTest()
: EnvironmentalReverbHelper(std::get<DESCRIPTOR_INDEX>(GetParam())) {
std::tie(mTag, mParamValue) = std::get<TAG_VALUE_PAIR>(GetParam());
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
EnvironmentalReverb::Tag mTag;
int mParamValue;
};
TEST_P(EnvironmentalReverbRoomLevelTest, SetAndGetRoomLevel) {
EXPECT_NO_FATAL_FAILURE(addRoomLevelParam());
SetAndGetReverbParameters();
TEST_P(EnvironmentalReverbParamTest, SetAndGetParameter) {
createEnvParam(mTag, mParamValue);
ASSERT_NO_FATAL_FAILURE(setAndVerifyParam(
isParamValid(mEnvParam) ? EX_NONE : EX_ILLEGAL_ARGUMENT, mEnvParam, mTag));
}
std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbRoomLevelTest,
EnvironmentalReverbTest, EnvironmentalReverbParamTest,
::testing::Combine(
testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
Range::environmentalReverb,
EnvironmentalReverb::roomLevelMb>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbRoomLevelTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string roomLevel = std::to_string(std::get<1>(info.param));
std::string name = getPrefix(descriptor) + "_roomLevel" + roomLevel;
testing::ValuesIn(buildSetAndGetTestParams())),
[](const testing::TestParamInfo<EnvironmentalReverbParamTest::ParamType>& info) {
auto descriptor = std::get<DESCRIPTOR_INDEX>(info.param).second;
auto tag = std::get<TAG_VALUE_PAIR>(info.param).first;
auto val = std::get<TAG_VALUE_PAIR>(info.param).second;
std::string name =
getPrefix(descriptor) + "_Tag_" + toString(tag) + std::to_string(val);
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbRoomLevelTest);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbParamTest);
class EnvironmentalReverbRoomHfLevelTest
class EnvironmentalReverbDataTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, TagVectorPair>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbRoomHfLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mRoomHfLevel = std::get<1>(GetParam());
EnvironmentalReverbDataTest()
: EnvironmentalReverbHelper(std::get<DESCRIPTOR_INDEX>(GetParam())) {
std::tie(mTag, mParamValues) = std::get<TAG_VALUE_PAIR>(GetParam());
mInput.resize(kBufferSize);
generateSineWaveInput(mInput);
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
void assertEnergyIncreasingWithParameter(bool bypass) {
createEnvParam(EnvironmentalReverb::bypass, bypass);
ASSERT_NO_FATAL_FAILURE(setAndVerifyParam(EX_NONE, mEnvParam, EnvironmentalReverb::bypass));
float baseEnergy = 0;
for (int val : mParamValues) {
std::vector<float> output(kBufferSize);
setParameterAndProcess(mInput, output, val, mTag);
float energy = computeOutputEnergy(mInput, output);
ASSERT_GT(energy, baseEnergy);
baseEnergy = energy;
}
}
void SetUp() override { SetUpReverb(); }
void assertZeroEnergyWithBypass(bool bypass) {
createEnvParam(EnvironmentalReverb::bypass, bypass);
ASSERT_NO_FATAL_FAILURE(setAndVerifyParam(EX_NONE, mEnvParam, EnvironmentalReverb::bypass));
for (int val : mParamValues) {
std::vector<float> output(kBufferSize);
setParameterAndProcess(mInput, output, val, mTag);
float energy = computeOutputEnergy(mInput, output);
ASSERT_EQ(energy, 0);
}
}
void TearDown() override { TearDownReverb(); }
EnvironmentalReverb::Tag mTag;
std::vector<int> mParamValues;
std::vector<float> mInput;
};
TEST_P(EnvironmentalReverbRoomHfLevelTest, SetAndGetRoomHfLevel) {
EXPECT_NO_FATAL_FAILURE(addRoomHfLevelParam(mRoomHfLevel));
SetAndGetReverbParameters();
TEST_P(EnvironmentalReverbDataTest, IncreasingParamValue) {
assertEnergyIncreasingWithParameter(false);
}
TEST_P(EnvironmentalReverbDataTest, WithBypassEnabled) {
assertZeroEnergyWithBypass(true);
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbRoomHfLevelTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
EnvironmentalReverbTest, EnvironmentalReverbDataTest,
::testing::Combine(
testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<
EnvironmentalReverb, int, Range::environmentalReverb,
EnvironmentalReverb::roomHfLevelMb>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbRoomHfLevelTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string roomHfLevel = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_roomHfLevel" + roomHfLevel;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
testing::ValuesIn(kParamsIncreasingVector)),
[](const testing::TestParamInfo<EnvironmentalReverbDataTest::ParamType>& info) {
auto descriptor = std::get<DESCRIPTOR_INDEX>(info.param).second;
auto tag = std::get<TAG_VALUE_PAIR>(info.param).first;
std::string name = getPrefix(descriptor) + "_Tag_" + toString(tag);
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbRoomHfLevelTest);
class EnvironmentalReverbDecayTimeTest
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDataTest);
class EnvironmentalReverbMinimumParamTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, TagValuePair>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbDecayTimeTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mDecayTime = std::get<1>(GetParam());
EnvironmentalReverbMinimumParamTest()
: EnvironmentalReverbHelper(std::get<DESCRIPTOR_INDEX>(GetParam())) {
std::tie(mTag, mValue) = std::get<TAG_VALUE_PAIR>(GetParam());
}
void SetUp() override {
SetUpReverb();
createEnvParam(EnvironmentalReverb::roomLevelMb, kMinRoomLevel);
ASSERT_NO_FATAL_FAILURE(
setAndVerifyParam(EX_NONE, mEnvParam, EnvironmentalReverb::roomLevelMb));
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
EnvironmentalReverb::Tag mTag;
int mValue;
};
TEST_P(EnvironmentalReverbDecayTimeTest, SetAndGetDecayTime) {
EXPECT_NO_FATAL_FAILURE(addDecayTimeParam(mDecayTime));
SetAndGetReverbParameters();
TEST_P(EnvironmentalReverbMinimumParamTest, MinimumValueTest) {
std::vector<float> input(kBufferSize);
generateSineWaveInput(input);
std::vector<float> output(kBufferSize);
setParameterAndProcess(input, output, mValue, mTag);
float energy = computeOutputEnergy(input, output);
// No Auxiliary output for minimum param values
ASSERT_EQ(energy, 0);
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDecayTimeTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
EnvironmentalReverbTest, EnvironmentalReverbMinimumParamTest,
::testing::Combine(
testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<
EnvironmentalReverb, int, Range::environmentalReverb,
EnvironmentalReverb::decayTimeMs>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDecayTimeTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string decayTime = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_decayTime" + decayTime;
testing::ValuesIn(kParamsMinimumValue)),
[](const testing::TestParamInfo<EnvironmentalReverbMinimumParamTest::ParamType>& info) {
auto descriptor = std::get<DESCRIPTOR_INDEX>(info.param).second;
auto tag = std::get<TAG_VALUE_PAIR>(info.param).first;
auto val = std::get<TAG_VALUE_PAIR>(info.param).second;
std::string name =
getPrefix(descriptor) + "_Tag_" + toString(tag) + std::to_string(val);
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDecayTimeTest);
class EnvironmentalReverbDecayHfRatioTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbDecayHfRatioTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mDecayHfRatio = std::get<1>(GetParam());
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
};
TEST_P(EnvironmentalReverbDecayHfRatioTest, SetAndGetDecayHfRatio) {
EXPECT_NO_FATAL_FAILURE(addDecayHfRatioParam(mDecayHfRatio));
SetAndGetReverbParameters();
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDecayHfRatioTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<
EnvironmentalReverb, int, Range::environmentalReverb,
EnvironmentalReverb::decayHfRatioPm>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string decayHfRatio = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_decayHfRatio" + decayHfRatio;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDecayHfRatioTest);
class EnvironmentalReverbLevelTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mLevel = std::get<1>(GetParam());
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
};
TEST_P(EnvironmentalReverbLevelTest, SetAndGetLevel) {
EXPECT_NO_FATAL_FAILURE(addLevelParam(mLevel));
SetAndGetReverbParameters();
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbLevelTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<
EnvironmentalReverb, int, Range::environmentalReverb,
EnvironmentalReverb::levelMb>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string level = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_level" + level;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbLevelTest);
class EnvironmentalReverbDelayTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbDelayTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mDelay = std::get<1>(GetParam());
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
};
TEST_P(EnvironmentalReverbDelayTest, SetAndGetDelay) {
EXPECT_NO_FATAL_FAILURE(addDelayParam(mDelay));
SetAndGetReverbParameters();
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDelayTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<
EnvironmentalReverb, int, Range::environmentalReverb,
EnvironmentalReverb::delayMs>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDelayTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string delay = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_delay" + delay;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDelayTest);
class EnvironmentalReverbDiffusionTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbDiffusionTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mDiffusion = std::get<1>(GetParam());
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
};
TEST_P(EnvironmentalReverbDiffusionTest, SetAndGetDiffusion) {
EXPECT_NO_FATAL_FAILURE(addDiffusionParam(mDiffusion));
SetAndGetReverbParameters();
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDiffusionTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<
EnvironmentalReverb, int, Range::environmentalReverb,
EnvironmentalReverb::diffusionPm>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDiffusionTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string diffusion = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_diffusion" + diffusion;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDiffusionTest);
class EnvironmentalReverbDensityTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbDensityTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mDensity = std::get<1>(GetParam());
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
};
TEST_P(EnvironmentalReverbDensityTest, SetAndGetDensity) {
EXPECT_NO_FATAL_FAILURE(addDensityParam(mDensity));
SetAndGetReverbParameters();
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDensityTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::ValuesIn(EffectHelper::getTestValueSet<
EnvironmentalReverb, int, Range::environmentalReverb,
EnvironmentalReverb::densityPm>(
kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDensityTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string density = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_density" + density;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDensityTest);
class EnvironmentalReverbBypassTest
: public ::testing::TestWithParam<
std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, bool>>,
public EnvironmentalReverbHelper {
public:
EnvironmentalReverbBypassTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
mBypass = std::get<1>(GetParam());
}
void SetUp() override { SetUpReverb(); }
void TearDown() override { TearDownReverb(); }
};
TEST_P(EnvironmentalReverbBypassTest, SetAndGetBypass) {
EXPECT_NO_FATAL_FAILURE(addBypassParam(mBypass));
SetAndGetReverbParameters();
}
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbBypassTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidEnvReverb())),
testing::Bool()),
[](const testing::TestParamInfo<EnvironmentalReverbBypassTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string bypass = std::to_string(std::get<1>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
toString(descriptor.common.id.uuid) + "_bypass" + bypass;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
});
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbBypassTest);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbMinimumParamTest);
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);