diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-01 21:37:59 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-01 21:37:59 +0000 |
commit | 972d05917e37e520229d71881940dcdeb11e2964 (patch) | |
tree | b522551f1ea7f066be8bf8d0222da12ea141b666 /audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp | |
parent | 2d9a2e57719afa1adf94062355d0792bb9b625ee (diff) | |
parent | 74f46595794c48c09a0b83eb1e908c168e6f6848 (diff) |
Snap for 9239618 from 74f46595794c48c09a0b83eb1e908c168e6f6848 to tm-platform-release
Change-Id: I55dbd72b75ef88ac16d1ee884868b2ef742aafab
Diffstat (limited to 'audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp')
-rw-r--r-- | audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp index e59423fa98..d95bb06c3a 100644 --- a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp +++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp @@ -35,6 +35,7 @@ #include <common/all-versions/VersionUtils.h> +#include <cutils/properties.h> #include <gtest/gtest.h> #include <hidl/GtestPrinter.h> #include <hidl/ServiceManagement.h> @@ -623,6 +624,27 @@ TEST_P(AudioEffectHidlTest, GetParameter) { EXPECT_TRUE(ret.isOk()); } +TEST_P(AudioEffectHidlTest, GetParameterInvalidMaxReplySize) { + description("Verify that GetParameter caps the maximum reply size"); + const bool isNewDeviceLaunchingOnTPlus = property_get_int32("ro.vendor.api_level", 0) >= 33; + if (!isNewDeviceLaunchingOnTPlus) { + GTEST_SKIP() << "The test only applies to devices launching on T or later"; + } + // Use a non-empty parameter to avoid being rejected by any earlier checks. + hidl_vec<uint8_t> parameter; + parameter.resize(16); + // Use very large size to ensure that the service does not crash. Since parameters + // are specific to each effect, and some effects may not have parameters at all, + // simply checking the return value would not reveal an issue of using an uncapped value. + const uint32_t veryLargeReplySize = std::numeric_limits<uint32_t>::max() - 100; + Result retval = Result::OK; + Return<void> ret = + effect->getParameter(parameter, veryLargeReplySize, + [&](Result r, const hidl_vec<uint8_t>&) { retval = r; }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::INVALID_ARGUMENTS, retval); +} + TEST_P(AudioEffectHidlTest, GetSupportedConfigsForFeature) { description("Verify that GetSupportedConfigsForFeature does not crash"); Return<void> ret = effect->getSupportedConfigsForFeature( @@ -643,6 +665,37 @@ TEST_P(AudioEffectHidlTest, SetCurrentConfigForFeature) { EXPECT_TRUE(ret.isOk()); } +TEST_P(AudioEffectHidlTest, GetSupportedConfigsForFeatureInvalidConfigSize) { + description("Verify that GetSupportedConfigsForFeature caps the maximum config size"); + const bool isNewDeviceLaunchingOnTPlus = property_get_int32("ro.vendor.api_level", 0) >= 33; + if (!isNewDeviceLaunchingOnTPlus) { + GTEST_SKIP() << "The test only applies to devices launching on T or later"; + } + // Use very large size to ensure that the service does not crash. + const uint32_t veryLargeConfigSize = std::numeric_limits<uint32_t>::max() - 100; + Result retval = Result::OK; + Return<void> ret = effect->getSupportedConfigsForFeature( + 0, 1, veryLargeConfigSize, + [&](Result r, uint32_t, const hidl_vec<uint8_t>&) { retval = r; }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::INVALID_ARGUMENTS, retval); +} + +TEST_P(AudioEffectHidlTest, GetCurrentConfigForFeatureInvalidConfigSize) { + description("Verify that GetCurrentConfigForFeature caps the maximum config size"); + const bool isNewDeviceLaunchingOnTPlus = property_get_int32("ro.vendor.api_level", 0) >= 33; + if (!isNewDeviceLaunchingOnTPlus) { + GTEST_SKIP() << "The test only applies to devices launching on T or later"; + } + // Use very large size to ensure that the service does not crash. + const uint32_t veryLargeConfigSize = std::numeric_limits<uint32_t>::max() - 100; + Result retval = Result::OK; + Return<void> ret = effect->getCurrentConfigForFeature( + 0, veryLargeConfigSize, [&](Result r, const hidl_vec<uint8_t>&) { retval = r; }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::INVALID_ARGUMENTS, retval); +} + // The main test class for Equalizer Audio Effect HIDL HAL. class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest { public: |