• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "input_manager_util.h"
17 
18 #include "event_util_test.h"
19 #include "input_event.h"
20 #include "key_event.h"
21 #include "pointer_event.h"
22 
23 namespace OHOS {
24 namespace MMI {
25 namespace {
26 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, MMI_LOG_DOMAIN, "InputManagerUtil"};
27 constexpr int32_t TIME_WAIT_FOR_OP = 100;
28 constexpr int32_t NANOSECOND_TO_MILLISECOND = 1000000;
29 constexpr int32_t DEFAULT_POINTER_ID = 0;
30 constexpr int32_t DEFAULT_DEVICE_ID = 0;
31 constexpr int32_t INDEX_FIRST = 1;
32 constexpr int32_t INDEX_SECOND = 2;
33 constexpr int32_t INDEX_THIRD = 3;
34 constexpr int32_t MOUSE_ICON_SIZE = 64;
35 constexpr int32_t POINTER_ITEM_DISPLAY_X_ONE = 25;
36 constexpr int32_t POINTER_ITEM_DISPLAY_X_TWO = 50;
37 constexpr int32_t POINTER_ITEM_DISPLAY_X_THREE = 53;
38 constexpr int32_t POINTER_ITEM_DISPLAY_X_FOUR = 200;
39 constexpr int32_t POINTER_ITEM_DISPLAY_X_FIVE = 503;
40 constexpr int32_t POINTER_ITEM_DISPLAY_X_SIX = 520;
41 constexpr int32_t POINTER_ITEM_DISPLAY_X_SEVEN = 523;
42 constexpr int32_t POINTER_ITEM_DISPLAY_X_EIGHT = 550;
43 constexpr int32_t POINTER_ITEM_DISPLAY_X_NINE = 593;
44 constexpr int32_t POINTER_ITEM_DISPLAY_X_TEN = 600;
45 constexpr int32_t POINTER_ITEM_DISPLAY_X_ELEVEN = 610;
46 constexpr int32_t POINTER_ITEM_DISPLAY_X_TWELVE = 623;
47 constexpr int32_t POINTER_ITEM_DISPLAY_X_THIRTEEN = 10;
48 constexpr int32_t POINTER_ITEM_DISPLAY_X_FOURTEEN = 100;
49 constexpr int32_t POINTER_ITEM_DISPLAY_X_FIFTEEN = 40;
50 constexpr int32_t POINTER_ITEM_DISPLAY_X_SIXTEEN = 546;
51 constexpr int32_t POINTER_ITEM_DISPLAY_X_SEVENTEEN = 555;
52 constexpr int32_t POINTER_ITEM_DISPLAY_X_EIGHTEEN = 888;
53 constexpr int32_t POINTER_ITEM_DISPLAY_Y_ONE = 10;
54 constexpr int32_t POINTER_ITEM_DISPLAY_Y_TWO = 50;
55 constexpr int32_t POINTER_ITEM_DISPLAY_Y_THREE = 60;
56 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FOUR = 68;
57 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FIVE = 80;
58 constexpr int32_t POINTER_ITEM_DISPLAY_Y_SIX = 200;
59 constexpr int32_t POINTER_ITEM_DISPLAY_Y_SEVEN = 504;
60 constexpr int32_t POINTER_ITEM_DISPLAY_Y_EIGHT = 530;
61 constexpr int32_t POINTER_ITEM_DISPLAY_Y_NINE = 555;
62 constexpr int32_t POINTER_ITEM_DISPLAY_Y_TEN = 610;
63 constexpr int32_t POINTER_ITEM_DISPLAY_Y_ELEVEN = 650;
64 constexpr int32_t POINTER_ITEM_DISPLAY_Y_TWELVE = 703;
65 constexpr int32_t POINTER_ITEM_DISPLAY_Y_THIRTEEN = 723;
66 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FOURTEEN = 733;
67 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FIFTEEN = 777;
68 constexpr int32_t POINTER_ITEM_DISPLAY_Y_SIXTEEN = 783;
69 constexpr int32_t POINTER_ITEM_DISPLAY_Y_SEVENTEEN = 823;
70 constexpr int32_t POINTER_ITEM_DISPLAY_Y_EIGHTEEN = 910;
71 constexpr int32_t POINTER_ITEM_DISPLAY_Y_NINETEEN = 999;
72 constexpr int32_t POINTER_ITEM_DISPLAY_Y_TWENTY = 1259;
73 constexpr int32_t POINTER_ITEM_WIDTH_ONE = 20;
74 constexpr int32_t POINTER_ITEM_WIDTH_TWO = 50;
75 constexpr int32_t POINTER_ITEM_WIDTH_THREE = 80;
76 constexpr int32_t POINTER_ITEM_HEIGHT_ONE = 60;
77 constexpr int32_t POINTER_ITEM_HEIGHT_TWO = 80;
78 constexpr int32_t POINTER_ITEM_WINDOW_X_ONE = 20;
79 constexpr int32_t POINTER_ITEM_WINDOW_X_TWO = 55;
80 constexpr int32_t POINTER_ITEM_WINDOW_X_THREE = 67;
81 constexpr int32_t POINTER_ITEM_WINDOW_X_FOUR = 70;
82 constexpr int32_t POINTER_ITEM_WINDOW_X_FIVE = 80;
83 constexpr int32_t POINTER_ITEM_WINDOW_X_SIX = 120;
84 constexpr int32_t POINTER_ITEM_WINDOW_X_SEVEN = 300;
85 constexpr int32_t POINTER_ITEM_WINDOW_X_EIGHT = 323;
86 constexpr int32_t POINTER_ITEM_WINDOW_X_NINE = 701;
87 constexpr int32_t POINTER_ITEM_WINDOW_X_TEN = 720;
88 constexpr int32_t POINTER_ITEM_WINDOW_X_ELEVEN = 740;
89 constexpr int32_t POINTER_ITEM_WINDOW_Y_ONE = 45;
90 constexpr int32_t POINTER_ITEM_WINDOW_Y_TWO = 66;
91 constexpr int32_t POINTER_ITEM_WINDOW_Y_THREE = 70;
92 constexpr int32_t POINTER_ITEM_WINDOW_Y_FOUR = 90;
93 constexpr int32_t POINTER_ITEM_WINDOW_Y_FIVE = 99;
94 constexpr int32_t POINTER_ITEM_WINDOW_Y_SIX = 106;
95 constexpr int32_t POINTER_ITEM_WINDOW_Y_SEVEN = 300;
96 constexpr int32_t POINTER_ITEM_WINDOW_Y_EIGHT = 453;
97 constexpr int32_t POINTER_ITEM_WINDOW_Y_NINE = 702;
98 constexpr int32_t POINTER_ITEM_WINDOW_Y_TEN = 730;
99 constexpr int32_t POINTER_ITEM_WINDOW_Y_ELEVEN = 750;
100 constexpr double POINTER_ITEM_PRESSURE_ONE = 5.0;
101 constexpr double POINTER_ITEM_PRESSURE_TWO = 7.0;
102 constexpr double POINTER_ITEM_PRESSURE_THREE = 0.15;
103 constexpr double POINTER_ITEM_PRESSURE_FOUR = 0.45;
104 constexpr double POINTER_ITEM_PRESSURE_FIVE = 0.7;
105 constexpr double POINTER_AXIS_VALUE_ONE = -1.0000;
106 constexpr double POINTER_AXIS_VALUE_TWO = 30.0;
107 constexpr double POINTER_AXIS_VALUE_THREE = 40.0;
108 constexpr double POINTER_ITEM_TITLE_X_ONE = 2.12;
109 constexpr double POINTER_ITEM_TITLE_X_TWO = 12.22;
110 constexpr double POINTER_ITEM_TITLE_X_THREE = 10.0;
111 constexpr double POINTER_ITEM_TITLE_Y_ONE = 5.43;
112 constexpr double POINTER_ITEM_TITLE_Y_TWO = 15.33;
113 constexpr double POINTER_ITEM_TITLE_Y_THREE = -9.0;
114 }  // namespace
115 
InitOption(const std::set<int32_t> & preKeys,int32_t finalKey,bool isFinalKeyDown,int32_t duration)116 std::shared_ptr<KeyOption> InputManagerUtil::InitOption(
117     const std::set<int32_t> &preKeys, int32_t finalKey, bool isFinalKeyDown, int32_t duration)
118 {
119     std::shared_ptr<KeyOption> keyOption = std::make_shared<KeyOption>();
120     keyOption->SetFinalKeyDown(isFinalKeyDown);
121     keyOption->SetFinalKey(finalKey);
122     keyOption->SetPreKeys(preKeys);
123     keyOption->SetFinalKeyDownDuration(duration);
124     return keyOption;
125 }
126 
SetupPointerEvent001()127 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent001()
128 {
129     auto pointerEvent = PointerEvent::Create();
130     CHKPP(pointerEvent);
131     PointerEvent::PointerItem item;
132     item.SetPointerId(0);
133     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SEVEN);
134     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THIRTEEN);
135     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
136     item.SetDeviceId(1);
137     pointerEvent->AddPointerItem(item);
138 
139     item.SetPointerId(1);
140     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ELEVEN);
141     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_EIGHTEEN);
142     item.SetPressure(POINTER_ITEM_PRESSURE_TWO);
143     item.SetDeviceId(1);
144     pointerEvent->AddPointerItem(item);
145 
146     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
147     pointerEvent->SetPointerId(1);
148     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
149     return pointerEvent;
150 }
151 
SetupPointerEvent002()152 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent002()
153 {
154     auto pointerEvent = PointerEvent::Create();
155     CHKPP(pointerEvent);
156     PointerEvent::PointerItem item;
157     item.SetPointerId(0);
158     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_NINE);
159     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_SIXTEEN);
160     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
161     item.SetDeviceId(1);
162     pointerEvent->AddPointerItem(item);
163 
164     item.SetPointerId(1);
165     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TEN);
166     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TEN);
167     item.SetPressure(POINTER_ITEM_PRESSURE_TWO);
168     item.SetDeviceId(1);
169     pointerEvent->AddPointerItem(item);
170 
171     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
172     pointerEvent->SetPointerId(1);
173     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
174     return pointerEvent;
175 }
176 
SetupPointerEvent003()177 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent003()
178 {
179     auto pointerEvent = PointerEvent::Create();
180     CHKPP(pointerEvent);
181     PointerEvent::PointerItem item;
182     item.SetPointerId(0);
183     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_THREE);
184     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FOURTEEN);
185     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
186     item.SetDeviceId(1);
187     pointerEvent->AddPointerItem(item);
188 
189     item.SetPointerId(1);
190     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWELVE);
191     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_SEVENTEEN);
192     item.SetPressure(0);
193     item.SetDeviceId(1);
194     pointerEvent->AddPointerItem(item);
195 
196     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
197     pointerEvent->SetPointerId(1);
198     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
199     return pointerEvent;
200 }
201 
SetupPointerEvent005()202 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent005()
203 {
204     auto pointerEvent = PointerEvent::Create();
205     CHKPP(pointerEvent);
206     int64_t downTime = GetNanoTime() / NANOSECOND_TO_MILLISECOND;
207     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
208     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
209     pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_LEFT);
210     pointerEvent->SetPointerId(0);
211     pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT);
212     PointerEvent::PointerItem item;
213     item.SetPointerId(0);
214     item.SetDownTime(downTime);
215     item.SetPressed(true);
216 
217     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SIX);
218     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_EIGHT);
219     item.SetWindowX(POINTER_ITEM_WINDOW_X_ELEVEN);
220     item.SetWindowY(POINTER_ITEM_WINDOW_Y_ELEVEN);
221 
222     item.SetWidth(0);
223     item.SetHeight(0);
224     item.SetPressure(0);
225     item.SetDeviceId(0);
226     pointerEvent->AddPointerItem(item);
227     return pointerEvent;
228 }
229 
SetupPointerEvent006()230 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent006()
231 {
232     auto pointerEvent = PointerEvent::Create();
233     CHKPP(pointerEvent);
234     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
235     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
236     pointerEvent->SetPointerId(0);
237     PointerEvent::PointerItem item;
238     item.SetPressed(false);
239     item.SetPointerId(0);
240     item.SetDownTime(0);
241 
242     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
243     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FOUR);
244     item.SetWindowX(POINTER_ITEM_WINDOW_X_THREE);
245     item.SetWindowY(POINTER_ITEM_WINDOW_Y_FIVE);
246 
247     item.SetWidth(POINTER_ITEM_WIDTH_TWO);
248     item.SetPressure(0);
249     item.SetDeviceId(0);
250     item.SetHeight(POINTER_ITEM_HEIGHT_ONE);
251     pointerEvent->AddPointerItem(item);
252     return pointerEvent;
253 }
254 
SetupPointerEvent007()255 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent007()
256 {
257     auto pointerEvent = PointerEvent::Create();
258     CHKPP(pointerEvent);
259     int64_t downTime = GetNanoTime() / NANOSECOND_TO_MILLISECOND;
260     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
261     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
262     pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_LEFT);
263     pointerEvent->SetPointerId(0);
264     pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT);
265     PointerEvent::PointerItem item;
266     item.SetPointerId(0);
267     item.SetDownTime(downTime);
268     item.SetPressed(false);
269     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_EIGHT);
270     item.SetWindowX(POINTER_ITEM_WINDOW_X_TEN);
271     item.SetWindowY(POINTER_ITEM_WINDOW_Y_TEN);
272     item.SetWidth(POINTER_ITEM_WIDTH_THREE);
273     item.SetHeight(POINTER_ITEM_HEIGHT_TWO);
274     item.SetPressure(0);
275     item.SetDeviceId(0);
276     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_ELEVEN);
277     pointerEvent->AddPointerItem(item);
278     return pointerEvent;
279 }
280 
SetupPointerEvent009()281 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent009()
282 {
283     auto pointerEvent = PointerEvent::Create();
284     CHKPP(pointerEvent);
285     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
286     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_UPDATE);
287     pointerEvent->SetPointerId(1);
288     pointerEvent->SetAxisValue(PointerEvent::AXIS_TYPE_SCROLL_VERTICAL, POINTER_AXIS_VALUE_ONE);
289     PointerEvent::PointerItem item;
290     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_SEVEN);
291     item.SetDownTime(0);
292     item.SetPressed(false);
293     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FIVE);
294     item.SetWindowX(POINTER_ITEM_WINDOW_X_NINE);
295     item.SetPointerId(1);
296     item.SetWindowY(POINTER_ITEM_WINDOW_Y_NINE);
297     item.SetDeviceId(0);
298     item.SetWidth(POINTER_ITEM_WIDTH_ONE);
299     item.SetHeight(POINTER_ITEM_HEIGHT_ONE);
300     item.SetPressure(0);
301     pointerEvent->AddPointerItem(item);
302     return pointerEvent;
303 }
304 
SetupPointerEvent010()305 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent010()
306 {
307     auto pointerEvent = PointerEvent::Create();
308     CHKPP(pointerEvent);
309     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
310     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_UPDATE);
311     pointerEvent->SetPointerId(1);
312     pointerEvent->SetAxisValue(PointerEvent::AXIS_TYPE_SCROLL_VERTICAL, POINTER_AXIS_VALUE_TWO);
313     pointerEvent->SetAxisValue(PointerEvent::AXIS_TYPE_SCROLL_HORIZONTAL, POINTER_AXIS_VALUE_THREE);
314     PointerEvent::PointerItem item;
315     item.SetPointerId(1);
316     item.SetDownTime(0);
317     item.SetPressed(false);
318 
319     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FOUR);
320     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_SIX);
321     item.SetWindowX(POINTER_ITEM_WINDOW_X_SEVEN);
322     item.SetWindowY(POINTER_ITEM_WINDOW_Y_SEVEN);
323 
324     item.SetWidth(0);
325     item.SetHeight(0);
326     item.SetPressure(0);
327     item.SetDeviceId(0);
328     pointerEvent->AddPointerItem(item);
329     return pointerEvent;
330 }
331 
SetupPointerEvent011()332 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent011()
333 {
334     auto pointerEvent = PointerEvent::Create();
335     CHKPP(pointerEvent);
336     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
337     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
338     pointerEvent->SetPointerId(1);
339     PointerEvent::PointerItem item;
340     item.SetTiltY(POINTER_ITEM_TITLE_Y_ONE);
341     item.SetPointerId(0);
342     item.SetDownTime(0);
343     item.SetWindowY(POINTER_ITEM_WINDOW_Y_EIGHT);
344     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SEVEN);
345     item.SetWindowX(POINTER_ITEM_WINDOW_X_EIGHT);
346     item.SetHeight(0);
347     item.SetTiltX(POINTER_ITEM_TITLE_X_ONE);
348     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THIRTEEN);
349     item.SetPressure(POINTER_ITEM_PRESSURE_THREE);
350     item.SetDeviceId(1);
351     item.SetWidth(0);
352     pointerEvent->AddPointerItem(item);
353 
354     item.SetDownTime(0);
355     item.SetPointerId(1);
356     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
357     item.SetWindowX(POINTER_ITEM_WINDOW_X_FOUR);
358     item.SetWidth(0);
359     item.SetDeviceId(1);
360     item.SetHeight(0);
361     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
362     item.SetTiltX(POINTER_ITEM_TITLE_X_TWO);
363     item.SetTiltY(POINTER_ITEM_TITLE_Y_TWO);
364     item.SetPressure(POINTER_ITEM_PRESSURE_FOUR);
365     item.SetWindowY(POINTER_ITEM_WINDOW_Y_THREE);
366     pointerEvent->AddPointerItem(item);
367     return pointerEvent;
368 }
369 
SetupPointerEvent012()370 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent012()
371 {
372     auto pointerEvent = PointerEvent::Create();
373     CHKPP(pointerEvent);
374     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
375     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
376     pointerEvent->SetPointerId(1);
377     PointerEvent::PointerItem item;
378     item.SetDeviceId(1);
379     item.SetTiltY(POINTER_ITEM_TITLE_Y_ONE);
380     item.SetHeight(0);
381     item.SetDownTime(0);
382     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THIRTEEN);
383     item.SetWindowX(POINTER_ITEM_WINDOW_X_EIGHT);
384     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SEVEN);
385     item.SetWindowY(POINTER_ITEM_WINDOW_Y_EIGHT);
386     item.SetWidth(0);
387     item.SetTiltX(POINTER_ITEM_TITLE_X_ONE);
388     item.SetPressure(POINTER_ITEM_PRESSURE_THREE);
389     item.SetPointerId(0);
390     pointerEvent->AddPointerItem(item);
391 
392     item.SetDeviceId(1);
393     item.SetDownTime(0);
394     item.SetTiltX(POINTER_ITEM_TITLE_X_TWO);
395     item.SetWindowX(POINTER_ITEM_WINDOW_X_FOUR);
396     item.SetWindowY(POINTER_ITEM_WINDOW_Y_THREE);
397     item.SetWidth(0);
398     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
399     item.SetHeight(0);
400     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
401     item.SetTiltY(POINTER_ITEM_TITLE_Y_TWO);
402     item.SetPressure(POINTER_ITEM_PRESSURE_FOUR);
403     item.SetPointerId(1);
404     pointerEvent->AddPointerItem(item);
405     return pointerEvent;
406 }
407 
SetupPointerEvent013()408 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent013()
409 {
410     auto pointerEvent = PointerEvent::Create();
411     CHKPP(pointerEvent);
412     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
413     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
414     pointerEvent->SetPointerId(1);
415     PointerEvent::PointerItem item;
416     item.SetPointerId(0);
417     item.SetDownTime(0);
418     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SEVEN);
419     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THIRTEEN);
420     item.SetWindowX(POINTER_ITEM_WINDOW_X_EIGHT);
421     item.SetWindowY(POINTER_ITEM_WINDOW_Y_EIGHT);
422     item.SetWidth(0);
423     item.SetHeight(0);
424     item.SetTiltX(POINTER_ITEM_TITLE_X_ONE);
425     item.SetTiltY(POINTER_ITEM_TITLE_Y_ONE);
426     item.SetPressure(POINTER_ITEM_PRESSURE_THREE);
427     item.SetDeviceId(1);
428     pointerEvent->AddPointerItem(item);
429 
430     item.SetPointerId(1);
431     item.SetDownTime(0);
432     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
433     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
434     item.SetWindowX(POINTER_ITEM_WINDOW_X_FOUR);
435     item.SetWindowY(POINTER_ITEM_WINDOW_Y_THREE);
436     item.SetWidth(0);
437     item.SetHeight(0);
438     item.SetTiltX(POINTER_ITEM_TITLE_X_TWO);
439     item.SetTiltY(POINTER_ITEM_TITLE_Y_TWO);
440     item.SetPressure(POINTER_ITEM_PRESSURE_FOUR);
441     item.SetDeviceId(1);
442     pointerEvent->AddPointerItem(item);
443     return pointerEvent;
444 }
445 
SetupPointerEvent014()446 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent014()
447 {
448     auto pointerEvent = PointerEvent::Create();
449     CHKPP(pointerEvent);
450     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
451     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
452     pointerEvent->SetPointerId(0);
453     PointerEvent::PointerItem item;
454     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FOURTEEN);
455     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_NINE);
456     item.SetWindowX(POINTER_ITEM_WINDOW_X_ONE);
457     item.SetWindowY(POINTER_ITEM_WINDOW_Y_ONE);
458 
459     item.SetWidth(0);
460     item.SetHeight(0);
461     item.SetPressed(false);
462     item.SetPointerId(0);
463     item.SetDownTime(0);
464     item.SetPressure(0);
465     item.SetDeviceId(0);
466     pointerEvent->AddPointerItem(item);
467     return pointerEvent;
468 }
469 
SetupPointerEvent015()470 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent015()
471 {
472     auto pointerEvent = PointerEvent::Create();
473     CHKPP(pointerEvent);
474     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
475     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
476     pointerEvent->SetPointerId(0);
477     PointerEvent::PointerItem item;
478     item.SetPointerId(0);
479     item.SetHeight(0);
480     item.SetPressure(0);
481     item.SetWidth(0);
482     item.SetDeviceId(0);
483     item.SetDownTime(0);
484     item.SetPressed(false);
485 
486     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
487     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWENTY);
488     item.SetWindowX(POINTER_ITEM_WINDOW_X_SIX);
489     item.SetWindowY(POINTER_ITEM_WINDOW_Y_SIX);
490 
491     pointerEvent->AddPointerItem(item);
492     return pointerEvent;
493 }
494 
495 #ifdef OHOS_BUILD_ENABLE_JOYSTICK
SetupPointerEvent016()496 std::shared_ptr<PointerEvent> InputManagerUtil::SetupPointerEvent016()
497 {
498     auto pointerEvent = PointerEvent::Create();
499     CHKPP(pointerEvent);
500     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
501     return pointerEvent;
502 }
503 #endif  // OHOS_BUILD_ENABLE_JOYSTICK
504 
SetupMouseEvent001()505 std::shared_ptr<PointerEvent> InputManagerUtil::SetupMouseEvent001()
506 {
507     auto pointerEvent = PointerEvent::Create();
508     CHKPP(pointerEvent);
509     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
510     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
511     pointerEvent->SetPointerId(0);
512     PointerEvent::PointerItem item;
513 
514     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
515     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FIVE);
516     item.SetWidth(0);
517     item.SetHeight(0);
518     item.SetPressure(0);
519     item.SetDeviceId(0);
520     item.SetWindowX(POINTER_ITEM_WINDOW_X_TWO);
521     item.SetWindowY(POINTER_ITEM_WINDOW_Y_TWO);
522     item.SetPointerId(0);
523     item.SetDownTime(0);
524     item.SetPressed(false);
525 
526     pointerEvent->AddPointerItem(item);
527     return pointerEvent;
528 }
529 
SetupMouseEvent002()530 std::shared_ptr<PointerEvent> InputManagerUtil::SetupMouseEvent002()
531 {
532     auto pointerEvent = PointerEvent::Create();
533     CHKPP(pointerEvent);
534     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
535     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
536     pointerEvent->SetPointerId(0);
537     PointerEvent::PointerItem item;
538     item.SetDownTime(0);
539     item.SetPressed(false);
540     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FIFTEEN);
541     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THREE);
542     item.SetWidth(0);
543     item.SetHeight(0);
544     item.SetWindowX(POINTER_ITEM_WINDOW_X_FIVE);
545     item.SetWindowY(POINTER_ITEM_WINDOW_Y_FOUR);
546     item.SetPressure(0);
547     item.SetPointerId(0);
548     item.SetDeviceId(0);
549     pointerEvent->AddPointerItem(item);
550     return pointerEvent;
551 }
552 
SetupTouchScreenEvent001()553 std::shared_ptr<PointerEvent> InputManagerUtil::SetupTouchScreenEvent001()
554 {
555     auto pointerEvent = PointerEvent::Create();
556     CHKPP(pointerEvent);
557     PointerEvent::PointerItem item;
558     item.SetPointerId(0);
559     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_THIRTEEN);
560     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_ONE);
561     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
562     item.SetDeviceId(1);
563     pointerEvent->AddPointerItem(item);
564     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
565     pointerEvent->SetPointerId(0);
566     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
567     return pointerEvent;
568 }
569 
SetupTouchScreenEvent002()570 std::shared_ptr<PointerEvent> InputManagerUtil::SetupTouchScreenEvent002()
571 {
572     auto pointerEvent = PointerEvent::Create();
573     CHKPP(pointerEvent);
574     PointerEvent::PointerItem item;
575     item.SetPointerId(0);
576     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
577     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
578     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
579     item.SetDeviceId(1);
580     pointerEvent->AddPointerItem(item);
581     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
582     pointerEvent->SetPointerId(0);
583     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
584     return pointerEvent;
585 }
586 
SetupKeyEvent001()587 std::shared_ptr<KeyEvent> InputManagerUtil::SetupKeyEvent001()
588 {
589     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
590     CHKPP(keyEvent);
591     int64_t downTime = GetNanoTime() / NANOSECOND_TO_MILLISECOND;
592     KeyEvent::KeyItem kitDown;
593     kitDown.SetPressed(true);
594     kitDown.SetDownTime(downTime);
595     kitDown.SetKeyCode(KeyEvent::KEYCODE_A);
596     keyEvent->AddPressedKeyItems(kitDown);
597     keyEvent->SetKeyCode(KeyEvent::KEYCODE_A);
598     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
599 
600     return keyEvent;
601 }
602 
SetupKeyEvent002()603 std::shared_ptr<KeyEvent> InputManagerUtil::SetupKeyEvent002()
604 {
605     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
606     CHKPP(keyEvent);
607     int64_t downTime = GetNanoTime() / NANOSECOND_TO_MILLISECOND;
608     KeyEvent::KeyItem kitDown;
609     kitDown.SetKeyCode(KeyEvent::KEYCODE_A);
610     kitDown.SetPressed(true);
611     kitDown.SetDownTime(downTime);
612     keyEvent->SetKeyCode(KeyEvent::KEYCODE_A);
613     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
614     keyEvent->AddPressedKeyItems(kitDown);
615 
616     return keyEvent;
617 }
618 
SetupKeyEvent003()619 std::shared_ptr<KeyEvent> InputManagerUtil::SetupKeyEvent003()
620 {
621     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
622     CHKPP(keyEvent);
623     int64_t downTime = GetNanoTime() / NANOSECOND_TO_MILLISECOND;
624     KeyEvent::KeyItem kitDown;
625     kitDown.SetKeyCode(KeyEvent::KEYCODE_A);
626     kitDown.SetDownTime(downTime);
627     kitDown.SetPressed(true);
628     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
629     keyEvent->SetKeyCode(KeyEvent::KEYCODE_A);
630     keyEvent->AddPressedKeyItems(kitDown);
631 
632     return keyEvent;
633 }
634 
TestMarkConsumedStep1()635 std::shared_ptr<PointerEvent> InputManagerUtil::TestMarkConsumedStep1()
636 {
637     auto pointerEvent = PointerEvent::Create();
638     CHKPP(pointerEvent);
639     PointerEvent::PointerItem item;
640     item.SetPointerId(0);
641     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SEVEN);
642     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THIRTEEN);
643     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
644     item.SetDeviceId(1);
645     pointerEvent->AddPointerItem(item);
646 
647     pointerEvent->SetId(std::numeric_limits<int32_t>::max() - INDEX_THIRD);
648     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
649     pointerEvent->SetPointerId(0);
650     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
651 
652 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
653     TestSimulateInputEvent(pointerEvent);
654 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
655     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
656     return pointerEvent;
657 }
658 
TestMarkConsumedStep2()659 std::shared_ptr<PointerEvent> InputManagerUtil::TestMarkConsumedStep2()
660 {
661     auto pointerEvent = PointerEvent::Create();
662     CHKPP(pointerEvent);
663     PointerEvent::PointerItem item;
664     item.SetPointerId(0);
665     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWELVE);
666     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THIRTEEN);
667     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
668     item.SetDeviceId(1);
669     pointerEvent->AddPointerItem(item);
670 
671     pointerEvent->SetId(std::numeric_limits<int32_t>::max() - INDEX_SECOND);
672     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
673     pointerEvent->SetPointerId(0);
674     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
675 
676 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
677     TestSimulateInputEvent(pointerEvent);
678 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
679     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
680     return pointerEvent;
681 }
682 
TestMarkConsumedStep3(int32_t monitorId,int32_t eventId)683 void InputManagerUtil::TestMarkConsumedStep3(int32_t monitorId, int32_t eventId)
684 {
685     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
686     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MARK_CONSUMED);
687     TestMarkConsumed(monitorId, eventId);
688     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
689 }
690 
TestMarkConsumedStep4()691 void InputManagerUtil::TestMarkConsumedStep4()
692 {
693     auto pointerEvent = PointerEvent::Create();
694     CHKPV(pointerEvent);
695     PointerEvent::PointerItem item;
696     item.SetDeviceId(1);
697     item.SetPointerId(0);
698     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SEVENTEEN);
699     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FIFTEEN);
700     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
701     pointerEvent->AddPointerItem(item);
702 
703     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
704     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
705     pointerEvent->SetPointerId(0);
706     pointerEvent->SetId(std::numeric_limits<int32_t>::max() - INDEX_FIRST);
707 
708 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
709     TestSimulateInputEvent(pointerEvent, TestScene::EXCEPTION_TEST);
710 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
711     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
712 }
713 
TestMarkConsumedStep5()714 void InputManagerUtil::TestMarkConsumedStep5()
715 {
716     auto pointerEvent = PointerEvent::Create();
717     CHKPV(pointerEvent);
718     PointerEvent::PointerItem item;
719     item.SetPointerId(0);
720     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SIXTEEN);
721     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWELVE);
722     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
723     item.SetDeviceId(1);
724     pointerEvent->AddPointerItem(item);
725 
726     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
727     pointerEvent->SetId(std::numeric_limits<int32_t>::max());
728     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
729     pointerEvent->SetPointerId(0);
730 
731 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
732     TestSimulateInputEvent(pointerEvent, TestScene::EXCEPTION_TEST);
733 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
734     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
735 }
736 
TestMarkConsumedStep6()737 void InputManagerUtil::TestMarkConsumedStep6()
738 {
739     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
740     auto pointerEvent = PointerEvent::Create();
741     CHKPV(pointerEvent);
742     PointerEvent::PointerItem item;
743     item.SetPointerId(0);
744     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_EIGHTEEN);
745     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_NINETEEN);
746     item.SetPressure(POINTER_ITEM_PRESSURE_ONE);
747     item.SetDeviceId(1);
748     pointerEvent->AddPointerItem(item);
749 
750     pointerEvent->SetId(std::numeric_limits<int32_t>::max());
751     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
752     pointerEvent->SetPointerId(0);
753     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
754 
755     TestUtil->SetRecvFlag(RECV_FLAG::RECV_FOCUS);
756 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
757     TestSimulateInputEvent(pointerEvent);
758 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
759     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
760 }
761 
TestMarkConsumed(int32_t monitorId,int32_t eventId)762 void InputManagerUtil::TestMarkConsumed(int32_t monitorId, int32_t eventId)
763 {
764     AccessMonitor monitor;
765     InputManager::GetInstance()->MarkConsumed(monitorId, eventId);
766 }
767 
SetMouseIconTest(const std::string iconPath)768 std::unique_ptr<OHOS::Media::PixelMap> InputManagerUtil::SetMouseIconTest(const std::string iconPath)
769 {
770     CALL_DEBUG_ENTER;
771     OHOS::Media::SourceOptions opts;
772     opts.formatHint = "image/svg+xml";
773     uint32_t ret = 0;
774     auto imageSource = OHOS::Media::ImageSource::CreateImageSource(iconPath, opts, ret);
775     CHKPP(imageSource);
776     std::set<std::string> formats;
777     ret = imageSource->GetSupportedFormats(formats);
778     MMI_HILOGD("Get supported format ret:%{public}u", ret);
779 
780     OHOS::Media::DecodeOptions decodeOpts;
781     decodeOpts.desiredSize = {.width = MOUSE_ICON_SIZE, .height = MOUSE_ICON_SIZE};
782 
783     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, ret);
784     if (pixelMap == nullptr) {
785         MMI_HILOGE("The pixelMap is nullptr");
786     }
787     return pixelMap;
788 }
789 
TestAddMonitor(std::shared_ptr<IInputEventConsumer> consumer)790 int32_t InputManagerUtil::TestAddMonitor(std::shared_ptr<IInputEventConsumer> consumer)
791 {
792     AccessMonitor monitor;
793     return InputManager::GetInstance()->AddMonitor(consumer);
794 }
795 
TestRemoveMonitor(int32_t monitorId)796 void InputManagerUtil::TestRemoveMonitor(int32_t monitorId)
797 {
798     AccessMonitor monitor;
799     InputManager::GetInstance()->RemoveMonitor(monitorId);
800 }
801 
TestMonitor(int32_t monitorId,std::shared_ptr<PointerEvent> pointerEvent)802 void InputManagerUtil::TestMonitor(int32_t monitorId, std::shared_ptr<PointerEvent> pointerEvent)
803 {
804 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_MONITOR)
805     TestSimulateInputEvent(pointerEvent);
806 #endif  // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_MONITOR
807 
808     if (IsValidHandlerId(monitorId)) {
809         TestRemoveMonitor(monitorId);
810         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
811     }
812 }
813 
TestInterceptorIdAndPointerEvent(int32_t interceptorId,std::shared_ptr<PointerEvent> pointerEvent)814 void InputManagerUtil::TestInterceptorIdAndPointerEvent(
815     int32_t interceptorId, std::shared_ptr<PointerEvent> pointerEvent)
816 {
817 #ifdef OHOS_BUILD_ENABLE_INTERCEPTOR
818     EXPECT_TRUE(IsValidHandlerId(interceptorId));
819 #else
820     EXPECT_EQ(interceptorId, ERROR_UNSUPPORT);
821 #endif  // OHOS_BUILD_ENABLE_INTERCEPTOR
822     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
823 
824 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_INTERCEPTOR)
825     SimulateInputEventUtilTest(pointerEvent);
826 #endif  // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_INTERCEPTOR
827 
828     if (IsValidHandlerId(interceptorId)) {
829         InputManager::GetInstance()->RemoveInterceptor(interceptorId);
830         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
831     }
832 }
833 
TestInterceptorId(int32_t interceptorId1,int32_t interceptorId2)834 void InputManagerUtil::TestInterceptorId(int32_t interceptorId1, int32_t interceptorId2)
835 {
836     if (IsValidHandlerId(interceptorId1)) {
837         InputManager::GetInstance()->RemoveInterceptor(interceptorId1);
838         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
839     }
840 
841     if (IsValidHandlerId(interceptorId2)) {
842         InputManager::GetInstance()->RemoveInterceptor(interceptorId2);
843         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
844     }
845 }
846 
SetupTabletToolEvent001()847 std::shared_ptr<PointerEvent> InputManagerUtil::SetupTabletToolEvent001()
848 {
849     auto pointerEvent = PointerEvent::Create();
850     CHKPP(pointerEvent);
851     PointerEvent::PointerItem item;
852     item.SetPointerId(DEFAULT_POINTER_ID);
853     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_SEVEN);
854     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THIRTEEN);
855     item.SetPressure(POINTER_ITEM_PRESSURE_FIVE);
856     item.SetTiltX(POINTER_ITEM_TITLE_X_THREE);
857     item.SetTiltY(POINTER_ITEM_TITLE_Y_THREE);
858     item.SetDeviceId(DEFAULT_DEVICE_ID);
859     item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
860     pointerEvent->AddPointerItem(item);
861 
862     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
863     pointerEvent->SetPointerId(DEFAULT_POINTER_ID);
864     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
865     return pointerEvent;
866 }
867 }  // namespace MMI
868 }  // namespace OHOS