diff options
author | Zhuoyao Zhang | 2018-02-08 23:13:22 -0600 |
---|---|---|
committer | Zhuoyao Zhang | 2018-02-13 18:58:40 -0600 |
commit | 8e27676c4c56c1fbfec0de08f272c62c8798fb5d (patch) | |
tree | 6908d685992c1f5cf8d4921a0b993f9c3df4ae4c /vibrator/1.1 | |
parent | 03086cfea42f73481cc0a5007dcccafa84b6fe35 (diff) | |
download | platform-hardware-interfaces-8e27676c4c56c1fbfec0de08f272c62c8798fb5d.tar.gz platform-hardware-interfaces-8e27676c4c56c1fbfec0de08f272c62c8798fb5d.tar.xz platform-hardware-interfaces-8e27676c4c56c1fbfec0de08f272c62c8798fb5d.zip |
Convert vibrator hal test to use VtsHalHidlTargetTestEnvBase
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalVibratorV1_0Target
vts-tradefed run vts -m VtsHalVibratorV1_1Target
Change-Id: Iff6015b15c0cca93213e5afe976bd98b6cb3a13b
Merged-In: Iff6015b15c0cca93213e5afe976bd98b6cb3a13b
(cherry picked from commit 7e1c2896adbb64aa4e975b15beb7796b7f3cb9bb)
Diffstat (limited to 'vibrator/1.1')
-rw-r--r-- | vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp b/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp index 35000f8f..1a47fe9f 100644 --- a/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp +++ b/vibrator/1.1/vts/functional/VtsHalVibratorV1_1TargetTest.cpp | |||
@@ -17,6 +17,7 @@ | |||
17 | #define LOG_TAG "vibrator_hidl_hal_test" | 17 | #define LOG_TAG "vibrator_hidl_hal_test" |
18 | 18 | ||
19 | #include <VtsHalHidlTargetTestBase.h> | 19 | #include <VtsHalHidlTargetTestBase.h> |
20 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
20 | #include <android-base/logging.h> | 21 | #include <android-base/logging.h> |
21 | #include <android/hardware/vibrator/1.1/IVibrator.h> | 22 | #include <android/hardware/vibrator/1.1/IVibrator.h> |
22 | #include <android/hardware/vibrator/1.1/types.h> | 23 | #include <android/hardware/vibrator/1.1/types.h> |
@@ -31,11 +32,27 @@ using ::android::hardware::Return; | |||
31 | using ::android::hardware::Void; | 32 | using ::android::hardware::Void; |
32 | using ::android::sp; | 33 | using ::android::sp; |
33 | 34 | ||
35 | // Test environment for Vibrator HIDL HAL. | ||
36 | class VibratorHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
37 | public: | ||
38 | // get the test environment singleton | ||
39 | static VibratorHidlEnvironment* Instance() { | ||
40 | static VibratorHidlEnvironment* instance = new VibratorHidlEnvironment; | ||
41 | return instance; | ||
42 | } | ||
43 | |||
44 | virtual void registerTestServices() override { registerTestService<IVibrator>(); } | ||
45 | |||
46 | private: | ||
47 | VibratorHidlEnvironment() {} | ||
48 | }; | ||
49 | |||
34 | // The main test class for VIBRATOR HIDL HAL 1.1. | 50 | // The main test class for VIBRATOR HIDL HAL 1.1. |
35 | class VibratorHidlTest_1_1 : public ::testing::VtsHalHidlTargetTestBase { | 51 | class VibratorHidlTest_1_1 : public ::testing::VtsHalHidlTargetTestBase { |
36 | public: | 52 | public: |
37 | virtual void SetUp() override { | 53 | virtual void SetUp() override { |
38 | vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>(); | 54 | vibrator = ::testing::VtsHalHidlTargetTestBase::getService<IVibrator>( |
55 | VibratorHidlEnvironment::Instance()->getServiceName<IVibrator>()); | ||
39 | ASSERT_NE(vibrator, nullptr); | 56 | ASSERT_NE(vibrator, nullptr); |
40 | } | 57 | } |
41 | 58 | ||
@@ -61,7 +78,9 @@ TEST_F(VibratorHidlTest_1_1, PerformEffect_1_1) { | |||
61 | } | 78 | } |
62 | 79 | ||
63 | int main(int argc, char** argv) { | 80 | int main(int argc, char** argv) { |
81 | ::testing::AddGlobalTestEnvironment(VibratorHidlEnvironment::Instance()); | ||
64 | ::testing::InitGoogleTest(&argc, argv); | 82 | ::testing::InitGoogleTest(&argc, argv); |
83 | VibratorHidlEnvironment::Instance()->init(&argc, argv); | ||
65 | int status = RUN_ALL_TESTS(); | 84 | int status = RUN_ALL_TESTS(); |
66 | LOG(INFO) << "Test result = " << status; | 85 | LOG(INFO) << "Test result = " << status; |
67 | return status; | 86 | return status; |