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