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: Kevin Rocard <krocard@google.com>
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 9653886..f90ff05 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -1020,6 +1020,10 @@
"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 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, 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,8 +1381,9 @@
TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {
doc::test("Query and set the HAC state");
- testAccessors("HAC", {true, false, true}, &IPrimaryDevice::setHacEnabled,
- &IPrimaryDevice::getHacEnabled);
+ testOptionalAccessors("HAC", {true, false, true},
+ &IPrimaryDevice::setHacEnabled,
+ &IPrimaryDevice::getHacEnabled);
}
//////////////////////////////////////////////////////////////////////////////