mirror of
https://gitee.com/openharmony/xts_hats
synced 2025-02-22 19:30:44 +00:00
parent
004abc90a0
commit
4fab1d5375
@ -27,6 +27,7 @@ ohos_moduletest_suite("HatsHdfNfcHdiTest") {
|
||||
deps = [
|
||||
"//drivers/interface/nfc/v1_0:libnfc_proxy_1.0",
|
||||
"//drivers/peripheral/nfc/hdi_service:hdi_nfc_service",
|
||||
"//foundation/communication/nfc/services:nfc_service",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
@ -41,6 +42,7 @@ ohos_moduletest_suite("HatsHdfNfcHdiTest") {
|
||||
"//third_party/nfc_hdiimpl/SN100x/halimpl/src/include/",
|
||||
"//third_party/libnfc-nci/SN100x/src/gki/ulinux/",
|
||||
"//third_party/libnfc-nci/SN100x/src/gki/common/",
|
||||
"//foundation/communication/nfc/services/src/utils/",
|
||||
]
|
||||
|
||||
if (is_standard_system) {
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "v1_0/infc_interface.h"
|
||||
#include "v1_0/nfc_types.h"
|
||||
#include "NfcAdaptation.h"
|
||||
|
||||
#include "nfc_chip_type_parser.h"
|
||||
|
||||
using namespace OHOS::HDI::Nfc::V1_0;
|
||||
using namespace testing::ext;
|
||||
@ -34,7 +34,7 @@ using INfcV1_0 = OHOS::HDI::Nfc::V1_0::INfcInterface;
|
||||
using OHOS::HDI::Nfc::V1_0::NfcStatus;
|
||||
using OHOS::HDI::Nfc::V1_0::NfcEvent;
|
||||
using OHOS::HDI::Nfc::V1_0::INfcCallback;
|
||||
using INfcV1_0 = OHOS::HDI::Nfc::V1_0::INfcInterface;
|
||||
using OHOS::NFC::NfcChipTypeParser;
|
||||
|
||||
extern "C" INfcInterface *NfcInterfaceImplGetInstance(void)
|
||||
{
|
||||
@ -55,14 +55,17 @@ namespace {
|
||||
|
||||
class NfcClientCallback : public INfcCallback {
|
||||
public:
|
||||
NfcClientCallback()
|
||||
{}
|
||||
virtual ~NfcClientCallback()
|
||||
{}
|
||||
NfcClientCallback(tHAL_NFC_CBACK* eventCallback, tHAL_NFC_DATA_CBACK dataCallback)
|
||||
{
|
||||
mEventCallback = eventCallback;
|
||||
mDataCallback = dataCallback;
|
||||
};
|
||||
virtual ~NfcClientCallback() = default;
|
||||
|
||||
int32_t OnData(const std::vector<uint8_t>& data)
|
||||
int32_t OnData(const std::vector<uint8_t>& data) override
|
||||
{
|
||||
if (mDataCallback != nullptr && !data.empty()) {
|
||||
mDataCallback(data.size(), (uint8_t *)&data[0]);
|
||||
@ -70,7 +73,7 @@ class NfcClientCallback : public INfcCallback {
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t OnEvent(NfcEvent event, NfcStatus status)
|
||||
int32_t OnEvent(NfcEvent event, NfcStatus status) override
|
||||
{
|
||||
if (mEventCallback != nullptr) {
|
||||
mEventCallback((uint8_t)event, (tHAL_NFC_STATUS)status);
|
||||
@ -124,6 +127,10 @@ static void DataCallback(uint16_t len, uint8_t *data)
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_Hdinfcopen_0100, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -138,6 +145,8 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_Hdinfcopen_0100, TestSize.Level2)
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_HdinfcCoreInitialized_0200
|
||||
* @tc.desc: Configures the nfc chip after initializing the nfc core.
|
||||
@ -145,6 +154,10 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_Hdinfcopen_0100, TestSize.Level2)
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcCoreInitialized_0200, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -154,6 +167,7 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcCoreInitialized_0200, TestSize.Le
|
||||
int32_t ret = mHal->CoreInitialized(data, nfcbtType);
|
||||
EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_HdinfcPrediscover_0300
|
||||
@ -162,6 +176,10 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcCoreInitialized_0200, TestSize.Le
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcPrediscover_0300, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -170,6 +188,7 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcPrediscover_0300, TestSize.Level2
|
||||
int32_t ret = mHal->Prediscover(nfcbtType);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_HdinfcWrite_0400
|
||||
@ -178,6 +197,10 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcPrediscover_0300, TestSize.Level2
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcWrite_0400, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -187,6 +210,7 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcWrite_0400, TestSize.Level2)
|
||||
int32_t ret = mHal->Write(data, nfcbtType);
|
||||
EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_HdinfcControlGranted_0500
|
||||
@ -195,6 +219,10 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcWrite_0400, TestSize.Level2)
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcControlGranted_0500, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -203,6 +231,7 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcControlGranted_0500, TestSize.Lev
|
||||
int32_t ret = mHal->ControlGranted(nfcbtType);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_HdinfcPowerCycle_0600
|
||||
@ -211,6 +240,10 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcControlGranted_0500, TestSize.Lev
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcPowerCycle_0600, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -219,6 +252,7 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcPowerCycle_0600, TestSize.Level2)
|
||||
int32_t ret = mHal->PowerCycle(nfcbtType);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_HdinfcIoctl_0700
|
||||
@ -227,6 +261,10 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcPowerCycle_0600, TestSize.Level2)
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcIoctl_0700, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -240,6 +278,7 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcIoctl_0700, TestSize.Level2)
|
||||
int32_t ret = mHal->Ioctl(nfcCommand, v_data, nfcbtType);
|
||||
EXPECT_EQ(HDF_ERR_INVALID_PARAM, ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SUB_DriverSystem_HdinfcClose_0800
|
||||
@ -248,6 +287,10 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcIoctl_0700, TestSize.Level2)
|
||||
*/
|
||||
HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcClose_0800, TestSize.Level2)
|
||||
{
|
||||
if (!NfcChipTypeParser::IsSn110()) {
|
||||
EXPECT_EQ(HDF_SUCCESS, HDF_SUCCESS);
|
||||
}
|
||||
else{
|
||||
if (mHal == nullptr) {
|
||||
ASSERT_NE(nullptr, mHal);
|
||||
return;
|
||||
@ -256,3 +299,4 @@ HWTEST_F(HdfNfcHdiTest, SUB_DriverSystem_HdinfcClose_0800, TestSize.Level2)
|
||||
int32_t ret = mHal->Close(nfcbtType);
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user