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 #undef MMI_LOG_TAG
22 #define MMI_LOG_TAG "InputManagerPointerTest"
23 
24 namespace OHOS {
25 namespace MMI {
26 namespace {
27 constexpr int32_t TIME_WAIT_FOR_OP = 100;
28 constexpr int32_t SIZE_TYPE_CASE = 3;
29 constexpr int32_t POINTER_ITEM_DISPLAY_X_ONE = 222;
30 constexpr int32_t POINTER_ITEM_DISPLAY_X_TWO = 444;
31 constexpr int32_t POINTER_ITEM_DISPLAY_X_THREE = 555;
32 constexpr int32_t POINTER_ITEM_DISPLAY_X_FOUR = 666;
33 constexpr int32_t POINTER_ITEM_DISPLAY_X_FIVE = 923;
34 constexpr int32_t POINTER_ITEM_DISPLAY_Y_ONE = 223;
35 constexpr int32_t POINTER_ITEM_DISPLAY_Y_TWO = 333;
36 constexpr int32_t POINTER_ITEM_DISPLAY_Y_THREE = 555;
37 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FOUR = 777;
38 constexpr int32_t POINTER_ITEM_DISPLAY_Y_FIVE = 793;
39 constexpr int32_t MOVE_MOUSE_OFFSET_ONE = -2000;
40 constexpr int32_t MOVE_MOUSE_OFFSET_TWO = 50;
41 constexpr int32_t MOVE_MOUSE_OFFSET_THREE = 100;
42 constexpr int32_t MOVE_MOUSE_OFFSET_FOUR = 150;
43 constexpr int32_t MOVE_MOUSE_OFFSET_FIVE = 300;
44 constexpr int32_t MOVE_MOUSE_OFFSET_SIX = 350;
45 constexpr int32_t MOVE_MOUSE_OFFSET_SEVEN = 400;
46 constexpr int32_t MOVE_MOUSE_OFFSET_EIGHT = 450;
47 constexpr int32_t MOVE_MOUSE_OFFSET_NINE = 500;
48 constexpr int32_t MOVE_MOUSE_OFFSET_TEN = 550;
49 constexpr int32_t MOVE_MOUSE_OFFSET_ELEVEN = 700;
50 constexpr int32_t MOVE_MOUSE_OFFSET_TWELVE = 1000;
51 constexpr int32_t MOVE_MOUSE_OFFSET_THIRTEEN = -1000;
52 constexpr int32_t POINTER_SPEED_ONE = 4;
53 constexpr int32_t POINTER_SPEED_TWO = 5;
54 constexpr int32_t POINTER_SPEED_THREE = 9;
55 constexpr int32_t POINTER_SPEED_FOUR = 11;
56 constexpr int32_t POINTER_SPEED_FIVE = 20;
57 constexpr int32_t RIGHT_CLICK_TYPE = 2;
58 constexpr int32_t INVAID_VALUE = -1;
59 constexpr int32_t MOUSE_ICON_HOT_SPOT = 20;
60 constexpr int64_t POINTER_ITEM_DOWNTIME_ONE = 9999;
61 constexpr int64_t POINTER_ITEM_DOWNTIME_TWO = 10001;
62 constexpr int64_t POINTER_ITEM_DOWNTIME_THREE = 10003;
63 constexpr int64_t POINTER_ITEM_DOWNTIME_FOUR = 10009;
64 constexpr int64_t POINTER_ITEM_DOWNTIME_FIVE = 10010;
65 
66 HapInfoParams infoManagerTestInfoParms = {
67     .userID = 1,
68     .bundleName = "InputManagerPointerTest",
69     .instIndex = 0,
70     .appIDDesc = "test",
71     .isSystemApp = true
72 };
73 
74 PermissionDef infoManagerTestPermDef = {
75     .permissionName = "ohos.permission.test",
76     .bundleName = "InputManagerPointerTest",
77     .grantMode = 1,
78     .availableLevel = APL_SYSTEM_CORE,
79     .label = "label",
80     .labelId = 1,
81     .description = "test pointer event",
82     .descriptionId = 1,
83 };
84 
85 PermissionStateFull infoManagerTestState = {
86     .permissionName = "ohos.permission.test",
87     .isGeneral = true,
88     .resDeviceID = { "local" },
89     .grantStatus = { PermissionState::PERMISSION_GRANTED },
90     .grantFlags = { 1 },
91 };
92 
93 HapPolicyParams infoManagerTestPolicyPrams = {
94     .apl = APL_SYSTEM_CORE,
95     .domain = "test.domain",
96     .permList = { infoManagerTestPermDef },
97     .permStateList = { infoManagerTestState }
98 };
99 } // namespace
100 
101 class AccessToken {
102 public:
AccessToken()103     AccessToken()
104     {
105         currentID_ = GetSelfTokenID();
106         AccessTokenIDEx tokenIdEx = AccessTokenKit::AllocHapToken(infoManagerTestInfoParms, infoManagerTestPolicyPrams);
107         accessID_ = tokenIdEx.tokenIDEx;
108         SetSelfTokenID(accessID_);
109     }
~AccessToken()110     ~AccessToken()
111     {
112         AccessTokenKit::DeleteToken(accessID_);
113         SetSelfTokenID(currentID_);
114     }
115 private:
116     uint64_t currentID_ = 0;
117     uint64_t accessID_ = 0;
118 };
119 
120 class InputManagerPointerTest : public testing::Test {
121 public:
122     void SetUp();
123     void TearDown();
124     static void SetUpTestCase();
125     std::string GetEventDump();
126 
127 private:
128     int32_t prePointerSpeed_ { 5 };
129     int32_t prePrimaryButton_ { 0 };
130     int32_t preScrollRows_ { 3 };
131     int32_t preTouchpadPointerSpeed_ { 9 };
132     int32_t preRightClickType_ { 1 };
133     int32_t prePointerSize_ { 1 };
134     int32_t prePointerColor_ { -1 };
135     bool preHoverScrollState_ { true };
136     bool preScrollSwitch_ { true };
137     bool preScrollDirection_ { true };
138     bool preTapSwitch_ { true };
139     bool prePinchSwitch_ { true };
140     bool preSwipeSwitch_ { true };
141     bool preRotateSwitch_ { true };
142     bool preDoubleTapAndDragState_ { true };
143 };
144 
SetUpTestCase()145 void InputManagerPointerTest::SetUpTestCase()
146 {
147     ASSERT_TRUE(TestUtil->Init());
148 }
149 
SetUp()150 void InputManagerPointerTest::SetUp()
151 {
152     TestUtil->SetRecvFlag(RECV_FLAG::RECV_FOCUS);
153     InputManager::GetInstance()->GetPointerSpeed(prePointerSpeed_);
154     InputManager::GetInstance()->GetMousePrimaryButton(prePrimaryButton_);
155     InputManager::GetInstance()->GetHoverScrollState(preHoverScrollState_);
156     InputManager::GetInstance()->GetMouseScrollRows(preScrollRows_);
157     InputManager::GetInstance()->GetTouchpadScrollSwitch(preScrollSwitch_);
158     InputManager::GetInstance()->GetTouchpadScrollDirection(preScrollDirection_);
159     InputManager::GetInstance()->GetTouchpadTapSwitch(preTapSwitch_);
160     InputManager::GetInstance()->GetTouchpadPointerSpeed(preTouchpadPointerSpeed_);
161     InputManager::GetInstance()->GetTouchpadPinchSwitch(prePinchSwitch_);
162     InputManager::GetInstance()->GetTouchpadSwipeSwitch(preSwipeSwitch_);
163     InputManager::GetInstance()->GetTouchpadRightClickType(preRightClickType_);
164     InputManager::GetInstance()->GetTouchpadRotateSwitch(preRotateSwitch_);
165     InputManager::GetInstance()->GetTouchpadDoubleTapAndDragState(preDoubleTapAndDragState_);
166     InputManager::GetInstance()->GetPointerSize(prePointerSize_);
167     InputManager::GetInstance()->GetPointerColor(prePointerColor_);
168 }
169 
TearDown()170 void InputManagerPointerTest::TearDown()
171 {
172     TestUtil->AddEventDump("");
173     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
174     InputManager::GetInstance()->SetPointerSpeed(prePointerSpeed_);
175     InputManager::GetInstance()->SetMousePrimaryButton(prePrimaryButton_);
176     InputManager::GetInstance()->SetHoverScrollState(preHoverScrollState_);
177     InputManager::GetInstance()->SetMouseScrollRows(preScrollRows_);
178     InputManager::GetInstance()->SetTouchpadScrollSwitch(preScrollSwitch_);
179     InputManager::GetInstance()->SetTouchpadScrollDirection(preScrollDirection_);
180     InputManager::GetInstance()->SetTouchpadTapSwitch(preTapSwitch_);
181     InputManager::GetInstance()->SetTouchpadPointerSpeed(preTouchpadPointerSpeed_);
182     InputManager::GetInstance()->SetTouchpadPinchSwitch(prePinchSwitch_);
183     InputManager::GetInstance()->SetTouchpadSwipeSwitch(preSwipeSwitch_);
184     InputManager::GetInstance()->SetTouchpadRotateSwitch(preRotateSwitch_);
185     InputManager::GetInstance()->SetTouchpadDoubleTapAndDragState(preDoubleTapAndDragState_);
186     InputManager::GetInstance()->SetTouchpadRightClickType(preRightClickType_);
187     InputManager::GetInstance()->SetPointerSize(prePointerSize_);
188     InputManager::GetInstance()->SetPointerColor(prePointerColor_);
189 }
190 
GetEventDump()191 std::string InputManagerPointerTest::GetEventDump()
192 {
193     return TestUtil->GetEventDump();
194 }
195 
196 /**
197  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_001
198  * @tc.desc: Verify that the mouse moves away from the window
199  * @tc.type: FUNC
200  * @tc.require: I5HMF3 I5HMEF
201  */
202 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_001, TestSize.Level1)
203 {
204     CALL_TEST_DEBUG;
205     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupPointerEvent014()};
206     ASSERT_NE(pointerEvent, nullptr);
207 #ifdef OHOS_BUILD_ENABLE_POINTER
208     AccessToken accessToken;
209     SimulateInputEventUtilTest(pointerEvent);
210 #endif  // OHOS_BUILD_ENABLE_POINTER
211 }
212 
213 /**
214  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_002
215  * @tc.desc: Verify return mouse away from the window
216  * @tc.type: FUNC
217  * @tc.require: I5HMF3 I5HMEF
218  */
219 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_002, TestSize.Level1)
220 {
221     CALL_TEST_DEBUG;
222     std::shared_ptr<KeyEvent> keyEvent{InputManagerUtil::SetupKeyEvent002()};
223     ASSERT_NE(keyEvent, nullptr);
224 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
225     AccessToken accessToken;
226     SimulateInputEventUtilTest(keyEvent);
227 #endif  // OHOS_BUILD_ENABLE_KEYBOARD
228 }
229 
230 /**
231  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_003
232  * @tc.desc: Verify that the home button and mouse leave the window
233  * @tc.type: FUNC
234  * @tc.require: I5HMF3 I5HMEF
235  */
236 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_003, TestSize.Level1)
237 {
238     CALL_TEST_DEBUG;
239     std::shared_ptr<KeyEvent> keyEvent{InputManagerUtil::SetupKeyEvent003()};
240     ASSERT_NE(keyEvent, nullptr);
241 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
242     AccessToken accessToken;
243     SimulateInputEventUtilTest(keyEvent);
244 #endif  // OHOS_BUILD_ENABLE_KEYBOARD
245 }
246 
247 /**
248  * @tc.name: InputManagerPointerTest_MouseEventEnterAndLeave_004
249  * @tc.desc: Verify that the mouse moves to the navigation bar to leave the window
250  * @tc.type: FUNC
251  * @tc.require: I5HMF3 I5HMEF
252  */
253 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseEventEnterAndLeave_004, TestSize.Level1)
254 {
255     CALL_TEST_DEBUG;
256     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupPointerEvent015()};
257     ASSERT_NE(pointerEvent, nullptr);
258 #ifdef OHOS_BUILD_ENABLE_POINTER
259     AccessToken accessToken;
260     SimulateInputEventUtilTest(pointerEvent);
261 #endif  // OHOS_BUILD_ENABLE_POINTER
262 }
263 
264 /**
265  * @tc.name: InputManagerPointerTest_AddMonitor_001
266  * @tc.desc: Verify pointerevent monitor
267  * @tc.type: FUNC
268  * @tc.require:
269  */
270 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMonitor_001, TestSize.Level1)
271 {
272     CALL_TEST_DEBUG;
__anonf35bd14b0202(std::shared_ptr<PointerEvent> event) 273     auto pointerEventFun = [](std::shared_ptr<PointerEvent> event) { MMI_HILOGD("Add monitor success"); };
274     int32_t monitorId = InputManager::GetInstance()->AddMonitor(pointerEventFun);
275 #if (defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)) && defined(OHOS_BUILD_ENABLE_MONITOR)
276     ASSERT_NE(monitorId, INVALID_HANDLER_ID);
277 #else
278     ASSERT_EQ(monitorId, ERROR_UNSUPPORT);
279 #endif  // OHOS_BUILD_ENABLE_MONITOR ||  OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
280     InputManager::GetInstance()->RemoveMonitor(monitorId);
281 }
282 
283 /**
284  * @tc.name: InputManagerPointerTest_AddMonitor_002
285  * @tc.desc: Verify keyevent monitor
286  * @tc.type: FUNC
287  * @tc.require:
288  */
289 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMonitor_002, TestSize.Level1)
290 {
291     CALL_TEST_DEBUG;
__anonf35bd14b0302(std::shared_ptr<KeyEvent> event) 292     auto keyEventFun = [](std::shared_ptr<KeyEvent> event) { MMI_HILOGD("Add monitor success"); };
293     int32_t monitorId = InputManager::GetInstance()->AddMonitor(keyEventFun);
294 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_MONITOR)
295     ASSERT_NE(monitorId, INVALID_HANDLER_ID);
296 #else
297     ASSERT_EQ(monitorId, ERROR_UNSUPPORT);
298 #endif  // OHOS_BUILD_ENABLE_KEYBOARD || OHOS_BUILD_ENABLE_MONITOR
299     InputManager::GetInstance()->RemoveMonitor(monitorId);
300 }
301 
302 /**
303  * @tc.name: InputManagerPointerTest_OnAddScreenMonitor_001
304  * @tc.desc: Verify touchscreen down event monitor
305  * @tc.type: FUNC
306  * @tc.require:
307  */
308 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddScreenMonitor_001, TestSize.Level1)
309 {
310     CALL_TEST_DEBUG;
311     auto pointerEvent = InputManagerUtil::SetupPointerEvent001();
312     ASSERT_NE(pointerEvent, nullptr);
313 
314     auto callbackPtr = GetPtr<InputEventCallback>();
315     ASSERT_TRUE(callbackPtr != nullptr);
316     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
317 #ifdef OHOS_BUILD_ENABLE_MONITOR
318     EXPECT_TRUE(IsValidHandlerId(monitorId));
319 #else
320     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
321 #endif  // OHOS_BUILD_ENABLE_MONITOR
322     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
323 
324     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
325     InputManagerUtil::TestRemoveMonitor(monitorId);
326 }
327 
328 /**
329  * @tc.name: InputManagerPointerTest_OnAddScreenMonitor_002
330  * @tc.desc: Verify touchscreen move event multiple monitor
331  * @tc.type: FUNC
332  * @tc.require:
333  */
334 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddScreenMonitor_002, TestSize.Level1)
335 {
336     CALL_TEST_DEBUG;
337     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
338     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
339     std::vector<int32_t> ids(N_TEST_CASES);
340     std::vector<std::shared_ptr<InputEventCallback>> cbs(N_TEST_CASES);
341 
342     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; i++) {
343         cbs[i] = GetPtr<InputEventCallback>();
344         ASSERT_TRUE(cbs[i] != nullptr);
345         ids[i] = InputManagerUtil::TestAddMonitor(cbs[i]);
346 #ifdef OHOS_BUILD_ENABLE_MONITOR
347         EXPECT_TRUE(IsValidHandlerId(ids[i]));
348 #else
349         EXPECT_EQ(ids[i], ERROR_UNSUPPORT);
350 #endif  // OHOS_BUILD_ENABLE_MONITOR
351         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
352     }
353 
354     auto pointerEvent = InputManagerUtil::SetupPointerEvent002();
355     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
356 
357     for (const auto &id : ids) {
358         std::string sPointerEs = GetEventDump();
359         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
360 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
361         ASSERT_TRUE(!sPointerEs.empty());
362 #else
363         ASSERT_TRUE(sPointerEs.empty());
364 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
365         if (IsValidHandlerId(id)) {
366             InputManagerUtil::TestRemoveMonitor(id);
367         }
368         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
369     }
370 
371     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; i++) {
372         InputManagerUtil::TestRemoveMonitor(ids[i]);
373     }
374 }
375 
376 /**
377  * @tc.name: InputManagerPointerTest_OnAddScreenMonitor_003
378  * @tc.desc: Verify touchscreen up event monitor
379  * @tc.type: FUNC
380  * @tc.require:
381  */
382 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddScreenMonitor_003, TestSize.Level1)
383 {
384     CALL_TEST_DEBUG;
385     auto pointerEvent = InputManagerUtil::SetupPointerEvent003();
386     ASSERT_NE(pointerEvent, nullptr);
387 
388     auto callbackPtr = GetPtr<InputEventCallback>();
389     ASSERT_TRUE(callbackPtr != nullptr);
390     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
391 #ifdef OHOS_BUILD_ENABLE_MONITOR
392     EXPECT_TRUE(IsValidHandlerId(monitorId));
393 #else
394     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
395 #endif  // OHOS_BUILD_ENABLE_MONITOR
396     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
397 
398 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
399     TestSimulateInputEvent(pointerEvent);
400 #endif  // OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
401 
402     if (IsValidHandlerId(monitorId)) {
403         InputManagerUtil::TestRemoveMonitor(monitorId);
404         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
405     }
406     InputManagerUtil::TestRemoveMonitor(monitorId);
407 }
408 
409 /**
410  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_001
411  * @tc.desc: Verify touchpad down event monitor
412  * @tc.type: FUNC
413  * @tc.require:
414  */
415 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_001, TestSize.Level1)
416 {
417     CALL_TEST_DEBUG;
418     auto pointerEvent = PointerEvent::Create();
419     ASSERT_NE(pointerEvent, nullptr);
420     PointerEvent::PointerItem item;
421     item.SetDownTime(POINTER_ITEM_DOWNTIME_THREE);
422     item.SetPressed(true);
423     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_ONE);
424     item.SetDeviceId(1);
425     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_TWO);
426     item.SetPointerId(0);
427     pointerEvent->AddPointerItem(item);
428     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
429     pointerEvent->SetPointerId(0);
430     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
431 
432     auto callbackPtr = GetPtr<InputEventCallback>();
433     ASSERT_TRUE(callbackPtr != nullptr);
434     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
435 #ifdef OHOS_BUILD_ENABLE_MONITOR
436     EXPECT_TRUE(IsValidHandlerId(monitorId));
437 #else
438     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
439 #endif  // OHOS_BUILD_ENABLE_MONITOR
440     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
441 
442     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
443     InputManagerUtil::TestRemoveMonitor(monitorId);
444 }
445 
446 /**
447  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_002
448  * @tc.desc: Verify touchpad move event monitor
449  * @tc.type: FUNC
450  * @tc.require:
451  */
452 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_002, TestSize.Level1)
453 {
454     CALL_TEST_DEBUG;
455     auto pointerEvent = PointerEvent::Create();
456     ASSERT_NE(pointerEvent, nullptr);
457     PointerEvent::PointerItem item;
458     item.SetPointerId(0);
459     item.SetDownTime(POINTER_ITEM_DOWNTIME_TWO);
460     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_TWO);
461     item.SetPressed(true);
462     item.SetDeviceId(1);
463     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_THREE);
464     pointerEvent->AddPointerItem(item);
465     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
466     pointerEvent->SetPointerId(0);
467     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
468 
469     auto callbackPtr = GetPtr<InputEventCallback>();
470     ASSERT_TRUE(callbackPtr != nullptr);
471     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
472 #ifdef OHOS_BUILD_ENABLE_MONITOR
473     EXPECT_TRUE(IsValidHandlerId(monitorId));
474 #else
475     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
476 #endif  // OHOS_BUILD_ENABLE_MONITOR
477     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
478 
479     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
480     InputManagerUtil::TestRemoveMonitor(monitorId);
481 }
482 
483 /**
484  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_003
485  * @tc.desc: Verify touchpad up event monitor
486  * @tc.type: FUNC
487  * @tc.require:
488  */
489 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_003, TestSize.Level1)
490 {
491     CALL_TEST_DEBUG;
492     auto pointerEvent = PointerEvent::Create();
493     ASSERT_NE(pointerEvent, nullptr);
494     PointerEvent::PointerItem item;
495     item.SetDownTime(POINTER_ITEM_DOWNTIME_ONE);
496     item.SetPointerId(0);
497     item.SetPressed(true);
498     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FOUR);
499     item.SetDeviceId(1);
500     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FOUR);
501     pointerEvent->AddPointerItem(item);
502     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
503     pointerEvent->SetPointerId(0);
504     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
505 
506     auto callbackPtr = GetPtr<InputEventCallback>();
507     ASSERT_TRUE(callbackPtr != nullptr);
508     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
509 #ifdef OHOS_BUILD_ENABLE_MONITOR
510     EXPECT_TRUE(IsValidHandlerId(monitorId));
511 #else
512     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
513 #endif  // OHOS_BUILD_ENABLE_MONITOR
514     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
515 
516     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
517     InputManagerUtil::TestRemoveMonitor(monitorId);
518 }
519 
520 /**
521  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_004
522  * @tc.desc: Verify touchpad multiple monitor
523  * @tc.type: FUNC
524  * @tc.require:
525  */
526 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_004, TestSize.Level1)
527 {
528     CALL_TEST_DEBUG;
529     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
530     auto pointerEvent = PointerEvent::Create();
531     ASSERT_NE(pointerEvent, nullptr);
532     PointerEvent::PointerItem item;
533     item.SetDownTime(POINTER_ITEM_DOWNTIME_FOUR);
534     item.SetDeviceId(1);
535     item.SetPointerId(0);
536     item.SetPressed(true);
537     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_THREE);
538     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_FIVE);
539     pointerEvent->AddPointerItem(item);
540     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
541     pointerEvent->SetPointerId(0);
542     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
543 
544     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
545     std::vector<int32_t> ids(N_TEST_CASES);
546     auto callbackPtr = GetPtr<InputEventCallback>();
547     ASSERT_TRUE(callbackPtr != nullptr);
548     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
549         ids[i] = InputManagerUtil::TestAddMonitor(callbackPtr);
550 #ifdef OHOS_BUILD_ENABLE_MONITOR
551         EXPECT_TRUE(IsValidHandlerId(ids[i]));
552 #else
553         EXPECT_EQ(ids[i], ERROR_UNSUPPORT);
554 #endif  // OHOS_BUILD_ENABLE_MONITOR
555         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
556     }
557 
558     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
559 
560     for (const auto &id : ids) {
561         std::string sPointerEs = GetEventDump();
562         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
563 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_MONITOR)
564         ASSERT_TRUE(!sPointerEs.empty());
565 #else
566         ASSERT_TRUE(sPointerEs.empty());
567 #endif  // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_MONITOR
568         if (IsValidHandlerId(id)) {
569             InputManagerUtil::TestRemoveMonitor(id);
570         }
571         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
572     }
573 
574     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
575         InputManagerUtil::TestRemoveMonitor(ids[i]);
576     }
577 }
578 
579 /**
580  * @tc.name: InputManagerPointerTest_OnAddTouchPadMonitor_005
581  * @tc.desc: Verify touchpad monitor
582  * @tc.type: FUNC
583  * @tc.require:
584  */
585 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddTouchPadMonitor_005, TestSize.Level1)
586 {
587     CALL_TEST_DEBUG;
588     auto pointerEvent = PointerEvent::Create();
589     ASSERT_NE(pointerEvent, nullptr);
590     PointerEvent::PointerItem item;
591     item.SetDownTime(POINTER_ITEM_DOWNTIME_FIVE);
592     item.SetPointerId(0);
593     item.SetDeviceId(1);
594     item.SetPressed(true);
595     item.SetDisplayX(POINTER_ITEM_DISPLAY_X_FIVE);
596     item.SetDisplayY(POINTER_ITEM_DISPLAY_Y_ONE);
597     pointerEvent->AddPointerItem(item);
598     pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
599     pointerEvent->SetPointerId(0);
600     pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
601 
602     auto callbackPtr = GetPtr<InputEventCallback>();
603     ASSERT_TRUE(callbackPtr != nullptr);
604     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
605 #ifdef OHOS_BUILD_ENABLE_MONITOR
606     EXPECT_TRUE(IsValidHandlerId(monitorId));
607 #else
608     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
609 #endif  // OHOS_BUILD_ENABLE_MONITOR
610     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
611 
612     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
613     InputManagerUtil::TestRemoveMonitor(monitorId);
614 }
615 
616 /**
617  * @tc.name: InputManagerPointerTest_AddMouseMonitor_001
618  * @tc.desc: Verify mouse down event monitor
619  * @tc.type: FUNC
620  * @tc.require:
621  */
622 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMouseMonitor_001, TestSize.Level1)
623 {
624     CALL_TEST_DEBUG;
625     auto callbackPtr = GetPtr<InputEventCallback>();
626     ASSERT_NE(callbackPtr, nullptr);
627     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
628 #ifdef OHOS_BUILD_ENABLE_MONITOR
629     EXPECT_TRUE(IsValidHandlerId(monitorId));
630 #else
631     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
632 #endif  // OHOS_BUILD_ENABLE_MONITOR
633     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
634 
635     auto pointerEvent = InputManagerUtil::SetupPointerEvent005();
636     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
637     InputManagerUtil::TestRemoveMonitor(monitorId);
638 }
639 
640 /**
641  * @tc.name: InputManagerPointerTest_AddMouseMonitor_003
642  * @tc.desc: Verify mouse up event monitor
643  * @tc.type: FUNC
644  * @tc.require:
645  */
646 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMouseMonitor_003, TestSize.Level1)
647 {
648     CALL_TEST_DEBUG;
649     auto callbackPtr = GetPtr<InputEventCallback>();
650     ASSERT_TRUE(callbackPtr != nullptr);
651     int32_t monitorId = InputManagerUtil::TestAddMonitor(callbackPtr);
652 #ifdef OHOS_BUILD_ENABLE_MONITOR
653     EXPECT_TRUE(IsValidHandlerId(monitorId));
654 #else
655     EXPECT_EQ(monitorId, ERROR_UNSUPPORT);
656 #endif  // OHOS_BUILD_ENABLE_MONITOR
657     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
658 
659     auto pointerEvent = InputManagerUtil::SetupPointerEvent007();
660     ASSERT_TRUE(pointerEvent != nullptr);
661     InputManagerUtil::TestMonitor(monitorId, pointerEvent);
662     InputManagerUtil::TestRemoveMonitor(monitorId);
663 }
664 
665 /**
666  * @tc.name: InputManagerPointerTest_AddMouseMonitor_004
667  * @tc.desc: Verify monitor upper limit
668  * @tc.type: FUNC
669  * @tc.require:
670  */
671 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_AddMouseMonitor_004, TestSize.Level1)
672 {
673     CALL_TEST_DEBUG;
674     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
675     const std::vector<int32_t>::size_type N_TEST_CASES{MAX_N_INPUT_HANDLERS - 1};
676     std::vector<int32_t> ids;
677     int32_t maxMonitor = 0;
678 
679     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
680         auto callbackPtr = GetPtr<InputEventCallback>();
681         ASSERT_TRUE(callbackPtr != nullptr);
682         maxMonitor = InputManagerUtil::TestAddMonitor(callbackPtr);
683         if (IsValidHandlerId(maxMonitor)) {
684             ids.push_back(maxMonitor);
685             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
686         }
687     }
688 
689     auto pointerEvent = InputManagerUtil::SetupPointerEvent007();
690     pointerEvent->AddFlag(PointerEvent::EVENT_FLAG_NO_INTERCEPT);
691     ASSERT_TRUE(pointerEvent != nullptr);
692     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
693     maxMonitor = 0;
694     for (const auto &id : ids) {
695         if (!GetEventDump().empty()) {
696             maxMonitor++;
697         }
698         if (IsValidHandlerId(id)) {
699             InputManagerUtil::TestRemoveMonitor(id);
700             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
701         }
702     }
703 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_MONITOR)
704     ASSERT_EQ(maxMonitor, ids.size());
705 #else
706     ASSERT_EQ(maxMonitor, 0);
707 #endif  // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_MONITOR
708 }
709 
710 /**
711  * @tc.name: InputManagerPointerTest_OnAddKeyboardMonitor_001
712  * @tc.desc: Verify Keyboard multiple monitor
713  * @tc.type: FUNC
714  * @tc.require:
715  */
716 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddKeyboardMonitor_001, TestSize.Level1)
717 {
718     CALL_TEST_DEBUG;
719     TestUtil->SetRecvFlag(RECV_FLAG::RECV_MONITOR);
720     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
721     std::vector<int32_t> ids;
722     auto callbackPtr = GetPtr<InputEventCallback>();
723     ASSERT_TRUE(callbackPtr != nullptr);
724     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
725         int32_t id = InputManagerUtil::TestAddMonitor(callbackPtr);
726         if (IsValidHandlerId(id)) {
727             ids.push_back(id);
728             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
729         }
730     }
731 
732     auto injectEvent = InputManagerUtil::SetupKeyEvent001();
733     ASSERT_TRUE(injectEvent != nullptr);
734     InputManager::GetInstance()->SimulateInputEvent(injectEvent);
735 
736     for (const auto &id : ids) {
737         std::string sPointerEs = GetEventDump();
738         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
739 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_MONITOR)
740         ASSERT_TRUE(!sPointerEs.empty());
741 #else
742         ASSERT_TRUE(sPointerEs.empty());
743 #endif  // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_MONITOR
744         if (IsValidHandlerId(id)) {
745             InputManagerUtil::TestRemoveMonitor(id);
746         }
747         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
748     }
749 }
750 
751 /**
752  * @tc.name: InputManagerPointerTest_OnAddKeyboardMonitor_002
753  * @tc.desc: Verify Keyboard multiple monitor
754  * @tc.type: FUNC
755  * @tc.require:
756  */
757 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_OnAddKeyboardMonitor_002, TestSize.Level1)
758 {
759     CALL_TEST_DEBUG;
760     const std::vector<int32_t>::size_type N_TEST_CASES{SIZE_TYPE_CASE};
761     std::vector<int32_t> ids;
762     auto callbackPtr = GetPtr<InputEventCallback>();
763     ASSERT_TRUE(callbackPtr != nullptr);
764     for (std::vector<int32_t>::size_type i = 0; i < N_TEST_CASES; ++i) {
765         int32_t id = InputManagerUtil::TestAddMonitor(callbackPtr);
766         if (IsValidHandlerId(id)) {
767             ids.push_back(id);
768             std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
769         }
770     }
771 
772     auto injectEvent = InputManagerUtil::SetupKeyEvent001();
773     ASSERT_TRUE(injectEvent != nullptr);
774     injectEvent->SetKeyCode(KeyEvent::KEYCODE_UNKNOWN);
775     InputManager::GetInstance()->SimulateInputEvent(injectEvent);
776 
777     for (const auto &id : ids) {
778         std::string sPointerEs = GetEventDump();
779         MMI_HILOGD("sPointerEs:%{public}s", sPointerEs.c_str());
780         ASSERT_TRUE(sPointerEs.empty());
781         if (IsValidHandlerId(id)) {
782             InputManagerUtil::TestRemoveMonitor(id);
783         }
784         std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
785     }
786 }
787 
788 /**
789  * @tc.name: InputManagerPointerTest_SetWindowInputEventConsumer_001
790  * @tc.desc: Verify pointerEvent report eventHandler
791  * @tc.type: FUNC
792  * @tc.require: I5HMDY
793  */
794 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetWindowInputEventConsumer_001, TestSize.Level1)
795 {
796     CALL_TEST_DEBUG;
797     auto runner = AppExecFwk::EventRunner::Create("cooperateHdrTest");
798     ASSERT_TRUE(runner != nullptr);
799     auto eventHandler = std::make_shared<AppExecFwk::EventHandler>(runner);
800     ASSERT_TRUE(eventHandler != nullptr);
801     uint64_t runnerThreadId = 0;
802 
__anonf35bd14b0402() 803     auto fun = [&runnerThreadId]() {
804         runnerThreadId = GetThisThreadId();
805         MMI_HILOGD("Create eventHandler is threadId:%{public}" PRIu64, runnerThreadId);
806         ASSERT_TRUE(runnerThreadId != 0);
807     };
808     eventHandler->PostSyncTask(fun, AppExecFwk::EventHandler::Priority::IMMEDIATE);
809     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
810     auto consumer = GetPtr<WindowEventConsumer>();
811     ASSERT_TRUE(consumer != nullptr);
812     MMI::InputManager::GetInstance()->SetWindowInputEventConsumer(consumer, eventHandler);
813     auto pointerEvent = InputManagerUtil::SetupPointerEvent005();
814     pointerEvent->AddFlag(PointerEvent::EVENT_FLAG_NO_INTERCEPT);
815     ASSERT_TRUE(pointerEvent != nullptr);
816     AccessToken accessToken;
817     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
818     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
819     uint64_t consumerThreadId = consumer->GetConsumerThreadId();
820 #ifdef OHOS_BUILD_ENABLE_POINTER
821     EXPECT_EQ(runnerThreadId, consumerThreadId);
822 #else
823     ASSERT_TRUE(runnerThreadId != consumerThreadId);
824 #endif  // OHOS_BUILD_ENABLE_POINTER
825 }
826 
827 /**
828  * @tc.name: InputManagerPointerTest_SetWindowInputEventConsumer_002
829  * @tc.desc: Verify keyEvent report eventHandler
830  * @tc.type: FUNC
831  * @tc.require: I5HMDY
832  */
833 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetWindowInputEventConsumer_002, TestSize.Level1)
834 {
835     CALL_TEST_DEBUG;
836     const std::string threadTest = "threadNameTest";
837     auto runner = AppExecFwk::EventRunner::Create(threadTest);
838     ASSERT_TRUE(runner != nullptr);
839     auto eventHandler = std::make_shared<AppExecFwk::EventHandler>(runner);
840     ASSERT_TRUE(eventHandler != nullptr);
841     uint64_t runnerThreadId = 0;
842 
__anonf35bd14b0502() 843     auto fun = [&runnerThreadId]() {
844         runnerThreadId = GetThisThreadId();
845         MMI_HILOGD("Create eventHandler is threadId:%{public}" PRIu64, runnerThreadId);
846         ASSERT_TRUE(runnerThreadId != 0);
847     };
848     eventHandler->PostSyncTask(fun, AppExecFwk::EventHandler::Priority::IMMEDIATE);
849     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
850     auto consumer = GetPtr<WindowEventConsumer>();
851     ASSERT_TRUE(consumer != nullptr);
852     MMI::InputManager::GetInstance()->SetWindowInputEventConsumer(consumer, eventHandler);
853     auto keyEvent = InputManagerUtil::SetupKeyEvent001();
854     ASSERT_TRUE(keyEvent != nullptr);
855     keyEvent->SetKeyCode(KeyEvent::KEYCODE_A);
856     AccessToken accessToken;
857     InputManager::GetInstance()->SimulateInputEvent(keyEvent);
858     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
859     uint64_t consumerThreadId = consumer->GetConsumerThreadId();
860 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
861     EXPECT_EQ(runnerThreadId, consumerThreadId);
862 #else
863     ASSERT_TRUE(runnerThreadId != consumerThreadId);
864 #endif  // OHOS_BUILD_ENABLE_KEYBOARD
865 }
866 
867 /**
868  * @tc.name: InputManagerPointerTest_MoveMouse_01
869  * @tc.desc: Verify move mouse
870  * @tc.type: FUNC
871  * @tc.require:
872  */
873 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MoveMouse_01, TestSize.Level1)
874 {
875     CALL_TEST_DEBUG;
876     ASSERT_NO_FATAL_FAILURE(InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO));
877 }
878 
879 /**
880  * @tc.name: InputManagerPointerTest_MoveMouse_02
881  * @tc.desc: Verify move mouse
882  * @tc.type: FUNC
883  * @tc.require:
884  */
885 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MoveMouse_02, TestSize.Level1)
886 {
887     CALL_TEST_DEBUG;
888     ASSERT_NO_FATAL_FAILURE(
889         InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THIRTEEN, MOVE_MOUSE_OFFSET_THREE));
890 }
891 
892 /**
893  * @tc.name: InputManagerPointerTest_MouseHotArea_001
894  * @tc.desc: Mouse event Search window by pointerHotAreas
895  * @tc.type: FUNC
896  * @tc.require: I5HMCB
897  */
898 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseHotArea_001, TestSize.Level1)
899 {
900     CALL_TEST_DEBUG;
901     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupMouseEvent001()};
902     ASSERT_TRUE(pointerEvent != nullptr);
903     InputManager::GetInstance()->SimulateInputEvent(pointerEvent);
904     ASSERT_EQ(pointerEvent->GetSourceType(), PointerEvent::SOURCE_TYPE_MOUSE);
905 }
906 
907 /**
908  * @tc.name: InputManagerPointerTest_MouseHotArea_002
909  * @tc.desc: Mouse event Search window by pointerHotAreas
910  * @tc.type: FUNC
911  * @tc.require: I5HMCB
912  */
913 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_MouseHotArea_002, TestSize.Level1)
914 {
915     CALL_TEST_DEBUG;
916     std::shared_ptr<PointerEvent> pointerEvent{InputManagerUtil::SetupMouseEvent002()};
917     ASSERT_TRUE(pointerEvent != nullptr);
918     ASSERT_EQ(pointerEvent->GetSourceType(), PointerEvent::SOURCE_TYPE_MOUSE);
919 }
920 
921 /**
922  * @tc.name: InputManagerPointerTest_SetPointerLocation_001
923  * @tc.desc: Sets the absolute coordinate of mouse.
924  * @tc.type: FUNC
925  * @tc.require:
926  */
927 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerLocation_001, TestSize.Level1)
928 {
929     CALL_TEST_DEBUG;
930     int32_t x = 0;
931     int32_t y = 0;
932     ASSERT_NO_FATAL_FAILURE(InputManager::GetInstance()->SetPointerLocation(x, y));
933 }
934 
935 /**
936  * @tc.name: InputManagerPointerTest_SetPointerLocation_002
937  * @tc.desc: Sets the absolute coordinate of mouse.
938  * @tc.type: FUNC
939  * @tc.require:
940  */
941 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerLocation_002, TestSize.Level1)
942 {
943     CALL_TEST_DEBUG;
944     int32_t x = 300;
945     int32_t y = 300;
946     ASSERT_TRUE(InputManager::GetInstance()->SetPointerLocation(x, y) == RET_OK);
947 }
948 
949 /**
950  * @tc.name: InputManagerPointerTest_SetPointerVisible_001
951  * @tc.desc: Sets whether the pointer icon is visible
952  * @tc.type: FUNC
953  * @tc.require: I530VT
954  */
955 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerVisible_001, TestSize.Level1)
956 {
957     bool isVisible{true};
958     if (InputManager::GetInstance()->SetPointerVisible(isVisible) == RET_OK) {
959         ASSERT_TRUE(InputManager::GetInstance()->IsPointerVisible() == isVisible);
960     }
961 }
962 
963 /**
964  * @tc.name: InputManagerPointerTest_SetPointerVisible_002
965  * @tc.desc: Sets whether the pointer icon is visible
966  * @tc.type: FUNC
967  * @tc.require: I530VT
968  */
969 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerVisible_002, TestSize.Level1)
970 {
971     bool isVisible{false};
972     if (InputManager::GetInstance()->SetPointerVisible(isVisible) == RET_OK) {
973         ASSERT_TRUE(InputManager::GetInstance()->IsPointerVisible() == isVisible);
974     }
975 }
976 
977 /**
978  * @tc.name: InputManagerPointerTest_SetPointSpeed_001
979  * @tc.desc: Abnormal speed value processing
980  * @tc.type: FUNC
981  * @tc.require: I530XP I530UX
982  */
983 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_001, TestSize.Level1)
984 {
985     CALL_TEST_DEBUG;
986     const int32_t speed = INVAID_VALUE;
987     InputManager::GetInstance()->SetPointerSpeed(speed);
988     int32_t speed1;
989     InputManager::GetInstance()->GetPointerSpeed(speed1);
990     ASSERT_EQ(speed1, 1);
991     InputManager::GetInstance()->MoveMouse(-MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
992     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
993     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
994     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
995     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
996     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
997     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
998     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
999     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1000     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
1001     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1002     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
1003     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1004 }
1005 
1006 /**
1007  * @tc.name: InputManagerPointerTest_SetPointSpeed_002
1008  * @tc.desc: Normal speed value processing
1009  * @tc.type: FUNC
1010  * @tc.require: I530XP I530UX
1011  */
1012 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_002, TestSize.Level1)
1013 {
1014     CALL_TEST_DEBUG;
1015     const int32_t speed = 1;
1016     InputManager::GetInstance()->SetPointerSpeed(speed);
1017     int32_t speed1;
1018     InputManager::GetInstance()->GetPointerSpeed(speed1);
1019     ASSERT_EQ(speed1, speed);
1020     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
1021     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
1022     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1023     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
1024     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1025     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
1026     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1027     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
1028     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1029     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
1030     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1031     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
1032     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1033 }
1034 
1035 /**
1036  * @tc.name: InputManagerPointerTest_SetPointSpeed_003
1037  * @tc.desc: Normal speed value processing
1038  * @tc.type: FUNC
1039  * @tc.require: I530XP I530UX
1040  */
1041 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_003, TestSize.Level1)
1042 {
1043     CALL_TEST_DEBUG;
1044     const int32_t speed = POINTER_SPEED_ONE;
1045     InputManager::GetInstance()->SetPointerSpeed(speed);
1046     int32_t speed1;
1047     InputManager::GetInstance()->GetPointerSpeed(speed1);
1048     ASSERT_EQ(speed1, speed);
1049     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
1050     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
1051     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1052     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
1053     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1054     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
1055     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1056     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
1057     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1058     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
1059     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1060     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
1061     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1062 }
1063 
1064 /**
1065  * @tc.name: InputManagerPointerTest_SetPointSpeed_004
1066  * @tc.desc: Normal speed value processing
1067  * @tc.type: FUNC
1068  * @tc.require: I530XP I530UX
1069  */
1070 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_004, TestSize.Level1)
1071 {
1072     CALL_TEST_DEBUG;
1073     const int32_t speed = POINTER_SPEED_FOUR;
1074     InputManager::GetInstance()->SetPointerSpeed(speed);
1075     int32_t speed1;
1076     InputManager::GetInstance()->GetPointerSpeed(speed1);
1077     ASSERT_EQ(speed1, speed);
1078     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
1079     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
1080     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1081     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
1082     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1083     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
1084     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1085     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
1086     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1087     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
1088     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1089     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
1090     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1091 }
1092 
1093 /**
1094  * @tc.name: InputManagerPointerTest_SetPointSpeed_005
1095  * @tc.desc: Abnormal speed value processing
1096  * @tc.type: FUNC
1097  * @tc.require: I530XP I530UX
1098  */
1099 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointSpeed_005, TestSize.Level1)
1100 {
1101     CALL_TEST_DEBUG;
1102     const int32_t speed = POINTER_SPEED_FIVE;
1103     InputManager::GetInstance()->SetPointerSpeed(speed);
1104     int32_t speed1;
1105     InputManager::GetInstance()->GetPointerSpeed(speed1);
1106     ASSERT_EQ(speed1, POINTER_SPEED_FOUR);
1107     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ONE, MOVE_MOUSE_OFFSET_ONE);
1108     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_TWO, MOVE_MOUSE_OFFSET_TWO);
1109     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1110     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_THREE, MOVE_MOUSE_OFFSET_FOUR);
1111     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1112     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_FIVE, MOVE_MOUSE_OFFSET_SIX);
1113     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1114     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_SEVEN, MOVE_MOUSE_OFFSET_EIGHT);
1115     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1116     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_NINE, MOVE_MOUSE_OFFSET_TEN);
1117     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1118     InputManager::GetInstance()->MoveMouse(MOVE_MOUSE_OFFSET_ELEVEN, MOVE_MOUSE_OFFSET_TWELVE);
1119     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP));
1120 }
1121 
1122 /**
1123  * @tc.name: InputManagerPointerTest_SetHoverScrollState_001
1124  * @tc.desc: Sets mouse hover scroll state in inactive window
1125  * @tc.type: FUNC
1126  * @tc.require: I530XS
1127  */
1128 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetHoverScrollState_001, TestSize.Level1)
1129 {
1130     CALL_TEST_DEBUG;
1131     ASSERT_TRUE(InputManager::GetInstance()->SetHoverScrollState(false) == RET_OK);
1132     InputManager::GetInstance()->SetHoverScrollState(true);
1133 }
1134 
1135 /**
1136  * @tc.name: InputManagerPointerTest_SetHoverScrollState_002
1137  * @tc.desc: Sets mouse hover scroll state in inactive window
1138  * @tc.type: FUNC
1139  * @tc.require: I530XS
1140  */
1141 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetHoverScrollState_002, TestSize.Level1)
1142 {
1143     CALL_TEST_DEBUG;
1144     ASSERT_TRUE(InputManager::GetInstance()->SetHoverScrollState(true) == RET_OK);
1145 }
1146 
1147 /**
1148  * @tc.name: InputManagerPointerTest_GetHoverScrollState_001
1149  * @tc.desc: Gets mouse hover scroll state in inactive window
1150  * @tc.type: FUNC
1151  * @tc.require: I530XS
1152  */
1153 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetHoverScrollState_001, TestSize.Level1)
1154 {
1155     CALL_TEST_DEBUG;
1156     bool state = true;
1157     if (InputManager::GetInstance()->SetHoverScrollState(state) == RET_OK) {
1158         ASSERT_TRUE(InputManager::GetInstance()->GetHoverScrollState(state) == RET_OK);
1159         ASSERT_TRUE(state);
1160     }
1161 }
1162 
1163 /**
1164  * @tc.name: InputManagerPointerTest_SetMousePrimaryButton_001
1165  * @tc.desc: Sets mouse primary button
1166  * @tc.type: FUNC
1167  * @tc.require: I530XS
1168  */
1169 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMousePrimaryButton_001, TestSize.Level1)
1170 {
1171     CALL_TEST_DEBUG;
1172     int32_t primaryButton = 1;
1173     ASSERT_TRUE(InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_OK);
1174     primaryButton = 0;
1175     ASSERT_TRUE(InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_OK);
1176 }
1177 
1178 /**
1179  * @tc.name: InputManagerPointerTest_SetMousePrimaryButton_002
1180  * @tc.desc: Sets mouse primary button
1181  * @tc.type: FUNC
1182  * @tc.require: I530XS
1183  */
1184 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMousePrimaryButton_002, TestSize.Level1)
1185 {
1186     CALL_TEST_DEBUG;
1187     int32_t primaryButton = INVAID_VALUE;
1188     ASSERT_TRUE(InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_ERR);
1189 }
1190 
1191 /**
1192  * @tc.name: InputManagerPointerTest_GetMousePrimaryButton_001
1193  * @tc.desc: Gets mouse primary button
1194  * @tc.type: FUNC
1195  * @tc.require: I530XS
1196  */
1197 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetMousePrimaryButton_001, TestSize.Level1)
1198 {
1199     CALL_TEST_DEBUG;
1200     int32_t primaryButton = 1;
1201     if (InputManager::GetInstance()->SetMousePrimaryButton(primaryButton) == RET_OK) {
1202         ASSERT_TRUE(InputManager::GetInstance()->GetMousePrimaryButton(primaryButton) == RET_OK);
1203         ASSERT_EQ(primaryButton, PrimaryButton::RIGHT_BUTTON);
1204     }
1205 }
1206 
1207 /**
1208  * @tc.name: InputManagerPointerTest_SetMouseScrollRows_001
1209  * @tc.desc: Sets mouse scroll rows
1210  * @tc.type: FUNC
1211  * @tc.require: I530XS
1212  */
1213 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseScrollRows_001, TestSize.Level1)
1214 {
1215     CALL_TEST_DEBUG;
1216     int32_t rows = 1;
1217     ASSERT_TRUE(InputManager::GetInstance()->SetMouseScrollRows(rows) == RET_OK);
1218 }
1219 
1220 /**
1221  * @tc.name: InputManagerPointerTest_GetMouseScrollRows_001
1222  * @tc.desc: Sets mouse scroll rows
1223  * @tc.type: FUNC
1224  * @tc.require: I530XS
1225  */
1226 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetMouseScrollRows_001, TestSize.Level1)
1227 {
1228     CALL_TEST_DEBUG;
1229     int32_t rows = 50;
1230     int32_t newRows = 3;
1231     if (InputManager::GetInstance()->SetMouseScrollRows(rows) == RET_OK) {
1232         ASSERT_TRUE(InputManager::GetInstance()->GetMouseScrollRows(newRows) == RET_OK);
1233         ASSERT_EQ(rows, newRows);
1234     }
1235 }
1236 
1237 /**
1238  * @tc.name: InputManagerPointerTest_SetMouseIcon_001
1239  * @tc.desc: Set the mouse icon for linux window
1240  * @tc.type: FUNC
1241  * @tc.require: I530XS
1242  */
1243 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseIcon_001, TestSize.Level1)
1244 {
1245     CALL_TEST_DEBUG;
1246     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1247     CHKPV(window);
1248     uint32_t windowId = window->GetWindowId();
1249     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
1250     PointerStyle pointerStyle;
1251     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1252     ASSERT_NE(pixelMap, nullptr);
1253     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1254     if (InputManager::GetInstance()->SetMouseIcon(windowId, (void *)pixelMap.get()) == RET_OK) {
1255         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1256         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1257     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1258         ASSERT_FALSE(false);  // errors occur
1259     } else {
1260         ASSERT_TRUE(false);
1261     }
1262 }
1263 
1264 /**
1265  * @tc.name: InputManagerPointerTest_SetMouseIcon_002
1266  * @tc.desc: Set the mouse icon for linux window
1267  * @tc.type: FUNC
1268  * @tc.require: I530XS
1269  */
1270 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseIcon_002, TestSize.Level1)
1271 {
1272     CALL_TEST_DEBUG;
1273     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1274     CHKPV(window);
1275     uint32_t windowId = window->GetWindowId();
1276     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1277     PointerStyle pointerStyle;
1278     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1279     ASSERT_NE(pixelMap, nullptr);
1280     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1281     if (InputManager::GetInstance()->SetMouseIcon(windowId, (void *)pixelMap.get()) == RET_OK) {
1282         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1283         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1284     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1285         ASSERT_FALSE(false);  // errors occur
1286     } else {
1287         ASSERT_TRUE(false);
1288     }
1289 }
1290 
1291 /**
1292  * @tc.name: InputManagerPointerTest_SetMouseIcon_003
1293  * @tc.desc: Set the mouse icon for linux window
1294  * @tc.type: FUNC
1295  * @tc.require: I530XS
1296  */
1297 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseIcon_003, TestSize.Level1)
1298 {
1299     CALL_TEST_DEBUG;
1300     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1301     CHKPV(window);
1302     uint32_t windowId = window->GetWindowId();
1303     PointerStyle pointerStyle;
1304     pointerStyle.id = MOUSE_ICON::DEFAULT;
1305     int32_t ret = InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle);
1306     ASSERT_TRUE(ret == RET_OK);
1307     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1308     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1309     ASSERT_TRUE(pixelMap != nullptr);
1310     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1311     ret = InputManager::GetInstance()->SetMouseIcon(INVAID_VALUE, (void *)pixelMap.get());
1312     ASSERT_EQ(ret, RET_ERR);
1313     ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1314     ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEFAULT);
1315 }
1316 
1317 /**
1318  * @tc.name: InputManagerPointerTest_SetMouseHotSpot_001
1319  * @tc.desc: Set the mouse icon hot spot for linux window
1320  * @tc.type: FUNC
1321  * @tc.require: I530XS
1322  */
1323 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseHotSpot_001, TestSize.Level1)
1324 {
1325     CALL_TEST_DEBUG;
1326     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1327     CHKPV(window);
1328     uint32_t windowId = window->GetWindowId();
1329     PointerStyle pointerStyle;
1330     pointerStyle.id = MOUSE_ICON::CROSS;
1331     if (InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle) == RET_OK) {
1332         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1333         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::CROSS);
1334     }
1335     ASSERT_FALSE(
1336         InputManager::GetInstance()->SetMouseHotSpot(windowId, MOUSE_ICON_HOT_SPOT, MOUSE_ICON_HOT_SPOT) == RET_OK);
1337 }
1338 
1339 /**
1340  * @tc.name: InputManagerPointerTest_SetMouseHotSpot_002
1341  * @tc.desc: Set the mouse icon hot spot for linux window
1342  * @tc.type: FUNC
1343  * @tc.require: I530XS
1344  */
1345 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetMouseHotSpot_002, TestSize.Level1)
1346 {
1347     CALL_TEST_DEBUG;
1348     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1349     CHKPV(window);
1350     uint32_t windowId = window->GetWindowId();
1351     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Default.svg";
1352     PointerStyle pointerStyle;
1353     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1354     ASSERT_NE(pixelMap, nullptr);
1355     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1356     if (InputManager::GetInstance()->SetMouseIcon(windowId, (void *)pixelMap.get()) == RET_OK) {
1357         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1358         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1359         ASSERT_TRUE(
1360             InputManager::GetInstance()->SetMouseHotSpot(windowId, MOUSE_ICON_HOT_SPOT, MOUSE_ICON_HOT_SPOT) == RET_OK);
1361     } else {
1362         ASSERT_FALSE(
1363             InputManager::GetInstance()->SetMouseHotSpot(windowId, MOUSE_ICON_HOT_SPOT, MOUSE_ICON_HOT_SPOT) == RET_OK);
1364     }
1365 }
1366 
1367 /**
1368  * @tc.name: InputManagerPointerTest_SetPointerStyle_001
1369  * @tc.desc: Sets the pointer style of the window
1370  * @tc.type: FUNC
1371  * @tc.require: I530XS
1372  */
1373 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerStyle_001, TestSize.Level1)
1374 {
1375     CALL_TEST_DEBUG;
1376     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1377     CHKPV(window);
1378     uint32_t windowId = window->GetWindowId();
1379     PointerStyle pointerStyle;
1380     pointerStyle.id = MOUSE_ICON::CROSS;
1381     if (InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle) == RET_OK) {
1382         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1383         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::CROSS);
1384     }
1385 }
1386 
1387 /**
1388  * @tc.name: InputManagerPointerTest_SetPointerStyle_002
1389  * @tc.desc: Sets the pointer style of the window
1390  * @tc.type: FUNC
1391  * @tc.require: I530XS
1392  */
1393 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerStyle_002, TestSize.Level1)
1394 {
1395     CALL_TEST_DEBUG;
1396     uint32_t windowId = INVAID_VALUE;
1397     PointerStyle pointerStyle;
1398     pointerStyle.id = MOUSE_ICON::CROSS;
1399     if (InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle) == RET_OK) {
1400         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1401         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::CROSS);
1402     }
1403 }
1404 
1405 /**
1406  * @tc.name: InputManagerPointerTest_SetTouchpadScrollSwitch_001
1407  * @tc.desc: Set touchpad scroll switch
1408  * @tc.type: FUNC
1409  * @tc.require:
1410  */
1411 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadScrollSwitch_001, TestSize.Level1)
1412 {
1413     CALL_TEST_DEBUG;
1414     bool flag = false;
1415     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadScrollSwitch(flag) == RET_OK);
1416 }
1417 
1418 /**
1419  * @tc.name: InputManagerPointerTest_GetTouchpadScrollSwitch_001
1420  * @tc.desc: Get touchpad scroll switch
1421  * @tc.type: FUNC
1422  * @tc.require:
1423  */
1424 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadScrollSwitch_001, TestSize.Level1)
1425 {
1426     CALL_TEST_DEBUG;
1427     bool flag = true;
1428     InputManager::GetInstance()->SetTouchpadScrollSwitch(flag);
1429     bool newFlag = true;
1430     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadScrollSwitch(newFlag) == RET_OK);
1431     ASSERT_TRUE(flag == newFlag);
1432 }
1433 
1434 /**
1435  * @tc.name: InputManagerPointerTest_SetTouchpadScrollDirection_001
1436  * @tc.desc: Set touchpad scroll direction switch
1437  * @tc.type: FUNC
1438  * @tc.require:
1439  */
1440 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadScrollDirection_001, TestSize.Level1)
1441 {
1442     CALL_TEST_DEBUG;
1443     bool state = false;
1444     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadScrollDirection(state) == RET_OK);
1445 }
1446 
1447 /**
1448  * @tc.name: InputManagerPointerTest_GetTouchpadScrollDirection_001
1449  * @tc.desc: Get touchpad scroll direction switch
1450  * @tc.type: FUNC
1451  * @tc.require:
1452  */
1453 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadScrollDirection_001, TestSize.Level1)
1454 {
1455     CALL_TEST_DEBUG;
1456     bool state = true;
1457     InputManager::GetInstance()->SetTouchpadScrollDirection(state);
1458     bool newState = true;
1459     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadScrollDirection(newState) == RET_OK);
1460     ASSERT_TRUE(state == newState);
1461 }
1462 
1463 /**
1464  * @tc.name: InputManagerPointerTest_SetTouchpadTapSwitch_001
1465  * @tc.desc: Set touchpad tap switch
1466  * @tc.type: FUNC
1467  * @tc.require:
1468  */
1469 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadTapSwitch_001, TestSize.Level1)
1470 {
1471     CALL_TEST_DEBUG;
1472     bool flag = false;
1473     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadTapSwitch(flag) == RET_OK);
1474 }
1475 
1476 /**
1477  * @tc.name: InputManagerPointerTest_GetTouchpadTapSwitch_001
1478  * @tc.desc: Get touchpad tap switch
1479  * @tc.type: FUNC
1480  * @tc.require:
1481  */
1482 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadTapSwitch_001, TestSize.Level1)
1483 {
1484     CALL_TEST_DEBUG;
1485     bool flag = true;
1486     InputManager::GetInstance()->SetTouchpadTapSwitch(flag);
1487     bool newFlag = true;
1488     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadTapSwitch(newFlag) == RET_OK);
1489     ASSERT_TRUE(flag == newFlag);
1490 }
1491 
1492 /**
1493  * @tc.name: InputManagerPointerTest_SetTouchpadDoubleTapAndDragState_001
1494  * @tc.desc: Set touchpad double tap and drag switch
1495  * @tc.type: FUNC
1496  * @tc.require:
1497  */
1498 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadDoubleTapAndDragState_001, TestSize.Level1)
1499 {
1500     CALL_TEST_DEBUG;
1501     bool flag = false;
1502     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadDoubleTapAndDragState(flag) == RET_OK);
1503 }
1504 
1505 /**
1506  * @tc.name: InputManagerPointerTest_GetTouchpadDoubleTapAndDragState_001
1507  * @tc.desc: Get touchpad double tap and drag switch
1508  * @tc.type: FUNC
1509  * @tc.require:
1510  */
1511 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadDoubleTapAndDragState_001, TestSize.Level1)
1512 {
1513     CALL_TEST_DEBUG;
1514     bool flag = true;
1515     InputManager::GetInstance()->SetTouchpadDoubleTapAndDragState(flag);
1516     bool newFlag = true;
1517     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadDoubleTapAndDragState(newFlag) == RET_OK);
1518     ASSERT_TRUE(flag == newFlag);
1519 }
1520 
1521 /**
1522  * @tc.name: InputManagerPointerTest_SetTouchpadPointerSpeed_001
1523  * @tc.desc: Set touchpad pointer speed
1524  * @tc.type: FUNC
1525  * @tc.require:
1526  */
1527 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadPointerSpeed_001, TestSize.Level1)
1528 {
1529     CALL_TEST_DEBUG;
1530     int32_t speed = POINTER_SPEED_ONE;
1531     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadPointerSpeed(speed) == RET_OK);
1532 }
1533 
1534 /**
1535  * @tc.name: InputManagerPointerTest_GetTouchpadPointerSpeed_001
1536  * @tc.desc: Get touchpad pointer speed
1537  * @tc.type: FUNC
1538  * @tc.require:
1539  */
1540 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadPointerSpeed_001, TestSize.Level1)
1541 {
1542     CALL_TEST_DEBUG;
1543     int32_t speed = POINTER_SPEED_TWO;
1544     InputManager::GetInstance()->SetTouchpadPointerSpeed(speed);
1545     int32_t newSpeed = POINTER_SPEED_THREE;
1546     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadPointerSpeed(newSpeed) == RET_OK);
1547     ASSERT_TRUE(speed == newSpeed);
1548 }
1549 
1550 /**
1551  * @tc.name: InputManagerPointerTest_SetTouchpadPinchSwitch_001
1552  * @tc.desc: Set touchpad pinch switch
1553  * @tc.type: FUNC
1554  * @tc.require:
1555  */
1556 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadPinchSwitch_001, TestSize.Level1)
1557 {
1558     CALL_TEST_DEBUG;
1559     bool flag = false;
1560     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadPinchSwitch(flag) == RET_OK);
1561 }
1562 
1563 /**
1564  * @tc.name: InputManagerPointerTest_GetTouchpadPinchSwitch_001
1565  * @tc.desc: Get touchpad pinch switch
1566  * @tc.type: FUNC
1567  * @tc.require:
1568  */
1569 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadPinchSwitch_001, TestSize.Level1)
1570 {
1571     CALL_TEST_DEBUG;
1572     bool flag = true;
1573     InputManager::GetInstance()->SetTouchpadPinchSwitch(flag);
1574     bool newFlag = true;
1575     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadPinchSwitch(newFlag) == RET_OK);
1576     ASSERT_TRUE(flag == newFlag);
1577 }
1578 
1579 /**
1580  * @tc.name: InputManagerPointerTest_SetTouchpadSwipeSwitch_001
1581  * @tc.desc: Set touchpad swipe switch
1582  * @tc.type: FUNC
1583  * @tc.require:
1584  */
1585 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadSwipeSwitch_001, TestSize.Level1)
1586 {
1587     CALL_TEST_DEBUG;
1588     bool flag = false;
1589     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadSwipeSwitch(flag) == RET_OK);
1590 }
1591 
1592 /**
1593  * @tc.name: InputManagerPointerTest_GetTouchpadSwipeSwitch_001
1594  * @tc.desc: Get touchpad swipe switch
1595  * @tc.type: FUNC
1596  * @tc.require:
1597  */
1598 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadSwipeSwitch_001, TestSize.Level1)
1599 {
1600     CALL_TEST_DEBUG;
1601     bool flag = true;
1602     InputManager::GetInstance()->SetTouchpadSwipeSwitch(flag);
1603     bool newFlag = true;
1604     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadSwipeSwitch(newFlag) == RET_OK);
1605     ASSERT_TRUE(flag == newFlag);
1606 }
1607 
1608 /**
1609  * @tc.name: InputManagerPointerTest_SetTouchpadRightClickType_001
1610  * @tc.desc: Set touchpad right click type
1611  * @tc.type: FUNC
1612  * @tc.require:
1613  */
1614 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadRightClickType_001, TestSize.Level1)
1615 {
1616     CALL_TEST_DEBUG;
1617     int32_t type = 1;
1618     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadRightClickType(type) == RET_OK);
1619 }
1620 
1621 /**
1622  * @tc.name: InputManagerPointerTest_GetTouchpadRightClickType_001
1623  * @tc.desc: Get touchpad right click type
1624  * @tc.type: FUNC
1625  * @tc.require:
1626  */
1627 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadRightClickType_001, TestSize.Level1)
1628 {
1629     CALL_TEST_DEBUG;
1630     int32_t type = RIGHT_CLICK_TYPE;
1631     InputManager::GetInstance()->SetTouchpadRightClickType(type);
1632     int32_t newType = 1;
1633     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadRightClickType(newType) == RET_OK);
1634     ASSERT_TRUE(type == newType);
1635 }
1636 
1637 /**
1638  * @tc.name: InputManagerPointerTest_SetTouchpadRotateSwitch_001
1639  * @tc.desc: Set touchpad rotate switch
1640  * @tc.type: FUNC
1641  * @tc.require:
1642  */
1643 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetTouchpadRotateSwitch_001, TestSize.Level1)
1644 {
1645     CALL_TEST_DEBUG;
1646     bool rotateSwitch = false;
1647     ASSERT_TRUE(InputManager::GetInstance()->SetTouchpadRotateSwitch(rotateSwitch) == RET_OK);
1648 }
1649 
1650 /**
1651  * @tc.name: InputManagerPointerTest_GetTouchpadRotateSwitch_001
1652  * @tc.desc: Get touchpad rotate switch
1653  * @tc.type: FUNC
1654  * @tc.require:
1655  */
1656 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetTouchpadRotateSwitch_001, TestSize.Level1)
1657 {
1658     CALL_TEST_DEBUG;
1659     bool rotateSwitch = true;
1660     InputManager::GetInstance()->SetTouchpadRotateSwitch(rotateSwitch);
1661     bool newRotateSwitch = true;
1662     ASSERT_TRUE(InputManager::GetInstance()->GetTouchpadRotateSwitch(newRotateSwitch) == RET_OK);
1663     ASSERT_TRUE(rotateSwitch == newRotateSwitch);
1664 }
1665 
1666 /**
1667  * @tc.name: InputManagerPointerTest_SetPointerSize_001
1668  * @tc.desc: Sets pointer size
1669  * @tc.type: FUNC
1670  * @tc.require: I530XS
1671  */
1672 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerSize_001, TestSize.Level1)
1673 {
1674     CALL_TEST_DEBUG;
1675     int32_t setSize = 3;
1676     ASSERT_TRUE(InputManager::GetInstance()->SetPointerSize(setSize) == RET_OK);
1677     setSize = 1;
1678     InputManager::GetInstance()->SetPointerSize(setSize);
1679 }
1680 
1681 /**
1682  * @tc.name: InputManagerPointerTest_GetPointerSize_001
1683  * @tc.desc: Gets pointer size
1684  * @tc.type: FUNC
1685  * @tc.require: I530XS
1686  */
1687 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetPointerSize_001, TestSize.Level1)
1688 {
1689     CALL_TEST_DEBUG;
1690     int32_t setSize = 1;
1691     ASSERT_TRUE(InputManager::GetInstance()->SetPointerSize(setSize) == RET_OK);
1692     int32_t getSize = 3;
1693     ASSERT_TRUE(InputManager::GetInstance()->GetPointerSize(getSize) == RET_OK);
1694     ASSERT_TRUE(setSize == getSize);
1695 }
1696 
1697 /**
1698  * @tc.name: InputManagerPointerTest_SetPointerColor_001
1699  * @tc.desc: Sets pointer color
1700  * @tc.type: FUNC
1701  * @tc.require: I530XS
1702  */
1703 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetPointerColor_001, TestSize.Level1)
1704 {
1705     CALL_TEST_DEBUG;
1706     std::vector<int32_t> deviceIds;
__anonf35bd14b0602(std::vector<int32_t> ids) 1707     auto callback = [&deviceIds] (std::vector<int32_t> ids) {
1708         deviceIds = ids;
1709     };
1710     int32_t ret = InputManager::GetInstance()->GetDeviceIds(callback);
1711     ASSERT_EQ(ret, RET_OK);
1712     for (const auto& devicedId : deviceIds) {
1713         std::shared_ptr<InputDevice> device;
__anonf35bd14b0702(std::shared_ptr<InputDevice> inputDevice) 1714         auto tmpcallback = [&device] (std::shared_ptr<InputDevice> inputDevice) {
1715             device = inputDevice;
1716         };
1717         ASSERT_EQ(InputManager::GetInstance()->GetDevice(devicedId, tmpcallback), RET_OK);
1718         ASSERT_TRUE(device != nullptr);
1719         if (device->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_POINTER)) {
1720             int32_t setColor = 0xA946F1;
1721             ASSERT_TRUE(InputManager::GetInstance()->SetPointerColor(setColor) == RET_OK);
1722             setColor = 0x000000;
1723             InputManager::GetInstance()->SetPointerColor(setColor);
1724             break;
1725         }
1726     }
1727 }
1728 
1729 /**
1730  * @tc.name: InputManagerPointerTest_GetPointerColor_001
1731  * @tc.desc: Gets pointer color
1732  * @tc.type: FUNC
1733  * @tc.require: I530XS
1734  */
1735 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_GetPointerColor_001, TestSize.Level1)
1736 {
1737     CALL_TEST_DEBUG;
1738     std::vector<int32_t> deviceIds;
__anonf35bd14b0802(std::vector<int32_t> ids) 1739     auto callback = [&deviceIds] (std::vector<int32_t> ids) {
1740         deviceIds = ids;
1741     };
1742     int32_t ret = InputManager::GetInstance()->GetDeviceIds(callback);
1743     ASSERT_EQ(ret, RET_OK);
1744     for (const auto& devicedId : deviceIds) {
1745         std::shared_ptr<InputDevice> device;
__anonf35bd14b0902(std::shared_ptr<InputDevice> inputDevice) 1746         auto tmpcallback = [&device] (std::shared_ptr<InputDevice> inputDevice) {
1747             device = inputDevice;
1748         };
1749         ASSERT_EQ(InputManager::GetInstance()->GetDevice(devicedId, tmpcallback), RET_OK);
1750         ASSERT_TRUE(device != nullptr);
1751         if (device->HasCapability(InputDeviceCapability::INPUT_DEV_CAP_POINTER)) {
1752             int32_t setColor = 0x000000;
1753             ASSERT_TRUE(InputManager::GetInstance()->SetPointerColor(setColor) == RET_OK);
1754             int32_t getColor = 3;
1755             ASSERT_TRUE(InputManager::GetInstance()->GetPointerColor(getColor) == RET_OK);
1756             ASSERT_TRUE(setColor == getColor);
1757             break;
1758         }
1759     }
1760 }
1761 
1762 /**
1763  * @tc.name: InputManagerPointerTest_SetCustomCursor_001
1764  * @tc.desc: Set the mouse custom cursor
1765  * @tc.type: FUNC
1766  * @tc.require: I530XS
1767  */
1768 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetCustomCursor_001, TestSize.Level1)
1769 {
1770     CALL_TEST_DEBUG;
1771     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1772     CHKPV(window);
1773     uint32_t windowId = window->GetWindowId();
1774     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
1775     PointerStyle pointerStyle;
1776     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1777     ASSERT_NE(pixelMap, nullptr);
1778     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1779     if (InputManager::GetInstance()->SetCustomCursor(windowId, (void *)pixelMap.get(), 32, 32) == RET_OK) {
1780         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1781         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1782     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1783         ASSERT_FALSE(false);  // errors occur
1784     } else {
1785         ASSERT_TRUE(false);
1786     }
1787 }
1788 
1789 /**
1790  * @tc.name: InputManagerPointerTest_SetCustomCursor_002
1791  * @tc.desc: Set the mouse custom cursor
1792  * @tc.type: FUNC
1793  * @tc.require: I530XS
1794  */
1795 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetCustomCursor_002, TestSize.Level1)
1796 {
1797     CALL_TEST_DEBUG;
1798     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1799     CHKPV(window);
1800     uint32_t windowId = window->GetWindowId();
1801     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1802     PointerStyle pointerStyle;
1803     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1804     ASSERT_NE(pixelMap, nullptr);
1805     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1806     if (InputManager::GetInstance()->SetCustomCursor(windowId, (void *)pixelMap.get(), 64, 64) == RET_OK) {
1807         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1808         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1809     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1810         ASSERT_FALSE(false);  // errors occur
1811     } else {
1812         ASSERT_TRUE(false);
1813     }
1814 }
1815 
1816 /**
1817  * @tc.name: InputManagerPointerTest_SetCustomCursor_003
1818  * @tc.desc: Set the mouse custom cursor
1819  * @tc.type: FUNC
1820  * @tc.require: I530XS
1821  */
1822 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetCustomCursor_003, TestSize.Level1)
1823 {
1824     CALL_TEST_DEBUG;
1825     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1826     CHKPV(window);
1827     uint32_t windowId = window->GetWindowId();
1828     PointerStyle pointerStyle;
1829     pointerStyle.id = MOUSE_ICON::DEFAULT;
1830     int32_t ret = InputManager::GetInstance()->SetPointerStyle(windowId, pointerStyle);
1831     ASSERT_TRUE(ret == RET_OK);
1832     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1833     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1834     ASSERT_TRUE(pixelMap != nullptr);
1835     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1836     ret = InputManager::GetInstance()->SetCustomCursor(INVAID_VALUE, (void *)pixelMap.get(), 0, 0);
1837     ASSERT_EQ(ret, RET_ERR);
1838     ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1839     ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEFAULT);
1840 }
1841 
1842 /**
1843  * @tc.name: InputManagerPointerTest_SetCustomCursor_004
1844  * @tc.desc: Set the mouse custom cursor
1845  * @tc.type: FUNC
1846  * @tc.require: I530XS
1847  */
1848 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetCustomCursor_004, TestSize.Level1)
1849 {
1850     CALL_TEST_DEBUG;
1851     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1852     CHKPV(window);
1853     uint32_t windowId = window->GetWindowId();
1854     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1855     PointerStyle pointerStyle;
1856     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1857     ASSERT_NE(pixelMap, nullptr);
1858     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1859     if (InputManager::GetInstance()->SetCustomCursor(windowId, (void *)pixelMap.get()) == RET_OK) {
1860         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1861         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1862     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1863         ASSERT_FALSE(false);  // errors occur
1864     } else {
1865         ASSERT_TRUE(false);
1866     }
1867 }
1868 
1869 /**
1870  * @tc.name: InputManagerPointerTest_SetCustomCursor_005
1871  * @tc.desc: Set the mouse custom cursor
1872  * @tc.type: FUNC
1873  * @tc.require: I530XS
1874  */
1875 HWTEST_F(InputManagerPointerTest, InputManagerPointerTest_SetCustomCursor_005, TestSize.Level1)
1876 {
1877     CALL_TEST_DEBUG;
1878     auto window = WindowUtilsTest::GetInstance()->GetWindow();
1879     CHKPV(window);
1880     uint32_t windowId = window->GetWindowId();
1881     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/Zoom_Out.svg";
1882     PointerStyle pointerStyle;
1883     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = InputManagerUtil::SetMouseIconTest(iconPath);
1884     ASSERT_NE(pixelMap, nullptr);
1885     pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1886     int32_t focusX = 64;
1887     if (InputManager::GetInstance()->SetCustomCursor(windowId, (void *)pixelMap.get(), focusX) == RET_OK) {
1888         ASSERT_TRUE(InputManager::GetInstance()->GetPointerStyle(windowId, pointerStyle) == RET_OK);
1889         ASSERT_EQ(pointerStyle.id, MOUSE_ICON::DEVELOPER_DEFINED_ICON);
1890     } else if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1891         ASSERT_FALSE(false);  // errors occur
1892     } else {
1893         ASSERT_TRUE(false);
1894     }
1895 }
1896 }  // namespace MMI
1897 }  // namespace OHOS