Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 17 | #include <aidl/Vintf.h> |
Mikhail Naganov | 872d4a6 | 2023-03-09 18:19:01 -0800 | [diff] [blame] | 18 | #define LOG_TAG "VtsHalEnvironmentalReverbTest" |
| 19 | #include <android-base/logging.h> |
| 20 | |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 21 | #include "EffectHelper.h" |
| 22 | |
| 23 | using namespace android; |
| 24 | |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 25 | using aidl::android::hardware::audio::effect::Descriptor; |
| 26 | using aidl::android::hardware::audio::effect::EnvironmentalReverb; |
| 27 | using aidl::android::hardware::audio::effect::IEffect; |
| 28 | using aidl::android::hardware::audio::effect::IFactory; |
| 29 | using aidl::android::hardware::audio::effect::kEnvReverbTypeUUID; |
| 30 | using aidl::android::hardware::audio::effect::Parameter; |
| 31 | |
| 32 | /** |
| 33 | * Here we focus on specific parameter checking, general IEffect interfaces testing performed in |
| 34 | * VtsAudioEffectTargetTest. |
| 35 | * Testing parameter range, assuming the parameter supported by effect is in this range. |
| 36 | * This range is verified with IEffect.getDescriptor() and range defined in the documentation, for |
| 37 | * any index supported value test expects EX_NONE from IEffect.setParameter(), otherwise expects |
| 38 | * EX_ILLEGAL_ARGUMENT. |
| 39 | */ |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 40 | |
| 41 | class EnvironmentalReverbHelper : public EffectHelper { |
| 42 | public: |
| 43 | EnvironmentalReverbHelper(std::pair<std::shared_ptr<IFactory>, Descriptor> pair) { |
| 44 | std::tie(mFactory, mDescriptor) = pair; |
| 45 | } |
| 46 | |
| 47 | void SetUpReverb() { |
| 48 | ASSERT_NE(nullptr, mFactory); |
| 49 | ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); |
| 50 | |
| 51 | Parameter::Specific specific = getDefaultParamSpecific(); |
| 52 | Parameter::Common common = EffectHelper::createParamCommon( |
| 53 | 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, |
| 54 | kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); |
| 55 | IEffect::OpenEffectReturn ret; |
| 56 | ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE)); |
| 57 | ASSERT_NE(nullptr, mEffect); |
| 58 | } |
| 59 | |
| 60 | void TearDownReverb() { |
| 61 | ASSERT_NO_FATAL_FAILURE(close(mEffect)); |
| 62 | ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); |
| 63 | } |
| 64 | |
| 65 | Parameter::Specific getDefaultParamSpecific() { |
Sham Rathod | e362a46 | 2023-01-05 18:46:21 +0530 | [diff] [blame] | 66 | EnvironmentalReverb er = EnvironmentalReverb::make<EnvironmentalReverb::roomLevelMb>(-6000); |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 67 | Parameter::Specific specific = |
| 68 | Parameter::Specific::make<Parameter::Specific::environmentalReverb>(er); |
| 69 | return specific; |
| 70 | } |
| 71 | |
| 72 | static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100; |
| 73 | std::shared_ptr<IFactory> mFactory; |
| 74 | std::shared_ptr<IEffect> mEffect; |
| 75 | Descriptor mDescriptor; |
Sham Rathod | e362a46 | 2023-01-05 18:46:21 +0530 | [diff] [blame] | 76 | int mRoomLevel = -6000; |
| 77 | int mRoomHfLevel = 0; |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 78 | int mDecayTime = 1000; |
| 79 | int mDecayHfRatio = 500; |
Sham Rathod | e362a46 | 2023-01-05 18:46:21 +0530 | [diff] [blame] | 80 | int mLevel = -6000; |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 81 | int mDelay = 40; |
Sham Rathod | e362a46 | 2023-01-05 18:46:21 +0530 | [diff] [blame] | 82 | int mDiffusion = 1000; |
| 83 | int mDensity = 1000; |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 84 | bool mBypass = false; |
| 85 | |
| 86 | void SetAndGetReverbParameters() { |
| 87 | for (auto& it : mTags) { |
| 88 | auto& tag = it.first; |
| 89 | auto& er = it.second; |
| 90 | |
| 91 | // validate parameter |
| 92 | Descriptor desc; |
| 93 | ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc)); |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 94 | const bool valid = isParameterValid<EnvironmentalReverb, Range::environmentalReverb>( |
| 95 | it.second, desc); |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 96 | const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT; |
| 97 | |
| 98 | // set |
| 99 | Parameter expectParam; |
| 100 | Parameter::Specific specific; |
| 101 | specific.set<Parameter::Specific::environmentalReverb>(er); |
| 102 | expectParam.set<Parameter::specific>(specific); |
| 103 | EXPECT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString(); |
| 104 | |
| 105 | // only get if parameter in range and set success |
| 106 | if (expected == EX_NONE) { |
| 107 | Parameter getParam; |
| 108 | Parameter::Id id; |
| 109 | EnvironmentalReverb::Id erId; |
| 110 | erId.set<EnvironmentalReverb::Id::commonTag>(tag); |
| 111 | id.set<Parameter::Id::environmentalReverbTag>(erId); |
| 112 | // if set success, then get should match |
| 113 | EXPECT_STATUS(expected, mEffect->getParameter(id, &getParam)); |
| 114 | EXPECT_EQ(expectParam, getParam); |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | void addRoomLevelParam() { |
| 120 | EnvironmentalReverb er; |
| 121 | er.set<EnvironmentalReverb::roomLevelMb>(mRoomLevel); |
| 122 | mTags.push_back({EnvironmentalReverb::roomLevelMb, er}); |
| 123 | } |
| 124 | |
| 125 | void addRoomHfLevelParam(int roomHfLevel) { |
| 126 | EnvironmentalReverb er; |
| 127 | er.set<EnvironmentalReverb::roomHfLevelMb>(roomHfLevel); |
| 128 | mTags.push_back({EnvironmentalReverb::roomHfLevelMb, er}); |
| 129 | } |
| 130 | |
| 131 | void addDecayTimeParam(int decayTime) { |
| 132 | EnvironmentalReverb er; |
| 133 | er.set<EnvironmentalReverb::decayTimeMs>(decayTime); |
| 134 | mTags.push_back({EnvironmentalReverb::decayTimeMs, er}); |
| 135 | } |
| 136 | |
| 137 | void addDecayHfRatioParam(int decayHfRatio) { |
| 138 | EnvironmentalReverb er; |
| 139 | er.set<EnvironmentalReverb::decayHfRatioPm>(decayHfRatio); |
| 140 | mTags.push_back({EnvironmentalReverb::decayHfRatioPm, er}); |
| 141 | } |
| 142 | |
| 143 | void addLevelParam(int level) { |
| 144 | EnvironmentalReverb er; |
| 145 | er.set<EnvironmentalReverb::levelMb>(level); |
| 146 | mTags.push_back({EnvironmentalReverb::levelMb, er}); |
| 147 | } |
| 148 | |
| 149 | void addDelayParam(int delay) { |
| 150 | EnvironmentalReverb er; |
| 151 | er.set<EnvironmentalReverb::delayMs>(delay); |
| 152 | mTags.push_back({EnvironmentalReverb::delayMs, er}); |
| 153 | } |
| 154 | |
| 155 | void addDiffusionParam(int diffusion) { |
| 156 | EnvironmentalReverb er; |
| 157 | er.set<EnvironmentalReverb::diffusionPm>(diffusion); |
| 158 | mTags.push_back({EnvironmentalReverb::diffusionPm, er}); |
| 159 | } |
| 160 | |
| 161 | void addDensityParam(int density) { |
| 162 | EnvironmentalReverb er; |
| 163 | er.set<EnvironmentalReverb::densityPm>(density); |
| 164 | mTags.push_back({EnvironmentalReverb::densityPm, er}); |
| 165 | } |
| 166 | |
| 167 | void addBypassParam(bool bypass) { |
| 168 | EnvironmentalReverb er; |
| 169 | er.set<EnvironmentalReverb::bypass>(bypass); |
| 170 | mTags.push_back({EnvironmentalReverb::bypass, er}); |
| 171 | } |
| 172 | |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 173 | private: |
| 174 | std::vector<std::pair<EnvironmentalReverb::Tag, EnvironmentalReverb>> mTags; |
| 175 | void CleanUp() { mTags.clear(); } |
| 176 | }; |
| 177 | |
| 178 | class EnvironmentalReverbRoomLevelTest |
| 179 | : public ::testing::TestWithParam< |
| 180 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 181 | public EnvironmentalReverbHelper { |
| 182 | public: |
| 183 | EnvironmentalReverbRoomLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 184 | mRoomLevel = std::get<1>(GetParam()); |
| 185 | } |
| 186 | |
| 187 | void SetUp() override { SetUpReverb(); } |
| 188 | |
| 189 | void TearDown() override { TearDownReverb(); } |
| 190 | }; |
| 191 | |
| 192 | TEST_P(EnvironmentalReverbRoomLevelTest, SetAndGetRoomLevel) { |
| 193 | EXPECT_NO_FATAL_FAILURE(addRoomLevelParam()); |
| 194 | SetAndGetReverbParameters(); |
| 195 | } |
| 196 | |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 197 | std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair; |
| 198 | |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 199 | INSTANTIATE_TEST_SUITE_P( |
| 200 | EnvironmentalReverbTest, EnvironmentalReverbRoomLevelTest, |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 201 | ::testing::Combine( |
| 202 | testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors( |
| 203 | IFactory::descriptor, kEnvReverbTypeUUID)), |
| 204 | testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int, |
| 205 | Range::environmentalReverb, |
| 206 | EnvironmentalReverb::roomLevelMb>( |
| 207 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 208 | [](const testing::TestParamInfo<EnvironmentalReverbRoomLevelTest::ParamType>& info) { |
| 209 | auto descriptor = std::get<0>(info.param).second; |
| 210 | std::string roomLevel = std::to_string(std::get<1>(info.param)); |
| 211 | |
| 212 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 213 | descriptor.common.name + "_UUID_" + |
| 214 | descriptor.common.id.uuid.toString() + "_roomLevel" + roomLevel; |
| 215 | std::replace_if( |
| 216 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 217 | return name; |
| 218 | }); |
| 219 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbRoomLevelTest); |
| 220 | |
| 221 | class EnvironmentalReverbRoomHfLevelTest |
| 222 | : public ::testing::TestWithParam< |
| 223 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 224 | public EnvironmentalReverbHelper { |
| 225 | public: |
| 226 | EnvironmentalReverbRoomHfLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 227 | mRoomHfLevel = std::get<1>(GetParam()); |
| 228 | } |
| 229 | |
| 230 | void SetUp() override { SetUpReverb(); } |
| 231 | |
| 232 | void TearDown() override { TearDownReverb(); } |
| 233 | }; |
| 234 | |
| 235 | TEST_P(EnvironmentalReverbRoomHfLevelTest, SetAndGetRoomHfLevel) { |
| 236 | EXPECT_NO_FATAL_FAILURE(addRoomHfLevelParam(mRoomHfLevel)); |
| 237 | SetAndGetReverbParameters(); |
| 238 | } |
| 239 | |
| 240 | INSTANTIATE_TEST_SUITE_P( |
| 241 | EnvironmentalReverbTest, EnvironmentalReverbRoomHfLevelTest, |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 242 | ::testing::Combine( |
| 243 | testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, |
| 244 | kEnvReverbTypeUUID)), |
| 245 | testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int, |
| 246 | Range::environmentalReverb, |
| 247 | EnvironmentalReverb::roomHfLevelMb>( |
| 248 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 249 | [](const testing::TestParamInfo<EnvironmentalReverbRoomHfLevelTest::ParamType>& info) { |
| 250 | auto descriptor = std::get<0>(info.param).second; |
| 251 | std::string roomHfLevel = std::to_string(std::get<1>(info.param)); |
| 252 | |
| 253 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 254 | descriptor.common.name + "_UUID_" + |
| 255 | descriptor.common.id.uuid.toString() + "_roomHfLevel" + roomHfLevel; |
| 256 | std::replace_if( |
| 257 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 258 | return name; |
| 259 | }); |
| 260 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbRoomHfLevelTest); |
| 261 | |
| 262 | class EnvironmentalReverbDecayTimeTest |
| 263 | : public ::testing::TestWithParam< |
| 264 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 265 | public EnvironmentalReverbHelper { |
| 266 | public: |
| 267 | EnvironmentalReverbDecayTimeTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 268 | mDecayTime = std::get<1>(GetParam()); |
| 269 | } |
| 270 | |
| 271 | void SetUp() override { SetUpReverb(); } |
| 272 | |
| 273 | void TearDown() override { TearDownReverb(); } |
| 274 | }; |
| 275 | |
| 276 | TEST_P(EnvironmentalReverbDecayTimeTest, SetAndGetDecayTime) { |
| 277 | EXPECT_NO_FATAL_FAILURE(addDecayTimeParam(mDecayTime)); |
| 278 | SetAndGetReverbParameters(); |
| 279 | } |
| 280 | |
| 281 | INSTANTIATE_TEST_SUITE_P( |
| 282 | EnvironmentalReverbTest, EnvironmentalReverbDecayTimeTest, |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 283 | ::testing::Combine( |
| 284 | testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, |
| 285 | kEnvReverbTypeUUID)), |
| 286 | testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int, |
| 287 | Range::environmentalReverb, |
| 288 | EnvironmentalReverb::decayTimeMs>( |
| 289 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 290 | [](const testing::TestParamInfo<EnvironmentalReverbDecayTimeTest::ParamType>& info) { |
| 291 | auto descriptor = std::get<0>(info.param).second; |
| 292 | std::string decayTime = std::to_string(std::get<1>(info.param)); |
| 293 | |
| 294 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 295 | descriptor.common.name + "_UUID_" + |
| 296 | descriptor.common.id.uuid.toString() + "_decayTime" + decayTime; |
| 297 | std::replace_if( |
| 298 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 299 | return name; |
| 300 | }); |
| 301 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDecayTimeTest); |
| 302 | |
| 303 | class EnvironmentalReverbDecayHfRatioTest |
| 304 | : public ::testing::TestWithParam< |
| 305 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 306 | public EnvironmentalReverbHelper { |
| 307 | public: |
| 308 | EnvironmentalReverbDecayHfRatioTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 309 | mDecayHfRatio = std::get<1>(GetParam()); |
| 310 | } |
| 311 | |
| 312 | void SetUp() override { SetUpReverb(); } |
| 313 | |
| 314 | void TearDown() override { TearDownReverb(); } |
| 315 | }; |
| 316 | |
| 317 | TEST_P(EnvironmentalReverbDecayHfRatioTest, SetAndGetDecayHfRatio) { |
| 318 | EXPECT_NO_FATAL_FAILURE(addDecayHfRatioParam(mDecayHfRatio)); |
| 319 | SetAndGetReverbParameters(); |
| 320 | } |
| 321 | |
| 322 | INSTANTIATE_TEST_SUITE_P( |
| 323 | EnvironmentalReverbTest, EnvironmentalReverbDecayHfRatioTest, |
| 324 | ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors( |
| 325 | IFactory::descriptor, kEnvReverbTypeUUID)), |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 326 | testing::ValuesIn(EffectHelper::getTestValueSet< |
| 327 | EnvironmentalReverb, int, Range::environmentalReverb, |
| 328 | EnvironmentalReverb::decayHfRatioPm>( |
| 329 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 330 | [](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) { |
| 331 | auto descriptor = std::get<0>(info.param).second; |
| 332 | std::string decayHfRatio = std::to_string(std::get<1>(info.param)); |
| 333 | |
| 334 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 335 | descriptor.common.name + "_UUID_" + |
| 336 | descriptor.common.id.uuid.toString() + "_decayHfRatio" + |
| 337 | decayHfRatio; |
| 338 | std::replace_if( |
| 339 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 340 | return name; |
| 341 | }); |
| 342 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDecayHfRatioTest); |
| 343 | |
| 344 | class EnvironmentalReverbLevelTest |
| 345 | : public ::testing::TestWithParam< |
| 346 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 347 | public EnvironmentalReverbHelper { |
| 348 | public: |
| 349 | EnvironmentalReverbLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 350 | mLevel = std::get<1>(GetParam()); |
| 351 | } |
| 352 | |
| 353 | void SetUp() override { SetUpReverb(); } |
| 354 | |
| 355 | void TearDown() override { TearDownReverb(); } |
| 356 | }; |
| 357 | |
| 358 | TEST_P(EnvironmentalReverbLevelTest, SetAndGetLevel) { |
| 359 | EXPECT_NO_FATAL_FAILURE(addLevelParam(mLevel)); |
| 360 | SetAndGetReverbParameters(); |
| 361 | } |
| 362 | |
| 363 | INSTANTIATE_TEST_SUITE_P( |
| 364 | EnvironmentalReverbTest, EnvironmentalReverbLevelTest, |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 365 | ::testing::Combine( |
| 366 | testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, |
| 367 | kEnvReverbTypeUUID)), |
| 368 | testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int, |
| 369 | Range::environmentalReverb, |
| 370 | EnvironmentalReverb::levelMb>( |
| 371 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 372 | [](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) { |
| 373 | auto descriptor = std::get<0>(info.param).second; |
| 374 | std::string level = std::to_string(std::get<1>(info.param)); |
| 375 | |
| 376 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 377 | descriptor.common.name + "_UUID_" + |
| 378 | descriptor.common.id.uuid.toString() + "_level" + level; |
| 379 | std::replace_if( |
| 380 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 381 | return name; |
| 382 | }); |
| 383 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbLevelTest); |
| 384 | |
| 385 | class EnvironmentalReverbDelayTest |
| 386 | : public ::testing::TestWithParam< |
| 387 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 388 | public EnvironmentalReverbHelper { |
| 389 | public: |
| 390 | EnvironmentalReverbDelayTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 391 | mDelay = std::get<1>(GetParam()); |
| 392 | } |
| 393 | |
| 394 | void SetUp() override { SetUpReverb(); } |
| 395 | |
| 396 | void TearDown() override { TearDownReverb(); } |
| 397 | }; |
| 398 | |
| 399 | TEST_P(EnvironmentalReverbDelayTest, SetAndGetDelay) { |
| 400 | EXPECT_NO_FATAL_FAILURE(addDelayParam(mDelay)); |
| 401 | SetAndGetReverbParameters(); |
| 402 | } |
| 403 | |
| 404 | INSTANTIATE_TEST_SUITE_P( |
| 405 | EnvironmentalReverbTest, EnvironmentalReverbDelayTest, |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 406 | ::testing::Combine( |
| 407 | testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, |
| 408 | kEnvReverbTypeUUID)), |
| 409 | testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int, |
| 410 | Range::environmentalReverb, |
| 411 | EnvironmentalReverb::delayMs>( |
| 412 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 413 | [](const testing::TestParamInfo<EnvironmentalReverbDelayTest::ParamType>& info) { |
| 414 | auto descriptor = std::get<0>(info.param).second; |
| 415 | std::string delay = std::to_string(std::get<1>(info.param)); |
| 416 | |
| 417 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 418 | descriptor.common.name + "_UUID_" + |
| 419 | descriptor.common.id.uuid.toString() + "_delay" + delay; |
| 420 | std::replace_if( |
| 421 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 422 | return name; |
| 423 | }); |
| 424 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDelayTest); |
| 425 | |
| 426 | class EnvironmentalReverbDiffusionTest |
| 427 | : public ::testing::TestWithParam< |
| 428 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 429 | public EnvironmentalReverbHelper { |
| 430 | public: |
| 431 | EnvironmentalReverbDiffusionTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 432 | mDiffusion = std::get<1>(GetParam()); |
| 433 | } |
| 434 | |
| 435 | void SetUp() override { SetUpReverb(); } |
| 436 | |
| 437 | void TearDown() override { TearDownReverb(); } |
| 438 | }; |
| 439 | |
| 440 | TEST_P(EnvironmentalReverbDiffusionTest, SetAndGetDiffusion) { |
| 441 | EXPECT_NO_FATAL_FAILURE(addDiffusionParam(mDiffusion)); |
| 442 | SetAndGetReverbParameters(); |
| 443 | } |
| 444 | |
| 445 | INSTANTIATE_TEST_SUITE_P( |
| 446 | EnvironmentalReverbTest, EnvironmentalReverbDiffusionTest, |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 447 | ::testing::Combine( |
| 448 | testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, |
| 449 | kEnvReverbTypeUUID)), |
| 450 | testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int, |
| 451 | Range::environmentalReverb, |
| 452 | EnvironmentalReverb::diffusionPm>( |
| 453 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 454 | [](const testing::TestParamInfo<EnvironmentalReverbDiffusionTest::ParamType>& info) { |
| 455 | auto descriptor = std::get<0>(info.param).second; |
| 456 | std::string diffusion = std::to_string(std::get<1>(info.param)); |
| 457 | |
| 458 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 459 | descriptor.common.name + "_UUID_" + |
| 460 | descriptor.common.id.uuid.toString() + "_diffusion" + diffusion; |
| 461 | std::replace_if( |
| 462 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 463 | return name; |
| 464 | }); |
| 465 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDiffusionTest); |
| 466 | |
| 467 | class EnvironmentalReverbDensityTest |
| 468 | : public ::testing::TestWithParam< |
| 469 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>, |
| 470 | public EnvironmentalReverbHelper { |
| 471 | public: |
| 472 | EnvironmentalReverbDensityTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 473 | mDensity = std::get<1>(GetParam()); |
| 474 | } |
| 475 | |
| 476 | void SetUp() override { SetUpReverb(); } |
| 477 | |
| 478 | void TearDown() override { TearDownReverb(); } |
| 479 | }; |
| 480 | |
| 481 | TEST_P(EnvironmentalReverbDensityTest, SetAndGetDensity) { |
| 482 | EXPECT_NO_FATAL_FAILURE(addDensityParam(mDensity)); |
| 483 | SetAndGetReverbParameters(); |
| 484 | } |
| 485 | |
| 486 | INSTANTIATE_TEST_SUITE_P( |
| 487 | EnvironmentalReverbTest, EnvironmentalReverbDensityTest, |
Shunkai Yao | 0a0c45e | 2023-02-13 17:41:11 +0000 | [diff] [blame] | 488 | ::testing::Combine( |
| 489 | testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor, |
| 490 | kEnvReverbTypeUUID)), |
| 491 | testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int, |
| 492 | Range::environmentalReverb, |
| 493 | EnvironmentalReverb::densityPm>( |
| 494 | kDescPair, EffectHelper::expandTestValueBasic<int>))), |
Shraddha Basantwani | dbb0ed6 | 2022-11-17 20:32:18 +0530 | [diff] [blame] | 495 | [](const testing::TestParamInfo<EnvironmentalReverbDensityTest::ParamType>& info) { |
| 496 | auto descriptor = std::get<0>(info.param).second; |
| 497 | std::string density = std::to_string(std::get<1>(info.param)); |
| 498 | |
| 499 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 500 | descriptor.common.name + "_UUID_" + |
| 501 | descriptor.common.id.uuid.toString() + "_density" + density; |
| 502 | std::replace_if( |
| 503 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 504 | return name; |
| 505 | }); |
| 506 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDensityTest); |
| 507 | |
| 508 | class EnvironmentalReverbBypassTest |
| 509 | : public ::testing::TestWithParam< |
| 510 | std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, bool>>, |
| 511 | public EnvironmentalReverbHelper { |
| 512 | public: |
| 513 | EnvironmentalReverbBypassTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) { |
| 514 | mBypass = std::get<1>(GetParam()); |
| 515 | } |
| 516 | |
| 517 | void SetUp() override { SetUpReverb(); } |
| 518 | |
| 519 | void TearDown() override { TearDownReverb(); } |
| 520 | }; |
| 521 | |
| 522 | TEST_P(EnvironmentalReverbBypassTest, SetAndGetBypass) { |
| 523 | EXPECT_NO_FATAL_FAILURE(addBypassParam(mBypass)); |
| 524 | SetAndGetReverbParameters(); |
| 525 | } |
| 526 | |
| 527 | INSTANTIATE_TEST_SUITE_P( |
| 528 | EnvironmentalReverbTest, EnvironmentalReverbBypassTest, |
| 529 | ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors( |
| 530 | IFactory::descriptor, kEnvReverbTypeUUID)), |
| 531 | testing::Bool()), |
| 532 | [](const testing::TestParamInfo<EnvironmentalReverbBypassTest::ParamType>& info) { |
| 533 | auto descriptor = std::get<0>(info.param).second; |
| 534 | std::string bypass = std::to_string(std::get<1>(info.param)); |
| 535 | |
| 536 | std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + |
| 537 | descriptor.common.name + "_UUID_" + |
| 538 | descriptor.common.id.uuid.toString() + "_bypass" + bypass; |
| 539 | std::replace_if( |
| 540 | name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); |
| 541 | return name; |
| 542 | }); |
| 543 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbBypassTest); |
| 544 | |
| 545 | int main(int argc, char** argv) { |
| 546 | ::testing::InitGoogleTest(&argc, argv); |
| 547 | ABinderProcess_setThreadPoolMaxThreadCount(1); |
| 548 | ABinderProcess_startThreadPool(); |
| 549 | return RUN_ALL_TESTS(); |
| 550 | } |