diff options
author | nelsonli <nelsonli@google.com> | 2019-10-29 16:16:55 +0800 |
---|---|---|
committer | nelsonli <nelsonli@google.com> | 2019-10-29 16:16:55 +0800 |
commit | 6edb7e28d4b3d50d50a1b68ac5241abdb570c5b5 (patch) | |
tree | 5544a09903e1c295989baecb359d00b1f0673e0e /vr | |
parent | 69879436a57d0dbfc4d3020aa8900138bdbdb67c (diff) | |
download | platform_hardware_interfaces-6edb7e28d4b3d50d50a1b68ac5241abdb570c5b5.tar.gz platform_hardware_interfaces-6edb7e28d4b3d50d50a1b68ac5241abdb570c5b5.tar.bz2 platform_hardware_interfaces-6edb7e28d4b3d50d50a1b68ac5241abdb570c5b5.zip |
[vts-core] add VtsHalVrV1_0TargetTest to vts-core
Convert VtsHalVrV1_0TargetTest to be parameterized test
and add it to vts-core
Bug: 142397658
Test: $atest VtsHalVrV1_0TargetTest
Change-Id: Ic14260b15baebad082f6da0c52c09e58e40760b2
Diffstat (limited to 'vr')
-rw-r--r-- | vr/1.0/vts/functional/Android.bp | 2 | ||||
-rw-r--r-- | vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp | 41 |
2 files changed, 14 insertions, 29 deletions
diff --git a/vr/1.0/vts/functional/Android.bp b/vr/1.0/vts/functional/Android.bp index 958cce768a..bd0336cc15 100644 --- a/vr/1.0/vts/functional/Android.bp +++ b/vr/1.0/vts/functional/Android.bp @@ -19,5 +19,5 @@ cc_test { defaults: ["VtsHalTargetTestDefaults"], srcs: ["VtsHalVrV1_0TargetTest.cpp"], static_libs: ["android.hardware.vr@1.0"], - test_suites: ["general-tests"], + test_suites: ["general-tests", "vts-core"], } diff --git a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp index b1656130e9..c08e5caaf3 100644 --- a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp +++ b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp @@ -15,11 +15,12 @@ */ #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 <gtest/gtest.h> #include <hardware/vr.h> +#include <hidl/GtestPrinter.h> +#include <hidl/ServiceManagement.h> #include <log/log.h> using ::android::hardware::vr::V1_0::IVr; @@ -27,24 +28,11 @@ 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 { +class VrHidlTest : public ::testing::TestWithParam<std::string> { public: void SetUp() override { - vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>( - VrHidlEnvironment::Instance()->getServiceName<IVr>()); + vr = IVr::getService(GetParam()); ASSERT_NE(vr, nullptr); } @@ -54,19 +42,19 @@ class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase { }; // Sanity check that Vr::init does not crash. -TEST_F(VrHidlTest, Init) { +TEST_P(VrHidlTest, Init) { EXPECT_TRUE(vr->init().isOk()); } // Sanity check Vr::setVrMode is able to enable and disable VR mode. -TEST_F(VrHidlTest, SetVrMode) { +TEST_P(VrHidlTest, SetVrMode) { EXPECT_TRUE(vr->init().isOk()); EXPECT_TRUE(vr->setVrMode(true).isOk()); EXPECT_TRUE(vr->setVrMode(false).isOk()); } // Sanity check that Vr::init and Vr::setVrMode can be used in any order. -TEST_F(VrHidlTest, ReInit) { +TEST_P(VrHidlTest, ReInit) { EXPECT_TRUE(vr->init().isOk()); EXPECT_TRUE(vr->setVrMode(true).isOk()); EXPECT_TRUE(vr->init().isOk()); @@ -75,11 +63,8 @@ TEST_F(VrHidlTest, ReInit) { EXPECT_TRUE(vr->setVrMode(false).isOk()); } -int main(int argc, char **argv) { - ::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; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, VrHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IVr::descriptor)), + android::hardware::PrintInstanceNameToString); + |