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