mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
Convert nfc hal test to use VtsHalHidlTargetTestEnvBase
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalNfcV1_0Target
Change-Id: I7a66c98507811ea4f4a18a8e08476878dfd59748
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <VtsHalHidlTargetCallbackBase.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
using ::android::hardware::nfc::V1_0::INfc;
|
||||
using ::android::hardware::nfc::V1_0::INfcClientCallback;
|
||||
@@ -93,11 +94,26 @@ class NfcClientCallback
|
||||
};
|
||||
};
|
||||
|
||||
// Test environment for Nfc HIDL HAL.
|
||||
class NfcHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static NfcHidlEnvironment* Instance() {
|
||||
static NfcHidlEnvironment* instance = new NfcHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<INfc>(); }
|
||||
private:
|
||||
NfcHidlEnvironment() {}
|
||||
};
|
||||
|
||||
// The main test class for NFC HIDL HAL.
|
||||
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>();
|
||||
nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>(
|
||||
NfcHidlEnvironment::Instance()->getServiceName<INfc>());
|
||||
ASSERT_NE(nfc_, nullptr);
|
||||
|
||||
nfc_cb_ = new NfcClientCallback();
|
||||
@@ -163,15 +179,6 @@ class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
sp<NfcClientCallback> nfc_cb_;
|
||||
};
|
||||
|
||||
// A class for test environment setup (kept since this file is a template).
|
||||
class NfcHidlEnvironment : public ::testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {}
|
||||
virtual void TearDown() {}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
/*
|
||||
* OpenAndClose:
|
||||
* Makes an open call, waits for NfcEvent.OPEN_CPLT
|
||||
@@ -586,8 +593,9 @@ TEST_F(NfcHidlTest, OpenAfterOpen) {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
|
||||
::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
NfcHidlEnvironment::Instance()->init(&argc, argv);
|
||||
|
||||
std::system("svc nfc disable"); /* Turn off NFC */
|
||||
sleep(5);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <VtsHalHidlTargetCallbackBase.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
using ::android::hardware::nfc::V1_1::INfc;
|
||||
using ::android::hardware::nfc::V1_1::INfcClientCallback;
|
||||
@@ -78,6 +79,20 @@ class NfcClientCallback : public ::testing::VtsHalHidlTargetCallbackBase<NfcClie
|
||||
};
|
||||
};
|
||||
|
||||
// Test environment for Nfc HIDL HAL.
|
||||
class NfcHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static NfcHidlEnvironment* Instance() {
|
||||
static NfcHidlEnvironment* instance = new NfcHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<INfc>(); }
|
||||
private:
|
||||
NfcHidlEnvironment() {}
|
||||
};
|
||||
|
||||
// The main test class for NFC HIDL HAL.
|
||||
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
@@ -127,15 +142,6 @@ class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
sp<NfcClientCallback> nfc_cb_;
|
||||
};
|
||||
|
||||
// A class for test environment setup (kept since this file is a template).
|
||||
class NfcHidlEnvironment : public ::testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {}
|
||||
virtual void TearDown() {}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
/*
|
||||
* factoryReset
|
||||
* calls factoryReset()
|
||||
@@ -204,8 +210,9 @@ TEST_F(NfcHidlTest, CloseForPowerCaseOffAfterClose) {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
|
||||
::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
NfcHidlEnvironment::Instance()->init(&argc, argv);
|
||||
|
||||
std::system("svc nfc disable"); /* Turn off NFC */
|
||||
sleep(5);
|
||||
|
||||
Reference in New Issue
Block a user