Audio V4: setMode VTS incorrectly assume 0 was invalid

Thus the test was always incorrectly failing.
Also improve the test error messages.

Bug: 77307068
Test: VtsHalAudioV4_0TargetTest
Change-Id: I95db94ed99f7ca32af35422e36a95084e72279d8
Signed-off-by: Kevin Rocard <krocard@google.com>
This commit is contained in:
Kevin Rocard 2018-04-21 00:32:06 -07:00
parent 92dcce0924
commit dea4c3803f
2 changed files with 6 additions and 8 deletions

View file

@ -47,6 +47,7 @@ DEFINE_GTEST_PRINT_TO(Result)
namespace common {
namespace AUDIO_HAL_VERSION {
DEFINE_GTEST_PRINT_TO(AudioConfig)
DEFINE_GTEST_PRINT_TO(AudioMode)
DEFINE_GTEST_PRINT_TO(AudioDevice)
DEFINE_GTEST_PRINT_TO(AudioFormat)
DEFINE_GTEST_PRINT_TO(AudioChannelMask)

View file

@ -1272,19 +1272,16 @@ TEST_F(AudioPrimaryHidlTest, setVoiceVolume) {
}
TEST_F(AudioPrimaryHidlTest, setMode) {
doc::test(
"Make sure setMode always succeeds if mode is valid "
"and fails otherwise");
doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise");
// Test Invalid values
for (int mode : {-1, 0, int(AudioMode::IN_COMMUNICATION) + 1}) {
SCOPED_TRACE("mode=" + to_string(mode));
ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode(mode)));
for (int mode : {-2, -1, int(AudioMode::IN_COMMUNICATION) + 1}) {
ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->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 */}) {
SCOPED_TRACE("mode=" + toString(mode));
ASSERT_OK(device->setMode(mode));
ASSERT_OK(device->setMode(mode)) << "mode=" << toString(mode);
}
}