From 238fbcc61a393b672cf59db6a4d29ef476cd56d3 Mon Sep 17 00:00:00 2001 From: David Li Date: Mon, 19 Jul 2021 12:48:06 +0800 Subject: [PATCH] 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 --- .../functional/4.0/AudioPrimaryHidlHalTest.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp index b96cc83673..f8af0304ad 100644 --- a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp @@ -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) {