blob: 23b20bd1fbf2aed322c7b5d44b9d1352bcd4ffa4 [file] [log] [blame]
Shunkai Yao67b1be62022-07-13 05:01:42 +00001/*
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
Shunkai Yao45905172022-08-24 18:14:02 +000017#include <memory>
Shunkai Yao67b1be62022-07-13 05:01:42 +000018#include <string>
Shunkai Yao45905172022-08-24 18:14:02 +000019#include <unordered_map>
20#include <unordered_set>
21#include <vector>
Shunkai Yao67b1be62022-07-13 05:01:42 +000022
23#define LOG_TAG "VtsHalAudioEffect"
24
25#include <aidl/Gtest.h>
26#include <aidl/Vintf.h>
27#include <android-base/logging.h>
28#include <android-base/properties.h>
29#include <android/binder_interface_utils.h>
30#include <android/binder_manager.h>
31#include <android/binder_process.h>
32
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000033#include <aidl/android/hardware/audio/effect/IEffect.h>
Shunkai Yao67b1be62022-07-13 05:01:42 +000034#include <aidl/android/hardware/audio/effect/IFactory.h>
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000035#include <aidl/android/media/audio/common/AudioChannelLayout.h>
36#include <aidl/android/media/audio/common/AudioDeviceType.h>
Shunkai Yao67b1be62022-07-13 05:01:42 +000037
38#include "AudioHalBinderServiceUtil.h"
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000039#include "EffectFactoryHelper.h"
Shunkai Yao121c6dd2022-09-21 23:42:08 +000040#include "TestUtils.h"
Shunkai Yao67b1be62022-07-13 05:01:42 +000041
42using namespace android;
43
44using ndk::ScopedAStatus;
45
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000046using aidl::android::hardware::audio::effect::CommandId;
Shunkai Yao67b1be62022-07-13 05:01:42 +000047using aidl::android::hardware::audio::effect::Descriptor;
Shunkai Yao45905172022-08-24 18:14:02 +000048using aidl::android::hardware::audio::effect::IEffect;
Shunkai Yao67b1be62022-07-13 05:01:42 +000049using aidl::android::hardware::audio::effect::IFactory;
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000050using aidl::android::hardware::audio::effect::Parameter;
51using aidl::android::hardware::audio::effect::State;
52using aidl::android::media::audio::common::AudioChannelLayout;
53using aidl::android::media::audio::common::AudioDeviceType;
Shunkai Yao67b1be62022-07-13 05:01:42 +000054
Shunkai Yao45905172022-08-24 18:14:02 +000055class AudioEffect : public testing::TestWithParam<std::string> {
56 public:
57 void SetUp() override {
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000058 ASSERT_NO_FATAL_FAILURE(mFactoryHelper.ConnectToFactoryService());
59 CreateEffects();
60 initParamCommon();
61 initParamSpecific();
Shunkai Yao45905172022-08-24 18:14:02 +000062 }
63
64 void TearDown() override {
65 CloseEffects();
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000066 DestroyEffects();
Shunkai Yao45905172022-08-24 18:14:02 +000067 }
68
69 void OpenEffects() {
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000070 auto open = [&](const std::shared_ptr<IEffect>& effect) {
71 IEffect::OpenEffectReturn ret;
72 EXPECT_IS_OK(effect->open(mCommon, mSpecific, &ret));
73 };
Shunkai Yao45905172022-08-24 18:14:02 +000074 EXPECT_NO_FATAL_FAILURE(ForEachEffect(open));
75 }
76
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000077 void CloseEffects(const binder_status_t status = EX_NONE) {
78 auto close = [&](const std::shared_ptr<IEffect>& effect) {
79 EXPECT_STATUS(status, effect->close());
80 };
81
Shunkai Yao45905172022-08-24 18:14:02 +000082 EXPECT_NO_FATAL_FAILURE(ForEachEffect(close));
83 }
84
Shunkai Yaoea24c1a2022-09-28 17:39:23 +000085 void CreateEffects(const int n = 1) {
86 for (int i = 0; i < n; i++) {
87 ASSERT_NO_FATAL_FAILURE(mFactoryHelper.QueryAndCreateAllEffects());
88 }
89 }
90
91 void DestroyEffects(const binder_status_t status = EX_NONE, const int remaining = 0) {
92 ASSERT_NO_FATAL_FAILURE(mFactoryHelper.DestroyEffects(status, remaining));
93 }
94
Shunkai Yao45905172022-08-24 18:14:02 +000095 void GetEffectDescriptors() {
96 auto get = [](const std::shared_ptr<IEffect>& effect) {
97 Descriptor desc;
Shunkai Yao121c6dd2022-09-21 23:42:08 +000098 EXPECT_IS_OK(effect->getDescriptor(&desc));
Shunkai Yao45905172022-08-24 18:14:02 +000099 };
100 EXPECT_NO_FATAL_FAILURE(ForEachEffect(get));
101 }
102
Shunkai Yaoea24c1a2022-09-28 17:39:23 +0000103 void CommandEffects(CommandId command) {
104 auto close = [&](const std::shared_ptr<IEffect>& effect) {
105 EXPECT_IS_OK(effect->command(command));
106 };
107 EXPECT_NO_FATAL_FAILURE(ForEachEffect(close));
108 }
109
110 void CommandEffectsExpectStatus(CommandId command, const binder_status_t status) {
111 auto func = [&](const std::shared_ptr<IEffect>& effect) {
112 EXPECT_STATUS(status, effect->command(command));
113 };
114 EXPECT_NO_FATAL_FAILURE(ForEachEffect(func));
115 }
116
117 void ExpectState(State expected) {
118 auto get = [&](const std::shared_ptr<IEffect>& effect) {
119 State state = State::INIT;
120 EXPECT_IS_OK(effect->getState(&state));
121 EXPECT_EQ(expected, state);
122 };
123 EXPECT_NO_FATAL_FAILURE(ForEachEffect(get));
124 }
125
126 void SetParameter() {
127 auto func = [&](const std::shared_ptr<IEffect>& effect) {
128 Parameter param;
129 param.set<Parameter::common>(mCommon);
130 EXPECT_IS_OK(effect->setParameter(param));
131 };
132 EXPECT_NO_FATAL_FAILURE(ForEachEffect(func));
133 }
134
135 void VerifyParameters() {
136 auto func = [&](const std::shared_ptr<IEffect>& effect) {
137 Parameter paramCommonGet = Parameter(), paramCommonExpect = Parameter();
138 Parameter::Id id;
139 id.set<Parameter::Id::commonTag>(0);
140 paramCommonExpect.set<Parameter::common>(mCommon);
141 EXPECT_IS_OK(effect->getParameter(id, &paramCommonGet));
142 EXPECT_EQ(paramCommonExpect, paramCommonGet)
143 << paramCommonExpect.toString() << " vs " << paramCommonGet.toString();
144 };
145 EXPECT_NO_FATAL_FAILURE(ForEachEffect(func));
146 }
147
Shunkai Yao45905172022-08-24 18:14:02 +0000148 template <typename Functor>
149 void ForEachEffect(Functor functor) {
Shunkai Yaoea24c1a2022-09-28 17:39:23 +0000150 auto effectMap = mFactoryHelper.GetEffectMap();
Shunkai Yao45905172022-08-24 18:14:02 +0000151 for (const auto& it : effectMap) {
152 SCOPED_TRACE(it.second.toString());
153 functor(it.first);
154 }
155 }
156
Shunkai Yaoea24c1a2022-09-28 17:39:23 +0000157 void initParamCommon(int session = -1, int ioHandle = -1,
158 AudioDeviceType deviceType = AudioDeviceType::NONE,
159 int iSampleRate = 48000, int oSampleRate = 48000, long iFrameCount = 0x100,
160 long oFrameCount = 0x100) {
161 mCommon.session = session;
162 mCommon.ioHandle = ioHandle;
163 mCommon.device.type = deviceType;
164 mCommon.input.base.sampleRate = iSampleRate;
165 mCommon.input.base.channelMask = mInputChannelLayout;
166 mCommon.input.frameCount = iFrameCount;
167 mCommon.output.base.sampleRate = oSampleRate;
168 mCommon.output.base.channelMask = mOutputChannelLayout;
169 mCommon.output.frameCount = oFrameCount;
170 }
171
172 void initParamSpecific(Parameter::Specific::Tag tag = Parameter::Specific::equalizer) {
173 switch (tag) {
174 case Parameter::Specific::equalizer:
175 mSpecific.set<Parameter::Specific::equalizer>();
176 break;
177 default:
178 return;
179 }
180 }
181
182 void setInputChannelLayout(AudioChannelLayout input) { mInputChannelLayout = input; }
183 void setOutputChannelLayout(AudioChannelLayout output) { mOutputChannelLayout = output; }
184
185 EffectFactoryHelper mFactoryHelper = EffectFactoryHelper(GetParam());
186
187 private:
188 AudioChannelLayout mInputChannelLayout =
189 AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
190 AudioChannelLayout::LAYOUT_STEREO);
191 AudioChannelLayout mOutputChannelLayout =
192 AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
193 AudioChannelLayout::LAYOUT_STEREO);
194
195 Parameter::Common mCommon;
196 Parameter::Specific mSpecific;
197 static IEffect::OpenEffectReturn mOpenReturn;
Shunkai Yao45905172022-08-24 18:14:02 +0000198};
199
200TEST_P(AudioEffect, OpenEffectTest) {
201 EXPECT_NO_FATAL_FAILURE(OpenEffects());
202}
203
204TEST_P(AudioEffect, OpenAndCloseEffect) {
205 EXPECT_NO_FATAL_FAILURE(OpenEffects());
206 EXPECT_NO_FATAL_FAILURE(CloseEffects());
207}
208
209TEST_P(AudioEffect, CloseUnopenedEffectTest) {
210 EXPECT_NO_FATAL_FAILURE(CloseEffects());
211}
212
213TEST_P(AudioEffect, DoubleOpenCloseEffects) {
214 EXPECT_NO_FATAL_FAILURE(OpenEffects());
215 EXPECT_NO_FATAL_FAILURE(CloseEffects());
216 EXPECT_NO_FATAL_FAILURE(OpenEffects());
217 EXPECT_NO_FATAL_FAILURE(CloseEffects());
218
219 EXPECT_NO_FATAL_FAILURE(OpenEffects());
220 EXPECT_NO_FATAL_FAILURE(OpenEffects());
221 EXPECT_NO_FATAL_FAILURE(CloseEffects());
222
223 EXPECT_NO_FATAL_FAILURE(OpenEffects());
224 EXPECT_NO_FATAL_FAILURE(CloseEffects());
225 EXPECT_NO_FATAL_FAILURE(CloseEffects());
226}
227
228TEST_P(AudioEffect, GetDescriptors) {
229 EXPECT_NO_FATAL_FAILURE(GetEffectDescriptors());
230}
231
232TEST_P(AudioEffect, DescriptorIdExistAndUnique) {
233 auto checker = [&](const std::shared_ptr<IEffect>& effect) {
234 Descriptor desc;
235 std::vector<Descriptor::Identity> idList;
Shunkai Yao121c6dd2022-09-21 23:42:08 +0000236 EXPECT_IS_OK(effect->getDescriptor(&desc));
Shunkai Yaoea24c1a2022-09-28 17:39:23 +0000237 mFactoryHelper.QueryEffects(desc.common.id.type, desc.common.id.uuid, &idList);
Shunkai Yao121c6dd2022-09-21 23:42:08 +0000238 EXPECT_EQ(idList.size(), 1UL);
Shunkai Yao45905172022-08-24 18:14:02 +0000239 };
240 EXPECT_NO_FATAL_FAILURE(ForEachEffect(checker));
241
242 // Check unique with a set
243 auto stringHash = [](const Descriptor::Identity& id) {
244 return std::hash<std::string>()(id.toString());
245 };
Shunkai Yaoea24c1a2022-09-28 17:39:23 +0000246 auto vec = mFactoryHelper.GetCompleteEffectIdList();
Shunkai Yao45905172022-08-24 18:14:02 +0000247 std::unordered_set<Descriptor::Identity, decltype(stringHash)> idSet(0, stringHash);
248 for (auto it : vec) {
Shunkai Yao121c6dd2022-09-21 23:42:08 +0000249 EXPECT_EQ(idSet.count(it), 0UL);
Shunkai Yao45905172022-08-24 18:14:02 +0000250 idSet.insert(it);
251 }
252}
253
Shunkai Yaoea24c1a2022-09-28 17:39:23 +0000254/// State testing.
255// An effect instance is in INIT state by default after it was created.
256TEST_P(AudioEffect, InitStateAfterCreation) {
257 ExpectState(State::INIT);
258}
259
260// An effect instance transfer to INIT state after it was open successfully with IEffect.open().
261TEST_P(AudioEffect, IdleStateAfterOpen) {
262 EXPECT_NO_FATAL_FAILURE(OpenEffects());
263 ExpectState(State::IDLE);
264 EXPECT_NO_FATAL_FAILURE(CloseEffects());
265}
266
267// An effect instance is in PROCESSING state after it receive an START command.
268TEST_P(AudioEffect, ProcessingStateAfterStart) {
269 EXPECT_NO_FATAL_FAILURE(OpenEffects());
270 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
271 ExpectState(State::PROCESSING);
272 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
273 EXPECT_NO_FATAL_FAILURE(CloseEffects());
274}
275
276// An effect instance transfer to IDLE state after Command.Id.STOP in PROCESSING state.
277TEST_P(AudioEffect, IdleStateAfterStop) {
278 EXPECT_NO_FATAL_FAILURE(OpenEffects());
279 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
280 ExpectState(State::PROCESSING);
281 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
282 ExpectState(State::IDLE);
283 EXPECT_NO_FATAL_FAILURE(CloseEffects());
284}
285
286// An effect instance transfer to IDLE state after Command.Id.RESET in PROCESSING state.
287TEST_P(AudioEffect, IdleStateAfterReset) {
288 EXPECT_NO_FATAL_FAILURE(OpenEffects());
289 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
290 ExpectState(State::PROCESSING);
291 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
292 ExpectState(State::IDLE);
293 EXPECT_NO_FATAL_FAILURE(CloseEffects());
294}
295
296// An effect instance transfer to INIT if instance receive a close() call.
297TEST_P(AudioEffect, InitStateAfterClose) {
298 EXPECT_NO_FATAL_FAILURE(OpenEffects());
299 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
300 ExpectState(State::PROCESSING);
301 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
302 ExpectState(State::IDLE);
303 EXPECT_NO_FATAL_FAILURE(CloseEffects());
304 ExpectState(State::INIT);
305}
306
307// An effect instance shouldn't accept any command before open.
308TEST_P(AudioEffect, NoCommandAcceptedBeforeOpen) {
309 ExpectState(State::INIT);
310 EXPECT_NO_FATAL_FAILURE(CommandEffectsExpectStatus(CommandId::START, EX_ILLEGAL_STATE));
311 EXPECT_NO_FATAL_FAILURE(CommandEffectsExpectStatus(CommandId::STOP, EX_ILLEGAL_STATE));
312 EXPECT_NO_FATAL_FAILURE(CommandEffectsExpectStatus(CommandId::RESET, EX_ILLEGAL_STATE));
313 ExpectState(State::INIT);
314}
315
316// No-op when receive STOP command in IDLE state.
317TEST_P(AudioEffect, StopCommandInIdleStateNoOp) {
318 ExpectState(State::INIT);
319 EXPECT_NO_FATAL_FAILURE(OpenEffects());
320 ExpectState(State::IDLE);
321 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
322 ExpectState(State::IDLE);
323 EXPECT_NO_FATAL_FAILURE(CloseEffects());
324}
325
326// No-op when receive STOP command in IDLE state.
327TEST_P(AudioEffect, ResetCommandInIdleStateNoOp) {
328 ExpectState(State::INIT);
329 EXPECT_NO_FATAL_FAILURE(OpenEffects());
330 ExpectState(State::IDLE);
331 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
332 ExpectState(State::IDLE);
333 EXPECT_NO_FATAL_FAILURE(CloseEffects());
334}
335
336// Repeat START and STOP command.
337TEST_P(AudioEffect, RepeatStartAndStop) {
338 EXPECT_NO_FATAL_FAILURE(OpenEffects());
339 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
340 ExpectState(State::PROCESSING);
341 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
342 ExpectState(State::IDLE);
343 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
344 ExpectState(State::PROCESSING);
345 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
346 ExpectState(State::IDLE);
347 EXPECT_NO_FATAL_FAILURE(CloseEffects());
348}
349
350// Repeat START and RESET command.
351TEST_P(AudioEffect, RepeatStartAndReset) {
352 EXPECT_NO_FATAL_FAILURE(OpenEffects());
353 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
354 ExpectState(State::PROCESSING);
355 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
356 ExpectState(State::IDLE);
357 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
358 ExpectState(State::PROCESSING);
359 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
360 ExpectState(State::IDLE);
361 EXPECT_NO_FATAL_FAILURE(CloseEffects());
362}
363
364// Repeat START and STOP command, try to close at PROCESSING state.
365TEST_P(AudioEffect, CloseProcessingStateEffects) {
366 EXPECT_NO_FATAL_FAILURE(OpenEffects());
367 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
368 ExpectState(State::PROCESSING);
369 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
370 ExpectState(State::IDLE);
371 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
372 ExpectState(State::PROCESSING);
373 EXPECT_NO_FATAL_FAILURE(CloseEffects(EX_ILLEGAL_STATE));
374 // cleanup
375 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
376 ExpectState(State::IDLE);
377}
378
379// Expect EX_ILLEGAL_STATE if the effect instance is not in a proper state to be destroyed.
380TEST_P(AudioEffect, DestroyOpenEffects) {
381 // cleanup all effects.
382 EXPECT_NO_FATAL_FAILURE(CloseEffects());
383 ASSERT_NO_FATAL_FAILURE(DestroyEffects());
384
385 // open effects, destroy without close, expect to get EX_ILLEGAL_STATE status.
386 EXPECT_NO_FATAL_FAILURE(CreateEffects());
387 EXPECT_NO_FATAL_FAILURE(OpenEffects());
388 EXPECT_NO_FATAL_FAILURE(DestroyEffects(EX_ILLEGAL_STATE, 1));
389 EXPECT_NO_FATAL_FAILURE(CloseEffects());
390}
391
392/// Parameter testing.
393// Verify parameters pass in open can be successfully get.
394TEST_P(AudioEffect, VerifyParametersAfterOpen) {
395 EXPECT_NO_FATAL_FAILURE(OpenEffects());
396 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
397 EXPECT_NO_FATAL_FAILURE(CloseEffects());
398}
399
400// Verify parameters pass in set can be successfully get.
401TEST_P(AudioEffect, SetAndGetParameter) {
402 EXPECT_NO_FATAL_FAILURE(OpenEffects());
403 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
404 initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
405 44100 /* iSampleRate */, 44100 /* oSampleRate */);
406 EXPECT_NO_FATAL_FAILURE(SetParameter());
407 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
408 EXPECT_NO_FATAL_FAILURE(CloseEffects());
409}
410
411// Verify parameters pass in set can be successfully get.
412TEST_P(AudioEffect, SetAndGetParameterInProcessing) {
413 EXPECT_NO_FATAL_FAILURE(OpenEffects());
414 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
415 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
416 ExpectState(State::PROCESSING);
417 initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
418 44100 /* iSampleRate */, 44100 /* oSampleRate */);
419 EXPECT_NO_FATAL_FAILURE(SetParameter());
420 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
421 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
422 ExpectState(State::IDLE);
423 EXPECT_NO_FATAL_FAILURE(CloseEffects());
424}
425
426// Parameters kept after reset.
427TEST_P(AudioEffect, ResetAndVerifyParameter) {
428 EXPECT_NO_FATAL_FAILURE(OpenEffects());
429 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
430 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
431 ExpectState(State::PROCESSING);
432 initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
433 44100 /* iSampleRate */, 44100 /* oSampleRate */);
434 EXPECT_NO_FATAL_FAILURE(SetParameter());
435 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
436 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::RESET));
437 ExpectState(State::IDLE);
438 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
439 EXPECT_NO_FATAL_FAILURE(CloseEffects());
440}
441
442// Multiple instances of same implementation running.
443TEST_P(AudioEffect, MultipleInstancesRunning) {
444 EXPECT_NO_FATAL_FAILURE(CreateEffects(3));
445 ExpectState(State::INIT);
446 EXPECT_NO_FATAL_FAILURE(OpenEffects());
447 ExpectState(State::IDLE);
448 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::START));
449 ExpectState(State::PROCESSING);
450 initParamCommon(1 /* session */, 1 /* ioHandle */, AudioDeviceType::IN_DEFAULT /* deviceType */,
451 44100 /* iSampleRate */, 44100 /* oSampleRate */);
452 EXPECT_NO_FATAL_FAILURE(SetParameter());
453 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
454 EXPECT_NO_FATAL_FAILURE(CommandEffects(CommandId::STOP));
455 ExpectState(State::IDLE);
456 EXPECT_NO_FATAL_FAILURE(VerifyParameters());
457 EXPECT_NO_FATAL_FAILURE(CloseEffects());
458}
459
Shunkai Yao45905172022-08-24 18:14:02 +0000460INSTANTIATE_TEST_SUITE_P(AudioEffectTest, AudioEffect,
461 testing::ValuesIn(android::getAidlHalInstanceNames(IFactory::descriptor)),
462 android::PrintInstanceNameToString);
463GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioEffect);
Shunkai Yao67b1be62022-07-13 05:01:42 +0000464
465int main(int argc, char** argv) {
466 ::testing::InitGoogleTest(&argc, argv);
467 ABinderProcess_setThreadPoolMaxThreadCount(1);
468 ABinderProcess_startThreadPool();
469 return RUN_ALL_TESTS();
Shunkai Yao45905172022-08-24 18:14:02 +0000470}