Skip to content

Commit

Permalink
[RESTRICT AUTOMERGE] HapticGenerator VTS: validate parameter before s…
Browse files Browse the repository at this point in the history
…etting am: d994467

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3276956

Change-Id: Ib668843372fafe36240c54607f3ee9bbd17bd367
Signed-off-by: Automerger Merge Worker <[email protected]>
  • Loading branch information
Shunkai Yao authored and android-build-merge-worker-robot committed Sep 23, 2024
2 parents 9a24a94 + d994467 commit 7a03de8
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,23 @@ 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
Parameter getParam;
Parameter::Id id;
HapticGenerator::Id hgId;
hgId.set<HapticGenerator::Id::commonTag>(tag);
id.set<Parameter::Id::hapticGeneratorTag>(hgId);
EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
EXPECT_EQ(expectParam, getParam) << expectParam.toString() << "\n"
<< getParam.toString();

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;
hgId.set<HapticGenerator::Id::commonTag>(tag);
id.set<Parameter::Id::hapticGeneratorTag>(hgId);
EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
EXPECT_EQ(expectParam, getParam) << expectParam.toString() << "\n"
<< getParam.toString();
}
}
}

Expand Down

0 comments on commit 7a03de8

Please sign in to comment.