diff options
author | Michael Wright | 2018-01-23 18:22:02 -0600 |
---|---|---|
committer | Michael Wright | 2018-01-24 18:53:31 -0600 |
commit | ed5d92cc7cdaf07bf7e97cc7894f3147cd055b73 (patch) | |
tree | a91b6532f33887b5a845e21dfb88526d1f74c49b /vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp | |
parent | b6371e782db1c82bc2b3261579c4f25c31a9c1b1 (diff) | |
download | platform-hardware-interfaces-ed5d92cc7cdaf07bf7e97cc7894f3147cd055b73.tar.gz platform-hardware-interfaces-ed5d92cc7cdaf07bf7e97cc7894f3147cd055b73.tar.xz platform-hardware-interfaces-ed5d92cc7cdaf07bf7e97cc7894f3147cd055b73.zip |
Add new vibrator effects.
Add new effects for pop, thud and heavy click, as well as constants to
play back pre-defined ringtone effects.
Bug: 64185677
Bug: 64184692
Test: run vts --skip-all-system-status-check --skip-preconditions
--primary-abi-only --module VtsHalVibratorV1_2TargetTest
Change-Id: I4baae73e1471208f9f54bb1c03da8c27ca6b0ee1
Diffstat (limited to 'vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp')
-rw-r--r-- | vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp b/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp new file mode 100644 index 00000000..d07d1b78 --- /dev/null +++ b/vibrator/1.2/vts/functional/VtsHalVibratorV1_2TargetTest.cpp | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "vibrator_hidl_hal_test" | ||
18 | |||
19 | #include <VtsHalHidlTargetTestBase.h> | ||
20 | #include <android-base/logging.h> | ||
21 | #include <android/hardware/vibrator/1.0/types.h> | ||
22 | #include <android/hardware/vibrator/1.2/IVibrator.h> | ||
23 | #include <android/hardware/vibrator/1.2/types.h> | ||
24 | #include <unistd.h> | ||
25 | |||
26 | using ::android::hardware::vibrator::V1_0::Status; | ||
27 | using ::android::hardware::vibrator::V1_0::EffectStrength; | ||
28 | using ::android::hardware::vibrator::V1_2::Effect; | ||
29 | using ::android::hardware::vibrator::V1_2::IVibrator; | ||
30 | using ::android::hardware::hidl_enum_iterator; | ||
31 | using ::android::hardware::Return; | ||
32 | using ::android::hardware::Void; | ||
33 | using ::android::sp; | ||
34 | |||
35 | // The main test class for VIBRATOR HIDL HAL 1.2. | ||
36 | class VibratorHidlTest_1_2 : public ::testing::VtsHalHidlTargetTestBase { | ||
37 | public: | ||
38 | virtual void SetUp() override { | ||
39 | vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>(); | ||
40 | ASSERT_NE(vibrator, nullptr); | ||
41 | } | ||
42 | |||
43 | virtual void TearDown() override {} | ||
44 | |||
45 | sp<IVibrator> vibrator; | ||
46 | }; | ||
47 | |||
48 | static void validatePerformEffect(Status status, uint32_t lengthMs) { | ||
49 | ASSERT_TRUE(status == Status::OK || status == Status::UNSUPPORTED_OPERATION); | ||
50 | if (status == Status::OK) { | ||
51 | ASSERT_GT(lengthMs, static_cast<uint32_t>(0)) | ||
52 | << "Effects that return OK must return a non-zero duration"; | ||
53 | } else { | ||
54 | ASSERT_EQ(lengthMs, static_cast<uint32_t>(0)) | ||
55 | << "Effects that return UNSUPPORTED_OPERATION must have a duration of zero"; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | TEST_F(VibratorHidlTest_1_2, PerformEffect_1_2) { | ||
60 | for (const auto& effect : hidl_enum_iterator<Effect>()) { | ||
61 | for (const auto& strength : hidl_enum_iterator<EffectStrength>()) { | ||
62 | vibrator->perform_1_2(effect, strength, validatePerformEffect); | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | |||
67 | int main(int argc, char** argv) { | ||
68 | ::testing::InitGoogleTest(&argc, argv); | ||
69 | int status = RUN_ALL_TESTS(); | ||
70 | LOG(INFO) << "Test result = " << status; | ||
71 | return status; | ||
72 | } | ||