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