Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d994467f authored by Shunkai Yao's avatar Shunkai Yao
Browse files

[RESTRICT AUTOMERGE] HapticGenerator VTS: validate parameter before setting

the newer version of HapticGenerator have range defined

Bug: 368467232
Test: atest VtsHalHapticGeneratorTargetTest
Change-Id: I1e366caf7d3944bc371d3b646733ed873aa111c8
Merged-In: I9da0f6f2573722089efadb78ff96fc265bdad164
parent fe611786
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -121,9 +121,14 @@ class HapticGeneratorParamTest : public ::testing::TestWithParam<HapticGenerator
            Parameter::Specific specific;
            specific.set<Parameter::Specific::hapticGenerator>(setHg);
            expectParam.set<Parameter::specific>(specific);
            EXPECT_STATUS(EX_NONE, mEffect->setParameter(expectParam)) << expectParam.toString();

            // get parameter
            const bool valid =
                    isParameterValid<HapticGenerator, Range::hapticGenerator>(setHg, mDescriptor);
            const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
            EXPECT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();

            // only get if parameter in range and set success
            if (expected == EX_NONE) {
                Parameter getParam;
                Parameter::Id id;
                HapticGenerator::Id hgId;
@@ -134,6 +139,7 @@ class HapticGeneratorParamTest : public ::testing::TestWithParam<HapticGenerator
                                                 << getParam.toString();
            }
        }
    }

    void addHapticScaleParam(int id, HapticGenerator::VibratorScale scale) {
        HapticGenerator setHg;