diff options
author | Zhuoyao Zhang <zhuoyao@google.com> | 2018-02-09 20:43:24 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-02-09 20:43:24 +0000 |
commit | 0f090a495b6a15af55841fc3b65e97a4de3ec1e5 (patch) | |
tree | 1f1706651a0f0763af76fc318d0d2d301c9d12a2 /vr/1.0 | |
parent | 3818705c2de5c8efdf927b63f8bcfeb622003cc5 (diff) | |
parent | 92a1fbfe6e6cbab49e07a9454e78744cc554dd44 (diff) | |
download | platform_hardware_interfaces-0f090a495b6a15af55841fc3b65e97a4de3ec1e5.tar.gz platform_hardware_interfaces-0f090a495b6a15af55841fc3b65e97a4de3ec1e5.tar.bz2 platform_hardware_interfaces-0f090a495b6a15af55841fc3b65e97a4de3ec1e5.zip |
Merge "Convert vr hal test to use VtsHalHidlTargetTestEnvBase" am: f82e0825b6 am: a587d66b53
am: 92a1fbfe6e
Change-Id: I9e81601fe9e5cce64e1f9c6a83b424a21e394385
Diffstat (limited to 'vr/1.0')
-rw-r--r-- | vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp index 23f4c71dfb..b1656130e9 100644 --- a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp +++ b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp @@ -16,6 +16,7 @@ #define LOG_TAG "vr_hidl_hal_test" #include <VtsHalHidlTargetTestBase.h> +#include <VtsHalHidlTargetTestEnvBase.h> #include <android-base/logging.h> #include <android/hardware/vr/1.0/IVr.h> #include <hardware/vr.h> @@ -26,11 +27,24 @@ using ::android::hardware::Return; using ::android::hardware::Void; using ::android::sp; +// Test environment for Vr HIDL HAL. +class VrHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static VrHidlEnvironment* Instance() { + static VrHidlEnvironment* instance = new VrHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService<IVr>(); } +}; + // The main test class for VR HIDL HAL. class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase { public: void SetUp() override { - vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>(); + vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>( + VrHidlEnvironment::Instance()->getServiceName<IVr>()); ASSERT_NE(vr, nullptr); } @@ -39,16 +53,6 @@ class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase { sp<IVr> vr; }; - -// A class for test environment setup (kept since this file is a template). -class VrHidlEnvironment : public ::testing::Environment { - public: - void SetUp() {} - void TearDown() {} - - private: -}; - // Sanity check that Vr::init does not crash. TEST_F(VrHidlTest, Init) { EXPECT_TRUE(vr->init().isOk()); @@ -72,8 +76,9 @@ TEST_F(VrHidlTest, ReInit) { } int main(int argc, char **argv) { - ::testing::AddGlobalTestEnvironment(new VrHidlEnvironment); + ::testing::AddGlobalTestEnvironment(VrHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); + VrHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; |