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

Commit 238fbcc6 authored by David Li's avatar David Li
Browse files

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
parent 04247248
Loading
Loading
Loading
Loading
+10 −7
Original line number Original line Diff line number Diff line
@@ -343,18 +343,21 @@ TEST_P(AudioPrimaryHidlTest, setMode) {
#endif
#endif


    for (int mode : {-2, -1, maxMode + 1}) {
    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;
                << "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
    // AudioMode::CALL_SCREEN as support is optional
#if MAJOR_VERSION >= 6
#if MAJOR_VERSION >= 6
    ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, getDevice()->setMode(AudioMode::CALL_SCREEN));
    EXPECT_RESULT(okOrNotSupportedOrInvalidArgs, getDevice()->setMode(AudioMode::CALL_SCREEN));
#endif
#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) {
TEST_P(AudioPrimaryHidlTest, setBtHfpSampleRate) {