Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83dcb849 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I34db56fe,I539b408f,I76155f89 into udc-qpr-dev

* changes:
  Effect AIDL: correct some code format
  Effect AIDL: Skipping vts test case if its not supported by effect
  vts: Don't excercise data path for offloaded/bypass effects
parents 149c988c 97edf605
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -77,3 +77,10 @@ inline ::testing::AssertionResult assertResult(const char* exp_expr, const char*
#define EXPECT_STATUS(expected, ret)                                                       \
    EXPECT_PRED_FORMAT2(::android::hardware::audio::common::testing::detail::assertResult, \
                        expected, ret)

#define SKIP_TEST_IF_DATA_UNSUPPORTED(flags)                                                     \
    ({                                                                                           \
        if ((flags).hwAcceleratorMode == Flags::HardwareAccelerator::TUNNEL || (flags).bypass) { \
            GTEST_SKIP() << "Skip data path for offload";                                        \
        }                                                                                        \
    })
 No newline at end of file
+57 −7
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ using ndk::ScopedAStatus;

using aidl::android::hardware::audio::effect::CommandId;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::Flags;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::Parameter;
@@ -85,6 +86,14 @@ class AudioEffectTest : public testing::TestWithParam<EffectTestParam>, public E
    }
};

class AudioEffectDataPathTest : public AudioEffectTest {
  public:
    void SetUp() override {
        AudioEffectTest::SetUp();
        SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
    }
};

TEST_P(AudioEffectTest, SetupAndTearDown) {
    // Intentionally empty test body.
}
@@ -495,6 +504,11 @@ TEST_P(AudioEffectTest, SetAndGetParameterAfterReset) {

// Set and get AudioDeviceDescription in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterDeviceDescription) {
    if (!mDescriptor.common.flags.deviceIndication) {
        GTEST_SKIP() << "Skipping test as effect does not support deviceIndication"
                     << mDescriptor.common.flags.toString();
    }

    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
    ASSERT_NO_FATAL_FAILURE(open(mEffect));

@@ -518,6 +532,11 @@ TEST_P(AudioEffectTest, SetAndGetParameterDeviceDescription) {

// Set and get AudioMode in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterAudioMode) {
    if (!mDescriptor.common.flags.audioModeIndication) {
        GTEST_SKIP() << "Skipping test as effect does not support audioModeIndication"
                     << mDescriptor.common.flags.toString();
    }

    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
    ASSERT_NO_FATAL_FAILURE(open(mEffect));

@@ -538,6 +557,11 @@ TEST_P(AudioEffectTest, SetAndGetParameterAudioMode) {

// Set and get AudioSource in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterAudioSource) {
    if (!mDescriptor.common.flags.audioSourceIndication) {
        GTEST_SKIP() << "Skipping test as effect does not support audioSourceIndication"
                     << mDescriptor.common.flags.toString();
    }

    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
    ASSERT_NO_FATAL_FAILURE(open(mEffect));

@@ -558,6 +582,11 @@ TEST_P(AudioEffectTest, SetAndGetParameterAudioSource) {

// Set and get VolumeStereo in Parameter
TEST_P(AudioEffectTest, SetAndGetParameterVolume) {
    if (mDescriptor.common.flags.volume == Flags::Volume::NONE) {
        GTEST_SKIP() << "Skipping test as effect does not support volume"
                     << mDescriptor.common.flags.toString();
    }

    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
    ASSERT_NO_FATAL_FAILURE(open(mEffect));

@@ -577,7 +606,8 @@ TEST_P(AudioEffectTest, SetAndGetParameterVolume) {

/// Data processing test
// Send data to effects and expect it to be consumed by checking statusMQ.
TEST_P(AudioEffectTest, ConsumeDataInProcessingState) {
// Effects exposing bypass flags or operating in offload mode will be skipped.
TEST_P(AudioEffectDataPathTest, ConsumeDataInProcessingState) {
    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

    Parameter::Common common = EffectHelper::createParamCommon(
@@ -610,7 +640,8 @@ TEST_P(AudioEffectTest, ConsumeDataInProcessingState) {
}

// Send data to effects and expect it to be consumed after effect restart.
TEST_P(AudioEffectTest, ConsumeDataAfterRestart) {
// Effects exposing bypass flags or operating in offload mode will be skipped.
TEST_P(AudioEffectDataPathTest, ConsumeDataAfterRestart) {
    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

    Parameter::Common common = EffectHelper::createParamCommon(
@@ -649,7 +680,8 @@ TEST_P(AudioEffectTest, ConsumeDataAfterRestart) {
}

// Send data to IDLE effects and expect it to be consumed after effect start.
TEST_P(AudioEffectTest, SendDataAtIdleAndConsumeDataInProcessing) {
// Effects exposing bypass flags or operating in offload mode will be skipped.
TEST_P(AudioEffectDataPathTest, SendDataAtIdleAndConsumeDataInProcessing) {
    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

    Parameter::Common common = EffectHelper::createParamCommon(
@@ -682,7 +714,8 @@ TEST_P(AudioEffectTest, SendDataAtIdleAndConsumeDataInProcessing) {
}

// Send data multiple times.
TEST_P(AudioEffectTest, ProcessDataMultipleTimes) {
// Effects exposing bypass flags or operating in offload mode will be skipped.
TEST_P(AudioEffectDataPathTest, ProcessDataMultipleTimes) {
    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

    Parameter::Common common = EffectHelper::createParamCommon(
@@ -721,7 +754,8 @@ TEST_P(AudioEffectTest, ProcessDataMultipleTimes) {
}

// Send data to processing state effects, stop, and restart.
TEST_P(AudioEffectTest, ConsumeDataAndRestart) {
// Effects exposing bypass flags or operating in offload mode will be skipped.
TEST_P(AudioEffectDataPathTest, ConsumeDataAndRestart) {
    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

    Parameter::Common common = EffectHelper::createParamCommon(
@@ -762,7 +796,8 @@ TEST_P(AudioEffectTest, ConsumeDataAndRestart) {
}

// Send data to closed effects and expect it not be consumed.
TEST_P(AudioEffectTest, NotConsumeDataByClosedEffect) {
// Effects exposing bypass flags or operating in offload mode will be skipped.
TEST_P(AudioEffectDataPathTest, NotConsumeDataByClosedEffect) {
    ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));

    Parameter::Common common = EffectHelper::createParamCommon(
@@ -788,7 +823,8 @@ TEST_P(AudioEffectTest, NotConsumeDataByClosedEffect) {
}

// Send data to multiple effects.
TEST_P(AudioEffectTest, ConsumeDataMultipleEffects) {
// Effects exposing bypass flags or operating in offload mode will be skipped.
TEST_P(AudioEffectDataPathTest, ConsumeDataMultipleEffects) {
    std::shared_ptr<IEffect> effect1, effect2;
    ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mDescriptor));
    ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mDescriptor));
@@ -855,6 +891,20 @@ INSTANTIATE_TEST_SUITE_P(
        });
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioEffectTest);

INSTANTIATE_TEST_SUITE_P(
        SingleEffectInstanceTest, AudioEffectDataPathTest,
        ::testing::Combine(testing::ValuesIn(
                EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor))),
        [](const testing::TestParamInfo<AudioEffectDataPathTest::ParamType>& info) {
            auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
            std::string name = getPrefix(descriptor);
            std::replace_if(
                    name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
            return name;
        });

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioEffectDataPathTest);

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    ABinderProcess_setThreadPoolMaxThreadCount(1);