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 "test/unittest/core/pipeline/pipeline_context_test_ng.h" 17 18 #define private public 19 #define protected public 20 #include "base/log/dump_log.h" 21 #include "core/interfaces/native/node/node_utils.h" 22 #include "core/components_ng/pattern/button/button_event_hub.h" 23 #include "core/components_ng/pattern/navigation/navigation_pattern.h" 24 #include "core/components_ng/pattern/navrouter/navdestination_group_node.h" 25 #include "test/mock/core/common/mock_container.h" 26 #include "test/unittest/core/pattern/scroll/mock_task_executor.h" 27 using namespace testing; 28 using namespace testing::ext; 29 30 namespace OHOS::Ace { 31 namespace NG { 32 namespace { 33 struct TouchTimeTestCase { 34 uint64_t vsyncTime; 35 uint64_t compensationValue; 36 std::vector<uint64_t> touchEventTimes; 37 uint32_t targetTouchEventSize; 38 uint32_t originTouchEventSize; 39 }; 40 41 const std::vector<TouchTimeTestCase> COLLECT_TOUCH_EVENTS_TESTCASES = { 42 { AFTER_VSYNC_TIME, BEFORE_VSYNC_TIME, { BEFORE_VSYNC_TIME, DEFAULT_VSYNC_TIME }, 2, 0 }, 43 { DEFAULT_VSYNC_TIME, 0, { BEFORE_VSYNC_TIME, DEFAULT_VSYNC_TIME }, 2, 0 }, 44 { DEFAULT_VSYNC_TIME, 0, { DEFAULT_VSYNC_TIME, AFTER_VSYNC_TIME }, 1, 1 }, 45 { DEFAULT_VSYNC_TIME, 0, { AFTER_VSYNC_TIME, AFTER_VSYNC_TIME }, 0, 2 }, 46 }; 47 48 const std::vector<TouchTimeTestCase> FLUSH_TOUCH_EVENTS_TESTCASES = { 49 { DEFAULT_VSYNC_TIME, 0, {}, 0, 0 }, 50 { DEFAULT_VSYNC_TIME, 0, { BEFORE_VSYNC_TIME }, 0, 1 }, 51 { DEFAULT_VSYNC_TIME, 0, { BEFORE_VSYNC_TIME, BEFORE_VSYNC_TIME }, 0, 2 }, 52 { DEFAULT_VSYNC_TIME, 0, { DEFAULT_VSYNC_TIME, AFTER_VSYNC_TIME }, 1, 2 }, 53 }; 54 55 } // namespace 56 /** 57 * @tc.name: PipelineContextTestNg036 58 * @tc.desc: Test RequestFocus. 59 * @tc.type: FUNC 60 */ 61 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg036, TestSize.Level1) 62 { 63 /** 64 * @tc.steps1: initialize parameters and make sure pointers are not null. 65 */ 66 ASSERT_NE(context_, nullptr); 67 ASSERT_NE(frameNode_, nullptr); 68 context_->rootNode_ = frameNode_; 69 auto eventHub = frameNode_->GetOrCreateEventHub<EventHub>(); 70 ASSERT_NE(eventHub, nullptr); 71 auto focusHub = eventHub->GetOrCreateFocusHub(); 72 ASSERT_NE(focusHub, nullptr); 73 frameNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); 74 auto frameNode_1 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); 75 eventHub->host_ = frameNode_1; 76 frameNode_1->UpdateInspectorId("123"); 77 78 /** 79 * @tc.steps3: change host_,focusType_,enabled_, 80 focusable_,parentFocusable_,currentFocus_ 81 */ 82 auto eventHub1 = frameNode_1->GetOrCreateEventHub<EventHub>(); 83 eventHub1->host_ = nullptr; 84 focusHub->focusType_ = FocusType::NODE; 85 eventHub->enabled_ = true; 86 focusHub->focusable_ = true; 87 focusHub->parentFocusable_ = true; 88 focusHub->currentFocus_ = true; 89 90 /** 91 * @tc.steps4: change isSubPipeline_ and call RequestFocus with empty string 92 * @tc.expect: RequestFocus empty string return false. 93 */ 94 context_->isSubPipeline_ = true; 95 auto rt = context_->RequestFocus(""); 96 EXPECT_FALSE(rt); 97 98 /** 99 * @tc.steps4: change isSubPipeline_ and call RequestFocus with empty string 100 * @tc.expect: RequestFocus empty string return false. 101 */ 102 context_->isSubPipeline_ = false; 103 rt = context_->RequestFocus(""); 104 EXPECT_FALSE(rt); 105 } 106 107 /** 108 * @tc.name: PipelineContextTestNg037 109 * @tc.desc: Test ExecuteSurfaceChangedCallbacks. 110 * @tc.type: FUNC 111 */ 112 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg037, TestSize.Level1) 113 { 114 /** 115 * @tc.steps1: initialize parameters and make sure pointers are not null. 116 set flag and creat callback then set into surfaceChangedCallbackMap_. 117 call ExecuteSurfaceChangedCallbacks. 118 * @tc.expect: flag turns true. 119 */ 120 ASSERT_NE(context_, nullptr); 121 bool flag = false; 122 auto callback = [&flag](int32_t input_1, int32_t input_2, int32_t input_3, int32_t input_4, __anonaf4252cb0202(int32_t input_1, int32_t input_2, int32_t input_3, int32_t input_4, WindowSizeChangeReason type) 123 WindowSizeChangeReason type) { flag = !flag; }; 124 context_->surfaceChangedCallbackMap_[0] = callback; 125 context_->surfaceChangedCallbackMap_[1] = nullptr; 126 context_->ExecuteSurfaceChangedCallbacks(0, 0, WindowSizeChangeReason::ROTATION); 127 EXPECT_TRUE(flag); 128 } 129 130 /** 131 * @tc.name: PipelineContextTestNg038 132 * @tc.desc: Test FlushWindowSizeChangeCallback. 133 * @tc.type: FUNC 134 */ 135 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg038, TestSize.Level1) 136 { 137 /** 138 * @tc.steps1: initialize parameters and make sure pointers are not null. 139 set onWindowSizeChangeCallbacks_. 140 * @tc.expect: the value -1 has been erased. 141 */ 142 ASSERT_NE(context_, nullptr); 143 context_->onWindowSizeChangeCallbacks_.emplace_back(-1); 144 ASSERT_NE(frameNode_, nullptr); 145 context_->onWindowSizeChangeCallbacks_.emplace_back(frameNode_->GetId()); 146 context_->FlushWindowSizeChangeCallback(0, 0, WindowSizeChangeReason::UNDEFINED); 147 EXPECT_EQ(context_->onWindowSizeChangeCallbacks_.size(), 1); 148 } 149 150 /** 151 * @tc.name: PipelineContextTestNg039 152 * @tc.desc: Test GetCurrentFrameInfo. 153 * @tc.type: FUNC 154 */ 155 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg039, TestSize.Level1) 156 { 157 /** 158 * @tc.steps1: initialize parameters and make sure pointers are not null. 159 set dumpFrameCount_ and dumpFrameInfos_. 160 * @tc.expect: the return value of GetCurrentFrameInfo is null. 161 */ 162 ASSERT_NE(context_, nullptr); 163 SystemProperties::dumpFrameCount_ = 1; 164 context_->dumpFrameInfos_.push_back({}); 165 auto rt = context_->GetCurrentFrameInfo(DEFAULT_UINT64_1, DEFAULT_UINT64_2); 166 context_->DumpPipelineInfo(); 167 EXPECT_NE(rt, nullptr); 168 } 169 170 /** 171 * @tc.name: PipelineContextTestNg041 172 * @tc.desc: Test the function OnLayoutCompleted. 173 * @tc.type: FUNC 174 */ 175 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg041, TestSize.Level1) 176 { 177 /** 178 * @tc.steps1: initialize parameters. 179 * @tc.expected: frontend-ptr is non-null. 180 */ 181 ContainerScope scope(DEFAULT_INSTANCE_ID); 182 ASSERT_NE(context_, nullptr); 183 auto frontend = AceType::MakeRefPtr<MockFrontend>(); 184 context_->weakFrontend_ = frontend; 185 186 /** 187 * @tc.steps2: test the function OnLayoutCompleted by TEST_TAG. 188 * @tc.expected: frontend componentId_ is TEST_TAG 189 */ 190 context_->OnLayoutCompleted(TEST_TAG); 191 EXPECT_EQ(frontend->GetComponentId(), TEST_TAG); 192 context_->weakFrontend_.Reset(); 193 } 194 195 /** 196 * @tc.name: PipelineContextTestNg042 197 * @tc.desc: Test the function OnDrawCompleted. 198 * @tc.type: FUNC 199 */ 200 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg042, TestSize.Level1) 201 { 202 /** 203 * @tc.steps1: initialize parameters. 204 * @tc.expected: frontend-ptr is non-null. 205 */ 206 207 ContainerScope scope(DEFAULT_INSTANCE_ID); 208 ASSERT_NE(context_, nullptr); 209 auto frontend = AceType::MakeRefPtr<MockFrontend>(); 210 context_->weakFrontend_ = frontend; 211 212 /** 213 * @tc.steps4: test the function OnDrawCompleted by TEST_TAG. 214 * @tc.expected: frontend componentId_ is TEST_TAG 215 */ 216 context_->OnDrawCompleted(TEST_TAG); 217 EXPECT_EQ(frontend->GetComponentId(), TEST_TAG); 218 context_->weakFrontend_.Reset(); 219 } 220 221 /** 222 * @tc.name: UITaskSchedulerTestNg001 223 * @tc.desc: Test FlushLayoutTask. 224 * @tc.type: FUNC 225 */ 226 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg001, TestSize.Level1) 227 { 228 /** 229 * @tc.steps1: Create taskScheduler. 230 */ 231 UITaskScheduler taskScheduler; 232 233 /** 234 * @tc.steps2: Create frameInfo and StartRecordFrameInfo. 235 */ 236 FrameInfo frameInfo; 237 taskScheduler.StartRecordFrameInfo(&frameInfo); 238 239 /** 240 * @tc.steps3: Create some frameNode. 241 */ 242 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, 1, nullptr); 243 frameNode->SetInDestroying(); 244 auto frameNode2 = FrameNode::GetOrCreateFrameNode(TEST_TAG, 2, nullptr); 245 246 /** 247 * @tc.steps4: Calling FlushLayoutTask with no layout. 248 * @tc.expected: frame info not record. 249 */ 250 taskScheduler.FlushLayoutTask(false); 251 EXPECT_EQ(frameInfo.layoutInfos_.size(), 0); 252 253 /** 254 * @tc.steps5: add some layoutNode and recall FlushLayoutTask with false . 255 * @tc.expected: frame info not record. 256 */ 257 taskScheduler.AddDirtyLayoutNode(frameNode); 258 taskScheduler.AddDirtyLayoutNode(frameNode2); 259 taskScheduler.FlushLayoutTask(false); 260 EXPECT_EQ(frameInfo.layoutInfos_.size(), 1); 261 262 /** 263 * @tc.steps6: add layoutNode again and set isLayoutDirtyMarked_ true and recall FlushLayoutTask with false . 264 * @tc.expected: frame info record true frameInfo.layoutInfos_.size is 2. 265 */ 266 taskScheduler.AddDirtyLayoutNode(frameNode2); 267 frameNode2->isLayoutDirtyMarked_ = true; 268 taskScheduler.FlushLayoutTask(false); 269 EXPECT_EQ(frameInfo.layoutInfos_.size(), 2); 270 271 /** 272 * @tc.steps7: add layoutNode again and call FlushLayoutTask with true . 273 * @tc.expected: frame info record true frameInfo.layoutInfos_.size is 3. 274 */ 275 taskScheduler.AddDirtyLayoutNode(frameNode2); 276 frameNode2->isLayoutDirtyMarked_ = true; 277 taskScheduler.FlushLayoutTask(true); 278 EXPECT_EQ(frameInfo.layoutInfos_.size(), 3); 279 280 /** 281 * @tc.steps8: finish FinishRecordFrameInfo and do step7. 282 * @tc.expected: frame info stop record frameInfo.layoutInfos_.size is 3. 283 */ 284 taskScheduler.FinishRecordFrameInfo(); 285 taskScheduler.AddDirtyLayoutNode(frameNode2); 286 frameNode2->isLayoutDirtyMarked_ = true; 287 taskScheduler.FlushLayoutTask(true); 288 EXPECT_EQ(frameInfo.layoutInfos_.size(), 3); 289 } 290 291 /** 292 * @tc.name: UITaskSchedulerTestNg002 293 * @tc.desc: Test FlushAfterLayoutTask. 294 * @tc.type: FUNC 295 */ 296 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg002, TestSize.Level1) 297 { 298 /** 299 * @tc.steps1: Create taskScheduler. 300 */ 301 UITaskScheduler taskScheduler; 302 303 /** 304 * @tc.steps2: Call FlushAfterLayoutTask. 305 */ 306 taskScheduler.FlushAfterLayoutTask(); 307 308 /** 309 * @tc.steps3: Call AddAfterLayoutTask. 310 * @tc.expected: afterLayoutTasks_ in the taskScheduler size is 2. 311 */ __anonaf4252cb0302() 312 taskScheduler.AddAfterLayoutTask([]() {}); 313 taskScheduler.AddAfterLayoutTask(nullptr); 314 EXPECT_EQ(taskScheduler.afterLayoutTasks_.size(), 2); 315 316 /** 317 * @tc.steps4: Call FlushTaskWithCheck. 318 * @tc.expected: afterLayoutTasks_ in the taskScheduler size is 0. 319 */ 320 taskScheduler.FlushTaskWithCheck(); 321 EXPECT_EQ(taskScheduler.afterLayoutTasks_.size(), 0); 322 } 323 324 /** 325 * @tc.name: UITaskSchedulerTestNg003 326 * @tc.desc: Test FlushAfterLayoutTask. 327 * @tc.type: FUNC 328 */ 329 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg003, TestSize.Level1) 330 { 331 /** 332 * @tc.steps1: Create taskScheduler. 333 */ 334 UITaskScheduler taskScheduler; 335 336 /** 337 * @tc.steps2: Call FlushPredictTask. 338 */ 339 taskScheduler.FlushPredictTask(0); 340 341 /** 342 * @tc.steps3: Call AddPredictTask. 343 * @tc.expected: predictTask_ in the taskScheduler size is 2. 344 */ __anonaf4252cb0402(int64_t, bool) 345 taskScheduler.AddPredictTask([](int64_t, bool) {}); 346 taskScheduler.AddPredictTask(nullptr); 347 EXPECT_EQ(taskScheduler.predictTask_.size(), 2); 348 349 /** 350 * @tc.steps4: Call FlushPredictTask. 351 * @tc.expected: predictTask_ in the taskScheduler size is 0. 352 */ 353 taskScheduler.FlushPredictTask(0); 354 EXPECT_EQ(taskScheduler.predictTask_.size(), 0); 355 } 356 357 /** 358 * @tc.name: UITaskSchedulerTestNg004 359 * @tc.desc: Test NeedAdditionalLayout. 360 * @tc.type: FUNC 361 */ 362 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg004, TestSize.Level1) 363 { 364 /** 365 * @tc.steps1: Create taskScheduler. 366 */ 367 UITaskScheduler taskScheduler; 368 369 /** 370 * @tc.steps2: Create some frameNode and configure the required parameters. 371 */ 372 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, 1, nullptr); 373 frameNode->layoutProperty_ = nullptr; 374 auto frameNode2 = FrameNode::GetOrCreateFrameNode(TEST_TAG, 2, nullptr); 375 376 /** 377 * @tc.steps3: Call AddDirtyLayoutNode with different parameters. 378 * @tc.expected: NeedAdditionalLayout return false. 379 */ 380 taskScheduler.AddDirtyLayoutNode(frameNode); 381 taskScheduler.AddDirtyLayoutNode(frameNode2); 382 EXPECT_FALSE(taskScheduler.NeedAdditionalLayout()); 383 384 /** 385 * @tc.steps4: Create a appropriate node and recall AddDirtyLayoutNode. 386 * @tc.expected: NeedAdditionalLayout return true. 387 */ 388 auto frameNode3 = FrameNode::GetOrCreateFrameNode(TEST_TAG, 3, nullptr); 389 auto geometryTransition = AceType::MakeRefPtr<NG::GeometryTransition>("test", frameNode3); 390 geometryTransition->hasOutAnim_ = true; 391 geometryTransition->inNode_ = frameNode2; 392 geometryTransition->outNode_ = frameNode3; 393 frameNode3->GetLayoutProperty()->geometryTransition_ = geometryTransition; 394 taskScheduler.AddDirtyLayoutNode(frameNode3); 395 EXPECT_TRUE(taskScheduler.NeedAdditionalLayout()); 396 taskScheduler.CleanUp(); 397 } 398 399 /** 400 * @tc.name: UITaskSchedulerTestNg005 401 * @tc.desc: Test FlushRenderTask. 402 * @tc.type: FUNC 403 */ 404 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg005, TestSize.Level1) 405 { 406 /** 407 * @tc.steps1: Create taskScheduler. 408 */ 409 UITaskScheduler taskScheduler; 410 411 /** 412 * @tc.steps2: Create frameInfo and StartRecordFrameInfo. 413 */ 414 FrameInfo frameInfo; 415 taskScheduler.StartRecordFrameInfo(&frameInfo); 416 417 /** 418 * @tc.steps3: Create some frameNode. 419 */ 420 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, 1, nullptr); 421 frameNode->SetInDestroying(); 422 taskScheduler.dirtyRenderNodes_[1].emplace(nullptr); 423 auto pattern = AceType::MakeRefPtr<Pattern>(); 424 auto frameNode2 = FrameNode::CreateFrameNode(TEST_TAG, 2, pattern); 425 426 /** 427 * @tc.steps4: Calling FlushRenderTask with no layout. 428 * @tc.expected: frame info not record. 429 */ 430 taskScheduler.FlushRenderTask(false); 431 432 /** 433 * @tc.steps5: add some layoutNode and recall FlushRenderTask with false . 434 * @tc.expected: frame info not record. 435 */ 436 taskScheduler.AddDirtyRenderNode(frameNode); 437 taskScheduler.AddDirtyRenderNode(frameNode2); 438 taskScheduler.FlushRenderTask(false); 439 EXPECT_EQ(frameInfo.renderInfos_.size(), 0); 440 } 441 442 /** 443 * @tc.name: UITaskSchedulerTestNg002 444 * @tc.desc: Test FlushAfterLayoutTask. 445 * @tc.type: FUNC 446 */ 447 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg006, TestSize.Level1) 448 { 449 /** 450 * @tc.steps1: Create taskScheduler. 451 */ 452 UITaskScheduler taskScheduler; 453 454 /** 455 * @tc.steps2: Call FlushAfterLayoutTask. 456 */ 457 taskScheduler.FlushAfterLayoutTask(); 458 459 /** 460 * @tc.steps3: Call AddAfterLayoutTask. 461 * @tc.expected: afterLayoutTasks_ in the taskScheduler size is 2. 462 */ __anonaf4252cb0502() 463 taskScheduler.AddPersistAfterLayoutTask([]() {}); 464 taskScheduler.AddPersistAfterLayoutTask(nullptr); 465 EXPECT_EQ(taskScheduler.persistAfterLayoutTasks_.size(), 2); 466 467 /** 468 * @tc.steps4: Call FlushTaskWithCheck. 469 * @tc.expected: afterLayoutTasks_ in the taskScheduler size is 0. 470 */ 471 taskScheduler.FlushTaskWithCheck(); 472 EXPECT_EQ(taskScheduler.afterLayoutTasks_.size(), 0); 473 } 474 475 /** 476 * @tc.name: PipelineContextTestNg044 477 * @tc.desc: Test the function FlushAnimation. 478 * @tc.type: FUNC 479 */ 480 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg044, TestSize.Level1) 481 { 482 /** 483 * @tc.steps1: initialize parameters. 484 * @tc.expected: All pointer is non-null. 485 */ 486 ASSERT_NE(context_, nullptr); 487 488 /** 489 * @tc.steps2: Call the function FlushAnimation with unempty scheduleTasks_. 490 * @tc.expected: The nanoTimestamp of scheduleTask is equal to NANO_TIME_STAMP. 491 */ 492 auto scheduleTask = AceType::MakeRefPtr<MockScheduleTask>(); 493 EXPECT_NE(scheduleTask->GetNanoTimestamp(), NANO_TIME_STAMP); 494 495 /** 496 * @tc.steps3: Call the function AddScheduleTask. 497 * @tc.expected: The scheduleTasks_ has the task id. 498 */ 499 auto id = context_->AddScheduleTask(scheduleTask); 500 EXPECT_EQ(context_->scheduleTasks_.count(id), 1); 501 502 /** 503 * @tc.steps4: Call the function RemoveScheduleTask. 504 * @tc.expected: The scheduleTasks_ does not have the task id. 505 */ 506 context_->RemoveScheduleTask(id); 507 EXPECT_EQ(context_->scheduleTasks_.count(id), 0); 508 } 509 510 /** 511 * @tc.name: PipelineContextTestNg045 512 * @tc.desc: Test the function FlushAnimation. 513 * @tc.type: FUNC 514 */ 515 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg045, TestSize.Level1) 516 { 517 /** 518 * @tc.steps1: initialize parameters. 519 * @tc.expected: All pointer is non-null. 520 */ 521 ASSERT_NE(context_, nullptr); 522 ASSERT_TRUE(context_->needRenderNode_.empty()); 523 /** 524 * @tc.steps2: Call the function FlushAnimation with unempty scheduleTasks_. 525 * @tc.expected: The nanoTimestamp of scheduleTask is equal to NANO_TIME_STAMP. 526 */ 527 auto pattern = AceType::MakeRefPtr<Pattern>(); 528 auto frameNode = FrameNode::CreateFrameNode(TEST_TAG, 3, pattern); 529 context_->SetNeedRenderNode(WeakPtr<FrameNode>(frameNode)); 530 EXPECT_EQ(context_->needRenderNode_.count(WeakPtr<FrameNode>(frameNode)), 1); 531 532 /** 533 * @tc.steps3: Call the function FlushPipelineImmediately. 534 * @tc.expected: The nanoTimestamp of scheduleTask is equal to NANO_TIME_STAMP. 535 */ 536 context_->FlushPipelineImmediately(); 537 EXPECT_TRUE(context_->isRebuildFinished_); 538 } 539 540 /** 541 * @tc.name: PipelineContextTestNg046 542 * @tc.desc: Test the function AddAnimationClosure and FlushAnimationClosure. 543 * @tc.type: FUNC 544 */ 545 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg046, TestSize.Level1) 546 { 547 /** 548 * @tc.steps1: initialize parameters. 549 * @tc.expected: All pointer is non-null. 550 */ 551 ASSERT_NE(context_, nullptr); 552 /** 553 * @tc.steps2: call AddAnimationClosure. 554 * @tc.expected: The animationClosuresList_ has 1 element. 555 */ __anonaf4252cb0602() 556 auto mockAnimation = []() -> void {}; 557 context_->AddAnimationClosure(mockAnimation); 558 EXPECT_EQ(context_->animationClosuresList_.size(), 1); 559 /** 560 * @tc.steps3: call FlushAnimationClosure. 561 * @tc.expected: The animationClosuresList_ has 1 element. 562 */ 563 context_->FlushAnimationClosure(); 564 EXPECT_TRUE(context_->animationClosuresList_.empty()); 565 } 566 567 /** 568 * @tc.name: PipelineContextTestNg046 569 * @tc.desc: Test the function GetStageManager. 570 * @tc.type: FUNC 571 */ 572 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg047, TestSize.Level1) 573 { 574 /** 575 * @tc.steps1: initialize parameters. 576 * @tc.expected: All pointer is non-null. 577 */ 578 ASSERT_NE(context_, nullptr); 579 /** 580 * @tc.steps2: call GetStageManager. 581 * @tc.expected: The stageManager is not null. 582 */ 583 context_->SetupRootElement(); 584 auto stageManager = context_->GetStageManager(); 585 EXPECT_NE(stageManager, nullptr); 586 } 587 588 /** 589 * @tc.name: PipelineContextTestNg048 590 * @tc.desc: Test the function GetSelectOverlayManager. 591 * @tc.type: FUNC 592 */ 593 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg048, TestSize.Level1) 594 { 595 /** 596 * @tc.steps1: initialize parameters. 597 * @tc.expected: All pointer is non-null. 598 */ 599 ASSERT_NE(context_, nullptr); 600 /** 601 * @tc.steps2: call SetupRootElement. 602 * @tc.expected: The selectOverlayManager is not null. 603 */ 604 context_->SetupRootElement(); 605 auto selectOverlayManager = context_->GetSelectOverlayManager(); 606 EXPECT_NE(selectOverlayManager, nullptr); 607 } 608 609 /** 610 * @tc.name: PipelineContextTestNg049 611 * @tc.desc: Test the function GetFullScreenManager. 612 * @tc.type: FUNC 613 */ 614 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg049, TestSize.Level1) 615 { 616 /** 617 * @tc.steps1: initialize parameters. 618 * @tc.expected: All pointer is non-null. 619 */ 620 ASSERT_NE(context_, nullptr); 621 /** 622 * @tc.steps2: call GetFullScreenManager. 623 * @tc.expected: The fullScreenManager is not null. 624 */ 625 context_->SetupRootElement(); 626 auto fullScreenManager = context_->GetFullScreenManager(); 627 EXPECT_NE(fullScreenManager, nullptr); 628 } 629 630 /** 631 * @tc.name: PipelineContextTestNg050 632 * @tc.desc: Test the function UpdateSystemSafeArea and UpdateCutoutSafeArea. 633 * @tc.type: FUNC 634 */ 635 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg050, TestSize.Level1) 636 { 637 /** 638 * @tc.steps1: initialize parameters. 639 * @tc.expected: All pointer is non-null. 640 */ 641 ASSERT_NE(context_, nullptr); 642 /** 643 * @tc.steps2: call AddAnimationClosure. 644 * @tc.expected: The GetFullScreenManager is not null. 645 */ 646 context_->SetMinPlatformVersion(10); 647 SafeAreaInsets::Inset left { 0, 1 }; 648 SafeAreaInsets::Inset top { 0, 2 }; 649 SafeAreaInsets::Inset right { 0, 3 }; 650 SafeAreaInsets::Inset bottom { 0, 4 }; 651 SafeAreaInsets safeAreaInsets(left, top, right, bottom); 652 context_->UpdateSystemSafeArea(safeAreaInsets); 653 EXPECT_EQ(context_->safeAreaManager_->systemSafeArea_, safeAreaInsets); 654 655 context_->UpdateCutoutSafeArea(safeAreaInsets); 656 EXPECT_NE(context_->safeAreaManager_->cutoutSafeArea_, safeAreaInsets); 657 658 context_->UpdateNavSafeArea(safeAreaInsets); 659 660 EXPECT_EQ(context_->safeAreaManager_->navSafeArea_, safeAreaInsets); 661 662 context_->SetIsLayoutFullScreen(true); 663 context_->SetIsLayoutFullScreen(false); 664 context_->SetIsNeedAvoidWindow(true); 665 context_->SetIsNeedAvoidWindow(false); 666 EXPECT_TRUE(context_->IsEnableKeyBoardAvoidMode()); 667 } 668 669 /** 670 * @tc.name: PipelineContextTestNg051 671 * @tc.desc: Test the function SetIgnoreViewSafeArea. 672 * @tc.type: FUNC 673 */ 674 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg051, TestSize.Level1) 675 { 676 /** 677 * @tc.steps1: initialize parameters. 678 * @tc.expected: All pointer is non-null. 679 */ 680 ASSERT_NE(context_, nullptr); 681 /** 682 * @tc.steps2: call SetIgnoreViewSafeArea. 683 * @tc.expected: The ignoreSafeArea_ is true. 684 */ 685 context_->safeAreaManager_->ignoreSafeArea_ = false; 686 context_->SetIgnoreViewSafeArea(true); 687 EXPECT_TRUE(context_->safeAreaManager_->ignoreSafeArea_); 688 } 689 690 /** 691 * @tc.name: PipelineContextTestNg052 692 * @tc.desc: Test the function SyncSafeArea. 693 * @tc.type: FUNC 694 */ 695 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg052, TestSize.Level1) 696 { 697 /** 698 * @tc.steps1: initialize parameters. 699 * @tc.expected: All pointer is non-null. 700 */ 701 ASSERT_NE(context_, nullptr); 702 /** 703 * @tc.steps2: call SyncSafeArea. 704 * @tc.expected: The isLayoutDirtyMarked_ is true. 705 */ 706 context_->SetupRootElement(); 707 auto frameNodeId = ElementRegister::GetInstance()->MakeUniqueId(); 708 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId, nullptr); 709 context_->safeAreaManager_->AddGeoRestoreNode(frameNode); 710 context_->SyncSafeArea(SafeAreaSyncType::SYNC_TYPE_NONE); 711 EXPECT_TRUE(frameNode->isLayoutDirtyMarked_); 712 } 713 714 /** 715 * @tc.name: PipelineContextTestNg053 716 * @tc.desc: Test the function FindNavigationNodeToHandleBack. 717 * @tc.type: FUNC 718 */ 719 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg053, TestSize.Level1) 720 { 721 /** 722 * @tc.steps1: initialize parameters. 723 * @tc.expected: All pointer is non-null. 724 */ 725 ASSERT_NE(context_, nullptr); 726 /** 727 * @tc.steps2: call FindNavigationNodeToHandleBack. 728 * @tc.expected: The ret is nullptr. 729 */ 730 context_->SetupRootElement(); 731 auto nodeId = ElementRegister::GetInstance()->MakeUniqueId(); 732 auto navigationStack = AceType::MakeRefPtr<NavigationStack>(); 733 auto node = NavigationGroupNode::GetOrCreateGroupNode( __anonaf4252cb0702() 734 TEST_TAG, nodeId, []() { return AceType::MakeRefPtr<NavigationPattern>(); }); 735 node->GetPattern<NavigationPattern>()->SetNavigationStack(std::move(navigationStack)); 736 auto childId = ElementRegister::GetInstance()->MakeUniqueId(); 737 auto childNode = NavigationGroupNode::GetOrCreateGroupNode( __anonaf4252cb0802() 738 TEST_TAG, childId, []() { return AceType::MakeRefPtr<NavigationPattern>(); }); 739 childNode->GetPattern<NavigationPattern>()->SetNavigationStack(std::move(navigationStack)); 740 node->AddChild(childNode); 741 context_->GetNavigationController(std::to_string(nodeId)); 742 context_->AddOrReplaceNavigationNode(std::to_string(childId), AceType::WeakClaim(AceType::RawPtr(childNode))); 743 context_->DeleteNavigationNode(std::to_string(childId)); 744 context_->AddNavigationNode(nodeId, AceType::WeakClaim(AceType::RawPtr(node))); 745 context_->RemoveNavigationNode(nodeId, nodeId); 746 context_->FirePageChanged(nodeId, false); 747 bool isEntry = false; 748 EXPECT_EQ(context_->FindNavigationNodeToHandleBack(node, isEntry), nullptr); 749 } 750 751 /** 752 * @tc.name: PipelineContextTestNg054 753 * @tc.desc: Test the function AddAfterLayoutTask and AddAfterRenderTask. 754 * @tc.type: FUNC 755 */ 756 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg054, TestSize.Level1) 757 { 758 /** 759 * @tc.steps1: initialize parameters. 760 * @tc.expected: All pointer is non-null. 761 */ 762 ASSERT_NE(context_, nullptr); 763 /** 764 * @tc.steps2: call AddAfterLayoutTask. 765 * @tc.expected: The afterLayoutTasks_ size is 1. 766 */ 767 context_->SetupRootElement(); __anonaf4252cb0902() 768 context_->AddAfterLayoutTask([]() -> void {}); 769 EXPECT_EQ(context_->taskScheduler_->afterLayoutTasks_.size(), 1); 770 /** 771 * @tc.steps3: call AddAfterLayoutTask. 772 * @tc.expected: The afterLayoutTasks_ size is 1. 773 */ 774 context_->taskScheduler_->afterRenderTasks_.clear(); __anonaf4252cb0a02() 775 context_->AddAfterRenderTask([]() -> void {}); 776 EXPECT_EQ(context_->taskScheduler_->afterRenderTasks_.size(), 1); 777 } 778 779 /** 780 * @tc.name: PipelineContextTestNg055 781 * @tc.desc: Test the function AddFontNodeNG and RemoveFontNodeNG. 782 * @tc.type: FUNC 783 */ 784 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg055, TestSize.Level1) 785 { 786 /** 787 * @tc.steps1: initialize parameters. 788 * @tc.expected: All pointer is non-null. 789 */ 790 ASSERT_NE(context_, nullptr); 791 /** 792 * @tc.steps2: call AddFontNodeNG. 793 * @tc.expected: fontNodesNG_.size() is 1. 794 */ 795 context_->SetupRootElement(); 796 context_->fontManager_ = AceType::MakeRefPtr<MockFontManager>(); 797 auto fontNodeId = ElementRegister::GetInstance()->MakeUniqueId(); 798 auto fontNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, fontNodeId, nullptr); 799 context_->AddFontNodeNG(fontNode); 800 EXPECT_EQ(context_->GetFontManager()->fontNodesNG_.size(), 1); 801 /** 802 * @tc.steps2: call RemoveFontNodeNG. 803 * @tc.expected: fontNodesNG_.size() is 0. 804 */ 805 context_->RemoveFontNodeNG(fontNode); 806 EXPECT_EQ(context_->GetFontManager()->fontNodesNG_.size(), 0); 807 } 808 809 /** 810 * @tc.name: PipelineContextTestNg056 811 * @tc.desc: Test the function AddFontNodeNG and RemoveFontNodeNG. 812 * @tc.type: FUNC 813 */ 814 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg056, TestSize.Level1) 815 { 816 /** 817 * @tc.steps1: initialize parameters. 818 * @tc.expected: All pointer is non-null. 819 */ 820 ASSERT_NE(context_, nullptr); 821 /** 822 * @tc.steps2: call IsWindowSceneConsumed. 823 * @tc.expected: The return is false. 824 */ 825 context_->SetupRootElement(); 826 EXPECT_FALSE(context_->IsWindowSceneConsumed()); 827 /** 828 * @tc.steps2: call SetWindowSceneConsumed(true) and IsWindowSceneConsumed. 829 * @tc.expected: The return is true. 830 */ 831 context_->SetWindowSceneConsumed(true); 832 EXPECT_TRUE(context_->IsWindowSceneConsumed()); 833 } 834 835 /** 836 * @tc.name: PipelineContextTestNg057 837 * @tc.desc: Test the function AddFontNodeNG and RemoveFontNodeNG. 838 * @tc.type: FUNC 839 */ 840 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg057, TestSize.Level1) 841 { 842 /** 843 * @tc.steps1: initialize parameters. 844 * @tc.expected: All pointer is non-null. 845 */ 846 ASSERT_NE(context_, nullptr); 847 848 auto needRenderNodeId = ElementRegister::GetInstance()->MakeUniqueId(); 849 auto needRenderNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, needRenderNodeId, nullptr); 850 context_->SetNeedRenderNode(WeakPtr<FrameNode>(needRenderNode)); 851 EXPECT_EQ(context_->needRenderNode_.count(WeakPtr<FrameNode>(needRenderNode)), 1); 852 context_->InspectDrew(); 853 EXPECT_EQ(context_->needRenderNode_.count(WeakPtr<FrameNode>(needRenderNode)), 0); 854 } 855 856 /** 857 * @tc.name: PipelineContextTestNg058 858 * @tc.desc: Test the function FlushMouseEventG. 859 * @tc.type: FUNC 860 */ 861 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg058, TestSize.Level1) 862 { 863 /** 864 * @tc.steps1: initialize parameters. 865 * @tc.expected: pointer is non-null. 866 */ 867 ASSERT_NE(context_, nullptr); 868 869 /** 870 * @tc.steps2: Call the function FlushMouseEvent with default action. 871 * @tc.expected: The function is called and cover branch mouseAction is not WINDOW_LEAVE. 872 */ 873 context_->lastMouseEvent_ = std::make_unique<MouseEvent>(); 874 context_->FlushMouseEvent(); 875 auto result = context_->lastMouseEvent_->action == MouseAction::WINDOW_LEAVE; 876 EXPECT_FALSE(result); 877 878 /** 879 * @tc.steps3: Call the function FlushMouseEvent with lastMouseEvent_ is nullptr. 880 * @tc.expected: The function is called and cover branch lastMouseEvent_ is nullptr. 881 */ 882 context_->lastMouseEvent_ = nullptr; 883 context_->FlushMouseEvent(); 884 EXPECT_EQ(context_->lastMouseEvent_, nullptr); 885 886 /** 887 * @tc.steps4: Call the function FlushMouseEvent with mouseAction is WINDOW_LEAVE. 888 * @tc.expected: The function is called and cover branch mouseAction is WINDOW_LEAVE. 889 */ 890 context_->lastMouseEvent_ = std::make_unique<MouseEvent>(); 891 context_->lastMouseEvent_->action = MouseAction::WINDOW_LEAVE; 892 context_->FlushMouseEvent(); 893 result = context_->lastMouseEvent_->action == MouseAction::WINDOW_LEAVE; 894 EXPECT_TRUE(result); 895 } 896 897 /** 898 * @tc.name: PipelineContextTestNg059 899 * @tc.desc: Test the function OnIdle. 900 * @tc.type: FUNC 901 */ 902 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg059, TestSize.Level1) 903 { 904 /** 905 * @tc.steps1: initialize parameters. 906 * @tc.expected: All pointer is non-null. 907 */ 908 ASSERT_NE(context_, nullptr); 909 910 /** 911 * @tc.steps2: Call the function OnIdle with canUseLongPredictTask_. 912 * @tc.expected: called OnIdle and cover branch canUseLongPredictTask_ is true. 913 */ 914 context_->canUseLongPredictTask_ = true; 915 context_->OnIdle(1); 916 EXPECT_TRUE(context_->touchEvents_.empty()); 917 918 /** 919 * @tc.steps3: Call the function OnIdle with touchEvents_ is not empty. 920 * @tc.expected: The value of flagCbk changed. 921 */ 922 bool flagCbk = false; __anonaf4252cb0b02(int64_t, bool) 923 context_->AddPredictTask([&flagCbk](int64_t, bool) { flagCbk = true; }); 924 TouchEvent event; 925 event.id = RENDER_EVENT_ID; 926 context_->touchEvents_.push_back(event); 927 context_->canUseLongPredictTask_ = true; 928 context_->OnIdle(2); 929 EXPECT_TRUE(flagCbk); 930 } 931 932 /** 933 * @tc.name: PipelineContextTestNg063 934 * @tc.desc: Test the function OpenFrontendAnimation and CloseFrontendAnimation. 935 * @tc.type: FUNC 936 */ 937 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg063, TestSize.Level1) 938 { 939 decltype(context_->pendingFrontendAnimation_) temp; 940 std::swap(context_->pendingFrontendAnimation_, temp); 941 /** 942 * @tc.steps1: Call CloseFrontAnimation directly. 943 * @tc.expected: No animation is generated. The pending flag stack is empty. 944 */ 945 context_->CloseFrontendAnimation(); 946 EXPECT_EQ(context_->pendingFrontendAnimation_.size(), 0); 947 /** 948 * @tc.steps2: Call OpenFrontendAnimation. 949 * @tc.expected: A pending flag is pushed to the stack. 950 */ 951 AnimationOption option(Curves::EASE, 1000); 952 context_->OpenFrontendAnimation(option, option.GetCurve(), nullptr); 953 EXPECT_TRUE(context_->HasPendingAnimation()); 954 /** 955 * @tc.steps3: Call CloseFrontendAnimation after OpenFrontendAnimation. 956 * @tc.expected: The pending flag is out of stack. 957 */ 958 context_->CloseFrontendAnimation(); 959 EXPECT_TRUE(!context_->HasPendingAnimation()); 960 } 961 962 /** 963 * @tc.name: PipelineContextTestNg064 964 * @tc.desc: Test history and current. 965 * @tc.type: FUNC 966 */ 967 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg064, TestSize.Level1) 968 { 969 /** 970 * @tc.steps1: history and current timestamps are equal to nanoTimeStamp 971 * @tc.expected: Expect the result to be (0.0, 0.0) 972 */ 973 AvgPoint history_fs = { 974 .x = 1.0f, 975 .y = 2.0f, 976 .time = 1000 977 }; 978 AvgPoint current_fs = { 979 .x = 2.0f, 980 .y = 2.0f, 981 .time = 2000 982 }; 983 uint64_t nanoTimeStampFs = 1000; 984 auto result_fs = ResampleAlgo::LinearInterpolation(history_fs, current_fs, nanoTimeStampFs); 985 EXPECT_EQ(result_fs.x, 0.0f); 986 EXPECT_EQ(result_fs.y, 0.0f); 987 EXPECT_EQ(result_fs.inputXDeltaSlope, 0.0f); 988 EXPECT_EQ(result_fs.inputYDeltaSlope, 0.0f); 989 990 /** 991 * @tc.steps2: history and current timestamps are equal to nanoTimeStamp 992 * @tc.expected: Expect the result to be (0.0, 0.0) 993 */ 994 AvgPoint history_se = { 995 .x = 1.0f, 996 .y = 1.0f, 997 .time = 2000 998 }; 999 AvgPoint current_se = { 1000 .x = 2.0f, 1001 .y = 2.0f, 1002 .time = 1000 1003 }; 1004 uint64_t nanoTimeStampSe = 1500; 1005 auto result_se = ResampleAlgo::LinearInterpolation(history_se, current_se, nanoTimeStampSe); 1006 EXPECT_EQ(result_se.x, 0.0f); 1007 EXPECT_EQ(result_se.y, 0.0f); 1008 EXPECT_EQ(result_se.inputXDeltaSlope, 0.0f); 1009 EXPECT_EQ(result_se.inputYDeltaSlope, 0.0f); 1010 1011 /** 1012 * @tc.steps3: history and current timestamps are equal to nanoTimeStamp 1013 * @tc.expected: Expect the result to be (1.75, 1.75) 1014 */ 1015 AvgPoint history_th = { 1016 .x = 1.0f, 1017 .y = 1.0f, 1018 .time = 1000 1019 }; 1020 AvgPoint current_th = { 1021 .x = 2.0f, 1022 .y = 2.0f, 1023 .time = 3000 1024 }; 1025 uint64_t nanoTimeStampTh = 2500; 1026 auto result_th = ResampleAlgo::LinearInterpolation(history_th, current_th, nanoTimeStampTh); 1027 EXPECT_EQ(result_th.x, 1.75f); 1028 EXPECT_EQ(result_th.y, 1.75f); 1029 EXPECT_EQ(result_th.inputXDeltaSlope, 500000.0f); 1030 EXPECT_EQ(result_th.inputYDeltaSlope, 500000.0f); 1031 } 1032 1033 /** 1034 * @tc.name: PipelineContextTestNg065 1035 * @tc.desc: Test history and current. 1036 * @tc.type: FUNC 1037 */ 1038 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg065, TestSize.Level1) 1039 { 1040 /** 1041 * @tc.steps1: GetResampleCoord illegal value verification 1042 * @tc.expected: All result is 0.0f. 1043 */ 1044 std::vector<TouchEvent> emptyHistory; 1045 std::vector<TouchEvent> emptyCurrent; 1046 uint64_t nanoTimeStamp = 1234567890; 1047 auto result = ResampleAlgo::GetResampleCoord(std::vector<PointerEvent>(emptyHistory.begin(), emptyHistory.end()), 1048 std::vector<PointerEvent>(emptyCurrent.begin(), emptyCurrent.end()), nanoTimeStamp, CoordinateType::NORMAL); 1049 EXPECT_FLOAT_EQ(0.0f, result.x); 1050 EXPECT_FLOAT_EQ(0.0f, result.y); 1051 auto timeStampAce = TimeStamp(std::chrono::nanoseconds(1000)); 1052 emptyHistory.push_back(TouchEvent {}.SetX(100.0f).SetY(200.0f).SetTime(timeStampAce)); 1053 result = ResampleAlgo::GetResampleCoord(std::vector<PointerEvent>(emptyHistory.begin(), emptyHistory.end()), 1054 std::vector<PointerEvent>(emptyCurrent.begin(), emptyCurrent.end()), nanoTimeStamp, CoordinateType::SCREEN); 1055 EXPECT_FLOAT_EQ(0.0f, result.x); 1056 EXPECT_FLOAT_EQ(0.0f, result.y); 1057 emptyHistory.clear(); 1058 auto timeStampTwo = TimeStamp(std::chrono::nanoseconds(2000)); 1059 emptyCurrent.push_back(TouchEvent {}.SetX(200.0f).SetY(300.0f).SetTime(timeStampTwo)); 1060 result = ResampleAlgo::GetResampleCoord(std::vector<PointerEvent>(emptyHistory.begin(), emptyHistory.end()), 1061 std::vector<PointerEvent>(emptyCurrent.begin(), emptyCurrent.end()), nanoTimeStamp, 1062 CoordinateType::GLOBALDISPLAY); 1063 EXPECT_FLOAT_EQ(0.0f, result.x); 1064 EXPECT_FLOAT_EQ(0.0f, result.y); 1065 auto timeStampThree = TimeStamp(std::chrono::nanoseconds(3000)); 1066 emptyCurrent.push_back(TouchEvent {}.SetX(300.0f).SetY(200.0f).SetTime(timeStampThree)); 1067 auto illegalType = static_cast<CoordinateType>(999); 1068 result = ResampleAlgo::GetResampleCoord(std::vector<PointerEvent>(emptyHistory.begin(), emptyHistory.end()), 1069 std::vector<PointerEvent>(emptyCurrent.begin(), emptyCurrent.end()), nanoTimeStamp, illegalType); 1070 EXPECT_FLOAT_EQ(0.0f, result.x); 1071 EXPECT_FLOAT_EQ(0.0f, result.y); 1072 } 1073 1074 /** 1075 * @tc.name: PipelineContextTestNg066 1076 * @tc.desc: Test history and current. 1077 * @tc.type: FUNC 1078 */ 1079 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg066, TestSize.Level1) 1080 { 1081 auto timeStampAce = TimeStamp(std::chrono::nanoseconds(1000)); 1082 auto timeStampTwo = TimeStamp(std::chrono::nanoseconds(2000)); 1083 auto timeStampThree = TimeStamp(std::chrono::nanoseconds(3000)); 1084 auto timeStampFour = TimeStamp(std::chrono::nanoseconds(2000)); 1085 std::vector<TouchEvent> history; 1086 history.push_back(TouchEvent {}.SetX(100.0f).SetY(200.0f).SetTime(timeStampAce)); 1087 history.push_back(TouchEvent {}.SetX(150.0f).SetY(250.0f).SetTime(timeStampTwo)); 1088 std::vector<TouchEvent> current; 1089 current.push_back(TouchEvent {}.SetX(200.0f).SetY(300.0f).SetTime(timeStampThree)); 1090 current.push_back(TouchEvent {}.SetX(250.0f).SetY(350.0f).SetTime(timeStampFour)); 1091 1092 auto resampledCoord = ResampleAlgo::GetResampleCoord(std::vector<PointerEvent>(history.begin(), history.end()), 1093 std::vector<PointerEvent>(current.begin(), current.end()), 30000000, CoordinateType::SCREEN); 1094 1095 ASSERT_FLOAT_EQ(200.0f, resampledCoord.x); 1096 ASSERT_FLOAT_EQ(300.0f, resampledCoord.y); 1097 1098 SystemProperties::debugEnabled_ = true; 1099 resampledCoord = ResampleAlgo::GetResampleCoord(std::vector<PointerEvent>(history.begin(), history.end()), 1100 std::vector<PointerEvent>(current.begin(), current.end()), 2500, CoordinateType::SCREEN); 1101 ASSERT_FLOAT_EQ(0.0f, resampledCoord.x); 1102 ASSERT_FLOAT_EQ(0.0f, resampledCoord.y); 1103 } 1104 1105 /** 1106 * @tc.name: PipelineContextTestNg067 1107 * @tc.desc: Test history and current. 1108 * @tc.type: FUNC 1109 */ 1110 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg067, TestSize.Level1) 1111 { 1112 /** 1113 * @tc.steps1: nanoTimeStamp is less than history timestamp 1114 * @tc.expected: Expect the result to be (0.0, 0.0) 1115 */ 1116 AvgPoint history_for = { 1117 .x = 1.0f, 1118 .y = 1.0f, 1119 .time = 1000 1120 }; 1121 AvgPoint current_for = { 1122 .x = 2.0f, 1123 .y = 2.0f, 1124 .time = 2000 1125 }; 1126 uint64_t nanoTimeStampFor = 500; 1127 auto result_for = ResampleAlgo::LinearInterpolation(history_for, current_for, nanoTimeStampFor); 1128 EXPECT_EQ(result_for.x, 0.0f); 1129 EXPECT_EQ(result_for.y, 0.0f); 1130 EXPECT_EQ(result_for.inputXDeltaSlope, 0.0f); 1131 EXPECT_EQ(result_for.inputYDeltaSlope, 0.0f); 1132 1133 /** 1134 * @tc.steps2: nanoTimeStamp is less than current timestamp 1135 * @tc.expected: Expect non-zero value 1136 */ 1137 AvgPoint history_fie = { 1138 .x = 1.0f, 1139 .y = 1.0f, 1140 .time = 1000 1141 }; 1142 AvgPoint current_fie = { 1143 .x = 2.0f, 1144 .y = 2.0f, 1145 .time = 2000 1146 }; 1147 uint64_t nanoTimeStampFie = 1500; 1148 auto result_fie = ResampleAlgo::LinearInterpolation(history_fie, current_fie, nanoTimeStampFie); 1149 EXPECT_NE(result_fie.x, 0.0f); 1150 EXPECT_NE(result_fie.y, 0.0f); 1151 EXPECT_NE(result_fie.inputXDeltaSlope, 0.0f); 1152 EXPECT_NE(result_fie.inputYDeltaSlope, 0.0f); 1153 1154 /** 1155 * @tc.steps3: nanoTimeStamp is greater than current timestamp 1156 * @tc.expected: Expect non-zero value 1157 */ 1158 AvgPoint history_six = { 1159 .x = 1.0f, 1160 .y = 1.0f, 1161 .time = 1000 1162 }; 1163 AvgPoint current_six = { 1164 .x = 2.0f, 1165 .y = 2.0f, 1166 .time = 2000 1167 }; 1168 uint64_t nanoTimeStampSix = 2500; 1169 auto result_six = ResampleAlgo::LinearInterpolation(history_six, current_six, nanoTimeStampSix); 1170 EXPECT_NE(result_six.x, 0.0f); 1171 EXPECT_NE(result_six.y, 0.0f); 1172 EXPECT_NE(result_six.inputXDeltaSlope, 0.0f); 1173 EXPECT_NE(result_six.inputYDeltaSlope, 0.0f); 1174 } 1175 1176 /** 1177 * @tc.name: PipelineContextTestNg068 1178 * @tc.desc: Test history and current. 1179 * @tc.type: FUNC 1180 */ 1181 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg068, TestSize.Level1) 1182 { 1183 auto timeStampAce = TimeStamp(std::chrono::nanoseconds(1000)); 1184 auto timeStampTwo = TimeStamp(std::chrono::nanoseconds(2000)); 1185 std::vector<TouchEvent> current; 1186 current.push_back(TouchEvent {}.SetX(100.0f).SetY(200.0f).SetTime(timeStampAce)); 1187 current.push_back(TouchEvent {}.SetX(150.0f).SetY(250.0f).SetTime(timeStampTwo)); 1188 uint64_t nanoTimeStamp = 1500; 1189 1190 TouchEvent latestPoint = context_->eventManager_->GetLatestPoint(current, nanoTimeStamp); 1191 1192 ASSERT_FLOAT_EQ(100.0f, latestPoint.x); 1193 ASSERT_FLOAT_EQ(200.0f, latestPoint.y); 1194 } 1195 1196 /** 1197 * @tc.name: PipelineContextTestNg069 1198 * @tc.desc: Test history and current. 1199 * @tc.type: FUNC 1200 */ 1201 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg069, TestSize.Level1) 1202 { 1203 auto timeStampAce = TimeStamp(std::chrono::nanoseconds(1000)); 1204 auto timeStampTwo = TimeStamp(std::chrono::nanoseconds(2000)); 1205 auto timeStampThree = TimeStamp(std::chrono::nanoseconds(3000)); 1206 auto timeStampFour = TimeStamp(std::chrono::nanoseconds(4000)); 1207 std::vector<TouchEvent> history; 1208 history.push_back(TouchEvent {}.SetX(100.0f).SetY(200.0f).SetTime(timeStampAce)); 1209 history.push_back(TouchEvent {}.SetX(150.0f).SetY(250.0f).SetTime(timeStampTwo)); 1210 std::vector<TouchEvent> current; 1211 current.push_back(TouchEvent {}.SetX(200.0f).SetY(300.0f).SetTime(timeStampThree)); 1212 current.push_back(TouchEvent {}.SetX(250.0f).SetY(350.0f).SetTime(timeStampFour)); 1213 uint64_t nanoTimeStamp = 2500; 1214 1215 TouchEvent resampledTouchEvent; 1216 context_->eventManager_->GetResampleTouchEvent(history, current, 1217 nanoTimeStamp, resampledTouchEvent); 1218 1219 ASSERT_FLOAT_EQ(175.0f, resampledTouchEvent.x); 1220 ASSERT_FLOAT_EQ(275.0f, resampledTouchEvent.y); 1221 } 1222 1223 /** 1224 * @tc.name: PipelineContextTestNg070 1225 * @tc.desc: Test GetLatestPoint. 1226 * @tc.type: FUNC 1227 */ 1228 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg070, TestSize.Level1) 1229 { 1230 std::vector<TouchEvent> events; 1231 1232 TouchEvent event; 1233 event.time = TimeStamp(std::chrono::nanoseconds(1000)); 1234 events.push_back(event); 1235 1236 TouchEvent result = context_->eventManager_->GetLatestPoint(events, 1000); 1237 ASSERT_EQ(static_cast<uint64_t>(result.time.time_since_epoch().count()), 1000); 1238 } 1239 1240 /** 1241 * @tc.name: PipelineContextTestNg071 1242 * @tc.desc: Test GetLatestPoint. 1243 * @tc.type: FUNC 1244 */ 1245 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg071, TestSize.Level1) 1246 { 1247 std::vector<TouchEvent> events; 1248 1249 TouchEvent eventAce; 1250 eventAce.time = TimeStamp(std::chrono::nanoseconds(2000)); 1251 events.push_back(eventAce); 1252 1253 TouchEvent eventTwo; 1254 eventTwo.time = TimeStamp(std::chrono::nanoseconds(3000)); 1255 events.push_back(eventTwo); 1256 1257 uint64_t nanoTimeStamp = 1500; 1258 1259 TouchEvent result = context_->eventManager_->GetLatestPoint(events, nanoTimeStamp); 1260 ASSERT_GT(static_cast<uint64_t>(result.time.time_since_epoch().count()), nanoTimeStamp); 1261 } 1262 1263 /** 1264 * @tc.name: PipelineContextTestNg072 1265 * @tc.desc: Test GetLatestPoint. 1266 * @tc.type: FUNC 1267 */ 1268 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg072, TestSize.Level1) 1269 { 1270 std::vector<TouchEvent> events; 1271 1272 TouchEvent eventAce; 1273 eventAce.time = TimeStamp(std::chrono::nanoseconds(500)); 1274 events.push_back(eventAce); 1275 1276 TouchEvent eventTwo; 1277 eventTwo.time = TimeStamp(std::chrono::nanoseconds(1000)); 1278 events.push_back(eventTwo); 1279 1280 uint64_t nanoTimeStamp = 1500; 1281 1282 TouchEvent result = context_->eventManager_->GetLatestPoint(events, nanoTimeStamp); 1283 ASSERT_LT(static_cast<uint64_t>(result.time.time_since_epoch().count()), nanoTimeStamp); 1284 } 1285 1286 /** 1287 * @tc.name: PipelineContextTestNg073 1288 * @tc.desc: Test the function GetSafeArea and GetSafeAreaWithoutProcess. 1289 * @tc.type: FUNC 1290 */ 1291 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg073, TestSize.Level1) 1292 { 1293 /** 1294 * @tc.steps1: initialize parameters. 1295 * @tc.expected: All pointer is non-null. 1296 */ 1297 ASSERT_NE(context_, nullptr); 1298 /** 1299 * @tc.steps2: call UpdateSystemSafeArea and SetIgnoreViewSafeArea, then check the value of GetSafeArea 1300 and GetSafeAreaWithoutProcess. 1301 * @tc.expected: The GetSafeArea is empty, and the GetSafeAreaWithoutProcess is systemSafeArea. 1302 */ 1303 SafeAreaInsets::Inset left { 0, 1 }; 1304 SafeAreaInsets::Inset top { 0, 2 }; 1305 SafeAreaInsets::Inset right { 0, 3 }; 1306 SafeAreaInsets::Inset bottom { 0, 4 }; 1307 SafeAreaInsets safeAreaInsets(left, top, right, bottom); 1308 1309 SafeAreaInsets::Inset inset {}; 1310 SafeAreaInsets emptySafeAreaInsets(inset, inset, inset, inset); 1311 1312 context_->UpdateSystemSafeArea(safeAreaInsets); 1313 context_->SetIgnoreViewSafeArea(true); 1314 1315 EXPECT_EQ(context_->safeAreaManager_->GetSafeArea(), emptySafeAreaInsets); 1316 } 1317 1318 /** 1319 * @tc.name: PipelineContextTestNg074 1320 * @tc.desc: Test the function SetOnceVsyncListener. 1321 * @tc.type: FUNC 1322 */ 1323 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg074, TestSize.Level1) 1324 { 1325 /** 1326 * @tc.steps1: initialize parameters. 1327 * @tc.expected: All pointer is non-null. 1328 */ 1329 ASSERT_NE(context_, nullptr); 1330 1331 /** 1332 * @tc.steps2: Set a non-null function to context. 1333 * @tc.expected: The onceVsyncListener_ is non-null. 1334 */ 1335 bool flag = false; __anonaf4252cb0c02() 1336 auto getVsyncFunc = [&flag]() { flag = !flag; }; 1337 context_->SetOnceVsyncListener(getVsyncFunc); 1338 EXPECT_TRUE(context_->HasOnceVsyncListener()); 1339 1340 /** 1341 * @tc.steps2: Set a null function to context. 1342 * @tc.expected: The onceVsyncListener_ is null. 1343 */ 1344 context_->SetOnceVsyncListener(nullptr); 1345 EXPECT_FALSE(context_->HasOnceVsyncListener()); 1346 } 1347 1348 /** 1349 * @tc.name: PipelineContextTestNg075 1350 * @tc.desc: Test the function FlushOnceVsyncTask. 1351 * @tc.type: FUNC 1352 */ 1353 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg075, TestSize.Level1) 1354 { 1355 /** 1356 * @tc.steps1: initialize parameters. 1357 * @tc.expected: All pointer is non-null. 1358 */ 1359 ASSERT_NE(context_, nullptr); 1360 1361 /** 1362 * @tc.steps2: Set a non-null function to context and call FlushOnceVsyncTask. 1363 * @tc.expected: The onceVsyncListener_ is null and flag changes to true. 1364 */ 1365 bool flag = false; __anonaf4252cb0d02() 1366 auto getVsyncFunc = [&flag]() { flag = !flag; }; 1367 context_->SetOnceVsyncListener(getVsyncFunc); 1368 context_->FlushOnceVsyncTask(); 1369 EXPECT_FALSE(context_->HasOnceVsyncListener()); 1370 EXPECT_TRUE(flag); 1371 1372 /** 1373 * @tc.steps2: Set a non-null function to context and call FlushOnceVsyncTask. 1374 * @tc.expected: The onceVsyncListener_ is null and flag is still true. 1375 */ 1376 context_->SetOnceVsyncListener(nullptr); 1377 context_->FlushOnceVsyncTask(); 1378 EXPECT_FALSE(context_->HasOnceVsyncListener()); 1379 EXPECT_TRUE(flag); 1380 } 1381 1382 /** 1383 + * @tc.name: PipelineContextTestNg076 1384 + * @tc.desc: Test the function GetMainPipelineContext and NeedSoftKeyboard. 1385 + * @tc.type: FUNC 1386 + */ 1387 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg076, TestSize.Level1) 1388 { 1389 /** 1390 * @tc.steps1: initialize parameters. 1391 * @tc.expected: All pointer is non-null. 1392 */ 1393 ASSERT_NE(context_, nullptr); 1394 /** 1395 * @tc.steps2: Get current pipeline 1396 * @tc.expected: pipeline is not null. 1397 */ 1398 auto pipeline = PipelineContext::GetMainPipelineContext(); 1399 EXPECT_NE(pipeline, nullptr); 1400 EXPECT_FALSE(pipeline->NeedSoftKeyboard()); 1401 auto frameNode = FrameNode::GetOrCreateFrameNode("test", 10, nullptr); 1402 EXPECT_FALSE(pipeline->NeedSoftKeyboard()); 1403 1404 /** 1405 * @tc.steps3: Get current pipeline through the Container 1406 * @tc.expected: pipeline is null. 1407 */ __anonaf4252cb0e02(FoldStatus folderStatus) 1408 pipeline->foldStatusChangedCallbackMap_.emplace(1, [](FoldStatus folderStatus) {}); 1409 pipeline->foldStatusChangedCallbackMap_.emplace(2, nullptr); __anonaf4252cb0f02(FoldDisplayMode foldDisplayMode) 1410 pipeline->foldDisplayModeChangedCallbackMap_.emplace(1, [](FoldDisplayMode foldDisplayMode) {}); 1411 pipeline->foldDisplayModeChangedCallbackMap_.emplace(2, nullptr); 1412 pipeline->transformHintChangedCallbackMap_.emplace(1, nullptr); __anonaf4252cb1002(uint32_t num) 1413 pipeline->transformHintChangedCallbackMap_.emplace(2, [](uint32_t num) {}); 1414 pipeline->OnFoldStatusChange(FoldStatus::EXPAND); 1415 pipeline->OnFoldDisplayModeChange(FoldDisplayMode::FULL); 1416 pipeline->OnTransformHintChanged(0); 1417 EXPECT_NE(PipelineContext::GetContextByContainerId(0), nullptr); 1418 pipeline->AddDirtyPropertyNode(frameNode); 1419 EXPECT_TRUE(pipeline->hasIdleTasks_); 1420 DelayedTask delayedTask; 1421 pipeline->delayedTasks_.push_back(delayedTask); 1422 DelayedTask delayedTask1; 1423 delayedTask1.timeStamp = GetSysTimestamp(); 1424 delayedTask1.time = 1; 1425 pipeline->delayedTasks_.push_back(delayedTask1); 1426 pipeline->ProcessDelayTasks(); 1427 EXPECT_EQ(pipeline->delayedTasks_.size(), 1); 1428 } 1429 1430 /** 1431 + * @tc.name: PipelineContextTestNg077 1432 + * @tc.desc: Test the function HandleFocusNode. 1433 + * @tc.type: FUNC 1434 + */ 1435 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg077, TestSize.Level1) 1436 { 1437 /** 1438 * @tc.steps1: Get current pipeline 1439 * @tc.expected: pipeline is null. 1440 */ 1441 auto pipeline = PipelineContext::GetMainPipelineContext(); 1442 EXPECT_NE(pipeline, nullptr); 1443 1444 /** 1445 * @tc.steps2: Changing node information affects the return results. 1446 * @tc.expected:return frameNode is not null. 1447 */ 1448 auto frameNode = FrameNode::GetOrCreateFrameNode("test", 5, nullptr); 1449 auto frameNode1 = FrameNode::GetOrCreateFrameNode("test", 6, nullptr); 1450 auto frameNode2 = FrameNode::GetOrCreateFrameNode("test", 7, nullptr); 1451 frameNode->GetOrCreateFocusHub(); 1452 frameNode1->GetOrCreateFocusHub()->currentFocus_ = false; 1453 frameNode2->GetOrCreateFocusHub()->currentFocus_ = true; 1454 frameNode1->GetOrCreateFocusHub()->SetFocusType(FocusType::NODE); 1455 frameNode2->GetOrCreateFocusHub()->SetFocusType(FocusType::NODE); 1456 frameNode->AddChild(frameNode1); 1457 frameNode->AddChild(frameNode2); 1458 pipeline->SetScreenNode(frameNode); 1459 frameNode1->GetOrCreateFocusHub()->currentFocus_ = true; 1460 auto frameNode3 = FrameNode::GetOrCreateFrameNode("test", 8, nullptr); 1461 auto frameNode4 = FrameNode::GetOrCreateFrameNode("test", 9, nullptr); 1462 frameNode2->AddChild(frameNode3); 1463 frameNode2->AddChild(frameNode4); 1464 frameNode2->GetOrCreateFocusHub()->focusable_ = true; 1465 frameNode3->GetOrCreateFocusHub()->currentFocus_ = false; 1466 frameNode4->GetOrCreateFocusHub()->currentFocus_ = true; 1467 frameNode4->GetOrCreateFocusHub()->focusable_ = false; 1468 frameNode3->GetOrCreateFocusHub()->SetFocusType(FocusType::NODE); 1469 frameNode4->GetOrCreateFocusHub()->SetFocusType(FocusType::NODE); 1470 } 1471 1472 /** 1473 + * @tc.name: PipelineContextTestNg078 1474 + * @tc.desc: Test the function HandleFocusNode. 1475 + * @tc.type: FUNC 1476 + */ 1477 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg078, TestSize.Level1) 1478 { 1479 /** 1480 * @tc.steps1: Get current pipeline 1481 * @tc.expected: pipeline is not null. 1482 */ 1483 auto pipeline = PipelineContext::GetMainPipelineContext(); 1484 EXPECT_NE(pipeline, nullptr); 1485 auto frameNode = FrameNode::GetOrCreateFrameNode("test", 5, nullptr); 1486 pipeline->StartFullToMultWindowAnimation(DEFAULT_INT3, DEFAULT_INT3, WindowSizeChangeReason::RECOVER); 1487 pipeline->StartFullToMultWindowAnimation(DEFAULT_INT3, DEFAULT_INT3, WindowSizeChangeReason::FULL_TO_FLOATING); 1488 pipeline->AvoidanceLogic(0.0); 1489 EXPECT_EQ(pipeline->finishFunctions_.size(), 0); 1490 auto viewDataWrap = ViewDataWrap::CreateViewDataWrap(); 1491 EXPECT_FALSE(pipeline->DumpPageViewData(nullptr, viewDataWrap)); 1492 EXPECT_FALSE(pipeline->DumpPageViewData(frameNode, viewDataWrap)); 1493 EXPECT_FALSE(pipeline->CheckNeedAutoSave()); 1494 pipeline->NotifyFillRequestSuccess(AceAutoFillType::ACE_DETAIL_INFO_WITHOUT_STREET, viewDataWrap); 1495 pipeline->NotifyFillRequestFailed(frameNode, 101); 1496 1497 /** 1498 * @tc.steps2: Partial addition of function execution. 1499 * @tc.expected:Change the state of the pipeline. 1500 */ 1501 pipeline->ContainerModalUnFocus(); 1502 pipeline->windowModal_ = WindowModal::NORMAL; 1503 pipeline->SetContainerModalTitleHeight(0); 1504 pipeline->UpdateTitleInTargetPos(false, 0); 1505 pipeline->SetContainerModalTitleVisible(false, true); 1506 pipeline->SetCloseButtonStatus(false); 1507 pipeline->GetContainerModalTitleHeight(); 1508 pipeline->windowModal_ = WindowModal::CONTAINER_MODAL; 1509 pipeline->GetContainerModalTitleHeight(); 1510 pipeline->ContainerModalUnFocus(); 1511 pipeline->UpdateTitleInTargetPos(false, 0); 1512 pipeline->SetCloseButtonStatus(true); 1513 pipeline->SetContainerModalTitleVisible(true, false); 1514 pipeline->SetContainerModalTitleHeight(0); 1515 pipeline->SetAppBgColor(Color::BLACK); 1516 auto frameNode1 = FrameNode::GetOrCreateFrameNode("test", 6, nullptr); 1517 pipeline->activeNode_ = AceType::WeakClaim(AceType::RawPtr(frameNode1)); 1518 pipeline->GetCurrentExtraInfo(); 1519 } 1520 1521 /** 1522 * @tc.name: PipelineContextTestNg074 1523 * @tc.desc: Test the function SetFontScale. 1524 * @tc.type: FUNC 1525 */ 1526 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg079, TestSize.Level1) 1527 { 1528 /** 1529 * @tc.steps1: initialize parameters. 1530 * @tc.expected: All pointer is non-null. 1531 */ 1532 ASSERT_NE(context_, nullptr); 1533 1534 float fontScale = 1.2f; 1535 context_->SetFontScale(fontScale); 1536 ASSERT_EQ(context_->fontScale_, fontScale); 1537 } 1538 1539 /** 1540 * @tc.name: PipelineContextTestNg075 1541 * @tc.desc: Test the function SetFontWeightScale. 1542 * @tc.type: FUNC 1543 */ 1544 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg080, TestSize.Level1) 1545 { 1546 /** 1547 * @tc.steps1: initialize parameters. 1548 * @tc.expected: All pointer is non-null. 1549 */ 1550 ASSERT_NE(context_, nullptr); 1551 1552 float fontWeightScale = 1.2f; 1553 context_->SetFontWeightScale(fontWeightScale); 1554 ASSERT_EQ(context_->fontWeightScale_, fontWeightScale); 1555 } 1556 1557 /** 1558 * @tc.name: PipelineContextTestNg081 1559 * @tc.desc: Test the function CheckNeedUpdateBackgroundColor. 1560 * @tc.type: FUNC 1561 */ 1562 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg081, TestSize.Level1) 1563 { 1564 /** 1565 * @tc.step1: Set pipelineContext attribute isFormRender_ and renderingMode_. 1566 * @tc.expected: Render alphaValue is not equal to 75. 1567 */ 1568 context_->isFormRender_ = false; 1569 context_->renderingMode_ = RENDERINGMODE_SINGLE_COLOR; 1570 Color color; 1571 context_->CheckNeedUpdateBackgroundColor(color); 1572 uint32_t alphaValue = color.GetAlpha(); 1573 ASSERT_NE(alphaValue, 75); 1574 } 1575 1576 /** 1577 * @tc.name: PipelineContextTestNg082 1578 * @tc.desc: Test the function CheckNeedUpdateBackgroundColor. 1579 * @tc.type: FUNC 1580 */ 1581 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg082, TestSize.Level1) 1582 { 1583 /** 1584 * @tc.step1: Set pipelineContext attribute isFormRender_ and renderingMode_. 1585 * @tc.expected: Render alphaValue is not equal to 75. 1586 */ 1587 context_->isFormRender_ = true; 1588 context_->renderingMode_ = RENDERINGMODE_FULL_COLOR; 1589 Color color; 1590 context_->CheckNeedUpdateBackgroundColor(color); 1591 uint32_t alphaValue = color.GetAlpha(); 1592 ASSERT_NE(alphaValue, 75); 1593 } 1594 1595 /** 1596 * @tc.name: PipelineContextTestNg083 1597 * @tc.desc: Test the function CheckNeedUpdateBackgroundColor. 1598 * @tc.type: FUNC 1599 */ 1600 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg083, TestSize.Level1) 1601 { 1602 /** 1603 * @tc.step1: Set pipelineContext attribute isFormRender_ and renderingMode_. 1604 * @tc.expected: Render alphaValue is equal to 75. 1605 */ 1606 context_->isFormRender_ = true; 1607 context_->renderingMode_ = RENDERINGMODE_SINGLE_COLOR; 1608 Color color; 1609 context_->CheckNeedUpdateBackgroundColor(color); 1610 uint32_t alphaValue = color.GetAlpha(); 1611 ASSERT_EQ(alphaValue, 75); 1612 } 1613 1614 /** 1615 * @tc.name: PipelineContextTestNg084 1616 * @tc.desc: Test the function CheckNeedDisableUpdateBackgroundImage. 1617 * @tc.type: FUNC 1618 */ 1619 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg084, TestSize.Level1) 1620 { 1621 /** 1622 * @tc.step1: Set pipelineContext attribute isFormRender_ and renderingMode_. 1623 * @tc.expected: No update background image. 1624 */ 1625 context_->isFormRender_ = false; 1626 context_->renderingMode_ = RENDERINGMODE_SINGLE_COLOR; 1627 bool isUpdateBGIamge = context_->CheckNeedDisableUpdateBackgroundImage(); 1628 ASSERT_NE(isUpdateBGIamge, true); 1629 } 1630 1631 /** 1632 * @tc.name: PipelineContextTestNg085 1633 * @tc.desc: Test the function CheckNeedDisableUpdateBackgroundImage. 1634 * @tc.type: FUNC 1635 */ 1636 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg085, TestSize.Level1) 1637 { 1638 /** 1639 * @tc.step1: Set pipelineContext attribute isFormRender_ and renderingMode_. 1640 * @tc.expected: No update background image. 1641 */ 1642 context_->isFormRender_ = true; 1643 context_->renderingMode_ = RENDERINGMODE_FULL_COLOR; 1644 bool isUpdateBGIamge = context_->CheckNeedDisableUpdateBackgroundImage(); 1645 ASSERT_NE(isUpdateBGIamge, true); 1646 } 1647 1648 /** 1649 * @tc.name: PipelineContextTestNg086 1650 * @tc.desc: Test the function CheckNeedDisableUpdateBackgroundImage. 1651 * @tc.type: FUNC 1652 */ 1653 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg086, TestSize.Level1) 1654 { 1655 /** 1656 * @tc.step1: Set pipelineContext attribute isFormRender_ and renderingMode_. 1657 * @tc.expected: Update background image. 1658 */ 1659 context_->isFormRender_ = true; 1660 context_->renderingMode_ = RENDERINGMODE_SINGLE_COLOR; 1661 bool isUpdateBGIamge = context_->CheckNeedDisableUpdateBackgroundImage(); 1662 ASSERT_EQ(isUpdateBGIamge, true); 1663 } 1664 1665 /** 1666 * @tc.name: PipelineContextTestNg087 1667 * @tc.desc: Test the function ClearNode. 1668 * @tc.type: FUNC 1669 */ 1670 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg087, TestSize.Level1) 1671 { 1672 /** 1673 * @tc.steps1: initialize parameters. 1674 * @tc.expected: All pointer is non-null. 1675 */ 1676 ASSERT_NE(context_, nullptr); 1677 context_->dirtyPropertyNodes_.emplace(frameNode_); 1678 context_->needRenderNode_.emplace(WeakPtr<FrameNode>(frameNode_)); 1679 context_->dirtyFocusNode_ = frameNode_; 1680 context_->dirtyFocusScope_ = frameNode_; 1681 context_->dirtyRequestFocusNode_ = frameNode_; 1682 context_->activeNode_ = frameNode_; 1683 context_->focusNode_ = frameNode_; 1684 1685 /** 1686 * @tc.step2: detach framenode. 1687 */ 1688 context_->DetachNode(frameNode_); 1689 1690 EXPECT_NE(context_->dirtyPropertyNodes_.count(frameNode_), 1); 1691 EXPECT_NE(context_->needRenderNode_.count(WeakPtr<FrameNode>(frameNode_)), 1); 1692 EXPECT_NE(context_->dirtyFocusNode_, frameNode_); 1693 EXPECT_NE(context_->dirtyFocusScope_, frameNode_); 1694 EXPECT_NE(context_->dirtyRequestFocusNode_, frameNode_); 1695 EXPECT_NE(context_->activeNode_, frameNode_); 1696 EXPECT_NE(context_->focusNode_, frameNode_); 1697 } 1698 1699 /** 1700 * @tc.name: UITaskSchedulerTestNg007 1701 * @tc.desc: Test AddLayoutNode. 1702 * @tc.type: FUNC 1703 */ 1704 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg007, TestSize.Level1) 1705 { 1706 /** 1707 * @tc.steps1: Create taskScheduler add layoutNode. 1708 */ 1709 UITaskScheduler taskScheduler; 1710 auto layoutNode = AceType::MakeRefPtr<FrameNode>("test", -1, AceType::MakeRefPtr<Pattern>(), false); 1711 1712 /** 1713 * @tc.steps2: Call AddLayoutNode. 1714 * @tc.expected: taskScheduler.layoutNodes_.size() = 1 1715 */ 1716 taskScheduler.AddLayoutNode(layoutNode); 1717 EXPECT_EQ(taskScheduler.layoutNodes_.size(), 1); 1718 } 1719 1720 /** 1721 * @tc.name: UITaskSchedulerTestNg008 1722 * @tc.desc: SetLayoutNodeRect 1723 * @tc.type: FUNC 1724 */ 1725 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg008, TestSize.Level1) 1726 { 1727 /** 1728 * @tc.steps: step1. prepare the environment variables for the function. 1729 */ 1730 UITaskScheduler taskScheduler; 1731 auto layoutNode = AceType::MakeRefPtr<FrameNode>("test", -1, AceType::MakeRefPtr<Pattern>(), false); 1732 taskScheduler.AddLayoutNode(layoutNode); 1733 layoutNode->isFind_ = true; 1734 1735 /** 1736 * @tc.steps: step2. test SetLayoutNodeRect. 1737 */ 1738 taskScheduler.SetLayoutNodeRect(); 1739 EXPECT_EQ(layoutNode->isFind_, false); 1740 } 1741 1742 /** 1743 * @tc.name: UITaskSchedulerTestNg009 1744 * @tc.desc: AddDirtyRenderNode 1745 * @tc.type: FUNC 1746 */ 1747 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg009, TestSize.Level1) 1748 { 1749 /** 1750 * @tc.steps: step1. prepare the environment variables for the function. 1751 */ 1752 UITaskScheduler taskScheduler; 1753 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, 1, nullptr); 1754 taskScheduler.dirtyRenderNodes_.clear(); 1755 1756 /** 1757 * @tc.steps: step2. test AddDirtyRenderNode. 1758 */ 1759 taskScheduler.AddDirtyRenderNode(frameNode); 1760 taskScheduler.AddDirtyRenderNode(frameNode); 1761 EXPECT_TRUE(DumpLog::GetInstance().result_.find("Fail to emplace")); 1762 } 1763 1764 /** 1765 * @tc.name: UITaskSchedulerTestNg010 1766 * @tc.desc: FlushLayoutTask 1767 * @tc.type: FUNC 1768 */ 1769 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg010, TestSize.Level1) 1770 { 1771 /** 1772 * @tc.steps: step1. prepare the environment variables for the function. 1773 */ 1774 UITaskScheduler taskScheduler; 1775 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, 1, nullptr); 1776 taskScheduler.AddDirtyLayoutNode(frameNode); 1777 taskScheduler.isLayouting_ = true; 1778 1779 /** 1780 * @tc.steps: step2. test FlushLayoutTask. 1781 */ 1782 taskScheduler.FlushLayoutTask(false); 1783 EXPECT_TRUE(DumpLog::GetInstance().result_.find("you are already")); 1784 } 1785 1786 1787 /** 1788 * @tc.name: UITaskSchedulerTestNg012 1789 * @tc.desc: FlushTaskWithCheck 1790 * @tc.type: FUNC 1791 */ 1792 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg012, TestSize.Level1) 1793 { 1794 /** 1795 * @tc.steps: step1. prepare the environment variables for the function. 1796 */ 1797 UITaskScheduler taskScheduler; 1798 int record = taskScheduler.multiLayoutCount_; 1799 taskScheduler.isLayouting_ = true; 1800 1801 /** 1802 * @tc.steps: step2. test FlushTaskWithCheck. 1803 */ 1804 taskScheduler.FlushTaskWithCheck(); 1805 EXPECT_EQ(record + 1, taskScheduler.multiLayoutCount_); 1806 } 1807 1808 /** 1809 * @tc.name: UITaskSchedulerTestNg013 1810 * @tc.desc: FlushAllSingleNodeTasks、RequestFrameOnLayoutCountExceeds、FlushPersistAfterLayoutTask 1811 * @tc.type: FUNC 1812 */ 1813 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg013, TestSize.Level1) 1814 { 1815 /** 1816 * @tc.steps: step1. prepare the environment variables for the function and test FlushAllSingleNodeTasks. 1817 */ 1818 UITaskScheduler taskScheduler; 1819 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, 1, nullptr); 1820 taskScheduler.AddSingleNodeToFlush(frameNode); 1821 taskScheduler.FlushAllSingleNodeTasks(); 1822 1823 /** 1824 * @tc.steps: step2. test FlushPersistAfterLayoutTask. 1825 */ __anonaf4252cb1102() 1826 taskScheduler.AddPersistAfterLayoutTask([]() {}); 1827 taskScheduler.AddPersistAfterLayoutTask(nullptr); 1828 taskScheduler.FlushPersistAfterLayoutTask(); 1829 1830 /** 1831 * @tc.steps: step3. set the variables to meet the conditional values and test RequestFrameOnLayoutCountExceeds. 1832 */ 1833 UITaskScheduler taskScheduler2; 1834 RefPtr<NG::UINode> previewCustomNode = NG::ViewStackProcessor::GetInstance()->Finish(); 1835 ElementRegister::GetInstance()->AddUINode(previewCustomNode); 1836 NG::FrameNode* frameNode2 = ElementRegister::GetInstance()->GetFrameNodePtrById(1); 1837 taskScheduler2.AddSafeAreaPaddingProcessTask(frameNode2); 1838 taskScheduler2.FlushSafeAreaPaddingProcess(); 1839 taskScheduler.RequestFrameOnLayoutCountExceeds(); 1840 } 1841 1842 /** 1843 * @tc.name: UITaskSchedulerTestNg014 1844 * @tc.desc: FlushSafeAreaPaddingProcess 1845 * @tc.type: FUNC 1846 */ 1847 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg014, TestSize.Level1) 1848 { 1849 /** 1850 * @tc.steps: step1. prepare the environment variables for the function. 1851 */ 1852 UITaskScheduler taskScheduler; 1853 RefPtr<NG::UINode> previewCustomNode = NG::ViewStackProcessor::GetInstance()->Finish(); 1854 ElementRegister::GetInstance()->AddUINode(previewCustomNode); 1855 NG::FrameNode* frameNode = ElementRegister::GetInstance()->GetFrameNodePtrById(1); 1856 1857 /** 1858 * @tc.steps: step1. test FlushSafeAreaPaddingProcess. 1859 */ 1860 taskScheduler.AddSafeAreaPaddingProcessTask(frameNode); 1861 taskScheduler.FlushSafeAreaPaddingProcess(); 1862 bool isempty = taskScheduler.safeAreaPaddingProcessTasks_.empty(); 1863 EXPECT_EQ(isempty, true); 1864 } 1865 1866 /** 1867 * @tc.name: UITaskSchedulerTestNg015 1868 * @tc.desc: Test FlushAfterModifierTask. 1869 * @tc.type: FUNC 1870 */ 1871 HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg015, TestSize.Level1) 1872 { 1873 /** 1874 * @tc.steps1: Create taskScheduler. 1875 */ 1876 UITaskScheduler taskScheduler; 1877 1878 /** 1879 * @tc.steps2: Call FlushAfterModifierTask. 1880 */ 1881 taskScheduler.FlushAfterModifierTask(); 1882 1883 /** 1884 * @tc.steps3: Call FlushAfterModifierTask. 1885 * @tc.expected: afterModifierTasks_ in the taskScheduler size is 2. 1886 */ __anonaf4252cb1202() 1887 taskScheduler.AddAfterModifierTask([]() {}); 1888 taskScheduler.AddAfterModifierTask(nullptr); 1889 EXPECT_EQ(taskScheduler.afterModifierTasks_.size(), 2); 1890 1891 /** 1892 * @tc.steps4: Call FlushAfterModifierTask. 1893 * @tc.expected: afterModifierTasks_ in the taskScheduler size is 0. 1894 */ 1895 taskScheduler.FlushAfterModifierTask(); 1896 EXPECT_EQ(taskScheduler.afterModifierTasks_.size(), 0); 1897 } 1898 1899 /** 1900 * @tc.name: TestAddIgnoreLayoutSafeAreaBundle 1901 * @tc.desc: Test AddIgnoreLayoutSafeAreaBundle 1902 * @tc.type: FUNC 1903 */ 1904 HWTEST_F(PipelineContextTestNg, TestAddIgnoreLayoutSafeAreaBundle, TestSize.Level0) 1905 { 1906 UITaskScheduler taskScheduler; 1907 taskScheduler.AddIgnoreLayoutSafeAreaBundle(IgnoreLayoutSafeAreaBundle()); 1908 taskScheduler.AddIgnoreLayoutSafeAreaBundle(IgnoreLayoutSafeAreaBundle()); 1909 taskScheduler.AddIgnoreLayoutSafeAreaBundle(IgnoreLayoutSafeAreaBundle()); 1910 1911 EXPECT_EQ(taskScheduler.ignoreLayoutSafeAreaBundles_.size(), 3); 1912 } 1913 1914 /** 1915 * @tc.name: PipelineContextTestNg097 1916 * @tc.desc: Test the function RegisterTouchEventListener 1917 * @tc.type: FUNC 1918 */ 1919 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg097, TestSize.Level1) 1920 { 1921 /** 1922 * @tc.steps1: initialize parameters,construct changeInfoListeners_ 1923 */ 1924 std::shared_ptr<ITouchEventCallback> touchEventCallback = nullptr; 1925 context_->RegisterTouchEventListener(touchEventCallback); 1926 ASSERT_EQ(context_->listenerVector_.size(), 0); 1927 } 1928 1929 /** 1930 * @tc.name: PipelineContextTestNg098 1931 * @tc.desc: Test the function AddChangedFrameNode 1932 * @tc.type: FUNC 1933 */ 1934 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg098, TestSize.Level1) 1935 { 1936 /** 1937 * @tc.steps1: AddChangedFrameNode 1938 */ 1939 auto frameNode = AceType::MakeRefPtr<FrameNode>("test1", -1, AceType::MakeRefPtr<Pattern>(), false); 1940 EXPECT_FALSE(context_->AddChangedFrameNode(frameNode)); 1941 context_->CleanNodeChangeFlag(); 1942 EXPECT_FALSE(context_->AddChangedFrameNode(frameNode)); 1943 } 1944 1945 /** 1946 * @tc.name: PipelineContextTestNg099 1947 * @tc.desc: Test the function AddFrameNodeChangeListener 1948 * @tc.type: FUNC 1949 */ 1950 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg099, TestSize.Level1) 1951 { 1952 /** 1953 * @tc.steps1: AddFrameNodeChangeListener 1954 */ 1955 auto frameNode = AceType::MakeRefPtr<FrameNode>("test1", -1, AceType::MakeRefPtr<Pattern>(), false); 1956 context_->AddFrameNodeChangeListener(frameNode); 1957 context_->FlushNodeChangeFlag(); 1958 EXPECT_EQ(context_->changeInfoListeners_.size(), 1); 1959 context_->AddFrameNodeChangeListener(frameNode); 1960 EXPECT_EQ(context_->changeInfoListeners_.size(), 1); 1961 context_->RemoveFrameNodeChangeListener(frameNode); 1962 context_->FlushNodeChangeFlag(); 1963 EXPECT_EQ(context_->changeInfoListeners_.size(), 1); 1964 } 1965 1966 /** 1967 * @tc.name: PipelineContextTestNg100 1968 * @tc.desc: Test the function UpdateHalfFoldHoverStatus 1969 * @tc.type: FUNC 1970 */ 1971 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg100, TestSize.Level1) 1972 { 1973 /** 1974 * @tc.steps1: initialize parameters. 1975 * @tc.expected: All pointer is non-null. 1976 */ 1977 ASSERT_NE(context_, nullptr); 1978 context_->minPlatformVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_THIRTEEN); 1979 RefPtr<DisplayInfo> displayInfo = AceType::MakeRefPtr<DisplayInfo>(); 1980 displayInfo->SetWidth(DEFAULT_INT10); 1981 displayInfo->SetHeight(DEFAULT_INT10); 1982 displayInfo->SetIsFoldable(true); 1983 displayInfo->SetFoldStatus(FoldStatus::HALF_FOLD); 1984 displayInfo->SetRotation(Rotation::ROTATION_90); 1985 MockContainer::Current()->SetDisplayInfo(displayInfo); 1986 context_->UpdateHalfFoldHoverStatus(DEFAULT_INT10, DEFAULT_INT10); 1987 ASSERT_EQ(context_->isHalfFoldHoverStatus_, true); 1988 } 1989 1990 /** 1991 * @tc.name: MouseEvent01 1992 * @tc.desc: Test GetResampleMouseEvent 1993 * @tc.type: FUNC 1994 */ 1995 HWTEST_F(PipelineContextTestNg, MouseEvent01, TestSize.Level1) 1996 { 1997 auto timeStampAce = TimeStamp(std::chrono::nanoseconds(1000)); 1998 auto timeStampTwo = TimeStamp(std::chrono::nanoseconds(2000)); 1999 auto timeStampThree = TimeStamp(std::chrono::nanoseconds(3000)); 2000 auto timeStampFour = TimeStamp(std::chrono::nanoseconds(4000)); 2001 std::vector<MouseEvent> history; 2002 MouseEvent historyMouseEvent1; 2003 historyMouseEvent1.x = 100.0f; 2004 historyMouseEvent1.y = 200.0f; 2005 historyMouseEvent1.time = timeStampAce; 2006 history.push_back(historyMouseEvent1); 2007 MouseEvent historyMouseEvent2; 2008 historyMouseEvent2.x = 150.0f; 2009 historyMouseEvent2.y = 250.0f; 2010 historyMouseEvent2.time = timeStampTwo; 2011 history.push_back(historyMouseEvent2); 2012 std::vector<MouseEvent> current; 2013 MouseEvent currentMouseEvent1; 2014 currentMouseEvent1.x = 200.0f; 2015 currentMouseEvent1.y = 300.0f; 2016 currentMouseEvent1.time = timeStampThree; 2017 current.push_back(currentMouseEvent1); 2018 MouseEvent currentMouseEvent2; 2019 currentMouseEvent2.x = 250.0f; 2020 currentMouseEvent2.y = 350.0f; 2021 currentMouseEvent2.time = timeStampFour; 2022 current.push_back(currentMouseEvent2); 2023 uint64_t nanoTimeStamp = 2500; 2024 2025 MouseEvent resampledMouseEvent = context_->eventManager_->GetResampleMouseEvent(history, current, nanoTimeStamp); 2026 EXPECT_EQ(175.0f, resampledMouseEvent.x); 2027 EXPECT_EQ(275.0f, resampledMouseEvent.y); 2028 } 2029 2030 /** 2031 * @tc.name: DragEvent01 2032 * @tc.desc: Test GetResamplePointerEvent 2033 * @tc.type: FUNC 2034 */ 2035 HWTEST_F(PipelineContextTestNg, DragEvent01, TestSize.Level1) 2036 { 2037 auto timeStampAce = TimeStamp(std::chrono::nanoseconds(1000)); 2038 auto timeStampTwo = TimeStamp(std::chrono::nanoseconds(2000)); 2039 auto timeStampThree = TimeStamp(std::chrono::nanoseconds(3000)); 2040 auto timeStampFour = TimeStamp(std::chrono::nanoseconds(4000)); 2041 2042 std::vector<DragPointerEvent> history; 2043 DragPointerEvent historyDrageEvent1; 2044 historyDrageEvent1.x = 200; 2045 historyDrageEvent1.y = 300; 2046 historyDrageEvent1.time = timeStampAce; 2047 history.push_back(historyDrageEvent1); 2048 DragPointerEvent historyDrageEvent2; 2049 historyDrageEvent2.x = 250; 2050 historyDrageEvent2.y = 350; 2051 historyDrageEvent2.time = timeStampTwo; 2052 history.push_back(historyDrageEvent2); 2053 std::vector<DragPointerEvent> current; 2054 DragPointerEvent currentDragEvent1; 2055 currentDragEvent1.x = 300; 2056 currentDragEvent1.y = 400; 2057 currentDragEvent1.time = timeStampThree; 2058 current.push_back(currentDragEvent1); 2059 DragPointerEvent currentDragEvent2; 2060 currentDragEvent2.x = 350; 2061 currentDragEvent2.y = 450; 2062 currentDragEvent2.time = timeStampFour; 2063 current.push_back(currentDragEvent2); 2064 uint64_t nanoTimeStamp = 3100; 2065 2066 DragPointerEvent resampledPointerEvent = context_->eventManager_->GetResamplePointerEvent( 2067 history, current, nanoTimeStamp); 2068 EXPECT_EQ(305, resampledPointerEvent.x); 2069 EXPECT_EQ(405, resampledPointerEvent.y); 2070 } 2071 2072 /** 2073 * @tc.name: PipelineCancelDragIfRightBtnPressedTest001 2074 * @tc.desc: Test CancelDragIfRightBtnPressed 2075 * @tc.type: FUNC 2076 */ 2077 HWTEST_F(PipelineContextTestNg, PipelineCancelDragIfRightBtnPressedTest001, TestSize.Level1) 2078 { 2079 /** 2080 * @tc.steps1: initialize parameters. 2081 * @tc.expected: All pointer is non-null. 2082 */ 2083 ASSERT_NE(context_, nullptr); 2084 context_->SetupRootElement(); 2085 auto manager = context_->GetDragDropManager(); 2086 ASSERT_NE(manager, nullptr); 2087 MouseEvent event; 2088 2089 /** 2090 * @tc.steps2: test function with mouse event button is None. 2091 * @tc.expected: dragDropManager's dragCancel flag is false. 2092 */ 2093 manager->SetIsDragCancel(true); 2094 context_->NotifyDragMouseEvent(event); 2095 EXPECT_FALSE(manager->isDragCancel_); 2096 2097 /** 2098 * @tc.steps3: test function with mouse event button is Right Button. 2099 * @tc.expected: dragDropManager's dragCancel flag is true. 2100 */ 2101 event.button = MouseButton::RIGHT_BUTTON; 2102 event.action = MouseAction::PRESS; 2103 context_->NotifyDragMouseEvent(event); 2104 EXPECT_TRUE(manager->isDragCancel_); 2105 2106 /** 2107 * @tc.steps4: test function without dragDropManager_. 2108 * @tc.expected: dragDropManager's dragCancel flag is true. 2109 */ 2110 context_->dragDropManager_ = nullptr; 2111 context_->NotifyDragMouseEvent(event); 2112 EXPECT_TRUE(manager->isDragCancel_); 2113 } 2114 2115 /** 2116 * @tc.name: PipelineOnDragEvent001 2117 * @tc.desc: Test reset drag frameNode with pull in. 2118 * @tc.type: FUNC 2119 */ 2120 HWTEST_F(PipelineContextTestNg, PipelineOnDragEvent001, TestSize.Level1) 2121 { 2122 /** 2123 * @tc.steps1: initialize parameters. 2124 * @tc.expected: All pointer is non-null. 2125 */ 2126 ASSERT_NE(context_, nullptr); 2127 context_->SetupRootElement(); 2128 auto manager = context_->GetDragDropManager(); 2129 ASSERT_NE(manager, nullptr); 2130 auto frameNode = AceType::MakeRefPtr<FrameNode>("test1", -1, AceType::MakeRefPtr<Pattern>(), false); 2131 manager->preTargetFrameNode_ = frameNode; 2132 2133 DragPointerEvent dragEvent; 2134 DragEventAction action = DragEventAction::DRAG_EVENT_START; 2135 context_->OnDragEvent(dragEvent, action); 2136 EXPECT_NE(manager->preTargetFrameNode_, frameNode); 2137 } 2138 2139 /** 2140 * @tc.name: PipelineFlushTouchEvents001 2141 * @tc.desc: Test the function CollectTouchEventsBeforeVsync. 2142 * @tc.type: FUNC 2143 */ 2144 HWTEST_F(PipelineContextTestNg, PipelineFlushTouchEvents001, TestSize.Level1) 2145 { 2146 /** 2147 * @tc.steps1: initialize parameters. 2148 * @tc.expected: All pointer is non-null. 2149 */ 2150 ASSERT_NE(context_, nullptr); 2151 context_->SetupRootElement(); 2152 2153 for (auto& testCase : COLLECT_TOUCH_EVENTS_TESTCASES) { 2154 context_->touchEvents_.clear(); 2155 context_->vsyncTime_ = testCase.vsyncTime; 2156 context_->compensationValue_ = testCase.compensationValue; 2157 for (auto& touchTimes : testCase.touchEventTimes) { 2158 TouchEvent event; 2159 event.time = TimeStamp(std::chrono::nanoseconds(touchTimes)); 2160 context_->touchEvents_.emplace_back(event); 2161 } 2162 std::list<TouchEvent> touchEvents; 2163 context_->CollectTouchEventsBeforeVsync(touchEvents); 2164 EXPECT_EQ(touchEvents.size(), testCase.targetTouchEventSize); 2165 EXPECT_EQ(context_->touchEvents_.size(), testCase.originTouchEventSize); 2166 } 2167 } 2168 2169 /** 2170 * @tc.name: PipelineFlushTouchEvents002 2171 * @tc.desc: Test the function FlushTouchEvents with normal touchEvents. 2172 * @tc.type: FUNC 2173 */ 2174 HWTEST_F(PipelineContextTestNg, PipelineFlushTouchEvents002, TestSize.Level1) 2175 { 2176 /** 2177 * @tc.steps1: initialize parameters. 2178 * @tc.expected: All pointer is non-null. 2179 */ 2180 ASSERT_NE(context_, nullptr); 2181 ASSERT_NE(context_->eventManager_, nullptr); 2182 context_->SetupRootElement(); 2183 context_->vsyncTime_ = AFTER_VSYNC_TIME; 2184 context_->eventManager_->idToTouchPoints_.clear(); 2185 bool isAcc = context_->touchAccelarate_; 2186 context_->touchAccelarate_ = false; 2187 2188 for (auto& testCase : FLUSH_TOUCH_EVENTS_TESTCASES) { 2189 context_->resampleTimeStamp_ = testCase.vsyncTime; 2190 context_->compensationValue_ = testCase.compensationValue; 2191 context_->touchEvents_.clear(); 2192 context_->historyPointsById_.clear(); 2193 for (auto& touchTimes : testCase.touchEventTimes) { 2194 TouchEvent event; 2195 event.type = TouchType::MOVE; 2196 event.time = TimeStamp(std::chrono::nanoseconds(touchTimes)); 2197 context_->touchEvents_.emplace_back(event); 2198 } 2199 context_->FlushTouchEvents(); 2200 EXPECT_EQ(context_->historyPointsById_.size(), testCase.targetTouchEventSize); 2201 auto idToTouchPoint = context_->eventManager_->GetIdToTouchPoint(); 2202 EXPECT_EQ(idToTouchPoint[DEFAULT_INT0].history.size(), testCase.originTouchEventSize); 2203 } 2204 context_->touchAccelarate_ = isAcc; 2205 } 2206 2207 HWTEST_F(PipelineContextTestNg, PipelineOnHoverMove001, TestSize.Level1) 2208 { 2209 /** 2210 * @tc.steps1: initialize parameters. 2211 * @tc.expected: All pointer is non-null. 2212 */ 2213 ASSERT_NE(context_, nullptr); 2214 ASSERT_NE(context_->eventManager_, nullptr); 2215 2216 TouchEvent event; 2217 RefPtr<HoverEventTarget> penHoverMoveEventTarget_ = AceType::MakeRefPtr<HoverEventTarget>("Button", 25); 2218 penHoverMoveEventTarget_->onPenHoverMoveEventCallback_ = nullptr; 2219 bool ret = penHoverMoveEventTarget_->HandlePenHoverMoveEvent(event); 2220 EXPECT_EQ(ret, false); 2221 } 2222 2223 HWTEST_F(PipelineContextTestNg, PipelineOnHoverMove002, TestSize.Level1) 2224 { 2225 /** 2226 * @tc.steps1: initialize parameters. 2227 * @tc.expected: All pointer is non-null. 2228 */ 2229 ASSERT_NE(context_, nullptr); 2230 ASSERT_NE(context_->eventManager_, nullptr); 2231 2232 TouchEvent event; 2233 RefPtr<HoverEventTarget> penHoverMoveEventTarget_ = AceType::MakeRefPtr<HoverEventTarget>("Button", 25); __anonaf4252cb1302(HoverInfo& penHoverMoveInfo) 2234 penHoverMoveEventTarget_->onPenHoverMoveEventCallback_ = [](HoverInfo& penHoverMoveInfo) {}; 2235 bool ret = penHoverMoveEventTarget_->HandlePenHoverMoveEvent(event); 2236 EXPECT_EQ(ret, true); 2237 } 2238 2239 /** 2240 * @tc.name: GetCurrentPageNameCallback 2241 * @tc.desc: Test GetCurrentPageNameCallback of pipeline_context 2242 * @tc.type: FUNC 2243 */ 2244 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg201, TestSize.Level1) 2245 { 2246 /** 2247 * @tc.steps1: initialize parameters. 2248 * @tc.expected: All pointer is non-null. 2249 */ 2250 ASSERT_NE(context_, nullptr); 2251 /** 2252 * @tc.steps: make stageManager_ is nullptr. 2253 */ 2254 context_->stageManager_ = nullptr; 2255 EXPECT_EQ(context_->stageManager_, nullptr); 2256 2257 std::string res = context_->GetCurrentPageNameCallback(); 2258 EXPECT_EQ(res, ""); 2259 } 2260 2261 /** 2262 * @tc.name: GetCurrentPageNameCallback 2263 * @tc.desc: Test GetCurrentPageNameCallback of pipeline_context 2264 * @tc.type: FUNC 2265 */ 2266 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg202, TestSize.Level1) 2267 { 2268 /** 2269 * @tc.steps1: initialize parameters. 2270 * @tc.expected: All pointer is non-null. 2271 */ 2272 ASSERT_NE(context_, nullptr); 2273 auto ONE = 2274 FrameNode::CreateFrameNode("one", 1, AceType::MakeRefPtr<Pattern>(), true); 2275 /** 2276 * @tc.steps: Ensure that stageManager_ is not nullptr. 2277 */ 2278 context_->stageManager_ = AceType::MakeRefPtr<StageManager>(ONE); 2279 ASSERT_NE(context_->stageManager_, nullptr); 2280 RefPtr<FrameNode> pageNode = context_->stageManager_->GetLastPage(); 2281 EXPECT_EQ(pageNode, nullptr); 2282 2283 std::string res = context_->GetCurrentPageNameCallback(); 2284 EXPECT_EQ(res, ""); 2285 } 2286 2287 /** 2288 * @tc.name: GetCurrentPageNameCallback 2289 * @tc.desc: Test GetCurrentPageNameCallback of pipeline_context 2290 * @tc.type: FUNC 2291 */ 2292 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg203, TestSize.Level1) 2293 { 2294 /** 2295 * @tc.steps1: initialize parameters. 2296 * @tc.expected: All pointer is non-null. 2297 */ 2298 ASSERT_NE(context_, nullptr); 2299 auto stageNode = FrameNode::CreateFrameNode("testFrameNode", 0, AceType::MakeRefPtr<StagePattern>()); 2300 auto firstNode = 2301 FrameNode::CreateFrameNode("1", 1, AceType::MakeRefPtr<PagePattern>(AceType::MakeRefPtr<PageInfo>())); 2302 auto secondNode = 2303 FrameNode::CreateFrameNode("2", 2, AceType::MakeRefPtr<PagePattern>(AceType::MakeRefPtr<PageInfo>())); 2304 2305 auto stageManager = AceType::MakeRefPtr<StageManager>(stageNode); 2306 /** 2307 * @tc.steps: Ensure that stageManager_->GetLastPage() is not nullptr. 2308 */ 2309 stageManager->PushPage(firstNode); 2310 stageManager->PushPage(secondNode); 2311 /** 2312 * @tc.steps: Ensure that stageManager_ is not nullptr. 2313 */ 2314 context_->stageManager_ = stageManager; 2315 ASSERT_NE(context_->stageManager_, nullptr); 2316 ASSERT_NE(context_->stageManager_->GetLastPage(), nullptr); 2317 2318 auto pagePattern = secondNode->GetPattern<PagePattern>(); 2319 ASSERT_NE(pagePattern, nullptr); 2320 int32_t pageId = pagePattern->GetPageInfo()->GetPageId(); 2321 EXPECT_EQ(pageId, 0); 2322 auto it = context_->pageToNavigationNodes_.find(pageId); 2323 bool empty = it == context_->pageToNavigationNodes_.end() || it->second.empty(); 2324 EXPECT_EQ(empty, true); 2325 2326 std::string res = context_->GetCurrentPageNameCallback(); 2327 EXPECT_EQ(res, ""); 2328 2329 auto pageInfo = AceType::MakeRefPtr<PageInfo>(1, "testUrl", "testPath"); 2330 /** 2331 * @tc.steps: Ensure that pagePattern->GetPageInfo() is not nullptr. 2332 */ 2333 pagePattern->pageInfo_ = pageInfo; 2334 ASSERT_NE(pagePattern->GetPageInfo(), nullptr); 2335 int32_t pageId2 = pagePattern->GetPageInfo()->GetPageId(); 2336 EXPECT_EQ(pageId2, 1); 2337 2338 auto it2 = context_->pageToNavigationNodes_.find(pageId); 2339 bool empty2 = it2 == context_->pageToNavigationNodes_.end() || it->second.empty(); 2340 EXPECT_EQ(empty2, true); 2341 std::string res2 = context_->GetCurrentPageNameCallback(); 2342 EXPECT_EQ(res2, ""); 2343 } 2344 2345 /** 2346 * @tc.name: GetCurrentPageNameCallback 2347 * @tc.desc: Test GetCurrentPageNameCallback of pipeline_context 2348 * @tc.type: FUNC 2349 */ 2350 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg204, TestSize.Level1) 2351 { 2352 /** 2353 * @tc.steps1: initialize parameters. 2354 * @tc.expected: All pointer is non-null. 2355 */ 2356 ASSERT_NE(context_, nullptr); 2357 auto stageNode = FrameNode::CreateFrameNode("testFrameNode", 0, AceType::MakeRefPtr<StagePattern>()); 2358 auto firstNode = 2359 FrameNode::CreateFrameNode("1", 1, AceType::MakeRefPtr<PagePattern>(AceType::MakeRefPtr<PageInfo>())); 2360 auto secondNode = 2361 FrameNode::CreateFrameNode("2", 2, AceType::MakeRefPtr<PagePattern>(AceType::MakeRefPtr<PageInfo>())); 2362 2363 auto stageManager = AceType::MakeRefPtr<StageManager>(stageNode); 2364 /** 2365 * @tc.steps: Ensure that stageManager_->GetLastPage() is not nullptr. 2366 */ 2367 stageManager->PushPage(firstNode); 2368 stageManager->PushPage(secondNode); 2369 /** 2370 * @tc.steps: Ensure that stageManager_ is not nullptr. 2371 */ 2372 context_->stageManager_ = stageManager; 2373 std::string res = context_->GetCurrentPageNameCallback(); 2374 auto pagePattern = secondNode->GetPattern<PagePattern>(); 2375 2376 auto pageInfo = AceType::MakeRefPtr<PageInfo>(1, "testUrl", "testPath"); 2377 /** 2378 * @tc.steps: Ensure that pagePattern->GetPageInfo() is not nullptr. 2379 */ 2380 pagePattern->pageInfo_ = pageInfo; 2381 /** 2382 * @tc.steps: make it->second has value. 2383 */ 2384 context_->pageToNavigationNodes_[1].push_back(firstNode); 2385 int32_t pageId = pagePattern->GetPageInfo()->GetPageId(); 2386 auto it = context_->pageToNavigationNodes_.find(pageId); 2387 bool empty = it == context_->pageToNavigationNodes_.end() || it->second.empty(); 2388 EXPECT_EQ(empty, false); 2389 2390 RefPtr<NavigationGroupNode> navigationNode = nullptr; 2391 for (auto iter = it->second.begin(); iter != it->second.end() && !navigationNode; ++iter) { 2392 navigationNode = AceType::DynamicCast<NavigationGroupNode>((*iter).Upgrade()); 2393 } 2394 /** 2395 * @tc.steps: it->second is firstNode, can not DynamicCast to NavigationGroupNode. 2396 */ 2397 EXPECT_EQ(navigationNode, nullptr); 2398 2399 std::string res2 = context_->GetCurrentPageNameCallback(); 2400 EXPECT_EQ(res2, ""); 2401 } 2402 2403 /** 2404 * @tc.name: GetCurrentPageNameCallback 2405 * @tc.desc: Test GetCurrentPageNameCallback of pipeline_context 2406 * @tc.type: FUNC 2407 */ 2408 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg205, TestSize.Level1) 2409 { 2410 /** 2411 * @tc.steps1: initialize parameters. 2412 * @tc.expected: All pointer is non-null. 2413 */ 2414 ASSERT_NE(context_, nullptr); 2415 auto stageNode = FrameNode::CreateFrameNode("testFrameNode", 0, AceType::MakeRefPtr<StagePattern>()); 2416 auto firstNode = 2417 FrameNode::CreateFrameNode("1", 1, AceType::MakeRefPtr<PagePattern>(AceType::MakeRefPtr<PageInfo>())); 2418 2419 auto stageManager = AceType::MakeRefPtr<StageManager>(stageNode); 2420 /** 2421 * @tc.steps: Ensure that stageManager_->GetLastPage() is not nullptr. 2422 */ 2423 stageManager->PushPage(firstNode); 2424 /** 2425 * @tc.steps: Ensure that stageManager_ is not nullptr. 2426 */ 2427 context_->stageManager_ = stageManager; 2428 std::string res = context_->GetCurrentPageNameCallback(); 2429 auto pagePattern = firstNode->GetPattern<PagePattern>(); 2430 2431 auto pageInfo = AceType::MakeRefPtr<PageInfo>(1, "testUrl", "testPath"); 2432 /** 2433 * @tc.steps: Ensure that pagePattern->GetPageInfo() is not nullptr. 2434 */ 2435 pagePattern->pageInfo_ = pageInfo; 2436 2437 /** 2438 * @tc.steps: make it->second has value and type is navigationNode. 2439 */ 2440 auto navigationGroupNode = NavigationGroupNode::GetOrCreateGroupNode( __anonaf4252cb1402() 2441 "navigationNode", 11, []() { return AceType::MakeRefPtr<NavigationPattern>(); } 2442 ); 2443 RefPtr<NavigationPattern> navigationPattern = navigationGroupNode->GetPattern<NavigationPattern>(); 2444 navigationPattern->navigationStack_ = AceType::MakeRefPtr<NavigationStack>(); 2445 WeakPtr<UINode> navigationGroupNodeVal = AceType::WeakClaim(AceType::RawPtr(navigationGroupNode)); 2446 2447 context_->pageToNavigationNodes_[1].push_back(navigationGroupNodeVal); 2448 int32_t pageId = pagePattern->GetPageInfo()->GetPageId(); 2449 auto it = context_->pageToNavigationNodes_.find(pageId); 2450 bool empty = it == context_->pageToNavigationNodes_.end() || it->second.empty(); 2451 EXPECT_EQ(empty, false); 2452 2453 RefPtr<NavigationGroupNode> navigationNode = nullptr; 2454 for (auto iter = it->second.begin(); iter != it->second.end() && !navigationNode; ++iter) { 2455 navigationNode = AceType::DynamicCast<NavigationGroupNode>((*iter).Upgrade()); 2456 } 2457 /** 2458 * @tc.steps: it->second is navigationNode, can DynamicCast to NavigationGroupNode. 2459 */ 2460 EXPECT_NE(navigationNode, nullptr); 2461 ASSERT_NE(navigationNode->GetPattern(), nullptr); 2462 auto pattern = AceType::DynamicCast<NavigationPattern>(navigationNode->GetPattern()); 2463 ASSERT_NE(pattern, nullptr); 2464 2465 const auto& navDestinationNodes = pattern->GetAllNavDestinationNodes(); 2466 /** 2467 * @tc.steps: navDestinationNodes is navPathList in navigationPattern->navigationStack_, is nullptr. 2468 */ 2469 int32_t size = static_cast<int32_t>(navDestinationNodes.size()); 2470 EXPECT_EQ(size, 0); 2471 2472 std::string res2 = context_->GetCurrentPageNameCallback(); 2473 EXPECT_EQ(res2, ""); 2474 } 2475 2476 /** 2477 * @tc.name: GetCurrentPageNameCallback 2478 * @tc.desc: Test GetCurrentPageNameCallback of pipeline_context 2479 * @tc.type: FUNC 2480 */ 2481 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg206, TestSize.Level1) 2482 { 2483 /** 2484 * @tc.steps1: initialize parameters. 2485 * @tc.expected: All pointer is non-null. 2486 */ 2487 ASSERT_NE(context_, nullptr); 2488 auto stageNode = FrameNode::CreateFrameNode("testFrameNode", 0, AceType::MakeRefPtr<StagePattern>()); 2489 auto firstNode = 2490 FrameNode::CreateFrameNode("1", 1, AceType::MakeRefPtr<PagePattern>(AceType::MakeRefPtr<PageInfo>())); 2491 2492 auto stageManager = AceType::MakeRefPtr<StageManager>(stageNode); 2493 /** 2494 * @tc.steps: Ensure that stageManager_->GetLastPage() is not nullptr. 2495 */ 2496 stageManager->PushPage(firstNode); 2497 /** 2498 * @tc.steps: Ensure that stageManager_ is not nullptr. 2499 */ 2500 context_->stageManager_ = stageManager; 2501 auto pagePattern = firstNode->GetPattern<PagePattern>(); 2502 2503 auto pageInfo = AceType::MakeRefPtr<PageInfo>(1, "testUrl", "testPath"); 2504 /** 2505 * @tc.steps: Ensure that pagePattern->GetPageInfo() is not nullptr. 2506 */ 2507 pagePattern->pageInfo_ = pageInfo; 2508 /** 2509 * @tc.steps: make it->second has value and type is navigationNode. 2510 */ 2511 2512 auto navigationGroupNode = NavigationGroupNode::GetOrCreateGroupNode( __anonaf4252cb1502() 2513 "navigationNode", 11, []() { return AceType::MakeRefPtr<NavigationPattern>(); } 2514 ); 2515 RefPtr<NavigationPattern> navigationPattern = navigationGroupNode->GetPattern<NavigationPattern>(); 2516 navigationPattern->navigationStack_ = AceType::MakeRefPtr<NavigationStack>(); 2517 WeakPtr<UINode> navigationGroupNodeVal = AceType::WeakClaim(AceType::RawPtr(navigationGroupNode)); 2518 2519 context_->pageToNavigationNodes_[1].push_back(navigationGroupNodeVal); 2520 int32_t pageId = pagePattern->GetPageInfo()->GetPageId(); 2521 auto it = context_->pageToNavigationNodes_.find(pageId); 2522 bool empty = it == context_->pageToNavigationNodes_.end() || it->second.empty(); 2523 EXPECT_EQ(empty, false); 2524 2525 RefPtr<NavigationGroupNode> navigationNode = nullptr; 2526 for (auto iter = it->second.begin(); iter != it->second.end() && !navigationNode; ++iter) { 2527 navigationNode = AceType::DynamicCast<NavigationGroupNode>((*iter).Upgrade()); 2528 } 2529 /** 2530 * @tc.steps: it->second is navigationNode, can DynamicCast to NavigationGroupNode. 2531 */ 2532 EXPECT_NE(navigationNode, nullptr); 2533 ASSERT_NE(navigationNode->GetPattern(), nullptr); 2534 auto pattern = AceType::DynamicCast<NavigationPattern>(navigationNode->GetPattern()); 2535 ASSERT_NE(pattern, nullptr); 2536 2537 /** 2538 * @tc.steps: make navigationPattern->navigationStack_ not nullptr. 2539 */ 2540 NavPathList navPathList; 2541 navPathList.emplace_back(std::make_pair("pageOne", nullptr)); 2542 navPathList.emplace_back(std::make_pair("pageTwo", nullptr)); 2543 navPathList.emplace_back(std::make_pair("pageThree", nullptr)); 2544 navPathList.emplace_back(std::make_pair("pageFour", nullptr)); 2545 navigationPattern->navigationStack_->SetNavPathList(navPathList); 2546 2547 const auto& navDestinationNodes = pattern->GetAllNavDestinationNodes(); 2548 int32_t size = static_cast<int32_t>(navDestinationNodes.size()); 2549 EXPECT_NE(size, 0); 2550 2551 std::string res = context_->GetCurrentPageNameCallback(); 2552 EXPECT_EQ(res, "pageFour"); 2553 } 2554 2555 /** 2556 * @tc.name: GetCurrentPageNameCallback 2557 * @tc.desc: Test GetCurrentContext of pipeline_context 2558 * @tc.type: FUNC 2559 */ 2560 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg207, TestSize.Level1) 2561 { 2562 /** 2563 * @tc.steps1: initialize parameters. 2564 * @tc.expected: All pointer is non-null. 2565 */ 2566 ASSERT_NE(context_, nullptr); 2567 /** 2568 * @tc.steps: make currentContainer is not nullptr. 2569 */ 2570 auto currentContainer = Container::Current(); 2571 ASSERT_NE(currentContainer, nullptr); 2572 2573 auto res = context_->GetCurrentContext(); 2574 auto pipelineRes = AceType::DynamicCast<PipelineContext>(currentContainer->GetPipelineContext()); 2575 EXPECT_EQ(res, pipelineRes); 2576 } 2577 2578 /** 2579 * @tc.name: GetCurrentPageNameCallback 2580 * @tc.desc: Test GetCurrentContextSafely of pipeline_context 2581 * @tc.type: FUNC 2582 */ 2583 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg208, TestSize.Level1) 2584 { 2585 /** 2586 * @tc.steps1: initialize parameters. 2587 * @tc.expected: All pointer is non-null. 2588 */ 2589 ASSERT_NE(context_, nullptr); 2590 /** 2591 * @tc.steps: make currentContainer is not nullptr. 2592 */ 2593 auto currentContainer = Container::CurrentSafely(); 2594 ASSERT_NE(currentContainer, nullptr); 2595 2596 auto res = context_->GetCurrentContextSafely(); 2597 auto pipelineRes = AceType::DynamicCast<PipelineContext>(currentContainer->GetPipelineContext()); 2598 EXPECT_EQ(res, pipelineRes); 2599 } 2600 2601 /** 2602 * @tc.name: GetCurrentPageNameCallback 2603 * @tc.desc: Test GetCurrentContextSafelyWithCheck of pipeline_context 2604 * @tc.type: FUNC 2605 */ 2606 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg209, TestSize.Level1) 2607 { 2608 /** 2609 * @tc.steps1: initialize parameters. 2610 * @tc.expected: All pointer is non-null. 2611 */ 2612 ASSERT_NE(context_, nullptr); 2613 /** 2614 * @tc.steps: make currentContainer is not nullptr. 2615 */ 2616 auto currentContainer = Container::CurrentSafelyWithCheck(); 2617 ASSERT_NE(currentContainer, nullptr); 2618 2619 auto res = context_->GetCurrentContextSafelyWithCheck(); 2620 auto pipelineRes = AceType::DynamicCast<PipelineContext>(currentContainer->GetPipelineContext()); 2621 EXPECT_EQ(res, pipelineRes); 2622 } 2623 2624 /** 2625 * @tc.name: GetCurrentPageNameCallback 2626 * @tc.desc: Test GetCurrentContextPtrSafely of pipeline_context 2627 * @tc.type: FUNC 2628 */ 2629 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg210, TestSize.Level1) 2630 { 2631 /** 2632 * @tc.steps1: initialize parameters. 2633 * @tc.expected: All pointer is non-null. 2634 */ 2635 ASSERT_NE(context_, nullptr); 2636 /** 2637 * @tc.steps: make currentContainer is not nullptr. 2638 */ 2639 auto currentContainer = Container::CurrentSafely(); 2640 ASSERT_NE(currentContainer, nullptr); 2641 const auto& base = currentContainer->GetPipelineContext(); 2642 ASSERT_NE(base, nullptr); 2643 auto res = context_->GetCurrentContextPtrSafely(); 2644 auto pipelineRes = AceType::DynamicCast<PipelineContext>(AceType::RawPtr(base)); 2645 EXPECT_EQ(res, pipelineRes); 2646 } 2647 2648 /** 2649 * @tc.name: GetCurrentPageNameCallback 2650 * @tc.desc: Test GetCurrentRootWidth of pipeline_context 2651 * @tc.type: FUNC 2652 */ 2653 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg211, TestSize.Level1) 2654 { 2655 /** 2656 * @tc.steps1: initialize parameters. 2657 * @tc.expected: All pointer is non-null. 2658 */ 2659 ASSERT_NE(context_, nullptr); 2660 context_->rootWidth_ = 100.0f; 2661 float res = context_->GetCurrentRootWidth(); 2662 EXPECT_EQ(res, 100.0f); 2663 } 2664 2665 /** 2666 * @tc.name: GetCurrentPageNameCallback 2667 * @tc.desc: Test GetCurrentRootHeight of pipeline_context 2668 * @tc.type: FUNC 2669 */ 2670 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg212, TestSize.Level1) 2671 { 2672 /** 2673 * @tc.steps1: initialize parameters. 2674 * @tc.expected: All pointer is non-null. 2675 */ 2676 ASSERT_NE(context_, nullptr); 2677 context_->rootHeight_ = 100.0f; 2678 float res = context_->GetCurrentRootHeight(); 2679 EXPECT_EQ(res, 100.0f); 2680 } 2681 2682 2683 /** 2684 * @tc.name: GetCurrentPageNameCallback 2685 * @tc.desc: Test CheckThreadSafe of pipeline_context 2686 * @tc.type: FUNC 2687 */ 2688 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg213, TestSize.Level1) 2689 { 2690 /** 2691 * @tc.steps1: initialize parameters. 2692 * @tc.expected: All pointer is non-null. 2693 */ 2694 ASSERT_NE(context_, nullptr); 2695 /** 2696 * @tc.steps: make taskExecutor_ is nullptr. 2697 */ 2698 auto oldTaskExecutor = context_->taskExecutor_; 2699 context_->taskExecutor_ = nullptr; 2700 bool res = context_->CheckThreadSafe(); 2701 EXPECT_TRUE(res); 2702 2703 /** 2704 * @tc.steps: Restore value taskExecutor_. 2705 */ 2706 context_->taskExecutor_ = oldTaskExecutor; 2707 } 2708 2709 /** 2710 * @tc.name: GetCurrentPageNameCallback 2711 * @tc.desc: Test CheckThreadSafe of pipeline_context 2712 * @tc.type: FUNC 2713 */ 2714 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg214, TestSize.Level1) 2715 { 2716 /** 2717 * @tc.steps1: initialize parameters. 2718 * @tc.expected: All pointer is non-null. 2719 */ 2720 ASSERT_NE(context_, nullptr); 2721 auto taskExecutor = context_->taskExecutor_; 2722 ASSERT_NE(taskExecutor, nullptr); 2723 2724 /** 2725 * @tc.steps: make !isFormRender_ is false. 2726 */ 2727 context_->SetIsFormRender(true); 2728 2729 bool res = context_->CheckThreadSafe(); 2730 EXPECT_TRUE(res); 2731 } 2732 2733 /** 2734 * @tc.name: GetCurrentPageNameCallback 2735 * @tc.desc: Test CheckThreadSafe of pipeline_context 2736 * @tc.type: FUNC 2737 */ 2738 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg215, TestSize.Level1) 2739 { 2740 /** 2741 * @tc.steps1: initialize parameters. 2742 * @tc.expected: All pointer is non-null. 2743 */ 2744 ASSERT_NE(context_, nullptr); 2745 auto taskExecutor = context_->taskExecutor_; 2746 ASSERT_NE(taskExecutor, nullptr); 2747 context_->SetIsFormRender(false); 2748 2749 bool res = context_->CheckThreadSafe(); 2750 EXPECT_TRUE(res); 2751 } 2752 2753 /** 2754 * @tc.name: GetCurrentPageNameCallback 2755 * @tc.desc: Test CheckThreadSafe of pipeline_context 2756 * @tc.type: FUNC 2757 */ 2758 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg216, TestSize.Level1) 2759 { 2760 /** 2761 * @tc.steps1: initialize parameters. 2762 * @tc.expected: All pointer is non-null. 2763 */ 2764 ASSERT_NE(context_, nullptr); 2765 auto taskExecutor = context_->taskExecutor_; 2766 ASSERT_NE(taskExecutor, nullptr); 2767 context_->SetIsFormRender(true); 2768 2769 bool res = context_->CheckThreadSafe(); 2770 EXPECT_TRUE(res); 2771 } 2772 2773 /** 2774 * @tc.name: GetCurrentPageNameCallback 2775 * @tc.desc: Test AddDirtyPropertyNode of pipeline_context 2776 * @tc.type: FUNC 2777 */ 2778 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg217, TestSize.Level1) 2779 { 2780 /** 2781 * @tc.steps1: initialize parameters. 2782 * @tc.expected: All pointer is non-null. 2783 */ 2784 ASSERT_NE(context_, nullptr); 2785 auto taskExecutor = context_->taskExecutor_; 2786 ASSERT_NE(taskExecutor, nullptr); 2787 context_->SetIsFormRender(false); 2788 2789 auto dirtyNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); 2790 context_->AddDirtyPropertyNode(dirtyNode); 2791 2792 auto it = context_->dirtyPropertyNodes_.find(dirtyNode); 2793 EXPECT_NE(it, context_->dirtyPropertyNodes_.end()); 2794 EXPECT_TRUE(context_->hasIdleTasks_); 2795 } 2796 2797 /** 2798 * @tc.name: GetCurrentPageNameCallback 2799 * @tc.desc: Test AddDirtyCustomNode of pipeline_context 2800 * @tc.type: FUNC 2801 */ 2802 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg218, TestSize.Level1) 2803 { 2804 /** 2805 * @tc.steps1: initialize parameters. 2806 * @tc.expected: All pointer is non-null. 2807 */ 2808 ASSERT_NE(context_, nullptr); 2809 context_->hasIdleTasks_ = false; 2810 /** 2811 * @tc.steps: make dirtyNode is nullptr. 2812 */ 2813 RefPtr<UINode> dirtyNode = nullptr; 2814 context_->AddDirtyCustomNode(dirtyNode); 2815 auto size = context_->dirtyNodes_.size(); 2816 EXPECT_EQ(size, 0); 2817 EXPECT_FALSE(context_->hasIdleTasks_); 2818 } 2819 2820 /** 2821 * @tc.name: GetCurrentPageNameCallback 2822 * @tc.desc: Test AddDirtyCustomNode of pipeline_context 2823 * @tc.type: FUNC 2824 */ 2825 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg219, TestSize.Level1) 2826 { 2827 /** 2828 * @tc.steps1: initialize parameters. 2829 * @tc.expected: All pointer is non-null. 2830 */ 2831 ASSERT_NE(context_, nullptr); 2832 /** 2833 * @tc.steps: make dirtyNode is not nullptr. 2834 */ 2835 RefPtr<UINode> dirtyNode = 2836 AceType::MakeRefPtr<FrameNode>("node", -1, AceType::MakeRefPtr<Pattern>()); 2837 ASSERT_NE(dirtyNode, nullptr); 2838 auto inspector = dirtyNode->GetInspectorId().value_or(""); 2839 EXPECT_TRUE(inspector.empty()); 2840 /** 2841 * @tc.steps: add dirtyNode. 2842 */ 2843 context_->AddDirtyCustomNode(dirtyNode); 2844 auto size = context_->dirtyNodes_.size(); 2845 EXPECT_NE(size, 0); 2846 auto it = context_->dirtyNodes_.find(dirtyNode); 2847 EXPECT_NE(it, context_->dirtyNodes_.end()); 2848 EXPECT_TRUE(context_->hasIdleTasks_); 2849 } 2850 2851 /** 2852 * @tc.name: GetCurrentPageNameCallback 2853 * @tc.desc: Test AddDirtyCustomNode of pipeline_context 2854 * @tc.type: FUNC 2855 */ 2856 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg220, TestSize.Level1) 2857 { 2858 /** 2859 * @tc.steps1: initialize parameters. 2860 * @tc.expected: All pointer is non-null. 2861 */ 2862 ASSERT_NE(context_, nullptr); 2863 /** 2864 * @tc.steps: make dirtyNode is not nullptr. 2865 */ 2866 RefPtr<UINode> dirtyNode1 = 2867 AceType::MakeRefPtr<FrameNode>("node", -1, AceType::MakeRefPtr<Pattern>()); 2868 ASSERT_NE(dirtyNode1, nullptr); 2869 dirtyNode1->UpdateInspectorId("test_id1"); 2870 2871 RefPtr<UINode> dirtyNode2 = 2872 AceType::MakeRefPtr<FrameNode>("node", -1, AceType::MakeRefPtr<Pattern>()); 2873 ASSERT_NE(dirtyNode2, nullptr); 2874 dirtyNode2->UpdateInspectorId("test_id2"); 2875 /** 2876 * @tc.steps: add dirtyNode1 and dirtyNode2. 2877 */ 2878 context_->AddDirtyCustomNode(dirtyNode1); 2879 context_->AddDirtyCustomNode(dirtyNode2); 2880 2881 auto it1 = context_->dirtyNodes_.find(dirtyNode1); 2882 EXPECT_NE(it1, context_->dirtyNodes_.end()); 2883 auto it2 = context_->dirtyNodes_.find(dirtyNode2); 2884 EXPECT_NE(it2, context_->dirtyNodes_.end()); 2885 EXPECT_TRUE(context_->hasIdleTasks_); 2886 } 2887 2888 /** 2889 * @tc.name: GetCurrentPageNameCallback 2890 * @tc.desc: Test AddDirtyFreezeNode of pipeline_context 2891 * @tc.type: FUNC 2892 */ 2893 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg221, TestSize.Level1) 2894 { 2895 /** 2896 * @tc.steps1: initialize parameters. 2897 * @tc.expected: All pointer is non-null. 2898 */ 2899 ASSERT_NE(context_, nullptr); 2900 context_->dirtyFreezeNode_.clear(); 2901 /** 2902 * @tc.steps: make node is nullptr. 2903 */ 2904 FrameNode* node = nullptr; 2905 context_->AddDirtyFreezeNode(node); 2906 auto size = context_->dirtyFreezeNode_.size(); 2907 EXPECT_NE(size, 0); 2908 EXPECT_TRUE(context_->hasIdleTasks_); 2909 } 2910 2911 /** 2912 * @tc.name: GetCurrentPageNameCallback 2913 * @tc.desc: Test AddDirtyFreezeNode of pipeline_context 2914 * @tc.type: FUNC 2915 */ 2916 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg222, TestSize.Level1) 2917 { 2918 /** 2919 * @tc.steps1: initialize parameters. 2920 * @tc.expected: All pointer is non-null. 2921 */ 2922 ASSERT_NE(context_, nullptr); 2923 context_->dirtyFreezeNode_.clear(); 2924 /** 2925 * @tc.steps: make node is not nullptr. 2926 */ 2927 auto frameNodeRef = 2928 FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true); 2929 ASSERT_NE(frameNodeRef, nullptr); 2930 FrameNode* node = &(*frameNodeRef); 2931 2932 context_->AddDirtyFreezeNode(node); 2933 auto it = std::find(context_->dirtyFreezeNode_.begin(), 2934 context_->dirtyFreezeNode_.end(), AceType::WeakClaim(node)); 2935 EXPECT_NE(it, context_->dirtyFreezeNode_.end()); 2936 2937 auto size = context_->dirtyFreezeNode_.size(); 2938 EXPECT_NE(size, 0); 2939 EXPECT_TRUE(context_->hasIdleTasks_); 2940 } 2941 2942 /** 2943 * @tc.name: GetCurrentPageNameCallback 2944 * @tc.desc: Test AddDirtyFreezeNode of pipeline_context 2945 * @tc.type: FUNC 2946 */ 2947 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg223, TestSize.Level1) 2948 { 2949 /** 2950 * @tc.steps1: initialize parameters. 2951 * @tc.expected: All pointer is non-null. 2952 */ 2953 ASSERT_NE(context_, nullptr); 2954 context_->FlushFreezeNode(); 2955 EXPECT_TRUE(context_->dirtyFreezeNode_.empty()); 2956 } 2957 2958 /** 2959 * @tc.name: GetCurrentPageNameCallback 2960 * @tc.desc: Test AddDirtyFreezeNode of pipeline_context 2961 * @tc.type: FUNC 2962 */ 2963 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg224, TestSize.Level1) 2964 { 2965 /** 2966 * @tc.steps1: initialize parameters. 2967 * @tc.expected: All pointer is non-null. 2968 */ 2969 ASSERT_NE(context_, nullptr); 2970 /** 2971 * @tc.steps: make context_->dirtyFreezeNode_.size() is 0. 2972 */ 2973 context_->dirtyFreezeNode_.clear(); 2974 context_->FlushFreezeNode(); 2975 EXPECT_TRUE(context_->dirtyFreezeNode_.empty()); 2976 } 2977 2978 /** 2979 * @tc.name: GetCurrentPageNameCallback 2980 * @tc.desc: Test AddPendingDeleteCustomNode of pipeline_context 2981 * @tc.type: FUNC 2982 */ 2983 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg225, TestSize.Level1) 2984 { 2985 /** 2986 * @tc.steps1: initialize parameters. 2987 * @tc.expected: All pointer is non-null. 2988 */ 2989 ASSERT_NE(context_, nullptr); 2990 auto size = context_->pendingDeleteCustomNode_.size(); 2991 ASSERT_EQ(size, 0); 2992 RefPtr<CustomNode> node1 = CustomNode::CreateCustomNode(1, "test1"); 2993 RefPtr<CustomNode> node2 = CustomNode::CreateCustomNode(2, "test2"); 2994 RefPtr<CustomNode> node3 = CustomNode::CreateCustomNode(3, "test3"); 2995 context_->AddPendingDeleteCustomNode(node1); 2996 context_->AddPendingDeleteCustomNode(node2); 2997 context_->AddPendingDeleteCustomNode(node3); 2998 2999 auto size2 = context_->pendingDeleteCustomNode_.size(); 3000 EXPECT_EQ(size2, 3); 3001 } 3002 3003 /** 3004 * @tc.name: GetCurrentPageNameCallback 3005 * @tc.desc: Test AddPendingDeleteCustomNode of pipeline_context 3006 * @tc.type: FUNC 3007 */ 3008 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg226, TestSize.Level1) 3009 { 3010 /** 3011 * @tc.steps1: initialize parameters. 3012 * @tc.expected: All pointer is non-null. 3013 */ 3014 ASSERT_NE(context_, nullptr); 3015 3016 /** 3017 * @tc.steps: make context_->pendingDeleteCustomNode_ is empty. 3018 */ 3019 while (!context_->pendingDeleteCustomNode_.empty()) { 3020 context_->pendingDeleteCustomNode_.pop(); 3021 } 3022 auto size = context_->pendingDeleteCustomNode_.size(); 3023 EXPECT_EQ(size, 0); 3024 /** 3025 * @tc.steps: make node is nullptr. 3026 */ 3027 RefPtr<CustomNode> node = nullptr; 3028 context_->AddPendingDeleteCustomNode(node); 3029 3030 auto size2 = context_->pendingDeleteCustomNode_.size(); 3031 EXPECT_NE(size2, 0); 3032 } 3033 3034 /** 3035 * @tc.name: GetCurrentPageNameCallback 3036 * @tc.desc: Test FlushPendingDeleteCustomNode of pipeline_context 3037 * @tc.type: FUNC 3038 */ 3039 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg227, TestSize.Level1) 3040 { 3041 /** 3042 * @tc.steps1: initialize parameters. 3043 * @tc.expected: All pointer is non-null. 3044 */ 3045 ASSERT_NE(context_, nullptr); 3046 RefPtr<CustomNode> node1 = CustomNode::CreateCustomNode(11, "test1"); 3047 RefPtr<CustomNode> node2 = CustomNode::CreateCustomNode(21, "test2"); 3048 RefPtr<CustomNode> node3 = CustomNode::CreateCustomNode(31, "test3"); 3049 context_->pendingDeleteCustomNode_.push(node1); 3050 context_->pendingDeleteCustomNode_.push(node2); 3051 context_->pendingDeleteCustomNode_.push(node3); 3052 3053 context_->FlushPendingDeleteCustomNode(); 3054 auto size = context_->pendingDeleteCustomNode_.size(); 3055 EXPECT_EQ(size, 0); 3056 } 3057 3058 /** 3059 * @tc.name: GetCurrentPageNameCallback 3060 * @tc.desc: Test FlushPendingDeleteCustomNode of pipeline_context 3061 * @tc.type: FUNC 3062 */ 3063 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg228, TestSize.Level1) 3064 { 3065 /** 3066 * @tc.steps1: initialize parameters. 3067 * @tc.expected: All pointer is non-null. 3068 */ 3069 ASSERT_NE(context_, nullptr); 3070 /** 3071 * @tc.steps: make context_->pendingDeleteCustomNode_ is empty. 3072 */ 3073 while (!context_->pendingDeleteCustomNode_.empty()) { 3074 context_->pendingDeleteCustomNode_.pop(); 3075 } 3076 3077 context_->FlushPendingDeleteCustomNode(); 3078 auto size = context_->pendingDeleteCustomNode_.size(); 3079 EXPECT_EQ(size, 0); 3080 } 3081 3082 /** 3083 * @tc.name: GetCurrentPageNameCallback 3084 * @tc.desc: Test FlushDirtyPropertyNodes of pipeline_context 3085 * @tc.type: FUNC 3086 */ 3087 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg229, TestSize.Level1) 3088 { 3089 /** 3090 * @tc.steps1: initialize parameters. 3091 * @tc.expected: All pointer is non-null. 3092 */ 3093 ASSERT_NE(context_, nullptr); 3094 RefPtr<FrameNode> frameNode1 = FrameNode::GetOrCreateFrameNode("frameNode1", 1, nullptr); 3095 RefPtr<FrameNode> frameNode2 = FrameNode::GetOrCreateFrameNode("frameNode2", 2, nullptr); 3096 RefPtr<FrameNode> frameNode3 = FrameNode::GetOrCreateFrameNode("frameNode3", 3, nullptr); 3097 context_->dirtyPropertyNodes_.emplace(frameNode1); 3098 context_->dirtyPropertyNodes_.emplace(frameNode2); 3099 context_->dirtyPropertyNodes_.emplace(frameNode3); 3100 3101 context_->FlushDirtyPropertyNodes(); 3102 auto size = context_->dirtyPropertyNodes_.size(); 3103 EXPECT_EQ(size, 0); 3104 } 3105 3106 /** 3107 * @tc.name: GetCurrentPageNameCallback 3108 * @tc.desc: Test FlushDirtyPropertyNodes of pipeline_context 3109 * @tc.type: FUNC 3110 */ 3111 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg230, TestSize.Level1) 3112 { 3113 /** 3114 * @tc.steps1: initialize parameters. 3115 * @tc.expected: All pointer is non-null. 3116 */ 3117 ASSERT_NE(context_, nullptr); 3118 /** 3119 * @tc.steps: make !CheckThreadSafe() is true. 3120 */ 3121 auto taskExecutor = context_->taskExecutor_; 3122 ASSERT_NE(taskExecutor, nullptr); 3123 context_->SetIsFormRender(false); 3124 3125 context_->dirtyPropertyNodes_.clear(); 3126 context_->FlushDirtyPropertyNodes(); 3127 auto size = context_->dirtyPropertyNodes_.size(); 3128 EXPECT_EQ(size, 0); 3129 } 3130 3131 /** 3132 * @tc.name: GetCurrentPageNameCallback 3133 * @tc.desc: Test FlushDragEvents of pipeline_context 3134 * @tc.type: FUNC 3135 */ 3136 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg231, TestSize.Level1) 3137 { 3138 /** 3139 * @tc.steps1: initialize parameters. 3140 * @tc.expected: All pointer is non-null. 3141 */ 3142 ASSERT_NE(context_, nullptr); 3143 /** 3144 * @tc.steps: make dragDropManager_ is nullptr. 3145 */ 3146 context_->dragDropManager_ = nullptr; 3147 context_->FlushDragEvents(); 3148 auto isEmpty = context_->dragEvents_.empty(); 3149 EXPECT_TRUE(isEmpty); 3150 } 3151 3152 /** 3153 * @tc.name: GetCurrentPageNameCallback 3154 * @tc.desc: Test FlushDragEvents of pipeline_context 3155 * @tc.type: FUNC 3156 */ 3157 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg232, TestSize.Level1) 3158 { 3159 /** 3160 * @tc.steps1: initialize parameters. 3161 * @tc.expected: All pointer is non-null. 3162 */ 3163 ASSERT_NE(context_, nullptr); 3164 /** 3165 * @tc.steps: make dragDropManager_ is not nullptr. 3166 */ 3167 auto manager = AceType::MakeRefPtr<DragDropManager>(); 3168 ASSERT_NE(manager, nullptr); 3169 manager->SetDragFwkShow(true); 3170 context_->dragDropManager_ = manager; 3171 /** 3172 * @tc.steps: make context_->dragEvents_.empty() is true. 3173 */ 3174 context_->dragEvents_.clear(); 3175 3176 context_->FlushDragEvents(); 3177 auto isEmpty = context_->nodeToPointEvent_.empty(); 3178 EXPECT_TRUE(isEmpty); 3179 EXPECT_TRUE(context_->canUseLongPredictTask_); 3180 } 3181 3182 /** 3183 * @tc.name: GetCurrentPageNameCallback 3184 * @tc.desc: Test FlushDragEvents of pipeline_context 3185 * @tc.type: FUNC 3186 */ 3187 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg233, TestSize.Level1) 3188 { 3189 /** 3190 * @tc.steps1: initialize parameters. 3191 * @tc.expected: All pointer is non-null. 3192 */ 3193 ASSERT_NE(context_, nullptr); 3194 /** 3195 * @tc.steps: make dragDropManager_ is not nullptr. 3196 */ 3197 auto manager = AceType::MakeRefPtr<DragDropManager>(); 3198 ASSERT_NE(manager, nullptr); 3199 manager->SetDragFwkShow(true); 3200 context_->dragDropManager_ = manager; 3201 3202 /** 3203 * @tc.steps: make context_->dragEvents_.empty() is false. 3204 */ 3205 RefPtr<FrameNode> frameNode1 = FrameNode::GetOrCreateFrameNode("frameNode1", 1, nullptr); 3206 RefPtr<FrameNode> frameNode2 = FrameNode::GetOrCreateFrameNode("frameNode2", 2, nullptr); 3207 DragPointerEvent dragPointEvent1; 3208 dragPointEvent1.pointerEventId = 1; 3209 dragPointEvent1.windowX = 0.0f; 3210 dragPointEvent1.windowY = 10.0f; 3211 dragPointEvent1.displayX = 0.0; 3212 dragPointEvent1.displayY = 0.0; 3213 3214 DragPointerEvent dragPointEvent2; 3215 dragPointEvent2.pointerEventId = 1; 3216 dragPointEvent2.windowX = 0.0f; 3217 dragPointEvent2.windowY = 10.0f; 3218 dragPointEvent2.displayX = 0.0; 3219 dragPointEvent2.displayY = 10.0; 3220 3221 context_->dragEvents_[frameNode1].emplace_back(dragPointEvent1); 3222 context_->dragEvents_[frameNode2].emplace_back(dragPointEvent2); 3223 auto isEmpty = context_->nodeToPointEvent_.empty(); 3224 EXPECT_TRUE(isEmpty); 3225 context_->FlushDragEvents(); 3226 isEmpty = context_->nodeToPointEvent_.empty(); 3227 EXPECT_FALSE(isEmpty); 3228 EXPECT_FALSE(context_->canUseLongPredictTask_); 3229 } 3230 3231 /** 3232 * @tc.name: PipelineContextTestNg234 3233 * @tc.desc: Test the function SetNeedRenderForDrawChildrenNode. 3234 * @tc.type: FUNC 3235 */ 3236 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg234, TestSize.Level1) 3237 { 3238 /** 3239 * @tc.steps1: initialize parameters. 3240 * @tc.expected: All pointer is non-null. 3241 */ 3242 ASSERT_NE(context_, nullptr); 3243 ASSERT_TRUE(context_->needRenderForDrawChildrenNodes_.empty()); 3244 /** 3245 * @tc.steps2: Call the function FlushAnimation with unempty scheduleTasks_. 3246 * @tc.expected: The nanoTimestamp of scheduleTask is equal to NANO_TIME_STAMP. 3247 */ 3248 auto pattern = AceType::MakeRefPtr<Pattern>(); 3249 auto frameNode = FrameNode::CreateFrameNode(TEST_TAG, 3, pattern); 3250 context_->SetNeedRenderForDrawChildrenNode(WeakPtr<FrameNode>(frameNode)); 3251 EXPECT_EQ(context_->needRenderForDrawChildrenNodes_.count(WeakPtr<FrameNode>(frameNode)), 1); 3252 3253 /** 3254 * @tc.steps3: Call the function FlushPipelineImmediately. 3255 * @tc.expected: The nanoTimestamp of scheduleTask is equal to NANO_TIME_STAMP. 3256 */ 3257 context_->FlushPipelineImmediately(); 3258 EXPECT_TRUE(context_->isRebuildFinished_); 3259 } 3260 3261 /** 3262 * @tc.name: PipelineContextTestNg235 3263 * @tc.desc: Test the function SetNeedRenderForDrawChildrenNode. 3264 * @tc.type: FUNC 3265 */ 3266 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg235, TestSize.Level1) 3267 { 3268 /** 3269 * @tc.steps1: initialize parameters. 3270 * @tc.expected: All pointer is non-null. 3271 */ 3272 ASSERT_NE(context_, nullptr); 3273 3274 auto needRenderNodeId = ElementRegister::GetInstance()->MakeUniqueId(); 3275 auto needRenderNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, needRenderNodeId, nullptr); 3276 context_->SetNeedRenderForDrawChildrenNode(WeakPtr<FrameNode>(needRenderNode)); 3277 EXPECT_EQ(context_->needRenderForDrawChildrenNodes_.count(WeakPtr<FrameNode>(needRenderNode)), 1); 3278 context_->InspectDrew(); 3279 EXPECT_EQ(context_->needRenderForDrawChildrenNodes_.count(WeakPtr<FrameNode>(needRenderNode)), 0); 3280 } 3281 3282 /** 3283 * @tc.name: PipelineContextTestNg236 3284 * @tc.desc: Test the function OnDrawChildrenCompleted. 3285 * @tc.type: FUNC 3286 */ 3287 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg236, TestSize.Level1) 3288 { 3289 /** 3290 * @tc.steps1: initialize parameters and call OnDrawChildrenCompleted function. 3291 * @tc.expected: weakFrontend_.Upgrade() is null. 3292 */ 3293 ASSERT_NE(context_, nullptr); 3294 context_->OnDrawChildrenCompleted(TEST_TAG); 3295 EXPECT_EQ(context_->weakFrontend_.Upgrade(), nullptr); 3296 } 3297 3298 /** 3299 * @tc.name: PipelineContextTestNg237 3300 * @tc.desc: Test the function OnDrawChildrenCompleted. 3301 * @tc.type: FUNC 3302 */ 3303 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg237, TestSize.Level1) 3304 { 3305 /** 3306 * @tc.steps1: initialize parameters. 3307 * @tc.expected: frontend-ptr is non-null. 3308 */ 3309 3310 ContainerScope scope(DEFAULT_INSTANCE_ID); 3311 ASSERT_NE(context_, nullptr); 3312 auto frontend = AceType::MakeRefPtr<MockFrontend>(); 3313 context_->weakFrontend_ = frontend; 3314 3315 /** 3316 * @tc.steps4: test the function OnDrawChildrenCompleted by TEST_TAG. 3317 * @tc.expected: frontend componentId_ is TEST_TAG 3318 */ 3319 context_->OnDrawChildrenCompleted(TEST_TAG); 3320 EXPECT_EQ(frontend->GetComponentId(), TEST_TAG); 3321 context_->weakFrontend_.Reset(); 3322 } 3323 3324 /** 3325 * @tc.name: PipelineContextTestNg238 3326 * @tc.desc: Test the function UpdateOcclusionCullingStatus. 3327 * @tc.type: FUNC 3328 */ 3329 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg238, TestSize.Level1) 3330 { 3331 /** 3332 * @tc.steps1: Add keyOcclusion node's id to occlusion map. 3333 * @tc.expected: The occlusion map's size is equal to the number of added nodes. 3334 */ 3335 ASSERT_NE(context_, nullptr); 3336 RefPtr<FrameNode> frameNode1 = FrameNode::CreateFrameNode("test1", 1, AceType::MakeRefPtr<Pattern>()); 3337 RefPtr<FrameNode> frameNode2 = FrameNode::CreateFrameNode("test2", 2, AceType::MakeRefPtr<Pattern>()); 3338 context_->AddToOcclusionMap(1, true); 3339 context_->AddToOcclusionMap(2, false); 3340 context_->AddToOcclusionMap(3, false); 3341 EXPECT_EQ(context_->keyOcclusionNodes_.size(), 3); 3342 3343 /** 3344 * @tc.steps2: Call the function UpdateOcclusionCullingStatus. 3345 * @tc.expected: The occlusion map's size is equal to 0. 3346 */ 3347 context_->UpdateOcclusionCullingStatus(); 3348 EXPECT_TRUE(context_->keyOcclusionNodes_.empty()); 3349 } 3350 3351 /** 3352 * @tc.name: PipelineContextTestNg239 3353 * @tc.desc: Test OnTouchEvent. 3354 * @tc.type: FUNC 3355 */ 3356 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg239, TestSize.Level1) 3357 { 3358 ASSERT_NE(context_, nullptr); 3359 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3360 TouchEvent event; 3361 event.type = TouchType::MOVE; 3362 event.id = 4; 3363 event.x = 70; 3364 event.y = 80; 3365 event.sourceType = SourceType::TOUCH; 3366 event.passThrough = false; 3367 context_->viewScale_ = 0; 3368 context_->OnTouchEvent(event, context_->rootNode_, false); 3369 } 3370 3371 /** 3372 * @tc.name: PipelineContextTestNg240 3373 * @tc.desc: Test OnTouchEvent. 3374 * @tc.type: FUNC 3375 */ 3376 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg240, TestSize.Level1) 3377 { 3378 ASSERT_NE(context_, nullptr); 3379 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3380 TouchEvent event; 3381 event.type = TouchType::MOVE; 3382 event.id = 4; 3383 event.x = 70; 3384 event.y = 80; 3385 event.sourceType = SourceType::TOUCH; 3386 event.passThrough = true; 3387 context_->viewScale_ = 0; 3388 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3389 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3390 context_->isEventsPassThrough_ = false; 3391 context_->eventManager_->passThroughResult_ = true; 3392 context_->OnTouchEvent(event, context_->rootNode_, false); 3393 EXPECT_EQ(context_->eventManager_->passThroughResult_, context_->postEventManager_->passThroughResult_); 3394 } 3395 3396 /** 3397 * @tc.name: PipelineContextTestNg241 3398 * @tc.desc: Test OnTouchEvent. 3399 * @tc.type: FUNC 3400 */ 3401 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg241, TestSize.Level1) 3402 { 3403 ASSERT_NE(context_, nullptr); 3404 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3405 TouchEvent event; 3406 event.type = TouchType::MOVE; 3407 event.id = 4; 3408 event.x = 70; 3409 event.y = 80; 3410 event.sourceType = SourceType::TOUCH; 3411 event.passThrough = false; 3412 context_->isEventsPassThrough_ = false; 3413 context_->viewScale_ = 0; 3414 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3415 context_->OnTouchEvent(event, context_->rootNode_, false); 3416 EXPECT_EQ(context_->instanceId_, 0); 3417 } 3418 3419 /** 3420 * @tc.name: PipelineContextTestNg242 3421 * @tc.desc: Test OnTouchEvent. 3422 * @tc.type: FUNC 3423 */ 3424 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg242, TestSize.Level1) 3425 { 3426 ASSERT_NE(context_, nullptr); 3427 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3428 TouchEvent event; 3429 event.type = TouchType::UP; 3430 event.id = 4; 3431 event.x = 70; 3432 event.y = 80; 3433 event.sourceType = SourceType::TOUCH; 3434 event.passThrough = false; 3435 context_->isEventsPassThrough_ = false; 3436 context_->viewScale_ = 0; 3437 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3438 context_->OnTouchEvent(event, context_->rootNode_, false); 3439 EXPECT_EQ(context_->eventManager_->passThroughResult_, context_->postEventManager_->passThroughResult_); 3440 } 3441 3442 /** 3443 * @tc.name: PipelineContextTestNg243 3444 * @tc.desc: Test OnTouchEvent. 3445 * @tc.type: FUNC 3446 */ 3447 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg243, TestSize.Level1) 3448 { 3449 ASSERT_NE(context_, nullptr); 3450 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3451 TouchEvent event; 3452 event.type = TouchType::UP; 3453 event.id = 4; 3454 event.x = 70; 3455 event.y = 80; 3456 event.sourceType = SourceType::TOUCH; 3457 event.passThrough = false; 3458 context_->isEventsPassThrough_ = false; 3459 context_->viewScale_ = 0; 3460 context_->postEventManager_ = nullptr; 3461 context_->OnTouchEvent(event, context_->rootNode_, false); 3462 EXPECT_EQ(context_->instanceId_, 0); 3463 } 3464 3465 /** 3466 * @tc.name: PipelineContextTestNg244 3467 * @tc.desc: Test OnTouchEvent. 3468 * @tc.type: FUNC 3469 */ 3470 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg244, TestSize.Level1) 3471 { 3472 ASSERT_NE(context_, nullptr); 3473 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3474 TouchEvent event; 3475 event.type = TouchType::UP; 3476 event.id = 4; 3477 event.x = 70; 3478 event.y = 80; 3479 event.sourceType = SourceType::TOUCH; 3480 event.passThrough = false; 3481 context_->isEventsPassThrough_ = false; 3482 context_->viewScale_ = 0; 3483 context_->postEventManager_ = nullptr; 3484 context_->OnTouchEvent(event, context_->rootNode_, false); 3485 EXPECT_EQ(context_->instanceId_, 0); 3486 } 3487 3488 /** 3489 * @tc.name: PipelineContextTestNg245 3490 * @tc.desc: Test OnMouseEvent. 3491 * @tc.type: FUNC 3492 */ 3493 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg245, TestSize.Level1) 3494 { 3495 ASSERT_NE(context_, nullptr); 3496 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3497 MouseEvent event; 3498 event.action = MouseAction::PRESS; 3499 event.passThrough = false; 3500 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3501 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3502 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3503 context_->OnMouseEvent(event, context_->rootNode_); 3504 EXPECT_EQ(context_->lastMouseEvent_->node, context_->rootNode_); 3505 } 3506 3507 /** 3508 * @tc.name: PipelineContextTestNg246 3509 * @tc.desc: Test OnMouseEvent. 3510 * @tc.type: FUNC 3511 */ 3512 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg246, TestSize.Level1) 3513 { 3514 ASSERT_NE(context_, nullptr); 3515 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3516 MouseEvent event; 3517 event.action = MouseAction::MOVE; 3518 event.passThrough = true; 3519 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3520 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3521 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3522 context_->OnMouseEvent(event, context_->rootNode_); 3523 EXPECT_EQ(context_->postEventManager_->passThroughResult_, context_->eventManager_->passThroughResult_); 3524 } 3525 3526 /** 3527 * @tc.name: PipelineContextTestNg247 3528 * @tc.desc: Test OnMouseEvent. 3529 * @tc.type: FUNC 3530 */ 3531 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg247, TestSize.Level1) 3532 { 3533 ASSERT_NE(context_, nullptr); 3534 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3535 MouseEvent event; 3536 event.action = MouseAction::MOVE; 3537 event.passThrough = false; 3538 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3539 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3540 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3541 context_->OnMouseEvent(event, context_->rootNode_); 3542 EXPECT_EQ(context_->lastMouseEvent_->node, context_->rootNode_); 3543 } 3544 3545 /** 3546 * @tc.name: PipelineContextTestNg248 3547 * @tc.desc: Test OnMouseEvent. 3548 * @tc.type: FUNC 3549 */ 3550 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg248, TestSize.Level1) 3551 { 3552 ASSERT_NE(context_, nullptr); 3553 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3554 MouseEvent event; 3555 event.action = MouseAction::PRESS; 3556 event.passThrough = true; 3557 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3558 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3559 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3560 context_->OnMouseEvent(event, context_->rootNode_); 3561 EXPECT_EQ(context_->lastMouseEvent_->node, context_->rootNode_); 3562 } 3563 3564 /** 3565 * @tc.name: PipelineContextTestNg249 3566 * @tc.desc: Test OnMouseEvent. 3567 * @tc.type: FUNC 3568 */ 3569 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg249, TestSize.Level1) 3570 { 3571 ASSERT_NE(context_, nullptr); 3572 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3573 MouseEvent event; 3574 event.action = MouseAction::PRESS; 3575 event.passThrough = false; 3576 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3577 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3578 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3579 context_->OnMouseEvent(event, context_->rootNode_); 3580 EXPECT_EQ(context_->lastMouseEvent_->node, context_->rootNode_); 3581 } 3582 3583 /** 3584 * @tc.name: PipelineContextTestNg250 3585 * @tc.desc: Test OnMouseEvent. 3586 * @tc.type: FUNC 3587 */ 3588 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg250, TestSize.Level1) 3589 { 3590 ASSERT_NE(context_, nullptr); 3591 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3592 MouseEvent event; 3593 event.action = MouseAction::MOVE; 3594 event.passThrough = true; 3595 context_->postEventManager_ = nullptr; 3596 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3597 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3598 context_->OnMouseEvent(event, context_->rootNode_); 3599 EXPECT_EQ(context_->lastMouseEvent_->node, context_->rootNode_); 3600 } 3601 3602 /** 3603 * @tc.name: PipelineContextTestNg251 3604 * @tc.desc: Test OnAxisEvent. 3605 * @tc.type: FUNC 3606 */ 3607 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg251, TestSize.Level1) 3608 { 3609 ASSERT_NE(context_, nullptr); 3610 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3611 AxisEvent event; 3612 event.action = AxisAction::CANCEL; 3613 context_->postEventManager_ = AceType::MakeRefPtr<PostEventManager>(); 3614 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3615 context_->postEventManager_->passThroughResult_ = false; 3616 context_->eventManager_->passThroughResult_ = true; 3617 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3618 context_->OnAxisEvent(event, context_->rootNode_); 3619 EXPECT_NE(context_->postEventManager_->passThroughResult_, context_->eventManager_->passThroughResult_); 3620 } 3621 3622 /** 3623 * @tc.name: PipelineContextTestNg252 3624 * @tc.desc: Test OnAxisEvent. 3625 * @tc.type: FUNC 3626 */ 3627 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg252, TestSize.Level1) 3628 { 3629 ASSERT_NE(context_, nullptr); 3630 context_->rootNode_ = AceType::MakeRefPtr<FrameNode>("test1", 1, AceType::MakeRefPtr<Pattern>()); 3631 AxisEvent event; 3632 event.action = AxisAction::CANCEL; 3633 context_->postEventManager_ = nullptr; 3634 context_->eventManager_ = AceType::MakeRefPtr<EventManager>(); 3635 context_->eventManager_->passThroughResult_ = true; 3636 context_->accessibilityManagerNG_ = AceType::MakeRefPtr<AccessibilityManagerNG>(); 3637 context_->dragDropManager_ = AceType::MakeRefPtr<DragDropManager>(); 3638 context_->OnAxisEvent(event, context_->rootNode_); 3639 EXPECT_FALSE(context_->dragDropManager_->isDragCancel_); 3640 } 3641 3642 /** 3643 * @tc.name: PipelineContextTestNg253 3644 * @tc.desc: Test the function SetAreaChangeNodeMinDepth. 3645 * @tc.type: FUNC 3646 */ 3647 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg253, TestSize.Level1) 3648 { 3649 /** 3650 * @tc.expected: The initialize val is -1. 3651 */ 3652 context_->areaChangeNodeMinDepth_ = -1; 3653 ASSERT_NE(context_, nullptr); 3654 EXPECT_EQ(context_->areaChangeNodeMinDepth_, -1); 3655 3656 /** 3657 * @tc.steps2: Call the function SetAreaChangeNodeMinDepth and set val 10. 3658 * @tc.expected: The areaChangeNodeMinDepth_ is equal to 10. 3659 */ 3660 context_->SetAreaChangeNodeMinDepth(10); 3661 EXPECT_EQ(context_->areaChangeNodeMinDepth_, 10); 3662 3663 /** 3664 * @tc.steps3: Call the function SetAreaChangeNodeMinDepth and set val 5. 3665 * @tc.expected: The areaChangeNodeMinDepth_ is equal to 5. 3666 */ 3667 context_->SetAreaChangeNodeMinDepth(5); 3668 EXPECT_EQ(context_->areaChangeNodeMinDepth_, 5); 3669 3670 /** 3671 * @tc.steps4: Call the function SetAreaChangeNodeMinDepth and set val 10. 3672 * @tc.expected: The areaChangeNodeMinDepth_ is equal to 5. 3673 */ 3674 context_->SetAreaChangeNodeMinDepth(10); 3675 EXPECT_EQ(context_->areaChangeNodeMinDepth_, 5); 3676 } 3677 3678 3679 /** 3680 * @tc.name: PipelineContextTestNg254 3681 * @tc.desc: Test the function SetIsDisappearChangeNodeMinDepth. 3682 * @tc.type: FUNC 3683 */ 3684 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg254, TestSize.Level1) 3685 { 3686 /** 3687 * @tc.expected: The initialize val is -1. 3688 */ 3689 context_->isDisappearChangeNodeMinDepth_ = -1; 3690 ASSERT_NE(context_, nullptr); 3691 EXPECT_EQ(context_->isDisappearChangeNodeMinDepth_, -1); 3692 3693 /** 3694 * @tc.steps2: Call the function SetIsDisappearChangeNodeMinDepth and set val 10. 3695 * @tc.expected: The isDisappearChangeNodeMinDepth_ is equal to 10. 3696 */ 3697 context_->SetIsDisappearChangeNodeMinDepth(10); 3698 EXPECT_EQ(context_->isDisappearChangeNodeMinDepth_, 10); 3699 3700 /** 3701 * @tc.steps3: Call the function SetIsDisappearChangeNodeMinDepth and set val 5. 3702 * @tc.expected: The isDisappearChangeNodeMinDepth_ is equal to 5. 3703 */ 3704 context_->SetIsDisappearChangeNodeMinDepth(5); 3705 EXPECT_EQ(context_->isDisappearChangeNodeMinDepth_, 5); 3706 3707 /** 3708 * @tc.steps4: Call the function SetIsDisappearChangeNodeMinDepth and set val 10. 3709 * @tc.expected: The isDisappearChangeNodeMinDepth_ is equal to 5. 3710 */ 3711 context_->SetIsDisappearChangeNodeMinDepth(10); 3712 EXPECT_EQ(context_->isDisappearChangeNodeMinDepth_, 5); 3713 } 3714 3715 /** 3716 * @tc.name: PipelineContextTestNg302 3717 * @tc.desc: Test FlushRenderTask. 3718 * @tc.type: FUNC 3719 */ 3720 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg302, TestSize.Level1) 3721 { 3722 /** 3723 * @tc.steps1: Test CheckIfGetTheme. 3724 */ 3725 ASSERT_NE(context_, nullptr); 3726 context_->SetIsJsCard(false); 3727 context_->SetIsFormRender(false); 3728 auto result = context_->CheckIfGetTheme(); 3729 EXPECT_TRUE(result); 3730 3731 context_->SetIsJsCard(true); 3732 context_->SetIsFormRender(false); 3733 result = context_->CheckIfGetTheme(); 3734 EXPECT_FALSE(result); 3735 3736 context_->SetIsJsCard(false); 3737 context_->SetIsFormRender(true); 3738 result = context_->CheckIfGetTheme(); 3739 EXPECT_FALSE(result); 3740 3741 context_->SetIsJsCard(true); 3742 context_->SetIsFormRender(true); 3743 result = context_->CheckIfGetTheme(); 3744 EXPECT_FALSE(result); 3745 3746 auto container = MockContainer::Current(); 3747 EXPECT_TRUE(container); 3748 container->SetUIContentType(UIContentType::DYNAMIC_COMPONENT); 3749 context_->SetIsJsCard(false); 3750 context_->SetIsFormRender(false); 3751 result = context_->CheckIfGetTheme(); 3752 EXPECT_TRUE(result); 3753 3754 context_->SetIsJsCard(true); 3755 context_->SetIsFormRender(false); 3756 result = context_->CheckIfGetTheme(); 3757 EXPECT_FALSE(result); 3758 3759 context_->SetIsJsCard(false); 3760 context_->SetIsFormRender(true); 3761 result = context_->CheckIfGetTheme(); 3762 EXPECT_TRUE(result); 3763 3764 context_->SetIsJsCard(true); 3765 context_->SetIsFormRender(true); 3766 result = context_->CheckIfGetTheme(); 3767 EXPECT_FALSE(result); 3768 } 3769 3770 /** 3771 * @tc.name: PipelineContextTestNgAvoidance 3772 * @tc.desc: Test AvoidanceLogic. 3773 * @tc.type: FUNC 3774 */ 3775 HWTEST_F(PipelineContextTestNg, PipelineContextTestNgAvoidance, TestSize.Level1) 3776 { 3777 auto pipeline = PipelineContext::GetMainPipelineContext(); 3778 EXPECT_NE(pipeline, nullptr); 3779 pipeline->rootHeight_ = 400.0f; 3780 EXPECT_EQ(pipeline->GetCurrentRootHeight(), 400.0f); 3781 pipeline->AvoidanceLogic(0.0); 3782 auto keyboardOffset = pipeline->safeAreaManager_->GetKeyboardOffset(); 3783 EXPECT_EQ(keyboardOffset, 0.0f); 3784 } 3785 3786 /** 3787 * @tc.name: PipelineContextTestNg255 3788 * @tc.desc: Test FlushMouseEventForHover. 3789 * @tc.type: FUNC 3790 */ 3791 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg255, TestSize.Level1) 3792 { 3793 /** 3794 * @tc.steps1: initialize parameters. 3795 * @tc.expected: All pointer is non-null. 3796 */ 3797 ASSERT_NE(context_, nullptr); 3798 context_->SetupRootElement(); 3799 auto manager = context_->GetDragDropManager(); 3800 ASSERT_NE(manager, nullptr); 3801 auto frameNodeId_017 = ElementRegister::GetInstance()->MakeUniqueId(); 3802 auto frameNode = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_017, nullptr); 3803 ASSERT_NE(frameNode, nullptr); 3804 3805 /** 3806 * @tc.steps2: Call the function OnDragEvent with isDragged_=true, currentId_=DEFAULT_INT1 and DRAG_EVENT_OUT. 3807 * @tc.expected: The currentId_ is equal to DEFAULT_INT1. 3808 */ 3809 manager->isDragged_ = true; 3810 manager->currentId_ = DEFAULT_INT1; 3811 context_->OnDragEvent({ DEFAULT_INT1, DEFAULT_INT1 }, DragEventAction::DRAG_EVENT_OUT); 3812 EXPECT_EQ(manager->currentId_, DEFAULT_INT1); 3813 3814 auto delegate = AceType::MakeRefPtr<TouchDelegate>(); 3815 std::unordered_map<int32_t, TouchDelegates> touchDelegatesMap; 3816 touchDelegatesMap[0].emplace_back(delegate); 3817 context_->eventManager_->touchDelegatesMap_ = touchDelegatesMap; 3818 context_->OnDragEvent({ DEFAULT_INT1, DEFAULT_INT1 }, DragEventAction::DRAG_EVENT_OUT); 3819 EXPECT_EQ(manager->currentId_, DEFAULT_INT1); 3820 } 3821 3822 /** 3823 * @tc.name: ExeAppAIFunctionCallback 3824 * @tc.desc: Test ExeAppAIFunctionCallback of pipeline_context 3825 * @tc.type: FUNC 3826 */ 3827 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg256, TestSize.Level1) 3828 { 3829 /** 3830 * @tc.steps1: initialize parameters. 3831 * @tc.expected: All pointer is non-null. 3832 */ 3833 ASSERT_NE(context_, nullptr); 3834 3835 /** 3836 * @tc.steps2: make rootNode_ is nullptr. 3837 */ 3838 context_->rootNode_ = nullptr; 3839 EXPECT_EQ(context_->rootNode_, nullptr); 3840 3841 uint32_t result = context_->ExeAppAIFunctionCallback("Success", ""); 3842 EXPECT_EQ(result, AI_CALL_NODE_INVALID); 3843 } 3844 3845 /** 3846 * @tc.name: ExeAppAIFunctionCallback 3847 * @tc.desc: Test ExeAppAIFunctionCallback of pipeline_context 3848 * @tc.type: FUNC 3849 */ 3850 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg257, TestSize.Level1) 3851 { 3852 /** 3853 * @tc.steps1: initialize parameters. 3854 * @tc.expected: All pointer is non-null. 3855 */ 3856 ASSERT_NE(context_, nullptr); 3857 3858 /** 3859 * @tc.steps2: Ensure that rootNode_ is not nullptr. 3860 */ 3861 auto rootNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<Pattern>(), true); 3862 context_->rootNode_ = rootNode; 3863 ASSERT_NE(context_->rootNode_, nullptr); 3864 3865 /** 3866 * @tc.steps3: topNavNode cannot be found. 3867 */ 3868 uint32_t result = context_->ExeAppAIFunctionCallback("Success", ""); 3869 EXPECT_EQ(result, AI_CALL_NODE_INVALID); 3870 } 3871 3872 /** 3873 * @tc.name: ExeAppAIFunctionCallback 3874 * @tc.desc: Test ExeAppAIFunctionCallback of pipeline_context 3875 * @tc.type: FUNC 3876 */ 3877 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg258, TestSize.Level1) 3878 { 3879 /** 3880 * @tc.steps1: initialize parameters. 3881 * @tc.expected: All pointer is non-null. 3882 */ 3883 ASSERT_NE(context_, nullptr); 3884 3885 /** 3886 * @tc.steps2: Ensure that rootNode_ is not nullptr. 3887 */ 3888 auto rootNode = FrameNode::CreateFrameNode("root", 1, AceType::MakeRefPtr<Pattern>(), true); 3889 context_->rootNode_ = rootNode; 3890 ASSERT_NE(context_->rootNode_, nullptr); 3891 3892 /** 3893 * @tc.steps3: make navigationGroupNode. 3894 */ 3895 auto navigationGroupNode = NavigationGroupNode::GetOrCreateGroupNode( __anonaf4252cb1602() 3896 V2::NAVIGATION_VIEW_ETS_TAG, 11, []() { return AceType::MakeRefPtr<NavigationPattern>(); } 3897 ); 3898 RefPtr<NavigationPattern> navigationPattern = navigationGroupNode->GetPattern<NavigationPattern>(); 3899 navigationPattern->navigationStack_ = AceType::MakeRefPtr<NavigationStack>(); 3900 rootNode->AddChild(navigationGroupNode); 3901 3902 /** 3903 * @tc.steps4: make some NavDestinationNode. 3904 */ 3905 auto navDestinationNode1 = FrameNode::CreateFrameNode( 3906 V2::NAVDESTINATION_VIEW_ETS_TAG, 21, AceType::MakeRefPtr<Pattern>(), true); 3907 auto navDestinationNode2 = FrameNode::CreateFrameNode( 3908 V2::NAVDESTINATION_VIEW_ETS_TAG, 22, AceType::MakeRefPtr<Pattern>(), true); 3909 auto navDestinationNode3 = FrameNode::CreateFrameNode( 3910 V2::NAVDESTINATION_VIEW_ETS_TAG, 23, AceType::MakeRefPtr<Pattern>(), true); 3911 auto navDestinationNode4 = FrameNode::CreateFrameNode( 3912 V2::NAVDESTINATION_VIEW_ETS_TAG, 24, AceType::MakeRefPtr<Pattern>(), true); 3913 NavPathList navPathList; 3914 navPathList.emplace_back(std::make_pair("pageOne", navDestinationNode1)); 3915 navPathList.emplace_back(std::make_pair("pageTwo", navDestinationNode2)); 3916 navPathList.emplace_back(std::make_pair("pageThree", navDestinationNode3)); 3917 navPathList.emplace_back(std::make_pair("pageFour", navDestinationNode4)); 3918 navigationPattern->navigationStack_->SetNavPathList(navPathList); 3919 3920 uint32_t result = context_->ExeAppAIFunctionCallback("Success", ""); 3921 EXPECT_EQ(result, AI_CALLER_INVALID); 3922 } 3923 3924 /** 3925 * @tc.name: OnDumpBindAICaller 3926 * @tc.desc: Test OnDumpBindAICaller. 3927 * @tc.type: FUNC 3928 */ 3929 HWTEST_F(PipelineContextTestNg, PipelineContextTestNg259, TestSize.Level1) 3930 { 3931 /** 3932 * @tc.steps1: initialize parameters. 3933 * @tc.expected: context_ is not null. 3934 */ 3935 ASSERT_NE(context_, nullptr); 3936 auto rootNode = FrameNode::CreateFrameNode("root", 1, AceType::MakeRefPtr<Pattern>(), true); 3937 context_->rootNode_ = rootNode; 3938 ASSERT_NE(context_->rootNode_, nullptr); 3939 3940 /** 3941 * @tc.steps2: make navigationGroupNode. 3942 */ 3943 auto navigationGroupNode = NavigationGroupNode::GetOrCreateGroupNode( __anonaf4252cb1702() 3944 V2::NAVIGATION_VIEW_ETS_TAG, 11, []() { return AceType::MakeRefPtr<NavigationPattern>(); } 3945 ); 3946 RefPtr<NavigationPattern> navigationPattern = navigationGroupNode->GetPattern<NavigationPattern>(); 3947 navigationPattern->navigationStack_ = AceType::MakeRefPtr<NavigationStack>(); 3948 rootNode->AddChild(navigationGroupNode); 3949 3950 /** 3951 * @tc.steps3: make some NavDestinationNode. 3952 */ 3953 auto navDestinationNode1 = FrameNode::CreateFrameNode( 3954 V2::NAVDESTINATION_VIEW_ETS_TAG, 21, AceType::MakeRefPtr<Pattern>(), true); 3955 auto navDestinationNode2 = FrameNode::CreateFrameNode( 3956 V2::NAVDESTINATION_VIEW_ETS_TAG, 22, AceType::MakeRefPtr<Pattern>(), true); 3957 auto navDestinationNode3 = FrameNode::CreateFrameNode( 3958 V2::NAVDESTINATION_VIEW_ETS_TAG, 23, AceType::MakeRefPtr<Pattern>(), true); 3959 auto navDestinationNode4 = FrameNode::CreateFrameNode( 3960 V2::NAVDESTINATION_VIEW_ETS_TAG, 24, AceType::MakeRefPtr<Pattern>(), true); 3961 NavPathList navPathList; 3962 navPathList.emplace_back(std::make_pair("pageOne", navDestinationNode1)); 3963 navPathList.emplace_back(std::make_pair("pageTwo", navDestinationNode2)); 3964 navPathList.emplace_back(std::make_pair("pageThree", navDestinationNode3)); 3965 navPathList.emplace_back(std::make_pair("pageFour", navDestinationNode4)); 3966 navigationPattern->navigationStack_->SetNavPathList(navPathList); 3967 3968 /** 3969 * @tc.steps4: find topNavNode. 3970 * @tc.expected: topNavNode found. 3971 */ 3972 RefPtr<FrameNode> topNavNode; 3973 rootNode->FindTopNavDestination(topNavNode); 3974 ASSERT_NE(topNavNode, nullptr); 3975 EXPECT_EQ(topNavNode, navDestinationNode4); 3976 3977 /** 3978 * @tc.steps5: Call the function OnDumpBindAICaller. 3979 * @tc.expected: topNavNode->CallAIFunction result is AI_CALL_SUCCESS. 3980 */ 3981 std::vector<std::string> params; 3982 params.push_back("-bindaihelper"); 3983 params.push_back("-bind"); 3984 EXPECT_EQ(params.size(), 2); 3985 context_->OnDumpBindAICaller(params); 3986 auto result = topNavNode->CallAIFunction("Success", ""); 3987 EXPECT_EQ(result, AI_CALL_SUCCESS); 3988 3989 /** 3990 * @tc.steps6: Call the function OnDumpBindAICaller. 3991 * @tc.expected: topNavNode->CallAIFunction result is AI_CALLER_INVALID. 3992 */ 3993 params.clear(); 3994 params.push_back("-bindaihelper"); 3995 params.push_back("-unbind"); 3996 EXPECT_EQ(params.size(), 2); 3997 context_->OnDumpBindAICaller(params); 3998 result = topNavNode->CallAIFunction("Success", ""); 3999 EXPECT_EQ(result, AI_CALLER_INVALID); 4000 4001 /** 4002 * @tc.steps7: Call the function OnDumpBindAICaller. 4003 * @tc.expected: topNavNode->CallAIFunction result is AI_CALLER_INVALID. 4004 */ 4005 params.clear(); 4006 EXPECT_EQ(params.size(), 0); 4007 context_->OnDumpBindAICaller(params); 4008 result = topNavNode->CallAIFunction("Success", ""); 4009 EXPECT_EQ(result, AI_CALLER_INVALID); 4010 } 4011 } // namespace NG 4012 } // namespace OHOS::Ace 4013