diff options
author | Zhuoyao Zhang <zhuoyao@google.com> | 2018-02-16 00:16:15 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-02-16 00:16:15 +0000 |
commit | d571a2bc57410bedaba8f8725c268d99d0983fc2 (patch) | |
tree | c5a9112ba62b080f8190075b854ad78f367e0bbe /health | |
parent | b6a8851f307303d2bc9c7ac244406429ace47808 (diff) | |
parent | d5e930ea16aa7b5fbd4b30cae50843011bc65ee5 (diff) | |
download | android_hardware_interfaces-d571a2bc57410bedaba8f8725c268d99d0983fc2.tar.gz android_hardware_interfaces-d571a2bc57410bedaba8f8725c268d99d0983fc2.tar.bz2 android_hardware_interfaces-d571a2bc57410bedaba8f8725c268d99d0983fc2.zip |
Merge "Convert health hal test to use VtsHalHidlTargetTestEnvBase" am: 8a5a99ca3b am: ef211ccb88
am: d5e930ea16
Change-Id: Iea1bedb26ec6eabc050b4f2c7c99cda2dfe9894e
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; |