• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "define_multimodal.h"
17 #include "event_util_test.h"
18 #include "input_manager_util.h"
19 #include "pixel_map.h"
20 
21 namespace OHOS {
22 namespace MMI {
23 namespace {
24 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, MMI_LOG_DOMAIN, "InputManagerPointerTest"};
25 constexpr int32_t TIME_WAIT_FOR_OP = 100;
26 constexpr int32_t SIZE_TYPE_CASE = 3;
27 constexpr int32_t POINTER_ITEM_DISPLAY_X_ONE = 222;
28 constexpr int32_t POINTER_ITEM_DISPLAY_X_TWO = 444;
29 constexpr int32_t POINTER_ITEM_DISPLAY_X_THREE = 555;
30 constexpr int32_t POINTER_ITEM_DISPLAY_X_FOUR = 666;
31 constexpr int32_t POINTER_ITEM_DISPLAY_X_FIVE = 923;
32 constexpr int32_t POINTER_ITEM_DISPLAY_Y_ONE = 223;
33 constexpr int32_t POINTER_ITEM_DISPLAY_Y_TWO = 333;
34 constexpr int32_t POINTER_ITEM_DISPLAY_Y_THREE = 555;
35 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FOUR = 777;
36 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FIVE = 793;
37 constexpr int32_t MOVE_MOUSE_OFFSET_ONE = -2000;
38 constexpr int32_t MOVE_MOUSE_OFFSET_TWO = 50;
39 constexpr int32_t MOVE_MOUSE_OFFSET_THREE = 100;
40 constexpr int32_t MOVE_MOUSE_OFFSET_FOUR = 150;
41 constexpr int32_t MOVE_MOUSE_OFFSET_FIVE = 300;
42 constexpr int32_t MOVE_MOUSE_OFFSET_SIX = 350;
43 constexpr int32_t MOVE_MOUSE_OFFSET_SEVEN = 400;
44 constexpr int32_t MOVE_MOUSE_OFFSET_EIGHT = 450;
45 constexpr int32_t MOVE_MOUSE_OFFSET_NINE = 500;
46 constexpr int32_t MOVE_MOUSE_OFFSET_TEN = 550;
47 constexpr int32_t MOVE_MOUSE_OFFSET_ELEVEN = 700;
48 constexpr int32_t MOVE_MOUSE_OFFSET_TWELVE = 1000;
49 constexpr int32_t MOVE_MOUSE_OFFSET_THIRTEEN = -1000;
50 constexpr int32_t POINTER_SPEED_ONE = 4;
51 constexpr int32_t POINTER_SPEED_TWO = 5;
52 constexpr int32_t POINTER_SPEED_THREE = 9;
53 constexpr int32_t POINTER_SPEED_FOUR = 11;
54 constexpr int32_t POINTER_SPEED_FIVE = 20;
55 constexpr int32_t RIGHT_CLICK_TYPE = 2;
56 constexpr int32_t INVAID_VALUE = -1;
57 constexpr int32_t MOUSE_ICON_HOT_SPOT = 20;
58 constexpr int64_t POINTER_ITEM_DOWNTIME_ONE = 9999;
59 constexpr int64_t POINTER_ITEM_DOWNTIME_TWO = 10001;
60 constexpr int64_t POINTER_ITEM_DOWNTIME_THREE = 10003;
61 constexpr int64_t POINTER_ITEM_DOWNTIME_FOUR = 10009;
62 constexpr int64_t POINTER_ITEM_DOWNTIME_FIVE = 10010;
63 }  // namespace
64 
65 class InputManagerPointerTest : public testing::Test {
66 public:
67     void SetUp();
68     void TearDown();
69     static void SetUpTestCase();
70     std::string GetEventDump();
71 };
72 
SetUpTestCase()73 void InputManagerPointerTest::SetUpTestCase()
74 {
75     ASSERT_TRUE(TestUtil->Init());
76 }
77 
SetUp()78 void InputManagerPointerTest::SetUp()
79 {
80     TestUtil->SetRecvFlag(RECV_FLAG::RECV_FOCUS);
81 }
82 
TearDown()83 void InputManagerPointerTest::TearDown()
84 {
85     TestUtil->AddEventDump("");
86     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
87 }
88 
GetEventDump()89 std::string InputManagerPointerTest::GetEventDump()
90 {
91     return TestUtil->GetEventDump();
92 }
93 
94 /**
95  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_001
96  * @tc.desc: Verify that the mouse moves away from the window
97  * @tc.type: FUNC
98  * @tc.require: I5HMF3 I5HMEF
99  */
100 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_001, TestSize.Level1)
101 {
102     CALL_TEST_DEBUG;
103     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupPointerEvent014()};
104     ASSERT_NE(pointerEvent, nullptr);
105 #ifdef OHOS_BUILD_ENABLE_POINTER
106     SimulateInputEventUtilTest(pointerEvent);
107 #endif  // OHOS_BUILD_ENABLE_POINTER
108 }
109 
110 /**
111  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_002
112  * @tc.desc: Verify return mouse away from the window
113  * @tc.type: FUNC
114  * @tc.require: I5HMF3 I5HMEF
115  */
116 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_002, TestSize.Level1)
117 {
118     CALL_TEST_DEBUG;
119     std::shared_ptr<KeyEvent> keyEvent{InputManagerUtil::SetupKeyEvent002()};
120     ASSERT_NE(keyEvent, nullptr);
121 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
122     SimulateInputEventUtilTest(keyEvent);
123 #endif  // OHOS_BUILD_ENABLE_KEYBOARD
124 }
125 
126 /**
127  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_003
128  * @tc.desc: Verify that the home button and mouse leave the window
129  * @tc.type: FUNC
130  * @tc.require: I5HMF3 I5HMEF
131  */
132 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_003, TestSize.Level1)
133 {
134     CALL_TEST_DEBUG;
135     std::shared_ptr<KeyEvent> keyEvent{InputManagerUtil::SetupKeyEvent003()};
136     ASSERT_NE(keyEvent, nullptr);
137 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
138     SimulateInputEventUtilTest(keyEvent);
139 #endif  // OHOS_BUILD_ENABLE_KEYBOARD
140 }
141 
142 /**
143  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_004
144  * @tc.desc: Verify that the mouse moves to the navigation bar to leave the window
145  * @tc.type: FUNC
146  * @tc.require: I5HMF3 I5HMEF
147  */
148 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_004, TestSize.Level1)
149 {
150     CALL_TEST_DEBUG;
151     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupPointerEvent015()};
152     ASSERT_NE(pointerEvent, nullptr);
153 #ifdef OHOS_BUILD_ENABLE_POINTER
154     SimulateInputEventUtilTest(pointerEvent);
155 #endif  // OHOS_BUILD_ENABLE_POINTER
156 }
157 
158 /**
159  * @tc.name: InputManagerPointerTest_AddMonitor_001
160  * @tc.desc: Verify pointerevent monitor
161  * @tc.type: FUNC
162  * @tc.require:
163  */
164 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMonitor_001, TestSize.Level1)
165 {
166     CALL_TEST_DEBUG;
__anon9f51aff20202(std::shared_ptr<PointerEvent> event) 167     auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) { MMI_HILOGD("Add monitor success"); };
168     int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
169 #if (defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)) && defined(OHOS_BUILD_ENABLE_MONITOR)
170     ASSERT_NE(monitorId, INVALID_HANDLER_ID);
171 #else
172     ASSERT_EQ(monitorId, ERROR_UNSUPPORT);
173 #endif  // OHOS_BUILD_ENABLE_MONITOR ||  OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
174     InputManager::GetInstance()->RemoveMonitor(monitorId);
175 }
176 
177 /**
178  * @tc.name: InputManagerPointerTest_AddMonitor_002
179  * @tc.desc: Verify keyevent monitor
180  * @tc.type: FUNC
181  * @tc.require:
182  */
183 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMonitor_002, TestSize.Level1)
184 {
185     CALL_TEST_DEBUG;
__anon9f51aff20302(std::shared_ptr<KeyEvent> event) 186     auto keyEventFun = [](std::shared_ptr<KeyEvent> event) { MMI_HILOGD("Add monitor success"); };
187     int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
188 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_MONITOR)
189     ASSERT_NE(monitorId, INVALID_HANDLER_ID);
190 #else
191     ASSERT_EQ(monitorId, ERROR_UNSUPPORT);
192 #endif  // OHOS_BUILD_ENABLE_KEYBOARD || OHOS_BUILD_ENABLE_MONITOR
193     InputManager::GetInstance()->RemoveMonitor(monitorId);
194 }
195 
196 /**
197  * @tc.name: InputManagerPointerTest_OnAddScreenMonitor_001
198  * @tc.desc: Verify touchscreen down event monitor
199  * @tc.type: FUNC
200  * @tc.require:
201  */
202 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddScreenMonitor_001, TestSize.Level1)
203 {
204     CALL_TEST_DEBUG;
205     auto pointerEvent = InputManagerUtil::SetupPointerEvent001();
206     ASSERT_NE(pointerEvent, nullptr);
207 
208     auto callbackPtr = GetPtr<InputEventCallback>();
209     ASSERT_TRUE(callbackPtr != nullptr);
210     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
211 #ifdef OHOS_BUILD_ENABLE_MONITOR
212     EXPECT_TRUE(IsValidHandlerId(monitorId));
213 #else
214     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
215 #endif  // OHOS_BUILD_ENABLE_MONITOR
216     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
217 
218     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
219     InputManagerUtil::TestRemoveMonitor(monitorId);
220 }
221 
222 /**
223  * @tc.name: InputManagerPointerTest_OnAddScreenMonitor_002
224  * @tc.desc: Verify touchscreen move event multiple monitor
225  * @tc.type: FUNC
226  * @tc.require:
227  */
228 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddScreenMonitor_002, TestSize.Level1)
229 {
230     CALL_TEST_DEBUG;
231     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
232     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
233     std::vector<int32_t> ids(N_TEST_CASES);
234     std::vector<std::shared_ptr<InputEventCallback>> cbs(N_TEST_CASES);
235 
236     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; i++) {
237         cbs[i] = GetPtr<InputEventCallback>();
238         ASSERT_TRUE(cbs[i] != nullptr);
239         ids[i] = InputManagerUtil::TestAddMonitor(cbs[i]);
240 #ifdef OHOS_BUILD_ENABLE_MONITOR
241         EXPECT_TRUE(IsValidHandlerId(ids[i]));
242 #else
243         EXPECT_EQ(ids[i], ERROR_UNSUPPORT);
244 #endif  // OHOS_BUILD_ENABLE_MONITOR
245         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
246     }
247 
248     auto pointerEvent = InputManagerUtil::SetupPointerEvent002();
249     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
250 
251     for (const auto &id : ids) {
252         std::string sPointerEs = GetEventDump();
253         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
254 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
255         ASSERT_TRUE(!sPointerEs.empty());
256 #else
257         ASSERT_TRUE(sPointerEs.empty());
258 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
259         if (IsValidHandlerId(id)) {
260             InputManagerUtil::TestRemoveMonitor(id);
261         }
262         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
263     }
264 
265     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; i++) {
266         InputManagerUtil::TestRemoveMonitor(ids[i]);
267     }
268 }
269 
270 /**
271  * @tc.name: InputManagerPointerTest_OnAddScreenMonitor_003
272  * @tc.desc: Verify touchscreen up event monitor
273  * @tc.type: FUNC
274  * @tc.require:
275  */
276 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddScreenMonitor_003, TestSize.Level1)
277 {
278     CALL_TEST_DEBUG;
279     auto pointerEvent = InputManagerUtil::SetupPointerEvent003();
280     ASSERT_NE(pointerEvent, nullptr);
281 
282     auto callbackPtr = GetPtr<InputEventCallback>();
283     ASSERT_TRUE(callbackPtr != nullptr);
284     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
285 #ifdef OHOS_BUILD_ENABLE_MONITOR
286     EXPECT_TRUE(IsValidHandlerId(monitorId));
287 #else
288     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
289 #endif  // OHOS_BUILD_ENABLE_MONITOR
290     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
291 
292 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
293     TestSimulateInputEvent(pointerEvent);
294 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
295 
296     if (IsValidHandlerId(monitorId)) {
297         InputManagerUtil::TestRemoveMonitor(monitorId);
298         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
299     }
300     InputManagerUtil::TestRemoveMonitor(monitorId);
301 }
302 
303 /**
304  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_001
305  * @tc.desc: Verify touchpad down event monitor
306  * @tc.type: FUNC
307  * @tc.require:
308  */
309 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_001, TestSize.Level1)
310 {
311     CALL_TEST_DEBUG;
312     auto pointerEvent = PointerEvent::Create();
313     ASSERT_NE(pointerEvent, nullptr);
314     PointerEvent::PointerItem item;
315     item.SetDownTime(POINTER_ITEM_DOWNTIME_THREE);
316     item.SetPressed(true);
317     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
318     item.SetDeviceId(1);
319     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
320     item.SetPointerId(0);
321     pointerEvent->AddPointerItem(item);
322     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
323     pointerEvent->SetPointerId(0);
324     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
325 
326     auto callbackPtr = GetPtr<InputEventCallback>();
327     ASSERT_TRUE(callbackPtr != nullptr);
328     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
329 #ifdef OHOS_BUILD_ENABLE_MONITOR
330     EXPECT_TRUE(IsValidHandlerId(monitorId));
331 #else
332     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
333 #endif  // OHOS_BUILD_ENABLE_MONITOR
334     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
335 
336     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
337     InputManagerUtil::TestRemoveMonitor(monitorId);
338 }
339 
340 /**
341  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_002
342  * @tc.desc: Verify touchpad move event monitor
343  * @tc.type: FUNC
344  * @tc.require:
345  */
346 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_002, TestSize.Level1)
347 {
348     CALL_TEST_DEBUG;
349     auto pointerEvent = PointerEvent::Create();
350     ASSERT_NE(pointerEvent, nullptr);
351     PointerEvent::PointerItem item;
352     item.SetPointerId(0);
353     item.SetDownTime(POINTER_ITEM_DOWNTIME_TWO);
354     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
355     item.SetPressed(true);
356     item.SetDeviceId(1);
357     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THREE);
358     pointerEvent->AddPointerItem(item);
359     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
360     pointerEvent->SetPointerId(0);
361     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
362 
363     auto callbackPtr = GetPtr<InputEventCallback>();
364     ASSERT_TRUE(callbackPtr != nullptr);
365     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
366 #ifdef OHOS_BUILD_ENABLE_MONITOR
367     EXPECT_TRUE(IsValidHandlerId(monitorId));
368 #else
369     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
370 #endif  // OHOS_BUILD_ENABLE_MONITOR
371     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
372 
373     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
374     InputManagerUtil::TestRemoveMonitor(monitorId);
375 }
376 
377 /**
378  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_003
379  * @tc.desc: Verify touchpad up event monitor
380  * @tc.type: FUNC
381  * @tc.require:
382  */
383 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_003, TestSize.Level1)
384 {
385     CALL_TEST_DEBUG;
386     auto pointerEvent = PointerEvent::Create();
387     ASSERT_NE(pointerEvent, nullptr);
388     PointerEvent::PointerItem item;
389     item.SetDownTime(POINTER_ITEM_DOWNTIME_ONE);
390     item.SetPointerId(0);
391     item.SetPressed(true);
392     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FOUR);
393     item.SetDeviceId(1);
394     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FOUR);
395     pointerEvent->AddPointerItem(item);
396     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
397     pointerEvent->SetPointerId(0);
398     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
399 
400     auto callbackPtr = GetPtr<InputEventCallback>();
401     ASSERT_TRUE(callbackPtr != nullptr);
402     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
403 #ifdef OHOS_BUILD_ENABLE_MONITOR
404     EXPECT_TRUE(IsValidHandlerId(monitorId));
405 #else
406     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
407 #endif  // OHOS_BUILD_ENABLE_MONITOR
408     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
409 
410     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
411     InputManagerUtil::TestRemoveMonitor(monitorId);
412 }
413 
414 /**
415  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_004
416  * @tc.desc: Verify touchpad multiple monitor
417  * @tc.type: FUNC
418  * @tc.require:
419  */
420 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_004, TestSize.Level1)
421 {
422     CALL_TEST_DEBUG;
423     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
424     auto pointerEvent = PointerEvent::Create();
425     ASSERT_NE(pointerEvent, nullptr);
426     PointerEvent::PointerItem item;
427     item.SetDownTime(POINTER_ITEM_DOWNTIME_FOUR);
428     item.SetDeviceId(1);
429     item.SetPointerId(0);
430     item.SetPressed(true);
431     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_THREE);
432     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FIVE);
433     pointerEvent->AddPointerItem(item);
434     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
435     pointerEvent->SetPointerId(0);
436     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
437 
438     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
439     std::vector<int32_t> ids(N_TEST_CASES);
440     auto callbackPtr = GetPtr<InputEventCallback>();
441     ASSERT_TRUE(callbackPtr != nullptr);
442     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
443         ids[i] = InputManagerUtil::TestAddMonitor(callbackPtr);
444 #ifdef OHOS_BUILD_ENABLE_MONITOR
445         EXPECT_TRUE(IsValidHandlerId(ids[i]));
446 #else
447         EXPECT_EQ(ids[i], ERROR_UNSUPPORT);
448 #endif  // OHOS_BUILD_ENABLE_MONITOR
449         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
450     }
451 
452     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
453 
454     for (const auto &id : ids) {
455         std::string sPointerEs = GetEventDump();
456         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
457 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_MONITOR)
458         ASSERT_TRUE(!sPointerEs.empty());
459 #else
460         ASSERT_TRUE(sPointerEs.empty());
461 #endif  // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_MONITOR
462         if (IsValidHandlerId(id)) {
463             InputManagerUtil::TestRemoveMonitor(id);
464         }
465         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
466     }
467 
468     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
469         InputManagerUtil::TestRemoveMonitor(ids[i]);
470     }
471 }
472 
473 /**
474  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_005
475  * @tc.desc: Verify touchpad monitor
476  * @tc.type: FUNC
477  * @tc.require:
478  */
479 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_005, TestSize.Level1)
480 {
481     CALL_TEST_DEBUG;
482     auto pointerEvent = PointerEvent::Create();
483     ASSERT_NE(pointerEvent, nullptr);
484     PointerEvent::PointerItem item;
485     item.SetDownTime(POINTER_ITEM_DOWNTIME_FIVE);
486     item.SetPointerId(0);
487     item.SetDeviceId(1);
488     item.SetPressed(true);
489     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FIVE);
490     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_ONE);
491     pointerEvent->AddPointerItem(item);
492     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
493     pointerEvent->SetPointerId(0);
494     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
495 
496     auto callbackPtr = GetPtr<InputEventCallback>();
497     ASSERT_TRUE(callbackPtr != nullptr);
498     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
499 #ifdef OHOS_BUILD_ENABLE_MONITOR
500     EXPECT_TRUE(IsValidHandlerId(monitorId));
501 #else
502     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
503 #endif  // OHOS_BUILD_ENABLE_MONITOR
504     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
505 
506     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
507     InputManagerUtil::TestRemoveMonitor(monitorId);
508 }
509 
510 /**
511  * @tc.name: InputManagerPointerTest_AddMouseMonitor_001
512  * @tc.desc: Verify mouse down event monitor
513  * @tc.type: FUNC
514  * @tc.require:
515  */
516 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMouseMonitor_001, TestSize.Level1)
517 {
518     CALL_TEST_DEBUG;
519     auto callbackPtr = GetPtr<InputEventCallback>();
520     ASSERT_NE(callbackPtr, nullptr);
521     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
522 #ifdef OHOS_BUILD_ENABLE_MONITOR
523     EXPECT_TRUE(IsValidHandlerId(monitorId));
524 #else
525     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
526 #endif  // OHOS_BUILD_ENABLE_MONITOR
527     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
528 
529     auto pointerEvent = InputManagerUtil::SetupPointerEvent005();
530     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
531     InputManagerUtil::TestRemoveMonitor(monitorId);
532 }
533 
534 /**
535  * @tc.name: InputManagerPointerTest_AddMouseMonitor_003
536  * @tc.desc: Verify mouse up event monitor
537  * @tc.type: FUNC
538  * @tc.require:
539  */
540 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMouseMonitor_003, TestSize.Level1)
541 {
542     CALL_TEST_DEBUG;
543     auto callbackPtr = GetPtr<InputEventCallback>();
544     ASSERT_TRUE(callbackPtr != nullptr);
545     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
546 #ifdef OHOS_BUILD_ENABLE_MONITOR
547     EXPECT_TRUE(IsValidHandlerId(monitorId));
548 #else
549     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
550 #endif  // OHOS_BUILD_ENABLE_MONITOR
551     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
552 
553     auto pointerEvent = InputManagerUtil::SetupPointerEvent007();
554     ASSERT_TRUE(pointerEvent != nullptr);
555     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
556     InputManagerUtil::TestRemoveMonitor(monitorId);
557 }
558 
559 /**
560  * @tc.name: InputManagerPointerTest_AddMouseMonitor_004
561  * @tc.desc: Verify monitor upper limit
562  * @tc.type: FUNC
563  * @tc.require:
564  */
565 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMouseMonitor_004, TestSize.Level1)
566 {
567     CALL_TEST_DEBUG;
568     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
569     const std::vector<int32_t>::size_type N_TEST_CASES{MAX_N_INPUT_HANDLERS - 1};
570     std::vector<int32_t> ids;
571     int32_t maxMonitor = 0;
572 
573     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
574         auto callbackPtr = GetPtr<InputEventCallback>();
575         ASSERT_TRUE(callbackPtr != nullptr);
576         maxMonitor = InputManagerUtil::TestAddMonitor(callbackPtr);
577         if (IsValidHandlerId(maxMonitor)) {
578             ids.push_back(maxMonitor);
579             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
580         }
581     }
582 
583     auto pointerEvent = InputManagerUtil::SetupPointerEvent007();
584     pointerEvent->AddFlag(PointerEvent::EVENT_FLAG_NO_INTERCEPT);
585     ASSERT_TRUE(pointerEvent != nullptr);
586     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
587     maxMonitor = 0;
588     for (const auto &id : ids) {
589         if (!GetEventDump().empty()) {
590             maxMonitor++;
591         }
592         if (IsValidHandlerId(id)) {
593             InputManagerUtil::TestRemoveMonitor(id);
594             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
595         }
596     }
597 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_MONITOR)
598     ASSERT_EQ(maxMonitor, ids.size());
599 #else
600     ASSERT_EQ(maxMonitor, 0);
601 #endif  // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_MONITOR
602 }
603 
604 /**
605  * @tc.name: InputManagerPointerTest_OnAddKeyboardMonitor_001
606  * @tc.desc: Verify Keyboard multiple monitor
607  * @tc.type: FUNC
608  * @tc.require:
609  */
610 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddKeyboardMonitor_001, TestSize.Level1)
611 {
612     CALL_TEST_DEBUG;
613     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
614     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
615     std::vector<int32_t> ids;
616     auto callbackPtr = GetPtr<InputEventCallback>();
617     ASSERT_TRUE(callbackPtr != nullptr);
618     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
619         int32_t id = InputManagerUtil::TestAddMonitor(callbackPtr);
620         if (IsValidHandlerId(id)) {
621             ids.push_back(id);
622             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
623         }
624     }
625 
626     auto injectEvent = InputManagerUtil::SetupKeyEvent001();
627     ASSERT_TRUE(injectEvent != nullptr);
628     InputManager::GetInstance()->SimulateInputEvent(injectEvent);
629 
630     for (const auto &id : ids) {
631         std::string sPointerEs = GetEventDump();
632         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
633 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_MONITOR)
634         ASSERT_TRUE(!sPointerEs.empty());
635 #else
636         ASSERT_TRUE(sPointerEs.empty());
637 #endif  // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_MONITOR
638         if (IsValidHandlerId(id)) {
639             InputManagerUtil::TestRemoveMonitor(id);
640         }
641         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
642     }
643 }
644 
645 /**
646  * @tc.name: InputManagerPointerTest_OnAddKeyboardMonitor_002
647  * @tc.desc: Verify Keyboard multiple monitor
648  * @tc.type: FUNC
649  * @tc.require:
650  */
651 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddKeyboardMonitor_002, TestSize.Level1)
652 {
653     CALL_TEST_DEBUG;
654     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
655     std::vector<int32_t> ids;
656     auto callbackPtr = GetPtr<InputEventCallback>();
657     ASSERT_TRUE(callbackPtr != nullptr);
658     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
659         int32_t id = InputManagerUtil::TestAddMonitor(callbackPtr);
660         if (IsValidHandlerId(id)) {
661             ids.push_back(id);
662             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
663         }
664     }
665 
666     auto injectEvent = InputManagerUtil::SetupKeyEvent001();
667     ASSERT_TRUE(injectEvent != nullptr);
668     injectEvent->SetKeyCode(KeyEvent::KEYCODE_UNKNOWN);
669     InputManager::GetInstance()->SimulateInputEvent(injectEvent);
670 
671     for (const auto &id : ids) {
672         std::string sPointerEs = GetEventDump();
673         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
674         ASSERT_TRUE(sPointerEs.empty());
675         if (IsValidHandlerId(id)) {
676             InputManagerUtil::TestRemoveMonitor(id);
677         }
678         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
679     }
680 }
681 
682 /**
683  * @tc.name: InputManagerPointerTest_SetWindowInputEventConsumer_001
684  * @tc.desc: Verify pointerEvent report eventHandler
685  * @tc.type: FUNC
686  * @tc.require: I5HMDY
687  */
688 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetWindowInputEventConsumer_001, TestSize.Level1)
689 {
690     CALL_TEST_DEBUG;
691     auto runner = AppExecFwk::EventRunner::Create("cooperateHdrTest");
692     ASSERT_TRUE(runner != nullptr);
693     auto eventHandler = std::make_shared<AppExecFwk::EventHandler>(runner);
694     ASSERT_TRUE(eventHandler != nullptr);
695     uint64_t runnerThreadId = 0;
696 
__anon9f51aff20402() 697     auto fun = [&runnerThreadId]() {
698         runnerThreadId = GetThisThreadId();
699         MMI_HILOGD("Create eventHandler is threadId:%{public}" PRIu64, runnerThreadId);
700         ASSERT_TRUE(runnerThreadId != 0);
701     };
702     eventHandler->PostSyncTask(fun, AppExecFwk::EventHandler::Priority::IMMEDIATE);
703     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
704     auto consumer = GetPtr<WindowEventConsumer>();
705     ASSERT_TRUE(consumer != nullptr);
706     MMI::InputManager::GetInstance()->SetWindowInputEventConsumer(consumer, eventHandler);
707     auto pointerEvent = InputManagerUtil::SetupPointerEvent005();
708     pointerEvent->AddFlag(PointerEvent::EVENT_FLAG_NO_INTERCEPT);
709     ASSERT_TRUE(pointerEvent != nullptr);
710     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
711     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
712     uint64_t consumerThreadId = consumer->GetConsumerThreadId();
713 #ifdef OHOS_BUILD_ENABLE_POINTER
714     if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
715         ASSERT_TRUE(runnerThreadId != consumerThreadId);
716     } else {
717         EXPECT_EQ(runnerThreadId, consumerThreadId);
718     }
719 #else
720     ASSERT_TRUE(runnerThreadId != consumerThreadId);
721 #endif  // OHOS_BUILD_ENABLE_POINTER
722 }
723 
724 /**
725  * @tc.name: InputManagerPointerTest_SetWindowInputEventConsumer_002
726  * @tc.desc: Verify keyEvent report eventHandler
727  * @tc.type: FUNC
728  * @tc.require: I5HMDY
729  */
730 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetWindowInputEventConsumer_002, TestSize.Level1)
731 {
732     CALL_TEST_DEBUG;
733     const std::string threadTest = "threadNameTest";
734     auto runner = AppExecFwk::EventRunner::Create(threadTest);
735     ASSERT_TRUE(runner != nullptr);
736     auto eventHandler = std::make_shared<AppExecFwk::EventHandler>(runner);
737     ASSERT_TRUE(eventHandler != nullptr);
738     uint64_t runnerThreadId = 0;
739 
__anon9f51aff20502() 740     auto fun = [&runnerThreadId]() {
741         runnerThreadId = GetThisThreadId();
742         MMI_HILOGD("Create eventHandler is threadId:%{public}" PRIu64, runnerThreadId);
743         ASSERT_TRUE(runnerThreadId != 0);
744     };
745     eventHandler->PostSyncTask(fun, AppExecFwk::EventHandler::Priority::IMMEDIATE);
746     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
747     auto consumer = GetPtr<WindowEventConsumer>();
748     ASSERT_TRUE(consumer != nullptr);
749     MMI::InputManager::GetInstance()->SetWindowInputEventConsumer(consumer, eventHandler);
750     auto keyEvent = InputManagerUtil::SetupKeyEvent001();
751     ASSERT_TRUE(keyEvent != nullptr);
752     keyEvent->SetKeyCode(KeyEvent::KEYCODE_A);
753     InputManager::GetInstance()->SimulateInputEvent(keyEvent);
754     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
755     uint64_t consumerThreadId = consumer->GetConsumerThreadId();
756 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
757     if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
758         ASSERT_TRUE(runnerThreadId != consumerThreadId);
759     } else {
760         EXPECT_EQ(runnerThreadId, consumerThreadId);
761     }
762 #else
763     ASSERT_TRUE(runnerThreadId != consumerThreadId);
764 #endif  // OHOS_BUILD_ENABLE_KEYBOARD
765 }
766 
767 /**
768  * @tc.name: InputManagerPointerTest_MoveMouse_01
769  * @tc.desc: Verify move mouse
770  * @tc.type: FUNC
771  * @tc.require:
772  */
773 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MoveMouse_01, TestSize.Level1)
774 {
775     CALL_TEST_DEBUG;
776     ASSERT_NO_FATAL_FAILURE(InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO));
777 }
778 
779 /**
780  * @tc.name: InputManagerPointerTest_MoveMouse_02
781  * @tc.desc: Verify move mouse
782  * @tc.type: FUNC
783  * @tc.require:
784  */
785 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MoveMouse_02, TestSize.Level1)
786 {
787     CALL_TEST_DEBUG;
788     ASSERT_NO_FATAL_FAILURE(
789         InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THIRTEEN, MOVE_MOUSE_OFFSET_THREE));
790 }
791 
792 /**
793  * @tc.name: InputManagerPointerTest_MouseHotArea_001
794  * @tc.desc: Mouse event Search window by pointerHotAreas
795  * @tc.type: FUNC
796  * @tc.require: I5HMCB
797  */
798 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseHotArea_001, TestSize.Level1)
799 {
800     CALL_TEST_DEBUG;
801     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupMouseEvent001()};
802     ASSERT_TRUE(pointerEvent != nullptr);
803     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
804     ASSERT_EQ(pointerEvent->GetSourceType(), PointerEvent::SOURCE_TYPE_MOUSE);
805 }
806 
807 /**
808  * @tc.name: InputManagerPointerTest_MouseHotArea_002
809  * @tc.desc: Mouse event Search window by pointerHotAreas
810  * @tc.type: FUNC
811  * @tc.require: I5HMCB
812  */
813 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseHotArea_002, TestSize.Level1)
814 {
815     CALL_TEST_DEBUG;
816     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupMouseEvent002()};
817     ASSERT_TRUE(pointerEvent != nullptr);
818     ASSERT_EQ(pointerEvent->GetSourceType(), PointerEvent::SOURCE_TYPE_MOUSE);
819 }
820 
821 /**
822  * @tc.name: InputManagerPointerTest_SetPointerLocation_001
823  * @tc.desc: Sets the absolute coordinate of mouse.
824  * @tc.type: FUNC
825  * @tc.require:
826  */
827 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerLocation_001, TestSize.Level1)
828 {
829     CALL_TEST_DEBUG;
830     int32_t x = 0;
831     int32_t y = 0;
832     ASSERT_NO_FATAL_FAILURE(InputManager::GetInstance()->SetPointerLocation(x, y));
833 }
834 
835 /**
836  * @tc.name: InputManagerPointerTest_SetPointerVisible_001
837  * @tc.desc: Sets whether the pointer icon is visible
838  * @tc.type: FUNC
839  * @tc.require: I530VT
840  */
841 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerVisible_001, TestSize.Level1)
842 {
843     bool isVisible{true};
844     if (InputManager::GetInstance()->SetPointerVisible(isVisible) == RET_OK) {
845         ASSERT_TRUE(InputManager::GetInstance()->IsPointerVisible() == isVisible);
846     }
847 }
848 
849 /**
850  * @tc.name: InputManagerPointerTest_SetPointerVisible_002
851  * @tc.desc: Sets whether the pointer icon is visible
852  * @tc.type: FUNC
853  * @tc.require: I530VT
854  */
855 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerVisible_002, TestSize.Level1)
856 {
857     bool isVisible{false};
858     if (InputManager::GetInstance()->SetPointerVisible(isVisible) == RET_OK) {
859         ASSERT_TRUE(InputManager::GetInstance()->IsPointerVisible() == isVisible);
860     }
861 }
862 
863 /**
864  * @tc.name: InputManagerPointerTest_SetPointSpeed_001
865  * @tc.desc: Abnormal speed value processing
866  * @tc.type: FUNC
867  * @tc.require: I530XP I530UX
868  */
869 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_001, TestSize.Level1)
870 {
871     CALL_TEST_DEBUG;
872     const int32_t speed = INVAID_VALUE;
873     InputManager::GetInstance()->SetPointerSpeed(speed);
874     int32_t speed1;
875     InputManager::GetInstance()->GetPointerSpeed(speed1);
876     ASSERT_EQ(speed1, 1);
877     InputManager::GetInstance()->MoveMouse(-MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
878     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
879     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
880     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
881     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
882     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
883     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
884     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
885     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
886     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
887     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
888     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
889     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
890 }
891 
892 /**
893  * @tc.name: InputManagerPointerTest_SetPointSpeed_002
894  * @tc.desc: Normal speed value processing
895  * @tc.type: FUNC
896  * @tc.require: I530XP I530UX
897  */
898 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_002, TestSize.Level1)
899 {
900     CALL_TEST_DEBUG;
901     const int32_t speed = 1;
902     InputManager::GetInstance()->SetPointerSpeed(speed);
903     int32_t speed1;
904     InputManager::GetInstance()->GetPointerSpeed(speed1);
905     ASSERT_EQ(speed1, speed);
906     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
907     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
908     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
909     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
910     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
911     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
912     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
913     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
914     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
915     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
916     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
917     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
918     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
919 }
920 
921 /**
922  * @tc.name: InputManagerPointerTest_SetPointSpeed_003
923  * @tc.desc: Normal speed value processing
924  * @tc.type: FUNC
925  * @tc.require: I530XP I530UX
926  */
927 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_003, TestSize.Level1)
928 {
929     CALL_TEST_DEBUG;
930     const int32_t speed = POINTER_SPEED_ONE;
931     InputManager::GetInstance()->SetPointerSpeed(speed);
932     int32_t speed1;
933     InputManager::GetInstance()->GetPointerSpeed(speed1);
934     ASSERT_EQ(speed1, speed);
935     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
936     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
937     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
938     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
939     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
940     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
941     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
942     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
943     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
944     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
945     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
946     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
947     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
948 }
949 
950 /**
951  * @tc.name: InputManagerPointerTest_SetPointSpeed_004
952  * @tc.desc: Normal speed value processing
953  * @tc.type: FUNC
954  * @tc.require: I530XP I530UX
955  */
956 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_004, TestSize.Level1)
957 {
958     CALL_TEST_DEBUG;
959     const int32_t speed = POINTER_SPEED_FOUR;
960     InputManager::GetInstance()->SetPointerSpeed(speed);
961     int32_t speed1;
962     InputManager::GetInstance()->GetPointerSpeed(speed1);
963     ASSERT_EQ(speed1, speed);
964     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
965     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
966     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
967     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
968     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
969     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
970     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
971     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
972     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
973     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
974     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
975     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
976     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
977 }
978 
979 /**
980  * @tc.name: InputManagerPointerTest_SetPointSpeed_005
981  * @tc.desc: Abnormal speed value processing
982  * @tc.type: FUNC
983  * @tc.require: I530XP I530UX
984  */
985 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_005, TestSize.Level1)
986 {
987     CALL_TEST_DEBUG;
988     const int32_t speed = POINTER_SPEED_FIVE;
989     InputManager::GetInstance()->SetPointerSpeed(speed);
990     int32_t speed1;
991     InputManager::GetInstance()->GetPointerSpeed(speed1);
992     ASSERT_EQ(speed1, POINTER_SPEED_FOUR);
993     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
994     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
995     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
996     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
997     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
998     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
999     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1000     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
1001     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1002     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
1003     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1004     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
1005     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1006 }
1007 
1008 /**
1009  * @tc.name: InputManagerPointerTest_SetHoverScrollState_001
1010  * @tc.desc: Sets mouse hover scroll state in inactive window
1011  * @tc.type: FUNC
1012  * @tc.require: I530XS
1013  */
1014 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetHoverScrollState_001, TestSize.Level1)
1015 {
1016     CALL_TEST_DEBUG;
1017     ASSERT_TRUE(InputManager::GetInstance()->SetHoverScrollState(false) == RET_OK);
1018     InputManager::GetInstance()->SetHoverScrollState(true);
1019     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1020     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1021 }
1022 
1023 /**
1024  * @tc.name: InputManagerPointerTest_SetHoverScrollState_002
1025  * @tc.desc: Sets mouse hover scroll state in inactive window
1026  * @tc.type: FUNC
1027  * @tc.require: I530XS
1028  */
1029 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetHoverScrollState_002, TestSize.Level1)
1030 {
1031     CALL_TEST_DEBUG;
1032     ASSERT_TRUE(InputManager::GetInstance()->SetHoverScrollState(true) == RET_OK);
1033     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1034     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1035 }
1036 
1037 /**
1038  * @tc.name: InputManagerPointerTest_GetHoverScrollState_001
1039  * @tc.desc: Gets mouse hover scroll state in inactive window
1040  * @tc.type: FUNC
1041  * @tc.require: I530XS
1042  */
1043 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetHoverScrollState_001, TestSize.Level1)
1044 {
1045     CALL_TEST_DEBUG;
1046     bool state = true;
1047     if (InputManager::GetInstance()->SetHoverScrollState(state) == RET_OK) {
1048         ASSERT_TRUE(InputManager::GetInstance()->GetHoverScrollState(state) == RET_OK);
1049         ASSERT_TRUE(state);
1050     }
1051     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1052     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1053 }
1054 
1055 /**
1056  * @tc.name: InputManagerPointerTest_SetMousePrimaryButton_001
1057  * @tc.desc: Sets mouse primary button
1058  * @tc.type: FUNC
1059  * @tc.require: I530XS
1060  */
1061 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMousePrimaryButton_001, TestSize.Level1)
1062 {
1063     CALL_TEST_DEBUG;
1064     int32_t primaryButton = 1;
1065     ASSERT_TRUE(InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_OK);
1066     primaryButton = 0;
1067     ASSERT_TRUE(InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_OK);
1068     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1069     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1070 }
1071 
1072 /**
1073  * @tc.name: InputManagerPointerTest_SetMousePrimaryButton_002
1074  * @tc.desc: Sets mouse primary button
1075  * @tc.type: FUNC
1076  * @tc.require: I530XS
1077  */
1078 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMousePrimaryButton_002, TestSize.Level1)
1079 {
1080     CALL_TEST_DEBUG;
1081     int32_t primaryButton = INVAID_VALUE;
1082     ASSERT_TRUE(InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_ERR);
1083 }
1084 
1085 /**
1086  * @tc.name: InputManagerPointerTest_GetMousePrimaryButton_001
1087  * @tc.desc: Gets mouse primary button
1088  * @tc.type: FUNC
1089  * @tc.require: I530XS
1090  */
1091 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetMousePrimaryButton_001, TestSize.Level1)
1092 {
1093     CALL_TEST_DEBUG;
1094     int32_t primaryButton = 1;
1095     if (InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_OK) {
1096         ASSERT_TRUE(InputManager::GetInstance()->GetMousePrimaryButton(primaryButton) == RET_OK);
1097         ASSERT_EQ(primaryButton, PrimaryButton::RIGHT_BUTTON);
1098     }
1099     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1100     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1101 }
1102 
1103 /**
1104  * @tc.name: InputManagerPointerTest_SetMouseScrollRows_001
1105  * @tc.desc: Sets mouse scroll rows
1106  * @tc.type: FUNC
1107  * @tc.require: I530XS
1108  */
1109 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseScrollRows_001, TestSize.Level1)
1110 {
1111     CALL_TEST_DEBUG;
1112     int32_t rows = 1;
1113     ASSERT_TRUE(InputManager::GetInstance()->SetMouseScrollRows(rows) == RET_OK);
1114     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1115     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1116 }
1117 
1118 /**
1119  * @tc.name: InputManagerPointerTest_GetMouseScrollRows_001
1120  * @tc.desc: Sets mouse scroll rows
1121  * @tc.type: FUNC
1122  * @tc.require: I530XS
1123  */
1124 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetMouseScrollRows_001, TestSize.Level1)
1125 {
1126     CALL_TEST_DEBUG;
1127     int32_t rows = 50;
1128     int32_t newRows = 3;
1129     if (InputManager::GetInstance()->SetMouseScrollRows(rows) == RET_OK) {
1130         ASSERT_TRUE(InputManager::GetInstance()->GetMouseScrollRows(newRows) == RET_OK);
1131         ASSERT_EQ(rows, newRows);
1132     }
1133     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1134     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1135 }
1136 
1137 /**
1138  * @tc.name: InputManagerPointerTest_SetMouseIcon_001
1139  * @tc.desc: Set the mouse icon for linux window
1140  * @tc.type: FUNC
1141  * @tc.require: I530XS
1142  */
1143 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseIcon_001, TestSize.Level1)
1144 {
1145     CALL_TEST_DEBUG;
1146     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1147     CHKPV(window);
1148     uint32_t windowId = window->GetWindowId();
1149     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
1150     PointerStyle pointerStyle;
1151     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1152     ASSERT_NE(pixelMap, nullptr);
1153     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1154     if (InputManager::GetInstance()->SetMouseIcon(windowId, (void *)pixelMap.get()) == RET_OK) {
1155         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1156         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1157     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1158         ASSERT_FALSE(false);  // errors occur
1159     } else {
1160         ASSERT_TRUE(false);
1161     }
1162 }
1163 
1164 /**
1165  * @tc.name: InputManagerPointerTest_SetMouseIcon_002
1166  * @tc.desc: Set the mouse icon for linux window
1167  * @tc.type: FUNC
1168  * @tc.require: I530XS
1169  */
1170 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseIcon_002, TestSize.Level1)
1171 {
1172     CALL_TEST_DEBUG;
1173     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1174     CHKPV(window);
1175     uint32_t windowId = window->GetWindowId();
1176     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1177     PointerStyle pointerStyle;
1178     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1179     ASSERT_NE(pixelMap, nullptr);
1180     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1181     if (InputManager::GetInstance()->SetMouseIcon(windowId, (void *)pixelMap.get()) == RET_OK) {
1182         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1183         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1184     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1185         ASSERT_FALSE(false);  // errors occur
1186     } else {
1187         ASSERT_TRUE(false);
1188     }
1189 }
1190 
1191 /**
1192  * @tc.name: InputManagerPointerTest_SetMouseIcon_003
1193  * @tc.desc: Set the mouse icon for linux window
1194  * @tc.type: FUNC
1195  * @tc.require: I530XS
1196  */
1197 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseIcon_003, TestSize.Level1)
1198 {
1199     CALL_TEST_DEBUG;
1200     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1201     CHKPV(window);
1202     uint32_t windowId = window->GetWindowId();
1203     PointerStyle pointerStyle;
1204     pointerStyle.id = MOUSE_ICON::DEFAULT;
1205     int32_t ret = InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle);
1206     if ((Rosen::SceneBoardJudgement::IsSceneBoardEnabled())) {
1207         ASSERT_TRUE(ret != RET_OK);
1208         return;
1209     } else {
1210         ASSERT_TRUE(ret == RET_OK);
1211     }
1212     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1213     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1214     ASSERT_TRUE(pixelMap != nullptr);
1215     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1216     ret = InputManager::GetInstance()->SetMouseIcon(INVAID_VALUE, (void *)pixelMap.get());
1217     ASSERT_EQ(ret, RET_ERR);
1218     ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1219     ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEFAULT);
1220 }
1221 
1222 /**
1223  * @tc.name: InputManagerPointerTest_SetMouseHotSpot_001
1224  * @tc.desc: Set the mouse icon hot spot for linux window
1225  * @tc.type: FUNC
1226  * @tc.require: I530XS
1227  */
1228 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseHotSpot_001, TestSize.Level1)
1229 {
1230     CALL_TEST_DEBUG;
1231     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1232     CHKPV(window);
1233     uint32_t windowId = window->GetWindowId();
1234     PointerStyle pointerStyle;
1235     pointerStyle.id = MOUSE_ICON::CROSS;
1236     if (InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle) == RET_OK) {
1237         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1238         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::CROSS);
1239         ASSERT_FALSE(
1240             InputManager::GetInstance()->SetMouseHotSpot(windowId, MOUSE_ICON_HOT_SPOT, MOUSE_ICON_HOT_SPOT) == RET_OK);
1241     }
1242 }
1243 
1244 /**
1245  * @tc.name: InputManagerPointerTest_SetMouseHotSpot_002
1246  * @tc.desc: Set the mouse icon hot spot for linux window
1247  * @tc.type: FUNC
1248  * @tc.require: I530XS
1249  */
1250 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseHotSpot_002, TestSize.Level1)
1251 {
1252     CALL_TEST_DEBUG;
1253     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1254     CHKPV(window);
1255     uint32_t windowId = window->GetWindowId();
1256     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Default.svg";
1257     PointerStyle pointerStyle;
1258     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1259     ASSERT_NE(pixelMap, nullptr);
1260     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1261     if (InputManager::GetInstance()->SetMouseIcon(windowId, (void *)pixelMap.get()) == RET_OK) {
1262         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1263         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1264         ASSERT_TRUE(
1265             InputManager::GetInstance()->SetMouseHotSpot(windowId, MOUSE_ICON_HOT_SPOT, MOUSE_ICON_HOT_SPOT) == RET_OK);
1266     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1267         ASSERT_FALSE(false);
1268     } else {
1269         ASSERT_TRUE(false);
1270     }
1271 }
1272 
1273 /**
1274  * @tc.name: InputManagerPointerTest_SetPointerStyle_001
1275  * @tc.desc: Sets the pointer style of the window
1276  * @tc.type: FUNC
1277  * @tc.require: I530XS
1278  */
1279 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerStyle_001, TestSize.Level1)
1280 {
1281     CALL_TEST_DEBUG;
1282     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1283     CHKPV(window);
1284     uint32_t windowId = window->GetWindowId();
1285     PointerStyle pointerStyle;
1286     pointerStyle.id = MOUSE_ICON::CROSS;
1287     if (InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle) == RET_OK) {
1288         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1289         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::CROSS);
1290     }
1291 }
1292 
1293 /**
1294  * @tc.name: InputManagerPointerTest_SetPointerStyle_002
1295  * @tc.desc: Sets the pointer style of the window
1296  * @tc.type: FUNC
1297  * @tc.require: I530XS
1298  */
1299 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerStyle_002, TestSize.Level1)
1300 {
1301     CALL_TEST_DEBUG;
1302     uint32_t windowId = INVAID_VALUE;
1303     PointerStyle pointerStyle;
1304     pointerStyle.id = MOUSE_ICON::CROSS;
1305     if (InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle) == RET_OK) {
1306         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1307         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::CROSS);
1308     }
1309 }
1310 
1311 /**
1312  * @tc.name: InputManagerPointerTest_SetTouchpadScrollSwitch_001
1313  * @tc.desc: Set touchpad scroll switch
1314  * @tc.type: FUNC
1315  * @tc.require:
1316  */
1317 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadScrollSwitch_001, TestSize.Level1)
1318 {
1319     CALL_TEST_DEBUG;
1320     bool flag = false;
1321     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadScrollSwitch(flag) == RET_OK);
1322     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1323     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1324 }
1325 
1326 /**
1327  * @tc.name: InputManagerPointerTest_GetTouchpadScrollSwitch_001
1328  * @tc.desc: Get touchpad scroll switch
1329  * @tc.type: FUNC
1330  * @tc.require:
1331  */
1332 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadScrollSwitch_001, TestSize.Level1)
1333 {
1334     CALL_TEST_DEBUG;
1335     bool flag = true;
1336     InputManager::GetInstance()->SetTouchpadScrollSwitch(flag);
1337     bool newFlag = true;
1338     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadScrollSwitch(newFlag) == RET_OK);
1339     ASSERT_TRUE(flag == newFlag);
1340     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1341     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1342 }
1343 
1344 /**
1345  * @tc.name: InputManagerPointerTest_SetTouchpadScrollDirection_001
1346  * @tc.desc: Set touchpad scroll direction switch
1347  * @tc.type: FUNC
1348  * @tc.require:
1349  */
1350 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadScrollDirection_001, TestSize.Level1)
1351 {
1352     CALL_TEST_DEBUG;
1353     bool state = false;
1354     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadScrollDirection(state) == RET_OK);
1355     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1356     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1357 }
1358 
1359 /**
1360  * @tc.name: InputManagerPointerTest_GetTouchpadScrollDirection_001
1361  * @tc.desc: Get touchpad scroll direction switch
1362  * @tc.type: FUNC
1363  * @tc.require:
1364  */
1365 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadScrollDirection_001, TestSize.Level1)
1366 {
1367     CALL_TEST_DEBUG;
1368     bool state = true;
1369     InputManager::GetInstance()->SetTouchpadScrollDirection(state);
1370     bool newState = true;
1371     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadScrollDirection(newState) == RET_OK);
1372     ASSERT_TRUE(state == newState);
1373     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1374     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1375 }
1376 
1377 /**
1378  * @tc.name: InputManagerPointerTest_SetTouchpadTapSwitch_001
1379  * @tc.desc: Set touchpad tap switch
1380  * @tc.type: FUNC
1381  * @tc.require:
1382  */
1383 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadTapSwitch_001, TestSize.Level1)
1384 {
1385     CALL_TEST_DEBUG;
1386     bool flag = false;
1387     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadTapSwitch(flag) == RET_OK);
1388     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1389     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1390 }
1391 
1392 /**
1393  * @tc.name: InputManagerPointerTest_GetTouchpadTapSwitch_001
1394  * @tc.desc: Get touchpad tap switch
1395  * @tc.type: FUNC
1396  * @tc.require:
1397  */
1398 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadTapSwitch_001, TestSize.Level1)
1399 {
1400     CALL_TEST_DEBUG;
1401     bool flag = true;
1402     InputManager::GetInstance()->SetTouchpadTapSwitch(flag);
1403     bool newFlag = true;
1404     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadTapSwitch(newFlag) == RET_OK);
1405     ASSERT_TRUE(flag == newFlag);
1406     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1407     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1408 }
1409 
1410 /**
1411  * @tc.name: InputManagerPointerTest_SetTouchpadPointerSpeed_001
1412  * @tc.desc: Set touchpad pointer speed
1413  * @tc.type: FUNC
1414  * @tc.require:
1415  */
1416 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadPointerSpeed_001, TestSize.Level1)
1417 {
1418     CALL_TEST_DEBUG;
1419     int32_t speed = POINTER_SPEED_ONE;
1420     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadPointerSpeed(speed) == RET_OK);
1421     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1422     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1423 }
1424 
1425 /**
1426  * @tc.name: InputManagerPointerTest_GetTouchpadPointerSpeed_001
1427  * @tc.desc: Get touchpad pointer speed
1428  * @tc.type: FUNC
1429  * @tc.require:
1430  */
1431 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadPointerSpeed_001, TestSize.Level1)
1432 {
1433     CALL_TEST_DEBUG;
1434     int32_t speed = POINTER_SPEED_TWO;
1435     InputManager::GetInstance()->SetTouchpadPointerSpeed(speed);
1436     int32_t newSpeed = POINTER_SPEED_THREE;
1437     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadPointerSpeed(newSpeed) == RET_OK);
1438     ASSERT_TRUE(speed == newSpeed);
1439     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1440     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1441 }
1442 
1443 /**
1444  * @tc.name: InputManagerPointerTest_SetTouchpadPinchSwitch_001
1445  * @tc.desc: Set touchpad pinch switch
1446  * @tc.type: FUNC
1447  * @tc.require:
1448  */
1449 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadPinchSwitch_001, TestSize.Level1)
1450 {
1451     CALL_TEST_DEBUG;
1452     bool flag = false;
1453     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadPinchSwitch(flag) == RET_OK);
1454     const char *touchpadFileName = "/data/service/el1/public/multimodalinput/touchpad_settings.xml";
1455     ASSERT_TRUE(remove(touchpadFileName) == RET_OK);
1456 }
1457 
1458 /**
1459  * @tc.name: InputManagerPointerTest_GetTouchpadPinchSwitch_001
1460  * @tc.desc: Get touchpad pinch switch
1461  * @tc.type: FUNC
1462  * @tc.require:
1463  */
1464 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadPinchSwitch_001, TestSize.Level1)
1465 {
1466     CALL_TEST_DEBUG;
1467     bool flag = true;
1468     InputManager::GetInstance()->SetTouchpadPinchSwitch(flag);
1469     bool newFlag = true;
1470     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadPinchSwitch(newFlag) == RET_OK);
1471     ASSERT_TRUE(flag == newFlag);
1472     const char *touchpadFileName = "/data/service/el1/public/multimodalinput/touchpad_settings.xml";
1473     ASSERT_TRUE(remove(touchpadFileName) == RET_OK);
1474 }
1475 
1476 /**
1477  * @tc.name: InputManagerPointerTest_SetTouchpadSwipeSwitch_001
1478  * @tc.desc: Set touchpad swipe switch
1479  * @tc.type: FUNC
1480  * @tc.require:
1481  */
1482 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadSwipeSwitch_001, TestSize.Level1)
1483 {
1484     CALL_TEST_DEBUG;
1485     bool flag = false;
1486     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadSwipeSwitch(flag) == RET_OK);
1487     const char *touchpadFileName = "/data/service/el1/public/multimodalinput/touchpad_settings.xml";
1488     ASSERT_TRUE(remove(touchpadFileName) == RET_OK);
1489 }
1490 
1491 /**
1492  * @tc.name: InputManagerPointerTest_GetTouchpadSwipeSwitch_001
1493  * @tc.desc: Get touchpad swipe switch
1494  * @tc.type: FUNC
1495  * @tc.require:
1496  */
1497 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadSwipeSwitch_001, TestSize.Level1)
1498 {
1499     CALL_TEST_DEBUG;
1500     bool flag = true;
1501     InputManager::GetInstance()->SetTouchpadSwipeSwitch(flag);
1502     bool newFlag = true;
1503     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadSwipeSwitch(newFlag) == RET_OK);
1504     ASSERT_TRUE(flag == newFlag);
1505     const char *touchpadFileName = "/data/service/el1/public/multimodalinput/touchpad_settings.xml";
1506     ASSERT_TRUE(remove(touchpadFileName) == RET_OK);
1507 }
1508 
1509 /**
1510  * @tc.name: InputManagerPointerTest_SetTouchpadRightClickType_001
1511  * @tc.desc: Set touchpad right click type
1512  * @tc.type: FUNC
1513  * @tc.require:
1514  */
1515 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadRightClickType_001, TestSize.Level1)
1516 {
1517     CALL_TEST_DEBUG;
1518     int32_t type = 1;
1519     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadRightClickType(type) == RET_OK);
1520     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1521     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1522 }
1523 
1524 /**
1525  * @tc.name: InputManagerPointerTest_GetTouchpadRightClickType_001
1526  * @tc.desc: Get touchpad right click type
1527  * @tc.type: FUNC
1528  * @tc.require:
1529  */
1530 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadRightClickType_001, TestSize.Level1)
1531 {
1532     CALL_TEST_DEBUG;
1533     int32_t type = RIGHT_CLICK_TYPE;
1534     InputManager::GetInstance()->SetTouchpadRightClickType(type);
1535     int32_t newType = 1;
1536     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadRightClickType(newType) == RET_OK);
1537     ASSERT_TRUE(type == newType);
1538     const char *mouseFileName = "/data/service/el1/public/multimodalinput/mouse_settings.xml";
1539     ASSERT_TRUE(remove(mouseFileName) == RET_OK);
1540 }
1541 }  // namespace MMI
1542 }  // namespace OHOS