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