1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#include "hdi_input_test.h"
17094332d3Sopenharmony_ci#include <cstdint>
18094332d3Sopenharmony_ci#include <cstdio>
19094332d3Sopenharmony_ci#include <cstdlib>
20094332d3Sopenharmony_ci#include <string>
21094332d3Sopenharmony_ci#include <unistd.h>
22094332d3Sopenharmony_ci#include <fcntl.h>
23094332d3Sopenharmony_ci#include <gtest/gtest.h>
24094332d3Sopenharmony_ci#include <securec.h>
25094332d3Sopenharmony_ci#include "osal_time.h"
26094332d3Sopenharmony_ci#include "hdf_log.h"
27094332d3Sopenharmony_ci#include "input_manager.h"
28094332d3Sopenharmony_ci
29094332d3Sopenharmony_ciusing namespace testing::ext;
30094332d3Sopenharmony_ci
31094332d3Sopenharmony_ciIInputInterface *g_inputInterface;
32094332d3Sopenharmony_ciInputEventCb g_callback;
33094332d3Sopenharmony_ciInputHostCb g_hotplugCb;
34094332d3Sopenharmony_cistatic bool g_hasDev = false;
35094332d3Sopenharmony_ci
36094332d3Sopenharmony_cistatic void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg);
37094332d3Sopenharmony_cistatic void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex);
38094332d3Sopenharmony_cistatic void CloseOnlineDev(InputDevDesc *sta, int32_t len);
39094332d3Sopenharmony_cistatic void OpenOnlineDev(InputDevDesc *sta, int32_t len);
40094332d3Sopenharmony_ci
41094332d3Sopenharmony_ciclass HdiInputTest : public testing::Test {
42094332d3Sopenharmony_cipublic:
43094332d3Sopenharmony_ci    static void SetUpTestCase();
44094332d3Sopenharmony_ci    static void TearDownTestCase();
45094332d3Sopenharmony_ci    void SetUp();
46094332d3Sopenharmony_ci    void TearDown();
47094332d3Sopenharmony_ci};
48094332d3Sopenharmony_ci
49094332d3Sopenharmony_civoid HdiInputTest::SetUpTestCase()
50094332d3Sopenharmony_ci{
51094332d3Sopenharmony_ci    int32_t ret;
52094332d3Sopenharmony_ci    InputDevDesc sta[MAX_DEVICES];
53094332d3Sopenharmony_ci    ret = memset_s(sta, MAX_DEVICES * sizeof(InputDevDesc), 0, MAX_DEVICES * sizeof(InputDevDesc));
54094332d3Sopenharmony_ci    if (ret != 0) {
55094332d3Sopenharmony_ci        HDF_LOGE("memset failed");
56094332d3Sopenharmony_ci        return;
57094332d3Sopenharmony_ci    }
58094332d3Sopenharmony_ci    ret = GetInputInterface(&g_inputInterface);
59094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
60094332d3Sopenharmony_ci        HDF_LOGE("%s: get input hdi failed, ret %d", __func__, ret);
61094332d3Sopenharmony_ci    }
62094332d3Sopenharmony_ci
63094332d3Sopenharmony_ci    g_callback.EventPkgCallback = ReportEventPkgCallback;
64094332d3Sopenharmony_ci    g_hotplugCb.HotPlugCallback = ReportHotPlugEventPkgCallback;
65094332d3Sopenharmony_ci    ret = g_inputInterface->iInputManager->ScanInputDevice(sta, MAX_DEVICES);
66094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
67094332d3Sopenharmony_ci        HDF_LOGE("%s: scan device failed, ret %d", __func__, ret);
68094332d3Sopenharmony_ci    }
69094332d3Sopenharmony_ci    for (int32_t i = 0; i < MAX_DEVICES; i++) {
70094332d3Sopenharmony_ci        if (sta[i].devIndex == 0) {
71094332d3Sopenharmony_ci            break;
72094332d3Sopenharmony_ci        }
73094332d3Sopenharmony_ci        g_hasDev = true;
74094332d3Sopenharmony_ci    }
75094332d3Sopenharmony_ci}
76094332d3Sopenharmony_ci
77094332d3Sopenharmony_civoid HdiInputTest::TearDownTestCase()
78094332d3Sopenharmony_ci{
79094332d3Sopenharmony_ci    ReleaseInputInterface(&g_inputInterface);
80094332d3Sopenharmony_ci}
81094332d3Sopenharmony_ci
82094332d3Sopenharmony_civoid HdiInputTest::SetUp()
83094332d3Sopenharmony_ci{
84094332d3Sopenharmony_ci}
85094332d3Sopenharmony_ci
86094332d3Sopenharmony_civoid HdiInputTest::TearDown()
87094332d3Sopenharmony_ci{
88094332d3Sopenharmony_ci}
89094332d3Sopenharmony_ci
90094332d3Sopenharmony_ci#define INPUT_CHECK_NULL_POINTER(pointer, ret) do { \
91094332d3Sopenharmony_ci    if ((pointer) == NULL) { \
92094332d3Sopenharmony_ci        HDF_LOGE("%s: null pointer", __func__); \
93094332d3Sopenharmony_ci        ASSERT_EQ ((ret), INPUT_SUCCESS); \
94094332d3Sopenharmony_ci    } \
95094332d3Sopenharmony_ci} while (0)
96094332d3Sopenharmony_ci
97094332d3Sopenharmony_cistatic void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex)
98094332d3Sopenharmony_ci{
99094332d3Sopenharmony_ci    if (pkgs == NULL) {
100094332d3Sopenharmony_ci        return;
101094332d3Sopenharmony_ci    }
102094332d3Sopenharmony_ci    for (uint32_t i = 0; i < count; i++) {
103094332d3Sopenharmony_ci        printf("%s: pkgs[%u] = 0x%x, 0x%x, %d\n", __func__, i, pkgs[i]->type, pkgs[i]->code, pkgs[i]->value);
104094332d3Sopenharmony_ci    }
105094332d3Sopenharmony_ci}
106094332d3Sopenharmony_ci
107094332d3Sopenharmony_cistatic void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg)
108094332d3Sopenharmony_ci{
109094332d3Sopenharmony_ci    int32_t ret;
110094332d3Sopenharmony_ci    if (msg == NULL) {
111094332d3Sopenharmony_ci        return;
112094332d3Sopenharmony_ci    }
113094332d3Sopenharmony_ci    HDF_LOGI("%s: status =%d devId=%d type =%d", __func__, msg->status, msg->devIndex, msg->devType);
114094332d3Sopenharmony_ci
115094332d3Sopenharmony_ci    if (msg->status == 0) {
116094332d3Sopenharmony_ci        ret = g_inputInterface->iInputManager->OpenInputDevice(msg->devIndex);
117094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
118094332d3Sopenharmony_ci            HDF_LOGE("%s: open device[%u] failed, ret %d", __func__, msg->devIndex, ret);
119094332d3Sopenharmony_ci        }
120094332d3Sopenharmony_ci
121094332d3Sopenharmony_ci        ret  = g_inputInterface->iInputReporter->RegisterReportCallback(msg->devIndex, &g_callback);
122094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
123094332d3Sopenharmony_ci            HDF_LOGE("%s: register callback failed for device[%d], ret %d", __func__, msg->devIndex, ret);
124094332d3Sopenharmony_ci        }
125094332d3Sopenharmony_ci    } else {
126094332d3Sopenharmony_ci        ret = g_inputInterface->iInputReporter->UnregisterReportCallback(msg->devIndex);
127094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
128094332d3Sopenharmony_ci            HDF_LOGE("%s: unregister callback failed, ret %d", __func__, ret);
129094332d3Sopenharmony_ci        }
130094332d3Sopenharmony_ci
131094332d3Sopenharmony_ci        ret = g_inputInterface->iInputManager->CloseInputDevice(msg->devIndex);
132094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
133094332d3Sopenharmony_ci            HDF_LOGE("%s: close device failed, ret %d", __func__, ret);
134094332d3Sopenharmony_ci        }
135094332d3Sopenharmony_ci    }
136094332d3Sopenharmony_ci}
137094332d3Sopenharmony_ci
138094332d3Sopenharmony_cistatic void OpenOnlineDev(InputDevDesc *sta, int32_t len)
139094332d3Sopenharmony_ci{
140094332d3Sopenharmony_ci    int32_t ret = g_inputInterface->iInputManager->ScanInputDevice(sta, len);
141094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
142094332d3Sopenharmony_ci        HDF_LOGE("%s: scan device failed, ret %d", __func__, ret);
143094332d3Sopenharmony_ci    }
144094332d3Sopenharmony_ci    ASSERT_EQ(ret, INPUT_SUCCESS);
145094332d3Sopenharmony_ci
146094332d3Sopenharmony_ci    for (int32_t i = 0; i < len; i++) {
147094332d3Sopenharmony_ci        if (sta[i].devIndex == 0) {
148094332d3Sopenharmony_ci            break;
149094332d3Sopenharmony_ci        }
150094332d3Sopenharmony_ci        ret = g_inputInterface->iInputManager->OpenInputDevice(sta[i].devIndex);
151094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
152094332d3Sopenharmony_ci            HDF_LOGE("%s: open device[%d] failed, ret %d", __func__, sta[i].devIndex, ret);
153094332d3Sopenharmony_ci        }
154094332d3Sopenharmony_ci        ASSERT_EQ(ret, INPUT_SUCCESS);
155094332d3Sopenharmony_ci
156094332d3Sopenharmony_ci        ret  = g_inputInterface->iInputReporter->RegisterReportCallback(sta[i].devIndex, &g_callback);
157094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
158094332d3Sopenharmony_ci            HDF_LOGE("%s: register callback failed for device[%d], ret %d", __func__, sta[i].devIndex, ret);
159094332d3Sopenharmony_ci        }
160094332d3Sopenharmony_ci        ASSERT_EQ(ret, INPUT_SUCCESS);
161094332d3Sopenharmony_ci    }
162094332d3Sopenharmony_ci}
163094332d3Sopenharmony_ci
164094332d3Sopenharmony_cistatic void CloseOnlineDev(InputDevDesc *sta, int32_t len)
165094332d3Sopenharmony_ci{
166094332d3Sopenharmony_ci    int32_t ret = g_inputInterface->iInputManager->ScanInputDevice(sta, len);
167094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
168094332d3Sopenharmony_ci        HDF_LOGE("%s: scan device failed, ret %d", __func__, ret);
169094332d3Sopenharmony_ci    }
170094332d3Sopenharmony_ci    ASSERT_EQ(ret, INPUT_SUCCESS);
171094332d3Sopenharmony_ci
172094332d3Sopenharmony_ci    for (int32_t i = 0; i < len; i++) {
173094332d3Sopenharmony_ci        if (sta[i].devIndex == 0) {
174094332d3Sopenharmony_ci            break;
175094332d3Sopenharmony_ci        }
176094332d3Sopenharmony_ci        ret = g_inputInterface->iInputReporter->UnregisterReportCallback(sta[i].devIndex);
177094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
178094332d3Sopenharmony_ci            HDF_LOGE("%s: register callback failed for device[%d], ret %d", __func__, sta[i].devIndex, ret);
179094332d3Sopenharmony_ci        }
180094332d3Sopenharmony_ci        ASSERT_EQ(ret, INPUT_SUCCESS);
181094332d3Sopenharmony_ci
182094332d3Sopenharmony_ci        ret = g_inputInterface->iInputManager->CloseInputDevice(sta[i].devIndex);
183094332d3Sopenharmony_ci        if (ret != INPUT_SUCCESS) {
184094332d3Sopenharmony_ci            HDF_LOGE("%s: close device[%d] failed, ret %d", __func__, sta[i].devIndex, ret);
185094332d3Sopenharmony_ci        }
186094332d3Sopenharmony_ci        ASSERT_EQ(ret, INPUT_SUCCESS);
187094332d3Sopenharmony_ci    }
188094332d3Sopenharmony_ci}
189094332d3Sopenharmony_ci
190094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, ScanInputDevice, TestSize.Level1)
191094332d3Sopenharmony_ci{
192094332d3Sopenharmony_ci    InputDevDesc sta[MAX_DEVICES];
193094332d3Sopenharmony_ci
194094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] RegisterCallbackAndReportData001 enter", __func__);
195094332d3Sopenharmony_ci    int32_t ret;
196094332d3Sopenharmony_ci
197094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
198094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
199094332d3Sopenharmony_ci
200094332d3Sopenharmony_ci    ret  = g_inputInterface->iInputManager->ScanInputDevice(sta, sizeof(sta)/sizeof(InputDevDesc));
201094332d3Sopenharmony_ci    if (!ret) {
202094332d3Sopenharmony_ci        HDF_LOGI("%s:%d, %d, %d, %d", __func__, sta[0].devType, sta[0].devIndex, sta[1].devType, sta[1].devIndex);
203094332d3Sopenharmony_ci    }
204094332d3Sopenharmony_ci
205094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
206094332d3Sopenharmony_ci}
207094332d3Sopenharmony_ci
208094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, HotPlugCallback, TestSize.Level1)
209094332d3Sopenharmony_ci{
210094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] HotPlugCallback Testcase enter", __func__);
211094332d3Sopenharmony_ci    int32_t ret = INPUT_SUCCESS;
212094332d3Sopenharmony_ci    InputDevDesc sta[MAX_DEVICES];
213094332d3Sopenharmony_ci
214094332d3Sopenharmony_ci    ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
215094332d3Sopenharmony_ci    if (ret != 0) {
216094332d3Sopenharmony_ci        HDF_LOGE("%s: memcpy failed, line %d", __func__, __LINE__);
217094332d3Sopenharmony_ci    }
218094332d3Sopenharmony_ci
219094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
220094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
221094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
222094332d3Sopenharmony_ci
223094332d3Sopenharmony_ci    ret = g_inputInterface->iInputReporter->RegisterHotPlugCallback(&g_hotplugCb);
224094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
225094332d3Sopenharmony_ci        HDF_LOGE("%s: register hotplug callback failed for device manager, ret %d", __func__, ret);
226094332d3Sopenharmony_ci    }
227094332d3Sopenharmony_ci    ASSERT_EQ(ret, INPUT_SUCCESS);
228094332d3Sopenharmony_ci
229094332d3Sopenharmony_ci    OpenOnlineDev(sta, MAX_DEVICES);
230094332d3Sopenharmony_ci
231094332d3Sopenharmony_ci    HDF_LOGI("%s: wait 15s for testing, pls hotplug now", __func__);
232094332d3Sopenharmony_ci    HDF_LOGI("%s: The event data is as following:", __func__);
233094332d3Sopenharmony_ci    OsalMSleep(KEEP_ALIVE_TIME_MS);
234094332d3Sopenharmony_ci
235094332d3Sopenharmony_ci    ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
236094332d3Sopenharmony_ci    if (ret != 0) {
237094332d3Sopenharmony_ci        HDF_LOGE("%s: memcpy failed, line %d", __func__, __LINE__);
238094332d3Sopenharmony_ci    }
239094332d3Sopenharmony_ci
240094332d3Sopenharmony_ci    CloseOnlineDev(sta, MAX_DEVICES);
241094332d3Sopenharmony_ci
242094332d3Sopenharmony_ci    ret = g_inputInterface->iInputReporter->UnregisterHotPlugCallback();
243094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
244094332d3Sopenharmony_ci        HDF_LOGE("%s: unregister hotplug callback failed for device manager, ret %d", __func__, ret);
245094332d3Sopenharmony_ci    }
246094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
247094332d3Sopenharmony_ci}
248094332d3Sopenharmony_ci
249094332d3Sopenharmony_ci/**
250094332d3Sopenharmony_ci  * @tc.name: OpenInputDev001
251094332d3Sopenharmony_ci  * @tc.desc: open input device test
252094332d3Sopenharmony_ci  * @tc.type: FUNC
253094332d3Sopenharmony_ci  * @tc.require: AR000F867R, AR000F8QNL
254094332d3Sopenharmony_ci  */
255094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, OpenInputDev001, TestSize.Level1)
256094332d3Sopenharmony_ci{
257094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
258094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] OpenInputDev001 enter", __func__);
259094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
260094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
261094332d3Sopenharmony_ci    int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
262094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
263094332d3Sopenharmony_ci        HDF_LOGE("%s: open device1 failed, ret %d", __func__, ret);
264094332d3Sopenharmony_ci    }
265094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
266094332d3Sopenharmony_ci}
267094332d3Sopenharmony_ci
268094332d3Sopenharmony_ci/**
269094332d3Sopenharmony_ci  * @tc.name: OpenInputDevice002
270094332d3Sopenharmony_ci  * @tc.desc: open input device test
271094332d3Sopenharmony_ci  * @tc.type: FUNC
272094332d3Sopenharmony_ci  * @tc.require: AR000F867R
273094332d3Sopenharmony_ci  */
274094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, OpenInputDevice002, TestSize.Level1)
275094332d3Sopenharmony_ci{
276094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
277094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] OpenInputDev002 enter", __func__);
278094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
279094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
280094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
281094332d3Sopenharmony_ci    int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(INVALID_INDEX);
282094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
283094332d3Sopenharmony_ci        HDF_LOGE("%s: device5 dose not exist, can't open it, ret %d", __func__, ret);
284094332d3Sopenharmony_ci    }
285094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
286094332d3Sopenharmony_ci}
287094332d3Sopenharmony_ci
288094332d3Sopenharmony_ci/**
289094332d3Sopenharmony_ci  * @tc.name: CloseInputDevice001
290094332d3Sopenharmony_ci  * @tc.desc: close input device test
291094332d3Sopenharmony_ci  * @tc.type: FUNC
292094332d3Sopenharmony_ci  * @tc.require: AR000F867T, AR000F8QNL
293094332d3Sopenharmony_ci  */
294094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, CloseInputDevice001, TestSize.Level1)
295094332d3Sopenharmony_ci{
296094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
297094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] CloseInputDev001 enter", __func__);
298094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
299094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
300094332d3Sopenharmony_ci    int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
301094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
302094332d3Sopenharmony_ci        HDF_LOGE("%s: close device1 failed, ret %d", __func__, ret);
303094332d3Sopenharmony_ci    }
304094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
305094332d3Sopenharmony_ci}
306094332d3Sopenharmony_ci
307094332d3Sopenharmony_ci/**
308094332d3Sopenharmony_ci  * @tc.name: CloseInputDevice002
309094332d3Sopenharmony_ci  * @tc.desc: close input device test
310094332d3Sopenharmony_ci  * @tc.type: FUNC
311094332d3Sopenharmony_ci  * @tc.require: AR000F867T
312094332d3Sopenharmony_ci  */
313094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, CloseInputDevice002, TestSize.Level1)
314094332d3Sopenharmony_ci{
315094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
316094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] CloseInputDev002 enter", __func__);
317094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
318094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
319094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
320094332d3Sopenharmony_ci    int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(INVALID_INDEX);
321094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
322094332d3Sopenharmony_ci        HDF_LOGE("%s: device5 doesn't exist, can't close it, ret %d", __func__, ret);
323094332d3Sopenharmony_ci    }
324094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
325094332d3Sopenharmony_ci}
326094332d3Sopenharmony_ci
327094332d3Sopenharmony_ci/**
328094332d3Sopenharmony_ci  * @tc.name: GetInputDevice001
329094332d3Sopenharmony_ci  * @tc.desc: get input device info test
330094332d3Sopenharmony_ci  * @tc.type: FUNC
331094332d3Sopenharmony_ci  * @tc.require: AR000F867S
332094332d3Sopenharmony_ci  */
333094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetInputDevice001, TestSize.Level1)
334094332d3Sopenharmony_ci{
335094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
336094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetInputDevice001 enter", __func__);
337094332d3Sopenharmony_ci    InputDeviceInfo *dev = NULL;
338094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
339094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
340094332d3Sopenharmony_ci
341094332d3Sopenharmony_ci    int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
342094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
343094332d3Sopenharmony_ci        HDF_LOGE("%s: open device1 failed, ret %d", __func__, ret);
344094332d3Sopenharmony_ci    }
345094332d3Sopenharmony_ci    ASSERT_EQ(ret, INPUT_SUCCESS);
346094332d3Sopenharmony_ci
347094332d3Sopenharmony_ci    ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, &dev);
348094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
349094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1 failed, ret %d", __func__, ret);
350094332d3Sopenharmony_ci    }
351094332d3Sopenharmony_ci
352094332d3Sopenharmony_ci    HDF_LOGI("%s: devindex = %u, devType = %u", __func__, dev->devIndex,
353094332d3Sopenharmony_ci            dev->devType);
354094332d3Sopenharmony_ci    HDF_LOGI("%s: chipInfo = %s, vendorName = %s, chipName = %s",
355094332d3Sopenharmony_ci        __func__, dev->chipInfo, dev->vendorName, dev->chipName);
356094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
357094332d3Sopenharmony_ci}
358094332d3Sopenharmony_ci
359094332d3Sopenharmony_ci/**
360094332d3Sopenharmony_ci  * @tc.name: GetInputDeviceList001
361094332d3Sopenharmony_ci  * @tc.desc: get input device list info test
362094332d3Sopenharmony_ci  * @tc.type: FUNC
363094332d3Sopenharmony_ci  * @tc.require: AR000F8680
364094332d3Sopenharmony_ci  */
365094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetInputDeviceList001, TestSize.Level1)
366094332d3Sopenharmony_ci{
367094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
368094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetInputDeviceList001 enter", __func__);
369094332d3Sopenharmony_ci    int32_t ret;
370094332d3Sopenharmony_ci    uint32_t num = 0;
371094332d3Sopenharmony_ci    InputDeviceInfo *dev[MAX_INPUT_DEV_NUM] = {0};
372094332d3Sopenharmony_ci
373094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
374094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
375094332d3Sopenharmony_ci    ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, dev, MAX_INPUT_DEV_NUM);
376094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
377094332d3Sopenharmony_ci        HDF_LOGE("%s: get device list failed, ret %d", __func__, ret);
378094332d3Sopenharmony_ci    }
379094332d3Sopenharmony_ci    ret = num <= MAX_INPUT_DEV_NUM ? HDF_SUCCESS : HDF_FAILURE;  /* num <= MAX_INPUT_DEV_NUM return true */
380094332d3Sopenharmony_ci    ASSERT_EQ(ret, INPUT_SUCCESS);
381094332d3Sopenharmony_ci
382094332d3Sopenharmony_ci
383094332d3Sopenharmony_ci    for (uint32_t i = 0; i < num; i++) {
384094332d3Sopenharmony_ci        HDF_LOGI("%s: num = %u, device[%d]'s info is:", __func__, num, i);
385094332d3Sopenharmony_ci        HDF_LOGI("%s: index = %u, devType = %u", __func__, dev[i]->devIndex,
386094332d3Sopenharmony_ci                dev[i]->devType);
387094332d3Sopenharmony_ci        HDF_LOGI("%s: chipInfo = %s, vendorName = %s, chipName = %s",
388094332d3Sopenharmony_ci            __func__, dev[i]->chipInfo, dev[i]->vendorName, dev[i]->chipName);
389094332d3Sopenharmony_ci    }
390094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
391094332d3Sopenharmony_ci}
392094332d3Sopenharmony_ci
393094332d3Sopenharmony_ci/**
394094332d3Sopenharmony_ci  * @tc.name: GetDeviceType001
395094332d3Sopenharmony_ci  * @tc.desc: get input device type test
396094332d3Sopenharmony_ci  * @tc.type: FUNC
397094332d3Sopenharmony_ci  * @tc.require: AR000F8681, AR000F8QNL
398094332d3Sopenharmony_ci  */
399094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetDeviceType001, TestSize.Level1)
400094332d3Sopenharmony_ci{
401094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
402094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetDeviceType001 enter", __func__);
403094332d3Sopenharmony_ci    int32_t ret;
404094332d3Sopenharmony_ci    uint32_t devType = INIT_DEFAULT_VALUE;
405094332d3Sopenharmony_ci
406094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
407094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
408094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetDeviceType(TOUCH_INDEX, &devType);
409094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
410094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's type failed, ret %d", __func__, ret);
411094332d3Sopenharmony_ci    }
412094332d3Sopenharmony_ci    HDF_LOGI("%s: device1's type is %u", __func__, devType);
413094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
414094332d3Sopenharmony_ci}
415094332d3Sopenharmony_ci
416094332d3Sopenharmony_ci/**
417094332d3Sopenharmony_ci  * @tc.name: GetChipInfo001
418094332d3Sopenharmony_ci  * @tc.desc: get input device chip info test
419094332d3Sopenharmony_ci  * @tc.type: FUNC
420094332d3Sopenharmony_ci  * @tc.require: AR000F8682
421094332d3Sopenharmony_ci  */
422094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetChipInfo001, TestSize.Level1)
423094332d3Sopenharmony_ci{
424094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
425094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetChipInfo001 enter", __func__);
426094332d3Sopenharmony_ci    int32_t ret;
427094332d3Sopenharmony_ci    char chipInfo[CHIP_INFO_LEN] = {0};
428094332d3Sopenharmony_ci
429094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
430094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
431094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, chipInfo, CHIP_INFO_LEN);
432094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
433094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's chip info failed, ret %d", __func__, ret);
434094332d3Sopenharmony_ci    }
435094332d3Sopenharmony_ci    HDF_LOGI("%s: device1's chip info is %s", __func__, chipInfo);
436094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
437094332d3Sopenharmony_ci}
438094332d3Sopenharmony_ci
439094332d3Sopenharmony_ci/**
440094332d3Sopenharmony_ci  * @tc.name: GetInputDevice002
441094332d3Sopenharmony_ci  * @tc.desc: get input device chip info test
442094332d3Sopenharmony_ci  * @tc.type: FUNC
443094332d3Sopenharmony_ci  * @tc.require: AR000F8683
444094332d3Sopenharmony_ci  */
445094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetInputDevice002, TestSize.Level1)
446094332d3Sopenharmony_ci{
447094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
448094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetInputDevice002 enter", __func__);
449094332d3Sopenharmony_ci    int32_t ret;
450094332d3Sopenharmony_ci    InputDeviceInfo *dev = NULL;
451094332d3Sopenharmony_ci
452094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
453094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
454094332d3Sopenharmony_ci    ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, &dev);
455094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
456094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1 failed, ret %d", __func__, ret);
457094332d3Sopenharmony_ci    }
458094332d3Sopenharmony_ci
459094332d3Sopenharmony_ci    HDF_LOGI("%s: After fill the info, new device0's info is:", __func__);
460094332d3Sopenharmony_ci    HDF_LOGI("%s: new devindex = %u, devType = %u", __func__, dev->devIndex,
461094332d3Sopenharmony_ci            dev->devType);
462094332d3Sopenharmony_ci    HDF_LOGI("%s: new chipInfo = %s, vendorName = %s, chipName = %s",
463094332d3Sopenharmony_ci        __func__, dev->chipInfo, dev->vendorName, dev->chipName);
464094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
465094332d3Sopenharmony_ci}
466094332d3Sopenharmony_ci
467094332d3Sopenharmony_ci/**
468094332d3Sopenharmony_ci  * @tc.name: RegisterCallback001
469094332d3Sopenharmony_ci  * @tc.desc: get input device chip info test
470094332d3Sopenharmony_ci  * @tc.type: FUNC
471094332d3Sopenharmony_ci  * @tc.require: AR000F8684, AR000F8QNL
472094332d3Sopenharmony_ci  */
473094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, RegisterCallback001, TestSize.Level1)
474094332d3Sopenharmony_ci{
475094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
476094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] RegisterCallbac001 enter", __func__);
477094332d3Sopenharmony_ci    int32_t ret;
478094332d3Sopenharmony_ci
479094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
480094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
481094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
482094332d3Sopenharmony_ci    ret  = g_inputInterface->iInputReporter->RegisterReportCallback(INVALID_INDEX, &g_callback);
483094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
484094332d3Sopenharmony_ci        HDF_LOGE("%s: device2 dose not exist, can't register callback to it, ret %d", __func__, ret);
485094332d3Sopenharmony_ci    }
486094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
487094332d3Sopenharmony_ci}
488094332d3Sopenharmony_ci
489094332d3Sopenharmony_ci/**
490094332d3Sopenharmony_ci  * @tc.name: SetPowerStatus001
491094332d3Sopenharmony_ci  * @tc.desc: set device power status test
492094332d3Sopenharmony_ci  * @tc.type: FUNC
493094332d3Sopenharmony_ci  * @tc.require: AR000F867T
494094332d3Sopenharmony_ci  */
495094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, SetPowerStatus001, TestSize.Level1)
496094332d3Sopenharmony_ci{
497094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
498094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] SetPowerStatus001 enter", __func__);
499094332d3Sopenharmony_ci    int32_t ret;
500094332d3Sopenharmony_ci    uint32_t setStatus = INPUT_LOW_POWER;
501094332d3Sopenharmony_ci
502094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
503094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
504094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
505094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
506094332d3Sopenharmony_ci        HDF_LOGE("%s: set device1's power status failed, ret %d", __func__, ret);
507094332d3Sopenharmony_ci    }
508094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
509094332d3Sopenharmony_ci}
510094332d3Sopenharmony_ci
511094332d3Sopenharmony_ci/**
512094332d3Sopenharmony_ci  * @tc.name: SetPowerStatus002
513094332d3Sopenharmony_ci  * @tc.desc: set device power status test
514094332d3Sopenharmony_ci  * @tc.type: FUNC
515094332d3Sopenharmony_ci  * @tc.require: AR000F867T
516094332d3Sopenharmony_ci  */
517094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, SetPowerStatus002, TestSize.Level1)
518094332d3Sopenharmony_ci{
519094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
520094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] SetPowerStatus002 enter", __func__);
521094332d3Sopenharmony_ci    int32_t ret;
522094332d3Sopenharmony_ci    uint32_t setStatus = INPUT_LOW_POWER;
523094332d3Sopenharmony_ci
524094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
525094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
526094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
527094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->SetPowerStatus(INVALID_INDEX, setStatus);
528094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
529094332d3Sopenharmony_ci        HDF_LOGE("%s: set device5's power status failed, ret %d", __func__, ret);
530094332d3Sopenharmony_ci    }
531094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
532094332d3Sopenharmony_ci}
533094332d3Sopenharmony_ci
534094332d3Sopenharmony_ci/**
535094332d3Sopenharmony_ci  * @tc.name: GetPowerStatus001
536094332d3Sopenharmony_ci  * @tc.desc: get device power status test
537094332d3Sopenharmony_ci  * @tc.type: FUNC
538094332d3Sopenharmony_ci  * @tc.require: AR000F867S
539094332d3Sopenharmony_ci  */
540094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetPowerStatus001, TestSize.Level1)
541094332d3Sopenharmony_ci{
542094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
543094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetPowerStatus001 enter", __func__);
544094332d3Sopenharmony_ci    int32_t ret;
545094332d3Sopenharmony_ci    uint32_t getStatus = 0;
546094332d3Sopenharmony_ci
547094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
548094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
549094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
550094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
551094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's power status failed, ret %d", __func__, ret);
552094332d3Sopenharmony_ci    }
553094332d3Sopenharmony_ci    HDF_LOGI("%s: device1's power status is %d:", __func__, getStatus);
554094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
555094332d3Sopenharmony_ci}
556094332d3Sopenharmony_ci
557094332d3Sopenharmony_ci/**
558094332d3Sopenharmony_ci  * @tc.name: GetPowerStatus002
559094332d3Sopenharmony_ci  * @tc.desc: get device power status test
560094332d3Sopenharmony_ci  * @tc.type: FUNC
561094332d3Sopenharmony_ci  * @tc.require: AR000F867S
562094332d3Sopenharmony_ci  */
563094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetPowerStatus002, TestSize.Level1)
564094332d3Sopenharmony_ci{
565094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
566094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetPowerStatus002 enter", __func__);
567094332d3Sopenharmony_ci    int32_t ret;
568094332d3Sopenharmony_ci    uint32_t getStatus = 0;
569094332d3Sopenharmony_ci
570094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
571094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
572094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
573094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetPowerStatus(INVALID_INDEX, &getStatus);
574094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
575094332d3Sopenharmony_ci        HDF_LOGE("%s: get device5's power status failed, ret %d", __func__, ret);
576094332d3Sopenharmony_ci    }
577094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
578094332d3Sopenharmony_ci}
579094332d3Sopenharmony_ci
580094332d3Sopenharmony_ci/**
581094332d3Sopenharmony_ci  * @tc.name: GetVendorName001
582094332d3Sopenharmony_ci  * @tc.desc: get device vendor name test
583094332d3Sopenharmony_ci  * @tc.type: FUNC
584094332d3Sopenharmony_ci  * @tc.require: AR000F867T
585094332d3Sopenharmony_ci  */
586094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetVendorName001, TestSize.Level1)
587094332d3Sopenharmony_ci{
588094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
589094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetVendorName001 enter", __func__);
590094332d3Sopenharmony_ci    int32_t ret;
591094332d3Sopenharmony_ci    char vendorName[NAME_MAX_LEN] = {0};
592094332d3Sopenharmony_ci
593094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
594094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
595094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetVendorName(TOUCH_INDEX, vendorName, NAME_MAX_LEN);
596094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
597094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's vendor name failed, ret %d", __func__, ret);
598094332d3Sopenharmony_ci    }
599094332d3Sopenharmony_ci    HDF_LOGI("%s: device1's vendor name is %s:", __func__, vendorName);
600094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
601094332d3Sopenharmony_ci}
602094332d3Sopenharmony_ci
603094332d3Sopenharmony_ci/**
604094332d3Sopenharmony_ci  * @tc.name: GetVendorName002
605094332d3Sopenharmony_ci  * @tc.desc: get device vendor name test
606094332d3Sopenharmony_ci  * @tc.type: FUNC
607094332d3Sopenharmony_ci  * @tc.require: AR000F867T
608094332d3Sopenharmony_ci  */
609094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetVendorName002, TestSize.Level1)
610094332d3Sopenharmony_ci{
611094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
612094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetVendorName002 enter", __func__);
613094332d3Sopenharmony_ci    int32_t ret;
614094332d3Sopenharmony_ci    char vendorName[NAME_MAX_LEN] = {0};
615094332d3Sopenharmony_ci
616094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
617094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
618094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
619094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetVendorName(INVALID_INDEX, vendorName, NAME_MAX_LEN);
620094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
621094332d3Sopenharmony_ci        HDF_LOGE("%s: get device5's vendor name failed, ret %d", __func__, ret);
622094332d3Sopenharmony_ci    }
623094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
624094332d3Sopenharmony_ci}
625094332d3Sopenharmony_ci
626094332d3Sopenharmony_ci/**
627094332d3Sopenharmony_ci  * @tc.name: GetChipName001
628094332d3Sopenharmony_ci  * @tc.desc: get device chip name test
629094332d3Sopenharmony_ci  * @tc.type: FUNC
630094332d3Sopenharmony_ci  * @tc.require: AR000F867S
631094332d3Sopenharmony_ci  */
632094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetChipName001, TestSize.Level1)
633094332d3Sopenharmony_ci{
634094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
635094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetChipName001 enter", __func__);
636094332d3Sopenharmony_ci    int32_t ret;
637094332d3Sopenharmony_ci    char chipName[NAME_MAX_LEN] = {0};
638094332d3Sopenharmony_ci
639094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
640094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
641094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetChipName(TOUCH_INDEX, chipName, NAME_MAX_LEN);
642094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
643094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's chip name failed, ret %d", __func__, ret);
644094332d3Sopenharmony_ci    }
645094332d3Sopenharmony_ci    HDF_LOGI("%s: device1's chip name is %s", __func__, chipName);
646094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
647094332d3Sopenharmony_ci}
648094332d3Sopenharmony_ci
649094332d3Sopenharmony_ci/**
650094332d3Sopenharmony_ci  * @tc.name: GetChipName002
651094332d3Sopenharmony_ci  * @tc.desc: get device chip name test
652094332d3Sopenharmony_ci  * @tc.type: FUNC
653094332d3Sopenharmony_ci  * @tc.require: AR000F867S
654094332d3Sopenharmony_ci  */
655094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, GetChipName002, TestSize.Level1)
656094332d3Sopenharmony_ci{
657094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
658094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] GetChipName002 enter", __func__);
659094332d3Sopenharmony_ci    int32_t ret;
660094332d3Sopenharmony_ci    char chipName[NAME_MAX_LEN] = {0};
661094332d3Sopenharmony_ci
662094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
663094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
664094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
665094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->GetChipName(INVALID_INDEX, chipName, NAME_MAX_LEN);
666094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
667094332d3Sopenharmony_ci        HDF_LOGE("%s: get device5's chip name failed, ret %d", __func__, ret);
668094332d3Sopenharmony_ci    }
669094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
670094332d3Sopenharmony_ci}
671094332d3Sopenharmony_ci
672094332d3Sopenharmony_ci/**
673094332d3Sopenharmony_ci  * @tc.name: SetGestureMode001
674094332d3Sopenharmony_ci  * @tc.desc: set device gesture mode test
675094332d3Sopenharmony_ci  * @tc.type: FUNC
676094332d3Sopenharmony_ci  * @tc.require: AR000F867S
677094332d3Sopenharmony_ci  */
678094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, SetGestureMode001, TestSize.Level1)
679094332d3Sopenharmony_ci{
680094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
681094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] SetGestureMode001 enter", __func__);
682094332d3Sopenharmony_ci    int32_t ret;
683094332d3Sopenharmony_ci    uint32_t gestureMode = 1;
684094332d3Sopenharmony_ci
685094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
686094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
687094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->SetGestureMode(TOUCH_INDEX, gestureMode);
688094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
689094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's gestureMode failed, ret %d", __func__, ret);
690094332d3Sopenharmony_ci    }
691094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
692094332d3Sopenharmony_ci}
693094332d3Sopenharmony_ci
694094332d3Sopenharmony_ci/**
695094332d3Sopenharmony_ci  * @tc.name: SetGestureMode002
696094332d3Sopenharmony_ci  * @tc.desc: set device gesture mode test
697094332d3Sopenharmony_ci  * @tc.type: FUNC
698094332d3Sopenharmony_ci  * @tc.require: AR000F867S
699094332d3Sopenharmony_ci  */
700094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, SetGestureMode002, TestSize.Level1)
701094332d3Sopenharmony_ci{
702094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
703094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] SetGestureMode001 enter", __func__);
704094332d3Sopenharmony_ci    int32_t ret;
705094332d3Sopenharmony_ci    uint32_t gestureMode = 1;
706094332d3Sopenharmony_ci
707094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
708094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
709094332d3Sopenharmony_ci    /* Device "5" is used for testing nonexistent device node */
710094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->SetGestureMode(INVALID_INDEX, gestureMode);
711094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
712094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's gestureMode failed, ret %d", __func__, ret);
713094332d3Sopenharmony_ci    }
714094332d3Sopenharmony_ci    EXPECT_NE(ret, INPUT_SUCCESS);
715094332d3Sopenharmony_ci}
716094332d3Sopenharmony_ci
717094332d3Sopenharmony_ci/**
718094332d3Sopenharmony_ci  * @tc.name: RunCapacitanceTest001
719094332d3Sopenharmony_ci  * @tc.desc: set device gesture mode test
720094332d3Sopenharmony_ci  * @tc.type: FUNC
721094332d3Sopenharmony_ci  * @tc.require: AR000F867R
722094332d3Sopenharmony_ci  */
723094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, RunCapacitanceTest001, TestSize.Level1)
724094332d3Sopenharmony_ci{
725094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
726094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] RunCapacitanceTest001 enter", __func__);
727094332d3Sopenharmony_ci    int32_t ret;
728094332d3Sopenharmony_ci    char result[TEST_RESULT_LEN] = {0};
729094332d3Sopenharmony_ci    uint32_t testType = MMI_TEST;
730094332d3Sopenharmony_ci
731094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
732094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
733094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, TEST_RESULT_LEN);
734094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
735094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's gestureMode failed, ret %d", __func__, ret);
736094332d3Sopenharmony_ci    }
737094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
738094332d3Sopenharmony_ci}
739094332d3Sopenharmony_ci
740094332d3Sopenharmony_ci/**
741094332d3Sopenharmony_ci  * @tc.name: RunCapacitanceTest001
742094332d3Sopenharmony_ci  * @tc.desc: set device gesture mode test
743094332d3Sopenharmony_ci  * @tc.type: FUNC
744094332d3Sopenharmony_ci  * @tc.require: AR000F867R
745094332d3Sopenharmony_ci  */
746094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, RunExtraCommand001, TestSize.Level1)
747094332d3Sopenharmony_ci{
748094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
749094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] RunExtraCommand001 enter", __func__);
750094332d3Sopenharmony_ci    int32_t ret;
751094332d3Sopenharmony_ci    InputExtraCmd extraCmd = {0};
752094332d3Sopenharmony_ci    extraCmd.cmdCode = "WakeUpMode";
753094332d3Sopenharmony_ci    extraCmd.cmdValue = "Enable";
754094332d3Sopenharmony_ci
755094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
756094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
757094332d3Sopenharmony_ci    ret = g_inputInterface->iInputController->RunExtraCommand(TOUCH_INDEX, &extraCmd);
758094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
759094332d3Sopenharmony_ci        HDF_LOGE("%s: get device1's gestureMode failed, ret %d", __func__, ret);
760094332d3Sopenharmony_ci    }
761094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
762094332d3Sopenharmony_ci}
763094332d3Sopenharmony_ci
764094332d3Sopenharmony_ci/**
765094332d3Sopenharmony_ci  * @tc.name: RegisterCallbackAndReportData001
766094332d3Sopenharmony_ci  * @tc.desc: get input device chip info test
767094332d3Sopenharmony_ci  * @tc.type: FUNC
768094332d3Sopenharmony_ci  * @tc.require: AR000F8682, AR000F8QNL
769094332d3Sopenharmony_ci  */
770094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, RegisterCallbackAndReportData001, TestSize.Level1)
771094332d3Sopenharmony_ci{
772094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
773094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] RegisterCallbackAndReportData001 enter", __func__);
774094332d3Sopenharmony_ci    int32_t ret;
775094332d3Sopenharmony_ci
776094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
777094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
778094332d3Sopenharmony_ci
779094332d3Sopenharmony_ci    ret  = g_inputInterface->iInputReporter->RegisterReportCallback(TOUCH_INDEX, &g_callback);
780094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
781094332d3Sopenharmony_ci        HDF_LOGE("%s: register callback failed for device 1, ret %d", __func__, ret);
782094332d3Sopenharmony_ci    }
783094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
784094332d3Sopenharmony_ci    HDF_LOGI("%s: wait 15s for testing, pls touch the panel now", __func__);
785094332d3Sopenharmony_ci    HDF_LOGI("%s: The event data is as following:", __func__);
786094332d3Sopenharmony_ci    OsalMSleep(KEEP_ALIVE_TIME_MS);
787094332d3Sopenharmony_ci}
788094332d3Sopenharmony_ci
789094332d3Sopenharmony_ci/**
790094332d3Sopenharmony_ci  * @tc.name: UnregisterReportCallback001
791094332d3Sopenharmony_ci  * @tc.desc: get input device chip info test
792094332d3Sopenharmony_ci  * @tc.type: FUNC
793094332d3Sopenharmony_ci  * @tc.require: SR000F867Q
794094332d3Sopenharmony_ci  */
795094332d3Sopenharmony_ciHWTEST_F(HdiInputTest, UnregisterReportCallback001, TestSize.Level1)
796094332d3Sopenharmony_ci{
797094332d3Sopenharmony_ci    ASSERT_EQ(g_hasDev, true);
798094332d3Sopenharmony_ci    HDF_LOGI("%s: [Input] UnregisterReportCallback001 enter", __func__);
799094332d3Sopenharmony_ci    int32_t ret;
800094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
801094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
802094332d3Sopenharmony_ci    INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
803094332d3Sopenharmony_ci
804094332d3Sopenharmony_ci    ret  = g_inputInterface->iInputReporter->UnregisterReportCallback(TOUCH_INDEX);
805094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
806094332d3Sopenharmony_ci        HDF_LOGE("%s: unregister callback failed for device1, ret %d", __func__, ret);
807094332d3Sopenharmony_ci    }
808094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
809094332d3Sopenharmony_ci
810094332d3Sopenharmony_ci    ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
811094332d3Sopenharmony_ci    if (ret != INPUT_SUCCESS) {
812094332d3Sopenharmony_ci        HDF_LOGE("%s: close device1 failed, ret %d", __func__, ret);
813094332d3Sopenharmony_ci    }
814094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
815094332d3Sopenharmony_ci    HDF_LOGI("%s: Close the device1 successfully after all test", __func__);
816094332d3Sopenharmony_ci}
817