1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <semaphore.h>
17
18 #include "event_log_helper.h"
19 #include "event_util_test.h"
20 #include "input_manager.h"
21 #include "input_manager_util.h"
22 #include "multimodal_event_handler.h"
23 #include "system_info.h"
24
25 #undef MMI_LOG_TAG
26 #define MMI_LOG_TAG "InputManagerInjectTest"
27
28 namespace OHOS {
29 namespace MMI {
30 namespace {
31 constexpr int32_t TIME_WAIT_FOR_OP = 100;
32 constexpr int32_t NANOSECOND_TO_MILLISECOND = 1000000;
33 constexpr int32_t POINTER_ITEM_DISPLAY_X_ONE = 147;
34 constexpr int32_t POINTER_ITEM_DISPLAY_Y_TWO = 258;
35 constexpr int32_t INVAID_VALUE = -1;
36 constexpr double POINTER_ITEM_PRESSURE = 5.0;
37 } // namespace
38
39 class InputManagerInjectTest : public testing::Test {
40 public:
41 void SetUp();
42 void TearDown();
43 static void SetUpTestCase();
44 std::string GetEventDump();
45 void SetKeyEvent(int32_t act, int32_t code, bool pressed, int32_t time);
46 void SetPointerEvent(int32_t id, int32_t pressed, int32_t action, int32_t type);
47 void SetItemPointerEvent(int32_t id, int32_t pressed, int32_t action, int32_t type);
48
49 private:
50 int32_t keyboardRepeatRate_ { 50 };
51 int32_t keyboardRepeatDelay_ { 500 };
52 };
53
SetUpTestCase()54 void InputManagerInjectTest::SetUpTestCase()
55 {
56 ASSERT_TRUE(TestUtil->Init());
57 }
58
SetUp()59 void InputManagerInjectTest::SetUp()
60 {
61 TestUtil->SetRecvFlag(RECV_FLAG::RECV_FOCUS);
62 }
63
TearDown()64 void InputManagerInjectTest::TearDown()
65 {
66 TestUtil->AddEventDump("");
67 std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
68 InputManager::GetInstance()->SetKeyboardRepeatDelay(keyboardRepeatDelay_);
69 InputManager::GetInstance()->SetKeyboardRepeatRate(keyboardRepeatRate_);
70 }
71
GetEventDump()72 std::string InputManagerInjectTest::GetEventDump()
73 {
74 return TestUtil->GetEventDump();
75 }
76
SetKeyEvent(int32_t act,int32_t code,bool pressed,int32_t time)77 void InputManagerInjectTest::SetKeyEvent(int32_t act, int32_t code, bool pressed, int32_t time)
78 {
79 auto keyEvent = KeyEvent::Create();
80 ASSERT_NE(keyEvent, nullptr);
81 keyEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
82
83 KeyEvent::KeyItem item;
84 keyEvent->SetKeyAction(act);
85 keyEvent->SetRepeat(true);
86 item.SetKeyCode(code);
87 item.SetPressed(pressed);
88 item.SetDownTime(time);
89 keyEvent->AddKeyItem(item);
90 InputManager::GetInstance()->SimulateInputEvent(keyEvent);
91 }
92
SetPointerEvent(int32_t id,int32_t pressed,int32_t action,int32_t type)93 void InputManagerInjectTest::SetPointerEvent(int32_t id, int32_t pressed, int32_t action, int32_t type)
94 {
95 auto pointerEvent = PointerEvent::Create();
96 ASSERT_NE(pointerEvent, nullptr);
97 pointerEvent->SetButtonId(id);
98 pointerEvent->SetButtonPressed(pressed);
99
100 pointerEvent->SetPointerAction(action);
101 pointerEvent->SetSourceType(type);
102 pointerEvent->SetPointerId(0);
103 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
104 }
105
SetItemPointerEvent(int32_t id,int32_t pressed,int32_t action,int32_t type)106 void InputManagerInjectTest::SetItemPointerEvent(int32_t id, int32_t pressed, int32_t action, int32_t type)
107 {
108 auto pointerEvent = PointerEvent::Create();
109 ASSERT_NE(pointerEvent, nullptr);
110 PointerEvent::PointerItem item;
111 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
112 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
113 item.SetPressure(POINTER_ITEM_PRESSURE);
114 item.SetPointerId(0);
115 pointerEvent->SetButtonId(id);
116 pointerEvent->SetButtonPressed(pressed);
117
118 pointerEvent->SetPointerAction(action);
119 pointerEvent->SetSourceType(type);
120 pointerEvent->SetPointerId(0);
121 pointerEvent->AddPointerItem(item);
122 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
123 }
124
125 /**
126 * @tc.name: InputManager_InjectEvent_004
127 * @tc.desc: Injection interface detection
128 * @tc.type: FUNC
129 * @tc.require:
130 */
131 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_004, TestSize.Level1)
132 {
133 CALL_TEST_DEBUG;
134 bool ret = true;
__anon4cabfd4f0202(std::shared_ptr<KeyEvent> event) 135 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
136 MMI_HILOGI("Add monitor InjectEvent_004");
137 };
138 auto monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
139 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
140
141 auto keyEvent = KeyEvent::Create();
142 ASSERT_NE(keyEvent, nullptr);
143 keyEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
144
145 KeyEvent::KeyItem item;
146 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
147 item.SetKeyCode(KeyEvent::KEYCODE_F1);
148 item.SetPressed(false);
149 item.SetDownTime(500);
150 keyEvent->AddKeyItem(item);
151 InputManager::GetInstance()->SimulateInputEvent(keyEvent);
152 ASSERT_TRUE(ret);
153 InputManager::GetInstance()->RemoveMonitor(monitorId);
154 }
155
156 /**
157 * @tc.name: InputManager_InjectEvent_005
158 * @tc.desc: Injection interface detection
159 * @tc.type: FUNC
160 * @tc.require:
161 */
162 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_005, TestSize.Level1)
163 {
164 CALL_TEST_DEBUG;
165 bool ret = true;
__anon4cabfd4f0302(std::shared_ptr<KeyEvent> event) 166 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
167 MMI_HILOGI("Add monitor InjectEvent_005");
168 };
169 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
170 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
171
172 auto keyEvent = KeyEvent::Create();
173 ASSERT_NE(keyEvent, nullptr);
174 keyEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
175
176 KeyEvent::KeyItem item;
177 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
178 keyEvent->SetRepeat(true);
179 item.SetKeyCode(KeyEvent::KEYCODE_SPACE);
180 item.SetPressed(true);
181 item.SetDownTime(200);
182 keyEvent->AddKeyItem(item);
183 InputManager::GetInstance()->SimulateInputEvent(keyEvent);
184 ASSERT_TRUE(ret);
185 InputManager::GetInstance()->RemoveMonitor(monitorId);
186 }
187
188 /**
189 * @tc.name: InputManager_InjectEvent_006
190 * @tc.desc: Injection interface detection
191 * @tc.type: FUNC
192 * @tc.require:
193 */
194 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_006, TestSize.Level1)
195 {
196 CALL_TEST_DEBUG;
197 bool ret = true;
__anon4cabfd4f0402(std::shared_ptr<KeyEvent> event) 198 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
199 MMI_HILOGI("Add monitor InjectEvent_006");
200 };
201 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
202 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
203
204 auto keyDownEvent = KeyEvent::Create();
205 ASSERT_NE(keyDownEvent, nullptr);
206 keyDownEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
207 std::vector<int32_t> downKey;
208 downKey.push_back(KeyEvent::KEYCODE_CTRL_LEFT);
209 downKey.push_back(KeyEvent::KEYCODE_C);
210
211 KeyEvent::KeyItem downItem[downKey.size()];
212 for (size_t i = 0; i < downKey.size(); i++) {
213 keyDownEvent->SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT);
214 keyDownEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
215 downItem[i].SetKeyCode(downKey[i]);
216 downItem[i].SetPressed(true);
217 downItem[i].SetDownTime(500);
218 keyDownEvent->AddPressedKeyItems(downItem[i]);
219 }
220 InputManager::GetInstance()->SimulateInputEvent(keyDownEvent);
221
222 auto keyUpEvent = KeyEvent::Create();
223 ASSERT_NE(keyUpEvent, nullptr);
224 keyUpEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
225 std::vector<int32_t> upKey;
226 upKey.push_back(KeyEvent::KEYCODE_CTRL_LEFT);
227 upKey.push_back(KeyEvent::KEYCODE_C);
228
229 KeyEvent::KeyItem upItem[upKey.size()];
230 for (size_t i = 0; i < upKey.size(); i++) {
231 keyUpEvent->SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT);
232 keyUpEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
233 upItem[i].SetKeyCode(upKey[i]);
234 upItem[i].SetPressed(true);
235 upItem[i].SetDownTime(0);
236 keyUpEvent->RemoveReleasedKeyItems(upItem[i]);
237 }
238 InputManager::GetInstance()->SimulateInputEvent(keyUpEvent);
239 ASSERT_TRUE(ret);
240 InputManager::GetInstance()->RemoveMonitor(monitorId);
241 }
242
243 /**
244 * @tc.name: InputManager_InjectEvent_007
245 * @tc.desc: Injection interface detection
246 * @tc.type: FUNC
247 * @tc.require:
248 */
249 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_007, TestSize.Level1)
250 {
251 CALL_TEST_DEBUG;
252 bool ret = true;
__anon4cabfd4f0502(std::shared_ptr<KeyEvent> event) 253 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
254 MMI_HILOGI("Add monitor InjectEvent_007");
255 };
256 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
257 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
258
259 auto keyEvent = KeyEvent::Create();
260 ASSERT_NE(keyEvent, nullptr);
261 keyEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
262
263 KeyEvent::KeyItem item;
264 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
265 item.SetKeyCode(KeyEvent::KEYCODE_F1);
266 item.SetPressed(false);
267 item.SetDownTime(-500);
268 keyEvent->AddKeyItem(item);
269 InputManager::GetInstance()->SimulateInputEvent(keyEvent);
270 ASSERT_TRUE(ret);
271 InputManager::GetInstance()->RemoveMonitor(monitorId);
272 }
273
274 /**
275 * @tc.name: InputManager_InjectEvent_008
276 * @tc.desc: Injection interface detection
277 * @tc.type: FUNC
278 * @tc.require:
279 */
280 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_008, TestSize.Level1)
281 {
282 CALL_TEST_DEBUG;
283 bool ret = true;
__anon4cabfd4f0602(std::shared_ptr<KeyEvent> event) 284 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
285 MMI_HILOGI("Add monitor InjectEvent_008");
286 };
287 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
288 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
289
290 auto keyEvent = KeyEvent::Create();
291 ASSERT_NE(keyEvent, nullptr);
292 keyEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
293
294 KeyEvent::KeyItem item;
295 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
296 keyEvent->SetRepeat(true);
297 item.SetKeyCode(KeyEvent::KEYCODE_SPACE);
298 item.SetDownTime(200);
299 keyEvent->AddKeyItem(item);
300 InputManager::GetInstance()->SimulateInputEvent(keyEvent);
301 ASSERT_TRUE(ret);
302 InputManager::GetInstance()->RemoveMonitor(monitorId);
303 }
304
305 /**
306 * @tc.name: InputManager_InjectEvent_009
307 * @tc.desc: Injection interface detection
308 * @tc.type: FUNC
309 * @tc.require:
310 */
311 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_009, TestSize.Level1)
312 {
313 CALL_TEST_DEBUG;
314 bool ret = true;
__anon4cabfd4f0702(std::shared_ptr<KeyEvent> event) 315 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
316 MMI_HILOGI("Add monitor InjectEvent_009");
317 };
318 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
319 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
320
321 auto keyDownEvent = KeyEvent::Create();
322 ASSERT_NE(keyDownEvent, nullptr);
323 keyDownEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
324 std::vector<int32_t> downKey;
325 downKey.push_back(KeyEvent::KEYCODE_CTRL_LEFT);
326 downKey.push_back(KeyEvent::KEYCODE_C);
327
328 KeyEvent::KeyItem downItem[downKey.size()];
329 for (size_t i = 0; i < downKey.size(); i++) {
330 keyDownEvent->SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT);
331 keyDownEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
332 downItem[i].SetKeyCode(downKey[i]);
333 downItem[i].SetPressed(true);
334 downItem[i].SetDownTime(500);
335 keyDownEvent->AddPressedKeyItems(downItem[i]);
336 }
337 InputManager::GetInstance()->SimulateInputEvent(keyDownEvent);
338
339 auto keyUpEvent = KeyEvent::Create();
340 ASSERT_NE(keyUpEvent, nullptr);
341 keyUpEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
342 std::vector<int32_t> upKey;
343 upKey.push_back(KeyEvent::KEYCODE_CTRL_LEFT);
344 upKey.push_back(KeyEvent::KEYCODE_V);
345
346 KeyEvent::KeyItem upItem[upKey.size()];
347 for (size_t i = 0; i < upKey.size(); i++) {
348 keyUpEvent->SetKeyCode(KeyEvent::KEYCODE_CTRL_LEFT);
349 keyUpEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
350 upItem[i].SetKeyCode(upKey[i]);
351 upItem[i].SetPressed(true);
352 upItem[i].SetDownTime(0);
353 keyUpEvent->RemoveReleasedKeyItems(upItem[i]);
354 }
355 InputManager::GetInstance()->SimulateInputEvent(keyUpEvent);
356 ASSERT_TRUE(ret);
357 InputManager::GetInstance()->RemoveMonitor(monitorId);
358 }
359
360 /**
361 * @tc.name: InputManager_InjectEvent_010
362 * @tc.desc: Injection interface detection
363 * @tc.type: FUNC
364 * @tc.require:
365 */
366 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_010, TestSize.Level1)
367 {
368 CALL_TEST_DEBUG;
369 bool ret = true;
__anon4cabfd4f0802(std::shared_ptr<KeyEvent> event) 370 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
371 MMI_HILOGI("Add monitor InjectEvent_010");
372 };
373 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
374 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
375
376 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_DPAD_DOWN,
377 true, 200);
378 ASSERT_TRUE(ret);
379 InputManager::GetInstance()->RemoveMonitor(monitorId);
380 }
381
382 /**
383 * @tc.name: InputManager_InjectEvent_011
384 * @tc.desc: Injection interface detection
385 * @tc.type: FUNC
386 * @tc.require:
387 */
388 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_011, TestSize.Level1)
389 {
390 CALL_TEST_DEBUG;
391 bool ret = true;
__anon4cabfd4f0902(std::shared_ptr<KeyEvent> event) 392 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
393 MMI_HILOGI("Add monitor InjectEvent_011");
394 };
395 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
396 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
397
398 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_ESCAPE,
399 true, 200);
400 ASSERT_TRUE(ret);
401 InputManager::GetInstance()->RemoveMonitor(monitorId);
402 }
403
404 /**
405 * @tc.name: InputManager_InjectEvent_012
406 * @tc.desc: Injection interface detection
407 * @tc.type: FUNC
408 * @tc.require:
409 */
410 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_012, TestSize.Level1)
411 {
412 CALL_TEST_DEBUG;
413 bool ret = true;
__anon4cabfd4f0a02(std::shared_ptr<KeyEvent> event) 414 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
415 MMI_HILOGI("Add monitor InjectEvent_012");
416 };
417 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
418 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
419
420 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_6,
421 true, 200);
422 ASSERT_TRUE(ret);
423 InputManager::GetInstance()->RemoveMonitor(monitorId);
424 }
425
426 /**
427 * @tc.name: InputManager_InjectEvent_013
428 * @tc.desc: Injection interface detection
429 * @tc.type: FUNC
430 * @tc.require:
431 */
432 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_013, TestSize.Level1)
433 {
434 CALL_TEST_DEBUG;
435 bool ret = true;
__anon4cabfd4f0b02(std::shared_ptr<KeyEvent> event) 436 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
437 MMI_HILOGI("Add monitor InjectEvent_013");
438 };
439 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
440 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
441
442 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_MINUS,
443 true, 200);
444 ASSERT_TRUE(ret);
445 InputManager::GetInstance()->RemoveMonitor(monitorId);
446 }
447
448 /**
449 * @tc.name: InputManager_InjectEvent_014
450 * @tc.desc: Injection interface detection
451 * @tc.type: FUNC
452 * @tc.require:
453 */
454 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_014, TestSize.Level1)
455 {
456 CALL_TEST_DEBUG;
457 bool ret = true;
__anon4cabfd4f0c02(std::shared_ptr<KeyEvent> event) 458 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
459 MMI_HILOGI("Add monitor InjectEvent_014");
460 };
461 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
462 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
463
464 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_HOME,
465 true, 200);
466 ASSERT_TRUE(ret);
467 InputManager::GetInstance()->RemoveMonitor(monitorId);
468 }
469
470 /**
471 * @tc.name: InputManager_InjectEvent_015
472 * @tc.desc: Injection interface detection
473 * @tc.type: FUNC
474 * @tc.require:
475 */
476 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_015, TestSize.Level1)
477 {
478 CALL_TEST_DEBUG;
479 bool ret = true;
__anon4cabfd4f0d02(std::shared_ptr<KeyEvent> event) 480 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
481 MMI_HILOGI("Add monitor InjectEvent_015");
482 };
483 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
484 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
485
486 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_DEL,
487 true, 200);
488 ASSERT_TRUE(ret);
489 InputManager::GetInstance()->RemoveMonitor(monitorId);
490 }
491
492 /**
493 * @tc.name: InputManager_InjectEvent_016
494 * @tc.desc: Injection interface detection
495 * @tc.type: FUNC
496 * @tc.require:
497 */
498 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_016, TestSize.Level1)
499 {
500 CALL_TEST_DEBUG;
501 bool ret = true;
__anon4cabfd4f0e02(std::shared_ptr<KeyEvent> event) 502 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
503 MMI_HILOGI("Add monitor InjectEvent_016");
504 };
505 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
506 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
507
508 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_BUTTON_L1,
509 true, 200);
510 ASSERT_TRUE(ret);
511 InputManager::GetInstance()->RemoveMonitor(monitorId);
512 }
513
514 /**
515 * @tc.name: InputManager_InjectEvent_017
516 * @tc.desc: Injection interface detection
517 * @tc.type: FUNC
518 * @tc.require:
519 */
520 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_017, TestSize.Level1)
521 {
522 CALL_TEST_DEBUG;
523 bool ret = true;
__anon4cabfd4f0f02(std::shared_ptr<KeyEvent> event) 524 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
525 MMI_HILOGI("Add monitor InjectEvent_017");
526 };
527 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
528 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
529
530 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_SPACE,
531 true, 200);
532 ASSERT_TRUE(ret);
533 InputManager::GetInstance()->RemoveMonitor(monitorId);
534 }
535
536 /**
537 * @tc.name: InputManager_InjectEvent_018
538 * @tc.desc: Injection interface detection
539 * @tc.type: FUNC
540 * @tc.require:
541 */
542 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_018, TestSize.Level1)
543 {
544 CALL_TEST_DEBUG;
545 bool ret = true;
__anon4cabfd4f1002(std::shared_ptr<KeyEvent> event) 546 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
547 MMI_HILOGI("Add monitor InjectEvent_018");
548 };
549 int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
550 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
551
552 SetKeyEvent(KeyEvent::KEY_ACTION_DOWN, KeyEvent::KEYCODE_BRIGHTNESS_UP,
553 true, 200);
554 ASSERT_TRUE(ret);
555 InputManager::GetInstance()->RemoveMonitor(monitorId);
556 }
557
558 /**
559 * @tc.name: InputManager_InjectEvent_019
560 * @tc.desc: Injection interface detection
561 * @tc.type: FUNC
562 * @tc.require:
563 */
564 HWTEST_F(InputManagerInjectTest, InputManager_InjectEvent_019, TestSize.Level1)
565 {
566 CALL_TEST_DEBUG;
567 bool ret = true;
__anon4cabfd4f1102(std::shared_ptr<KeyEvent> event) 568 auto keyEventFun = [&ret](std::shared_ptr<KeyEvent> event) {
569 MMI_HILOGI("Add monitor InjectEvent_019");
570 };
571 auto monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
572 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
573
574 auto keyEvent = KeyEvent::Create();
575 ASSERT_NE(keyEvent, nullptr);
576 keyEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT);
577
578 KeyEvent::KeyItem item;
579 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
580 item.SetKeyCode(-1);
581 item.SetPressed(true);
582 item.SetDownTime(500);
583 keyEvent->AddKeyItem(item);
584 InputManager::GetInstance()->SimulateInputEvent(keyEvent);
585 ASSERT_TRUE(ret);
586 InputManager::GetInstance()->RemoveMonitor(monitorId);
587 }
588
589 /**
590 * @tc.name: InputManagerTest_SubscribeKeyEvent_004
591 * @tc.desc: Injection interface detection
592 * @tc.type: FUNC
593 * @tc.require:
594 */
595 HWTEST_F(InputManagerInjectTest, InputManagerTest_SubscribeKeyEvent_004, TestSize.Level1)
596 {
597 CALL_TEST_DEBUG;
__anon4cabfd4f1202(std::shared_ptr<KeyEvent> keyEvent) 598 auto keyEventFun = [](std::shared_ptr<KeyEvent> keyEvent) {
599 EventLogHelper::PrintEventData(keyEvent, MMI_LOG_HEADER);
600 MMI_HILOGI("Add monitor SubscribeKeyEvent_004");
601 };
602 auto monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
603
604 std::set<int32_t> preKeys;
605 std::shared_ptr<KeyOption> keyOption = std::make_shared<KeyOption>();
606 keyOption->SetPreKeys(preKeys);
607 keyOption->SetFinalKey(KeyEvent::KEYCODE_VOLUME_UP);
608 keyOption->SetFinalKeyDown(true);
609 keyOption->SetFinalKeyDownDuration(INVAID_VALUE);
610 int32_t subscribeId = INVAID_VALUE;
611 subscribeId = InputManager::GetInstance()->SubscribeKeyEvent(keyOption, keyEventFun);
612
613 std::shared_ptr<KeyEvent> injectDownEvent = KeyEvent::Create();
614 ASSERT_TRUE(injectDownEvent != nullptr);
615 int64_t downTime = GetNanoTime() / NANOSECOND_TO_MILLISECOND;
616 KeyEvent::KeyItem kitDown;
617 kitDown.SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
618 kitDown.SetPressed(true);
619 kitDown.SetDownTime(downTime);
620 injectDownEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
621 injectDownEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
622 injectDownEvent->AddPressedKeyItems(kitDown);
623 InputManager::GetInstance()->SimulateInputEvent(injectDownEvent);
624 InputManager::GetInstance()->RemoveMonitor(monitorId);
625 }
626
627 /**
628 * @tc.name: InputManagerTest_SubscribeKeyEvent_005
629 * @tc.desc: Injection interface detection
630 * @tc.type: FUNC
631 * @tc.require:
632 */
633 HWTEST_F(InputManagerInjectTest, InputManagerTest_SubscribeKeyEvent_005, TestSize.Level1)
634 {
635 CALL_TEST_DEBUG;
__anon4cabfd4f1302(std::shared_ptr<KeyEvent> keyEvent) 636 auto keyEventFun = [](std::shared_ptr<KeyEvent> keyEvent) {
637 EventLogHelper::PrintEventData(keyEvent, MMI_LOG_HEADER);
638 MMI_HILOGI("Add monitor SubscribeKeyEvent_005");
639 };
640 auto monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
641
642 std::set<int32_t> preKeys;
643 std::shared_ptr<KeyOption> keyOption = std::make_shared<KeyOption>();
644 keyOption->SetPreKeys(preKeys);
645 keyOption->SetFinalKey(KeyEvent::KEYCODE_VOLUME_UP);
646 keyOption->SetFinalKeyDown(true);
647 keyOption->SetFinalKeyDownDuration(INVAID_VALUE);
648 int32_t subscribeId = INVAID_VALUE;
649 subscribeId = InputManager::GetInstance()->SubscribeKeyEvent(keyOption, keyEventFun);
650
651 std::shared_ptr<KeyEvent> injectDownEvent = KeyEvent::Create();
652 ASSERT_TRUE(injectDownEvent != nullptr);
653 KeyEvent::KeyItem kitDown;
654 kitDown.SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
655 kitDown.SetPressed(true);
656 injectDownEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP);
657 injectDownEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
658 injectDownEvent->AddPressedKeyItems(kitDown);
659 InputManager::GetInstance()->SimulateInputEvent(injectDownEvent);
660 InputManager::GetInstance()->RemoveMonitor(monitorId);
661 }
662
663 /**
664 * @tc.name: InputManager_InjectMouseEvent_007
665 * @tc.desc: Injection interface detection
666 * @tc.type: FUNC
667 * @tc.require:
668 */
669 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_007, TestSize.Level1)
670 {
671 CALL_TEST_DEBUG;
__anon4cabfd4f1402(std::shared_ptr<PointerEvent> event) 672 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
673 MMI_HILOGI("Add monitor InjectMouseEvent_007");
674 };
675 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
676 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
677
678 auto pointerEvent = PointerEvent::Create();
679 ASSERT_NE(pointerEvent, nullptr);
680 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
681 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
682
683 PointerEvent::PointerItem item;
684 item.SetPointerId(0);
685 item.SetDisplayX(200);
686 item.SetDisplayY(200);
687 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
688 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
689 pointerEvent->SetPointerId(0);
690 pointerEvent->AddPointerItem(item);
691 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
692 InputManager::GetInstance()->RemoveMonitor(monitorId);
693 }
694
695 /**
696 * @tc.name: InputManager_InjectMouseEvent_008
697 * @tc.desc: Injection interface detection
698 * @tc.type: FUNC
699 * @tc.require:
700 */
701 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_008, TestSize.Level1)
702 {
703 CALL_TEST_DEBUG;
__anon4cabfd4f1502(std::shared_ptr<PointerEvent> event) 704 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
705 MMI_HILOGI("Add monitor InjectMouseEvent_008");
706 };
707 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
708 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
709
710 auto pointerEvent = PointerEvent::Create();
711 ASSERT_NE(pointerEvent, nullptr);
712 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_MIDDLE);
713 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_MIDDLE);
714
715 PointerEvent::PointerItem item;
716 item.SetPointerId(0);
717 item.SetDisplayX(200);
718 item.SetDisplayY(200);
719 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
720 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
721 pointerEvent->SetPointerId(0);
722 pointerEvent->AddPointerItem(item);
723 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
724 InputManager::GetInstance()->RemoveMonitor(monitorId);
725 }
726
727 /**
728 * @tc.name: InputManager_InjectMouseEvent_009
729 * @tc.desc: Injection interface detection
730 * @tc.type: FUNC
731 * @tc.require:
732 */
733 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_009, TestSize.Level1)
734 {
735 CALL_TEST_DEBUG;
__anon4cabfd4f1602(std::shared_ptr<PointerEvent> event) 736 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
737 MMI_HILOGI("Add monitor InjectMouseEvent_009");
738 };
739 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
740 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
741
742 auto pointerEvent = PointerEvent::Create();
743 ASSERT_NE(pointerEvent, nullptr);
744
745 PointerEvent::PointerItem item;
746 item.SetPointerId(0);
747 item.SetDisplayX(200);
748 item.SetDisplayY(200);
749 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
750 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
751 pointerEvent->SetPointerId(0);
752 pointerEvent->AddPointerItem(item);
753 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
754 InputManager::GetInstance()->RemoveMonitor(monitorId);
755 }
756
757 /**
758 * @tc.name: InputManager_InjectMouseEvent_013
759 * @tc.desc: Injection interface detection
760 * @tc.type: FUNC
761 * @tc.require:
762 */
763 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_013, TestSize.Level1)
764 {
765 CALL_TEST_DEBUG;
__anon4cabfd4f1702(std::shared_ptr<PointerEvent> event) 766 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
767 MMI_HILOGI("Add monitor InjectMouseEvent_013");
768 };
769 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
770 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
771
772 auto pointerEvent = PointerEvent::Create();
773 ASSERT_NE(pointerEvent, nullptr);
774 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
775 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
776
777 PointerEvent::PointerItem item;
778 item.SetPointerId(0);
779 item.SetDisplayY(200);
780 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
781 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
782 pointerEvent->SetPointerId(0);
783 pointerEvent->AddPointerItem(item);
784 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
785 InputManager::GetInstance()->RemoveMonitor(monitorId);
786 }
787
788 /**
789 * @tc.name: InputManager_InjectMouseEvent_014
790 * @tc.desc: Injection interface detection
791 * @tc.type: FUNC
792 * @tc.require:
793 */
794 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_014, TestSize.Level1)
795 {
796 CALL_TEST_DEBUG;
__anon4cabfd4f1802(std::shared_ptr<PointerEvent> event) 797 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
798 MMI_HILOGI("Add monitor InjectMouseEvent_014");
799 };
800 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
801 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
802
803 auto pointerEvent = PointerEvent::Create();
804 ASSERT_NE(pointerEvent, nullptr);
805 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
806 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
807
808 PointerEvent::PointerItem item;
809 item.SetPointerId(0);
810 item.SetDisplayX(200);
811 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
812 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
813 pointerEvent->SetPointerId(0);
814 pointerEvent->AddPointerItem(item);
815 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
816 InputManager::GetInstance()->RemoveMonitor(monitorId);
817 }
818
819 /**
820 * @tc.name: InputManager_InjectMouseEvent_015
821 * @tc.desc: Injection interface detection
822 * @tc.type: FUNC
823 * @tc.require:
824 */
825 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_015, TestSize.Level1)
826 {
827 CALL_TEST_DEBUG;
__anon4cabfd4f1902(std::shared_ptr<PointerEvent> event) 828 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
829 MMI_HILOGI("Add monitor InjectMouseEvent_015");
830 };
831 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
832 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
833
834 auto pointerEvent = PointerEvent::Create();
835 ASSERT_NE(pointerEvent, nullptr);
836 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
837 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
838
839 PointerEvent::PointerItem item;
840 item.SetPointerId(0);
841 item.SetDisplayX(200);
842 item.SetDisplayY(200);
843 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
844 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
845 pointerEvent->AddPointerItem(item);
846 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
847 InputManager::GetInstance()->RemoveMonitor(monitorId);
848 }
849
850 /**
851 * @tc.name: InputManager_InjectMouseEvent_016
852 * @tc.desc: Injection interface detection
853 * @tc.type: FUNC
854 * @tc.require:
855 */
856 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_016, TestSize.Level1)
857 {
858 CALL_TEST_DEBUG;
__anon4cabfd4f1a02(std::shared_ptr<PointerEvent> event) 859 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
860 MMI_HILOGI("Add monitor InjectMouseEvent_016");
861 };
862 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
863 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
864
865 auto pointerEvent = PointerEvent::Create();
866 ASSERT_NE(pointerEvent, nullptr);
867 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_SIDE);
868 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_MIDDLE);
869
870 PointerEvent::PointerItem item;
871 item.SetPointerId(0);
872 item.SetDisplayX(200);
873 item.SetDisplayY(200);
874 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
875 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
876 pointerEvent->SetPointerId(0);
877 pointerEvent->AddPointerItem(item);
878 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
879 InputManager::GetInstance()->RemoveMonitor(monitorId);
880 }
881
882 /**
883 * @tc.name: InputManager_InjectMouseEvent_017
884 * @tc.desc: Injection interface detection
885 * @tc.type: FUNC
886 * @tc.require:
887 */
888 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_017, TestSize.Level1)
889 {
890 CALL_TEST_DEBUG;
__anon4cabfd4f1b02(std::shared_ptr<PointerEvent> event) 891 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
892 MMI_HILOGI("Add monitor InjectMouseEvent_017");
893 };
894 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
895 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
896
897 auto pointerEvent = PointerEvent::Create();
898 ASSERT_NE(pointerEvent, nullptr);
899 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_MIDDLE);
900 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_SIDE);
901
902 PointerEvent::PointerItem item;
903 item.SetPointerId(0);
904 item.SetDisplayX(200);
905 item.SetDisplayY(200);
906 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_DOWN);
907 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
908 pointerEvent->SetPointerId(0);
909 pointerEvent->AddPointerItem(item);
910 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
911 InputManager::GetInstance()->RemoveMonitor(monitorId);
912 }
913
914 /**
915 * @tc.name: InputManager_InjectMouseEvent_018
916 * @tc.desc: Injection interface detection
917 * @tc.type: FUNC
918 * @tc.require:
919 */
920 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_018, TestSize.Level1)
921 {
922 CALL_TEST_DEBUG;
__anon4cabfd4f1c02(std::shared_ptr<PointerEvent> event) 923 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
924 MMI_HILOGI("Add monitor InjectMouseEvent_018");
925 };
926 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
927 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
928
929 auto pointerEvent = PointerEvent::Create();
930 ASSERT_NE(pointerEvent, nullptr);
931
932 PointerEvent::PointerItem item;
933 item.SetDisplayX(200);
934 item.SetDisplayY(200);
935 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
936 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
937 pointerEvent->AddPointerItem(item);
938 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
939 InputManager::GetInstance()->RemoveMonitor(monitorId);
940 }
941
942 /**
943 * @tc.name: InputManager_InjectMouseEvent_019
944 * @tc.desc: Injection interface detection
945 * @tc.type: FUNC
946 * @tc.require:
947 */
948 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_019, TestSize.Level1)
949 {
950 CALL_TEST_DEBUG;
__anon4cabfd4f1d02(std::shared_ptr<PointerEvent> event) 951 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
952 MMI_HILOGI("Add monitor InjectMouseEvent_019");
953 };
954 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
955 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
956
957 auto pointerEvent = PointerEvent::Create();
958 ASSERT_NE(pointerEvent, nullptr);
959
960 PointerEvent::PointerItem item;
961 item.SetPointerId(0);
962 item.SetDisplayX(2000);
963 item.SetDisplayY(2000);
964 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
965 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
966 pointerEvent->SetPointerId(0);
967 pointerEvent->AddPointerItem(item);
968 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
969 InputManager::GetInstance()->RemoveMonitor(monitorId);
970 }
971
972 /**
973 * @tc.name: InputManager_InjectTouchpadEvent_001
974 * @tc.desc: Injection interface detection
975 * @tc.type: FUNC
976 * @tc.require:
977 */
978 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_001, TestSize.Level1)
979 {
980 CALL_TEST_DEBUG;
__anon4cabfd4f1e02(std::shared_ptr<PointerEvent> event) 981 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
982 MMI_HILOGI("Add monitor InjectTouchpadEvent_001");
983 };
984 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
985 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
986
987 auto pointerEvent = PointerEvent::Create();
988 ASSERT_NE(pointerEvent, nullptr);
989 PointerEvent::PointerItem item;
990 item.SetPointerId(0);
991 item.SetDisplayX(200);
992 item.SetDisplayY(200);
993 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
994 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
995 pointerEvent->SetPointerId(0);
996 pointerEvent->AddPointerItem(item);
997 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
998 InputManager::GetInstance()->RemoveMonitor(monitorId);
999 }
1000
1001 /**
1002 * @tc.name: InputManager_InjectTouchpadEvent_002
1003 * @tc.desc: Injection interface detection
1004 * @tc.type: FUNC
1005 * @tc.require:
1006 */
1007 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_002, TestSize.Level1)
1008 {
1009 CALL_TEST_DEBUG;
__anon4cabfd4f1f02(std::shared_ptr<PointerEvent> event) 1010 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1011 MMI_HILOGI("Add monitor InjectTouchpadEvent_002");
1012 };
1013 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1014 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1015
1016 auto pointerEvent = PointerEvent::Create();
1017 ASSERT_NE(pointerEvent, nullptr);
1018 PointerEvent::PointerItem item;
1019 item.SetPointerId(0);
1020 item.SetDisplayX(200);
1021 item.SetDisplayY(200);
1022 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_SWIPE_UPDATE);
1023 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1024 pointerEvent->SetPointerId(0);
1025 pointerEvent->AddPointerItem(item);
1026 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1027 InputManager::GetInstance()->RemoveMonitor(monitorId);
1028 }
1029
1030 /**
1031 * @tc.name: InputManager_InjectTouchpadEvent_003
1032 * @tc.desc: Injection interface detection
1033 * @tc.type: FUNC
1034 * @tc.require:
1035 */
1036 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_003, TestSize.Level1)
1037 {
1038 CALL_TEST_DEBUG;
__anon4cabfd4f2002(std::shared_ptr<PointerEvent> event) 1039 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1040 MMI_HILOGI("Add monitor InjectTouchpadEvent_003");
1041 };
1042 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1043 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1044
1045 auto pointerEvent = PointerEvent::Create();
1046 ASSERT_NE(pointerEvent, nullptr);
1047
1048 PointerEvent::PointerItem item;
1049 item.SetPointerId(0);
1050 item.SetDisplayY(200);
1051 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1052 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1053 pointerEvent->SetPointerId(0);
1054 pointerEvent->AddPointerItem(item);
1055 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1056 InputManager::GetInstance()->RemoveMonitor(monitorId);
1057 }
1058
1059 /**
1060 * @tc.name: InputManager_InjectTouchpadEvent_004
1061 * @tc.desc: Injection interface detection
1062 * @tc.type: FUNC
1063 * @tc.require:
1064 */
1065 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_004, TestSize.Level1)
1066 {
1067 CALL_TEST_DEBUG;
__anon4cabfd4f2102(std::shared_ptr<PointerEvent> event) 1068 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1069 MMI_HILOGI("Add monitor InjectTouchpadEvent_004");
1070 };
1071 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1072 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1073
1074 auto pointerEvent = PointerEvent::Create();
1075 ASSERT_NE(pointerEvent, nullptr);
1076
1077 PointerEvent::PointerItem item;
1078 item.SetPointerId(0);
1079 item.SetDisplayX(200);
1080 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1081 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1082 pointerEvent->SetPointerId(0);
1083 pointerEvent->AddPointerItem(item);
1084 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1085 InputManager::GetInstance()->RemoveMonitor(monitorId);
1086 }
1087
1088 /**
1089 * @tc.name: InputManager_InjectTouchpadEvent_005
1090 * @tc.desc: Injection interface detection
1091 * @tc.type: FUNC
1092 * @tc.require:AR000GJG6G
1093 */
1094 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_005, TestSize.Level1)
1095 {
1096 CALL_TEST_DEBUG;
__anon4cabfd4f2202(std::shared_ptr<PointerEvent> event) 1097 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1098 MMI_HILOGI("Add monitor InjectTouchpadEvent_005");
1099 };
1100 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1101 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1102
1103 auto pointerEvent = PointerEvent::Create();
1104 ASSERT_NE(pointerEvent, nullptr);
1105
1106 PointerEvent::PointerItem item;
1107 item.SetPointerId(0);
1108 item.SetDisplayX(200);
1109 item.SetDisplayY(200);
1110 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1111 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1112 pointerEvent->AddPointerItem(item);
1113 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1114 InputManager::GetInstance()->RemoveMonitor(monitorId);
1115 }
1116
1117 /**
1118 * @tc.name: InputManager_InjectTouchpadEvent_006
1119 * @tc.desc: Injection interface detection
1120 * @tc.type: FUNC
1121 * @tc.require:AR000GJG6G
1122 */
1123 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_006, TestSize.Level1)
1124 {
1125 CALL_TEST_DEBUG;
__anon4cabfd4f2302(std::shared_ptr<PointerEvent> event) 1126 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1127 MMI_HILOGI("Add monitor InjectTouchpadEvent_006");
1128 };
1129 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1130 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1131
1132 auto pointerEvent = PointerEvent::Create();
1133 ASSERT_NE(pointerEvent, nullptr);
1134
1135 PointerEvent::PointerItem item;
1136 item.SetPointerId(0);
1137 item.SetDisplayX(200);
1138 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_SWIPE_UPDATE);
1139 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1140 pointerEvent->SetPointerId(0);
1141 pointerEvent->AddPointerItem(item);
1142 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1143 InputManager::GetInstance()->RemoveMonitor(monitorId);
1144 }
1145
1146 /**
1147 * @tc.name: InputManager_InjectTouchscreenEvent_001
1148 * @tc.desc: Injection interface detection
1149 * @tc.type: FUNC
1150 * @tc.require:
1151 */
1152 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_001, TestSize.Level1)
1153 {
1154 CALL_TEST_DEBUG;
__anon4cabfd4f2402(std::shared_ptr<PointerEvent> event) 1155 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1156 MMI_HILOGI("Add monitor InjectTouchscreenEvent_001");
1157 };
1158 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1159 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1160
1161 auto pointerEvent = PointerEvent::Create();
1162 ASSERT_NE(pointerEvent, nullptr);
1163
1164 PointerEvent::PointerItem item;
1165 item.SetPointerId(0);
1166 item.SetDisplayX(200);
1167 item.SetDisplayY(200);
1168 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1169 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1170 pointerEvent->SetPointerId(0);
1171 pointerEvent->AddPointerItem(item);
1172 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1173 InputManager::GetInstance()->RemoveMonitor(monitorId);
1174 }
1175
1176 /**
1177 * @tc.name: InputManager_InjectTouchscreenEvent_002
1178 * @tc.desc: Injection interface detection
1179 * @tc.type: FUNC
1180 * @tc.require:
1181 */
1182 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_002, TestSize.Level1)
1183 {
1184 CALL_TEST_DEBUG;
__anon4cabfd4f2502(std::shared_ptr<PointerEvent> event) 1185 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1186 MMI_HILOGI("Add monitor InjectTouchscreenEvent_002");
1187 };
1188 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1189 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1190
1191 auto pointerEvent = PointerEvent::Create();
1192 ASSERT_NE(pointerEvent, nullptr);
1193
1194 PointerEvent::PointerItem item;
1195 item.SetPointerId(0);
1196 item.SetDisplayX(200);
1197 item.SetDisplayY(200);
1198 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1199 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1200 pointerEvent->SetPointerId(0);
1201 pointerEvent->AddPointerItem(item);
1202 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1203 InputManager::GetInstance()->RemoveMonitor(monitorId);
1204 }
1205
1206 /**
1207 * @tc.name: InputManager_InjectTouchscreenEvent_003
1208 * @tc.desc: Injection interface detection
1209 * @tc.type: FUNC
1210 * @tc.require:
1211 */
1212 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_003, TestSize.Level1)
1213 {
1214 CALL_TEST_DEBUG;
__anon4cabfd4f2602(std::shared_ptr<PointerEvent> event) 1215 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1216 MMI_HILOGI("Add monitor InjectTouchscreenEvent_003");
1217 };
1218 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1219 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1220
1221 auto pointerEvent = PointerEvent::Create();
1222 ASSERT_NE(pointerEvent, nullptr);
1223
1224 PointerEvent::PointerItem item;
1225 item.SetPointerId(0);
1226 item.SetDisplayX(200);
1227 item.SetDisplayY(200);
1228 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_ENTER);
1229 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1230 pointerEvent->SetPointerId(0);
1231 pointerEvent->AddPointerItem(item);
1232 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1233 InputManager::GetInstance()->RemoveMonitor(monitorId);
1234 }
1235
1236 /**
1237 * @tc.name: InputManager_InjectTouchscreenEvent_004
1238 * @tc.desc: Injection interface detection
1239 * @tc.type: FUNC
1240 * @tc.require:
1241 */
1242 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_004, TestSize.Level1)
1243 {
1244 CALL_TEST_DEBUG;
__anon4cabfd4f2702(std::shared_ptr<PointerEvent> event) 1245 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1246 MMI_HILOGI("Add monitor InjectTouchscreenEvent_004");
1247 };
1248 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1249 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1250
1251 auto pointerEvent = PointerEvent::Create();
1252 ASSERT_NE(pointerEvent, nullptr);
1253
1254 PointerEvent::PointerItem item;
1255 item.SetPointerId(0);
1256 item.SetDisplayX(200);
1257 item.SetDisplayY(200);
1258 item.SetDownTime(500);
1259 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1260 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1261 pointerEvent->SetPointerId(0);
1262 pointerEvent->AddPointerItem(item);
1263 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1264 InputManager::GetInstance()->RemoveMonitor(monitorId);
1265 }
1266
1267 /**
1268 * @tc.name: InputManager_InjectTouchscreenEvent_005
1269 * @tc.desc: Injection interface detection
1270 * @tc.type: FUNC
1271 * @tc.require:
1272 */
1273 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_005, TestSize.Level1)
1274 {
1275 CALL_TEST_DEBUG;
__anon4cabfd4f2802(std::shared_ptr<PointerEvent> event) 1276 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1277 MMI_HILOGI("Add monitor InjectTouchscreenEvent_005");
1278 };
1279 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1280 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1281
1282 auto pointerEvent = PointerEvent::Create();
1283 ASSERT_NE(pointerEvent, nullptr);
1284
1285 PointerEvent::PointerItem item;
1286 item.SetPointerId(0);
1287 item.SetDisplayY(200);
1288 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1289 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1290 pointerEvent->SetPointerId(0);
1291 pointerEvent->AddPointerItem(item);
1292 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1293 InputManager::GetInstance()->RemoveMonitor(monitorId);
1294 }
1295
1296 /**
1297 * @tc.name: InputManager_InjectTouchscreenEvent_006
1298 * @tc.desc: Injection interface detection
1299 * @tc.type: FUNC
1300 * @tc.require:
1301 */
1302 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_006, TestSize.Level1)
1303 {
1304 CALL_TEST_DEBUG;
__anon4cabfd4f2902(std::shared_ptr<PointerEvent> event) 1305 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1306 MMI_HILOGI("Add monitor InjectTouchscreenEvent_006");
1307 };
1308 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1309 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1310
1311 auto pointerEvent = PointerEvent::Create();
1312 ASSERT_NE(pointerEvent, nullptr);
1313
1314 PointerEvent::PointerItem item;
1315 item.SetPointerId(0);
1316 item.SetDisplayX(200);
1317 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1318 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1319 pointerEvent->SetPointerId(0);
1320 pointerEvent->AddPointerItem(item);
1321 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1322 InputManager::GetInstance()->RemoveMonitor(monitorId);
1323 }
1324
1325 /**
1326 * @tc.name: InputManager_InjectTouchscreenEvent_007
1327 * @tc.desc: Injection interface detection
1328 * @tc.type: FUNC
1329 * @tc.require:
1330 */
1331 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_007, TestSize.Level1)
1332 {
1333 CALL_TEST_DEBUG;
__anon4cabfd4f2a02(std::shared_ptr<PointerEvent> event) 1334 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1335 MMI_HILOGI("Add monitor InjectTouchscreenEvent_007");
1336 };
1337 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1338 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1339
1340 auto pointerEvent = PointerEvent::Create();
1341 ASSERT_NE(pointerEvent, nullptr);
1342
1343 PointerEvent::PointerItem item;
1344 item.SetPointerId(0);
1345 item.SetDisplayY(200);
1346 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1347 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1348 pointerEvent->SetPointerId(0);
1349 pointerEvent->AddPointerItem(item);
1350 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1351 InputManager::GetInstance()->RemoveMonitor(monitorId);
1352 }
1353
1354 /**
1355 * @tc.name: InputManager_InjectTouchscreenEvent_008
1356 * @tc.desc: Injection interface detection
1357 * @tc.type: FUNC
1358 * @tc.require:
1359 */
1360 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_008, TestSize.Level1)
1361 {
1362 CALL_TEST_DEBUG;
__anon4cabfd4f2b02(std::shared_ptr<PointerEvent> event) 1363 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1364 MMI_HILOGI("Add monitor InjectTouchscreenEvent_008");
1365 };
1366 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1367 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1368
1369 auto pointerEvent = PointerEvent::Create();
1370 ASSERT_NE(pointerEvent, nullptr);
1371
1372 PointerEvent::PointerItem item;
1373 item.SetPointerId(0);
1374 item.SetDisplayX(200);
1375 item.SetDisplayY(200);
1376 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1377 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1378 pointerEvent->AddPointerItem(item);
1379 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1380 InputManager::GetInstance()->RemoveMonitor(monitorId);
1381 }
1382
1383 /**
1384 * @tc.name: InputManager_InjectTouchscreenEvent_009
1385 * @tc.desc: Injection interface detection
1386 * @tc.type: FUNC
1387 * @tc.require:
1388 */
1389 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_009, TestSize.Level1)
1390 {
1391 CALL_TEST_DEBUG;
__anon4cabfd4f2c02(std::shared_ptr<PointerEvent> event) 1392 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1393 MMI_HILOGI("Add monitor InjectTouchscreenEvent_009");
1394 };
1395 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1396 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1397
1398 auto pointerEvent = PointerEvent::Create();
1399 ASSERT_NE(pointerEvent, nullptr);
1400
1401 PointerEvent::PointerItem item;
1402 item.SetPointerId(0);
1403 item.SetDisplayX(200);
1404 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_MOVE);
1405 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1406 pointerEvent->SetPointerId(0);
1407 pointerEvent->AddPointerItem(item);
1408 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1409 InputManager::GetInstance()->RemoveMonitor(monitorId);
1410 }
1411
1412 /**
1413 * @tc.name: InputManager_InjectTouchscreenEvent_010
1414 * @tc.desc: Injection interface detection
1415 * @tc.type: FUNC
1416 * @tc.require:
1417 */
1418 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_010, TestSize.Level1)
1419 {
1420 CALL_TEST_DEBUG;
__anon4cabfd4f2d02(std::shared_ptr<PointerEvent> event) 1421 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1422 MMI_HILOGI("Add monitor InjectTouchscreenEvent_010");
1423 };
1424 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1425 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1426
1427 auto pointerEvent = PointerEvent::Create();
1428 ASSERT_NE(pointerEvent, nullptr);
1429
1430 PointerEvent::PointerItem item;
1431 item.SetPointerId(0);
1432 item.SetDisplayY(200);
1433 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_MOVE);
1434 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1435 pointerEvent->SetPointerId(0);
1436 pointerEvent->AddPointerItem(item);
1437 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1438 InputManager::GetInstance()->RemoveMonitor(monitorId);
1439 }
1440
1441 /**
1442 * @tc.name: InputManager_InjectTouchscreenEvent_011
1443 * @tc.desc: Injection interface detection
1444 * @tc.type: FUNC
1445 * @tc.require:
1446 */
1447 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_011, TestSize.Level1)
1448 {
1449 CALL_TEST_DEBUG;
__anon4cabfd4f2e02(std::shared_ptr<PointerEvent> event) 1450 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1451 MMI_HILOGI("Add monitor InjectTouchscreenEvent_011");
1452 };
1453 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1454 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1455
1456 auto pointerEvent = PointerEvent::Create();
1457 ASSERT_NE(pointerEvent, nullptr);
1458
1459 PointerEvent::PointerItem item;
1460 item.SetDisplayX(200);
1461 item.SetDisplayY(200);
1462 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_MOVE);
1463 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1464 pointerEvent->AddPointerItem(item);
1465 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1466 InputManager::GetInstance()->RemoveMonitor(monitorId);
1467 }
1468
1469 /**
1470 * @tc.name: InputManager_InjectTouchscreenEvent_012
1471 * @tc.desc: Injection interface detection
1472 * @tc.type: FUNC
1473 * @tc.require:
1474 */
1475 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_012, TestSize.Level1)
1476 {
1477 CALL_TEST_DEBUG;
__anon4cabfd4f2f02(std::shared_ptr<PointerEvent> event) 1478 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1479 MMI_HILOGI("Add monitor InjectTouchscreenEvent_012");
1480 };
1481 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1482 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1483
1484 auto pointerEvent = PointerEvent::Create();
1485 ASSERT_NE(pointerEvent, nullptr);
1486
1487 PointerEvent::PointerItem item;
1488 item.SetPointerId(0);
1489 item.SetDisplayX(200);
1490 item.SetDisplayY(200);
1491 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1492 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1493 pointerEvent->SetPointerId(0);
1494 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1495 InputManager::GetInstance()->RemoveMonitor(monitorId);
1496 }
1497
1498 /**
1499 * @tc.name: InputManagerTest_SimulateInputEventZorder_002
1500 * @tc.desc: Simulate input evnet with zOrder.
1501 * @tc.type: FUNC
1502 * @tc.require:
1503 */
1504 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_002, TestSize.Level1)
1505 {
1506 CALL_TEST_DEBUG;
__anon4cabfd4f3002(std::shared_ptr<PointerEvent> event) 1507 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1508 MMI_HILOGI("Add monitor SimulateInputEventZorder_002");
1509 };
1510 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1511 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1512
1513 auto pointerEvent = PointerEvent::Create();
1514 ASSERT_NE(pointerEvent, nullptr);
1515
1516 PointerEvent::PointerItem item;
1517 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1518 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1519 item.SetPressure(POINTER_ITEM_PRESSURE);
1520 item.SetPointerId(0);
1521 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1522 pointerEvent->SetPointerId(0);
1523 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1524 pointerEvent->AddPointerItem(item);
1525 pointerEvent->SetZOrder(10.0);
1526
1527 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0, false);
1528 InputManager::GetInstance()->RemoveMonitor(monitorId);
1529 }
1530
1531 /**
1532 * @tc.name: InputManagerTest_SimulateInputEventZorder_003
1533 * @tc.desc: Simulate input evnet with zOrder.
1534 * @tc.type: FUNC
1535 * @tc.require:
1536 */
1537 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_003, TestSize.Level1)
1538 {
1539 CALL_TEST_DEBUG;
__anon4cabfd4f3102(std::shared_ptr<PointerEvent> event) 1540 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1541 MMI_HILOGI("Add monitor SimulateInputEventZorder_003");
1542 };
1543 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1544 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1545
1546 auto pointerEvent = PointerEvent::Create();
1547 ASSERT_NE(pointerEvent, nullptr);
1548
1549 PointerEvent::PointerItem item;
1550 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1551 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1552 item.SetPressure(POINTER_ITEM_PRESSURE);
1553 item.SetPointerId(0);
1554 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1555 pointerEvent->SetPointerId(0);
1556 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1557 pointerEvent->AddPointerItem(item);
1558 pointerEvent->SetZOrder(-1000.0);
1559
1560 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, -1000.0, false);
1561 InputManager::GetInstance()->RemoveMonitor(monitorId);
1562 }
1563
1564 /**
1565 * @tc.name: InputManagerTest_SimulateInputEventZorder_004
1566 * @tc.desc: Simulate input evnet with zOrder.
1567 * @tc.type: FUNC
1568 * @tc.require:
1569 */
1570 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_004, TestSize.Level1)
1571 {
1572 CALL_TEST_DEBUG;
__anon4cabfd4f3202(std::shared_ptr<PointerEvent> event) 1573 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1574 MMI_HILOGI("Add monitor SimulateInputEventZorder_004");
1575 };
1576 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1577 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1578
1579 auto pointerEvent = PointerEvent::Create();
1580 ASSERT_NE(pointerEvent, nullptr);
1581
1582 PointerEvent::PointerItem item;
1583 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1584 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1585 item.SetPressure(POINTER_ITEM_PRESSURE);
1586 item.SetPointerId(0);
1587 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1588 pointerEvent->SetPointerId(0);
1589 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1590 pointerEvent->AddPointerItem(item);
1591 pointerEvent->SetZOrder(10.0);
1592
1593 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0, false);
1594 InputManager::GetInstance()->RemoveMonitor(monitorId);
1595 }
1596
1597 /**
1598 * @tc.name: InputManagerTest_SimulateInputEventZorder_005
1599 * @tc.desc: Simulate input evnet with zOrder.
1600 * @tc.type: FUNC
1601 * @tc.require:
1602 */
1603 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_005, TestSize.Level1)
1604 {
1605 CALL_TEST_DEBUG;
__anon4cabfd4f3302(std::shared_ptr<PointerEvent> event) 1606 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1607 MMI_HILOGI("Add monitor SimulateInputEventZorder_005");
1608 };
1609 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1610 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1611
1612 auto pointerEvent = PointerEvent::Create();
1613 ASSERT_NE(pointerEvent, nullptr);
1614
1615 PointerEvent::PointerItem item;
1616 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1617 item.SetPressure(POINTER_ITEM_PRESSURE);
1618 item.SetPointerId(0);
1619 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1620 pointerEvent->SetPointerId(0);
1621 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1622 pointerEvent->AddPointerItem(item);
1623 pointerEvent->SetZOrder(10.0);
1624
1625 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0, false);
1626 InputManager::GetInstance()->RemoveMonitor(monitorId);
1627 }
1628
1629 /**
1630 * @tc.name: InputManagerTest_SimulateInputEventZorder_006
1631 * @tc.desc: Simulate input evnet with zOrder.
1632 * @tc.type: FUNC
1633 * @tc.require:
1634 */
1635 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_006, TestSize.Level1)
1636 {
1637 CALL_TEST_DEBUG;
__anon4cabfd4f3402(std::shared_ptr<PointerEvent> event) 1638 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1639 MMI_HILOGI("Add monitor SimulateInputEventZorder_006");
1640 };
1641 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1642 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1643
1644 auto pointerEvent = PointerEvent::Create();
1645 ASSERT_NE(pointerEvent, nullptr);
1646
1647 PointerEvent::PointerItem item;
1648 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1649 item.SetPressure(POINTER_ITEM_PRESSURE);
1650 item.SetPointerId(0);
1651 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1652 pointerEvent->SetPointerId(0);
1653 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1654 pointerEvent->AddPointerItem(item);
1655 pointerEvent->SetZOrder(10.0);
1656
1657 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0, false);
1658 InputManager::GetInstance()->RemoveMonitor(monitorId);
1659 }
1660
1661 /**
1662 * @tc.name: InputManagerTest_SimulateInputEventZorder_007
1663 * @tc.desc: Simulate input evnet with zOrder.
1664 * @tc.type: FUNC
1665 * @tc.require:
1666 */
1667 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_007, TestSize.Level1)
1668 {
1669 CALL_TEST_DEBUG;
__anon4cabfd4f3502(std::shared_ptr<PointerEvent> event) 1670 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1671 MMI_HILOGI("Add monitor SimulateInputEventZorder_007");
1672 };
1673 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1674 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1675
1676 auto pointerEvent = PointerEvent::Create();
1677 ASSERT_NE(pointerEvent, nullptr);
1678
1679 PointerEvent::PointerItem item;
1680 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1681 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1682 item.SetPointerId(0);
1683 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1684 pointerEvent->SetPointerId(0);
1685 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1686 pointerEvent->AddPointerItem(item);
1687 pointerEvent->SetZOrder(10.0);
1688
1689 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0, false);
1690 InputManager::GetInstance()->RemoveMonitor(monitorId);
1691 }
1692
1693 /**
1694 * @tc.name: InputManagerTest_SimulateInputEventZorder_008
1695 * @tc.desc: Simulate input evnet with zOrder.
1696 * @tc.type: FUNC
1697 * @tc.require:
1698 */
1699 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_008, TestSize.Level1)
1700 {
1701 CALL_TEST_DEBUG;
__anon4cabfd4f3602(std::shared_ptr<PointerEvent> event) 1702 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1703 MMI_HILOGI("Add monitor SimulateInputEventZorder_008");
1704 };
1705 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1706 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1707
1708 auto pointerEvent = PointerEvent::Create();
1709 ASSERT_NE(pointerEvent, nullptr);
1710
1711 PointerEvent::PointerItem item;
1712 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1713 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1714 item.SetPointerId(0);
1715 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1716 pointerEvent->SetPointerId(0);
1717 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1718 pointerEvent->AddPointerItem(item);
1719 pointerEvent->SetZOrder(20.0);
1720 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0, false);
1721 InputManager::GetInstance()->RemoveMonitor(monitorId);
1722 }
1723 } // namespace MMI
1724 } // namespace OHOS
1725