/* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "VtsHalAudioEffectTargetTest" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "AudioHalBinderServiceUtil.h" #include "EffectFactoryHelper.h" #include "EffectHelper.h" #include "TestUtils.h" using namespace android; using ndk::ScopedAStatus; using aidl::android::hardware::audio::effect::CommandId; using aidl::android::hardware::audio::effect::Descriptor; using aidl::android::hardware::audio::effect::IEffect; using aidl::android::hardware::audio::effect::IFactory; using aidl::android::hardware::audio::effect::Parameter; using aidl::android::hardware::audio::effect::State; using aidl::android::media::audio::common::AudioDeviceDescription; using aidl::android::media::audio::common::AudioDeviceType; using aidl::android::media::audio::common::AudioMode; using aidl::android::media::audio::common::AudioSource; enum ParamName { PARAM_INSTANCE_NAME }; using EffectTestParam = std::tuple, Descriptor>>; class AudioEffectTest : public testing::TestWithParam, public EffectHelper { public: AudioEffectTest() { std::tie(mFactory, mDescriptor) = std::get(GetParam()); } void SetUp() override {} void TearDown() override { // Do the cleanup for every test case if (mEffect) { ASSERT_NO_FATAL_FAILURE(commandIgnoreRet(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(closeIgnoreRet(mEffect)); ASSERT_NO_FATAL_FAILURE(destroyIgnoreRet(mFactory, mEffect)); mEffect.reset(); } } static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100; std::shared_ptr mFactory; std::shared_ptr mEffect; Descriptor mDescriptor; void setAndGetParameter(Parameter::Id id, const Parameter& set) { Parameter get; EXPECT_IS_OK(mEffect->setParameter(set)); EXPECT_IS_OK(mEffect->getParameter(id, &get)); EXPECT_EQ(set, get) << set.toString() << "\n vs \n" << get.toString(); } }; TEST_P(AudioEffectTest, SetupAndTearDown) { // Intentionally empty test body. } TEST_P(AudioEffectTest, CreateAndDestroy) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } TEST_P(AudioEffectTest, OpenAndClose) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } TEST_P(AudioEffectTest, CloseUnopenedEffect) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } TEST_P(AudioEffectTest, DoubleOpenAndClose) { std::shared_ptr effect1, effect2; ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mDescriptor)); ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(effect1)); ASSERT_NO_FATAL_FAILURE(open(effect2, 1 /* session */)); ASSERT_NO_FATAL_FAILURE(close(effect1)); ASSERT_NO_FATAL_FAILURE(close(effect2)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect1)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect2)); } TEST_P(AudioEffectTest, TripleOpenAndClose) { std::shared_ptr effect1, effect2, effect3; ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mDescriptor)); ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mDescriptor)); ASSERT_NO_FATAL_FAILURE(create(mFactory, effect3, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(effect1)); ASSERT_NO_FATAL_FAILURE(open(effect2, 1 /* session */)); ASSERT_NO_FATAL_FAILURE(open(effect3, 2 /* session */)); ASSERT_NO_FATAL_FAILURE(close(effect1)); ASSERT_NO_FATAL_FAILURE(close(effect2)); ASSERT_NO_FATAL_FAILURE(close(effect3)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect1)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect2)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect3)); } TEST_P(AudioEffectTest, GetDescritorBeforeOpen) { Descriptor desc; ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, desc)); EXPECT_EQ(mDescriptor.common.id.type, desc.common.id.type); EXPECT_EQ(mDescriptor.common.id.uuid, desc.common.id.uuid); EXPECT_EQ(mDescriptor.common.name, desc.common.name); EXPECT_EQ(mDescriptor.common.implementor, desc.common.implementor); // Effect implementation Must fill in implementor and name EXPECT_NE("", desc.common.name); EXPECT_NE("", desc.common.implementor); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } TEST_P(AudioEffectTest, GetDescritorAfterOpen) { Descriptor beforeOpen, afterOpen, afterClose; ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, beforeOpen)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, afterOpen)); EXPECT_EQ(beforeOpen.toString(), afterOpen.toString()) << "\n" << beforeOpen.toString() << "\n" << afterOpen.toString(); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, afterClose)); EXPECT_EQ(beforeOpen.toString(), afterClose.toString()) << "\n" << beforeOpen.toString() << "\n" << afterClose.toString(); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } TEST_P(AudioEffectTest, DescriptorExistAndUnique) { Descriptor desc; auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor); std::set idSet; for (const auto& it : descList) { auto& id = it.second.common.id; EXPECT_EQ(0ul, idSet.count(id)); idSet.insert(id); } ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, desc)); int uuidCount = std::count_if(idSet.begin(), idSet.end(), [&](const auto& id) { return id.uuid == desc.common.id.uuid && id.type == desc.common.id.type; }); EXPECT_EQ(1, uuidCount); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } /// State testing. // An effect instance is in INIT state by default after it was created. TEST_P(AudioEffectTest, InitStateAfterCreation) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // An effect instance transfer to IDLE state after IEffect.ASSERT_NO_FATAL_FAILURE(open(). TEST_P(AudioEffectTest, IdleStateAfterOpen) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // An effect instance is in PROCESSING state after it receive an START command. TEST_P(AudioEffectTest, ProcessingStateAfterStart) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // An effect instance transfer to IDLE state after Command.Id.STOP in PROCESSING state. TEST_P(AudioEffectTest, IdleStateAfterStop) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // An effect instance transfer to IDLE state after Command.Id.RESET in PROCESSING state. TEST_P(AudioEffectTest, IdleStateAfterReset) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // An effect instance transfer to INIT after IEffect.ASSERT_NO_FATAL_FAILURE(close(). TEST_P(AudioEffectTest, InitStateAfterClose) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // An effect instance shouldn't accept any command before open. TEST_P(AudioEffectTest, NoCommandAcceptedBeforeOpen) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START, EX_ILLEGAL_STATE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP, EX_ILLEGAL_STATE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET, EX_ILLEGAL_STATE)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // No-op when receive STOP command in IDLE state. TEST_P(AudioEffectTest, StopCommandInIdleStateNoOp) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // No-op when receive RESET command in IDLE state. TEST_P(AudioEffectTest, ResetCommandInIdleStateNoOp) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Repeat START and STOP command. TEST_P(AudioEffectTest, RepeatStartAndStop) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Repeat START and RESET command. TEST_P(AudioEffectTest, RepeatStartAndReset) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Try to close an effect instance at PROCESSING state. TEST_P(AudioEffectTest, CloseProcessingStateEffects) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(close(mEffect, EX_ILLEGAL_STATE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Expect EX_ILLEGAL_STATE if the effect instance is not in a proper state to be destroyed. TEST_P(AudioEffectTest, DestroyOpenEffects) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect, EX_ILLEGAL_STATE)); // cleanup ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Expect EX_ILLEGAL_STATE if the effect instance is not in a proper state to be destroyed. TEST_P(AudioEffectTest, DestroyProcessingEffects) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect, EX_ILLEGAL_STATE)); // cleanup ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } TEST_P(AudioEffectTest, NormalSequenceStates) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } /// Parameter testing. // Verify parameters pass in open can be successfully get. TEST_P(AudioEffectTest, VerifyCommonParametersAfterOpen) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); Parameter::Common common = EffectHelper::createParamCommon(); IEffect::OpenEffectReturn ret; ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE)); Parameter get = Parameter(), expect = Parameter(); expect.set(common); Parameter::Id id; id.set(Parameter::common); EXPECT_IS_OK(mEffect->getParameter(id, &get)); EXPECT_EQ(expect, get) << expect.toString() << "\n vs \n" << get.toString(); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Verify parameters pass in set can be successfully get. TEST_P(AudioEffectTest, SetAndGetCommonParameter) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */); Parameter::Id id = Parameter::Id::make(Parameter::common); ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make(common))); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Verify parameters set and get in PROCESSING state. TEST_P(AudioEffectTest, SetAndGetParameterInProcessing) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */); Parameter::Id id = Parameter::Id::make(Parameter::common); ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make(common))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Verify parameters set and get in IDLE state. TEST_P(AudioEffectTest, SetAndGetParameterInIdle) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */); Parameter::Id id = Parameter::Id::make(Parameter::common); ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make(common))); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Verify Parameters kept after stop. TEST_P(AudioEffectTest, SetAndGetParameterAfterStop) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */); Parameter::Id id = Parameter::Id::make(Parameter::common); ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make(common))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Verify Parameters kept after reset. TEST_P(AudioEffectTest, SetAndGetParameterAfterReset) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */); Parameter::Id id = Parameter::Id::make(Parameter::common); ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make(common))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make(common))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Set and get AudioDeviceDescription in Parameter TEST_P(AudioEffectTest, SetAndGetParameterDeviceDescription) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); std::vector deviceDescs = { {.type = AudioDeviceType::IN_DEFAULT, .connection = AudioDeviceDescription::CONNECTION_ANALOG}, {.type = AudioDeviceType::IN_DEVICE, .connection = AudioDeviceDescription::CONNECTION_BT_A2DP}}; Parameter::Id id = Parameter::Id::make(Parameter::deviceDescription); ASSERT_NO_FATAL_FAILURE( setAndGetParameter(id, Parameter::make(deviceDescs))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Set and get AudioMode in Parameter TEST_P(AudioEffectTest, SetAndGetParameterAudioMode) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); Parameter::Id id = Parameter::Id::make(Parameter::mode); ASSERT_NO_FATAL_FAILURE( setAndGetParameter(id, Parameter::make(AudioMode::NORMAL))); ASSERT_NO_FATAL_FAILURE( setAndGetParameter(id, Parameter::make(AudioMode::IN_COMMUNICATION))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Set and get AudioSource in Parameter TEST_P(AudioEffectTest, SetAndGetParameterAudioSource) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); Parameter::Id id = Parameter::Id::make(Parameter::source); ASSERT_NO_FATAL_FAILURE( setAndGetParameter(id, Parameter::make(AudioSource::DEFAULT))); ASSERT_NO_FATAL_FAILURE(setAndGetParameter( id, Parameter::make(AudioSource::VOICE_RECOGNITION))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Set and get VolumeStereo in Parameter TEST_P(AudioEffectTest, SetAndGetParameterVolume) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); ASSERT_NO_FATAL_FAILURE(open(mEffect)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); Parameter::Id id = Parameter::Id::make(Parameter::volumeStereo); Parameter::VolumeStereo volume = {.left = 10.0, .right = 10.0}; ASSERT_NO_FATAL_FAILURE( setAndGetParameter(id, Parameter::make(volume))); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } /// Data processing test // Send data to effects and expect it to be consumed by checking statusMQ. TEST_P(AudioEffectTest, ConsumeDataInProcessingState) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); IEffect::OpenEffectReturn ret; ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE)); auto statusMQ = std::make_unique(ret.statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique(ret.inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique(ret.outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); std::vector buffer; EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Send data to effects and expect it to be consumed after effect restart. TEST_P(AudioEffectTest, ConsumeDataAfterRestart) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); IEffect::OpenEffectReturn ret; ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE)); auto statusMQ = std::make_unique(ret.statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique(ret.inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique(ret.outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); std::vector buffer; ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 0, outputMQ, buffer.size(), buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Send data to IDLE effects and expect it to be consumed after effect start. TEST_P(AudioEffectTest, SendDataAtIdleAndConsumeDataInProcessing) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); IEffect::OpenEffectReturn ret; ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE)); auto statusMQ = std::make_unique(ret.statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique(ret.inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique(ret.outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); std::vector buffer; EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Send data multiple times. TEST_P(AudioEffectTest, ProcessDataMultipleTimes) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); IEffect::OpenEffectReturn ret; ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE)); auto statusMQ = std::make_unique(ret.statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique(ret.inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique(ret.outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); std::vector buffer; EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Send data to processing state effects, stop, and restart. TEST_P(AudioEffectTest, ConsumeDataAndRestart) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); IEffect::OpenEffectReturn ret; ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE)); auto statusMQ = std::make_unique(ret.statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique(ret.inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique(ret.outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); std::vector buffer; EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer)); ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Send data to closed effects and expect it not be consumed. TEST_P(AudioEffectTest, NotConsumeDataByClosedEffect) { ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor)); Parameter::Common common = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); IEffect::OpenEffectReturn ret; ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE)); ASSERT_NO_FATAL_FAILURE(close(mEffect)); auto statusMQ = std::make_unique(ret.statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique(ret.inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique(ret.outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); std::vector buffer; EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect)); } // Send data to multiple effects. TEST_P(AudioEffectTest, ConsumeDataMultipleEffects) { std::shared_ptr effect1, effect2; ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mDescriptor)); ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mDescriptor)); Parameter::Common common1 = EffectHelper::createParamCommon( 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */, kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */); Parameter::Common common2 = EffectHelper::createParamCommon( 1 /* session */, 1 /* ioHandle */, 48000 /* iSampleRate */, 48000 /* oSampleRate */, 2 * kInputFrameCount /* iFrameCount */, 2 * kOutputFrameCount /* oFrameCount */); IEffect::OpenEffectReturn ret1, ret2; ASSERT_NO_FATAL_FAILURE(open(effect1, common1, std::nullopt /* specific */, &ret1, EX_NONE)); ASSERT_NO_FATAL_FAILURE(open(effect2, common2, std::nullopt /* specific */, &ret2, EX_NONE)); ASSERT_NO_FATAL_FAILURE(command(effect1, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(effect1, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(effect2, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(effect2, State::PROCESSING)); auto statusMQ1 = std::make_unique(ret1.statusMQ); ASSERT_TRUE(statusMQ1->isValid()); auto inputMQ1 = std::make_unique(ret1.inputDataMQ); ASSERT_TRUE(inputMQ1->isValid()); auto outputMQ1 = std::make_unique(ret1.outputDataMQ); ASSERT_TRUE(outputMQ1->isValid()); std::vector buffer1, buffer2; EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common1, inputMQ1, buffer1)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ1, inputMQ1, buffer1)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ1, 1, outputMQ1, buffer1.size(), buffer1)); auto statusMQ2 = std::make_unique(ret2.statusMQ); ASSERT_TRUE(statusMQ2->isValid()); auto inputMQ2 = std::make_unique(ret2.inputDataMQ); ASSERT_TRUE(inputMQ2->isValid()); auto outputMQ2 = std::make_unique(ret2.outputDataMQ); ASSERT_TRUE(outputMQ2->isValid()); EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common2, inputMQ2, buffer2)); EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ2, inputMQ2, buffer2)); EXPECT_NO_FATAL_FAILURE( EffectHelper::readFromFmq(statusMQ2, 1, outputMQ2, buffer2.size(), buffer2)); ASSERT_NO_FATAL_FAILURE(command(effect1, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(effect1, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(effect1)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect1)); ASSERT_NO_FATAL_FAILURE(command(effect2, CommandId::STOP)); ASSERT_NO_FATAL_FAILURE(expectState(effect2, State::IDLE)); ASSERT_NO_FATAL_FAILURE(close(effect2)); ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect2)); } INSTANTIATE_TEST_SUITE_P( SingleEffectInstanceTest, AudioEffectTest, ::testing::Combine(testing::ValuesIn( EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor))), [](const testing::TestParamInfo& info) { auto descriptor = std::get(info.param).second; std::string name = "Implementor_" + descriptor.common.implementor + "_name_" + descriptor.common.name + "_TYPE_" + descriptor.common.id.type.toString() + "_UUID_" + descriptor.common.id.uuid.toString(); std::replace_if( name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_'); return name; }); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioEffectTest); int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); ABinderProcess_setThreadPoolMaxThreadCount(1); ABinderProcess_startThreadPool(); return RUN_ALL_TESTS(); }