diff options
author | Steven Moreland <smoreland@google.com> | 2019-11-07 17:02:43 -0800 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2019-11-08 10:24:34 -0800 |
commit | f33538889f0c0dec0fea0102bac1c596029afcf1 (patch) | |
tree | 24eb3951b0458ee98bfc11806231e44f9f66e8c1 /vibrator | |
parent | 9d11eca8292d0af63175bb759501c250cee22de8 (diff) | |
download | platform_hardware_interfaces-f33538889f0c0dec0fea0102bac1c596029afcf1.tar.gz platform_hardware_interfaces-f33538889f0c0dec0fea0102bac1c596029afcf1.tar.bz2 platform_hardware_interfaces-f33538889f0c0dec0fea0102bac1c596029afcf1.zip |
vibrator: fix VTS for effects
A few issues were causing effects tests to fail:
- invalid effects were not actually invalid
- test for invalid effects improved to consider invalid effects and
strengths separately
- test sleeps for appropriate amount of time after requesting effect to
be performed
- logging used to diagnose issues left in place for convenience
Bug: 141828236
Test: atest VtsHalVibratorTargetTest (on device which suffers from these
issues that cf did not hit)
Change-Id: Id220d36c27d85f068dce6b8961f705eef8dc6a4f
Diffstat (limited to 'vibrator')
-rw-r--r-- | vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp index aeb9b70088..a8e1fe4275 100644 --- a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +++ b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp @@ -46,13 +46,13 @@ const std::vector<EffectStrength> kEffectStrengths = {EffectStrength::LIGHT, Eff EffectStrength::STRONG}; const std::vector<Effect> kInvalidEffects = { - static_cast<Effect>(static_cast<int32_t>(*kEffects.begin()) - 1), - static_cast<Effect>(static_cast<int32_t>(*kEffects.end()) + 1), + static_cast<Effect>(static_cast<int32_t>(kEffects.front()) - 1), + static_cast<Effect>(static_cast<int32_t>(kEffects.back()) + 1), }; const std::vector<EffectStrength> kInvalidEffectStrengths = { - static_cast<EffectStrength>(static_cast<int8_t>(*kEffectStrengths.begin()) - 1), - static_cast<EffectStrength>(static_cast<int8_t>(*kEffectStrengths.end()) + 1), + static_cast<EffectStrength>(static_cast<int8_t>(kEffectStrengths.front()) - 1), + static_cast<EffectStrength>(static_cast<int8_t>(kEffectStrengths.back()) + 1), }; class CompletionCallback : public BnVibratorCallback { @@ -119,10 +119,13 @@ TEST_P(VibratorAidl, ValidateEffect) { Status status = vibrator->perform(effect, strength, nullptr /*callback*/, &lengthMs); if (isEffectSupported) { - EXPECT_TRUE(status.isOk()); + EXPECT_TRUE(status.isOk()) + << static_cast<int>(effect) << " " << static_cast<int>(strength); EXPECT_GT(lengthMs, 0); + usleep(lengthMs * 1000); } else { - EXPECT_EQ(status.exceptionCode(), Status::EX_UNSUPPORTED_OPERATION); + EXPECT_EQ(status.exceptionCode(), Status::EX_UNSUPPORTED_OPERATION) + << static_cast<int>(effect) << " " << static_cast<int>(strength); EXPECT_EQ(lengthMs, 0); } } @@ -179,10 +182,19 @@ TEST_P(VibratorAidl, ValidateEffectWithCallbackNotSupported) { TEST_P(VibratorAidl, InvalidEffectsUnsupported) { for (Effect effect : kInvalidEffects) { + for (EffectStrength strength : kEffectStrengths) { + int32_t lengthMs; + Status status = vibrator->perform(effect, strength, nullptr /*callback*/, &lengthMs); + EXPECT_EQ(status.exceptionCode(), Status::EX_UNSUPPORTED_OPERATION) + << static_cast<int>(effect) << " " << static_cast<int>(strength); + } + } + for (Effect effect : kEffects) { for (EffectStrength strength : kInvalidEffectStrengths) { int32_t lengthMs; Status status = vibrator->perform(effect, strength, nullptr /*callback*/, &lengthMs); - EXPECT_EQ(status.exceptionCode(), Status::EX_UNSUPPORTED_OPERATION); + EXPECT_EQ(status.exceptionCode(), Status::EX_UNSUPPORTED_OPERATION) + << static_cast<int>(effect) << " " << static_cast<int>(strength); } } } |