diff options
author | Zhuoyao Zhang | 2018-02-08 23:00:15 -0600 |
---|---|---|
committer | Zhuoyao Zhang | 2018-02-10 14:44:54 -0600 |
commit | b4744d1460c284c72399f86528583f3bafb2d745 (patch) | |
tree | efe978d72cfda68847db753db0af7edc78d1bf30 /nfc/1.1 | |
parent | 8f7ff5730b152542d476b039b15601785e3b777a (diff) | |
download | platform-hardware-interfaces-b4744d1460c284c72399f86528583f3bafb2d745.tar.gz platform-hardware-interfaces-b4744d1460c284c72399f86528583f3bafb2d745.tar.xz platform-hardware-interfaces-b4744d1460c284c72399f86528583f3bafb2d745.zip |
Convert nfc hal test to use VtsHalHidlTargetTestEnvBase
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalNfcV1_0Target
Change-Id: I7a66c98507811ea4f4a18a8e08476878dfd59748
Diffstat (limited to 'nfc/1.1')
-rw-r--r-- | nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp b/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp index a5b40d47..bef412b6 100644 --- a/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp +++ b/nfc/1.1/vts/functional/VtsHalNfcV1_1TargetTest.cpp | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <VtsHalHidlTargetCallbackBase.h> | 26 | #include <VtsHalHidlTargetCallbackBase.h> |
27 | #include <VtsHalHidlTargetTestBase.h> | 27 | #include <VtsHalHidlTargetTestBase.h> |
28 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
28 | 29 | ||
29 | using ::android::hardware::nfc::V1_1::INfc; | 30 | using ::android::hardware::nfc::V1_1::INfc; |
30 | using ::android::hardware::nfc::V1_1::INfcClientCallback; | 31 | using ::android::hardware::nfc::V1_1::INfcClientCallback; |
@@ -78,6 +79,20 @@ class NfcClientCallback : public ::testing::VtsHalHidlTargetCallbackBase<NfcClie | |||
78 | }; | 79 | }; |
79 | }; | 80 | }; |
80 | 81 | ||
82 | // Test environment for Nfc HIDL HAL. | ||
83 | class NfcHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
84 | public: | ||
85 | // get the test environment singleton | ||
86 | static NfcHidlEnvironment* Instance() { | ||
87 | static NfcHidlEnvironment* instance = new NfcHidlEnvironment; | ||
88 | return instance; | ||
89 | } | ||
90 | |||
91 | virtual void registerTestServices() override { registerTestService<INfc>(); } | ||
92 | private: | ||
93 | NfcHidlEnvironment() {} | ||
94 | }; | ||
95 | |||
81 | // The main test class for NFC HIDL HAL. | 96 | // The main test class for NFC HIDL HAL. |
82 | class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 97 | class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
83 | public: | 98 | public: |
@@ -127,15 +142,6 @@ class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
127 | sp<NfcClientCallback> nfc_cb_; | 142 | sp<NfcClientCallback> nfc_cb_; |
128 | }; | 143 | }; |
129 | 144 | ||
130 | // A class for test environment setup (kept since this file is a template). | ||
131 | class NfcHidlEnvironment : public ::testing::Environment { | ||
132 | public: | ||
133 | virtual void SetUp() {} | ||
134 | virtual void TearDown() {} | ||
135 | |||
136 | private: | ||
137 | }; | ||
138 | |||
139 | /* | 145 | /* |
140 | * factoryReset | 146 | * factoryReset |
141 | * calls factoryReset() | 147 | * calls factoryReset() |
@@ -204,8 +210,9 @@ TEST_F(NfcHidlTest, CloseForPowerCaseOffAfterClose) { | |||
204 | } | 210 | } |
205 | 211 | ||
206 | int main(int argc, char** argv) { | 212 | int main(int argc, char** argv) { |
207 | ::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment); | 213 | ::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance()); |
208 | ::testing::InitGoogleTest(&argc, argv); | 214 | ::testing::InitGoogleTest(&argc, argv); |
215 | NfcHidlEnvironment::Instance()->init(&argc, argv); | ||
209 | 216 | ||
210 | std::system("svc nfc disable"); /* Turn off NFC */ | 217 | std::system("svc nfc disable"); /* Turn off NFC */ |
211 | sleep(5); | 218 | sleep(5); |