Update composePwleV2 VTS test

Updating composePwleV2 VTS test to verify cases where the PWLE V2 capability is not supported.

Bug: 347034419
Flag: TEST_ONLY
Test: vts-tradefed run vts -m VtsHalVibratorTargetTest
Change-Id: I73de882f6595e858cea922b5378e5e7da4719140
This commit is contained in:
Ahmad Khalil
2024-08-22 12:25:36 +00:00
parent 4deb197f2b
commit 7eacaad15e
2 changed files with 20 additions and 0 deletions

View File

@@ -543,6 +543,14 @@ float getPwleV2FrequencyMaxHz(std::vector<PwleV2OutputMapEntry> frequencyToOutpu
ndk::ScopedAStatus Vibrator::composePwleV2(const std::vector<PwleV2Primitive>& composite,
const std::shared_ptr<IVibratorCallback>& callback) {
int32_t capabilities = 0;
if (!getCapabilities(&capabilities).isOk()) {
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
if ((capabilities & IVibrator::CAP_COMPOSE_PWLE_EFFECTS_V2) == 0) {
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
}
int compositionSizeMax;
getPwleV2CompositionSizeMax(&compositionSizeMax);
if (composite.size() <= 0 || composite.size() > compositionSizeMax) {

View File

@@ -89,6 +89,7 @@ const std::vector<CompositePrimitive> kInvalidPrimitives = {
static constexpr std::chrono::milliseconds VIBRATION_CALLBACK_TIMEOUT = 100ms;
static constexpr int32_t VENDOR_EFFECTS_MIN_VERSION = 3;
static constexpr int32_t PWLE_V2_MIN_VERSION = 3;
static std::vector<std::string> findVibratorManagerNames() {
std::vector<std::string> names;
@@ -1117,6 +1118,17 @@ TEST_P(VibratorAidl, ComposeValidPwleV2Effect) {
EXPECT_OK(vibrator->off());
}
TEST_P(VibratorAidl, ComposePwleV2Unsupported) {
if (version < PWLE_V2_MIN_VERSION) {
EXPECT_EQ(capabilities & IVibrator::CAP_COMPOSE_PWLE_EFFECTS_V2, 0)
<< "Vibrator version " << version << " should not report PWLE V2 capability.";
}
if (capabilities & IVibrator::CAP_COMPOSE_PWLE_EFFECTS_V2) return;
EXPECT_UNKNOWN_OR_UNSUPPORTED(
vibrator->composePwleV2(pwle_v2_utils::composeValidPwleV2Effect(vibrator), nullptr));
}
TEST_P(VibratorAidl, ComposeValidPwleV2EffectWithCallback) {
if (!(capabilities & IVibrator::CAP_COMPOSE_PWLE_EFFECTS_V2)) {
GTEST_SKIP() << "PWLE V2 not supported, skipping test";