• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/unittest/core/base/frame_node_test_ng.h"
16 
17 #include "core/common/recorder/event_definition.h"
18 #include "core/components_ng/property/grid_property.h"
19 #include "core/common/recorder/event_recorder.h"
20 #include "core/common/recorder/node_data_cache.h"
21 #include "core/components_ng/pattern/image/image_pattern.h"
22 #include "core/components_ng/pattern/stage/page_pattern.h"
23 #include "test/mock/base/mock_task_executor.h"
24 #include "test/mock/core/render/mock_canvas_image.h"
25 
26 using namespace testing;
27 using namespace testing::ext;
28 
29 namespace OHOS::Ace::NG {
30 namespace {} // namespace
31 
32 /**
33  * @tc.name: FrameNodeGetIsLayoutNode01
34  * @tc.desc: Test the function GetIsLayoutNode
35  * @tc.type: FUNC
36  */
37 HWTEST_F(FrameNodeTestNg, FrameNodeGetIsLayoutNode01, TestSize.Level1)
38 {
39     /**
40      * @tc.steps1: call the function GetIsLayoutNode.
41      * @tc.expected: Value returned as expected.
42      */
43     RefPtr<FrameNode> node = FrameNode::CreateCommonNode("node", 1, false, AceType::MakeRefPtr<Pattern>());
44     EXPECT_FALSE(node->GetIsLayoutNode());
45 }
46 
47 /**
48  * @tc.name: FrameNodeGetIsLayoutNode02
49  * @tc.desc: Test the function GetIsLayoutNode
50  * @tc.type: FUNC
51  */
52 HWTEST_F(FrameNodeTestNg, FrameNodeGetIsLayoutNode02, TestSize.Level1)
53 {
54     /**
55      * @tc.steps1: call the function GetIsLayoutNode.
56      * @tc.expected: Value returned as expected.
57      */
58     RefPtr<FrameNode> node = FrameNode::CreateCommonNode("node", 1, true, AceType::MakeRefPtr<Pattern>());
59     EXPECT_TRUE(node->GetIsLayoutNode());
60 }
61 
62 /**
63  * @tc.name: FrameNodeSetIsFindGetIsFind01
64  * @tc.desc: Test the function SetIsFind GetIsFind
65  * @tc.type: FUNC
66  */
67 HWTEST_F(FrameNodeTestNg, FrameNodeSetIsFindGetIsFind01, TestSize.Level1)
68 {
69     /**
70      * @tc.steps1: call the function SetIsFind GetIsFind.
71      * @tc.expected: Value returned as expected.
72      */
73     RefPtr<FrameNode> node = FrameNode::CreateFrameNode("node", 1, AceType::MakeRefPtr<Pattern>());
74     node->SetIsFind(true);
75     EXPECT_TRUE(node->GetIsFind());
76 }
77 
78 /**
79  * @tc.name: FrameNodeSetIsFindGetIsFind02
80  * @tc.desc: Test the function SetIsFind GetIsFind
81  * @tc.type: FUNC
82  */
83 HWTEST_F(FrameNodeTestNg, FrameNodeSetIsFindGetIsFind02, TestSize.Level1)
84 {
85     /**
86      * @tc.steps1: call the function SetIsFind GetIsFind.
87      * @tc.expected: Value returned as expected.
88      */
89     RefPtr<FrameNode> node = FrameNode::CreateFrameNode("node", 1, AceType::MakeRefPtr<Pattern>());
90     node->SetIsFind(false);
91     EXPECT_FALSE(node->GetIsFind());
92 }
93 
94 /**
95  * @tc.name: FrameNodeGetOneDepthVisibleFrame01
96  * @tc.desc: Test the function GetOneDepthVisibleFrame
97  * @tc.type: FUNC
98  */
99 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrame01, TestSize.Level1)
100 {
101     /**
102      * @tc.steps: step1. create frameNode ,childNode and overlayNode.
103      */
104     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
105     auto childNode =
106         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode
107     auto overlayNode =
108         FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), true); // 3 is id of overlayNode
109 
110     /**
111      * @tc.steps: step2. add childnode to the childnode list
112      */
113     std::list<RefPtr<FrameNode>> children;
114     children.push_back(childNode);
115     node->frameChildren_ = { children.begin(), children.end() };
116 
117     /**
118      * @tc.steps: step3. call the function GetOneDepthVisibleFrame.
119      */
120     node->SetOverlayNode(overlayNode);
121     node->GetOneDepthVisibleFrame(children);
122     EXPECT_NE(node->overlayNode_, nullptr);
123 }
124 
125 /**
126  * @tc.name: FrameNodeGetOneDepthVisibleFrame02
127  * @tc.desc: Test the function GetOneDepthVisibleFrame
128  * @tc.type: FUNC
129  */
130 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrame02, TestSize.Level1)
131 {
132     /**
133      * @tc.steps: step1. create frameNode ,childNode and overlayNode.
134      */
135     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
136     auto childNode =
137         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode
138     auto overlayNode = nullptr;
139 
140     /**
141      * @tc.steps: step2. add childnode to the childnode list
142      */
143     std::list<RefPtr<FrameNode>> children;
144     children.push_back(childNode);
145     node->frameChildren_ = { children.begin(), children.end() };
146 
147     /**
148      * @tc.steps: step3. call the function GetOneDepthVisibleFrame.
149      */
150     node->SetOverlayNode(overlayNode);
151     node->GetOneDepthVisibleFrame(children);
152     EXPECT_EQ(node->overlayNode_, nullptr);
153 }
154 
155 /**
156  * @tc.name: FrameNodeGetOneDepthVisibleFrameWithOffset01
157  * @tc.desc: Test the function GetOneDepthVisibleFrameWithOffset
158  * @tc.type: FUNC
159  */
160 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrameWithOffset01, TestSize.Level1)
161 {
162     /**
163      * @tc.steps: step1. create frameNode ,childNode and overlayNode.
164      */
165     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
166     auto childNode =
167         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode
168     auto overlayNode =
169         FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), true); // 3 is id of overlayNode
170 
171     /**
172      * @tc.steps: step2. add childnode to the childnode list
173      */
174     std::list<RefPtr<FrameNode>> children;
175     children.push_back(childNode);
176     node->frameChildren_ = { children.begin(), children.end() };
177 
178     /**
179      * @tc.steps: step3. call the function GetOneDepthVisibleFrameWithOffset.
180      */
181     OffsetF Offset = { 0, 0 };
182     node->SetOverlayNode(overlayNode);
183     node->GetOneDepthVisibleFrameWithOffset(children, Offset);
184     EXPECT_NE(node->overlayNode_, nullptr);
185 }
186 
187 /**
188  * @tc.name: FrameNodeGetOneDepthVisibleFrameWithOffset02
189  * @tc.desc: Test the function GetOneDepthVisibleFrameWithOffset
190  * @tc.type: FUNC
191  */
192 HWTEST_F(FrameNodeTestNg, FrameNodeGetOneDepthVisibleFrameWithOffset02, TestSize.Level1)
193 {
194     /**
195      * @tc.steps: step1. create frameNode ,childNode and overlayNode.
196      */
197     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
198     auto childNode =
199         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNode
200     auto overlayNode = nullptr;
201 
202     /**
203      * @tc.steps: step2. add childnode to the childnode list
204      */
205     std::list<RefPtr<FrameNode>> children;
206     children.push_back(childNode);
207     node->frameChildren_ = { children.begin(), children.end() };
208 
209     /**
210      * @tc.steps: step3. call the function GetOneDepthVisibleFrameWithOffset.
211      */
212     OffsetF Offset = { 0, 0 };
213     node->SetOverlayNode(overlayNode);
214     node->GetOneDepthVisibleFrameWithOffset(children, Offset);
215     EXPECT_EQ(node->overlayNode_, nullptr);
216 }
217 
218 /**
219  * @tc.name: FrameNodeGetOrCreateCommonNode01
220  * @tc.desc: Test the function GetOrCreateCommonNode
221  * @tc.type: FUNC
222  */
223 HWTEST_F(FrameNodeTestNg, FrameNodeGetOrCreateCommonNode01, TestSize.Level1)
224 {
225     /**
226      * @tc.steps: step1: create commonNode.
227      */
228     RefPtr<FrameNode> commonNode = FrameNode::CreateCommonNode("commonNode", 1, true, AceType::MakeRefPtr<Pattern>());
229     EXPECT_TRUE(commonNode->GetIsLayoutNode());
230     /**
231      * @tc.steps: step2: call the function GetOrCreateCommonNode.
232      * @tc.expected: Value returned as expected.
233      */
234     auto blankNode =
__anon61db40680202() 235         FrameNode::GetOrCreateCommonNode("commonNode", 1, false, []() { return AceType::MakeRefPtr<Pattern>(); });
236     EXPECT_EQ(strcmp(blankNode->GetTag().c_str(), "commonNode"), 0);
237     EXPECT_FALSE(blankNode->GetIsLayoutNode());
238 }
239 
240 /**
241  * @tc.name: FrameNodeProcessOffscreenNode01
242  * @tc.desc: Test the function ProcessOffscreenNode
243  * @tc.type: FUNC
244  */
245 HWTEST_F(FrameNodeTestNg, FrameNodeProcessOffscreenNode01, TestSize.Level1)
246 {
247     /**
248      * @tc.steps: step1. create frameNode and childNode.
249      */
250     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
251     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
252     auto childNodeOne =
253         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true); // 2 is id of childNodeOne
254     auto childNodeTwo = nullptr;
255 
256     /**
257      * @tc.steps: step2. add childnode to the predictLayoutNode list
258      */
259     node->AddPredictLayoutNode(childNodeOne);
260     node->AddPredictLayoutNode(childNodeTwo);
261 
262     /**
263      * @tc.steps: step3. call the function ProcessOffscreenNode.
264      */
265     frameNode->ProcessOffscreenNode(node);
266     EXPECT_NE(frameNode, nullptr);
267 }
268 
269 /**
270  * @tc.name: FrameNodeDumpAlignRulesInfo01
271  * @tc.desc: Test the function DumpAlignRulesInfo
272  * @tc.type: FUNC
273  */
274 HWTEST_F(FrameNodeTestNg, FrameNodeDumpAlignRulesInfo01, TestSize.Level1)
275 {
276     /**
277      * @tc.steps: step1. create frameNode.
278      */
279     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
280 
281     /**
282      * @tc.steps: step2. create layoutProperty.
283      */
284     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
285     layoutProperty->flexItemProperty_ = std::make_unique<FlexItemProperty>();
286     std::map<AlignDirection, AlignRule> firstItemAlignRules;
287     AlignRule alignRule;
288     alignRule.anchor = "test";
289     alignRule.horizontal = HorizontalAlign::START;
290     firstItemAlignRules[AlignDirection::LEFT] = alignRule;
291 
292     layoutProperty->UpdateAlignRules(firstItemAlignRules);
293     layoutProperty->flexItemProperty_->propFlexGrow = 1.0f;
294 
295     /**
296      * @tc.steps: step3. call the function DumpAlignRulesInfo.
297      */
298     frameNode->SetLayoutProperty(layoutProperty);
299     frameNode->DumpAlignRulesInfo();
300     EXPECT_NE(frameNode, nullptr);
301     EXPECT_NE(frameNode->layoutProperty_, nullptr);
302 }
303 
304 /**
305  * @tc.name: FrameNodeDumpSafeAreaInfo01
306  * @tc.desc: Test the function DumpSafeAreaInfo
307  * @tc.type: FUNC
308  */
309 HWTEST_F(FrameNodeTestNg, FrameNodeDumpSafeAreaInfo01, TestSize.Level1)
310 {
311     SafeAreaExpandOpts opts;
312     SafeAreaInsets safeArea;
313     SafeAreaExpandOpts expandOpts = {
314         .edges = SAFE_AREA_TYPE_SYSTEM,
315         .type = SAFE_AREA_EDGE_TOP,
316     };
317     SafeAreaInsets::Inset inset = {
318         .start = 0,
319         .end = 1,
320     };
321 
322     SafeAreaInsets safeAreaInset(inset, inset, inset, inset);
323     /**
324      * @tc.steps: step1. create frameNode.
325      */
326     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
327 
328     /**
329      * @tc.steps: step2. create layoutProperty.
330      */
331     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
332     layoutProperty->safeAreaExpandOpts_ = std::make_unique<SafeAreaExpandOpts>(opts);
333     layoutProperty->safeAreaInsets_ = std::make_unique<SafeAreaInsets>(safeArea);
334     layoutProperty->UpdateSafeAreaExpandOpts(expandOpts);
335     layoutProperty->UpdateSafeAreaInsets(safeAreaInset);
336     EXPECT_EQ(layoutProperty->safeAreaExpandOpts_->edges, SAFE_AREA_TYPE_SYSTEM);
337     EXPECT_EQ(layoutProperty->safeAreaExpandOpts_->type, SAFE_AREA_EDGE_TOP);
338 
339     /**
340      * @tc.steps: step3. call the function DumpSafeAreaInfo.
341      */
342     frameNode->SetLayoutProperty(layoutProperty);
343     frameNode->DumpSafeAreaInfo();
344 }
345 
346 /**
347  * @tc.name: FrameNodeDumpCommonInfo01
348  * @tc.desc: Test the function DumpCommonInfo
349  * @tc.type: FUNC
350  */
351 HWTEST_F(FrameNodeTestNg, FrameNodeDumpCommonInfo01, TestSize.Level1)
352 {
353     LayoutConstraintF layoutConstraintF = {
354         .minSize = { 1, 1 },
355         .maxSize = { 10, 10 },        // 10 is the maxSize of width and height
356         .percentReference = { 5, 5 }, // 5 is the percentReference of width and height
357         .parentIdealSize = { 2, 2 },  // 2 is the parentIdealSize of width and height
358     };
359 
360     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
361 
362     /**
363      * @tc.steps: step1. create frameNode.
364      */
365     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
366     frameNode->AddChild(FRAME_NODE);
367     EXPECT_EQ(frameNode->GetTotalChildCount(), 1);
368 
369     /**
370      * @tc.steps: step2. create layoutProperty.
371      */
372     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
373     layoutProperty->propVisibility_ = VisibleType::INVISIBLE;
374     layoutProperty->SetLayoutRect(testRect);
375     layoutProperty->layoutConstraint_ = layoutConstraintF;
376     layoutProperty->contentConstraint_ = layoutConstraintF;
377 
378     /**
379      * @tc.steps: step3. call the function DumpCommonInfo.
380      */
381     frameNode->SetLayoutProperty(layoutProperty);
382     frameNode->DumpCommonInfo();
383 }
384 
385 /**
386  * @tc.name: FrameNodeDumpCommonInfo02
387  * @tc.desc: Test frameNode DumpCommonInfo
388  * @tc.type: FUNC
389  */
390 HWTEST_F(FrameNodeTestNg, FrameNodeDumpCommonInfo02, TestSize.Level1)
391 {
392     /**
393      * @tc.steps: step1. create frameNode.
394      */
395     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
396     EXPECT_NE(frameNode->pattern_, nullptr);
397 
398     /**
399      * @tc.steps: step2. call DumpCommonInfo.
400      * @tc.expected: expect description_[12] is BorderRadius.
401      */
402     frameNode->geometryNode_->frame_.rect_ = { 10.0f, 10.0f, 10.0f, 10.0f };
403     LayoutConstraintF parentLayoutConstraint;
404     frameNode->geometryNode_->parentLayoutConstraint_ = parentLayoutConstraint;
405     frameNode->isFreeze_ = true;
406     frameNode->userFreeze_ = true;
407     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
408     layoutProperty->propVisibility_ = VisibleType::INVISIBLE;
409     layoutProperty->padding_ = std::make_unique<PaddingProperty>();
410     layoutProperty->safeAreaPadding_ = std::make_unique<PaddingProperty>();
411     layoutProperty->borderWidth_ = std::make_unique<BorderWidthProperty>();
412     frameNode->layoutProperty_ = layoutProperty;
413     Dimension radius(10.0f);
414     BorderRadiusProperty borderRadiusProperty { radius, radius, radius, radius };
415     frameNode->renderContext_->UpdateBorderRadius(borderRadiusProperty);
416     DumpLog::GetInstance().description_.clear();
417     frameNode->DumpCommonInfo();
418     EXPECT_EQ(DumpLog::GetInstance().description_[11],
419         "BorderRadius: radiusTopLeft: [10.00px]radiusTopRight: "
420         "[10.00px]radiusBottomLeft: [10.00px]radiusBottomRight: [10.00px]\n");
421 }
422 
423 /**
424  * @tc.name: FrameNodeDumpOnSizeChangeInfo01
425  * @tc.desc: Test the function DumpOnSizeChangeInfo
426  * @tc.type: FUNC
427  */
428 HWTEST_F(FrameNodeTestNg, FrameNodeDumpOnSizeChangeInfo01, TestSize.Level1)
429 {
430     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
431     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
432     FrameNode::onSizeChangeDumpInfo dumpInfo1 { 1, testLastFrameRect,
433         testCurrFrameRect }; // 1 is the onSizeChangeTimeStamp
434     FrameNode::onSizeChangeDumpInfo dumpInfo2 { 2, testLastFrameRect,
435         testCurrFrameRect }; // 2 is the onSizeChangeTimeStamp
436 
437     /**
438      * @tc.steps: step1. create frameNode.
439      */
440     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
441 
442     /**
443      * @tc.steps: step2. add onSizeChangeDumpInfos.
444      */
445     frameNode->onSizeChangeDumpInfos.push_back(dumpInfo1);
446     frameNode->onSizeChangeDumpInfos.push_back(dumpInfo2);
447 
448     /**
449      * @tc.steps: step3. call the function DumpOnSizeChangeInfo.
450      */
451     frameNode->DumpOnSizeChangeInfo();
452     EXPECT_NE(frameNode, nullptr);
453 }
454 
455 /**
456  * @tc.name: FrameNodeDumpInfo01
457  * @tc.desc: Test the function DumpInfo DumpAdvanceInfo CheckAutoSave
458  * @tc.type: FUNC
459  */
460 HWTEST_F(FrameNodeTestNg, FrameNodeDumpInfo01, TestSize.Level1)
461 {
462     /**
463      * @tc.steps: step1. create frameNode.
464      */
465     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
466     EXPECT_NE(frameNode->pattern_, nullptr);
467 
468     /**
469      * @tc.steps: step2. update pattern_.
470      */
471     auto pattern = frameNode->pattern_;
472     frameNode->pattern_ = nullptr;
473 
474     /**
475      * @tc.steps: step3. call the function DumpOnSizeChangeInfo DumpAdvanceInfo CheckAutoSave.
476      */
477     auto viewDataWrap = ViewDataWrap::CreateViewDataWrap();
478     frameNode->DumpInfo();
479     frameNode->DumpAdvanceInfo();
480     frameNode->DumpViewDataPageNode(viewDataWrap);
481     EXPECT_FALSE(frameNode->CheckAutoSave());
482     frameNode->pattern_ = pattern;
483 }
484 
485 /**
486  * @tc.name: FrameNodeMouseToJsonValue01
487  * @tc.desc: Test the function MouseToJsonValue
488  * @tc.type: FUNC
489  */
490 HWTEST_F(FrameNodeTestNg, FrameNodeMouseToJsonValue01, TestSize.Level1)
491 {
492     /**
493      * @tc.steps: step1. create frameNode.
494      */
495     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
496     EXPECT_NE(frameNode->pattern_, nullptr);
497 
498     /**
499      * @tc.steps: step2. call the function MouseToJsonValue.
500      */
501     InspectorFilter testFilter;
502     auto jsonValue = std::make_unique<JsonValue>();
503     testFilter.AddFilterAttr("focusable");
504     frameNode->MouseToJsonValue(jsonValue, testFilter);
505     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
506 }
507 
508 /**
509  * @tc.name: FrameNodeTouchToJsonValue01
510  * @tc.desc: Test the function TouchToJsonValue
511  * @tc.type: FUNC
512  */
513 HWTEST_F(FrameNodeTestNg, FrameNodeTouchToJsonValue01, TestSize.Level1)
514 {
515     /**
516      * @tc.steps: step1. create frameNode.
517      */
518     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
519     EXPECT_NE(frameNode->pattern_, nullptr);
520 
521     /**
522      * @tc.steps: step2. call the function TouchToJsonValue.
523      */
524     InspectorFilter testFilter;
525     auto jsonValue = std::make_unique<JsonValue>();
526     testFilter.AddFilterAttr("focusable");
527     frameNode->TouchToJsonValue(jsonValue, testFilter);
528     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
529 }
530 
531 /**
532  * @tc.name: FrameNodeTouchToJsonValue02
533  * @tc.desc: Test the function TouchToJsonValue
534  * @tc.type: FUNC
535  */
536 HWTEST_F(FrameNodeTestNg, FrameNodeTouchToJsonValue02, TestSize.Level1)
537 {
538     /**
539      * @tc.steps: step1. create frameNode.
540      */
541     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
542     EXPECT_NE(frameNode->pattern_, nullptr);
543     frameNode->isActive_ = true;
544     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
545 
546     /**
547      * @tc.steps: step2. update the mouseResponseRegion.
548      */
549     DimensionRect responseRect(Dimension(0), Dimension(0), DimensionOffset(OFFSETF));
550     std::vector<DimensionRect> mouseResponseRegion;
551     mouseResponseRegion.emplace_back(responseRect);
552     auto gestureEventHub = frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
553     gestureEventHub->SetMouseResponseRegion(mouseResponseRegion);
554 
555     /**
556      * @tc.steps: step3. call the function TouchToJsonValue.
557      */
558     InspectorFilter testFilter;
559     auto jsonValue = std::make_unique<JsonValue>();
560     frameNode->TouchToJsonValue(jsonValue, testFilter);
561     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
562 }
563 
564 /**
565  * @tc.name: FrameNodeToTreeJson01
566  * @tc.desc: Test the function ToTreeJson
567  * @tc.type: FUNC
568  */
569 HWTEST_F(FrameNodeTestNg, FrameNodeToTreeJson01, TestSize.Level1)
570 {
571     /**
572      * @tc.steps: step1. create frameNode.
573      */
574     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
575     EXPECT_NE(frameNode->pattern_, nullptr);
576 
577     /**
578      * @tc.steps: step2. call the function ToTreeJson.
579      */
580     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
581     frameNode->SetLayoutProperty(layoutProperty);
582 
583     InspectorConfig testConfig;
584     auto jsonValue = std::make_unique<JsonValue>();
585     testConfig.contentOnly = true;
586     frameNode->ToTreeJson(jsonValue, testConfig);
587 }
588 
589 /**
590  * @tc.name: FrameNodeToTreeJson02
591  * @tc.desc: Test the function ToTreeJson
592  * @tc.type: FUNC
593  */
594 HWTEST_F(FrameNodeTestNg, FrameNodeToTreeJson02, TestSize.Level1)
595 {
596     /**
597      * @tc.steps: step1. create frameNode.
598      */
599     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
600     EXPECT_NE(frameNode->pattern_, nullptr);
601 
602     /**
603      * @tc.steps: step2. call the function ToTreeJson.
604      */
605     frameNode->paintProperty_ = nullptr;
606     frameNode->propInspectorId_ = "123";
607     frameNode->accessibilityProperty_ = nullptr;
608     frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateFocusHub();
609 
610     InspectorConfig testConfig;
611     auto jsonValue = std::make_unique<JsonValue>();
612     testConfig.contentOnly = false;
613     frameNode->ToTreeJson(jsonValue, testConfig);
614 }
615 
616 /**
617  * @tc.name: FrameNodeToTreeJson03
618  * @tc.desc: Test the function ToTreeJson
619  * @tc.type: FUNC
620  */
621 HWTEST_F(FrameNodeTestNg, FrameNodeToTreeJson03, TestSize.Level1)
622 {
623     /**
624      * @tc.steps: step1. create frameNode.
625      */
626     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
627     EXPECT_NE(frameNode->pattern_, nullptr);
628 
629     /**
630      * @tc.steps: step2. call the function ToTreeJson.
631      */
632     auto pattern = frameNode->pattern_;
633     frameNode->pattern_ = nullptr;
634     frameNode->paintProperty_ = nullptr;
635     frameNode->accessibilityProperty_->accessibilityText_ = "test";
636     frameNode->layoutProperty_ = nullptr;
637 
638     InspectorConfig testConfig;
639     auto jsonValue = std::make_unique<JsonValue>();
640     testConfig.contentOnly = false;
641     frameNode->ToTreeJson(jsonValue, testConfig);
642     frameNode->pattern_ = pattern;
643 }
644 
645 /**
646  * @tc.name: FrameNodeFromJson01
647  * @tc.desc: Test the function FromJson
648  * @tc.type: FUNC
649  */
650 HWTEST_F(FrameNodeTestNg, FrameNodeFromJson01, TestSize.Level1)
651 {
652     /**
653      * @tc.steps: step1. create frameNode.
654      */
655     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
656     EXPECT_NE(frameNode->pattern_, nullptr);
657 
658     /**
659      * @tc.steps: step2. call the function FromJson.
660      */
661     auto eventHub = frameNode->eventHub_;
662     frameNode->eventHub_ = nullptr;
663     InspectorFilter testFilter;
664     auto jsonValue = std::make_unique<JsonValue>();
665     testFilter.AddFilterAttr("focusable");
666     frameNode->FromJson(jsonValue);
667     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
668     frameNode->eventHub_ = eventHub;
669 }
670 
671 /**
672  * @tc.name: FrameNodeUpdateGeometryTransition01
673  * @tc.desc: Test the function UpdateGeometryTransition
674  * @tc.type: FUNC
675  */
676 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateGeometryTransition01, TestSize.Level1)
677 {
678     /**
679      * @tc.steps: step1. create frameNode.
680      */
681     auto frameNode = FrameNode::CreateFrameNode("parent", 0, AceType::MakeRefPtr<Pattern>(), true);
682     auto child = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>());
683     EXPECT_NE(frameNode->pattern_, nullptr);
684     frameNode->AddChild(child);
685     EXPECT_EQ(frameNode->GetTotalChildCount(), 1);
686 
687     /**
688      * @tc.steps: step2. update geometryTransition.
689      */
690     frameNode->GetLayoutProperty()->UpdateGeometryTransition("parent", true);
691     child->GetLayoutProperty()->UpdateGeometryTransition("child", false);
692     LayoutProperty::UpdateAllGeometryTransition(frameNode);
693 
694     /**
695      * @tc.steps: step3. call the function UpdateGeometryTransition.
696      */
697     frameNode->UpdateGeometryTransition();
698 }
699 
700 /**
701  * @tc.name: FrameNodeOnAttachToMainTree01
702  * @tc.desc: Test the function OnAttachToMainTree
703  * @tc.type: FUNC
704  */
705 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree01, TestSize.Level1)
706 {
707     /**
708      * @tc.steps: step1. create node.
709      */
710     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
711     auto childNodeOne =
712         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), false); // 2 is id of childNodeOne
713     auto childNodeTwo = nullptr;
714     auto childNodeThree =
715         FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), false); // 3 is id of childNodeThree
716     EXPECT_NE(frameNode->pattern_, nullptr);
717 
718     /**
719      * @tc.steps: step2. update node.
720      */
721     childNodeOne->isLayoutDirtyMarked_ = true;
722     childNodeThree->isLayoutDirtyMarked_ = false;
723     frameNode->AddPredictLayoutNode(childNodeOne);
724     frameNode->AddPredictLayoutNode(childNodeTwo);
725     frameNode->AddPredictLayoutNode(childNodeThree);
726     frameNode->useOffscreenProcess_ = true;
727     frameNode->isPropertyDiffMarked_ = true;
728 
729     /**
730      * @tc.steps: step3. call the function OnAttachToMainTree.
731      */
732     frameNode->OnAttachToMainTree(true);
733 }
734 
735 /**
736  * @tc.name: FrameNodeOnAttachToMainTree02
737  * @tc.desc: Test the function OnAttachToMainTree
738  * @tc.type: FUNC
739  */
740 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree02, TestSize.Level1)
741 {
742     LayoutConstraintF layoutConstraintF = {
743         .minSize = { 1, 1 },
744         .maxSize = { 10, 10 },        // 10 is the maxSize of width and height
745         .percentReference = { 5, 5 }, // 5 is the percentReference of width and height
746         .parentIdealSize = { 2, 2 },  // 2 is the parentIdealSize of width and height
747     };
748     /**
749      * @tc.steps: step1. create node.
750      */
751     auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true);
752     auto childNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), false);
753 
754     /**
755      * @tc.steps: step2. update node.
756      */
757     childNode->isLayoutDirtyMarked_ = true;
758     frameNode->AddPredictLayoutNode(childNode);
759     frameNode->useOffscreenProcess_ = false;
760     frameNode->isPropertyDiffMarked_ = true;
761     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF);
762 
763     /**
764      * @tc.steps: step3. call the function OnAttachToMainTree.
765      */
766     frameNode->OnAttachToMainTree(true);
767     EXPECT_TRUE(childNode->isLayoutDirtyMarked_);
768     EXPECT_FALSE(frameNode->useOffscreenProcess_);
769     EXPECT_TRUE(frameNode->isPropertyDiffMarked_);
770     auto context = frameNode->GetContext();
771     bool hasDirtyPropertyNodes = context->dirtyPropertyNodes_.find(frameNode) != context->dirtyPropertyNodes_.end();
772     EXPECT_TRUE(hasDirtyPropertyNodes);
773 }
774 
775 /**
776  * @tc.name: FrameNodeOnAttachToBuilderNode01
777  * @tc.desc: Test the function OnAttachToBuilderNode
778  * @tc.type: FUNC
779  */
780 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToBuilderNode01, TestSize.Level1)
781 {
782     /**
783      * @tc.steps: step1. create node.
784      */
785     auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true);
786 
787     /**
788      * @tc.steps: step2. call the function OnAttachToBuilderNode.
789      */
790     frameNode->OnAttachToBuilderNode(NodeStatus::BUILDER_NODE_ON_MAINTREE);
791     EXPECT_NE(frameNode->pattern_, nullptr);
792 }
793 
794 /**
795  * @tc.name: FrameNodeOnConfigurationUpdate01
796  * @tc.desc: Test the function OnConfigurationUpdate
797  * @tc.type: FUNC
798  */
799 HWTEST_F(FrameNodeTestNg, FrameNodeOnConfigurationUpdate01, TestSize.Level1)
800 {
801     /**
802      * @tc.steps: step1. create node.
803      */
804     auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true);
__anon61db40680302() 805     auto callback = []() {};
806     frameNode->SetColorModeUpdateCallback(std::move(callback));
807 
808     /**
809      * @tc.steps: step2. call the function OnConfigurationUpdate.
810      */
811     ConfigurationChange configurationChange;
812     configurationChange.colorModeUpdate = true;
813     configurationChange.fontUpdate = false;
814     configurationChange.iconUpdate = false;
815     configurationChange.skinUpdate = false;
816     frameNode->OnConfigurationUpdate(configurationChange);
817     EXPECT_TRUE(configurationChange.colorModeUpdate);
818     EXPECT_FALSE(configurationChange.fontUpdate);
819     EXPECT_FALSE(configurationChange.iconUpdate);
820     EXPECT_FALSE(configurationChange.skinUpdate);
821 }
822 
823 /**
824  * @tc.name: FrameNodeSwapDirtyLayoutWrapperOnMainThread01
825  * @tc.desc: Test the function SwapDirtyLayoutWrapperOnMainThread
826  * @tc.type: FUNC
827  */
828 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread01, TestSize.Level1)
829 {
830     /**
831      * @tc.steps: step1. create frameNode.
832      */
833     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
834     frameNode->isActive_ = false;
835     /**
836      * @tc.steps: step2. create layoutProperty.
837      */
838     BorderWidthProperty borderWidth = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp };
839     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
840     layoutProperty->UpdateBorderWidth(borderWidth);
841 
842     RefPtr<LayoutWrapper> layoutWrapper = frameNode->CreateLayoutWrapper(true, true);
843     layoutWrapper->SetActive(true);
844 
__anon61db40680402() 845     auto builderFunc = []() -> RefPtr<UINode> {
846         auto node = FrameNode::CreateFrameNode("node", 0, AceType::MakeRefPtr<Pattern>(), true);
847         auto childNode = FrameNode::CreateFrameNode("child", 1, AceType::MakeRefPtr<Pattern>(), true);
848         node->AddChild(childNode);
849         return node;
850     };
851 
852     /**
853      * @tc.steps: step3. call the function DumpCommonInfo.
854      */
855     frameNode->SetBackgroundFunction(builderFunc);
856     frameNode->SetLayoutProperty(layoutProperty);
857     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
858     EXPECT_TRUE(frameNode->isActive_);
859 }
860 
861 /**
862  * @tc.name: FrameNodeSwapDirtyLayoutWrapperOnMainThread02
863  * @tc.desc: Test the function SwapDirtyLayoutWrapperOnMainThread
864  * @tc.type: FUNC
865  */
866 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread02, TestSize.Level1)
867 {
868     LayoutConstraintF layoutConstraintF = {
869         .minSize = { 1, 1 },
870         .maxSize = { 10, 10 },        // 10 is the maxSize of width and height
871         .percentReference = { 5, 5 }, // 5 is the percentReference of width and height
872         .parentIdealSize = { 2, 2 },  // 2 is the parentIdealSize of width and height
873     };
874     /**
875      * @tc.steps: step1. create frameNode.
876      */
877     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
878     frameNode->isActive_ = false;
879     /**
880      * @tc.steps: step2. create layoutProperty.
881      */
882     BorderWidthProperty borderWidth = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp };
883     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
884     layoutProperty->UpdateBorderWidth(borderWidth);
885     layoutProperty->layoutConstraint_ = layoutConstraintF;
886     layoutProperty->contentConstraint_ = layoutConstraintF;
887     frameNode->GetOrCreateFocusHub()->currentFocus_ = true;
888 
889     RefPtr<LayoutWrapper> layoutWrapper = frameNode->CreateLayoutWrapper(true, true);
890     layoutWrapper->SetActive(true);
891 
__anon61db40680502() 892     auto builderFunc = []() -> RefPtr<UINode> { return nullptr; };
893 
894     /**
895      * @tc.steps: step3. update renderContext_.
896      */
897     BorderColorProperty borderColorProperty;
898     borderColorProperty.SetColor(Color::BLUE);
899     frameNode->renderContext_->UpdateBorderColor(borderColorProperty);
900     BorderStyleProperty borderStyleProperty;
901     borderStyleProperty.SetBorderStyle(BorderStyle::SOLID);
902     frameNode->renderContext_->UpdateBorderStyle(borderStyleProperty);
903     BorderWidthProperty dashGapProperty;
904     dashGapProperty.SetBorderWidth(Dimension(1));
905     frameNode->renderContext_->UpdateDashGap(dashGapProperty);
906     BorderWidthProperty dashWidthProperty;
907     dashWidthProperty.SetBorderWidth(Dimension(1));
908     frameNode->renderContext_->UpdateDashWidth(dashWidthProperty);
909 
910     /**
911      * @tc.steps: step4. call the function DumpCommonInfo.
912      */
913     frameNode->SetBackgroundFunction(builderFunc);
914     frameNode->SetLayoutProperty(layoutProperty);
915     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
916     EXPECT_NE(frameNode->pattern_, nullptr);
917     EXPECT_NE(frameNode->layoutProperty_, nullptr);
918 }
919 
920 /**
921  * @tc.name: FrameNodeAdjustGridOffset01
922  * @tc.desc: Test the function AdjustGridOffset
923  * @tc.type: FUNC
924  */
925 HWTEST_F(FrameNodeTestNg, FrameNodeAdjustGridOffset01, TestSize.Level1)
926 {
927     /**
928      * @tc.steps: step1. create frameNode.
929      */
930     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
931     frameNode->isActive_ = true;
932 
933     /**
934      * @tc.steps: step2. create layoutProperty.
935      */
936     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
937     layoutProperty->gridProperty_ = std::make_unique<GridProperty>();
938     layoutProperty->UpdateGridProperty(1, 0, GridSizeType::UNDEFINED);
939 
940     layoutProperty->gridProperty_ = std::make_unique<GridProperty>();
941     frameNode->SetParent(FRAME_NODE);
942     frameNode->NotifyVisibleChange(VisibleType::INVISIBLE, VisibleType::VISIBLE);
943     RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>();
944     geometryNode->SetFrameOffset(OffsetF(1.0f, 0.0f));
945     frameNode->geometryNode_ = geometryNode;
946     layoutProperty->BuildGridProperty(frameNode);
947 
948     /**
949      * @tc.steps: step4. call the function DumpCommonInfo.
950      */
951     frameNode->SetLayoutProperty(layoutProperty);
952     frameNode->AdjustGridOffset();
953     EXPECT_NE(frameNode->pattern_, nullptr);
954     EXPECT_NE(frameNode->layoutProperty_, nullptr);
955 }
956 
957 /**
958  * @tc.name: FrameNodeClearUserOnAreaChange01
959  * @tc.desc: Test the function ClearUserOnAreaChange
960  * @tc.type: FUNC
961  */
962 HWTEST_F(FrameNodeTestNg, FrameNodeClearUserOnAreaChange01, TestSize.Level1)
963 {
964     /**
965      * @tc.steps: step1. create frameNode.
966      */
967     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
968     EXPECT_NE(frameNode->pattern_, nullptr);
969 
970     /**
971      * @tc.steps: step2. call the function ClearUserOnAreaChange.
972      */
973     auto eventHub = frameNode->eventHub_;
974     frameNode->eventHub_ = nullptr;
975     frameNode->ClearUserOnAreaChange();
976     frameNode->eventHub_ = eventHub;
977 }
978 
979 /**
980  * @tc.name: FrameNodeTriggerOnAreaChangeCallback01
981  * @tc.desc: Test the function TriggerOnAreaChangeCallback
982  * @tc.type: FUNC
983  */
984 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback01, TestSize.Level1)
985 {
986     /**
987      * @tc.steps: step1. create frameNode.
988      */
989     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
990     EXPECT_NE(frameNode->pattern_, nullptr);
991     frameNode->isActive_ = true;
992     bool flag = false;
993     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon61db40680602(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 994                                           const OffsetF& origin) { flag = !flag; };
995     frameNode->GetOrCreateEventHub<EventHub>()->SetOnAreaChanged(std::move(onAreaChanged));
996     frameNode->GetOrCreateEventHub<EventHub>()->AddInnerOnAreaChangedCallback(1, std::move(onAreaChanged));
997     frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset
998     frameNode->lastFrameRect_ =
999         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1000 
1001     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1002     posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1003     /**
1004      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1005      */
1006     frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1);
1007 }
1008 
1009 /**
1010  * @tc.name: FrameNodeTriggerOnAreaChangeCallback02
1011  * @tc.desc: Test the function TriggerOnAreaChangeCallback
1012  * @tc.type: FUNC
1013  */
1014 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback02, TestSize.Level1)
1015 {
1016     /**
1017      * @tc.steps: step1. create frameNode.
1018      */
1019     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1020     EXPECT_NE(frameNode->pattern_, nullptr);
1021     frameNode->isActive_ = true;
1022     bool flag = false;
1023     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon61db40680702(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 1024                                           const OffsetF& origin) { flag = !flag; };
1025     frameNode->GetOrCreateEventHub<EventHub>()->SetOnAreaChanged(std::move(onAreaChanged));
1026     frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset
1027     frameNode->lastFrameRect_ =
1028         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1029 
1030     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1031     posProperty->UpdateOffset(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1032     /**
1033      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1034      */
1035     frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1);
1036 }
1037 
1038 /**
1039  * @tc.name: FrameNodeTriggerOnAreaChangeCallback03
1040  * @tc.desc: Test the function TriggerOnAreaChangeCallback
1041  * @tc.type: FUNC
1042  */
1043 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback03, TestSize.Level1)
1044 {
1045     /**
1046      * @tc.steps: step1. create frameNode.
1047      */
1048     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1049     EXPECT_NE(frameNode->pattern_, nullptr);
1050     frameNode->isActive_ = true;
1051     bool flag = false;
1052     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon61db40680802(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 1053                                           const OffsetF& origin) { flag = !flag; };
1054     frameNode->GetOrCreateEventHub<EventHub>()->AddInnerOnAreaChangedCallback(1, std::move(onAreaChanged));
1055     frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset
1056     frameNode->lastFrameRect_ =
1057         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1058 
1059     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1060     posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1061     /**
1062      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1063      */
1064     frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1);
1065 }
1066 
1067 /**
1068  * @tc.name: FrameNodeAddInnerOnSizeChangeCallback01
1069  * @tc.desc: Test the function AddInnerOnSizeChangeCallback
1070  * @tc.type: FUNC
1071  */
1072 HWTEST_F(FrameNodeTestNg, FrameNodeAddInnerOnSizeChangeCallback01, TestSize.Level1)
1073 {
1074     /**
1075      * @tc.steps: step1. create frameNode.
1076      */
1077     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1078     EXPECT_NE(frameNode->pattern_, nullptr);
__anon61db40680902(const RectF& oldRect, const RectF& rect) 1079     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1080     frameNode->lastFrameNodeRect_ = std::make_unique<RectF>(RectF(OffsetF(1.0f, 1.0f), SizeF(1.0f, 1.0f)));
1081     /**
1082      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1083      */
1084     frameNode->AddInnerOnSizeChangeCallback(1, std::move(callback));
1085 }
1086 
1087 /**
1088  * @tc.name: FrameNodeAddInnerOnSizeChangeCallback02
1089  * @tc.desc: Test the function AddInnerOnSizeChangeCallback
1090  * @tc.type: FUNC
1091  */
1092 HWTEST_F(FrameNodeTestNg, FrameNodeAddInnerOnSizeChangeCallback02, TestSize.Level1)
1093 {
1094     /**
1095      * @tc.steps: step1. create frameNode.
1096      */
1097     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1098     EXPECT_NE(frameNode->pattern_, nullptr);
__anon61db40680a02(const RectF& oldRect, const RectF& rect) 1099     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1100     /**
1101      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1102      */
1103     frameNode->AddInnerOnSizeChangeCallback(1, std::move(callback));
1104 }
1105 
1106 /**
1107  * @tc.name: FrameNodeSetJSFrameNodeOnSizeChangeCallback01
1108  * @tc.desc: Test the function SetJSFrameNodeOnSizeChangeCallback
1109  * @tc.type: FUNC
1110  */
1111 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSFrameNodeOnSizeChangeCallback01, TestSize.Level1)
1112 {
1113     /**
1114      * @tc.steps: step1. create frameNode.
1115      */
1116     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1117     EXPECT_NE(frameNode->pattern_, nullptr);
__anon61db40680b02(const RectF& oldRect, const RectF& rect) 1118     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1119     frameNode->lastFrameNodeRect_ = std::make_unique<RectF>(RectF(OffsetF(1.0f, 1.0f), SizeF(1.0f, 1.0f)));
1120     /**
1121      * @tc.steps: step3. call the function SetJSFrameNodeOnSizeChangeCallback.
1122      */
1123     frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(callback));
1124 }
1125 
1126 /**
1127  * @tc.name: FrameNodeSetJSFrameNodeOnSizeChangeCallback02
1128  * @tc.desc: Test the function SetJSFrameNodeOnSizeChangeCallback
1129  * @tc.type: FUNC
1130  */
1131 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSFrameNodeOnSizeChangeCallback02, TestSize.Level1)
1132 {
1133     /**
1134      * @tc.steps: step1. create frameNode.
1135      */
1136     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1137     EXPECT_NE(frameNode->pattern_, nullptr);
__anon61db40680c02(const RectF& oldRect, const RectF& rect) 1138     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1139     /**
1140      * @tc.steps: step3. call the function SetJSFrameNodeOnSizeChangeCallback.
1141      */
1142     frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(callback));
1143 }
1144 
1145 /**
1146  * @tc.name: FrameNodeGetRectWithRender01
1147  * @tc.desc: Test the function GetRectWithRender
1148  * @tc.type: FUNC
1149  */
1150 HWTEST_F(FrameNodeTestNg, FrameNodeGetRectWithRender01, TestSize.Level1)
1151 {
1152     /**
1153      * @tc.steps: step1. create frameNode.
1154      */
1155     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1156     EXPECT_NE(frameNode->pattern_, nullptr);
1157     frameNode->isActive_ = true;
1158 
1159     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1160     posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1161     /**
1162      * @tc.steps: step3. call the function GetRectWithRender.
1163      */
1164     frameNode->GetRectWithRender();
1165 }
1166 
1167 /**
1168  * @tc.name: FrameNodeGetRectWithRender02
1169  * @tc.desc: Test the function GetRectWithRender
1170  * @tc.type: FUNC
1171  */
1172 HWTEST_F(FrameNodeTestNg, FrameNodeGetRectWithRender02, TestSize.Level1)
1173 {
1174     /**
1175      * @tc.steps: step1. create frameNode.
1176      */
1177     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1178     EXPECT_NE(frameNode->pattern_, nullptr);
1179     frameNode->isActive_ = true;
1180 
1181     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1182     posProperty->UpdateOffset(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1183     /**
1184      * @tc.steps: step3. call the function GetRectWithRender.
1185      */
1186     frameNode->GetRectWithRender();
1187 }
1188 
1189 /**
1190  * @tc.name: FrameNodeTriggerOnSizeChangeCallback01
1191  * @tc.desc: Test the function TriggerOnSizeChangeCallback
1192  * @tc.type: FUNC
1193  */
1194 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback01, TestSize.Level1)
1195 {
1196     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1197     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1198     FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect,
1199         testCurrFrameRect }; // 1 is the onSizeChangeTimeStamp
1200     FrameNode::onSizeChangeDumpInfo dumpInfoTwo { 2, testLastFrameRect,
1201         testCurrFrameRect }; // 2 is the onSizeChangeTimeStamp
1202     FrameNode::onSizeChangeDumpInfo dumpInfoThree { 3, testLastFrameRect,
1203         testCurrFrameRect }; // 3 is the onSizeChangeTimeStamp
1204     FrameNode::onSizeChangeDumpInfo dumpInfoFour { 4, testLastFrameRect,
1205         testCurrFrameRect }; // 4 is the onSizeChangeTimeStamp
1206     FrameNode::onSizeChangeDumpInfo dumpInfoFive { 5, testLastFrameRect,
1207         testCurrFrameRect }; // 5 is the onSizeChangeTimeStamp
1208     /**
1209      * @tc.steps: step1. create frameNode.
1210      */
1211     auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true);
1212     EXPECT_NE(frameNode->pattern_, nullptr);
1213     frameNode->isActive_ = true;
1214     auto pattern = frameNode->GetPattern<PagePattern>();
1215     pattern->isOnShow_ = true;
1216     bool flag = false;
__anon61db40680d02(const RectF& oldRect, const RectF& rect) 1217     OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; };
1218     frameNode->GetOrCreateEventHub<EventHub>()->SetOnSizeChanged(std::move(onSizeChanged));
1219     frameNode->GetOrCreateEventHub<EventHub>()->AddInnerOnSizeChanged(1, std::move(onSizeChanged));
1220     frameNode->lastFrameNodeRect_ =
1221         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1222     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne);
1223     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoTwo);
1224     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoThree);
1225     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoFour);
1226     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoFive);
1227     /**
1228      * @tc.steps: step3. call the function TriggerOnSizeChangeCallback.
1229      */
1230     frameNode->TriggerOnSizeChangeCallback();
1231 }
1232 
1233 /**
1234  * @tc.name: FrameNodeTriggerOnSizeChangeCallback02
1235  * @tc.desc: Test the function TriggerOnSizeChangeCallback
1236  * @tc.type: FUNC
1237  */
1238 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback02, TestSize.Level1)
1239 {
1240     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1241     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1242     FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect, testCurrFrameRect };
1243     /**
1244      * @tc.steps: step1. create frameNode.
1245      */
1246     auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true);
1247     EXPECT_NE(frameNode->pattern_, nullptr);
1248     frameNode->isActive_ = true;
1249     auto pattern = frameNode->GetPattern<PagePattern>();
1250     pattern->isOnShow_ = true;
1251     bool flag = false;
__anon61db40680e02(const RectF& oldRect, const RectF& rect) 1252     OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; };
1253     frameNode->GetOrCreateEventHub<EventHub>()->SetOnSizeChanged(std::move(onSizeChanged));
1254     frameNode->lastFrameNodeRect_ =
1255         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1256     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne);
1257     /**
1258      * @tc.steps: step3. call the function TriggerOnSizeChangeCallback.
1259      */
1260     frameNode->TriggerOnSizeChangeCallback();
1261 }
1262 
1263 /**
1264  * @tc.name: FrameNodeTriggerOnSizeChangeCallback03
1265  * @tc.desc: Test the function TriggerOnSizeChangeCallback
1266  * @tc.type: FUNC
1267  */
1268 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback03, TestSize.Level1)
1269 {
1270     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1271     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1272     FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect, testCurrFrameRect };
1273     /**
1274      * @tc.steps: step1. create frameNode.
1275      */
1276     auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true);
1277     EXPECT_NE(frameNode->pattern_, nullptr);
1278     frameNode->isActive_ = true;
1279     auto pattern = frameNode->GetPattern<PagePattern>();
1280     pattern->isOnShow_ = true;
1281     bool flag = false;
__anon61db40680f02(const RectF& oldRect, const RectF& rect) 1282     OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; };
1283     frameNode->GetOrCreateEventHub<EventHub>()->AddInnerOnSizeChanged(1, std::move(onSizeChanged));
1284     frameNode->lastFrameNodeRect_ =
1285         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1286     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne);
1287     /**
1288      * @tc.steps: step3. call the function TriggerOnSizeChangeCallback.
1289      */
1290     frameNode->TriggerOnSizeChangeCallback();
1291 }
1292 
1293 /**
1294  * @tc.name: FrameNodIsFrameDisappear01
1295  * @tc.desc: Test the function IsFrameDisappear.
1296  * @tc.type: FUNC
1297  */
1298 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear01, TestSize.Level1)
1299 {
1300     /**
1301      * @tc.steps: step1. create frameNode.
1302      */
1303     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1304     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1305     parentNode->isActive_ = false;
1306     frameNode->onMainTree_ = true;
1307     auto context = frameNode->GetContext();
1308     context->onShow_ = true;
1309     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1310 
1311     /**
1312      * @tc.steps: step2. create layoutProperty.
1313      */
1314     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1315     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1316     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1317     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1318 
1319     /**
1320      * @tc.steps: step3. call the function IsFrameDisappear.
1321      */
1322     parentNode->SetLayoutProperty(parentLayoutProperty);
1323     frameNode->SetLayoutProperty(layoutProperty);
1324     frameNode->IsFrameDisappear();
1325     EXPECT_FALSE(parentNode->isActive_);
1326     EXPECT_TRUE(frameNode->onMainTree_);
1327     EXPECT_NE(frameNode->pattern_, nullptr);
1328     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1329 }
1330 
1331 /**
1332  * @tc.name: FrameNodIsFrameDisappear02
1333  * @tc.desc: Test the function IsFrameDisappear
1334  * @tc.type: FUNC
1335  */
1336 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear02, TestSize.Level1)
1337 {
1338     /**
1339      * @tc.steps: step1. create frameNode.
1340      */
1341     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1342     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1343     parentNode->isActive_ = true;
1344     frameNode->onMainTree_ = true;
1345     auto context = frameNode->GetContext();
1346     context->onShow_ = true;
1347     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1348 
1349     /**
1350      * @tc.steps: step2. create layoutProperty.
1351      */
1352     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1353     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1354     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1355     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1356 
1357     /**
1358      * @tc.steps: step3. call the function IsFrameDisappear.
1359      */
1360     parentNode->SetLayoutProperty(parentLayoutProperty);
1361     frameNode->SetLayoutProperty(layoutProperty);
1362     frameNode->IsFrameDisappear();
1363     EXPECT_TRUE(parentNode->isActive_);
1364     EXPECT_TRUE(frameNode->onMainTree_);
1365     EXPECT_NE(frameNode->pattern_, nullptr);
1366     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1367 }
1368 
1369 /**
1370  * @tc.name: FrameNodIsFrameDisappear03
1371  * @tc.desc: Test the function IsFrameDisappear
1372  * @tc.type: FUNC
1373  */
1374 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear03, TestSize.Level1)
1375 {
1376     /**
1377      * @tc.steps: step1. create frameNode.
1378      */
1379     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1380     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1381     parentNode->isActive_ = true;
1382     frameNode->isActive_ = false;
1383     frameNode->onMainTree_ = true;
1384     auto context = frameNode->GetContext();
1385     context->onShow_ = true;
1386     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1387 
1388     /**
1389      * @tc.steps: step2. create layoutProperty.
1390      */
1391     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1392     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1393     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1394     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1395 
1396     /**
1397      * @tc.steps: step3. call the function IsFrameDisappear.
1398      */
1399     parentNode->SetLayoutProperty(parentLayoutProperty);
1400     frameNode->SetLayoutProperty(layoutProperty);
1401     frameNode->IsFrameDisappear(TIMESTAMP_1);
1402     EXPECT_TRUE(parentNode->isActive_);
1403     EXPECT_TRUE(frameNode->onMainTree_);
1404     EXPECT_NE(frameNode->pattern_, nullptr);
1405     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1406 }
1407 
1408 /**
1409  * @tc.name: FrameNodIsFrameDisappear04
1410  * @tc.desc: Test the function IsFrameDisappear
1411  * @tc.type: FUNC
1412  */
1413 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear04, TestSize.Level1)
1414 {
1415     /**
1416      * @tc.steps: step1. create frameNode.
1417      */
1418     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1419     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1420     auto frameNode2 = FrameNode::CreateFrameNode("frameNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
1421     parentNode->SetDepth(1);
1422     frameNode->SetDepth(2);
1423     frameNode2->SetDepth(3);
1424     parentNode->isActive_ = true;
1425     frameNode->isActive_ = true;
1426     frameNode2->onMainTree_ = true;
1427     frameNode2->isActive_ = true;
1428     auto context = frameNode2->GetContext();
1429     context->onShow_ = true;
1430     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1431     frameNode2->SetParent(AceType::WeakClaim(AceType::RawPtr(frameNode)));
1432 
1433     /**
1434      * @tc.steps: step2. create layoutProperty.
1435      */
1436     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1437     parentLayoutProperty->propVisibility_ = VisibleType::VISIBLE;
1438     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1439     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1440     auto layoutProperty2 = AceType::MakeRefPtr<LayoutProperty>();
1441     layoutProperty2->propVisibility_ = VisibleType::VISIBLE;
1442 
1443     /**
1444      * @tc.steps: step3. call the function IsFrameDisappear and create TIMESTAMP_1 cache.
1445      * @tc.expected: expect res is false
1446      */
1447     parentNode->SetLayoutProperty(parentLayoutProperty);
1448     frameNode->SetLayoutProperty(layoutProperty);
1449     frameNode2->SetLayoutProperty(layoutProperty2);
1450     EXPECT_FALSE(frameNode2->IsFrameDisappear(TIMESTAMP_1));
1451 
1452     /**
1453      * @tc.steps: step4. call the function IsFrameDisappear and use TIMESTAMP_1 cache.
1454      * @tc.expected: expect res is false
1455      */
1456     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1457     EXPECT_FALSE(frameNode2->IsFrameDisappear(TIMESTAMP_2, 0));
1458 
1459     /**
1460      * @tc.steps: step5. call the function IsFrameDisappear and no use TIMESTAMP_1 cache.
1461      * @tc.expected: expect res is true
1462      */
1463     EXPECT_TRUE(frameNode2->IsFrameDisappear(TIMESTAMP_3));
1464 }
1465 
1466 /**
1467  * @tc.name: FrameNodIsFrameDisappear05
1468  * @tc.desc: Test the function IsFrameDisappear
1469  * @tc.type: FUNC
1470  */
1471 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear05, TestSize.Level1)
1472 {
1473     /**
1474      * @tc.steps: step1. create frameNode.
1475      */
1476     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1477     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1478     auto frameNode2 = FrameNode::CreateFrameNode("frameNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
1479     parentNode->SetDepth(1);
1480     frameNode->SetDepth(2);
1481     frameNode2->SetDepth(3);
1482     parentNode->isActive_ = true;
1483     frameNode->isActive_ = true;
1484     frameNode2->onMainTree_ = true;
1485     frameNode2->isActive_ = true;
1486     auto context = frameNode2->GetContext();
1487     context->onShow_ = true;
1488     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1489     frameNode2->SetParent(AceType::WeakClaim(AceType::RawPtr(frameNode)));
1490 
1491     /**
1492      * @tc.steps: step2. create layoutProperty.
1493      */
1494     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1495     parentLayoutProperty->propVisibility_ = VisibleType::VISIBLE;
1496     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1497     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1498     auto layoutProperty2 = AceType::MakeRefPtr<LayoutProperty>();
1499     layoutProperty2->propVisibility_ = VisibleType::VISIBLE;
1500 
1501     /**
1502      * @tc.steps: step3. call the function IsFrameDisappear and create TIMESTAMP_1 cache.
1503      * @tc.expected: expect res is false
1504      */
1505     parentNode->SetLayoutProperty(parentLayoutProperty);
1506     frameNode->SetLayoutProperty(layoutProperty);
1507     frameNode2->SetLayoutProperty(layoutProperty2);
1508     EXPECT_FALSE(frameNode2->IsFrameDisappear(TIMESTAMP_1));
1509 
1510     /**
1511      * @tc.steps: step4. call the function IsFrameDisappear and use TIMESTAMP_1 cache.
1512      * @tc.expected: expect res is false
1513      */
1514     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1515     EXPECT_FALSE(frameNode2->IsFrameDisappear(TIMESTAMP_2, 3));
1516 
1517     /**
1518      * @tc.steps: step5. call the function IsFrameDisappear and no use TIMESTAMP_1 cache.
1519      * @tc.expected: expect res is true
1520      */
1521     EXPECT_TRUE(frameNode2->IsFrameDisappear(TIMESTAMP_3, 1));
1522 }
1523 
1524 /**
1525  * @tc.name: FrameNodIsFrameDisappear06
1526  * @tc.desc: Test the function IsFrameDisappear OnShow branch
1527  * @tc.type: FUNC
1528  */
1529 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear06, TestSize.Level1)
1530 {
1531     /**
1532      * @tc.steps: step1. create frameNode.
1533      */
1534     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1535     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1536     auto frameNode2 = FrameNode::CreateFrameNode("frameNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
1537     parentNode->SetDepth(1);
1538     frameNode->SetDepth(2);
1539     frameNode2->SetDepth(3);
1540     parentNode->isActive_ = true;
1541     frameNode->isActive_ = true;
1542     frameNode2->onMainTree_ = true;
1543     frameNode2->isActive_ = true;
1544     auto context = frameNode2->GetContext();
1545     context->onShow_ = true;
1546     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1547     frameNode2->SetParent(AceType::WeakClaim(AceType::RawPtr(frameNode)));
1548 
1549     /**
1550      * @tc.steps: step2. create layoutProperty.
1551      */
1552     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1553     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1554     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1555     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1556     auto layoutProperty2 = AceType::MakeRefPtr<LayoutProperty>();
1557     layoutProperty2->propVisibility_ = VisibleType::VISIBLE;
1558 
1559     /**
1560      * @tc.steps: step3. call the function IsFrameDisappear and create TIMESTAMP_1 cache.
1561      * @tc.expected: expect res is true
1562      */
1563     parentNode->SetLayoutProperty(parentLayoutProperty);
1564     frameNode->SetLayoutProperty(layoutProperty);
1565     frameNode2->SetLayoutProperty(layoutProperty2);
1566     EXPECT_TRUE(frameNode2->IsFrameDisappear(TIMESTAMP_1));
1567 
1568     /**
1569      * @tc.steps: step4. set onshow false and call the function IsFrameDisappear.
1570      * @tc.expected: expect res is true
1571      */
1572     parentLayoutProperty->propVisibility_ = VisibleType::VISIBLE;
1573     context->onShow_ = false;
1574     EXPECT_TRUE(frameNode2->IsFrameDisappear(TIMESTAMP_2, 1));
1575 
1576     /**
1577      * @tc.steps: step5. call the function IsFrameDisappear and no use TIMESTAMP_1 cache.
1578      * @tc.expected: expect res is true
1579      */
1580     context->onShow_ = true;
1581     EXPECT_FALSE(frameNode2->IsFrameDisappear(TIMESTAMP_3, 0));
1582 }
1583 
1584 /**
1585  * @tc.name: FrameNodIsFrameDisappear07
1586  * @tc.desc: Test the function IsFrameDisappear result true branch
1587  * @tc.type: FUNC
1588  */
1589 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear07, TestSize.Level1)
1590 {
1591     /**
1592      * @tc.steps: step1. create frameNode.
1593      */
1594     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1595     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1596     auto frameNode2 = FrameNode::CreateFrameNode("frameNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
1597     parentNode->SetDepth(1);
1598     frameNode->SetDepth(2);
1599     frameNode2->SetDepth(3);
1600     parentNode->isActive_ = true;
1601     frameNode->isActive_ = true;
1602     frameNode2->onMainTree_ = true;
1603     frameNode2->isActive_ = true;
1604     auto context = frameNode2->GetContext();
1605     context->onShow_ = true;
1606     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1607     frameNode2->SetParent(AceType::WeakClaim(AceType::RawPtr(frameNode)));
1608 
1609     /**
1610      * @tc.steps: step2. create layoutProperty.
1611      */
1612     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1613     parentLayoutProperty->propVisibility_ = VisibleType::VISIBLE;
1614     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1615     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1616     auto layoutProperty2 = AceType::MakeRefPtr<LayoutProperty>();
1617     layoutProperty2->propVisibility_ = VisibleType::VISIBLE;
1618 
1619     /**
1620      * @tc.steps: step3. call the function IsFrameDisappear and create TIMESTAMP_1 cache.
1621      * @tc.expected: expect res is false
1622      */
1623     parentNode->SetLayoutProperty(parentLayoutProperty);
1624     frameNode->SetLayoutProperty(layoutProperty);
1625     frameNode2->SetLayoutProperty(layoutProperty2);
1626     EXPECT_FALSE(frameNode2->IsFrameDisappear(TIMESTAMP_1));
1627 
1628     /**
1629      * @tc.steps: step4. set frameNode2 INVISIBLE and call the function IsFrameDisappear.
1630      * @tc.expected: expect res is false
1631      */
1632     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1633     layoutProperty2->propVisibility_ = VisibleType::INVISIBLE;
1634     EXPECT_TRUE(frameNode2->IsFrameDisappear(TIMESTAMP_2, 1));
1635 
1636     /**
1637      * @tc.steps: step5. call the function IsFrameDisappear and no use TIMESTAMP_1 cache.
1638      * @tc.expected: expect res is true
1639      */
1640     layoutProperty2->propVisibility_ = VisibleType::VISIBLE;
1641     EXPECT_TRUE(frameNode2->IsFrameDisappear(TIMESTAMP_3, 3));
1642 }
1643 
1644 /**
1645  * @tc.name: FrameNodeCalculateOffsetRelativeToWindow01
1646  * @tc.desc: Test the function CalculateOffsetRelativeToWindow
1647  * @tc.type: FUNC
1648  */
1649 HWTEST_F(FrameNodeTestNg, FrameNodeCalculateOffsetRelativeToWindow01, TestSize.Level1)
1650 {
1651     /**
1652      * @tc.steps: step1. create frameNode.
1653      */
1654     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1655     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1656     auto frameNode2 = FrameNode::CreateFrameNode("frameNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
1657     parentNode->SetDepth(1);
1658     frameNode->SetDepth(2);
1659     frameNode2->SetDepth(3);
1660     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1661     frameNode2->SetParent(AceType::WeakClaim(AceType::RawPtr(frameNode)));
1662 
1663     /**
1664      * @tc.steps: step2. set Offset.
1665      */
1666     parentNode->GetGeometryNode()->SetFrameOffset(OffsetF(1.1, 2.3));
1667     frameNode->GetGeometryNode()->SetSelfAdjust(RectF(1.0, 1.0, 0.0, 0.0));
1668     frameNode->GetGeometryNode()->SetFrameOffset(OffsetF(3.2, 4.1));
1669     frameNode2->GetGeometryNode()->SetFrameOffset(OffsetF(5.3, 6.3));
1670 
1671     /**
1672      * @tc.steps: step3. call the function CalculateOffsetRelativeToWindow and create TIMESTAMP_1 cache.
1673      * @tc.expected: expect res is frameNode offset + parentNode offset
1674      */
1675     EXPECT_EQ(frameNode->CalculateOffsetRelativeToWindow(TIMESTAMP_1), OffsetF(5.3, 7.4));
1676 
1677     /**
1678      * @tc.steps: step4. call the function CalculateOffsetRelativeToWindow and create TIMESTAMP_1 cache.
1679      * @tc.expected: expect res is frameNode2 offset + framenode cache offset
1680      */
1681 
1682     parentNode->GetGeometryNode()->SetFrameOffset(OffsetF(2.1, 3.3));
1683     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_1), OffsetF(10.6, 13.7));
1684 
1685 
1686     /**
1687      * @tc.steps: step5. call the function CalculateOffsetRelativeToWindow TIMESTAMP_2.
1688      * @tc.expected: expect res is frameNode2 offset + framenode offset + parentNode offset
1689      */
1690     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_2), OffsetF(11.6, 14.7));
1691 }
1692 
1693 /**
1694  * @tc.name: FrameNodeCalculateOffsetRelativeToWindow02
1695  * @tc.desc: Test the function CalculateOffsetRelativeToWindow
1696  * @tc.type: FUNC
1697  */
1698 HWTEST_F(FrameNodeTestNg, FrameNodeCalculateOffsetRelativeToWindow02, TestSize.Level1)
1699 {
1700     /**
1701      * @tc.steps: step1. create frameNode.
1702      */
1703     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1704     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1705     auto frameNode2 = FrameNode::CreateFrameNode("frameNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
1706     parentNode->SetDepth(1);
1707     frameNode->SetDepth(2);
1708     frameNode2->SetDepth(3);
1709     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1710     frameNode2->SetParent(AceType::WeakClaim(AceType::RawPtr(frameNode)));
1711 
1712     /**
1713      * @tc.steps: step2. set Offset.
1714      */
1715     parentNode->GetGeometryNode()->SetFrameOffset(OffsetF(1.1, 2.3));
1716     frameNode->GetGeometryNode()->SetFrameOffset(OffsetF(3.2, 4.1));
1717     frameNode2->GetGeometryNode()->SetFrameOffset(OffsetF(5.3, 6.3));
1718 
1719     /**
1720      * @tc.steps: step3. call the function CalculateOffsetRelativeToWindow and create TIMESTAMP_1 cache.
1721      * @tc.expected: expect res is frameNode2 offset + frameNode offset + parentNode offset
1722      */
1723     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_1), OffsetF(9.6, 12.7));
1724 
1725     /**
1726      * @tc.steps: step4. call the function CalculateOffsetRelativeToWindow and use TIMESTAMP_1 cache.
1727      * @tc.expected: expect res is frameNode2 offset + framenode cache offset
1728      */
1729 
1730     parentNode->GetGeometryNode()->SetFrameOffset(OffsetF(2.1, 3.3));
1731     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_2, false, 0), OffsetF(9.6, 12.7));
1732 
1733 
1734     /**
1735      * @tc.steps: step5. call the function CalculateOffsetRelativeToWindow TIMESTAMP_2.
1736      * @tc.expected: expect res is frameNode2 offset + framenode offset + parentNode offset
1737      */
1738     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_3), OffsetF(10.6, 13.7));
1739 }
1740 
1741 /**
1742  * @tc.name: FrameNodeCalculateOffsetRelativeToWindow03
1743  * @tc.desc: Test the function CalculateOffsetRelativeToWindow
1744  * @tc.type: FUNC
1745  */
1746 HWTEST_F(FrameNodeTestNg, FrameNodeCalculateOffsetRelativeToWindow03, TestSize.Level1)
1747 {
1748     /**
1749      * @tc.steps: step1. create frameNode.
1750      */
1751     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1752     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1753     auto frameNode2 = FrameNode::CreateFrameNode("frameNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
1754     parentNode->SetDepth(1);
1755     frameNode->SetDepth(2);
1756     frameNode2->SetDepth(3);
1757     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1758     frameNode2->SetParent(AceType::WeakClaim(AceType::RawPtr(frameNode)));
1759 
1760     /**
1761      * @tc.steps: step2. set Offset.
1762      */
1763     parentNode->GetGeometryNode()->SetFrameOffset(OffsetF(1.1, 2.3));
1764     frameNode->GetGeometryNode()->SetFrameOffset(OffsetF(3.2, 4.1));
1765     frameNode2->GetGeometryNode()->SetFrameOffset(OffsetF(5.3, 6.3));
1766 
1767     /**
1768      * @tc.steps: step3. call the function CalculateOffsetRelativeToWindow and create TIMESTAMP_1 cache.
1769      * @tc.expected: expect res is frameNode offset + frameNode2 + parentNode offset
1770      */
1771     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_1), OffsetF(9.6, 12.7));
1772 
1773     /**
1774      * @tc.steps: step4. call the function CalculateOffsetRelativeToWindow and use TIMESTAMP_1 cache.
1775      * @tc.expected: expect res is frameNode2 offset + framenode cache offset
1776      */
1777 
1778     parentNode->GetGeometryNode()->SetFrameOffset(OffsetF(2.1, 3.3));
1779     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_2, false, 2), OffsetF(9.6, 12.7));
1780 
1781 
1782     /**
1783      * @tc.steps: step5. call the function CalculateOffsetRelativeToWindow TIMESTAMP_3.
1784      * @tc.expected: expect res is frameNode2 offset + framenode offset + parentNode offset
1785      */
1786     EXPECT_EQ(frameNode2->CalculateOffsetRelativeToWindow(TIMESTAMP_3), OffsetF(10.6, 13.7));
1787 }
1788 
1789 /**
1790  * @tc.name: FrameNodeTriggerVisibleAreaChangeCallback01
1791  * @tc.desc: Test the function TriggerVisibleAreaChangeCallback
1792  * @tc.type: FUNC
1793  */
1794 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback01, TestSize.Level1)
1795 {
1796     /**
1797      * @tc.steps: step1. create frameNode.
1798      */
1799     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1800     frameNode->onMainTree_ = true;
1801     frameNode->isActive_ = true;
1802     frameNode->isWindowBoundary_ = false;
1803     auto context = frameNode->GetContext();
1804     context->onShow_ = true;
1805     VisibleCallbackInfo callbackInfo;
1806     int32_t flag = 0;
__anon61db40681002(bool isVisible, double radio) 1807     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1808     callbackInfo.callback = jsCallback;
1809     callbackInfo.period = 1;
1810     frameNode->GetOrCreateEventHub<EventHub>()->visibleAreaUserCallback_ = callbackInfo;
1811     frameNode->TriggerVisibleAreaChangeCallback(0, false);
1812     frameNode->GetOrCreateEventHub<EventHub>()->visibleAreaUserCallback_.callback = nullptr;
1813     frameNode->GetOrCreateEventHub<EventHub>()->visibleAreaInnerCallback_ = callbackInfo;
1814     frameNode->TriggerVisibleAreaChangeCallback(0, false);
1815     EXPECT_NE(frameNode->GetOrCreateEventHub<EventHub>(), nullptr);
1816     frameNode->isCalculateInnerVisibleRectClip_ = true;
1817     frameNode->lastInnerVisibleRatio_ = 10.0;
1818     frameNode->lastVisibleRatio_ = 10.0;
1819     frameNode->TriggerVisibleAreaChangeCallback(0, true);
1820     frameNode->GetOrCreateEventHub<EventHub>()->visibleAreaUserCallback_ = callbackInfo;
1821     /**
1822      * @tc.steps: step2. create layoutProperty.
1823      */
1824     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1825     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1826 
1827     /**
1828      * @tc.steps: step3. call the function TriggerVisibleAreaChangeCallback.
1829      */
1830     std::vector<double> ratios = { 0, 1.0 };
1831     frameNode->SetLayoutProperty(layoutProperty);
1832     frameNode->TriggerVisibleAreaChangeCallback(false);
1833     frameNode->ProcessAllVisibleCallback(ratios, callbackInfo, 1.0, 0.0, true);
1834     EXPECT_NE(frameNode->GetOrCreateEventHub<EventHub>(), nullptr);
1835 }
1836 
1837 /**
1838  * @tc.name: FrameNodeThrottledVisibleTask01
1839  * @tc.desc: Test the function ThrottledVisibleTask
1840  * @tc.type: FUNC
1841  */
1842 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask01, TestSize.Level1)
1843 {
1844     /**
1845      * @tc.steps: step1. create frameNode.
1846      */
1847     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1848     frameNode->throttledCallbackOnTheWay_ = true;
1849     frameNode->lastThrottledVisibleRatio_ = 0.0;
1850     frameNode->isActive_ = true;
1851     auto context = frameNode->GetContext();
1852     context->onShow_ = false;
1853     VisibleCallbackInfo callbackInfo;
1854     int32_t flag = 0;
__anon61db40681102(bool isVisible, double radio) 1855     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1856     callbackInfo.callback = jsCallback;
1857     callbackInfo.period = 1;
1858     frameNode->GetOrCreateEventHub<EventHub>()->throttledVisibleAreaCallback_ = callbackInfo;
1859 
1860     /**
1861      * @tc.steps: step2. create layoutProperty.
1862      */
1863     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1864     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1865 
1866     /**
1867      * @tc.steps: step3. call the function ThrottledVisibleTask.
1868      */
1869     frameNode->SetLayoutProperty(layoutProperty);
1870     frameNode->ThrottledVisibleTask();
1871     EXPECT_NE(frameNode, nullptr);
1872     EXPECT_FALSE(frameNode->throttledCallbackOnTheWay_);
1873 }
1874 
1875 /**
1876  * @tc.name: FrameNodeThrottledVisibleTask02
1877  * @tc.desc: Test the function ThrottledVisibleTask
1878  * @tc.type: FUNC
1879  */
1880 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask02, TestSize.Level1)
1881 {
1882     /**
1883      * @tc.steps: step1. create frameNode.
1884      */
1885     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1886     frameNode->throttledCallbackOnTheWay_ = true;
1887     frameNode->lastThrottledVisibleRatio_ = 1.0;
1888     frameNode->isActive_ = true;
1889     auto context = frameNode->GetContext();
1890     context->onShow_ = false;
1891     VisibleCallbackInfo callbackInfo;
1892     int32_t flag = 0;
__anon61db40681202(bool isVisible, double radio) 1893     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1894     callbackInfo.callback = jsCallback;
1895     callbackInfo.period = 1;
1896     frameNode->GetOrCreateEventHub<EventHub>()->throttledVisibleAreaCallback_ = callbackInfo;
1897 
1898     /**
1899      * @tc.steps: step2. create layoutProperty.
1900      */
1901     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1902     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1903 
1904     /**
1905      * @tc.steps: step3. call the function ThrottledVisibleTask.
1906      */
1907     frameNode->SetLayoutProperty(layoutProperty);
1908     frameNode->ThrottledVisibleTask();
1909     EXPECT_NE(frameNode, nullptr);
1910     EXPECT_FALSE(frameNode->throttledCallbackOnTheWay_);
1911     EXPECT_TRUE(frameNode->isActive_);
1912     EXPECT_EQ(frameNode->GetOrCreateEventHub<EventHub>()->throttledVisibleAreaCallback_.period, 1);
1913 }
1914 
1915 /**
1916  * @tc.name: FrameNodeThrottledVisibleTask03
1917  * @tc.desc: Test the function ThrottledVisibleTask
1918  * @tc.type: FUNC
1919  */
1920 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask03, TestSize.Level1)
1921 {
1922     /**
1923      * @tc.steps: step1. create frameNode.
1924      */
1925     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1926     frameNode->throttledCallbackOnTheWay_ = false;
1927     VisibleCallbackInfo callbackInfo;
1928     int32_t flag = 0;
__anon61db40681302(bool isVisible, double radio) 1929     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1930     callbackInfo.callback = jsCallback;
1931     callbackInfo.period = 1;
1932     frameNode->GetOrCreateEventHub<EventHub>()->throttledVisibleAreaCallback_ = callbackInfo;
1933 
1934     /**
1935      * @tc.steps: step2. call the function ThrottledVisibleTask.
1936      */
1937     frameNode->ThrottledVisibleTask();
1938     EXPECT_NE(frameNode, nullptr);
1939     EXPECT_EQ(frameNode->GetOrCreateEventHub<EventHub>()->throttledVisibleAreaCallback_.period, 1);
1940 }
1941 
1942 /**
1943  * @tc.name: FrameNodeCreateLayoutTask01
1944  * @tc.desc: Test the function CreateLayoutTask
1945  * @tc.type: FUNC
1946  */
1947 HWTEST_F(FrameNodeTestNg, FrameNodeCreateLayoutTask01, TestSize.Level1)
1948 {
1949     /**
1950      * @tc.steps: step1. create frameNode.
1951      */
1952     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1953     frameNode->isLayoutDirtyMarked_ = true;
1954 
1955     /**
1956      * @tc.steps: step2. create layoutProperty.
1957      */
1958     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1959     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1960     layoutProperty->SetLayoutRect(testRect);
1961     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1962 
1963     /**
1964      * @tc.steps: step3. call the function CreateLayoutTask.
1965      */
1966     frameNode->SetLayoutProperty(layoutProperty);
1967     frameNode->CreateLayoutTask(true);
1968     EXPECT_NE(frameNode, nullptr);
1969     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
1970 }
1971 
1972 /**
1973  * @tc.name: FrameNodeCreateRenderTask01
1974  * @tc.desc: Test the function CreateRenderTask
1975  * @tc.type: FUNC
1976  */
1977 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask01, TestSize.Level1)
1978 {
1979     /**
1980      * @tc.steps: step1. create frameNode.
1981      */
1982     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1983     frameNode->isRenderDirtyMarked_ = true;
1984     frameNode->UpdateInspectorId("123");
1985     frameNode->renderContext_->UpdateAccessibilityFocus(true);
1986     /**
1987      * @tc.steps: step2. create layoutProperty.
1988      */
1989     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1990     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1991     layoutProperty->SetLayoutRect(testRect);
1992     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1993 
1994     /**
1995      * @tc.steps: step3. call the function CreateRenderTask.
1996      */
1997     frameNode->SetLayoutProperty(layoutProperty);
1998     frameNode->CreateRenderTask(true).value()();
1999     EXPECT_NE(frameNode, nullptr);
2000     EXPECT_NE(frameNode->layoutProperty_, nullptr);
2001     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
2002 }
2003 
2004 /**
2005  * @tc.name: FrameNodeCreateRenderTask02
2006  * @tc.desc: Test the function CreateRenderTask
2007  * @tc.type: FUNC
2008  */
2009 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask02, TestSize.Level1)
2010 {
2011     /**
2012      * @tc.steps: step1. create frameNode.
2013      */
2014     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2015     frameNode->isRenderDirtyMarked_ = true;
2016     frameNode->renderContext_->UpdateAccessibilityFocus(true);
2017     /**
2018      * @tc.steps: step2. create layoutProperty.
2019      */
2020     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
2021     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
2022     layoutProperty->SetLayoutRect(testRect);
2023     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
2024 
2025     /**
2026      * @tc.steps: step3. call the function CreateRenderTask.
2027      */
2028     frameNode->SetLayoutProperty(layoutProperty);
2029     frameNode->CreateRenderTask(false).value()();
2030     EXPECT_NE(frameNode, nullptr);
2031     EXPECT_NE(frameNode->layoutProperty_, nullptr);
2032     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
2033 }
2034 
2035 /**
2036  * @tc.name: FrameNodeUpdateLayoutWrapper01
2037  * @tc.desc: Test the function UpdateLayoutWrapper
2038  * @tc.type: FUNC
2039  */
2040 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutWrapper01, TestSize.Level1)
2041 {
2042     /**
2043      * @tc.steps: step1. create frameNode.
2044      */
2045     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2046     auto testNode = FrameNode::CreateFrameNode("test", 0, AceType::MakeRefPtr<Pattern>());
2047     RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>();
2048     RefPtr<LayoutWrapperNode> layoutWrapper =
2049         AceType::MakeRefPtr<LayoutWrapperNode>(testNode, geometryNode, testNode->GetLayoutProperty());
2050 
2051     /**
2052      * @tc.steps: step2. create layoutProperty.
2053      */
2054     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
2055     layoutProperty->propVisibility_ = VisibleType::GONE;
2056     layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_LAYOUT);
2057 
2058     /**
2059      * @tc.steps: step3. call the function UpdateLayoutWrapper.
2060      */
2061     frameNode->SetLayoutProperty(layoutProperty);
2062     frameNode->UpdateLayoutWrapper(layoutWrapper, false, true);
2063     EXPECT_NE(frameNode, nullptr);
2064     EXPECT_NE(frameNode->layoutProperty_, nullptr);
2065     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::GONE);
2066 }
2067 
2068 /**
2069  * @tc.name: FrameNodeUpdateLayoutWrapper02
2070  * @tc.desc: Test the function UpdateLayoutWrapper
2071  * @tc.type: FUNC
2072  */
2073 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutWrapper02, TestSize.Level1)
2074 {
2075     /**
2076      * @tc.steps: step1. create frameNode.
2077      */
2078     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2079 
2080     /**
2081      * @tc.steps: step2. create layoutProperty.
2082      */
2083     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
2084     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
2085     layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_LAYOUT);
2086 
2087     /**
2088      * @tc.steps: step3. call the function UpdateLayoutWrapper.
2089      */
2090     frameNode->SetLayoutProperty(layoutProperty);
2091     frameNode->UpdateLayoutWrapper(nullptr, false, true);
2092     EXPECT_NE(frameNode, nullptr);
2093     EXPECT_NE(frameNode->layoutProperty_, nullptr);
2094     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
2095 }
2096 
2097 /**
2098  * @tc.name: FrameNodeGetContentModifier01
2099  * @tc.desc: Test the function GetContentModifier
2100  * @tc.type: FUNC
2101  */
2102 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier01, TestSize.Level1)
2103 {
2104     /**
2105      * @tc.steps: step1. create frameNode.
2106      */
2107     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<ImagePattern>(), true);
2108     frameNode->renderContext_->UpdateAccessibilityFocus(true);
2109     frameNode->GetPattern<ImagePattern>()->image_ = AceType::MakeRefPtr<NG::MockCanvasImage>();
2110 
2111     /**
2112      * @tc.steps: step2. call the function GetContentModifier.
2113      */
2114     frameNode->GetContentModifier();
2115     frameNode->renderContext_->UpdateAccessibilityFocus(false);
2116     frameNode->GetContentModifier();
2117     EXPECT_NE(frameNode, nullptr);
2118 }
2119 
2120 /**
2121  * @tc.name: FrameNodeGetContentModifier02
2122  * @tc.desc: Test the function GetContentModifier
2123  * @tc.type: FUNC
2124  */
2125 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier02, TestSize.Level1)
2126 {
2127     /**
2128      * @tc.steps: step1. create frameNode.
2129      */
2130     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<ImagePattern>(), true);
2131     frameNode->renderContext_->UpdateAccessibilityFocus(true);
2132     frameNode->GetPattern<ImagePattern>()->image_ = AceType::MakeRefPtr<NG::MockCanvasImage>();
2133     frameNode->extensionHandler_ = AceType::MakeRefPtr<ExtensionHandler>();
2134 
2135     /**
2136      * @tc.steps: step2. call the function GetContentModifier.
2137      */
2138     frameNode->GetContentModifier();
2139     EXPECT_NE(frameNode->extensionHandler_, nullptr);
2140 }
2141 
2142 /**
2143  * @tc.name: FrameNodeGetContentModifier03
2144  * @tc.desc: Test the function GetContentModifier
2145  * @tc.type: FUNC
2146  */
2147 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier03, TestSize.Level1)
2148 {
2149     /**
2150      * @tc.steps: step1. create frameNode.
2151      */
2152     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2153     frameNode->renderContext_->UpdateAccessibilityFocus(true);
2154     /**
2155      * @tc.steps: step2. call the function GetContentModifier.
2156      */
2157     frameNode->GetContentModifier();
2158     EXPECT_NE(frameNode, nullptr);
2159 }
2160 
2161 /**
2162  * @tc.name: FrameNodePostIdleTask01
2163  * @tc.desc: Test the function PostIdleTask
2164  * @tc.type: FUNC
2165  */
2166 HWTEST_F(FrameNodeTestNg, FrameNodePostIdleTask01, TestSize.Level1)
2167 {
2168     /**
2169      * @tc.steps: step1. create frameNode.
2170      */
2171     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2172     /**
2173      * @tc.steps: step2. call the function PostIdleTask.
2174      */
2175     int32_t flag = 0;
__anon61db40681402(int64_t radio, bool isVisible) 2176     std::function<void(int64_t, bool)>&& callback = [&flag](int64_t radio, bool isVisible) { flag++; };
2177     frameNode->PostIdleTask(std::move(callback));
2178     EXPECT_NE(frameNode, nullptr);
2179 }
2180 
2181 /**
2182  * @tc.name: FrameNodeRebuildRenderContextTree01
2183  * @tc.desc: Test the function RebuildRenderContextTree
2184  * @tc.type: FUNC
2185  */
2186 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree01, TestSize.Level1)
2187 {
2188     /**
2189      * @tc.steps: step1. create frameNode.
2190      */
2191     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2192     frameNode->needSyncRenderTree_ = true;
2193     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
2194 
2195     /**
2196      * @tc.steps: step2. create layoutProperty.
2197      */
2198     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
2199     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
2200 
2201     /**
2202      * @tc.steps: step3. call the function RebuildRenderContextTree.
2203      */
2204     frameNode->overlayNode_->SetLayoutProperty(layoutProperty);
2205     frameNode->RebuildRenderContextTree();
2206     EXPECT_NE(frameNode->overlayNode_, nullptr);
2207 
2208     /**
2209      * @tc.steps: step4. update layoutProperty and call the function RebuildRenderContextTree.
2210      */
2211     layoutProperty->propVisibility_ = VisibleType::INVISIBLE;
2212     frameNode->overlayNode_->SetLayoutProperty(layoutProperty);
2213     frameNode->RebuildRenderContextTree();
2214 
2215     /**
2216      * @tc.steps: step5. update overlayNode_ nullptr and call the function RebuildRenderContextTree.
2217      */
2218     frameNode->overlayNode_ = nullptr;
2219     frameNode->RebuildRenderContextTree();
2220     EXPECT_EQ(frameNode->overlayNode_, nullptr);
2221 }
2222 
2223 /**
2224  * @tc.name: FrameNodeRebuildRenderContextTree02
2225  * @tc.desc: Test the function RebuildRenderContextTree
2226  * @tc.type: FUNC
2227  */
2228 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree02, TestSize.Level1)
2229 {
2230     /**
2231      * @tc.steps: step1. create frameNode.
2232      */
2233     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2234     frameNode->needSyncRenderTree_ = true;
2235     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
2236 
2237     /**
2238      * @tc.steps: step2. create layoutProperty.
2239      */
2240     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
2241     layoutProperty->propVisibility_ = VisibleType::INVISIBLE;
2242 
2243     /**
2244      * @tc.steps: step3. call the function RebuildRenderContextTree.
2245      */
2246     frameNode->overlayNode_->SetLayoutProperty(layoutProperty);
2247     frameNode->RebuildRenderContextTree();
2248     EXPECT_NE(frameNode->overlayNode_->layoutProperty_, nullptr);
2249 }
2250 
2251 /**
2252  * @tc.name: FrameNodeRebuildRenderContextTree03
2253  * @tc.desc: Test the function RebuildRenderContextTree
2254  * @tc.type: FUNC
2255  */
2256 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree03, TestSize.Level1)
2257 {
2258     /**
2259      * @tc.steps: step1. create frameNode.
2260      */
2261     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2262     frameNode->needSyncRenderTree_ = true;
2263     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
2264     frameNode->overlayNode_->layoutProperty_ = nullptr;
2265 
2266     /**
2267      * @tc.steps: step2. call the function RebuildRenderContextTree.
2268      */
2269     frameNode->RebuildRenderContextTree();
2270     EXPECT_EQ(frameNode->overlayNode_->layoutProperty_, nullptr);
2271 }
2272 
2273 /**
2274  * @tc.name: FrameNodeMarkModifyDone01
2275  * @tc.desc: Test the function MarkModifyDone
2276  * @tc.type: FUNC
2277  */
2278 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone01, TestSize.Level1)
2279 {
2280     /**
2281      * @tc.steps: step1. create frameNode.
2282      */
2283     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2284     frameNode->isPrivacySensitive_ = true;
2285     frameNode->isRestoreInfoUsed_ = false;
2286     frameNode->restoreId_ = 1;
2287     auto index = static_cast<int32_t>(Recorder::EventCategory::CATEGORY_COMPONENT);
2288     Recorder::EventRecorder::Get().eventSwitch_[index] = true;
2289     Recorder::EventRecorder::Get().globalSwitch_[index] = true;
2290     std::unordered_set<std::string> nodeSet;
2291     nodeSet.emplace("abc");
2292     Recorder::NodeDataCache::Get().mergedConfig_->shareNodes.emplace("test", nodeSet);
2293 
2294     /**
2295      * @tc.steps: step2. call the function MarkModifyDone.
2296      */
2297     frameNode->MarkModifyDone();
2298     EXPECT_TRUE(frameNode->isPrivacySensitive_);
2299     EXPECT_TRUE(frameNode->isRestoreInfoUsed_);
2300 }
2301 
2302 /**
2303  * @tc.name: FrameNodeMarkModifyDone02
2304  * @tc.desc: Test the function MarkModifyDone
2305  * @tc.type: FUNC
2306  */
2307 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone02, TestSize.Level1)
2308 {
2309     /**
2310      * @tc.steps: step1. create frameNode.
2311      */
2312     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2313     frameNode->isPrivacySensitive_ = true;
2314     frameNode->isRestoreInfoUsed_ = false;
2315     frameNode->restoreId_ = 1;
2316     auto pipeline = MockPipelineContext::GetCurrentContext();
2317     pipeline->privacySensitiveManager_ = nullptr;
2318 
2319     /**
2320      * @tc.steps: step2. call the function MarkModifyDone.
2321      */
2322     frameNode->MarkModifyDone();
2323     EXPECT_TRUE(frameNode->isPrivacySensitive_);
2324     EXPECT_TRUE(frameNode->isRestoreInfoUsed_);
2325     EXPECT_EQ(pipeline->privacySensitiveManager_, nullptr);
2326 }
2327 
2328 /**
2329  * @tc.name: FrameNodeMarkDirtyNode01
2330  * @tc.desc: Test the function MarkDirtyNode
2331  * @tc.type: FUNC
2332  */
2333 HWTEST_F(FrameNodeTestNg, FrameNodeMarkDirtyNode01, TestSize.Level1)
2334 {
2335     /**
2336      * @tc.steps: step1. create frameNode.
2337      */
2338     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2339     frameNode->isPropertyDiffMarked_ = true;
2340     auto testNode = FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2341     testNode->isPropertyDiffMarked_ = false;
2342 
2343     /**
2344      * @tc.steps: step2. call the function MarkDirtyNode.
2345      */
2346     frameNode->MarkDirtyNode(PROPERTY_UPDATE_DIFF);
2347     testNode->MarkDirtyNode(PROPERTY_UPDATE_DIFF);
2348     EXPECT_FALSE(frameNode->isPrivacySensitive_);
2349     EXPECT_FALSE(frameNode->isRestoreInfoUsed_);
2350 }
2351 
2352 /**
2353  * @tc.name: FrameNodeGetAncestorNodeOfFrame01
2354  * @tc.desc: Test the function GetAncestorNodeOfFrame
2355  * @tc.type: FUNC
2356  */
2357 HWTEST_F(FrameNodeTestNg, FrameNodeGetAncestorNodeOfFrame01, TestSize.Level1)
2358 {
2359     /**
2360      * @tc.steps: step1. create frameNode.
2361      */
2362     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2363     frameNode->isWindowBoundary_ = true;
2364 
2365     /**
2366      * @tc.steps: step2. call the function GetAncestorNodeOfFrame.
2367      */
2368     frameNode->GetAncestorNodeOfFrame(true);
2369     EXPECT_TRUE(frameNode->isWindowBoundary_);
2370 }
2371 
2372 /**
2373  * @tc.name: FrameNodeGetFirstAutoFillContainerNode01
2374  * @tc.desc: Test the function GetFirstAutoFillContainerNode
2375  * @tc.type: FUNC
2376  */
2377 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode01, TestSize.Level1)
2378 {
2379     /**
2380      * @tc.steps: step1. create frameNode.
2381      */
2382     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2383 
2384     /**
2385      * @tc.steps: step2. call the function GetFirstAutoFillContainerNode.
2386      */
2387     frameNode->GetFirstAutoFillContainerNode();
2388     EXPECT_NE(frameNode, nullptr);
2389 }
2390 
2391 /**
2392  * @tc.name: FrameNodeGetFirstAutoFillContainerNode02
2393  * @tc.desc: Test the function GetFirstAutoFillContainerNode
2394  * @tc.type: FUNC
2395  */
2396 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode02, TestSize.Level1)
2397 {
2398     /**
2399      * @tc.steps: step1. create frameNode.
2400      */
2401     auto frameNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2402     auto parentNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2403     parentNode->AddChild(frameNode);
2404 
2405     /**
2406      * @tc.steps: step2. call the function GetFirstAutoFillContainerNode.
2407      */
2408     frameNode->GetFirstAutoFillContainerNode();
2409     EXPECT_NE(frameNode, nullptr);
2410     EXPECT_NE(parentNode, nullptr);
2411 }
2412 
2413 /**
2414  * @tc.name: FrameNodeGetFirstAutoFillContainerNode03
2415  * @tc.desc: Test the function GetFirstAutoFillContainerNode
2416  * @tc.type: FUNC
2417  */
2418 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode03, TestSize.Level1)
2419 {
2420     /**
2421      * @tc.steps: step1. create frameNode.
2422      */
2423     auto frameNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2424     auto parentNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2425     parentNode->AddChild(frameNode);
2426 
2427     /**
2428      * @tc.steps: step2. call the function GetFirstAutoFillContainerNode.
2429      */
2430     frameNode->GetFirstAutoFillContainerNode();
2431     EXPECT_NE(frameNode, nullptr);
2432     EXPECT_NE(parentNode, nullptr);
2433 }
2434 
2435 /**
2436  * @tc.name: FrameNodeNotifyFillRequestSuccess01
2437  * @tc.desc: Test the function NotifyFillRequestSuccess
2438  * @tc.type: FUNC
2439  */
2440 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyFillRequestSuccess01, TestSize.Level1)
2441 {
2442     /**
2443      * @tc.steps: step1. create frameNode.
2444      */
2445     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2446     EXPECT_NE(frameNode->pattern_, nullptr);
2447 
2448     /**
2449      * @tc.steps: step2. call the function NotifyFillRequestSuccess.
2450      */
2451     auto viewDataWrap = ViewDataWrap::CreateViewDataWrap();
2452     auto nodeWrap = PageNodeInfoWrap::CreatePageNodeInfoWrap();
2453     frameNode->NotifyFillRequestSuccess(viewDataWrap, nodeWrap, AceAutoFillType::ACE_PASSWORD);
2454     auto pattern = frameNode->pattern_;
2455     frameNode->pattern_ = nullptr;
2456     frameNode->NotifyFillRequestSuccess(viewDataWrap, nodeWrap, AceAutoFillType::ACE_PASSWORD);
2457     frameNode->pattern_ = pattern;
2458 }
2459 
2460 /**
2461  * @tc.name: FrameNodeNotifyFillRequestFailed01
2462  * @tc.desc: Test the function NotifyFillRequestFailed
2463  * @tc.type: FUNC
2464  */
2465 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyFillRequestFailed01, TestSize.Level1)
2466 {
2467     /**
2468      * @tc.steps: step1. create frameNode.
2469      */
2470     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2471     EXPECT_NE(frameNode->pattern_, nullptr);
2472 
2473     /**
2474      * @tc.steps: step2. call the function NotifyFillRequestFailed.
2475      */
2476     auto pattern = frameNode->pattern_;
2477     frameNode->pattern_ = nullptr;
2478     frameNode->NotifyFillRequestFailed(1, "test", true);
2479     frameNode->pattern_ = pattern;
2480 }
2481 
2482 /**
2483  * @tc.name: FrameNodeMarkNeedRender01
2484  * @tc.desc: Test the function MarkNeedRender
2485  * @tc.type: FUNC
2486  */
2487 HWTEST_F(FrameNodeTestNg, FrameNodeMarkNeedRender01, TestSize.Level1)
2488 {
2489     /**
2490      * @tc.steps: step1. create frameNode.
2491      */
2492     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2493     frameNode->isLayoutDirtyMarked_ = false;
2494     frameNode->isRenderDirtyMarked_ = false;
2495 
2496     /**
2497      * @tc.steps: step2. call the function MarkNeedRender.
2498      */
2499     frameNode->MarkNeedRender(false);
2500     EXPECT_FALSE(frameNode->isLayoutDirtyMarked_);
2501     EXPECT_TRUE(frameNode->isRenderDirtyMarked_);
2502 }
2503 
2504 /**
2505  * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrame01
2506  * @tc.desc: Test the function OnGenerateOneDepthVisibleFrame
2507  * @tc.type: FUNC
2508  */
2509 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrame01, TestSize.Level1)
2510 {
2511     /**
2512      * @tc.steps: step1. create frameNode.
2513      */
2514     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2515     auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2516     frameNode->isLayoutNode_ = true;
2517     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
2518 
2519     /**
2520      * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrame.
2521      */
2522     std::list<RefPtr<FrameNode>> children;
2523     children.push_back(childNode);
2524     frameNode->OnGenerateOneDepthVisibleFrame(children);
2525     EXPECT_TRUE(frameNode->isLayoutNode_);
2526 }
2527 
2528 /**
2529  * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrame02
2530  * @tc.desc: Test the function OnGenerateOneDepthVisibleFrame
2531  * @tc.type: FUNC
2532  */
2533 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrame02, TestSize.Level1)
2534 {
2535     /**
2536      * @tc.steps: step1. create frameNode.
2537      */
2538     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2539     auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2540     frameNode->isLayoutNode_ = true;
2541     frameNode->overlayNode_ = nullptr;
2542 
2543     /**
2544      * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrame.
2545      */
2546     std::list<RefPtr<FrameNode>> children;
2547     children.push_back(childNode);
2548     frameNode->OnGenerateOneDepthVisibleFrame(children);
2549     EXPECT_TRUE(frameNode->isLayoutNode_);
2550     EXPECT_EQ(frameNode->overlayNode_, nullptr);
2551 }
2552 
2553 /**
2554  * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrameWithTransition01
2555  * @tc.desc: Test the function OnGenerateOneDepthVisibleFrameWithTransition
2556  * @tc.type: FUNC
2557  */
2558 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrameWithTransition01, TestSize.Level1)
2559 {
2560     /**
2561      * @tc.steps: step1. create frameNode.
2562      */
2563     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2564     auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2565     frameNode->isLayoutNode_ = true;
2566     frameNode->isActive_ = true;
2567     frameNode->overlayNode_ = nullptr;
2568 
2569     /**
2570      * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrameWithTransition.
2571      */
2572     std::list<RefPtr<FrameNode>> children;
2573     children.push_back(childNode);
2574     frameNode->OnGenerateOneDepthVisibleFrameWithTransition(children);
2575     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
2576     frameNode->OnGenerateOneDepthVisibleFrameWithTransition(children);
2577     EXPECT_TRUE(frameNode->isActive_);
2578     EXPECT_TRUE(frameNode->isLayoutNode_);
2579     EXPECT_EQ(frameNode->overlayNode_, 1);
2580 }
2581 
2582 /**
2583  * @tc.name: FrameNodeProcessThrottledVisibleCallback01
2584  * @tc.desc: Test frame node method
2585  * @tc.type: FUNC
2586  */
2587 HWTEST_F(FrameNodeTestNg, FrameNodeProcessThrottledVisibleCallback01, TestSize.Level1)
2588 {
2589     /**
2590      * @tc.steps: step1. create frameNode.
2591      */
2592     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2593 
2594     /**
2595      * @tc.steps: step2. set VisibleAreaUserCallback.
2596      */
2597     VisibleCallbackInfo callbackInfo;
2598     constexpr uint32_t minInterval = 100; // 100ms
2599     int flag = 0;
__anon61db40681502(bool input1, double input2) 2600     callbackInfo.callback = [&flag](bool input1, double input2) { flag += 1; };
2601     callbackInfo.period = minInterval;
2602     frameNode->SetVisibleAreaUserCallback({ 0.2, 0.8, 0.21, 0.79, 0.5 }, callbackInfo);
2603     frameNode->lastThrottledVisibleRatio_ = 0.7f;
2604 
2605     /**
2606      * @tc.steps: step3. call the function ProcessThrottledVisibleCallback.
2607      */
2608     frameNode->ProcessThrottledVisibleCallback(true);
2609     EXPECT_TRUE(frameNode->eventHub_->GetThrottledVisibleAreaCallback().callback);
2610     EXPECT_FLOAT_EQ(frameNode->lastThrottledVisibleRatio_, 0.0f);
2611 }
2612 
2613 /**
2614  * @tc.name: FrameNodeProcessThrottledVisibleCallback02
2615  * @tc.desc: Test frame node method
2616  * @tc.type: FUNC
2617  */
2618 HWTEST_F(FrameNodeTestNg, FrameNodeProcessThrottledVisibleCallback02, TestSize.Level1)
2619 {
2620     /**
2621      * @tc.steps: step1. create frameNode.
2622      */
2623     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2624     EXPECT_NE(frameNode->pattern_, nullptr);
2625 
2626     /**
2627      * @tc.steps: step2. set VisibleAreaUserCallback.
2628      */
2629     VisibleCallbackInfo callbackInfo;
2630     constexpr uint32_t minInterval = 100; // 100ms
2631     int flag = 0;
__anon61db40681602(bool input1, double input2) 2632     callbackInfo.callback = [&flag](bool input1, double input2) { flag += 1; };
2633     callbackInfo.period = minInterval;
2634     frameNode->SetVisibleAreaUserCallback({ 0.2, 0.8, 0.21, 0.79, 0.5 }, callbackInfo);
2635     auto context = MockPipelineContext::GetCurrentContext();
2636     context->taskExecutor_ = AceType::MakeRefPtr<MockTaskExecutor>();
2637     /**
2638      * @tc.steps: step3. call the function ProcessThrottledVisibleCallback.
2639      */
2640     frameNode->throttledCallbackOnTheWay_ = true;
2641     frameNode->ProcessThrottledVisibleCallback(false);
2642     EXPECT_EQ(frameNode->throttledCallbackOnTheWay_, true);
2643 }
2644 
2645 /**
2646  * @tc.name: FrameNodeProcessThrottledVisibleCallback03
2647  * @tc.desc: Test frame node method
2648  * @tc.type: FUNC
2649  */
2650 HWTEST_F(FrameNodeTestNg, FrameNodeProcessThrottledVisibleCallback03, TestSize.Level1)
2651 {
2652     /**
2653      * @tc.steps: step1. create frameNode.
2654      */
2655     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2656     EXPECT_NE(frameNode->pattern_, nullptr);
2657 
2658     /**
2659      * @tc.steps: step2. set VisibleAreaUserCallback.
2660      */
2661     VisibleCallbackInfo callbackInfo;
2662     constexpr uint32_t minInterval = 100; // 100ms
2663     int flag = 0;
__anon61db40681702(bool input1, double input2) 2664     callbackInfo.callback = [&flag](bool input1, double input2) { flag += 1; };
2665     callbackInfo.period = minInterval;
2666     frameNode->SetVisibleAreaUserCallback({ 0.2, 0.8, 0.21, 0.79, 0.5 }, callbackInfo);
2667     auto context = MockPipelineContext::GetCurrentContext();
2668     context->taskExecutor_ = AceType::MakeRefPtr<MockTaskExecutor>();
2669 
2670     /**
2671      * @tc.steps: step2. call the function ProcessThrottledVisibleCallback.
2672      */
2673     frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateFocusHub();
2674     frameNode->throttledCallbackOnTheWay_ = false;
2675     frameNode->ProcessThrottledVisibleCallback(false);
2676     EXPECT_EQ(frameNode->throttledCallbackOnTheWay_, false);
2677 }
2678 
2679 /**
2680  * @tc.name: FrameNodeProcessThrottledVisibleCallback04
2681  * @tc.desc: Test frame node method
2682  * @tc.type: FUNC
2683  */
2684 HWTEST_F(FrameNodeTestNg, FrameNodeProcessThrottledVisibleCallback04, TestSize.Level1)
2685 {
2686     /**
2687      * @tc.steps: step1. create frameNode.
2688      */
2689     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2690     EXPECT_NE(frameNode->pattern_, nullptr);
2691 
2692     /**
2693      * @tc.steps: step2. set VisibleAreaUserCallback.
2694      */
2695     VisibleCallbackInfo callbackInfo;
2696     constexpr uint32_t minInterval = 100; // 100ms
2697     int flag = 0;
__anon61db40681802(bool input1, double input2) 2698     callbackInfo.callback = [&flag](bool input1, double input2) { flag += 1; };
2699     callbackInfo.period = minInterval;
2700     frameNode->lastThrottledTriggerTime_ = GetCurrentTimestamp();
2701     frameNode->SetVisibleAreaUserCallback({ 0.2, 0.8, 0.21, 0.79, 0.5 }, callbackInfo);
2702     auto context = MockPipelineContext::GetCurrentContext();
2703     context->taskExecutor_ = AceType::MakeRefPtr<MockTaskExecutor>();
2704 
2705     /**
2706      * @tc.steps: step2. call the function ProcessThrottledVisibleCallback.
2707      */
2708     frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateFocusHub();
2709     frameNode->throttledCallbackOnTheWay_ = false;
2710     frameNode->ProcessThrottledVisibleCallback(false);
2711 }
2712 
2713 /**
2714  * @tc.name: FrameNodeGetResponseRegionListForTouch01
2715  * @tc.desc: Test frame node method
2716  * @tc.type: FUNC
2717  */
2718 HWTEST_F(FrameNodeTestNg, FrameNodeGetResponseRegionListForTouch01, TestSize.Level1)
2719 {
2720     /**
2721      * @tc.steps: step1. create frameNode.
2722      */
2723     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2724     /**
2725      * @tc.steps: step2. construct parameters.
2726      */
2727     frameNode->isActive_ = true;
2728     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
2729 
2730     DimensionRect responseRect(Dimension(0), Dimension(0), DimensionOffset(OFFSETF));
2731     std::vector<DimensionRect> responseRegion;
2732     responseRegion.emplace_back(responseRect);
2733 
2734     /**
2735      * @tc.steps: step3. call GetResponseRegionList.
2736      * @tc.expected: expect ResponseRegion is not empty.
2737      */
2738     auto gestureEventHub = frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
2739     gestureEventHub->SetResponseRegion(responseRegion);
2740 
2741     auto paintRect = frameNode->renderContext_->GetPaintRectWithoutTransform();
2742     frameNode->GetResponseRegionListForTouch(paintRect);
2743     EXPECT_FALSE(gestureEventHub->GetResponseRegion().empty());
2744 }
2745 
2746 /**
2747  * @tc.name: FrameNodeGetResponseRegionListForTouch02
2748  * @tc.desc: Test frame node method
2749  * @tc.type: FUNC
2750  */
2751 HWTEST_F(FrameNodeTestNg, FrameNodeGetResponseRegionListForTouch02, TestSize.Level1)
2752 {
2753     /**
2754      * @tc.steps: step1. create frameNode.
2755      */
2756     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2757     /**
2758      * @tc.steps: step2. construct parameters.
2759      */
2760     frameNode->isActive_ = true;
2761     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
2762 
2763     DimensionRect responseRect(Dimension(0), Dimension(0), DimensionOffset(OFFSETF));
2764     std::vector<DimensionRect> responseRegion;
2765     responseRegion.emplace_back(responseRect);
2766 
2767     /**
2768      * @tc.steps: step3. call GetResponseRegionList.
2769      * @tc.expected: expect ResponseRegion is not empty.
2770      */
2771     auto gestureEventHub = frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
2772     gestureEventHub->SetResponseRegion(responseRegion);
2773     auto clickRecognizer = AceType::MakeRefPtr<ClickRecognizer>(1, 1);
2774     gestureEventHub->gestureHierarchy_.emplace_back(clickRecognizer);
2775 
2776     auto paintRect = frameNode->renderContext_->GetPaintRectWithoutTransform();
2777     frameNode->GetResponseRegionListForTouch(paintRect);
2778     EXPECT_FALSE(gestureEventHub->GetResponseRegion().empty());
2779 }
2780 
2781 /**
2782  * @tc.name: FrameNodeGetResponseRegionListForTouch03
2783  * @tc.desc: Test frame node method
2784  * @tc.type: FUNC
2785  */
2786 HWTEST_F(FrameNodeTestNg, FrameNodeGetResponseRegionListForTouch03, TestSize.Level1)
2787 {
2788     /**
2789      * @tc.steps: step1. create frameNode.
2790      */
2791     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2792     /**
2793      * @tc.steps: step2. construct parameters.
2794      */
2795     frameNode->isActive_ = true;
2796     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
2797 
2798     /**
2799      * @tc.steps: step3. call GetResponseRegionList.
2800      * @tc.expected: expect ResponseRegion is not empty.
2801      */
2802     auto gestureEventHub = frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
2803     auto clickRecognizer = AceType::MakeRefPtr<ClickRecognizer>(1, 1);
2804     gestureEventHub->gestureHierarchy_.emplace_back(clickRecognizer);
2805 
2806     auto paintRect = frameNode->renderContext_->GetPaintRectWithoutTransform();
2807     auto responseRegionList = frameNode->GetResponseRegionListForTouch(paintRect);
2808     EXPECT_TRUE(responseRegionList.empty());
2809 }
2810 
2811 /**
2812  * @tc.name: FrameNodeProcessMouseTestHit01
2813  * @tc.desc: Test frame node method
2814  * @tc.type: FUNC
2815  */
2816 HWTEST_F(FrameNodeTestNg, FrameNodeProcessMouseTestHit01, TestSize.Level1)
2817 {
2818     /**
2819      * @tc.steps: step1. create frameNode.
2820      */
2821     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2822     /**
2823      * @tc.steps: step2. construct parameters.
2824      */
2825     PointF globalPoint;
2826     PointF parentLocalPoint;
2827     TouchRestrict touchRestrict;
2828     TouchTestResult result;
2829     ResponseLinkResult responseLinkResult;
2830 
2831     /**
2832      * @tc.steps: step3. eventHub_ is nullptr, call ProcessMouseTestHit.
2833      * @tc.expected: expect ProcessMouseTestHit is false.
2834      */
2835     frameNode->eventHub_ = nullptr;
2836     EXPECT_FALSE(frameNode->ProcessMouseTestHit(globalPoint, parentLocalPoint, touchRestrict, result));
2837 
2838     /**
2839      * @tc.steps: step4. eventHub_ is gestureEventHub, call ProcessMouseTestHit.
2840      * @tc.expected: expect ProcessMouseTestHit is false.
2841      */
2842     auto gestureEventHub = frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
2843     EXPECT_FALSE(frameNode->ProcessMouseTestHit(globalPoint, parentLocalPoint, touchRestrict, result));
2844 
2845     /**
2846      * @tc.steps: step3. call ProcessMouseTestHit.
2847      * @tc.expected: expect ProcessMouseTestHit is false.
2848      */
2849     auto inputEventHub = frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateInputEventHub();
2850     EXPECT_FALSE(frameNode->ProcessMouseTestHit(globalPoint, parentLocalPoint, touchRestrict, result));
2851 
2852     /**
2853      * @tc.steps: step4. call ProcessMouseTestHit.
2854      * @tc.expected: expect ProcessMouseTestHit is false.
2855      */
2856     touchRestrict.touchEvent.SetSourceTool(SourceTool::PEN);
2857     touchRestrict.touchEvent.SetType(TouchType::PROXIMITY_IN);
2858     EXPECT_FALSE(frameNode->ProcessMouseTestHit(globalPoint, parentLocalPoint, touchRestrict, result));
2859 }
2860 
2861 /**
2862  * @tc.name: FrameNodeGetResponseRegionListByTraversal01
2863  * @tc.desc: Test frame node method
2864  * @tc.type: FUNC
2865  */
2866 HWTEST_F(FrameNodeTestNg, FrameNodeGetResponseRegionListByTraversal01, TestSize.Level1)
2867 {
2868     /**
2869      * @tc.steps: step1. create frameNode.
2870      */
2871     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2872     EXPECT_NE(frameNode->pattern_, nullptr);
2873 
2874     /**
2875      * @tc.steps: step2. call GetResponseRegionListByTraversal.
2876      * @tc.expected: expect ResponseRegion is not empty.
2877      */
2878     NG::RectF responseRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
2879     std::vector<RectF> responseRegionList;
2880     responseRegionList.emplace_back(responseRect);
2881     auto context = MockPipelineContext::GetCurrentContext();
2882     frameNode->GetResponseRegionListByTraversal(responseRegionList, responseRect);
2883 }
2884 
2885 /**
2886  * @tc.name: OnLayoutFinish001
2887  * @tc.desc: Test frameNode OnLayoutFinish
2888  * @tc.type: FUNC
2889  */
2890 HWTEST_F(FrameNodeTestNg, OnLayoutFinish001, TestSize.Level1)
2891 {
2892     /**
2893      * @tc.steps: step1. create frameNode.
2894      */
2895     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2896     EXPECT_NE(frameNode->pattern_, nullptr);
2897 
2898     /**
2899      * @tc.steps: step2. call OnLayoutFinish.
2900      * @tc.expected: expect BorderRadius radiusTopLeft is 10, OuterBorderRadius radiusTopRight is 20
2901      * and result return true.
2902      */
2903     auto context = AceType::MakeRefPtr<PipelineContext>();
2904     frameNode->context_ = AceType::RawPtr(context);
2905     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
2906     auto geometryTransition = AceType::MakeRefPtr<GeometryTransition>("active");
2907     layoutProperty->geometryTransition_ = geometryTransition;
2908     frameNode->layoutProperty_ = layoutProperty;
2909     frameNode->isActive_ = true;
2910     Dimension radius(10.0f);
2911     Dimension dimension(20.0f);
2912     BorderRadiusProperty borderRadiusProperty;
2913     BorderRadiusProperty outerBorderRadiusProperty;
2914     borderRadiusProperty.radiusTopLeft = radius;
2915     outerBorderRadiusProperty.radiusTopRight = dimension;
2916     frameNode->renderContext_->UpdateBorderRadius(borderRadiusProperty);
2917     frameNode->renderContext_->UpdateOuterBorderRadius(outerBorderRadiusProperty);
2918     bool needSyncRsNode = true;
2919     DirtySwapConfig config;
2920     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
2921     frameNode->context_ = nullptr;
2922     EXPECT_EQ(frameNode->renderContext_->GetBorderRadius()->radiusTopLeft.value().Value(), 10.0f);
2923     EXPECT_EQ(frameNode->renderContext_->GetOuterBorderRadius()->radiusTopRight.value().Value(), 20.0f);
2924     EXPECT_FALSE(result);
2925 }
2926 
2927 /**
2928  * @tc.name: OnLayoutFinish002
2929  * @tc.desc: Test frameNode OnLayoutFinish
2930  * @tc.type: FUNC
2931  */
2932 HWTEST_F(FrameNodeTestNg, OnLayoutFinish002, TestSize.Level1)
2933 {
2934     /**
2935      * @tc.steps: step1. create frameNode.
2936      */
2937     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2938     EXPECT_NE(frameNode->pattern_, nullptr);
2939 
2940     /**
2941      * @tc.steps: step2. call OnLayoutFinish.
2942      * @tc.expected: expect BorderRadius radiusTopLeft is 20, OuterBorderRadius radiusTopRight is 20
2943      * and result return true.
2944      */
2945     auto context = AceType::MakeRefPtr<PipelineContext>();
2946     frameNode->context_ = AceType::RawPtr(context);
2947     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
2948     auto geometryTransition = AceType::MakeRefPtr<GeometryTransition>("active");
2949     layoutProperty->geometryTransition_ = geometryTransition;
2950     frameNode->layoutProperty_ = layoutProperty;
2951     frameNode->isActive_ = true;
2952     Dimension radius(20.0f);
2953     Dimension dimension(20.0f);
2954     BorderRadiusProperty borderRadiusProperty;
2955     BorderRadiusProperty outerBorderRadiusProperty;
2956     borderRadiusProperty.radiusTopLeft = radius;
2957     outerBorderRadiusProperty.radiusTopRight = dimension;
2958     frameNode->renderContext_->UpdateBorderRadius(borderRadiusProperty);
2959     frameNode->renderContext_->UpdateOuterBorderRadius(outerBorderRadiusProperty);
2960     bool needSyncRsNode = true;
2961     DirtySwapConfig config;
2962     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
2963     frameNode->context_ = nullptr;
2964     EXPECT_EQ(frameNode->renderContext_->GetBorderRadius()->radiusTopLeft.value().Value(), 20.0f);
2965     EXPECT_EQ(frameNode->renderContext_->GetOuterBorderRadius()->radiusTopRight.value().Value(), 20.0f);
2966     EXPECT_FALSE(result);
2967 }
2968 
2969 
2970 /**
2971  * @tc.name: OnLayoutFinish003
2972  * @tc.desc: Test frameNode OnLayoutFinish
2973  * @tc.type: FUNC
2974  */
2975 HWTEST_F(FrameNodeTestNg, OnLayoutFinish003, TestSize.Level1)
2976 {
2977     /**
2978      * @tc.steps: step1. create frameNode.
2979      */
2980     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
2981     EXPECT_NE(frameNode->pattern_, nullptr);
2982 
2983     /**
2984      * @tc.steps: step2. isLayoutNode_ true and context true, test OnLayoutFinish.
2985      * @tc.expected: result return false.
2986      */
2987     bool needSyncRsNode = true;
2988     DirtySwapConfig config;
2989     frameNode->isLayoutNode_ = true;
2990     auto context = AceType::MakeRefPtr<PipelineContext>();
2991     frameNode->context_ = AceType::RawPtr(context);
2992     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
2993     EXPECT_FALSE(result);
2994 
2995     /**
2996      * @tc.steps: step3. isLayoutNode_ true and context false, test OnLayoutFinish.
2997      * @tc.expected: result return false.
2998      */
2999     frameNode->context_ = nullptr;
3000     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3001     EXPECT_FALSE(result);
3002 
3003     /**
3004      * @tc.steps: step4. isLayoutNode_ false, test OnLayoutFinish.
3005      * @tc.expected: result return false.
3006      */
3007     frameNode->isLayoutNode_ = false;
3008     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3009     EXPECT_FALSE(result);
3010 }
3011 
3012 /**
3013  * @tc.name: OnLayoutFinish004
3014  * @tc.desc: Test frameNode OnLayoutFinish
3015  * @tc.type: FUNC
3016  */
3017 HWTEST_F(FrameNodeTestNg, OnLayoutFinish004, TestSize.Level1)
3018 {
3019     /**
3020      * @tc.steps: step1. create frameNode.
3021      */
3022     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3023     EXPECT_NE(frameNode->pattern_, nullptr);
3024 
3025     /**
3026      * @tc.steps: step2. isActive_ false and hasTransition false, test OnLayoutFinish.
3027      * @tc.expected: result return false.
3028      */
3029     bool needSyncRsNode = true;
3030     DirtySwapConfig config;
3031     frameNode->isActive_ = false;
3032     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
3033     layoutProperty->geometryTransition_ = nullptr;
3034     frameNode->layoutProperty_ = layoutProperty;
3035     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3036     EXPECT_FALSE(result);
3037 
3038     /**
3039      * @tc.steps: step3. isActive_ false and hasTransition true, test OnLayoutFinish.
3040      * @tc.expected: result return false.
3041      */
3042     auto geometryTransition = AceType::MakeRefPtr<GeometryTransition>("active");
3043     layoutProperty->geometryTransition_ = geometryTransition;
3044     frameNode->layoutProperty_ = layoutProperty;
3045     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3046     EXPECT_FALSE(result);
3047 
3048     /**
3049      * @tc.steps: step4. isActive_ true, test OnLayoutFinish.
3050      * @tc.expected: result return false.
3051      */
3052     frameNode->isActive_ = true;
3053     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3054     EXPECT_FALSE(result);
3055 }
3056 
3057 /**
3058  * @tc.name: OnLayoutFinish005
3059  * @tc.desc: Test frameNode OnLayoutFinish
3060  * @tc.type: FUNC
3061  */
3062 HWTEST_F(FrameNodeTestNg, OnLayoutFinish005, TestSize.Level1)
3063 {
3064     /**
3065      * @tc.steps: step1. create frameNode.
3066      */
3067     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3068     EXPECT_NE(frameNode->pattern_, nullptr);
3069 
3070     /**
3071      * @tc.steps: step2. needSkipSyncGeometryNode_ true and geometryTransition null, test OnLayoutFinish.
3072      * @tc.expected: result return false.
3073      */
3074     bool needSyncRsNode = true;
3075     DirtySwapConfig config;
3076     frameNode->isActive_ = true;
3077     frameNode->needSkipSyncGeometryNode_ = true;
3078     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
3079     layoutProperty->geometryTransition_ = nullptr;
3080     frameNode->layoutProperty_ = layoutProperty;
3081     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3082     EXPECT_FALSE(result);
3083 
3084     /**
3085      * @tc.steps: step3. needSkipSyncGeometryNode_ true and geometryTransition valid,, test OnLayoutFinish.
3086      * @tc.expected: result return false.
3087      */
3088     auto geometryTransition = AceType::MakeRefPtr<GeometryTransition>("active");
3089     layoutProperty->geometryTransition_ = geometryTransition;
3090     frameNode->layoutProperty_ = layoutProperty;
3091     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3092     EXPECT_FALSE(result);
3093 
3094     /**
3095      * @tc.steps: step4. needSkipSyncGeometryNode_ false, test OnLayoutFinish.
3096      * @tc.expected: result return false.
3097      */
3098     frameNode->needSkipSyncGeometryNode_ = false;
3099     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3100     EXPECT_FALSE(result);
3101 }
3102 
3103 /**
3104  * @tc.name: OnLayoutFinish006
3105  * @tc.desc: Test frameNode OnLayoutFinish
3106  * @tc.type: FUNC
3107  */
3108 HWTEST_F(FrameNodeTestNg, OnLayoutFinish006, TestSize.Level1)
3109 {
3110     /**
3111      * @tc.steps: step1. create frameNode.
3112      */
3113     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3114     EXPECT_NE(frameNode->pattern_, nullptr);
3115 
3116     /**
3117      * @tc.steps: step2. oldGeometryNode_ valid, test OnLayoutFinish.
3118      * @tc.expected: result return false.
3119      */
3120     bool needSyncRsNode = true;
3121     DirtySwapConfig config;
3122     frameNode->isActive_ = true;
3123     frameNode->needSkipSyncGeometryNode_ = false;
3124     frameNode->oldGeometryNode_ = AceType::MakeRefPtr<GeometryNode>();
3125     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3126     EXPECT_FALSE(result);
3127 
3128     /**
3129      * @tc.steps: step3. oldGeometryNode_ null, test OnLayoutFinish.
3130      * @tc.expected: result return false.
3131      */
3132     frameNode->oldGeometryNode_ = nullptr;
3133     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3134     EXPECT_FALSE(result);
3135 }
3136 
3137 /**
3138  * @tc.name: OnLayoutFinish007
3139  * @tc.desc: Test frameNode OnLayoutFinish
3140  * @tc.type: FUNC
3141  */
3142 HWTEST_F(FrameNodeTestNg, OnLayoutFinish007, TestSize.Level1)
3143 {
3144     /**
3145      * @tc.steps: step1. create frameNode.
3146      */
3147     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3148     EXPECT_NE(frameNode->pattern_, nullptr);
3149 
3150     /**
3151      * @tc.steps: step2. tag equals V2::PAGE_ETS_TAG, test OnLayoutFinish.
3152      * @tc.expected: result return false.
3153      */
3154     bool needSyncRsNode = true;
3155     DirtySwapConfig config;
3156     frameNode->isActive_ = true;
3157     frameNode->needSkipSyncGeometryNode_ = false;
3158     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3159     EXPECT_FALSE(result);
3160 
3161     /**
3162      * @tc.steps: step3. tag not equals V2::PAGE_ETS_TAG, test OnLayoutFinish.
3163      * @tc.expected: result return false.
3164      */
3165     frameNode->tag_ = "frameNode";
3166     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3167     EXPECT_FALSE(result);
3168 }
3169 
3170 /**
3171  * @tc.name: OnLayoutFinish008
3172  * @tc.desc: Test frameNode OnLayoutFinish
3173  * @tc.type: FUNC
3174  */
3175 HWTEST_F(FrameNodeTestNg, OnLayoutFinish008, TestSize.Level1)
3176 {
3177     /**
3178      * @tc.steps: step1. create frameNode.
3179      */
3180     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3181     EXPECT_NE(frameNode->pattern_, nullptr);
3182 
3183     /**
3184      * @tc.steps: step2. config.skipMeasure false and config.skipLayout false, test OnLayoutFinish.
3185      * @tc.expected: result return true.
3186      */
3187     bool needSyncRsNode = true;
3188     DirtySwapConfig config;
3189     frameNode->isActive_ = true;
3190     frameNode->needSkipSyncGeometryNode_ = false;
3191     auto layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3192     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3193     layoutAlgorithmWrapper->skipMeasure_ = false;
3194     layoutAlgorithmWrapper->skipLayout_ = false;
3195     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3196     EXPECT_TRUE(result);
3197 
3198     /**
3199      * @tc.steps: step3. config.skipMeasure false and config.skipLayout true, test OnLayoutFinish.
3200      * @tc.expected: result return true.
3201      */
3202     layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3203     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3204     layoutAlgorithmWrapper->skipMeasure_ = false;
3205     layoutAlgorithmWrapper->skipLayout_ = true;
3206     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3207     EXPECT_TRUE(result);
3208 
3209     /**
3210      * @tc.steps: step4. config.skipMeasure true, test OnLayoutFinish.
3211      * @tc.expected: result return true.
3212      */
3213     layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3214     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3215     layoutAlgorithmWrapper->skipMeasure_ = true;
3216     layoutAlgorithmWrapper->skipLayout_ = true;
3217     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3218     EXPECT_TRUE(result);
3219 }
3220 
3221 /**
3222  * @tc.name: OnLayoutFinish009
3223  * @tc.desc: Test frameNode OnLayoutFinish
3224  * @tc.type: FUNC
3225  */
3226 HWTEST_F(FrameNodeTestNg, OnLayoutFinish009, TestSize.Level1)
3227 {
3228     /**
3229      * @tc.steps: step1. set API20.
3230      */
3231     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
3232     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_TWENTY);
3233 
3234     /**
3235      * @tc.steps: step2. create frameNode.
3236      */
3237     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3238     EXPECT_NE(frameNode->pattern_, nullptr);
3239 
3240     /**
3241      * @tc.steps: step3. API20, test OnLayoutFinish.
3242      * @tc.expected: result return true.
3243      */
3244     bool needSyncRsNode = true;
3245     DirtySwapConfig config;
3246     frameNode->isActive_ = true;
3247     frameNode->needSkipSyncGeometryNode_ = false;
3248     auto layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3249     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3250     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3251     EXPECT_TRUE(result);
3252 
3253     /**
3254      * @tc.steps: step4. revert to the origin API.
3255      */
3256     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
3257 }
3258 
3259 /**
3260  * @tc.name: OnLayoutFinish010
3261  * @tc.desc: Test frameNode OnLayoutFinish
3262  * @tc.type: FUNC
3263  */
3264 HWTEST_F(FrameNodeTestNg, OnLayoutFinish010, TestSize.Level1)
3265 {
3266     /**
3267      * @tc.steps: step1. set API19.
3268      */
3269     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
3270     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_NINETEEN);
3271 
3272     /**
3273      * @tc.steps: step2. create frameNode.
3274      */
3275     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3276     EXPECT_NE(frameNode->pattern_, nullptr);
3277 
3278     /**
3279      * @tc.steps: step3. API19, test OnLayoutFinish.
3280      * @tc.expected: result return true.
3281      */
3282     bool needSyncRsNode = true;
3283     DirtySwapConfig config;
3284     frameNode->isActive_ = true;
3285     frameNode->needSkipSyncGeometryNode_ = false;
3286     auto layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3287     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3288     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3289     EXPECT_TRUE(result);
3290 
3291     /**
3292      * @tc.steps: step4. revert to the origin API.
3293      */
3294     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
3295 }
3296 
3297 /**
3298  * @tc.name: OnLayoutFinish011
3299  * @tc.desc: Test frameNode OnLayoutFinish
3300  * @tc.type: FUNC
3301  */
3302 HWTEST_F(FrameNodeTestNg, OnLayoutFinish011, TestSize.Level1)
3303 {
3304     /**
3305      * @tc.steps: step1. set API20.
3306      */
3307     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
3308     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_TWENTY);
3309 
3310     /**
3311      * @tc.steps: step2. create frameNode.
3312      */
3313     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3314     EXPECT_NE(frameNode->pattern_, nullptr);
3315 
3316     /**
3317      * @tc.steps: step3. needRerender true, test OnLayoutFinish.
3318      * @tc.expected: result return true.
3319      */
3320     bool needSyncRsNode = true;
3321     DirtySwapConfig config;
3322     frameNode->isActive_ = true;
3323     frameNode->needSkipSyncGeometryNode_ = false;
3324     auto layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3325     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3326     auto extensionHandler = AceType::MakeRefPtr<ExtensionHandler>();
3327     frameNode->extensionHandler_ = extensionHandler;
3328     extensionHandler->needRender_ = true;
3329     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3330     EXPECT_TRUE(result);
3331 
3332     /**
3333      * @tc.steps: step4. revert to the origin API.
3334      */
3335     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
3336 }
3337 
3338 /**
3339  * @tc.name: OnLayoutFinish012
3340  * @tc.desc: Test frameNode OnLayoutFinish
3341  * @tc.type: FUNC
3342  */
3343 HWTEST_F(FrameNodeTestNg, OnLayoutFinish012, TestSize.Level1)
3344 {
3345     /**
3346      * @tc.steps: step1. set API20.
3347      */
3348     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
3349     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_TWENTY);
3350 
3351     /**
3352      * @tc.steps: step2. create frameNode.
3353      */
3354     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3355     EXPECT_NE(frameNode->pattern_, nullptr);
3356 
3357     /**
3358      * @tc.steps: step3. needRerender false, drawModifier valid and not skipMeasure, test OnLayoutFinish.
3359      * @tc.expected: result return true.
3360      */
3361     bool needSyncRsNode = true;
3362     DirtySwapConfig config;
3363     frameNode->isActive_ = true;
3364     frameNode->needSkipSyncGeometryNode_ = false;
3365     auto layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3366     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3367     auto extensionHandler = AceType::MakeRefPtr<ExtensionHandler>();
3368     frameNode->extensionHandler_ = extensionHandler;
3369     extensionHandler->needRender_ = false;
3370     auto drawModifier = AceType::MakeRefPtr<DrawModifier>();
3371     extensionHandler->drawModifier_ = drawModifier;
3372     layoutAlgorithmWrapper->skipMeasure_ = false;
3373     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3374     EXPECT_TRUE(result);
3375 
3376     /**
3377      * @tc.steps: step4. needRerender false, drawModifier valid and skipMeasure, test OnLayoutFinish.
3378      * @tc.expected: result return true.
3379      */
3380     layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3381     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3382     layoutAlgorithmWrapper->skipMeasure_ = true;
3383     PropertyChangeFlag propertyChangeFlag = PROPERTY_UPDATE_NORMAL;
3384     frameNode->paintProperty_->propertyChangeFlag_ = propertyChangeFlag;
3385     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3386     EXPECT_TRUE(result);
3387 
3388     /**
3389      * @tc.steps: step5. revert to the origin API.
3390      */
3391     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
3392 }
3393 
3394 /**
3395  * @tc.name: OnLayoutFinish013
3396  * @tc.desc: Test frameNode OnLayoutFinish
3397  * @tc.type: FUNC
3398  */
3399 HWTEST_F(FrameNodeTestNg, OnLayoutFinish013, TestSize.Level1)
3400 {
3401     /**
3402      * @tc.steps: step1. set API20.
3403      */
3404     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
3405     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_TWENTY);
3406 
3407     /**
3408      * @tc.steps: step2. create frameNode.
3409      */
3410     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3411     EXPECT_NE(frameNode->pattern_, nullptr);
3412 
3413     /**
3414      * @tc.steps: step3. needRerender false and CheckNeedRender true, test OnLayoutFinish.
3415      * @tc.expected: result return true.
3416      */
3417     bool needSyncRsNode = true;
3418     DirtySwapConfig config;
3419     frameNode->isActive_ = true;
3420     frameNode->needSkipSyncGeometryNode_ = false;
3421     auto layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3422     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3423     auto extensionHandler = AceType::MakeRefPtr<ExtensionHandler>();
3424     frameNode->extensionHandler_ = extensionHandler;
3425     extensionHandler->needRender_ = false;
3426     PropertyChangeFlag propertyChangeFlag = PROPERTY_UPDATE_RENDER;
3427     frameNode->paintProperty_->propertyChangeFlag_ = propertyChangeFlag;
3428     auto result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3429     EXPECT_TRUE(result);
3430 
3431     /**
3432      * @tc.steps: step4. needRerender false and CheckNeedRender false, test OnLayoutFinish.
3433      * @tc.expected: result return true.
3434      */
3435     layoutAlgorithmWrapper = AceType::MakeRefPtr<LayoutAlgorithmWrapper>(nullptr);
3436     frameNode->layoutAlgorithm_ = layoutAlgorithmWrapper;
3437     propertyChangeFlag = PROPERTY_UPDATE_NORMAL;
3438     frameNode->paintProperty_->propertyChangeFlag_ = propertyChangeFlag;
3439     result = frameNode->OnLayoutFinish(needSyncRsNode, config);
3440     EXPECT_TRUE(result);
3441 
3442     /**
3443      * @tc.steps: step5. revert to the origin API.
3444      */
3445     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
3446 }
3447 } // namespace OHOS::Ace::NG
3448