1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci#include <benchmark/benchmark.h>
16094332d3Sopenharmony_ci#include <cmath>
17094332d3Sopenharmony_ci#include <cstdio>
18094332d3Sopenharmony_ci#include <gtest/gtest.h>
19094332d3Sopenharmony_ci#include <securec.h>
20094332d3Sopenharmony_ci#include <string>
21094332d3Sopenharmony_ci#include <unistd.h>
22094332d3Sopenharmony_ci#include <vector>
23094332d3Sopenharmony_ci#include "hdf_base.h"
24094332d3Sopenharmony_ci#include "input_callback_impl.h"
25094332d3Sopenharmony_ci#include "input_type.h"
26094332d3Sopenharmony_ci#include "osal_time.h"
27094332d3Sopenharmony_ci#include "v1_0/iinput_interfaces.h"
28094332d3Sopenharmony_ci
29094332d3Sopenharmony_ciusing namespace OHOS::HDI::Input::V1_0;
30094332d3Sopenharmony_ciusing namespace std;
31094332d3Sopenharmony_ciusing namespace testing::ext;
32094332d3Sopenharmony_ci
33094332d3Sopenharmony_cinamespace  {
34094332d3Sopenharmony_ci    sptr<IInputInterfaces>  g_inputInterfaces = nullptr;
35094332d3Sopenharmony_ci    sptr<IInputCallback> g_callback = nullptr;
36094332d3Sopenharmony_ci
37094332d3Sopenharmony_ci    constexpr int32_t INIT_DEFAULT_VALUE = 255;
38094332d3Sopenharmony_ci    constexpr int32_t TOUCH_INDEX = 1;
39094332d3Sopenharmony_ci    constexpr int32_t TEST_RESULT_LEN = 32;
40094332d3Sopenharmony_ci
41094332d3Sopenharmony_ciclass InputBenchmarkTest : public benchmark::Fixture {
42094332d3Sopenharmony_cipublic:
43094332d3Sopenharmony_ci    void SetUp(const ::benchmark::State &state);
44094332d3Sopenharmony_ci    void TearDown(const ::benchmark::State &state);
45094332d3Sopenharmony_ci};
46094332d3Sopenharmony_ci
47094332d3Sopenharmony_civoid InputBenchmarkTest::SetUp(const ::benchmark::State &state)
48094332d3Sopenharmony_ci{
49094332d3Sopenharmony_ci    g_inputInterfaces = IInputInterfaces::Get(true);
50094332d3Sopenharmony_ci    if (g_inputInterfaces != nullptr) {
51094332d3Sopenharmony_ci        g_callback = new InputCallbackImpl(g_inputInterfaces, nullptr);
52094332d3Sopenharmony_ci    }
53094332d3Sopenharmony_ci}
54094332d3Sopenharmony_ci
55094332d3Sopenharmony_civoid InputBenchmarkTest::TearDown(const ::benchmark::State &state)
56094332d3Sopenharmony_ci{
57094332d3Sopenharmony_ci    g_inputInterfaces = nullptr;
58094332d3Sopenharmony_ci}
59094332d3Sopenharmony_ci
60094332d3Sopenharmony_ci/**
61094332d3Sopenharmony_ci  * @tc.name: HdfInput_ScanInputDevice_test
62094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface ScanInputDevice.
63094332d3Sopenharmony_ci  * @tc.type: FUNC
64094332d3Sopenharmony_ci  */
65094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_ScanInputDevice_test)(benchmark::State &state)
66094332d3Sopenharmony_ci{
67094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
68094332d3Sopenharmony_ci
69094332d3Sopenharmony_ci    std::vector<DevDesc> sta;
70094332d3Sopenharmony_ci    int32_t ret;
71094332d3Sopenharmony_ci    for (auto _ : state) {
72094332d3Sopenharmony_ci        ret = g_inputInterfaces->ScanInputDevice(sta);
73094332d3Sopenharmony_ci    }
74094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
75094332d3Sopenharmony_ci}
76094332d3Sopenharmony_ci
77094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_ScanInputDevice_test)->
78094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
79094332d3Sopenharmony_ci
80094332d3Sopenharmony_ci/**
81094332d3Sopenharmony_ci  * @tc.name: HdfInput_OpenInputDevice_test
82094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface OpenInputDevice and CloseInputDevice.
83094332d3Sopenharmony_ci  * @tc.type: FUNC
84094332d3Sopenharmony_ci  */
85094332d3Sopenharmony_ci
86094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_OpenInputDevice_test)(benchmark::State &state)
87094332d3Sopenharmony_ci{
88094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
89094332d3Sopenharmony_ci
90094332d3Sopenharmony_ci    int32_t ret;
91094332d3Sopenharmony_ci    for (auto _ : state) {
92094332d3Sopenharmony_ci        ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
93094332d3Sopenharmony_ci        ret = g_inputInterfaces->CloseInputDevice(TOUCH_INDEX);
94094332d3Sopenharmony_ci    }
95094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
96094332d3Sopenharmony_ci}
97094332d3Sopenharmony_ci
98094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_OpenInputDevice_test)->
99094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
100094332d3Sopenharmony_ci
101094332d3Sopenharmony_ci/**
102094332d3Sopenharmony_ci  * @tc.name: HdfInput_GetInputDevice_test
103094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetInputDevice.
104094332d3Sopenharmony_ci  * @tc.type: FUNC
105094332d3Sopenharmony_ci  */
106094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_GetInputDevice_test)(benchmark::State &state)
107094332d3Sopenharmony_ci{
108094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
109094332d3Sopenharmony_ci
110094332d3Sopenharmony_ci    int32_t ret;
111094332d3Sopenharmony_ci    struct DeviceInfo dev;
112094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
113094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
114094332d3Sopenharmony_ci    for (auto _ : state) {
115094332d3Sopenharmony_ci        ret = g_inputInterfaces->GetInputDevice(TOUCH_INDEX, dev);
116094332d3Sopenharmony_ci    }
117094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
118094332d3Sopenharmony_ci    EXPECT_EQ((uint32_t)TOUCH_INDEX, dev.devIndex);
119094332d3Sopenharmony_ci}
120094332d3Sopenharmony_ci
121094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_GetInputDevice_test)->
122094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
123094332d3Sopenharmony_ci
124094332d3Sopenharmony_ci/**
125094332d3Sopenharmony_ci  * @tc.name: HdfInput_GetInputDeviceList_test
126094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetInputDeviceList.
127094332d3Sopenharmony_ci  * @tc.type: FUNC
128094332d3Sopenharmony_ci  */
129094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_GetInputDeviceList_test)(benchmark::State &state)
130094332d3Sopenharmony_ci{
131094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
132094332d3Sopenharmony_ci
133094332d3Sopenharmony_ci    int32_t ret;
134094332d3Sopenharmony_ci    uint32_t num = 0;
135094332d3Sopenharmony_ci    std::vector<DeviceInfo> dev;
136094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
137094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
138094332d3Sopenharmony_ci    for (auto _ : state) {
139094332d3Sopenharmony_ci        ret = g_inputInterfaces->GetInputDeviceList(num, dev, MAX_INPUT_DEV_NUM);
140094332d3Sopenharmony_ci    }
141094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
142094332d3Sopenharmony_ci    ASSERT_LE(num, (uint32_t)MAX_INPUT_DEV_NUM);
143094332d3Sopenharmony_ci}
144094332d3Sopenharmony_ci
145094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_GetInputDeviceList_test)->
146094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
147094332d3Sopenharmony_ci
148094332d3Sopenharmony_ci/**
149094332d3Sopenharmony_ci  * @tc.name: HdfInput_GetDeviceType_test
150094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetDeviceType.
151094332d3Sopenharmony_ci  * @tc.type: FUNC
152094332d3Sopenharmony_ci  */
153094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_GetDeviceType_test)(benchmark::State &state)
154094332d3Sopenharmony_ci{
155094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
156094332d3Sopenharmony_ci
157094332d3Sopenharmony_ci    int32_t ret;
158094332d3Sopenharmony_ci    uint32_t devType = INIT_DEFAULT_VALUE;
159094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
160094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
161094332d3Sopenharmony_ci    for (auto _ : state) {
162094332d3Sopenharmony_ci        ret = g_inputInterfaces->GetDeviceType(TOUCH_INDEX, devType);
163094332d3Sopenharmony_ci    }
164094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
165094332d3Sopenharmony_ci}
166094332d3Sopenharmony_ci
167094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_GetDeviceType_test)->
168094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
169094332d3Sopenharmony_ci
170094332d3Sopenharmony_ci/**
171094332d3Sopenharmony_ci  * @tc.name: HdfInput_GetChipInfo_test
172094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetChipInfo.
173094332d3Sopenharmony_ci  * @tc.type: FUNC
174094332d3Sopenharmony_ci  */
175094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_GetChipInfo_test)(benchmark::State &state)
176094332d3Sopenharmony_ci{
177094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
178094332d3Sopenharmony_ci
179094332d3Sopenharmony_ci    int32_t ret;
180094332d3Sopenharmony_ci    std::string chipInfo;
181094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
182094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
183094332d3Sopenharmony_ci    for (auto _ : state) {
184094332d3Sopenharmony_ci        ret = g_inputInterfaces->GetChipInfo(TOUCH_INDEX, chipInfo);
185094332d3Sopenharmony_ci    }
186094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
187094332d3Sopenharmony_ci}
188094332d3Sopenharmony_ci
189094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_GetChipInfo_test)->
190094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
191094332d3Sopenharmony_ci
192094332d3Sopenharmony_ci/**
193094332d3Sopenharmony_ci  * @tc.name: HdfInput_SetPowerStatus_test
194094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface SetPowerStatus.
195094332d3Sopenharmony_ci  * @tc.type: FUNC
196094332d3Sopenharmony_ci  */
197094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_SetPowerStatus_test)(benchmark::State &state)
198094332d3Sopenharmony_ci{
199094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
200094332d3Sopenharmony_ci
201094332d3Sopenharmony_ci    int32_t ret;
202094332d3Sopenharmony_ci    uint32_t setStatus = INPUT_LOW_POWER;
203094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
204094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
205094332d3Sopenharmony_ci    for (auto _ : state) {
206094332d3Sopenharmony_ci        ret = g_inputInterfaces->SetPowerStatus(TOUCH_INDEX, setStatus);
207094332d3Sopenharmony_ci    }
208094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
209094332d3Sopenharmony_ci}
210094332d3Sopenharmony_ci
211094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_SetPowerStatus_test)->
212094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
213094332d3Sopenharmony_ci
214094332d3Sopenharmony_ci/**
215094332d3Sopenharmony_ci  * @tc.name: HdfInput_GetPowerStatus_test
216094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetPowerStatus.
217094332d3Sopenharmony_ci  * @tc.type: FUNC
218094332d3Sopenharmony_ci  */
219094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_GetPowerStatus_test)(benchmark::State &state)
220094332d3Sopenharmony_ci{
221094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
222094332d3Sopenharmony_ci
223094332d3Sopenharmony_ci    int32_t ret;
224094332d3Sopenharmony_ci    uint32_t getStatus = 0;
225094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
226094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
227094332d3Sopenharmony_ci    for (auto _ : state) {
228094332d3Sopenharmony_ci        ret = g_inputInterfaces->GetPowerStatus(TOUCH_INDEX, getStatus);
229094332d3Sopenharmony_ci    }
230094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
231094332d3Sopenharmony_ci}
232094332d3Sopenharmony_ci
233094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_GetPowerStatus_test)->
234094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
235094332d3Sopenharmony_ci
236094332d3Sopenharmony_ci/**
237094332d3Sopenharmony_ci  * @tc.name: HdfInput_GetVendorName_test
238094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetVendorName.
239094332d3Sopenharmony_ci  * @tc.type: FUNC
240094332d3Sopenharmony_ci  */
241094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_GetVendorName_test)(benchmark::State &state)
242094332d3Sopenharmony_ci{
243094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
244094332d3Sopenharmony_ci
245094332d3Sopenharmony_ci    int32_t ret;
246094332d3Sopenharmony_ci    std::string vendorName;
247094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
248094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
249094332d3Sopenharmony_ci    for (auto _ : state) {
250094332d3Sopenharmony_ci        ret = g_inputInterfaces->GetVendorName(TOUCH_INDEX, vendorName);
251094332d3Sopenharmony_ci    }
252094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
253094332d3Sopenharmony_ci}
254094332d3Sopenharmony_ci
255094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_GetVendorName_test)->
256094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
257094332d3Sopenharmony_ci
258094332d3Sopenharmony_ci/**
259094332d3Sopenharmony_ci  * @tc.name: HdfInput_GetChipName_test
260094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetChipName.
261094332d3Sopenharmony_ci  * @tc.type: FUNC
262094332d3Sopenharmony_ci  */
263094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_GetChipName_test)(benchmark::State &state)
264094332d3Sopenharmony_ci{
265094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
266094332d3Sopenharmony_ci
267094332d3Sopenharmony_ci    int32_t ret;
268094332d3Sopenharmony_ci    std::string chipName;
269094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
270094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
271094332d3Sopenharmony_ci    for (auto _ : state) {
272094332d3Sopenharmony_ci        ret = g_inputInterfaces->GetChipName(TOUCH_INDEX, chipName);
273094332d3Sopenharmony_ci    }
274094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
275094332d3Sopenharmony_ci}
276094332d3Sopenharmony_ci
277094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_GetChipName_test)->
278094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
279094332d3Sopenharmony_ci
280094332d3Sopenharmony_ci/**
281094332d3Sopenharmony_ci  * @tc.name: HdfInput_SetGestureMode_test
282094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface SetGestureMode.
283094332d3Sopenharmony_ci  * @tc.type: FUNC
284094332d3Sopenharmony_ci  */
285094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_SetGestureMode_test)(benchmark::State &state)
286094332d3Sopenharmony_ci{
287094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
288094332d3Sopenharmony_ci
289094332d3Sopenharmony_ci    int32_t ret;
290094332d3Sopenharmony_ci    uint32_t gestureMode = 1;
291094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
292094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
293094332d3Sopenharmony_ci    for (auto _ : state) {
294094332d3Sopenharmony_ci        ret = g_inputInterfaces->SetGestureMode(TOUCH_INDEX, gestureMode);
295094332d3Sopenharmony_ci    }
296094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
297094332d3Sopenharmony_ci}
298094332d3Sopenharmony_ci
299094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_SetGestureMode_test)->
300094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
301094332d3Sopenharmony_ci
302094332d3Sopenharmony_ci/**
303094332d3Sopenharmony_ci  * @tc.name: HdfInput_RunCapacitanceTest_test
304094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface RunCapacitanceTest.
305094332d3Sopenharmony_ci  * @tc.type: FUNC
306094332d3Sopenharmony_ci  */
307094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_RunCapacitanceTest_test)(benchmark::State &state)
308094332d3Sopenharmony_ci{
309094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
310094332d3Sopenharmony_ci
311094332d3Sopenharmony_ci    int32_t ret;
312094332d3Sopenharmony_ci    uint32_t testType = MMI_TEST;
313094332d3Sopenharmony_ci    std::string result;
314094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
315094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
316094332d3Sopenharmony_ci    for (auto _ : state) {
317094332d3Sopenharmony_ci        ret = g_inputInterfaces->RunCapacitanceTest(TOUCH_INDEX, testType, result, TEST_RESULT_LEN);
318094332d3Sopenharmony_ci    }
319094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
320094332d3Sopenharmony_ci}
321094332d3Sopenharmony_ci
322094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_RunCapacitanceTest_test)->
323094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
324094332d3Sopenharmony_ci
325094332d3Sopenharmony_ci/**
326094332d3Sopenharmony_ci  * @tc.name: HdfInput_RunExtraCommand_test
327094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface RunExtraCommand.
328094332d3Sopenharmony_ci  * @tc.type: FUNC
329094332d3Sopenharmony_ci  */
330094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_RunExtraCommand_test)(benchmark::State &state)
331094332d3Sopenharmony_ci{
332094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
333094332d3Sopenharmony_ci
334094332d3Sopenharmony_ci    int32_t ret;
335094332d3Sopenharmony_ci    struct ExtraCmd extraCmd;
336094332d3Sopenharmony_ci    extraCmd.cmdCode = "WakeUpMode";
337094332d3Sopenharmony_ci    extraCmd.cmdValue = "Enable";
338094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
339094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
340094332d3Sopenharmony_ci    for (auto _ : state) {
341094332d3Sopenharmony_ci        ret = g_inputInterfaces->RunExtraCommand(TOUCH_INDEX, extraCmd);
342094332d3Sopenharmony_ci    }
343094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
344094332d3Sopenharmony_ci}
345094332d3Sopenharmony_ci
346094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_RunExtraCommand_test)->
347094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
348094332d3Sopenharmony_ci
349094332d3Sopenharmony_ci
350094332d3Sopenharmony_ci/**
351094332d3Sopenharmony_ci  * @tc.name: HdfInput_RegisterReportCallback_test
352094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface RegisterReportCallback and UnregisterReportCallback.
353094332d3Sopenharmony_ci  * @tc.type: FUNC
354094332d3Sopenharmony_ci  */
355094332d3Sopenharmony_ciBENCHMARK_F(InputBenchmarkTest, HdfInput_RegisterReportCallback_test)(benchmark::State &state)
356094332d3Sopenharmony_ci{
357094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_inputInterfaces);
358094332d3Sopenharmony_ci
359094332d3Sopenharmony_ci    int32_t ret;
360094332d3Sopenharmony_ci    ret = g_inputInterfaces->OpenInputDevice(TOUCH_INDEX);
361094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
362094332d3Sopenharmony_ci    for (auto _ : state) {
363094332d3Sopenharmony_ci        ret = g_inputInterfaces->RegisterReportCallback(TOUCH_INDEX, g_callback);
364094332d3Sopenharmony_ci        ret = g_inputInterfaces->UnregisterReportCallback(TOUCH_INDEX);
365094332d3Sopenharmony_ci    }
366094332d3Sopenharmony_ci    EXPECT_EQ(ret, INPUT_SUCCESS);
367094332d3Sopenharmony_ci    ret = g_inputInterfaces->CloseInputDevice(TOUCH_INDEX);
368094332d3Sopenharmony_ci    EXPECT_EQ(INPUT_SUCCESS, ret);
369094332d3Sopenharmony_ci}
370094332d3Sopenharmony_ci
371094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(InputBenchmarkTest, HdfInput_RegisterReportCallback_test)->
372094332d3Sopenharmony_ci    Iterations(100)->Repetitions(3)->ReportAggregatesOnly();
373094332d3Sopenharmony_ci} // namespace
374094332d3Sopenharmony_ci
375094332d3Sopenharmony_ciBENCHMARK_MAIN();
376