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 #include "test/mock/base/mock_task_executor.h" 16 #include "test/mock/core/render/mock_canvas_image.h" 17 #include "test/unittest/core/base/frame_node_test_ng.h" 18 19 #include "frameworks/core/common/recorder/event_recorder.h" 20 #include "frameworks/core/common/recorder/node_data_cache.h" 21 #include "frameworks/core/components_ng/pattern/image/image_pattern.h" 22 #include "frameworks/core/components_ng/pattern/stage/page_pattern.h" 23 24 using namespace testing; 25 using namespace testing::ext; 26 27 namespace OHOS::Ace::NG { 28 namespace {} // namespace 29 30 /** 31 * @tc.name: FrameNodeGetIsLayoutNode01 32 * @tc.desc: Test the function GetIsLayoutNode 33 * @tc.type: FUNC 34 */ 35 HWTEST_F(FrameNodeTestNg, FrameNodeGetIsLayoutNode01, TestSize.Level1) 36 { 37 /** 38 * @tc.steps1: call the function GetIsLayoutNode. 39 * @tc.expected: Value returned as expected. 40 */ 41 RefPtr<FrameNode> node = FrameNode::CreateCommonNode("node", 1, false, AceType::MakeRefPtr<Pattern>()); 42 EXPECT_FALSE(node->GetIsLayoutNode()); 43 } 44 45 /** 46 * @tc.name: FrameNodeGetIsLayoutNode02 47 * @tc.desc: Test the function GetIsLayoutNode 48 * @tc.type: FUNC 49 */ 50 HWTEST_F(FrameNodeTestNg, FrameNodeGetIsLayoutNode02, TestSize.Level1) 51 { 52 /** 53 * @tc.steps1: call the function GetIsLayoutNode. 54 * @tc.expected: Value returned as expected. 55 */ 56 RefPtr<FrameNode> node = FrameNode::CreateCommonNode("node", 1, true, AceType::MakeRefPtr<Pattern>()); 57 EXPECT_TRUE(node->GetIsLayoutNode()); 58 } 59 60 /** 61 * @tc.name: FrameNodeSetIsFindGetIsFind01 62 * @tc.desc: Test the function SetIsFind GetIsFind 63 * @tc.type: FUNC 64 */ 65 HWTEST_F(FrameNodeTestNg, FrameNodeSetIsFindGetIsFind01, TestSize.Level1) 66 { 67 /** 68 * @tc.steps1: call the function SetIsFind GetIsFind. 69 * @tc.expected: Value returned as expected. 70 */ 71 RefPtr<FrameNode> node = FrameNode::CreateFrameNode("node", 1, AceType::MakeRefPtr<Pattern>()); 72 node->SetIsFind(true); 73 EXPECT_TRUE(node->GetIsFind()); 74 } 75 76 /** 77 * @tc.name: FrameNodeSetIsFindGetIsFind02 78 * @tc.desc: Test the function SetIsFind GetIsFind 79 * @tc.type: FUNC 80 */ 81 HWTEST_F(FrameNodeTestNg, FrameNodeSetIsFindGetIsFind02, TestSize.Level1) 82 { 83 /** 84 * @tc.steps1: call the function SetIsFind GetIsFind. 85 * @tc.expected: Value returned as expected. 86 */ 87 RefPtr<FrameNode> node = FrameNode::CreateFrameNode("node", 1, AceType::MakeRefPtr<Pattern>()); 88 node->SetIsFind(false); 89 EXPECT_FALSE(node->GetIsFind()); 90 } 91 92 /** 93 * @tc.name: FrameNodeGetOneDepthVisibleFrame01 94 * @tc.desc: Test the function GetOneDepthVisibleFrame 95 * @tc.type: FUNC 96 */ 97 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrame01, TestSize.Level1) 98 { 99 /** 100 * @tc.steps: step1. create frameNode ,childNode and overlayNode. 101 */ 102 auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true); 103 auto childNode = 104 FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode 105 auto overlayNode = 106 FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), true); // 3 is id of overlayNode 107 108 /** 109 * @tc.steps: step2. add childnode to the childnode list 110 */ 111 std::list<RefPtr<FrameNode>> children; 112 children.push_back(childNode); 113 node->frameChildren_ = { children.begin(), children.end() }; 114 115 /** 116 * @tc.steps: step3. call the function GetOneDepthVisibleFrame. 117 */ 118 node->SetOverlayNode(overlayNode); 119 node->GetOneDepthVisibleFrame(children); 120 } 121 122 /** 123 * @tc.name: FrameNodeGetOneDepthVisibleFrame02 124 * @tc.desc: Test the function GetOneDepthVisibleFrame 125 * @tc.type: FUNC 126 */ 127 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrame02, TestSize.Level1) 128 { 129 /** 130 * @tc.steps: step1. create frameNode ,childNode and overlayNode. 131 */ 132 auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true); 133 auto childNode = 134 FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode 135 auto overlayNode = nullptr; 136 137 /** 138 * @tc.steps: step2. add childnode to the childnode list 139 */ 140 std::list<RefPtr<FrameNode>> children; 141 children.push_back(childNode); 142 node->frameChildren_ = { children.begin(), children.end() }; 143 144 /** 145 * @tc.steps: step3. call the function GetOneDepthVisibleFrame. 146 */ 147 node->SetOverlayNode(overlayNode); 148 node->GetOneDepthVisibleFrame(children); 149 } 150 151 /** 152 * @tc.name: FrameNodeGetOneDepthVisibleFrameWithOffset01 153 * @tc.desc: Test the function GetOneDepthVisibleFrameWithOffset 154 * @tc.type: FUNC 155 */ 156 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrameWithOffset01, TestSize.Level1) 157 { 158 /** 159 * @tc.steps: step1. create frameNode ,childNode and overlayNode. 160 */ 161 auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true); 162 auto childNode = 163 FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode 164 auto overlayNode = 165 FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), true); // 3 is id of overlayNode 166 167 /** 168 * @tc.steps: step2. add childnode to the childnode list 169 */ 170 std::list<RefPtr<FrameNode>> children; 171 children.push_back(childNode); 172 node->frameChildren_ = { children.begin(), children.end() }; 173 174 /** 175 * @tc.steps: step3. call the function GetOneDepthVisibleFrameWithOffset. 176 */ 177 OffsetF Offset = { 0, 0 }; 178 node->SetOverlayNode(overlayNode); 179 node->GetOneDepthVisibleFrameWithOffset(children, Offset); 180 } 181 182 /** 183 * @tc.name: FrameNodeGetOneDepthVisibleFrameWithOffset02 184 * @tc.desc: Test the function GetOneDepthVisibleFrameWithOffset 185 * @tc.type: FUNC 186 */ 187 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrameWithOffset02, TestSize.Level1) 188 { 189 /** 190 * @tc.steps: step1. create frameNode ,childNode and overlayNode. 191 */ 192 auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true); 193 auto childNode = 194 FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode 195 auto overlayNode = nullptr; 196 197 /** 198 * @tc.steps: step2. add childnode to the childnode list 199 */ 200 std::list<RefPtr<FrameNode>> children; 201 children.push_back(childNode); 202 node->frameChildren_ = { children.begin(), children.end() }; 203 204 /** 205 * @tc.steps: step3. call the function GetOneDepthVisibleFrameWithOffset. 206 */ 207 OffsetF Offset = { 0, 0 }; 208 node->SetOverlayNode(overlayNode); 209 node->GetOneDepthVisibleFrameWithOffset(children, Offset); 210 } 211 212 /** 213 * @tc.name: FrameNodeGetOrCreateCommonNode01 214 * @tc.desc: Test the function GetOrCreateCommonNode 215 * @tc.type: FUNC 216 */ 217 HWTEST_F(FrameNodeTestNg, FrameNodeGetOrCreateCommonNode01, TestSize.Level1) 218 { 219 /** 220 * @tc.steps: step1: create commonNode. 221 */ 222 RefPtr<FrameNode> commonNode = FrameNode::CreateCommonNode("commonNode", 1, true, AceType::MakeRefPtr<Pattern>()); 223 EXPECT_TRUE(commonNode->GetIsLayoutNode()); 224 /** 225 * @tc.steps: step2: call the function GetOrCreateCommonNode. 226 * @tc.expected: Value returned as expected. 227 */ 228 auto blankNode = __anon023d61880202() 229 FrameNode::GetOrCreateCommonNode("commonNode", 1, false, []() { return AceType::MakeRefPtr<Pattern>(); }); 230 EXPECT_EQ(strcmp(blankNode->GetTag().c_str(), "commonNode"), 0); 231 EXPECT_FALSE(blankNode->GetIsLayoutNode()); 232 } 233 234 /** 235 * @tc.name: FrameNodeProcessOffscreenNode01 236 * @tc.desc: Test the function ProcessOffscreenNode 237 * @tc.type: FUNC 238 */ 239 HWTEST_F(FrameNodeTestNg, FrameNodeProcessOffscreenNode01, TestSize.Level1) 240 { 241 /** 242 * @tc.steps: step1. create frameNode and childNode. 243 */ 244 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 245 auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true); 246 auto childNodeOne = 247 FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNodeOne 248 auto childNodeTwo = nullptr; 249 250 /** 251 * @tc.steps: step2. add childnode to the predictLayoutNode list 252 */ 253 node->AddPredictLayoutNode(childNodeOne); 254 node->AddPredictLayoutNode(childNodeTwo); 255 256 /** 257 * @tc.steps: step3. call the function ProcessOffscreenNode. 258 */ 259 frameNode->ProcessOffscreenNode(node); 260 } 261 262 /** 263 * @tc.name: FrameNodeDumpAlignRulesInfo01 264 * @tc.desc: Test the function DumpAlignRulesInfo 265 * @tc.type: FUNC 266 */ 267 HWTEST_F(FrameNodeTestNg, FrameNodeDumpAlignRulesInfo01, TestSize.Level1) 268 { 269 /** 270 * @tc.steps: step1. create frameNode. 271 */ 272 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 273 274 /** 275 * @tc.steps: step2. create layoutProperty. 276 */ 277 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 278 layoutProperty->flexItemProperty_ = std::make_unique<FlexItemProperty>(); 279 std::map<AlignDirection, AlignRule> firstItemAlignRules; 280 AlignRule alignRule; 281 alignRule.anchor = "test"; 282 alignRule.horizontal = HorizontalAlign::START; 283 firstItemAlignRules[AlignDirection::LEFT] = alignRule; 284 285 layoutProperty->UpdateAlignRules(firstItemAlignRules); 286 layoutProperty->flexItemProperty_->propFlexGrow = 1.0f; 287 288 /** 289 * @tc.steps: step3. call the function DumpAlignRulesInfo. 290 */ 291 frameNode->SetLayoutProperty(layoutProperty); 292 frameNode->DumpAlignRulesInfo(); 293 } 294 295 /** 296 * @tc.name: FrameNodeDumpSafeAreaInfo01 297 * @tc.desc: Test the function DumpSafeAreaInfo 298 * @tc.type: FUNC 299 */ 300 HWTEST_F(FrameNodeTestNg, FrameNodeDumpSafeAreaInfo01, TestSize.Level1) 301 { 302 SafeAreaExpandOpts opts; 303 SafeAreaInsets safeArea; 304 SafeAreaExpandOpts expandOpts = { 305 .edges = SAFE_AREA_TYPE_SYSTEM, 306 .type = SAFE_AREA_EDGE_TOP, 307 }; 308 SafeAreaInsets::Inset inset = { 309 .start = 0, 310 .end = 1, 311 }; 312 313 SafeAreaInsets safeAreaInset(inset, inset, inset, inset); 314 /** 315 * @tc.steps: step1. create frameNode. 316 */ 317 auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 318 319 /** 320 * @tc.steps: step2. create layoutProperty. 321 */ 322 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 323 layoutProperty->safeAreaExpandOpts_ = std::make_unique<SafeAreaExpandOpts>(opts); 324 layoutProperty->safeAreaInsets_ = std::make_unique<SafeAreaInsets>(safeArea); 325 layoutProperty->UpdateSafeAreaExpandOpts(expandOpts); 326 layoutProperty->UpdateSafeAreaInsets(safeAreaInset); 327 EXPECT_EQ(layoutProperty->safeAreaExpandOpts_->edges, SAFE_AREA_TYPE_SYSTEM); 328 EXPECT_EQ(layoutProperty->safeAreaExpandOpts_->type, SAFE_AREA_EDGE_TOP); 329 330 /** 331 * @tc.steps: step3. call the function DumpSafeAreaInfo. 332 */ 333 frameNode->SetLayoutProperty(layoutProperty); 334 frameNode->DumpSafeAreaInfo(); 335 } 336 337 /** 338 * @tc.name: FrameNodeDumpCommonInfo01 339 * @tc.desc: Test the function DumpCommonInfo 340 * @tc.type: FUNC 341 */ 342 HWTEST_F(FrameNodeTestNg, FrameNodeDumpCommonInfo01, TestSize.Level1) 343 { 344 LayoutConstraintF layoutConstraintF = { 345 .minSize = { 1, 1 }, 346 .maxSize = { 10, 10 }, // 10 is the maxSize of width and height 347 .percentReference = { 5, 5 }, // 5 is the percentReference of width and height 348 .parentIdealSize = { 2, 2 }, // 2 is the parentIdealSize of width and height 349 }; 350 351 NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 352 353 /** 354 * @tc.steps: step1. create frameNode. 355 */ 356 auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 357 frameNode->AddChild(FRAME_NODE); 358 EXPECT_EQ(frameNode->GetTotalChildCount(), 1); 359 360 /** 361 * @tc.steps: step2. create layoutProperty. 362 */ 363 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 364 layoutProperty->propVisibility_ = VisibleType::INVISIBLE; 365 layoutProperty->SetLayoutRect(testRect); 366 layoutProperty->layoutConstraint_ = layoutConstraintF; 367 layoutProperty->contentConstraint_ = layoutConstraintF; 368 369 /** 370 * @tc.steps: step3. call the function DumpCommonInfo. 371 */ 372 frameNode->SetLayoutProperty(layoutProperty); 373 frameNode->DumpCommonInfo(); 374 } 375 376 /** 377 * @tc.name: FrameNodeDumpOnSizeChangeInfo01 378 * @tc.desc: Test the function DumpOnSizeChangeInfo 379 * @tc.type: FUNC 380 */ 381 HWTEST_F(FrameNodeTestNg, FrameNodeDumpOnSizeChangeInfo01, TestSize.Level1) 382 { 383 NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 384 NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 385 FrameNode::onSizeChangeDumpInfo dumpInfo1 { 1, testLastFrameRect, 386 testCurrFrameRect }; // 1 is the onSizeChangeTimeStamp 387 FrameNode::onSizeChangeDumpInfo dumpInfo2 { 2, testLastFrameRect, 388 testCurrFrameRect }; // 2 is the onSizeChangeTimeStamp 389 390 /** 391 * @tc.steps: step1. create frameNode. 392 */ 393 auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 394 395 /** 396 * @tc.steps: step2. add onSizeChangeDumpInfos. 397 */ 398 frameNode->onSizeChangeDumpInfos.push_back(dumpInfo1); 399 frameNode->onSizeChangeDumpInfos.push_back(dumpInfo2); 400 401 /** 402 * @tc.steps: step3. call the function DumpOnSizeChangeInfo. 403 */ 404 frameNode->DumpOnSizeChangeInfo(); 405 } 406 407 /** 408 * @tc.name: FrameNodeDumpInfo01 409 * @tc.desc: Test the function DumpInfo DumpAdvanceInfo CheckAutoSave 410 * @tc.type: FUNC 411 */ 412 HWTEST_F(FrameNodeTestNg, FrameNodeDumpInfo01, TestSize.Level1) 413 { 414 /** 415 * @tc.steps: step1. create frameNode. 416 */ 417 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 418 EXPECT_NE(frameNode->pattern_, nullptr); 419 420 /** 421 * @tc.steps: step2. update pattern_. 422 */ 423 auto pattern = frameNode->pattern_; 424 frameNode->pattern_ = nullptr; 425 426 /** 427 * @tc.steps: step3. call the function DumpOnSizeChangeInfo DumpAdvanceInfo CheckAutoSave. 428 */ 429 auto viewDataWrap = ViewDataWrap::CreateViewDataWrap(); 430 frameNode->DumpInfo(); 431 frameNode->DumpAdvanceInfo(); 432 frameNode->DumpViewDataPageNode(viewDataWrap); 433 EXPECT_FALSE(frameNode->CheckAutoSave()); 434 frameNode->pattern_ = pattern; 435 } 436 437 /** 438 * @tc.name: FrameNodeMouseToJsonValue01 439 * @tc.desc: Test the function MouseToJsonValue 440 * @tc.type: FUNC 441 */ 442 HWTEST_F(FrameNodeTestNg, FrameNodeMouseToJsonValue01, TestSize.Level1) 443 { 444 /** 445 * @tc.steps: step1. create frameNode. 446 */ 447 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 448 EXPECT_NE(frameNode->pattern_, nullptr); 449 450 /** 451 * @tc.steps: step2. call the function MouseToJsonValue. 452 */ 453 InspectorFilter testFilter; 454 auto jsonValue = std::make_unique<JsonValue>(); 455 testFilter.AddFilterAttr("focusable"); 456 frameNode->MouseToJsonValue(jsonValue, testFilter); 457 EXPECT_FALSE(jsonValue->GetBool("enabled", false)); 458 } 459 460 /** 461 * @tc.name: FrameNodeTouchToJsonValue01 462 * @tc.desc: Test the function TouchToJsonValue 463 * @tc.type: FUNC 464 */ 465 HWTEST_F(FrameNodeTestNg, FrameNodeTouchToJsonValue01, TestSize.Level1) 466 { 467 /** 468 * @tc.steps: step1. create frameNode. 469 */ 470 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 471 EXPECT_NE(frameNode->pattern_, nullptr); 472 473 /** 474 * @tc.steps: step2. call the function TouchToJsonValue. 475 */ 476 InspectorFilter testFilter; 477 auto jsonValue = std::make_unique<JsonValue>(); 478 testFilter.AddFilterAttr("focusable"); 479 frameNode->TouchToJsonValue(jsonValue, testFilter); 480 EXPECT_FALSE(jsonValue->GetBool("enabled", false)); 481 } 482 483 /** 484 * @tc.name: FrameNodeTouchToJsonValue02 485 * @tc.desc: Test the function TouchToJsonValue 486 * @tc.type: FUNC 487 */ 488 HWTEST_F(FrameNodeTestNg, FrameNodeTouchToJsonValue02, TestSize.Level1) 489 { 490 /** 491 * @tc.steps: step1. create frameNode. 492 */ 493 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 494 EXPECT_NE(frameNode->pattern_, nullptr); 495 frameNode->isActive_ = true; 496 frameNode->eventHub_->SetEnabled(true); 497 498 /** 499 * @tc.steps: step2. update the mouseResponseRegion. 500 */ 501 DimensionRect responseRect(Dimension(0), Dimension(0), DimensionOffset(OFFSETF)); 502 std::vector<DimensionRect> mouseResponseRegion; 503 mouseResponseRegion.emplace_back(responseRect); 504 auto gestureEventHub = frameNode->eventHub_->GetOrCreateGestureEventHub(); 505 gestureEventHub->SetMouseResponseRegion(mouseResponseRegion); 506 507 /** 508 * @tc.steps: step3. call the function TouchToJsonValue. 509 */ 510 InspectorFilter testFilter; 511 auto jsonValue = std::make_unique<JsonValue>(); 512 frameNode->TouchToJsonValue(jsonValue, testFilter); 513 EXPECT_FALSE(jsonValue->GetBool("enabled", false)); 514 } 515 516 /** 517 * @tc.name: FrameNodeGeometryNodeToJsonValue01 518 * @tc.desc: Test the function GeometryNodeToJsonValue 519 * @tc.type: FUNC 520 */ 521 HWTEST_F(FrameNodeTestNg, FrameNodeGeometryNodeToJsonValue01, TestSize.Level1) 522 { 523 /** 524 * @tc.steps: step1. create frameNode. 525 */ 526 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 527 EXPECT_NE(frameNode->pattern_, nullptr); 528 529 /** 530 * @tc.steps: step2. call the function GeometryNodeToJsonValue. 531 */ 532 InspectorFilter testFilter; 533 auto jsonValue = std::make_unique<JsonValue>(); 534 testFilter.AddFilterAttr("focusable"); 535 frameNode->GeometryNodeToJsonValue(jsonValue, testFilter); 536 EXPECT_FALSE(jsonValue->GetBool("enabled", false)); 537 } 538 539 /** 540 * @tc.name: FrameNodeFromJson01 541 * @tc.desc: Test the function FromJson 542 * @tc.type: FUNC 543 */ 544 HWTEST_F(FrameNodeTestNg, FrameNodeFromJson01, TestSize.Level1) 545 { 546 /** 547 * @tc.steps: step1. create frameNode. 548 */ 549 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 550 EXPECT_NE(frameNode->pattern_, nullptr); 551 552 /** 553 * @tc.steps: step2. call the function FromJson. 554 */ 555 auto eventHub = frameNode->eventHub_; 556 frameNode->eventHub_ = nullptr; 557 InspectorFilter testFilter; 558 auto jsonValue = std::make_unique<JsonValue>(); 559 testFilter.AddFilterAttr("focusable"); 560 frameNode->FromJson(jsonValue); 561 EXPECT_FALSE(jsonValue->GetBool("enabled", false)); 562 frameNode->eventHub_ = eventHub; 563 } 564 565 /** 566 * @tc.name: FrameNodeUpdateGeometryTransition01 567 * @tc.desc: Test the function UpdateGeometryTransition 568 * @tc.type: FUNC 569 */ 570 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateGeometryTransition01, TestSize.Level1) 571 { 572 /** 573 * @tc.steps: step1. create frameNode. 574 */ 575 auto frameNode = FrameNode::CreateFrameNode("parent", 0, AceType::MakeRefPtr<Pattern>(), true); 576 auto child = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>()); 577 EXPECT_NE(frameNode->pattern_, nullptr); 578 frameNode->AddChild(child); 579 EXPECT_EQ(frameNode->GetTotalChildCount(), 1); 580 581 /** 582 * @tc.steps: step2. update geometryTransition. 583 */ 584 frameNode->GetLayoutProperty()->UpdateGeometryTransition("parent", true); 585 child->GetLayoutProperty()->UpdateGeometryTransition("child", false); 586 LayoutProperty::UpdateAllGeometryTransition(frameNode); 587 588 /** 589 * @tc.steps: step3. call the function UpdateGeometryTransition. 590 */ 591 frameNode->UpdateGeometryTransition(); 592 } 593 594 /** 595 * @tc.name: FrameNodeOnAttachToMainTree01 596 * @tc.desc: Test the function OnAttachToMainTree 597 * @tc.type: FUNC 598 */ 599 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree01, TestSize.Level1) 600 { 601 /** 602 * @tc.steps: step1. create node. 603 */ 604 auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true); 605 auto childNodeOne = 606 FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), false); // 2 is id of childNodeOne 607 auto childNodeTwo = nullptr; 608 auto childNodeThree = 609 FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), false); // 3 is id of childNodeThree 610 EXPECT_NE(frameNode->pattern_, nullptr); 611 612 /** 613 * @tc.steps: step2. update node. 614 */ 615 childNodeOne->isLayoutDirtyMarked_ = true; 616 childNodeThree->isLayoutDirtyMarked_ = false; 617 frameNode->AddPredictLayoutNode(childNodeOne); 618 frameNode->AddPredictLayoutNode(childNodeTwo); 619 frameNode->AddPredictLayoutNode(childNodeThree); 620 frameNode->useOffscreenProcess_ = true; 621 frameNode->isPropertyDiffMarked_ = true; 622 623 /** 624 * @tc.steps: step3. call the function OnAttachToMainTree. 625 */ 626 frameNode->OnAttachToMainTree(true); 627 } 628 629 /** 630 * @tc.name: FrameNodeOnAttachToMainTree02 631 * @tc.desc: Test the function OnAttachToMainTree 632 * @tc.type: FUNC 633 */ 634 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree02, TestSize.Level1) 635 { 636 LayoutConstraintF layoutConstraintF = { 637 .minSize = { 1, 1 }, 638 .maxSize = { 10, 10 }, // 10 is the maxSize of width and height 639 .percentReference = { 5, 5 }, // 5 is the percentReference of width and height 640 .parentIdealSize = { 2, 2 }, // 2 is the parentIdealSize of width and height 641 }; 642 /** 643 * @tc.steps: step1. create node. 644 */ 645 auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true); 646 auto childNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), false); 647 648 /** 649 * @tc.steps: step2. update node. 650 */ 651 childNode->isLayoutDirtyMarked_ = true; 652 frameNode->AddPredictLayoutNode(childNode); 653 frameNode->useOffscreenProcess_ = false; 654 frameNode->isPropertyDiffMarked_ = true; 655 frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF); 656 657 /** 658 * @tc.steps: step3. call the function OnAttachToMainTree. 659 */ 660 frameNode->OnAttachToMainTree(true); 661 } 662 663 /** 664 * @tc.name: FrameNodeOnAttachToBuilderNode01 665 * @tc.desc: Test the function OnAttachToBuilderNode 666 * @tc.type: FUNC 667 */ 668 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToBuilderNode01, TestSize.Level1) 669 { 670 /** 671 * @tc.steps: step1. create node. 672 */ 673 auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true); 674 675 /** 676 * @tc.steps: step2. call the function OnAttachToBuilderNode. 677 */ 678 frameNode->OnAttachToBuilderNode(NodeStatus::BUILDER_NODE_ON_MAINTREE); 679 } 680 681 /** 682 * @tc.name: FrameNodeOnConfigurationUpdate01 683 * @tc.desc: Test the function OnConfigurationUpdate 684 * @tc.type: FUNC 685 */ 686 HWTEST_F(FrameNodeTestNg, FrameNodeOnConfigurationUpdate01, TestSize.Level1) 687 { 688 /** 689 * @tc.steps: step1. create node. 690 */ 691 auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true); __anon023d61880302() 692 auto callback = []() {}; 693 frameNode->SetColorModeUpdateCallback(std::move(callback)); 694 695 /** 696 * @tc.steps: step2. call the function OnConfigurationUpdate. 697 */ 698 ConfigurationChange configurationChange; 699 configurationChange.colorModeUpdate = true; 700 configurationChange.fontUpdate = false; 701 configurationChange.iconUpdate = false; 702 configurationChange.skinUpdate = false; 703 frameNode->OnConfigurationUpdate(configurationChange); 704 } 705 706 /** 707 * @tc.name: FrameNodeSwapDirtyLayoutWrapperOnMainThread01 708 * @tc.desc: Test the function SwapDirtyLayoutWrapperOnMainThread 709 * @tc.type: FUNC 710 */ 711 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread01, TestSize.Level1) 712 { 713 /** 714 * @tc.steps: step1. create frameNode. 715 */ 716 auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 717 frameNode->isActive_ = false; 718 /** 719 * @tc.steps: step2. create layoutProperty. 720 */ 721 BorderWidthProperty borderWidth = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp }; 722 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 723 layoutProperty->UpdateBorderWidth(borderWidth); 724 725 RefPtr<LayoutWrapper> layoutWrapper = frameNode->CreateLayoutWrapper(true, true); 726 layoutWrapper->SetActive(true); 727 __anon023d61880402() 728 auto builderFunc = []() -> RefPtr<UINode> { 729 auto node = FrameNode::CreateFrameNode("node", 0, AceType::MakeRefPtr<Pattern>(), true); 730 auto childNode = FrameNode::CreateFrameNode("child", 1, AceType::MakeRefPtr<Pattern>(), true); 731 node->AddChild(childNode); 732 return node; 733 }; 734 735 /** 736 * @tc.steps: step3. call the function DumpCommonInfo. 737 */ 738 frameNode->SetBackgroundFunction(builderFunc); 739 frameNode->SetLayoutProperty(layoutProperty); 740 frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper); 741 } 742 743 /** 744 * @tc.name: FrameNodeSwapDirtyLayoutWrapperOnMainThread02 745 * @tc.desc: Test the function SwapDirtyLayoutWrapperOnMainThread 746 * @tc.type: FUNC 747 */ 748 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread02, TestSize.Level1) 749 { 750 LayoutConstraintF layoutConstraintF = { 751 .minSize = { 1, 1 }, 752 .maxSize = { 10, 10 }, // 10 is the maxSize of width and height 753 .percentReference = { 5, 5 }, // 5 is the percentReference of width and height 754 .parentIdealSize = { 2, 2 }, // 2 is the parentIdealSize of width and height 755 }; 756 /** 757 * @tc.steps: step1. create frameNode. 758 */ 759 auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 760 frameNode->isActive_ = false; 761 /** 762 * @tc.steps: step2. create layoutProperty. 763 */ 764 BorderWidthProperty borderWidth = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp }; 765 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 766 layoutProperty->UpdateBorderWidth(borderWidth); 767 layoutProperty->layoutConstraint_ = layoutConstraintF; 768 layoutProperty->contentConstraint_ = layoutConstraintF; 769 frameNode->GetOrCreateFocusHub()->currentFocus_ = true; 770 771 RefPtr<LayoutWrapper> layoutWrapper = frameNode->CreateLayoutWrapper(true, true); 772 layoutWrapper->SetActive(true); 773 __anon023d61880502() 774 auto builderFunc = []() -> RefPtr<UINode> { return nullptr; }; 775 776 /** 777 * @tc.steps: step3. update renderContext_. 778 */ 779 BorderColorProperty borderColorProperty; 780 borderColorProperty.SetColor(Color::BLUE); 781 frameNode->renderContext_->UpdateBorderColor(borderColorProperty); 782 BorderStyleProperty borderStyleProperty; 783 borderStyleProperty.SetBorderStyle(BorderStyle::SOLID); 784 frameNode->renderContext_->UpdateBorderStyle(borderStyleProperty); 785 BorderWidthProperty dashGapProperty; 786 dashGapProperty.SetBorderWidth(Dimension(1)); 787 frameNode->renderContext_->UpdateDashGap(dashGapProperty); 788 BorderWidthProperty dashWidthProperty; 789 dashWidthProperty.SetBorderWidth(Dimension(1)); 790 frameNode->renderContext_->UpdateDashWidth(dashWidthProperty); 791 792 /** 793 * @tc.steps: step4. call the function DumpCommonInfo. 794 */ 795 frameNode->SetBackgroundFunction(builderFunc); 796 frameNode->SetLayoutProperty(layoutProperty); 797 frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper); 798 } 799 800 /** 801 * @tc.name: FrameNodeAdjustGridOffset01 802 * @tc.desc: Test the function AdjustGridOffset 803 * @tc.type: FUNC 804 */ 805 HWTEST_F(FrameNodeTestNg, FrameNodeAdjustGridOffset01, TestSize.Level1) 806 { 807 /** 808 * @tc.steps: step1. create frameNode. 809 */ 810 auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 811 frameNode->isActive_ = true; 812 813 /** 814 * @tc.steps: step2. create layoutProperty. 815 */ 816 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 817 layoutProperty->gridProperty_ = std::make_unique<GridProperty>(); 818 layoutProperty->UpdateGridProperty(1, 0, GridSizeType::UNDEFINED); 819 820 layoutProperty->gridProperty_ = std::make_unique<GridProperty>(); 821 frameNode->SetParent(FRAME_NODE); 822 frameNode->NotifyVisibleChange(VisibleType::INVISIBLE, VisibleType::VISIBLE); 823 RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>(); 824 geometryNode->SetFrameOffset(OffsetF(1.0f, 0.0f)); 825 frameNode->geometryNode_ = geometryNode; 826 layoutProperty->BuildGridProperty(frameNode); 827 828 /** 829 * @tc.steps: step4. call the function DumpCommonInfo. 830 */ 831 frameNode->SetLayoutProperty(layoutProperty); 832 frameNode->AdjustGridOffset(); 833 } 834 835 /** 836 * @tc.name: FrameNodeClearUserOnAreaChange01 837 * @tc.desc: Test the function ClearUserOnAreaChange 838 * @tc.type: FUNC 839 */ 840 HWTEST_F(FrameNodeTestNg, FrameNodeClearUserOnAreaChange01, TestSize.Level1) 841 { 842 /** 843 * @tc.steps: step1. create frameNode. 844 */ 845 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 846 EXPECT_NE(frameNode->pattern_, nullptr); 847 848 /** 849 * @tc.steps: step2. call the function ClearUserOnAreaChange. 850 */ 851 auto eventHub = frameNode->eventHub_; 852 frameNode->eventHub_ = nullptr; 853 frameNode->ClearUserOnAreaChange(); 854 frameNode->eventHub_ = eventHub; 855 } 856 857 /** 858 * @tc.name: FrameNodeTriggerOnAreaChangeCallback01 859 * @tc.desc: Test the function TriggerOnAreaChangeCallback 860 * @tc.type: FUNC 861 */ 862 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback01, TestSize.Level1) 863 { 864 /** 865 * @tc.steps: step1. create frameNode. 866 */ 867 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 868 EXPECT_NE(frameNode->pattern_, nullptr); 869 frameNode->isActive_ = true; 870 bool flag = false; 871 OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, __anon023d61880602(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 872 const OffsetF& origin) { flag = !flag; }; 873 frameNode->eventHub_->SetOnAreaChanged(std::move(onAreaChanged)); 874 frameNode->eventHub_->AddInnerOnAreaChangedCallback(1, std::move(onAreaChanged)); 875 frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset 876 frameNode->lastFrameRect_ = 877 std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size 878 879 auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty(); 880 posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1))); 881 /** 882 * @tc.steps: step3. call the function TriggerOnAreaChangeCallback. 883 */ 884 frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1); 885 } 886 887 /** 888 * @tc.name: FrameNodeTriggerOnAreaChangeCallback02 889 * @tc.desc: Test the function TriggerOnAreaChangeCallback 890 * @tc.type: FUNC 891 */ 892 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback02, TestSize.Level1) 893 { 894 /** 895 * @tc.steps: step1. create frameNode. 896 */ 897 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 898 EXPECT_NE(frameNode->pattern_, nullptr); 899 frameNode->isActive_ = true; 900 bool flag = false; 901 OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, __anon023d61880702(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 902 const OffsetF& origin) { flag = !flag; }; 903 frameNode->eventHub_->SetOnAreaChanged(std::move(onAreaChanged)); 904 frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset 905 frameNode->lastFrameRect_ = 906 std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size 907 908 auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty(); 909 posProperty->UpdateOffset(OffsetT<Dimension>(Dimension(1), Dimension(1))); 910 /** 911 * @tc.steps: step3. call the function TriggerOnAreaChangeCallback. 912 */ 913 frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1); 914 } 915 916 /** 917 * @tc.name: FrameNodeTriggerOnAreaChangeCallback03 918 * @tc.desc: Test the function TriggerOnAreaChangeCallback 919 * @tc.type: FUNC 920 */ 921 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback03, TestSize.Level1) 922 { 923 /** 924 * @tc.steps: step1. create frameNode. 925 */ 926 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 927 EXPECT_NE(frameNode->pattern_, nullptr); 928 frameNode->isActive_ = true; 929 bool flag = false; 930 OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, __anon023d61880802(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 931 const OffsetF& origin) { flag = !flag; }; 932 frameNode->eventHub_->AddInnerOnAreaChangedCallback(1, std::move(onAreaChanged)); 933 frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset 934 frameNode->lastFrameRect_ = 935 std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size 936 937 auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty(); 938 posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1))); 939 /** 940 * @tc.steps: step3. call the function TriggerOnAreaChangeCallback. 941 */ 942 frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1); 943 } 944 945 /** 946 * @tc.name: FrameNodeAddInnerOnSizeChangeCallback01 947 * @tc.desc: Test the function AddInnerOnSizeChangeCallback 948 * @tc.type: FUNC 949 */ 950 HWTEST_F(FrameNodeTestNg, FrameNodeAddInnerOnSizeChangeCallback01, TestSize.Level1) 951 { 952 /** 953 * @tc.steps: step1. create frameNode. 954 */ 955 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 956 EXPECT_NE(frameNode->pattern_, nullptr); __anon023d61880902(const RectF& oldRect, const RectF& rect) 957 OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {}; 958 frameNode->lastFrameNodeRect_ = std::make_unique<RectF>(RectF(OffsetF(1.0f, 1.0f), SizeF(1.0f, 1.0f))); 959 /** 960 * @tc.steps: step3. call the function TriggerOnAreaChangeCallback. 961 */ 962 frameNode->AddInnerOnSizeChangeCallback(1, std::move(callback)); 963 } 964 965 /** 966 * @tc.name: FrameNodeAddInnerOnSizeChangeCallback02 967 * @tc.desc: Test the function AddInnerOnSizeChangeCallback 968 * @tc.type: FUNC 969 */ 970 HWTEST_F(FrameNodeTestNg, FrameNodeAddInnerOnSizeChangeCallback02, TestSize.Level1) 971 { 972 /** 973 * @tc.steps: step1. create frameNode. 974 */ 975 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 976 EXPECT_NE(frameNode->pattern_, nullptr); __anon023d61880a02(const RectF& oldRect, const RectF& rect) 977 OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {}; 978 /** 979 * @tc.steps: step3. call the function TriggerOnAreaChangeCallback. 980 */ 981 frameNode->AddInnerOnSizeChangeCallback(1, std::move(callback)); 982 } 983 984 /** 985 * @tc.name: FrameNodeSetJSFrameNodeOnSizeChangeCallback01 986 * @tc.desc: Test the function SetJSFrameNodeOnSizeChangeCallback 987 * @tc.type: FUNC 988 */ 989 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSFrameNodeOnSizeChangeCallback01, TestSize.Level1) 990 { 991 /** 992 * @tc.steps: step1. create frameNode. 993 */ 994 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 995 EXPECT_NE(frameNode->pattern_, nullptr); __anon023d61880b02(const RectF& oldRect, const RectF& rect) 996 OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {}; 997 frameNode->lastFrameNodeRect_ = std::make_unique<RectF>(RectF(OffsetF(1.0f, 1.0f), SizeF(1.0f, 1.0f))); 998 /** 999 * @tc.steps: step3. call the function SetJSFrameNodeOnSizeChangeCallback. 1000 */ 1001 frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(callback)); 1002 } 1003 1004 /** 1005 * @tc.name: FrameNodeSetJSFrameNodeOnSizeChangeCallback02 1006 * @tc.desc: Test the function SetJSFrameNodeOnSizeChangeCallback 1007 * @tc.type: FUNC 1008 */ 1009 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSFrameNodeOnSizeChangeCallback02, TestSize.Level1) 1010 { 1011 /** 1012 * @tc.steps: step1. create frameNode. 1013 */ 1014 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1015 EXPECT_NE(frameNode->pattern_, nullptr); __anon023d61880c02(const RectF& oldRect, const RectF& rect) 1016 OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {}; 1017 /** 1018 * @tc.steps: step3. call the function SetJSFrameNodeOnSizeChangeCallback. 1019 */ 1020 frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(callback)); 1021 } 1022 1023 /** 1024 * @tc.name: FrameNodeGetRectWithRender01 1025 * @tc.desc: Test the function GetRectWithRender 1026 * @tc.type: FUNC 1027 */ 1028 HWTEST_F(FrameNodeTestNg, FrameNodeGetRectWithRender01, TestSize.Level1) 1029 { 1030 /** 1031 * @tc.steps: step1. create frameNode. 1032 */ 1033 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1034 EXPECT_NE(frameNode->pattern_, nullptr); 1035 frameNode->isActive_ = true; 1036 1037 auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty(); 1038 posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1))); 1039 /** 1040 * @tc.steps: step3. call the function GetRectWithRender. 1041 */ 1042 frameNode->GetRectWithRender(); 1043 } 1044 1045 /** 1046 * @tc.name: FrameNodeGetRectWithRender02 1047 * @tc.desc: Test the function GetRectWithRender 1048 * @tc.type: FUNC 1049 */ 1050 HWTEST_F(FrameNodeTestNg, FrameNodeGetRectWithRender02, TestSize.Level1) 1051 { 1052 /** 1053 * @tc.steps: step1. create frameNode. 1054 */ 1055 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1056 EXPECT_NE(frameNode->pattern_, nullptr); 1057 frameNode->isActive_ = true; 1058 1059 auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty(); 1060 posProperty->UpdateOffset(OffsetT<Dimension>(Dimension(1), Dimension(1))); 1061 /** 1062 * @tc.steps: step3. call the function GetRectWithRender. 1063 */ 1064 frameNode->GetRectWithRender(); 1065 } 1066 1067 /** 1068 * @tc.name: FrameNodeTriggerOnSizeChangeCallback01 1069 * @tc.desc: Test the function TriggerOnSizeChangeCallback 1070 * @tc.type: FUNC 1071 */ 1072 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback01, TestSize.Level1) 1073 { 1074 NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1075 NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1076 FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect, 1077 testCurrFrameRect }; // 1 is the onSizeChangeTimeStamp 1078 FrameNode::onSizeChangeDumpInfo dumpInfoTwo { 2, testLastFrameRect, 1079 testCurrFrameRect }; // 2 is the onSizeChangeTimeStamp 1080 FrameNode::onSizeChangeDumpInfo dumpInfoThree { 3, testLastFrameRect, 1081 testCurrFrameRect }; // 3 is the onSizeChangeTimeStamp 1082 FrameNode::onSizeChangeDumpInfo dumpInfoFour { 4, testLastFrameRect, 1083 testCurrFrameRect }; // 4 is the onSizeChangeTimeStamp 1084 FrameNode::onSizeChangeDumpInfo dumpInfoFive { 5, testLastFrameRect, 1085 testCurrFrameRect }; // 5 is the onSizeChangeTimeStamp 1086 /** 1087 * @tc.steps: step1. create frameNode. 1088 */ 1089 auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true); 1090 EXPECT_NE(frameNode->pattern_, nullptr); 1091 frameNode->isActive_ = true; 1092 auto pattern = frameNode->GetPattern<PagePattern>(); 1093 pattern->isOnShow_ = true; 1094 bool flag = false; __anon023d61880d02(const RectF& oldRect, const RectF& rect) 1095 OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; }; 1096 frameNode->eventHub_->SetOnSizeChanged(std::move(onSizeChanged)); 1097 frameNode->eventHub_->AddInnerOnSizeChanged(1, std::move(onSizeChanged)); 1098 frameNode->lastFrameNodeRect_ = 1099 std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size 1100 frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne); 1101 frameNode->onSizeChangeDumpInfos.push_back(dumpInfoTwo); 1102 frameNode->onSizeChangeDumpInfos.push_back(dumpInfoThree); 1103 frameNode->onSizeChangeDumpInfos.push_back(dumpInfoFour); 1104 frameNode->onSizeChangeDumpInfos.push_back(dumpInfoFive); 1105 /** 1106 * @tc.steps: step3. call the function TriggerOnSizeChangeCallback. 1107 */ 1108 frameNode->TriggerOnSizeChangeCallback(); 1109 } 1110 1111 /** 1112 * @tc.name: FrameNodeTriggerOnSizeChangeCallback02 1113 * @tc.desc: Test the function TriggerOnSizeChangeCallback 1114 * @tc.type: FUNC 1115 */ 1116 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback02, TestSize.Level1) 1117 { 1118 NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1119 NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1120 FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect, testCurrFrameRect }; 1121 /** 1122 * @tc.steps: step1. create frameNode. 1123 */ 1124 auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true); 1125 EXPECT_NE(frameNode->pattern_, nullptr); 1126 frameNode->isActive_ = true; 1127 auto pattern = frameNode->GetPattern<PagePattern>(); 1128 pattern->isOnShow_ = true; 1129 bool flag = false; __anon023d61880e02(const RectF& oldRect, const RectF& rect) 1130 OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; }; 1131 frameNode->eventHub_->SetOnSizeChanged(std::move(onSizeChanged)); 1132 frameNode->lastFrameNodeRect_ = 1133 std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size 1134 frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne); 1135 /** 1136 * @tc.steps: step3. call the function TriggerOnSizeChangeCallback. 1137 */ 1138 frameNode->TriggerOnSizeChangeCallback(); 1139 } 1140 1141 /** 1142 * @tc.name: FrameNodeTriggerOnSizeChangeCallback03 1143 * @tc.desc: Test the function TriggerOnSizeChangeCallback 1144 * @tc.type: FUNC 1145 */ 1146 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback03, TestSize.Level1) 1147 { 1148 NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1149 NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1150 FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect, testCurrFrameRect }; 1151 /** 1152 * @tc.steps: step1. create frameNode. 1153 */ 1154 auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true); 1155 EXPECT_NE(frameNode->pattern_, nullptr); 1156 frameNode->isActive_ = true; 1157 auto pattern = frameNode->GetPattern<PagePattern>(); 1158 pattern->isOnShow_ = true; 1159 bool flag = false; __anon023d61880f02(const RectF& oldRect, const RectF& rect) 1160 OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; }; 1161 frameNode->eventHub_->AddInnerOnSizeChanged(1, std::move(onSizeChanged)); 1162 frameNode->lastFrameNodeRect_ = 1163 std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size 1164 frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne); 1165 /** 1166 * @tc.steps: step3. call the function TriggerOnSizeChangeCallback. 1167 */ 1168 frameNode->TriggerOnSizeChangeCallback(); 1169 } 1170 1171 /** 1172 * @tc.name: FrameNodIsFrameDisappear01 1173 * @tc.desc: Test the function IsFrameDisappear 1174 * @tc.type: FUNC 1175 */ 1176 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear01, TestSize.Level1) 1177 { 1178 /** 1179 * @tc.steps: step1. create frameNode. 1180 */ 1181 auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1182 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1183 parentNode->isActive_ = false; 1184 frameNode->onMainTree_ = true; 1185 auto context = frameNode->GetContext(); 1186 context->onShow_ = true; 1187 frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode))); 1188 1189 /** 1190 * @tc.steps: step2. create layoutProperty. 1191 */ 1192 auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1193 parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE; 1194 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1195 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1196 1197 /** 1198 * @tc.steps: step3. call the function IsFrameDisappear. 1199 */ 1200 parentNode->SetLayoutProperty(parentLayoutProperty); 1201 frameNode->SetLayoutProperty(layoutProperty); 1202 frameNode->IsFrameDisappear(); 1203 } 1204 1205 /** 1206 * @tc.name: FrameNodIsFrameDisappear02 1207 * @tc.desc: Test the function IsFrameDisappear 1208 * @tc.type: FUNC 1209 */ 1210 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear02, TestSize.Level1) 1211 { 1212 /** 1213 * @tc.steps: step1. create frameNode. 1214 */ 1215 auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1216 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1217 parentNode->isActive_ = true; 1218 frameNode->onMainTree_ = true; 1219 auto context = frameNode->GetContext(); 1220 context->onShow_ = true; 1221 frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode))); 1222 1223 /** 1224 * @tc.steps: step2. create layoutProperty. 1225 */ 1226 auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1227 parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE; 1228 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1229 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1230 1231 /** 1232 * @tc.steps: step3. call the function IsFrameDisappear. 1233 */ 1234 parentNode->SetLayoutProperty(parentLayoutProperty); 1235 frameNode->SetLayoutProperty(layoutProperty); 1236 frameNode->IsFrameDisappear(); 1237 } 1238 1239 /** 1240 * @tc.name: FrameNodeTriggerVisibleAreaChangeCallback01 1241 * @tc.desc: Test the function TriggerVisibleAreaChangeCallback 1242 * @tc.type: FUNC 1243 */ 1244 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback01, TestSize.Level1) 1245 { 1246 /** 1247 * @tc.steps: step1. create frameNode. 1248 */ 1249 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1250 frameNode->onMainTree_ = true; 1251 frameNode->isActive_ = true; 1252 frameNode->isWindowBoundary_ = false; 1253 auto context = frameNode->GetContext(); 1254 context->onShow_ = true; 1255 VisibleCallbackInfo callbackInfo; 1256 int32_t flag = 0; __anon023d61881002(bool isVisible, double radio) 1257 const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; }; 1258 callbackInfo.callback = jsCallback; 1259 callbackInfo.period = 1; 1260 frameNode->eventHub_->visibleAreaUserCallback_ = callbackInfo; 1261 frameNode->TriggerVisibleAreaChangeCallback(0, false); 1262 frameNode->eventHub_->visibleAreaUserCallback_.callback = nullptr; 1263 frameNode->eventHub_->visibleAreaInnerCallback_ = callbackInfo; 1264 frameNode->TriggerVisibleAreaChangeCallback(0, false); 1265 EXPECT_NE(frameNode->eventHub_, nullptr); 1266 frameNode->isCalculateInnerVisibleRectClip_ = true; 1267 frameNode->lastInnerVisibleRatio_ = 10.0; 1268 frameNode->lastVisibleRatio_ = 10.0; 1269 frameNode->TriggerVisibleAreaChangeCallback(0, true); 1270 frameNode->eventHub_->visibleAreaUserCallback_ = callbackInfo; 1271 /** 1272 * @tc.steps: step2. create layoutProperty. 1273 */ 1274 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1275 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1276 1277 /** 1278 * @tc.steps: step3. call the function TriggerVisibleAreaChangeCallback. 1279 */ 1280 std::vector<double> ratios = { 0, 1.0 }; 1281 frameNode->SetLayoutProperty(layoutProperty); 1282 frameNode->TriggerVisibleAreaChangeCallback(false); 1283 frameNode->ProcessAllVisibleCallback(ratios, callbackInfo, 1.0, 0.0, true); 1284 EXPECT_NE(frameNode->eventHub_, nullptr); 1285 } 1286 1287 /** 1288 * @tc.name: FrameNodeThrottledVisibleTask01 1289 * @tc.desc: Test the function ThrottledVisibleTask 1290 * @tc.type: FUNC 1291 */ 1292 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask01, TestSize.Level1) 1293 { 1294 /** 1295 * @tc.steps: step1. create frameNode. 1296 */ 1297 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1298 frameNode->throttledCallbackOnTheWay_ = true; 1299 frameNode->lastThrottledVisibleRatio_ = 0.0; 1300 frameNode->isActive_ = true; 1301 auto context = frameNode->GetContext(); 1302 context->onShow_ = false; 1303 VisibleCallbackInfo callbackInfo; 1304 int32_t flag = 0; __anon023d61881102(bool isVisible, double radio) 1305 const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; }; 1306 callbackInfo.callback = jsCallback; 1307 callbackInfo.period = 1; 1308 frameNode->eventHub_->throttledVisibleAreaCallback_ = callbackInfo; 1309 1310 /** 1311 * @tc.steps: step2. create layoutProperty. 1312 */ 1313 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1314 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1315 1316 /** 1317 * @tc.steps: step3. call the function ThrottledVisibleTask. 1318 */ 1319 frameNode->SetLayoutProperty(layoutProperty); 1320 frameNode->ThrottledVisibleTask(); 1321 } 1322 1323 /** 1324 * @tc.name: FrameNodeThrottledVisibleTask02 1325 * @tc.desc: Test the function ThrottledVisibleTask 1326 * @tc.type: FUNC 1327 */ 1328 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask02, TestSize.Level1) 1329 { 1330 /** 1331 * @tc.steps: step1. create frameNode. 1332 */ 1333 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1334 frameNode->throttledCallbackOnTheWay_ = true; 1335 frameNode->lastThrottledVisibleRatio_ = 1.0; 1336 frameNode->isActive_ = true; 1337 auto context = frameNode->GetContext(); 1338 context->onShow_ = false; 1339 VisibleCallbackInfo callbackInfo; 1340 int32_t flag = 0; __anon023d61881202(bool isVisible, double radio) 1341 const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; }; 1342 callbackInfo.callback = jsCallback; 1343 callbackInfo.period = 1; 1344 frameNode->eventHub_->throttledVisibleAreaCallback_ = callbackInfo; 1345 1346 /** 1347 * @tc.steps: step2. create layoutProperty. 1348 */ 1349 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1350 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1351 1352 /** 1353 * @tc.steps: step3. call the function ThrottledVisibleTask. 1354 */ 1355 frameNode->SetLayoutProperty(layoutProperty); 1356 frameNode->ThrottledVisibleTask(); 1357 } 1358 1359 /** 1360 * @tc.name: FrameNodeThrottledVisibleTask03 1361 * @tc.desc: Test the function ThrottledVisibleTask 1362 * @tc.type: FUNC 1363 */ 1364 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask03, TestSize.Level1) 1365 { 1366 /** 1367 * @tc.steps: step1. create frameNode. 1368 */ 1369 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1370 frameNode->throttledCallbackOnTheWay_ = false; 1371 VisibleCallbackInfo callbackInfo; 1372 int32_t flag = 0; __anon023d61881302(bool isVisible, double radio) 1373 const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; }; 1374 callbackInfo.callback = jsCallback; 1375 callbackInfo.period = 1; 1376 frameNode->eventHub_->throttledVisibleAreaCallback_ = callbackInfo; 1377 1378 /** 1379 * @tc.steps: step2. call the function ThrottledVisibleTask. 1380 */ 1381 frameNode->ThrottledVisibleTask(); 1382 } 1383 1384 /** 1385 * @tc.name: FrameNodeCreateLayoutTask01 1386 * @tc.desc: Test the function CreateLayoutTask 1387 * @tc.type: FUNC 1388 */ 1389 HWTEST_F(FrameNodeTestNg, FrameNodeCreateLayoutTask01, TestSize.Level1) 1390 { 1391 /** 1392 * @tc.steps: step1. create frameNode. 1393 */ 1394 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1395 frameNode->isLayoutDirtyMarked_ = true; 1396 1397 /** 1398 * @tc.steps: step2. create layoutProperty. 1399 */ 1400 NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1401 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1402 layoutProperty->SetLayoutRect(testRect); 1403 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1404 1405 /** 1406 * @tc.steps: step3. call the function CreateLayoutTask. 1407 */ 1408 frameNode->SetLayoutProperty(layoutProperty); 1409 frameNode->CreateLayoutTask(true); 1410 } 1411 1412 /** 1413 * @tc.name: FrameNodeCreateRenderTask01 1414 * @tc.desc: Test the function CreateRenderTask 1415 * @tc.type: FUNC 1416 */ 1417 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask01, TestSize.Level1) 1418 { 1419 /** 1420 * @tc.steps: step1. create frameNode. 1421 */ 1422 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1423 frameNode->isRenderDirtyMarked_ = true; 1424 frameNode->UpdateInspectorId("123"); 1425 frameNode->renderContext_->UpdateAccessibilityFocus(true); 1426 /** 1427 * @tc.steps: step2. create layoutProperty. 1428 */ 1429 NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1430 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1431 layoutProperty->SetLayoutRect(testRect); 1432 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1433 1434 /** 1435 * @tc.steps: step3. call the function CreateRenderTask. 1436 */ 1437 frameNode->SetLayoutProperty(layoutProperty); 1438 frameNode->CreateRenderTask(true).value()(); 1439 } 1440 1441 /** 1442 * @tc.name: FrameNodeCreateRenderTask02 1443 * @tc.desc: Test the function CreateRenderTask 1444 * @tc.type: FUNC 1445 */ 1446 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask02, TestSize.Level1) 1447 { 1448 /** 1449 * @tc.steps: step1. create frameNode. 1450 */ 1451 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1452 frameNode->isRenderDirtyMarked_ = true; 1453 frameNode->renderContext_->UpdateAccessibilityFocus(true); 1454 /** 1455 * @tc.steps: step2. create layoutProperty. 1456 */ 1457 NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect 1458 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1459 layoutProperty->SetLayoutRect(testRect); 1460 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1461 1462 /** 1463 * @tc.steps: step3. call the function CreateRenderTask. 1464 */ 1465 frameNode->SetLayoutProperty(layoutProperty); 1466 frameNode->CreateRenderTask(false).value()(); 1467 } 1468 1469 /** 1470 * @tc.name: FrameNodeUpdateLayoutWrapper01 1471 * @tc.desc: Test the function UpdateLayoutWrapper 1472 * @tc.type: FUNC 1473 */ 1474 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutWrapper01, TestSize.Level1) 1475 { 1476 /** 1477 * @tc.steps: step1. create frameNode. 1478 */ 1479 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1480 auto testNode = FrameNode::CreateFrameNode("test", 0, AceType::MakeRefPtr<Pattern>()); 1481 RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>(); 1482 RefPtr<LayoutWrapperNode> layoutWrapper = 1483 AceType::MakeRefPtr<LayoutWrapperNode>(testNode, geometryNode, testNode->GetLayoutProperty()); 1484 1485 /** 1486 * @tc.steps: step2. create layoutProperty. 1487 */ 1488 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1489 layoutProperty->propVisibility_ = VisibleType::GONE; 1490 layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_LAYOUT); 1491 1492 /** 1493 * @tc.steps: step3. call the function UpdateLayoutWrapper. 1494 */ 1495 frameNode->SetLayoutProperty(layoutProperty); 1496 frameNode->UpdateLayoutWrapper(layoutWrapper, false, true); 1497 } 1498 1499 /** 1500 * @tc.name: FrameNodeUpdateLayoutWrapper02 1501 * @tc.desc: Test the function UpdateLayoutWrapper 1502 * @tc.type: FUNC 1503 */ 1504 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutWrapper02, TestSize.Level1) 1505 { 1506 /** 1507 * @tc.steps: step1. create frameNode. 1508 */ 1509 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1510 1511 /** 1512 * @tc.steps: step2. create layoutProperty. 1513 */ 1514 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1515 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1516 layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_LAYOUT); 1517 1518 /** 1519 * @tc.steps: step3. call the function UpdateLayoutWrapper. 1520 */ 1521 frameNode->SetLayoutProperty(layoutProperty); 1522 frameNode->UpdateLayoutWrapper(nullptr, false, true); 1523 } 1524 1525 /** 1526 * @tc.name: FrameNodeGetContentModifier01 1527 * @tc.desc: Test the function GetContentModifier 1528 * @tc.type: FUNC 1529 */ 1530 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier01, TestSize.Level1) 1531 { 1532 /** 1533 * @tc.steps: step1. create frameNode. 1534 */ 1535 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<ImagePattern>(), true); 1536 frameNode->renderContext_->UpdateAccessibilityFocus(true); 1537 frameNode->GetPattern<ImagePattern>()->image_ = AceType::MakeRefPtr<NG::MockCanvasImage>(); 1538 1539 /** 1540 * @tc.steps: step2. call the function GetContentModifier. 1541 */ 1542 frameNode->GetContentModifier(); 1543 frameNode->renderContext_->UpdateAccessibilityFocus(false); 1544 frameNode->GetContentModifier(); 1545 } 1546 1547 /** 1548 * @tc.name: FrameNodeGetContentModifier02 1549 * @tc.desc: Test the function GetContentModifier 1550 * @tc.type: FUNC 1551 */ 1552 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier02, TestSize.Level1) 1553 { 1554 /** 1555 * @tc.steps: step1. create frameNode. 1556 */ 1557 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<ImagePattern>(), true); 1558 frameNode->renderContext_->UpdateAccessibilityFocus(true); 1559 frameNode->GetPattern<ImagePattern>()->image_ = AceType::MakeRefPtr<NG::MockCanvasImage>(); 1560 frameNode->extensionHandler_ = AceType::MakeRefPtr<ExtensionHandler>(); 1561 1562 /** 1563 * @tc.steps: step2. call the function GetContentModifier. 1564 */ 1565 frameNode->GetContentModifier(); 1566 } 1567 1568 /** 1569 * @tc.name: FrameNodeGetContentModifier03 1570 * @tc.desc: Test the function GetContentModifier 1571 * @tc.type: FUNC 1572 */ 1573 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier03, TestSize.Level1) 1574 { 1575 /** 1576 * @tc.steps: step1. create frameNode. 1577 */ 1578 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1579 frameNode->renderContext_->UpdateAccessibilityFocus(true); 1580 /** 1581 * @tc.steps: step2. call the function GetContentModifier. 1582 */ 1583 frameNode->GetContentModifier(); 1584 } 1585 1586 /** 1587 * @tc.name: FrameNodePostIdleTask01 1588 * @tc.desc: Test the function PostIdleTask 1589 * @tc.type: FUNC 1590 */ 1591 HWTEST_F(FrameNodeTestNg, FrameNodePostIdleTask01, TestSize.Level1) 1592 { 1593 /** 1594 * @tc.steps: step1. create frameNode. 1595 */ 1596 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1597 /** 1598 * @tc.steps: step2. call the function PostIdleTask. 1599 */ 1600 int32_t flag = 0; __anon023d61881402(int64_t radio, bool isVisible) 1601 std::function<void(int64_t, bool)>&& callback = [&flag](int64_t radio, bool isVisible) { flag++; }; 1602 frameNode->PostIdleTask(std::move(callback)); 1603 } 1604 1605 /** 1606 * @tc.name: FrameNodeRebuildRenderContextTree01 1607 * @tc.desc: Test the function RebuildRenderContextTree 1608 * @tc.type: FUNC 1609 */ 1610 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree01, TestSize.Level1) 1611 { 1612 /** 1613 * @tc.steps: step1. create frameNode. 1614 */ 1615 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1616 frameNode->needSyncRenderTree_ = true; 1617 frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>()); 1618 1619 /** 1620 * @tc.steps: step2. create layoutProperty. 1621 */ 1622 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1623 layoutProperty->propVisibility_ = VisibleType::VISIBLE; 1624 1625 /** 1626 * @tc.steps: step3. call the function RebuildRenderContextTree. 1627 */ 1628 frameNode->overlayNode_->SetLayoutProperty(layoutProperty); 1629 frameNode->RebuildRenderContextTree(); 1630 1631 /** 1632 * @tc.steps: step4. update layoutProperty and call the function RebuildRenderContextTree. 1633 */ 1634 layoutProperty->propVisibility_ = VisibleType::INVISIBLE; 1635 frameNode->overlayNode_->SetLayoutProperty(layoutProperty); 1636 frameNode->RebuildRenderContextTree(); 1637 1638 /** 1639 * @tc.steps: step5. update overlayNode_ nullptr and call the function RebuildRenderContextTree. 1640 */ 1641 frameNode->overlayNode_ = nullptr; 1642 frameNode->RebuildRenderContextTree(); 1643 } 1644 1645 /** 1646 * @tc.name: FrameNodeRebuildRenderContextTree02 1647 * @tc.desc: Test the function RebuildRenderContextTree 1648 * @tc.type: FUNC 1649 */ 1650 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree02, TestSize.Level1) 1651 { 1652 /** 1653 * @tc.steps: step1. create frameNode. 1654 */ 1655 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1656 frameNode->needSyncRenderTree_ = true; 1657 frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>()); 1658 1659 /** 1660 * @tc.steps: step2. create layoutProperty. 1661 */ 1662 auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>(); 1663 layoutProperty->propVisibility_ = VisibleType::INVISIBLE; 1664 1665 /** 1666 * @tc.steps: step3. call the function RebuildRenderContextTree. 1667 */ 1668 frameNode->overlayNode_->SetLayoutProperty(layoutProperty); 1669 frameNode->RebuildRenderContextTree(); 1670 } 1671 1672 /** 1673 * @tc.name: FrameNodeRebuildRenderContextTree03 1674 * @tc.desc: Test the function RebuildRenderContextTree 1675 * @tc.type: FUNC 1676 */ 1677 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree03, TestSize.Level1) 1678 { 1679 /** 1680 * @tc.steps: step1. create frameNode. 1681 */ 1682 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1683 frameNode->needSyncRenderTree_ = true; 1684 frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>()); 1685 frameNode->overlayNode_->layoutProperty_ = nullptr; 1686 1687 /** 1688 * @tc.steps: step2. call the function RebuildRenderContextTree. 1689 */ 1690 frameNode->RebuildRenderContextTree(); 1691 } 1692 1693 /** 1694 * @tc.name: FrameNodeMarkModifyDone01 1695 * @tc.desc: Test the function MarkModifyDone 1696 * @tc.type: FUNC 1697 */ 1698 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone01, TestSize.Level1) 1699 { 1700 /** 1701 * @tc.steps: step1. create frameNode. 1702 */ 1703 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1704 frameNode->isPrivacySensitive_ = true; 1705 frameNode->isRestoreInfoUsed_ = false; 1706 frameNode->restoreId_ = 1; 1707 Recorder::EventRecorder::Get().componentEnable_ = true; 1708 Recorder::EventRecorder::Get().eventSwitch_.componentEnable = true; 1709 std::unordered_set<std::string> nodeSet; 1710 nodeSet.emplace("abc"); 1711 Recorder::NodeDataCache::Get().mergedConfig_->shareNodes.emplace("test", nodeSet); 1712 1713 /** 1714 * @tc.steps: step2. call the function MarkModifyDone. 1715 */ 1716 frameNode->MarkModifyDone(); 1717 } 1718 1719 /** 1720 * @tc.name: FrameNodeMarkModifyDone02 1721 * @tc.desc: Test the function MarkModifyDone 1722 * @tc.type: FUNC 1723 */ 1724 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone02, TestSize.Level1) 1725 { 1726 /** 1727 * @tc.steps: step1. create frameNode. 1728 */ 1729 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1730 frameNode->isPrivacySensitive_ = true; 1731 frameNode->isRestoreInfoUsed_ = false; 1732 frameNode->restoreId_ = 1; 1733 auto pipeline = MockPipelineContext::GetCurrentContext(); 1734 pipeline->privacySensitiveManager_ = nullptr; 1735 1736 /** 1737 * @tc.steps: step2. call the function MarkModifyDone. 1738 */ 1739 frameNode->MarkModifyDone(); 1740 } 1741 1742 /** 1743 * @tc.name: FrameNodeMarkDirtyNode01 1744 * @tc.desc: Test the function MarkDirtyNode 1745 * @tc.type: FUNC 1746 */ 1747 HWTEST_F(FrameNodeTestNg, FrameNodeMarkDirtyNode01, TestSize.Level1) 1748 { 1749 /** 1750 * @tc.steps: step1. create frameNode. 1751 */ 1752 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1753 frameNode->isPropertyDiffMarked_ = true; 1754 auto testNode = FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1755 testNode->isPropertyDiffMarked_ = false; 1756 1757 /** 1758 * @tc.steps: step2. call the function MarkDirtyNode. 1759 */ 1760 frameNode->MarkDirtyNode(PROPERTY_UPDATE_DIFF); 1761 testNode->MarkDirtyNode(PROPERTY_UPDATE_DIFF); 1762 } 1763 1764 /** 1765 * @tc.name: FrameNodeGetAncestorNodeOfFrame01 1766 * @tc.desc: Test the function GetAncestorNodeOfFrame 1767 * @tc.type: FUNC 1768 */ 1769 HWTEST_F(FrameNodeTestNg, FrameNodeGetAncestorNodeOfFrame01, TestSize.Level1) 1770 { 1771 /** 1772 * @tc.steps: step1. create frameNode. 1773 */ 1774 auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1775 frameNode->isWindowBoundary_ = true; 1776 1777 /** 1778 * @tc.steps: step2. call the function GetAncestorNodeOfFrame. 1779 */ 1780 frameNode->GetAncestorNodeOfFrame(true); 1781 } 1782 1783 /** 1784 * @tc.name: FrameNodeGetFirstAutoFillContainerNode01 1785 * @tc.desc: Test the function GetFirstAutoFillContainerNode 1786 * @tc.type: FUNC 1787 */ 1788 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode01, TestSize.Level1) 1789 { 1790 /** 1791 * @tc.steps: step1. create frameNode. 1792 */ 1793 auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 1794 1795 /** 1796 * @tc.steps: step2. call the function GetFirstAutoFillContainerNode. 1797 */ 1798 frameNode->GetFirstAutoFillContainerNode(); 1799 } 1800 1801 /** 1802 * @tc.name: FrameNodeGetFirstAutoFillContainerNode02 1803 * @tc.desc: Test the function GetFirstAutoFillContainerNode 1804 * @tc.type: FUNC 1805 */ 1806 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode02, TestSize.Level1) 1807 { 1808 /** 1809 * @tc.steps: step1. create frameNode. 1810 */ 1811 auto frameNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 1812 auto parentNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 1813 parentNode->AddChild(frameNode); 1814 1815 /** 1816 * @tc.steps: step2. call the function GetFirstAutoFillContainerNode. 1817 */ 1818 frameNode->GetFirstAutoFillContainerNode(); 1819 } 1820 1821 /** 1822 * @tc.name: FrameNodeGetFirstAutoFillContainerNode03 1823 * @tc.desc: Test the function GetFirstAutoFillContainerNode 1824 * @tc.type: FUNC 1825 */ 1826 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode03, TestSize.Level1) 1827 { 1828 /** 1829 * @tc.steps: step1. create frameNode. 1830 */ 1831 auto frameNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 1832 auto parentNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true); 1833 parentNode->AddChild(frameNode); 1834 1835 /** 1836 * @tc.steps: step2. call the function GetFirstAutoFillContainerNode. 1837 */ 1838 frameNode->GetFirstAutoFillContainerNode(); 1839 } 1840 1841 /** 1842 * @tc.name: FrameNodeNotifyFillRequestSuccess01 1843 * @tc.desc: Test the function NotifyFillRequestSuccess 1844 * @tc.type: FUNC 1845 */ 1846 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyFillRequestSuccess01, TestSize.Level1) 1847 { 1848 /** 1849 * @tc.steps: step1. create frameNode. 1850 */ 1851 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1852 EXPECT_NE(frameNode->pattern_, nullptr); 1853 1854 /** 1855 * @tc.steps: step2. call the function NotifyFillRequestSuccess. 1856 */ 1857 auto viewDataWrap = ViewDataWrap::CreateViewDataWrap(); 1858 auto nodeWrap = PageNodeInfoWrap::CreatePageNodeInfoWrap(); 1859 frameNode->NotifyFillRequestSuccess(viewDataWrap, nodeWrap, AceAutoFillType::ACE_PASSWORD); 1860 auto pattern = frameNode->pattern_; 1861 frameNode->pattern_ = nullptr; 1862 frameNode->NotifyFillRequestSuccess(viewDataWrap, nodeWrap, AceAutoFillType::ACE_PASSWORD); 1863 frameNode->pattern_ = pattern; 1864 } 1865 1866 /** 1867 * @tc.name: FrameNodeNotifyFillRequestFailed01 1868 * @tc.desc: Test the function NotifyFillRequestFailed 1869 * @tc.type: FUNC 1870 */ 1871 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyFillRequestFailed01, TestSize.Level1) 1872 { 1873 /** 1874 * @tc.steps: step1. create frameNode. 1875 */ 1876 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1877 EXPECT_NE(frameNode->pattern_, nullptr); 1878 1879 /** 1880 * @tc.steps: step2. call the function NotifyFillRequestFailed. 1881 */ 1882 auto pattern = frameNode->pattern_; 1883 frameNode->pattern_ = nullptr; 1884 frameNode->NotifyFillRequestFailed(1, "test", true); 1885 frameNode->pattern_ = pattern; 1886 } 1887 1888 /** 1889 * @tc.name: FrameNodeMarkNeedRender01 1890 * @tc.desc: Test the function MarkNeedRender 1891 * @tc.type: FUNC 1892 */ 1893 HWTEST_F(FrameNodeTestNg, FrameNodeMarkNeedRender01, TestSize.Level1) 1894 { 1895 /** 1896 * @tc.steps: step1. create frameNode. 1897 */ 1898 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1899 frameNode->isLayoutDirtyMarked_ = false; 1900 frameNode->isRenderDirtyMarked_ = false; 1901 1902 /** 1903 * @tc.steps: step2. call the function MarkNeedRender. 1904 */ 1905 frameNode->MarkNeedRender(false); 1906 } 1907 1908 /** 1909 * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrame01 1910 * @tc.desc: Test the function OnGenerateOneDepthVisibleFrame 1911 * @tc.type: FUNC 1912 */ 1913 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrame01, TestSize.Level1) 1914 { 1915 /** 1916 * @tc.steps: step1. create frameNode. 1917 */ 1918 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1919 auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1920 frameNode->isLayoutNode_ = true; 1921 frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>()); 1922 1923 /** 1924 * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrame. 1925 */ 1926 std::list<RefPtr<FrameNode>> children; 1927 children.push_back(childNode); 1928 frameNode->OnGenerateOneDepthVisibleFrame(children); 1929 } 1930 1931 /** 1932 * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrame02 1933 * @tc.desc: Test the function OnGenerateOneDepthVisibleFrame 1934 * @tc.type: FUNC 1935 */ 1936 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrame02, TestSize.Level1) 1937 { 1938 /** 1939 * @tc.steps: step1. create frameNode. 1940 */ 1941 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1942 auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1943 frameNode->isLayoutNode_ = true; 1944 frameNode->overlayNode_ = nullptr; 1945 1946 /** 1947 * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrame. 1948 */ 1949 std::list<RefPtr<FrameNode>> children; 1950 children.push_back(childNode); 1951 frameNode->OnGenerateOneDepthVisibleFrame(children); 1952 } 1953 1954 /** 1955 * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrameWithTransition01 1956 * @tc.desc: Test the function OnGenerateOneDepthVisibleFrameWithTransition 1957 * @tc.type: FUNC 1958 */ 1959 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrameWithTransition01, TestSize.Level1) 1960 { 1961 /** 1962 * @tc.steps: step1. create frameNode. 1963 */ 1964 auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true); 1965 auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true); 1966 frameNode->isLayoutNode_ = true; 1967 frameNode->isActive_ = true; 1968 frameNode->overlayNode_ = nullptr; 1969 1970 /** 1971 * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrameWithTransition. 1972 */ 1973 std::list<RefPtr<FrameNode>> children; 1974 children.push_back(childNode); 1975 frameNode->OnGenerateOneDepthVisibleFrameWithTransition(children); 1976 frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>()); 1977 frameNode->OnGenerateOneDepthVisibleFrameWithTransition(children); 1978 } 1979 } // namespace OHOS::Ace::NG 1980