• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #include "gtest/gtest.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS::Ace::NG {
22 const NG::BorderWidthProperty BORDER_WIDTH_TEST = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp };
SetUpTestSuite()23 void FrameNodeTestNg::SetUpTestSuite()
24 {
25     MockPipelineContext::SetUp();
26 }
27 
TearDownTestSuite()28 void FrameNodeTestNg::TearDownTestSuite()
29 {
30     MockPipelineContext::TearDown();
31 }
32 
33 /**
34  * @tc.name: FrameNodeTestNg001
35  * @tc.desc: Test frame node method
36  * @tc.type: FUNC
37  */
38 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg001, TestSize.Level1)
39 {
__anon6a214d5b0102() 40     auto one = FrameNode::GetOrCreateFrameNode("one", 1, []() { return AceType::MakeRefPtr<Pattern>(); });
41     auto two = FrameNode::GetFrameNode("two", 1);
42     EXPECT_NE(one, nullptr);
43     EXPECT_EQ(two, nullptr);
44 
45     /**
46      * @tc.steps: step2. create FrameNode and set a callback
47      * @tc.expect: call DestroyCallback while object is destroyed
48      */
49     bool flag = false;
50     auto three = FrameNode::GetOrCreateFrameNode("one", 1, nullptr);
51     ASSERT_NE(three, nullptr);
__anon6a214d5b0202() 52     three->PushDestroyCallbackWithTag([&flag]() { flag = !flag; }, "");
53     three = nullptr;
54     EXPECT_TRUE(flag);
55 }
56 
57 /**
58  * @tc.name: FrameNodeTestNg002
59  * @tc.desc: Test frame node method
60  * @tc.type: FUNC
61  */
62 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg002, TestSize.Level1)
63 {
__anon6a214d5b0302() 64     auto one = FrameNode::GetOrCreateFrameNode("one", 1, []() { return AceType::MakeRefPtr<Pattern>(); });
65     one->SetParent(FRAME_NODE_PARENT);
66     auto two = FrameNode::GetFrameNode("two", 1);
67     EXPECT_NE(one, nullptr);
68     EXPECT_EQ(two, nullptr);
69     ElementRegister::GetInstance()->Clear();
70 }
71 
72 /**
73  * @tc.name: FrameNodeTestNg004
74  * @tc.desc: Test frame node method
75  * @tc.type: FUNC
76  */
77 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg004, TestSize.Level1)
78 {
79     /**
80      * @tc.steps: step1. create framenode and initialize the params used in Test.
81      */
82     auto node = FrameNode::CreateFrameNode("childNode", 10, AceType::MakeRefPtr<Pattern>(), true);
83     node->AttachToMainTree();
84     node->GetRenderContext()->RequestNextFrame();
85     EXPECT_TRUE(node->IsOnMainTree());
86 
87     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
88     const RefPtr<FrameNode> parentNode =
89         FrameNode::CreateFrameNode("RelativeContainer", nodeId, AceType::MakeRefPtr<Pattern>(), true);
90     node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
91 
92     /**
93      * @tc.steps: step2. call OnInspectorIdUpdate .
94      * @tc.expect: this parentNode is MarkDirtyNode, but this Tag() != "RelativeContainer"
95      * this parentNode is not MarkDirtyNode
96      */
97     node->OnInspectorIdUpdate("RelativeContainer");
98     EXPECT_EQ(parentNode->GetTag(), "RelativeContainer");
99 }
100 
101 /**
102  * @tc.name: FrameNodeTestNg007
103  * @tc.desc: Test frame node method
104  * @tc.type: FUNC
105  */
106 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg007, TestSize.Level1)
107 {
108     /**
109      * @tc.steps: step 1. create framenode and initialize the params used in Test.
110      */
111     auto node = FrameNode::CreateFrameNode("childNode", 10, AceType::MakeRefPtr<Pattern>(), true);
112 
113     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
114     const RefPtr<FrameNode> parentNode =
115         FrameNode::CreateFrameNode("parent", nodeId, AceType::MakeRefPtr<Pattern>(), true);
116     node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
117 
118     const RefPtr<FrameNode> overlayNode =
119         FrameNode::CreateFrameNode("overlayNode", nodeId, AceType::MakeRefPtr<Pattern>(), true);
120 
121     /**
122      * @tc.steps: step 2. call OnInspectorIdUpdate .
123      * @tc.expect: this parentNode is MarkDirtyNode, but this Tag() != "RelativeContainer"
124      * this parentNode is not MarkDirtyNode
125      */
126 
127     node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
128     node->OnInspectorIdUpdate("RelativeContainer");
129     EXPECT_EQ(parentNode->GetTag(), "parent");
130 
131     /**
132      * @tc.steps: step 3. call LayoutOverlay .
133      * @tc.expect: FrameRect of overlayNode is 0.
134      */
135     node->SetOverlayNode(overlayNode);
136     node->LayoutOverlay();
137 
138     auto layoutProperty = overlayNode->GetLayoutProperty();
139     layoutProperty->positionProperty_ = std::make_unique<PositionProperty>();
140     node->LayoutOverlay();
141     EXPECT_EQ(overlayNode->GetGeometryNode()->GetFrameRect().GetX(), 0);
142 
143     /**
144      * @tc.steps: step 4. call GetFrameChildByIndex .
145      * @tc.expect: index == 0 return uiNode, index != 0 return null
146      */
147     EXPECT_TRUE(node->GetFrameChildByIndex(0, false));
148     EXPECT_FALSE(node->GetFrameChildByIndex(1, false));
149 
150     /**
151      * @tc.steps: step 5. call GetBaselineDistance .
152      * @tc.expect: node has not child return 0. if node has child return  childBaseline of child
153      */
154     EXPECT_EQ(node->GetBaselineDistance(), 0);
155     node->AddChild(FRAME_NODE);
156     EXPECT_EQ(node->GetBaselineDistance(), 0);
157     auto nodeLayoutProperty = node->GetLayoutProperty();
158     nodeLayoutProperty->geometryTransition_ =
159         ElementRegister::GetInstance()->GetOrCreateGeometryTransition("test", false, true);
160     node->Layout();
161     EXPECT_FALSE(node->IsRootMeasureNode());
162     node->SetRootMeasureNode();
163     node->Layout();
164     EXPECT_TRUE(node->IsRootMeasureNode());
165 }
166 
167 /**
168  * @tc.name: FrameNodeTestNg008
169  * @tc.desc: Test frame node method
170  * @tc.type: FUNC
171  */
172 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg008, TestSize.Level1)
173 {
174     /**
175      * @tc.steps: step 1. create framenode and initialize the params used in Test.
176      */
177     RefPtr<NG::DrawModifier> drawModifier = AceType::MakeRefPtr<NG::DrawModifier>();
178     ASSERT_NE(drawModifier, nullptr);
179 
180     /**
181      * @tc.steps: step 2. call get function .
182      * @tc.expect: expect the return value to be correct.
183      */
184     EXPECT_TRUE(FRAME_NODE->IsSupportDrawModifier());
185 
186     /**
187      * @tc.steps: step 3. call GetContentModifier when drawModifier is null.
188      * @tc.expect: expect the return value to be correct.
189      */
190     EXPECT_EQ(FRAME_NODE->GetContentModifier(), nullptr);
191 
192     /**
193      * @tc.steps: step 4. Nodes created by virtual classes, call GetContentModifier when drawModifier is null.
194      * @tc.expect: expect the return value to be correct.
195      */
196     FRAME_NODE->SetDrawModifier(drawModifier);
197     EXPECT_EQ(FRAME_NODE->GetContentModifier(), nullptr);
198 
199     /**
200      * @tc.steps: step 5. Nodes created by virtual classes, call SetRemoveCustomProperties.
201      * @tc.expect: expect call successfully.
202      */
__anon6a214d5b0402() 203     FRAME_NODE->SetRemoveCustomProperties([]() -> void {});
204 }
205 
206 /**
207  * @tc.name: FrameNodeTouchTest001
208  * @tc.desc: Test frame node method
209  * @tc.type: FUNC
210  */
211 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest, TestSize.Level1)
212 {
213     /**
214      * @tc.steps: step1. create framenode and initialize the params used in Test.
215      */
216     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
217     node->AttachToMainTree();
218     node->GetOrCreateGestureEventHub();
219     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
220     node->renderContext_ = mockRenderContext;
221     node->SetActive(true);
222     auto localPoint = PointF(10, 10);
223     auto parentLocalPoint = PointF(10, 10);
224     const NG::PointF point { 10, 10 };
225     const PointF parentLocalPointOne = { 10, 10 };
226     TouchRestrict touchRestrict = { TouchRestrict::NONE };
227     auto globalPoint = PointF(10, 10);
228     auto touchTestResult = std::list<RefPtr<TouchEventTarget>>();
229     ResponseLinkResult responseLinkResult;
230 
231     mockRenderContext->rect_ = RectF(0, 0, 100, 100);
232     EXPECT_CALL(*mockRenderContext, GetPointWithTransform(_)).WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
233 
234     /**
235      * @tc.steps: step2. create childnode
236      */
237     auto childNode = FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true);
238     childNode->SetExclusiveEventForChild(true);
239     auto mockRenderContextforChild = AceType::MakeRefPtr<MockRenderContext>();
240     childNode->renderContext_ = mockRenderContextforChild;
241     mockRenderContext->rect_ = RectF(0, 0, 100, 100);
242     EXPECT_CALL(*mockRenderContextforChild, GetPointWithTransform(_))
243         .WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
244     childNode->GetOrCreateGestureEventHub();
245     childNode->SetActive(true);
246     auto childEventHub = childNode->GetOrCreateGestureEventHub();
247 
248     /**
249      * @tc.steps: step3. add childnode to the framenode
250      */
251     std::list<RefPtr<FrameNode>> children;
252     children.push_back(childNode);
253     node->frameChildren_ = { children.begin(), children.end() };
254 
255     /**
256      * @tc.steps: step4. create grandChildNode
257      */
258 
259     auto grandChildNode = FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), true);
260     grandChildNode->SetExclusiveEventForChild(true);
261     grandChildNode->renderContext_ = mockRenderContextforChild;
262     mockRenderContext->rect_ = RectF(0, 0, 100, 100);
263     EXPECT_CALL(*mockRenderContextforChild, GetPointWithTransform(_))
264         .WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
265     grandChildNode->GetOrCreateGestureEventHub();
266     grandChildNode->SetActive(true);
267     auto grandChildEventHub = grandChildNode->GetOrCreateGestureEventHub();
268 
269     /**
270      * @tc.steps: step5. add grandChildNode to the childnode
271      */
272     std::list<RefPtr<FrameNode>> grandChild;
273     grandChild.push_back(grandChildNode);
274     childNode->frameChildren_ = { grandChild.begin(), grandChild.end() };
275 
276     /**
277      * @tc.steps: step6. compare hitTestResult which is retured in function TouchTest whith expected value.
278      * @tc.expected: step6. hitTestResult  is STOP_BUBBLING when hitTestModeofGrandChilds or hitTestModeofChild is
279      * HTMBLOCK;
280      */
281     HitTestMode hitTestModeofGrandChilds[] = { HitTestMode::HTMBLOCK, HitTestMode::HTMDEFAULT };
282     HitTestMode hitTestModeofChilds[] = { HitTestMode::HTMDEFAULT, HitTestMode::HTMBLOCK, HitTestMode::HTMTRANSPARENT,
283         HitTestMode::HTMNONE, HitTestMode::HTMTRANSPARENT_SELF };
284     bool isStacks[] = { true, false };
285 
286     for (auto hitTestModeofGrandChild : hitTestModeofGrandChilds) {
287         grandChildEventHub->SetHitTestMode(hitTestModeofGrandChild);
288         for (auto isStack : isStacks) {
289             for (auto hitTestModeofChild : hitTestModeofChilds) {
290                 childNode->SetExclusiveEventForChild(isStack);
291                 childEventHub->SetHitTestMode(hitTestModeofChild);
292                 auto result = childNode->TouchTest(globalPoint, parentLocalPointOne, parentLocalPointOne, touchRestrict,
293                     touchTestResult, 0, responseLinkResult, true);
294                 result = node->TouchTest(globalPoint, parentLocalPointOne, parentLocalPointOne, touchRestrict,
295                     touchTestResult, 0, responseLinkResult, true);
296             }
297         }
298     }
299 }
300 
301 /**
302  * @tc.name: FrameNodeTestNg005
303  * @tc.desc: Test frame node method
304  * @tc.type: FUNC
305  */
306 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg005, TestSize.Level1)
307 {
308     /**
309      * @tc.steps: step1. callback function.
310      * @tc.expected: expect The function is run ok.
311      */
312     auto one = FrameNode::CreateFrameNodeWithTree("main", 10, AceType::MakeRefPtr<Pattern>());
313     EXPECT_NE(one, nullptr);
314 
315     MeasureProperty calcLayoutConstraint;
316     FRAME_NODE->UpdateLayoutConstraint(std::move(calcLayoutConstraint));
317     EXPECT_EQ(FRAME_NODE2->layoutProperty_->propertyChangeFlag_, 1);
318 
319     FRAME_NODE2->needSyncRenderTree_ = true;
320     FRAME_NODE2->RebuildRenderContextTree();
321     EXPECT_FALSE(FRAME_NODE2->needSyncRenderTree_);
322 
323     /**
324      * @tc.steps: step 2. create and set overlayNode.
325      * @tc.expect:cover branch overlayNode is not null and function is run ok.
326      */
327     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
328     const RefPtr<FrameNode> overlayNode =
329         FrameNode::CreateFrameNode("overlayNode", nodeId, AceType::MakeRefPtr<Pattern>(), true);
330     FRAME_NODE2->SetOverlayNode(overlayNode);
331     FRAME_NODE2->RebuildRenderContextTree();
332     EXPECT_FALSE(FRAME_NODE2->needSyncRenderTree_);
333 
334     FRAME_NODE2->OnMountToParentDone();
335 
336     FRAME_NODE2->FlushUpdateAndMarkDirty();
337 
338     std::list<RefPtr<FrameNode>> visibleList;
339     FRAME_NODE2->isActive_ = true;
340     FRAME_NODE2->OnGenerateOneDepthVisibleFrame(visibleList);
341     EXPECT_TRUE(FRAME_NODE2->IsVisible());
342 
343     FRAME_NODE2->OnGenerateOneDepthAllFrame(visibleList);
344     EXPECT_EQ(visibleList.size(), 2);
345 
346     auto pattern = FRAME_NODE2->GetPattern();
347     EXPECT_EQ(pattern, 1);
348 
349     auto atomicNode = FRAME_NODE2->IsAtomicNode();
350     EXPECT_TRUE(atomicNode);
351 
352     auto hitTestMode = FRAME_NODE2->GetHitTestMode();
353     EXPECT_EQ(hitTestMode, HitTestMode::HTMDEFAULT);
354 
355     auto touchable = FRAME_NODE2->GetTouchable();
356     EXPECT_TRUE(touchable);
357 
358     const PointF globalPoint;
359     const PointF parentLocalPoint;
360     MouseTestResult onMouseResult;
361     MouseTestResult onHoverResult;
362     RefPtr<FrameNode> hoverNode;
363     auto mouse = FRAME_NODE2->MouseTest(globalPoint, parentLocalPoint, onMouseResult, onHoverResult, hoverNode);
364     EXPECT_EQ(mouse, HitTestResult::BUBBLING);
365 }
366 
367 /**
368  * @tc.name: FrameNodeTestNg006
369  * @tc.desc: Test frame node method
370  * @tc.type: FUNC
371  */
372 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg006, TestSize.Level1)
373 {
374     /**
375      * @tc.steps: step1. callback function.
376      * @tc.expected: expect The function is run ok.
377      */
378     FRAME_NODE2->OnWindowShow();
379     FRAME_NODE2->OnWindowHide();
380     FRAME_NODE2->OnWindowFocused();
381     FRAME_NODE2->OnWindowUnfocused();
382     FRAME_NODE2->OnWindowSizeChanged(1, 1, WindowSizeChangeReason::CUSTOM_ANIMATION);
383 
384     OffsetF Offset = { 0, 0 };
385     FRAME_NODE2->SetParent(FRAME_NODE3);
386     auto relativeOffset = FRAME_NODE2->GetTransformRelativeOffset();
387     EXPECT_EQ(relativeOffset, Offset);
388 
389     FRAME_NODE2->SetParent(FRAME_NODE3);
390     auto rectOffset = FRAME_NODE2->GetPaintRectOffset(true);
391     EXPECT_EQ(rectOffset, Offset);
392 
393     FRAME_NODE2->OnNotifyMemoryLevel(true);
394 
395     auto childrenCount = FRAME_NODE2->GetAllDepthChildrenCount();
396     EXPECT_EQ(childrenCount, 1);
397 
398     DimensionRect dimensionRect;
399     FRAME_NODE2->AddHotZoneRect(dimensionRect);
400     FRAME_NODE2->RemoveLastHotZoneRect();
401     EXPECT_NE(FRAME_NODE2->GetEventHub<EventHub>(), nullptr);
402 
403     FRAME_NODE->ProcessOffscreenNode(FRAME_NODE3);
404     FRAME_NODE->GetTransformRectRelativeToWindow();
405     FRAME_NODE->GetPaintRectOffsetToStage();
406 
407     float x = 1.0;
408     float y = 1.0;
409     auto Position = FRAME_NODE->FindChildByPosition(x, y);
410     EXPECT_EQ(Position, nullptr);
411 
412     FRAME_NODE->ProvideRestoreInfo();
413     auto immediately = FRAME_NODE->RemoveImmediately();
414     EXPECT_TRUE(immediately);
415 }
416 
417 /**
418  * @tc.name: FrameNodeTestNg_DumpInfo006
419  * @tc.desc: Test frame node method
420  * @tc.type: FUNC
421  */
422 HWTEST_F(FrameNodeTestNg, FrameNodeDumpInfo006, TestSize.Level1)
423 {
424     /**
425      * @tc.steps: step1. callback DumpInfo
426      * @tc.expected: expect The function is run ok.
427      */
428     LayoutProperty layoutProperty;
429     FRAME_NODE->DumpInfo();
430 
431     FRAME_NODE->layoutProperty_->UpdatePadding(PaddingPropertyT<CalcLength>());
432     FRAME_NODE->layoutProperty_->GetPaddingProperty();
433     FRAME_NODE->DumpInfo();
434     EXPECT_EQ(layoutProperty.padding_, nullptr);
435 
436     FRAME_NODE->layoutProperty_->UpdateMargin(PaddingProperty());
437     FRAME_NODE->layoutProperty_->GetMarginProperty();
438     FRAME_NODE->DumpInfo();
439     EXPECT_EQ(layoutProperty.margin_, nullptr);
440 
441     FRAME_NODE->layoutProperty_->UpdateBorderWidth(BorderWidthPropertyT<Dimension>());
442     FRAME_NODE->layoutProperty_->GetBorderWidthProperty();
443     FRAME_NODE->DumpInfo();
444     EXPECT_EQ(layoutProperty.borderWidth_, nullptr);
445 
446     /**
447      * @tc.steps: step2. set layoutConstraintF_ an geometryNode_'sParentLayoutConstraint
448                 and call DumpInfo
449      * @tc.expected: expect The function is run ok.
450      */
451     FRAME_NODE->layoutProperty_->calcLayoutConstraint_ = std::make_unique<MeasureProperty>();
452     auto layoutConstraintF_ = LayoutConstraintF();
453     FRAME_NODE->geometryNode_->SetParentLayoutConstraint(layoutConstraintF_);
454     FRAME_NODE->DumpInfo();
455     EXPECT_EQ(layoutProperty.calcLayoutConstraint_, nullptr);
456 }
457 
458 /**
459  * @tc.name: FrameNodeTestNg_ToJsonValue007
460  * @tc.desc: Test frame node method
461  * @tc.type: FUNC
462  */
463 HWTEST_F(FrameNodeTestNg, FrameNodeToJsonValue007, TestSize.Level1)
464 {
465     /**
466      * @tc.steps: step1. build a object to jsonValue
467      * @tc.expected: expect The function is run ok.
468      */
469     auto gestureEventHub = FRAME_NODE->GetOrCreateGestureEventHub();
470 
471     std::vector<DimensionRect> responseRegion;
472     responseRegion.push_back(DimensionRect());
473     gestureEventHub->SetResponseRegion(responseRegion);
474 
475     auto jsonValue = JsonUtil::Create(true);
476     FRAME_NODE->ToJsonValue(jsonValue, filter);
477     EXPECT_TRUE(jsonValue);
478 
479     /**
480      * @tc.steps: step2. build a object to jsonValue and call FromJson
481      * @tc.expected: expect The function is run ok.
482      */
483     FRAME_NODE->FromJson(jsonValue);
484     FRAME_NODE->renderContext_ = nullptr;
485     FRAME_NODE->focusHub_ = nullptr;
486     auto jsonValue2 = JsonUtil::Create(true);
487     FRAME_NODE->ToJsonValue(jsonValue2, filter);
488     FRAME_NODE->FromJson(jsonValue2);
489     EXPECT_TRUE(jsonValue2);
490 }
491 
492 /**
493  * @tc.name: FrameNodeTestNg_OnAttachToMainTree008
494  * @tc.desc: Test frame node method
495  * @tc.type: FUNC
496  */
497 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree008, TestSize.Level1)
498 {
499     /**
500      * @tc.steps: step1. build a object to OnAttachToMainTree
501      * @tc.expected: expect The function is run ok.
502      */
503     FRAME_NODE2->OnAttachToMainTree(true);
504 
505     auto request = FRAME_NODE2->hasPendingRequest_ = true;
506     FRAME_NODE2->OnAttachToMainTree(true);
507     EXPECT_TRUE(request);
508 
509     /**
510      * @tc.steps: step2 set PositionProperty of FRAME_NODE2 and call OnAttachToMainTree
511      * @tc.expected: expect The function is run ok.
512      */
513     auto& posProperty = FRAME_NODE2->renderContext_->GetOrCreatePositionProperty();
514     posProperty->UpdateOffset(OffsetT<Dimension>()); // OffsetT<Dimension>
515     FRAME_NODE2->SetParent(FRAME_NODE_PARENT);
516     auto testNode_ = TestNode::CreateTestNode(100);
517     FRAME_NODE_PARENT->SetParent(testNode_);
518     FRAME_NODE2->OnAttachToMainTree(true);
519     EXPECT_TRUE(request);
520 }
521 
522 /**
523  * @tc.name: FrameNodeTestNg_NotifyVisibleChange009
524  * @tc.desc: Test frame node method
525  * @tc.type: FUNC
526  */
527 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyVisibleChange009, TestSize.Level1)
528 {
529     /**
530      * @tc.steps: step1. build a object to NotifyVisibleChange
531      * @tc.expected: expect The FRAME_NODE2 is not nullptr.
532      */
533     FRAME_NODE2->AddChild(FRAME_NODE3);
534     FRAME_NODE2->NotifyVisibleChange(VisibleType::VISIBLE, VisibleType::INVISIBLE);
535     FRAME_NODE2->Clean();
536     EXPECT_NE(FRAME_NODE2, nullptr);
537 }
538 
539 /**
540  * @tc.name: FrameNodeTestNg_SwapDirtyLayoutWrapperOnMainThread0010
541  * @tc.desc: Test frame node method
542  * @tc.type: FUNC
543  */
544 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread0010, TestSize.Level1)
545 {
546     /**
547      * @tc.steps: step1. build a object to SwapDirtyLayoutWrapperOnMainThread
548      */
549     RefPtr<LayoutWrapper> layoutWrapper = FRAME_NODE2->CreateLayoutWrapper(true, true);
550 
551     /**
552      * @tc.steps: step2. callback SwapDirtyLayoutWrapperOnMainThread
553      * @tc.expected: expect layoutWrapper is not nullptr.
554      */
555     FRAME_NODE2->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
556     EXPECT_NE(layoutWrapper, nullptr);
557     layoutWrapper->SetActive(true);
558     auto test = FRAME_NODE2->IsActive();
559 
560     /**
561      * @tc.steps: step3. callback SwapDirtyLayoutWrapperOnMainThread
562      * @tc.expected: expect isActive_ is false.
563      */
564     FRAME_NODE2->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
565     EXPECT_TRUE(test);
566 }
567 
568 /**
569  * @tc.name: FrameNodeTestNg_AdjustGridOffset0011
570  * @tc.desc: Test frame node method
571  * @tc.type: FUNC
572  */
573 HWTEST_F(FrameNodeTestNg, FrameNodeAdjustGridOffset0011, TestSize.Level1)
574 {
575     /**
576      * @tc.steps: step1. build a object to AdjustGridOffset
577      * @tc.expected: expect active is true.
578      */
579     FRAME_NODE2->SetActive(true);
580     bool active = FRAME_NODE2->IsActive();
581     FRAME_NODE2->AdjustGridOffset();
582     EXPECT_TRUE(active);
583 
584     FRAME_NODE2->SetParent(FRAME_NODE_PARENT);
585     FRAME_NODE2->GetAncestorNodeOfFrame(false);
586 
587     FRAME_NODE2->SetActive(false);
588 
589     /**
590      * @tc.steps: step2. build a object to AdjustGridOffset
591      * @tc.expected: expect active1 is false.
592      */
593     bool active1 = FRAME_NODE2->IsActive();
594     FRAME_NODE2->AdjustGridOffset();
595     EXPECT_FALSE(active1);
596 }
597 
598 /**
599  * @tc.name: FrameNodeTestNg_SetOnAreaChangeCallback0012
600  * @tc.desc: Test frame node method
601  * @tc.type: FUNC
602  */
603 HWTEST_F(FrameNodeTestNg, FrameNodeSetOnAreaChangeCallback0012, TestSize.Level1)
604 {
605     /**
606      * @tc.steps: step1. build a object to SetOnAreaChangeCallback
607      * @tc.expected: expect The function is run ok.
608      */
609     OnAreaChangedFunc callback = [](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon6a214d5b0502(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 610                                      const OffsetF& origin) {};
611     FRAME_NODE2->SetOnAreaChangeCallback(std::move(callback));
612     EXPECT_NE(FRAME_NODE2->lastFrameRect_, nullptr);
613     EXPECT_NE(FRAME_NODE2->lastParentOffsetToWindow_, nullptr);
614 
615     /**
616      * @tc.steps: step2.test while callback is nullptr
617      * @tc.expected:expect The function is run ok.
618      */
619     FRAME_NODE2->lastFrameRect_ = nullptr;
620     FRAME_NODE2->lastParentOffsetToWindow_ = nullptr;
621     FRAME_NODE2->SetOnAreaChangeCallback(nullptr);
622     EXPECT_NE(FRAME_NODE2->lastFrameRect_, nullptr);
623     EXPECT_NE(FRAME_NODE2->lastParentOffsetToWindow_, nullptr);
624 }
625 
626 /**
627  * @tc.name: FrameNodeTestNg_TriggerOnAreaChangeCallback0013
628  * @tc.desc: Test frame node method
629  * @tc.type: FUNC
630  */
631 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback0013, TestSize.Level1)
632 {
633     /**
634      * @tc.steps: step1. set a flag and init a callback(onAreaChanged)
635      */
636     bool flag = false;
637     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon6a214d5b0602(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 638                                           const OffsetF& origin) { flag = !flag; };
639 
640     /**
641      * @tc.steps: step2. call TriggerOnAreaChangeCallback before set callback
642      * @tc.expected: expect flag is still false
643      */
644     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_1);
645     EXPECT_FALSE(flag);
646 
647     /**
648      * @tc.steps: step3.set callback and release lastParentOffsetToWindow_
649      * @tc.expected: expect flag is still false
650      */
651     FRAME_NODE2->GetEventHub<EventHub>()->SetOnAreaChanged(std::move(onAreaChanged));
652     FRAME_NODE2->lastParentOffsetToWindow_ = nullptr;
653     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_2);
654     EXPECT_FALSE(flag);
655 
656     /**
657      * @tc.steps: step4. release lastFrameRect_
658      * @tc.expected: expect flag is still false
659      */
660     FRAME_NODE2->lastFrameRect_ = nullptr;
661     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_3);
662     EXPECT_FALSE(flag);
663 
664     /**
665      * @tc.steps: step5.set lastParentOffsetToWindow_ and lastFrameRect_
666      * @tc.expected: expect flag is still false
667      */
668     FRAME_NODE2->lastParentOffsetToWindow_ = std::make_unique<OffsetF>();
669     FRAME_NODE2->lastFrameRect_ = std::make_unique<RectF>();
670     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_4);
671     EXPECT_FALSE(flag);
672 }
673 
674 /**
675  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback0014
676  * @tc.desc: Test frame node method
677  * @tc.type: FUNC
678  */
679 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback0014, TestSize.Level1)
680 {
681     /**
682      * @tc.steps: step1. build a object to TriggerVisibleAreaChangeCallback
683      * @tc.expected: expect The function is run ok.
684      */
685     VisibleCallbackInfo callbackInfo;
686     FRAME_NODE2->SetVisibleAreaUserCallback({ 0.0f }, callbackInfo);
687     FRAME_NODE2->TriggerVisibleAreaChangeCallback(1);
688 
689     /**
690      * @tc.steps: step2. callback SetParent
691      * @tc.expected: expect parent is same with parentNode.
692      */
693     auto parentNode = AceType::MakeRefPtr<FrameNode>("test", -1, AceType::MakeRefPtr<Pattern>(), false);
694     FRAME_NODE2->SetParent(FRAME_NODE3);
695     FRAME_NODE2->TriggerVisibleAreaChangeCallback(2);
696     auto parent = FRAME_NODE2->GetParent();
697     EXPECT_EQ(parent, 1);
698 
699     auto parentNode1 = FrameNode::CreateFrameNode("parent", 2, AceType::MakeRefPtr<Pattern>());
700     RefPtr<FrameNode> frameNodes[3] = { parentNode1, nullptr, nullptr };
701     FRAME_NODE2->TriggerVisibleAreaChangeCallback(3);
702     auto parent1 = FRAME_NODE2->GetParent();
703     EXPECT_EQ(parent1, 1);
704 
705     FRAME_NODE2->lastVisibleRatio_ = 1.0;
706     FRAME_NODE2->TriggerVisibleAreaChangeCallback(4);
707 
708     /**
709      * @tc.steps: step3. set onShow_ and call TriggerVisibleAreaChangeCallback
710      * @tc.expected: expect GetOnShow is true and lastVisibleRatio_ is zero.
711      */
712     auto context = PipelineContext::GetCurrentContext();
713     context->onShow_ = true;
714     FRAME_NODE2->TriggerVisibleAreaChangeCallback(5);
715     auto testNode_ = TestNode::CreateTestNode(101);
716     FRAME_NODE3->SetParent(testNode_);
717     FRAME_NODE3->isActive_ = true;
718     FRAME_NODE2->TriggerVisibleAreaChangeCallback(6);
719     FRAME_NODE3->layoutProperty_->UpdateVisibility(VisibleType::INVISIBLE);
720     FRAME_NODE2->layoutProperty_->UpdateVisibility(VisibleType::VISIBLE);
721     FRAME_NODE2->isActive_ = true;
722     FRAME_NODE2->TriggerVisibleAreaChangeCallback(7);
723     FRAME_NODE3->layoutProperty_->UpdateVisibility(VisibleType::VISIBLE);
724     FRAME_NODE2->TriggerVisibleAreaChangeCallback(8);
725     EXPECT_TRUE(context->GetOnShow());
726     EXPECT_EQ(FRAME_NODE2->lastVisibleRatio_, 1);
727 }
728 
729 /**
730  * @tc.name: FrameNodeTestNg_CreateLayoutTask0015
731  * @tc.desc: Test frame node method
732  * @tc.type: FUNC
733  */
734 HWTEST_F(FrameNodeTestNg, FrameNodeCreateLayoutTask0015, TestSize.Level1)
735 {
736     /**
737      * @tc.steps: step1. build a object to CreateLayoutTask
738      * @tc.expected: expect The function is run ok.
739      */
740     FRAME_NODE2->isLayoutDirtyMarked_ = true;
741     FRAME_NODE2->CreateLayoutTask(true);
742     EXPECT_FALSE(FRAME_NODE2->isLayoutDirtyMarked_);
743 
744     FRAME_NODE2->CreateLayoutTask(true);
745 
746     FRAME_NODE2->isLayoutDirtyMarked_ = true;
747     FRAME_NODE2->CreateLayoutTask(false);
748     EXPECT_FALSE(FRAME_NODE2->isLayoutDirtyMarked_);
749 }
750 
751 /**
752  * @tc.name: FrameNodeTestNg_CreateRenderTask0016
753  * @tc.desc: Test frame node method
754  * @tc.type: FUNC
755  */
756 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask0016, TestSize.Level1)
757 {
758     /**
759      * @tc.steps: step1. build a object to CreateRenderTask
760      * @tc.expected: expect The isRenderDirtyMarked_ is false.
761      */
762     FRAME_NODE2->isRenderDirtyMarked_ = true;
763     FRAME_NODE2->CreateRenderTask(true);
764     EXPECT_FALSE(FRAME_NODE2->isRenderDirtyMarked_);
765 
766     FRAME_NODE2->isRenderDirtyMarked_ = true;
767     FRAME_NODE2->CreateRenderTask(false);
768 
769     FRAME_NODE2->CreateRenderTask(true);
770     EXPECT_FALSE(FRAME_NODE2->isRenderDirtyMarked_);
771 }
772 
773 /**
774  * @tc.name: FrameNodeTestNg_UpdateLayoutPropertyFlag0018
775  * @tc.desc: Test frame node method
776  * @tc.type: FUNC
777  */
778 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutPropertyFlag0018, TestSize.Level1)
779 {
780     /**
781      * @tc.steps: step1.call back UpdateLayoutPropertyFlag.
782      * @tc.expected: expect selfFlag is same with PROPERTY_UPDATE_BY_CHILD_REQUEST.
783      */
784     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
785     auto selfFlag = FRAME_NODE2->layoutProperty_->GetPropertyChangeFlag();
786     FRAME_NODE2->UpdateLayoutPropertyFlag();
787     EXPECT_EQ(selfFlag, PROPERTY_UPDATE_BY_CHILD_REQUEST);
788 
789     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
790     FRAME_NODE2->AddChild(FRAME_NODE3);
791     FRAME_NODE2->UpdateLayoutPropertyFlag();
792     FRAME_NODE2->Clean();
793 }
794 
795 /**
796  * @tc.name: FrameNodeTestNg_UpdateChildrenLayoutWrapper0019
797  * @tc.desc: Test frame node method
798  * @tc.type: FUNC
799  */
800 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateChildrenLayoutWrapper0019, TestSize.Level1)
801 {
802     /**
803      * @tc.steps: step1. AddChild for FRAME_NODE2 and callback UpdateChildrenLayoutWrapper.
804      * @tc.expected: expect The UpdateLayoutWrapper is true.
805      */
806     FRAME_NODE2->AddChild(FRAME_NODE3);
807     FRAME_NODE2->UpdateChildrenLayoutWrapper(FRAME_NODE2->UpdateLayoutWrapper(nullptr, true, true), true, true);
808     FRAME_NODE2->Clean();
809     EXPECT_TRUE(FRAME_NODE2->UpdateLayoutWrapper(nullptr, true, true));
810 }
811 
812 /**
813  * @tc.name: FrameNodeTestNg_MarkModifyDone0021
814  * @tc.desc: Test frame node method
815  * @tc.type: FUNC
816  */
817 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone0021, TestSize.Level1)
818 {
819     /**
820      * @tc.steps: step1. build a object to MarkModifyDone.
821      * @tc.expected:expect The function is run ok.
822      */
823     FRAME_NODE2->MarkModifyDone();
824     EXPECT_TRUE(FRAME_NODE2->isRestoreInfoUsed_);
825     FRAME_NODE2->isRestoreInfoUsed_ = true;
826     FRAME_NODE2->MarkModifyDone();
827     EXPECT_TRUE(FRAME_NODE2->isRestoreInfoUsed_);
828 }
829 
830 /**
831  * @tc.name: FrameNodeTestNg_MarkNeedRender0022
832  * @tc.desc: Test frame node method
833  * @tc.type: FUNC
834  */
835 HWTEST_F(FrameNodeTestNg, FrameNodeMarkNeedRender0022, TestSize.Level1)
836 {
837     /**
838      * @tc.steps: step1. callback MarkNeedRenderOnly.
839      * @tc.expected: expect The function is run ok.
840      */
841     FRAME_NODE2->MarkNeedRenderOnly();
842     auto test = FRAME_NODE2->isRenderDirtyMarked_ = false;
843     auto test1 = FRAME_NODE2->isLayoutDirtyMarked_ = false;
844     FRAME_NODE2->MarkNeedRender(false);
845     FRAME_NODE2->MarkNeedRender(true);
846     EXPECT_FALSE(test);
847     EXPECT_FALSE(test1);
848 }
849 
850 /**
851  * @tc.name: FrameNodeTestNg_IsNeedRequestParentMeasure0023
852  * @tc.desc: Test frame node method
853  * @tc.type: FUNC
854  */
855 HWTEST_F(FrameNodeTestNg, FrameNodeIsNeedRequestParentMeasure0023, TestSize.Level1)
856 {
857     /**
858      * @tc.steps: step1. callback IsNeedRequestParentMeasure.
859      * @tc.expected: expect The function return value is true.
860      */
861     auto test = FRAME_NODE2->IsNeedRequestParentMeasure();
862     EXPECT_TRUE(test);
863 
864     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
865     FRAME_NODE2->IsNeedRequestParentMeasure();
866 
867     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
868     FRAME_NODE2->layoutProperty_->calcLayoutConstraint_ = std::make_unique<MeasureProperty>();
869     auto test1 = FRAME_NODE2->IsNeedRequestParentMeasure();
870     EXPECT_TRUE(test1);
871 }
872 
873 /**
874  * @tc.name: FrameNodeTestNg_OnGenerateOneDepthVisibleFrameWithTransition0024
875  * @tc.desc: Test frame node method
876  * @tc.type: FUNC
877  */
878 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrameWithTransition0024, TestSize.Level1)
879 {
880     /**
881      * @tc.steps: step1. callback OnGenerateOneDepthVisibleFrameWithTransition.
882      * @tc.expected: expect The function is run ok.
883      */
884     std::list<RefPtr<FrameNode>> visibleList;
885     FRAME_NODE2->OnGenerateOneDepthVisibleFrameWithTransition(visibleList);
886 
887     /**
888      * @tc.steps: step2.push the framenode to visibleList and callback OnGenerateOneDepthVisibleFrameWithTransition
889      * @tc.expected: expect visibleList.size is 3.
890      */
891     visibleList.push_back(FRAME_NODE);
892     FRAME_NODE3->OnGenerateOneDepthVisibleFrameWithTransition(visibleList);
893     EXPECT_EQ(visibleList.size(), 3);
894 }
895 
896 /**
897  * @tc.name: FrameNodeTestNg_IsOutOfTouchTestRegion0025
898  * @tc.desc: Test frame node method
899  * @tc.type: FUNC
900  */
901 HWTEST_F(FrameNodeTestNg, FrameNodeIsOutOfTouchTestRegion0025, TestSize.Level1)
902 {
903     /**
904      * @tc.steps: step1. callback IsOutOfTouchTestRegion.
905      * @tc.expected: expect The function return value is true.
906      */
907     PointF pointF;
908     std::vector<RectF> rectF;
909     TouchEvent touchEvent;
910     auto test = FRAME_NODE2->IsOutOfTouchTestRegion(std::move(pointF), touchEvent);
911     EXPECT_TRUE(test);
912 
913     auto test1 = FRAME_NODE2->InResponseRegionList(pointF, rectF);
914     auto test2 = FRAME_NODE2->IsOutOfTouchTestRegion(std::move(pointF), touchEvent);
915     EXPECT_FALSE(test1);
916     EXPECT_TRUE(test2);
917 }
918 
919 /**
920  * @tc.name: FrameNodeTestNg_TouchTest0026
921  * @tc.desc: Test frame node method
922  * @tc.type: FUNC
923  */
924 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest0026, TestSize.Level1)
925 {
926     /**
927      * @tc.steps: step1. callback TouchTest.
928      * @tc.expected: expect The function return value is true.
929      */
930     PointF globalPoint;
931     PointF parentLocalPoint;
932     TouchRestrict touchRestrict;
933     TouchTestResult result;
934     ResponseLinkResult responseLinkResult;
935     SystemProperties::debugEnabled_ = true;
936     FRAME_NODE2->TouchTest(
937         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
938 
939     SystemProperties::debugEnabled_ = false;
940     FRAME_NODE2->TouchTest(
941         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
942 
943     /**
944      * @tc.steps: step2. set isActive_ and IsEnabled is false.
945      * @tc.expected: expect The function return value is OUT_OF_REGION.
946      */
947     FRAME_NODE2->isActive_ = false;
948     FRAME_NODE2->GetEventHub<EventHub>()->SetEnabled(false);
949     auto test = FRAME_NODE2->TouchTest(
950         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
951     EXPECT_EQ(test, HitTestResult::OUT_OF_REGION);
952 }
953 
954 /**
955  * @tc.name: FrameNodeTestNg_AxisTest0027
956  * @tc.desc: Test frame node method
957  * @tc.type: FUNC
958  */
959 HWTEST_F(FrameNodeTestNg, FrameNodeAxisTest0027, TestSize.Level1)
960 {
961     /**
962      * @tc.steps: step1. callback AxisTest.
963      * @tc.expected: expect inputEventHub_ is run not null.
964      */
965     const PointF globalPoint;
966     const PointF parentLocalPoint;
967     const PointF parentRevertPoint;
968     TouchRestrict touchRestrict;
969     AxisTestResult onAxisResult;
970     FRAME_NODE2->GetEventHub<EventHub>()->GetOrCreateInputEventHub();
971     FRAME_NODE2->AxisTest(globalPoint, parentLocalPoint, parentRevertPoint, touchRestrict, onAxisResult);
972     EXPECT_NE(FRAME_NODE2->GetEventHub<EventHub>()->inputEventHub_, nullptr);
973 }
974 
975 /**
976  * @tc.name: FrameNodeTestNg0028
977  * @tc.desc: Test frame node method
978  * @tc.type: FUNC
979  */
980 HWTEST_F(FrameNodeTestNg, FrameNodeOnAccessibilityEvent0028, TestSize.Level1)
981 {
982     /**
983      * @tc.steps: step1. callback OnAccessibilityEvent.
984      * @tc.expected: expect The function is true.
985      */
986     auto test = AceApplicationInfo::GetInstance().isAccessibilityEnabled_ = true;
987     FRAME_NODE2->OnAccessibilityEvent(
988         AccessibilityEventType::CHANGE, WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
989     FRAME_NODE2->OnAccessibilityEvent(AccessibilityEventType::TEXT_CHANGE, "", "");
990     EXPECT_TRUE(test);
991 
992     /**
993      * @tc.steps: step2. callback OnAccessibilityEvent.
994      * @tc.expected: expect The function is false.
995      */
996     auto test1 = AceApplicationInfo::GetInstance().isAccessibilityEnabled_ = false;
997     FRAME_NODE2->OnAccessibilityEvent(AccessibilityEventType::ACCESSIBILITY_FOCUSED);
998     EXPECT_FALSE(test1);
999 }
1000 
1001 /**
1002  * @tc.name: FrameNodeTestNg0029
1003  * @tc.desc: Test frame node method
1004  * @tc.type: FUNC
1005  */
1006 HWTEST_F(FrameNodeTestNg, FrameNodeOnAccessibilityEventForVirtualNode0029, TestSize.Level1)
1007 {
1008     /**
1009      * @tc.steps: step1. callback OnAccessibilityEventForVirtualNode.
1010      * @tc.expected: expect The function is true.
1011      */
1012     AccessibilityEvent event;
1013     auto accessibilityId = 1;
1014     auto test = AceApplicationInfo::GetInstance().isAccessibilityEnabled_ = true;
1015     FRAME_NODE2->OnAccessibilityEventForVirtualNode(AccessibilityEventType::CHANGE, accessibilityId);
1016     EXPECT_TRUE(test);
1017 
1018     /**
1019      * @tc.steps: step2. callback OnAccessibilityEventForVirtualNode.
1020      * @tc.expected: expect The function is false.
1021      */
1022     auto test1 = AceApplicationInfo::GetInstance().isAccessibilityEnabled_ = false;
1023     FRAME_NODE2->OnAccessibilityEventForVirtualNode(AccessibilityEventType::FOCUS, accessibilityId);
1024     EXPECT_FALSE(test1);
1025 }
1026 
1027 /**
1028  * @tc.name: FrameNodeTestNg_MarkRemoving0029
1029  * @tc.desc: Test frame node method
1030  * @tc.type: FUNC
1031  */
1032 HWTEST_F(FrameNodeTestNg, FrameNodeMarkRemoving0029, TestSize.Level1)
1033 {
1034     /**
1035      * @tc.steps: step1. callback MarkRemoving.
1036      * @tc.expected: expect The function return value is true.
1037      */
1038     FRAME_NODE2->SetParent(FRAME_NODE_PARENT);
1039     FRAME_NODE2->AddChild(FRAME_NODE3);
1040     FRAME_NODE2->layoutProperty_->UpdateGeometryTransition("id");
1041     auto mark = FRAME_NODE2->MarkRemoving();
1042     FRAME_NODE2->Clean();
1043     EXPECT_TRUE(mark);
1044 
1045     FRAME_NODE2->layoutProperty_ = nullptr;
1046     auto mark1 = FRAME_NODE2->MarkRemoving();
1047     EXPECT_FALSE(mark1);
1048 }
1049 
1050 /**
1051  * @tc.name: FrameNodeTestNg_CalculateCurrentVisibleRatio0030
1052  * @tc.desc: Test frame node method
1053  * @tc.type: FUNC
1054  */
1055 HWTEST_F(FrameNodeTestNg, FrameNodeCalculateCurrentVisibleRatio0030, TestSize.Level1)
1056 {
1057     /**
1058      * @tc.steps: step1. callback RemoveLastHotZoneRect.
1059      * @tc.expected: step1. expect The function is run ok.
1060      */
1061     RectF visibleRect;
1062     RectF renderRect;
1063     FRAME_NODE2->CalculateCurrentVisibleRatio(visibleRect, renderRect);
1064     EXPECT_EQ(visibleRect.Width(), 0);
1065     EXPECT_EQ(renderRect.Width(), 0);
1066 
1067     /**
1068      * @tc.steps: step2. set wrong value and call CalculateCurrentVisibleRatio
1069      * @tc.expected: expect The function returns 0.
1070      */
1071     renderRect.SetWidth(-1);
1072     EXPECT_EQ(FRAME_NODE2->CalculateCurrentVisibleRatio(visibleRect, renderRect), 0);
1073     visibleRect.SetWidth(-1);
1074     EXPECT_EQ(FRAME_NODE2->CalculateCurrentVisibleRatio(visibleRect, renderRect), 0);
1075 }
1076 
1077 /**
1078  * @tc.name: FrameNodeTestNg_InitializePatternAndContext0032
1079  * @tc.desc: Test InitializePatternAndContext
1080  * @tc.type: FUNC
1081  */
1082 HWTEST_F(FrameNodeTestNg, FrameNodeInitializePatternAndContext0032, TestSize.Level1)
1083 {
1084     /**
1085      * @tc.steps: step1. create a node and set onMainTree_=false, then call InitializePatternAndContext
1086             and trigger the callback
1087      * @tc.expected: hasPendingRequest_ is true
1088      */
__anon6a214d5b0702() 1089     auto one = FrameNode::GetOrCreateFrameNode("one", 11, []() { return AceType::MakeRefPtr<Pattern>(); });
1090     one->onMainTree_ = false;
1091     one->InitializePatternAndContext();
1092     auto renderContext_ = one->renderContext_;
1093     renderContext_->RequestNextFrame();
1094     EXPECT_TRUE(one->hasPendingRequest_);
1095 }
1096 
1097 /**
1098  * @tc.name: FrameNodeTestNg_ProcessAllVisibleCallback0033
1099  * @tc.desc: Test ProcessAllVisibleCallback
1100  * @tc.type: FUNC
1101  */
1102 HWTEST_F(FrameNodeTestNg, FrameNodeProcessAllVisibleCallback0033, TestSize.Level1)
1103 {
1104     /**
1105      * @tc.steps: step1. create a node and init a vector for preparing for args, then set a flag
1106      */
__anon6a214d5b0802() 1107     auto one = FrameNode::GetOrCreateFrameNode("one", 11, []() { return AceType::MakeRefPtr<Pattern>(); });
1108     std::vector<double> visibleAreaRatios { 0.2, 0.8, 0.21, 0.79, 0.5 };
1109     int flag = 0;
__anon6a214d5b0902(bool input1, double input2) 1110     auto defaultCallback = [&flag](bool input1, double input2) { flag += 1; };
1111     VisibleCallbackInfo callbackInfo { defaultCallback, 1.0, false };
1112 
1113     /**
1114      * @tc.steps: step2. call ProcessAllVisibleCallback with 0.5 from 0
1115      * @tc.expected: flag is 1
1116      */
1117     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 0.5, 0);
1118     EXPECT_EQ(flag, 1);
1119 
1120     /**
1121      * @tc.steps: step3. call ProcessAllVisibleCallback with 0 from 0.5
1122      * @tc.expected: flag is 2
1123      */
1124     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 0, 0.5);
1125     EXPECT_EQ(flag, 2);
1126 
1127     /**
1128      * @tc.steps: step4. call ProcessAllVisibleCallback with 0 from 0
1129      * @tc.expected: flag is 2
1130      */
1131     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 0, 0);
1132     EXPECT_EQ(flag, 2);
1133 
1134     /**
1135      * @tc.steps: step5. call ProcessAllVisibleCallback with 1 from 0
1136      * @tc.expected: flag is 3
1137      */
1138     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 1, 0);
1139     EXPECT_EQ(flag, 3);
1140 
1141     /**
1142      * @tc.steps: step6. call ProcessAllVisibleCallback with 1 from 1
1143      * @tc.expected: flag is 3
1144      */
1145     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 1, 1);
1146     EXPECT_EQ(flag, 3);
1147 }
1148 
1149 /**
1150  * @tc.name: FrameNodeTestNg_AnimateHoverEffect0034
1151  * @tc.desc: Test AnimateHoverEffect
1152  * @tc.type: FUNC
1153  */
1154 HWTEST_F(FrameNodeTestNg, FrameNodeAnimateHoverEffect0034, TestSize.Level1)
1155 {
1156     /**
1157      * @tc.steps: step1. create a frame node and release inputEventHub_, then
1158             change hoverEffectType_ and call AnimateHoverEffect
1159      * @tc.expected: AnimateHoverEffectScale has been called
1160      */
__anon6a214d5b0a02() 1161     auto one = FrameNode::GetOrCreateFrameNode("one", 12, []() { return AceType::MakeRefPtr<Pattern>(); });
1162     one->GetEventHub<EventHub>()->inputEventHub_ = nullptr;
1163     auto renderContext = AceType::DynamicCast<MockRenderContext>(one->renderContext_);
1164     EXPECT_CALL(*renderContext, AnimateHoverEffectScale(_));
1165     one->AnimateHoverEffect(false);
1166     auto inputEventHub = one->GetEventHub<EventHub>()->GetOrCreateInputEventHub();
1167     inputEventHub->hoverEffectType_ = HoverEffectType::UNKNOWN;
1168     one->AnimateHoverEffect(false);
1169     inputEventHub->hoverEffectType_ = HoverEffectType::AUTO;
1170     one->AnimateHoverEffect(false);
1171     inputEventHub->hoverEffectType_ = HoverEffectType::SCALE;
1172     one->AnimateHoverEffect(false);
1173     inputEventHub->hoverEffectType_ = HoverEffectType::BOARD;
1174     one->AnimateHoverEffect(false);
1175     inputEventHub->hoverEffectType_ = HoverEffectType::OPACITY;
1176     one->AnimateHoverEffect(false);
1177     inputEventHub->hoverEffectType_ = HoverEffectType::NONE;
1178     one->AnimateHoverEffect(false);
1179 }
1180 
1181 /**
1182  * @tc.name: FrameNodeTestNg_CreateAnimatablePropertyFloat0035
1183  * @tc.desc: Test AnimateHoverEffect
1184  * @tc.type: FUNC
1185  */
1186 HWTEST_F(FrameNodeTestNg, FrameNodeCreateAnimatablePropertyFloat0035, TestSize.Level1)
1187 {
1188     /**
1189      * @tc.steps: step1. call CreateAnimatablePropertyFloat.
1190      * @tc.expected: expect GetRenderContext is not null.
1191      */
1192     FRAME_NODE->CreateAnimatablePropertyFloat(NAME, value, onCallbackEvent);
1193 
1194     FRAME_NODE->renderContext_ = AceType::MakeRefPtr<MockRenderContext>();
1195     FRAME_NODE->CreateAnimatablePropertyFloat(NAME, value, onCallbackEvent);
1196 
1197     /**
1198      * @tc.steps: step2. put value to map and call CreateAnimatablePropertyFloat.
1199      * @tc.expected: expect iter is not equal map.
1200      */
1201     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("test", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1202     FRAME_NODE->CreateAnimatablePropertyFloat(NAME, value, onCallbackEvent);
1203     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1204     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1205     EXPECT_NE(iter, map);
1206 }
1207 
1208 /**
1209  * @tc.name: FrameNodeTestNg_UpdateAnimatablePropertyFloat0036
1210  * @tc.desc: Test AnimateHoverEffect
1211  * @tc.type: FUNC
1212  */
1213 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateAnimatablePropertyFloat0036, TestSize.Level1)
1214 {
1215     /**
1216      * @tc.steps: step1. call UpdateAnimatablePropertyFloat.
1217      * @tc.expected: expect iter is not equal map.
1218      */
1219     FRAME_NODE->UpdateAnimatablePropertyFloat(NAME, value);
1220     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1221     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("propertyName", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1222     FRAME_NODE->UpdateAnimatablePropertyFloat(NAME, value);
1223     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1224     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1225     EXPECT_NE(iter, map);
1226 
1227     /**
1228      * @tc.steps: step2. call UpdateAnimatablePropertyFloat and clear nodeAnimatablePropertyMap_.
1229      * @tc.expected: expect property is nullptr.
1230      */
1231     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1232     FRAME_NODE->UpdateAnimatablePropertyFloat(NAME, value);
1233     auto property = AceType::DynamicCast<NodeAnimatablePropertyFloat>(iter->second);
1234     EXPECT_EQ(property, nullptr);
1235 }
1236 
1237 /**
1238  * @tc.name: FrameNodeTestNg_CreateAnimatableArithmeticProperty0037
1239  * @tc.desc: Test AnimateHoverEffect
1240  * @tc.type: FUNC
1241  */
1242 HWTEST_F(FrameNodeTestNg, FrameNodeCreateAnimatableArithmeticProperty0037, TestSize.Level1)
1243 {
1244     /**
1245      * @tc.steps: step1. call CreateAnimatableArithmeticProperty.
1246      * @tc.expected: expect iter is not equal map.
1247      */
1248     RefPtr<CustomAnimatableArithmetic> value = AceType::MakeRefPtr<CustomAnimatableArithmetic>();
1249     std::function<void(const RefPtr<NG::CustomAnimatableArithmetic>&)> onCallbackEvent;
1250     FRAME_NODE->CreateAnimatableArithmeticProperty(NAME, value, onCallbackEvent);
1251     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("test", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1252     FRAME_NODE->CreateAnimatableArithmeticProperty(NAME, value, onCallbackEvent);
1253     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1254     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1255     EXPECT_NE(iter, map);
1256 }
1257 
1258 /**
1259  * @tc.name: FrameNodeTestNg_UpdateAnimatableArithmeticProperty0038
1260  * @tc.desc: Test AnimateHoverEffect
1261  * @tc.type: FUNC
1262  */
1263 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateAnimatableArithmeticProperty0038, TestSize.Level1)
1264 {
1265     /**
1266      * @tc.steps: step1. call UpdateAnimatableArithmeticProperty.
1267      * @tc.expected: expect iter is not equal map.
1268      */
1269     RefPtr<CustomAnimatableArithmetic> value = AceType::MakeRefPtr<CustomAnimatableArithmetic>();
1270     FRAME_NODE->UpdateAnimatableArithmeticProperty(NAME, value);
1271     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1272 
1273     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("propertyName", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1274     FRAME_NODE->UpdateAnimatableArithmeticProperty(NAME, value);
1275     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1276     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1277     EXPECT_NE(iter, map);
1278 
1279     /**
1280      * @tc.steps: step2. call UpdateAnimatablePropertyFloat and clear nodeAnimatablePropertyMap_.
1281      * @tc.expected: expect property is nullptr.
1282      */
1283     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1284     FRAME_NODE->UpdateAnimatableArithmeticProperty("", value);
1285     auto property = AceType::DynamicCast<NodeAnimatableArithmeticProperty>(iter->second);
1286     EXPECT_EQ(property, nullptr);
1287 }
1288 
1289 /**
1290  * @tc.name: FrameNodeTestNg0039
1291  * @tc.desc: Test of FrameProxy
1292  * @tc.type: FUNC
1293  */
1294 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg0039, TestSize.Level1)
1295 {
1296     /**
1297      * @tc.steps: step1. creat childNode、create LazyForEachNode
1298      * @tc.expected: childNode is not null
1299      */
1300     auto childNode = FrameNode::CreateFrameNode(
1301         "child", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
1302     auto itemNode = FrameNode::CreateFrameNode(
1303         "itemNode", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
1304     childNode->AddChild(itemNode);
1305     /**
1306      * @tc.steps: step2. call SetIsOverlayNode.
1307      * @tc.expected: change IsOverlayNode().
1308      */
1309     ConfigurationChange configurationChange;
1310     childNode->OnConfigurationUpdate(configurationChange);
1311     configurationChange.languageUpdate = true;
1312     childNode->OnConfigurationUpdate(configurationChange);
1313     configurationChange.colorModeUpdate = true;
1314     childNode->OnConfigurationUpdate(configurationChange);
1315     configurationChange.directionUpdate = true;
1316     childNode->OnConfigurationUpdate(configurationChange);
1317     configurationChange.dpiUpdate = true;
1318     childNode->OnConfigurationUpdate(configurationChange);
1319     configurationChange.fontUpdate = true;
1320     configurationChange.iconUpdate = true;
1321     configurationChange.skinUpdate = true;
1322     configurationChange.fontWeightScaleUpdate = true;
1323     childNode->OnConfigurationUpdate(configurationChange);
1324     configurationChange.fontScaleUpdate = true;
1325     childNode->OnConfigurationUpdate(configurationChange);
1326 
1327     childNode->SetBackgroundLayoutConstraint(itemNode);
1328     childNode->ForceUpdateLayoutPropertyFlag(PROPERTY_UPDATE_MEASURE_SELF);
1329     childNode->GetPaintRectWithTransform();
1330     childNode->GetTransformScale();
1331     childNode->SetJSViewActive(true);
1332     auto layoutProperty = childNode->GetLayoutProperty();
1333     EXPECT_FALSE(layoutProperty->IsOverlayNode());
1334     layoutProperty->SetIsOverlayNode(true);
1335     childNode->DumpOverlayInfo();
1336     EXPECT_TRUE(layoutProperty->IsOverlayNode());
1337 }
1338 
1339 /**
1340  * @tc.name: FrameNodeTestNg_SetOnAreaChangeCallback040
1341  * @tc.desc: Test frame node method
1342  * @tc.type: FUNC
1343  */
1344 HWTEST_F(FrameNodeTestNg, SetOnAreaChangeCallback040, TestSize.Level1)
1345 {
1346     /**
1347      * @tc.steps: step1. build a object to SetOnAreaChangeCallback
1348      * @tc.expected: expect cover branch lastFrameRect_ non null and function is run ok.
1349      */
1350     OnAreaChangedFunc callback = [](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon6a214d5b0b02(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 1351                                      const OffsetF& origin) {};
1352     FRAME_NODE2->lastFrameRect_ = std::make_unique<RectF>();
1353     FRAME_NODE2->SetOnAreaChangeCallback(std::move(callback));
1354     EXPECT_NE(FRAME_NODE2->lastFrameRect_, nullptr);
1355 
1356     /**
1357      * @tc.steps: step2.test while callback is nullptr
1358      * @tc.expected:expect cover branch lastParentOffsetToWindow_ non null and function is run ok.
1359      */
1360 
1361     FRAME_NODE2->lastParentOffsetToWindow_ = std::make_unique<OffsetF>();
1362     FRAME_NODE2->SetOnAreaChangeCallback(nullptr);
1363     EXPECT_NE(FRAME_NODE2->lastParentOffsetToWindow_, nullptr);
1364 }
1365 
1366 /**
1367  * @tc.name: FrameNodeTestNg_SwapDirtyLayoutWrapperOnMainThread040
1368  * @tc.desc: Test frame node method
1369  * @tc.type: FUNC
1370  */
1371 HWTEST_F(FrameNodeTestNg, SwapDirtyLayoutWrapperOnMainThread040, TestSize.Level1)
1372 {
1373     /**
1374      * @tc.steps: step1. creat frameNode and layoutProperty
1375      */
1376     RefPtr<LayoutWrapper> layoutWrapper = FRAME_NODE2->CreateLayoutWrapper(true, true);
1377     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1378     auto layoutProperty = frameNode->GetLayoutProperty<LayoutProperty>();
1379     ASSERT_NE(layoutProperty, nullptr);
1380 
1381     /**
1382      * @tc.steps: step2. setBorderWidth and updateBorderWidth.
1383      * @tc.expected: expect borderWidth property is not nullptr.
1384      */
1385     BorderWidthProperty overCountBorderWidth;
1386     overCountBorderWidth.SetBorderWidth(Dimension(10, DimensionUnit::VP));
1387     layoutProperty->UpdateBorderWidth(overCountBorderWidth);
1388     frameNode->SetLayoutProperty(layoutProperty);
1389 
1390     /**
1391      * @tc.steps: step3. callback SwapDirtyLayoutWrapperOnMainThread
1392      * @tc.expected: expect GetBorderWidthProperty is not nullptr.
1393      */
1394     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
1395     EXPECT_NE(layoutProperty->GetBorderWidthProperty(), nullptr);
1396 
1397     /**
1398      * @tc.steps: step4. updatae layoutConstraint and set eventHub_.
1399      * @tc.expected: expect cover branch eventHub_ non null and function is run ok .
1400      */
1401     auto layoutConstraintF_ = LayoutConstraintF();
1402     layoutConstraintF_.maxSize = CONTAINER_SIZE;
1403     layoutConstraintF_.percentReference = CONTAINER_SIZE;
1404     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF_);
1405     layoutProperty->UpdateLayoutConstraint(layoutConstraintF_);
1406 
1407     frameNode->GetEventHub<EventHub>()->GetOrCreateFocusHub();
1408     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
1409     EXPECT_NE(frameNode->eventHub_, nullptr);
1410 
1411     /**
1412      * @tc.steps: step5. set currentFocus_ is true and call SwapDirtyLayoutWrapperOnMainThread.
1413      * @tc.expected: expect cover branch IsCurrentFocus() is true and function is run ok .
1414      */
1415     frameNode->GetEventHub<EventHub>()->GetOrCreateFocusHub()->currentFocus_ = true;
1416     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
1417     EXPECT_TRUE(frameNode->GetEventHub<EventHub>()->GetOrCreateFocusHub()->IsCurrentFocus());
1418 }
1419 
1420 /**
1421  * @tc.name: FrameNodeTouchTest047
1422  * @tc.desc: Test method GeometryNodeToJsonValue
1423  * @tc.type: FUNC
1424  */
1425 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest047, TestSize.Level1)
1426 {
1427     /**
1428      * @tc.steps: step1. construct parameters.
1429      */
1430     std::unique_ptr<JsonValue> value = JsonUtil::Create(true);
1431 
1432     /**
1433      * @tc.steps: step2. construct parameters.
1434      * @tc.expected: expect cover branch layoutProperty_ is nullptr.
1435      */
1436     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1437     EXPECT_EQ(FRAME_NODE2->layoutProperty_, nullptr);
1438 
1439     /**
1440      * @tc.steps: step3. set layoutProperty_ and call GeometryNodeToJsonValue.
1441      * @tc.expected: expect cover branch layoutProperty_ is not nullptr.
1442      */
1443     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1444     FRAME_NODE2->layoutProperty_ = layoutProperty;
1445     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1446     EXPECT_NE(FRAME_NODE2->layoutProperty_, nullptr);
1447 
1448     /**
1449      * @tc.steps: step4. set calcLayoutConstraint_ and call GeometryNodeToJsonValue.
1450      * @tc.expected: expect cover branch calcLayoutConstraint_ is not nullptr.
1451      */
1452     FRAME_NODE2->layoutProperty_->calcLayoutConstraint_ = std::make_unique<MeasureProperty>();
1453 
1454     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1455     EXPECT_NE(FRAME_NODE2->layoutProperty_->calcLayoutConstraint_, nullptr);
1456 
1457     /**
1458      * @tc.steps: step5. set selfIdealSize and call GeometryNodeToJsonValue.
1459      * @tc.expected: expect cover branch selfIdealSize has value.
1460      */
1461     std::optional<CalcLength> len = CalcLength("auto");
1462     FRAME_NODE2->layoutProperty_->calcLayoutConstraint_->selfIdealSize = CalcSize(len, len);
1463     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1464     EXPECT_NE(FRAME_NODE2->renderContext_, nullptr);
1465 
1466     FRAME_NODE2->layoutProperty_ = nullptr;
1467 }
1468 
1469 /**
1470  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback048
1471  * @tc.desc: Test frame node method
1472  * @tc.type: FUNC
1473  */
1474 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback048, TestSize.Level1)
1475 {
1476     /**
1477      * @tc.steps: step1. build a object to TriggerVisibleAreaChangeCallback
1478      * @tc.expected: expect The function is run ok.
1479      */
1480     VisibleCallbackInfo callbackInfo;
1481     constexpr uint32_t minInterval = 100; // 100ms
1482     int flag = 0;
__anon6a214d5b0c02(bool input1, double input2) 1483     callbackInfo.callback = [&flag](bool input1, double input2) { flag += 1; };
1484     callbackInfo.period = minInterval;
1485     FRAME_NODE2->SetVisibleAreaUserCallback({ 0.2, 0.8, 0.21, 0.79, 0.5 }, callbackInfo);
1486     FRAME_NODE2->ProcessThrottledVisibleCallback(false);
1487     EXPECT_EQ(FRAME_NODE2->throttledCallbackOnTheWay_, false);
1488 }
1489 
1490 /**
1491  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback049
1492  * @tc.desc: Test the function GetValidLeafChildNumber
1493  * @tc.type: FUNC
1494  */
1495 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback049, TestSize.Level1)
1496 {
1497     /**
1498      * @tc.steps: step1. build a object to TriggerVisibleAreaChangeCallback
1499      * @tc.expected: expect The function is run ok.
1500      */
1501     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
1502     const RefPtr<FrameNode> node =
1503         FrameNode::CreateFrameNode("TriggerVisibleAreaChangeCallback001", nodeId, AceType::MakeRefPtr<Pattern>(), true);
1504 
1505     /**
1506      * @tc.steps2: Call the function GetValidLeafChildNumber.
1507      * @tc.expected: Value returned as expected.
1508      */
1509     EXPECT_EQ(FRAME_NODE2->GetValidLeafChildNumber(node, 1), 1);
1510     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>(), true);
1511     GET_CHILD1->UpdateInspectorId("child1");
1512     node->AddChild(GET_CHILD1);
1513     EXPECT_EQ(FRAME_NODE2->GetValidLeafChildNumber(node, 1), 1);
1514 
1515     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>(), true);
1516     GET_CHILD2->UpdateInspectorId("child2");
1517     node->AddChild(GET_CHILD2);
1518     EXPECT_EQ(FRAME_NODE2->GetValidLeafChildNumber(node, 3), 2);
1519 }
1520 
1521 /**
1522  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback050
1523  * @tc.desc: Test the function MarkAndCheckNewOpIncNode
1524  * @tc.type: FUNC
1525  */
1526 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback050, TestSize.Level1)
1527 {
1528     /**
1529      * @tc.steps: step1. creat node and generate a node tree.
1530      */
1531     RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
1532     RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
1533     RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
1534     GET_PARENT->AddChild(GET_CHILD1);
1535     GET_PARENT->AddChild(GET_CHILD2);
1536     GET_CHILD1->MarkAndCheckNewOpIncNode();
1537     EXPECT_FALSE(GET_PARENT->GetSuggestOpIncActivatedOnce());
1538 
1539     /**
1540      * @tc.steps2: set suggestOpIncByte_ and call the function MarkAndCheckNewOpIncNode.
1541      * @tc.expected: Value returned as expected.
1542      */
1543     GET_PARENT->suggestOpIncByte_ = 7;
1544     GET_CHILD1->SetSuggestOpIncActivatedOnce();
1545     GET_PARENT->SetSuggestOpIncActivatedOnce();
1546     GET_CHILD1->MarkAndCheckNewOpIncNode();
1547     EXPECT_TRUE(GET_PARENT->GetSuggestOpIncActivatedOnce());
1548     GET_CHILD1->suggestOpIncByte_ = 1;
1549     GET_CHILD1->MarkAndCheckNewOpIncNode();
1550 }
1551 
1552 /**
1553  * @tc.name: FrameNodeTouchTest051
1554  * @tc.desc: Test frameNode FindSuggestOpIncNode
1555  * @tc.type: FUNC
1556  */
1557 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest051, TestSize.Level1)
1558 {
1559     /**
1560      * @tc.steps: step1. initialize parameters.
1561      */
1562     std::string tag = "test";
1563     auto frameNode = FrameNode::CreateFrameNode(tag, 1, AceType::MakeRefPtr<Pattern>(), true);
1564     auto frameNode1 = FrameNode::CreateFrameNode("test1", 2, AceType::MakeRefPtr<Pattern>(), true);
1565     frameNode->AddChild(frameNode1);
1566     frameNode->GetBaselineDistance();
1567 
1568     /**
1569      * @tc.steps: step2. set frame size and call FindSuggestOpIncNode
1570      * @tc.expected: expect result value.
1571      */
1572     frameNode->geometryNode_->SetFrameSize(SizeF(20, 20));
1573     auto result = frameNode->FindSuggestOpIncNode(tag, SizeF(0, 0), 1);
1574     EXPECT_EQ(result, 3);
1575     result = frameNode->FindSuggestOpIncNode(tag, SizeF(0, 0), 1);
1576     EXPECT_EQ(result, 2);
1577     SystemProperties::debugEnabled_ = true;
1578     frameNode->suggestOpIncByte_ = 0;
1579     result = frameNode->FindSuggestOpIncNode(tag, SizeF(0, 0), 1);
1580     EXPECT_EQ(result, 3);
1581 }
1582 
1583 /**
1584  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback052
1585  * @tc.desc: Test the function IsOpIncValidNode
1586  * @tc.type: FUNC
1587  */
1588 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback052, TestSize.Level1)
1589 {
1590     /**
1591      * @tc.steps: step1. initialize parameters.
1592      */
1593 
1594     SizeF boundary(1, 1);
1595     int32_t childNumber = 2;
1596 
1597     /**
1598      * @tc.steps2: call the function IsOpIncValidNode.
1599      * @tc.expected: Value returned as expected.
1600      */
1601     auto result = FRAME_NODE2->IsOpIncValidNode(boundary, childNumber);
1602     EXPECT_EQ(result, 2);
1603 
1604     FRAME_NODE2->geometryNode_->SetFrameSize(SizeF(20, 20));
1605     result = FRAME_NODE2->IsOpIncValidNode(boundary, childNumber);
1606     EXPECT_EQ(result, 3);
1607 
1608     SizeF boundary1(40, 40);
1609     FRAME_NODE2->geometryNode_->SetFrameSize(SizeF(20, 20));
1610     result = FRAME_NODE2->IsOpIncValidNode(boundary1, childNumber);
1611     EXPECT_EQ(result, 2);
1612 }
1613 
1614 /**
1615  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback053
1616  * @tc.desc: Test the function MarkSuggestOpIncGroup
1617  * @tc.type: FUNC
1618  */
1619 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback053, TestSize.Level1)
1620 {
1621     /**
1622      * @tc.steps1: call the function MarkSuggestOpIncGroup.
1623      * @tc.expected: Value returned as expected.
1624      */
1625     EXPECT_TRUE(FRAME_NODE2->MarkSuggestOpIncGroup(true, true));
1626 
1627     FRAME_NODE2->SetCanSuggestOpInc(true);
1628     FRAME_NODE2->SetSuggestOpIncMarked(true);
1629     FRAME_NODE2->SetOpIncGroupCheckedThrough(true);
1630     EXPECT_TRUE(FRAME_NODE2->MarkSuggestOpIncGroup(true, true));
1631 
1632     FRAME_NODE2->SetSuggestOpIncMarked(false);
1633     FRAME_NODE2->SetCanSuggestOpInc(false);
1634     FRAME_NODE2->SetOpIncGroupCheckedThrough(false);
1635     EXPECT_TRUE(FRAME_NODE2->MarkSuggestOpIncGroup(true, true));
1636 }
1637 
1638 /**
1639  * @tc.name: FrameNodeTestNg_IsPaintRectWithTransformValid054
1640  * @tc.desc: Test frame node method IsPaintRectWithTransformValid
1641  * @tc.type: FUNC
1642  */
1643 HWTEST_F(FrameNodeTestNg, FrameNodeIsPaintRectWithTransformValid054, TestSize.Level1)
1644 {
1645     /**
1646      * @tc.steps: step1. callback IsPaintRectWithTransformValid.
1647      * @tc.expected: expect The function return value is true when width or height is nearZero.
1648      */
1649     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1650     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1651     node->renderContext_ = mockRenderContext;
1652 
1653     mockRenderContext->rect_ = RectF(0, 0, 0, 10);
1654     mockRenderContext->paintRect_ = RectF(0, 0, 0, 10);
1655     auto test1 = node->IsPaintRectWithTransformValid();
1656     EXPECT_TRUE(test1);
1657 
1658     mockRenderContext->rect_ = RectF(0, 0, 10, 0);
1659     mockRenderContext->paintRect_ = RectF(0, 0, 10, 0);
1660     auto test2 = node->IsPaintRectWithTransformValid();
1661     EXPECT_TRUE(test2);
1662 
1663     mockRenderContext->rect_ = RectF(0, 0, 10, 10);
1664     mockRenderContext->paintRect_ = RectF(0, 0, 10, 10);
1665     auto test3 = node->IsPaintRectWithTransformValid();
1666     EXPECT_FALSE(test3);
1667 
1668     mockRenderContext->rect_ = RectF(0, 0, 0, 0);
1669     mockRenderContext->paintRect_ = RectF(0, 0, 0, 0);
1670     auto test4 = node->IsPaintRectWithTransformValid();
1671     EXPECT_TRUE(test4);
1672 }
1673 
1674 /**
1675  * @tc.name: FrameNodeTestNg_Predict001
1676  * @tc.desc: Test frame node method ResetPredictNodes
1677  * @tc.type: FUNC
1678  */
1679 HWTEST_F(FrameNodeTestNg, FrameNodePredict001, TestSize.Level1)
1680 {
1681     /**
1682      * @tc.steps: step1. add predictNode to main node and delete main node.
1683      * @tc.expected: expect the predictNode is not layout dirty marked after main node desconstructed.
1684      */
1685     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1686     auto predictNode = FrameNode::CreateFrameNode("predict", 1, AceType::MakeRefPtr<Pattern>(), false);
1687     predictNode->SetLayoutDirtyMarked(true);
1688     node->AddPredictLayoutNode(predictNode);
1689     node.Reset();
1690     EXPECT_FALSE(predictNode->IsLayoutDirtyMarked());
1691 }
1692 
1693 /**
1694  * @tc.name: FrameNodeSetJSCustomProperty055
1695  * @tc.desc: Test SetJSCustomProperty isCNode true, expect result is false.
1696  * @tc.type: FUNC
1697  */
1698 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSCustomProperty055, TestSize.Level1)
1699 {
1700     /**
1701      * @tc.steps: step1. initialize parameters.
1702      */
1703     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1704 
1705     /**
1706      * @tc.steps: step2. set isCNode true.
1707      * @tc.expected: expect result is false.
1708      */
1709     frameNode->setIsCNode(true);
__anon6a214d5b0d02() 1710     std::function<bool()> func = []() -> bool { return true; };
__anon6a214d5b0e02(const std::string& key) 1711     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1712         return "getFuncA";
1713     };
1714     frameNode->SetJSCustomProperty(func, getFuncA);
1715     std::string getValue;
1716     bool result = frameNode->GetCapiCustomProperty("key", getValue);
1717     EXPECT_EQ(result, false);
1718 }
1719 
1720 /**
1721  * @tc.name: FrameNodeSetJSCustomProperty056
1722  * @tc.desc: Test SetJSCustomProperty isCNode false, expect result is false.
1723  * @tc.type: FUNC
1724  */
1725 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSCustomProperty056, TestSize.Level1)
1726 {
1727     /**
1728      * @tc.steps: step1. initialize parameters.
1729      */
1730     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1731 
1732     /**
1733      * @tc.steps: step2. set isCNode false.
1734      * @tc.expected: expect result is false.
1735      */
1736     frameNode->setIsCNode(false);
__anon6a214d5b0f02() 1737     std::function<bool()> func = []() -> bool { return true; };
__anon6a214d5b1002(const std::string& key) 1738     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1739         return "getFuncA";
1740     };
1741     frameNode->SetJSCustomProperty(func, getFuncA);
1742     frameNode->setIsCNode(true);
1743     std::string getValue;
1744     bool result = frameNode->GetCapiCustomProperty("key", getValue);
1745     EXPECT_EQ(result, false);
1746 }
1747 
1748 /**
1749  * @tc.name: FrameNodeGetJSCustomProperty058
1750  * @tc.desc: Test GetJSCustomProperty getCustomProperty_ value getFuncA, expect result value getFuncA.
1751  * @tc.type: FUNC
1752  */
1753 HWTEST_F(FrameNodeTestNg, FrameNodeGetJSCustomProperty058, TestSize.Level1)
1754 {
1755     /**
1756      * @tc.steps: step1. initialize parameters.
1757      */
1758     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1759 
1760     /**
1761      * @tc.steps: step2. set getCustomProperty_ value getFuncA.
1762      * @tc.expected: expect result value getFuncA.
1763      */
__anon6a214d5b1102() 1764     std::function<bool()> func = []() -> bool { return true; };
__anon6a214d5b1202(const std::string& key) 1765     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1766         return "getFuncA";
1767     };
1768     frameNode->SetJSCustomProperty(func, getFuncA);
1769     frameNode->SetCustomPropertyMapFlagByKey("key");
1770     std::string getValue;
1771     bool result = frameNode->GetJSCustomProperty("key", getValue);
1772     EXPECT_EQ(result, true);
1773     EXPECT_EQ(getValue, "getFuncA");
1774 }
1775 
1776 /**
1777  * @tc.name: FrameNodeGetJSCustomProperty059
1778  * @tc.desc: Test GetJSCustomProperty getCustomProperty_ nullptr
1779  * @tc.type: FUNC
1780  */
1781 HWTEST_F(FrameNodeTestNg, FrameNodeGetJSCustomProperty059, TestSize.Level1)
1782 {
1783     /**
1784      * @tc.steps: step1. initialize parameters.
1785      */
1786     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1787 
1788     /**
1789      * @tc.steps: step2. set getCustomProperty_ nullptr
1790      * @tc.expected: expect result GetJSCustomProperty false.
1791      */
__anon6a214d5b1302() 1792     std::function<bool()> func = []() -> bool { return true; };
1793     frameNode->SetJSCustomProperty(func, nullptr);
1794     frameNode->SetCustomPropertyMapFlagByKey("key");
1795     std::string getValue;
1796     bool result = frameNode->GetJSCustomProperty("key", getValue);
1797     EXPECT_EQ(result, false);
1798 }
1799 
1800 /**
1801  * @tc.name: FrameNodeGetCapiCustomProperty060
1802  * @tc.desc: Test GetCapiCustomProperty no key value value value added.
1803  * @tc.type: FUNC
1804  */
1805 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty060, TestSize.Level1)
1806 {
1807     /**
1808      * @tc.steps: step1. initialize parameters.
1809      */
1810     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1811 
1812     /**
1813      * @tc.steps: step2. GetCapiCustomProperty
1814      * @tc.expected: expect result value false.
1815      */
1816     frameNode->setIsCNode(false);
1817     std::string value;
1818     bool result = frameNode->GetCapiCustomProperty("key", value);
1819     EXPECT_EQ(result, false);
1820 }
1821 
1822 /**
1823  * @tc.name: FrameNodeGetCapiCustomProperty061
1824  * @tc.desc: Test GetCapiCustomProperty the key value value value exists.
1825  * @tc.type: FUNC
1826  */
1827 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty061, TestSize.Level1)
1828 {
1829     /**
1830      * @tc.steps: step1. initialize parameters.
1831      */
1832     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1833 
1834     /**
1835      * @tc.steps: step2. add the key value as value1.
1836      * @tc.expected: expect result value1.
1837      */
1838     frameNode->setIsCNode(true);
1839     frameNode->AddCustomProperty("key", "value1");
1840     std::string value;
1841     bool result = frameNode->GetCapiCustomProperty("key", value);
1842     EXPECT_EQ(result, true);
1843     EXPECT_EQ(value, "value1");
1844 }
1845 
1846 /**
1847  * @tc.name: FrameNodeGetCapiCustomProperty062
1848  * @tc.desc: Test GetCapiCustomProperty the key value does not exist.
1849  * @tc.type: FUNC
1850  */
1851 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty062, TestSize.Level1)
1852 {
1853     /**
1854      * @tc.steps: step1. initialize parameters.
1855      */
1856     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1857 
1858     /**
1859      * @tc.steps: step2. set key is value1
1860      * @tc.expected: expect result value.
1861      */
1862     frameNode->setIsCNode(true);
1863     frameNode->AddCustomProperty("key", "value1");
1864     std::string value;
1865     bool result = frameNode->GetCapiCustomProperty("key1", value);
1866     EXPECT_EQ(result, false);
1867 }
1868 
1869 /**
1870  * @tc.name: FrameNodeRemoveCustomProperty063
1871  * @tc.desc: Test RemoveCustomProperty.
1872  * @tc.type: FUNC
1873  */
1874 HWTEST_F(FrameNodeTestNg, FrameNodeRemoveCustomProperty063, TestSize.Level1)
1875 {
1876     /**
1877      * @tc.steps: step1. initialize parameters.
1878      */
1879     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1880 
1881     /**
1882      * @tc.steps: step2. set key is value1, remove key.
1883      * @tc.expected: expect result false.
1884      */
1885     frameNode->setIsCNode(true);
1886     frameNode->AddCustomProperty("key", "value1");
1887     frameNode->RemoveCustomProperty("key");
1888     std::string value;
1889     bool result = frameNode->GetCapiCustomProperty("key", value);
1890     EXPECT_EQ(result, false);
1891 }
1892 
1893 /**
1894  * @tc.name: FrameNodeTestNg_OnAutoEventParamUpdate
1895  * @tc.desc: Test frame node method
1896  * @tc.type: FUNC
1897  */
1898 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg_OnAutoEventParamUpdate, TestSize.Level1)
1899 {
1900     /**
1901      * @tc.steps: step1. create framenode and initialize the params used in Test.
1902      */
1903     auto node = FrameNode::CreateFrameNode("childNode", 10, AceType::MakeRefPtr<Pattern>(), true);
1904     node->AttachToMainTree();
1905     node->GetRenderContext()->RequestNextFrame();
1906     EXPECT_TRUE(node->IsOnMainTree());
1907 
1908     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
1909     const RefPtr<FrameNode> parentNode =
1910         FrameNode::CreateFrameNode("RelativeContainer", nodeId, AceType::MakeRefPtr<Pattern>(), true);
1911     node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
1912 
1913     /**
1914      * @tc.steps: step2. call OnAutoEventParamUpdate.
1915      * @tc.expect: this parentNode is MarkDirtyNode, but this Tag() != "RelativeContainer"
1916      * this parentNode is not MarkDirtyNode
1917      */
1918     node->OnAutoEventParamUpdate("{\"$origin\":\"Tom\",\"$exposureCfg\":{\"ratio\":0.8,\"duration\":3000}}");
1919     EXPECT_EQ(parentNode->GetTag(), "RelativeContainer");
1920 }
1921 
1922 /**
1923  * @tc.name: FrameNodeTestNg065
1924  * @tc.desc: Test GetIsLayoutNode.
1925  * @tc.type: FUNC
1926  */
1927 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg065, TestSize.Level1)
1928 {
1929     auto frameNode =
1930         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1931     bool isLayoutNode = false;
1932     frameNode->isLayoutNode_ = isLayoutNode;
1933     bool result = frameNode->GetIsLayoutNode();
1934     EXPECT_EQ(result, isLayoutNode);
1935 
1936     isLayoutNode = false;
1937     frameNode->isLayoutNode_ = isLayoutNode;
1938     result = frameNode->GetIsLayoutNode();
1939     EXPECT_EQ(result, isLayoutNode);
1940 }
1941 
1942 /**
1943  * @tc.name: FrameNodeTestNg066
1944  * @tc.desc: Test GetIsFind.
1945  * @tc.type: FUNC
1946  */
1947 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg066, TestSize.Level1)
1948 {
1949     auto frameNode =
1950         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1951     bool isFind = true;
1952     frameNode->isFind_ = isFind;
1953     bool result = frameNode->GetIsFind();
1954     EXPECT_EQ(result, isFind);
1955 
1956     isFind = false;
1957     frameNode->isFind_ = isFind;
1958     result = frameNode->GetIsFind();
1959     EXPECT_EQ(result, isFind);
1960 }
1961 
1962 /**
1963  * @tc.name: FrameNodeTestNg067
1964  * @tc.desc: Test SetIsFind.
1965  * @tc.type: FUNC
1966  */
1967 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg067, TestSize.Level1)
1968 {
1969     auto frameNode =
1970         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1971     bool isFind = true;
1972     frameNode->SetIsFind(isFind);
1973     bool result = frameNode->GetIsFind();
1974     EXPECT_EQ(result, isFind);
1975 
1976     isFind = false;
1977     frameNode->SetIsFind(isFind);
1978     result = frameNode->GetIsFind();
1979     EXPECT_EQ(result, isFind);
1980 }
1981 
1982 /**
1983  * @tc.name: FrameNodeTestNg069
1984  * @tc.desc: Test CheckAutoSave.
1985  * @tc.type: FUNC
1986  */
1987 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg069, TestSize.Level1)
1988 {
1989     auto frameNode =
1990         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1991 
1992     auto pattern_ = frameNode->GetPattern();
1993     EXPECT_NE(pattern_, nullptr);
1994     bool result = frameNode->CheckAutoSave();
1995     EXPECT_EQ(result, pattern_->CheckAutoSave());
1996 
1997     pattern_ = nullptr;
1998     result = frameNode->CheckAutoSave();
1999     EXPECT_FALSE(result);
2000 }
2001 
2002 /**
2003  * @tc.name: FrameNodeTestNg070
2004  * @tc.desc: Test RenderCustomChild.
2005  * @tc.type: FUNC
2006  */
2007 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg070, TestSize.Level1)
2008 {
2009     auto frameNode =
2010         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2011 
2012     int64_t deadline = 1;
2013     bool result = frameNode->RenderCustomChild(deadline);
2014     bool res = frameNode->UINode::RenderCustomChild(deadline);
2015     EXPECT_EQ(result, res);
2016 }
2017 
2018 /**
2019  * @tc.name: FrameNodeTestNg081
2020  * @tc.desc: Test GetOrCreateCommonNode.
2021  * @tc.type: FUNC
2022  */
2023 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg081, TestSize.Level1)
2024 {
2025     bool isLayoutNode = true;
2026     auto commonOne =
__anon6a214d5b1402() 2027         FrameNode::GetOrCreateCommonNode("commonOne", 1, isLayoutNode, []() { return AceType::MakeRefPtr<Pattern>(); });
2028     auto commonTwo = FrameNode::GetFrameNode("commonTwo", 1);
2029     EXPECT_NE(commonOne, nullptr);
2030     EXPECT_EQ(commonTwo, nullptr);
2031 
2032     /**
2033      * @tc.steps: step2. create FrameNode and set a callback
2034      * @tc.expect: call DestroyCallback while object is destroyed
2035      */
2036     bool flag = true;
2037     auto commonThree = FrameNode::GetOrCreateFrameNode("commonOne", 1, nullptr);
2038     ASSERT_NE(commonThree, nullptr);
__anon6a214d5b1502() 2039     commonThree->PushDestroyCallbackWithTag([&flag]() { flag = !flag; }, "");
2040     commonThree = nullptr;
2041     EXPECT_FALSE(flag);
2042 }
2043 
2044 /**
2045  * @tc.name: FrameNodeTestNg082
2046  * @tc.desc: Test CreateCommonNode.
2047  * @tc.type: FUNC
2048  */
2049 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg082, TestSize.Level1)
2050 {
2051     /* @tc.steps: step1. create commonNode and initialize the params used in Test.
2052       */
2053     bool isLayoutNode = false;
2054     auto commonNode =
2055         FrameNode::CreateCommonNode("CommonChildNode", 20, isLayoutNode, AceType::MakeRefPtr<Pattern>(), true);
2056     commonNode->AttachToMainTree();
2057     commonNode->GetRenderContext()->RequestNextFrame();
2058     EXPECT_TRUE(commonNode->IsOnMainTree());
2059 
2060     int32_t commonNodeId = ElementRegister::GetInstance()->MakeUniqueId();
2061     const RefPtr<FrameNode> commonParentNode =
2062         FrameNode::CreateCommonNode("CommonRelativeContainer", commonNodeId, isLayoutNode,
2063         AceType::MakeRefPtr<Pattern>(), true);
2064     commonNode->SetParent(AceType::WeakClaim(AceType::RawPtr(commonParentNode)));
2065 
2066     /**
2067      * @tc.steps: step2. call OnInspectorIdUpdate .
2068      * @tc.expect: this commonParentNode is MarkDirtyNode, but this Tag() != "RelativeContainer"
2069      * this commonParentNode is not MarkDirtyNode
2070      */
2071     commonNode->OnInspectorIdUpdate("CommonRelativeContainer");
2072     EXPECT_EQ(commonParentNode->GetTag(), "CommonRelativeContainer");
2073 }
2074 
2075 /**
2076  * @tc.name: FrameNodeTestNg083
2077  * @tc.desc: Test RequestParentDirty.
2078  * @tc.type: FUNC
2079  */
2080 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg083, TestSize.Level1)
2081 {
2082     /* @tc.steps: step1. create frameNodeTemp and initialize the params used in Test.
2083     */
2084     auto frameNodeTemp =
2085         FrameNode::CreateFrameNode("root", 2, AceType::MakeRefPtr<Pattern>(), true);
2086 
2087     /**
2088      * @tc.steps: step2. frameNodeTemp is a root node
2089      * @tc.expect: frameNodeTemp call RequestParentDirty
2090     */
2091     bool result = frameNodeTemp->FrameNode::RequestParentDirty();
2092     EXPECT_FALSE(result);
2093 
2094     /**
2095      * @tc.steps: step3. create childNode and  added to frameNodeTemp
2096      * @tc.expect: childNode call RequestParentDirty
2097      */
2098     auto childNode =
2099         FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), false);
2100     frameNodeTemp->AddChild(childNode);
2101     result = childNode->FrameNode::RequestParentDirty();
2102     EXPECT_TRUE(result);
2103 }
2104 
2105 /**
2106  * @tc.name: FrameNodeTestNg084
2107  * @tc.desc: Test AddCustomProperty.
2108  * @tc.type: FUNC
2109  */
2110 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg084, TestSize.Level1)
2111 {
2112     /* @tc.steps: step1. create frameNode and initialize the params used in Test.
2113     */
2114     auto frameNode =
2115         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2116     /**
2117      * @tc.steps: step2. setIsCNode true
2118      * @tc.expect: frameNode call AddCustomProperty
2119     */
2120     frameNode->setIsCNode(true);
2121     frameNode->AddCustomProperty("key1", "value1");
2122     std::string value;
2123     bool result = frameNode->GetCapiCustomProperty("key1", value);
2124     EXPECT_EQ(result, true);
2125     EXPECT_EQ(value, "value1");
2126 }
2127 
2128 /**
2129  * @tc.name: FrameNodeTestNg085
2130  * @tc.desc: Test GetActiveChildren.
2131  * @tc.type: FUNC
2132  */
2133 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg085, TestSize.Level1)
2134 {
2135     /* @tc.steps: step1. create frameNode and initialize the params used in Test.
2136     */
2137     auto frameNode =
2138         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2139     /**
2140      * @tc.steps: step2. create childNode1 and added to frameNode
2141      * @tc.expect: childNode1 setActive true
2142     */
2143     auto childNode1 =
2144         FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), false);
2145     frameNode->AddChild(childNode1);
2146     childNode1->SetActive(true);
2147     /**
2148      * @tc.steps: step3. create childNode2 and added to frameNode
2149      * @tc.expect: childNode2 setActive false
2150     */
2151     auto childNode2 =
2152         FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), false);
2153     frameNode->AddChild(childNode2);
2154     childNode2->SetActive(false);
2155 
2156     std::list<RefPtr<FrameNode>> list = frameNode->FrameNode::GetActiveChildren();
2157     EXPECT_EQ(list.size(), 1);
2158 }
2159 
2160 /**
2161  * @tc.name: FrameNodeTestNg086
2162  * @tc.desc: Test ChildrenUpdatedFrom.
2163  * @tc.type: FUNC
2164  */
2165 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg086, TestSize.Level1)
2166 {
2167     /* @tc.steps: step1. create frameNode and initialize the params used in Test.
2168     */
2169     auto frameNode =
2170         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2171     /**
2172      * @tc.steps: step2. childrenUpdatedFrom_ >= 0 and index > childrenUpdatedFrom_
2173      * @tc.expect: childrenUpdatedFrom_ do not change
2174     */
2175     frameNode->childrenUpdatedFrom_ = 0;
2176     int32_t index = 2;
2177     frameNode->FrameNode::ChildrenUpdatedFrom(index);
2178     int32_t currentIndex = frameNode->childrenUpdatedFrom_;
2179     EXPECT_EQ(currentIndex, 0);
2180 
2181     /**
2182      * @tc.steps: step3. childrenUpdatedFrom_ >= 0 and index < childrenUpdatedFrom_
2183      * @tc.expect: childrenUpdatedFrom_ is set to index
2184     */
2185     frameNode->childrenUpdatedFrom_ = 3;
2186     frameNode->FrameNode::ChildrenUpdatedFrom(index);
2187     currentIndex = frameNode->childrenUpdatedFrom_;
2188     EXPECT_EQ(currentIndex, 2);
2189 
2190     /**
2191      * @tc.steps: step3. childrenUpdatedFrom_ < 0
2192      * @tc.expect: childrenUpdatedFrom_ is set to index
2193     */
2194     frameNode->childrenUpdatedFrom_ = -1;
2195     frameNode->FrameNode::ChildrenUpdatedFrom(index);
2196     currentIndex = frameNode->childrenUpdatedFrom_;
2197     EXPECT_EQ(currentIndex, 2);
2198 }
2199 
2200 /**
2201  * @tc.name: FrameNodeTestNg087
2202  * @tc.desc: Test DumpBorder.
2203  * @tc.type: FUNC
2204  */
2205 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg087, TestSize.Level1)
2206 {
2207     /* @tc.steps: step1. create frameNode and initialize the params used in Test.
2208     */
2209     auto frameNode =
2210         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2211     /**
2212      * @tc.steps: step2. set border, up、right、down、left is 0
2213      * @tc.expect: frameNode call FrameNode::DumpBorder
2214     */
2215     const std::unique_ptr<NG::BorderWidthProperty>& border =
2216         std::make_unique<NG::BorderWidthProperty>();
2217     std::string label = "Border";
2218     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2219     ASSERT_NE(border, nullptr);
2220     frameNode->FrameNode::DumpBorder(border, label, json);
2221     std::string result = json->ToString();
2222     EXPECT_EQ(result, "{}");
2223 
2224     /**
2225      * @tc.steps: step2. set border, up、right、down、left is 1.0vp
2226      * @tc.expect: frameNode call FrameNode::DumpBorder
2227     */
2228     const std::unique_ptr<NG::BorderWidthProperty>& border2 =
2229         std::make_unique<NG::BorderWidthProperty>(BORDER_WIDTH_TEST);
2230     frameNode->FrameNode::DumpBorder(border2, label, json);
2231     result = json->ToString();
2232     EXPECT_EQ(result, "{\"Border\":\"[1.00vp,1.00vp,1.00vp,1.00vp]\"}");
2233 }
2234 
2235 /**
2236  * @tc.name: FrameNodeTestNg088
2237  * @tc.desc: Test DumpSimplifySafeAreaInfo.
2238  * @tc.type: FUNC
2239  */
2240 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg088, TestSize.Level1)
2241 {
2242     /* @tc.steps: step1. create frameNode and initialize the params used in Test.
2243     */
2244     auto frameNode =
2245         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2246 
2247     /**
2248      * @tc.steps: step2. make opts and safeAreaExpandOpts_
2249      * @tc.expect: SafeAreaExpandOpts is set to Json
2250     */
2251     SafeAreaExpandOpts opts;
2252     opts.type = SAFE_AREA_TYPE_SYSTEM;
2253     opts.edges = SAFE_AREA_EDGE_TOP;
2254     frameNode->GetLayoutProperty()->safeAreaExpandOpts_ = std::make_unique<SafeAreaExpandOpts>(opts);
2255 
2256     /**
2257      * @tc.steps: step3. make safeAreaInsets_
2258      * @tc.expect: safeAreaInsets is set to Json
2259     */
2260     SafeAreaInsets::Inset inset = {
2261         .start = 0,
2262         .end = 1,
2263     };
2264     SafeAreaInsets safeAreaInset(inset, inset, inset, inset);
2265     frameNode->GetLayoutProperty()->safeAreaInsets_ = std::make_unique<SafeAreaInsets>(safeAreaInset);
2266 
2267     /**
2268      * @tc.steps: step4. make SelfOrParentExpansive() true
2269      * and geometryNode_->GetSelfAdjust() is not defaultValue, geometryNode_->GetParentAdjust() is not defaultValue
2270      * @tc.expect: SelfAdjust  is set to Json, ParentSelfAdjust is set to Json
2271     */
2272     RectF selfAdjust(1.0, 1.0, 1.0, 1.0);
2273     frameNode->geometryNode_->SetSelfAdjust(selfAdjust);
2274     frameNode->geometryNode_->parentAdjust_.SetRect(0, 0, 10, 10);
2275 
2276     ASSERT_NE(frameNode->GetTag(), V2::PAGE_ETS_TAG);
2277 
2278     auto pipe = MockPipelineContext::GetCurrent();
2279     frameNode->context_ = AceType::RawPtr(pipe);
2280     auto pipeline = frameNode->GetContext();
2281     ASSERT_NE(pipeline, nullptr);
2282 
2283     pipeline->safeAreaManager_ = AceType::MakeRefPtr<SafeAreaManager>();
2284     auto manager = pipeline->GetSafeAreaManager();
2285     ASSERT_NE(manager, nullptr);
2286 
2287     /**
2288      * @tc.steps: step5. make manager->KeyboardSafeAreaEnabled() true
2289      * @tc.expect: KeyboardInset  is set to Json
2290     */
2291     manager->keyboardSafeAreaEnabled_ = true;
2292 
2293     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2294     frameNode->DumpSimplifySafeAreaInfo(json);
2295     std::string result = json->ToString();
2296     const std::string expectStr = "{\"SafeAreaExpandOpts\":\"SafeAreaExpandOpts: type:SAFE_AREA_TYPE_SYSTEM, " \
2297                                 "edges: SAFE_AREA_EDGE_TOP\",\"SafeAreaInsets\":\"SafeAreaInsets left_: [start: " \
2298                                 "0, end: 1], top_: [start: 0, end: 1], right_: [start: 0, end: 1], " \
2299                                 "bottom_: [start: 0, end: 1]\",\"SelfAdjust\":\"RectT (1.00, 1.00) - " \
2300                                 "[1.00 x 1.00]\",\"ParentSelfAdjust\":\"RectT (0.00, 0.00) - [10.00 x 10.00]\"}";
2301     EXPECT_EQ(result, expectStr);
2302 }
2303 
2304 /**
2305  * @tc.name: FrameNodeTestNg089
2306  * @tc.desc: Test DumpSimplifyCommonInfo.
2307  * @tc.type: FUNC
2308  */
2309 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg089, TestSize.Level1)
2310 {
2311     /* @tc.steps: step1. create frameNode and initialize the params used in Test.
2312      */
2313     auto frameNode =
2314         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2315 
2316     /**
2317      * @tc.steps: step2. make geometryNode_->GetFrameRect()
2318      * @tc.expect: FrameRect is set to Json
2319      */
2320     const NG::RectF rect = { 10.0f, 20.0f, 30.0f, 40.0f };
2321     frameNode->geometryNode_->frame_.rect_ = rect;
2322     /**
2323      * @tc.steps: step3. make renderContext_->GetBackgroundColor()
2324      * @tc.expect: BackgroundColor is set to Json
2325      */
2326     frameNode->renderContext_->UpdateBackgroundColor(Color::BLUE);
2327 
2328     /**
2329      * @tc.steps: step4. make layoutProperty_->GetVisibility()
2330      * @tc.expect: Visible is set to Json
2331      */
2332     frameNode->layoutProperty_->UpdateVisibility(VisibleType::INVISIBLE);
2333 
2334     /**
2335      * @tc.steps: step5. make layoutProperty_->GetLayoutRect()
2336      * @tc.expect: LayoutRect is set to Json
2337      */
2338     frameNode->layoutProperty_->SetLayoutRect(rect);
2339 
2340     /**
2341      * @tc.steps: step6. make layoutProperty_->GetCalcLayoutConstraint()
2342      * @tc.expect: UserDefinedConstraint is set to Json
2343      */
2344     frameNode->layoutProperty_->calcLayoutConstraint_ = std::make_unique<MeasureProperty>();
2345 
2346     /**
2347      * @tc.steps: step7. make layoutProperty_->GetPaddingProperty() and layoutProperty_->GetContentLayoutConstraint()
2348      * @tc.expect: ContentConstraint is set to Json
2349      */
2350     frameNode->layoutProperty_->padding_ = std::make_unique<PaddingProperty>();
2351     LayoutConstraintF constraint;
2352     constraint.selfIdealSize.width_ = 20.0f;
2353     constraint.selfIdealSize.height_ = 30.0f;
2354     frameNode->layoutProperty_->contentConstraint_ = constraint;
2355 
2356     /**
2357      * @tc.steps: step8. make geometryNode_->GetParentLayoutConstraint()
2358      * @tc.expect: ParentLayoutConstraint is set to Json
2359      */
2360     LayoutConstraintF layoutConstraint;
2361     layoutConstraint.percentReference.width_ = 10.0;
2362     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraint);
2363 
2364     /**
2365      * @tc.steps: step9. call DumpSimplifyCommonInfo
2366      * @tc.expect: check each key
2367      */
2368     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2369     frameNode->DumpSimplifyCommonInfo(json);
2370 
2371     EXPECT_TRUE(json->IsObject());
2372     EXPECT_TRUE(json->Contains("FrameRect"));
2373     EXPECT_FALSE(json->Contains("PaintRectWithoutTransform"));
2374     EXPECT_TRUE(json->Contains("BackgroundColor"));
2375     EXPECT_TRUE(json->Contains("Offset"));
2376     EXPECT_TRUE(json->Contains("Visible"));
2377     EXPECT_EQ(json->GetInt64("Visible"), 1);
2378     EXPECT_TRUE(json->Contains("LayoutRect"));
2379     EXPECT_TRUE(json->Contains("UserDefinedConstraint"));
2380     EXPECT_TRUE(json->Contains("ContentConstraint"));
2381     EXPECT_FALSE(json->Contains("ZIndex"));
2382     EXPECT_TRUE(json->Contains("ParentLayoutConstraint"));
2383 }
2384 
2385 /**
2386  * @tc.name: FrameNodeTestNg090
2387  * @tc.desc: Test DumpPadding.
2388  * @tc.type: FUNC
2389  */
2390 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg090, TestSize.Level1)
2391 {
2392     /* @tc.steps: step1. create frameNode and initialize the params used in Test.
2393      */
2394     auto frameNode =
2395         FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2396 
2397     /**
2398      * @tc.steps: step2. set padding value is not 0
2399      * @tc.expect: check each key
2400      */
2401     std::unique_ptr<NG::PaddingProperty> padding = std::make_unique<NG::PaddingProperty>();
2402     padding->top = CalcLength(1.0, DimensionUnit::PX);
2403     padding->right = CalcLength("2.0vp");
2404     padding->bottom = NG::CalcLength::FromString("3.0vp");
2405     padding->left = CalcLength(4.0, DimensionUnit::PX);
2406 
2407     std::string label = "Padding";
2408     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2409     ASSERT_NE(padding, nullptr);
2410 
2411     /**
2412      * @tc.steps: step3. call DumpPadding
2413      * @tc.expect: Padding is set to Json
2414      */
2415     frameNode->DumpPadding(padding, label, json);
2416     EXPECT_TRUE(json->Contains(label));
2417 }
2418 
2419 /**
2420  * @tc.name: FrameNodeTestNg091
2421  * @tc.desc: Test AddFrameNodeChangeInfoFlag
2422  * @tc.type: FUNC
2423  */
2424 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg091, TestSize.Level1)
2425 {
2426     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2427     frameNode->AddFrameNodeChangeInfoFlag(1 << 5);
2428     EXPECT_EQ(frameNode->GetChangeInfoFlag(), 1 << 5);
2429 }
2430 
2431 /**
2432  * @tc.name: FrameNodeTestNg092
2433  * @tc.desc: Test AddFrameNodeChangeInfoFlag
2434  * @tc.type: FUNC
2435  */
2436 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg092, TestSize.Level1)
2437 {
2438     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2439     frameNode->AddFrameNodeChangeInfoFlag(0);
2440     EXPECT_EQ(frameNode->GetChangeInfoFlag(), 0);
2441 }
2442 } // namespace OHOS::Ace::NG
2443