diff options
author | Zhuoyao Zhang <zhuoyao@google.com> | 2018-02-08 20:55:27 -0800 |
---|---|---|
committer | Zhuoyao Zhang <zhuoyao@google.com> | 2018-02-12 23:48:50 +0000 |
commit | 91456084c29c6f4a3f629d7c44631ee3ee3b29e6 (patch) | |
tree | 43c066a08c5027c3a0cfc6239b08d376d1767996 /health | |
parent | 8f7ff5730b152542d476b039b15601785e3b777a (diff) | |
download | android_hardware_interfaces-91456084c29c6f4a3f629d7c44631ee3ee3b29e6.tar.gz android_hardware_interfaces-91456084c29c6f4a3f629d7c44631ee3ee3b29e6.tar.bz2 android_hardware_interfaces-91456084c29c6f4a3f629d7c44631ee3ee3b29e6.zip |
Convert health hal test to use VtsHalHidlTargetTestEnvBase
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalHealthV1_0Target
Change-Id: Ibbe9421b5a737d7eb2d021bd64757a548d3c95fc
Diffstat (limited to 'health')
-rw-r--r-- | health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp b/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp index 324eb9ff9..335d15d17 100644 --- a/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp +++ b/health/1.0/vts/functional/VtsHalHealthV1_0TargetTest.cpp @@ -19,7 +19,9 @@ #include <android/hardware/health/1.0/IHealth.h> #include <android/hardware/health/1.0/types.h> #include <log/log.h> + #include <VtsHalHidlTargetTestBase.h> +#include <VtsHalHidlTargetTestEnvBase.h> using HealthConfig = ::android::hardware::health::V1_0::HealthConfig; using HealthInfo = ::android::hardware::health::V1_0::HealthInfo; @@ -28,10 +30,25 @@ using Result = ::android::hardware::health::V1_0::Result; using ::android::sp; +// Test environment for Health HIDL HAL. +class HealthHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static HealthHidlEnvironment* Instance() { + static HealthHidlEnvironment* instance = new HealthHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService<IHealth>(); } + private: + HealthHidlEnvironment() {} +}; + class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { - health = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>(); + health = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>( + HealthHidlEnvironment::Instance()->getServiceName<IHealth>()); ASSERT_NE(health, nullptr); health->init(config, [&](const auto& halConfigOut) { config = halConfigOut; }); @@ -57,7 +74,9 @@ TEST_F(HealthHidlTest, TestEnergyCounter) { } int main(int argc, char **argv) { + ::testing::AddGlobalTestEnvironment(HealthHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); + HealthHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; |