1 /*
2 * Copyright (c) 2021-2024 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
16 #include <cstdint>
17 #include <cstdio>
18 #include <cstdlib>
19 #include <string>
20 #include <unistd.h>
21 #include <fcntl.h>
22 #include <gtest/gtest.h>
23 #include <securec.h>
24 #include "osal_time.h"
25 #include "hdf_log.h"
26 #include "input_manager.h"
27 #include "hdi_input_test.h"
28
29 using namespace testing::ext;
30
31 IInputInterface *g_inputInterface;
32 InputEventCb g_callback;
33 InputHostCb g_hotplugCb;
34 bool g_HasDev = false;
35 InputDevDesc g_allDev[MAX_DEVICES];
36
37 static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg);
38 static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex);
39 static void CloseOnlineDev();
40 static void OpenOnlineDev();
41
42 class HdiInputTest : public testing::Test {
43 public:
44 static void SetUpTestCase();
45 static void TearDownTestCase();
46 void SetUp();
47 void TearDown();
48 };
49
SetUpTestCase()50 void HdiInputTest::SetUpTestCase()
51 {
52 int32_t ret;
53 ret = memset_s(g_allDev, MAX_DEVICES * sizeof(InputDevDesc), 0, MAX_DEVICES * sizeof(InputDevDesc));
54 if (ret != 0) {
55 HDF_LOGE("memset failed.\n");
56 return;
57 }
58 ret = GetInputInterface(&g_inputInterface);
59 if (ret != INPUT_SUCCESS) {
60 HDF_LOGE("%s: get input hdi failed, ret %d \n", __func__, ret);
61 }
62
63 g_callback.EventPkgCallback = ReportEventPkgCallback;
64 g_hotplugCb.HotPlugCallback = ReportHotPlugEventPkgCallback;
65 ret = g_inputInterface->iInputManager->ScanInputDevice(g_allDev, MAX_DEVICES);
66 if (ret) {
67 HDF_LOGE("%s: scan device failed, ret %d \n", __func__, ret);
68 }
69 if (g_allDev[0].devIndex == 1){
70 g_HasDev = true;
71 printf("%s: scan deviceIndex:%d,devType:%d. \n", __func__, g_allDev[0].devIndex, g_allDev[0].devType);
72 }
73 for (int32_t i = 0; i < MAX_DEVICES; i++) {
74 if (g_allDev[i].devIndex == 0) {
75 break;
76 }
77 printf("%s: scan deviceIndex:%d,devType:%d. \n", __func__, g_allDev[i].devIndex, g_allDev[i].devType);
78 g_HasDev = true;
79 }
80 if (!g_HasDev) {
81 HDF_LOGE("no input devices, please check .\n");
82 }
83 }
84
TearDownTestCase()85 void HdiInputTest::TearDownTestCase()
86 {
87 ReleaseInputInterface(&g_inputInterface);
88 }
89
SetUp()90 void HdiInputTest::SetUp()
91 {
92 }
93
TearDown()94 void HdiInputTest::TearDown()
95 {
96 }
97
ReportEventPkgCallback(const InputEventPackage ** pkgs,uint32_t count,uint32_t devIndex)98 static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex)
99 {
100 if (pkgs == nullptr) {
101 return;
102 }
103 for (int32_t i = 0; i < count; i++) {
104 printf("%s: pkgs[%d] = 0x%x, 0x%x, %d\n", __func__, i, pkgs[i]->type, pkgs[i]->code, pkgs[i]->value);
105 EXPECT_GE(pkgs[i]->type, 0);
106 EXPECT_GE(pkgs[i]->code, 0);
107 EXPECT_GE(pkgs[i]->value, 0);
108 }
109 }
110
ReportHotPlugEventPkgCallback(const InputHotPlugEvent * msg)111 static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg)
112 {
113 int32_t ret;
114 if (msg == nullptr) {
115 return;
116 }
117 HDF_LOGI("%s: status =%d devId=%d type =%d \n", __func__, msg->status, msg->devIndex, msg->devType);
118 EXPECT_GE(msg->status, 0);
119 EXPECT_GE(msg->devIndex, 0);
120 EXPECT_GE(msg->devType, 0);
121
122 if (msg->status == 0) {
123 ret = g_inputInterface->iInputManager->OpenInputDevice(msg->devIndex);
124 if (ret) {
125 HDF_LOGE("%s: open device[%u] failed, ret %d \n", __func__, msg->devIndex, ret);
126 }
127
128 ret = g_inputInterface->iInputReporter->RegisterReportCallback(msg->devIndex, &g_callback);
129 if (ret) {
130 HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, msg->devIndex, ret);
131 }
132 } else {
133 ret = g_inputInterface->iInputReporter->UnregisterReportCallback(msg->devIndex);
134 if (ret) {
135 HDF_LOGE("%s: unregister callback failed, ret %d \n", __func__, ret);
136 }
137
138 ret = g_inputInterface->iInputManager->CloseInputDevice(msg->devIndex);
139 if (ret) {
140 HDF_LOGE("%s: close device failed, ret %d \n", __func__, ret);
141 }
142 }
143 }
144
OpenOnlineDev()145 static void OpenOnlineDev()
146 {
147 for (int32_t i = 0; i < MAX_DEVICES; i++) {
148 if (g_allDev[i].devIndex == 0) {
149 break;
150 }
151 int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(g_allDev[i].devIndex);
152 if (ret) {
153 HDF_LOGE("%s: open device[%d] failed, ret %d \n", __func__, g_allDev[i].devIndex, ret);
154 }
155 ASSERT_EQ(ret, INPUT_SUCCESS);
156
157 ret = g_inputInterface->iInputReporter->RegisterReportCallback(g_allDev[i].devIndex, &g_callback);
158 if (ret) {
159 HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, g_allDev[i].devIndex, ret);
160 }
161 ASSERT_EQ(ret, INPUT_SUCCESS);
162 }
163 }
164
CloseOnlineDev()165 static void CloseOnlineDev()
166 {
167 for (int32_t i = 0; i < MAX_DEVICES; i++) {
168 if (g_allDev[i].devIndex == 0) {
169 break;
170 }
171 int32_t ret = g_inputInterface->iInputReporter->UnregisterReportCallback(g_allDev[i].devIndex);
172 if (ret) {
173 HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, g_allDev[i].devIndex, ret);
174 }
175 ASSERT_EQ(ret, INPUT_SUCCESS);
176
177 ret = g_inputInterface->iInputManager->CloseInputDevice(g_allDev[i].devIndex);
178 if (ret) {
179 HDF_LOGE("%s: close device[%d] failed, ret %d \n", __func__, g_allDev[i].devIndex, ret);
180 }
181 ASSERT_EQ(ret, INPUT_SUCCESS);
182 }
183 }
184
185 /**
186 * @tc.number: SUB_Driver_Input_Hdi_4500
187 * @tc.name: open input device test
188 * @tc.desc: [C- SOFTWARE -0010]
189 * @tc.size: Medium
190 * @tc.level: level 0
191 */
192 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4500, Function | MediumTest | Level1)
193 {
194 HDF_LOGI("%s: [Input] RegisterCallbackAndReportData001 enter \n", __func__);
195 int32_t ret;
196
197 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
198 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
199
200 ret = g_inputInterface->iInputManager->ScanInputDevice(g_allDev, sizeof(g_allDev)/sizeof(InputDevDesc));
201 EXPECT_EQ(ret, INPUT_SUCCESS);
202 }
203
204 /**
205 * @tc.number: SUB_Driver_Input_Hdi_2900
206 * @tc.name: open input device test
207 * @tc.desc: [C- SOFTWARE -0010]
208 * @tc.size: Medium
209 * @tc.level: level 0
210 */
211 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2900, Function | MediumTest | Level3)
212 {
213 HDF_LOGI("%s: [Input] HotPlugCallback Testcase enter\n", __func__);
214
215 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
216 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
217 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
218
219 int32_t ret = g_inputInterface->iInputReporter->RegisterHotPlugCallback(&g_hotplugCb);
220 if (ret) {
221 HDF_LOGE("%s: register hotplug callback failed for device manager, ret %d\n", __func__, ret);
222 }
223 ASSERT_EQ(ret, INPUT_SUCCESS);
224
225 OpenOnlineDev();
226
227 printf("%s: wait 5s for testing, pls hotplug now\n", __func__);
228 printf("%s: The event data is as following:\n", __func__);
229 OsalMSleep(KEEP_ALIVE_TIME_MS);
230
231 CloseOnlineDev();
232
233 ret = g_inputInterface->iInputReporter->UnregisterHotPlugCallback();
234 if (ret) {
235 HDF_LOGE("%s: unregister hotplug callback failed for device manager, ret %d\n", __func__, ret);
236 }
237 EXPECT_EQ(ret, INPUT_SUCCESS);
238 }
239
240 /**
241 * @tc.number: SUB_Driver_Input_Hdi_2500
242 * @tc.name: open input device test
243 * @tc.desc: [C- SOFTWARE -0010]
244 * @tc.size: Medium
245 * @tc.level: level 0
246 */
247 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2500, Function | MediumTest | Level0)
248 {
249 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
250 ASSERT_EQ(g_HasDev, true);
251 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
252 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
253 int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
254 ASSERT_EQ(ret, INPUT_SUCCESS);
255 ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
256 ASSERT_EQ(ret, INPUT_SUCCESS);
257 }
258 int32_t ret = INPUT_SUCCESS;
259 EXPECT_EQ(ret, INPUT_SUCCESS);
260
261 }
262
263 /**
264 * @tc.number: SUB_Driver_Input_Hdi_2800
265 * @tc.name: open input device error test
266 * @tc.desc: [C- SOFTWARE -0010]
267 * @tc.size: Medium
268 * @tc.level: level 0
269 */
270 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2800, Function | MediumTest | Level0)
271 {
272 ASSERT_EQ(g_HasDev, true);
273 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
274 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
275 /* Device "0" is used for testing nonexistent device node */
276 int32_t ret = g_inputInterface->iInputManager->OpenInputDevice(0);
277 EXPECT_NE(ret, INPUT_SUCCESS);
278 /* Device "5" is used for testing nonexistent device node */
279 ret = g_inputInterface->iInputManager->OpenInputDevice(INVALID_INDEX);
280 EXPECT_NE(ret, INPUT_SUCCESS);
281 }
282
283 /**
284 * @tc.number: SUB_Driver_Input_Hdi_0400
285 * @tc.name: close input device test
286 * @tc.desc: [C- SOFTWARE -0010]
287 * @tc.size: Medium
288 */
289 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_0400, Function | MediumTest | Level0)
290 {
291 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
292 ASSERT_EQ(g_HasDev, true);
293 int32_t ret = 0;
294 g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
295 EXPECT_EQ(ret, INPUT_SUCCESS);
296 ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
297 EXPECT_EQ(ret, INPUT_SUCCESS);
298 }
299 int32_t ret = INPUT_SUCCESS;
300 EXPECT_EQ(ret, INPUT_SUCCESS);
301 }
302 /**
303 * @tc.number: SUB_Driver_Input_Hdi_0300
304 * @tc.name: close input device error test
305 * @tc.desc: [C- SOFTWARE -0010]
306 * @tc.size: Medium
307 * @tc.level: level 0
308 */
309 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_0300, Function | MediumTest | Level0)
310 {
311 ASSERT_EQ(g_HasDev, true);
312 int32_t ret = 0;
313 ret = g_inputInterface->iInputManager->CloseInputDevice(0);
314 EXPECT_NE(ret, INPUT_SUCCESS);
315 ret = g_inputInterface->iInputManager->CloseInputDevice(INVALID_INDEX);
316 EXPECT_NE(ret, INPUT_SUCCESS);
317 }
318
319 /**
320 * @tc.number: SUB_Driver_Input_Hdi_1700
321 * @tc.name: get input device id info test
322 * @tc.desc: [C- SOFTWARE -0010]
323 * @tc.size: Medium
324 * @tc.level: level 0
325 */
326 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_1700, Function | MediumTest | Level0)
327 {
328 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
329 ASSERT_EQ(g_HasDev, true);
330 int32_t ret = 0;
331 InputDeviceInfo *dev = nullptr;
332 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
333 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
334
335 ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
336 if (ret) {
337 HDF_LOGE("%s: open device1 failed, ret %d\n", __func__, ret);
338 }
339 ASSERT_EQ(ret, INPUT_SUCCESS);
340 ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, &dev);
341 EXPECT_EQ(ret, INPUT_SUCCESS);
342 EXPECT_EQ((uint32_t)TOUCH_INDEX, dev->devIndex);
343 HDF_LOGI("devindex = %u, devType = %u\n", dev->devIndex, dev->devType);
344 HDF_LOGI("chipInfo = %s, VendorName = %s,chipName = %s\n", dev->chipInfo, dev->vendorName, dev->chipName);
345 }
346 int32_t ret = INPUT_SUCCESS;
347 EXPECT_EQ(ret, INPUT_SUCCESS);
348 }
349
350 /**
351 * @tc.number: SUB_Driver_Input_Hdi_1100
352 * @tc.name: get input device id error test
353 * @tc.desc: [C- SOFTWARE -0010]
354 * @tc.size: Medium
355 * @tc.level: level 0
356 */
357 HWTEST_F(HdiInputTest, SSUB_Driver_Input_Hdi_1100, Function | MediumTest | Level0)
358 {
359 ASSERT_EQ(g_HasDev, true);
360 int32_t ret = 0;
361 InputDeviceInfo *dev = nullptr;
362
363 ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, nullptr);
364 EXPECT_NE(ret, INPUT_SUCCESS);
365 ret = g_inputInterface->iInputManager->GetInputDevice(0, &dev);
366 EXPECT_NE(ret, INPUT_SUCCESS);
367 ret = g_inputInterface->iInputManager->GetInputDevice(INVALID_INDEX, &dev);
368 EXPECT_NE(ret, INPUT_SUCCESS);
369 ret = g_inputInterface->iInputManager->GetInputDevice(MAX_INPUT_DEV_NUM, &dev);
370 EXPECT_NE(ret, INPUT_SUCCESS);
371 }
372
373 /**
374 * @tc.number: SUB_Driver_Input_Hdi_1600
375 * @tc.name: get input device list info test
376 * @tc.desc: [C- SOFTWARE -0010]
377 * @tc.size: Medium
378 * @tc.level: level 0
379 */
380 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_1600, Function | MediumTest | Level0)
381 {
382 ASSERT_EQ(g_HasDev, true);
383 int32_t ret;
384 uint32_t num = 0;
385 InputDeviceInfo *dev[MAX_INPUT_DEV_NUM] = {0};
386
387 ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, dev, MAX_INPUT_DEV_NUM);
388 EXPECT_EQ(ret, INPUT_SUCCESS);
389 ASSERT_LE(num, (uint32_t)MAX_INPUT_DEV_NUM);
390 for (uint32_t i = 0; i < num; i++) {
391 HDF_LOGI("num = %u,device[%d]'s info is :\n", num, i);
392 HDF_LOGI("index = %u, devType = %u\n", dev[i]->devIndex, dev[i]->devType);
393 HDF_LOGI("chipInfo = %s, VendorName = %s,chipName = %s\n", dev[i]->chipInfo, dev[i]->vendorName,
394 dev[i]->chipName);
395 EXPECT_LE(0, dev[i]->devType);
396 }
397 }
398 /**
399 * @tc.number: SUB_Driver_Input_Hdi_1500
400 * @tc.name: get input device list info error test
401 * @tc.desc: [C- SOFTWARE -0010]
402 * @tc.size: Medium
403 * @tc.level: level 0
404 */
405 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_1500, Function | MediumTest | Level0)
406 {
407 ASSERT_EQ(g_HasDev, true);
408 int32_t ret;
409 uint32_t num = 0;
410 InputDeviceInfo *dev[MAX_INPUT_DEV_NUM] = {0};
411
412 ret = g_inputInterface->iInputManager->GetInputDeviceList(nullptr, dev, MAX_INPUT_DEV_NUM);
413 EXPECT_NE(ret, INPUT_SUCCESS);
414 ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, nullptr, MAX_INPUT_DEV_NUM);
415 EXPECT_NE(ret, INPUT_SUCCESS);
416 ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, dev, 0);
417 EXPECT_NE(ret, INPUT_SUCCESS);
418 }
419
420 /**
421 * @tc.number: SUB_Driver_Input_Hdi_1000
422 * @tc.name: get input device type test
423 * @tc.desc: [C- SOFTWARE -0010]
424 * @tc.size: Medium
425 * @tc.level: level 0
426 */
427 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_1000, Function | MediumTest | Level0)
428 {
429 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
430 ASSERT_EQ(g_HasDev, true);
431 int32_t ret;
432 uint32_t devType = INIT_DEFAULT_VALUE;
433
434 ret = g_inputInterface->iInputController->GetDeviceType(TOUCH_INDEX, &devType);
435 EXPECT_EQ(ret, INPUT_SUCCESS);
436 EXPECT_EQ(devType, INDEV_TYPE_TOUCH);
437 }
438 int32_t ret = INPUT_SUCCESS;
439 EXPECT_EQ(ret, INPUT_SUCCESS);
440 }
441 /**
442 * @tc.number: SUB_Driver_Input_Hdi_0900
443 * @tc.name: get input device type error test
444 * @tc.desc: [C- SOFTWARE -0010]
445 * @tc.size: Medium
446 * @tc.level: level 0
447 */
448 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_0900, Function | MediumTest | Level0)
449 {
450 ASSERT_EQ(g_HasDev, true);
451 int32_t ret;
452 uint32_t devType = INIT_DEFAULT_VALUE;
453
454 ret = g_inputInterface->iInputController->GetDeviceType(TOUCH_INDEX, nullptr);
455 EXPECT_NE(ret, INPUT_SUCCESS);
456 ret = g_inputInterface->iInputController->GetDeviceType(0, &devType);
457 EXPECT_NE(ret, INPUT_SUCCESS);
458 ret = g_inputInterface->iInputController->GetDeviceType(MAX_INPUT_DEV_NUM, &devType);
459 EXPECT_NE(ret, INPUT_SUCCESS);
460 }
461
462 /**
463 * @tc.number: SUB_Driver_Input_Hdi_0600
464 * @tc.name: get input device chip info test
465 * @tc.desc: [C- SOFTWARE -0010]
466 * @tc.size: Medium
467 * @tc.level: level 0
468 */
469 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_0600, Function | MediumTest | Level0)
470 {
471 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
472 ASSERT_EQ(g_HasDev, true);
473 int32_t ret;
474 char chipInfo[CHIP_INFO_LEN] = {0};
475
476 ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, chipInfo, CHIP_INFO_LEN);
477 ASSERT_EQ(ret, INPUT_SUCCESS);
478 HDF_LOGI("device's chip info is %s\n", chipInfo);
479 }
480 int32_t ret = INPUT_SUCCESS;
481 EXPECT_EQ(ret, INPUT_SUCCESS);
482 }
483 /**
484 * @tc.number: SUB_Driver_Input_Hdi_0500
485 * @tc.name: get input device chip info error test
486 * @tc.desc: [C- SOFTWARE -0010]
487 * @tc.size: Medium
488 * @tc.level: level 0
489 */
490 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_0500, Function | MediumTest | Level0)
491 {
492 ASSERT_EQ(g_HasDev, true);
493 int32_t ret;
494 char chipInfo[CHIP_INFO_LEN] = {0};
495
496 ret = g_inputInterface->iInputController->GetChipInfo(0, chipInfo, CHIP_INFO_LEN);
497 EXPECT_NE(ret, INPUT_SUCCESS);
498 ret = g_inputInterface->iInputController->GetChipInfo(MAX_INPUT_DEV_NUM, chipInfo, CHIP_INFO_LEN);
499 EXPECT_NE(ret, INPUT_SUCCESS);
500 ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, nullptr, CHIP_INFO_LEN);
501 EXPECT_NE(ret, INPUT_SUCCESS);
502 ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, chipInfo, CHIP_INFO_LEN - 1);
503 EXPECT_NE(ret, INPUT_SUCCESS);
504 }
505
506 /**
507 * @tc.number: SUB_Driver_Input_Hdi_1400
508 * @tc.name: get input device info test
509 * @tc.desc: [C- SOFTWARE -0010]
510 * @tc.size: Medium
511 * @tc.level: level 0
512 */
513 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_1400, Function | MediumTest | Level0)
514 {
515 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
516 ASSERT_EQ(g_HasDev, true);
517 int32_t ret;
518 char chipInfo[CHIP_INFO_LEN] = {0};
519 InputDeviceInfo *dev =NULL;
520 ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, &dev);
521 EXPECT_EQ(ret, INPUT_SUCCESS);
522 ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, chipInfo, CHIP_INFO_LEN);
523 EXPECT_EQ(ret, INPUT_SUCCESS);
524 HDF_LOGI("device1's chip info is %s? chipInfo = %s\n", chipInfo, dev->chipInfo);
525 }
526 int32_t ret = INPUT_SUCCESS;
527 EXPECT_EQ(ret, INPUT_SUCCESS);
528 }
529 /**
530 * @tc.number: SUB_Driver_Input_Hdi_4900
531 * @tc.name: set device power status test-INPUT_LOW_POWER
532 * @tc.desc: [C- SOFTWARE -0010]
533 * @tc.size: Medium
534 * @tc.level: level 0
535 */
536 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4900, Function | MediumTest | Level0)
537 {
538 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
539 ASSERT_EQ(g_HasDev, true);
540 int32_t ret;
541 uint32_t setStatus = INPUT_LOW_POWER;
542 uint32_t getStatus = 0;
543
544 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
545 EXPECT_EQ(ret, INPUT_SUCCESS);
546 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
547 EXPECT_EQ(ret, INPUT_SUCCESS);
548 ASSERT_EQ(setStatus, getStatus);
549 }
550 int32_t ret = INPUT_SUCCESS;
551 EXPECT_EQ(ret, INPUT_SUCCESS);
552 }
553 /**
554 * @tc.number: SUB_Driver_Input_Hdi_5100
555 * @tc.name: set device power status test-INPUT_SUSPEND
556 * @tc.desc: [C- SOFTWARE -0010]
557 * @tc.size: Medium
558 * @tc.level: level 0
559 */
560 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_5100, Function | MediumTest | Level0)
561 {
562 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
563 ASSERT_EQ(g_HasDev, true);
564 int32_t ret;
565 uint32_t setStatus = INPUT_SUSPEND;
566 uint32_t getStatus = 0;
567
568 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
569 EXPECT_EQ(ret, INPUT_SUCCESS);
570 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
571 EXPECT_EQ(ret, INPUT_SUCCESS);
572 ASSERT_EQ(setStatus, getStatus);
573 }
574 int32_t ret = INPUT_SUCCESS;
575 EXPECT_EQ(ret, INPUT_SUCCESS);
576 }
577
578 /**
579 * @tc.number: SUB_Driver_Input_Hdi_5000
580 * @tc.name: set device power status test-INPUT_RESUME
581 * @tc.desc: [C- SOFTWARE -0010]
582 * @tc.size: Medium
583 * @tc.level: level 0
584 */
585 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_5000, Function | MediumTest | Level0)
586 {
587 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
588 ASSERT_EQ(g_HasDev, true);
589 int32_t ret;
590 uint32_t setStatus = INPUT_RESUME;
591 uint32_t getStatus = 0;
592
593 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
594 EXPECT_EQ(ret, INPUT_SUCCESS);
595 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
596 EXPECT_EQ(ret, INPUT_SUCCESS);
597 ASSERT_EQ(setStatus, getStatus);
598 }
599 int32_t ret = INPUT_SUCCESS;
600 EXPECT_EQ(ret, INPUT_SUCCESS);
601 }
602 /**
603 * @tc.number: SUB_Driver_Input_Hdi_4800
604 * @tc.name: set device poewr status error test
605 * @tc.desc: [C- SOFTWARE -0010]
606 * @tc.size: Medium
607 * @tc.level: level 0
608 */
609 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4800, Function | MediumTest | Level0)
610 {
611 ASSERT_EQ(g_HasDev, true);
612 int32_t ret;
613 uint32_t setStatus = INPUT_LOW_POWER;
614
615 ret = g_inputInterface->iInputController->SetPowerStatus(0, setStatus);
616 EXPECT_NE(ret, INPUT_SUCCESS);
617 ret = g_inputInterface->iInputController->SetPowerStatus(MAX_INPUT_DEV_NUM, setStatus);
618 EXPECT_NE(ret, INPUT_SUCCESS);
619 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, INPUT_POWER_STATUS_UNKNOWN);
620 EXPECT_NE(ret, INPUT_SUCCESS);
621 }
622
623 /**
624 * @tc.number: SUB_Driver_Input_Hdi_4400
625 * @tc.name: set device power status error test_2
626 * @tc.desc: [C- SOFTWARE -0010]
627 * @tc.size: Medium
628 * @tc.level: level 0
629 */
630 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4400, Function | MediumTest | Level0)
631 {
632 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
633 ASSERT_EQ(g_HasDev, true);
634 int32_t ret;
635 uint32_t setStatus = INPUT_SUSPEND;
636 uint32_t getStatus = 0;
637
638 ret = g_inputInterface->iInputController->SetPowerStatus(0, setStatus);
639 EXPECT_NE(ret, INPUT_SUCCESS);
640 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
641 EXPECT_EQ(ret, INPUT_SUCCESS);
642 ASSERT_NE(setStatus, getStatus);
643 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
644 EXPECT_EQ(ret, INPUT_SUCCESS);
645 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
646 EXPECT_EQ(ret, INPUT_SUCCESS);
647 ASSERT_EQ(setStatus, getStatus);
648 }
649 int32_t ret = INPUT_SUCCESS;
650 EXPECT_EQ(ret, INPUT_SUCCESS);
651 }
652
653 /**
654 * @tc.number: SUB_Driver_Input_Hdi_5300
655 * @tc.name: set device power status error test_2
656 * @tc.desc: [C- SOFTWARE -0010]
657 * @tc.size: Medium
658 * @tc.level: level 0
659 */
660 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_5300, Function | MediumTest | Level0)
661 {
662 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
663 ASSERT_EQ(g_HasDev, true);
664 int32_t ret;
665 uint32_t setStatus = INPUT_RESUME;
666 uint32_t getStatus = 0;
667
668 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
669 EXPECT_EQ(ret, INPUT_SUCCESS);
670 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
671 EXPECT_EQ(ret, INPUT_SUCCESS);
672 ASSERT_EQ(setStatus, getStatus);
673 ret = g_inputInterface->iInputController->SetPowerStatus(0, setStatus);
674 EXPECT_NE(ret, INPUT_SUCCESS);
675 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
676 EXPECT_EQ(ret, INPUT_SUCCESS);
677 ASSERT_EQ(setStatus, getStatus);
678
679 }
680 int32_t ret = INPUT_SUCCESS;
681 EXPECT_EQ(ret, INPUT_SUCCESS);
682 }
683
684 /**
685 * @tc.number: SUB_Driver_Input_Hdi_2100
686 * @tc.name: get device poewr status test
687 * @tc.desc: [C- SOFTWARE -0010]
688 * @tc.size: Medium
689 * @tc.level: level 0
690 */
691 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2100, Function | MediumTest | Level0)
692 {
693 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
694 ASSERT_EQ(g_HasDev, true);
695 int32_t ret;
696 uint32_t setStatus = INPUT_RESUME;
697 uint32_t getStatus = 0;
698
699 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
700 EXPECT_EQ(ret, INPUT_SUCCESS);
701 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
702 EXPECT_EQ(ret, INPUT_SUCCESS);
703 ASSERT_EQ(setStatus, getStatus);
704 }
705 int32_t ret = INPUT_SUCCESS;
706 EXPECT_EQ(ret, INPUT_SUCCESS);
707 }
708
709 /**
710 * @tc.number: SUB_Driver_Input_Hdi_2200
711 * @tc.name: get device poewr status test-INPUT_SUSPEND
712 * @tc.desc: [C- SOFTWARE -0010]
713 * @tc.size: Medium
714 * @tc.level: level 0
715 */
716 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2200, Function | MediumTest | Level0)
717 {
718 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
719 ASSERT_EQ(g_HasDev, true);
720 int32_t ret;
721 uint32_t setStatus = INPUT_SUSPEND;
722 uint32_t getStatus = 0;
723
724 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
725 EXPECT_EQ(ret, INPUT_SUCCESS);
726 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
727 EXPECT_EQ(ret, INPUT_SUCCESS);
728 ASSERT_EQ(setStatus, getStatus);
729 }
730 int32_t ret = INPUT_SUCCESS;
731 EXPECT_EQ(ret, INPUT_SUCCESS);
732 }
733
734 /**
735 * @tc.number: SUB_Driver_Input_Hdi_1900
736 * @tc.name: get device poewr status test-INPUT_LOW_POWER
737 * @tc.desc: [C- SOFTWARE -0010]
738 * @tc.size: Medium
739 * @tc.level: level 0
740 */
741 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_1900, Function | MediumTest | Level0)
742 {
743 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
744 ASSERT_EQ(g_HasDev, true);
745 int32_t ret;
746 uint32_t setStatus = INPUT_LOW_POWER;
747 uint32_t getStatus = 0;
748
749 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
750 EXPECT_EQ(ret, INPUT_SUCCESS);
751 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
752 EXPECT_EQ(ret, INPUT_SUCCESS);
753 ASSERT_EQ(setStatus, getStatus);
754 }
755 int32_t ret = INPUT_SUCCESS;
756 EXPECT_EQ(ret, INPUT_SUCCESS);
757 }
758
759 /**
760 * @tc.number: SUB_Driver_Input_Hdi_2000
761 * @tc.name: get device poewr status test-INPUT_POWER_STATUS_UNKNOWN
762 * @tc.desc: [C- SOFTWARE -0010]
763 * @tc.size: Medium
764 * @tc.level: level 0
765 */
766 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2000, Function | MediumTest | Level0)
767 {
768 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
769 ASSERT_EQ(g_HasDev, true);
770 int32_t ret;
771 uint32_t setStatus = INPUT_POWER_STATUS_UNKNOWN;
772 uint32_t getStatus = 0;
773
774 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
775 EXPECT_NE(ret, INPUT_SUCCESS);
776 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
777 EXPECT_EQ(ret, INPUT_SUCCESS);
778 ASSERT_NE(setStatus, getStatus);
779 }
780 int32_t ret = INPUT_SUCCESS;
781 EXPECT_EQ(ret, INPUT_SUCCESS);
782 }
783
784 /**
785 * @tc.number: SUB_Driver_Input_Hdi_1800
786 * @tc.name: get device poewr status error test
787 * @tc.desc: [C- SOFTWARE -0010]
788 * @tc.size: Medium
789 * @tc.level: level 0
790 */
791 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_1800, Function | MediumTest | Level0)
792 {
793 ASSERT_EQ(g_HasDev, true);
794 int32_t ret;
795 uint32_t getStatus = 0;
796
797 ret = g_inputInterface->iInputController->GetPowerStatus(0, &getStatus);
798 EXPECT_NE(ret, INPUT_SUCCESS);
799 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, nullptr);
800 EXPECT_NE(ret, INPUT_SUCCESS);
801 ret = g_inputInterface->iInputController->GetPowerStatus(MAX_INPUT_DEV_NUM, &getStatus);
802 EXPECT_NE(ret, INPUT_SUCCESS);
803 }
804
805 /**
806 * @tc.number: SUB_Driver_Input_Hdi_2400
807 * @tc.name: get device vendor name test
808 * @tc.desc: [C- SOFTWARE -0010]
809 * @tc.size: Medium
810 * @tc.level: level 0
811 */
812 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2400, Function | MediumTest | Level0)
813 {
814 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
815 ASSERT_EQ(g_HasDev, true);
816 int32_t ret;
817 char vendorName[VENDOR_NAME_LEN] = {0};
818
819 ret = g_inputInterface->iInputController->GetVendorName(TOUCH_INDEX, vendorName, VENDOR_NAME_LEN);
820 EXPECT_EQ(ret, INPUT_SUCCESS);
821 HDF_LOGI("device1's vendor name is %s:\n", vendorName);
822 }
823 int32_t ret = INPUT_SUCCESS;
824 EXPECT_EQ(ret, INPUT_SUCCESS);
825 }
826
827 /**
828 * @tc.number: SUB_Driver_Input_Hdi_2300
829 * @tc.name: get device vendor name error test
830 * @tc.desc: [C- SOFTWARE -0010]
831 * @tc.size: Medium
832 * @tc.level: level 0
833 */
834 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_2300, Function | MediumTest | Level0)
835 {
836 ASSERT_EQ(g_HasDev, true);
837 int32_t ret;
838 char vendorName[VENDOR_NAME_LEN] = {0};
839
840 ret = g_inputInterface->iInputController->GetVendorName(MAX_INPUT_DEV_NUM, vendorName, VENDOR_NAME_LEN);
841 EXPECT_NE(ret, INPUT_SUCCESS);
842 ret = g_inputInterface->iInputController->GetVendorName(0, vendorName, VENDOR_NAME_LEN);
843 EXPECT_NE(ret, INPUT_SUCCESS);
844 ret = g_inputInterface->iInputController->GetVendorName(TOUCH_INDEX, nullptr, VENDOR_NAME_LEN);
845 EXPECT_NE(ret, INPUT_SUCCESS);
846 ret = g_inputInterface->iInputController->GetVendorName(TOUCH_INDEX, vendorName, VENDOR_NAME_LEN - 1);
847 EXPECT_NE(ret, INPUT_SUCCESS);
848 }
849
850
851 /**
852 * @tc.number: SUB_Driver_Input_Hdi_0800
853 * @tc.name: get device chip name test
854 * @tc.desc: [C- SOFTWARE -0010]
855 * @tc.size: Medium
856 * @tc.level: level 0
857 */
858 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_0800, Function | MediumTest | Level0)
859 {
860 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
861 ASSERT_EQ(g_HasDev, true);
862 int32_t ret;
863 char chipName[CHIP_NAME_LEN] = {0};
864
865 ret = g_inputInterface->iInputController->GetChipName(TOUCH_INDEX, chipName, CHIP_NAME_LEN);
866 EXPECT_EQ(ret, INPUT_SUCCESS);
867 HDF_LOGI("device1's vendor name is %s:\n", chipName);
868 }
869 int32_t ret = INPUT_SUCCESS;
870 EXPECT_EQ(ret, INPUT_SUCCESS);
871 }
872 /**
873 * @tc.number: SUB_Driver_Input_Hdi_0700
874 * @tc.name: get device chip name error test
875 * @tc.desc: [C- SOFTWARE -0010]
876 * @tc.size: Medium
877 * @tc.level: level 0
878 */
879 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_0700, Function | MediumTest | Level0)
880 {
881 ASSERT_EQ(g_HasDev, true);
882 int32_t ret;
883 char chipName[CHIP_NAME_LEN] = {0};
884
885 ret = g_inputInterface->iInputController->GetChipName(MAX_INPUT_DEV_NUM, chipName, CHIP_NAME_LEN);
886 EXPECT_NE(ret, INPUT_SUCCESS);
887 ret = g_inputInterface->iInputController->GetChipName(0, chipName, CHIP_NAME_LEN);
888 EXPECT_NE(ret, INPUT_SUCCESS);
889 ret = g_inputInterface->iInputController->GetChipName(TOUCH_INDEX, nullptr, CHIP_NAME_LEN);
890 EXPECT_NE(ret, INPUT_SUCCESS);
891 ret = g_inputInterface->iInputController->GetChipName(TOUCH_INDEX, chipName, CHIP_NAME_LEN - 1);
892 EXPECT_NE(ret, INPUT_SUCCESS);
893 }
894
895 /**
896 * @tc.number: SUB_Driver_Input_Hdi_4700
897 * @tc.name: set device gesture mode test
898 * @tc.desc: [C- SOFTWARE -0010]
899 * @tc.size: Medium
900 * @tc.level: level 0
901 */
902 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4700, Function | MediumTest | Level0)
903 {
904 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
905 ASSERT_EQ(g_HasDev, true);
906 int32_t ret;
907 uint32_t gestureMode = 1;
908
909 ret = g_inputInterface->iInputController->SetGestureMode(TOUCH_INDEX, gestureMode);
910 EXPECT_EQ(ret, INPUT_SUCCESS);
911 }
912 int32_t ret = INPUT_SUCCESS;
913 EXPECT_EQ(ret, INPUT_SUCCESS);
914 }
915
916 /**
917 * @tc.number: SUB_Driver_Input_Hdi_4600
918 * @tc.name: set device gesture mode error test
919 * @tc.desc: [C- SOFTWARE -0010]
920 * @tc.size: Medium
921 * @tc.level: level 0
922 */
923 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4600, Function | MediumTest | Level0)
924 {
925 ASSERT_EQ(g_HasDev, true);
926 int32_t ret;
927 uint32_t gestureMode = 1;
928
929 ret = g_inputInterface->iInputController->SetGestureMode(0, gestureMode);
930 EXPECT_NE(ret, INPUT_SUCCESS);
931 ret = g_inputInterface->iInputController->SetGestureMode(MAX_INPUT_DEV_NUM, gestureMode);
932 EXPECT_NE(ret, INPUT_SUCCESS);
933 }
934
935 /**
936 * @tc.number: SUB_Driver_Input_Hdi_3700
937 * @tc.name: Run Capacitance test-BASE_TEST
938 * @tc.desc: [C- SOFTWARE -0010]
939 * @tc.size: Medium
940 * @tc.level: level 0
941 */
942 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3700, Function | MediumTest | Level0)
943 {
944 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
945 ASSERT_EQ(g_HasDev, true);
946 int32_t ret;
947 uint32_t testType = BASE_TEST;
948 char result[MAX_INPUT_DEV_NUM] = {0};
949
950 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, MAX_INPUT_DEV_NUM);
951 EXPECT_EQ(ret, INPUT_SUCCESS);
952 }
953 int32_t ret = INPUT_SUCCESS;
954 EXPECT_EQ(ret, INPUT_SUCCESS);
955 }
956
957 /**
958 * @tc.number: SUB_Driver_Input_Hdi_3800
959 * @tc.name: Run Capacitance test-FULL_TEST
960 * @tc.desc: [C- SOFTWARE -0010]
961 * @tc.size: Medium
962 * @tc.level: level 0
963 */
964 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3800, Function | MediumTest | Level0)
965 {
966 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
967 ASSERT_EQ(g_HasDev, true);
968 int32_t ret;
969 uint32_t testType = FULL_TEST;
970 char result[MAX_INPUT_DEV_NUM] = {0};
971
972 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, MAX_INPUT_DEV_NUM);
973 EXPECT_EQ(ret, INPUT_SUCCESS);
974 }
975 int32_t ret = INPUT_SUCCESS;
976 EXPECT_EQ(ret, INPUT_SUCCESS);
977 }
978
979 /**
980 * @tc.number: SUB_Driver_Input_Hdi_3900
981 * @tc.name: Run Capacitance test-MMI_TEST
982 * @tc.desc: [C- SOFTWARE -0010]
983 * @tc.size: Medium
984 * @tc.level: level 0
985 */
986 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3900, Function | MediumTest | Level0)
987 {
988 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
989 ASSERT_EQ(g_HasDev, true);
990 int32_t ret;
991 uint32_t testType = MMI_TEST;
992 char result[MAX_INPUT_DEV_NUM] = {0};
993
994 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, MAX_INPUT_DEV_NUM);
995 EXPECT_EQ(ret, INPUT_SUCCESS);
996 }
997 int32_t ret = INPUT_SUCCESS;
998 EXPECT_EQ(ret, INPUT_SUCCESS);
999 }
1000
1001 /**
1002 * @tc.number: SUB_Driver_Input_Hdi_4000
1003 * @tc.name: Run Capacitance test-RUNNING_TEST
1004 * @tc.desc: [C- SOFTWARE -0010]
1005 * @tc.size: Medium
1006 * @tc.level: level 0
1007 */
1008 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4000, Function | MediumTest | Level0)
1009 {
1010 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
1011 ASSERT_EQ(g_HasDev, true);
1012 int32_t ret;
1013 uint32_t testType = RUNNING_TEST;
1014 char result[MAX_INPUT_DEV_NUM] = {0};
1015
1016 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, MAX_INPUT_DEV_NUM);
1017 EXPECT_EQ(ret, INPUT_SUCCESS);
1018 }
1019 int32_t ret = INPUT_SUCCESS;
1020 EXPECT_EQ(ret, INPUT_SUCCESS);
1021 }
1022
1023 /**
1024 * @tc.number: SUB_Driver_Input_Hdi_4100
1025 * @tc.name: Run Capacitance test-TEST_TYPE_UNKNOWN
1026 * @tc.desc: [C- SOFTWARE -0010]
1027 * @tc.size: Medium
1028 * @tc.level: level 0
1029 */
1030 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4100, Function | MediumTest | Level0)
1031 {
1032 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
1033 ASSERT_EQ(g_HasDev, true);
1034 int32_t ret;
1035 uint32_t testType = TEST_TYPE_UNKNOWN;
1036 char result[MAX_INPUT_DEV_NUM] = {0};
1037
1038 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, MAX_INPUT_DEV_NUM);
1039 EXPECT_NE(ret, INPUT_SUCCESS);
1040 }
1041 int32_t ret = INPUT_SUCCESS;
1042 EXPECT_EQ(ret, INPUT_SUCCESS);
1043 }
1044
1045 /**
1046 * @tc.number: SUB_Driver_Input_Hdi_3500
1047 * @tc.name: Run Capacitance error test-MMI_TEST
1048 * @tc.desc: [C- SOFTWARE -0010]
1049 * @tc.size: Medium
1050 * @tc.level: level 0
1051 */
1052 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3500, Function | MediumTest | Level0)
1053 {
1054 ASSERT_EQ(g_HasDev, true);
1055 int32_t ret;
1056 uint32_t testType = MMI_TEST;
1057 char result[MAX_INPUT_DEV_NUM] = {0};
1058
1059 ret = g_inputInterface->iInputController->RunCapacitanceTest(0, testType, result, MAX_INPUT_DEV_NUM);
1060 EXPECT_NE(ret, INPUT_SUCCESS);
1061 ret = g_inputInterface->iInputController->RunCapacitanceTest(MAX_INPUT_DEV_NUM, testType, result,
1062 MAX_INPUT_DEV_NUM);
1063 EXPECT_NE(ret, INPUT_SUCCESS);
1064 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, TEST_TYPE_UNKNOWN, result,
1065 MAX_INPUT_DEV_NUM);
1066 EXPECT_NE(ret, INPUT_SUCCESS);
1067 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, nullptr, MAX_INPUT_DEV_NUM);
1068 EXPECT_NE(ret, INPUT_SUCCESS);
1069 }
1070 /**
1071 * @tc.number: SUB_Driver_Input_Hdi_3300
1072 * @tc.name: Run Capacitance error test-BASE_TEST
1073 * @tc.desc: [C- SOFTWARE -0010]
1074 * @tc.size: Medium
1075 * @tc.level: level 0
1076 */
1077 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3300, Function | MediumTest | Level0)
1078 {
1079 ASSERT_EQ(g_HasDev, true);
1080 int32_t ret;
1081 uint32_t testType = BASE_TEST;
1082 char result[MAX_INPUT_DEV_NUM] = {0};
1083
1084 ret = g_inputInterface->iInputController->RunCapacitanceTest(0, testType, result, MAX_INPUT_DEV_NUM);
1085 EXPECT_NE(ret, INPUT_SUCCESS);
1086 ret = g_inputInterface->iInputController->RunCapacitanceTest(MAX_INPUT_DEV_NUM, testType, result,
1087 MAX_INPUT_DEV_NUM);
1088 EXPECT_NE(ret, INPUT_SUCCESS);
1089 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, TEST_TYPE_UNKNOWN, result,
1090 MAX_INPUT_DEV_NUM);
1091 EXPECT_NE(ret, INPUT_SUCCESS);
1092 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, nullptr, MAX_INPUT_DEV_NUM);
1093 EXPECT_NE(ret, INPUT_SUCCESS);
1094 }
1095
1096 /**
1097 * @tc.number: SUB_Driver_Input_Hdi_3400
1098 * @tc.name: Run Capacitance error test-FULL_TEST
1099 * @tc.desc: [C- SOFTWARE -0010]
1100 * @tc.size: Medium
1101 * @tc.level: level 0
1102 */
1103 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3400, Function | MediumTest | Level0)
1104 {
1105 ASSERT_EQ(g_HasDev, true);
1106 int32_t ret;
1107 uint32_t testType = FULL_TEST;
1108 char result[MAX_INPUT_DEV_NUM] = {0};
1109
1110 ret = g_inputInterface->iInputController->RunCapacitanceTest(0, testType, result, MAX_INPUT_DEV_NUM);
1111 EXPECT_NE(ret, INPUT_SUCCESS);
1112 ret = g_inputInterface->iInputController->RunCapacitanceTest(MAX_INPUT_DEV_NUM, testType, result,
1113 MAX_INPUT_DEV_NUM);
1114 EXPECT_NE(ret, INPUT_SUCCESS);
1115 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, TEST_TYPE_UNKNOWN, result,
1116 MAX_INPUT_DEV_NUM);
1117 EXPECT_NE(ret, INPUT_SUCCESS);
1118 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, nullptr, MAX_INPUT_DEV_NUM);
1119 EXPECT_NE(ret, INPUT_SUCCESS);
1120 }
1121
1122 /**
1123 * @tc.number: SUB_Driver_Input_Hdi_3600
1124 * @tc.name: Run Capacitance error test-RUNNING_TEST
1125 * @tc.desc: [C- SOFTWARE -0010]
1126 * @tc.size: Medium
1127 * @tc.level: level 0
1128 */
1129 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3600, Function | MediumTest | Level0)
1130 {
1131 ASSERT_EQ(g_HasDev, true);
1132 int32_t ret;
1133 uint32_t testType = RUNNING_TEST;
1134 char result[MAX_INPUT_DEV_NUM] = {0};
1135
1136 ret = g_inputInterface->iInputController->RunCapacitanceTest(0, testType, result, MAX_INPUT_DEV_NUM);
1137 EXPECT_NE(ret, INPUT_SUCCESS);
1138 ret = g_inputInterface->iInputController->RunCapacitanceTest(MAX_INPUT_DEV_NUM, testType, result,
1139 MAX_INPUT_DEV_NUM);
1140 EXPECT_NE(ret, INPUT_SUCCESS);
1141 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, TEST_TYPE_UNKNOWN, result,
1142 MAX_INPUT_DEV_NUM);
1143 EXPECT_NE(ret, INPUT_SUCCESS);
1144 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, nullptr, MAX_INPUT_DEV_NUM);
1145 EXPECT_NE(ret, INPUT_SUCCESS);
1146 }
1147 /**
1148 * @tc.number: SUB_Driver_Input_Hdi_4300
1149 * @tc.name: Run Extra Command test
1150 * @tc.desc: [C- SOFTWARE -0010]
1151 * @tc.size: Medium
1152 * @tc.level: level 0
1153 */
1154 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4300, Function | MediumTest | Level0)
1155 {
1156 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
1157 ASSERT_EQ(g_HasDev, true);
1158 int32_t ret;
1159 InputExtraCmd extraCmd = {0};
1160 extraCmd.cmdCode = "WakeUpMode";
1161 extraCmd.cmdValue = "Enable";
1162
1163 ret = g_inputInterface->iInputController->RunExtraCommand(TOUCH_INDEX, &extraCmd);
1164 EXPECT_EQ(ret, INPUT_SUCCESS);
1165 }
1166 int32_t ret = INPUT_SUCCESS;
1167 EXPECT_EQ(ret, INPUT_SUCCESS);
1168 }
1169
1170 /**
1171 * @tc.number: SUB_Driver_Input_Hdi_4200
1172 * @tc.name: Run Extra Command error test
1173 * @tc.desc: [C- SOFTWARE -0010]
1174 * @tc.size: Medium
1175 * @tc.level: level 0
1176 */
1177 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_4200, Function | MediumTest | Level0)
1178 {
1179 ASSERT_EQ(g_HasDev, true);
1180 int32_t ret;
1181 InputExtraCmd extraCmd = {0};
1182 extraCmd.cmdCode = "WakeUpMode";
1183 extraCmd.cmdValue = "Enable";
1184
1185 ret = g_inputInterface->iInputController->RunExtraCommand(MAX_INPUT_DEV_NUM, &extraCmd);
1186 EXPECT_NE(ret, INPUT_SUCCESS);
1187 ret = g_inputInterface->iInputController->RunExtraCommand(0, &extraCmd);
1188 EXPECT_NE(ret, INPUT_SUCCESS);
1189 ret = g_inputInterface->iInputController->RunExtraCommand(TOUCH_INDEX, nullptr);
1190 EXPECT_NE(ret, INPUT_SUCCESS);
1191 }
1192
1193 /**
1194 * @tc.number: SUB_Driver_Input_Hdi_3000
1195 * @tc.name: Register Report Callback test
1196 * @tc.desc: [C- SOFTWARE -0010]
1197 * @tc.size: Medium
1198 * @tc.level: level 0
1199 */
1200 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3000, Function | MediumTest | Level0)
1201 {
1202 ASSERT_EQ(g_HasDev, true);
1203 int32_t ret;
1204 g_callback.EventPkgCallback = ReportEventPkgCallback;
1205 ret = g_inputInterface->iInputReporter->RegisterReportCallback(0, &g_callback);
1206 EXPECT_NE(ret, INPUT_SUCCESS);
1207 ret = g_inputInterface->iInputReporter->RegisterReportCallback(MAX_INPUT_DEV_NUM, &g_callback);
1208 EXPECT_NE(ret, INPUT_SUCCESS);
1209 ret = g_inputInterface->iInputReporter->RegisterReportCallback(TOUCH_INDEX, nullptr);
1210 EXPECT_NE(ret, INPUT_SUCCESS);
1211 }
1212
1213 /**
1214 * @tc.number: SUB_Driver_Input_Hdi_3100
1215 * @tc.name: Register Report Callback test
1216 * @tc.desc: [C- SOFTWARE -0010]
1217 * @tc.size: Medium
1218 * @tc.level: level 0
1219 */
1220 HWTEST_F(HdiInputTest, SUB_Driver_Input_Hdi_3100, Function | MediumTest | Level0)
1221 {
1222 if (g_allDev[0].devType == INDEV_TYPE_TOUCH) {
1223 ASSERT_EQ(g_HasDev, true);
1224 int32_t ret;
1225 g_callback.EventPkgCallback = ReportEventPkgCallback;
1226
1227 ret = g_inputInterface->iInputReporter->RegisterReportCallback(TOUCH_INDEX, &g_callback);
1228 EXPECT_EQ(ret, INPUT_SUCCESS);
1229 printf("wait 5 for testing, pls touch the panel now\n");
1230 printf("the event data is as following:\n");
1231 OsalMSleep(KEEP_ALIVE_TIME_MS);
1232 ret = g_inputInterface->iInputReporter->UnregisterReportCallback(TOUCH_INDEX);
1233 EXPECT_EQ(ret, INPUT_SUCCESS);
1234 }
1235 int32_t ret = INPUT_SUCCESS;
1236 EXPECT_EQ(ret, INPUT_SUCCESS);
1237 }