• 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/mock/base/mock_task_executor.h"
16 #include "test/mock/core/render/mock_canvas_image.h"
17 #include "test/unittest/core/base/frame_node_test_ng.h"
18 
19 #include "core/common/recorder/event_definition.h"
20 #include "core/components_ng/property/grid_property.h"
21 #include "core/common/recorder/event_recorder.h"
22 #include "core/common/recorder/node_data_cache.h"
23 #include "core/components_ng/pattern/image/image_pattern.h"
24 #include "core/components_ng/pattern/stage/page_pattern.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 =
__anon0d795ec60202() 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: FrameNodeDumpOnSizeChangeInfo01
387  * @tc.desc: Test the function DumpOnSizeChangeInfo
388  * @tc.type: FUNC
389  */
390 HWTEST_F(FrameNodeTestNg, FrameNodeDumpOnSizeChangeInfo01, TestSize.Level1)
391 {
392     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
393     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
394     FrameNode::onSizeChangeDumpInfo dumpInfo1 { 1, testLastFrameRect,
395         testCurrFrameRect }; // 1 is the onSizeChangeTimeStamp
396     FrameNode::onSizeChangeDumpInfo dumpInfo2 { 2, testLastFrameRect,
397         testCurrFrameRect }; // 2 is the onSizeChangeTimeStamp
398 
399     /**
400      * @tc.steps: step1. create frameNode.
401      */
402     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
403 
404     /**
405      * @tc.steps: step2. add onSizeChangeDumpInfos.
406      */
407     frameNode->onSizeChangeDumpInfos.push_back(dumpInfo1);
408     frameNode->onSizeChangeDumpInfos.push_back(dumpInfo2);
409 
410     /**
411      * @tc.steps: step3. call the function DumpOnSizeChangeInfo.
412      */
413     frameNode->DumpOnSizeChangeInfo();
414     EXPECT_NE(frameNode, nullptr);
415 }
416 
417 /**
418  * @tc.name: FrameNodeDumpInfo01
419  * @tc.desc: Test the function DumpInfo DumpAdvanceInfo CheckAutoSave
420  * @tc.type: FUNC
421  */
422 HWTEST_F(FrameNodeTestNg, FrameNodeDumpInfo01, TestSize.Level1)
423 {
424     /**
425      * @tc.steps: step1. create frameNode.
426      */
427     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
428     EXPECT_NE(frameNode->pattern_, nullptr);
429 
430     /**
431      * @tc.steps: step2. update pattern_.
432      */
433     auto pattern = frameNode->pattern_;
434     frameNode->pattern_ = nullptr;
435 
436     /**
437      * @tc.steps: step3. call the function DumpOnSizeChangeInfo DumpAdvanceInfo CheckAutoSave.
438      */
439     auto viewDataWrap = ViewDataWrap::CreateViewDataWrap();
440     frameNode->DumpInfo();
441     frameNode->DumpAdvanceInfo();
442     frameNode->DumpViewDataPageNode(viewDataWrap);
443     EXPECT_FALSE(frameNode->CheckAutoSave());
444     frameNode->pattern_ = pattern;
445 }
446 
447 /**
448  * @tc.name: FrameNodeMouseToJsonValue01
449  * @tc.desc: Test the function MouseToJsonValue
450  * @tc.type: FUNC
451  */
452 HWTEST_F(FrameNodeTestNg, FrameNodeMouseToJsonValue01, TestSize.Level1)
453 {
454     /**
455      * @tc.steps: step1. create frameNode.
456      */
457     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
458     EXPECT_NE(frameNode->pattern_, nullptr);
459 
460     /**
461      * @tc.steps: step2. call the function MouseToJsonValue.
462      */
463     InspectorFilter testFilter;
464     auto jsonValue = std::make_unique<JsonValue>();
465     testFilter.AddFilterAttr("focusable");
466     frameNode->MouseToJsonValue(jsonValue, testFilter);
467     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
468 }
469 
470 /**
471  * @tc.name: FrameNodeTouchToJsonValue01
472  * @tc.desc: Test the function TouchToJsonValue
473  * @tc.type: FUNC
474  */
475 HWTEST_F(FrameNodeTestNg, FrameNodeTouchToJsonValue01, TestSize.Level1)
476 {
477     /**
478      * @tc.steps: step1. create frameNode.
479      */
480     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
481     EXPECT_NE(frameNode->pattern_, nullptr);
482 
483     /**
484      * @tc.steps: step2. call the function TouchToJsonValue.
485      */
486     InspectorFilter testFilter;
487     auto jsonValue = std::make_unique<JsonValue>();
488     testFilter.AddFilterAttr("focusable");
489     frameNode->TouchToJsonValue(jsonValue, testFilter);
490     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
491 }
492 
493 /**
494  * @tc.name: FrameNodeTouchToJsonValue02
495  * @tc.desc: Test the function TouchToJsonValue
496  * @tc.type: FUNC
497  */
498 HWTEST_F(FrameNodeTestNg, FrameNodeTouchToJsonValue02, TestSize.Level1)
499 {
500     /**
501      * @tc.steps: step1. create frameNode.
502      */
503     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
504     EXPECT_NE(frameNode->pattern_, nullptr);
505     frameNode->isActive_ = true;
506     frameNode->GetEventHub<EventHub>()->SetEnabled(true);
507 
508     /**
509      * @tc.steps: step2. update the mouseResponseRegion.
510      */
511     DimensionRect responseRect(Dimension(0), Dimension(0), DimensionOffset(OFFSETF));
512     std::vector<DimensionRect> mouseResponseRegion;
513     mouseResponseRegion.emplace_back(responseRect);
514     auto gestureEventHub = frameNode->GetEventHub<EventHub>()->GetOrCreateGestureEventHub();
515     gestureEventHub->SetMouseResponseRegion(mouseResponseRegion);
516 
517     /**
518      * @tc.steps: step3. call the function TouchToJsonValue.
519      */
520     InspectorFilter testFilter;
521     auto jsonValue = std::make_unique<JsonValue>();
522     frameNode->TouchToJsonValue(jsonValue, testFilter);
523     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
524 }
525 
526 /**
527  * @tc.name: FrameNodeGeometryNodeToJsonValue01
528  * @tc.desc: Test the function GeometryNodeToJsonValue
529  * @tc.type: FUNC
530  */
531 HWTEST_F(FrameNodeTestNg, FrameNodeGeometryNodeToJsonValue01, TestSize.Level1)
532 {
533     /**
534      * @tc.steps: step1. create frameNode.
535      */
536     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
537     EXPECT_NE(frameNode->pattern_, nullptr);
538 
539     /**
540      * @tc.steps: step2. call the function GeometryNodeToJsonValue.
541      */
542     InspectorFilter testFilter;
543     auto jsonValue = std::make_unique<JsonValue>();
544     testFilter.AddFilterAttr("focusable");
545     frameNode->GeometryNodeToJsonValue(jsonValue, testFilter);
546     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
547 }
548 
549 /**
550  * @tc.name: FrameNodeToTreeJson01
551  * @tc.desc: Test the function ToTreeJson
552  * @tc.type: FUNC
553  */
554 HWTEST_F(FrameNodeTestNg, FrameNodeToTreeJson01, TestSize.Level1)
555 {
556     /**
557      * @tc.steps: step1. create frameNode.
558      */
559     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
560     EXPECT_NE(frameNode->pattern_, nullptr);
561 
562     /**
563      * @tc.steps: step2. call the function ToTreeJson.
564      */
565     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
566     frameNode->SetLayoutProperty(layoutProperty);
567 
568     InspectorConfig testConfig;
569     auto jsonValue = std::make_unique<JsonValue>();
570     testConfig.contentOnly = true;
571     frameNode->ToTreeJson(jsonValue, testConfig);
572 }
573 
574 /**
575  * @tc.name: FrameNodeToTreeJson02
576  * @tc.desc: Test the function ToTreeJson
577  * @tc.type: FUNC
578  */
579 HWTEST_F(FrameNodeTestNg, FrameNodeToTreeJson02, TestSize.Level1)
580 {
581     /**
582      * @tc.steps: step1. create frameNode.
583      */
584     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
585     EXPECT_NE(frameNode->pattern_, nullptr);
586 
587     /**
588      * @tc.steps: step2. call the function ToTreeJson.
589      */
590     frameNode->paintProperty_ = nullptr;
591     frameNode->propInspectorId_ = "123";
592     frameNode->accessibilityProperty_ = nullptr;
593     frameNode->GetEventHub<EventHub>()->GetOrCreateFocusHub();
594 
595     InspectorConfig testConfig;
596     auto jsonValue = std::make_unique<JsonValue>();
597     testConfig.contentOnly = false;
598     frameNode->ToTreeJson(jsonValue, testConfig);
599 }
600 
601 /**
602  * @tc.name: FrameNodeToTreeJson03
603  * @tc.desc: Test the function ToTreeJson
604  * @tc.type: FUNC
605  */
606 HWTEST_F(FrameNodeTestNg, FrameNodeToTreeJson03, TestSize.Level1)
607 {
608     /**
609      * @tc.steps: step1. create frameNode.
610      */
611     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
612     EXPECT_NE(frameNode->pattern_, nullptr);
613 
614     /**
615      * @tc.steps: step2. call the function ToTreeJson.
616      */
617     auto pattern = frameNode->pattern_;
618     frameNode->pattern_ = nullptr;
619     frameNode->paintProperty_ = nullptr;
620     frameNode->accessibilityProperty_->accessibilityText_ = "test";
621     frameNode->layoutProperty_ = nullptr;
622 
623     InspectorConfig testConfig;
624     auto jsonValue = std::make_unique<JsonValue>();
625     testConfig.contentOnly = false;
626     frameNode->ToTreeJson(jsonValue, testConfig);
627     frameNode->pattern_ = pattern;
628 }
629 
630 /**
631  * @tc.name: FrameNodeFromJson01
632  * @tc.desc: Test the function FromJson
633  * @tc.type: FUNC
634  */
635 HWTEST_F(FrameNodeTestNg, FrameNodeFromJson01, TestSize.Level1)
636 {
637     /**
638      * @tc.steps: step1. create frameNode.
639      */
640     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
641     EXPECT_NE(frameNode->pattern_, nullptr);
642 
643     /**
644      * @tc.steps: step2. call the function FromJson.
645      */
646     auto eventHub = frameNode->eventHub_;
647     frameNode->eventHub_ = nullptr;
648     InspectorFilter testFilter;
649     auto jsonValue = std::make_unique<JsonValue>();
650     testFilter.AddFilterAttr("focusable");
651     frameNode->FromJson(jsonValue);
652     EXPECT_FALSE(jsonValue->GetBool("enabled", false));
653     frameNode->eventHub_ = eventHub;
654 }
655 
656 /**
657  * @tc.name: FrameNodeUpdateGeometryTransition01
658  * @tc.desc: Test the function UpdateGeometryTransition
659  * @tc.type: FUNC
660  */
661 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateGeometryTransition01, TestSize.Level1)
662 {
663     /**
664      * @tc.steps: step1. create frameNode.
665      */
666     auto frameNode = FrameNode::CreateFrameNode("parent", 0, AceType::MakeRefPtr<Pattern>(), true);
667     auto child = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>());
668     EXPECT_NE(frameNode->pattern_, nullptr);
669     frameNode->AddChild(child);
670     EXPECT_EQ(frameNode->GetTotalChildCount(), 1);
671 
672     /**
673      * @tc.steps: step2. update geometryTransition.
674      */
675     frameNode->GetLayoutProperty()->UpdateGeometryTransition("parent", true);
676     child->GetLayoutProperty()->UpdateGeometryTransition("child", false);
677     LayoutProperty::UpdateAllGeometryTransition(frameNode);
678 
679     /**
680      * @tc.steps: step3. call the function UpdateGeometryTransition.
681      */
682     frameNode->UpdateGeometryTransition();
683 }
684 
685 /**
686  * @tc.name: FrameNodeOnAttachToMainTree01
687  * @tc.desc: Test the function OnAttachToMainTree
688  * @tc.type: FUNC
689  */
690 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree01, TestSize.Level1)
691 {
692     /**
693      * @tc.steps: step1. create node.
694      */
695     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
696     auto childNodeOne =
697         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), false); // 2 is id of childNodeOne
698     auto childNodeTwo = nullptr;
699     auto childNodeThree =
700         FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), false); // 3 is id of childNodeThree
701     EXPECT_NE(frameNode->pattern_, nullptr);
702 
703     /**
704      * @tc.steps: step2. update node.
705      */
706     childNodeOne->isLayoutDirtyMarked_ = true;
707     childNodeThree->isLayoutDirtyMarked_ = false;
708     frameNode->AddPredictLayoutNode(childNodeOne);
709     frameNode->AddPredictLayoutNode(childNodeTwo);
710     frameNode->AddPredictLayoutNode(childNodeThree);
711     frameNode->useOffscreenProcess_ = true;
712     frameNode->isPropertyDiffMarked_ = true;
713 
714     /**
715      * @tc.steps: step3. call the function OnAttachToMainTree.
716      */
717     frameNode->OnAttachToMainTree(true);
718 }
719 
720 /**
721  * @tc.name: FrameNodeOnAttachToMainTree02
722  * @tc.desc: Test the function OnAttachToMainTree
723  * @tc.type: FUNC
724  */
725 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree02, TestSize.Level1)
726 {
727     LayoutConstraintF layoutConstraintF = {
728         .minSize = { 1, 1 },
729         .maxSize = { 10, 10 },        // 10 is the maxSize of width and height
730         .percentReference = { 5, 5 }, // 5 is the percentReference of width and height
731         .parentIdealSize = { 2, 2 },  // 2 is the parentIdealSize of width and height
732     };
733     /**
734      * @tc.steps: step1. create node.
735      */
736     auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true);
737     auto childNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), false);
738 
739     /**
740      * @tc.steps: step2. update node.
741      */
742     childNode->isLayoutDirtyMarked_ = true;
743     frameNode->AddPredictLayoutNode(childNode);
744     frameNode->useOffscreenProcess_ = false;
745     frameNode->isPropertyDiffMarked_ = true;
746     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF);
747 
748     /**
749      * @tc.steps: step3. call the function OnAttachToMainTree.
750      */
751     frameNode->OnAttachToMainTree(true);
752     EXPECT_TRUE(childNode->isLayoutDirtyMarked_);
753     EXPECT_FALSE(frameNode->useOffscreenProcess_);
754     EXPECT_TRUE(frameNode->isPropertyDiffMarked_);
755     auto context = frameNode->GetContext();
756     bool hasDirtyPropertyNodes = context->dirtyPropertyNodes_.find(frameNode) != context->dirtyPropertyNodes_.end();
757     EXPECT_TRUE(hasDirtyPropertyNodes);
758 }
759 
760 /**
761  * @tc.name: FrameNodeOnAttachToBuilderNode01
762  * @tc.desc: Test the function OnAttachToBuilderNode
763  * @tc.type: FUNC
764  */
765 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToBuilderNode01, TestSize.Level1)
766 {
767     /**
768      * @tc.steps: step1. create node.
769      */
770     auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true);
771 
772     /**
773      * @tc.steps: step2. call the function OnAttachToBuilderNode.
774      */
775     frameNode->OnAttachToBuilderNode(NodeStatus::BUILDER_NODE_ON_MAINTREE);
776     EXPECT_NE(frameNode->pattern_, nullptr);
777 }
778 
779 /**
780  * @tc.name: FrameNodeOnConfigurationUpdate01
781  * @tc.desc: Test the function OnConfigurationUpdate
782  * @tc.type: FUNC
783  */
784 HWTEST_F(FrameNodeTestNg, FrameNodeOnConfigurationUpdate01, TestSize.Level1)
785 {
786     /**
787      * @tc.steps: step1. create node.
788      */
789     auto frameNode = FrameNode::CreateFrameNode("main", 0, AceType::MakeRefPtr<Pattern>(), true);
__anon0d795ec60302() 790     auto callback = []() {};
791     frameNode->SetColorModeUpdateCallback(std::move(callback));
792 
793     /**
794      * @tc.steps: step2. call the function OnConfigurationUpdate.
795      */
796     ConfigurationChange configurationChange;
797     configurationChange.colorModeUpdate = true;
798     configurationChange.fontUpdate = false;
799     configurationChange.iconUpdate = false;
800     configurationChange.skinUpdate = false;
801     frameNode->OnConfigurationUpdate(configurationChange);
802     EXPECT_TRUE(configurationChange.colorModeUpdate);
803     EXPECT_FALSE(configurationChange.fontUpdate);
804     EXPECT_FALSE(configurationChange.iconUpdate);
805     EXPECT_FALSE(configurationChange.skinUpdate);
806 }
807 
808 /**
809  * @tc.name: FrameNodeSwapDirtyLayoutWrapperOnMainThread01
810  * @tc.desc: Test the function SwapDirtyLayoutWrapperOnMainThread
811  * @tc.type: FUNC
812  */
813 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread01, TestSize.Level1)
814 {
815     /**
816      * @tc.steps: step1. create frameNode.
817      */
818     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
819     frameNode->isActive_ = false;
820     /**
821      * @tc.steps: step2. create layoutProperty.
822      */
823     BorderWidthProperty borderWidth = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp };
824     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
825     layoutProperty->UpdateBorderWidth(borderWidth);
826 
827     RefPtr<LayoutWrapper> layoutWrapper = frameNode->CreateLayoutWrapper(true, true);
828     layoutWrapper->SetActive(true);
829 
__anon0d795ec60402() 830     auto builderFunc = []() -> RefPtr<UINode> {
831         auto node = FrameNode::CreateFrameNode("node", 0, AceType::MakeRefPtr<Pattern>(), true);
832         auto childNode = FrameNode::CreateFrameNode("child", 1, AceType::MakeRefPtr<Pattern>(), true);
833         node->AddChild(childNode);
834         return node;
835     };
836 
837     /**
838      * @tc.steps: step3. call the function DumpCommonInfo.
839      */
840     frameNode->SetBackgroundFunction(builderFunc);
841     frameNode->SetLayoutProperty(layoutProperty);
842     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
843     EXPECT_TRUE(frameNode->isActive_);
844 }
845 
846 /**
847  * @tc.name: FrameNodeSwapDirtyLayoutWrapperOnMainThread02
848  * @tc.desc: Test the function SwapDirtyLayoutWrapperOnMainThread
849  * @tc.type: FUNC
850  */
851 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread02, TestSize.Level1)
852 {
853     LayoutConstraintF layoutConstraintF = {
854         .minSize = { 1, 1 },
855         .maxSize = { 10, 10 },        // 10 is the maxSize of width and height
856         .percentReference = { 5, 5 }, // 5 is the percentReference of width and height
857         .parentIdealSize = { 2, 2 },  // 2 is the parentIdealSize of width and height
858     };
859     /**
860      * @tc.steps: step1. create frameNode.
861      */
862     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
863     frameNode->isActive_ = false;
864     /**
865      * @tc.steps: step2. create layoutProperty.
866      */
867     BorderWidthProperty borderWidth = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp };
868     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
869     layoutProperty->UpdateBorderWidth(borderWidth);
870     layoutProperty->layoutConstraint_ = layoutConstraintF;
871     layoutProperty->contentConstraint_ = layoutConstraintF;
872     frameNode->GetOrCreateFocusHub()->currentFocus_ = true;
873 
874     RefPtr<LayoutWrapper> layoutWrapper = frameNode->CreateLayoutWrapper(true, true);
875     layoutWrapper->SetActive(true);
876 
__anon0d795ec60502() 877     auto builderFunc = []() -> RefPtr<UINode> { return nullptr; };
878 
879     /**
880      * @tc.steps: step3. update renderContext_.
881      */
882     BorderColorProperty borderColorProperty;
883     borderColorProperty.SetColor(Color::BLUE);
884     frameNode->renderContext_->UpdateBorderColor(borderColorProperty);
885     BorderStyleProperty borderStyleProperty;
886     borderStyleProperty.SetBorderStyle(BorderStyle::SOLID);
887     frameNode->renderContext_->UpdateBorderStyle(borderStyleProperty);
888     BorderWidthProperty dashGapProperty;
889     dashGapProperty.SetBorderWidth(Dimension(1));
890     frameNode->renderContext_->UpdateDashGap(dashGapProperty);
891     BorderWidthProperty dashWidthProperty;
892     dashWidthProperty.SetBorderWidth(Dimension(1));
893     frameNode->renderContext_->UpdateDashWidth(dashWidthProperty);
894 
895     /**
896      * @tc.steps: step4. call the function DumpCommonInfo.
897      */
898     frameNode->SetBackgroundFunction(builderFunc);
899     frameNode->SetLayoutProperty(layoutProperty);
900     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
901     EXPECT_NE(frameNode->pattern_, nullptr);
902     EXPECT_NE(frameNode->layoutProperty_, nullptr);
903 }
904 
905 /**
906  * @tc.name: FrameNodeAdjustGridOffset01
907  * @tc.desc: Test the function AdjustGridOffset
908  * @tc.type: FUNC
909  */
910 HWTEST_F(FrameNodeTestNg, FrameNodeAdjustGridOffset01, TestSize.Level1)
911 {
912     /**
913      * @tc.steps: step1. create frameNode.
914      */
915     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
916     frameNode->isActive_ = true;
917 
918     /**
919      * @tc.steps: step2. create layoutProperty.
920      */
921     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
922     layoutProperty->gridProperty_ = std::make_unique<GridProperty>();
923     layoutProperty->UpdateGridProperty(1, 0, GridSizeType::UNDEFINED);
924 
925     layoutProperty->gridProperty_ = std::make_unique<GridProperty>();
926     frameNode->SetParent(FRAME_NODE);
927     frameNode->NotifyVisibleChange(VisibleType::INVISIBLE, VisibleType::VISIBLE);
928     RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>();
929     geometryNode->SetFrameOffset(OffsetF(1.0f, 0.0f));
930     frameNode->geometryNode_ = geometryNode;
931     layoutProperty->BuildGridProperty(frameNode);
932 
933     /**
934      * @tc.steps: step4. call the function DumpCommonInfo.
935      */
936     frameNode->SetLayoutProperty(layoutProperty);
937     frameNode->AdjustGridOffset();
938     EXPECT_NE(frameNode->pattern_, nullptr);
939     EXPECT_NE(frameNode->layoutProperty_, nullptr);
940 }
941 
942 /**
943  * @tc.name: FrameNodeClearUserOnAreaChange01
944  * @tc.desc: Test the function ClearUserOnAreaChange
945  * @tc.type: FUNC
946  */
947 HWTEST_F(FrameNodeTestNg, FrameNodeClearUserOnAreaChange01, TestSize.Level1)
948 {
949     /**
950      * @tc.steps: step1. create frameNode.
951      */
952     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
953     EXPECT_NE(frameNode->pattern_, nullptr);
954 
955     /**
956      * @tc.steps: step2. call the function ClearUserOnAreaChange.
957      */
958     auto eventHub = frameNode->eventHub_;
959     frameNode->eventHub_ = nullptr;
960     frameNode->ClearUserOnAreaChange();
961     frameNode->eventHub_ = eventHub;
962 }
963 
964 /**
965  * @tc.name: FrameNodeTriggerOnAreaChangeCallback01
966  * @tc.desc: Test the function TriggerOnAreaChangeCallback
967  * @tc.type: FUNC
968  */
969 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback01, TestSize.Level1)
970 {
971     /**
972      * @tc.steps: step1. create frameNode.
973      */
974     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
975     EXPECT_NE(frameNode->pattern_, nullptr);
976     frameNode->isActive_ = true;
977     bool flag = false;
978     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon0d795ec60602(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 979                                           const OffsetF& origin) { flag = !flag; };
980     frameNode->GetEventHub<EventHub>()->SetOnAreaChanged(std::move(onAreaChanged));
981     frameNode->GetEventHub<EventHub>()->AddInnerOnAreaChangedCallback(1, std::move(onAreaChanged));
982     frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset
983     frameNode->lastFrameRect_ =
984         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
985 
986     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
987     posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1)));
988     /**
989      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
990      */
991     frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1);
992 }
993 
994 /**
995  * @tc.name: FrameNodeTriggerOnAreaChangeCallback02
996  * @tc.desc: Test the function TriggerOnAreaChangeCallback
997  * @tc.type: FUNC
998  */
999 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback02, TestSize.Level1)
1000 {
1001     /**
1002      * @tc.steps: step1. create frameNode.
1003      */
1004     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1005     EXPECT_NE(frameNode->pattern_, nullptr);
1006     frameNode->isActive_ = true;
1007     bool flag = false;
1008     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon0d795ec60702(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 1009                                           const OffsetF& origin) { flag = !flag; };
1010     frameNode->GetEventHub<EventHub>()->SetOnAreaChanged(std::move(onAreaChanged));
1011     frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset
1012     frameNode->lastFrameRect_ =
1013         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1014 
1015     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1016     posProperty->UpdateOffset(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1017     /**
1018      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1019      */
1020     frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1);
1021 }
1022 
1023 /**
1024  * @tc.name: FrameNodeTriggerOnAreaChangeCallback03
1025  * @tc.desc: Test the function TriggerOnAreaChangeCallback
1026  * @tc.type: FUNC
1027  */
1028 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback03, TestSize.Level1)
1029 {
1030     /**
1031      * @tc.steps: step1. create frameNode.
1032      */
1033     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1034     EXPECT_NE(frameNode->pattern_, nullptr);
1035     frameNode->isActive_ = true;
1036     bool flag = false;
1037     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon0d795ec60802(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 1038                                           const OffsetF& origin) { flag = !flag; };
1039     frameNode->GetEventHub<EventHub>()->AddInnerOnAreaChangedCallback(1, std::move(onAreaChanged));
1040     frameNode->lastParentOffsetToWindow_ = std::make_unique<OffsetF>(OffsetF(50.0f, 50.0f)); // 50.0f is the offset
1041     frameNode->lastFrameRect_ =
1042         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1043 
1044     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1045     posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1046     /**
1047      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1048      */
1049     frameNode->TriggerOnAreaChangeCallback(TIMESTAMP_1);
1050 }
1051 
1052 /**
1053  * @tc.name: FrameNodeAddInnerOnSizeChangeCallback01
1054  * @tc.desc: Test the function AddInnerOnSizeChangeCallback
1055  * @tc.type: FUNC
1056  */
1057 HWTEST_F(FrameNodeTestNg, FrameNodeAddInnerOnSizeChangeCallback01, TestSize.Level1)
1058 {
1059     /**
1060      * @tc.steps: step1. create frameNode.
1061      */
1062     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1063     EXPECT_NE(frameNode->pattern_, nullptr);
__anon0d795ec60902(const RectF& oldRect, const RectF& rect) 1064     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1065     frameNode->lastFrameNodeRect_ = std::make_unique<RectF>(RectF(OffsetF(1.0f, 1.0f), SizeF(1.0f, 1.0f)));
1066     /**
1067      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1068      */
1069     frameNode->AddInnerOnSizeChangeCallback(1, std::move(callback));
1070 }
1071 
1072 /**
1073  * @tc.name: FrameNodeAddInnerOnSizeChangeCallback02
1074  * @tc.desc: Test the function AddInnerOnSizeChangeCallback
1075  * @tc.type: FUNC
1076  */
1077 HWTEST_F(FrameNodeTestNg, FrameNodeAddInnerOnSizeChangeCallback02, TestSize.Level1)
1078 {
1079     /**
1080      * @tc.steps: step1. create frameNode.
1081      */
1082     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1083     EXPECT_NE(frameNode->pattern_, nullptr);
__anon0d795ec60a02(const RectF& oldRect, const RectF& rect) 1084     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1085     /**
1086      * @tc.steps: step3. call the function TriggerOnAreaChangeCallback.
1087      */
1088     frameNode->AddInnerOnSizeChangeCallback(1, std::move(callback));
1089 }
1090 
1091 /**
1092  * @tc.name: FrameNodeSetJSFrameNodeOnSizeChangeCallback01
1093  * @tc.desc: Test the function SetJSFrameNodeOnSizeChangeCallback
1094  * @tc.type: FUNC
1095  */
1096 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSFrameNodeOnSizeChangeCallback01, TestSize.Level1)
1097 {
1098     /**
1099      * @tc.steps: step1. create frameNode.
1100      */
1101     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1102     EXPECT_NE(frameNode->pattern_, nullptr);
__anon0d795ec60b02(const RectF& oldRect, const RectF& rect) 1103     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1104     frameNode->lastFrameNodeRect_ = std::make_unique<RectF>(RectF(OffsetF(1.0f, 1.0f), SizeF(1.0f, 1.0f)));
1105     /**
1106      * @tc.steps: step3. call the function SetJSFrameNodeOnSizeChangeCallback.
1107      */
1108     frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(callback));
1109 }
1110 
1111 /**
1112  * @tc.name: FrameNodeSetJSFrameNodeOnSizeChangeCallback02
1113  * @tc.desc: Test the function SetJSFrameNodeOnSizeChangeCallback
1114  * @tc.type: FUNC
1115  */
1116 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSFrameNodeOnSizeChangeCallback02, TestSize.Level1)
1117 {
1118     /**
1119      * @tc.steps: step1. create frameNode.
1120      */
1121     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1122     EXPECT_NE(frameNode->pattern_, nullptr);
__anon0d795ec60c02(const RectF& oldRect, const RectF& rect) 1123     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
1124     /**
1125      * @tc.steps: step3. call the function SetJSFrameNodeOnSizeChangeCallback.
1126      */
1127     frameNode->SetJSFrameNodeOnSizeChangeCallback(std::move(callback));
1128 }
1129 
1130 /**
1131  * @tc.name: FrameNodeGetRectWithRender01
1132  * @tc.desc: Test the function GetRectWithRender
1133  * @tc.type: FUNC
1134  */
1135 HWTEST_F(FrameNodeTestNg, FrameNodeGetRectWithRender01, TestSize.Level1)
1136 {
1137     /**
1138      * @tc.steps: step1. create frameNode.
1139      */
1140     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1141     EXPECT_NE(frameNode->pattern_, nullptr);
1142     frameNode->isActive_ = true;
1143 
1144     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1145     posProperty->UpdatePosition(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1146     /**
1147      * @tc.steps: step3. call the function GetRectWithRender.
1148      */
1149     frameNode->GetRectWithRender();
1150 }
1151 
1152 /**
1153  * @tc.name: FrameNodeGetRectWithRender02
1154  * @tc.desc: Test the function GetRectWithRender
1155  * @tc.type: FUNC
1156  */
1157 HWTEST_F(FrameNodeTestNg, FrameNodeGetRectWithRender02, TestSize.Level1)
1158 {
1159     /**
1160      * @tc.steps: step1. create frameNode.
1161      */
1162     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
1163     EXPECT_NE(frameNode->pattern_, nullptr);
1164     frameNode->isActive_ = true;
1165 
1166     auto& posProperty = frameNode->renderContext_->GetOrCreatePositionProperty();
1167     posProperty->UpdateOffset(OffsetT<Dimension>(Dimension(1), Dimension(1)));
1168     /**
1169      * @tc.steps: step3. call the function GetRectWithRender.
1170      */
1171     frameNode->GetRectWithRender();
1172 }
1173 
1174 /**
1175  * @tc.name: FrameNodeTriggerOnSizeChangeCallback01
1176  * @tc.desc: Test the function TriggerOnSizeChangeCallback
1177  * @tc.type: FUNC
1178  */
1179 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback01, TestSize.Level1)
1180 {
1181     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1182     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1183     FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect,
1184         testCurrFrameRect }; // 1 is the onSizeChangeTimeStamp
1185     FrameNode::onSizeChangeDumpInfo dumpInfoTwo { 2, testLastFrameRect,
1186         testCurrFrameRect }; // 2 is the onSizeChangeTimeStamp
1187     FrameNode::onSizeChangeDumpInfo dumpInfoThree { 3, testLastFrameRect,
1188         testCurrFrameRect }; // 3 is the onSizeChangeTimeStamp
1189     FrameNode::onSizeChangeDumpInfo dumpInfoFour { 4, testLastFrameRect,
1190         testCurrFrameRect }; // 4 is the onSizeChangeTimeStamp
1191     FrameNode::onSizeChangeDumpInfo dumpInfoFive { 5, testLastFrameRect,
1192         testCurrFrameRect }; // 5 is the onSizeChangeTimeStamp
1193     /**
1194      * @tc.steps: step1. create frameNode.
1195      */
1196     auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true);
1197     EXPECT_NE(frameNode->pattern_, nullptr);
1198     frameNode->isActive_ = true;
1199     auto pattern = frameNode->GetPattern<PagePattern>();
1200     pattern->isOnShow_ = true;
1201     bool flag = false;
__anon0d795ec60d02(const RectF& oldRect, const RectF& rect) 1202     OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; };
1203     frameNode->GetEventHub<EventHub>()->SetOnSizeChanged(std::move(onSizeChanged));
1204     frameNode->GetEventHub<EventHub>()->AddInnerOnSizeChanged(1, std::move(onSizeChanged));
1205     frameNode->lastFrameNodeRect_ =
1206         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1207     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne);
1208     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoTwo);
1209     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoThree);
1210     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoFour);
1211     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoFive);
1212     /**
1213      * @tc.steps: step3. call the function TriggerOnSizeChangeCallback.
1214      */
1215     frameNode->TriggerOnSizeChangeCallback();
1216 }
1217 
1218 /**
1219  * @tc.name: FrameNodeTriggerOnSizeChangeCallback02
1220  * @tc.desc: Test the function TriggerOnSizeChangeCallback
1221  * @tc.type: FUNC
1222  */
1223 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback02, TestSize.Level1)
1224 {
1225     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1226     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1227     FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect, testCurrFrameRect };
1228     /**
1229      * @tc.steps: step1. create frameNode.
1230      */
1231     auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true);
1232     EXPECT_NE(frameNode->pattern_, nullptr);
1233     frameNode->isActive_ = true;
1234     auto pattern = frameNode->GetPattern<PagePattern>();
1235     pattern->isOnShow_ = true;
1236     bool flag = false;
__anon0d795ec60e02(const RectF& oldRect, const RectF& rect) 1237     OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; };
1238     frameNode->GetEventHub<EventHub>()->SetOnSizeChanged(std::move(onSizeChanged));
1239     frameNode->lastFrameNodeRect_ =
1240         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1241     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne);
1242     /**
1243      * @tc.steps: step3. call the function TriggerOnSizeChangeCallback.
1244      */
1245     frameNode->TriggerOnSizeChangeCallback();
1246 }
1247 
1248 /**
1249  * @tc.name: FrameNodeTriggerOnSizeChangeCallback03
1250  * @tc.desc: Test the function TriggerOnSizeChangeCallback
1251  * @tc.type: FUNC
1252  */
1253 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnSizeChangeCallback03, TestSize.Level1)
1254 {
1255     NG::RectF testLastFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1256     NG::RectF testCurrFrameRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1257     FrameNode::onSizeChangeDumpInfo dumpInfoOne { 1, testLastFrameRect, testCurrFrameRect };
1258     /**
1259      * @tc.steps: step1. create frameNode.
1260      */
1261     auto frameNode = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(nullptr), true);
1262     EXPECT_NE(frameNode->pattern_, nullptr);
1263     frameNode->isActive_ = true;
1264     auto pattern = frameNode->GetPattern<PagePattern>();
1265     pattern->isOnShow_ = true;
1266     bool flag = false;
__anon0d795ec60f02(const RectF& oldRect, const RectF& rect) 1267     OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; };
1268     frameNode->GetEventHub<EventHub>()->AddInnerOnSizeChanged(1, std::move(onSizeChanged));
1269     frameNode->lastFrameNodeRect_ =
1270         std::make_unique<RectF>(RectF(OffsetF(50.0f, 50.0f), SizeF(50.0f, 50.0f))); // 50.0f is ths offset and size
1271     frameNode->onSizeChangeDumpInfos.push_back(dumpInfoOne);
1272     /**
1273      * @tc.steps: step3. call the function TriggerOnSizeChangeCallback.
1274      */
1275     frameNode->TriggerOnSizeChangeCallback();
1276 }
1277 
1278 /**
1279  * @tc.name: FrameNodIsFrameDisappear01
1280  * @tc.desc: Test the function IsFrameDisappear
1281  * @tc.type: FUNC
1282  */
1283 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear01, TestSize.Level1)
1284 {
1285     /**
1286      * @tc.steps: step1. create frameNode.
1287      */
1288     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1289     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1290     parentNode->isActive_ = false;
1291     frameNode->onMainTree_ = true;
1292     auto context = frameNode->GetContext();
1293     context->onShow_ = true;
1294     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1295 
1296     /**
1297      * @tc.steps: step2. create layoutProperty.
1298      */
1299     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1300     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1301     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1302     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1303 
1304     /**
1305      * @tc.steps: step3. call the function IsFrameDisappear.
1306      */
1307     parentNode->SetLayoutProperty(parentLayoutProperty);
1308     frameNode->SetLayoutProperty(layoutProperty);
1309     frameNode->IsFrameDisappear();
1310     EXPECT_FALSE(parentNode->isActive_);
1311     EXPECT_TRUE(frameNode->onMainTree_);
1312     EXPECT_NE(frameNode->pattern_, nullptr);
1313     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1314 }
1315 
1316 /**
1317  * @tc.name: FrameNodIsFrameDisappear02
1318  * @tc.desc: Test the function IsFrameDisappear
1319  * @tc.type: FUNC
1320  */
1321 HWTEST_F(FrameNodeTestNg, FrameNodeIsFrameDisappear02, TestSize.Level1)
1322 {
1323     /**
1324      * @tc.steps: step1. create frameNode.
1325      */
1326     auto parentNode = FrameNode::CreateFrameNode("parentNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1327     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1328     parentNode->isActive_ = true;
1329     frameNode->onMainTree_ = true;
1330     auto context = frameNode->GetContext();
1331     context->onShow_ = true;
1332     frameNode->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1333 
1334     /**
1335      * @tc.steps: step2. create layoutProperty.
1336      */
1337     auto parentLayoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1338     parentLayoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1339     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1340     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1341 
1342     /**
1343      * @tc.steps: step3. call the function IsFrameDisappear.
1344      */
1345     parentNode->SetLayoutProperty(parentLayoutProperty);
1346     frameNode->SetLayoutProperty(layoutProperty);
1347     frameNode->IsFrameDisappear();
1348     EXPECT_TRUE(parentNode->isActive_);
1349     EXPECT_TRUE(frameNode->onMainTree_);
1350     EXPECT_NE(frameNode->pattern_, nullptr);
1351     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1352 }
1353 
1354 /**
1355  * @tc.name: FrameNodeTriggerVisibleAreaChangeCallback01
1356  * @tc.desc: Test the function TriggerVisibleAreaChangeCallback
1357  * @tc.type: FUNC
1358  */
1359 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback01, TestSize.Level1)
1360 {
1361     /**
1362      * @tc.steps: step1. create frameNode.
1363      */
1364     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1365     frameNode->onMainTree_ = true;
1366     frameNode->isActive_ = true;
1367     frameNode->isWindowBoundary_ = false;
1368     auto context = frameNode->GetContext();
1369     context->onShow_ = true;
1370     VisibleCallbackInfo callbackInfo;
1371     int32_t flag = 0;
__anon0d795ec61002(bool isVisible, double radio) 1372     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1373     callbackInfo.callback = jsCallback;
1374     callbackInfo.period = 1;
1375     frameNode->GetEventHub<EventHub>()->visibleAreaUserCallback_ = callbackInfo;
1376     frameNode->TriggerVisibleAreaChangeCallback(0, false);
1377     frameNode->GetEventHub<EventHub>()->visibleAreaUserCallback_.callback = nullptr;
1378     frameNode->GetEventHub<EventHub>()->visibleAreaInnerCallback_ = callbackInfo;
1379     frameNode->TriggerVisibleAreaChangeCallback(0, false);
1380     EXPECT_NE(frameNode->GetEventHub<EventHub>(), nullptr);
1381     frameNode->isCalculateInnerVisibleRectClip_ = true;
1382     frameNode->lastInnerVisibleRatio_ = 10.0;
1383     frameNode->lastVisibleRatio_ = 10.0;
1384     frameNode->TriggerVisibleAreaChangeCallback(0, true);
1385     frameNode->GetEventHub<EventHub>()->visibleAreaUserCallback_ = callbackInfo;
1386     /**
1387      * @tc.steps: step2. create layoutProperty.
1388      */
1389     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1390     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1391 
1392     /**
1393      * @tc.steps: step3. call the function TriggerVisibleAreaChangeCallback.
1394      */
1395     std::vector<double> ratios = { 0, 1.0 };
1396     frameNode->SetLayoutProperty(layoutProperty);
1397     frameNode->TriggerVisibleAreaChangeCallback(false);
1398     frameNode->ProcessAllVisibleCallback(ratios, callbackInfo, 1.0, 0.0, true);
1399     EXPECT_NE(frameNode->GetEventHub<EventHub>(), nullptr);
1400 }
1401 
1402 /**
1403  * @tc.name: FrameNodeThrottledVisibleTask01
1404  * @tc.desc: Test the function ThrottledVisibleTask
1405  * @tc.type: FUNC
1406  */
1407 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask01, TestSize.Level1)
1408 {
1409     /**
1410      * @tc.steps: step1. create frameNode.
1411      */
1412     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1413     frameNode->throttledCallbackOnTheWay_ = true;
1414     frameNode->lastThrottledVisibleRatio_ = 0.0;
1415     frameNode->isActive_ = true;
1416     auto context = frameNode->GetContext();
1417     context->onShow_ = false;
1418     VisibleCallbackInfo callbackInfo;
1419     int32_t flag = 0;
__anon0d795ec61102(bool isVisible, double radio) 1420     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1421     callbackInfo.callback = jsCallback;
1422     callbackInfo.period = 1;
1423     frameNode->GetEventHub<EventHub>()->throttledVisibleAreaCallback_ = callbackInfo;
1424 
1425     /**
1426      * @tc.steps: step2. create layoutProperty.
1427      */
1428     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1429     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1430 
1431     /**
1432      * @tc.steps: step3. call the function ThrottledVisibleTask.
1433      */
1434     frameNode->SetLayoutProperty(layoutProperty);
1435     frameNode->ThrottledVisibleTask();
1436     EXPECT_NE(frameNode, nullptr);
1437     EXPECT_FALSE(frameNode->throttledCallbackOnTheWay_);
1438 }
1439 
1440 /**
1441  * @tc.name: FrameNodeThrottledVisibleTask02
1442  * @tc.desc: Test the function ThrottledVisibleTask
1443  * @tc.type: FUNC
1444  */
1445 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask02, TestSize.Level1)
1446 {
1447     /**
1448      * @tc.steps: step1. create frameNode.
1449      */
1450     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1451     frameNode->throttledCallbackOnTheWay_ = true;
1452     frameNode->lastThrottledVisibleRatio_ = 1.0;
1453     frameNode->isActive_ = true;
1454     auto context = frameNode->GetContext();
1455     context->onShow_ = false;
1456     VisibleCallbackInfo callbackInfo;
1457     int32_t flag = 0;
__anon0d795ec61202(bool isVisible, double radio) 1458     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1459     callbackInfo.callback = jsCallback;
1460     callbackInfo.period = 1;
1461     frameNode->GetEventHub<EventHub>()->throttledVisibleAreaCallback_ = callbackInfo;
1462 
1463     /**
1464      * @tc.steps: step2. create layoutProperty.
1465      */
1466     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1467     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1468 
1469     /**
1470      * @tc.steps: step3. call the function ThrottledVisibleTask.
1471      */
1472     frameNode->SetLayoutProperty(layoutProperty);
1473     frameNode->ThrottledVisibleTask();
1474     EXPECT_NE(frameNode, nullptr);
1475     EXPECT_FALSE(frameNode->throttledCallbackOnTheWay_);
1476     EXPECT_TRUE(frameNode->isActive_);
1477     EXPECT_EQ(frameNode->GetEventHub<EventHub>()->throttledVisibleAreaCallback_.period, 1);
1478 }
1479 
1480 /**
1481  * @tc.name: FrameNodeThrottledVisibleTask03
1482  * @tc.desc: Test the function ThrottledVisibleTask
1483  * @tc.type: FUNC
1484  */
1485 HWTEST_F(FrameNodeTestNg, FrameNodeThrottledVisibleTask03, TestSize.Level1)
1486 {
1487     /**
1488      * @tc.steps: step1. create frameNode.
1489      */
1490     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1491     frameNode->throttledCallbackOnTheWay_ = false;
1492     VisibleCallbackInfo callbackInfo;
1493     int32_t flag = 0;
__anon0d795ec61302(bool isVisible, double radio) 1494     const std::function<void(bool, double)>&& jsCallback = [&flag](bool isVisible, double radio) { flag++; };
1495     callbackInfo.callback = jsCallback;
1496     callbackInfo.period = 1;
1497     frameNode->GetEventHub<EventHub>()->throttledVisibleAreaCallback_ = callbackInfo;
1498 
1499     /**
1500      * @tc.steps: step2. call the function ThrottledVisibleTask.
1501      */
1502     frameNode->ThrottledVisibleTask();
1503     EXPECT_NE(frameNode, nullptr);
1504     EXPECT_EQ(frameNode->GetEventHub<EventHub>()->throttledVisibleAreaCallback_.period, 1);
1505 }
1506 
1507 /**
1508  * @tc.name: FrameNodeCreateLayoutTask01
1509  * @tc.desc: Test the function CreateLayoutTask
1510  * @tc.type: FUNC
1511  */
1512 HWTEST_F(FrameNodeTestNg, FrameNodeCreateLayoutTask01, TestSize.Level1)
1513 {
1514     /**
1515      * @tc.steps: step1. create frameNode.
1516      */
1517     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1518     frameNode->isLayoutDirtyMarked_ = true;
1519 
1520     /**
1521      * @tc.steps: step2. create layoutProperty.
1522      */
1523     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1524     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1525     layoutProperty->SetLayoutRect(testRect);
1526     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1527 
1528     /**
1529      * @tc.steps: step3. call the function CreateLayoutTask.
1530      */
1531     frameNode->SetLayoutProperty(layoutProperty);
1532     frameNode->CreateLayoutTask(true);
1533     EXPECT_NE(frameNode, nullptr);
1534     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
1535 }
1536 
1537 /**
1538  * @tc.name: FrameNodeCreateRenderTask01
1539  * @tc.desc: Test the function CreateRenderTask
1540  * @tc.type: FUNC
1541  */
1542 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask01, TestSize.Level1)
1543 {
1544     /**
1545      * @tc.steps: step1. create frameNode.
1546      */
1547     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1548     frameNode->isRenderDirtyMarked_ = true;
1549     frameNode->UpdateInspectorId("123");
1550     frameNode->renderContext_->UpdateAccessibilityFocus(true);
1551     /**
1552      * @tc.steps: step2. create layoutProperty.
1553      */
1554     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1555     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1556     layoutProperty->SetLayoutRect(testRect);
1557     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1558 
1559     /**
1560      * @tc.steps: step3. call the function CreateRenderTask.
1561      */
1562     frameNode->SetLayoutProperty(layoutProperty);
1563     frameNode->CreateRenderTask(true).value()();
1564     EXPECT_NE(frameNode, nullptr);
1565     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1566     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
1567 }
1568 
1569 /**
1570  * @tc.name: FrameNodeCreateRenderTask02
1571  * @tc.desc: Test the function CreateRenderTask
1572  * @tc.type: FUNC
1573  */
1574 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask02, TestSize.Level1)
1575 {
1576     /**
1577      * @tc.steps: step1. create frameNode.
1578      */
1579     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1580     frameNode->isRenderDirtyMarked_ = true;
1581     frameNode->renderContext_->UpdateAccessibilityFocus(true);
1582     /**
1583      * @tc.steps: step2. create layoutProperty.
1584      */
1585     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f }; // 10.0f is the x, y, width and height of rect
1586     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1587     layoutProperty->SetLayoutRect(testRect);
1588     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1589 
1590     /**
1591      * @tc.steps: step3. call the function CreateRenderTask.
1592      */
1593     frameNode->SetLayoutProperty(layoutProperty);
1594     frameNode->CreateRenderTask(false).value()();
1595     EXPECT_NE(frameNode, nullptr);
1596     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1597     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
1598 }
1599 
1600 /**
1601  * @tc.name: FrameNodeUpdateLayoutWrapper01
1602  * @tc.desc: Test the function UpdateLayoutWrapper
1603  * @tc.type: FUNC
1604  */
1605 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutWrapper01, TestSize.Level1)
1606 {
1607     /**
1608      * @tc.steps: step1. create frameNode.
1609      */
1610     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1611     auto testNode = FrameNode::CreateFrameNode("test", 0, AceType::MakeRefPtr<Pattern>());
1612     RefPtr<GeometryNode> geometryNode = AceType::MakeRefPtr<GeometryNode>();
1613     RefPtr<LayoutWrapperNode> layoutWrapper =
1614         AceType::MakeRefPtr<LayoutWrapperNode>(testNode, geometryNode, testNode->GetLayoutProperty());
1615 
1616     /**
1617      * @tc.steps: step2. create layoutProperty.
1618      */
1619     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1620     layoutProperty->propVisibility_ = VisibleType::GONE;
1621     layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_LAYOUT);
1622 
1623     /**
1624      * @tc.steps: step3. call the function UpdateLayoutWrapper.
1625      */
1626     frameNode->SetLayoutProperty(layoutProperty);
1627     frameNode->UpdateLayoutWrapper(layoutWrapper, false, true);
1628     EXPECT_NE(frameNode, nullptr);
1629     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1630     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::GONE);
1631 }
1632 
1633 /**
1634  * @tc.name: FrameNodeUpdateLayoutWrapper02
1635  * @tc.desc: Test the function UpdateLayoutWrapper
1636  * @tc.type: FUNC
1637  */
1638 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutWrapper02, TestSize.Level1)
1639 {
1640     /**
1641      * @tc.steps: step1. create frameNode.
1642      */
1643     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1644 
1645     /**
1646      * @tc.steps: step2. create layoutProperty.
1647      */
1648     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1649     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1650     layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_LAYOUT);
1651 
1652     /**
1653      * @tc.steps: step3. call the function UpdateLayoutWrapper.
1654      */
1655     frameNode->SetLayoutProperty(layoutProperty);
1656     frameNode->UpdateLayoutWrapper(nullptr, false, true);
1657     EXPECT_NE(frameNode, nullptr);
1658     EXPECT_NE(frameNode->layoutProperty_, nullptr);
1659     EXPECT_EQ(frameNode->layoutProperty_->propVisibility_, VisibleType::VISIBLE);
1660 }
1661 
1662 /**
1663  * @tc.name: FrameNodeGetContentModifier01
1664  * @tc.desc: Test the function GetContentModifier
1665  * @tc.type: FUNC
1666  */
1667 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier01, TestSize.Level1)
1668 {
1669     /**
1670      * @tc.steps: step1. create frameNode.
1671      */
1672     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<ImagePattern>(), true);
1673     frameNode->renderContext_->UpdateAccessibilityFocus(true);
1674     frameNode->GetPattern<ImagePattern>()->image_ = AceType::MakeRefPtr<NG::MockCanvasImage>();
1675 
1676     /**
1677      * @tc.steps: step2. call the function GetContentModifier.
1678      */
1679     frameNode->GetContentModifier();
1680     frameNode->renderContext_->UpdateAccessibilityFocus(false);
1681     frameNode->GetContentModifier();
1682     EXPECT_NE(frameNode, nullptr);
1683 }
1684 
1685 /**
1686  * @tc.name: FrameNodeGetContentModifier02
1687  * @tc.desc: Test the function GetContentModifier
1688  * @tc.type: FUNC
1689  */
1690 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier02, TestSize.Level1)
1691 {
1692     /**
1693      * @tc.steps: step1. create frameNode.
1694      */
1695     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<ImagePattern>(), true);
1696     frameNode->renderContext_->UpdateAccessibilityFocus(true);
1697     frameNode->GetPattern<ImagePattern>()->image_ = AceType::MakeRefPtr<NG::MockCanvasImage>();
1698     frameNode->extensionHandler_ = AceType::MakeRefPtr<ExtensionHandler>();
1699 
1700     /**
1701      * @tc.steps: step2. call the function GetContentModifier.
1702      */
1703     frameNode->GetContentModifier();
1704     EXPECT_NE(frameNode->extensionHandler_, nullptr);
1705 }
1706 
1707 /**
1708  * @tc.name: FrameNodeGetContentModifier03
1709  * @tc.desc: Test the function GetContentModifier
1710  * @tc.type: FUNC
1711  */
1712 HWTEST_F(FrameNodeTestNg, FrameNodeGetContentModifier03, TestSize.Level1)
1713 {
1714     /**
1715      * @tc.steps: step1. create frameNode.
1716      */
1717     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1718     frameNode->renderContext_->UpdateAccessibilityFocus(true);
1719     /**
1720      * @tc.steps: step2. call the function GetContentModifier.
1721      */
1722     frameNode->GetContentModifier();
1723     EXPECT_NE(frameNode, nullptr);
1724 }
1725 
1726 /**
1727  * @tc.name: FrameNodePostIdleTask01
1728  * @tc.desc: Test the function PostIdleTask
1729  * @tc.type: FUNC
1730  */
1731 HWTEST_F(FrameNodeTestNg, FrameNodePostIdleTask01, TestSize.Level1)
1732 {
1733     /**
1734      * @tc.steps: step1. create frameNode.
1735      */
1736     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1737     /**
1738      * @tc.steps: step2. call the function PostIdleTask.
1739      */
1740     int32_t flag = 0;
__anon0d795ec61402(int64_t radio, bool isVisible) 1741     std::function<void(int64_t, bool)>&& callback = [&flag](int64_t radio, bool isVisible) { flag++; };
1742     frameNode->PostIdleTask(std::move(callback));
1743     EXPECT_NE(frameNode, nullptr);
1744 }
1745 
1746 /**
1747  * @tc.name: FrameNodeRebuildRenderContextTree01
1748  * @tc.desc: Test the function RebuildRenderContextTree
1749  * @tc.type: FUNC
1750  */
1751 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree01, TestSize.Level1)
1752 {
1753     /**
1754      * @tc.steps: step1. create frameNode.
1755      */
1756     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1757     frameNode->needSyncRenderTree_ = true;
1758     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
1759 
1760     /**
1761      * @tc.steps: step2. create layoutProperty.
1762      */
1763     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1764     layoutProperty->propVisibility_ = VisibleType::VISIBLE;
1765 
1766     /**
1767      * @tc.steps: step3. call the function RebuildRenderContextTree.
1768      */
1769     frameNode->overlayNode_->SetLayoutProperty(layoutProperty);
1770     frameNode->RebuildRenderContextTree();
1771     EXPECT_NE(frameNode->overlayNode_, nullptr);
1772 
1773     /**
1774      * @tc.steps: step4. update layoutProperty and call the function RebuildRenderContextTree.
1775      */
1776     layoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1777     frameNode->overlayNode_->SetLayoutProperty(layoutProperty);
1778     frameNode->RebuildRenderContextTree();
1779 
1780     /**
1781      * @tc.steps: step5. update overlayNode_ nullptr and call the function RebuildRenderContextTree.
1782      */
1783     frameNode->overlayNode_ = nullptr;
1784     frameNode->RebuildRenderContextTree();
1785     EXPECT_EQ(frameNode->overlayNode_, nullptr);
1786 }
1787 
1788 /**
1789  * @tc.name: FrameNodeRebuildRenderContextTree02
1790  * @tc.desc: Test the function RebuildRenderContextTree
1791  * @tc.type: FUNC
1792  */
1793 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree02, TestSize.Level1)
1794 {
1795     /**
1796      * @tc.steps: step1. create frameNode.
1797      */
1798     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1799     frameNode->needSyncRenderTree_ = true;
1800     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
1801 
1802     /**
1803      * @tc.steps: step2. create layoutProperty.
1804      */
1805     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1806     layoutProperty->propVisibility_ = VisibleType::INVISIBLE;
1807 
1808     /**
1809      * @tc.steps: step3. call the function RebuildRenderContextTree.
1810      */
1811     frameNode->overlayNode_->SetLayoutProperty(layoutProperty);
1812     frameNode->RebuildRenderContextTree();
1813     EXPECT_NE(frameNode->overlayNode_->layoutProperty_, nullptr);
1814 }
1815 
1816 /**
1817  * @tc.name: FrameNodeRebuildRenderContextTree03
1818  * @tc.desc: Test the function RebuildRenderContextTree
1819  * @tc.type: FUNC
1820  */
1821 HWTEST_F(FrameNodeTestNg, FrameNodeRebuildRenderContextTree03, TestSize.Level1)
1822 {
1823     /**
1824      * @tc.steps: step1. create frameNode.
1825      */
1826     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1827     frameNode->needSyncRenderTree_ = true;
1828     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
1829     frameNode->overlayNode_->layoutProperty_ = nullptr;
1830 
1831     /**
1832      * @tc.steps: step2. call the function RebuildRenderContextTree.
1833      */
1834     frameNode->RebuildRenderContextTree();
1835     EXPECT_EQ(frameNode->overlayNode_->layoutProperty_, nullptr);
1836 }
1837 
1838 /**
1839  * @tc.name: FrameNodeMarkModifyDone01
1840  * @tc.desc: Test the function MarkModifyDone
1841  * @tc.type: FUNC
1842  */
1843 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone01, TestSize.Level1)
1844 {
1845     /**
1846      * @tc.steps: step1. create frameNode.
1847      */
1848     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1849     frameNode->isPrivacySensitive_ = true;
1850     frameNode->isRestoreInfoUsed_ = false;
1851     frameNode->restoreId_ = 1;
1852     auto index = static_cast<int32_t>(Recorder::EventCategory::CATEGORY_COMPONENT);
1853     Recorder::EventRecorder::Get().eventSwitch_[index] = true;
1854     Recorder::EventRecorder::Get().globalSwitch_[index] = true;
1855     std::unordered_set<std::string> nodeSet;
1856     nodeSet.emplace("abc");
1857     Recorder::NodeDataCache::Get().mergedConfig_->shareNodes.emplace("test", nodeSet);
1858 
1859     /**
1860      * @tc.steps: step2. call the function MarkModifyDone.
1861      */
1862     frameNode->MarkModifyDone();
1863     EXPECT_TRUE(frameNode->isPrivacySensitive_);
1864     EXPECT_TRUE(frameNode->isRestoreInfoUsed_);
1865 }
1866 
1867 /**
1868  * @tc.name: FrameNodeMarkModifyDone02
1869  * @tc.desc: Test the function MarkModifyDone
1870  * @tc.type: FUNC
1871  */
1872 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone02, TestSize.Level1)
1873 {
1874     /**
1875      * @tc.steps: step1. create frameNode.
1876      */
1877     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1878     frameNode->isPrivacySensitive_ = true;
1879     frameNode->isRestoreInfoUsed_ = false;
1880     frameNode->restoreId_ = 1;
1881     auto pipeline = MockPipelineContext::GetCurrentContext();
1882     pipeline->privacySensitiveManager_ = nullptr;
1883 
1884     /**
1885      * @tc.steps: step2. call the function MarkModifyDone.
1886      */
1887     frameNode->MarkModifyDone();
1888     EXPECT_TRUE(frameNode->isPrivacySensitive_);
1889     EXPECT_TRUE(frameNode->isRestoreInfoUsed_);
1890     EXPECT_EQ(pipeline->privacySensitiveManager_, nullptr);
1891 }
1892 
1893 /**
1894  * @tc.name: FrameNodeMarkDirtyNode01
1895  * @tc.desc: Test the function MarkDirtyNode
1896  * @tc.type: FUNC
1897  */
1898 HWTEST_F(FrameNodeTestNg, FrameNodeMarkDirtyNode01, TestSize.Level1)
1899 {
1900     /**
1901      * @tc.steps: step1. create frameNode.
1902      */
1903     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1904     frameNode->isPropertyDiffMarked_ = true;
1905     auto testNode = FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1906     testNode->isPropertyDiffMarked_ = false;
1907 
1908     /**
1909      * @tc.steps: step2. call the function MarkDirtyNode.
1910      */
1911     frameNode->MarkDirtyNode(PROPERTY_UPDATE_DIFF);
1912     testNode->MarkDirtyNode(PROPERTY_UPDATE_DIFF);
1913     EXPECT_FALSE(frameNode->isPrivacySensitive_);
1914     EXPECT_FALSE(frameNode->isRestoreInfoUsed_);
1915 }
1916 
1917 /**
1918  * @tc.name: FrameNodeGetAncestorNodeOfFrame01
1919  * @tc.desc: Test the function GetAncestorNodeOfFrame
1920  * @tc.type: FUNC
1921  */
1922 HWTEST_F(FrameNodeTestNg, FrameNodeGetAncestorNodeOfFrame01, TestSize.Level1)
1923 {
1924     /**
1925      * @tc.steps: step1. create frameNode.
1926      */
1927     auto frameNode = FrameNode::CreateFrameNode("frameNode", 1, AceType::MakeRefPtr<Pattern>(), true);
1928     frameNode->isWindowBoundary_ = true;
1929 
1930     /**
1931      * @tc.steps: step2. call the function GetAncestorNodeOfFrame.
1932      */
1933     frameNode->GetAncestorNodeOfFrame(true);
1934     EXPECT_TRUE(frameNode->isWindowBoundary_);
1935 }
1936 
1937 /**
1938  * @tc.name: FrameNodeGetFirstAutoFillContainerNode01
1939  * @tc.desc: Test the function GetFirstAutoFillContainerNode
1940  * @tc.type: FUNC
1941  */
1942 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode01, TestSize.Level1)
1943 {
1944     /**
1945      * @tc.steps: step1. create frameNode.
1946      */
1947     auto frameNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
1948 
1949     /**
1950      * @tc.steps: step2. call the function GetFirstAutoFillContainerNode.
1951      */
1952     frameNode->GetFirstAutoFillContainerNode();
1953     EXPECT_NE(frameNode, nullptr);
1954 }
1955 
1956 /**
1957  * @tc.name: FrameNodeGetFirstAutoFillContainerNode02
1958  * @tc.desc: Test the function GetFirstAutoFillContainerNode
1959  * @tc.type: FUNC
1960  */
1961 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode02, TestSize.Level1)
1962 {
1963     /**
1964      * @tc.steps: step1. create frameNode.
1965      */
1966     auto frameNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
1967     auto parentNode = FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
1968     parentNode->AddChild(frameNode);
1969 
1970     /**
1971      * @tc.steps: step2. call the function GetFirstAutoFillContainerNode.
1972      */
1973     frameNode->GetFirstAutoFillContainerNode();
1974     EXPECT_NE(frameNode, nullptr);
1975     EXPECT_NE(parentNode, nullptr);
1976 }
1977 
1978 /**
1979  * @tc.name: FrameNodeGetFirstAutoFillContainerNode03
1980  * @tc.desc: Test the function GetFirstAutoFillContainerNode
1981  * @tc.type: FUNC
1982  */
1983 HWTEST_F(FrameNodeTestNg, FrameNodeGetFirstAutoFillContainerNode03, TestSize.Level1)
1984 {
1985     /**
1986      * @tc.steps: step1. create frameNode.
1987      */
1988     auto frameNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
1989     auto parentNode = FrameNode::CreateFrameNode(V2::TABS_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
1990     parentNode->AddChild(frameNode);
1991 
1992     /**
1993      * @tc.steps: step2. call the function GetFirstAutoFillContainerNode.
1994      */
1995     frameNode->GetFirstAutoFillContainerNode();
1996     EXPECT_NE(frameNode, nullptr);
1997     EXPECT_NE(parentNode, nullptr);
1998 }
1999 
2000 /**
2001  * @tc.name: FrameNodeNotifyFillRequestSuccess01
2002  * @tc.desc: Test the function NotifyFillRequestSuccess
2003  * @tc.type: FUNC
2004  */
2005 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyFillRequestSuccess01, TestSize.Level1)
2006 {
2007     /**
2008      * @tc.steps: step1. create frameNode.
2009      */
2010     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2011     EXPECT_NE(frameNode->pattern_, nullptr);
2012 
2013     /**
2014      * @tc.steps: step2. call the function NotifyFillRequestSuccess.
2015      */
2016     auto viewDataWrap = ViewDataWrap::CreateViewDataWrap();
2017     auto nodeWrap = PageNodeInfoWrap::CreatePageNodeInfoWrap();
2018     frameNode->NotifyFillRequestSuccess(viewDataWrap, nodeWrap, AceAutoFillType::ACE_PASSWORD);
2019     auto pattern = frameNode->pattern_;
2020     frameNode->pattern_ = nullptr;
2021     frameNode->NotifyFillRequestSuccess(viewDataWrap, nodeWrap, AceAutoFillType::ACE_PASSWORD);
2022     frameNode->pattern_ = pattern;
2023 }
2024 
2025 /**
2026  * @tc.name: FrameNodeNotifyFillRequestFailed01
2027  * @tc.desc: Test the function NotifyFillRequestFailed
2028  * @tc.type: FUNC
2029  */
2030 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyFillRequestFailed01, TestSize.Level1)
2031 {
2032     /**
2033      * @tc.steps: step1. create frameNode.
2034      */
2035     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2036     EXPECT_NE(frameNode->pattern_, nullptr);
2037 
2038     /**
2039      * @tc.steps: step2. call the function NotifyFillRequestFailed.
2040      */
2041     auto pattern = frameNode->pattern_;
2042     frameNode->pattern_ = nullptr;
2043     frameNode->NotifyFillRequestFailed(1, "test", true);
2044     frameNode->pattern_ = pattern;
2045 }
2046 
2047 /**
2048  * @tc.name: FrameNodeMarkNeedRender01
2049  * @tc.desc: Test the function MarkNeedRender
2050  * @tc.type: FUNC
2051  */
2052 HWTEST_F(FrameNodeTestNg, FrameNodeMarkNeedRender01, TestSize.Level1)
2053 {
2054     /**
2055      * @tc.steps: step1. create frameNode.
2056      */
2057     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2058     frameNode->isLayoutDirtyMarked_ = false;
2059     frameNode->isRenderDirtyMarked_ = false;
2060 
2061     /**
2062      * @tc.steps: step2. call the function MarkNeedRender.
2063      */
2064     frameNode->MarkNeedRender(false);
2065     EXPECT_FALSE(frameNode->isLayoutDirtyMarked_);
2066     EXPECT_TRUE(frameNode->isRenderDirtyMarked_);
2067 }
2068 
2069 /**
2070  * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrame01
2071  * @tc.desc: Test the function OnGenerateOneDepthVisibleFrame
2072  * @tc.type: FUNC
2073  */
2074 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrame01, TestSize.Level1)
2075 {
2076     /**
2077      * @tc.steps: step1. create frameNode.
2078      */
2079     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2080     auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2081     frameNode->isLayoutNode_ = true;
2082     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
2083 
2084     /**
2085      * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrame.
2086      */
2087     std::list<RefPtr<FrameNode>> children;
2088     children.push_back(childNode);
2089     frameNode->OnGenerateOneDepthVisibleFrame(children);
2090     EXPECT_TRUE(frameNode->isLayoutNode_);
2091 }
2092 
2093 /**
2094  * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrame02
2095  * @tc.desc: Test the function OnGenerateOneDepthVisibleFrame
2096  * @tc.type: FUNC
2097  */
2098 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrame02, TestSize.Level1)
2099 {
2100     /**
2101      * @tc.steps: step1. create frameNode.
2102      */
2103     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2104     auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2105     frameNode->isLayoutNode_ = true;
2106     frameNode->overlayNode_ = nullptr;
2107 
2108     /**
2109      * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrame.
2110      */
2111     std::list<RefPtr<FrameNode>> children;
2112     children.push_back(childNode);
2113     frameNode->OnGenerateOneDepthVisibleFrame(children);
2114     EXPECT_TRUE(frameNode->isLayoutNode_);
2115     EXPECT_EQ(frameNode->overlayNode_, nullptr);
2116 }
2117 
2118 /**
2119  * @tc.name: FrameNodeOnGenerateOneDepthVisibleFrameWithTransition01
2120  * @tc.desc: Test the function OnGenerateOneDepthVisibleFrameWithTransition
2121  * @tc.type: FUNC
2122  */
2123 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrameWithTransition01, TestSize.Level1)
2124 {
2125     /**
2126      * @tc.steps: step1. create frameNode.
2127      */
2128     auto frameNode = FrameNode::CreateFrameNode("framenode", 1, AceType::MakeRefPtr<Pattern>(), true);
2129     auto childNode = FrameNode::CreateFrameNode("childNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2130     frameNode->isLayoutNode_ = true;
2131     frameNode->isActive_ = true;
2132     frameNode->overlayNode_ = nullptr;
2133 
2134     /**
2135      * @tc.steps: step2. call the function OnGenerateOneDepthVisibleFrameWithTransition.
2136      */
2137     std::list<RefPtr<FrameNode>> children;
2138     children.push_back(childNode);
2139     frameNode->OnGenerateOneDepthVisibleFrameWithTransition(children);
2140     frameNode->overlayNode_ = AceType::MakeRefPtr<FrameNode>("test", 1, AceType::MakeRefPtr<Pattern>());
2141     frameNode->OnGenerateOneDepthVisibleFrameWithTransition(children);
2142     EXPECT_TRUE(frameNode->isActive_);
2143     EXPECT_TRUE(frameNode->isLayoutNode_);
2144     EXPECT_EQ(frameNode->overlayNode_, 1);
2145 }
2146 } // namespace OHOS::Ace::NG
2147