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 #include <benchmark/benchmark.h>
16 #include <string>
17 #include <vector>
18
19 #include <cstdint>
20 #include <cstdio>
21 #include <cstdlib>
22 #include <string>
23 #include <unistd.h>
24 #include <fcntl.h>
25 #include <gtest/gtest.h>
26 #include <securec.h>
27 #include "osal_time.h"
28 #include "hdf_log.h"
29 #include "input_manager.h"
30 #include "../hdi_input/common/hdi_input_test.h"
31
32 using namespace std;
33 using namespace testing::ext;
34
35 namespace {
36 IInputInterface *g_inputInterface;
37 InputEventCb g_callback;
38 InputHostCb g_hotplugCb;
39 bool g_HasDev = false;
40
41 static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg);
42 static void ReportEventPkgCallback(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex);
43 static void CloseOnlineDev(InputDevDesc *sta, int32_t len);
44 static void OpenOnlineDev(InputDevDesc *sta, int32_t len);
45
46 class InputBenchmarkTest : public benchmark::Fixture {
47 public:
48 void SetUp(const ::benchmark::State &state);
49 void TearDown(const ::benchmark::State &state);
50 };
51
SetUp(const::benchmark::State & state)52 void InputBenchmarkTest::SetUp(const ::benchmark::State &state)
53 {
54 int32_t ret;
55 InputDevDesc sta[MAX_DEVICES];
56 ret = memset_s(sta, MAX_DEVICES * sizeof(InputDevDesc), 0, MAX_DEVICES * sizeof(InputDevDesc));
57 if (ret != 0) {
58 HDF_LOGE("memset failed.\n");
59 return;
60 }
61 ret = GetInputInterface(&g_inputInterface);
62 if (ret != INPUT_SUCCESS) {
63 HDF_LOGE("%s: get input hdi failed, ret %d \n", __func__, ret);
64 }
65
66 g_callback.EventPkgCallback = ReportEventPkgCallback;
67 g_hotplugCb.HotPlugCallback = ReportHotPlugEventPkgCallback;
68 ret = g_inputInterface->iInputManager->ScanInputDevice(sta, MAX_DEVICES);
69 if (ret) {
70 HDF_LOGE("%s: scan device failed, ret %d \n", __func__, ret);
71 }
72 for (int32_t i = 0; i < MAX_DEVICES; i++) {
73 if (sta[i].devIndex == 0) {
74 break;
75 }
76 g_HasDev = true;
77 }
78 }
79
TearDown(const::benchmark::State & state)80 void InputBenchmarkTest::TearDown(const ::benchmark::State &state)
81 {
82 ReleaseInputInterface(&g_inputInterface);
83 }
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 return;
89 }
90 for (int32_t i = 0; i < count; i++) {
91 printf("%s: pkgs[%d] = 0x%x, 0x%x, %d\n", __func__, i, pkgs[i]->type, pkgs[i]->code, pkgs[i]->value);
92 EXPECT_GE(pkgs[i]->type, 0);
93 EXPECT_GE(pkgs[i]->code, 0);
94 EXPECT_GE(pkgs[i]->value, 0);
95 }
96 }
97
ReportHotPlugEventPkgCallback(const InputHotPlugEvent * msg)98 static void ReportHotPlugEventPkgCallback(const InputHotPlugEvent *msg)
99 {
100 int32_t ret;
101 if (msg == nullptr) {
102 return;
103 }
104 HDF_LOGI("%s: status =%d devId=%d type =%d \n", __func__, msg->status, msg->devIndex, msg->devType);
105 EXPECT_GE(msg->status, 0);
106 EXPECT_GE(msg->devIndex, 0);
107 EXPECT_GE(msg->devType, 0);
108
109 if (msg->status == 0) {
110 ret = g_inputInterface->iInputManager->OpenInputDevice(msg->devIndex);
111 if (ret) {
112 HDF_LOGE("%s: open device[%u] failed, ret %d \n", __func__, msg->devIndex, ret);
113 }
114
115 ret = g_inputInterface->iInputReporter->RegisterReportCallback(msg->devIndex, &g_callback);
116 if (ret) {
117 HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, msg->devIndex, ret);
118 }
119 } else {
120 ret = g_inputInterface->iInputReporter->UnregisterReportCallback(msg->devIndex);
121 if (ret) {
122 HDF_LOGE("%s: unregister callback failed, ret %d \n", __func__, ret);
123 }
124
125 ret = g_inputInterface->iInputManager->CloseInputDevice(msg->devIndex);
126 if (ret) {
127 HDF_LOGE("%s: close device failed, ret %d \n", __func__, ret);
128 }
129 }
130 }
131
OpenOnlineDev(InputDevDesc * sta,int32_t len)132 static void OpenOnlineDev(InputDevDesc *sta, int32_t len)
133 {
134 int32_t ret = g_inputInterface->iInputManager->ScanInputDevice(sta, len);
135 if (ret) {
136 HDF_LOGE("%s: scan device failed, ret %d \n", __func__, ret);
137 }
138 ASSERT_EQ(ret, INPUT_SUCCESS);
139
140 for (int32_t i = 0; i < len; i++) {
141 if (sta[i].devIndex == 0) {
142 break;
143 }
144 ret = g_inputInterface->iInputManager->OpenInputDevice(sta[i].devIndex);
145 if (ret) {
146 HDF_LOGE("%s: open device[%d] failed, ret %d \n", __func__, sta[i].devIndex, ret);
147 }
148 ASSERT_EQ(ret, INPUT_SUCCESS);
149
150 ret = g_inputInterface->iInputReporter->RegisterReportCallback(sta[i].devIndex, &g_callback);
151 if (ret) {
152 HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, sta[i].devIndex, ret);
153 }
154 ASSERT_EQ(ret, INPUT_SUCCESS);
155 }
156 }
157
CloseOnlineDev(InputDevDesc * sta,int32_t len)158 static void CloseOnlineDev(InputDevDesc *sta, int32_t len)
159 {
160 int32_t ret = g_inputInterface->iInputManager->ScanInputDevice(sta, len);
161 if (ret) {
162 HDF_LOGE("%s: scan device failed, ret %d \n", __func__, ret);
163 }
164 ASSERT_EQ(ret, INPUT_SUCCESS);
165
166 for (int32_t i = 0; i < len; i++) {
167 if (sta[i].devIndex == 0) {
168 break;
169 }
170 ret = g_inputInterface->iInputReporter->UnregisterReportCallback(sta[i].devIndex);
171 if (ret) {
172 HDF_LOGE("%s: register callback failed for device[%d], ret %d \n", __func__, sta[i].devIndex, ret);
173 }
174 ASSERT_EQ(ret, INPUT_SUCCESS);
175
176 ret = g_inputInterface->iInputManager->CloseInputDevice(sta[i].devIndex);
177 if (ret) {
178 HDF_LOGE("%s: close device[%d] failed, ret %d \n", __func__, sta[i].devIndex, ret);
179 }
180 ASSERT_EQ(ret, INPUT_SUCCESS);
181 }
182 }
183
184 /**
185 * @tc.number: SUB_Driver_Input_HdiPerformance_0900
186 * @tc.name: open input device for ap mode benchmark test
187 * @tc.desc: [C- SOFTWARE -0010]
188 * @tc.size: Medium
189 * @tc.level: level 2
190 */
BENCHMARK_F(InputBenchmarkTest,ScanInputDevice)191 BENCHMARK_F(InputBenchmarkTest, ScanInputDevice)(benchmark::State &st)
192 {
193 InputDevDesc sta[MAX_DEVICES];
194
195 HDF_LOGI("%s: [Input] RegisterCallbackAndReportData001 enter \n", __func__);
196 int32_t ret;
197
198 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
199 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
200 for (auto _ : st) {
201 ret = g_inputInterface->iInputManager->ScanInputDevice(sta, sizeof(sta)/sizeof(InputDevDesc));
202 }
203 EXPECT_EQ(HDF_SUCCESS, ret);
204 }
205 BENCHMARK_REGISTER_F(InputBenchmarkTest, ScanInputDevice)->Iterations(100)->
206 Repetitions(3)->ReportAggregatesOnly();
207
208 /**
209 * @tc.number: SUB_Driver_Input_HdiPerformance_0500
210 * @tc.name: open input device for ap mode benchmark test
211 * @tc.desc: [C- SOFTWARE -0010]
212 * @tc.size: Medium
213 * @tc.level: level 2
214 */
BENCHMARK_F(InputBenchmarkTest,RegisterHotPlugCallback)215 BENCHMARK_F(InputBenchmarkTest, RegisterHotPlugCallback)(benchmark::State &st)
216 {
217 HDF_LOGI("%s: [Input] HotPlugCallback Testcase enter\n", __func__);
218 InputDevDesc sta[MAX_DEVICES];
219
220 int32_t ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
221 if (ret != 0) {
222 HDF_LOGE("%s: memcpy failed, line %d\n", __func__, __LINE__);
223 }
224
225 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
226 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
227 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
228 for (auto _ : st) {
229 ret = g_inputInterface->iInputReporter->RegisterHotPlugCallback(&g_hotplugCb);
230 }
231 if (ret) {
232 HDF_LOGE("%s: register hotplug callback failed for device manager, ret %d\n", __func__, ret);
233 }
234 ASSERT_EQ(ret, INPUT_SUCCESS);
235
236 OpenOnlineDev(sta, MAX_DEVICES);
237
238 OsalMSleep(KEEP_ALIVE_TIME_MS);
239
240 ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
241 if (ret != 0) {
242 HDF_LOGE("%s: memcpy failed, line %d\n", __func__, __LINE__);
243 }
244
245 CloseOnlineDev(sta, MAX_DEVICES);
246
247 ret = g_inputInterface->iInputReporter->UnregisterHotPlugCallback();
248 if (ret) {
249 HDF_LOGE("%s: unregister hotplug callback failed for device manager, ret %d\n", __func__, ret);
250 }
251 EXPECT_EQ(ret, INPUT_SUCCESS);
252 }
253 BENCHMARK_REGISTER_F(InputBenchmarkTest, RegisterHotPlugCallback)->Iterations(100)->
254 Repetitions(3)->ReportAggregatesOnly();
255
256 /**
257 * @tc.number: SUB_Driver_Input_HdiPerformance_1000
258 * @tc.name: open input device for ap mode benchmark test
259 * @tc.desc: [C- SOFTWARE -0010]
260 * @tc.size: Medium
261 * @tc.level: level 2
262 */
BENCHMARK_F(InputBenchmarkTest,UnregisterHotPlugCallback)263 BENCHMARK_F(InputBenchmarkTest, UnregisterHotPlugCallback)(benchmark::State &st)
264 {
265 HDF_LOGI("%s: [Input] HotPlugCallback Testcase enter\n", __func__);
266 InputDevDesc sta[MAX_DEVICES];
267
268 int32_t ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
269 if (ret != 0) {
270 HDF_LOGE("%s: memcpy failed, line %d\n", __func__, __LINE__);
271 }
272
273 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
274 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputReporter, INPUT_NULL_PTR);
275 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
276 ret = g_inputInterface->iInputReporter->RegisterHotPlugCallback(&g_hotplugCb);
277 if (ret) {
278 HDF_LOGE("%s: register hotplug callback failed for device manager, ret %d\n", __func__, ret);
279 }
280 ASSERT_EQ(ret, INPUT_SUCCESS);
281
282 OpenOnlineDev(sta, MAX_DEVICES);
283
284 OsalMSleep(KEEP_ALIVE_TIME_MS);
285
286 ret = memset_s(sta, sizeof(sta), 0, sizeof(sta));
287 if (ret != 0) {
288 HDF_LOGE("%s: memcpy failed, line %d\n", __func__, __LINE__);
289 }
290
291 CloseOnlineDev(sta, MAX_DEVICES);
292
293 for (auto _ : st) {
294 ret = g_inputInterface->iInputReporter->UnregisterHotPlugCallback();
295 }
296 if (ret) {
297 HDF_LOGE("%s: unregister hotplug callback failed for device manager, ret %d\n", __func__, ret);
298 }
299 EXPECT_EQ(ret, INPUT_SUCCESS);
300 }
301 BENCHMARK_REGISTER_F(InputBenchmarkTest, UnregisterHotPlugCallback)->Iterations(100)->
302 Repetitions(3)->ReportAggregatesOnly();
303
304
305 /**
306 * @tc.number: SUB_Driver_Input_HdiPerformance_0400
307 * @tc.name: open input device for ap mode benchmark test
308 * @tc.desc: [C- SOFTWARE -0010]
309 * @tc.size: Medium
310 * @tc.level: level 2
311 */
312
BENCHMARK_F(InputBenchmarkTest,OpenInputDevice)313 BENCHMARK_F(InputBenchmarkTest, OpenInputDevice)(benchmark::State &st)
314 {
315 ASSERT_EQ(g_HasDev, true);
316 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
317 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
318 int32_t ret;
319 for (auto _ : st) {
320 ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
321 }
322 ret = 0;
323 ASSERT_EQ(ret, INPUT_SUCCESS);
324 ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
325 }
326 BENCHMARK_REGISTER_F(InputBenchmarkTest, OpenInputDevice)->Iterations(100)->
327 Repetitions(3)->ReportAggregatesOnly();
328
329 /**
330 * @tc.number: SUB_Driver_Input_HdiPerformance_0100
331 * @tc.name: close input device for ap mode benchmark test
332 * @tc.desc: [C- SOFTWARE -0010]
333 * @tc.size: Medium
334 * @tc.level: level 2
335 */
BENCHMARK_F(InputBenchmarkTest,CloseInputDevice)336 BENCHMARK_F(InputBenchmarkTest, CloseInputDevice)(
337 benchmark::State &st)
338 {
339 ASSERT_EQ(g_HasDev, true);
340 int32_t ret = 0;
341 g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
342 EXPECT_EQ(ret, INPUT_SUCCESS);
343 for (auto _ : st) {
344 ret = g_inputInterface->iInputManager->CloseInputDevice(TOUCH_INDEX);
345 }
346 }
347 BENCHMARK_REGISTER_F(InputBenchmarkTest, CloseInputDevice)->Iterations(100)->
348 Repetitions(3)->ReportAggregatesOnly();
349
350
351 /**
352 * @tc.number: SUB_Driver_Input_HdiPerformance_0600
353 * @tc.name: get input device id for ap mode benchmark test
354 * @tc.desc: [C- SOFTWARE -0010]
355 * @tc.size: Medium
356 * @tc.level: level 2
357 */
BENCHMARK_F(InputBenchmarkTest,GetInputDevice)358 BENCHMARK_F(InputBenchmarkTest, GetInputDevice)(benchmark::State &st)
359 {
360 ASSERT_EQ(g_HasDev, true);
361 int32_t ret = 0;
362 InputDeviceInfo *dev = nullptr;
363 INPUT_CHECK_NULL_POINTER(g_inputInterface, INPUT_NULL_PTR);
364 INPUT_CHECK_NULL_POINTER(g_inputInterface->iInputManager, INPUT_NULL_PTR);
365
366 ret = g_inputInterface->iInputManager->OpenInputDevice(TOUCH_INDEX);
367 if (ret) {
368 HDF_LOGE("%s: open device1 failed, ret %d\n", __func__, ret);
369 }
370 ASSERT_EQ(ret, INPUT_SUCCESS);
371 for (auto _ : st) {
372 ret = g_inputInterface->iInputManager->GetInputDevice(TOUCH_INDEX, &dev);
373 }
374 EXPECT_EQ(ret, INPUT_SUCCESS);
375 EXPECT_EQ((uint32_t)TOUCH_INDEX, dev->devIndex);
376 HDF_LOGI("devindex = %u, devType = %u\n", dev->devIndex, dev->devType);
377 HDF_LOGI("chipInfo = %s, VendorName = %s,chipName = %s\n", dev->chipInfo, dev->vendorName, dev->chipName);
378 }
379 BENCHMARK_REGISTER_F(InputBenchmarkTest, GetInputDevice)->Iterations(100)->
380 Repetitions(3)->ReportAggregatesOnly();
381
382 /**
383 * @tc.number: SUB_Driver_Input_HdiPerformance_0700
384 * @tc.name: get input device list info test
385 * @tc.desc: [C- SOFTWARE -0010]
386 * @tc.size: Medium
387 * @tc.level: level 2
388 */
BENCHMARK_F(InputBenchmarkTest,GetInputDeviceList)389 BENCHMARK_F(InputBenchmarkTest, GetInputDeviceList)(
390 benchmark::State &st)
391 {
392 ASSERT_EQ(g_HasDev, true);
393 int32_t ret;
394 uint32_t num = 0;
395 InputDeviceInfo *dev[MAX_INPUT_DEV_NUM] = {0};
396
397 for (auto _ : st) {
398 ret = g_inputInterface->iInputManager->GetInputDeviceList(&num, dev, MAX_INPUT_DEV_NUM);
399 }
400 EXPECT_EQ(ret, INPUT_SUCCESS);
401 ASSERT_LE(num, (uint32_t)MAX_INPUT_DEV_NUM);
402 for (uint32_t i = 0; i < num; i++) {
403 HDF_LOGI("num = %u,device[%d]'s info is :\n", num, i);
404 HDF_LOGI("index = %u, devType = %u\n", dev[i]->devIndex, dev[i]->devType);
405 HDF_LOGI("chipInfo = %s, VendorName = %s,chipName = %s\n", dev[i]->chipInfo, dev[i]->vendorName,
406 dev[i]->chipName);
407 EXPECT_LE(0, dev[i]->devType);
408 }
409 }
410 BENCHMARK_REGISTER_F(InputBenchmarkTest, GetInputDeviceList)->Iterations(100)->
411 Repetitions(3)->ReportAggregatesOnly();
412
413 /**
414 * @tc.number: SUB_Driver_Input_HdiPerformance_0800
415 * @tc.name: get input device type test for ap mode benchmark test
416 * @tc.desc: [C- SOFTWARE -0010]
417 * @tc.size: Medium
418 * @tc.level: level 2
419 */
BENCHMARK_F(InputBenchmarkTest,GetDeviceType)420 BENCHMARK_F(InputBenchmarkTest, GetDeviceType)(benchmark::State &st)
421 {
422 ASSERT_EQ(g_HasDev, true);
423 int32_t ret;
424 uint32_t devType = INIT_DEFAULT_VALUE;
425
426 for (auto _ : st) {
427 ret = g_inputInterface->iInputController->GetDeviceType(TOUCH_INDEX, &devType);
428 }
429 }
430 BENCHMARK_REGISTER_F(InputBenchmarkTest, GetDeviceType)->Iterations(100)->
431 Repetitions(3)->ReportAggregatesOnly();
432
433 /**
434 * @tc.number: SUB_Driver_Input_HdiPerformance_0200
435 * @tc.name: get input device chip info for ap mode benchmark test
436 * @tc.desc: [C- SOFTWARE -0010]
437 * @tc.size: Medium
438 * @tc.level: level 2
439 */
BENCHMARK_F(InputBenchmarkTest,GetChipInfo)440 BENCHMARK_F(InputBenchmarkTest, GetChipInfo)(benchmark::State &st)
441 {
442 ASSERT_EQ(g_HasDev, true);
443 int32_t ret;
444 char chipInfo[CHIP_INFO_LEN] = {0};
445
446 for (auto _ : st) {
447 ret = g_inputInterface->iInputController->GetChipInfo(TOUCH_INDEX, chipInfo, CHIP_INFO_LEN);
448 }
449 HDF_LOGI("device's chip info is %s\n", chipInfo);
450 }
451 BENCHMARK_REGISTER_F(InputBenchmarkTest, GetChipInfo)->Iterations(100)->
452 Repetitions(3)->ReportAggregatesOnly();
453
454 /**
455 * @tc.number: SUB_Driver_Input_HdiPerformance_1300
456 * @tc.name: set device power status for ap mode benchmark test
457 * @tc.desc: [C- SOFTWARE -0010]
458 * @tc.size: Medium
459 * @tc.level: level 2
460 */
BENCHMARK_F(InputBenchmarkTest,SetPowerStatus)461 BENCHMARK_F(InputBenchmarkTest, SetPowerStatus)(benchmark::State &st)
462 {
463 ASSERT_EQ(g_HasDev, true);
464 int32_t ret;
465 uint32_t setStatus = INPUT_LOW_POWER;
466 uint32_t getStatus = 0;
467
468 for (auto _ : st) {
469 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
470 }
471 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
472 }
473 BENCHMARK_REGISTER_F(InputBenchmarkTest, SetPowerStatus)->Iterations(100)->
474 Repetitions(3)->ReportAggregatesOnly();
475
476 /**
477 * @tc.number: SUB_Driver_Input_HdiPerformance_1100
478 * @tc.name: get device poewr status for ap mode benchmark test
479 * @tc.desc: [C- SOFTWARE -0010]
480 * @tc.size: Medium
481 * @tc.level: level 2
482 */
BENCHMARK_F(InputBenchmarkTest,GetPowerStatus)483 BENCHMARK_F(InputBenchmarkTest, GetPowerStatus)(benchmark::State &st)
484 {
485 ASSERT_EQ(g_HasDev, true);
486 int32_t ret;
487 uint32_t setStatus = INPUT_RESUME;
488 uint32_t getStatus = 0;
489
490 ret = g_inputInterface->iInputController->SetPowerStatus(TOUCH_INDEX, setStatus);
491 for (auto _ : st) {
492 ret = g_inputInterface->iInputController->GetPowerStatus(TOUCH_INDEX, &getStatus);
493 }
494 ASSERT_EQ(setStatus, getStatus);
495 }
496 BENCHMARK_REGISTER_F(InputBenchmarkTest, GetPowerStatus)->Iterations(100)->
497 Repetitions(3)->ReportAggregatesOnly();
498
499 /**
500 * @tc.number: SUB_Driver_Input_HdiPerformance_1200
501 * @tc.name: get device vendor name for ap mode benchmark test
502 * @tc.desc: [C- SOFTWARE -0010]
503 * @tc.size: Medium
504 * @tc.level: level 2
505 */
BENCHMARK_F(InputBenchmarkTest,GetVendorName)506 BENCHMARK_F(InputBenchmarkTest, GetVendorName)(benchmark::State &st)
507 {
508 ASSERT_EQ(g_HasDev, true);
509 int32_t ret;
510 char vendorName[VENDOR_NAME_LEN] = {0};
511
512 for (auto _ : st) {
513 ret = g_inputInterface->iInputController->GetVendorName(TOUCH_INDEX, vendorName, VENDOR_NAME_LEN);
514 }
515 HDF_LOGI("device1's vendor name is %s:\n", vendorName);
516 }
517 BENCHMARK_REGISTER_F(InputBenchmarkTest, GetVendorName)->Iterations(100)->
518 Repetitions(3)->ReportAggregatesOnly();
519
520 /**
521 * @tc.number: SUB_Driver_Input_HdiPerformance_0300
522 * @tc.name: get device chip name for ap mode benchmark test
523 * @tc.desc: [C- SOFTWARE -0010]
524 * @tc.size: Medium
525 * @tc.level: level 2
526 */
BENCHMARK_F(InputBenchmarkTest,GetChipName)527 BENCHMARK_F(InputBenchmarkTest, GetChipName)(benchmark::State &st)
528 {
529 ASSERT_EQ(g_HasDev, true);
530 int32_t ret;
531 char chipName[CHIP_NAME_LEN] = {0};
532
533 for (auto _ : st) {
534 ret = g_inputInterface->iInputController->GetChipName(TOUCH_INDEX, chipName, CHIP_NAME_LEN);
535 }
536 HDF_LOGI("device1's vendor name is %s:\n", chipName);
537 }
538 BENCHMARK_REGISTER_F(InputBenchmarkTest, GetChipName)->Iterations(100)->
539 Repetitions(3)->ReportAggregatesOnly();
540
541 /**
542 * @tc.number: SUB_Driver_Input_HdiPerformance_1400
543 * @tc.name: set device gesture mode for ap mode benchmark test
544 * @tc.desc: [C- SOFTWARE -0010]
545 * @tc.size: Medium
546 * @tc.level: level 2
547 */
BENCHMARK_F(InputBenchmarkTest,SetGestureMode)548 BENCHMARK_F(InputBenchmarkTest, SetGestureMode)(benchmark::State &st)
549 {
550 ASSERT_EQ(g_HasDev, true);
551 int32_t ret;
552 uint32_t gestureMode = 1;
553
554 for (auto _ : st) {
555 ret = g_inputInterface->iInputController->SetGestureMode(TOUCH_INDEX, gestureMode);
556 }
557 }
558 BENCHMARK_REGISTER_F(InputBenchmarkTest, SetGestureMode)->Iterations(100)->
559 Repetitions(3)->ReportAggregatesOnly();
560
561 /**
562 * @tc.number: SUB_Driver_Input_HdiPerformance_1500
563 * @tc.name: Run Capacitance for ap mode benchmark test
564 * @tc.desc: [C- SOFTWARE -0010]
565 * @tc.size: Medium
566 * @tc.level: level 2
567 */
BENCHMARK_F(InputBenchmarkTest,RunCapacitanceTest)568 BENCHMARK_F(InputBenchmarkTest, RunCapacitanceTest)(benchmark::State &st)
569 {
570 ASSERT_EQ(g_HasDev, true);
571 int32_t ret;
572 uint32_t testType = MMI_TEST;
573 char result[MAX_INPUT_DEV_NUM] = {0};
574
575 for (auto _ : st) {
576 ret = g_inputInterface->iInputController->RunCapacitanceTest(TOUCH_INDEX, testType, result, MAX_INPUT_DEV_NUM);
577 }
578 }
579 BENCHMARK_REGISTER_F(InputBenchmarkTest, RunCapacitanceTest)->Iterations(100)->
580 Repetitions(3)->ReportAggregatesOnly();
581
582 /**
583 * @tc.number: SUB_Driver_Input_HdiPerformance_1600
584 * @tc.name: Run Extra Command for ap mode benchmark test
585 * @tc.desc: [C- SOFTWARE -0010]
586 * @tc.size: Medium
587 * @tc.level: level 2
588 */
BENCHMARK_F(InputBenchmarkTest,RunExtraCommand)589 BENCHMARK_F(InputBenchmarkTest, RunExtraCommand)(benchmark::State &st)
590 {
591 ASSERT_EQ(g_HasDev, true);
592 int32_t ret;
593 InputExtraCmd extraCmd = {0};
594 extraCmd.cmdCode = "WakeUpMode";
595 extraCmd.cmdValue = "Enable";
596
597 for (auto _ : st) {
598 ret = g_inputInterface->iInputController->RunExtraCommand(TOUCH_INDEX, &extraCmd);
599 }
600 }
601 BENCHMARK_REGISTER_F(InputBenchmarkTest, RunExtraCommand)->Iterations(100)->
602 Repetitions(3)->ReportAggregatesOnly();
603
604
605 /**
606 * @tc.number: SUB_Driver_Input_HdiPerformance_1700
607 * @tc.name: Register Report Callback for ap mode benchmark test
608 * @tc.desc: [C- SOFTWARE -0010]
609 * @tc.size: Medium
610 * @tc.level: level 2
611 */
BENCHMARK_F(InputBenchmarkTest,RegisterReportCallback)612 BENCHMARK_F(InputBenchmarkTest, RegisterReportCallback)(benchmark::State &st)
613 {
614 ASSERT_EQ(g_HasDev, true);
615 int32_t ret;
616 g_callback.EventPkgCallback = ReportEventPkgCallback;
617 ret = g_inputInterface->iInputReporter->RegisterReportCallback(0, &g_callback);
618 EXPECT_NE(ret, INPUT_SUCCESS);
619 ret = g_inputInterface->iInputReporter->RegisterReportCallback(MAX_INPUT_DEV_NUM, &g_callback);
620 EXPECT_NE(ret, INPUT_SUCCESS);
621 for (auto _ : st) {
622 ret = g_inputInterface->iInputReporter->RegisterReportCallback(TOUCH_INDEX, nullptr);
623 }
624 EXPECT_NE(ret, INPUT_SUCCESS);
625 }
626 BENCHMARK_REGISTER_F(InputBenchmarkTest, RegisterReportCallback)->Iterations(100)->
627 Repetitions(3)->ReportAggregatesOnly();
628
629 /**
630 * @tc.number: SUB_Driver_Input_HdiPerformance_1800
631 * @tc.name: Register Report Callback test
632 * @tc.desc: [C- SOFTWARE -0010]
633 * @tc.size: Medium
634 * @tc.level: level 2
635 */
BENCHMARK_F(InputBenchmarkTest,UnregisterReportCallback)636 BENCHMARK_F(InputBenchmarkTest, UnregisterReportCallback)(benchmark::State &st)
637 {
638 ASSERT_EQ(g_HasDev, true);
639 int32_t ret;
640 g_callback.EventPkgCallback = ReportEventPkgCallback;
641
642 ret = g_inputInterface->iInputReporter->RegisterReportCallback(TOUCH_INDEX, &g_callback);
643 OsalMSleep(KEEP_ALIVE_TIME_MS);
644 for (auto _ : st) {
645 ret = g_inputInterface->iInputReporter->UnregisterReportCallback(TOUCH_INDEX);
646 }
647 ret = 0;
648 EXPECT_EQ(ret, INPUT_SUCCESS);
649 }
650 BENCHMARK_REGISTER_F(InputBenchmarkTest, UnregisterReportCallback)->Iterations(100)->
651 Repetitions(3)->ReportAggregatesOnly();
652 }
653 BENCHMARK_MAIN();