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

Commit 98390a6c authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio HAL VTS: Some methods are optional



Although the method documentation does not say it,
some HIDL interface methods are optional.

Update the tests to allow NOT_SUPPORTED to be returned.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: If31acc2dbdb6d1d563910e85c99401c48f4f3f86
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 476e38fd
Loading
Loading
Loading
Loading
+24 −11
Original line number Diff line number Diff line
@@ -1020,6 +1020,10 @@ TEST_P(InputStreamTest, GetAudioSource) {
        "Retrieving the audio source of an input stream should always succeed");
    AudioSource source;
    ASSERT_OK(stream->getAudioSource(returnIn(res, source)));
    if (res == Result::NOT_SUPPORTED) {
        doc::partialTest("getAudioSource is not supported");
        return;
    }
    ASSERT_OK(res);
    ASSERT_EQ(AudioSource::DEFAULT, source);
}
@@ -1040,9 +1044,22 @@ static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
    }
}

static void testOptionalUnitaryGain(
    std::function<Return<Result>(float)> setGain, string debugName) {
    auto result = setGain(1);
    ASSERT_TRUE(result.isOk());
    if (result == Result::NOT_SUPPORTED) {
        doc::partialTest(debugName + " is not supported");
        return;
    }
    testUnitaryGain(setGain);
}

TEST_P(InputStreamTest, SetGain) {
    doc::test("The gain of an input stream should only be set between [0,1]");
    testUnitaryGain([this](float volume) { return stream->setGain(volume); });
    testOptionalUnitaryGain(
        [this](float volume) { return stream->setGain(volume); },
        "InputStream::setGain");
}

static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize,
@@ -1108,14 +1125,9 @@ TEST_P(OutputStreamTest, getLatency) {

TEST_P(OutputStreamTest, setVolume) {
    doc::test("Try to set the output volume");
    auto result = stream->setVolume(1, 1);
    ASSERT_TRUE(result.isOk());
    if (result == Result::NOT_SUPPORTED) {
        doc::partialTest("setVolume is not supported");
        return;
    }
    testUnitaryGain(
        [this](float volume) { return stream->setVolume(volume, volume); });
    testOptionalUnitaryGain(
        [this](float volume) { return stream->setVolume(volume, volume); },
        "setVolume");
}

static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize,
@@ -1369,7 +1381,8 @@ TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {

TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {
    doc::test("Query and set the HAC state");
    testAccessors("HAC", {true, false, true}, &IPrimaryDevice::setHacEnabled,
    testOptionalAccessors("HAC", {true, false, true},
                          &IPrimaryDevice::setHacEnabled,
                          &IPrimaryDevice::getHacEnabled);
}