Effect AIDL replace test cases icombine vector values with set
To avoid potential test cases with duplicate name.
Also update replace hardcode enum values with ndk::enum_range.
Bug: 258124419
Test: atest VtsHalAECTargetTest
Test: atest VtsHalAGCTargetTest
Change-Id: I6131d99f8b443ae48a487800190365cb645032da
diff --git a/audio/aidl/vts/VtsHalAECTargetTest.cpp b/audio/aidl/vts/VtsHalAECTargetTest.cpp
index a06ab42..eb92ef8 100644
--- a/audio/aidl/vts/VtsHalAECTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAECTargetTest.cpp
@@ -14,12 +14,13 @@
* limitations under the License.
*/
+#include <Utils.h>
#include <aidl/Vintf.h>
#include <algorithm>
+#include <unordered_set>
#define LOG_TAG "VtsHalAECParamTest"
-#include <Utils.h>
#include "EffectHelper.h"
using namespace android;
@@ -70,8 +71,8 @@
}
static const std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList;
- static const std::vector<int> kEchoDelayValues;
- static const std::vector<bool> kMobileModeValues;
+ static const std::unordered_set<int> kEchoDelayValues;
+ static const std::unordered_set<bool> kMobileModeValues;
static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
std::shared_ptr<IFactory> mFactory;
@@ -155,7 +156,7 @@
}
}
- static std::vector<int> getEchoDelayTestValues() {
+ static std::unordered_set<int> getEchoDelayTestValues() {
const auto max = std::max_element(
kFactoryDescList.begin(), kFactoryDescList.end(),
[](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
@@ -181,8 +182,9 @@
const std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> AECParamTest::kFactoryDescList =
EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kAcousticEchoCancelerTypeUUID);
-const std::vector<int> AECParamTest::kEchoDelayValues = AECParamTest::getEchoDelayTestValues();
-const std::vector<bool> AECParamTest::kMobileModeValues = {true, false};
+const std::unordered_set<int> AECParamTest::kEchoDelayValues =
+ AECParamTest::getEchoDelayTestValues();
+const std::unordered_set<bool> AECParamTest::kMobileModeValues = {true, false};
TEST_P(AECParamTest, SetAndGetEchoDelay) {
EXPECT_NO_FATAL_FAILURE(addEchoDelayParam(mEchoDelay));
diff --git a/audio/aidl/vts/VtsHalAGCTargetTest.cpp b/audio/aidl/vts/VtsHalAGCTargetTest.cpp
index ea3654f..484cc84 100644
--- a/audio/aidl/vts/VtsHalAGCTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAGCTargetTest.cpp
@@ -14,11 +14,13 @@
* limitations under the License.
*/
+#include <Utils.h>
#include <aidl/Vintf.h>
+#include <android/binder_enums.h>
+#include <unordered_set>
#define LOG_TAG "VtsHalAGCParamTest"
-#include <Utils.h>
#include "EffectHelper.h"
using namespace android;
@@ -78,9 +80,9 @@
static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
static const std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList;
- static const std::vector<int> kDigitalGainValues;
- static const std::vector<int> kSaturationMarginValues;
- static const std::vector<AutomaticGainControl::LevelEstimator> kLevelEstimatorValues;
+ static const std::unordered_set<int> kDigitalGainValues;
+ static const std::unordered_set<int> kSaturationMarginValues;
+ static const std::unordered_set<AutomaticGainControl::LevelEstimator> kLevelEstimatorValues;
std::shared_ptr<IFactory> mFactory;
std::shared_ptr<IEffect> mEffect;
@@ -158,7 +160,7 @@
return false;
}
}
- static std::vector<int> getDigitalGainValues() {
+ static std::unordered_set<int> getDigitalGainValues() {
const auto max = std::max_element(
kFactoryDescList.begin(), kFactoryDescList.end(),
[](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
@@ -175,7 +177,7 @@
.maxFixedDigitalGainMb;
return {-1, 0, maxGain - 1, maxGain, maxGain + 1};
}
- static std::vector<int> getSaturationMarginValues() {
+ static std::unordered_set<int> getSaturationMarginValues() {
const auto max = std::max_element(
kFactoryDescList.begin(), kFactoryDescList.end(),
[](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
@@ -201,11 +203,13 @@
const std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> AGCParamTest::kFactoryDescList =
EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kAutomaticGainControlTypeUUID);
-const std::vector<int> AGCParamTest::kDigitalGainValues = AGCParamTest::getDigitalGainValues();
-const std::vector<int> AGCParamTest::kSaturationMarginValues =
+const std::unordered_set<int> AGCParamTest::kDigitalGainValues =
+ AGCParamTest::getDigitalGainValues();
+const std::unordered_set<int> AGCParamTest::kSaturationMarginValues =
AGCParamTest::getSaturationMarginValues();
-const std::vector<AutomaticGainControl::LevelEstimator> AGCParamTest::kLevelEstimatorValues = {
- AutomaticGainControl::LevelEstimator::RMS, AutomaticGainControl::LevelEstimator::PEAK};
+const std::unordered_set<AutomaticGainControl::LevelEstimator> AGCParamTest::kLevelEstimatorValues =
+ {ndk::enum_range<AutomaticGainControl::LevelEstimator>().begin(),
+ ndk::enum_range<AutomaticGainControl::LevelEstimator>().end()};
TEST_P(AGCParamTest, SetAndGetDigitalGainParam) {
EXPECT_NO_FATAL_FAILURE(addDigitalGainParam(mGain));
diff --git a/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp b/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp
index a1daec2..d1f3b97 100644
--- a/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp
@@ -18,6 +18,9 @@
#include <Utils.h>
#include <aidl/Vintf.h>
+#include <android/binder_enums.h>
+#include <unordered_set>
+
#include "EffectHelper.h"
using namespace android;
@@ -61,9 +64,8 @@
const std::vector<int> kHapticScaleIdValues = {MIN_ID, 0, MAX_ID};
const std::vector<HapticGenerator::VibratorScale> kVibratorScaleValues = {
- HapticGenerator::VibratorScale::MUTE, HapticGenerator::VibratorScale::VERY_LOW,
- HapticGenerator::VibratorScale::LOW, HapticGenerator::VibratorScale::NONE,
- HapticGenerator::VibratorScale::HIGH, HapticGenerator::VibratorScale::VERY_HIGH};
+ ndk::enum_range<HapticGenerator::VibratorScale>().begin(),
+ ndk::enum_range<HapticGenerator::VibratorScale>().end()};
const std::vector<float> kResonantFrequencyValues = {MIN_FLOAT, 100, MAX_FLOAT};
const std::vector<float> kQFactorValues = {MIN_FLOAT, 100, MAX_FLOAT};
diff --git a/audio/aidl/vts/VtsHalNSTargetTest.cpp b/audio/aidl/vts/VtsHalNSTargetTest.cpp
index 186cb68..2845225 100644
--- a/audio/aidl/vts/VtsHalNSTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalNSTargetTest.cpp
@@ -19,6 +19,7 @@
#define LOG_TAG "VtsHalNSParamTest"
#include <Utils.h>
+#include <unordered_set>
#include "EffectHelper.h"
using namespace android;
@@ -69,7 +70,7 @@
static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
static const std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList;
- static const std::vector<NoiseSuppression::Level> kLevelValues;
+ static const std::unordered_set<NoiseSuppression::Level> kLevelValues;
std::shared_ptr<IFactory> mFactory;
std::shared_ptr<IEffect> mEffect;
@@ -122,9 +123,9 @@
const std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList =
EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
kNoiseSuppressionTypeUUID);
-const std::vector<NoiseSuppression::Level> NSParamTest::kLevelValues = {
- NoiseSuppression::Level::LOW, NoiseSuppression::Level::MEDIUM,
- NoiseSuppression::Level::HIGH};
+const std::unordered_set<NoiseSuppression::Level> NSParamTest::kLevelValues = {
+ ndk::enum_range<NoiseSuppression::Level>().begin(),
+ ndk::enum_range<NoiseSuppression::Level>().end()};
TEST_P(NSParamTest, SetAndGetLevel) {
EXPECT_NO_FATAL_FAILURE(addLevelParam(mLevel));