blob: e99c4a449e9685cda5278623e0e7d8dda426f88b [file] [log] [blame]
Shraddha Basantwanidbb0ed62022-11-17 20:32:18 +05301/*
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
17#define LOG_TAG "VtsHalEnvironmentalReverbTest"
18
19#include <Utils.h>
20#include <aidl/Vintf.h>
21#include "EffectHelper.h"
22
23using namespace android;
24
25using aidl::android::hardware::audio::effect::Capability;
26using aidl::android::hardware::audio::effect::Descriptor;
27using aidl::android::hardware::audio::effect::EnvironmentalReverb;
28using aidl::android::hardware::audio::effect::IEffect;
29using aidl::android::hardware::audio::effect::IFactory;
30using aidl::android::hardware::audio::effect::kEnvReverbTypeUUID;
31using aidl::android::hardware::audio::effect::Parameter;
32
33/**
34 * Here we focus on specific parameter checking, general IEffect interfaces testing performed in
35 * VtsAudioEffectTargetTest.
36 * Testing parameter range, assuming the parameter supported by effect is in this range.
37 * This range is verified with IEffect.getDescriptor() and range defined in the documentation, for
38 * any index supported value test expects EX_NONE from IEffect.setParameter(), otherwise expects
39 * EX_ILLEGAL_ARGUMENT.
40 */
41const std::vector<int> kRoomLevelValues = {
42 EnvironmentalReverb::MIN_ROOM_LEVEL_MB - 1, EnvironmentalReverb::MIN_ROOM_LEVEL_MB,
43 EnvironmentalReverb::MAX_ROOM_LEVEL_MB, EnvironmentalReverb::MAX_ROOM_LEVEL_MB + 1};
44const std::vector<int> kRoomHfLevelValues = {
45 EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB - 1, EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB,
46 EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB, EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB + 1};
47const std::vector<int> kDecayTimeValues = {
48 EnvironmentalReverb::MIN_DECAY_TIME_MS - 1, EnvironmentalReverb::MIN_DECAY_TIME_MS,
49 EnvironmentalReverb::MAX_DECAY_TIME_MS, EnvironmentalReverb::MAX_DECAY_TIME_MS + 1};
50const std::vector<int> kDecayHfRatioValues = {
51 EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM - 1, EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM,
52 EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM, EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM + 1};
53const std::vector<int> kLevelValues = {
54 EnvironmentalReverb::MIN_LEVEL_MB - 1, EnvironmentalReverb::MIN_LEVEL_MB,
55 EnvironmentalReverb::MAX_LEVEL_MB, EnvironmentalReverb::MAX_LEVEL_MB + 1};
56const std::vector<int> kDelayValues = {
57 EnvironmentalReverb::MIN_DELAY_MS - 1, EnvironmentalReverb::MIN_DELAY_MS,
58 EnvironmentalReverb::MAX_DELAY_MS, EnvironmentalReverb::MAX_DELAY_MS + 1};
59const std::vector<int> kDiffusionValues = {
60 EnvironmentalReverb::MIN_DIFFUSION_PM - 1, EnvironmentalReverb::MIN_DIFFUSION_PM,
61 EnvironmentalReverb::MAX_DIFFUSION_PM, EnvironmentalReverb::MAX_DIFFUSION_PM + 1};
62const std::vector<int> kDensityValues = {
63 EnvironmentalReverb::MIN_DENSITY_PM - 1, EnvironmentalReverb::MIN_DENSITY_PM,
64 EnvironmentalReverb::MAX_DENSITY_PM, EnvironmentalReverb::MAX_DENSITY_PM + 1};
65
66class EnvironmentalReverbHelper : public EffectHelper {
67 public:
68 EnvironmentalReverbHelper(std::pair<std::shared_ptr<IFactory>, Descriptor> pair) {
69 std::tie(mFactory, mDescriptor) = pair;
70 }
71
72 void SetUpReverb() {
73 ASSERT_NE(nullptr, mFactory);
74 ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
75
76 Parameter::Specific specific = getDefaultParamSpecific();
77 Parameter::Common common = EffectHelper::createParamCommon(
78 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
79 kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
80 IEffect::OpenEffectReturn ret;
81 ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
82 ASSERT_NE(nullptr, mEffect);
83 }
84
85 void TearDownReverb() {
86 ASSERT_NO_FATAL_FAILURE(close(mEffect));
87 ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
88 }
89
90 Parameter::Specific getDefaultParamSpecific() {
91 EnvironmentalReverb er = EnvironmentalReverb::make<EnvironmentalReverb::roomLevelMb>(
92 EnvironmentalReverb::MIN_ROOM_LEVEL_MB);
93 Parameter::Specific specific =
94 Parameter::Specific::make<Parameter::Specific::environmentalReverb>(er);
95 return specific;
96 }
97
98 static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
99 std::shared_ptr<IFactory> mFactory;
100 std::shared_ptr<IEffect> mEffect;
101 Descriptor mDescriptor;
102 int mRoomLevel = EnvironmentalReverb::MIN_ROOM_LEVEL_MB;
103 int mRoomHfLevel = EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB;
104 int mDecayTime = 1000;
105 int mDecayHfRatio = 500;
106 int mLevel = EnvironmentalReverb::MIN_LEVEL_MB;
107 int mDelay = 40;
108 int mDiffusion = EnvironmentalReverb::MAX_DIFFUSION_PM;
109 int mDensity = EnvironmentalReverb::MAX_DENSITY_PM;
110 bool mBypass = false;
111
112 void SetAndGetReverbParameters() {
113 for (auto& it : mTags) {
114 auto& tag = it.first;
115 auto& er = it.second;
116
117 // validate parameter
118 Descriptor desc;
119 ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
120 const bool valid = isTagInRange(it.first, it.second, desc);
121 const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
122
123 // set
124 Parameter expectParam;
125 Parameter::Specific specific;
126 specific.set<Parameter::Specific::environmentalReverb>(er);
127 expectParam.set<Parameter::specific>(specific);
128 EXPECT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();
129
130 // only get if parameter in range and set success
131 if (expected == EX_NONE) {
132 Parameter getParam;
133 Parameter::Id id;
134 EnvironmentalReverb::Id erId;
135 erId.set<EnvironmentalReverb::Id::commonTag>(tag);
136 id.set<Parameter::Id::environmentalReverbTag>(erId);
137 // if set success, then get should match
138 EXPECT_STATUS(expected, mEffect->getParameter(id, &getParam));
139 EXPECT_EQ(expectParam, getParam);
140 }
141 }
142 }
143
144 void addRoomLevelParam() {
145 EnvironmentalReverb er;
146 er.set<EnvironmentalReverb::roomLevelMb>(mRoomLevel);
147 mTags.push_back({EnvironmentalReverb::roomLevelMb, er});
148 }
149
150 void addRoomHfLevelParam(int roomHfLevel) {
151 EnvironmentalReverb er;
152 er.set<EnvironmentalReverb::roomHfLevelMb>(roomHfLevel);
153 mTags.push_back({EnvironmentalReverb::roomHfLevelMb, er});
154 }
155
156 void addDecayTimeParam(int decayTime) {
157 EnvironmentalReverb er;
158 er.set<EnvironmentalReverb::decayTimeMs>(decayTime);
159 mTags.push_back({EnvironmentalReverb::decayTimeMs, er});
160 }
161
162 void addDecayHfRatioParam(int decayHfRatio) {
163 EnvironmentalReverb er;
164 er.set<EnvironmentalReverb::decayHfRatioPm>(decayHfRatio);
165 mTags.push_back({EnvironmentalReverb::decayHfRatioPm, er});
166 }
167
168 void addLevelParam(int level) {
169 EnvironmentalReverb er;
170 er.set<EnvironmentalReverb::levelMb>(level);
171 mTags.push_back({EnvironmentalReverb::levelMb, er});
172 }
173
174 void addDelayParam(int delay) {
175 EnvironmentalReverb er;
176 er.set<EnvironmentalReverb::delayMs>(delay);
177 mTags.push_back({EnvironmentalReverb::delayMs, er});
178 }
179
180 void addDiffusionParam(int diffusion) {
181 EnvironmentalReverb er;
182 er.set<EnvironmentalReverb::diffusionPm>(diffusion);
183 mTags.push_back({EnvironmentalReverb::diffusionPm, er});
184 }
185
186 void addDensityParam(int density) {
187 EnvironmentalReverb er;
188 er.set<EnvironmentalReverb::densityPm>(density);
189 mTags.push_back({EnvironmentalReverb::densityPm, er});
190 }
191
192 void addBypassParam(bool bypass) {
193 EnvironmentalReverb er;
194 er.set<EnvironmentalReverb::bypass>(bypass);
195 mTags.push_back({EnvironmentalReverb::bypass, er});
196 }
197
198 bool isTagInRange(const EnvironmentalReverb::Tag& tag, const EnvironmentalReverb er,
199 const Descriptor& desc) const {
200 const EnvironmentalReverb::Capability& erCap =
201 desc.capability.get<Capability::environmentalReverb>();
202 switch (tag) {
203 case EnvironmentalReverb::roomLevelMb: {
204 int roomLevel = er.get<EnvironmentalReverb::roomLevelMb>();
205 return isRoomLevelInRange(roomLevel);
206 }
207 case EnvironmentalReverb::roomHfLevelMb: {
208 int roomHfLevel = er.get<EnvironmentalReverb::roomHfLevelMb>();
209 return isRoomHfLevelInRange(roomHfLevel);
210 }
211 case EnvironmentalReverb::decayTimeMs: {
212 int decayTime = er.get<EnvironmentalReverb::decayTimeMs>();
213 return isDecayTimeInRange(erCap, decayTime);
214 }
215 case EnvironmentalReverb::decayHfRatioPm: {
216 int decayHfRatio = er.get<EnvironmentalReverb::decayHfRatioPm>();
217 return isDecayHfRatioInRange(decayHfRatio);
218 }
219 case EnvironmentalReverb::levelMb: {
220 int level = er.get<EnvironmentalReverb::levelMb>();
221 return isLevelInRange(level);
222 }
223 case EnvironmentalReverb::delayMs: {
224 int delay = er.get<EnvironmentalReverb::delayMs>();
225 return isDelayInRange(delay);
226 }
227 case EnvironmentalReverb::diffusionPm: {
228 int diffusion = er.get<EnvironmentalReverb::diffusionPm>();
229 return isDiffusionInRange(diffusion);
230 }
231 case EnvironmentalReverb::densityPm: {
232 int density = er.get<EnvironmentalReverb::densityPm>();
233 return isDensityInRange(density);
234 }
235 case EnvironmentalReverb::bypass: {
236 return true;
237 }
238 default:
239 return false;
240 }
241 return false;
242 }
243
244 bool isRoomLevelInRange(int roomLevel) const {
245 return roomLevel >= EnvironmentalReverb::MIN_ROOM_LEVEL_MB &&
246 roomLevel <= EnvironmentalReverb::MAX_ROOM_LEVEL_MB;
247 }
248
249 bool isRoomHfLevelInRange(int roomHfLevel) const {
250 return roomHfLevel >= EnvironmentalReverb::MIN_ROOM_HF_LEVEL_MB &&
251 roomHfLevel <= EnvironmentalReverb::MAX_ROOM_HF_LEVEL_MB;
252 }
253
254 bool isDecayTimeInRange(const EnvironmentalReverb::Capability& cap, int decayTime) const {
255 return decayTime >= EnvironmentalReverb::MIN_DECAY_TIME_MS &&
256 decayTime <= EnvironmentalReverb::MAX_DECAY_TIME_MS &&
257 decayTime <= cap.maxDecayTimeMs;
258 }
259
260 bool isDecayHfRatioInRange(int decayHfRatio) const {
261 return decayHfRatio >= EnvironmentalReverb::MIN_DECAY_HF_RATIO_PM &&
262 decayHfRatio <= EnvironmentalReverb::MAX_DECAY_HF_RATIO_PM;
263 }
264
265 bool isLevelInRange(int level) const {
266 return level >= EnvironmentalReverb::MIN_LEVEL_MB &&
267 level <= EnvironmentalReverb::MAX_LEVEL_MB;
268 }
269
270 bool isDelayInRange(int delay) const {
271 return delay >= EnvironmentalReverb::MIN_DELAY_MS &&
272 delay <= EnvironmentalReverb::MAX_DELAY_MS;
273 }
274
275 bool isDiffusionInRange(int diffusion) const {
276 return diffusion >= EnvironmentalReverb::MIN_DIFFUSION_PM &&
277 diffusion <= EnvironmentalReverb::MAX_DIFFUSION_PM;
278 }
279
280 bool isDensityInRange(int density) const {
281 return density >= EnvironmentalReverb::MIN_DENSITY_PM &&
282 density <= EnvironmentalReverb::MAX_DENSITY_PM;
283 }
284
285 private:
286 std::vector<std::pair<EnvironmentalReverb::Tag, EnvironmentalReverb>> mTags;
287 void CleanUp() { mTags.clear(); }
288};
289
290class EnvironmentalReverbRoomLevelTest
291 : public ::testing::TestWithParam<
292 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
293 public EnvironmentalReverbHelper {
294 public:
295 EnvironmentalReverbRoomLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
296 mRoomLevel = std::get<1>(GetParam());
297 }
298
299 void SetUp() override { SetUpReverb(); }
300
301 void TearDown() override { TearDownReverb(); }
302};
303
304TEST_P(EnvironmentalReverbRoomLevelTest, SetAndGetRoomLevel) {
305 EXPECT_NO_FATAL_FAILURE(addRoomLevelParam());
306 SetAndGetReverbParameters();
307}
308
309INSTANTIATE_TEST_SUITE_P(
310 EnvironmentalReverbTest, EnvironmentalReverbRoomLevelTest,
311 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
312 IFactory::descriptor, kEnvReverbTypeUUID)),
313 testing::ValuesIn(kRoomLevelValues)),
314 [](const testing::TestParamInfo<EnvironmentalReverbRoomLevelTest::ParamType>& info) {
315 auto descriptor = std::get<0>(info.param).second;
316 std::string roomLevel = std::to_string(std::get<1>(info.param));
317
318 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
319 descriptor.common.name + "_UUID_" +
320 descriptor.common.id.uuid.toString() + "_roomLevel" + roomLevel;
321 std::replace_if(
322 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
323 return name;
324 });
325GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbRoomLevelTest);
326
327class EnvironmentalReverbRoomHfLevelTest
328 : public ::testing::TestWithParam<
329 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
330 public EnvironmentalReverbHelper {
331 public:
332 EnvironmentalReverbRoomHfLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
333 mRoomHfLevel = std::get<1>(GetParam());
334 }
335
336 void SetUp() override { SetUpReverb(); }
337
338 void TearDown() override { TearDownReverb(); }
339};
340
341TEST_P(EnvironmentalReverbRoomHfLevelTest, SetAndGetRoomHfLevel) {
342 EXPECT_NO_FATAL_FAILURE(addRoomHfLevelParam(mRoomHfLevel));
343 SetAndGetReverbParameters();
344}
345
346INSTANTIATE_TEST_SUITE_P(
347 EnvironmentalReverbTest, EnvironmentalReverbRoomHfLevelTest,
348 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
349 IFactory::descriptor, kEnvReverbTypeUUID)),
350 testing::ValuesIn(kRoomHfLevelValues)),
351 [](const testing::TestParamInfo<EnvironmentalReverbRoomHfLevelTest::ParamType>& info) {
352 auto descriptor = std::get<0>(info.param).second;
353 std::string roomHfLevel = std::to_string(std::get<1>(info.param));
354
355 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
356 descriptor.common.name + "_UUID_" +
357 descriptor.common.id.uuid.toString() + "_roomHfLevel" + roomHfLevel;
358 std::replace_if(
359 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
360 return name;
361 });
362GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbRoomHfLevelTest);
363
364class EnvironmentalReverbDecayTimeTest
365 : public ::testing::TestWithParam<
366 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
367 public EnvironmentalReverbHelper {
368 public:
369 EnvironmentalReverbDecayTimeTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
370 mDecayTime = std::get<1>(GetParam());
371 }
372
373 void SetUp() override { SetUpReverb(); }
374
375 void TearDown() override { TearDownReverb(); }
376};
377
378TEST_P(EnvironmentalReverbDecayTimeTest, SetAndGetDecayTime) {
379 EXPECT_NO_FATAL_FAILURE(addDecayTimeParam(mDecayTime));
380 SetAndGetReverbParameters();
381}
382
383INSTANTIATE_TEST_SUITE_P(
384 EnvironmentalReverbTest, EnvironmentalReverbDecayTimeTest,
385 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
386 IFactory::descriptor, kEnvReverbTypeUUID)),
387 testing::ValuesIn(kDecayTimeValues)),
388 [](const testing::TestParamInfo<EnvironmentalReverbDecayTimeTest::ParamType>& info) {
389 auto descriptor = std::get<0>(info.param).second;
390 std::string decayTime = std::to_string(std::get<1>(info.param));
391
392 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
393 descriptor.common.name + "_UUID_" +
394 descriptor.common.id.uuid.toString() + "_decayTime" + decayTime;
395 std::replace_if(
396 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
397 return name;
398 });
399GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDecayTimeTest);
400
401class EnvironmentalReverbDecayHfRatioTest
402 : public ::testing::TestWithParam<
403 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
404 public EnvironmentalReverbHelper {
405 public:
406 EnvironmentalReverbDecayHfRatioTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
407 mDecayHfRatio = std::get<1>(GetParam());
408 }
409
410 void SetUp() override { SetUpReverb(); }
411
412 void TearDown() override { TearDownReverb(); }
413};
414
415TEST_P(EnvironmentalReverbDecayHfRatioTest, SetAndGetDecayHfRatio) {
416 EXPECT_NO_FATAL_FAILURE(addDecayHfRatioParam(mDecayHfRatio));
417 SetAndGetReverbParameters();
418}
419
420INSTANTIATE_TEST_SUITE_P(
421 EnvironmentalReverbTest, EnvironmentalReverbDecayHfRatioTest,
422 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
423 IFactory::descriptor, kEnvReverbTypeUUID)),
424 testing::ValuesIn(kDecayHfRatioValues)),
425 [](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
426 auto descriptor = std::get<0>(info.param).second;
427 std::string decayHfRatio = std::to_string(std::get<1>(info.param));
428
429 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
430 descriptor.common.name + "_UUID_" +
431 descriptor.common.id.uuid.toString() + "_decayHfRatio" +
432 decayHfRatio;
433 std::replace_if(
434 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
435 return name;
436 });
437GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDecayHfRatioTest);
438
439class EnvironmentalReverbLevelTest
440 : public ::testing::TestWithParam<
441 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
442 public EnvironmentalReverbHelper {
443 public:
444 EnvironmentalReverbLevelTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
445 mLevel = std::get<1>(GetParam());
446 }
447
448 void SetUp() override { SetUpReverb(); }
449
450 void TearDown() override { TearDownReverb(); }
451};
452
453TEST_P(EnvironmentalReverbLevelTest, SetAndGetLevel) {
454 EXPECT_NO_FATAL_FAILURE(addLevelParam(mLevel));
455 SetAndGetReverbParameters();
456}
457
458INSTANTIATE_TEST_SUITE_P(
459 EnvironmentalReverbTest, EnvironmentalReverbLevelTest,
460 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
461 IFactory::descriptor, kEnvReverbTypeUUID)),
462 testing::ValuesIn(kLevelValues)),
463 [](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
464 auto descriptor = std::get<0>(info.param).second;
465 std::string level = std::to_string(std::get<1>(info.param));
466
467 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
468 descriptor.common.name + "_UUID_" +
469 descriptor.common.id.uuid.toString() + "_level" + level;
470 std::replace_if(
471 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
472 return name;
473 });
474GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbLevelTest);
475
476class EnvironmentalReverbDelayTest
477 : public ::testing::TestWithParam<
478 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
479 public EnvironmentalReverbHelper {
480 public:
481 EnvironmentalReverbDelayTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
482 mDelay = std::get<1>(GetParam());
483 }
484
485 void SetUp() override { SetUpReverb(); }
486
487 void TearDown() override { TearDownReverb(); }
488};
489
490TEST_P(EnvironmentalReverbDelayTest, SetAndGetDelay) {
491 EXPECT_NO_FATAL_FAILURE(addDelayParam(mDelay));
492 SetAndGetReverbParameters();
493}
494
495INSTANTIATE_TEST_SUITE_P(
496 EnvironmentalReverbTest, EnvironmentalReverbDelayTest,
497 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
498 IFactory::descriptor, kEnvReverbTypeUUID)),
499 testing::ValuesIn(kDelayValues)),
500 [](const testing::TestParamInfo<EnvironmentalReverbDelayTest::ParamType>& info) {
501 auto descriptor = std::get<0>(info.param).second;
502 std::string delay = std::to_string(std::get<1>(info.param));
503
504 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
505 descriptor.common.name + "_UUID_" +
506 descriptor.common.id.uuid.toString() + "_delay" + delay;
507 std::replace_if(
508 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
509 return name;
510 });
511GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDelayTest);
512
513class EnvironmentalReverbDiffusionTest
514 : public ::testing::TestWithParam<
515 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
516 public EnvironmentalReverbHelper {
517 public:
518 EnvironmentalReverbDiffusionTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
519 mDiffusion = std::get<1>(GetParam());
520 }
521
522 void SetUp() override { SetUpReverb(); }
523
524 void TearDown() override { TearDownReverb(); }
525};
526
527TEST_P(EnvironmentalReverbDiffusionTest, SetAndGetDiffusion) {
528 EXPECT_NO_FATAL_FAILURE(addDiffusionParam(mDiffusion));
529 SetAndGetReverbParameters();
530}
531
532INSTANTIATE_TEST_SUITE_P(
533 EnvironmentalReverbTest, EnvironmentalReverbDiffusionTest,
534 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
535 IFactory::descriptor, kEnvReverbTypeUUID)),
536 testing::ValuesIn(kDiffusionValues)),
537 [](const testing::TestParamInfo<EnvironmentalReverbDiffusionTest::ParamType>& info) {
538 auto descriptor = std::get<0>(info.param).second;
539 std::string diffusion = std::to_string(std::get<1>(info.param));
540
541 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
542 descriptor.common.name + "_UUID_" +
543 descriptor.common.id.uuid.toString() + "_diffusion" + diffusion;
544 std::replace_if(
545 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
546 return name;
547 });
548GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDiffusionTest);
549
550class EnvironmentalReverbDensityTest
551 : public ::testing::TestWithParam<
552 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>>,
553 public EnvironmentalReverbHelper {
554 public:
555 EnvironmentalReverbDensityTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
556 mDensity = std::get<1>(GetParam());
557 }
558
559 void SetUp() override { SetUpReverb(); }
560
561 void TearDown() override { TearDownReverb(); }
562};
563
564TEST_P(EnvironmentalReverbDensityTest, SetAndGetDensity) {
565 EXPECT_NO_FATAL_FAILURE(addDensityParam(mDensity));
566 SetAndGetReverbParameters();
567}
568
569INSTANTIATE_TEST_SUITE_P(
570 EnvironmentalReverbTest, EnvironmentalReverbDensityTest,
571 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
572 IFactory::descriptor, kEnvReverbTypeUUID)),
573 testing::ValuesIn(kDensityValues)),
574 [](const testing::TestParamInfo<EnvironmentalReverbDensityTest::ParamType>& info) {
575 auto descriptor = std::get<0>(info.param).second;
576 std::string density = std::to_string(std::get<1>(info.param));
577
578 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
579 descriptor.common.name + "_UUID_" +
580 descriptor.common.id.uuid.toString() + "_density" + density;
581 std::replace_if(
582 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
583 return name;
584 });
585GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbDensityTest);
586
587class EnvironmentalReverbBypassTest
588 : public ::testing::TestWithParam<
589 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, bool>>,
590 public EnvironmentalReverbHelper {
591 public:
592 EnvironmentalReverbBypassTest() : EnvironmentalReverbHelper(std::get<0>(GetParam())) {
593 mBypass = std::get<1>(GetParam());
594 }
595
596 void SetUp() override { SetUpReverb(); }
597
598 void TearDown() override { TearDownReverb(); }
599};
600
601TEST_P(EnvironmentalReverbBypassTest, SetAndGetBypass) {
602 EXPECT_NO_FATAL_FAILURE(addBypassParam(mBypass));
603 SetAndGetReverbParameters();
604}
605
606INSTANTIATE_TEST_SUITE_P(
607 EnvironmentalReverbTest, EnvironmentalReverbBypassTest,
608 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
609 IFactory::descriptor, kEnvReverbTypeUUID)),
610 testing::Bool()),
611 [](const testing::TestParamInfo<EnvironmentalReverbBypassTest::ParamType>& info) {
612 auto descriptor = std::get<0>(info.param).second;
613 std::string bypass = std::to_string(std::get<1>(info.param));
614
615 std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
616 descriptor.common.name + "_UUID_" +
617 descriptor.common.id.uuid.toString() + "_bypass" + bypass;
618 std::replace_if(
619 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
620 return name;
621 });
622GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EnvironmentalReverbBypassTest);
623
624int main(int argc, char** argv) {
625 ::testing::InitGoogleTest(&argc, argv);
626 ABinderProcess_setThreadPoolMaxThreadCount(1);
627 ABinderProcess_startThreadPool();
628 return RUN_ALL_TESTS();
629}