diff options
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; |