diff options
author | Zhuoyao Zhang | 2018-02-15 18:16:56 -0600 |
---|---|---|
committer | android-build-merger | 2018-02-15 18:16:56 -0600 |
commit | d776f7d1dc05f33017cc2d8a9f6b56f6d379437a (patch) | |
tree | 8daa25ef4e4b5c76818bab10966d6a82de0da867 /nfc/1.0 | |
parent | d571a2bc57410bedaba8f8725c268d99d0983fc2 (diff) | |
parent | ae709891abacf2de9c344b634a5b7b609587ee32 (diff) | |
download | platform-hardware-interfaces-d776f7d1dc05f33017cc2d8a9f6b56f6d379437a.tar.gz platform-hardware-interfaces-d776f7d1dc05f33017cc2d8a9f6b56f6d379437a.tar.xz platform-hardware-interfaces-d776f7d1dc05f33017cc2d8a9f6b56f6d379437a.zip |
Merge "Convert nfc hal test to use VtsHalHidlTargetTestEnvBase" am: 3ddc39293b am: 3cc658c11e
am: ae709891ab
Change-Id: I251b1c44adefd8e8e5cb0b341abfff5ce20ca3db
Diffstat (limited to 'nfc/1.0')
-rw-r--r-- | nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp index 2f00fbb8..e17c961d 100644 --- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp +++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp | |||
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #include <VtsHalHidlTargetCallbackBase.h> | 25 | #include <VtsHalHidlTargetCallbackBase.h> |
26 | #include <VtsHalHidlTargetTestBase.h> | 26 | #include <VtsHalHidlTargetTestBase.h> |
27 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
27 | 28 | ||
28 | using ::android::hardware::nfc::V1_0::INfc; | 29 | using ::android::hardware::nfc::V1_0::INfc; |
29 | using ::android::hardware::nfc::V1_0::INfcClientCallback; | 30 | using ::android::hardware::nfc::V1_0::INfcClientCallback; |
@@ -93,11 +94,26 @@ class NfcClientCallback | |||
93 | }; | 94 | }; |
94 | }; | 95 | }; |
95 | 96 | ||
97 | // Test environment for Nfc HIDL HAL. | ||
98 | class NfcHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
99 | public: | ||
100 | // get the test environment singleton | ||
101 | static NfcHidlEnvironment* Instance() { | ||
102 | static NfcHidlEnvironment* instance = new NfcHidlEnvironment; | ||
103 | return instance; | ||
104 | } | ||
105 | |||
106 | virtual void registerTestServices() override { registerTestService<INfc>(); } | ||
107 | private: | ||
108 | NfcHidlEnvironment() {} | ||
109 | }; | ||
110 | |||
96 | // The main test class for NFC HIDL HAL. | 111 | // The main test class for NFC HIDL HAL. |
97 | class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 112 | class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
98 | public: | 113 | public: |
99 | virtual void SetUp() override { | 114 | virtual void SetUp() override { |
100 | nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>(); | 115 | nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>( |
116 | NfcHidlEnvironment::Instance()->getServiceName<INfc>()); | ||
101 | ASSERT_NE(nfc_, nullptr); | 117 | ASSERT_NE(nfc_, nullptr); |
102 | 118 | ||
103 | nfc_cb_ = new NfcClientCallback(); | 119 | nfc_cb_ = new NfcClientCallback(); |
@@ -163,15 +179,6 @@ class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase { | |||
163 | sp<NfcClientCallback> nfc_cb_; | 179 | sp<NfcClientCallback> nfc_cb_; |
164 | }; | 180 | }; |
165 | 181 | ||
166 | // A class for test environment setup (kept since this file is a template). | ||
167 | class NfcHidlEnvironment : public ::testing::Environment { | ||
168 | public: | ||
169 | virtual void SetUp() {} | ||
170 | virtual void TearDown() {} | ||
171 | |||
172 | private: | ||
173 | }; | ||
174 | |||
175 | /* | 182 | /* |
176 | * OpenAndClose: | 183 | * OpenAndClose: |
177 | * Makes an open call, waits for NfcEvent.OPEN_CPLT | 184 | * Makes an open call, waits for NfcEvent.OPEN_CPLT |
@@ -586,8 +593,9 @@ TEST_F(NfcHidlTest, OpenAfterOpen) { | |||
586 | } | 593 | } |
587 | 594 | ||
588 | int main(int argc, char** argv) { | 595 | int main(int argc, char** argv) { |
589 | ::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment); | 596 | ::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance()); |
590 | ::testing::InitGoogleTest(&argc, argv); | 597 | ::testing::InitGoogleTest(&argc, argv); |
598 | NfcHidlEnvironment::Instance()->init(&argc, argv); | ||
591 | 599 | ||
592 | std::system("svc nfc disable"); /* Turn off NFC */ | 600 | std::system("svc nfc disable"); /* Turn off NFC */ |
593 | sleep(5); | 601 | sleep(5); |