Audio HAL VTS: stopped stream state getters may return INVALID_STATE
A never started stream should have its render position and next write
timestamp at 0 or indicate that the state is invalid.
Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I62e16066bb22101ee8f75154fc6c85a66be2f402
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 0af5c94..46a2f78 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -1182,27 +1182,39 @@
Capability(stream.get());
}
+template <class Value>
+static void checkInvalidStateOr0(Result res, Value value) {
+ switch (res) {
+ case Result::INVALID_STATE:
+ break;
+ case Result::OK:
+ ASSERT_EQ(0U, value);
+ break;
+ default:
+ FAIL() << "Unexpected result " << toString(res);
+ }
+}
+
TEST_P(OutputStreamTest, GetRenderPosition) {
- doc::test("The render position should be 0 on a not started");
+ doc::test("A new stream render position should be 0 or INVALID_STATE");
uint32_t dspFrames;
ASSERT_OK(stream->getRenderPosition(returnIn(res, dspFrames)));
if (res == Result::NOT_SUPPORTED) {
doc::partialTest("getRenderPosition is not supported");
return;
}
- ASSERT_OK(res);
- ASSERT_EQ(0U, dspFrames);
+ checkInvalidStateOr0(res, dspFrames);
}
TEST_P(OutputStreamTest, GetNextWriteTimestamp) {
- doc::test("The render position of a stream just created should be 0");
+ doc::test("A new stream next write timestamp should be 0 or INVALID_STATE");
uint64_t timestampUs;
ASSERT_OK(stream->getNextWriteTimestamp(returnIn(res, timestampUs)));
if (res == Result::NOT_SUPPORTED) {
doc::partialTest("getNextWriteTimestamp is not supported");
return;
}
- ASSERT_EQ(Result::INVALID_STATE, res);
+ checkInvalidStateOr0(res, timestampUs);
}
/** Stub implementation of out stream callback. */