audio: make sure to set back to AudioMode::NORMAL after the test case

If the major version is greater than or equal to 6, the test tries
to set the mode to AudioMode::CALL_SCREEN. However, it doesn't set
back to AudioMode::NORMAL. Replace all ASSERT with EXPECT to ensure the
test can reach to the explicit call to reset to AudioMode::NORMAL.

Bug: 194022995
Test: atest VtsHalAudioV7_0TargetTest
Change-Id: Ib9b6e310965a85b016853b72c60716fa054641c6
This commit is contained in:
David Li
2021-07-19 12:48:06 +08:00
parent 04247248ce
commit 238fbcc61a

View File

@@ -343,18 +343,21 @@ TEST_P(AudioPrimaryHidlTest, setMode) {
#endif
for (int mode : {-2, -1, maxMode + 1}) {
ASSERT_RESULT(Result::INVALID_ARGUMENTS, getDevice()->setMode(AudioMode(mode)))
EXPECT_RESULT(Result::INVALID_ARGUMENTS, getDevice()->setMode(AudioMode(mode)))
<< "mode=" << mode;
}
// Test valid values
for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
ASSERT_OK(getDevice()->setMode(mode)) << "mode=" << toString(mode);
}
// AudioMode::CALL_SCREEN as support is optional
#if MAJOR_VERSION >= 6
ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, getDevice()->setMode(AudioMode::CALL_SCREEN));
EXPECT_RESULT(okOrNotSupportedOrInvalidArgs, getDevice()->setMode(AudioMode::CALL_SCREEN));
#endif
// Test valid values
for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
AudioMode::NORMAL}) {
EXPECT_OK(getDevice()->setMode(mode)) << "mode=" << toString(mode);
}
// Make sure to leave the test in normal mode
getDevice()->setMode(AudioMode::NORMAL);
}
TEST_P(AudioPrimaryHidlTest, setBtHfpSampleRate) {