1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <cstdio> 17 #include <fstream> 18 #include <gtest/gtest.h> 19 20 #include "mmi_log.h" 21 #include "pointer_event.h" 22 #ifndef USE_ROSEN_DRAWING 23 #define USE_ROSEN_DRAWING 24 #endif 25 #include "touch_drawing_manager.h" 26 #include "window_info.h" 27 28 #undef MMI_LOG_TAG 29 #define MMI_LOG_TAG "TouchDrawingManagerTest" 30 31 namespace OHOS { 32 namespace MMI { 33 namespace { 34 using namespace testing::ext; 35 } // namespace 36 class TouchDrawingManagerTest : public testing::Test { 37 public: SetUpTestCase(void)38 static void SetUpTestCase(void) {}; TearDownTestCase(void)39 static void TearDownTestCase(void) {}; SetUp(void)40 void SetUp(void) 41 { 42 DisplayInfo info; 43 info.id = 1; 44 info.x =1; 45 info.y = 1; 46 info.width = 1; 47 info.height = 1; 48 int32_t displayDpi = 240; 49 info.dpi = displayDpi; 50 info.name = "xx"; 51 info.uniq = "xx"; 52 info.direction = DIRECTION0; 53 TOUCH_DRAWING_MGR->UpdateDisplayInfo(info); 54 } 55 }; 56 57 /** 58 * @tc.name: TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_001 59 * @tc.desc: Test GetOriginalTouchScreenCoordinates 60 * @tc.type: Function 61 * @tc.require: 62 */ 63 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_001, TestSize.Level1) 64 { 65 CALL_TEST_DEBUG; 66 int32_t width = 100; 67 int32_t height = 200; 68 int32_t physicalX = 50; 69 int32_t physicalY = 60; 70 TOUCH_DRAWING_MGR->GetOriginalTouchScreenCoordinates(DIRECTION0, width, height, physicalX, physicalY); 71 EXPECT_EQ(physicalX, 50); 72 EXPECT_EQ(physicalY, 60); 73 } 74 75 /** 76 * @tc.name: TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_002 77 * @tc.desc: Test GetOriginalTouchScreenCoordinates 78 * @tc.type: Function 79 * @tc.require: 80 */ 81 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_002, TestSize.Level1) 82 { 83 CALL_TEST_DEBUG; 84 int32_t width = 100; 85 int32_t height = 200; 86 int32_t physicalX = 50; 87 int32_t physicalY = 60; 88 TOUCH_DRAWING_MGR->GetOriginalTouchScreenCoordinates(DIRECTION90, width, height, physicalX, physicalY); 89 EXPECT_EQ(physicalX, 60); 90 EXPECT_EQ(physicalY, 50); 91 } 92 93 /** 94 * @tc.name: TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_003 95 * @tc.desc: Test GetOriginalTouchScreenCoordinates 96 * @tc.type: Function 97 * @tc.require: 98 */ 99 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_003, TestSize.Level1) 100 { 101 CALL_TEST_DEBUG; 102 int32_t width = 100; 103 int32_t height = 200; 104 int32_t physicalX = 50; 105 int32_t physicalY = 60; 106 TOUCH_DRAWING_MGR->GetOriginalTouchScreenCoordinates(DIRECTION180, width, height, physicalX, physicalY); 107 EXPECT_EQ(physicalX, 50); 108 EXPECT_EQ(physicalY, 140); 109 } 110 111 /** 112 * @tc.name: TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_004 113 * @tc.desc: Test GetOriginalTouchScreenCoordinates 114 * @tc.type: Function 115 * @tc.require: 116 */ 117 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_GetOriginalTouchScreenCoordinates_004, TestSize.Level1) 118 { 119 CALL_TEST_DEBUG; 120 int32_t width = 100; 121 int32_t height = 200; 122 int32_t physicalX = 50; 123 int32_t physicalY = 60; 124 TOUCH_DRAWING_MGR->GetOriginalTouchScreenCoordinates(DIRECTION270, width, height, physicalX, physicalY); 125 EXPECT_EQ(physicalX, 140); 126 EXPECT_EQ(physicalY, 50); 127 } 128 129 /** 130 * @tc.name: TouchDrawingManagerTest_IsValidAction_001 131 * @tc.desc: Test is valid action 132 * @tc.type: Function 133 * @tc.require: 134 */ 135 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_IsValidAction_001, TestSize.Level1) 136 { 137 CALL_TEST_DEBUG; 138 TouchDrawingManager manager; 139 bool ret = manager.IsValidAction(PointerEvent::POINTER_ACTION_DOWN); 140 EXPECT_TRUE(ret); 141 ret = manager.IsValidAction(PointerEvent::POINTER_ACTION_PULL_DOWN); 142 EXPECT_TRUE(ret); 143 ret = manager.IsValidAction(PointerEvent::POINTER_ACTION_MOVE); 144 EXPECT_TRUE(ret); 145 ret = manager.IsValidAction(PointerEvent::POINTER_ACTION_PULL_MOVE); 146 EXPECT_TRUE(ret); 147 ret = manager.IsValidAction(PointerEvent::POINTER_ACTION_UP); 148 EXPECT_TRUE(ret); 149 ret = manager.IsValidAction(PointerEvent::POINTER_ACTION_PULL_UP); 150 EXPECT_TRUE(ret); 151 ret = manager.IsValidAction(100); 152 EXPECT_FALSE(ret); 153 } 154 155 /** 156 * @tc.name: TouchDrawingManagerTest_DrawBubbleHandler_001 157 * @tc.desc: Test DrawBubbleHandler 158 * @tc.type: Function 159 * @tc.require: 160 */ 161 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawBubbleHandler_001, TestSize.Level1) 162 { 163 CALL_TEST_DEBUG; 164 auto pointerEvent = PointerEvent::Create(); 165 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_BEGIN); 166 EXPECT_NE(pointerEvent, nullptr); 167 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 168 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawBubbleHandler()); 169 } 170 171 /** 172 * @tc.name: TouchDrawingManagerTest_DrawBubbleHandler_002 173 * @tc.desc: Test DrawBubbleHandler 174 * @tc.type: Function 175 * @tc.require: 176 */ 177 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawBubbleHandler_002, TestSize.Level1) 178 { 179 CALL_TEST_DEBUG; 180 auto pointerEvent = PointerEvent::Create(); 181 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_UP); 182 EXPECT_NE(pointerEvent, nullptr); 183 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 184 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawBubbleHandler()); 185 } 186 187 /** 188 * @tc.name: TouchDrawingManagerTest_DrawBubbleHandler_003 189 * @tc.desc: Test DrawBubbleHandler 190 * @tc.type: Function 191 * @tc.require: 192 */ 193 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawBubbleHandler_003, TestSize.Level1) 194 { 195 CALL_TEST_DEBUG; 196 auto pointerEvent = PointerEvent::Create(); 197 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP); 198 EXPECT_NE(pointerEvent, nullptr); 199 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 200 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawBubbleHandler()); 201 } 202 203 /** 204 * @tc.name: TouchDrawingManagerTest_DrawBubble_001 205 * @tc.desc: Test DrawBubble 206 * @tc.type: Function 207 * @tc.require: 208 */ 209 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawBubble_001, TestSize.Level1) 210 { 211 CALL_TEST_DEBUG; 212 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawBubble()); 213 } 214 215 /** 216 * @tc.name: TouchDrawingManagerTest_DrawBubble_002 217 * @tc.desc: Test DrawBubble 218 * @tc.type: Function 219 * @tc.require: 220 */ 221 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawBubble_002, TestSize.Level1) 222 { 223 CALL_TEST_DEBUG; 224 auto pointerEvent = PointerEvent::Create(); 225 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); 226 EXPECT_NE(pointerEvent, nullptr); 227 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 228 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawBubble()); 229 } 230 231 /** 232 * @tc.name: TouchDrawingManagerTest_DrawPointerPositionHandler_001 233 * @tc.desc: Test DrawPointerPositionHandler 234 * @tc.type: Function 235 * @tc.require: 236 */ 237 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawPointerPositionHandler_001, TestSize.Level1) 238 { 239 CALL_TEST_DEBUG; 240 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawPointerPositionHandler()); 241 } 242 243 /** 244 * @tc.name: TouchDrawingManagerTest_DrawPointerPositionHandler_002 245 * @tc.desc: Test DrawPointerPositionHandler 246 * @tc.type: Function 247 * @tc.require: 248 */ 249 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawPointerPositionHandler_002, TestSize.Level1) 250 { 251 CALL_TEST_DEBUG; 252 auto pointerEvent = PointerEvent::Create(); 253 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP); 254 EXPECT_NE(pointerEvent, nullptr); 255 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 256 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawPointerPositionHandler()); 257 } 258 259 /** 260 * @tc.name: TouchDrawingManagerTest_DrawTracker_001 261 * @tc.desc: Test DrawTracker 262 * @tc.type: Function 263 * @tc.require: 264 */ 265 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawTracker_001, TestSize.Level1) 266 { 267 CALL_TEST_DEBUG; 268 int32_t x = 10; 269 int32_t y = 10; 270 int32_t pointerId = 0; 271 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawTracker(x, y, pointerId)); 272 } 273 274 /** 275 * @tc.name: TouchDrawingManagerTest_DrawTracker_002 276 * @tc.desc: Test DrawTracker 277 * @tc.type: Function 278 * @tc.require: 279 */ 280 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawTracker_002, TestSize.Level1) 281 { 282 CALL_TEST_DEBUG; 283 int32_t x = 11; 284 int32_t y = 11; 285 int32_t pointerId = 5; 286 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawTracker(x, y, pointerId)); 287 } 288 289 /** 290 * @tc.name: TouchDrawingManagerTest_DrawCrosshairs_001 291 * @tc.desc: Test DrawCrosshairs 292 * @tc.type: Function 293 * @tc.require: 294 */ 295 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawCrosshairs_001, TestSize.Level1) 296 { 297 CALL_TEST_DEBUG; 298 int32_t x = 11; 299 int32_t y = 11; 300 if (TOUCH_DRAWING_MGR->crosshairCanvasNode_ == nullptr) { 301 TOUCH_DRAWING_MGR->crosshairCanvasNode_ = Rosen::RSCanvasNode::Create(); 302 } 303 ASSERT_NE(TOUCH_DRAWING_MGR->crosshairCanvasNode_, nullptr); 304 auto canvas = static_cast<TouchDrawingManager::RosenCanvas *> 305 (TOUCH_DRAWING_MGR->crosshairCanvasNode_->BeginRecording(TOUCH_DRAWING_MGR->displayInfo_.width, 306 TOUCH_DRAWING_MGR->displayInfo_.height)); 307 ASSERT_NE(canvas, nullptr); 308 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawCrosshairs(canvas, x, y)); 309 } 310 311 /** 312 * @tc.name: TouchDrawingManagerTest_DrawCrosshairs_002 313 * @tc.desc: Test DrawCrosshairs 314 * @tc.type: Function 315 * @tc.require: 316 */ 317 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawCrosshairs_002, TestSize.Level1) 318 { 319 CALL_TEST_DEBUG; 320 int32_t x = 11; 321 int32_t y = 11; 322 if (TOUCH_DRAWING_MGR->crosshairCanvasNode_ == nullptr) { 323 TOUCH_DRAWING_MGR->crosshairCanvasNode_ = Rosen::RSCanvasNode::Create(); 324 } 325 auto canvas = static_cast<TouchDrawingManager::RosenCanvas *> 326 (TOUCH_DRAWING_MGR->crosshairCanvasNode_->BeginRecording(TOUCH_DRAWING_MGR->displayInfo_.width, 327 TOUCH_DRAWING_MGR->displayInfo_.height)); 328 ASSERT_NE(canvas, nullptr); 329 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION90; 330 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawCrosshairs(canvas, x, y)); 331 } 332 333 /** 334 * @tc.name: TouchDrawingManagerTest_DrawCrosshairs_003 335 * @tc.desc: Test DrawCrosshairs 336 * @tc.type: Function 337 * @tc.require: 338 */ 339 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawCrosshairs_003, TestSize.Level1) 340 { 341 CALL_TEST_DEBUG; 342 int32_t x = 11; 343 int32_t y = 11; 344 if (TOUCH_DRAWING_MGR->crosshairCanvasNode_ == nullptr) { 345 TOUCH_DRAWING_MGR->crosshairCanvasNode_ = Rosen::RSCanvasNode::Create(); 346 } 347 auto canvas = static_cast<TouchDrawingManager::RosenCanvas *> 348 (TOUCH_DRAWING_MGR->crosshairCanvasNode_->BeginRecording(TOUCH_DRAWING_MGR->displayInfo_.width, 349 TOUCH_DRAWING_MGR->displayInfo_.height)); 350 ASSERT_NE(canvas, nullptr); 351 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION270; 352 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawCrosshairs(canvas, x, y)); 353 } 354 355 /** 356 * @tc.name: TouchDrawingManagerTest_UpdatePointerPosition_001 357 * @tc.desc: Test UpdatePointerPosition 358 * @tc.type: Function 359 * @tc.require: 360 */ 361 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdatePointerPosition_001, TestSize.Level1) 362 { 363 CALL_TEST_DEBUG; 364 auto pointerEvent = PointerEvent::Create(); 365 pointerEvent->SetPointerId(5); 366 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP); 367 EXPECT_NE(pointerEvent, nullptr); 368 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 369 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdatePointerPosition()); 370 } 371 372 /** 373 * @tc.name: TouchDrawingManagerTest_UpdatePointerPosition_002 374 * @tc.desc: Test UpdatePointerPosition 375 * @tc.type: Function 376 * @tc.require: 377 */ 378 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdatePointerPosition_002, TestSize.Level1) 379 { 380 CALL_TEST_DEBUG; 381 auto pointerEvent = PointerEvent::Create(); 382 pointerEvent->SetPointerId(5); 383 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP); 384 EXPECT_NE(pointerEvent, nullptr); 385 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 386 TOUCH_DRAWING_MGR->currentPointerId_ = 5; 387 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdatePointerPosition()); 388 } 389 390 /** 391 * @tc.name: TouchDrawingManagerTest_UpdatePointerPosition_003 392 * @tc.desc: Test UpdatePointerPosition 393 * @tc.type: Function 394 * @tc.require: 395 */ 396 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdatePointerPosition_003, TestSize.Level1) 397 { 398 CALL_TEST_DEBUG; 399 auto pointerEvent = PointerEvent::Create(); 400 pointerEvent->SetPointerId(0); 401 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); 402 EXPECT_NE(pointerEvent, nullptr); 403 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 404 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdatePointerPosition()); 405 } 406 407 /** 408 * @tc.name: TouchDrawingManagerTest_UpdatePointerPosition_004 409 * @tc.desc: Test UpdatePointerPosition 410 * @tc.type: Function 411 * @tc.require: 412 */ 413 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdatePointerPosition_004, TestSize.Level1) 414 { 415 CALL_TEST_DEBUG; 416 auto pointerEvent = PointerEvent::Create(); 417 pointerEvent->SetPointerId(0); 418 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); 419 EXPECT_NE(pointerEvent, nullptr); 420 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 421 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdatePointerPosition()); 422 } 423 424 /** 425 * @tc.name: TouchDrawingManagerTest_UpdatePointerPosition_005 426 * @tc.desc: Test UpdatePointerPosition 427 * @tc.type: Function 428 * @tc.require: 429 */ 430 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdatePointerPosition_005, TestSize.Level1) 431 { 432 CALL_TEST_DEBUG; 433 auto pointerEvent = PointerEvent::Create(); 434 pointerEvent->SetPointerId(0); 435 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); 436 EXPECT_NE(pointerEvent, nullptr); 437 TOUCH_DRAWING_MGR->pointerEvent_ = pointerEvent; 438 PointerEvent::PointerItem item; 439 item.SetPointerId(0); 440 item.SetPressed(true); 441 TOUCH_DRAWING_MGR->lastPointerItem_.emplace_back(item); 442 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdatePointerPosition()); 443 } 444 445 /** 446 * @tc.name: TouchDrawingManagerTest_ClearTracker_001 447 * @tc.desc: Test ClearTracker 448 * @tc.type: Function 449 * @tc.require: 450 */ 451 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_ClearTracker_001, TestSize.Level1) 452 { 453 CALL_TEST_DEBUG; 454 if (TOUCH_DRAWING_MGR->trackerCanvasNode_ == nullptr) { 455 TOUCH_DRAWING_MGR->trackerCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 456 } 457 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->ClearTracker()); 458 } 459 460 /** 461 * @tc.name: TouchDrawingManagerTest_ClearTracker_002 462 * @tc.desc: Test ClearTracker 463 * @tc.type: Function 464 * @tc.require: 465 */ 466 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_ClearTracker_002, TestSize.Level1) 467 { 468 CALL_TEST_DEBUG; 469 if (TOUCH_DRAWING_MGR->trackerCanvasNode_ == nullptr) { 470 TOUCH_DRAWING_MGR->trackerCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 471 } 472 TOUCH_DRAWING_MGR->lastPointerItem_.clear(); 473 TOUCH_DRAWING_MGR->isDownAction_ = false; 474 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->ClearTracker()); 475 } 476 477 /** 478 * @tc.name: TouchDrawingManagerTest_ClearTracker_003 479 * @tc.desc: Test ClearTracker 480 * @tc.type: Function 481 * @tc.require: 482 */ 483 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_ClearTracker_003, TestSize.Level1) 484 { 485 CALL_TEST_DEBUG; 486 if (TOUCH_DRAWING_MGR->trackerCanvasNode_ == nullptr) { 487 TOUCH_DRAWING_MGR->trackerCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 488 } 489 PointerEvent::PointerItem item; 490 item.SetPointerId(0); 491 item.SetDisplayY(200); 492 TOUCH_DRAWING_MGR->lastPointerItem_.emplace_back(item); 493 TOUCH_DRAWING_MGR->isDownAction_ = true; 494 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->ClearTracker()); 495 } 496 497 /** 498 * @tc.name: TouchDrawingManagerTest_DrawLabels_001 499 * @tc.desc: Test DrawLabels 500 * @tc.type: Function 501 * @tc.require: 502 */ 503 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawLabels_001, TestSize.Level1) 504 { 505 CALL_TEST_DEBUG; 506 TOUCH_DRAWING_MGR->isDownAction_ = true; 507 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION90; 508 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawLabels()); 509 } 510 511 /** 512 * @tc.name: TouchDrawingManagerTest_DrawLabels_002 513 * @tc.desc: Test DrawLabels 514 * @tc.type: Function 515 * @tc.require: 516 */ 517 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawLabels_002, TestSize.Level1) 518 { 519 CALL_TEST_DEBUG; 520 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 521 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 522 } 523 TOUCH_DRAWING_MGR->isDownAction_ = true; 524 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION180; 525 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 526 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawLabels()); 527 } 528 529 /** 530 * @tc.name: TouchDrawingManagerTest_DrawLabels_003 531 * @tc.desc: Test DrawLabels 532 * @tc.type: Function 533 * @tc.require: 534 */ 535 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawLabels_003, TestSize.Level1) 536 { 537 CALL_TEST_DEBUG; 538 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 539 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 540 } 541 TOUCH_DRAWING_MGR->isDownAction_ = true; 542 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION270; 543 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 544 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawLabels()); 545 } 546 547 /** 548 * @tc.name: TouchDrawingManagerTest_DrawLabels_004 549 * @tc.desc: Test DrawLabels 550 * @tc.type: Function 551 * @tc.require: 552 */ 553 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawLabels_004, TestSize.Level1) 554 { 555 CALL_TEST_DEBUG; 556 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 557 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 558 } 559 TOUCH_DRAWING_MGR->isDownAction_ = true; 560 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION270; 561 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 562 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawLabels()); 563 } 564 565 /** 566 * @tc.name: TouchDrawingManagerTest_UpdateLabels_002 567 * @tc.desc: Test UpdateLabels 568 * @tc.type: Function 569 * @tc.require: 570 */ 571 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateLabels_002, TestSize.Level1) 572 { 573 CALL_TEST_DEBUG; 574 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 575 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 576 } 577 TOUCH_DRAWING_MGR->pointerMode_.isShow = true; 578 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdateLabels()); 579 } 580 581 /** 582 * @tc.name: TouchDrawingManagerTest_CreateObserver_001 583 * @tc.desc: Test CreateObserver 584 * @tc.type: Function 585 * @tc.require: 586 */ 587 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_CreateObserver_001, TestSize.Level1) 588 { 589 CALL_TEST_DEBUG; 590 TOUCH_DRAWING_MGR->hasBubbleObserver_ = false; 591 TOUCH_DRAWING_MGR->hasPointerObserver_ = false; 592 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->CreateObserver()); 593 } 594 595 /** 596 * @tc.name: TouchDrawingManagerTest_CreateObserver_002 597 * @tc.desc: Test CreateObserver 598 * @tc.type: Function 599 * @tc.require: 600 */ 601 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_CreateObserver_002, TestSize.Level1) 602 { 603 CALL_TEST_DEBUG; 604 TOUCH_DRAWING_MGR->hasBubbleObserver_ = true; 605 TOUCH_DRAWING_MGR->hasPointerObserver_ = false; 606 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->CreateObserver()); 607 } 608 609 /** 610 * @tc.name: TouchDrawingManagerTest_CreateObserver_003 611 * @tc.desc: Test CreateObserver 612 * @tc.type: Function 613 * @tc.require: 614 */ 615 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_CreateObserver_003, TestSize.Level1) 616 { 617 CALL_TEST_DEBUG; 618 TOUCH_DRAWING_MGR->hasBubbleObserver_ = false; 619 TOUCH_DRAWING_MGR->hasPointerObserver_ = true; 620 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->CreateObserver()); 621 } 622 623 /** 624 * @tc.name: TouchDrawingManagerTest_CreateObserver_004 625 * @tc.desc: Test CreateObserver 626 * @tc.type: Function 627 * @tc.require: 628 */ 629 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_CreateObserver_004, TestSize.Level1) 630 { 631 CALL_TEST_DEBUG; 632 TOUCH_DRAWING_MGR->hasBubbleObserver_ = true; 633 TOUCH_DRAWING_MGR->hasPointerObserver_ = true; 634 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->CreateObserver()); 635 } 636 637 /** 638 * @tc.name: TouchDrawingManagerTest_DrawRectItem_001 639 * @tc.desc: Test DrawRectItem 640 * @tc.type: Function 641 * @tc.require: 642 */ 643 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawRectItem_001, TestSize.Level1) 644 { 645 CALL_TEST_DEBUG; 646 TouchDrawingManager::RosenCanvas *canvas = nullptr; 647 std::string text; 648 Rosen::Drawing::Rect rect {}; 649 Rosen::Drawing::Color color {}; 650 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawRectItem(canvas, text, rect, color)); 651 } 652 653 /** 654 * @tc.name: TouchDrawingManagerTest_DrawRectItem_002 655 * @tc.desc: Test DrawRectItem 656 * @tc.type: Function 657 * @tc.require: 658 */ 659 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawRectItem_002, TestSize.Level1) 660 { 661 CALL_TEST_DEBUG; 662 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 663 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasNode::Create(); 664 } 665 auto canvas = static_cast<TouchDrawingManager::RosenCanvas *> 666 (TOUCH_DRAWING_MGR->labelsCanvasNode_->BeginRecording(TOUCH_DRAWING_MGR->displayInfo_.width, 667 TOUCH_DRAWING_MGR->displayInfo_.height)); 668 ASSERT_NE(canvas, nullptr); 669 std::string text = "test"; 670 Rosen::Drawing::Rect rect { 1, 1, 10, 10 }; 671 Rosen::Drawing::Color color = Rosen::Drawing::Color::ColorQuadSetARGB(192, 255, 255, 255); 672 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DrawRectItem(canvas, text, rect, color)); 673 TOUCH_DRAWING_MGR->labelsCanvasNode_->FinishRecording(); 674 Rosen::RSTransaction::FlushImplicitTransaction(); 675 } 676 677 /** 678 * @tc.name: TouchDrawingManagerTest_CreateTouchWindow_002 679 * @tc.desc: Test CreateTouchWindow 680 * @tc.type: Function 681 * @tc.require: 682 */ 683 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_CreateTouchWindow_002, TestSize.Level1) 684 { 685 CALL_TEST_DEBUG; 686 Rosen::RSSurfaceNodeConfig surfaceNodeConfig; 687 surfaceNodeConfig.SurfaceNodeName = "touch window"; 688 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 689 TOUCH_DRAWING_MGR->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); 690 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->CreateTouchWindow()); 691 } 692 693 /** 694 * @tc.name: TouchDrawingManagerTest_DestoryTouchWindow_001 695 * @tc.desc: Test DestoryTouchWindow 696 * @tc.type: Function 697 * @tc.require: 698 */ 699 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DestoryTouchWindow_001, TestSize.Level1) 700 { 701 CALL_TEST_DEBUG; 702 TOUCH_DRAWING_MGR->bubbleMode_.isShow = true; 703 TOUCH_DRAWING_MGR->pointerMode_.isShow = true; 704 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DestoryTouchWindow()); 705 } 706 707 /** 708 * @tc.name: TouchDrawingManagerTest_DestoryTouchWindow_002 709 * @tc.desc: Test DestoryTouchWindow 710 * @tc.type: Function 711 * @tc.require: 712 */ 713 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DestoryTouchWindow_002, TestSize.Level1) 714 { 715 CALL_TEST_DEBUG; 716 TOUCH_DRAWING_MGR->bubbleMode_.isShow = false; 717 TOUCH_DRAWING_MGR->pointerMode_.isShow = false; 718 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DestoryTouchWindow()); 719 } 720 721 /** 722 * @tc.name: TouchDrawingManagerTest_DestoryTouchWindow_003 723 * @tc.desc: Test DestoryTouchWindow 724 * @tc.type: Function 725 * @tc.require: 726 */ 727 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DestoryTouchWindow_003, TestSize.Level1) 728 { 729 CALL_TEST_DEBUG; 730 TOUCH_DRAWING_MGR->bubbleMode_.isShow = false; 731 TOUCH_DRAWING_MGR->pointerMode_.isShow = false; 732 Rosen::RSSurfaceNodeConfig surfaceNodeConfig; 733 surfaceNodeConfig.SurfaceNodeName = "touch window"; 734 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 735 TOUCH_DRAWING_MGR->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); 736 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->DestoryTouchWindow()); 737 } 738 /** 739 * @tc.name: TouchDrawingManagerTest_UpdateLastPointerItem_001 740 * @tc.desc: Test UpdateLastPointerItem 741 * @tc.type: Function 742 * @tc.require: 743 */ 744 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateLastPointerItem_001, TestSize.Level1) 745 { 746 CALL_TEST_DEBUG; 747 PointerEvent::PointerItem item; 748 item.SetPressed(false); 749 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdateLastPointerItem(item)); 750 } 751 752 /** 753 * @tc.name: TouchDrawingManagerTest_UpdateLastPointerItem_002 754 * @tc.desc: Test UpdateLastPointerItem 755 * @tc.type: Function 756 * @tc.require: 757 */ 758 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateLastPointerItem_002, TestSize.Level1) 759 { 760 CALL_TEST_DEBUG; 761 PointerEvent::PointerItem item; 762 item.SetPressed(true); 763 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdateLastPointerItem(item)); 764 } 765 766 /** 767 * @tc.name: TouchDrawingManagerTest_UpdateBubbleData_001 768 * @tc.desc: Test UpdateBubbleData 769 * @tc.type: Function 770 * @tc.require: 771 */ 772 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateBubbleData_001, TestSize.Level1) 773 { 774 CALL_TEST_DEBUG; 775 TOUCH_DRAWING_MGR->bubbleMode_.isShow = true; 776 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdateBubbleData()); 777 } 778 779 /** 780 * @tc.name: TouchDrawingManagerTest_UpdateBubbleData_002 781 * @tc.desc: Test UpdateBubbleData 782 * @tc.type: Function 783 * @tc.require: 784 */ 785 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateBubbleData_002, TestSize.Level1) 786 { 787 CALL_TEST_DEBUG; 788 TOUCH_DRAWING_MGR->bubbleMode_.isShow = false; 789 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->UpdateBubbleData()); 790 } 791 792 /** 793 * @tc.name: TouchDrawingManagerTest_RotationScreen_001 794 * @tc.desc: Test RotationScreen 795 * @tc.type: Function 796 * @tc.require: 797 */ 798 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_001, TestSize.Level1) 799 { 800 CALL_TEST_DEBUG; 801 TOUCH_DRAWING_MGR->isChangedRotation_ = true; 802 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 803 TOUCH_DRAWING_MGR->pointerMode_.isShow = true; 804 TOUCH_DRAWING_MGR->bubbleMode_.isShow = true; 805 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 806 } 807 808 /** 809 * @tc.name: TouchDrawingManagerTest_RotationScreen_002 810 * @tc.desc: Test RotationScreen 811 * @tc.type: Function 812 * @tc.require: 813 */ 814 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_002, TestSize.Level1) 815 { 816 CALL_TEST_DEBUG; 817 TOUCH_DRAWING_MGR->isChangedRotation_ = false; 818 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 819 TOUCH_DRAWING_MGR->pointerMode_.isShow = true; 820 TOUCH_DRAWING_MGR->bubbleMode_.isShow = true; 821 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 822 } 823 824 /** 825 * @tc.name: TouchDrawingManagerTest_RotationScreen_003 826 * @tc.desc: Test RotationScreen 827 * @tc.type: Function 828 * @tc.require: 829 */ 830 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_003, TestSize.Level1) 831 { 832 CALL_TEST_DEBUG; 833 TOUCH_DRAWING_MGR->isChangedRotation_ = true; 834 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION90; 835 TOUCH_DRAWING_MGR->pointerMode_.isShow = true; 836 TOUCH_DRAWING_MGR->bubbleMode_.isShow = true; 837 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 838 } 839 840 /** 841 * @tc.name: TouchDrawingManagerTest_RotationScreen_004 842 * @tc.desc: Test RotationScreen 843 * @tc.type: Function 844 * @tc.require: 845 */ 846 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_004, TestSize.Level1) 847 { 848 CALL_TEST_DEBUG; 849 TOUCH_DRAWING_MGR->isChangedRotation_ = true; 850 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 851 TOUCH_DRAWING_MGR->pointerMode_.isShow = false; 852 TOUCH_DRAWING_MGR->bubbleMode_.isShow = true; 853 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 854 } 855 856 /** 857 * @tc.name: TouchDrawingManagerTest_RotationScreen_005 858 * @tc.desc: Test RotationScreen 859 * @tc.type: Function 860 * @tc.require: 861 */ 862 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_005, TestSize.Level1) 863 { 864 CALL_TEST_DEBUG; 865 TOUCH_DRAWING_MGR->isChangedRotation_ = true; 866 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 867 TOUCH_DRAWING_MGR->pointerMode_.isShow = true; 868 TOUCH_DRAWING_MGR->bubbleMode_.isShow = false; 869 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 870 } 871 872 /** 873 * @tc.name: TouchDrawingManagerTest_RotationScreen_006 874 * @tc.desc: Test RotationScreen 875 * @tc.type: Function 876 * @tc.require: 877 */ 878 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_006, TestSize.Level1) 879 { 880 CALL_TEST_DEBUG; 881 TOUCH_DRAWING_MGR->isChangedRotation_ = false; 882 TOUCH_DRAWING_MGR->isChangedMode_ = true; 883 TOUCH_DRAWING_MGR->pointerMode_.isShow = true; 884 TOUCH_DRAWING_MGR->bubbleMode_.isShow = true; 885 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 886 } 887 888 /** 889 * @tc.name: TouchDrawingManagerTest_RotationScreen_007 890 * @tc.desc: Test RotationScreen 891 * @tc.type: Function 892 * @tc.require: 893 */ 894 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_007, TestSize.Level1) 895 { 896 CALL_TEST_DEBUG; 897 TOUCH_DRAWING_MGR->isChangedRotation_ = false; 898 TOUCH_DRAWING_MGR->isChangedMode_ = true; 899 TOUCH_DRAWING_MGR->pointerMode_.isShow = false; 900 TOUCH_DRAWING_MGR->bubbleMode_.isShow = false; 901 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 902 } 903 904 /** 905 * @tc.name: TouchDrawingManagerTest_RotationScreen_008 906 * @tc.desc: Test RotationScreen 907 * @tc.type: Function 908 * @tc.require: 909 */ 910 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_008, TestSize.Level1) 911 { 912 CALL_TEST_DEBUG; 913 TOUCH_DRAWING_MGR->isChangedRotation_ = false; 914 TOUCH_DRAWING_MGR->isChangedMode_ = false; 915 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationScreen()); 916 } 917 918 /** 919 * @tc.name: TouchDrawingManagerTest_AddCanvasNode_001 920 * @tc.desc: Test AddCanvasNode 921 * @tc.type: Function 922 * @tc.require: 923 */ 924 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_AddCanvasNode_001, TestSize.Level1) 925 { 926 CALL_TEST_DEBUG; 927 Rosen::RSSurfaceNodeConfig surfaceNodeConfig; 928 surfaceNodeConfig.SurfaceNodeName = "touch window"; 929 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 930 TOUCH_DRAWING_MGR->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); 931 932 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = nullptr; 933 bool isTrackerNode = true; 934 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->AddCanvasNode(canvasNode, isTrackerNode)); 935 } 936 937 /** 938 * @tc.name: TouchDrawingManagerTest_AddCanvasNode_002 939 * @tc.desc: Test AddCanvasNode 940 * @tc.type: Function 941 * @tc.require: 942 */ 943 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_AddCanvasNode_002, TestSize.Level1) 944 { 945 CALL_TEST_DEBUG; 946 Rosen::RSSurfaceNodeConfig surfaceNodeConfig; 947 surfaceNodeConfig.SurfaceNodeName = "touch window"; 948 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 949 TOUCH_DRAWING_MGR->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); 950 951 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = nullptr; 952 bool isTrackerNode = false; 953 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->AddCanvasNode(canvasNode, isTrackerNode)); 954 } 955 956 /** 957 * @tc.name: TouchDrawingManagerTest_RotationCanvasNode_001 958 * @tc.desc: Test RotationCanvasNode 959 * @tc.type: Function 960 * @tc.require: 961 */ 962 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationCanvasNode_001, TestSize.Level1) 963 { 964 CALL_TEST_DEBUG; 965 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = Rosen::RSCanvasNode::Create(); 966 ASSERT_NE(canvasNode, nullptr); 967 TOUCH_DRAWING_MGR->displayInfo_.direction = Direction::DIRECTION90; 968 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationCanvasNode(canvasNode)); 969 } 970 971 /** 972 * @tc.name: TouchDrawingManagerTest_RotationCanvasNode_002 973 * @tc.desc: Test RotationCanvasNode 974 * @tc.type: Function 975 * @tc.require: 976 */ 977 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationCanvasNode_002, TestSize.Level1) 978 { 979 CALL_TEST_DEBUG; 980 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = Rosen::RSCanvasNode::Create(); 981 ASSERT_NE(canvasNode, nullptr); 982 TOUCH_DRAWING_MGR->displayInfo_.direction = Direction::DIRECTION270; 983 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationCanvasNode(canvasNode)); 984 } 985 986 /** 987 * @tc.name: TouchDrawingManagerTest_RotationCanvasNode_003 988 * @tc.desc: Test RotationCanvasNode 989 * @tc.type: Function 990 * @tc.require: 991 */ 992 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationCanvasNode_003, TestSize.Level1) 993 { 994 CALL_TEST_DEBUG; 995 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = Rosen::RSCanvasNode::Create(); 996 ASSERT_NE(canvasNode, nullptr); 997 TOUCH_DRAWING_MGR->displayInfo_.direction = Direction::DIRECTION180; 998 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationCanvasNode(canvasNode)); 999 } 1000 1001 /** 1002 * @tc.name: TouchDrawingManagerTest_RotationCanvasNode_004 1003 * @tc.desc: Test RotationCanvasNode 1004 * @tc.type: Function 1005 * @tc.require: 1006 */ 1007 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationCanvasNode_004, TestSize.Level1) 1008 { 1009 CALL_TEST_DEBUG; 1010 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = Rosen::RSCanvasNode::Create(); 1011 ASSERT_NE(canvasNode, nullptr); 1012 TOUCH_DRAWING_MGR->displayInfo_.direction = Direction::DIRECTION0; 1013 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RotationCanvasNode(canvasNode)); 1014 } 1015 1016 /** 1017 * @tc.name: TouchDrawingManagerTest_RemovePointerPosition_001 1018 * @tc.desc: Test RemovePointerPosition 1019 * @tc.type: Function 1020 * @tc.require: 1021 */ 1022 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RemovePointerPosition_001, TestSize.Level1) 1023 { 1024 CALL_TEST_DEBUG; 1025 Rosen::RSSurfaceNodeConfig surfaceNodeConfig; 1026 surfaceNodeConfig.SurfaceNodeName = "touch window"; 1027 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 1028 TOUCH_DRAWING_MGR->surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); 1029 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->RemovePointerPosition()); 1030 } 1031 1032 /** 1033 * @tc.name: TouchDrawingManagerTest_Snapshot_001 1034 * @tc.desc: Test Snapshot 1035 * @tc.type: Function 1036 * @tc.require: 1037 */ 1038 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_Snapshot_001, TestSize.Level1) 1039 { 1040 CALL_TEST_DEBUG; 1041 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 1042 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 1043 } 1044 TOUCH_DRAWING_MGR->isChangedRotation_ = true; 1045 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION90; 1046 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 1047 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->Snapshot()); 1048 } 1049 1050 /** 1051 * @tc.name: TouchDrawingManagerTest_Snapshot_002 1052 * @tc.desc: Test Snapshot 1053 * @tc.type: Function 1054 * @tc.require: 1055 */ 1056 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_Snapshot_002, TestSize.Level1) 1057 { 1058 CALL_TEST_DEBUG; 1059 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 1060 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 1061 } 1062 TOUCH_DRAWING_MGR->isChangedRotation_ = true; 1063 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION180; 1064 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 1065 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->Snapshot()); 1066 } 1067 1068 /** 1069 * @tc.name: TouchDrawingManagerTest_Snapshot_003 1070 * @tc.desc: Test Snapshot 1071 * @tc.type: Function 1072 * @tc.require: 1073 */ 1074 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_Snapshot_003, TestSize.Level1) 1075 { 1076 CALL_TEST_DEBUG; 1077 if (TOUCH_DRAWING_MGR->labelsCanvasNode_ == nullptr) { 1078 TOUCH_DRAWING_MGR->labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 1079 } 1080 TOUCH_DRAWING_MGR->isChangedRotation_ = true; 1081 TOUCH_DRAWING_MGR->displayInfo_.direction = DIRECTION270; 1082 TOUCH_DRAWING_MGR->displayInfo_.displayDirection = DIRECTION0; 1083 EXPECT_NO_FATAL_FAILURE(TOUCH_DRAWING_MGR->Snapshot()); 1084 } 1085 1086 /** 1087 * @tc.name: TouchDrawingManagerTest_InitLabels_001 1088 * @tc.desc: Test InitLabels 1089 * @tc.type: Function 1090 * @tc.require: 1091 */ 1092 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_InitLabels_001, TestSize.Level1) 1093 { 1094 CALL_TEST_DEBUG; 1095 TOUCH_DRAWING_MGR->InitLabels(); 1096 EXPECT_EQ(TOUCH_DRAWING_MGR->isFirstDownAction_, true); 1097 EXPECT_EQ(TOUCH_DRAWING_MGR->isDownAction_, true); 1098 EXPECT_EQ(TOUCH_DRAWING_MGR->maxPointerCount_, 0); 1099 } 1100 1101 /** 1102 * @tc.name: TouchDrawingManagerTest_ResetCanvasNode_001 1103 * @tc.desc: Test ResetCanvasNode 1104 * @tc.type: Function 1105 * @tc.require: 1106 */ 1107 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_ResetCanvasNode_001, TestSize.Level1) 1108 { 1109 CALL_TEST_DEBUG; 1110 auto canvasNode = Rosen::RSCanvasDrawingNode::Create(); 1111 TOUCH_DRAWING_MGR->ResetCanvasNode(canvasNode); 1112 } 1113 1114 /** 1115 * @tc.name: TouchDrawingManagerTest_AddCanvasNode 1116 * @tc.desc: Test AddCanvasNode 1117 * @tc.type: Function 1118 * @tc.require: 1119 */ 1120 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_AddCanvasNode, TestSize.Level1) 1121 { 1122 CALL_TEST_DEBUG; 1123 TouchDrawingManager touchDrawingMgr; 1124 Rosen::RSSurfaceNodeConfig surfaceNodeConfig; 1125 surfaceNodeConfig.SurfaceNodeName = "touch window"; 1126 Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; 1127 touchDrawingMgr.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); 1128 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = Rosen::RSCanvasNode::Create(); 1129 ASSERT_NE(canvasNode, nullptr); 1130 bool isTrackerNode = true; 1131 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.AddCanvasNode(canvasNode, isTrackerNode)); 1132 1133 canvasNode = nullptr; 1134 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.AddCanvasNode(canvasNode, isTrackerNode)); 1135 } 1136 1137 /** 1138 * @tc.name: TouchDrawingManagerTest_RotationCanvasNode 1139 * @tc.desc: Test RotationCanvasNode 1140 * @tc.type: Function 1141 * @tc.require: 1142 */ 1143 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationCanvasNode, TestSize.Level1) 1144 { 1145 CALL_TEST_DEBUG; 1146 TouchDrawingManager touchDrawingMgr; 1147 std::shared_ptr<Rosen::RSCanvasNode> canvasNode = Rosen::RSCanvasNode::Create(); 1148 ASSERT_NE(canvasNode, nullptr); 1149 touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION90; 1150 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvasNode(canvasNode)); 1151 touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION270; 1152 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvasNode(canvasNode)); 1153 touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION180; 1154 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvasNode(canvasNode)); 1155 touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION0; 1156 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvasNode(canvasNode)); 1157 } 1158 1159 /** 1160 * @tc.name: TouchDrawingManagerTest_UpdateDisplayInfo 1161 * @tc.desc: Test UpdateDisplayInfo 1162 * @tc.type: Function 1163 * @tc.require: 1164 */ 1165 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateDisplayInfo, TestSize.Level1) 1166 { 1167 CALL_TEST_DEBUG; 1168 TouchDrawingManager touchDrawingMgr; 1169 DisplayInfo displayInfo; 1170 displayInfo.direction = Direction::DIRECTION0; 1171 touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION0; 1172 displayInfo.width = 700; 1173 displayInfo.height = 500; 1174 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); 1175 1176 displayInfo.direction = Direction::DIRECTION180; 1177 touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION180; 1178 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); 1179 1180 displayInfo.direction = Direction::DIRECTION270; 1181 touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION270; 1182 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); 1183 } 1184 1185 /** 1186 * @tc.name: TouchDrawingManagerTest_RotationCanvas 1187 * @tc.desc: Test RotationCanvas 1188 * @tc.type: Function 1189 * @tc.require: 1190 */ 1191 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationCanvas, TestSize.Level1) 1192 { 1193 CALL_TEST_DEBUG; 1194 TouchDrawingManager touchDrawingMgr; 1195 int32_t width = 300; 1196 int32_t height = 100; 1197 Direction direction = Direction::DIRECTION90; 1198 touchDrawingMgr.labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); 1199 auto canvas = static_cast<TouchDrawingManager::RosenCanvas *> 1200 (touchDrawingMgr.labelsCanvasNode_->BeginRecording(width, height)); 1201 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvas(canvas, direction)); 1202 direction = Direction::DIRECTION180; 1203 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvas(canvas, direction)); 1204 direction = Direction::DIRECTION270; 1205 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvas(canvas, direction)); 1206 direction = Direction::DIRECTION0; 1207 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationCanvas(canvas, direction)); 1208 } 1209 1210 /** 1211 * @tc.name: TouchDrawingManagerTest_DrawBubble 1212 * @tc.desc: Test DrawBubble 1213 * @tc.type: Function 1214 * @tc.require: 1215 */ 1216 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawBubble, TestSize.Level1) 1217 { 1218 CALL_TEST_DEBUG; 1219 TouchDrawingManager touchDrawingMgr; 1220 touchDrawingMgr.bubbleCanvasNode_ = Rosen::RSCanvasNode::Create(); 1221 touchDrawingMgr.pointerEvent_ = PointerEvent::Create(); 1222 ASSERT_NE(touchDrawingMgr.pointerEvent_, nullptr); 1223 PointerEvent::PointerItem item; 1224 item.SetPointerId(1); 1225 touchDrawingMgr.pointerEvent_->SetPointerId(1); 1226 touchDrawingMgr.pointerEvent_->AddPointerItem(item); 1227 touchDrawingMgr.pointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UP); 1228 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.DrawBubble()); 1229 touchDrawingMgr.pointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_UP); 1230 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.DrawBubble()); 1231 touchDrawingMgr.pointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL); 1232 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.DrawBubble()); 1233 } 1234 1235 /** 1236 * @tc.name: TouchDrawingManagerTest_DrawBubble_003 1237 * @tc.desc: Test DrawBubble 1238 * @tc.type: Function 1239 * @tc.require: 1240 */ 1241 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_DrawBubble_003, TestSize.Level1) 1242 { 1243 CALL_TEST_DEBUG; 1244 TouchDrawingManager touchDrawingMgr; 1245 touchDrawingMgr.bubbleCanvasNode_ = Rosen::RSCanvasNode::Create(); 1246 touchDrawingMgr.pointerEvent_ = PointerEvent::Create(); 1247 ASSERT_NE(touchDrawingMgr.pointerEvent_, nullptr); 1248 PointerEvent::PointerItem item; 1249 item.SetPointerId(1); 1250 touchDrawingMgr.pointerEvent_->AddPointerItem(item); 1251 touchDrawingMgr.pointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); 1252 item.SetPointerId(2); 1253 touchDrawingMgr.pointerEvent_->SetPointerId(2); 1254 touchDrawingMgr.pointerEvent_->AddPointerItem(item); 1255 EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.DrawBubble()); 1256 } 1257 1258 /** 1259 * @tc.name: TouchDrawingManagerTest_CalcDrawCoordinate_001 1260 * @tc.desc: Test CalcDrawCoordinate 1261 * @tc.type: Function 1262 * @tc.require: 1263 */ 1264 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_CalcDrawCoordinate_001, TestSize.Level1) 1265 { 1266 CALL_TEST_DEBUG; 1267 TouchDrawingManager touchDrawingMgr; 1268 DisplayInfo displayInfo; 1269 PointerEvent::PointerItem pointerItem; 1270 int32_t physicalX = 1; 1271 int32_t physicalY = 1; 1272 pointerItem.SetRawDisplayX(physicalX); 1273 pointerItem.SetRawDisplayY(physicalY); 1274 auto retPair = touchDrawingMgr.CalcDrawCoordinate(displayInfo, pointerItem); 1275 EXPECT_EQ(retPair.first, 1); 1276 EXPECT_EQ(retPair.second, 1); 1277 } 1278 1279 /** 1280 * @tc.name: TouchDrawingManagerTest_CalcDrawCoordinate_002 1281 * @tc.desc: Test CalcDrawCoordinate 1282 * @tc.type: Function 1283 * @tc.require: 1284 */ 1285 HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_CalcDrawCoordinate_002, TestSize.Level1) 1286 { 1287 CALL_TEST_DEBUG; 1288 TouchDrawingManager touchDrawingMgr; 1289 DisplayInfo displayInfo = { 1290 .id = 0, .x = 0, .y = 0, .width = 100, .height = 200, .dpi = 240, 1291 .transform = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f} 1292 }; 1293 PointerEvent::PointerItem pointerItem; 1294 int32_t physicalX = 10; 1295 int32_t physicalY = 10; 1296 pointerItem.SetRawDisplayX(physicalX); 1297 pointerItem.SetRawDisplayY(physicalY); 1298 auto retPair = touchDrawingMgr.CalcDrawCoordinate(displayInfo, pointerItem); 1299 EXPECT_EQ(retPair.first, 21); 1300 EXPECT_EQ(retPair.second, 21); 1301 } 1302 } // namespace MMI 1303 } // namespace OHOS 1304