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 "hdf_log.h"
24 #include "input_device_manager.h"
25 #include "input_manager.h"
26 #include "osal_time.h"
27
28 using namespace testing::ext;
29 using namespace OHOS::Input;
30 static IInputInterface *g_inputInterface;
31 static InputEventCb g_callback;
32 static InputHostCb g_hotplugCb;
33 static int32_t g_touchIndex;
34 static const int32_t KEEP_ALIVE_TIME_MS = 3000;
35 static const int32_t INVALID_INDEX = 15;
36 static const int32_t INVALID_INDEX1 = -1;
37 static const int32_t MAX_DEVICES = 32;
38 static const int32_t TEST_RESULT_LEN = 32;
39 static const int32_t TEST_TYPE = 2;
40 static const int32_t TEST_LEN1 = 10;
41 static const int32_t TEST_LEN2 = -1;
42 static const int32_t VALUE_NULL = 0;
43 static const int32_t VALUE_DEFAULT = 1;
44 static const uint32_t INIT_DEFAULT_VALUE = 255;
45
46 class HdiInputTest : public testing::Test {
47 public:
48 static void SetUpTestCase();
49 static void TearDownTestCase();
50 void SetUp();
51 void TearDown();
52 };
53
SetUpTestCase()54 void HdiInputTest::SetUpTestCase()
55 {
56 int32_t ret = GetInputInterface(&g_inputInterface);
57 if (ret != INPUT_SUCCESS) {
58 printf("%s: get input hdi failed, ret %d\n", __func__, ret);
59 }
60 }
61
TearDownTestCase()62 void HdiInputTest::TearDownTestCase()
63 {
64 if (g_inputInterface != nullptr) {
65 free(g_inputInterface);
66 g_inputInterface = nullptr;
67 }
68 }
69
SetUp()70 void HdiInputTest::SetUp()
71 {
72 }
73
TearDown()74 void HdiInputTest::TearDown()
75 {
76 }
77
78 #define INPUT_CHECK_NULL_POINTER(pointer, ret) do { \
79 if ((pointer) == nullptr) { \
80 printf("%s: null pointer", __func__); \
81 ASSERT_EQ ((ret), INPUT_SUCCESS); \
82 } \
83 } while (0)
84
ReportEventPkgCallback(const InputEventPackage ** pkgs,uint32_t count,uint32_t devIndex)85 static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex)
86 {
87 if (pkgs == nullptr) {
88 printf("%s: pkgs is null\n", __func__);
89 return;
90 }
91 for (uint32_t i = 0; i < count; i++) {
92 printf("device action Index: %u devIndex: %u type: %u code: %u value %d\n",
93 i, devIndex, pkgs[i]->type, pkgs[i]->code, pkgs[i]->value);
94 }
95 }
96
ReportHotPlugEventPkgCallback(const InputHotPlugEvent * msg)97 static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg)
98 {
99 if (msg == nullptr) {
100 printf("%s: msg is null\n", __func__);
101 return;
102 }
103 printf("%s: device hotplug action devIndex: %u devType: %u status: %u\n", __func__,
104 msg->devIndex, msg->devType, msg->status);
105 if (msg->status == INPUT_DEVICE_STATUS_OPENED) {
106 EXPECT_EQ(g_inputInterface->iInputManager->OpenInputDevice(msg->devIndex), INPUT_SUCCESS);
107 } else if (msg->status == INPUT_DEVICE_STATUS_CLOSED) {
108 EXPECT_EQ(g_inputInterface->iInputManager->CloseInputDevice(msg->devIndex), INPUT_SUCCESS);
109 } else {
110 // do nothing
111 }
112 }
113
114 /**
115 * @tc.name: ScanInputDevice001
116 * @tc.desc: scan input device test
117 * @tc.type: FUNC
118 * @tc.require: AR000F867R
119 */
120 HWTEST_F(HdiInputTest, ScanInputDevice001, TestSize.Level1)
121 {
122 InputDevDesc sta[MAX_DEVICES];
123 if (memset_s(sta, MAX_DEVICES * sizeof(InputDevDesc), 0, MAX_DEVICES * sizeof(InputDevDesc)) != EOK) {
124 printf("%s: memset_s failed\n", __func__);
125 return;
126 }
127 printf("%s: [Input] ScanInputDevice001 enter %d\n", __func__, __LINE__);
128 int32_t ret;
129 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
130 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
131 ret = g_inputInterface->iInputManager->ScanInputDevice(sta, sizeof(sta) / sizeof(InputDevDesc));
132 if (ret == INPUT_SUCCESS) {
133 printf("%s: ScanInputDevice result: %d, %d, %d, %d\n",
134 __func__, sta[0].devType, sta[0].devIndex, sta[1].devType, sta[1].devIndex);
135 }
136 for (int32_t i = 1; i < MAX_DEVICES; i++) {
137 if (sta[i].devIndex == 0) {
138 break;
139 }
140 if (sta[i].devType == INDEV_TYPE_TOUCH) {
141 g_touchIndex = sta[i].devIndex;
142 }
143 }
144 EXPECT_EQ(ret, INPUT_SUCCESS);
145 }
146
147 /**
148 * @tc.name: OpenInputDev001
149 * @tc.desc: open input device test
150 * @tc.type: FUNC
151 * @tc.require: AR000F867R
152 */
153 HWTEST_F(HdiInputTest, OpenInputDev001, TestSize.Level1)
154 {
155 printf("%s: [Input] OpenInputDev001 enter %d\n", __func__, __LINE__);
156 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
157 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
158 int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(VALUE_DEFAULT);
159 if (ret != INPUT_SUCCESS) {
160 printf("%s: open device1 failed, ret %d\n", __func__, ret);
161 }
162 EXPECT_EQ(ret, INPUT_SUCCESS);
163 }
164
165 /**
166 * @tc.name: OpenInputDevice002
167 * @tc.desc: open input device test
168 * @tc.type: FUNC
169 * @tc.require: AR000F867R
170 */
171 HWTEST_F(HdiInputTest, OpenInputDevice002, TestSize.Level1)
172 {
173 printf("%s: [Input] OpenInputDev002 enter %d\n", __func__, __LINE__);
174 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
175 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
176 /* Device "15" is used for testing nonexistent device node */
177 int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(INVALID_INDEX);
178 if (ret != HDF_SUCCESS) {
179 printf("%s: device %d dose not exist, can't open it, ret %d\n", __func__, INVALID_INDEX, ret);
180 }
181 EXPECT_NE(ret, INPUT_SUCCESS);
182 }
183
184
185 /**
186 * @tc.name: OpenInputDevice003
187 * @tc.desc: open input device test
188 * @tc.type: FUNC
189 * @tc.require: AR000F867R
190 */
191 HWTEST_F(HdiInputTest, OpenInputDevice003, TestSize.Level1)
192 {
193 printf("%s: [Input] OpenInputDev003 enter %d\n", __func__, __LINE__);
194 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
195 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
196 /* Device "-1" is used for testing nonexistent device node */
197 int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(INVALID_INDEX1);
198 if (ret != HDF_SUCCESS) {
199 printf("%s: device %d dose not exist, can't open it, ret %d\n", __func__, INVALID_INDEX1, ret);
200 }
201 EXPECT_NE(ret, INPUT_SUCCESS);
202 }
203
204 /**
205 * @tc.name: CloseInputDevice001
206 * @tc.desc: close input device test
207 * @tc.type: FUNC
208 * @tc.require: AR000F867T, AR000F8QNL
209 */
210 HWTEST_F(HdiInputTest, CloseInputDevice001, TestSize.Level1)
211 {
212 printf("%s: [Input] CloseInputDev001 enter %d\n", __func__, __LINE__);
213 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
214 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
215 int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(VALUE_DEFAULT);
216 if (ret != INPUT_SUCCESS) {
217 printf("%s: close device %d failed, ret %d\n", __func__, g_touchIndex, ret);
218 }
219 EXPECT_EQ(ret, INPUT_SUCCESS);
220 }
221
222 /**
223 * @tc.name: CloseInputDevice002
224 * @tc.desc: close input device test
225 * @tc.type: FUNC
226 * @tc.require: AR000F867T
227 */
228 HWTEST_F(HdiInputTest, CloseInputDevice002, TestSize.Level1)
229 {
230 printf("%s: [Input] CloseInputDev002 enter %d\n", __func__, __LINE__);
231 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
232 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
233 /* Device "15" is used for testing nonexistent device node */
234 int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(INVALID_INDEX);
235 if (ret == INPUT_FAILURE) {
236 printf("%s: device %d doesn't exist, can't close it, ret %d\n", __func__, INVALID_INDEX, ret);
237 }
238 EXPECT_NE(ret, INPUT_SUCCESS);
239 }
240
241 /**
242 * @tc.name: CloseInputDevice003
243 * @tc.desc: close input device test
244 * @tc.type: FUNC
245 * @tc.require: AR000F867T
246 */
247 HWTEST_F(HdiInputTest, CloseInputDevice003, TestSize.Level1)
248 {
249 printf("%s: [Input] CloseInputDev002 enter %d\n", __func__, __LINE__);
250 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
251 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
252 /* Device "-1" is used for testing nonexistent device node */
253 int32_t ret = g_inputInterface->iInputManager->CloseInputDevice(INVALID_INDEX1);
254 if (ret == INPUT_FAILURE) {
255 printf("%s: device %d doesn't exist, can't close it, ret %d\n", __func__, INVALID_INDEX1, ret);
256 }
257 EXPECT_NE(ret, INPUT_SUCCESS);
258 }
259
260 /**
261 * @tc.name: GetInputDevice001
262 * @tc.desc: get input device info test
263 * @tc.type: FUNC
264 * @tc.require: AR000F867S
265 */
266 HWTEST_F(HdiInputTest, GetInputDevice001, TestSize.Level1)
267 {
268 printf("%s: [Input] GetInputDevice001 enter %d\n", __func__, __LINE__);
269 InputDeviceInfo *dev = nullptr;
270 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
271 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
272 int32_t ret = g_inputInterface->iInputManager->GetInputDevice(g_touchIndex, &dev);
273 if (ret != INPUT_SUCCESS) {
274 printf("%s: get device %d failed, ret %d\n", __func__, g_touchIndex, ret);
275 }
276 printf("GetInputDevice001 %s: devIndex = %u, devType = %u\n", __func__, dev->devIndex, dev->devType);
277 printf("GetInputDevice001: chipInfo = %s, vendorName = %s, chipName = %s, devName = %s\n",
278 dev->chipInfo, dev->vendorName, dev->chipName, dev->attrSet.devName);
279 printf("GetInputDevice001: busType = %u, vendor = %u, product = %u, version = %u\n",
280 dev->attrSet.id.busType, dev->attrSet.id.vendor, dev->attrSet.id.product, dev->attrSet.id.version);
281 EXPECT_EQ(ret, INPUT_SUCCESS);
282 }
283
284 /**
285 * @tc.name: GetInputDevice002
286 * @tc.desc: get input device info test
287 * @tc.type: FUNC
288 * @tc.require: AR000F867S
289 */
290 HWTEST_F(HdiInputTest, GetInputDevice002, TestSize.Level1)
291 {
292 printf("%s: [Input] GetInputDevice002 enter %d\n", __func__, __LINE__);
293 InputDeviceInfo *dev = nullptr;
294 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
295 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
296 int32_t ret = g_inputInterface->iInputManager->GetInputDevice(INVALID_INDEX1, &dev);
297 if (ret != INPUT_SUCCESS) {
298 printf("%s: get device %d failed, ret %d\n", __func__, INVALID_INDEX1, ret);
299 }
300 EXPECT_NE(ret, INPUT_SUCCESS);
301 }
302
303 /**
304 * @tc.name: GetInputDevice003
305 * @tc.desc: get input device info test
306 * @tc.type: FUNC
307 * @tc.require: AR000F867S
308 */
309 HWTEST_F(HdiInputTest, GetInputDevice003, TestSize.Level1)
310 {
311 printf("%s: [Input] GetInputDevice003 enter %d\n", __func__, __LINE__);
312 InputDeviceInfo *dev = nullptr;
313 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
314 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
315 int32_t ret = g_inputInterface->iInputManager->GetInputDevice(INVALID_INDEX, &dev);
316 if (ret != INPUT_SUCCESS) {
317 printf("%s: get device %d failed, ret %d\n", __func__, INVALID_INDEX, ret);
318 }
319 EXPECT_NE(ret, INPUT_SUCCESS);
320 }
321
322 /**
323 * @tc.name: GetInputDeviceList001
324 * @tc.desc: get input device list info test
325 * @tc.type: FUNC
326 * @tc.require: AR000F8680
327 */
328 HWTEST_F(HdiInputTest, GetInputDeviceList001, TestSize.Level1)
329 {
330 printf("%s: [Input] GetInputDeviceList001 enter\n", __func__);
331 int32_t ret;
332 uint32_t num = 0;
333 InputDeviceInfo *dev = nullptr;
334 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
335 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
336 ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, &dev, MAX_INPUT_DEV_NUM);
337 if (ret != INPUT_SUCCESS) {
338 printf("%s: get device list failed, ret %d\n", __func__, ret);
339 }
340 /* num <= MAX_INPUT_DEV_NUM return true */
341 ASSERT_LE(num, MAX_INPUT_DEV_NUM);
342 for (uint32_t i = 0; i < num; i++) {
343 printf("%s: num = %u, device[%u]'s info is:\n", __func__, num, i);
344 printf("%s: index = %u, devType = %u\n", __func__, (dev + i)->devIndex, (dev + i)->devType);
345 printf("%s: chipInfo = %s, vendorName = %s, chipName = %s, devName = %s\n",
346 __func__, (dev + i)->chipInfo, (dev + i)->vendorName, (dev + i)->chipName, (dev + i)->attrSet.devName);
347 }
348 EXPECT_EQ(ret, INPUT_SUCCESS);
349 }
350
351 /**
352 * @tc.name: RegisterCallbackAndReportData001
353 * @tc.desc: get input device chip info test
354 * @tc.type: FUNC
355 * @tc.require: AR000F8682, AR000F8QNL
356 */
357 HWTEST_F(HdiInputTest, RegisterCallbackAndReportData001, TestSize.Level1)
358 {
359 printf("%s: [Input] RegisterCallbackAndReportData001 enter\n", __func__);
360 int32_t ret;
361 g_callback.EventPkgCallback = ReportEventPkgCallback;
362 g_hotplugCb.HotPlugCallback = ReportHotPlugEventPkgCallback;
363 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
364 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
365 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
366 ret = g_inputInterface->iInputReporter->RegisterReportCallback(g_touchIndex, &g_callback);
367 if (ret != INPUT_SUCCESS) {
368 printf("%s: register callback failed for device %d, ret %d\n", __func__, g_touchIndex, ret);
369 }
370 EXPECT_EQ(ret, INPUT_SUCCESS);
371 ret = g_inputInterface->iInputManager->OpenInputDevice(VALUE_DEFAULT);
372 EXPECT_EQ(ret, INPUT_SUCCESS);
373 printf("%s: wait 3s for testing, pls touch the panel now\n", __func__);
374 printf("%s: The event data is as following:\n", __func__);
375 OsalMSleep(KEEP_ALIVE_TIME_MS);
376 }
377
378 /**
379 * @tc.name: UnregisterReportCallback001
380 * @tc.desc: get input device chip info test
381 * @tc.type: FUNC
382 * @tc.require: SR000F867Q
383 */
384 HWTEST_F(HdiInputTest, UnregisterReportCallback001, TestSize.Level1)
385 {
386 printf("%s: [Input] UnregisterReportCallback001 enter\n", __func__);
387 int32_t ret;
388 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
389 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
390 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
391
392 ret = g_inputInterface->iInputReporter->UnregisterReportCallback(g_touchIndex);
393 if (ret != INPUT_SUCCESS) {
394 printf("%s: unregister callback failed for device %d, ret %d\n", __func__, g_touchIndex, ret);
395 }
396 EXPECT_EQ(ret, INPUT_SUCCESS);
397 ret = g_inputInterface->iInputManager->CloseInputDevice(VALUE_DEFAULT);
398 if (ret != INPUT_SUCCESS) {
399 printf("%s: close device %d failed, ret %d\n", __func__, g_touchIndex, ret);
400 }
401 EXPECT_EQ(ret, INPUT_SUCCESS);
402 }
403
404 /**
405 * @tc.name: FindIndexFromFd
406 * @tc.desc: find index from fd test
407 * @tc.type: FUNC
408 * @tc.require: SR000F867Q
409 */
410 HWTEST_F(HdiInputTest, FindIndexFromFd001, TestSize.Level1)
411 {
412 printf("%s: [Input] FindIndexFromFd001 enter\n", __func__);
413 int32_t ret;
414 InputDeviceManager InputDeviceManagerTest;
415 int32_t fd = VALUE_NULL;
416 uint32_t index = VALUE_NULL;
417 ret = InputDeviceManagerTest.FindIndexFromFd(fd, &index);
418 if (ret != INPUT_SUCCESS) {
419 printf("%s: find index from fd failed, ret %d\n", __func__, ret);
420 }
421 EXPECT_NE(ret, INPUT_SUCCESS);
422 }
423
424 /**
425 * @tc.name: FindIndexFromDevName
426 * @tc.desc: find index from device name test
427 * @tc.type: FUNC
428 * @tc.require: SR000F867Q
429 */
430 HWTEST_F(HdiInputTest, FindIndexFromDevName001, TestSize.Level1)
431 {
432 printf("%s: [Input] FindIndexFromDevName001 enter\n", __func__);
433 int32_t ret;
434 InputDeviceManager InputDeviceManagerTest;
435 string devName = "MOUSE1";
436 uint32_t index = VALUE_NULL;
437 ret = InputDeviceManagerTest.FindIndexFromDevName(devName, &index);
438 if (ret != INPUT_SUCCESS) {
439 printf("%s: find index from device name failed, ret %d\n", __func__, ret);
440 }
441 EXPECT_NE(ret, INPUT_SUCCESS);
442 }
443
444 /**
445 * @tc.name: SetPowerStatus
446 * @tc.desc: set power status test
447 * @tc.type: FUNC
448 * @tc.require: SR000F867Q
449 */
450 HWTEST_F(HdiInputTest, SetPowerStatus001, TestSize.Level1)
451 {
452 printf("%s: [Input] SetPowerStatus001 enter\n", __func__);
453 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
454 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
455
456 int32_t ret;
457 uint32_t status = VALUE_NULL;
458 ret = g_inputInterface->iInputController->SetPowerStatus(g_touchIndex, status);
459 if (ret != INPUT_SUCCESS) {
460 printf("%s: set power status failed, ret %d\n", __func__, ret);
461 }
462 EXPECT_EQ(ret, INPUT_SUCCESS);
463 }
464
465 /**
466 * @tc.name: SetPowerStatus
467 * @tc.desc: set power status test
468 * @tc.type: FUNC
469 * @tc.require: SR000F867Q
470 */
471 HWTEST_F(HdiInputTest, SetPowerStatus002, TestSize.Level1)
472 {
473 printf("%s: [Input] SetPowerStatus002 enter\n", __func__);
474 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
475 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
476
477 int32_t ret;
478 uint32_t status = VALUE_NULL;
479 ret = g_inputInterface->iInputController->SetPowerStatus(INVALID_INDEX, status);
480 if (ret != INPUT_SUCCESS) {
481 printf("%s: set power status failed, ret %d\n", __func__, ret);
482 }
483 EXPECT_NE(ret, INPUT_SUCCESS);
484 }
485
486 /**
487 * @tc.name: SetPowerStatus
488 * @tc.desc: set power status test
489 * @tc.type: FUNC
490 * @tc.require: SR000F867Q
491 */
492 HWTEST_F(HdiInputTest, SetPowerStatus003, TestSize.Level1)
493 {
494 printf("%s: [Input] SetPowerStatus003 enter\n", __func__);
495 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
496 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
497
498 int32_t ret;
499 uint32_t status = VALUE_NULL;
500 ret = g_inputInterface->iInputController->SetPowerStatus(INVALID_INDEX1, status);
501 if (ret != INPUT_SUCCESS) {
502 printf("%s: set power status failed, ret %d\n", __func__, ret);
503 }
504 EXPECT_NE(ret, INPUT_SUCCESS);
505 }
506
507 /**
508 * @tc.name: GetPowerStatus
509 * @tc.desc: get power status test
510 * @tc.type: FUNC
511 * @tc.require: SR000F867Q
512 */
513 HWTEST_F(HdiInputTest, GetPowerStatus001, TestSize.Level1)
514 {
515 printf("%s: [Input] GetPowerStatus001 enter\n", __func__);
516 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
517 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
518
519 int32_t ret;
520 uint32_t status = VALUE_NULL;
521 ret = g_inputInterface->iInputController->GetPowerStatus(g_touchIndex, &status);
522 if (ret != INPUT_SUCCESS) {
523 printf("%s: get power status failed, ret %d\n", __func__, ret);
524 }
525 EXPECT_EQ(ret, INPUT_SUCCESS);
526 }
527
528 /**
529 * @tc.name: GetPowerStatus
530 * @tc.desc: get power status test
531 * @tc.type: FUNC
532 * @tc.require: SR000F867Q
533 */
534 HWTEST_F(HdiInputTest, GetPowerStatus002, TestSize.Level1)
535 {
536 printf("%s: [Input] GetPowerStatus002 enter\n", __func__);
537 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
538 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
539
540 int32_t ret;
541 uint32_t status = VALUE_NULL;
542 ret = g_inputInterface->iInputController->GetPowerStatus(INVALID_INDEX, &status);
543 if (ret != INPUT_SUCCESS) {
544 printf("%s: get power status failed, ret %d\n", __func__, ret);
545 }
546 EXPECT_NE(ret, INPUT_SUCCESS);
547 }
548
549 /**
550 * @tc.name: GetPowerStatus
551 * @tc.desc: get power status test
552 * @tc.type: FUNC
553 * @tc.require: SR000F867Q
554 */
555 HWTEST_F(HdiInputTest, GetPowerStatus003, TestSize.Level1)
556 {
557 printf("%s: [Input] GetPowerStatus003 enter\n", __func__);
558 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
559 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
560
561 int32_t ret;
562 uint32_t status = VALUE_NULL;
563 ret = g_inputInterface->iInputController->GetPowerStatus(INVALID_INDEX1, &status);
564 if (ret != INPUT_SUCCESS) {
565 printf("%s: get power status failed, ret %d\n", __func__, ret);
566 }
567 EXPECT_NE(ret, INPUT_SUCCESS);
568 }
569
570 /**
571 * @tc.name: GetDeviceType
572 * @tc.desc: get device type test
573 * @tc.type: FUNC
574 * @tc.require: SR000F867Q
575 */
576 HWTEST_F(HdiInputTest, GetDeviceType001, TestSize.Level1)
577 {
578 printf("%s: [Input] GetDeviceType001 enter\n", __func__);
579 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
580 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
581
582 int32_t ret;
583 uint32_t deviceType = INIT_DEFAULT_VALUE;
584 ret = g_inputInterface->iInputController->GetDeviceType(g_touchIndex, &deviceType);
585 if (ret != INPUT_SUCCESS) {
586 printf("%s: get device type failed, ret %d\n", __func__, ret);
587 }
588 EXPECT_EQ(ret, INPUT_SUCCESS);
589 }
590
591 /**
592 * @tc.name: GetDeviceType
593 * @tc.desc: get device type test
594 * @tc.type: FUNC
595 * @tc.require: SR000F867Q
596 */
597 HWTEST_F(HdiInputTest, GetDeviceType002, TestSize.Level1)
598 {
599 printf("%s: [Input] GetDeviceType002 enter\n", __func__);
600 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
601 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
602
603 int32_t ret;
604 uint32_t deviceType = INIT_DEFAULT_VALUE;
605 ret = g_inputInterface->iInputController->GetDeviceType(INVALID_INDEX, &deviceType);
606 if (ret != INPUT_SUCCESS) {
607 printf("%s: get device type failed, ret %d\n", __func__, ret);
608 }
609 EXPECT_NE(ret, INPUT_SUCCESS);
610 }
611
612 /**
613 * @tc.name: GetDeviceType
614 * @tc.desc: get device type test
615 * @tc.type: FUNC
616 * @tc.require: SR000F867Q
617 */
618 HWTEST_F(HdiInputTest, GetDeviceType003, TestSize.Level1)
619 {
620 printf("%s: [Input] GetDeviceType003 enter\n", __func__);
621 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
622 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
623
624 int32_t ret;
625 uint32_t deviceType = INIT_DEFAULT_VALUE;
626 ret = g_inputInterface->iInputController->GetDeviceType(INVALID_INDEX1, &deviceType);
627 if (ret != INPUT_SUCCESS) {
628 printf("%s: get device type failed, ret %d\n", __func__, ret);
629 }
630 EXPECT_NE(ret, INPUT_SUCCESS);
631 }
632
633 /**
634 * @tc.name: GetChipInfo
635 * @tc.desc: get input device chip info test
636 * @tc.type: FUNC
637 * @tc.require: SR000F867Q
638 */
639 HWTEST_F(HdiInputTest, GetChipInfo001, TestSize.Level1)
640 {
641 printf("%s: [Input] GetChipInfo001 enter\n", __func__);
642 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
643 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
644
645 int32_t ret;
646 char chipInfo[TEST_LEN1] = {0};
647 ret = g_inputInterface->iInputController->GetChipInfo(g_touchIndex, chipInfo, TEST_LEN1);
648 if (ret != INPUT_SUCCESS) {
649 printf("%s: get chip info failed, ret %d\n", __func__, ret);
650 }
651 EXPECT_EQ(ret, INPUT_SUCCESS);
652 }
653
654 /**
655 * @tc.name: GetChipInfo
656 * @tc.desc: get input device chip info test
657 * @tc.type: FUNC
658 * @tc.require: SR000F867Q
659 */
660 HWTEST_F(HdiInputTest, GetChipInfo002, TestSize.Level1)
661 {
662 printf("%s: [Input] GetChipInfo002 enter\n", __func__);
663 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
664 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
665
666 int32_t ret;
667 char chipInfo[TEST_LEN1] = {0};
668 ret = g_inputInterface->iInputController->GetChipInfo(INVALID_INDEX, chipInfo, TEST_LEN1);
669 if (ret != INPUT_SUCCESS) {
670 printf("%s: get chip info failed, ret %d\n", __func__, ret);
671 }
672 EXPECT_NE(ret, INPUT_SUCCESS);
673 }
674
675 /**
676 * @tc.name: GetChipInfo
677 * @tc.desc: get input device chip info test
678 * @tc.type: FUNC
679 * @tc.require: SR000F867Q
680 */
681 HWTEST_F(HdiInputTest, GetChipInfo003, TestSize.Level1)
682 {
683 printf("%s: [Input] GetChipInfo003 enter\n", __func__);
684 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
685 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
686
687 int32_t ret;
688 char chipInfo[TEST_LEN1] = {0};
689 ret = g_inputInterface->iInputController->GetChipInfo(g_touchIndex, chipInfo, TEST_LEN2);
690 if (ret != INPUT_SUCCESS) {
691 printf("%s: get device chip info failed, ret %d\n", __func__, ret);
692 }
693 EXPECT_NE(ret, INPUT_SUCCESS);
694 }
695
696 /**
697 * @tc.name: GetVendorName
698 * @tc.desc: get device vendor name test
699 * @tc.type: FUNC
700 * @tc.require: SR000F867Q
701 */
702 HWTEST_F(HdiInputTest, GetVendorName001, TestSize.Level1)
703 {
704 printf("%s: [Input] GetVendorName001 enter\n", __func__);
705 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
706 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
707
708 int32_t ret;
709 char vendorName[TEST_LEN1] = {0};
710 ret = g_inputInterface->iInputController->GetVendorName(g_touchIndex, vendorName, TEST_LEN1);
711 if (ret != INPUT_SUCCESS) {
712 HDF_LOGE("%s: get device vendor name failed, ret %d", __func__, ret);
713 }
714 EXPECT_EQ(ret, INPUT_SUCCESS);
715 }
716
717 /**
718 * @tc.name: GetVendorName
719 * @tc.desc: get device vendor name test
720 * @tc.type: FUNC
721 * @tc.require: SR000F867Q
722 */
723 HWTEST_F(HdiInputTest, GetVendorName002, TestSize.Level1)
724 {
725 printf("%s: [Input] GetVendorName002 enter\n", __func__);
726 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
727 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
728
729 int32_t ret;
730 char vendorName[TEST_LEN1] = {0};
731 ret = g_inputInterface->iInputController->GetVendorName(INVALID_INDEX, vendorName, TEST_LEN1);
732 if (ret != INPUT_SUCCESS) {
733 HDF_LOGE("%s: get device vendor name failed, ret %d", __func__, ret);
734 }
735 EXPECT_NE(ret, INPUT_SUCCESS);
736 }
737
738 /**
739 * @tc.name: GetVendorName
740 * @tc.desc: get device vendor name test
741 * @tc.type: FUNC
742 * @tc.require: SR000F867Q
743 */
744 HWTEST_F(HdiInputTest, GetVendorName003, TestSize.Level1)
745 {
746 printf("%s: [Input] GetVendorName003 enter\n", __func__);
747 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
748 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
749
750 int32_t ret;
751 char vendorName[TEST_LEN1] = {0};
752 ret = g_inputInterface->iInputController->GetVendorName(g_touchIndex, vendorName, TEST_LEN2);
753 if (ret != INPUT_SUCCESS) {
754 HDF_LOGE("%s: get device vendor name failed, ret %d", __func__, ret);
755 }
756 EXPECT_NE(ret, INPUT_SUCCESS);
757 }
758
759 /**
760 * @tc.name: GetChipName
761 * @tc.desc: get device chip name test
762 * @tc.type: FUNC
763 * @tc.require: SR000F867Q
764 */
765 HWTEST_F(HdiInputTest, GetChipName001, TestSize.Level1)
766 {
767 printf("%s: [Input] GetChipName001 enter\n", __func__);
768 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
769 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
770
771 int32_t ret;
772 char chipName[TEST_LEN1] = {0};
773 ret = g_inputInterface->iInputController->GetChipName(g_touchIndex, chipName, TEST_LEN1);
774 if (ret != INPUT_SUCCESS) {
775 HDF_LOGE("%s: get device chip name failed, ret %d", __func__, ret);
776 }
777 EXPECT_EQ(ret, INPUT_SUCCESS);
778 }
779
780 /**
781 * @tc.name: GetChipName
782 * @tc.desc: get device chip name test
783 * @tc.type: FUNC
784 * @tc.require: SR000F867Q
785 */
786 HWTEST_F(HdiInputTest, GetChipName002, TestSize.Level1)
787 {
788 printf("%s: [Input] GetChipName002 enter\n", __func__);
789 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
790 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
791
792 int32_t ret;
793 char chipName[TEST_LEN1] = {0};
794 ret = g_inputInterface->iInputController->GetChipName(INVALID_INDEX, chipName, TEST_LEN1);
795 if (ret != INPUT_SUCCESS) {
796 HDF_LOGE("%s: get device chip name failed, ret %d", __func__, ret);
797 }
798 EXPECT_NE(ret, INPUT_SUCCESS);
799 }
800
801 /**
802 * @tc.name: GetChipName
803 * @tc.desc: get device chip name test
804 * @tc.type: FUNC
805 * @tc.require: SR000F867Q
806 */
807 HWTEST_F(HdiInputTest, GetChipName003, TestSize.Level1)
808 {
809 printf("%s: [Input] GetChipName003 enter\n", __func__);
810 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
811 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
812
813 int32_t ret;
814 char chipName[TEST_LEN1] = {0};
815 ret = g_inputInterface->iInputController->GetChipName(g_touchIndex, chipName, TEST_LEN2);
816 if (ret != INPUT_SUCCESS) {
817 HDF_LOGE("%s: get device chip name failed, ret %d", __func__, ret);
818 }
819 EXPECT_NE(ret, INPUT_SUCCESS);
820 }
821
822 /**
823 * @tc.name: SetGestureMode
824 * @tc.desc: set device gestureMode test
825 * @tc.type: FUNC
826 * @tc.require: SR000F867Q
827 */
828 HWTEST_F(HdiInputTest, SetGestureMode001, TestSize.Level1)
829 {
830 printf("%s: [Input] SetGestureMode001 enter\n", __func__);
831 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
832 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
833
834 int32_t ret;
835 uint32_t gestureMode = VALUE_DEFAULT;
836 ret = g_inputInterface->iInputController->SetGestureMode(g_touchIndex, gestureMode);
837 if (ret != INPUT_SUCCESS) {
838 HDF_LOGE("%s: set device gestureMode failed, ret %d", __func__, ret);
839 }
840 EXPECT_EQ(ret, INPUT_SUCCESS);
841 }
842
843 /**
844 * @tc.name: SetGestureMode
845 * @tc.desc: set device gestureMode test
846 * @tc.type: FUNC
847 * @tc.require: SR000F867Q
848 */
849 HWTEST_F(HdiInputTest, SetGestureMode002, TestSize.Level1)
850 {
851 printf("%s: [Input] SetGestureMode002 enter\n", __func__);
852 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
853 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
854
855 int32_t ret;
856 uint32_t gestureMode = VALUE_DEFAULT;
857 ret = g_inputInterface->iInputController->SetGestureMode(INVALID_INDEX, gestureMode);
858 if (ret != INPUT_SUCCESS) {
859 HDF_LOGE("%s: set device gestureMode failed, ret %d", __func__, ret);
860 }
861 EXPECT_NE(ret, INPUT_SUCCESS);
862 }
863
864 /**
865 * @tc.name: RunCapacitanceTest
866 * @tc.desc: run capacitance test test
867 * @tc.type: FUNC
868 * @tc.require: SR000F867Q
869 */
870 HWTEST_F(HdiInputTest, RunCapacitanceTest001, TestSize.Level1)
871 {
872 printf("%s: [Input] RunCapacitanceTest001 enter\n", __func__);
873 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
874 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
875
876 int32_t ret;
877 char result[TEST_RESULT_LEN] = {0};
878 uint32_t testType = TEST_TYPE;
879 ret = g_inputInterface->iInputController->RunCapacitanceTest(g_touchIndex, testType, result, TEST_RESULT_LEN);
880 if (ret != INPUT_SUCCESS) {
881 HDF_LOGE("%s: run capacitance test failed, ret %d", __func__, ret);
882 }
883 EXPECT_EQ(ret, INPUT_SUCCESS);
884 }
885
886 /**
887 * @tc.name: RunExtraCommand
888 * @tc.desc: run extra command test
889 * @tc.type: FUNC
890 * @tc.require: SR000F867Q
891 */
892 HWTEST_F(HdiInputTest, RunExtraCommand001, TestSize.Level1)
893 {
894 printf("%s: [Input] RunExtraCommand001 enter\n", __func__);
895 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
896 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
897
898 int32_t ret;
899 InputExtraCmd extraCmd = {0};
900 extraCmd.cmdCode = "WakeUpMode";
901 extraCmd.cmdValue = "Enable";
902 ret = g_inputInterface->iInputController->RunExtraCommand(g_touchIndex, &extraCmd);
903 if (ret != INPUT_SUCCESS) {
904 HDF_LOGE("%s: run extra command failed, ret %d", __func__, ret);
905 }
906 EXPECT_EQ(ret, INPUT_SUCCESS);
907 }
908
909 /**
910 * @tc.name: RunExtraCommand
911 * @tc.desc: run extra command test
912 * @tc.type: FUNC
913 * @tc.require: SR000F867Q
914 */
915 HWTEST_F(HdiInputTest, RunExtraCommand002, TestSize.Level1)
916 {
917 printf("%s: [Input] RunExtraCommand002 enter\n", __func__);
918 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
919 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputController, INPUT_NULL_PTR);
920
921 int32_t ret;
922 InputExtraCmd extraCmd = {0};
923 extraCmd.cmdCode = "WakeUpMode";
924 extraCmd.cmdValue = "Enable";
925 ret = g_inputInterface->iInputController->RunExtraCommand(INVALID_INDEX, &extraCmd);
926 if (ret != INPUT_SUCCESS) {
927 HDF_LOGE("%s: run extra command failed, ret %d", __func__, ret);
928 }
929 EXPECT_NE(ret, INPUT_SUCCESS);
930 }