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