diff options
author | Zhuoyao Zhang | 2018-02-09 14:43:24 -0600 |
---|---|---|
committer | android-build-merger | 2018-02-09 14:43:24 -0600 |
commit | 0f090a495b6a15af55841fc3b65e97a4de3ec1e5 (patch) | |
tree | 1f1706651a0f0763af76fc318d0d2d301c9d12a2 /vr | |
parent | 3818705c2de5c8efdf927b63f8bcfeb622003cc5 (diff) | |
parent | 92a1fbfe6e6cbab49e07a9454e78744cc554dd44 (diff) | |
download | platform-hardware-interfaces-0f090a495b6a15af55841fc3b65e97a4de3ec1e5.tar.gz platform-hardware-interfaces-0f090a495b6a15af55841fc3b65e97a4de3ec1e5.tar.xz 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')
-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 23f4c71d..b1656130 100644 --- a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp +++ b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #define LOG_TAG "vr_hidl_hal_test" | 17 | #define LOG_TAG "vr_hidl_hal_test" |
18 | #include <VtsHalHidlTargetTestBase.h> | 18 | #include <VtsHalHidlTargetTestBase.h> |
19 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
19 | #include <android-base/logging.h> | 20 | #include <android-base/logging.h> |
20 | #include <android/hardware/vr/1.0/IVr.h> | 21 | #include <android/hardware/vr/1.0/IVr.h> |
21 | #include <hardware/vr.h> | 22 | #include <hardware/vr.h> |
@@ -26,11 +27,24 @@ using ::android::hardware::Return; | |||
26 | using ::android::hardware::Void; | 27 | using ::android::hardware::Void; |
27 | using ::android::sp; | 28 | using ::android::sp; |
28 | 29 | ||
30 | // Test environment for Vr HIDL HAL. | ||
31 | class VrHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
32 | public: | ||
33 | // get the test environment singleton | ||
34 | static VrHidlEnvironment* Instance() { | ||
35 | static VrHidlEnvironment* instance = new VrHidlEnvironment; | ||
36 | return instance; | ||
37 | } | ||
38 | |||
39 | virtual void registerTestServices() override { registerTestService<IVr>(); } | ||
40 | }; | ||
41 | |||
29 | // The main test class for VR HIDL HAL. | 42 | // The main test class for VR HIDL HAL. |
30 | class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 43 | class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
31 | public: | 44 | public: |
32 | void SetUp() override { | 45 | void SetUp() override { |
33 | vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>(); | 46 | vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>( |
47 | VrHidlEnvironment::Instance()->getServiceName<IVr>()); | ||
34 | ASSERT_NE(vr, nullptr); | 48 | ASSERT_NE(vr, nullptr); |
35 | } | 49 | } |
36 | 50 | ||
@@ -39,16 +53,6 @@ class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
39 | sp<IVr> vr; | 53 | sp<IVr> vr; |
40 | }; | 54 | }; |
41 | 55 | ||
42 | |||
43 | // A class for test environment setup (kept since this file is a template). | ||
44 | class VrHidlEnvironment : public ::testing::Environment { | ||
45 | public: | ||
46 | void SetUp() {} | ||
47 | void TearDown() {} | ||
48 | |||
49 | private: | ||
50 | }; | ||
51 | |||
52 | // Sanity check that Vr::init does not crash. | 56 | // Sanity check that Vr::init does not crash. |
53 | TEST_F(VrHidlTest, Init) { | 57 | TEST_F(VrHidlTest, Init) { |
54 | EXPECT_TRUE(vr->init().isOk()); | 58 | EXPECT_TRUE(vr->init().isOk()); |
@@ -72,8 +76,9 @@ TEST_F(VrHidlTest, ReInit) { | |||
72 | } | 76 | } |
73 | 77 | ||
74 | int main(int argc, char **argv) { | 78 | int main(int argc, char **argv) { |
75 | ::testing::AddGlobalTestEnvironment(new VrHidlEnvironment); | 79 | ::testing::AddGlobalTestEnvironment(VrHidlEnvironment::Instance()); |
76 | ::testing::InitGoogleTest(&argc, argv); | 80 | ::testing::InitGoogleTest(&argc, argv); |
81 | VrHidlEnvironment::Instance()->init(&argc, argv); | ||
77 | int status = RUN_ALL_TESTS(); | 82 | int status = RUN_ALL_TESTS(); |
78 | ALOGI("Test result = %d", status); | 83 | ALOGI("Test result = %d", status); |
79 | return status; | 84 | return status; |