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 "i_preference_manager.h"
24 #include "knuckle_drawing_manager.h"
25 #include "libinput_mock.h"
26 #include "mmi_log.h"
27 #include "parameters.h"
28 #include "pixel_map.h"
29 #include "pointer_drawing_manager.h"
30 #include "pointer_event.h"
31 
32 #undef MMI_LOG_TAG
33 #define MMI_LOG_TAG "PointerDrawingManagerExTest"
34 
35 namespace OHOS {
36 namespace MMI {
37 namespace {
38 using namespace testing::ext;
39 constexpr int32_t MOUSE_ICON_SIZE = 64;
40 constexpr uint32_t DEFAULT_ICON_COLOR { 0xFF };
41 constexpr int32_t MIDDLE_PIXEL_MAP_WIDTH { 400 };
42 constexpr int32_t MIDDLE_PIXEL_MAP_HEIGHT { 400 };
43 constexpr int32_t MAX_PIXEL_MAP_WIDTH { 600 };
44 constexpr int32_t MAX_PIXEL_MAP_HEIGHT { 600 };
45 constexpr int32_t INT32_BYTE { 4 };
46 constexpr int32_t WINDOW_ROTATE { 0 };
47 constexpr int32_t FOLDABLE_DEVICE { 2 };
48 const std::string POINTER_COLOR { "pointerColor" };
49 const std::string POINTER_SIZE { "pointerSize" };
50 constexpr uint32_t RGB_CHANNEL_BITS_LENGTH { 24 };
51 constexpr float MAX_ALPHA_VALUE { 255.f };
52 const std::string MOUSE_FILE_NAME { "mouse_settings.xml" };
53 const int32_t ROTATE_POLICY = system::GetIntParameter("const.window.device.rotate_policy", 0);
54 } // namespace
55 
56 class PointerDrawingManagerExTest : public testing::Test {
57 public:
SetUpTestCase(void)58     static void SetUpTestCase(void) {};
TearDownTestCase(void)59     static void TearDownTestCase(void) {};
60     static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height);
SetUp(void)61     void SetUp(void)
62     {}
TearDown(void)63     void TearDown(void)
64     {}
65 
66     std::unique_ptr<OHOS::Media::PixelMap> SetMouseIconTest(const std::string iconPath);
67 private:
68 };
69 
SetMouseIconTest(const std::string iconPath)70 std::unique_ptr<OHOS::Media::PixelMap> PointerDrawingManagerExTest::SetMouseIconTest(const std::string iconPath)
71 {
72     CALL_DEBUG_ENTER;
73     OHOS::Media::SourceOptions opts;
74     opts.formatHint = "image/svg+xml";
75     uint32_t ret = 0;
76     auto imageSource = OHOS::Media::ImageSource::CreateImageSource(iconPath, opts, ret);
77     CHKPP(imageSource);
78     std::set<std::string> formats;
79     ret = imageSource->GetSupportedFormats(formats);
80     MMI_HILOGD("Get supported format ret:%{public}u", ret);
81 
82     OHOS::Media::DecodeOptions decodeOpts;
83     decodeOpts.desiredSize = {.width = MOUSE_ICON_SIZE, .height = MOUSE_ICON_SIZE};
84 
85     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, ret);
86     CHKPL(pixelMap);
87     return pixelMap;
88 }
89 
CreatePixelMap(int32_t width,int32_t height)90 std::shared_ptr<Media::PixelMap> PointerDrawingManagerExTest::CreatePixelMap(int32_t width, int32_t height)
91 {
92     CALL_DEBUG_ENTER;
93     if (width <= 0 || width > MAX_PIXEL_MAP_WIDTH || height <= 0 || height > MAX_PIXEL_MAP_HEIGHT) {
94         return nullptr;
95     }
96     Media::InitializationOptions opts;
97     opts.size.height = height;
98     opts.size.width = width;
99     opts.pixelFormat = Media::PixelFormat::BGRA_8888;
100     opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
101     opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE;
102 
103     int32_t colorLen = width * height;
104     uint32_t *pixelColors = new (std::nothrow) uint32_t[colorLen];
105     CHKPP(pixelColors);
106     int32_t colorByteCount = colorLen * INT32_BYTE;
107     errno_t ret = memset_s(pixelColors, colorByteCount, DEFAULT_ICON_COLOR, colorByteCount);
108     if (ret != EOK) {
109         delete[] pixelColors;
110         return nullptr;
111     }
112     std::shared_ptr<Media::PixelMap> pixelMap = Media::PixelMap::Create(pixelColors, colorLen, opts);
113     if (pixelMap == nullptr) {
114         delete[] pixelColors;
115         return nullptr;
116     }
117     delete[] pixelColors;
118     return pixelMap;
119 }
120 
121 /**
122  * @tc.name: InputWindowsManagerTest_SetPointerLocation_01
123  * @tc.desc: Test SetPointerLocation
124  * @tc.type: FUNC
125  * @tc.require:
126  */
127 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerLocation_01, TestSize.Level1)
128 {
129     CALL_TEST_DEBUG;
130     PointerDrawingManager pointerDrawingManager;
131     int32_t x = 50;
132     int32_t y = 60;
133     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.SetPointerLocation(x, y));
134 }
135 
136 /**
137  * @tc.name: InputWindowsManagerTest_SetPointerLocation_02
138  * @tc.desc: Test SetPointerLocation
139  * @tc.type: FUNC
140  * @tc.require:
141  */
142 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerLocation_02, TestSize.Level1)
143 {
144     CALL_TEST_DEBUG;
145     PointerDrawingManager pointerDrawingManager;
146     int32_t x = 40;
147     int32_t y = 50;
148     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
149     surfaceNodeConfig.SurfaceNodeName = "pointer window";
150     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
151     pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
152     ASSERT_TRUE(pointerDrawingManager.surfaceNode_ != nullptr);
153     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.SetPointerLocation(x, y));
154 }
155 
156 /**
157  * @tc.name: InputWindowsManagerTest_UpdateDefaultPointerStyle_01
158  * @tc.desc: Test UpdateDefaultPointerStyle
159  * @tc.type: FUNC
160  * @tc.require:
161  */
162 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdateDefaultPointerStyle_01, TestSize.Level1)
163 {
164     CALL_TEST_DEBUG;
165     PointerDrawingManager pointerDrawingManager;
166     int32_t pid = 1;
167     int32_t windowId = 2;
168     EXPECT_TRUE(windowId != GLOBAL_WINDOW_ID);
169     PointerStyle pointerStyle;
170     bool isUiExtension = true;
171     pointerStyle.id = 1;
172     int32_t ret1 = pointerDrawingManager.UpdateDefaultPointerStyle(pid, windowId, pointerStyle, isUiExtension);
173     EXPECT_EQ(ret1, RET_OK);
174 
175     PointerStyle style;
176     windowId = -1;
177     EXPECT_FALSE(windowId != GLOBAL_WINDOW_ID);
178     pointerStyle.id = 2;
179     style.id = 3;
180     EXPECT_TRUE(pointerStyle.id != style.id);
181     int32_t ret2 = pointerDrawingManager.UpdateDefaultPointerStyle(pid, windowId, pointerStyle, isUiExtension);
182     EXPECT_EQ(ret2, RET_OK);
183 
184     pointerStyle.id = MOUSE_ICON::DEFAULT;
185     int32_t ret3 = pointerDrawingManager.UpdateDefaultPointerStyle(pid, windowId, pointerStyle, isUiExtension);
186     EXPECT_EQ(ret3, RET_OK);
187 
188     pointerStyle.id = 3;
189     EXPECT_TRUE(pointerStyle.id == style.id);
190     int32_t ret4 = pointerDrawingManager.UpdateDefaultPointerStyle(pid, windowId, pointerStyle, isUiExtension);
191     EXPECT_EQ(ret4, RET_OK);
192 }
193 
194 /**
195  * @tc.name: InputWindowsManagerTest_UpdateIconPath_01
196  * @tc.desc: Test UpdateIconPath
197  * @tc.type: FUNC
198  * @tc.require:
199  */
200 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdateIconPath_01, TestSize.Level1)
201 {
202     CALL_TEST_DEBUG;
203     PointerDrawingManager pointerDrawingManager;
204     pointerDrawingManager.mouseIcons_[DEFAULT] = {0, "/system/etc/multimodalinput/mouse_icon/default_icon.svg"};
205     pointerDrawingManager.mouseIcons_[EAST] = {1, "/system/etc/multimodalinput/mouse_icon/east_icon.png"};
206     pointerDrawingManager.mouseIcons_[WEST] = {2, "/system/etc/multimodalinput/mouse_icon/west_icon.png"};
207     pointerDrawingManager.mouseIcons_[SOUTH] = {3, "/system/etc/multimodalinput/mouse_icon/south_icon.png"};
208     pointerDrawingManager.mouseIcons_[NORTH] = {4, "/system/etc/multimodalinput/mouse_icon/north_icon.png"};
209 
210     MOUSE_ICON mouseStyle = EAST;
211     std::string iconPath = ("/system/etc/multimodalinput/mouse_icon/Loading_Left.svg");
212     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.UpdateIconPath(mouseStyle, iconPath));
213 }
214 
215 /**
216  * @tc.name: InputWindowsManagerTest_UpdateIconPath_02
217  * @tc.desc: Test UpdateIconPath
218  * @tc.type: FUNC
219  * @tc.require:
220  */
221 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdateIconPath_02, TestSize.Level1)
222 {
223     CALL_TEST_DEBUG;
224     PointerDrawingManager pointerDrawingManager;
225     pointerDrawingManager.mouseIcons_[DEFAULT] = {0, "/system/etc/multimodalinput/mouse_icon/default_icon.svg"};
226     pointerDrawingManager.mouseIcons_[EAST] = {1, "/system/etc/multimodalinput/mouse_icon/east_icon.png"};
227     pointerDrawingManager.mouseIcons_[WEST] = {2, "/system/etc/multimodalinput/mouse_icon/west_icon.png"};
228     pointerDrawingManager.mouseIcons_[SOUTH] = {3, "/system/etc/multimodalinput/mouse_icon/south_icon.png"};
229     pointerDrawingManager.mouseIcons_[NORTH] = {4, "/system/etc/multimodalinput/mouse_icon/north_icon.png"};
230 
231     MOUSE_ICON mouseStyle = WEST_EAST;
232     std::string iconPath = ("/system/etc/multimodalinput/mouse_icon/Loading_Left.svg");
233     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.UpdateIconPath(mouseStyle, iconPath));
234 }
235 
236 /**
237  * @tc.name: InputWindowsManagerTest_CheckPointerStyleParam_01
238  * @tc.desc: Test CheckPointerStyleParam
239  * @tc.type: FUNC
240  * @tc.require:
241  */
242 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_CheckPointerStyleParam_01, TestSize.Level1)
243 {
244     CALL_TEST_DEBUG;
245     PointerDrawingManager pointerDrawingManager;
246     int32_t windowId = 2;
247     PointerStyle pointerStyle;
248     pointerStyle.id = -2;
249     bool ret1 = pointerDrawingManager.CheckPointerStyleParam(windowId, pointerStyle);
250     EXPECT_FALSE(ret1);
251 
252     pointerStyle.id = 46;
253     bool ret2 = pointerDrawingManager.CheckPointerStyleParam(windowId, pointerStyle);
254     EXPECT_FALSE(ret2);
255 
256     windowId = -3;
257     bool ret3 = pointerDrawingManager.CheckPointerStyleParam(windowId, pointerStyle);
258     EXPECT_FALSE(ret3);
259 }
260 
261 /**
262  * @tc.name: InputWindowsManagerTest_UpdateStyleOptions_01
263  * @tc.desc: Test UpdateStyleOptions
264  * @tc.type: FUNC
265  * @tc.require:
266  */
267 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdateStyleOptions_01, TestSize.Level1)
268 {
269     CALL_TEST_DEBUG;
270     PointerDrawingManager pointerDrawMgr;
271     pointerDrawMgr.pid_ = 3;
272     PointerStyle curPointerStyle;
273     curPointerStyle.options = 1;
274     int ret = WIN_MGR->SetPointerStyle(pointerDrawMgr.pid_, GLOBAL_WINDOW_ID, curPointerStyle);
275     EXPECT_EQ(ret, RET_OK);
276     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.UpdateStyleOptions());
277 }
278 
279 /**
280  * @tc.name: InputWindowsManagerTest_AdjustMouseFocus_01
281  * @tc.desc: Test AdjustMouseFocus
282  * @tc.type: FUNC
283  * @tc.require:
284  */
285 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocus_01, TestSize.Level1)
286 {
287     CALL_TEST_DEBUG;
288     PointerDrawingManager pointerDrawMgr;
289     Direction direction;
290     ICON_TYPE iconType = ANGLE_SW;
291     int32_t physicalX = 50;
292     int32_t physicalY = 60;
293 
294     direction = DIRECTION0;
295     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocus(direction, iconType, physicalX, physicalY));
296     direction = DIRECTION90;
297     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocus(direction, iconType, physicalX, physicalY));
298     direction = DIRECTION180;
299     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocus(direction, iconType, physicalX, physicalY));
300     direction = DIRECTION270;
301     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.AdjustMouseFocus(direction, iconType, physicalX, physicalY));
302 }
303 
304 /**
305  * @tc.name: PointerDrawingManagerExTest_ConvertToColorSpace
306  * @tc.desc: Test ConvertToColorSpace
307  * @tc.type: FUNC
308  * @tc.require:
309  */
310 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_ConvertToColorSpace, TestSize.Level1)
311 {
312     CALL_TEST_DEBUG;
313     PointerDrawingManager pointerDrawingManager;
314     Media::ColorSpace colorSpace = Media::ColorSpace::DISPLAY_P3;
315     EXPECT_NE(pointerDrawingManager.ConvertToColorSpace(colorSpace), nullptr);
316     colorSpace = Media::ColorSpace::LINEAR_SRGB;
317     EXPECT_NE(pointerDrawingManager.ConvertToColorSpace(colorSpace), nullptr);
318     colorSpace = Media::ColorSpace::SRGB;
319     EXPECT_NE(pointerDrawingManager.ConvertToColorSpace(colorSpace), nullptr);
320     colorSpace = static_cast<Media::ColorSpace>(5);
321     EXPECT_NE(pointerDrawingManager.ConvertToColorSpace(colorSpace), nullptr);
322 }
323 
324 /**
325  * @tc.name: PointerDrawingManagerExTest_PixelFormatToColorType
326  * @tc.desc: Test PixelFormatToColorType
327  * @tc.type: FUNC
328  * @tc.require:
329  */
330 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_PixelFormatToColorType, TestSize.Level1)
331 {
332     CALL_TEST_DEBUG;
333     PointerDrawingManager pointerDrawingManager;
334     Media::PixelFormat pixelFmt = Media::PixelFormat::RGB_565;
335     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
336         Rosen::Drawing::ColorType::COLORTYPE_RGB_565);
337     pixelFmt = Media::PixelFormat::RGBA_8888;
338     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
339         Rosen::Drawing::ColorType::COLORTYPE_RGBA_8888);
340     pixelFmt = Media::PixelFormat::BGRA_8888;
341     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
342         Rosen::Drawing::ColorType::COLORTYPE_BGRA_8888);
343     pixelFmt = Media::PixelFormat::ALPHA_8;
344     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
345         Rosen::Drawing::ColorType::COLORTYPE_ALPHA_8);
346     pixelFmt = Media::PixelFormat::RGBA_F16;
347     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
348         Rosen::Drawing::ColorType::COLORTYPE_RGBA_F16);
349     pixelFmt = Media::PixelFormat::UNKNOWN;
350     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
351         Rosen::Drawing::ColorType::COLORTYPE_UNKNOWN);
352     pixelFmt = Media::PixelFormat::ARGB_8888;
353     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
354         Rosen::Drawing::ColorType::COLORTYPE_UNKNOWN);
355     pixelFmt = Media::PixelFormat::RGB_888;
356     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
357         Rosen::Drawing::ColorType::COLORTYPE_UNKNOWN);
358     pixelFmt = Media::PixelFormat::NV21;
359     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
360         Rosen::Drawing::ColorType::COLORTYPE_UNKNOWN);
361     pixelFmt = Media::PixelFormat::NV12;
362     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
363         Rosen::Drawing::ColorType::COLORTYPE_UNKNOWN);
364     pixelFmt = Media::PixelFormat::CMYK;
365     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
366         Rosen::Drawing::ColorType::COLORTYPE_UNKNOWN);
367     pixelFmt = static_cast<Media::PixelFormat>(100);
368     EXPECT_EQ(pointerDrawingManager.PixelFormatToColorType(pixelFmt),
369         Rosen::Drawing::ColorType::COLORTYPE_UNKNOWN);
370 }
371 
372 /**
373  * @tc.name: PointerDrawingManagerExTest__AlphaTypeToAlphaType
374  * @tc.desc: Test AlphaTypeToAlphaType
375  * @tc.type: Function
376  * @tc.require:
377  */
378 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_AlphaTypeToAlphaType, TestSize.Level1)
379 {
380     CALL_TEST_DEBUG;
381     PointerDrawingManager pointerDrawingManager;
382     Media::AlphaType alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN;
383     EXPECT_EQ(pointerDrawingManager.AlphaTypeToAlphaType(alphaType),
384         Rosen::Drawing::AlphaType::ALPHATYPE_UNKNOWN);
385     alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
386     EXPECT_EQ(pointerDrawingManager.AlphaTypeToAlphaType(alphaType),
387         Rosen::Drawing::AlphaType::ALPHATYPE_OPAQUE);
388     alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_PREMUL;
389     EXPECT_EQ(pointerDrawingManager.AlphaTypeToAlphaType(alphaType),
390         Rosen::Drawing::AlphaType::ALPHATYPE_PREMUL);
391     alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_UNPREMUL;
392     EXPECT_EQ(pointerDrawingManager.AlphaTypeToAlphaType(alphaType),
393         Rosen::Drawing::AlphaType::ALPHATYPE_UNPREMUL);
394     alphaType = static_cast<Media::AlphaType>(5);
395     EXPECT_EQ(pointerDrawingManager.AlphaTypeToAlphaType(alphaType),
396         Rosen::Drawing::AlphaType::ALPHATYPE_UNKNOWN);
397 }
398 
399 /**
400  * @tc.name: InputWindowsManagerTest_DrawPointerStyle_01
401  * @tc.desc: Test DrawPointerStyle
402  * @tc.type: FUNC
403  * @tc.require:
404  */
405 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_DrawPointerStyle_01, TestSize.Level1)
406 {
407     CALL_TEST_DEBUG;
408     PointerDrawingManager pointerDrawingManager;
409     pointerDrawingManager.hasDisplay_ = true;
410     pointerDrawingManager.hasPointerDevice_ = true;
411 
412     PointerStyle pointerStyle;
413     pointerStyle.id = 1;
414     pointerStyle.color = 1;
415     pointerStyle.size = 2;
416 
417     int32_t ROTATE_POLICY;
418     ROTATE_POLICY = WINDOW_ROTATE;
419     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
420 }
421 
422 /**
423  * @tc.name: InputWindowsManagerTest_DrawPointerStyle_02
424  * @tc.desc: Test DrawPointerStyle
425  * @tc.type: FUNC
426  * @tc.require:
427  */
428 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_DrawPointerStyle_02, TestSize.Level1)
429 {
430     CALL_TEST_DEBUG;
431     PointerDrawingManager pointerDrawingManager;
432     pointerDrawingManager.hasDisplay_ = true;
433     pointerDrawingManager.hasPointerDevice_ = true;
434 
435     PointerStyle pointerStyle;
436     pointerStyle.id = 1;
437     pointerStyle.color = 1;
438     pointerStyle.size = 2;
439 
440     int32_t ROTATE_POLICY;
441     ROTATE_POLICY = FOLDABLE_DEVICE;
442     pointerDrawingManager.lastPhysicalX_ = -1;
443     pointerDrawingManager.lastPhysicalY_ = -1;
444     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
445 }
446 
447 /**
448  * @tc.name: InputWindowsManagerTest_DrawPointerStyle_03
449  * @tc.desc: Test DrawPointerStyle
450  * @tc.type: FUNC
451  * @tc.require:
452  */
453 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_DrawPointerStyle_03, TestSize.Level1)
454 {
455     CALL_TEST_DEBUG;
456     PointerDrawingManager pointerDrawingManager;
457     pointerDrawingManager.hasDisplay_ = true;
458     pointerDrawingManager.hasPointerDevice_ = true;
459 
460     PointerStyle pointerStyle;
461     pointerStyle.id = 1;
462     pointerStyle.color = 1;
463     pointerStyle.size = 2;
464 
465     int32_t ROTATE_POLICY;
466     ROTATE_POLICY = FOLDABLE_DEVICE;
467     pointerDrawingManager.lastPhysicalX_ = 1;
468     pointerDrawingManager.lastPhysicalY_ = -1;
469     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
470 }
471 
472 /**
473  * @tc.name: InputWindowsManagerTest_DrawPointerStyle_04
474  * @tc.desc: Test DrawPointerStyle
475  * @tc.type: FUNC
476  * @tc.require:
477  */
478 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_DrawPointerStyle_04, TestSize.Level1)
479 {
480     CALL_TEST_DEBUG;
481     PointerDrawingManager pointerDrawingManager;
482     pointerDrawingManager.hasDisplay_ = true;
483     pointerDrawingManager.hasPointerDevice_ = true;
484 
485     PointerStyle pointerStyle;
486     pointerStyle.id = 1;
487     pointerStyle.color = 1;
488     pointerStyle.size = 2;
489 
490     int32_t ROTATE_POLICY;
491     ROTATE_POLICY = FOLDABLE_DEVICE;
492     pointerDrawingManager.lastPhysicalX_ = 2;
493     pointerDrawingManager.lastPhysicalY_ = 2;
494     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPointerStyle(pointerStyle));
495 }
496 
497 /**
498  * @tc.name: InputWindowsManagerTest_SetPointerStyle_01
499  * @tc.desc: Test SetPointerStyle
500  * @tc.type: FUNC
501  * @tc.require:
502  */
503 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerStyle_01, TestSize.Level1)
504 {
505     CALL_TEST_DEBUG;
506     PointerDrawingManager pointerDrawingManager;
507     bool isUiExtension = false;
508 
509     PointerStyle pointerStyle;
510     pointerStyle.id = 1;
511     pointerStyle.color = 0;
512     pointerStyle.size = 2;
513 
514     int32_t pid = 1;
515     int32_t windowId = -2;
516     bool ret = pointerDrawingManager.CheckPointerStyleParam(windowId, pointerStyle);
517     EXPECT_FALSE(ret);
518 
519     int32_t ret2 = pointerDrawingManager.SetPointerStyle(pid, windowId, pointerStyle, isUiExtension);
520     EXPECT_EQ(ret2, RET_ERR);
521 }
522 
523 /**
524  * @tc.name: InputWindowsManagerTest_SetPointerStyle_02
525  * @tc.desc: Test SetPointerStyle
526  * @tc.type: FUNC
527  * @tc.require:
528  */
529 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerStyle_02, TestSize.Level1)
530 {
531     CALL_TEST_DEBUG;
532     PointerDrawingManager pointerDrawingManager;
533     bool isUiExtension = true;
534 
535     PointerStyle pointerStyle;
536     pointerStyle.id = 1;
537     pointerStyle.color = 0;
538     pointerStyle.size = 2;
539 
540     int32_t pid = 1;
541     int32_t windowId = GLOBAL_WINDOW_ID;
542     bool ret = pointerDrawingManager.CheckPointerStyleParam(windowId, pointerStyle);
543     EXPECT_TRUE(ret);
544 
545     int32_t ret2 = pointerDrawingManager.SetPointerStyle(pid, windowId, pointerStyle, isUiExtension);
546     EXPECT_EQ(ret2, RET_OK);
547 }
548 
549 /**
550  * @tc.name: InputWindowsManagerTest_SetPointerStylePreference_01
551  * @tc.desc: Test SetPointerStylePreference
552  * @tc.type: FUNC
553  * @tc.require:
554  */
555 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerStylePreference_01, TestSize.Level1)
556 {
557     CALL_TEST_DEBUG;
558     PointerDrawingManager pointerDrawingManager;
559     PointerStyle pointerStyle;
560     pointerStyle.id = 1;
561     pointerStyle.color = 1;
562     pointerStyle.size = 2;
563 
564     std::string name = "pointerStyle";
565     int32_t ret = PREFERENCES_MGR->SetIntValue(name, MOUSE_FILE_NAME, pointerStyle.id);
566     EXPECT_EQ(ret, RET_OK);
567 
568     int32_t ret2 = pointerDrawingManager.SetPointerStylePreference(pointerStyle);
569     EXPECT_EQ(ret2, RET_OK);
570 }
571 
572 /**
573  * @tc.name: InputWindowsManagerTest_SetMouseHotSpot_01
574  * @tc.desc: Test SetMouseHotSpot
575  * @tc.type: FUNC
576  * @tc.require:
577  */
578 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetMouseHotSpot_01, TestSize.Level1)
579 {
580     CALL_TEST_DEBUG;
581     PointerDrawingManager pointerDrawingManager;
582     int32_t pid = -1;
583     int32_t windowId = 2;
584     int32_t hotSpotX = 3;
585     int32_t hotSpotY = 4;
586     int32_t ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
587     ASSERT_EQ(ret, RET_ERR);
588 }
589 
590 /**
591  * @tc.name: InputWindowsManagerTest_SetMouseHotSpot_02
592  * @tc.desc: Test SetMouseHotSpot
593  * @tc.type: FUNC
594  * @tc.require:
595  */
596 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetMouseHotSpot_02, TestSize.Level1)
597 {
598     CALL_TEST_DEBUG;
599     PointerDrawingManager pointerDrawingManager;
600     int32_t pid = 1;
601     int32_t windowId = -2;
602     int32_t hotSpotX = 3;
603     int32_t hotSpotY = 4;
604     int32_t ret = pointerDrawingManager.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY);
605     ASSERT_EQ(ret, RET_ERR);
606 }
607 
608 /**
609  * @tc.name: InputWindowsManagerTest_SetMouseIcon_01
610  * @tc.desc: Test SetMouseIcon
611  * @tc.type: FUNC
612  * @tc.require:
613  */
614 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetMouseIcon_01, TestSize.Level1)
615 {
616     CALL_TEST_DEBUG;
617     PointerDrawingManager pointerDrawingManager;
618     int32_t pid = -1;
619     int32_t windowId = -2;
620     void* pixelMap = nullptr;
621     int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, pixelMap);
622     ASSERT_EQ(ret, RET_ERR);
623 }
624 
625 /**
626  * @tc.name: InputWindowsManagerTest_SetMouseIcon_02
627  * @tc.desc: Test SetMouseIcon
628  * @tc.type: FUNC
629  * @tc.require:
630  */
631 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetMouseIcon_02, TestSize.Level1)
632 {
633     CALL_TEST_DEBUG;
634     PointerDrawingManager pointerDrawingManager;
635     int32_t pid = 1;
636     int32_t windowId = -2;
637     void* pixelMap = nullptr;
638     int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, pixelMap);
639     ASSERT_EQ(ret, RET_ERR);
640 }
641 
642 /**
643  * @tc.name: InputWindowsManagerTest_SetMouseIcon_03
644  * @tc.desc: Test SetMouseIcon
645  * @tc.type: FUNC
646  * @tc.require:
647  */
648 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetMouseIcon_03, TestSize.Level1)
649 {
650     CALL_TEST_DEBUG;
651     PointerDrawingManager pointerDrawingManager;
652     int32_t pid = 1;
653     int32_t windowId = 2;
654     PointerStyle style;
655     int32_t ret1 = pointerDrawingManager.SetPointerStyle(pid, windowId, style);
656     EXPECT_EQ(ret1, RET_ERR);
657 
658     void* pixelMap = nullptr;
659     int32_t ret = pointerDrawingManager.SetMouseIcon(pid, windowId, pixelMap);
660     ASSERT_EQ(ret, RET_ERR);
661 }
662 
663 /**
664  * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection270_01
665  * @tc.desc: Test AdjustMouseFocusByDirection270
666  * @tc.type: FUNC
667  * @tc.require:
668  */
669 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocusByDirection270_01, TestSize.Level1)
670 {
671     CALL_TEST_DEBUG;
672     PointerDrawingManager pointerDrawingManager;
673     ICON_TYPE iconType = ANGLE_SW;
674     int32_t physicalX = 150;
675     int32_t physicalY = 200;
676     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection270(iconType, physicalX, physicalY));
677 }
678 
679 /**
680  * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection270_02
681  * @tc.desc: Test AdjustMouseFocusByDirection270
682  * @tc.type: FUNC
683  * @tc.require:
684  */
685 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocusByDirection270_02, TestSize.Level1)
686 {
687     CALL_TEST_DEBUG;
688     PointerDrawingManager pointerDrawingManager;
689     ICON_TYPE iconType = ANGLE_CENTER;
690     int32_t physicalX = 100;
691     int32_t physicalY = 150;
692     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection270(iconType, physicalX, physicalY));
693 }
694 
695 /**
696  * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection270_03
697  * @tc.desc: Test AdjustMouseFocusByDirection270
698  * @tc.type: FUNC
699  * @tc.require:
700  */
701 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocusByDirection270_03, TestSize.Level1)
702 {
703     CALL_TEST_DEBUG;
704     PointerDrawingManager pointerDrawingManager;
705     ICON_TYPE iconType = ANGLE_NW_RIGHT;
706     int32_t physicalX = 50;
707     int32_t physicalY = 150;
708     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection270(iconType, physicalX, physicalY));
709 }
710 
711 /**
712  * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection270_04
713  * @tc.desc: Test AdjustMouseFocusByDirection270
714  * @tc.type: FUNC
715  * @tc.require:
716  */
717 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocusByDirection270_04, TestSize.Level1)
718 {
719     CALL_TEST_DEBUG;
720     PointerDrawingManager pointerDrawingManager;
721     ICON_TYPE iconType = ANGLE_NW;
722     int32_t physicalX = 100;
723     int32_t physicalY = 50;
724     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection270(iconType, physicalX, physicalY));
725 }
726 
727 /**
728  * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection180
729  * @tc.desc: Test AdjustMouseFocusByDirection180
730  * @tc.type: FUNC
731  * @tc.require:
732  */
733 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocusByDirection180, TestSize.Level1)
734 {
735     CALL_TEST_DEBUG;
736     PointerDrawingManager pointerDrawingManager;
737     int32_t physicalX = 100;
738     int32_t physicalY = 50;
739     ICON_TYPE iconType = ANGLE_SW;
740     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection180(iconType, physicalX, physicalY));
741 
742     iconType = ANGLE_CENTER;
743     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection180(iconType, physicalX, physicalY));
744 
745     iconType = ANGLE_NW_RIGHT;
746     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection180(iconType, physicalX, physicalY));
747 
748     iconType = ANGLE_NW;
749     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection180(iconType, physicalX, physicalY));
750 }
751 
752 /**
753  * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection90
754  * @tc.desc: Test AdjustMouseFocusByDirection90
755  * @tc.type: FUNC
756  * @tc.require:
757  */
758 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocusByDirection90, TestSize.Level1)
759 {
760     CALL_TEST_DEBUG;
761     PointerDrawingManager pointerDrawingManager;
762     int32_t physicalX = 100;
763     int32_t physicalY = 150;
764     ICON_TYPE iconType = ANGLE_SW;
765     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
766 
767     iconType = ANGLE_CENTER;
768     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
769 
770     iconType = ANGLE_NW_RIGHT;
771     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
772 
773     iconType = ANGLE_NW;
774     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection90(iconType, physicalX, physicalY));
775 }
776 
777 /**
778  * @tc.name: InputWindowsManagerTest_AdjustMouseFocusByDirection0
779  * @tc.desc: Test AdjustMouseFocusByDirection0
780  * @tc.type: FUNC
781  * @tc.require:
782  */
783 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_AdjustMouseFocusByDirection0, TestSize.Level1)
784 {
785     CALL_TEST_DEBUG;
786     PointerDrawingManager pointerDrawingManager;
787     int32_t physicalX = 150;
788     int32_t physicalY = 200;
789     ICON_TYPE iconType = ANGLE_SW;
790     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection0(iconType, physicalX, physicalY));
791 
792     iconType = ANGLE_CENTER;
793     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection0(iconType, physicalX, physicalY));
794 
795     iconType = ANGLE_NW_RIGHT;
796     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection0(iconType, physicalX, physicalY));
797 
798     iconType = ANGLE_NW;
799     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.AdjustMouseFocusByDirection0(iconType, physicalX, physicalY));
800 }
801 
802 /**
803  * @tc.name: InputWindowsManagerTest_DrawPixelmap_001
804  * @tc.desc: Test DrawPixelmap
805  * @tc.type: FUNC
806  * @tc.require:
807  */
808 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_DrawPixelmap_001, TestSize.Level1)
809 {
810     CALL_TEST_DEBUG;
811     PointerDrawingManager pointerDrawingManager;
812     pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
813     OHOS::Rosen::Drawing::Canvas canvas;
814     MOUSE_ICON mouseStyle = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
815     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPixelmap(canvas, mouseStyle));
816 }
817 
818 /**
819  * @tc.name: InputWindowsManagerTest_DrawPixelmap_002
820  * @tc.desc: Test DrawPixelmap
821  * @tc.type: FUNC
822  * @tc.require:
823  */
824 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_DrawPixelmap_002, TestSize.Level1)
825 {
826     CALL_TEST_DEBUG;
827     PointerDrawingManager pointerDrawingManager;
828     pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
829     OHOS::Rosen::Drawing::Canvas canvas;
830     MOUSE_ICON mouseStyle = MOUSE_ICON::RUNNING;
831     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPixelmap(canvas, mouseStyle));
832 }
833 
834 /**
835  * @tc.name: InputWindowsManagerTest_DrawPixelmap_003
836  * @tc.desc: Test DrawPixelmap
837  * @tc.type: FUNC
838  * @tc.require:
839  */
840 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_DrawPixelmap_003, TestSize.Level1)
841 {
842     CALL_TEST_DEBUG;
843     PointerDrawingManager pointerDrawingManager;
844     pointerDrawingManager.userIcon_ = std::make_unique<OHOS::Media::PixelMap>();
845     OHOS::Rosen::Drawing::Canvas canvas;
846     MOUSE_ICON mouseStyle = MOUSE_ICON::WEST_EAST;
847     ASSERT_NO_FATAL_FAILURE(pointerDrawingManager.DrawPixelmap(canvas, mouseStyle));
848 }
849 
850 /**
851  * @tc.name: InputWindowsManagerTest_SetCustomCursor_001
852  * @tc.desc: Test SetCustomCursor
853  * @tc.type: FUNC
854  * @tc.require:
855  */
856 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetCustomCursor_001, TestSize.Level1)
857 {
858     CALL_TEST_DEBUG;
859     PointerDrawingManager pointerDrawingManager;
860     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
861     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
862     ASSERT_NE(pixelMap, nullptr);
863     int32_t pid = -1;
864     int32_t windowId = 1;
865     int32_t focusX = 2;
866     int32_t focusY = 3;
867     int32_t ret = pointerDrawingManager.SetCustomCursor((void *)pixelMap.get(), pid, windowId, focusX, focusY);
868     ASSERT_EQ(ret, RET_ERR);
869 }
870 
871 /**
872  * @tc.name: InputWindowsManagerTest_SetCustomCursor_002
873  * @tc.desc: Test SetCustomCursor
874  * @tc.type: FUNC
875  * @tc.require:
876  */
877 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetCustomCursor_002, TestSize.Level1)
878 {
879     CALL_TEST_DEBUG;
880     PointerDrawingManager pointerDrawingManager;
881     const std::string iconPath = "/system/etc/multimodalinput/mouse_icon/North_South.svg";
882     std::unique_ptr<OHOS::Media::PixelMap> pixelMap = SetMouseIconTest(iconPath);
883     ASSERT_NE(pixelMap, nullptr);
884     int32_t pid = 1;
885     int32_t windowId = -1;
886     int32_t focusX = 2;
887     int32_t focusY = 3;
888     int32_t ret = pointerDrawingManager.SetCustomCursor((void *)pixelMap.get(), pid, windowId, focusX, focusY);
889     EXPECT_EQ(ret, RET_ERR);
890 }
891 
892 /**
893  * @tc.name: InputWindowsManagerTest_SetPointerColor_01
894  * @tc.desc: Test SetPointerColor
895  * @tc.type: FUNC
896  * @tc.require:
897  */
898 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerColor_01, TestSize.Level1)
899 {
900     CALL_TEST_DEBUG;
901     PointerDrawingManager pointerDrawingManager;
902     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
903     surfaceNodeConfig.SurfaceNodeName = "pointer window";
904     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
905     pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
906     EXPECT_TRUE(pointerDrawingManager.surfaceNode_ != nullptr);
907     int32_t color = 0;
908     float alphaRatio = (static_cast<uint32_t>(color) >> RGB_CHANNEL_BITS_LENGTH) / MAX_ALPHA_VALUE;
909     EXPECT_FALSE(alphaRatio > 1);
910     int32_t ret = pointerDrawingManager.SetPointerColor(color);
911     EXPECT_EQ(ret, RET_OK);
912 }
913 
914 /**
915  * @tc.name: InputWindowsManagerTest_SetPointerColor_02
916  * @tc.desc: Test SetPointerColor
917  * @tc.type: FUNC
918  * @tc.require:
919  */
920 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerColor_02, TestSize.Level1)
921 {
922     CALL_TEST_DEBUG;
923     PointerDrawingManager pointerDrawingManager;
924     std::string name = POINTER_COLOR;
925     int32_t color = 0;
926     int32_t ret = PREFERENCES_MGR->SetIntValue(name, MOUSE_FILE_NAME, color);
927     EXPECT_EQ(ret, RET_OK);
928     int32_t ret2 = pointerDrawingManager.SetPointerColor(color);
929     EXPECT_EQ(ret2, RET_ERR);
930 }
931 
932 /**
933  * @tc.name: InputWindowsManagerTest_SetPointerSize_01
934  * @tc.desc: Test SetPointerSize
935  * @tc.type: FUNC
936  * @tc.require:
937  */
938 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerSize_01, TestSize.Level1)
939 {
940     CALL_TEST_DEBUG;
941     PointerDrawingManager pointerDrawingManager;
942     int32_t size = 0;
943     EXPECT_EQ(pointerDrawingManager.SetPointerSize(size), RET_OK);
944     size = 9;
945     EXPECT_EQ(pointerDrawingManager.SetPointerSize(size), RET_OK);
946 
947     size = 3;
948     std::string name = POINTER_SIZE;
949     int32_t ret = PREFERENCES_MGR->SetIntValue(name, MOUSE_FILE_NAME, size);
950     EXPECT_EQ(ret, RET_OK);
951     EXPECT_EQ(pointerDrawingManager.SetPointerSize(size), RET_OK);
952 }
953 
954 /**
955  * @tc.name: InputWindowsManagerTest_SetPointerSize_02
956  * @tc.desc: Test SetPointerSize
957  * @tc.type: FUNC
958  * @tc.require:
959  */
960 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerSize_02, TestSize.Level1)
961 {
962     CALL_TEST_DEBUG;
963     PointerDrawingManager pointerDrawingManager;
964     int32_t size = 5;
965     std::string name = POINTER_SIZE;
966     int32_t ret = PREFERENCES_MGR->SetIntValue(name, MOUSE_FILE_NAME, size);
967     EXPECT_EQ(ret, RET_OK);
968     EXPECT_EQ(pointerDrawingManager.SetPointerSize(size), RET_OK);
969 }
970 
971 /**
972  * @tc.name: InputWindowsManagerTest_SetPointerSize_03
973  * @tc.desc: Test SetPointerSize
974  * @tc.type: FUNC
975  * @tc.require:
976  */
977 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_SetPointerSize_03, TestSize.Level1)
978 {
979     CALL_TEST_DEBUG;
980     PointerDrawingManager pointerDrawingManager;
981     int32_t size = 5;
982     std::string name = POINTER_SIZE;
983     int32_t ret = PREFERENCES_MGR->SetIntValue(name, MOUSE_FILE_NAME, size);
984     EXPECT_EQ(ret, RET_OK);
985 
986     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
987     surfaceNodeConfig.SurfaceNodeName = "pointer window";
988     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
989     pointerDrawingManager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
990     EXPECT_TRUE(pointerDrawingManager.surfaceNode_ != nullptr);
991     EXPECT_EQ(pointerDrawingManager.SetPointerSize(size), RET_OK);
992 }
993 
994 /**
995  * @tc.name: InputWindowsManagerTest_UpdatePointerDevice_01
996  * @tc.desc: Test UpdatePointerDevice
997  * @tc.type: FUNC
998  * @tc.require:
999  */
1000 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdatePointerDevice_01, TestSize.Level1)
1001 {
1002     CALL_TEST_DEBUG;
1003     PointerDrawingManager manager;
1004     bool hasPointerDevice = true;
1005     bool isPointerVisible = true;
1006     bool isHotPlug = false;
1007     ASSERT_NO_FATAL_FAILURE(manager.UpdatePointerDevice(hasPointerDevice, isPointerVisible, isHotPlug));
1008 }
1009 
1010 /**
1011  * @tc.name: InputWindowsManagerTest_UpdatePointerDevice_02
1012  * @tc.desc: Test UpdatePointerDevice
1013  * @tc.type: FUNC
1014  * @tc.require:
1015  */
1016 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdatePointerDevice_02, TestSize.Level1)
1017 {
1018     CALL_TEST_DEBUG;
1019     PointerDrawingManager manager;
1020     bool hasPointerDevice = true;
1021     bool isPointerVisible = true;
1022     bool isHotPlug = true;
1023     ASSERT_NO_FATAL_FAILURE(manager.UpdatePointerDevice(hasPointerDevice, isPointerVisible, isHotPlug));
1024 }
1025 
1026 /**
1027  * @tc.name: InputWindowsManagerTest_UpdatePointerDevice_03
1028  * @tc.desc: Test UpdatePointerDevice
1029  * @tc.type: FUNC
1030  * @tc.require:
1031  */
1032 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdatePointerDevice_03, TestSize.Level1)
1033 {
1034     CALL_TEST_DEBUG;
1035     PointerDrawingManager manager;
1036     bool hasPointerDevice = false;
1037     bool isPointerVisible = false;
1038     bool isHotPlug = true;
1039 
1040     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1041     surfaceNodeConfig.SurfaceNodeName = "pointer window";
1042     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1043     manager.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1044     EXPECT_TRUE(manager.surfaceNode_ != nullptr);
1045     ASSERT_NO_FATAL_FAILURE(manager.UpdatePointerDevice(hasPointerDevice, isPointerVisible, isHotPlug));
1046 }
1047 
1048 /**
1049  * @tc.name: InputWindowsManagerTest_UpdatePointerDevice_04
1050  * @tc.desc: Test UpdatePointerDevice
1051  * @tc.type: FUNC
1052  * @tc.require:
1053  */
1054 HWTEST_F(PointerDrawingManagerExTest, InputWindowsManagerTest_UpdatePointerDevice_04, TestSize.Level1)
1055 {
1056     CALL_TEST_DEBUG;
1057     PointerDrawingManager manager;
1058     bool hasPointerDevice = false;
1059     bool isPointerVisible = false;
1060     bool isHotPlug = true;
1061     ASSERT_NO_FATAL_FAILURE(manager.UpdatePointerDevice(hasPointerDevice, isPointerVisible, isHotPlug));
1062 }
1063 
1064 /**
1065  * @tc.name: PointerDrawingManagerExTest_OnDisplayInfo
1066  * @tc.desc: Test OnDisplayInfo
1067  * @tc.type: FUNC
1068  * @tc.require:
1069  */
1070 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_OnDisplayInfo, TestSize.Level1)
1071 {
1072     CALL_TEST_DEBUG;
1073     PointerDrawingManager pointerDrawMgr;
1074     DisplayInfo displayInfo;
1075     DisplayGroupInfo displayGroupInfo;
1076     displayInfo.id = 10;
1077     displayInfo.width = 600;
1078     displayInfo.height = 600;
1079     displayGroupInfo.displaysInfo.push_back(displayInfo);
1080     pointerDrawMgr.displayInfo_.id = 15;
1081     pointerDrawMgr.surfaceNode_ = nullptr;
1082     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.OnDisplayInfo(displayGroupInfo));
1083 
1084     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1085     surfaceNodeConfig.SurfaceNodeName = "pointer window";
1086     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1087     pointerDrawMgr.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1088     ASSERT_NE(pointerDrawMgr.surfaceNode_, nullptr);
1089     pointerDrawMgr.displayInfo_.id = 30;
1090     pointerDrawMgr.screenId_ = 100;
1091     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.OnDisplayInfo(displayGroupInfo));
1092 }
1093 
1094 /**
1095  * @tc.name: PointerDrawingManagerExTest_DrawManager
1096  * @tc.desc: Test DrawManager
1097  * @tc.type: FUNC
1098  * @tc.require:
1099  */
1100 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_DrawManager, TestSize.Level1)
1101 {
1102     CALL_TEST_DEBUG;
1103     PointerDrawingManager pointerDrawMgr;
1104     pointerDrawMgr.hasDisplay_ = false;
1105     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DrawManager());
1106     pointerDrawMgr.hasDisplay_ = true;
1107     pointerDrawMgr.hasPointerDevice_ = false;
1108     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DrawManager());
1109     pointerDrawMgr.hasPointerDevice_ = true;
1110     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1111     surfaceNodeConfig.SurfaceNodeName = "pointer window";
1112     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1113     pointerDrawMgr.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1114     ASSERT_NE(pointerDrawMgr.surfaceNode_, nullptr);
1115     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DrawManager());
1116     pointerDrawMgr.surfaceNode_ = nullptr;
1117     pointerDrawMgr.displayInfo_.id = 100;
1118     pointerDrawMgr.displayInfo_.width = 600;
1119     pointerDrawMgr.displayInfo_.height = 600;
1120     pointerDrawMgr.displayInfo_.direction = DIRECTION0;
1121     pointerDrawMgr.lastPhysicalX_ = -1;
1122     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DrawManager());
1123     pointerDrawMgr.surfaceNode_ = nullptr;
1124     pointerDrawMgr.lastPhysicalY_ = 100;
1125     pointerDrawMgr.lastPhysicalY_ = -1;
1126     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DrawManager());
1127     pointerDrawMgr.surfaceNode_ = nullptr;
1128     pointerDrawMgr.lastPhysicalY_ = 100;
1129     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DrawManager());
1130 }
1131 
1132 /**
1133  * @tc.name: PointerDrawingManagerExTest_DeletePointerVisible
1134  * @tc.desc: Test DeletePointerVisible
1135  * @tc.type: FUNC
1136  * @tc.require:
1137  */
1138 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_DeletePointerVisible, TestSize.Level1)
1139 {
1140     CALL_TEST_DEBUG;
1141     PointerDrawingManager pointerDrawMgr;
1142     int32_t pid = 100;
1143     PointerDrawingManager::PidInfo pidInfo;
1144     pidInfo.pid = 50;
1145     pointerDrawMgr.pidInfos_.push_back(pidInfo);
1146     pidInfo.pid = 100;
1147     pointerDrawMgr.pidInfos_.push_back(pidInfo);
1148     pidInfo.pid = 300;
1149     pidInfo.visible = true;
1150     pointerDrawMgr.hapPidInfos_.push_back(pidInfo);
1151     pointerDrawMgr.pid_ = 300;
1152     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DeletePointerVisible(pid));
1153 }
1154 
1155 /**
1156  * @tc.name: PointerDrawingManagerExTest_DeletePointerVisible_001
1157  * @tc.desc: Test DeletePointerVisible
1158  * @tc.type: FUNC
1159  * @tc.require:
1160  */
1161 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_DeletePointerVisible_001, TestSize.Level1)
1162 {
1163     CALL_TEST_DEBUG;
1164     PointerDrawingManager pointerDrawMgr;
1165     int32_t pid = 100;
1166     PointerDrawingManager::PidInfo pidInfo;
1167     pidInfo.pid = 100;
1168     pointerDrawMgr.pidInfos_.push_back(pidInfo);
1169     pidInfo.visible = false;
1170     pointerDrawMgr.hapPidInfos_.push_back(pidInfo);
1171     pointerDrawMgr.pid_ = 100;
1172     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DeletePointerVisible(pid));
1173 }
1174 
1175 /**
1176  * @tc.name: PointerDrawingManagerExTest_DeletePointerVisible_002
1177  * @tc.desc: Test DeletePointerVisible
1178  * @tc.type: FUNC
1179  * @tc.require:
1180  */
1181 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_DeletePointerVisible_002, TestSize.Level1)
1182 {
1183     CALL_TEST_DEBUG;
1184     PointerDrawingManager pointerDrawMgr;
1185     int32_t pid = 100;
1186     PointerDrawingManager::PidInfo pidInfo;
1187     pidInfo.pid = 500;
1188     pointerDrawMgr.pidInfos_.push_back(pidInfo);
1189     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.DeletePointerVisible(pid));
1190 }
1191 
1192 /**
1193  * @tc.name: PointerDrawingManagerExTest_OnSessionLost
1194  * @tc.desc: Test OnSessionLost
1195  * @tc.type: FUNC
1196  * @tc.require:
1197  */
1198 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_OnSessionLost, TestSize.Level1)
1199 {
1200     CALL_TEST_DEBUG;
1201     PointerDrawingManager pointerDrawMgr;
1202     int32_t pid = 100;
1203     PointerDrawingManager::PidInfo pidInfo;
1204     pidInfo.pid = 200;
1205     pointerDrawMgr.hapPidInfos_.push_back(pidInfo);
1206     pidInfo.pid = 100;
1207     pointerDrawMgr.hapPidInfos_.push_back(pidInfo);
1208     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.OnSessionLost(pid));
1209 }
1210 
1211 /**
1212  * @tc.name: PointerDrawingManagerExTest_GetIconStyle
1213  * @tc.desc: Test GetIconStyle
1214  * @tc.type: FUNC
1215  * @tc.require:
1216  */
1217 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_GetIconStyle, TestSize.Level1)
1218 {
1219     CALL_TEST_DEBUG;
1220     PointerDrawingManager pointerDrawMgr;
1221     MOUSE_ICON mouseStyle = CURSOR_MOVE;
1222     IconStyle iconStyle;
1223     pointerDrawMgr.mouseIcons_.insert(std::make_pair(mouseStyle, iconStyle));
1224     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.GetIconStyle(mouseStyle));
1225     mouseStyle = static_cast<MOUSE_ICON>(100);
1226     ASSERT_NO_FATAL_FAILURE(pointerDrawMgr.GetIconStyle(mouseStyle));
1227 }
1228 
1229 /**
1230  * @tc.name: PointerDrawingManagerExTest_SetPointerVisible
1231  * @tc.desc: Test SetPointerVisible
1232  * @tc.type: FUNC
1233  * @tc.require:
1234  */
1235 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_SetPointerVisible, TestSize.Level1)
1236 {
1237     CALL_TEST_DEBUG;
1238     PointerDrawingManager pointerDrawMgr;
1239     int32_t pid = 1;
1240     bool visible = true;
1241     int32_t priority = 0;
1242     bool isHap = true;
1243     int32_t count = 101;
1244     PointerDrawingManager::PidInfo pidInfo;
1245     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1246     surfaceNodeConfig.SurfaceNodeName = "pointer window";
1247     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1248     pointerDrawMgr.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1249     ASSERT_NE(pointerDrawMgr.surfaceNode_, nullptr);
1250     for (int32_t i = 0; i < count; ++i) {
1251         pidInfo.pid = i;
1252         pointerDrawMgr.hapPidInfos_.push_back(pidInfo);
1253     }
1254     ASSERT_EQ(pointerDrawMgr.SetPointerVisible(pid, visible, priority, isHap), RET_OK);
1255     pid = 5;
1256     pointerDrawMgr.hapPidInfos_.pop_front();
1257     ASSERT_EQ(pointerDrawMgr.SetPointerVisible(pid, visible, priority, isHap), RET_OK);
1258 }
1259 
1260 /**
1261  * @tc.name: PointerDrawingManagerExTest_SetPointerVisible_001
1262  * @tc.desc: Test SetPointerVisible
1263  * @tc.type: FUNC
1264  * @tc.require:
1265  */
1266 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_SetPointerVisible_001, TestSize.Level1)
1267 {
1268     CALL_TEST_DEBUG;
1269     PointerDrawingManager pointerDrawMgr;
1270     int32_t pid = 0;
1271     bool visible = true;
1272     int32_t priority = 50;
1273     bool isHap = false;
1274     int32_t count = 105;
1275     PointerDrawingManager::PidInfo pidInfo;
1276     Rosen::RSSurfaceNodeConfig surfaceNodeConfig;
1277     surfaceNodeConfig.SurfaceNodeName = "pointer window";
1278     Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE;
1279     pointerDrawMgr.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType);
1280     ASSERT_NE(pointerDrawMgr.surfaceNode_, nullptr);
1281     for (int32_t i = 0; i < count; ++i) {
1282         pidInfo.pid = i;
1283         pointerDrawMgr.pidInfos_.push_back(pidInfo);
1284     }
1285     ASSERT_EQ(pointerDrawMgr.SetPointerVisible(pid, visible, priority, isHap), RET_OK);
1286 }
1287 
1288 /**
1289  * @tc.name: PointerDrawingManagerExTest_SetCustomCursor
1290  * @tc.desc: Test SetCustomCursor
1291  * @tc.type: FUNC
1292  * @tc.require:
1293  */
1294 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_SetCustomCursor, TestSize.Level1)
1295 {
1296     CALL_TEST_DEBUG;
1297     EXPECT_CALL(*WIN_MGR_MOCK, CheckWindowIdPermissionByPid).WillRepeatedly(testing::Return(RET_ERR));
1298     PointerDrawingManager pointerDrawMgr;
1299     std::shared_ptr<Media::PixelMap> pixelMapPtr = CreatePixelMap(MIDDLE_PIXEL_MAP_WIDTH, MIDDLE_PIXEL_MAP_HEIGHT);
1300     int32_t pid = 50;
1301     int32_t windowId = 100;
1302     int32_t focusX = 300;
1303     int32_t focusY = 300;
1304     EXPECT_EQ(pointerDrawMgr.SetCustomCursor((void *)pixelMapPtr.get(), pid, windowId, focusX, focusY), RET_ERR);
1305 }
1306 
1307 /**
1308  * @tc.name: PointerDrawingManagerExTest_SetMouseIcon
1309  * @tc.desc: Test SetCustomCursor
1310  * @tc.type: FUNC
1311  * @tc.require:
1312  */
1313 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_SetMouseIcon, TestSize.Level1)
1314 {
1315     CALL_TEST_DEBUG;
1316     PointerDrawingManager pointerDrawMgr;
1317     std::shared_ptr<Media::PixelMap> pixelMapPtr = CreatePixelMap(MIDDLE_PIXEL_MAP_WIDTH, MIDDLE_PIXEL_MAP_HEIGHT);
1318     int32_t pid = 50;
1319     int32_t windowId = -1;
1320     EXPECT_EQ(pointerDrawMgr.SetMouseIcon(pid, windowId, (void *)pixelMapPtr.get()), RET_ERR);
1321 }
1322 
1323 /**
1324  * @tc.name: PointerDrawingManagerExTest_SetMouseHotSpot
1325  * @tc.desc: Test SetCustomCursor
1326  * @tc.type: FUNC
1327  * @tc.require:
1328  */
1329 HWTEST_F(PointerDrawingManagerExTest, PointerDrawingManagerExTest_SetMouseHotSpot, TestSize.Level1)
1330 {
1331     CALL_TEST_DEBUG;
1332     PointerDrawingManager pointerDrawMgr;
1333     int32_t pid = 10;
1334     int32_t windowId = 100;
1335     int32_t hotSpotX = -1;
1336     int32_t hotSpotY = 100;
1337     EXPECT_EQ(pointerDrawMgr.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY), RET_ERR);
1338 }
1339 } // namespace MMI
1340 } // namespace OHOS