mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Convert nfc hal test to use VtsHalHidlTargetTestEnvBase"
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <VtsHalHidlTargetCallbackBase.h>
|
#include <VtsHalHidlTargetCallbackBase.h>
|
||||||
#include <VtsHalHidlTargetTestBase.h>
|
#include <VtsHalHidlTargetTestBase.h>
|
||||||
|
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||||
|
|
||||||
using ::android::hardware::nfc::V1_0::INfc;
|
using ::android::hardware::nfc::V1_0::INfc;
|
||||||
using ::android::hardware::nfc::V1_0::INfcClientCallback;
|
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.
|
// The main test class for NFC HIDL HAL.
|
||||||
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>();
|
nfc_ = ::testing::VtsHalHidlTargetTestBase::getService<INfc>(
|
||||||
|
NfcHidlEnvironment::Instance()->getServiceName<INfc>());
|
||||||
ASSERT_NE(nfc_, nullptr);
|
ASSERT_NE(nfc_, nullptr);
|
||||||
|
|
||||||
nfc_cb_ = new NfcClientCallback();
|
nfc_cb_ = new NfcClientCallback();
|
||||||
@@ -163,15 +179,6 @@ class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||||||
sp<NfcClientCallback> nfc_cb_;
|
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:
|
* OpenAndClose:
|
||||||
* Makes an open call, waits for NfcEvent.OPEN_CPLT
|
* Makes an open call, waits for NfcEvent.OPEN_CPLT
|
||||||
@@ -586,8 +593,9 @@ TEST_F(NfcHidlTest, OpenAfterOpen) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
|
::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance());
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
NfcHidlEnvironment::Instance()->init(&argc, argv);
|
||||||
|
|
||||||
std::system("svc nfc disable"); /* Turn off NFC */
|
std::system("svc nfc disable"); /* Turn off NFC */
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <VtsHalHidlTargetCallbackBase.h>
|
#include <VtsHalHidlTargetCallbackBase.h>
|
||||||
#include <VtsHalHidlTargetTestBase.h>
|
#include <VtsHalHidlTargetTestBase.h>
|
||||||
|
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||||
|
|
||||||
using ::android::hardware::nfc::V1_1::INfc;
|
using ::android::hardware::nfc::V1_1::INfc;
|
||||||
using ::android::hardware::nfc::V1_1::INfcClientCallback;
|
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.
|
// The main test class for NFC HIDL HAL.
|
||||||
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||||
public:
|
public:
|
||||||
@@ -127,15 +142,6 @@ class NfcHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||||||
sp<NfcClientCallback> nfc_cb_;
|
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
|
* factoryReset
|
||||||
* calls factoryReset()
|
* calls factoryReset()
|
||||||
@@ -204,8 +210,9 @@ TEST_F(NfcHidlTest, CloseForPowerCaseOffAfterClose) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
|
::testing::AddGlobalTestEnvironment(NfcHidlEnvironment::Instance());
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
NfcHidlEnvironment::Instance()->init(&argc, argv);
|
||||||
|
|
||||||
std::system("svc nfc disable"); /* Turn off NFC */
|
std::system("svc nfc disable"); /* Turn off NFC */
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
|||||||
Reference in New Issue
Block a user