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;
__anonc68ff6470202(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;
__anonc68ff6470302(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;
__anonc68ff6470402(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;
__anonc68ff6470502(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;
__anonc68ff6470602(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;
__anonc68ff6470702(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;
__anonc68ff6470802(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;
__anonc68ff6470902(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;
__anonc68ff6470a02(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;
__anonc68ff6470b02(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;
__anonc68ff6470c02(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;
__anonc68ff6470d02(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;
__anonc68ff6470e02(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;
__anonc68ff6470f02(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;
__anonc68ff6471002(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;
__anonc68ff6471102(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;
__anonc68ff6471202(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;
__anonc68ff6471302(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_006
665 * @tc.desc: Injection interface detection
666 * @tc.type: FUNC
667 * @tc.require:
668 */
669 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_006, TestSize.Level1)
670 {
671 CALL_TEST_DEBUG;
__anonc68ff6471402(std::shared_ptr<PointerEvent> event) 672 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
673 MMI_HILOGI("Add monitor InjectMouseEvent_006");
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_BUTTON_DOWN);
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_007
697 * @tc.desc: Injection interface detection
698 * @tc.type: FUNC
699 * @tc.require:
700 */
701 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_007, TestSize.Level1)
702 {
703 CALL_TEST_DEBUG;
__anonc68ff6471502(std::shared_ptr<PointerEvent> event) 704 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
705 MMI_HILOGI("Add monitor InjectMouseEvent_007");
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_RIGHT);
713 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
714
715 PointerEvent::PointerItem item;
716 item.SetPointerId(0);
717 item.SetDisplayX(200);
718 item.SetDisplayY(200);
719 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
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_008
729 * @tc.desc: Injection interface detection
730 * @tc.type: FUNC
731 * @tc.require:
732 */
733 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_008, TestSize.Level1)
734 {
735 CALL_TEST_DEBUG;
__anonc68ff6471602(std::shared_ptr<PointerEvent> event) 736 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
737 MMI_HILOGI("Add monitor InjectMouseEvent_008");
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 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_MIDDLE);
745 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_MIDDLE);
746
747 PointerEvent::PointerItem item;
748 item.SetPointerId(0);
749 item.SetDisplayX(200);
750 item.SetDisplayY(200);
751 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
752 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
753 pointerEvent->SetPointerId(0);
754 pointerEvent->AddPointerItem(item);
755 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
756 InputManager::GetInstance()->RemoveMonitor(monitorId);
757 }
758
759 /**
760 * @tc.name: InputManager_InjectMouseEvent_009
761 * @tc.desc: Injection interface detection
762 * @tc.type: FUNC
763 * @tc.require:
764 */
765 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_009, TestSize.Level1)
766 {
767 CALL_TEST_DEBUG;
__anonc68ff6471702(std::shared_ptr<PointerEvent> event) 768 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
769 MMI_HILOGI("Add monitor InjectMouseEvent_009");
770 };
771 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
772 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
773
774 auto pointerEvent = PointerEvent::Create();
775 ASSERT_NE(pointerEvent, nullptr);
776
777 PointerEvent::PointerItem item;
778 item.SetPointerId(0);
779 item.SetDisplayX(200);
780 item.SetDisplayY(200);
781 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
782 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
783 pointerEvent->SetPointerId(0);
784 pointerEvent->AddPointerItem(item);
785 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
786 InputManager::GetInstance()->RemoveMonitor(monitorId);
787 }
788
789 /**
790 * @tc.name: InputManager_InjectMouseEvent_010
791 * @tc.desc: Injection interface detection
792 * @tc.type: FUNC
793 * @tc.require:
794 */
795 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_010, TestSize.Level1)
796 {
797 CALL_TEST_DEBUG;
__anonc68ff6471802(std::shared_ptr<PointerEvent> event) 798 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
799 MMI_HILOGI("Add monitor InjectMouseEvent_010");
800 };
801 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
802 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
803
804 auto pointerEvent = PointerEvent::Create();
805 ASSERT_NE(pointerEvent, nullptr);
806 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
807 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
808
809 PointerEvent::PointerItem item;
810 item.SetPointerId(0);
811 item.SetDisplayX(200);
812 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
813 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
814 pointerEvent->SetPointerId(0);
815 pointerEvent->AddPointerItem(item);
816 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
817 InputManager::GetInstance()->RemoveMonitor(monitorId);
818 }
819
820 /**
821 * @tc.name: InputManager_InjectMouseEvent_011
822 * @tc.desc: Injection interface detection
823 * @tc.type: FUNC
824 * @tc.require:
825 */
826 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_011, TestSize.Level1)
827 {
828 CALL_TEST_DEBUG;
__anonc68ff6471902(std::shared_ptr<PointerEvent> event) 829 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
830 MMI_HILOGI("Add monitor InjectMouseEvent_011");
831 };
832 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
833 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
834
835 auto pointerEvent = PointerEvent::Create();
836 ASSERT_NE(pointerEvent, nullptr);
837 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
838 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
839
840 PointerEvent::PointerItem item;
841 item.SetPointerId(0);
842 item.SetDisplayY(200);
843 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
844 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
845 pointerEvent->SetPointerId(0);
846 pointerEvent->AddPointerItem(item);
847 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
848 InputManager::GetInstance()->RemoveMonitor(monitorId);
849 }
850
851 /**
852 * @tc.name: InputManager_InjectMouseEvent_012
853 * @tc.desc: Injection interface detection
854 * @tc.type: FUNC
855 * @tc.require:
856 */
857 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_012, TestSize.Level1)
858 {
859 CALL_TEST_DEBUG;
__anonc68ff6471a02(std::shared_ptr<PointerEvent> event) 860 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
861 MMI_HILOGI("Add monitor InjectMouseEvent_012");
862 };
863 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
864 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
865
866 auto pointerEvent = PointerEvent::Create();
867 ASSERT_NE(pointerEvent, nullptr);
868 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
869 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
870
871 PointerEvent::PointerItem item;
872 item.SetPointerId(0);
873 item.SetDisplayX(200);
874 item.SetDisplayY(200);
875 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
876 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
877 pointerEvent->AddPointerItem(item);
878 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
879 InputManager::GetInstance()->RemoveMonitor(monitorId);
880 }
881
882 /**
883 * @tc.name: InputManager_InjectMouseEvent_013
884 * @tc.desc: Injection interface detection
885 * @tc.type: FUNC
886 * @tc.require:
887 */
888 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_013, TestSize.Level1)
889 {
890 CALL_TEST_DEBUG;
__anonc68ff6471b02(std::shared_ptr<PointerEvent> event) 891 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
892 MMI_HILOGI("Add monitor InjectMouseEvent_013");
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_RIGHT);
900 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
901
902 PointerEvent::PointerItem item;
903 item.SetPointerId(0);
904 item.SetDisplayY(200);
905 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
906 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
907 pointerEvent->SetPointerId(0);
908 pointerEvent->AddPointerItem(item);
909 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
910 InputManager::GetInstance()->RemoveMonitor(monitorId);
911 }
912
913 /**
914 * @tc.name: InputManager_InjectMouseEvent_014
915 * @tc.desc: Injection interface detection
916 * @tc.type: FUNC
917 * @tc.require:
918 */
919 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_014, TestSize.Level1)
920 {
921 CALL_TEST_DEBUG;
__anonc68ff6471c02(std::shared_ptr<PointerEvent> event) 922 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
923 MMI_HILOGI("Add monitor InjectMouseEvent_014");
924 };
925 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
926 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
927
928 auto pointerEvent = PointerEvent::Create();
929 ASSERT_NE(pointerEvent, nullptr);
930 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
931 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
932
933 PointerEvent::PointerItem item;
934 item.SetPointerId(0);
935 item.SetDisplayX(200);
936 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
937 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
938 pointerEvent->SetPointerId(0);
939 pointerEvent->AddPointerItem(item);
940 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
941 InputManager::GetInstance()->RemoveMonitor(monitorId);
942 }
943
944 /**
945 * @tc.name: InputManager_InjectMouseEvent_015
946 * @tc.desc: Injection interface detection
947 * @tc.type: FUNC
948 * @tc.require:
949 */
950 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_015, TestSize.Level1)
951 {
952 CALL_TEST_DEBUG;
__anonc68ff6471d02(std::shared_ptr<PointerEvent> event) 953 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
954 MMI_HILOGI("Add monitor InjectMouseEvent_015");
955 };
956 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
957 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
958
959 auto pointerEvent = PointerEvent::Create();
960 ASSERT_NE(pointerEvent, nullptr);
961 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_RIGHT);
962 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
963
964 PointerEvent::PointerItem item;
965 item.SetPointerId(0);
966 item.SetDisplayX(200);
967 item.SetDisplayY(200);
968 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
969 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
970 pointerEvent->AddPointerItem(item);
971 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
972 InputManager::GetInstance()->RemoveMonitor(monitorId);
973 }
974
975 /**
976 * @tc.name: InputManager_InjectMouseEvent_016
977 * @tc.desc: Injection interface detection
978 * @tc.type: FUNC
979 * @tc.require:
980 */
981 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_016, TestSize.Level1)
982 {
983 CALL_TEST_DEBUG;
__anonc68ff6471e02(std::shared_ptr<PointerEvent> event) 984 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
985 MMI_HILOGI("Add monitor InjectMouseEvent_016");
986 };
987 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
988 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
989
990 auto pointerEvent = PointerEvent::Create();
991 ASSERT_NE(pointerEvent, nullptr);
992 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_SIDE);
993 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_MIDDLE);
994
995 PointerEvent::PointerItem item;
996 item.SetPointerId(0);
997 item.SetDisplayX(200);
998 item.SetDisplayY(200);
999 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
1000 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
1001 pointerEvent->SetPointerId(0);
1002 pointerEvent->AddPointerItem(item);
1003 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1004 InputManager::GetInstance()->RemoveMonitor(monitorId);
1005 }
1006
1007 /**
1008 * @tc.name: InputManager_InjectMouseEvent_017
1009 * @tc.desc: Injection interface detection
1010 * @tc.type: FUNC
1011 * @tc.require:
1012 */
1013 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_017, TestSize.Level1)
1014 {
1015 CALL_TEST_DEBUG;
__anonc68ff6471f02(std::shared_ptr<PointerEvent> event) 1016 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1017 MMI_HILOGI("Add monitor InjectMouseEvent_017");
1018 };
1019 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1020 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1021
1022 auto pointerEvent = PointerEvent::Create();
1023 ASSERT_NE(pointerEvent, nullptr);
1024 pointerEvent->SetButtonId(PointerEvent::MOUSE_BUTTON_MIDDLE);
1025 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_SIDE);
1026
1027 PointerEvent::PointerItem item;
1028 item.SetPointerId(0);
1029 item.SetDisplayX(200);
1030 item.SetDisplayY(200);
1031 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_DOWN);
1032 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
1033 pointerEvent->SetPointerId(0);
1034 pointerEvent->AddPointerItem(item);
1035 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1036 InputManager::GetInstance()->RemoveMonitor(monitorId);
1037 }
1038
1039 /**
1040 * @tc.name: InputManager_InjectMouseEvent_018
1041 * @tc.desc: Injection interface detection
1042 * @tc.type: FUNC
1043 * @tc.require:
1044 */
1045 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_018, TestSize.Level1)
1046 {
1047 CALL_TEST_DEBUG;
__anonc68ff6472002(std::shared_ptr<PointerEvent> event) 1048 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1049 MMI_HILOGI("Add monitor InjectMouseEvent_018");
1050 };
1051 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1052 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1053
1054 auto pointerEvent = PointerEvent::Create();
1055 ASSERT_NE(pointerEvent, nullptr);
1056
1057 PointerEvent::PointerItem item;
1058 item.SetDisplayX(200);
1059 item.SetDisplayY(200);
1060 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
1061 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
1062 pointerEvent->AddPointerItem(item);
1063 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1064 InputManager::GetInstance()->RemoveMonitor(monitorId);
1065 }
1066
1067 /**
1068 * @tc.name: InputManager_InjectMouseEvent_019
1069 * @tc.desc: Injection interface detection
1070 * @tc.type: FUNC
1071 * @tc.require:
1072 */
1073 HWTEST_F(InputManagerInjectTest, InputManager_InjectMouseEvent_019, TestSize.Level1)
1074 {
1075 CALL_TEST_DEBUG;
__anonc68ff6472102(std::shared_ptr<PointerEvent> event) 1076 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1077 MMI_HILOGI("Add monitor InjectMouseEvent_019");
1078 };
1079 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1080 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1081
1082 auto pointerEvent = PointerEvent::Create();
1083 ASSERT_NE(pointerEvent, nullptr);
1084
1085 PointerEvent::PointerItem item;
1086 item.SetPointerId(0);
1087 item.SetDisplayX(2000);
1088 item.SetDisplayY(2000);
1089 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
1090 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
1091 pointerEvent->SetPointerId(0);
1092 pointerEvent->AddPointerItem(item);
1093 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1094 InputManager::GetInstance()->RemoveMonitor(monitorId);
1095 }
1096
1097 /**
1098 * @tc.name: InputManager_InjectTouchpadEvent_001
1099 * @tc.desc: Injection interface detection
1100 * @tc.type: FUNC
1101 * @tc.require:
1102 */
1103 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_001, TestSize.Level1)
1104 {
1105 CALL_TEST_DEBUG;
__anonc68ff6472202(std::shared_ptr<PointerEvent> event) 1106 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1107 MMI_HILOGI("Add monitor InjectTouchpadEvent_001");
1108 };
1109 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1110 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1111
1112 auto pointerEvent = PointerEvent::Create();
1113 ASSERT_NE(pointerEvent, nullptr);
1114 PointerEvent::PointerItem item;
1115 item.SetPointerId(0);
1116 item.SetDisplayX(200);
1117 item.SetDisplayY(200);
1118 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1119 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1120 pointerEvent->SetPointerId(0);
1121 pointerEvent->AddPointerItem(item);
1122 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1123 InputManager::GetInstance()->RemoveMonitor(monitorId);
1124 }
1125
1126 /**
1127 * @tc.name: InputManager_InjectTouchpadEvent_002
1128 * @tc.desc: Injection interface detection
1129 * @tc.type: FUNC
1130 * @tc.require:
1131 */
1132 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_002, TestSize.Level1)
1133 {
1134 CALL_TEST_DEBUG;
__anonc68ff6472302(std::shared_ptr<PointerEvent> event) 1135 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1136 MMI_HILOGI("Add monitor InjectTouchpadEvent_002");
1137 };
1138 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1139 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1140
1141 auto pointerEvent = PointerEvent::Create();
1142 ASSERT_NE(pointerEvent, nullptr);
1143 PointerEvent::PointerItem item;
1144 item.SetPointerId(0);
1145 item.SetDisplayX(200);
1146 item.SetDisplayY(200);
1147 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_SWIPE_UPDATE);
1148 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1149 pointerEvent->SetPointerId(0);
1150 pointerEvent->AddPointerItem(item);
1151 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1152 InputManager::GetInstance()->RemoveMonitor(monitorId);
1153 }
1154
1155 /**
1156 * @tc.name: InputManager_InjectTouchpadEvent_003
1157 * @tc.desc: Injection interface detection
1158 * @tc.type: FUNC
1159 * @tc.require:
1160 */
1161 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_003, TestSize.Level1)
1162 {
1163 CALL_TEST_DEBUG;
__anonc68ff6472402(std::shared_ptr<PointerEvent> event) 1164 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1165 MMI_HILOGI("Add monitor InjectTouchpadEvent_003");
1166 };
1167 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1168 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1169
1170 auto pointerEvent = PointerEvent::Create();
1171 ASSERT_NE(pointerEvent, nullptr);
1172
1173 PointerEvent::PointerItem item;
1174 item.SetPointerId(0);
1175 item.SetDisplayY(200);
1176 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1177 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1178 pointerEvent->SetPointerId(0);
1179 pointerEvent->AddPointerItem(item);
1180 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1181 InputManager::GetInstance()->RemoveMonitor(monitorId);
1182 }
1183
1184 /**
1185 * @tc.name: InputManager_InjectTouchpadEvent_004
1186 * @tc.desc: Injection interface detection
1187 * @tc.type: FUNC
1188 * @tc.require:
1189 */
1190 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_004, TestSize.Level1)
1191 {
1192 CALL_TEST_DEBUG;
__anonc68ff6472502(std::shared_ptr<PointerEvent> event) 1193 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1194 MMI_HILOGI("Add monitor InjectTouchpadEvent_004");
1195 };
1196 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1197 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1198
1199 auto pointerEvent = PointerEvent::Create();
1200 ASSERT_NE(pointerEvent, nullptr);
1201
1202 PointerEvent::PointerItem item;
1203 item.SetPointerId(0);
1204 item.SetDisplayX(200);
1205 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1206 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1207 pointerEvent->SetPointerId(0);
1208 pointerEvent->AddPointerItem(item);
1209 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1210 InputManager::GetInstance()->RemoveMonitor(monitorId);
1211 }
1212
1213 /**
1214 * @tc.name: InputManager_InjectTouchpadEvent_005
1215 * @tc.desc: Injection interface detection
1216 * @tc.type: FUNC
1217 * @tc.require:AR000GJG6G
1218 */
1219 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_005, TestSize.Level1)
1220 {
1221 CALL_TEST_DEBUG;
__anonc68ff6472602(std::shared_ptr<PointerEvent> event) 1222 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1223 MMI_HILOGI("Add monitor InjectTouchpadEvent_005");
1224 };
1225 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1226 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1227
1228 auto pointerEvent = PointerEvent::Create();
1229 ASSERT_NE(pointerEvent, nullptr);
1230
1231 PointerEvent::PointerItem item;
1232 item.SetPointerId(0);
1233 item.SetDisplayX(200);
1234 item.SetDisplayY(200);
1235 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1236 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1237 pointerEvent->AddPointerItem(item);
1238 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1239 InputManager::GetInstance()->RemoveMonitor(monitorId);
1240 }
1241
1242 /**
1243 * @tc.name: InputManager_InjectTouchpadEvent_006
1244 * @tc.desc: Injection interface detection
1245 * @tc.type: FUNC
1246 * @tc.require:AR000GJG6G
1247 */
1248 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchpadEvent_006, TestSize.Level1)
1249 {
1250 CALL_TEST_DEBUG;
__anonc68ff6472702(std::shared_ptr<PointerEvent> event) 1251 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1252 MMI_HILOGI("Add monitor InjectTouchpadEvent_006");
1253 };
1254 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1255 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1256
1257 auto pointerEvent = PointerEvent::Create();
1258 ASSERT_NE(pointerEvent, nullptr);
1259
1260 PointerEvent::PointerItem item;
1261 item.SetPointerId(0);
1262 item.SetDisplayX(200);
1263 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_SWIPE_UPDATE);
1264 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1265 pointerEvent->SetPointerId(0);
1266 pointerEvent->AddPointerItem(item);
1267 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1268 InputManager::GetInstance()->RemoveMonitor(monitorId);
1269 }
1270
1271 /**
1272 * @tc.name: InputManager_InjectTouchscreenEvent_001
1273 * @tc.desc: Injection interface detection
1274 * @tc.type: FUNC
1275 * @tc.require:
1276 */
1277 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_001, TestSize.Level1)
1278 {
1279 CALL_TEST_DEBUG;
__anonc68ff6472802(std::shared_ptr<PointerEvent> event) 1280 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1281 MMI_HILOGI("Add monitor InjectTouchscreenEvent_001");
1282 };
1283 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1284 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1285
1286 auto pointerEvent = PointerEvent::Create();
1287 ASSERT_NE(pointerEvent, nullptr);
1288
1289 PointerEvent::PointerItem item;
1290 item.SetPointerId(0);
1291 item.SetDisplayX(200);
1292 item.SetDisplayY(200);
1293 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1294 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1295 pointerEvent->SetPointerId(0);
1296 pointerEvent->AddPointerItem(item);
1297 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1298 InputManager::GetInstance()->RemoveMonitor(monitorId);
1299 }
1300
1301 /**
1302 * @tc.name: InputManager_InjectTouchscreenEvent_002
1303 * @tc.desc: Injection interface detection
1304 * @tc.type: FUNC
1305 * @tc.require:
1306 */
1307 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_002, TestSize.Level1)
1308 {
1309 CALL_TEST_DEBUG;
__anonc68ff6472902(std::shared_ptr<PointerEvent> event) 1310 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1311 MMI_HILOGI("Add monitor InjectTouchscreenEvent_002");
1312 };
1313 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1314 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1315
1316 auto pointerEvent = PointerEvent::Create();
1317 ASSERT_NE(pointerEvent, nullptr);
1318
1319 PointerEvent::PointerItem item;
1320 item.SetPointerId(0);
1321 item.SetDisplayX(200);
1322 item.SetDisplayY(200);
1323 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1324 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1325 pointerEvent->SetPointerId(0);
1326 pointerEvent->AddPointerItem(item);
1327 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1328 InputManager::GetInstance()->RemoveMonitor(monitorId);
1329 }
1330
1331 /**
1332 * @tc.name: InputManager_InjectTouchscreenEvent_003
1333 * @tc.desc: Injection interface detection
1334 * @tc.type: FUNC
1335 * @tc.require:
1336 */
1337 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_003, TestSize.Level1)
1338 {
1339 CALL_TEST_DEBUG;
__anonc68ff6472a02(std::shared_ptr<PointerEvent> event) 1340 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1341 MMI_HILOGI("Add monitor InjectTouchscreenEvent_003");
1342 };
1343 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1344 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1345
1346 auto pointerEvent = PointerEvent::Create();
1347 ASSERT_NE(pointerEvent, nullptr);
1348
1349 PointerEvent::PointerItem item;
1350 item.SetPointerId(0);
1351 item.SetDisplayX(200);
1352 item.SetDisplayY(200);
1353 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_ENTER);
1354 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1355 pointerEvent->SetPointerId(0);
1356 pointerEvent->AddPointerItem(item);
1357 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1358 InputManager::GetInstance()->RemoveMonitor(monitorId);
1359 }
1360
1361 /**
1362 * @tc.name: InputManager_InjectTouchscreenEvent_004
1363 * @tc.desc: Injection interface detection
1364 * @tc.type: FUNC
1365 * @tc.require:
1366 */
1367 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_004, TestSize.Level1)
1368 {
1369 CALL_TEST_DEBUG;
__anonc68ff6472b02(std::shared_ptr<PointerEvent> event) 1370 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1371 MMI_HILOGI("Add monitor InjectTouchscreenEvent_004");
1372 };
1373 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1374 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1375
1376 auto pointerEvent = PointerEvent::Create();
1377 ASSERT_NE(pointerEvent, nullptr);
1378
1379 PointerEvent::PointerItem item;
1380 item.SetPointerId(0);
1381 item.SetDisplayX(200);
1382 item.SetDisplayY(200);
1383 item.SetDownTime(500);
1384 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1385 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1386 pointerEvent->SetPointerId(0);
1387 pointerEvent->AddPointerItem(item);
1388 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1389 InputManager::GetInstance()->RemoveMonitor(monitorId);
1390 }
1391
1392 /**
1393 * @tc.name: InputManager_InjectTouchscreenEvent_005
1394 * @tc.desc: Injection interface detection
1395 * @tc.type: FUNC
1396 * @tc.require:
1397 */
1398 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_005, TestSize.Level1)
1399 {
1400 CALL_TEST_DEBUG;
__anonc68ff6472c02(std::shared_ptr<PointerEvent> event) 1401 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1402 MMI_HILOGI("Add monitor InjectTouchscreenEvent_005");
1403 };
1404 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1405 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1406
1407 auto pointerEvent = PointerEvent::Create();
1408 ASSERT_NE(pointerEvent, nullptr);
1409
1410 PointerEvent::PointerItem item;
1411 item.SetPointerId(0);
1412 item.SetDisplayY(200);
1413 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_TRIPTAP);
1414 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1415 pointerEvent->SetPointerId(0);
1416 pointerEvent->AddPointerItem(item);
1417 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1418 InputManager::GetInstance()->RemoveMonitor(monitorId);
1419 }
1420
1421 /**
1422 * @tc.name: InputManager_InjectTouchscreenEvent_006
1423 * @tc.desc: Injection interface detection
1424 * @tc.type: FUNC
1425 * @tc.require:
1426 */
1427 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_006, TestSize.Level1)
1428 {
1429 CALL_TEST_DEBUG;
__anonc68ff6472d02(std::shared_ptr<PointerEvent> event) 1430 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1431 MMI_HILOGI("Add monitor InjectTouchscreenEvent_006");
1432 };
1433 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1434 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1435
1436 auto pointerEvent = PointerEvent::Create();
1437 ASSERT_NE(pointerEvent, nullptr);
1438
1439 PointerEvent::PointerItem item;
1440 item.SetPointerId(0);
1441 item.SetDisplayX(200);
1442 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1443 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1444 pointerEvent->SetPointerId(0);
1445 pointerEvent->AddPointerItem(item);
1446 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1447 InputManager::GetInstance()->RemoveMonitor(monitorId);
1448 }
1449
1450 /**
1451 * @tc.name: InputManager_InjectTouchscreenEvent_007
1452 * @tc.desc: Injection interface detection
1453 * @tc.type: FUNC
1454 * @tc.require:
1455 */
1456 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_007, TestSize.Level1)
1457 {
1458 CALL_TEST_DEBUG;
__anonc68ff6472e02(std::shared_ptr<PointerEvent> event) 1459 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1460 MMI_HILOGI("Add monitor InjectTouchscreenEvent_007");
1461 };
1462 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1463 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1464
1465 auto pointerEvent = PointerEvent::Create();
1466 ASSERT_NE(pointerEvent, nullptr);
1467
1468 PointerEvent::PointerItem item;
1469 item.SetPointerId(0);
1470 item.SetDisplayY(200);
1471 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1472 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1473 pointerEvent->SetPointerId(0);
1474 pointerEvent->AddPointerItem(item);
1475 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1476 InputManager::GetInstance()->RemoveMonitor(monitorId);
1477 }
1478
1479 /**
1480 * @tc.name: InputManager_InjectTouchscreenEvent_008
1481 * @tc.desc: Injection interface detection
1482 * @tc.type: FUNC
1483 * @tc.require:
1484 */
1485 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_008, TestSize.Level1)
1486 {
1487 CALL_TEST_DEBUG;
__anonc68ff6472f02(std::shared_ptr<PointerEvent> event) 1488 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1489 MMI_HILOGI("Add monitor InjectTouchscreenEvent_008");
1490 };
1491 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1492 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1493
1494 auto pointerEvent = PointerEvent::Create();
1495 ASSERT_NE(pointerEvent, nullptr);
1496
1497 PointerEvent::PointerItem item;
1498 item.SetPointerId(0);
1499 item.SetDisplayX(200);
1500 item.SetDisplayY(200);
1501 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_UPDATE);
1502 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1503 pointerEvent->AddPointerItem(item);
1504 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1505 InputManager::GetInstance()->RemoveMonitor(monitorId);
1506 }
1507
1508 /**
1509 * @tc.name: InputManager_InjectTouchscreenEvent_009
1510 * @tc.desc: Injection interface detection
1511 * @tc.type: FUNC
1512 * @tc.require:
1513 */
1514 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_009, TestSize.Level1)
1515 {
1516 CALL_TEST_DEBUG;
__anonc68ff6473002(std::shared_ptr<PointerEvent> event) 1517 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1518 MMI_HILOGI("Add monitor InjectTouchscreenEvent_009");
1519 };
1520 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1521 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1522
1523 auto pointerEvent = PointerEvent::Create();
1524 ASSERT_NE(pointerEvent, nullptr);
1525
1526 PointerEvent::PointerItem item;
1527 item.SetPointerId(0);
1528 item.SetDisplayX(200);
1529 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_MOVE);
1530 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1531 pointerEvent->SetPointerId(0);
1532 pointerEvent->AddPointerItem(item);
1533 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1534 InputManager::GetInstance()->RemoveMonitor(monitorId);
1535 }
1536
1537 /**
1538 * @tc.name: InputManager_InjectTouchscreenEvent_010
1539 * @tc.desc: Injection interface detection
1540 * @tc.type: FUNC
1541 * @tc.require:
1542 */
1543 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_010, TestSize.Level1)
1544 {
1545 CALL_TEST_DEBUG;
__anonc68ff6473102(std::shared_ptr<PointerEvent> event) 1546 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1547 MMI_HILOGI("Add monitor InjectTouchscreenEvent_010");
1548 };
1549 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1550 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1551
1552 auto pointerEvent = PointerEvent::Create();
1553 ASSERT_NE(pointerEvent, nullptr);
1554
1555 PointerEvent::PointerItem item;
1556 item.SetPointerId(0);
1557 item.SetDisplayY(200);
1558 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_MOVE);
1559 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1560 pointerEvent->SetPointerId(0);
1561 pointerEvent->AddPointerItem(item);
1562 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1563 InputManager::GetInstance()->RemoveMonitor(monitorId);
1564 }
1565
1566 /**
1567 * @tc.name: InputManager_InjectTouchscreenEvent_011
1568 * @tc.desc: Injection interface detection
1569 * @tc.type: FUNC
1570 * @tc.require:
1571 */
1572 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_011, TestSize.Level1)
1573 {
1574 CALL_TEST_DEBUG;
__anonc68ff6473202(std::shared_ptr<PointerEvent> event) 1575 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1576 MMI_HILOGI("Add monitor InjectTouchscreenEvent_011");
1577 };
1578 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1579 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1580
1581 auto pointerEvent = PointerEvent::Create();
1582 ASSERT_NE(pointerEvent, nullptr);
1583
1584 PointerEvent::PointerItem item;
1585 item.SetDisplayX(200);
1586 item.SetDisplayY(200);
1587 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_MOVE);
1588 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1589 pointerEvent->AddPointerItem(item);
1590 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1591 InputManager::GetInstance()->RemoveMonitor(monitorId);
1592 }
1593
1594 /**
1595 * @tc.name: InputManager_InjectTouchscreenEvent_012
1596 * @tc.desc: Injection interface detection
1597 * @tc.type: FUNC
1598 * @tc.require:
1599 */
1600 HWTEST_F(InputManagerInjectTest, InputManager_InjectTouchscreenEvent_012, TestSize.Level1)
1601 {
1602 CALL_TEST_DEBUG;
__anonc68ff6473302(std::shared_ptr<PointerEvent> event) 1603 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1604 MMI_HILOGI("Add monitor InjectTouchscreenEvent_012");
1605 };
1606 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1607 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1608
1609 auto pointerEvent = PointerEvent::Create();
1610 ASSERT_NE(pointerEvent, nullptr);
1611
1612 PointerEvent::PointerItem item;
1613 item.SetPointerId(0);
1614 item.SetDisplayX(200);
1615 item.SetDisplayY(200);
1616 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1617 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1618 pointerEvent->SetPointerId(0);
1619 InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
1620 InputManager::GetInstance()->RemoveMonitor(monitorId);
1621 }
1622
1623 /**
1624 * @tc.name: InputManagerTest_SimulateInputEventZorder_002
1625 * @tc.desc: Simulate input evnet with zOrder.
1626 * @tc.type: FUNC
1627 * @tc.require:
1628 */
1629 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_002, TestSize.Level1)
1630 {
1631 CALL_TEST_DEBUG;
__anonc68ff6473402(std::shared_ptr<PointerEvent> event) 1632 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1633 MMI_HILOGI("Add monitor SimulateInputEventZorder_002");
1634 };
1635 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1636 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1637
1638 auto pointerEvent = PointerEvent::Create();
1639 ASSERT_NE(pointerEvent, nullptr);
1640
1641 PointerEvent::PointerItem item;
1642 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1643 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1644 item.SetPressure(POINTER_ITEM_PRESSURE);
1645 item.SetPointerId(0);
1646 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1647 pointerEvent->SetPointerId(0);
1648 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1649 pointerEvent->AddPointerItem(item);
1650 pointerEvent->SetZOrder(10.0);
1651
1652 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0);
1653 InputManager::GetInstance()->RemoveMonitor(monitorId);
1654 }
1655
1656 /**
1657 * @tc.name: InputManagerTest_SimulateInputEventZorder_003
1658 * @tc.desc: Simulate input evnet with zOrder.
1659 * @tc.type: FUNC
1660 * @tc.require:
1661 */
1662 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_003, TestSize.Level1)
1663 {
1664 CALL_TEST_DEBUG;
__anonc68ff6473502(std::shared_ptr<PointerEvent> event) 1665 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1666 MMI_HILOGI("Add monitor SimulateInputEventZorder_003");
1667 };
1668 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1669 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1670
1671 auto pointerEvent = PointerEvent::Create();
1672 ASSERT_NE(pointerEvent, nullptr);
1673
1674 PointerEvent::PointerItem item;
1675 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1676 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1677 item.SetPressure(POINTER_ITEM_PRESSURE);
1678 item.SetPointerId(0);
1679 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1680 pointerEvent->SetPointerId(0);
1681 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1682 pointerEvent->AddPointerItem(item);
1683 pointerEvent->SetZOrder(-1000.0);
1684
1685 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, -1000.0);
1686 InputManager::GetInstance()->RemoveMonitor(monitorId);
1687 }
1688
1689 /**
1690 * @tc.name: InputManagerTest_SimulateInputEventZorder_004
1691 * @tc.desc: Simulate input evnet with zOrder.
1692 * @tc.type: FUNC
1693 * @tc.require:
1694 */
1695 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_004, TestSize.Level1)
1696 {
1697 CALL_TEST_DEBUG;
__anonc68ff6473602(std::shared_ptr<PointerEvent> event) 1698 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1699 MMI_HILOGI("Add monitor SimulateInputEventZorder_004");
1700 };
1701 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1702 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1703
1704 auto pointerEvent = PointerEvent::Create();
1705 ASSERT_NE(pointerEvent, nullptr);
1706
1707 PointerEvent::PointerItem item;
1708 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1709 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1710 item.SetPressure(POINTER_ITEM_PRESSURE);
1711 item.SetPointerId(0);
1712 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1713 pointerEvent->SetPointerId(0);
1714 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1715 pointerEvent->AddPointerItem(item);
1716 pointerEvent->SetZOrder(10.0);
1717
1718 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0);
1719 InputManager::GetInstance()->RemoveMonitor(monitorId);
1720 }
1721
1722 /**
1723 * @tc.name: InputManagerTest_SimulateInputEventZorder_005
1724 * @tc.desc: Simulate input evnet with zOrder.
1725 * @tc.type: FUNC
1726 * @tc.require:
1727 */
1728 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_005, TestSize.Level1)
1729 {
1730 CALL_TEST_DEBUG;
__anonc68ff6473702(std::shared_ptr<PointerEvent> event) 1731 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1732 MMI_HILOGI("Add monitor SimulateInputEventZorder_005");
1733 };
1734 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1735 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1736
1737 auto pointerEvent = PointerEvent::Create();
1738 ASSERT_NE(pointerEvent, nullptr);
1739
1740 PointerEvent::PointerItem item;
1741 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1742 item.SetPressure(POINTER_ITEM_PRESSURE);
1743 item.SetPointerId(0);
1744 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1745 pointerEvent->SetPointerId(0);
1746 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
1747 pointerEvent->AddPointerItem(item);
1748 pointerEvent->SetZOrder(10.0);
1749
1750 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0);
1751 InputManager::GetInstance()->RemoveMonitor(monitorId);
1752 }
1753
1754 /**
1755 * @tc.name: InputManagerTest_SimulateInputEventZorder_006
1756 * @tc.desc: Simulate input evnet with zOrder.
1757 * @tc.type: FUNC
1758 * @tc.require:
1759 */
1760 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_006, TestSize.Level1)
1761 {
1762 CALL_TEST_DEBUG;
__anonc68ff6473802(std::shared_ptr<PointerEvent> event) 1763 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1764 MMI_HILOGI("Add monitor SimulateInputEventZorder_006");
1765 };
1766 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1767 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1768
1769 auto pointerEvent = PointerEvent::Create();
1770 ASSERT_NE(pointerEvent, nullptr);
1771
1772 PointerEvent::PointerItem item;
1773 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1774 item.SetPressure(POINTER_ITEM_PRESSURE);
1775 item.SetPointerId(0);
1776 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1777 pointerEvent->SetPointerId(0);
1778 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1779 pointerEvent->AddPointerItem(item);
1780 pointerEvent->SetZOrder(10.0);
1781
1782 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0);
1783 InputManager::GetInstance()->RemoveMonitor(monitorId);
1784 }
1785
1786 /**
1787 * @tc.name: InputManagerTest_SimulateInputEventZorder_007
1788 * @tc.desc: Simulate input evnet with zOrder.
1789 * @tc.type: FUNC
1790 * @tc.require:
1791 */
1792 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_007, TestSize.Level1)
1793 {
1794 CALL_TEST_DEBUG;
__anonc68ff6473902(std::shared_ptr<PointerEvent> event) 1795 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1796 MMI_HILOGI("Add monitor SimulateInputEventZorder_007");
1797 };
1798 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1799 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1800
1801 auto pointerEvent = PointerEvent::Create();
1802 ASSERT_NE(pointerEvent, nullptr);
1803
1804 PointerEvent::PointerItem item;
1805 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1806 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1807 item.SetPointerId(0);
1808 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1809 pointerEvent->SetPointerId(0);
1810 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1811 pointerEvent->AddPointerItem(item);
1812 pointerEvent->SetZOrder(10.0);
1813
1814 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0);
1815 InputManager::GetInstance()->RemoveMonitor(monitorId);
1816 }
1817
1818 /**
1819 * @tc.name: InputManagerTest_SimulateInputEventZorder_008
1820 * @tc.desc: Simulate input evnet with zOrder.
1821 * @tc.type: FUNC
1822 * @tc.require:
1823 */
1824 HWTEST_F(InputManagerInjectTest, InputManagerTest_SimulateInputEventZorder_008, TestSize.Level1)
1825 {
1826 CALL_TEST_DEBUG;
__anonc68ff6473a02(std::shared_ptr<PointerEvent> event) 1827 auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) {
1828 MMI_HILOGI("Add monitor SimulateInputEventZorder_008");
1829 };
1830 int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
1831 ASSERT_NE(monitorId, ERROR_UNSUPPORT);
1832
1833 auto pointerEvent = PointerEvent::Create();
1834 ASSERT_NE(pointerEvent, nullptr);
1835
1836 PointerEvent::PointerItem item;
1837 item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
1838 item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
1839 item.SetPointerId(0);
1840 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1841 pointerEvent->SetPointerId(0);
1842 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
1843 pointerEvent->AddPointerItem(item);
1844 pointerEvent->SetZOrder(20.0);
1845 InputManager::GetInstance()->SimulateInputEvent(pointerEvent, 10.0);
1846 InputManager::GetInstance()->RemoveMonitor(monitorId);
1847 }
1848 } // namespace MMI
1849 } // namespace OHOS
1850