1 /* 2 * Copyright (c) 2025 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 <gtest/gtest.h> 17 18 #include "cursor_drawing_adapter.h" 19 #include "cursor_drawing_component.h" 20 21 using namespace testing::ext; 22 namespace OHOS { 23 namespace MMI { 24 25 class CursorDrawingComponentTest : public testing::Test { 26 public: SetUpTestCase(void)27 static void SetUpTestCase(void) {}; TearDownTestCase(void)28 static void TearDownTestCase(void) {}; SetUp(void)29 void SetUp(void) {}; TearDown(void)30 void TearDown(void) {}; 31 private: 32 static CursorDrawingComponent* instance_; 33 }; 34 35 CursorDrawingComponent* CursorDrawingComponentTest::instance_ = nullptr; 36 37 class CursorDrawingAdapterTest : public testing::Test { 38 public: SetUpTestCase(void)39 static void SetUpTestCase(void) {}; TearDownTestCase(void)40 static void TearDownTestCase(void) {}; SetUp(void)41 void SetUp(void) {}; TearDown(void)42 void TearDown(void) {}; 43 }; 44 45 /** 46 * @tc.name: CursorDrawingAdapterTest_GetPointerInstance_001 47 * @tc.desc: GetPointerInstance will return not nullptr when called 48 * @tc.type: FUNC 49 * @tc.require: 50 */ 51 HWTEST_F(CursorDrawingAdapterTest, CursorDrawingAdapterTest_GetPointerInstance_001, TestSize.Level1) 52 { 53 auto ret = GetPointerInstance(); 54 EXPECT_NE(ret, nullptr); 55 } 56 57 /** 58 * @tc.name: CursorDrawingComponentTest_load_001 59 * @tc.desc: Load and UnLoad will success when called twice 60 * @tc.type: FUNC 61 * @tc.require: 62 */ 63 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_load_001, TestSize.Level1) 64 { 65 CursorDrawingComponent cursorDrawingComponent; 66 EXPECT_EQ(cursorDrawingComponent.isLoaded_, false); 67 EXPECT_EQ(cursorDrawingComponent.soHandle_, nullptr); 68 69 cursorDrawingComponent.Load(); 70 EXPECT_EQ(cursorDrawingComponent.isLoaded_, true); 71 EXPECT_NE(cursorDrawingComponent.soHandle_, nullptr); 72 73 cursorDrawingComponent.UnLoad(); 74 EXPECT_EQ(cursorDrawingComponent.isLoaded_, false); 75 EXPECT_EQ(cursorDrawingComponent.soHandle_, nullptr); 76 77 cursorDrawingComponent.~CursorDrawingComponent(); 78 EXPECT_EQ(cursorDrawingComponent.isLoaded_, false); 79 EXPECT_EQ(cursorDrawingComponent.soHandle_, nullptr); 80 } 81 82 /** 83 * @tc.name: CursorDrawingComponentTest_GetInstance_001 84 * @tc.desc: GetInstance will return not nullptr when called 85 * @tc.type: FUNC 86 * @tc.require: 87 */ 88 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_GetInstance_001, TestSize.Level1) 89 { 90 instance_ = &CursorDrawingComponent::GetInstance(); 91 ASSERT_NE(instance_, nullptr); 92 ASSERT_EQ(instance_->isLoaded_, true); 93 ASSERT_NE(instance_->soHandle_, nullptr); 94 ASSERT_NE(instance_->pointerInstance_, nullptr); 95 EXPECT_EQ(instance_->Init(), true); 96 } 97 98 /** 99 * @tc.name: CursorDrawingComponentTest_DrawPointer_001 100 * @tc.desc: Test DrawPointer 101 * @tc.type: FUNC 102 * @tc.require: 103 */ 104 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_DrawPointer_001, TestSize.Level1) 105 { 106 int32_t displayId = 1; 107 int32_t physicalX = 1; 108 int32_t physicalY = 1; 109 PointerStyle pointerStyle; 110 Direction direction = DIRECTION0; 111 112 EXPECT_NO_FATAL_FAILURE(instance_->DrawPointer(displayId, physicalX, physicalY, pointerStyle, direction)); 113 } 114 115 /** 116 * @tc.name: CursorDrawingComponentTest_UpdateDisplayInfo_001 117 * @tc.desc: Test DrawPointer 118 * @tc.type: FUNC 119 * @tc.require: 120 */ 121 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_UpdateDisplayInfo_001, TestSize.Level1) 122 { 123 OLD::DisplayInfo displayInfo; 124 displayInfo.id = 0; 125 displayInfo.x =1; 126 displayInfo.y = 1; 127 displayInfo.width = 2; 128 displayInfo.height = 2; 129 displayInfo.dpi = 240; 130 displayInfo.name = "pp"; 131 displayInfo.direction = DIRECTION0; 132 displayInfo.displayMode = DisplayMode::FULL; 133 EXPECT_NO_FATAL_FAILURE(instance_->UpdateDisplayInfo(displayInfo)); 134 } 135 136 /** 137 * @tc.name: CursorDrawingComponentTest_OnWindowInfo_001 138 * @tc.desc: Test DrawPointer 139 * @tc.type: FUNC 140 * @tc.require: 141 */ 142 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_OnWindowInfo_001, TestSize.Level1) 143 { 144 WinInfo windowInfo; 145 windowInfo.windowId = 1; 146 windowInfo.windowPid = 1; 147 EXPECT_NO_FATAL_FAILURE(instance_->OnWindowInfo(windowInfo)); 148 } 149 150 /** 151 * @tc.name: CursorDrawingComponentTest_OnDisplayInfo_001 152 * @tc.desc: Test DrawPointer 153 * @tc.type: FUNC 154 * @tc.require: 155 */ 156 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_OnDisplayInfo_001, TestSize.Level1) 157 { 158 OLD::DisplayGroupInfo displayGroupInfo; 159 displayGroupInfo.focusWindowId = 0; 160 161 OLD::DisplayInfo displayInfo; 162 displayInfo.id = 0; 163 displayInfo.x =1; 164 displayInfo.y = 1; 165 displayInfo.width = 2; 166 displayInfo.height = 2; 167 displayInfo.dpi = 240; 168 displayInfo.name = "pp"; 169 displayInfo.uniq = "pp"; 170 displayInfo.direction = DIRECTION0; 171 displayInfo.displayMode = DisplayMode::FULL; 172 displayGroupInfo.displaysInfo.push_back(displayInfo); 173 174 WindowInfo info; 175 info.id = 1; 176 info.pid = 1; 177 info.uid = 1; 178 info.area = {1, 1, 1, 1}; 179 info.defaultHotAreas = { info.area }; 180 info.pointerHotAreas = { info.area }; 181 info.pointerChangeAreas = {16, 5, 16, 5, 16, 5, 16, 5}; 182 info.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; 183 info.agentWindowId = 1; 184 info.flags = 0; 185 info.displayId = 0; 186 info.zOrder = static_cast<float>(1); 187 displayGroupInfo.windowsInfo.push_back(info); 188 189 EXPECT_NO_FATAL_FAILURE(instance_->OnDisplayInfo(displayGroupInfo)); 190 191 auto ret = (instance_->GetCurrentDisplayInfo()); 192 EXPECT_EQ(ret.id, displayInfo.id); 193 } 194 195 /** 196 * @tc.name: CursorDrawingComponentTest_SetPointerVisible_001 197 * @tc.desc: Test DrawPointer 198 * @tc.type: FUNC 199 * @tc.require: 200 */ 201 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetPointerVisible_001, TestSize.Level1) 202 { 203 int32_t pid = 1; 204 bool visible = true; 205 int32_t priority = 0; 206 instance_->SetPointerVisible(pid, visible, priority, false); 207 bool ret = instance_->GetPointerVisible(pid); 208 EXPECT_EQ(ret, visible); 209 ret = instance_->IsPointerVisible(); 210 EXPECT_EQ(ret, visible); 211 EXPECT_NO_FATAL_FAILURE(instance_->DeletePointerVisible(pid)); 212 } 213 214 /** 215 * @tc.name: CursorDrawingComponentTest_SetPointerColor_001 216 * @tc.desc: Test DrawPointer 217 * @tc.type: FUNC 218 * @tc.require: 219 */ 220 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetPointerColor_001, TestSize.Level1) 221 { 222 int32_t color = 0; 223 EXPECT_NO_FATAL_FAILURE(instance_->SetPointerColor(color)); 224 225 auto ret = instance_->GetPointerColor(); 226 EXPECT_EQ(ret, color); 227 } 228 229 /** 230 * @tc.name: CursorDrawingComponentTest_SetPointerStyle_001 231 * @tc.desc: Test DrawPointer 232 * @tc.type: FUNC 233 * @tc.require: 234 */ 235 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetPointerStyle_001, TestSize.Level1) 236 { 237 int32_t pid = 1; 238 int32_t windowId = 1; 239 PointerStyle pointerStyle; 240 pointerStyle.id = 1; 241 bool isUiExtension = false; 242 int32_t ret = instance_->SetPointerStyle(pid, windowId, pointerStyle, isUiExtension); 243 EXPECT_EQ(ret, RET_ERR); 244 245 EXPECT_NO_FATAL_FAILURE(instance_->DrawPointerStyle(pointerStyle)); 246 247 ret = instance_->GetPointerStyle(pid, windowId, pointerStyle, isUiExtension); 248 EXPECT_EQ(ret, RET_OK); 249 250 auto style = instance_->GetLastMouseStyle(); 251 EXPECT_EQ(style.id, 0); 252 253 ret = instance_->SwitchPointerStyle(); 254 EXPECT_EQ(ret, RET_OK); 255 256 ret = instance_->ClearWindowPointerStyle(pid, windowId); 257 EXPECT_EQ(ret, RET_OK); 258 } 259 260 /** 261 * @tc.name: CursorDrawingComponentTest_SetPointerLocation_001 262 * @tc.desc: Test DrawPointer 263 * @tc.type: FUNC 264 * @tc.require: 265 */ 266 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetPointerLocation_001, TestSize.Level1) 267 { 268 int32_t x = 100; 269 int32_t y = 100; 270 int32_t displayId = 0; 271 EXPECT_NO_FATAL_FAILURE(instance_->SetPointerLocation(x, y, displayId)); 272 } 273 274 /** 275 * @tc.name: CursorDrawingComponentTest_SetMouseDisplayState_001 276 * @tc.desc: Test DrawPointer 277 * @tc.type: FUNC 278 * @tc.require: 279 */ 280 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetMouseDisplayState_001, TestSize.Level1) 281 { 282 bool state = true; 283 EXPECT_NO_FATAL_FAILURE(instance_->SetMouseDisplayState(state)); 284 bool ret = instance_->GetMouseDisplayState(); 285 EXPECT_EQ(ret, state); 286 } 287 288 /** 289 * @tc.name: CursorDrawingComponentTest_SetMouseHotSpot_001 290 * @tc.desc: Test DrawPointer 291 * @tc.type: FUNC 292 * @tc.require: 293 */ 294 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetMouseHotSpot_001, TestSize.Level1) 295 { 296 int32_t pid = 1; 297 int32_t windowId = 1; 298 int32_t hotSpotX = 1; 299 int32_t hotSpotY = 1; 300 int32_t ret = instance_->SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY); 301 EXPECT_EQ(ret, RET_ERR); 302 } 303 304 /** 305 * @tc.name: CursorDrawingComponentTest_SetMouseIcon_001 306 * @tc.desc: Test DrawPointer 307 * @tc.type: FUNC 308 * @tc.require: 309 */ 310 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetMouseIcon_001, TestSize.Level1) 311 { 312 int32_t pid = 1; 313 int32_t windowId = 1; 314 CursorPixelMap curPixelMap; 315 int32_t ret = instance_->SetMouseIcon(pid, windowId, curPixelMap); 316 EXPECT_EQ(ret, RET_ERR); 317 318 EXPECT_NO_FATAL_FAILURE(instance_->GetMouseIconPath()); 319 } 320 321 /** 322 * @tc.name: CursorDrawingComponentTest_SetCustomCursor_001 323 * @tc.desc: Test DrawPointer 324 * @tc.type: FUNC 325 * @tc.require: 326 */ 327 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetCustomCursor_001, TestSize.Level1) 328 { 329 CursorPixelMap curPixelMap; 330 int32_t pid = 1; 331 int32_t windowId = 1; 332 int32_t focusX = 1; 333 int32_t focusY = 1; 334 int32_t ret = instance_->SetCustomCursor(curPixelMap, pid, windowId, focusX, focusY); 335 EXPECT_EQ(ret, RET_ERR); 336 } 337 338 /** 339 * @tc.name: CursorDrawingComponentTest_SetCustomCursor_002 340 * @tc.desc: Test DrawPointer 341 * @tc.type: FUNC 342 * @tc.require: 343 */ 344 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetCustomCursor_002, TestSize.Level1) 345 { 346 int32_t pid = 1; 347 int32_t windowId = 1; 348 CustomCursor cursor; 349 CursorOptions options; 350 int32_t ret = instance_->SetCustomCursor(pid, windowId, cursor, options); 351 EXPECT_EQ(ret, RET_ERR); 352 } 353 354 /** 355 * @tc.name: CursorDrawingComponentTest_PointerSize_001 356 * @tc.desc: Test SetPointerSize and GetPointerSize 357 * @tc.type: FUNC 358 * @tc.require: 359 */ 360 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetPointerSize_001, TestSize.Level1) 361 { 362 int32_t size = 1; 363 int32_t ret = instance_->SetPointerSize(size); 364 EXPECT_EQ(ret, RET_OK); 365 ret = instance_->GetPointerSize(); 366 EXPECT_EQ(ret, size); 367 } 368 369 /** 370 * @tc.name: CursorDrawingComponentTest_GetPointerImageSize_001 371 * @tc.desc: Test DrawPointer 372 * @tc.type: FUNC 373 * @tc.require: 374 */ 375 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_GetPointerImageSize_001, TestSize.Level1) 376 { 377 int32_t width = 1; 378 int32_t height = 1; 379 EXPECT_NO_FATAL_FAILURE(instance_->GetPointerImageSize(width, height)); 380 } 381 382 /** 383 * @tc.name: CursorDrawingComponentTest_GetCursorSurfaceId_001 384 * @tc.desc: Test DrawPointer 385 * @tc.type: FUNC 386 * @tc.require: 387 */ 388 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_GetCursorSurfaceId_001, TestSize.Level1) 389 { 390 uint64_t surfaceId = 1; 391 int32_t ret = instance_->GetCursorSurfaceId(surfaceId); 392 EXPECT_EQ(ret, RET_OK); 393 } 394 395 /** 396 * @tc.name: CursorDrawingComponentTest_DrawMovePointer_001 397 * @tc.desc: Test DrawPointer 398 * @tc.type: FUNC 399 * @tc.require: 400 */ 401 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_DrawMovePointer_001, TestSize.Level1) 402 { 403 int32_t displayId = 1; 404 int32_t physicalX = 1; 405 int32_t physicalY = 1; 406 EXPECT_NO_FATAL_FAILURE(instance_->DrawMovePointer(displayId, physicalX, physicalY)); 407 } 408 409 /** 410 * @tc.name: CursorDrawingComponentTest_Dump_001 411 * @tc.desc: Test DrawPointer 412 * @tc.type: FUNC 413 * @tc.require: 414 */ 415 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_Dump_001, TestSize.Level1) 416 { 417 int32_t fd = 1; 418 const std::vector<std::string> args; 419 EXPECT_NO_FATAL_FAILURE(instance_->Dump(fd, args)); 420 } 421 422 /** 423 * @tc.name: CursorDrawingComponentTest_InitPointerCallback_001 424 * @tc.desc: Test DrawPointer 425 * @tc.type: FUNC 426 * @tc.require: 427 */ 428 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_InitPointerCallback_001, TestSize.Level1) 429 { 430 EXPECT_NO_FATAL_FAILURE(instance_->InitPointerCallback()); 431 } 432 433 /** 434 * @tc.name: CursorDrawingComponentTest_InitScreenInfo_001 435 * @tc.desc: Test DrawPointer 436 * @tc.type: FUNC 437 * @tc.require: 438 */ 439 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_InitScreenInfo_001, TestSize.Level1) 440 { 441 EXPECT_NO_FATAL_FAILURE(instance_->InitScreenInfo()); 442 } 443 444 /** 445 * @tc.name: CursorDrawingComponentTest_EnableHardwareCursorStats_001 446 * @tc.desc: Test DrawPointer 447 * @tc.type: FUNC 448 * @tc.require: 449 */ 450 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_EnableHardwareCursorStats_001, TestSize.Level1) 451 { 452 int32_t pid = 1; 453 bool enable = true; 454 int32_t ret = instance_->EnableHardwareCursorStats(pid, enable); 455 EXPECT_EQ(ret, RET_OK); 456 } 457 458 /** 459 * @tc.name: CursorDrawingComponentTest_GetHardwareCursorStats_001 460 * @tc.desc: Test GetHardwareCursorStats 461 * @tc.type: FUNC 462 * @tc.require: 463 */ 464 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_GetHardwareCursorStats_001, TestSize.Level1) 465 { 466 int32_t pid = 1; 467 uint32_t frameCount = 1; 468 uint32_t vsyncCount = 1; 469 int32_t ret = instance_->GetHardwareCursorStats(pid, frameCount, vsyncCount); 470 EXPECT_EQ(ret, RET_OK); 471 } 472 473 /** 474 * @tc.name: CursorDrawingComponentTest_ForceClearPointerVisiableStatus_001 475 * @tc.desc: Test ForceClearPointerVisiableStatus 476 * @tc.type: FUNC 477 * @tc.require: 478 */ 479 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_ForceClearPointerVisiableStatus_001, TestSize.Level1) 480 { 481 EXPECT_NO_FATAL_FAILURE(instance_->ForceClearPointerVisiableStatus()); 482 } 483 484 /** 485 * @tc.name: CursorDrawingComponentTest_InitPointerObserver_001 486 * @tc.desc: Test InitPointerObserver 487 * @tc.type: FUNC 488 * @tc.require: 489 */ 490 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_InitPointerObserver_001, TestSize.Level1) 491 { 492 EXPECT_NO_FATAL_FAILURE(instance_->InitPointerObserver()); 493 } 494 495 /** 496 * @tc.name: CursorDrawingComponentTest_OnSessionLost_001 497 * @tc.desc: Test OnSessionLost 498 * @tc.type: FUNC 499 * @tc.require: 500 */ 501 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_OnSessionLost_001, TestSize.Level1) 502 { 503 int32_t pid = 1; 504 EXPECT_NO_FATAL_FAILURE(instance_->OnSessionLost(pid)); 505 } 506 507 /** 508 * @tc.name: CursorDrawingComponentTest_SkipPointerLayer_001 509 * @tc.desc: Test SkipPointerLayer 510 * @tc.type: FUNC 511 * @tc.require: 512 */ 513 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SkipPointerLayer_001, TestSize.Level1) 514 { 515 bool isSkip = true; 516 int32_t ret = instance_->SkipPointerLayer(isSkip); 517 EXPECT_EQ(ret, RET_OK); 518 } 519 520 /** 521 * @tc.name: CursorDrawingComponentTest_SetDelegateProxy_001 522 * @tc.desc: Test SetDelegateProxy 523 * @tc.type: FUNC 524 * @tc.require: 525 */ 526 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SetDelegateProxy_001, TestSize.Level1) 527 { 528 std::shared_ptr<DelegateInterface> proxy; 529 EXPECT_NO_FATAL_FAILURE(instance_->SetDelegateProxy(proxy)); 530 531 auto ret = instance_->GetDelegateProxy(); 532 EXPECT_EQ(ret, nullptr); 533 } 534 535 /** 536 * @tc.name: CursorDrawingComponentTest_DestroyPointerWindow_001 537 * @tc.desc: Test DestroyPointerWindow 538 * @tc.type: FUNC 539 * @tc.require: 540 */ 541 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_DestroyPointerWindow_001, TestSize.Level1) 542 { 543 EXPECT_NO_FATAL_FAILURE(instance_->DestroyPointerWindow()); 544 } 545 546 /** 547 * @tc.name: CursorDrawingComponentTest_DrawScreenCenterPointer_001 548 * @tc.desc: Test DrawScreenCenterPointer 549 * @tc.type: FUNC 550 * @tc.require: 551 */ 552 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_DrawScreenCenterPointer_001, TestSize.Level1) 553 { 554 PointerStyle pointerStyle; 555 EXPECT_NO_FATAL_FAILURE(instance_->DrawScreenCenterPointer(pointerStyle)); 556 } 557 558 /** 559 * @tc.name: CursorDrawingComponentTest_SubscribeScreenModeChange_001 560 * @tc.desc: Test SubscribeScreenModeChange 561 * @tc.type: FUNC 562 * @tc.require: 563 */ 564 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_SubscribeScreenModeChange_001, TestSize.Level1) 565 { 566 EXPECT_NO_FATAL_FAILURE(instance_->SubscribeScreenModeChange()); 567 } 568 569 /** 570 * @tc.name: CursorDrawingComponentTest_RegisterDisplayStatusReceiver_001 571 * @tc.desc: Test RegisterDisplayStatusReceiver 572 * @tc.type: FUNC 573 * @tc.require: 574 */ 575 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_RegisterDisplayStatusReceiver_001, TestSize.Level1) 576 { 577 EXPECT_NO_FATAL_FAILURE(instance_->RegisterDisplayStatusReceiver()); 578 } 579 580 /** 581 * @tc.name: CursorDrawingComponentTest_UpdateMouseLayer_001 582 * @tc.desc: Test UpdateMouseLayer 583 * @tc.type: FUNC 584 * @tc.require: 585 */ 586 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_UpdateMouseLayer_001, TestSize.Level1) 587 { 588 PointerStyle pointerStyle; 589 int32_t displayId = 1; 590 int32_t physicalX = 1; 591 int32_t physicalY = 1; 592 int32_t ret = instance_->UpdateMouseLayer(pointerStyle, displayId, physicalX, physicalY); 593 EXPECT_EQ(ret, RET_OK); 594 } 595 596 /** 597 * @tc.name: CursorDrawingComponentTest_DrawNewDpiPointer_001 598 * @tc.desc: Test DrawNewDpiPointer 599 * @tc.type: FUNC 600 * @tc.require: 601 */ 602 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_DrawNewDpiPointer_001, TestSize.Level1) 603 { 604 int32_t ret = instance_->DrawNewDpiPointer(); 605 EXPECT_EQ(ret, RET_OK); 606 } 607 608 /** 609 * @tc.name: CursorDrawingComponentTest_GetHardCursorEnabled_001 610 * @tc.desc: Test GetHardCursorEnabled 611 * @tc.type: FUNC 612 * @tc.require: 613 */ 614 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_GetHardCursorEnabled_001, TestSize.Level1) 615 { 616 bool ret = instance_->GetHardCursorEnabled(); 617 EXPECT_EQ(ret, false); 618 } 619 620 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR 621 /** 622 * @tc.name: CursorDrawingComponentTest_GetPointerSnapshot_001 623 * @tc.desc: Test GetPointerSnapshot 624 * @tc.type: FUNC 625 * @tc.require: 626 */ 627 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_GetPointerSnapshot_001, TestSize.Level1) 628 { 629 void *pixelMapPtr = nullptr; 630 EXPECT_NO_FATAL_FAILURE(instance_->GetPointerSnapshot(pixelMapPtr)); 631 } 632 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR 633 634 /** 635 * @tc.name: CursorDrawingComponentTest_Load_002 636 * @tc.desc: Test Load 637 * @tc.type: FUNC 638 * @tc.require: 639 */ 640 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_Load_002, TestSize.Level1) 641 { 642 instance_ = &CursorDrawingComponent::GetInstance(); 643 ASSERT_NE(instance_, nullptr); 644 instance_->isLoaded_ = true; 645 instance_->soHandle_ = nullptr; 646 EXPECT_NO_FATAL_FAILURE(instance_->Load()); 647 } 648 649 /** 650 * @tc.name: CursorDrawingComponentTest_UnLoad_002 651 * @tc.desc: Test UnLoad 652 * @tc.type: FUNC 653 * @tc.require: 654 */ 655 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_UnLoad_002, TestSize.Level1) 656 { 657 instance_ = &CursorDrawingComponent::GetInstance(); 658 ASSERT_NE(instance_, nullptr); 659 instance_->isLoaded_ = true; 660 ASSERT_NE(instance_->soHandle_, nullptr); 661 EXPECT_NO_FATAL_FAILURE(instance_->UnLoad()); 662 } 663 664 /** 665 * @tc.name: CursorDrawingComponentTest_GetMouseIconPath 666 * @tc.desc: Test GetMouseIconPath 667 * @tc.type: FUNC 668 * @tc.require: 669 */ 670 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_GetMouseIconPath, TestSize.Level1) 671 { 672 int32_t pid = 1; 673 int32_t windowId = 1; 674 CursorPixelMap curPixelMap; 675 int32_t ret = instance_->SetMouseIcon(pid, windowId, curPixelMap); 676 instance_->isLoaded_ = false; 677 EXPECT_EQ(ret, RET_ERR); 678 EXPECT_NO_FATAL_FAILURE(instance_->GetMouseIconPath()); 679 680 instance_->isLoaded_ = true; 681 EXPECT_NO_FATAL_FAILURE(instance_->GetMouseIconPath()); 682 } 683 684 /** 685 * @tc.name: CursorDrawingComponentTest_RegisterDisplayStatusReceiver 686 * @tc.desc: Test RegisterDisplayStatusReceiver 687 * @tc.type: FUNC 688 * @tc.require: 689 */ 690 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_RegisterDisplayStatusReceiver, TestSize.Level1) 691 { 692 instance_->isLoaded_ = false; 693 EXPECT_NO_FATAL_FAILURE(instance_->RegisterDisplayStatusReceiver()); 694 695 instance_->isLoaded_ = true; 696 EXPECT_NO_FATAL_FAILURE(instance_->RegisterDisplayStatusReceiver()); 697 } 698 699 #ifndef OHOS_BUILD_ENABLE_WATCH 700 /** 701 * @tc.name: CursorDrawingComponentTest_NotifyPointerEventToRS 702 * @tc.desc: Test NotifyPointerEventToRS 703 * @tc.type: FUNC 704 * @tc.require: 705 */ 706 HWTEST_F(CursorDrawingComponentTest, CursorDrawingComponentTest_NotifyPointerEventToRS, TestSize.Level1) 707 { 708 instance_->isLoaded_ = false; 709 int32_t pointAction = 1; 710 int32_t pointCnt = 0; 711 EXPECT_NO_FATAL_FAILURE(instance_->NotifyPointerEventToRS(pointAction, pointCnt)); 712 713 instance_->isLoaded_ = true; 714 EXPECT_NO_FATAL_FAILURE(instance_->NotifyPointerEventToRS(pointAction, pointCnt)); 715 } 716 #endif // OHOS_BUILD_ENABLE_WATCH 717 } // namespace MMI 718 } // namespace OHOS 719