1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <cstdint>
16 #include <cstdio>
17 #include <cstdlib>
18 #include <fcntl.h>
19 #include <gtest/gtest.h>
20 #include <securec.h>
21 #include <string>
22 #include <unistd.h>
23 #include "input_uhdf_log.h"
24 #include "input_device_manager.h"
25 #include "input_manager.h"
26 #include "osal_time.h"
27 #include "osal_mem.h"
28 
29 using namespace testing::ext;
30 using namespace OHOS::Input;
31 static IInputInterface *g_inputInterface;
32 static InputEventCb g_callback;
33 static InputHostCb g_hotplugCb;
34 static int32_t g_touchIndex;
35 static uint32_t g_index = 1;
36 static int32_t g_fileDescriptorFirst = 3;
37 static int32_t g_fileDescriptorSecond = 4;
38 static uint32_t g_type = INDEV_TYPE_MOUSE;
39 static const int32_t KEEP_ALIVE_TIME_MS = 3000;
40 static const int32_t INVALID_INDEX = 15;
41 static const int32_t INVALID_INDEX1 = -1;
42 static const int32_t MAX_DEVICES = 32;
43 static const int32_t TEST_RESULT_LEN = 32;
44 static const int32_t TEST_TYPE = 2;
45 static const int32_t TEST_LEN1 = 10;
46 static const int32_t TEST_LEN2 = -1;
47 static const int32_t VALUE_NULL = 0;
48 static const int32_t VALUE_DEFAULT = 1;
49 static const uint32_t INIT_DEFAULT_VALUE = 255;
50 static const uint32_t STATUS = INPUT_DEVICE_STATUS_CLOSED;
51 static const string NODE_PATH = "dev/input/";
52 static const size_t COUNT = 1;
53 static const size_t INVALID_DEV_INDEX = 33;
54 
55 
56 class HdiInputTest : public testing::Test {
57 public:
58     static void SetUpTestCase();
59     static void TearDownTestCase();
60     void SetUp();
61     void TearDown();
62 };
63 
SetUpTestCase()64 void HdiInputTest::SetUpTestCase()
65 {
66     int32_t ret = GetInputInterface(&g_inputInterface);
67     if (ret != INPUT_SUCCESS) {
68         printf("%s: get input hdi failed, ret %d\n", __func__, ret);
69     }
70 }
71 
TearDownTestCase()72 void HdiInputTest::TearDownTestCase()
73 {
74     ReleaseInputInterface(&g_inputInterface);
75 }
76 
SetUp()77 void HdiInputTest::SetUp()
78 {
79 }
80 
TearDown()81 void HdiInputTest::TearDown()
82 {
83 }
84 
85 #define INPUT_CHECK_NULL_POINTER(pointer, ret) do { \
86     if ((pointer) == nullptr) { \
87         printf("%s: null pointer", __func__); \
88         ASSERT_EQ ((ret), INPUT_SUCCESS); \
89     } \
90 } while (0)
91 
ReportEventPkgCallback(const InputEventPackage ** pkgs,uint32_t count,uint32_t devIndex)92 static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex)
93 {
94     if (pkgs == nullptr) {
95         printf("%s: pkgs is null\n", __func__);
96         return;
97     }
98     for (uint32_t i = 0; i < count; i++) {
99         printf("device action Index: %u devIndex: %u type: %u code: %u value %d\n",
100             i, devIndex, pkgs[i]->type, pkgs[i]->code, pkgs[i]->value);
101     }
102 }
103 
ReportHotPlugEventPkgCallback(const InputHotPlugEvent * msg)104 static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg)
105 {
106     if (msg == nullptr) {
107         printf("%s: msg is null\n", __func__);
108         return;
109     }
110     printf("%s: device hotplug action devIndex: %u devType: %u status: %u\n", __func__,
111         msg->devIndex, msg->devType, msg->status);
112     if (msg->status == INPUT_DEVICE_STATUS_OPENED) {
113         EXPECT_EQ(g_inputInterface->iInputManager->OpenInputDevice(msg->devIndex), INPUT_SUCCESS);
114     } else if (msg->status == INPUT_DEVICE_STATUS_CLOSED) {
115         EXPECT_EQ(g_inputInterface->iInputManager->CloseInputDevice(msg->devIndex), INPUT_SUCCESS);
116     } else {
117         // do nothing
118     }
119 }
120 
121 /**
122   * @tc.name: ScanInputDevice001
123   * @tc.desc: scan input device test
124   * @tc.type: FUNC
125   * @tc.require: AR000F867R
126   */
127 HWTEST_F(HdiInputTest, ScanInputDevice001, TestSize.Level1)
128 {
129     InputDevDesc sta[MAX_DEVICES];
130     if (memset_s(sta, MAX_DEVICES * sizeof(InputDevDesc), 0, MAX_DEVICES * sizeof(InputDevDesc)) != EOK) {
131         printf("%s: memset_s failed\n", __func__);
132         return;
133     }
134     printf("%s: [Input] ScanInputDevice001 enter %d\n", __func__, __LINE__);
135     int32_t ret;
136     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
137     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
138     ret  = g_inputInterface->iInputManager->ScanInputDevice(sta, sizeof(sta) / sizeof(InputDevDesc));
139     if (ret == INPUT_SUCCESS) {
140         printf("%s: ScanInputDevice result: %d, %d, %d, %d\n",
141                __func__, sta[0].devType, sta[0].devIndex, sta[1].devType, sta[1].devIndex);
142     }
143     for (int32_t i = 1; i < MAX_DEVICES; i++) {
144         if (sta[i].devIndex == 0) {
145             break;
146         }
147         if (sta[i].devType == INDEV_TYPE_TOUCH) {
148             g_touchIndex = sta[i].devIndex;
149         }
150     }
151     EXPECT_EQ(ret, INPUT_SUCCESS);
152 }
153 
154 /**
155   * @tc.name: OpenInputDev001
156   * @tc.desc: open input device test
157   * @tc.type: FUNC
158   * @tc.require: AR000F867R
159   */
160 HWTEST_F(HdiInputTest, OpenInputDev001, TestSize.Level1)
161 {
162     printf("%s: [Input] OpenInputDev001 enter %d\n", __func__, __LINE__);
163     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
164     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
165     int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(VALUE_DEFAULT);
166     if (ret != INPUT_SUCCESS) {
167         printf("%s: open device1 failed, ret %d\n", __func__, ret);
168     }
169     EXPECT_EQ(ret, INPUT_SUCCESS);
170 }
171 
172 /**
173   * @tc.name: OpenInputDevice002
174   * @tc.desc: open input device test
175   * @tc.type: FUNC
176   * @tc.require: AR000F867R
177   */
178 HWTEST_F(HdiInputTest, OpenInputDevice002, TestSize.Level1)
179 {
180     printf("%s: [Input] OpenInputDev002 enter %d\n", __func__, __LINE__);
181     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
182     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
183     /* Device "15" is used for testing nonexistent device node */
184     int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(INVALID_INDEX);
185     if (ret != HDF_SUCCESS) {
186         printf("%s: device %d dose not exist, can't open it, ret %d\n", __func__, INVALID_INDEX, ret);
187     }
188     EXPECT_NE(ret, INPUT_SUCCESS);
189 }
190 
191 
192 /**
193   * @tc.name: OpenInputDevice003
194   * @tc.desc: open input device test
195   * @tc.type: FUNC
196   * @tc.require: AR000F867R
197   */
198 HWTEST_F(HdiInputTest, OpenInputDevice003, TestSize.Level1)
199 {
200     printf("%s: [Input] OpenInputDev003 enter %d\n", __func__, __LINE__);
201     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
202     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
203     /* Device "-1" is used for testing nonexistent device node */
204     int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(INVALID_INDEX1);
205     if (ret != HDF_SUCCESS) {
206         printf("%s: device %d dose not exist, can't open it, ret %d\n", __func__, INVALID_INDEX1, ret);
207     }
208     EXPECT_NE(ret, INPUT_SUCCESS);
209 }
210 
211 /**
212   * @tc.name: CloseInputDevice001
213   * @tc.desc: close input device test
214   * @tc.type: FUNC
215   * @tc.require: AR000F867T, AR000F8QNL
216   */
217 HWTEST_F(HdiInputTest, CloseInputDevice001, TestSize.Level1)
218 {
219     printf("%s: [Input] CloseInputDev001 enter %d\n", __func__, __LINE__);
220     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
221     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
222     int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(VALUE_DEFAULT);
223     if (ret != INPUT_SUCCESS) {
224         printf("%s: close device %d failed, ret %d\n", __func__, g_touchIndex, ret);
225     }
226     EXPECT_EQ(ret, INPUT_SUCCESS);
227 }
228 
229 /**
230   * @tc.name: CloseInputDevice002
231   * @tc.desc: close input device test
232   * @tc.type: FUNC
233   * @tc.require: AR000F867T
234   */
235 HWTEST_F(HdiInputTest, CloseInputDevice002, TestSize.Level1)
236 {
237     printf("%s: [Input] CloseInputDev002 enter %d\n", __func__, __LINE__);
238     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
239     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
240     /* Device "15" is used for testing nonexistent device node */
241     int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(INVALID_INDEX);
242     if (ret == INPUT_FAILURE) {
243         printf("%s: device %d doesn't exist, can't close it, ret %d\n", __func__, INVALID_INDEX, ret);
244     }
245     EXPECT_NE(ret, INPUT_SUCCESS);
246 }
247 
248 /**
249   * @tc.name: CloseInputDevice003
250   * @tc.desc: close input device test
251   * @tc.type: FUNC
252   * @tc.require: AR000F867T
253   */
254 HWTEST_F(HdiInputTest, CloseInputDevice003, TestSize.Level1)
255 {
256     printf("%s: [Input] CloseInputDev002 enter %d\n", __func__, __LINE__);
257     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
258     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
259     /* Device "-1" is used for testing nonexistent device node */
260     int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(INVALID_INDEX1);
261     if (ret == INPUT_FAILURE) {
262         printf("%s: device %d doesn't exist, can't close it, ret %d\n", __func__, INVALID_INDEX1, ret);
263     }
264     EXPECT_NE(ret, INPUT_SUCCESS);
265 }
266 
267 /**
268   * @tc.name: GetInputDevice001
269   * @tc.desc: get input device info test
270   * @tc.type: FUNC
271   * @tc.require: AR000F867S
272   */
273 HWTEST_F(HdiInputTest, GetInputDevice001, TestSize.Level1)
274 {
275     printf("%s: [Input] GetInputDevice001 enter %d\n", __func__, __LINE__);
276     InputDeviceInfo *dev = nullptr;
277     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
278     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
279     int32_t ret = g_inputInterface->iInputManager->GetInputDevice(g_touchIndex, &dev);
280     if (ret != INPUT_SUCCESS) {
281         printf("%s: get device %d failed, ret %d\n", __func__, g_touchIndex, ret);
282     }
283     printf("GetInputDevice001 %s: devIndex = %u, devType = %u\n", __func__, dev->devIndex, dev->devType);
284     printf("GetInputDevice001: chipInfo = %s, vendorName = %s, chipName = %s, devName = %s\n",
285         dev->chipInfo, dev->vendorName, dev->chipName, dev->attrSet.devName);
286     printf("GetInputDevice001: busType = %u, vendor = %u, product = %u, version = %u\n",
287         dev->attrSet.id.busType, dev->attrSet.id.vendor, dev->attrSet.id.product, dev->attrSet.id.version);
288     EXPECT_EQ(ret, INPUT_SUCCESS);
289 }
290 
291 /**
292   * @tc.name: GetInputDevice002
293   * @tc.desc: get input device info test
294   * @tc.type: FUNC
295   * @tc.require: AR000F867S
296   */
297 HWTEST_F(HdiInputTest, GetInputDevice002, TestSize.Level1)
298 {
299     printf("%s: [Input] GetInputDevice002 enter %d\n", __func__, __LINE__);
300     InputDeviceInfo *dev = nullptr;
301     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
302     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
303     int32_t ret = g_inputInterface->iInputManager->GetInputDevice(INVALID_INDEX1, &dev);
304     if (ret != INPUT_SUCCESS) {
305         printf("%s: get device %d failed, ret %d\n", __func__, INVALID_INDEX1, ret);
306     }
307     EXPECT_NE(ret, INPUT_SUCCESS);
308 }
309 
310 /**
311   * @tc.name: GetInputDevice003
312   * @tc.desc: get input device info test
313   * @tc.type: FUNC
314   * @tc.require: AR000F867S
315   */
316 HWTEST_F(HdiInputTest, GetInputDevice003, TestSize.Level1)
317 {
318     printf("%s: [Input] GetInputDevice003 enter %d\n", __func__, __LINE__);
319     InputDeviceInfo *dev = nullptr;
320     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
321     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
322     int32_t ret = g_inputInterface->iInputManager->GetInputDevice(INVALID_INDEX, &dev);
323     if (ret != INPUT_SUCCESS) {
324         printf("%s: get device %d failed, ret %d\n", __func__, INVALID_INDEX, ret);
325     }
326     EXPECT_NE(ret, INPUT_SUCCESS);
327 }
328 
329 /**
330   * @tc.name: GetInputDeviceList001
331   * @tc.desc: get input device list info test
332   * @tc.type: FUNC
333   * @tc.require: AR000F8680
334   */
335 HWTEST_F(HdiInputTest, GetInputDeviceList001, TestSize.Level1)
336 {
337     printf("%s: [Input] GetInputDeviceList001 enter\n", __func__);
338     int32_t ret;
339     uint32_t num = 0;
340     InputDeviceInfo *dev = nullptr;
341     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
342     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
343     ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, &dev, MAX_INPUT_DEV_NUM);
344     if (ret != INPUT_SUCCESS) {
345         printf("%s: get device list failed, ret %d\n", __func__, ret);
346     }
347     /* num <= MAX_INPUT_DEV_NUM return true */
348     ASSERT_LE(num, MAX_INPUT_DEV_NUM);
349     for (uint32_t i = 0; i < num; i++) {
350         printf("%s: num = %u, device[%u]'s info is:\n", __func__, num, i);
351         printf("%s: index = %u, devType = %u\n", __func__, (dev + i)->devIndex, (dev + i)->devType);
352         printf("%s: chipInfo = %s, vendorName = %s, chipName = %s, devName = %s\n",
353             __func__, (dev + i)->chipInfo, (dev + i)->vendorName, (dev + i)->chipName, (dev + i)->attrSet.devName);
354     }
355     EXPECT_EQ(ret, INPUT_SUCCESS);
356 }
357 
358 /**
359   * @tc.name: RegisterCallbackAndReportData001
360   * @tc.desc: get input device chip info test
361   * @tc.type: FUNC
362   * @tc.require: AR000F8682, AR000F8QNL
363   */
364 HWTEST_F(HdiInputTest, RegisterCallbackAndReportData001, TestSize.Level1)
365 {
366     printf("%s: [Input] RegisterCallbackAndReportData001 enter\n", __func__);
367     int32_t ret;
368     g_callback.EventPkgCallback = ReportEventPkgCallback;
369     g_hotplugCb.HotPlugCallback = ReportHotPlugEventPkgCallback;
370     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
371     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
372     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
373     ret  = g_inputInterface->iInputReporter->RegisterReportCallback(g_touchIndex, &g_callback);
374     if (ret != INPUT_SUCCESS) {
375         printf("%s: register callback failed for device %d, ret %d\n", __func__, g_touchIndex, ret);
376     }
377     EXPECT_EQ(ret, INPUT_SUCCESS);
378     ret = g_inputInterface->iInputManager->OpenInputDevice(VALUE_DEFAULT);
379     EXPECT_EQ(ret, INPUT_SUCCESS);
380     printf("%s: wait 3s for testing, pls touch the panel now\n", __func__);
381     printf("%s: The event data is as following:\n", __func__);
382     OsalMSleep(KEEP_ALIVE_TIME_MS);
383 }
384 
385 /**
386   * @tc.name: RegisterReportCallback001
387   * @tc.desc: register report callback fail
388   * @tc.type: FUNC
389   * @tc.require: AR000F8682, AR000F8QNL
390   */
391 HWTEST_F(HdiInputTest, RegisterReportCallback001, TestSize.Level1)
392 {
393     printf("%s: [Input] RegisterReportCallback001 enter\n", __func__);
394     InputDeviceManager iInputDeviceManager;
395     int32_t ret;
396     ret = iInputDeviceManager.RegisterReportCallback(0, nullptr);
397     if (ret != INPUT_SUCCESS) {
398         printf("%s: register report callback failed, ret %d\n", __func__, ret);
399     }
400     EXPECT_NE(ret, INPUT_SUCCESS);
401 }
402 
403 /**
404   * @tc.name: UnregisterReportCallback001
405   * @tc.desc: get input device chip info test
406   * @tc.type: FUNC
407   * @tc.require: SR000F867Q
408   */
409 HWTEST_F(HdiInputTest, UnregisterReportCallback001, TestSize.Level1)
410 {
411     printf("%s: [Input] UnregisterReportCallback001 enter\n", __func__);
412     int32_t ret;
413     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
414     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
415     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
416 
417     ret  = g_inputInterface->iInputReporter->UnregisterReportCallback(g_touchIndex);
418     if (ret != INPUT_SUCCESS) {
419         printf("%s: unregister callback failed for device %d, ret %d\n", __func__, g_touchIndex, ret);
420     }
421     EXPECT_EQ(ret, INPUT_SUCCESS);
422     ret = g_inputInterface->iInputManager->CloseInputDevice(VALUE_DEFAULT);
423     if (ret != INPUT_SUCCESS) {
424         printf("%s: close device %d failed, ret %d\n", __func__, g_touchIndex, ret);
425     }
426     EXPECT_EQ(ret, INPUT_SUCCESS);
427 }
428 
429 /**
430   * @tc.name: UnRegisterReportCallback001
431   * @tc.desc: unregister report callback fail
432   * @tc.type: FUNC
433   * @tc.require: AR000F8682, AR000F8QNL
434   */
435 HWTEST_F(HdiInputTest, UnRegisterReportCallback001, TestSize.Level1)
436 {
437     printf("%s: [Input] UnRegisterReportCallback001 enter\n", __func__);
438     int32_t ret;
439     InputDeviceManager iInputDeviceManager;
440     ret = iInputDeviceManager.UnregisterReportCallback(INVALID_DEV_INDEX);
441     if (ret != INPUT_SUCCESS) {
442         printf("%s: unregister report callback failed, ret %d\n", __func__, ret);
443     }
444     EXPECT_NE(ret, INPUT_SUCCESS);
445 }
446 
447 
448 /**
449   * @tc.name: FindIndexFromFd
450   * @tc.desc: find index from fd test
451   * @tc.type: FUNC
452   * @tc.require: SR000F867Q
453   */
454 HWTEST_F(HdiInputTest, FindIndexFromFd001, TestSize.Level1)
455 {
456     printf("%s: [Input] FindIndexFromFd001 enter\n", __func__);
457     int32_t ret;
458     InputDeviceManager InputDeviceManagerTest;
459     int32_t fd = VALUE_NULL;
460     uint32_t index = VALUE_NULL;
461     ret = InputDeviceManagerTest.FindIndexFromFd(fd, &index);
462     if (ret != INPUT_SUCCESS) {
463         printf("%s: find index from fd failed, ret %d\n", __func__, ret);
464     }
465     EXPECT_NE(ret, INPUT_SUCCESS);
466 }
467 
468 /**
469   * @tc.name: FindIndexFromDevName
470   * @tc.desc: find index from device name test
471   * @tc.type: FUNC
472   * @tc.require: SR000F867Q
473   */
474 HWTEST_F(HdiInputTest, FindIndexFromDevName001, TestSize.Level1)
475 {
476     printf("%s: [Input] FindIndexFromDevName001 enter\n", __func__);
477     int32_t ret;
478     InputDeviceManager InputDeviceManagerTest;
479     string devName = "MOUSE1";
480     uint32_t index = VALUE_NULL;
481     ret = InputDeviceManagerTest.FindIndexFromDevName(devName, &index);
482     if (ret != INPUT_SUCCESS) {
483         printf("%s: find index from device name failed, ret %d\n", __func__, ret);
484     }
485     EXPECT_NE(ret, INPUT_SUCCESS);
486 }
487 
488 /**
489   * @tc.name: SetPowerStatus
490   * @tc.desc: set power status test
491   * @tc.type: FUNC
492   * @tc.require: SR000F867Q
493   */
494 HWTEST_F(HdiInputTest, SetPowerStatus001, TestSize.Level1)
495 {
496     printf("%s: [Input] SetPowerStatus001 enter\n", __func__);
497     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
498     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
499 
500     int32_t ret;
501     uint32_t status = VALUE_NULL;
502     ret = g_inputInterface->iInputController->SetPowerStatus(g_touchIndex, status);
503     if (ret != INPUT_SUCCESS) {
504         printf("%s: set power status failed, ret %d\n", __func__, ret);
505     }
506     EXPECT_EQ(ret, INPUT_SUCCESS);
507 }
508 
509 /**
510   * @tc.name: SetPowerStatus
511   * @tc.desc: set power status test
512   * @tc.type: FUNC
513   * @tc.require: SR000F867Q
514   */
515 HWTEST_F(HdiInputTest, SetPowerStatus002, TestSize.Level1)
516 {
517     printf("%s: [Input] SetPowerStatus002 enter\n", __func__);
518     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
519     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
520 
521     int32_t ret;
522     uint32_t status = VALUE_NULL;
523     ret = g_inputInterface->iInputController->SetPowerStatus(INVALID_INDEX, status);
524     if (ret != INPUT_SUCCESS) {
525         printf("%s: set power status failed, ret %d\n", __func__, ret);
526     }
527     EXPECT_NE(ret, INPUT_SUCCESS);
528 }
529 
530 /**
531   * @tc.name: SetPowerStatus
532   * @tc.desc: set power status test
533   * @tc.type: FUNC
534   * @tc.require: SR000F867Q
535   */
536 HWTEST_F(HdiInputTest, SetPowerStatus003, TestSize.Level1)
537 {
538     printf("%s: [Input] SetPowerStatus003 enter\n", __func__);
539     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
540     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
541 
542     int32_t ret;
543     uint32_t status = VALUE_NULL;
544     ret = g_inputInterface->iInputController->SetPowerStatus(INVALID_INDEX1, status);
545     if (ret != INPUT_SUCCESS) {
546         printf("%s: set power status failed, ret %d\n", __func__, ret);
547     }
548     EXPECT_NE(ret, INPUT_SUCCESS);
549 }
550 
551 /**
552   * @tc.name: GetPowerStatus
553   * @tc.desc: get power status test
554   * @tc.type: FUNC
555   * @tc.require: SR000F867Q
556   */
557 HWTEST_F(HdiInputTest, GetPowerStatus001, TestSize.Level1)
558 {
559     printf("%s: [Input] GetPowerStatus001 enter\n", __func__);
560     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
561     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
562 
563     int32_t ret;
564     uint32_t status = VALUE_NULL;
565     ret = g_inputInterface->iInputController->GetPowerStatus(g_touchIndex, &status);
566     if (ret != INPUT_SUCCESS) {
567         printf("%s: get power status failed, ret %d\n", __func__, ret);
568     }
569     EXPECT_EQ(ret, INPUT_SUCCESS);
570 }
571 
572 /**
573   * @tc.name: GetPowerStatus
574   * @tc.desc: get power status test
575   * @tc.type: FUNC
576   * @tc.require: SR000F867Q
577   */
578 HWTEST_F(HdiInputTest, GetPowerStatus002, TestSize.Level1)
579 {
580     printf("%s: [Input] GetPowerStatus002 enter\n", __func__);
581     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
582     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
583 
584     int32_t ret;
585     uint32_t status = VALUE_NULL;
586     ret = g_inputInterface->iInputController->GetPowerStatus(INVALID_INDEX, &status);
587     if (ret != INPUT_SUCCESS) {
588         printf("%s: get power status failed, ret %d\n", __func__, ret);
589     }
590     EXPECT_NE(ret, INPUT_SUCCESS);
591 }
592 
593 /**
594   * @tc.name: GetPowerStatus
595   * @tc.desc: get power status test
596   * @tc.type: FUNC
597   * @tc.require: SR000F867Q
598   */
599 HWTEST_F(HdiInputTest, GetPowerStatus003, TestSize.Level1)
600 {
601     printf("%s: [Input] GetPowerStatus003 enter\n", __func__);
602     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
603     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
604 
605     int32_t ret;
606     uint32_t status = VALUE_NULL;
607     ret = g_inputInterface->iInputController->GetPowerStatus(INVALID_INDEX1, &status);
608     if (ret != INPUT_SUCCESS) {
609         printf("%s: get power status failed, ret %d\n", __func__, ret);
610     }
611     EXPECT_NE(ret, INPUT_SUCCESS);
612 }
613 
614 /**
615   * @tc.name: GetDeviceType
616   * @tc.desc: get device type test
617   * @tc.type: FUNC
618   * @tc.require: SR000F867Q
619   */
620 HWTEST_F(HdiInputTest, GetDeviceType001, TestSize.Level1)
621 {
622     printf("%s: [Input] GetDeviceType001 enter\n", __func__);
623     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
624     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
625 
626     int32_t ret;
627     uint32_t deviceType = INIT_DEFAULT_VALUE;
628     ret = g_inputInterface->iInputController->GetDeviceType(g_touchIndex, &deviceType);
629     if (ret != INPUT_SUCCESS) {
630         printf("%s: get device type failed, ret %d\n", __func__, ret);
631     }
632     EXPECT_EQ(ret, INPUT_SUCCESS);
633 }
634 
635 /**
636   * @tc.name: GetDeviceType
637   * @tc.desc: get device type test
638   * @tc.type: FUNC
639   * @tc.require: SR000F867Q
640   */
641 HWTEST_F(HdiInputTest, GetDeviceType002, TestSize.Level1)
642 {
643     printf("%s: [Input] GetDeviceType002 enter\n", __func__);
644     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
645     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
646 
647     int32_t ret;
648     uint32_t deviceType = INIT_DEFAULT_VALUE;
649     ret = g_inputInterface->iInputController->GetDeviceType(INVALID_INDEX, &deviceType);
650     if (ret != INPUT_SUCCESS) {
651         printf("%s: get device type failed, ret %d\n", __func__, ret);
652     }
653     EXPECT_NE(ret, INPUT_SUCCESS);
654 }
655 
656 /**
657   * @tc.name: GetDeviceType
658   * @tc.desc: get device type test
659   * @tc.type: FUNC
660   * @tc.require: SR000F867Q
661   */
662 HWTEST_F(HdiInputTest, GetDeviceType003, TestSize.Level1)
663 {
664     printf("%s: [Input] GetDeviceType003 enter\n", __func__);
665     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
666     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
667 
668     int32_t ret;
669     uint32_t deviceType = INIT_DEFAULT_VALUE;
670     ret = g_inputInterface->iInputController->GetDeviceType(INVALID_INDEX1, &deviceType);
671     if (ret != INPUT_SUCCESS) {
672         printf("%s: get device type failed, ret %d\n", __func__, ret);
673     }
674     EXPECT_NE(ret, INPUT_SUCCESS);
675 }
676 
677 /**
678   * @tc.name: GetChipInfo
679   * @tc.desc: get input device chip info test
680   * @tc.type: FUNC
681   * @tc.require: SR000F867Q
682   */
683 HWTEST_F(HdiInputTest, GetChipInfo001, TestSize.Level1)
684 {
685     printf("%s: [Input] GetChipInfo001 enter\n", __func__);
686     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
687     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
688 
689     int32_t ret;
690     char chipInfo[TEST_LEN1] = {0};
691     ret = g_inputInterface->iInputController->GetChipInfo(g_touchIndex, chipInfo, TEST_LEN1);
692     if (ret != INPUT_SUCCESS) {
693         printf("%s: get chip info failed, ret %d\n", __func__, ret);
694     }
695     EXPECT_EQ(ret, INPUT_SUCCESS);
696 }
697 
698 /**
699   * @tc.name: GetChipInfo
700   * @tc.desc: get input device chip info test
701   * @tc.type: FUNC
702   * @tc.require: SR000F867Q
703   */
704 HWTEST_F(HdiInputTest, GetChipInfo002, TestSize.Level1)
705 {
706     printf("%s: [Input] GetChipInfo002 enter\n", __func__);
707     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
708     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
709 
710     int32_t ret;
711     char chipInfo[TEST_LEN1] = {0};
712     ret = g_inputInterface->iInputController->GetChipInfo(INVALID_INDEX, chipInfo, TEST_LEN1);
713     if (ret != INPUT_SUCCESS) {
714         printf("%s: get chip info failed, ret %d\n", __func__, ret);
715     }
716     EXPECT_NE(ret, INPUT_SUCCESS);
717 }
718 
719 /**
720   * @tc.name: GetChipInfo
721   * @tc.desc: get input device chip info test
722   * @tc.type: FUNC
723   * @tc.require: SR000F867Q
724   */
725 HWTEST_F(HdiInputTest, GetChipInfo003, TestSize.Level1)
726 {
727     printf("%s: [Input] GetChipInfo003 enter\n", __func__);
728     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
729     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
730 
731     int32_t ret;
732     char chipInfo[TEST_LEN1] = {0};
733     ret = g_inputInterface->iInputController->GetChipInfo(g_touchIndex, chipInfo, TEST_LEN2);
734     if (ret != INPUT_SUCCESS) {
735         printf("%s: get device chip info failed, ret %d\n", __func__, ret);
736     }
737     EXPECT_NE(ret, INPUT_SUCCESS);
738 }
739 
740 /**
741   * @tc.name: GetVendorName
742   * @tc.desc: get device vendor name test
743   * @tc.type: FUNC
744   * @tc.require: SR000F867Q
745   */
746 HWTEST_F(HdiInputTest, GetVendorName001, TestSize.Level1)
747 {
748     printf("%s: [Input] GetVendorName001 enter\n", __func__);
749     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
750     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
751 
752     int32_t ret;
753     char vendorName[TEST_LEN1] = {0};
754     ret = g_inputInterface->iInputController->GetVendorName(g_touchIndex, vendorName, TEST_LEN1);
755     if (ret != INPUT_SUCCESS) {
756         HDF_LOGE("%s: get device vendor name failed, ret %d", __func__, ret);
757     }
758     EXPECT_EQ(ret, INPUT_SUCCESS);
759 }
760 
761 /**
762   * @tc.name: GetVendorName
763   * @tc.desc: get device vendor name test
764   * @tc.type: FUNC
765   * @tc.require: SR000F867Q
766   */
767 HWTEST_F(HdiInputTest, GetVendorName002, TestSize.Level1)
768 {
769     printf("%s: [Input] GetVendorName002 enter\n", __func__);
770     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
771     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
772 
773     int32_t ret;
774     char vendorName[TEST_LEN1] = {0};
775     ret = g_inputInterface->iInputController->GetVendorName(INVALID_INDEX, vendorName, TEST_LEN1);
776     if (ret != INPUT_SUCCESS) {
777         HDF_LOGE("%s: get device vendor name failed, ret %d", __func__, ret);
778     }
779     EXPECT_NE(ret, INPUT_SUCCESS);
780 }
781 
782 /**
783   * @tc.name: GetVendorName
784   * @tc.desc: get device vendor name test
785   * @tc.type: FUNC
786   * @tc.require: SR000F867Q
787   */
788 HWTEST_F(HdiInputTest, GetVendorName003, TestSize.Level1)
789 {
790     printf("%s: [Input] GetVendorName003 enter\n", __func__);
791     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
792     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
793 
794     int32_t ret;
795     char vendorName[TEST_LEN1] = {0};
796     ret = g_inputInterface->iInputController->GetVendorName(g_touchIndex, vendorName, TEST_LEN2);
797     if (ret != INPUT_SUCCESS) {
798         HDF_LOGE("%s: get device vendor name failed, ret %d", __func__, ret);
799     }
800     EXPECT_NE(ret, INPUT_SUCCESS);
801 }
802 
803 /**
804   * @tc.name: GetChipName
805   * @tc.desc: get device chip name test
806   * @tc.type: FUNC
807   * @tc.require: SR000F867Q
808   */
809 HWTEST_F(HdiInputTest, GetChipName001, TestSize.Level1)
810 {
811     printf("%s: [Input] GetChipName001 enter\n", __func__);
812     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
813     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
814 
815     int32_t ret;
816     char chipName[TEST_LEN1] = {0};
817     ret = g_inputInterface->iInputController->GetChipName(g_touchIndex, chipName, TEST_LEN1);
818     if (ret != INPUT_SUCCESS) {
819         HDF_LOGE("%s: get device chip name failed, ret %d", __func__, ret);
820     }
821     EXPECT_EQ(ret, INPUT_SUCCESS);
822 }
823 
824 /**
825   * @tc.name: GetChipName
826   * @tc.desc: get device chip name test
827   * @tc.type: FUNC
828   * @tc.require: SR000F867Q
829   */
830 HWTEST_F(HdiInputTest, GetChipName002, TestSize.Level1)
831 {
832     printf("%s: [Input] GetChipName002 enter\n", __func__);
833     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
834     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
835 
836     int32_t ret;
837     char chipName[TEST_LEN1] = {0};
838     ret = g_inputInterface->iInputController->GetChipName(INVALID_INDEX, chipName, TEST_LEN1);
839     if (ret != INPUT_SUCCESS) {
840         HDF_LOGE("%s: get device chip name failed, ret %d", __func__, ret);
841     }
842     EXPECT_NE(ret, INPUT_SUCCESS);
843 }
844 
845 /**
846   * @tc.name: GetChipName
847   * @tc.desc: get device chip name test
848   * @tc.type: FUNC
849   * @tc.require: SR000F867Q
850   */
851 HWTEST_F(HdiInputTest, GetChipName003, TestSize.Level1)
852 {
853     printf("%s: [Input] GetChipName003 enter\n", __func__);
854     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
855     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
856 
857     int32_t ret;
858     char chipName[TEST_LEN1] = {0};
859     ret = g_inputInterface->iInputController->GetChipName(g_touchIndex, chipName, TEST_LEN2);
860     if (ret != INPUT_SUCCESS) {
861         HDF_LOGE("%s: get device chip name failed, ret %d", __func__, ret);
862     }
863     EXPECT_NE(ret, INPUT_SUCCESS);
864 }
865 
866 /**
867   * @tc.name: SetGestureMode
868   * @tc.desc: set device gestureMode test
869   * @tc.type: FUNC
870   * @tc.require: SR000F867Q
871   */
872 HWTEST_F(HdiInputTest, SetGestureMode001, TestSize.Level1)
873 {
874     printf("%s: [Input] SetGestureMode001 enter\n", __func__);
875     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
876     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
877 
878     int32_t ret;
879     uint32_t gestureMode = VALUE_DEFAULT;
880     ret = g_inputInterface->iInputController->SetGestureMode(g_touchIndex, gestureMode);
881     if (ret != INPUT_SUCCESS) {
882         HDF_LOGE("%s: set device gestureMode failed, ret %d", __func__, ret);
883     }
884     EXPECT_EQ(ret, INPUT_SUCCESS);
885 }
886 
887 /**
888   * @tc.name: SetGestureMode
889   * @tc.desc: set device gestureMode test
890   * @tc.type: FUNC
891   * @tc.require: SR000F867Q
892   */
893 HWTEST_F(HdiInputTest, SetGestureMode002, TestSize.Level1)
894 {
895     printf("%s: [Input] SetGestureMode002 enter\n", __func__);
896     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
897     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
898 
899     int32_t ret;
900     uint32_t gestureMode = VALUE_DEFAULT;
901     ret = g_inputInterface->iInputController->SetGestureMode(INVALID_INDEX, gestureMode);
902     if (ret != INPUT_SUCCESS) {
903         HDF_LOGE("%s: set device gestureMode failed, ret %d", __func__, ret);
904     }
905     EXPECT_NE(ret, INPUT_SUCCESS);
906 }
907 
908 /**
909   * @tc.name: RunCapacitanceTest
910   * @tc.desc: run capacitance test test
911   * @tc.type: FUNC
912   * @tc.require: SR000F867Q
913   */
914 HWTEST_F(HdiInputTest, RunCapacitanceTest001, TestSize.Level1)
915 {
916     printf("%s: [Input] RunCapacitanceTest001 enter\n", __func__);
917     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
918     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
919 
920     int32_t ret;
921     char result[TEST_RESULT_LEN] = {0};
922     uint32_t testType = TEST_TYPE;
923     ret = g_inputInterface->iInputController->RunCapacitanceTest(g_touchIndex, testType, result, TEST_RESULT_LEN);
924     if (ret != INPUT_SUCCESS) {
925         HDF_LOGE("%s: run capacitance test failed, ret %d", __func__, ret);
926     }
927     EXPECT_EQ(ret, INPUT_SUCCESS);
928 }
929 
930 /**
931   * @tc.name: RunCapacitanceTest002
932   * @tc.desc: run capacitance test test002
933   * @tc.type: FUNC
934   * @tc.require: SR000F867Q
935   */
936 HWTEST_F(HdiInputTest, RunCapacitanceTest002, TestSize.Level1)
937 {
938     printf("%s: [Input] RunCapacitanceTest002 enter\n", __func__);
939     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
940     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
941 
942     int32_t ret;
943     char result[TEST_RESULT_LEN] = {0};
944     uint32_t testType = TEST_TYPE;
945     ret = g_inputInterface->iInputController->RunCapacitanceTest(g_touchIndex, testType, nullptr, TEST_RESULT_LEN);
946     if (ret != INPUT_SUCCESS) {
947         HDF_LOGE("%s: run capacitance test002 failed, ret %d", __func__, ret);
948     }
949     EXPECT_NE(ret, INPUT_SUCCESS);
950 }
951 
952 /**
953   * @tc.name: RunExtraCommand
954   * @tc.desc: run extra command test
955   * @tc.type: FUNC
956   * @tc.require: SR000F867Q
957   */
958 HWTEST_F(HdiInputTest, RunExtraCommand001, TestSize.Level1)
959 {
960     printf("%s: [Input] RunExtraCommand001 enter\n", __func__);
961     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
962     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
963 
964     int32_t ret;
965     InputExtraCmd extraCmd = {0};
966     extraCmd.cmdCode = "WakeUpMode";
967     extraCmd.cmdValue = "Enable";
968     ret = g_inputInterface->iInputController->RunExtraCommand(g_touchIndex, &extraCmd);
969     if (ret != INPUT_SUCCESS) {
970         HDF_LOGE("%s: run extra command failed, ret %d", __func__, ret);
971     }
972     EXPECT_EQ(ret, INPUT_SUCCESS);
973 }
974 
975 /**
976   * @tc.name: RunExtraCommand
977   * @tc.desc: run extra command test
978   * @tc.type: FUNC
979   * @tc.require: SR000F867Q
980   */
981 HWTEST_F(HdiInputTest, RunExtraCommand002, TestSize.Level1)
982 {
983     printf("%s: [Input] RunExtraCommand002 enter\n", __func__);
984     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
985     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
986 
987     int32_t ret;
988     InputExtraCmd extraCmd = {0};
989     extraCmd.cmdCode = "WakeUpMode";
990     extraCmd.cmdValue = "Enable";
991     ret = g_inputInterface->iInputController->RunExtraCommand(INVALID_INDEX, &extraCmd);
992     if (ret != INPUT_SUCCESS) {
993         HDF_LOGE("%s: run extra command failed, ret %d", __func__, ret);
994     }
995     EXPECT_NE(ret, INPUT_SUCCESS);
996 }
997 
998 /**
999   * @tc.name: RegisterHotPlugCallback
1000   * @tc.desc: Register Hot Plug Callback
1001   * @tc.type: FUNC
1002   * @tc.require: SR000F867Q
1003   */
1004 HWTEST_F(HdiInputTest, RegisterHotPlugCallback001, TestSize.Level1)
1005 {
1006     printf("%s: [Input] RegisterHotPlugCallback001 enter\n", __func__);
1007     int32_t ret;
1008     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
1009     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
1010 
1011     ret  = g_inputInterface->iInputReporter->RegisterHotPlugCallback(&g_hotplugCb);
1012     if (ret != INPUT_SUCCESS) {
1013         printf("%s: Register Hot Plug Callback failed, ret %d\n", __func__, ret);
1014     }
1015     EXPECT_EQ(ret, INPUT_SUCCESS);
1016 }
1017 
1018 /**
1019   * @tc.name: UnregisterHotPlugCallback
1020   * @tc.desc: Unregister Hot Plug Callback
1021   * @tc.type: FUNC
1022   * @tc.require: SR000F867Q
1023   */
1024 HWTEST_F(HdiInputTest, UnregisterHotPlugCallback001, TestSize.Level1)
1025 {
1026     printf("%s: [Input] UnregisterHotPlugCallback001 enter\n", __func__);
1027     int32_t ret;
1028     INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
1029     INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
1030 
1031     ret  = g_inputInterface->iInputReporter->UnregisterHotPlugCallback();
1032     if (ret != INPUT_SUCCESS) {
1033         printf("%s: Unregister Hot Plug Callback failed, ret %d\n", __func__, ret);
1034     }
1035     EXPECT_EQ(ret, INPUT_SUCCESS);
1036 }
1037 
1038 /**
1039   * @tc.name: SendHotPlugEvent
1040   * @tc.desc: Send Hot Plug Event
1041   * @tc.type: FUNC
1042   * @tc.require: SR000F867Q
1043   */
1044 HWTEST_F(HdiInputTest, SendHotPlugEvent001, TestSize.Level1)
1045 {
1046     printf("%s: [Input] SendHotPlugEvent001 enter\n", __func__);
1047     InputDeviceManager iInputDeviceManager;
1048     iInputDeviceManager.SendHotPlugEvent(g_type, g_index, STATUS);
1049 }
1050 
1051 /**
1052   * @tc.name: DoWithEventDeviceAdd
1053   * @tc.desc: Do With Event Device Add
1054   * @tc.type: FUNC
1055   * @tc.require: SR000F867Q
1056   */
1057 HWTEST_F(HdiInputTest, DoWithEventDeviceAdd001, TestSize.Level1)
1058 {
1059     printf("%s: [Input] DoWithEventDeviceAdd001 enter\n", __func__);
1060     InputDeviceManager iInputDeviceManager;
1061     iInputDeviceManager.DoWithEventDeviceAdd(g_fileDescriptorFirst, g_fileDescriptorSecond, NODE_PATH);
1062 }
1063 
1064 /**
1065   * @tc.name: DoWithEventDeviceDel
1066   * @tc.desc: Do With Event Device Del
1067   * @tc.type: FUNC
1068   * @tc.require: SR000F867Q
1069   */
1070 HWTEST_F(HdiInputTest, DoWithEventDeviceDel001, TestSize.Level1)
1071 {
1072     printf("%s: [Input] DoWithEventDeviceDel001 enter\n", __func__);
1073     InputDeviceManager iInputDeviceManager;
1074     iInputDeviceManager.DoWithEventDeviceDel(g_fileDescriptorFirst, g_index);
1075 }
1076 
1077 /**
1078   * @tc.name: ReportEventPkg001
1079   * @tc.desc: Report Event Pkg
1080   * @tc.type: FUNC
1081   * @tc.require: SR000F867Q
1082   */
1083 HWTEST_F(HdiInputTest, ReportEventPkg001, TestSize.Level1)
1084 {
1085     printf("%s: [Input] ReportEventPkg001 enter\n", __func__);
1086     InputEventPackage **evtPkg = (InputEventPackage **)OsalMemAlloc(sizeof(InputEventPackage *) * COUNT);
1087     INPUT_CHECK_NULL_POINTER(evtPkg, INPUT_NULL_PTR);
1088     InputDeviceManager iInputDeviceManager;
1089     iInputDeviceManager.ReportEventPkg(g_fileDescriptorFirst, evtPkg, COUNT);
1090 }
1091 
1092 /**
1093   * @tc.name: DoRead
1094   * @tc.desc: Do Read
1095   * @tc.type: FUNC
1096   * @tc.require: SR000F867Q
1097   */
1098 HWTEST_F(HdiInputTest, DoRead001, TestSize.Level1)
1099 {
1100     printf("%s: [Input] DoRead001 enter\n", __func__);
1101     struct input_event evtBuffer[EVENT_BUFFER_SIZE] {};
1102     InputDeviceManager iInputDeviceManager;
1103     iInputDeviceManager.DoRead(g_fileDescriptorFirst, evtBuffer, EVENT_BUFFER_SIZE);
1104 }
1105 
1106 /**
1107   * @tc.name: InotifyEventHandler
1108   * @tc.desc: Inotify Event Handler
1109   * @tc.type: FUNC
1110   * @tc.require: SR000F867Q
1111   */
1112 HWTEST_F(HdiInputTest, InotifyEventHandler001, TestSize.Level1)
1113 {
1114     printf("%s: [Input] InotifyEventHandler001 enter\n", __func__);
1115     int32_t ret;
1116     struct input_event evtBuffer[EVENT_BUFFER_SIZE] {};
1117     InputDeviceManager iInputDeviceManager;
1118     ret = iInputDeviceManager.InotifyEventHandler(g_fileDescriptorFirst, g_fileDescriptorSecond);
1119     if (ret != INPUT_SUCCESS) {
1120         printf("%s: Inotify Event Handler failed, ret %d\n", __func__, ret);
1121     }
1122     EXPECT_EQ(ret, INPUT_SUCCESS);
1123 }
1124 
1125 /**
1126   * @tc.name: ScanDevice
1127   * @tc.desc: Scan Device Fail
1128   * @tc.type: FUNC
1129   * @tc.require: SR000F867Q
1130   */
1131 HWTEST_F(HdiInputTest, ScanDevice001, TestSize.Level1)
1132 {
1133     printf("%s: [Input] ScanDevice001 enter\n", __func__);
1134     int32_t ret;
1135     InputDeviceManager iInputDeviceManager;
1136     ret = iInputDeviceManager.ScanDevice(nullptr, 0);
1137     if (ret != INPUT_SUCCESS) {
1138         printf("%s: Scan Device failed, ret %d\n", __func__, ret);
1139     }
1140     EXPECT_NE(ret, INPUT_SUCCESS);
1141 }
1142 
1143 /**
1144   * @tc.name: GetDeviceList
1145   * @tc.desc: Get Device List Fail
1146   * @tc.type: FUNC
1147   * @tc.require: SR000F867Q
1148   */
1149 HWTEST_F(HdiInputTest, GetDeviceList001, TestSize.Level1)
1150 {
1151     printf("%s: [Input] GetDeviceList001 enter\n", __func__);
1152     int32_t ret;
1153     InputDeviceManager iInputDeviceManager;
1154     ret = iInputDeviceManager.GetDeviceList(nullptr, nullptr, 0);
1155     if (ret != INPUT_SUCCESS) {
1156         printf("%s: Get Device List Failed, ret %d\n", __func__, ret);
1157     }
1158     EXPECT_NE(ret, INPUT_SUCCESS);
1159 }
1160