diff options
author | Zhuoyao Zhang | 2018-02-13 16:44:51 -0600 |
---|---|---|
committer | android-build-merger | 2018-02-13 16:44:51 -0600 |
commit | d8f7fd48eaef0771ba2b4009965004cfaab56c74 (patch) | |
tree | 8ff8b12c594aae87e9a10d96adc5e322a6604848 /light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp | |
parent | 11b80fe8d1f7da9e3e981cc86491b6812e0ffda7 (diff) | |
parent | 6a773b9a7cddcdcf76d33acf1cd7f050383adb8b (diff) | |
download | platform-hardware-interfaces-d8f7fd48eaef0771ba2b4009965004cfaab56c74.tar.gz platform-hardware-interfaces-d8f7fd48eaef0771ba2b4009965004cfaab56c74.tar.xz platform-hardware-interfaces-d8f7fd48eaef0771ba2b4009965004cfaab56c74.zip |
Merge "Convert light hal test to use VtsHalHidlTargetTestEnvBase" am: c4c77e570e am: 923bbc8934
am: 6a773b9a7c
Change-Id: I0c4ca12e6de262660a0b47d0098ee3b314c4f8a4
Diffstat (limited to 'light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp')
-rw-r--r-- | light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp index 3405422a..13290d91 100644 --- a/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp +++ b/light/2.0/vts/functional/VtsHalLightV2_0TargetTest.cpp | |||
@@ -16,12 +16,13 @@ | |||
16 | 16 | ||
17 | #define LOG_TAG "light_hidl_hal_test" | 17 | #define LOG_TAG "light_hidl_hal_test" |
18 | 18 | ||
19 | #include <VtsHalHidlTargetTestBase.h> | ||
20 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
19 | #include <android-base/logging.h> | 21 | #include <android-base/logging.h> |
20 | #include <android/hardware/light/2.0/ILight.h> | 22 | #include <android/hardware/light/2.0/ILight.h> |
21 | #include <android/hardware/light/2.0/types.h> | 23 | #include <android/hardware/light/2.0/types.h> |
22 | #include <VtsHalHidlTargetTestBase.h> | ||
23 | #include <set> | ||
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <set> | ||
25 | 26 | ||
26 | using ::android::hardware::light::V2_0::Brightness; | 27 | using ::android::hardware::light::V2_0::Brightness; |
27 | using ::android::hardware::light::V2_0::Flash; | 28 | using ::android::hardware::light::V2_0::Flash; |
@@ -72,10 +73,25 @@ const static std::set<Type> kAllTypes = { | |||
72 | Type::WIFI | 73 | Type::WIFI |
73 | }; | 74 | }; |
74 | 75 | ||
76 | // Test environment for Light HIDL HAL. | ||
77 | class LightHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
78 | public: | ||
79 | // get the test environment singleton | ||
80 | static LightHidlEnvironment* Instance() { | ||
81 | static LightHidlEnvironment* instance = new LightHidlEnvironment; | ||
82 | return instance; | ||
83 | } | ||
84 | |||
85 | virtual void registerTestServices() override { registerTestService<ILight>(); } | ||
86 | private: | ||
87 | LightHidlEnvironment() {} | ||
88 | }; | ||
89 | |||
75 | class LightHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 90 | class LightHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
76 | public: | 91 | public: |
77 | virtual void SetUp() override { | 92 | virtual void SetUp() override { |
78 | light = ::testing::VtsHalHidlTargetTestBase::getService<ILight>(); | 93 | light = ::testing::VtsHalHidlTargetTestBase::getService<ILight>( |
94 | LightHidlEnvironment::Instance()->getServiceName<ILight>()); | ||
79 | 95 | ||
80 | ASSERT_NE(light, nullptr); | 96 | ASSERT_NE(light, nullptr); |
81 | LOG(INFO) << "Test is remote " << light->isRemote(); | 97 | LOG(INFO) << "Test is remote " << light->isRemote(); |
@@ -149,7 +165,9 @@ TEST_F(LightHidlTest, TestUnsupported) { | |||
149 | } | 165 | } |
150 | 166 | ||
151 | int main(int argc, char **argv) { | 167 | int main(int argc, char **argv) { |
168 | ::testing::AddGlobalTestEnvironment(LightHidlEnvironment::Instance()); | ||
152 | ::testing::InitGoogleTest(&argc, argv); | 169 | ::testing::InitGoogleTest(&argc, argv); |
170 | LightHidlEnvironment::Instance()->init(&argc, argv); | ||
153 | int status = RUN_ALL_TESTS(); | 171 | int status = RUN_ALL_TESTS(); |
154 | LOG(INFO) << "Test result = " << status; | 172 | LOG(INFO) << "Test result = " << status; |
155 | return status; | 173 | return status; |