• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <gtest/gtest.h>
16 #include <thread>
17 #include <hdf_log.h>
18 
19 #include "nfc_vendor_adaptions.h"
20 #include "nfc_impl.h"
21 
22 namespace OHOS {
23 namespace HDI {
24 namespace Nfc {
25 namespace TEST {
26 using namespace testing;
27 using namespace testing::ext;
28 using namespace OHOS::HDI::Nfc;
29 class NfcVendorAdaptionsTest : public testing::Test {
30 public:
31     static void SetUpTestCase();
32     static void TearDownTestCase();
33     void SetUp();
34     void TearDown();
35 public:
36     std::shared_ptr<NfcVendorAdaptions> nfcVendorAdaptions = std::make_shared<NfcVendorAdaptions>();
37 };
38 
SetUpTestCase()39 void NfcVendorAdaptionsTest::SetUpTestCase()
40 {
41     HDF_LOGD("SetUpTestCase NfcVendorAdaptionsTest");
42 }
43 
TearDownTestCase()44 void NfcVendorAdaptionsTest::TearDownTestCase()
45 {
46     HDF_LOGD("TearDownTestCase NfcVendorAdaptionsTest");
47 }
48 
SetUp()49 void NfcVendorAdaptionsTest::SetUp()
50 {
51     sleep(1);
52     HDF_LOGD("SetUp NfcVendorAdaptionsTest");
53 }
54 
TearDown()55 void NfcVendorAdaptionsTest::TearDown()
56 {
57     HDF_LOGD("TearDown NfcVendorAdaptionsTest");
58 }
59 
60 /**
61  * @tc.name: VendorOpen001
62  * @tc.desc: Test NfcVendorAdaptionsTest VendorOpen.
63  * @tc.type: FUNC
64  */
65 HWTEST_F(NfcVendorAdaptionsTest, VendorOpen001, TestSize.Level1)
66 {
67     NfcStackCallbackT *pCback = nullptr;
68     NfcStackDataCallbackT *pDataCback = nullptr;
69     int ret = nfcVendorAdaptions->VendorOpen(pCback, pDataCback);
70     EXPECT_EQ(ret, HDF_FAILURE);
71 }
72 
73 /**
74  * @tc.name: VendorCoreInitialized001
75  * @tc.desc: Test NfcVendorAdaptionsTest VendorCoreInitialized.
76  * @tc.type: FUNC
77  */
78 HWTEST_F(NfcVendorAdaptionsTest, VendorCoreInitialized001, TestSize.Level1)
79 {
80     uint16_t coreInitRspLen = 0;
81     uint8_t *pCoreInitRspParams = nullptr;
82     int ret = nfcVendorAdaptions->VendorCoreInitialized(coreInitRspLen, pCoreInitRspParams);
83     EXPECT_EQ(ret, HDF_FAILURE);
84 }
85 
86 /**
87  * @tc.name: VendorWrite001
88  * @tc.desc: Test NfcVendorAdaptionsTest VendorWrite.
89  * @tc.type: FUNC
90  */
91 HWTEST_F(NfcVendorAdaptionsTest, VendorWrite001, TestSize.Level1)
92 {
93     uint16_t dataLen = 0;
94     uint8_t *pData = nullptr;
95     int ret = nfcVendorAdaptions->VendorWrite(dataLen, pData);
96     EXPECT_EQ(ret, HDF_FAILURE);
97 }
98 
99 /**
100  * @tc.name: VendorIoctl001
101  * @tc.desc: Test NfcVendorAdaptionsTest VendorIoctl.
102  * @tc.type: FUNC
103  */
104 HWTEST_F(NfcVendorAdaptionsTest, VendorIoctl001, TestSize.Level1)
105 {
106     long arg = 0;
107     void *pData = nullptr;
108     int ret = nfcVendorAdaptions->VendorIoctl(arg, pData);
109     EXPECT_EQ(ret, HDF_FAILURE);
110 }
111 
112 /**
113  * @tc.name: VendorIoctlWithResponse001
114  * @tc.desc: Test NfcVendorAdaptionsTest VendorIoctlWithResponse.
115  * @tc.type: FUNC
116  */
117 HWTEST_F(NfcVendorAdaptionsTest, VendorIoctlWithResponse001, TestSize.Level1)
118 {
119     long arg = 0;
120     void *pData = nullptr;
121     std::vector<uint8_t> pRetVal;
122     int ret = nfcVendorAdaptions->VendorIoctlWithResponse(arg, pData, 0, pRetVal);
123     EXPECT_EQ(ret, HDF_FAILURE);
124 }
125 
126 /**
127  * @tc.name: VendorShutdownCase001
128  * @tc.desc: Test NfcVendorAdaptionsTest VendorShutdownCase.
129  * @tc.type: FUNC
130  */
131 HWTEST_F(NfcVendorAdaptionsTest, VendorShutdownCase001, TestSize.Level1)
132 {
133     int ret = nfcVendorAdaptions->VendorShutdownCase();
134     EXPECT_EQ(ret, HDF_SUCCESS);
135 }
136 }
137 }
138 }
139 }