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 };
36
SetUpTestCase()37 void NfcVendorAdaptionsTest::SetUpTestCase()
38 {
39 HDF_LOGD("SetUpTestCase NfcVendorAdaptionsTest");
40 }
41
TearDownTestCase()42 void NfcVendorAdaptionsTest::TearDownTestCase()
43 {
44 HDF_LOGD("TearDownTestCase NfcVendorAdaptionsTest");
45 }
46
SetUp()47 void NfcVendorAdaptionsTest::SetUp()
48 {
49 HDF_LOGD("SetUp NfcVendorAdaptionsTest");
50 }
51
TearDown()52 void NfcVendorAdaptionsTest::TearDown()
53 {
54 HDF_LOGD("TearDown NfcVendorAdaptionsTest");
55 }
56
57 /**
58 * @tc.name: VendorOpen001
59 * @tc.desc: Test NfcVendorAdaptionsTest VendorOpen.
60 * @tc.type: FUNC
61 */
62 HWTEST_F(NfcVendorAdaptionsTest, VendorOpen001, TestSize.Level1)
63 {
64 NfcStackCallbackT *pCback = nullptr;
65 NfcStackDataCallbackT *pDataCback = nullptr;
66 std::shared_ptr<NfcVendorAdaptions> nfcVendorAdaptions = std::make_shared<NfcVendorAdaptions>();
67 int ret = nfcVendorAdaptions->VendorOpen(pCback, pDataCback);
68 EXPECT_EQ(ret, HDF_FAILURE);
69 }
70
71 /**
72 * @tc.name: VendorCoreInitialized001
73 * @tc.desc: Test NfcVendorAdaptionsTest VendorCoreInitialized.
74 * @tc.type: FUNC
75 */
76 HWTEST_F(NfcVendorAdaptionsTest, VendorCoreInitialized001, TestSize.Level1)
77 {
78 uint16_t coreInitRspLen = 0;
79 uint8_t *pCoreInitRspParams = nullptr;
80 std::shared_ptr<NfcVendorAdaptions> nfcVendorAdaptions = std::make_shared<NfcVendorAdaptions>();
81 int ret = nfcVendorAdaptions->VendorCoreInitialized(coreInitRspLen, pCoreInitRspParams);
82 EXPECT_EQ(ret, HDF_FAILURE);
83 }
84
85 /**
86 * @tc.name: VendorWrite001
87 * @tc.desc: Test NfcVendorAdaptionsTest VendorWrite.
88 * @tc.type: FUNC
89 */
90 HWTEST_F(NfcVendorAdaptionsTest, VendorWrite001, TestSize.Level1)
91 {
92 uint16_t dataLen = 0;
93 uint8_t *pData = nullptr;
94 std::shared_ptr<NfcVendorAdaptions> nfcVendorAdaptions = std::make_shared<NfcVendorAdaptions>();
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 std::shared_ptr<NfcVendorAdaptions> nfcVendorAdaptions = std::make_shared<NfcVendorAdaptions>();
109 int ret = nfcVendorAdaptions->VendorIoctl(arg, pData);
110 EXPECT_EQ(ret, HDF_FAILURE);
111 }
112
113 /**
114 * @tc.name: VendorIoctlWithResponse001
115 * @tc.desc: Test NfcVendorAdaptionsTest VendorIoctlWithResponse.
116 * @tc.type: FUNC
117 */
118 HWTEST_F(NfcVendorAdaptionsTest, VendorIoctlWithResponse001, TestSize.Level1)
119 {
120 long arg = 0;
121 void *pData = nullptr;
122 std::vector<uint8_t> pRetVal;
123 std::shared_ptr<NfcVendorAdaptions> nfcVendorAdaptions = std::make_shared<NfcVendorAdaptions>();
124 int ret = nfcVendorAdaptions->VendorIoctlWithResponse(arg, pData, 0, pRetVal);
125 EXPECT_EQ(ret, HDF_FAILURE);
126 }
127
128 /**
129 * @tc.name: VendorShutdownCase001
130 * @tc.desc: Test NfcVendorAdaptionsTest VendorShutdownCase.
131 * @tc.type: FUNC
132 */
133 HWTEST_F(NfcVendorAdaptionsTest, VendorShutdownCase001, TestSize.Level1)
134 {
135 std::shared_ptr<NfcVendorAdaptions> nfcVendorAdaptions = std::make_shared<NfcVendorAdaptions>();
136 int ret = nfcVendorAdaptions->VendorShutdownCase();
137 EXPECT_EQ(ret, HDF_SUCCESS);
138 }
139 }
140 }
141 }
142 }