1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <cstdio>
17 #include <fstream>
18
19 #include <gtest/gtest.h>
20
21 #include "image_source.h"
22 #include "input_windows_manager_mock.h"
23 #include "knuckle_drawing_manager.h"
24 #include "libinput_mock.h"
25 #include "mmi_log.h"
26 #include "pixel_map.h"
27 #include "pointer_drawing_manager.h"
28 #include "pointer_event.h"
29
30 #undef MMI_LOG_TAG
31 #define MMI_LOG_TAG "PointerDrawingManagerTest"
32
33 namespace OHOS {
34 namespace MMI {
35 namespace {
36 using namespace testing::ext;
37 constexpr int32_t MOUSE_ICON_SIZE = 64;
38 constexpr uint32_t DEFAULT_ICON_COLOR { 0xFF };
39 constexpr int32_t MIDDLE_PIXEL_MAP_WIDTH { 400 };
40 constexpr int32_t MIDDLE_PIXEL_MAP_HEIGHT { 400 };
41 constexpr int32_t MAX_PIXEL_MAP_WIDTH { 600 };
42 constexpr int32_t MAX_PIXEL_MAP_HEIGHT { 600 };
43 constexpr int32_t INT32_BYTE { 4 };
44 } // namespace
45
46 class PointerDrawingManagerTest : public testing::Test {
47 public:
SetUpTestCase(void)48 static void SetUpTestCase(void) {};
TearDownTestCase(void)49 static void TearDownTestCase(void) {};
50 static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height);
SetUp(void)51 void SetUp(void)
52 {}
TearDown(void)53 void TearDown(void)
54 {}
55
56 std::unique_ptr<OHOS::Media::PixelMap> SetMouseIconTest(const std::string iconPath);
57 private:
58 };
59
SetMouseIconTest(const std::string iconPath)60 std::unique_ptr<OHOS::Media::PixelMap> PointerDrawingManagerTest::SetMouseIconTest(const std::string iconPath)
61 {
62 CALL_DEBUG_ENTER;
63 OHOS::Media::SourceOptions opts;
64 opts.formatHint = "image/svg+xml";
65 uint32_t ret = 0;
66 auto imageSource = OHOS::Media::ImageSource::CreateImageSource(iconPath, opts, ret);
67 CHKPP(imageSource);
68 std::set<std::string> formats;
69 ret = imageSource->GetSupportedFormats(formats);
70 MMI_HILOGD("Get supported format ret:%{public}u", ret);
71
72 OHOS::Media::DecodeOptions decodeOpts;
73 decodeOpts.desiredSize = {.width = MOUSE_ICON_SIZE, .height = MOUSE_ICON_SIZE};
74
75 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, ret);
76 CHKPL(pixelMap);
77 return pixelMap;
78 }
79
CreatePixelMap(int32_t width,int32_t height)80 std::shared_ptr<Media::PixelMap> PointerDrawingManagerTest::CreatePixelMap(int32_t width, int32_t height)
81 {
82 CALL_DEBUG_ENTER;
83 if (width <= 0 || width > MAX_PIXEL_MAP_WIDTH || height <= 0 || height > MAX_PIXEL_MAP_HEIGHT) {
84 return nullptr;
85 }
86 Media::InitializationOptions opts;
87 opts.size.height = height;
88 opts.size.width = width;
89 opts.pixelFormat = Media::PixelFormat::BGRA_8888;
90 opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
91 opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE;
92
93 int32_t colorLen = width * height;
94 uint32_t *pixelColors = new (std::nothrow) uint32_t[colorLen];
95 CHKPP(pixelColors);
96 int32_t colorByteCount = colorLen * INT32_BYTE;
97 errno_t ret = memset_s(pixelColors, colorByteCount, DEFAULT_ICON_COLOR, colorByteCount);
98 if (ret != EOK) {
99 delete[] pixelColors;
100 return nullptr;
101 }
102 std::shared_ptr<Media::PixelMap> pixelMap = Media::PixelMap::Create(pixelColors, colorLen, opts);
103 if (pixelMap == nullptr) {
104 delete[] pixelColors;
105 return nullptr;
106 }
107 delete[] pixelColors;
108 return pixelMap;
109 }
110
111 /**
112 * @tc.name: InputWindowsManagerTest_DrawMovePointer_001
113 * @tc.desc: Test the funcation DrawMovePointer
114 * @tc.type: FUNC
115 * @tc.require:
116 */
117 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawMovePointer_001, TestSize.Level1)
118 {
119 CALL_TEST_DEBUG;
120 PointerDrawingManager manager;
121 int32_t displayId = 1;
122 int32_t physicalX = 2;
123 int32_t physicalY = 3;
124 PointerStyle pointerStyle;
125 Direction direction = DIRECTION0;
126 manager.surfaceNode_ = nullptr;
127 int32_t ret = manager.DrawMovePointer(displayId, physicalX, physicalY, pointerStyle, direction);
128 EXPECT_EQ(ret, RET_ERR);
129 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
130 surfaceNodeConfig.SurfaceNodeName = "pointer window";
131 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
132 manager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
133 ASSERT_TRUE(manager.surfaceNode_ != nullptr);
134 ret = manager.DrawMovePointer(displayId, physicalX, physicalY, pointerStyle, direction);
135 EXPECT_EQ(ret, RET_OK);
136 }
137
138 /**
139 * @tc.name: InputWindowsManagerTest_DrawCursor_002
140 * @tc.desc: Test the funcation DrawCursor
141 * @tc.type: FUNC
142 * @tc.require:
143 */
144 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawCursor_002, TestSize.Level1)
145 {
146 CALL_TEST_DEBUG;
147 PointerDrawingManager manager;
148 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
149 surfaceNodeConfig.SurfaceNodeName = "pointer window";
150 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
151 manager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
152 ASSERT_TRUE(manager.surfaceNode_ != nullptr);
153 MOUSE_ICON mouseStyle = EAST;
154 int32_t ret = manager.DrawCursor(mouseStyle);
155 EXPECT_EQ(ret, RET_OK);
156 }
157
158 /**
159 * @tc.name: InputWindowsManagerTest_Init_001
160 * @tc.desc: Test Init
161 * @tc.type: FUNC
162 * @tc.require:
163 */
164 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_Init_001, TestSize.Level1)
165 {
166 CALL_TEST_DEBUG;
167 bool isSucess = IPointerDrawingManager::GetInstance()->Init();
168 EXPECT_EQ(isSucess, true);
169 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
170 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
171 IconStyle iconStyle = pointerDrawingManager->GetIconStyle(MOUSE_ICON(MOUSE_ICON::DEFAULT));
172 EXPECT_EQ(iconStyle.alignmentWay, 7);
173 }
174
175 /**
176 * @tc.name: InputWindowsManagerTest_SetMouseDisplayState_001
177 * @tc.desc: Test SetMouseDisplayState
178 * @tc.type: FUNC
179 * @tc.require:
180 */
181 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseDisplayState_001, TestSize.Level1)
182 {
183 CALL_TEST_DEBUG;
184 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
185 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
186 pointerDrawingManager->SetMouseDisplayState(true);
187 bool mouseDisplayState = pointerDrawingManager->GetMouseDisplayState();
188 EXPECT_EQ(mouseDisplayState, true);
189 }
190
191 /**
192 * @tc.name: InputWindowsManagerTest_UpdatePointerDevice_001
193 * @tc.desc: Test UpdatePointerDevice
194 * @tc.type: FUNC
195 * @tc.require:
196 */
197 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_UpdatePointerDevice_001, TestSize.Level1)
198 {
199 CALL_TEST_DEBUG;
200 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
201 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
202 EXPECT_EQ(pointerDrawingManager->pidInfos_.size(), 0);
203 pointerDrawingManager->UpdatePointerDevice(true, true, true);
204 EXPECT_EQ(pointerDrawingManager->pidInfos_.size(), 1);
205 pointerDrawingManager->UpdatePointerDevice(false, true, true);
206 EXPECT_EQ(pointerDrawingManager->pidInfos_.size(), 0);
207 }
208
209 /**
210 * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection0_001
211 * @tc.desc: Test AdjustMouseFocusByDirection0
212 * @tc.type: FUNC
213 * @tc.require:
214 */
215 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_AdjustMouseFocusByDirection0_001, TestSize.Level1)
216 {
217 CALL_TEST_DEBUG;
218 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
219 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
220 pointerDrawingManager->imageWidth_ = 50;
221 pointerDrawingManager->imageHeight_ = 50;
222 pointerDrawingManager->userIconHotSpotX_ = 5;
223 pointerDrawingManager->userIconHotSpotY_ = 5;
224 int32_t physicalX = 100;
225 int32_t physicalY = 100;
226 pointerDrawingManager->AdjustMouseFocusByDirection0(ANGLE_SW, physicalX, physicalY);
227 EXPECT_EQ(physicalX, 100);
228 EXPECT_EQ(physicalY, 50);
229 physicalX = 100;
230 physicalY = 100;
231 pointerDrawingManager->AdjustMouseFocusByDirection0(ANGLE_CENTER, physicalX, physicalY);
232 EXPECT_EQ(physicalX, 75);
233 EXPECT_EQ(physicalY, 75);
234 physicalX = 100;
235 physicalY = 100;
236 pointerDrawingManager->AdjustMouseFocusByDirection0(ANGLE_NW_RIGHT, physicalX, physicalY);
237 EXPECT_EQ(physicalX, 95);
238 EXPECT_EQ(physicalY, 100);
239 physicalX = 100;
240 physicalY = 100;
241 pointerDrawingManager->userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
242 pointerDrawingManager->currentMouseStyle_.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
243 pointerDrawingManager->AdjustMouseFocusByDirection0(ANGLE_NW, physicalX, physicalY);
244 EXPECT_EQ(physicalX, 95);
245 EXPECT_EQ(physicalY, 95);
246 physicalX = 100;
247 physicalY = 100;
248 pointerDrawingManager->AdjustMouseFocusByDirection0(ANGLE_E, physicalX, physicalY);
249 EXPECT_EQ(physicalX, 100);
250 EXPECT_EQ(physicalY, 100);
251 }
252
253 /**
254 * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection90_001
255 * @tc.desc: Test AdjustMouseFocusByDirection90
256 * @tc.type: FUNC
257 * @tc.require:
258 */
259 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_AdjustMouseFocusByDirection90_001, TestSize.Level1)
260 {
261 CALL_TEST_DEBUG;
262 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
263 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
264 pointerDrawingManager->imageWidth_ = 50;
265 pointerDrawingManager->imageHeight_ = 50;
266 pointerDrawingManager->userIconHotSpotX_ = 5;
267 pointerDrawingManager->userIconHotSpotY_ = 5;
268 int32_t physicalX = 100;
269 int32_t physicalY = 100;
270 pointerDrawingManager->AdjustMouseFocusByDirection90(ANGLE_SW, physicalX, physicalY);
271 EXPECT_EQ(physicalX, 100);
272 EXPECT_EQ(physicalY, 150);
273 physicalX = 100;
274 physicalY = 100;
275 pointerDrawingManager->AdjustMouseFocusByDirection90(ANGLE_CENTER, physicalX, physicalY);
276 EXPECT_EQ(physicalX, 75);
277 EXPECT_EQ(physicalY, 125);
278 physicalX = 100;
279 physicalY = 100;
280 pointerDrawingManager->AdjustMouseFocusByDirection90(ANGLE_NW_RIGHT, physicalX, physicalY);
281 EXPECT_EQ(physicalX, 90);
282 EXPECT_EQ(physicalY, 105);
283 physicalX = 100;
284 physicalY = 100;
285 pointerDrawingManager->userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
286 pointerDrawingManager->currentMouseStyle_.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
287 pointerDrawingManager->AdjustMouseFocusByDirection90(ANGLE_NW, physicalX, physicalY);
288 EXPECT_EQ(physicalX, 95);
289 EXPECT_EQ(physicalY, 105);
290 physicalX = 100;
291 physicalY = 100;
292 pointerDrawingManager->AdjustMouseFocusByDirection90(ANGLE_E, physicalX, physicalY);
293 EXPECT_EQ(physicalX, 100);
294 EXPECT_EQ(physicalY, 100);
295 }
296
297 /**
298 * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection180_001
299 * @tc.desc: Test AdjustMouseFocusByDirection180
300 * @tc.type: FUNC
301 * @tc.require:
302 */
303 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_AdjustMouseFocusByDirection180_001, TestSize.Level1)
304 {
305 CALL_TEST_DEBUG;
306 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
307 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
308 pointerDrawingManager->imageWidth_ = 50;
309 pointerDrawingManager->imageHeight_ = 50;
310 pointerDrawingManager->userIconHotSpotX_ = 5;
311 pointerDrawingManager->userIconHotSpotY_ = 5;
312 int32_t physicalX = 100;
313 int32_t physicalY = 100;
314 pointerDrawingManager->AdjustMouseFocusByDirection180(ANGLE_SW, physicalX, physicalY);
315 EXPECT_EQ(physicalX, 100);
316 EXPECT_EQ(physicalY, 150);
317 physicalX = 100;
318 physicalY = 100;
319 pointerDrawingManager->AdjustMouseFocusByDirection180(ANGLE_CENTER, physicalX, physicalY);
320 EXPECT_EQ(physicalX, 125);
321 EXPECT_EQ(physicalY, 125);
322 physicalX = 100;
323 physicalY = 100;
324 pointerDrawingManager->AdjustMouseFocusByDirection180(ANGLE_NW_RIGHT, physicalX, physicalY);
325 EXPECT_EQ(physicalX, 110);
326 EXPECT_EQ(physicalY, 105);
327 physicalX = 100;
328 physicalY = 100;
329 pointerDrawingManager->userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
330 pointerDrawingManager->currentMouseStyle_.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
331 pointerDrawingManager->AdjustMouseFocusByDirection180(ANGLE_NW, physicalX, physicalY);
332 EXPECT_EQ(physicalX, 105);
333 EXPECT_EQ(physicalY, 105);
334 physicalX = 100;
335 physicalY = 100;
336 pointerDrawingManager->AdjustMouseFocusByDirection180(ANGLE_E, physicalX, physicalY);
337 EXPECT_EQ(physicalX, 100);
338 EXPECT_EQ(physicalY, 100);
339 }
340
341 /**
342 * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection270_001
343 * @tc.desc: Test AdjustMouseFocusByDirection270
344 * @tc.type: FUNC
345 * @tc.require:
346 */
347 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_AdjustMouseFocusByDirection270_001, TestSize.Level1)
348 {
349 CALL_TEST_DEBUG;
350 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
351 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
352 pointerDrawingManager->imageWidth_ = 50;
353 pointerDrawingManager->imageHeight_ = 50;
354 pointerDrawingManager->userIconHotSpotX_ = 5;
355 pointerDrawingManager->userIconHotSpotY_ = 5;
356 int32_t physicalX = 100;
357 int32_t physicalY = 100;
358 pointerDrawingManager->AdjustMouseFocusByDirection270(ANGLE_SW, physicalX, physicalY);
359 EXPECT_EQ(physicalX, 100);
360 EXPECT_EQ(physicalY, 50);
361 physicalX = 100;
362 physicalY = 100;
363 pointerDrawingManager->AdjustMouseFocusByDirection270(ANGLE_CENTER, physicalX, physicalY);
364 EXPECT_EQ(physicalX, 125);
365 EXPECT_EQ(physicalY, 75);
366 physicalX = 100;
367 physicalY = 100;
368 pointerDrawingManager->AdjustMouseFocusByDirection270(ANGLE_NW_RIGHT, physicalX, physicalY);
369 EXPECT_EQ(physicalX, 110);
370 EXPECT_EQ(physicalY, 95);
371 physicalX = 100;
372 physicalY = 100;
373 pointerDrawingManager->userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
374 pointerDrawingManager->currentMouseStyle_.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
375 pointerDrawingManager->AdjustMouseFocusByDirection270(ANGLE_NW, physicalX, physicalY);
376 EXPECT_EQ(physicalX, 105);
377 EXPECT_EQ(physicalY, 95);
378 physicalX = 100;
379 physicalY = 100;
380 pointerDrawingManager->AdjustMouseFocusByDirection270(ANGLE_E, physicalX, physicalY);
381 EXPECT_EQ(physicalX, 100);
382 EXPECT_EQ(physicalY, 100);
383 }
384
385 /**
386 * @tc.name: InputWindowsManagerTest_AdjustMouseFocus_001
387 * @tc.desc: Test AdjustMouseFocus
388 * @tc.type: FUNC
389 * @tc.require:
390 */
391 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_AdjustMouseFocus_001, TestSize.Level1)
392 {
393 CALL_TEST_DEBUG;
394 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
395 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
396 pointerDrawingManager->imageWidth_ = 50;
397 pointerDrawingManager->imageHeight_ = 50;
398 int32_t physicalX = 100;
399 int32_t physicalY = 100;
400 pointerDrawingManager->RotateDegree(DIRECTION0);
401 pointerDrawingManager->AdjustMouseFocus(DIRECTION0, ANGLE_SW, physicalX, physicalY);
402 EXPECT_EQ(physicalX, 100);
403 EXPECT_EQ(physicalY, 50);
404 physicalX = 100;
405 physicalY = 100;
406 pointerDrawingManager->RotateDegree(DIRECTION90);
407 pointerDrawingManager->AdjustMouseFocus(DIRECTION90, ANGLE_SW, physicalX, physicalY);
408 EXPECT_EQ(physicalX, 100);
409 EXPECT_EQ(physicalY, 150);
410 physicalX = 100;
411 physicalY = 100;
412 pointerDrawingManager->RotateDegree(DIRECTION180);
413 pointerDrawingManager->AdjustMouseFocus(DIRECTION180, ANGLE_SW, physicalX, physicalY);
414 EXPECT_EQ(physicalX, 100);
415 EXPECT_EQ(physicalY, 150);
416 physicalX = 100;
417 physicalY = 100;
418 pointerDrawingManager->RotateDegree(DIRECTION270);
419 pointerDrawingManager->AdjustMouseFocus(DIRECTION270, ANGLE_SW, physicalX, physicalY);
420 EXPECT_EQ(physicalX, 100);
421 EXPECT_EQ(physicalY, 50);
422 physicalX = 100;
423 physicalY = 100;
424 pointerDrawingManager->RotateDegree(static_cast<Direction>(4));
425 pointerDrawingManager->AdjustMouseFocus(static_cast<Direction>(4), ANGLE_SW, physicalX, physicalY);
426 EXPECT_EQ(physicalX, 100);
427 EXPECT_EQ(physicalY, 100);
428 }
429
430 /**
431 * @tc.name: InputWindowsManagerTest_SetPointerColor_001
432 * @tc.desc: Test SetPointerColor
433 * @tc.type: FUNC
434 * @tc.require:
435 */
436 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerColor_001, TestSize.Level1)
437 {
438 CALL_TEST_DEBUG;
439 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
440 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
441 pointerDrawingManager->SetPointerColor(-1);
442 int32_t color = pointerDrawingManager->GetPointerColor();
443 EXPECT_EQ(color, 16777215);
444 pointerDrawingManager->SetPointerColor(16777216);
445 color = pointerDrawingManager->GetPointerColor();
446 EXPECT_EQ(color, 0);
447 }
448
449 /**
450 * @tc.name: InputWindowsManagerTest_SetPointerVisible_001
451 * @tc.desc: Test SetPointerVisible
452 * @tc.type: FUNC
453 * @tc.require:
454 */
455 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerVisible_001, TestSize.Level1)
456 {
457 CALL_TEST_DEBUG;
458 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
459 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
460 for (int32_t i = 1; i < 102; i++) {
461 pointerDrawingManager->SetPointerVisible(i, false, 0, false);
462 }
463 bool visible = pointerDrawingManager->GetPointerVisible(1);
464 EXPECT_EQ(visible, true);
465 pointerDrawingManager->SetPointerVisible(11, true, 0, false);
466 visible = pointerDrawingManager->GetPointerVisible(11);
467 EXPECT_EQ(visible, true);
468 }
469
470 /**
471 * @tc.name: InputWindowsManagerTest_SetPointerStyle_001
472 * @tc.desc: Test SetPointerStyle
473 * @tc.type: FUNC
474 * @tc.require:
475 */
476 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerStyle_001, TestSize.Level1)
477 {
478 CALL_TEST_DEBUG;
479 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
480 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
481 PointerStyle pointerStyle;
482 pointerStyle.id = 0;
483 pointerDrawingManager->SetPointerStyle(1, -1, pointerStyle);
484 PointerStyle pointerStyleTmp;
485 pointerDrawingManager->GetPointerStyle(1, -1, pointerStyleTmp);
486 EXPECT_EQ(pointerStyleTmp.id, pointerStyle.id);
487 }
488
489 /**
490 * @tc.name: InputWindowsManagerTest_SetPointerSize_001
491 * @tc.desc: Test SetPointerSize
492 * @tc.type: FUNC
493 * @tc.require:
494 */
495 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerSize_001, TestSize.Level1)
496 {
497 CALL_TEST_DEBUG;
498 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
499 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
500 pointerDrawingManager->SetPointerSize(0);
501 int32_t pointerSize = pointerDrawingManager->GetPointerSize();
502 EXPECT_EQ(pointerSize, 1);
503 pointerDrawingManager->SetPointerSize(8);
504 pointerSize = pointerDrawingManager->GetPointerSize();
505 EXPECT_EQ(pointerSize, 7);
506 }
507
508 /**
509 * @tc.name: InputWindowsManagerTest_FixCursorPosition_001
510 * @tc.desc: Test FixCursorPosition
511 * @tc.type: FUNC
512 * @tc.require:
513 */
514 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_FixCursorPosition_001, TestSize.Level1)
515 {
516 CALL_TEST_DEBUG;
517 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
518 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
519 pointerDrawingManager->displayInfo_.displayDirection = DIRECTION0;
520 pointerDrawingManager->displayInfo_.direction = DIRECTION0;
521 pointerDrawingManager->displayInfo_.width = 500;
522 pointerDrawingManager->displayInfo_.height = 1100;
523 pointerDrawingManager->imageWidth_ = 48;
524 pointerDrawingManager->imageHeight_ = 48;
525 int32_t physicalX = 500;
526 int32_t physicalY = 1100;
527 pointerDrawingManager->FixCursorPosition(physicalX, physicalY);
528 EXPECT_EQ(physicalX, 497);
529 EXPECT_EQ(physicalY, 1097);
530 pointerDrawingManager->displayInfo_.direction = DIRECTION90;
531 physicalX = 1100;
532 physicalY = 500;
533 pointerDrawingManager->FixCursorPosition(physicalX, physicalY);
534 EXPECT_EQ(physicalX, 1097);
535 EXPECT_EQ(physicalY, 497);
536 pointerDrawingManager->displayInfo_.displayDirection = DIRECTION90;
537 pointerDrawingManager->displayInfo_.direction = DIRECTION0;
538 physicalX = 500;
539 physicalY = 1100;
540 pointerDrawingManager->FixCursorPosition(physicalX, physicalY);
541 EXPECT_EQ(physicalX, 497);
542 EXPECT_EQ(physicalY, 1097);
543 }
544
545 /**
546 * @tc.name: InputWindowsManagerTest_CreatePointerSwitchObserver_001
547 * @tc.desc: Test CreatePointerSwitchObserver
548 * @tc.type: FUNC
549 * @tc.require:
550 */
551 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_CreatePointerSwitchObserver_001, TestSize.Level1)
552 {
553 CALL_TEST_DEBUG;
554 PointerDrawingManager pointerDrawingManager;
555 isMagicCursor item;
556 item.isShow = true;
557 item.name = "test";
558 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.CreatePointerSwitchObserver(item));
559 }
560
561 /**
562 * @tc.name: InputWindowsManagerTest_DrawCursor_001
563 * @tc.desc: Test DrawCursor
564 * @tc.type: FUNC
565 * @tc.require:
566 */
567 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawCursor_001, TestSize.Level1)
568 {
569 CALL_TEST_DEBUG;
570 PointerDrawingManager pointerDrawingManager;
571 MOUSE_ICON mouseStyle = EAST;
572 int32_t ret = pointerDrawingManager.DrawCursor(mouseStyle);
573 EXPECT_EQ(ret, RET_ERR);
574 pointerDrawingManager.surfaceNode_ = nullptr;
575 ret = pointerDrawingManager.DrawCursor(mouseStyle);
576 EXPECT_EQ(ret, RET_ERR);
577 }
578
579 /**
580 * @tc.name: InputWindowsManagerTest_DrawLoadingPointerStyle_001
581 * @tc.desc: Test DrawLoadingPointerStyle
582 * @tc.type: FUNC
583 * @tc.require:
584 */
585 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawLoadingPointerStyle_001, TestSize.Level1)
586 {
587 CALL_TEST_DEBUG;
588 PointerDrawingManager pointerDrawingManager;
589 MOUSE_ICON mouseStyle = EAST;
590 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawLoadingPointerStyle(mouseStyle));
591 }
592
593 /**
594 * @tc.name: InputWindowsManagerTest_DrawRunningPointerAnimate_001
595 * @tc.desc: Test DrawRunningPointerAnimate
596 * @tc.type: FUNC
597 * @tc.require:
598 */
599 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawRunningPointerAnimate_001, TestSize.Level1)
600 {
601 CALL_TEST_DEBUG;
602 PointerDrawingManager pointerDrawingManager;
603 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
604 surfaceNodeConfig.SurfaceNodeName = "pointer window";
605 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
606 pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
607 pointerDrawingManager.surfaceNode_->SetFrameGravity(Rosen::Gravity::RESIZE_ASPECT_FILL);
608 pointerDrawingManager.surfaceNode_->SetPositionZ(Rosen::RSSurfaceNode::POINTER_WINDOW_POSITION_Z);
609 MOUSE_ICON mouseStyle = EAST;
610 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawRunningPointerAnimate(mouseStyle));
611 }
612
613 /**
614 * @tc.name: InputWindowsManagerTest_GetLayer_001
615 * @tc.desc: Test GetLayer
616 * @tc.type: FUNC
617 * @tc.require:
618 */
619 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_GetLayer_001, TestSize.Level1)
620 {
621 CALL_TEST_DEBUG;
622 PointerDrawingManager pointerDrawingManager;
623 pointerDrawingManager.surfaceNode_ = nullptr;
624 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.GetLayer());
625 }
626
627 /**
628 * @tc.name: InputWindowsManagerTest_SetMouseIcon_001
629 * @tc.desc: Test SetMouseIcon
630 * @tc.type: FUNC
631 * @tc.require:
632 */
633 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseIcon_001, TestSize.Level1)
634 {
635 CALL_TEST_DEBUG;
636 PointerDrawingManager pointerDrawingManager;
637 int32_t pid = -1;
638 int32_t windowId = 1;
639 void* pixelMap = nullptr;
640 int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, pixelMap);
641 EXPECT_EQ(ret, RET_ERR);
642 pid = 1;
643 ret = pointerDrawingManager.SetMouseIcon(pid, windowId, pixelMap);
644 EXPECT_EQ(ret, RET_ERR);
645 }
646
647 /**
648 * @tc.name: InputWindowsManagerTest_SetMouseHotSpot_001
649 * @tc.desc: Test SetMouseHotSpot
650 * @tc.type: FUNC
651 * @tc.require:
652 */
653 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseHotSpot_001, TestSize.Level1)
654 {
655 CALL_TEST_DEBUG;
656 PointerDrawingManager pointerDrawingManager;
657 int32_t pid = -1;
658 int32_t windowId = 1;
659 int32_t hotSpotX = 100;
660 int32_t hotSpotY = 100;
661 int32_t ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
662 EXPECT_EQ(ret, RET_ERR);
663 pid = 1;
664 windowId = -1;
665 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
666 EXPECT_EQ(ret, RET_ERR);
667 pid = 1;
668 windowId = 1;
669 hotSpotX = -1;
670 hotSpotY = -1;
671 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
672 EXPECT_EQ(ret, RET_ERR);
673 pid = 1;
674 windowId = 1;
675 hotSpotX = 100;
676 hotSpotY = 100;
677 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
678 EXPECT_EQ(ret, RET_ERR);
679 }
680
681 /**
682 * @tc.name: InputWindowsManagerTest_DecodeImageToPixelMap_001
683 * @tc.desc: Test DecodeImageToPixelMap
684 * @tc.type: FUNC
685 * @tc.require:
686 */
687 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DecodeImageToPixelMap_001, TestSize.Level1)
688 {
689 CALL_TEST_DEBUG;
690 PointerDrawingManager pointerDrawingManager;
691 std::string iconPath = ("/system/etc/multimodalinput/mouse_icon/Loading_Left.svg");
692 pointerDrawingManager.tempPointerColor_ = 1;
693 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DecodeImageToPixelMap(iconPath));
694 }
695
696 /**
697 * @tc.name: InputWindowsManagerTest_UpdatePointerVisible_001
698 * @tc.desc: Test UpdatePointerVisible
699 * @tc.type: FUNC
700 * @tc.require:
701 */
702 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_UpdatePointerVisible_001, TestSize.Level1)
703 {
704 CALL_TEST_DEBUG;
705 PointerDrawingManager pointerDrawingManager;
706 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
707 surfaceNodeConfig.SurfaceNodeName = "pointer window";
708 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
709 pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
710 pointerDrawingManager.mouseDisplayState_ = true;
711 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.UpdatePointerVisible());
712 pointerDrawingManager.mouseDisplayState_ = false;
713 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.UpdatePointerVisible());
714 }
715
716 /**
717 * @tc.name: InputWindowsManagerTest_IsPointerVisible_001
718 * @tc.desc: Test IsPointerVisible
719 * @tc.type: FUNC
720 * @tc.require:
721 */
722 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_IsPointerVisible_001, TestSize.Level1)
723 {
724 CALL_TEST_DEBUG;
725 PointerDrawingManager pointerDrawingManager;
726 bool ret = pointerDrawingManager.IsPointerVisible();
727 EXPECT_TRUE(ret);
728 }
729
730 /**
731 * @tc.name: InputWindowsManagerTest_DeletePointerVisible_001
732 * @tc.desc: Test DeletePointerVisible
733 * @tc.type: FUNC
734 * @tc.require:
735 */
736 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DeletePointerVisible_001, TestSize.Level1)
737 {
738 CALL_TEST_DEBUG;
739 PointerDrawingManager pointerDrawingManager;
740 int32_t pid = 1;
741 PointerDrawingManager::PidInfo info = { .pid = 1, .visible = true };
742 pointerDrawingManager.pidInfos_.push_back(info);
743 info = { .pid = 2, .visible = true };
744 pointerDrawingManager.pidInfos_.push_back(info);
745 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DeletePointerVisible(pid));
746 }
747
748 /**
749 * @tc.name: InputWindowsManagerTest_SetPointerLocation_001
750 * @tc.desc: Test SetPointerLocation
751 * @tc.type: FUNC
752 * @tc.require:
753 */
754 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerLocation_001, TestSize.Level1)
755 {
756 CALL_TEST_DEBUG;
757 PointerDrawingManager pointerDrawingManager;
758 int32_t x = 100;
759 int32_t y = 100;
760 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.SetPointerLocation(x, y));
761 }
762
763 /**
764 * @tc.name: InputWindowsManagerTest_UpdateDefaultPointerStyle_001
765 * @tc.desc: Test UpdateDefaultPointerStyle
766 * @tc.type: FUNC
767 * @tc.require:
768 */
769 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_UpdateDefaultPointerStyle_001, TestSize.Level1)
770 {
771 CALL_TEST_DEBUG;
772 PointerDrawingManager pointerDrawingManager;
773 int32_t pid = 1;
774 int32_t windowId = 1;
775 PointerStyle pointerStyle;
776 pointerStyle.id = 0;
777 pointerStyle.color = 0;
778 pointerStyle.size = 2;
779 int32_t ret = pointerDrawingManager.UpdateDefaultPointerStyle(pid, windowId, pointerStyle);
780 EXPECT_EQ(ret, RET_OK);
781 windowId = -1;
782 ret = pointerDrawingManager.UpdateDefaultPointerStyle(pid, windowId, pointerStyle);
783 EXPECT_EQ(ret, RET_OK);
784 }
785
786 /**
787 * @tc.name: InputWindowsManagerTest_SetPointerStylePreference_001
788 * @tc.desc: Test SetPointerStylePreference
789 * @tc.type: FUNC
790 * @tc.require:
791 */
792 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerStylePreference_001, TestSize.Level1)
793 {
794 CALL_TEST_DEBUG;
795 PointerDrawingManager pointerDrawingManager;
796 PointerStyle pointerStyle;
797 pointerStyle.id = 0;
798 pointerStyle.color = 0;
799 pointerStyle.size = 2;
800 int32_t ret = pointerDrawingManager.SetPointerStylePreference(pointerStyle);
801 EXPECT_EQ(ret, RET_OK);
802 }
803
804 /**
805 * @tc.name: InputWindowsManagerTest_CheckPointerStyleParam_001
806 * @tc.desc: Test CheckPointerStyleParam
807 * @tc.type: FUNC
808 * @tc.require:
809 */
810 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_CheckPointerStyleParam_001, TestSize.Level1)
811 {
812 CALL_TEST_DEBUG;
813 PointerDrawingManager pointerDrawingManager;
814 PointerStyle pointerStyle;
815 pointerStyle.id = EAST;
816 pointerStyle.color = 0;
817 pointerStyle.size = 2;
818 int32_t windowId = -2;
819 bool ret = pointerDrawingManager.CheckPointerStyleParam(windowId, pointerStyle);
820 EXPECT_FALSE(ret);
821 windowId = 1;
822 ret = pointerDrawingManager.CheckPointerStyleParam(windowId, pointerStyle);
823 EXPECT_TRUE(ret);
824 }
825
826 /**
827 * @tc.name: InputWindowsManagerTest_CheckMouseIconPath_001
828 * @tc.desc: Test CheckMouseIconPath
829 * @tc.type: FUNC
830 * @tc.require:
831 */
832 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_CheckMouseIconPath_001, TestSize.Level1)
833 {
834 CALL_TEST_DEBUG;
835 PointerDrawingManager pointerDrawingManager;
836 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.CheckMouseIconPath());
837 }
838
839 /**
840 * @tc.name: InputWindowsManagerTest_DrawPixelmap_001
841 * @tc.desc: Test DrawPixelmap
842 * @tc.type: FUNC
843 * @tc.require:
844 */
845 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPixelmap_001, TestSize.Level1)
846 {
847 CALL_TEST_DEBUG;
848 PointerDrawingManager pointerDrawingManager;
849 pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
850 OHOS::Rosen::Drawing::Canvas canvas;
851 MOUSE_ICON mouseStyle = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
852 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPixelmap(canvas, mouseStyle));
853 }
854
855 /**
856 * @tc.name: InputWindowsManagerTest_DrawPixelmap_002
857 * @tc.desc: Test DrawPixelmap
858 * @tc.type: FUNC
859 * @tc.require:
860 */
861 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPixelmap_002, TestSize.Level1)
862 {
863 CALL_TEST_DEBUG;
864 PointerDrawingManager pointerDrawingManager;
865 pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
866 OHOS::Rosen::Drawing::Canvas canvas;
867 MOUSE_ICON mouseStyle = MOUSE_ICON::RUNNING;
868 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPixelmap(canvas, mouseStyle));
869 }
870
871 /**
872 * @tc.name: InputWindowsManagerTest_DrawPixelmap_003
873 * @tc.desc: Test DrawPixelmap
874 * @tc.type: FUNC
875 * @tc.require:
876 */
877 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPixelmap_003, TestSize.Level1)
878 {
879 CALL_TEST_DEBUG;
880 PointerDrawingManager pointerDrawingManager;
881 pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
882 OHOS::Rosen::Drawing::Canvas canvas;
883 MOUSE_ICON mouseStyle = MOUSE_ICON::WEST_EAST;
884 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPixelmap(canvas, mouseStyle));
885 }
886
887 /**
888 * @tc.name: InputWindowsManagerTest_SetCustomCursor_001
889 * @tc.desc: Test SetCustomCursor
890 * @tc.type: FUNC
891 * @tc.require:
892 */
893 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetCustomCursor_001, TestSize.Level1)
894 {
895 CALL_TEST_DEBUG;
896 PointerDrawingManager pointerDrawingManager;
897 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
898 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
899 ASSERT_NE(pixelMap, nullptr);
900 int32_t pid = -1;
901 int32_t windowId = 1;
902 int32_t focusX = 2;
903 int32_t focusY = 3;
904 int32_t ret = pointerDrawingManager.SetCustomCursor((void *)pixelMap.get(), pid, windowId, focusX, focusY);
905 ASSERT_EQ(ret, RET_ERR);
906 }
907
908 /**
909 * @tc.name: InputWindowsManagerTest_SetCustomCursor_002
910 * @tc.desc: Test SetCustomCursor
911 * @tc.type: FUNC
912 * @tc.require:
913 */
914 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetCustomCursor_002, TestSize.Level1)
915 {
916 CALL_TEST_DEBUG;
917 PointerDrawingManager pointerDrawingManager;
918 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
919 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
920 ASSERT_NE(pixelMap, nullptr);
921 int32_t pid = 1;
922 int32_t windowId = -1;
923 int32_t focusX = 2;
924 int32_t focusY = 3;
925 int32_t ret = pointerDrawingManager.SetCustomCursor((void *)pixelMap.get(), pid, windowId, focusX, focusY);
926 ASSERT_EQ(ret, RET_ERR);
927 }
928
929 /**
930 * @tc.name: InputWindowsManagerTest_SetCustomCursor_003
931 * @tc.desc: Test SetCustomCursor
932 * @tc.type: FUNC
933 * @tc.require:
934 */
935 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetCustomCursor_003, TestSize.Level1)
936 {
937 CALL_TEST_DEBUG;
938 PointerDrawingManager pointerDrawingManager;
939 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
940 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
941 ASSERT_NE(pixelMap, nullptr);
942 int32_t pid = 1;
943 int32_t windowId = 2;
944 int32_t focusX = 2;
945 int32_t focusY = 3;
946 int32_t ret = pointerDrawingManager.SetCustomCursor((void *)pixelMap.get(), pid, windowId, focusX, focusY);
947 ASSERT_EQ(ret, RET_ERR);
948 }
949
950 /**
951 * @tc.name: InputWindowsManagerTest_SetCustomCursor_004
952 * @tc.desc: Test SetCustomCursor
953 * @tc.type: FUNC
954 * @tc.require:
955 */
956 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetCustomCursor_004, TestSize.Level1)
957 {
958 CALL_TEST_DEBUG;
959 PointerDrawingManager pointerDrawingManager;
960 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
961 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
962 ASSERT_NE(pixelMap, nullptr);
963 int32_t pid = 2;
964 int32_t windowId = 2;
965 int32_t focusX = -1;
966 int32_t focusY = 3;
967 int32_t ret = pointerDrawingManager.SetCustomCursor((void *)pixelMap.get(), pid, windowId, focusX, focusY);
968 ASSERT_EQ(ret, RET_ERR);
969 }
970
971 /**
972 * @tc.name: InputWindowsManagerTest_SetCustomCursor_005
973 * @tc.desc: Test SetCustomCursor
974 * @tc.type: FUNC
975 * @tc.require:
976 */
977 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetCustomCursor_005, TestSize.Level1)
978 {
979 CALL_TEST_DEBUG;
980 PointerDrawingManager pointerDrawingManager;
981 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
982 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
983 ASSERT_NE(pixelMap, nullptr);
984 int32_t pid = 2;
985 int32_t windowId = 2;
986 int32_t focusX = 3;
987 int32_t focusY = 4;
988 int32_t ret = pointerDrawingManager.SetCustomCursor((void *)pixelMap.get(), pid, windowId, focusX, focusY);
989 ASSERT_EQ(ret, RET_ERR);
990 }
991
992 /**
993 * @tc.name: InputWindowsManagerTest_SetMouseIcon_002
994 * @tc.desc: Test SetMouseIcon
995 * @tc.type: FUNC
996 * @tc.require:
997 */
998 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseIcon_002, TestSize.Level1)
999 {
1000 CALL_TEST_DEBUG;
1001 PointerDrawingManager pointerDrawingManager;
1002 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
1003 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
1004 ASSERT_NE(pixelMap, nullptr);
1005 int32_t pid = -1;
1006 int32_t windowId = 2;
1007 int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, (void *)pixelMap.get());
1008 ASSERT_EQ(ret, RET_ERR);
1009 }
1010
1011 /**
1012 * @tc.name: InputWindowsManagerTest_SetMouseIcon_003
1013 * @tc.desc: Test SetMouseIcon
1014 * @tc.type: FUNC
1015 * @tc.require:
1016 */
1017 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseIcon_003, TestSize.Level1)
1018 {
1019 CALL_TEST_DEBUG;
1020 PointerDrawingManager pointerDrawingManager;
1021 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
1022 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
1023 ASSERT_NE(pixelMap, nullptr);
1024 int32_t pid = 1;
1025 int32_t windowId = -2;
1026 int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, (void *)pixelMap.get());
1027 ASSERT_EQ(ret, RET_ERR);
1028 }
1029
1030 /**
1031 * @tc.name: InputWindowsManagerTest_SetMouseIcon_004
1032 * @tc.desc: Test SetMouseIcon
1033 * @tc.type: FUNC
1034 * @tc.require:
1035 */
1036 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseIcon_004, TestSize.Level1)
1037 {
1038 CALL_TEST_DEBUG;
1039 PointerDrawingManager pointerDrawingManager;
1040 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
1041 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
1042 ASSERT_NE(pixelMap, nullptr);
1043 int32_t pid = 1;
1044 int32_t windowId = 2;
1045 int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, (void *)pixelMap.get());
1046 ASSERT_EQ(ret, RET_ERR);
1047 }
1048
1049 /**
1050 * @tc.name: InputWindowsManagerTest_SetMouseIcon_005
1051 * @tc.desc: Test SetMouseIcon
1052 * @tc.type: FUNC
1053 * @tc.require:
1054 */
1055 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseIcon_005, TestSize.Level1)
1056 {
1057 CALL_TEST_DEBUG;
1058 PointerDrawingManager pointerDrawingManager;
1059 const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
1060 std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
1061 ASSERT_NE(pixelMap, nullptr);
1062 int32_t pid = 2;
1063 int32_t windowId = 2;
1064 int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, (void *)pixelMap.get());
1065 ASSERT_EQ(ret, RET_ERR);
1066 }
1067
1068 /**
1069 * @tc.name: InputWindowsManagerTest_SetMouseHotSpot_002
1070 * @tc.desc: Test SetMouseHotSpot
1071 * @tc.type: FUNC
1072 * @tc.require:
1073 */
1074 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseHotSpot_002, TestSize.Level1)
1075 {
1076 CALL_TEST_DEBUG;
1077 PointerDrawingManager pointerDrawingManager;
1078 int32_t pid = -1;
1079 int32_t windowId = 2;
1080 int32_t hotSpotX = 3;
1081 int32_t hotSpotY = 4;
1082 int32_t ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1083 ASSERT_EQ(ret, RET_ERR);
1084 pid = 1;
1085 windowId = -2;
1086 hotSpotX = 3;
1087 hotSpotY = 4;
1088 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1089 ASSERT_EQ(ret, RET_ERR);
1090 pid = 1;
1091 windowId = 2;
1092 hotSpotX = 3;
1093 hotSpotY = 4;
1094 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1095 ASSERT_EQ(ret, RET_ERR);
1096 pid = 2;
1097 windowId = 2;
1098 hotSpotX = -3;
1099 hotSpotY = -4;
1100 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1101 ASSERT_EQ(ret, RET_ERR);
1102 pid = 2;
1103 windowId = 2;
1104 hotSpotX = 3;
1105 hotSpotY = 4;
1106 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1107 ASSERT_EQ(ret, RET_ERR);
1108 }
1109
1110 /**
1111 * @tc.name: InputWindowsManagerTest_OnDisplayInfo_001
1112 * @tc.desc: Test OnDisplayInfo
1113 * @tc.type: FUNC
1114 * @tc.require:
1115 */
1116 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_OnDisplayInfo_001, TestSize.Level1)
1117 {
1118 CALL_TEST_DEBUG;
1119 PointerDrawingManager pointerDrawingManager;
1120 DisplayInfo displaysInfo;
1121 DisplayGroupInfo displayGroupInfo;
1122 displayGroupInfo.displaysInfo.push_back(displaysInfo);
1123 displayGroupInfo.focusWindowId = 0;
1124 displayGroupInfo.width = 0;
1125 displayGroupInfo.height = 0;
1126 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1127 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1128 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1129 pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1130 pointerDrawingManager.surfaceNode_->SetFrameGravity(Rosen::Gravity::RESIZE_ASPECT_FILL);
1131 pointerDrawingManager.surfaceNode_->SetPositionZ(Rosen::RSSurfaceNode::POINTER_WINDOW_POSITION_Z);
1132 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.OnDisplayInfo(displayGroupInfo));
1133 }
1134
1135 /**
1136 * @tc.name: InputWindowsManagerTest_OnDisplayInfo_002
1137 * @tc.desc: Test OnDisplayInfo
1138 * @tc.type: FUNC
1139 * @tc.require:
1140 */
1141 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_OnDisplayInfo_002, TestSize.Level1)
1142 {
1143 CALL_TEST_DEBUG;
1144 PointerDrawingManager pointerDrawingManager;
1145 DisplayInfo displaysInfo;
1146 DisplayGroupInfo displayGroupInfo;
1147 displayGroupInfo.displaysInfo.push_back(displaysInfo);
1148 displayGroupInfo.focusWindowId = 0;
1149 displayGroupInfo.width = 0;
1150 displayGroupInfo.height = 0;
1151 pointerDrawingManager.surfaceNode_ = nullptr;
1152 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.OnDisplayInfo(displayGroupInfo));
1153 }
1154
1155 /**
1156 * @tc.name: InputWindowsManagerTest_DrawManager_001
1157 * @tc.desc: Test DrawManager
1158 * @tc.type: FUNC
1159 * @tc.require:
1160 */
1161 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawManager_001, TestSize.Level1)
1162 {
1163 CALL_TEST_DEBUG;
1164 PointerDrawingManager pointerDrawingManager;
1165 pointerDrawingManager.hasDisplay_ = true;
1166 pointerDrawingManager.hasPointerDevice_ = true;
1167 pointerDrawingManager.surfaceNode_ = nullptr;
1168 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1169 }
1170
1171 /**
1172 * @tc.name: InputWindowsManagerTest_DrawManager_002
1173 * @tc.desc: Test DrawManager
1174 * @tc.type: FUNC
1175 * @tc.require:
1176 */
1177 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawManager_002, TestSize.Level1)
1178 {
1179 CALL_TEST_DEBUG;
1180 PointerDrawingManager pointerDrawingManager;
1181 pointerDrawingManager.hasDisplay_ = true;
1182 pointerDrawingManager.hasPointerDevice_ = true;
1183 pointerDrawingManager.surfaceNode_ = nullptr;
1184 pointerDrawingManager.displayInfo_.displayDirection = DIRECTION0;
1185 pointerDrawingManager.lastPhysicalX_ = -1;
1186 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1187 }
1188
1189 /**
1190 * @tc.name: InputWindowsManagerTest_DrawManager_003
1191 * @tc.desc: Test DrawManager
1192 * @tc.type: FUNC
1193 * @tc.require:
1194 */
1195 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawManager_003, TestSize.Level1)
1196 {
1197 CALL_TEST_DEBUG;
1198 PointerDrawingManager pointerDrawingManager;
1199 pointerDrawingManager.hasDisplay_ = true;
1200 pointerDrawingManager.hasPointerDevice_ = true;
1201 pointerDrawingManager.surfaceNode_ = nullptr;
1202 pointerDrawingManager.displayInfo_.displayDirection = DIRECTION90;
1203 pointerDrawingManager.lastPhysicalX_ = 2;
1204 pointerDrawingManager.lastPhysicalY_ = 2;
1205 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1206 }
1207
1208 /**
1209 * @tc.name: InputWindowsManagerTest_DrawManager_004
1210 * @tc.desc: Test DrawManager
1211 * @tc.type: FUNC
1212 * @tc.require:
1213 */
1214 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawManager_004, TestSize.Level1)
1215 {
1216 CALL_TEST_DEBUG;
1217 PointerDrawingManager pointerDrawingManager;
1218 pointerDrawingManager.hasDisplay_ = false;
1219 pointerDrawingManager.hasPointerDevice_ = true;
1220 pointerDrawingManager.surfaceNode_ = nullptr;
1221 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1222 }
1223
1224 /**
1225 * @tc.name: InputWindowsManagerTest_DrawPointerStyle_002
1226 * @tc.desc: Test DrawPointerStyle
1227 * @tc.type: FUNC
1228 * @tc.require:
1229 */
1230 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPointerStyle_002, TestSize.Level1)
1231 {
1232 CALL_TEST_DEBUG;
1233 PointerDrawingManager pointerDrawingManager;
1234 PointerStyle pointerStyle;
1235 pointerStyle.id = 0;
1236 pointerStyle.color = 0;
1237 pointerStyle.size = 2;
1238 pointerDrawingManager.hasDisplay_ = true;
1239 pointerDrawingManager.hasPointerDevice_ = true;
1240 pointerDrawingManager.surfaceNode_ = nullptr;
1241 pointerDrawingManager.displayInfo_.displayDirection = DIRECTION0;
1242 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1243 }
1244
1245 /**
1246 * @tc.name: InputWindowsManagerTest_DrawPointerStyle_003
1247 * @tc.desc: Test DrawPointerStyle
1248 * @tc.type: FUNC
1249 * @tc.require:
1250 */
1251 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPointerStyle_003, TestSize.Level1)
1252 {
1253 CALL_TEST_DEBUG;
1254 PointerDrawingManager pointerDrawingManager;
1255 PointerStyle pointerStyle;
1256 pointerStyle.id = 0;
1257 pointerStyle.color = 0;
1258 pointerStyle.size = 2;
1259 pointerDrawingManager.hasDisplay_ = true;
1260 pointerDrawingManager.hasPointerDevice_ = true;
1261 pointerDrawingManager.surfaceNode_ = nullptr;
1262 pointerDrawingManager.displayInfo_.displayDirection = DIRECTION90;
1263 pointerDrawingManager.lastPhysicalX_ = -1;
1264 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1265 }
1266
1267 /**
1268 * @tc.name: InputWindowsManagerTest_DrawPointerStyle_004
1269 * @tc.desc: Test DrawPointerStyle
1270 * @tc.type: FUNC
1271 * @tc.require:
1272 */
1273 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPointerStyle_004, TestSize.Level1)
1274 {
1275 CALL_TEST_DEBUG;
1276 PointerDrawingManager pointerDrawingManager;
1277 PointerStyle pointerStyle;
1278 pointerStyle.id = 0;
1279 pointerStyle.color = 0;
1280 pointerStyle.size = 2;
1281 pointerDrawingManager.hasDisplay_ = true;
1282 pointerDrawingManager.hasPointerDevice_ = true;
1283 pointerDrawingManager.surfaceNode_ = nullptr;
1284 pointerDrawingManager.displayInfo_.displayDirection = DIRECTION90;
1285 pointerDrawingManager.lastPhysicalX_ = 2;
1286 pointerDrawingManager.lastPhysicalY_ = 2;
1287 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1288 }
1289
1290 /**
1291 * @tc.name: InputWindowsManagerTest_DrawPointerStyle_005
1292 * @tc.desc: Test DrawPointerStyle
1293 * @tc.type: FUNC
1294 * @tc.require:
1295 */
1296 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPointerStyle_005, TestSize.Level1)
1297 {
1298 CALL_TEST_DEBUG;
1299 PointerDrawingManager pointerDrawingManager;
1300 PointerStyle pointerStyle;
1301 pointerStyle.id = 0;
1302 pointerStyle.color = 0;
1303 pointerStyle.size = 2;
1304 pointerDrawingManager.hasDisplay_ = false;
1305 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1306 }
1307
1308 /**
1309 * @tc.name: InputWindowsManagerTest_DrawPointer_001
1310 * @tc.desc: Test DrawPointer
1311 * @tc.type: FUNC
1312 * @tc.require:
1313 */
1314 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPointer_001, TestSize.Level1)
1315 {
1316 CALL_TEST_DEBUG;
1317 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1318 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1319 PointerStyle pointerStyle;
1320 pointerStyle.id = 0;
1321 pointerDrawingManager->DrawPointer(1, 100, 100, pointerStyle, DIRECTION180);
1322 EXPECT_EQ(pointerDrawingManager->lastDirection_, DIRECTION180);
1323 pointerDrawingManager->DrawPointer(1, 200, 200, pointerStyle, DIRECTION270);
1324 EXPECT_EQ(pointerDrawingManager->lastDirection_, DIRECTION270);
1325 }
1326
1327 /**
1328 * @tc.name: InputWindowsManagerTest_DrawPointerStyle_001
1329 * @tc.desc: Test DrawPointerStyle
1330 * @tc.type: FUNC
1331 * @tc.require:
1332 */
1333 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPointerStyle_001, TestSize.Level1)
1334 {
1335 CALL_TEST_DEBUG;
1336 PointerDrawingManager pointerDrawingManager;
1337 PointerStyle pointerStyle;
1338 pointerStyle.id = EAST;
1339 pointerStyle.color = 0;
1340 pointerStyle.size = 2;
1341 pointerDrawingManager.hasDisplay_ = true;
1342 pointerDrawingManager.hasPointerDevice_ = true;
1343 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1344 pointerDrawingManager.lastPhysicalX_ = -1;
1345 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1346 }
1347
1348 /**
1349 * @tc.name: InputWindowsManagerTest_SetMouseHotSpot_003
1350 * @tc.desc: Test SetMouseHotSpot
1351 * @tc.type: FUNC
1352 * @tc.require:
1353 */
1354 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetMouseHotSpot_003, TestSize.Level1)
1355 {
1356 CALL_TEST_DEBUG;
1357 auto winmgrmock = std::make_shared<InputWindowsManagerMock>();
1358 PointerDrawingManager pointerDrawingManager;
1359 int32_t pid = 1;
1360 int32_t windowId = -2;
1361 EXPECT_CALL(*winmgrmock, CheckWindowIdPermissionByPid).WillRepeatedly(testing::Return(RET_OK));
1362 int32_t hotSpotX = -1;
1363 int32_t hotSpotY = 2;
1364 pointerDrawingManager.userIcon_ = nullptr;
1365 int32_t ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1366 ASSERT_EQ(ret, RET_ERR);
1367 hotSpotX = 1;
1368 hotSpotY = -2;
1369 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1370 ASSERT_EQ(ret, RET_ERR);
1371 hotSpotX = 1;
1372 hotSpotY = 2;
1373 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1374 ASSERT_EQ(ret, RET_ERR);
1375 pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
1376 ASSERT_NE(pointerDrawingManager.userIcon_, nullptr);
1377 hotSpotX = -1;
1378 hotSpotY = 2;
1379 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1380 ASSERT_EQ(ret, RET_ERR);
1381 hotSpotX = -1;
1382 hotSpotY = -2;
1383 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1384 ASSERT_EQ(ret, RET_ERR);
1385 hotSpotX = 1;
1386 hotSpotY = -2;
1387 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1388 ASSERT_EQ(ret, RET_ERR);
1389 hotSpotX = 3;
1390 hotSpotY = 4;
1391 pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
1392 ASSERT_NE(pointerDrawingManager.userIcon_, nullptr);
1393 ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
1394 ASSERT_EQ(ret, RET_ERR);
1395 testing::Mock::AllowLeak(winmgrmock.get());
1396 }
1397
1398 /**
1399 * @tc.name: InputWindowsManagerTest_SetPointerColor_002
1400 * @tc.desc: Test SetPointerColor
1401 * @tc.type: FUNC
1402 * @tc.require:
1403 */
1404 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerColor_002, TestSize.Level1)
1405 {
1406 CALL_TEST_DEBUG;
1407 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1408 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1409 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1410 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1411 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1412 pointerDrawingManager->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1413 ASSERT_TRUE(pointerDrawingManager->surfaceNode_ != nullptr);
1414 pointerDrawingManager->SetPointerColor(16777216);
1415 int32_t color = pointerDrawingManager->GetPointerColor();
1416 EXPECT_EQ(color, RET_OK);
1417 }
1418
1419 /**
1420 * @tc.name: InputWindowsManagerTest_UpdatePointerDevice_002
1421 * @tc.desc: Test UpdatePointerDevice
1422 * @tc.type: FUNC
1423 * @tc.require:
1424 */
1425 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_UpdatePointerDevice_002, TestSize.Level1)
1426 {
1427 CALL_TEST_DEBUG;
1428 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1429 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1430 EXPECT_EQ(pointerDrawingManager->pidInfos_.size(), 100);
1431 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager->UpdatePointerDevice(true, false, true));
1432 EXPECT_EQ(pointerDrawingManager->pidInfos_.size(), 100);
1433 pointerDrawingManager->surfaceNode_ = nullptr;
1434 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager->UpdatePointerDevice(false, false, true));
1435 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1436 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1437 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1438 pointerDrawingManager->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1439 ASSERT_TRUE(pointerDrawingManager->surfaceNode_ != nullptr);
1440 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager->UpdatePointerDevice(false, false, true));
1441 }
1442
1443 /**
1444 * @tc.name: InputWindowsManagerTest_DrawManager_005
1445 * @tc.desc: Test DrawManager
1446 * @tc.type: FUNC
1447 * @tc.require:
1448 */
1449 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawManager_005, TestSize.Level1)
1450 {
1451 CALL_TEST_DEBUG;
1452 auto winmgrmock = std::make_shared<InputWindowsManagerMock>();
1453 PointerDrawingManager pointerDrawingManager;
1454 pointerDrawingManager.hasDisplay_ = true;
1455 pointerDrawingManager.hasPointerDevice_ = true;
1456 pointerDrawingManager.surfaceNode_ = nullptr;
1457 EXPECT_CALL(*winmgrmock, CheckWindowIdPermissionByPid).WillRepeatedly(testing::Return(RET_ERR));
1458 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1459 EXPECT_CALL(*winmgrmock, CheckWindowIdPermissionByPid).WillRepeatedly(testing::Return(RET_OK));
1460 pointerDrawingManager.lastPhysicalX_ = -1;
1461 pointerDrawingManager.lastPhysicalY_ = 1;
1462 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1463 pointerDrawingManager.lastPhysicalX_ = 1;
1464 pointerDrawingManager.lastPhysicalY_ = -1;
1465 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1466 pointerDrawingManager.lastPhysicalX_ = -1;
1467 pointerDrawingManager.lastPhysicalY_ = -1;
1468 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1469 EXPECT_CALL(*winmgrmock, CheckWindowIdPermissionByPid).WillRepeatedly(testing::Return(RET_OK));
1470 pointerDrawingManager.lastPhysicalX_ = 1;
1471 pointerDrawingManager.lastPhysicalY_ = 1;
1472 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawManager());
1473 testing::Mock::AllowLeak(winmgrmock.get());
1474 }
1475
1476 /**
1477 * @tc.name: InputWindowsManagerTest_SetPointerVisible_002
1478 * @tc.desc: Test SetPointerVisible
1479 * @tc.type: FUNC
1480 * @tc.require:
1481 */
1482 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerVisible_002, TestSize.Level1)
1483 {
1484 CALL_TEST_DEBUG;
1485 auto winmgrmock = std::make_shared<InputWindowsManagerMock>();
1486 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1487 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1488 EXPECT_CALL(*winmgrmock, GetExtraData).WillRepeatedly(testing::Return(ExtraData{true}));
1489 int32_t pid = 1;
1490 bool visible = true;
1491 int32_t priority = 0;
1492 int32_t ret = pointerDrawingManager->SetPointerVisible(pid, visible, priority, false);
1493 ASSERT_EQ(ret, RET_OK);
1494 visible = false;
1495 priority = 0;
1496 ret = pointerDrawingManager->SetPointerVisible(pid, visible, priority, false);
1497 ASSERT_EQ(ret, RET_OK);
1498 visible = true;
1499 priority = 1;
1500 ret = pointerDrawingManager->SetPointerVisible(pid, visible, priority, false);
1501 ASSERT_EQ(ret, RET_OK);
1502 visible = false;
1503 priority = 1;
1504 ret = pointerDrawingManager->SetPointerVisible(pid, visible, priority, false);
1505 ASSERT_EQ(ret, RET_OK);
1506 EXPECT_CALL(*winmgrmock, GetExtraData).WillRepeatedly(testing::Return(ExtraData{false}));
1507 visible = false;
1508 priority = 0;
1509 ret = pointerDrawingManager->SetPointerVisible(pid, visible, priority, false);
1510 ASSERT_EQ(ret, RET_OK);
1511 visible = true;
1512 priority = 1;
1513 ret = pointerDrawingManager->SetPointerVisible(pid, visible, priority, false);
1514 ASSERT_EQ(ret, RET_OK);
1515 visible = false;
1516 priority = 1;
1517 ret = pointerDrawingManager->SetPointerVisible(pid, visible, priority, false);
1518 ASSERT_EQ(ret, RET_OK);
1519 testing::Mock::AllowLeak(winmgrmock.get());
1520 }
1521
1522 /**
1523 * @tc.name: InputWindowsManagerTest_SetPointerLocation_002
1524 * @tc.desc: Test SetPointerLocation
1525 * @tc.type: FUNC
1526 * @tc.require:
1527 */
1528 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerLocation_002, TestSize.Level1)
1529 {
1530 CALL_TEST_DEBUG;
1531 PointerDrawingManager pointerDrawingManager;
1532 int32_t x = 100;
1533 int32_t y = 100;
1534 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1535 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1536 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1537 pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1538 ASSERT_TRUE(pointerDrawingManager.surfaceNode_ != nullptr);
1539 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.SetPointerLocation(x, y));
1540 }
1541
1542 /**
1543 * @tc.name: InputWindowsManagerTest_UpdateDefaultPointerStyle_002
1544 * @tc.desc: Test UpdateDefaultPointerStyle
1545 * @tc.type: FUNC
1546 * @tc.require:
1547 */
1548 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_UpdateDefaultPointerStyle_002, TestSize.Level1)
1549 {
1550 CALL_TEST_DEBUG;
1551 auto winmgrmock = std::make_shared<InputWindowsManagerMock>();
1552 PointerDrawingManager pointerDrawingManager;
1553 int32_t pid = 1;
1554 int32_t windowId = -1;
1555 PointerStyle pointerStyle;
1556 pointerStyle.id = 0;
1557 pointerStyle.color = 0;
1558 pointerStyle.size = 2;
1559 EXPECT_CALL(*winmgrmock, GetPointerStyle).WillRepeatedly(testing::Return(RET_ERR));
1560 int32_t ret = pointerDrawingManager.UpdateDefaultPointerStyle(pid, windowId, pointerStyle);
1561 EXPECT_EQ(ret, RET_OK);
1562 testing::Mock::AllowLeak(winmgrmock.get());
1563 }
1564
1565 /**
1566 * @tc.name: InputWindowsManagerTest_GetPointerStyle_001
1567 * @tc.desc: Test GetPointerStyle
1568 * @tc.type: FUNC
1569 * @tc.require:
1570 */
1571 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_GetPointerStyle_001, TestSize.Level1)
1572 {
1573 CALL_TEST_DEBUG;
1574 auto winmgrmock = std::make_shared<InputWindowsManagerMock>();
1575 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1576 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1577 int32_t pid = 1;
1578 int32_t windowId = 2;
1579 bool isUiExtension = true;
1580 PointerStyle pointerStyle;
1581 EXPECT_CALL(*winmgrmock, GetPointerStyle).WillRepeatedly(testing::Return(RET_ERR));
1582 int32_t ret = pointerDrawingManager->GetPointerStyle(pid, windowId, pointerStyle, isUiExtension);
1583 EXPECT_EQ(ret, RET_OK);
1584 testing::Mock::AllowLeak(winmgrmock.get());
1585 }
1586
1587 /**
1588 * @tc.name: InputWindowsManagerTest_DrawPointerStyle_006
1589 * @tc.desc: Test DrawPointerStyle
1590 * @tc.type: FUNC
1591 * @tc.require:
1592 */
1593 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_DrawPointerStyle_006, TestSize.Level1)
1594 {
1595 CALL_TEST_DEBUG;
1596 PointerDrawingManager pointerDrawingManager;
1597 PointerStyle pointerStyle;
1598 pointerStyle.id = 0;
1599 pointerStyle.color = 0;
1600 pointerStyle.size = 2;
1601 pointerDrawingManager.hasDisplay_ = false;
1602 pointerDrawingManager.hasPointerDevice_ = true;
1603 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1604 pointerDrawingManager.hasDisplay_ = true;
1605 pointerDrawingManager.hasPointerDevice_ = false;
1606 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1607 pointerDrawingManager.hasDisplay_ = false;
1608 pointerDrawingManager.hasPointerDevice_ = false;
1609 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1610 pointerDrawingManager.hasDisplay_ = true;
1611 pointerDrawingManager.hasPointerDevice_ = true;
1612 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1613 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1614 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1615 pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1616 ASSERT_TRUE(pointerDrawingManager.surfaceNode_ != nullptr);
1617 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1618 pointerDrawingManager.hasDisplay_ = true;
1619 pointerDrawingManager.hasPointerDevice_ = true;
1620 pointerDrawingManager.surfaceNode_ = nullptr;
1621 pointerDrawingManager.lastPhysicalX_ = -1;
1622 pointerDrawingManager.lastPhysicalY_ = 1;
1623 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1624 pointerDrawingManager.lastPhysicalX_ = 1;
1625 pointerDrawingManager.lastPhysicalY_ = -1;
1626 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1627 pointerDrawingManager.lastPhysicalX_ = -1;
1628 pointerDrawingManager.lastPhysicalY_ = -1;
1629 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1630 pointerDrawingManager.lastPhysicalX_ = 1;
1631 pointerDrawingManager.lastPhysicalY_ = 1;
1632 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
1633 }
1634
1635 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
1636 /**
1637 * @tc.name: InputWindowsManagerTest_SetPixelMap
1638 * @tc.desc: Test SetPixelMap
1639 * @tc.type: FUNC
1640 * @tc.require:
1641 */
1642 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPixelMap, TestSize.Level1)
1643 {
1644 CALL_TEST_DEBUG;
1645 PointerDrawingManager manager;
1646 std::shared_ptr<OHOS::Media::PixelMap> pixelMap = nullptr;
1647 ASSERT_NO_FATAL_FAILURE(manager.SetPixelMap(pixelMap));
1648 }
1649 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
1650
1651 /**
1652 * @tc.name: PointerDrawingManagerTest_SwitchPointerStyle
1653 * @tc.desc: Test SwitchPointerStyle
1654 * @tc.type: FUNC
1655 * @tc.require:
1656 */
1657 HWTEST_F(PointerDrawingManagerTest, PointerDrawingManagerTest_SwitchPointerStyle, TestSize.Level1)
1658 {
1659 CALL_TEST_DEBUG;
1660 PointerDrawingManager pointerDrawMgr;
1661 pointerDrawMgr.lastMouseStyle_.id = 2;
1662 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.SwitchPointerStyle());
1663 }
1664
1665 /**
1666 * @tc.name: PointerDrawingManagerTest_CreateMagicCursorChangeObserver
1667 * @tc.desc: Test CreateMagicCursorChangeObserver
1668 * @tc.type: FUNC
1669 * @tc.require:
1670 */
1671 HWTEST_F(PointerDrawingManagerTest, PointerDrawingManagerTest_CreateMagicCursorChangeObserver, TestSize.Level1)
1672 {
1673 CALL_TEST_DEBUG;
1674 PointerDrawingManager pointerDrawMgr;
1675 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.CreateMagicCursorChangeObserver());
1676 }
1677
1678 /**
1679 * @tc.name: PointerDrawingManagerTest_UpdateStyleOptions
1680 * @tc.desc: Test UpdateStyleOptions
1681 * @tc.type: FUNC
1682 * @tc.require:
1683 */
1684 HWTEST_F(PointerDrawingManagerTest, PointerDrawingManagerTest_UpdateStyleOptions, TestSize.Level1)
1685 {
1686 CALL_TEST_DEBUG;
1687 PointerDrawingManager pointerDrawMgr;
1688 pointerDrawMgr.pid_ = 100;
1689 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.UpdateStyleOptions());
1690 }
1691
1692 /**
1693 * @tc.name: PointerDrawingManagerTest_InitPointerObserver
1694 * @tc.desc: Test InitPointerObserver
1695 * @tc.type: FUNC
1696 * @tc.require:
1697 */
1698 HWTEST_F(PointerDrawingManagerTest, PointerDrawingManagerTest_InitPointerObserver, TestSize.Level1)
1699 {
1700 CALL_TEST_DEBUG;
1701 PointerDrawingManager pointerDrawMgr;
1702 pointerDrawMgr.hasInitObserver_ = true;
1703 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.InitPointerObserver());
1704
1705 pointerDrawMgr.hasInitObserver_ = false;
1706 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.InitPointerObserver());
1707 }
1708
1709 /**
1710 * @tc.name: PointerDrawingManagerTest_AdjustMouseFocusByDirection90
1711 * @tc.desc: Test AdjustMouseFocusByDirection90
1712 * @tc.type: FUNC
1713 * @tc.require:
1714 */
1715 HWTEST_F(PointerDrawingManagerTest, PointerDrawingManagerTest_AdjustMouseFocusByDirection90, TestSize.Level1)
1716 {
1717 CALL_TEST_DEBUG;
1718 PointerDrawingManager pointerDrawMgr;
1719 ICON_TYPE iconType = ANGLE_SW;
1720 int32_t physicalX = 500;
1721 int32_t physicalY = 500;
1722 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
1723 iconType = ANGLE_CENTER;
1724 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
1725 iconType = ANGLE_NW_RIGHT;
1726 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
1727 iconType = ANGLE_NW;
1728 pointerDrawMgr.userIcon_ = CreatePixelMap(MIDDLE_PIXEL_MAP_WIDTH, MIDDLE_PIXEL_MAP_HEIGHT);
1729 ASSERT_NE(pointerDrawMgr.userIcon_, nullptr);
1730 pointerDrawMgr.currentMouseStyle_.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
1731 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
1732 pointerDrawMgr.userIcon_ = nullptr;
1733 ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
1734 }
1735
1736 /**
1737 * @tc.name: InputWindowsManagerTest_SetPointerColor_003
1738 * @tc.desc: Test SetPointerColor
1739 * @tc.type: FUNC
1740 * @tc.require:
1741 */
1742 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerColor_003, TestSize.Level1)
1743 {
1744 CALL_TEST_DEBUG;
1745 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1746 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1747 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1748 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1749 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1750 pointerDrawingManager->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1751 ASSERT_TRUE(pointerDrawingManager->surfaceNode_ != nullptr);
1752 pointerDrawingManager->SetPointerColor(16777216);
1753 int32_t color = pointerDrawingManager->GetPointerColor();
1754 EXPECT_EQ(color, RET_OK);
1755 pointerDrawingManager->surfaceNode_ = nullptr;
1756 ASSERT_TRUE(pointerDrawingManager->surfaceNode_ == nullptr);
1757 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
1758 MAGIC_CURSOR->isExistDefaultStyle = false;
1759 int32_t ret = pointerDrawingManager->SetPointerColor(16777216);
1760 EXPECT_EQ(ret, RET_OK);
1761 MAGIC_CURSOR->isExistDefaultStyle = true;
1762 ret = pointerDrawingManager->SetPointerColor(16777216);
1763 EXPECT_EQ(ret, RET_OK);
1764 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
1765 }
1766
1767 /**
1768 * @tc.name: InputWindowsManagerTest_SetPointerSize_002
1769 * @tc.desc: Test SetPointerSize
1770 * @tc.type: FUNC
1771 * @tc.require:
1772 */
1773 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetPointerSize_002, TestSize.Level1)
1774 {
1775 CALL_TEST_DEBUG;
1776 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1777 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1778 pointerDrawingManager->SetPointerSize(0);
1779 int32_t pointerSize = pointerDrawingManager->GetPointerSize();
1780 EXPECT_EQ(pointerSize, 1);
1781 pointerDrawingManager->SetPointerSize(8);
1782 pointerSize = pointerDrawingManager->GetPointerSize();
1783 EXPECT_EQ(pointerSize, 7);
1784 pointerDrawingManager->surfaceNode_ = nullptr;
1785 ASSERT_TRUE(pointerDrawingManager->surfaceNode_ == nullptr);
1786 pointerDrawingManager->SetPointerSize(5);
1787 pointerSize = pointerDrawingManager->GetPointerSize();
1788 EXPECT_EQ(pointerSize, 5);
1789 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1790 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1791 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1792 pointerDrawingManager->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1793 ASSERT_TRUE(pointerDrawingManager->surfaceNode_ != nullptr);
1794 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
1795 MAGIC_CURSOR->isExistDefaultStyle = false;
1796 int32_t ret = pointerDrawingManager->SetPointerSize(5);
1797 EXPECT_EQ(ret, RET_OK);
1798 MAGIC_CURSOR->isExistDefaultStyle = true;
1799 ret = pointerDrawingManager->SetPointerSize(5);
1800 EXPECT_EQ(ret, RET_OK);
1801 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
1802 }
1803
1804 /**
1805 * @tc.name: InputWindowsManagerTest_UpdatePointerDevice_003
1806 * @tc.desc: Test UpdatePointerDevice
1807 * @tc.type: FUNC
1808 * @tc.require:
1809 */
1810 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_UpdatePointerDevice_003, TestSize.Level1)
1811 {
1812 CALL_TEST_DEBUG;
1813 std::shared_ptr<PointerDrawingManager> pointerDrawingManager =
1814 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
1815 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager->UpdatePointerDevice(true, false, true));
1816 pointerDrawingManager->UpdatePointerDevice(true, true, true);
1817 pointerDrawingManager->surfaceNode_ = nullptr;
1818 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager->UpdatePointerDevice(false, false, true));
1819 Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1820 surfaceNodeConfig.SurfaceNodeName = "pointer window";
1821 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1822 pointerDrawingManager->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1823 ASSERT_TRUE(pointerDrawingManager->surfaceNode_ != nullptr);
1824 ASSERT_NO_FATAL_FAILURE(pointerDrawingManager->UpdatePointerDevice(false, false, true));
1825 }
1826
1827 /**
1828 * @tc.name: InputWindowsManagerTest_SetTargetDevice_001
1829 * @tc.desc: Test SetTargetDevice
1830 * @tc.type: FUNC
1831 * @tc.require:
1832 */
1833 HWTEST_F(PointerDrawingManagerTest, InputWindowsManagerTest_SetTargetDevice_001, TestSize.Level1)
1834 {
1835 #ifdef OHOS_BUILD_ENABLE_HARDWARE_CURSOR
1836 CALL_TEST_DEBUG;
1837 uint32_t devId = 0;
1838 hardwareCursorPointerManager_->devId_ = 0;
1839 hardwareCursorPointerManager_->SetTargetDevice(devId);
1840 ASSERT_FALSE(hardwareCursorPointerManager_->isEnableState_);
1841 devId = 10;
1842 hardwareCursorPointerManager_->SetTargetDevice(devId);
1843 ASSERT_FALSE(hardwareCursorPointerManager_->isEnableState_);
1844 #endif // OHOS_BUILD_ENABLE_HARDWARE_CURSOR
1845 }
1846 } // namespace MMI
1847 } // namespace OHOS