Audio HAL VTS: setGain allow -0.0
Previously -0.0 was consider an invalid value as not in the range [0,1].
But it is quite difficult in C++ to differentiate -0.0 and 0.0 as -0.0 == 0.0
and such difference has no impact in practice.
Thus leave the implementation support or not -0.0.
Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: Ia0ebcb325f77adcf8471620f418da1cbe8995e36
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 f90ff05..0af5c94 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -1029,19 +1029,20 @@
}
static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
- for (float value : {0.0, 0.01, 0.5, 0.09, 1.0}) {
- SCOPED_TRACE("value=" + to_string(value));
- ASSERT_OK(setGain(value));
- }
- for (float value : (float[]){-INFINITY, -1.0, -0.0,
- 1.0 + std::numeric_limits<float>::epsilon(),
- 2.0, INFINITY, NAN}) {
+ for (float value :
+ (float[]){-INFINITY, -1.0, 1.0 + std::numeric_limits<float>::epsilon(),
+ 2.0, INFINITY, NAN}) {
SCOPED_TRACE("value=" + to_string(value));
// FIXME: NAN should never be accepted
// FIXME: Missing api doc. What should the impl do if the volume is
// outside [0,1] ?
ASSERT_RESULT(Result::INVALID_ARGUMENTS, setGain(value));
}
+ // Do not consider -0.0 as an invalid value as it is == with 0.0
+ for (float value : {-0.0, 0.0, 0.01, 0.5, 0.09, 1.0 /* Restore volume*/}) {
+ SCOPED_TRACE("value=" + to_string(value));
+ ASSERT_OK(setGain(value));
+ }
}
static void testOptionalUnitaryGain(