• 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 
17 using namespace testing;
18 using namespace testing::ext;
19 
20 namespace OHOS::Ace::NG {
SetUpTestSuite()21 void FrameNodeTestNg::SetUpTestSuite()
22 {
23     MockPipelineContext::SetUp();
24 }
25 
TearDownTestSuite()26 void FrameNodeTestNg::TearDownTestSuite()
27 {
28     MockPipelineContext::TearDown();
29 }
30 
31 /**
32  * @tc.name: FrameNodeTestNg001
33  * @tc.desc: Test frame node method
34  * @tc.type: FUNC
35  */
36 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg001, TestSize.Level1)
37 {
__anon26ad9ddd0102() 38     auto one = FrameNode::GetOrCreateFrameNode("one", 1, []() { return AceType::MakeRefPtr<Pattern>(); });
39     auto two = FrameNode::GetFrameNode("two", 1);
40     EXPECT_NE(one, nullptr);
41     EXPECT_EQ(two, nullptr);
42 
43     /**
44      * @tc.steps: step2. create FrameNode and set a callback
45      * @tc.expect: call DestroyCallback while object is destroyed
46      */
47     bool flag = false;
48     auto three = FrameNode::GetOrCreateFrameNode("one", 1, nullptr);
49     ASSERT_NE(three, nullptr);
__anon26ad9ddd0202() 50     three->PushDestroyCallback([&flag]() { flag = !flag; });
51     three = nullptr;
52     EXPECT_TRUE(flag);
53 }
54 
55 /**
56  * @tc.name: FrameNodeTestNg002
57  * @tc.desc: Test frame node method
58  * @tc.type: FUNC
59  */
60 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg002, TestSize.Level1)
61 {
__anon26ad9ddd0302() 62     auto one = FrameNode::GetOrCreateFrameNode("one", 1, []() { return AceType::MakeRefPtr<Pattern>(); });
63     one->SetParent(FRAME_NODE_PARENT);
64     auto two = FrameNode::GetFrameNode("two", 1);
65     EXPECT_NE(one, nullptr);
66     EXPECT_EQ(two, nullptr);
67     ElementRegister::GetInstance()->Clear();
68 }
69 
70 /**
71  * @tc.name: FrameNodeTestNg004
72  * @tc.desc: Test frame node method
73  * @tc.type: FUNC
74  */
75 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg004, TestSize.Level1)
76 {
77     /**
78      * @tc.steps: step1. create framenode and initialize the params used in Test.
79      */
80     auto node = FrameNode::CreateFrameNode("childNode", 10, AceType::MakeRefPtr<Pattern>(), true);
81     node->AttachToMainTree();
82     node->GetRenderContext()->RequestNextFrame();
83     EXPECT_TRUE(node->IsOnMainTree());
84 
85     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
86     const RefPtr<FrameNode> parentNode =
87         FrameNode::CreateFrameNode("RelativeContainer", nodeId, AceType::MakeRefPtr<Pattern>(), true);
88     node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
89 
90     /**
91      * @tc.steps: step2. call OnInspectorIdUpdate .
92      * @tc.expect: this parentNode is MarkDirtyNode, but this Tag() != "RelativeContainer"
93      * this parentNode is not MarkDirtyNode
94      */
95     node->OnInspectorIdUpdate("RelativeContainer");
96     EXPECT_EQ(parentNode->GetTag(), "RelativeContainer");
97 }
98 
99 /**
100  * @tc.name: FrameNodeTestNg007
101  * @tc.desc: Test frame node method
102  * @tc.type: FUNC
103  */
104 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg007, TestSize.Level1)
105 {
106     /**
107      * @tc.steps: step 1. create framenode and initialize the params used in Test.
108      */
109     auto node = FrameNode::CreateFrameNode("childNode", 10, AceType::MakeRefPtr<Pattern>(), true);
110 
111     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
112     const RefPtr<FrameNode> parentNode =
113         FrameNode::CreateFrameNode("parent", nodeId, AceType::MakeRefPtr<Pattern>(), true);
114     node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
115 
116     const RefPtr<FrameNode> overlayNode =
117         FrameNode::CreateFrameNode("overlayNode", nodeId, AceType::MakeRefPtr<Pattern>(), true);
118 
119     /**
120      * @tc.steps: step 2. call OnInspectorIdUpdate .
121      * @tc.expect: this parentNode is MarkDirtyNode, but this Tag() != "RelativeContainer"
122      * this parentNode is not MarkDirtyNode
123      */
124 
125     node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
126     node->OnInspectorIdUpdate("RelativeContainer");
127     EXPECT_EQ(parentNode->GetTag(), "parent");
128 
129     /**
130      * @tc.steps: step 3. call LayoutOverlay .
131      * @tc.expect: FrameRect of overlayNode is 0.
132      */
133     node->SetOverlayNode(overlayNode);
134     node->LayoutOverlay();
135 
136     auto layoutProperty = overlayNode->GetLayoutProperty();
137     layoutProperty->positionProperty_ = std::make_unique<PositionProperty>();
138     node->LayoutOverlay();
139     EXPECT_EQ(overlayNode->GetGeometryNode()->GetFrameRect().GetX(), 0);
140 
141     /**
142      * @tc.steps: step 4. call GetFrameChildByIndex .
143      * @tc.expect: index == 0 return uiNode, index != 0 return null
144      */
145     EXPECT_TRUE(node->GetFrameChildByIndex(0, false));
146     EXPECT_FALSE(node->GetFrameChildByIndex(1, false));
147 
148     /**
149      * @tc.steps: step 5. call GetBaselineDistance .
150      * @tc.expect: node has not child return 0. if node has child return  childBaseline of child
151      */
152     EXPECT_EQ(node->GetBaselineDistance(), 0);
153     node->AddChild(FRAME_NODE);
154     EXPECT_EQ(node->GetBaselineDistance(), 0);
155     auto nodeLayoutProperty = node->GetLayoutProperty();
156     nodeLayoutProperty->geometryTransition_ =
157         ElementRegister::GetInstance()->GetOrCreateGeometryTransition("test", false, true);
158     node->Layout();
159     EXPECT_FALSE(node->IsRootMeasureNode());
160     node->SetRootMeasureNode();
161     node->Layout();
162     EXPECT_TRUE(node->IsRootMeasureNode());
163 }
164 
165 /**
166  * @tc.name: FrameNodeTestNg008
167  * @tc.desc: Test frame node method
168  * @tc.type: FUNC
169  */
170 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg008, TestSize.Level1)
171 {
172     /**
173      * @tc.steps: step 1. create framenode and initialize the params used in Test.
174      */
175     RefPtr<NG::DrawModifier> drawModifier = AceType::MakeRefPtr<NG::DrawModifier>();
176     ASSERT_NE(drawModifier, nullptr);
177 
178     /**
179      * @tc.steps: step 2. call get function .
180      * @tc.expect: expect the return value to be correct.
181      */
182     EXPECT_TRUE(FRAME_NODE->IsSupportDrawModifier());
183 
184     /**
185      * @tc.steps: step 3. call GetContentModifier when drawModifier is null.
186      * @tc.expect: expect the return value to be correct.
187      */
188     EXPECT_EQ(FRAME_NODE->GetContentModifier(), nullptr);
189 
190     /**
191      * @tc.steps: step 4. Nodes created by virtual classes, call GetContentModifier when drawModifier is null.
192      * @tc.expect: expect the return value to be correct.
193      */
194     FRAME_NODE->SetDrawModifier(drawModifier);
195     EXPECT_EQ(FRAME_NODE->GetContentModifier(), nullptr);
196 
197     /**
198      * @tc.steps: step 5. Nodes created by virtual classes, call SetRemoveCustomProperties.
199      * @tc.expect: expect call successfully.
200      */
__anon26ad9ddd0402() 201     FRAME_NODE->SetRemoveCustomProperties([]() -> void {});
202 }
203 
204 /**
205  * @tc.name: FrameNodeTouchTest001
206  * @tc.desc: Test frame node method
207  * @tc.type: FUNC
208  */
209 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest, TestSize.Level1)
210 {
211     /**
212      * @tc.steps: step1. create framenode and initialize the params used in Test.
213      */
214     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
215     node->AttachToMainTree();
216     node->GetOrCreateGestureEventHub();
217     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
218     node->renderContext_ = mockRenderContext;
219     node->SetActive(true);
220     auto localPoint = PointF(10, 10);
221     auto parentLocalPoint = PointF(10, 10);
222     const NG::PointF point { 10, 10 };
223     const PointF parentLocalPointOne = { 10, 10 };
224     TouchRestrict touchRestrict = { TouchRestrict::NONE };
225     auto globalPoint = PointF(10, 10);
226     auto touchTestResult = std::list<RefPtr<TouchEventTarget>>();
227     ResponseLinkResult responseLinkResult;
228 
229     mockRenderContext->rect_ = RectF(0, 0, 100, 100);
230     EXPECT_CALL(*mockRenderContext, GetPointWithTransform(_)).WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
231 
232     /**
233      * @tc.steps: step2. create childnode
234      */
235     auto childNode = FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true);
236     childNode->SetExclusiveEventForChild(true);
237     auto mockRenderContextforChild = AceType::MakeRefPtr<MockRenderContext>();
238     childNode->renderContext_ = mockRenderContextforChild;
239     mockRenderContext->rect_ = RectF(0, 0, 100, 100);
240     EXPECT_CALL(*mockRenderContextforChild, GetPointWithTransform(_))
241         .WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
242     childNode->GetOrCreateGestureEventHub();
243     childNode->SetActive(true);
244     auto childEventHub = childNode->GetOrCreateGestureEventHub();
245 
246     /**
247      * @tc.steps: step3. add childnode to the framenode
248      */
249     std::list<RefPtr<FrameNode>> children;
250     children.push_back(childNode);
251     node->frameChildren_ = { children.begin(), children.end() };
252 
253     /**
254      * @tc.steps: step4. create grandChildNode
255      */
256 
257     auto grandChildNode = FrameNode::CreateFrameNode("main", 3, AceType::MakeRefPtr<Pattern>(), true);
258     grandChildNode->SetExclusiveEventForChild(true);
259     grandChildNode->renderContext_ = mockRenderContextforChild;
260     mockRenderContext->rect_ = RectF(0, 0, 100, 100);
261     EXPECT_CALL(*mockRenderContextforChild, GetPointWithTransform(_))
262         .WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
263     grandChildNode->GetOrCreateGestureEventHub();
264     grandChildNode->SetActive(true);
265     auto grandChildEventHub = grandChildNode->GetOrCreateGestureEventHub();
266 
267     /**
268      * @tc.steps: step5. add grandChildNode to the childnode
269      */
270     std::list<RefPtr<FrameNode>> grandChild;
271     grandChild.push_back(grandChildNode);
272     childNode->frameChildren_ = { grandChild.begin(), grandChild.end() };
273 
274     /**
275      * @tc.steps: step6. compare hitTestResult which is retured in function TouchTest whith expected value.
276      * @tc.expected: step6. hitTestResult  is STOP_BUBBLING when hitTestModeofGrandChilds or hitTestModeofChild is
277      * HTMBLOCK;
278      */
279     HitTestMode hitTestModeofGrandChilds[] = { HitTestMode::HTMBLOCK, HitTestMode::HTMDEFAULT };
280     HitTestMode hitTestModeofChilds[] = { HitTestMode::HTMDEFAULT, HitTestMode::HTMBLOCK, HitTestMode::HTMTRANSPARENT,
281         HitTestMode::HTMNONE, HitTestMode::HTMTRANSPARENT_SELF };
282     bool isStacks[] = { true, false };
283 
284     for (auto hitTestModeofGrandChild : hitTestModeofGrandChilds) {
285         grandChildEventHub->SetHitTestMode(hitTestModeofGrandChild);
286         for (auto isStack : isStacks) {
287             for (auto hitTestModeofChild : hitTestModeofChilds) {
288                 childNode->SetExclusiveEventForChild(isStack);
289                 childEventHub->SetHitTestMode(hitTestModeofChild);
290                 auto result = childNode->TouchTest(globalPoint, parentLocalPointOne, parentLocalPointOne, touchRestrict,
291                     touchTestResult, 0, responseLinkResult, true);
292                 result = node->TouchTest(globalPoint, parentLocalPointOne, parentLocalPointOne, touchRestrict,
293                     touchTestResult, 0, responseLinkResult, true);
294             }
295         }
296     }
297 }
298 
299 /**
300  * @tc.name: FrameNodeTestNg005
301  * @tc.desc: Test frame node method
302  * @tc.type: FUNC
303  */
304 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg005, TestSize.Level1)
305 {
306     /**
307      * @tc.steps: step1. callback function.
308      * @tc.expected: expect The function is run ok.
309      */
310     auto one = FrameNode::CreateFrameNodeWithTree("main", 10, AceType::MakeRefPtr<Pattern>());
311     EXPECT_NE(one, nullptr);
312 
313     MeasureProperty calcLayoutConstraint;
314     FRAME_NODE->UpdateLayoutConstraint(std::move(calcLayoutConstraint));
315     EXPECT_EQ(FRAME_NODE2->layoutProperty_->propertyChangeFlag_, 1);
316 
317     FRAME_NODE2->needSyncRenderTree_ = true;
318     FRAME_NODE2->RebuildRenderContextTree();
319     EXPECT_FALSE(FRAME_NODE2->needSyncRenderTree_);
320 
321     /**
322      * @tc.steps: step 2. create and set overlayNode.
323      * @tc.expect:cover branch overlayNode is not null and function is run ok.
324      */
325     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
326     const RefPtr<FrameNode> overlayNode =
327         FrameNode::CreateFrameNode("overlayNode", nodeId, AceType::MakeRefPtr<Pattern>(), true);
328     FRAME_NODE2->SetOverlayNode(overlayNode);
329     FRAME_NODE2->RebuildRenderContextTree();
330     EXPECT_FALSE(FRAME_NODE2->needSyncRenderTree_);
331 
332     FRAME_NODE2->OnMountToParentDone();
333 
334     FRAME_NODE2->FlushUpdateAndMarkDirty();
335 
336     std::list<RefPtr<FrameNode>> visibleList;
337     FRAME_NODE2->isActive_ = true;
338     FRAME_NODE2->OnGenerateOneDepthVisibleFrame(visibleList);
339     EXPECT_TRUE(FRAME_NODE2->IsVisible());
340 
341     FRAME_NODE2->OnGenerateOneDepthAllFrame(visibleList);
342     EXPECT_EQ(visibleList.size(), 2);
343 
344     auto pattern = FRAME_NODE2->GetPattern();
345     EXPECT_EQ(pattern, 1);
346 
347     auto atomicNode = FRAME_NODE2->IsAtomicNode();
348     EXPECT_TRUE(atomicNode);
349 
350     auto hitTestMode = FRAME_NODE2->GetHitTestMode();
351     EXPECT_EQ(hitTestMode, HitTestMode::HTMDEFAULT);
352 
353     auto touchable = FRAME_NODE2->GetTouchable();
354     EXPECT_TRUE(touchable);
355 
356     const PointF globalPoint;
357     const PointF parentLocalPoint;
358     MouseTestResult onMouseResult;
359     MouseTestResult onHoverResult;
360     RefPtr<FrameNode> hoverNode;
361     auto mouse = FRAME_NODE2->MouseTest(globalPoint, parentLocalPoint, onMouseResult, onHoverResult, hoverNode);
362     EXPECT_EQ(mouse, HitTestResult::BUBBLING);
363 }
364 
365 /**
366  * @tc.name: FrameNodeTestNg006
367  * @tc.desc: Test frame node method
368  * @tc.type: FUNC
369  */
370 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg006, TestSize.Level1)
371 {
372     /**
373      * @tc.steps: step1. callback function.
374      * @tc.expected: expect The function is run ok.
375      */
376     FRAME_NODE2->OnWindowShow();
377     FRAME_NODE2->OnWindowHide();
378     FRAME_NODE2->OnWindowFocused();
379     FRAME_NODE2->OnWindowUnfocused();
380     FRAME_NODE2->OnWindowSizeChanged(1, 1, WindowSizeChangeReason::CUSTOM_ANIMATION);
381 
382     OffsetF Offset = { 0, 0 };
383     FRAME_NODE2->SetParent(FRAME_NODE3);
384     auto relativeOffset = FRAME_NODE2->GetTransformRelativeOffset();
385     EXPECT_EQ(relativeOffset, Offset);
386 
387     FRAME_NODE2->SetParent(FRAME_NODE3);
388     auto rectOffset = FRAME_NODE2->GetPaintRectOffset(true);
389     EXPECT_EQ(rectOffset, Offset);
390 
391     FRAME_NODE2->OnNotifyMemoryLevel(true);
392 
393     auto childrenCount = FRAME_NODE2->GetAllDepthChildrenCount();
394     EXPECT_EQ(childrenCount, 1);
395 
396     DimensionRect dimensionRect;
397     FRAME_NODE2->AddHotZoneRect(dimensionRect);
398     FRAME_NODE2->RemoveLastHotZoneRect();
399     EXPECT_NE(FRAME_NODE2->eventHub_, nullptr);
400 
401     FRAME_NODE->ProcessOffscreenNode(FRAME_NODE3);
402     FRAME_NODE->GetTransformRectRelativeToWindow();
403     FRAME_NODE->GetPaintRectOffsetToPage();
404 
405     float x = 1.0;
406     float y = 1.0;
407     auto Position = FRAME_NODE->FindChildByPosition(x, y);
408     EXPECT_EQ(Position, nullptr);
409 
410     FRAME_NODE->ProvideRestoreInfo();
411     auto immediately = FRAME_NODE->RemoveImmediately();
412     EXPECT_TRUE(immediately);
413 }
414 
415 /**
416  * @tc.name: FrameNodeTestNg_DumpInfo006
417  * @tc.desc: Test frame node method
418  * @tc.type: FUNC
419  */
420 HWTEST_F(FrameNodeTestNg, FrameNodeDumpInfo006, TestSize.Level1)
421 {
422     /**
423      * @tc.steps: step1. callback DumpInfo
424      * @tc.expected: expect The function is run ok.
425      */
426     LayoutProperty layoutProperty;
427     FRAME_NODE->DumpInfo();
428 
429     FRAME_NODE->layoutProperty_->UpdatePadding(PaddingPropertyT<CalcLength>());
430     FRAME_NODE->layoutProperty_->GetPaddingProperty();
431     FRAME_NODE->DumpInfo();
432     EXPECT_EQ(layoutProperty.padding_, nullptr);
433 
434     FRAME_NODE->layoutProperty_->UpdateMargin(PaddingProperty());
435     FRAME_NODE->layoutProperty_->GetMarginProperty();
436     FRAME_NODE->DumpInfo();
437     EXPECT_EQ(layoutProperty.margin_, nullptr);
438 
439     FRAME_NODE->layoutProperty_->UpdateBorderWidth(BorderWidthPropertyT<Dimension>());
440     FRAME_NODE->layoutProperty_->GetBorderWidthProperty();
441     FRAME_NODE->DumpInfo();
442     EXPECT_EQ(layoutProperty.borderWidth_, nullptr);
443 
444     /**
445      * @tc.steps: step2. set layoutConstraintF_ an geometryNode_'sParentLayoutConstraint
446                 and call DumpInfo
447      * @tc.expected: expect The function is run ok.
448      */
449     FRAME_NODE->layoutProperty_->calcLayoutConstraint_ = std::make_unique<MeasureProperty>();
450     auto layoutConstraintF_ = LayoutConstraintF();
451     FRAME_NODE->geometryNode_->SetParentLayoutConstraint(layoutConstraintF_);
452     FRAME_NODE->DumpInfo();
453     EXPECT_EQ(layoutProperty.calcLayoutConstraint_, nullptr);
454 }
455 
456 /**
457  * @tc.name: FrameNodeTestNg_ToJsonValue007
458  * @tc.desc: Test frame node method
459  * @tc.type: FUNC
460  */
461 HWTEST_F(FrameNodeTestNg, FrameNodeToJsonValue007, TestSize.Level1)
462 {
463     /**
464      * @tc.steps: step1. build a object to jsonValue
465      * @tc.expected: expect The function is run ok.
466      */
467     auto gestureEventHub = FRAME_NODE->GetOrCreateGestureEventHub();
468 
469     std::vector<DimensionRect> responseRegion;
470     responseRegion.push_back(DimensionRect());
471     gestureEventHub->SetResponseRegion(responseRegion);
472 
473     auto jsonValue = JsonUtil::Create(true);
474     FRAME_NODE->ToJsonValue(jsonValue, filter);
475     EXPECT_TRUE(jsonValue);
476 
477     /**
478      * @tc.steps: step2. build a object to jsonValue and call FromJson
479      * @tc.expected: expect The function is run ok.
480      */
481     FRAME_NODE->FromJson(jsonValue);
482     FRAME_NODE->renderContext_ = nullptr;
483     FRAME_NODE->eventHub_->focusHub_ = nullptr;
484     auto jsonValue2 = JsonUtil::Create(true);
485     FRAME_NODE->ToJsonValue(jsonValue2, filter);
486     FRAME_NODE->FromJson(jsonValue2);
487     EXPECT_TRUE(jsonValue2);
488 }
489 
490 /**
491  * @tc.name: FrameNodeTestNg_OnAttachToMainTree008
492  * @tc.desc: Test frame node method
493  * @tc.type: FUNC
494  */
495 HWTEST_F(FrameNodeTestNg, FrameNodeOnAttachToMainTree008, TestSize.Level1)
496 {
497     /**
498      * @tc.steps: step1. build a object to OnAttachToMainTree
499      * @tc.expected: expect The function is run ok.
500      */
501     FRAME_NODE2->OnAttachToMainTree(true);
502 
503     auto request = FRAME_NODE2->hasPendingRequest_ = true;
504     FRAME_NODE2->OnAttachToMainTree(true);
505     EXPECT_TRUE(request);
506 
507     /**
508      * @tc.steps: step2 set PositionProperty of FRAME_NODE2 and call OnAttachToMainTree
509      * @tc.expected: expect The function is run ok.
510      */
511     auto& posProperty = FRAME_NODE2->renderContext_->GetOrCreatePositionProperty();
512     posProperty->UpdateOffset(OffsetT<Dimension>()); // OffsetT<Dimension>
513     FRAME_NODE2->SetParent(FRAME_NODE_PARENT);
514     auto testNode_ = TestNode::CreateTestNode(100);
515     FRAME_NODE_PARENT->SetParent(testNode_);
516     FRAME_NODE2->OnAttachToMainTree(true);
517     EXPECT_TRUE(request);
518 }
519 
520 /**
521  * @tc.name: FrameNodeTestNg_NotifyVisibleChange009
522  * @tc.desc: Test frame node method
523  * @tc.type: FUNC
524  */
525 HWTEST_F(FrameNodeTestNg, FrameNodeNotifyVisibleChange009, TestSize.Level1)
526 {
527     /**
528      * @tc.steps: step1. build a object to NotifyVisibleChange
529      * @tc.expected: expect The FRAME_NODE2 is not nullptr.
530      */
531     FRAME_NODE2->AddChild(FRAME_NODE3);
532     FRAME_NODE2->NotifyVisibleChange(VisibleType::VISIBLE, VisibleType::INVISIBLE);
533     FRAME_NODE2->Clean();
534     EXPECT_NE(FRAME_NODE2, nullptr);
535 }
536 
537 /**
538  * @tc.name: FrameNodeTestNg_SwapDirtyLayoutWrapperOnMainThread0010
539  * @tc.desc: Test frame node method
540  * @tc.type: FUNC
541  */
542 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirtyLayoutWrapperOnMainThread0010, TestSize.Level1)
543 {
544     /**
545      * @tc.steps: step1. build a object to SwapDirtyLayoutWrapperOnMainThread
546      */
547     RefPtr<LayoutWrapper> layoutWrapper = FRAME_NODE2->CreateLayoutWrapper(true, true);
548 
549     /**
550      * @tc.steps: step2. callback SwapDirtyLayoutWrapperOnMainThread
551      * @tc.expected: expect layoutWrapper is not nullptr.
552      */
553     FRAME_NODE2->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
554     EXPECT_NE(layoutWrapper, nullptr);
555     layoutWrapper->SetActive(true);
556     auto test = FRAME_NODE2->IsActive();
557 
558     /**
559      * @tc.steps: step3. callback SwapDirtyLayoutWrapperOnMainThread
560      * @tc.expected: expect isActive_ is false.
561      */
562     FRAME_NODE2->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
563     EXPECT_TRUE(test);
564 }
565 
566 /**
567  * @tc.name: FrameNodeTestNg_AdjustGridOffset0011
568  * @tc.desc: Test frame node method
569  * @tc.type: FUNC
570  */
571 HWTEST_F(FrameNodeTestNg, FrameNodeAdjustGridOffset0011, TestSize.Level1)
572 {
573     /**
574      * @tc.steps: step1. build a object to AdjustGridOffset
575      * @tc.expected: expect active is true.
576      */
577     FRAME_NODE2->SetActive(true);
578     bool active = FRAME_NODE2->IsActive();
579     FRAME_NODE2->AdjustGridOffset();
580     EXPECT_TRUE(active);
581 
582     FRAME_NODE2->SetParent(FRAME_NODE_PARENT);
583     FRAME_NODE2->GetAncestorNodeOfFrame(false);
584 
585     FRAME_NODE2->SetActive(false);
586 
587     /**
588      * @tc.steps: step2. build a object to AdjustGridOffset
589      * @tc.expected: expect active1 is false.
590      */
591     bool active1 = FRAME_NODE2->IsActive();
592     FRAME_NODE2->AdjustGridOffset();
593     EXPECT_FALSE(active1);
594 }
595 
596 /**
597  * @tc.name: FrameNodeTestNg_SetOnAreaChangeCallback0012
598  * @tc.desc: Test frame node method
599  * @tc.type: FUNC
600  */
601 HWTEST_F(FrameNodeTestNg, FrameNodeSetOnAreaChangeCallback0012, TestSize.Level1)
602 {
603     /**
604      * @tc.steps: step1. build a object to SetOnAreaChangeCallback
605      * @tc.expected: expect The function is run ok.
606      */
607     OnAreaChangedFunc callback = [](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon26ad9ddd0502(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 608                                      const OffsetF& origin) {};
609     FRAME_NODE2->SetOnAreaChangeCallback(std::move(callback));
610     EXPECT_NE(FRAME_NODE2->lastFrameRect_, nullptr);
611     EXPECT_NE(FRAME_NODE2->lastParentOffsetToWindow_, nullptr);
612 
613     /**
614      * @tc.steps: step2.test while callback is nullptr
615      * @tc.expected:expect The function is run ok.
616      */
617     FRAME_NODE2->lastFrameRect_ = nullptr;
618     FRAME_NODE2->lastParentOffsetToWindow_ = nullptr;
619     FRAME_NODE2->SetOnAreaChangeCallback(nullptr);
620     EXPECT_NE(FRAME_NODE2->lastFrameRect_, nullptr);
621     EXPECT_NE(FRAME_NODE2->lastParentOffsetToWindow_, nullptr);
622 }
623 
624 /**
625  * @tc.name: FrameNodeTestNg_TriggerOnAreaChangeCallback0013
626  * @tc.desc: Test frame node method
627  * @tc.type: FUNC
628  */
629 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerOnAreaChangeCallback0013, TestSize.Level1)
630 {
631     /**
632      * @tc.steps: step1. set a flag and init a callback(onAreaChanged)
633      */
634     bool flag = false;
635     OnAreaChangedFunc onAreaChanged = [&flag](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon26ad9ddd0602(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 636                                           const OffsetF& origin) { flag = !flag; };
637 
638     /**
639      * @tc.steps: step2. call TriggerOnAreaChangeCallback before set callback
640      * @tc.expected: expect flag is still false
641      */
642     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_1);
643     EXPECT_FALSE(flag);
644 
645     /**
646      * @tc.steps: step3.set callback and release lastParentOffsetToWindow_
647      * @tc.expected: expect flag is still false
648      */
649     FRAME_NODE2->eventHub_->SetOnAreaChanged(std::move(onAreaChanged));
650     FRAME_NODE2->lastParentOffsetToWindow_ = nullptr;
651     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_2);
652     EXPECT_FALSE(flag);
653 
654     /**
655      * @tc.steps: step4. release lastFrameRect_
656      * @tc.expected: expect flag is still false
657      */
658     FRAME_NODE2->lastFrameRect_ = nullptr;
659     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_3);
660     EXPECT_FALSE(flag);
661 
662     /**
663      * @tc.steps: step5.set lastParentOffsetToWindow_ and lastFrameRect_
664      * @tc.expected: expect flag is still false
665      */
666     FRAME_NODE2->lastParentOffsetToWindow_ = std::make_unique<OffsetF>();
667     FRAME_NODE2->lastFrameRect_ = std::make_unique<RectF>();
668     FRAME_NODE2->TriggerOnAreaChangeCallback(TIMESTAMP_4);
669     EXPECT_FALSE(flag);
670 }
671 
672 /**
673  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback0014
674  * @tc.desc: Test frame node method
675  * @tc.type: FUNC
676  */
677 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback0014, TestSize.Level1)
678 {
679     /**
680      * @tc.steps: step1. build a object to TriggerVisibleAreaChangeCallback
681      * @tc.expected: expect The function is run ok.
682      */
683     VisibleCallbackInfo callbackInfo;
684     FRAME_NODE2->SetVisibleAreaUserCallback({ 0.0f }, callbackInfo);
685     FRAME_NODE2->TriggerVisibleAreaChangeCallback(1);
686 
687     /**
688      * @tc.steps: step2. callback SetParent
689      * @tc.expected: expect parent is same with parentNode.
690      */
691     auto parentNode = AceType::MakeRefPtr<FrameNode>("test", -1, AceType::MakeRefPtr<Pattern>(), false);
692     FRAME_NODE2->SetParent(FRAME_NODE3);
693     FRAME_NODE2->TriggerVisibleAreaChangeCallback(2);
694     auto parent = FRAME_NODE2->GetParent();
695     EXPECT_EQ(parent, 1);
696 
697     auto parentNode1 = FrameNode::CreateFrameNode("parent", 2, AceType::MakeRefPtr<Pattern>());
698     RefPtr<FrameNode> frameNodes[3] = { parentNode1, nullptr, nullptr };
699     FRAME_NODE2->TriggerVisibleAreaChangeCallback(3);
700     auto parent1 = FRAME_NODE2->GetParent();
701     EXPECT_EQ(parent1, 1);
702 
703     FRAME_NODE2->lastVisibleRatio_ = 1.0;
704     FRAME_NODE2->TriggerVisibleAreaChangeCallback(4);
705 
706     /**
707      * @tc.steps: step3. set onShow_ and call TriggerVisibleAreaChangeCallback
708      * @tc.expected: expect GetOnShow is true and lastVisibleRatio_ is zero.
709      */
710     auto context = PipelineContext::GetCurrentContext();
711     context->onShow_ = true;
712     FRAME_NODE2->TriggerVisibleAreaChangeCallback(5);
713     auto testNode_ = TestNode::CreateTestNode(101);
714     FRAME_NODE3->SetParent(testNode_);
715     FRAME_NODE3->isActive_ = true;
716     FRAME_NODE2->TriggerVisibleAreaChangeCallback(6);
717     FRAME_NODE3->layoutProperty_->UpdateVisibility(VisibleType::INVISIBLE);
718     FRAME_NODE2->layoutProperty_->UpdateVisibility(VisibleType::VISIBLE);
719     FRAME_NODE2->isActive_ = true;
720     FRAME_NODE2->TriggerVisibleAreaChangeCallback(7);
721     FRAME_NODE3->layoutProperty_->UpdateVisibility(VisibleType::VISIBLE);
722     FRAME_NODE2->TriggerVisibleAreaChangeCallback(8);
723     EXPECT_TRUE(context->GetOnShow());
724 }
725 
726 /**
727  * @tc.name: FrameNodeTestNg_CreateLayoutTask0015
728  * @tc.desc: Test frame node method
729  * @tc.type: FUNC
730  */
731 HWTEST_F(FrameNodeTestNg, FrameNodeCreateLayoutTask0015, TestSize.Level1)
732 {
733     /**
734      * @tc.steps: step1. build a object to CreateLayoutTask
735      * @tc.expected: expect The function is run ok.
736      */
737     FRAME_NODE2->isLayoutDirtyMarked_ = true;
738     FRAME_NODE2->CreateLayoutTask(true);
739     EXPECT_FALSE(FRAME_NODE2->isLayoutDirtyMarked_);
740 
741     FRAME_NODE2->CreateLayoutTask(true);
742 
743     FRAME_NODE2->isLayoutDirtyMarked_ = true;
744     FRAME_NODE2->CreateLayoutTask(false);
745     EXPECT_FALSE(FRAME_NODE2->isLayoutDirtyMarked_);
746 }
747 
748 /**
749  * @tc.name: FrameNodeTestNg_CreateRenderTask0016
750  * @tc.desc: Test frame node method
751  * @tc.type: FUNC
752  */
753 HWTEST_F(FrameNodeTestNg, FrameNodeCreateRenderTask0016, TestSize.Level1)
754 {
755     /**
756      * @tc.steps: step1. build a object to CreateRenderTask
757      * @tc.expected: expect The isRenderDirtyMarked_ is false.
758      */
759     FRAME_NODE2->isRenderDirtyMarked_ = true;
760     FRAME_NODE2->CreateRenderTask(true);
761     EXPECT_FALSE(FRAME_NODE2->isRenderDirtyMarked_);
762 
763     FRAME_NODE2->isRenderDirtyMarked_ = true;
764     FRAME_NODE2->CreateRenderTask(false);
765 
766     FRAME_NODE2->CreateRenderTask(true);
767     EXPECT_FALSE(FRAME_NODE2->isRenderDirtyMarked_);
768 }
769 
770 /**
771  * @tc.name: FrameNodeTestNg_UpdateLayoutPropertyFlag0018
772  * @tc.desc: Test frame node method
773  * @tc.type: FUNC
774  */
775 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateLayoutPropertyFlag0018, TestSize.Level1)
776 {
777     /**
778      * @tc.steps: step1.call back UpdateLayoutPropertyFlag.
779      * @tc.expected: expect selfFlag is same with PROPERTY_UPDATE_BY_CHILD_REQUEST.
780      */
781     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
782     auto selfFlag = FRAME_NODE2->layoutProperty_->GetPropertyChangeFlag();
783     FRAME_NODE2->UpdateLayoutPropertyFlag();
784     EXPECT_EQ(selfFlag, PROPERTY_UPDATE_BY_CHILD_REQUEST);
785 
786     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
787     FRAME_NODE2->AddChild(FRAME_NODE3);
788     FRAME_NODE2->UpdateLayoutPropertyFlag();
789     FRAME_NODE2->Clean();
790 }
791 
792 /**
793  * @tc.name: FrameNodeTestNg_UpdateChildrenLayoutWrapper0019
794  * @tc.desc: Test frame node method
795  * @tc.type: FUNC
796  */
797 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateChildrenLayoutWrapper0019, TestSize.Level1)
798 {
799     /**
800      * @tc.steps: step1. AddChild for FRAME_NODE2 and callback UpdateChildrenLayoutWrapper.
801      * @tc.expected: expect The UpdateLayoutWrapper is true.
802      */
803     FRAME_NODE2->AddChild(FRAME_NODE3);
804     FRAME_NODE2->UpdateChildrenLayoutWrapper(FRAME_NODE2->UpdateLayoutWrapper(nullptr, true, true), true, true);
805     FRAME_NODE2->Clean();
806     EXPECT_TRUE(FRAME_NODE2->UpdateLayoutWrapper(nullptr, true, true));
807 }
808 
809 /**
810  * @tc.name: FrameNodeTestNg_MarkModifyDone0021
811  * @tc.desc: Test frame node method
812  * @tc.type: FUNC
813  */
814 HWTEST_F(FrameNodeTestNg, FrameNodeMarkModifyDone0021, TestSize.Level1)
815 {
816     /**
817      * @tc.steps: step1. build a object to MarkModifyDone.
818      * @tc.expected:expect The function is run ok.
819      */
820     FRAME_NODE2->MarkModifyDone();
821     EXPECT_TRUE(FRAME_NODE2->isRestoreInfoUsed_);
822     FRAME_NODE2->isRestoreInfoUsed_ = true;
823     FRAME_NODE2->MarkModifyDone();
824     EXPECT_TRUE(FRAME_NODE2->isRestoreInfoUsed_);
825 }
826 
827 /**
828  * @tc.name: FrameNodeTestNg_MarkNeedRender0022
829  * @tc.desc: Test frame node method
830  * @tc.type: FUNC
831  */
832 HWTEST_F(FrameNodeTestNg, FrameNodeMarkNeedRender0022, TestSize.Level1)
833 {
834     /**
835      * @tc.steps: step1. callback MarkNeedRenderOnly.
836      * @tc.expected: expect The function is run ok.
837      */
838     FRAME_NODE2->MarkNeedRenderOnly();
839     auto test = FRAME_NODE2->isRenderDirtyMarked_ = false;
840     auto test1 = FRAME_NODE2->isLayoutDirtyMarked_ = false;
841     FRAME_NODE2->MarkNeedRender(false);
842     FRAME_NODE2->MarkNeedRender(true);
843     EXPECT_FALSE(test);
844     EXPECT_FALSE(test1);
845 }
846 
847 /**
848  * @tc.name: FrameNodeTestNg_IsNeedRequestParentMeasure0023
849  * @tc.desc: Test frame node method
850  * @tc.type: FUNC
851  */
852 HWTEST_F(FrameNodeTestNg, FrameNodeIsNeedRequestParentMeasure0023, TestSize.Level1)
853 {
854     /**
855      * @tc.steps: step1. callback IsNeedRequestParentMeasure.
856      * @tc.expected: expect The function return value is true.
857      */
858     auto test = FRAME_NODE2->IsNeedRequestParentMeasure();
859     EXPECT_TRUE(test);
860 
861     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
862     FRAME_NODE2->IsNeedRequestParentMeasure();
863 
864     FRAME_NODE2->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_BY_CHILD_REQUEST;
865     FRAME_NODE2->layoutProperty_->calcLayoutConstraint_ = std::make_unique<MeasureProperty>();
866     auto test1 = FRAME_NODE2->IsNeedRequestParentMeasure();
867     EXPECT_TRUE(test1);
868 }
869 
870 /**
871  * @tc.name: FrameNodeTestNg_OnGenerateOneDepthVisibleFrameWithTransition0024
872  * @tc.desc: Test frame node method
873  * @tc.type: FUNC
874  */
875 HWTEST_F(FrameNodeTestNg, FrameNodeOnGenerateOneDepthVisibleFrameWithTransition0024, TestSize.Level1)
876 {
877     /**
878      * @tc.steps: step1. callback OnGenerateOneDepthVisibleFrameWithTransition.
879      * @tc.expected: expect The function is run ok.
880      */
881     std::list<RefPtr<FrameNode>> visibleList;
882     FRAME_NODE2->OnGenerateOneDepthVisibleFrameWithTransition(visibleList);
883 
884     /**
885      * @tc.steps: step2.push the framenode to visibleList and callback OnGenerateOneDepthVisibleFrameWithTransition
886      * @tc.expected: expect visibleList.size is 3.
887      */
888     visibleList.push_back(FRAME_NODE);
889     FRAME_NODE3->OnGenerateOneDepthVisibleFrameWithTransition(visibleList);
890     EXPECT_EQ(visibleList.size(), 3);
891 }
892 
893 /**
894  * @tc.name: FrameNodeTestNg_IsOutOfTouchTestRegion0025
895  * @tc.desc: Test frame node method
896  * @tc.type: FUNC
897  */
898 HWTEST_F(FrameNodeTestNg, FrameNodeIsOutOfTouchTestRegion0025, TestSize.Level1)
899 {
900     /**
901      * @tc.steps: step1. callback IsOutOfTouchTestRegion.
902      * @tc.expected: expect The function return value is true.
903      */
904     PointF pointF;
905     std::vector<RectF> rectF;
906     TouchEvent touchEvent;
907     auto test = FRAME_NODE2->IsOutOfTouchTestRegion(std::move(pointF), touchEvent);
908     EXPECT_TRUE(test);
909 
910     auto test1 = FRAME_NODE2->InResponseRegionList(pointF, rectF);
911     auto test2 = FRAME_NODE2->IsOutOfTouchTestRegion(std::move(pointF), touchEvent);
912     EXPECT_FALSE(test1);
913     EXPECT_TRUE(test2);
914 }
915 
916 /**
917  * @tc.name: FrameNodeTestNg_TouchTest0026
918  * @tc.desc: Test frame node method
919  * @tc.type: FUNC
920  */
921 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest0026, TestSize.Level1)
922 {
923     /**
924      * @tc.steps: step1. callback TouchTest.
925      * @tc.expected: expect The function return value is true.
926      */
927     PointF globalPoint;
928     PointF parentLocalPoint;
929     TouchRestrict touchRestrict;
930     TouchTestResult result;
931     ResponseLinkResult responseLinkResult;
932     SystemProperties::debugEnabled_ = true;
933     FRAME_NODE2->TouchTest(
934         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
935 
936     SystemProperties::debugEnabled_ = false;
937     FRAME_NODE2->TouchTest(
938         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
939 
940     /**
941      * @tc.steps: step2. set isActive_ and IsEnabled is false.
942      * @tc.expected: expect The function return value is OUT_OF_REGION.
943      */
944     FRAME_NODE2->isActive_ = false;
945     FRAME_NODE2->eventHub_->SetEnabled(false);
946     auto test = FRAME_NODE2->TouchTest(
947         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
948     EXPECT_EQ(test, HitTestResult::OUT_OF_REGION);
949 }
950 
951 /**
952  * @tc.name: FrameNodeTestNg_AxisTest0027
953  * @tc.desc: Test frame node method
954  * @tc.type: FUNC
955  */
956 HWTEST_F(FrameNodeTestNg, FrameNodeAxisTest0027, TestSize.Level1)
957 {
958     /**
959      * @tc.steps: step1. callback AxisTest.
960      * @tc.expected: expect inputEventHub_ is run not null.
961      */
962     const PointF globalPoint;
963     const PointF parentLocalPoint;
964     const PointF parentRevertPoint;
965     TouchRestrict touchRestrict;
966     AxisTestResult onAxisResult;
967     FRAME_NODE2->eventHub_->GetOrCreateInputEventHub();
968     FRAME_NODE2->AxisTest(globalPoint, parentLocalPoint, parentRevertPoint, touchRestrict, onAxisResult);
969     EXPECT_NE(FRAME_NODE2->eventHub_->inputEventHub_, nullptr);
970 }
971 
972 /**
973  * @tc.name: FrameNodeTestNg0028
974  * @tc.desc: Test frame node method
975  * @tc.type: FUNC
976  */
977 HWTEST_F(FrameNodeTestNg, FrameNodeOnAccessibilityEvent0028, TestSize.Level1)
978 {
979     /**
980      * @tc.steps: step1. callback OnAccessibilityEvent.
981      * @tc.expected: expect The function is true.
982      */
983     auto test = AceApplicationInfo::GetInstance().isAccessibilityEnabled_ = true;
984     FRAME_NODE2->OnAccessibilityEvent(
985         AccessibilityEventType::CHANGE, WindowsContentChangeTypes::CONTENT_CHANGE_TYPE_SUBTREE);
986     FRAME_NODE2->OnAccessibilityEvent(AccessibilityEventType::TEXT_CHANGE, "", "");
987     EXPECT_TRUE(test);
988 
989     /**
990      * @tc.steps: step2. callback OnAccessibilityEvent.
991      * @tc.expected: expect The function is false.
992      */
993     auto test1 = AceApplicationInfo::GetInstance().isAccessibilityEnabled_ = false;
994     FRAME_NODE2->OnAccessibilityEvent(AccessibilityEventType::ACCESSIBILITY_FOCUSED);
995     EXPECT_FALSE(test1);
996 }
997 
998 /**
999  * @tc.name: FrameNodeTestNg_MarkRemoving0029
1000  * @tc.desc: Test frame node method
1001  * @tc.type: FUNC
1002  */
1003 HWTEST_F(FrameNodeTestNg, FrameNodeMarkRemoving0029, TestSize.Level1)
1004 {
1005     /**
1006      * @tc.steps: step1. callback MarkRemoving.
1007      * @tc.expected: expect The function return value is true.
1008      */
1009     FRAME_NODE2->SetParent(FRAME_NODE_PARENT);
1010     FRAME_NODE2->AddChild(FRAME_NODE3);
1011     FRAME_NODE2->layoutProperty_->UpdateGeometryTransition("id");
1012     auto mark = FRAME_NODE2->MarkRemoving();
1013     FRAME_NODE2->Clean();
1014     EXPECT_TRUE(mark);
1015 
1016     FRAME_NODE2->layoutProperty_ = nullptr;
1017     auto mark1 = FRAME_NODE2->MarkRemoving();
1018     EXPECT_FALSE(mark1);
1019 }
1020 
1021 /**
1022  * @tc.name: FrameNodeTestNg_CalculateCurrentVisibleRatio0030
1023  * @tc.desc: Test frame node method
1024  * @tc.type: FUNC
1025  */
1026 HWTEST_F(FrameNodeTestNg, FrameNodeCalculateCurrentVisibleRatio0030, TestSize.Level1)
1027 {
1028     /**
1029      * @tc.steps: step1. callback RemoveLastHotZoneRect.
1030      * @tc.expected: step1. expect The function is run ok.
1031      */
1032     RectF visibleRect;
1033     RectF renderRect;
1034     FRAME_NODE2->CalculateCurrentVisibleRatio(visibleRect, renderRect);
1035     EXPECT_EQ(visibleRect.Width(), 0);
1036     EXPECT_EQ(renderRect.Width(), 0);
1037 
1038     /**
1039      * @tc.steps: step2. set wrong value and call CalculateCurrentVisibleRatio
1040      * @tc.expected: expect The function returns 0.
1041      */
1042     renderRect.SetWidth(-1);
1043     EXPECT_EQ(FRAME_NODE2->CalculateCurrentVisibleRatio(visibleRect, renderRect), 0);
1044     visibleRect.SetWidth(-1);
1045     EXPECT_EQ(FRAME_NODE2->CalculateCurrentVisibleRatio(visibleRect, renderRect), 0);
1046 }
1047 
1048 /**
1049  * @tc.name: FrameNodeTestNg_InitializePatternAndContext0032
1050  * @tc.desc: Test InitializePatternAndContext
1051  * @tc.type: FUNC
1052  */
1053 HWTEST_F(FrameNodeTestNg, FrameNodeInitializePatternAndContext0032, TestSize.Level1)
1054 {
1055     /**
1056      * @tc.steps: step1. create a node and set onMainTree_=false, then call InitializePatternAndContext
1057             and trigger the callback
1058      * @tc.expected: hasPendingRequest_ is true
1059      */
__anon26ad9ddd0702() 1060     auto one = FrameNode::GetOrCreateFrameNode("one", 11, []() { return AceType::MakeRefPtr<Pattern>(); });
1061     one->onMainTree_ = false;
1062     one->InitializePatternAndContext();
1063     auto renderContext_ = one->renderContext_;
1064     renderContext_->RequestNextFrame();
1065     EXPECT_TRUE(one->hasPendingRequest_);
1066 }
1067 
1068 /**
1069  * @tc.name: FrameNodeTestNg_ProcessAllVisibleCallback0033
1070  * @tc.desc: Test ProcessAllVisibleCallback
1071  * @tc.type: FUNC
1072  */
1073 HWTEST_F(FrameNodeTestNg, FrameNodeProcessAllVisibleCallback0033, TestSize.Level1)
1074 {
1075     /**
1076      * @tc.steps: step1. create a node and init a vector for preparing for args, then set a flag
1077      */
__anon26ad9ddd0802() 1078     auto one = FrameNode::GetOrCreateFrameNode("one", 11, []() { return AceType::MakeRefPtr<Pattern>(); });
1079     std::vector<double> visibleAreaRatios { 0.2, 0.8, 0.21, 0.79, 0.5 };
1080     int flag = 0;
__anon26ad9ddd0902(bool input1, double input2) 1081     auto defaultCallback = [&flag](bool input1, double input2) { flag += 1; };
1082     VisibleCallbackInfo callbackInfo { defaultCallback, 1.0, false };
1083 
1084     /**
1085      * @tc.steps: step2. call ProcessAllVisibleCallback with 0.5 from 0
1086      * @tc.expected: flag is 1
1087      */
1088     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 0.5, 0);
1089     EXPECT_EQ(flag, 1);
1090 
1091     /**
1092      * @tc.steps: step3. call ProcessAllVisibleCallback with 0 from 0.5
1093      * @tc.expected: flag is 2
1094      */
1095     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 0, 0.5);
1096     EXPECT_EQ(flag, 2);
1097 
1098     /**
1099      * @tc.steps: step4. call ProcessAllVisibleCallback with 0 from 0
1100      * @tc.expected: flag is 2
1101      */
1102     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 0, 0);
1103     EXPECT_EQ(flag, 2);
1104 
1105     /**
1106      * @tc.steps: step5. call ProcessAllVisibleCallback with 1 from 0
1107      * @tc.expected: flag is 3
1108      */
1109     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 1, 0);
1110     EXPECT_EQ(flag, 3);
1111 
1112     /**
1113      * @tc.steps: step6. call ProcessAllVisibleCallback with 1 from 1
1114      * @tc.expected: flag is 3
1115      */
1116     one->ProcessAllVisibleCallback(visibleAreaRatios, callbackInfo, 1, 1);
1117     EXPECT_EQ(flag, 3);
1118 }
1119 
1120 /**
1121  * @tc.name: FrameNodeTestNg_AnimateHoverEffect0034
1122  * @tc.desc: Test AnimateHoverEffect
1123  * @tc.type: FUNC
1124  */
1125 HWTEST_F(FrameNodeTestNg, FrameNodeAnimateHoverEffect0034, TestSize.Level1)
1126 {
1127     /**
1128      * @tc.steps: step1. create a frame node and release inputEventHub_, then
1129             change hoverEffectType_ and call AnimateHoverEffect
1130      * @tc.expected: AnimateHoverEffectScale has been called
1131      */
__anon26ad9ddd0a02() 1132     auto one = FrameNode::GetOrCreateFrameNode("one", 12, []() { return AceType::MakeRefPtr<Pattern>(); });
1133     one->eventHub_->inputEventHub_ = nullptr;
1134     auto renderContext = AceType::DynamicCast<MockRenderContext>(one->renderContext_);
1135     EXPECT_CALL(*renderContext, AnimateHoverEffectScale(_));
1136     one->AnimateHoverEffect(false);
1137     auto inputEventHub = one->eventHub_->GetOrCreateInputEventHub();
1138     inputEventHub->hoverEffectType_ = HoverEffectType::UNKNOWN;
1139     one->AnimateHoverEffect(false);
1140     inputEventHub->hoverEffectType_ = HoverEffectType::AUTO;
1141     one->AnimateHoverEffect(false);
1142     inputEventHub->hoverEffectType_ = HoverEffectType::SCALE;
1143     one->AnimateHoverEffect(false);
1144     inputEventHub->hoverEffectType_ = HoverEffectType::BOARD;
1145     one->AnimateHoverEffect(false);
1146     inputEventHub->hoverEffectType_ = HoverEffectType::OPACITY;
1147     one->AnimateHoverEffect(false);
1148     inputEventHub->hoverEffectType_ = HoverEffectType::NONE;
1149     one->AnimateHoverEffect(false);
1150 }
1151 
1152 /**
1153  * @tc.name: FrameNodeTestNg_CreateAnimatablePropertyFloat0035
1154  * @tc.desc: Test AnimateHoverEffect
1155  * @tc.type: FUNC
1156  */
1157 HWTEST_F(FrameNodeTestNg, FrameNodeCreateAnimatablePropertyFloat0035, TestSize.Level1)
1158 {
1159     /**
1160      * @tc.steps: step1. call CreateAnimatablePropertyFloat.
1161      * @tc.expected: expect GetRenderContext is not null.
1162      */
1163     FRAME_NODE->CreateAnimatablePropertyFloat(NAME, value, onCallbackEvent);
1164 
1165     FRAME_NODE->renderContext_ = AceType::MakeRefPtr<MockRenderContext>();
1166     FRAME_NODE->CreateAnimatablePropertyFloat(NAME, value, onCallbackEvent);
1167 
1168     /**
1169      * @tc.steps: step2. put value to map and call CreateAnimatablePropertyFloat.
1170      * @tc.expected: expect iter is not equal map.
1171      */
1172     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("test", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1173     FRAME_NODE->CreateAnimatablePropertyFloat(NAME, value, onCallbackEvent);
1174     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1175     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1176     EXPECT_NE(iter, map);
1177 }
1178 
1179 /**
1180  * @tc.name: FrameNodeTestNg_UpdateAnimatablePropertyFloat0036
1181  * @tc.desc: Test AnimateHoverEffect
1182  * @tc.type: FUNC
1183  */
1184 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateAnimatablePropertyFloat0036, TestSize.Level1)
1185 {
1186     /**
1187      * @tc.steps: step1. call UpdateAnimatablePropertyFloat.
1188      * @tc.expected: expect iter is not equal map.
1189      */
1190     FRAME_NODE->UpdateAnimatablePropertyFloat(NAME, value);
1191     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1192     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("propertyName", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1193     FRAME_NODE->UpdateAnimatablePropertyFloat(NAME, value);
1194     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1195     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1196     EXPECT_NE(iter, map);
1197 
1198     /**
1199      * @tc.steps: step2. call UpdateAnimatablePropertyFloat and clear nodeAnimatablePropertyMap_.
1200      * @tc.expected: expect property is nullptr.
1201      */
1202     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1203     FRAME_NODE->UpdateAnimatablePropertyFloat(NAME, value);
1204     auto property = AceType::DynamicCast<NodeAnimatablePropertyFloat>(iter->second);
1205     EXPECT_EQ(property, nullptr);
1206 }
1207 
1208 /**
1209  * @tc.name: FrameNodeTestNg_CreateAnimatableArithmeticProperty0037
1210  * @tc.desc: Test AnimateHoverEffect
1211  * @tc.type: FUNC
1212  */
1213 HWTEST_F(FrameNodeTestNg, FrameNodeCreateAnimatableArithmeticProperty0037, TestSize.Level1)
1214 {
1215     /**
1216      * @tc.steps: step1. call CreateAnimatableArithmeticProperty.
1217      * @tc.expected: expect iter is not equal map.
1218      */
1219     RefPtr<CustomAnimatableArithmetic> value = AceType::MakeRefPtr<CustomAnimatableArithmetic>();
1220     std::function<void(const RefPtr<NG::CustomAnimatableArithmetic>&)> onCallbackEvent;
1221     FRAME_NODE->CreateAnimatableArithmeticProperty(NAME, value, onCallbackEvent);
1222     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("test", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1223     FRAME_NODE->CreateAnimatableArithmeticProperty(NAME, value, onCallbackEvent);
1224     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1225     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1226     EXPECT_NE(iter, map);
1227 }
1228 
1229 /**
1230  * @tc.name: FrameNodeTestNg_UpdateAnimatableArithmeticProperty0038
1231  * @tc.desc: Test AnimateHoverEffect
1232  * @tc.type: FUNC
1233  */
1234 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateAnimatableArithmeticProperty0038, TestSize.Level1)
1235 {
1236     /**
1237      * @tc.steps: step1. call UpdateAnimatableArithmeticProperty.
1238      * @tc.expected: expect iter is not equal map.
1239      */
1240     RefPtr<CustomAnimatableArithmetic> value = AceType::MakeRefPtr<CustomAnimatableArithmetic>();
1241     FRAME_NODE->UpdateAnimatableArithmeticProperty(NAME, value);
1242     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1243 
1244     FRAME_NODE->nodeAnimatablePropertyMap_.emplace("propertyName", AceType::MakeRefPtr<NodeAnimatablePropertyBase>());
1245     FRAME_NODE->UpdateAnimatableArithmeticProperty(NAME, value);
1246     auto iter = FRAME_NODE->nodeAnimatablePropertyMap_.find(NAME);
1247     auto map = FRAME_NODE->nodeAnimatablePropertyMap_.end();
1248     EXPECT_NE(iter, map);
1249 
1250     /**
1251      * @tc.steps: step2. call UpdateAnimatablePropertyFloat and clear nodeAnimatablePropertyMap_.
1252      * @tc.expected: expect property is nullptr.
1253      */
1254     FRAME_NODE->nodeAnimatablePropertyMap_.clear();
1255     FRAME_NODE->UpdateAnimatableArithmeticProperty("", value);
1256     auto property = AceType::DynamicCast<NodeAnimatableArithmeticProperty>(iter->second);
1257     EXPECT_EQ(property, nullptr);
1258 }
1259 
1260 /**
1261  * @tc.name: FrameNodeTestNg0039
1262  * @tc.desc: Test of FrameProxy
1263  * @tc.type: FUNC
1264  */
1265 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg0039, TestSize.Level1)
1266 {
1267     /**
1268      * @tc.steps: step1. creat childNode、create LazyForEachNode
1269      * @tc.expected: childNode is not null
1270      */
1271     auto childNode = FrameNode::CreateFrameNode(
1272         "child", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
1273     auto itemNode = FrameNode::CreateFrameNode(
1274         "itemNode", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
1275     childNode->AddChild(itemNode);
1276     /**
1277      * @tc.steps: step2. call SetIsOverlayNode.
1278      * @tc.expected: change IsOverlayNode().
1279      */
1280     ConfigurationChange configurationChange;
1281     childNode->OnConfigurationUpdate(configurationChange);
1282     configurationChange.languageUpdate = true;
1283     childNode->OnConfigurationUpdate(configurationChange);
1284     configurationChange.colorModeUpdate = true;
1285     childNode->OnConfigurationUpdate(configurationChange);
1286     configurationChange.directionUpdate = true;
1287     childNode->OnConfigurationUpdate(configurationChange);
1288     configurationChange.dpiUpdate = true;
1289     childNode->OnConfigurationUpdate(configurationChange);
1290     configurationChange.fontUpdate = true;
1291     configurationChange.iconUpdate = true;
1292     configurationChange.skinUpdate = true;
1293     configurationChange.fontWeightScaleUpdate = true;
1294     childNode->OnConfigurationUpdate(configurationChange);
1295     configurationChange.fontScaleUpdate = true;
1296     childNode->OnConfigurationUpdate(configurationChange);
1297 
1298     childNode->SetBackgroundLayoutConstraint(itemNode);
1299     childNode->ForceUpdateLayoutPropertyFlag(PROPERTY_UPDATE_MEASURE_SELF);
1300     childNode->GetPaintRectWithTransform();
1301     childNode->GetTransformScale();
1302     childNode->SetJSViewActive(true);
1303     auto layoutProperty = childNode->GetLayoutProperty();
1304     EXPECT_FALSE(layoutProperty->IsOverlayNode());
1305     layoutProperty->SetIsOverlayNode(true);
1306     childNode->DumpOverlayInfo();
1307     EXPECT_TRUE(layoutProperty->IsOverlayNode());
1308 }
1309 
1310 /**
1311  * @tc.name: FrameNodeTestNg_SetOnAreaChangeCallback040
1312  * @tc.desc: Test frame node method
1313  * @tc.type: FUNC
1314  */
1315 HWTEST_F(FrameNodeTestNg, SetOnAreaChangeCallback040, TestSize.Level1)
1316 {
1317     /**
1318      * @tc.steps: step1. build a object to SetOnAreaChangeCallback
1319      * @tc.expected: expect cover branch lastFrameRect_ non null and function is run ok.
1320      */
1321     OnAreaChangedFunc callback = [](const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect,
__anon26ad9ddd0b02(const RectF& oldRect, const OffsetF& oldOrigin, const RectF& rect, const OffsetF& origin) 1322                                      const OffsetF& origin) {};
1323     FRAME_NODE2->lastFrameRect_ = std::make_unique<RectF>();
1324     FRAME_NODE2->SetOnAreaChangeCallback(std::move(callback));
1325     EXPECT_NE(FRAME_NODE2->lastFrameRect_, nullptr);
1326 
1327     /**
1328      * @tc.steps: step2.test while callback is nullptr
1329      * @tc.expected:expect cover branch lastParentOffsetToWindow_ non null and function is run ok.
1330      */
1331 
1332     FRAME_NODE2->lastParentOffsetToWindow_ = std::make_unique<OffsetF>();
1333     FRAME_NODE2->SetOnAreaChangeCallback(nullptr);
1334     EXPECT_NE(FRAME_NODE2->lastParentOffsetToWindow_, nullptr);
1335 }
1336 
1337 /**
1338  * @tc.name: FrameNodeTestNg_SwapDirtyLayoutWrapperOnMainThread040
1339  * @tc.desc: Test frame node method
1340  * @tc.type: FUNC
1341  */
1342 HWTEST_F(FrameNodeTestNg, SwapDirtyLayoutWrapperOnMainThread040, TestSize.Level1)
1343 {
1344     /**
1345      * @tc.steps: step1. creat frameNode and layoutProperty
1346      */
1347     RefPtr<LayoutWrapper> layoutWrapper = FRAME_NODE2->CreateLayoutWrapper(true, true);
1348     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1349     auto layoutProperty = frameNode->GetLayoutProperty<LayoutProperty>();
1350     ASSERT_NE(layoutProperty, nullptr);
1351 
1352     /**
1353      * @tc.steps: step2. setBorderWidth and updateBorderWidth.
1354      * @tc.expected: expect borderWidth property is not nullptr.
1355      */
1356     BorderWidthProperty overCountBorderWidth;
1357     overCountBorderWidth.SetBorderWidth(Dimension(10, DimensionUnit::VP));
1358     layoutProperty->UpdateBorderWidth(overCountBorderWidth);
1359     frameNode->SetLayoutProperty(layoutProperty);
1360 
1361     /**
1362      * @tc.steps: step3. callback SwapDirtyLayoutWrapperOnMainThread
1363      * @tc.expected: expect GetBorderWidthProperty is not nullptr.
1364      */
1365     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
1366     EXPECT_NE(layoutProperty->GetBorderWidthProperty(), nullptr);
1367 
1368     /**
1369      * @tc.steps: step4. updatae layoutConstraint and set eventHub_.
1370      * @tc.expected: expect cover branch eventHub_ non null and function is run ok .
1371      */
1372     auto layoutConstraintF_ = LayoutConstraintF();
1373     layoutConstraintF_.maxSize = CONTAINER_SIZE;
1374     layoutConstraintF_.percentReference = CONTAINER_SIZE;
1375     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF_);
1376     layoutProperty->UpdateLayoutConstraint(layoutConstraintF_);
1377 
1378     frameNode->eventHub_->GetOrCreateFocusHub();
1379     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
1380     EXPECT_NE(frameNode->eventHub_, nullptr);
1381 
1382     /**
1383      * @tc.steps: step5. set currentFocus_ is true and call SwapDirtyLayoutWrapperOnMainThread.
1384      * @tc.expected: expect cover branch IsCurrentFocus() is true and function is run ok .
1385      */
1386     frameNode->eventHub_->GetOrCreateFocusHub()->currentFocus_ = true;
1387     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
1388     EXPECT_TRUE(frameNode->eventHub_->GetOrCreateFocusHub()->IsCurrentFocus());
1389 }
1390 
1391 /**
1392  * @tc.name: FrameNodeTouchTest047
1393  * @tc.desc: Test method GeometryNodeToJsonValue
1394  * @tc.type: FUNC
1395  */
1396 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest047, TestSize.Level1)
1397 {
1398     /**
1399      * @tc.steps: step1. construct parameters.
1400      */
1401     std::unique_ptr<JsonValue> value = JsonUtil::Create(true);
1402 
1403     /**
1404      * @tc.steps: step2. construct parameters.
1405      * @tc.expected: expect cover branch layoutProperty_ is nullptr.
1406      */
1407     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1408     EXPECT_EQ(FRAME_NODE2->layoutProperty_, nullptr);
1409 
1410     /**
1411      * @tc.steps: step3. set layoutProperty_ and call GeometryNodeToJsonValue.
1412      * @tc.expected: expect cover branch layoutProperty_ is not nullptr.
1413      */
1414     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
1415     FRAME_NODE2->layoutProperty_ = layoutProperty;
1416     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1417     EXPECT_NE(FRAME_NODE2->layoutProperty_, nullptr);
1418 
1419     /**
1420      * @tc.steps: step4. set calcLayoutConstraint_ and call GeometryNodeToJsonValue.
1421      * @tc.expected: expect cover branch calcLayoutConstraint_ is not nullptr.
1422      */
1423     FRAME_NODE2->layoutProperty_->calcLayoutConstraint_ = std::make_unique<MeasureProperty>();
1424 
1425     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1426     EXPECT_NE(FRAME_NODE2->layoutProperty_->calcLayoutConstraint_, nullptr);
1427 
1428     /**
1429      * @tc.steps: step5. set selfIdealSize and call GeometryNodeToJsonValue.
1430      * @tc.expected: expect cover branch selfIdealSize has value.
1431      */
1432     std::optional<CalcLength> len = CalcLength("auto");
1433     FRAME_NODE2->layoutProperty_->calcLayoutConstraint_->selfIdealSize = CalcSize(len, len);
1434     FRAME_NODE2->GeometryNodeToJsonValue(value, filter);
1435     EXPECT_NE(FRAME_NODE2->renderContext_, nullptr);
1436 
1437     FRAME_NODE2->layoutProperty_ = nullptr;
1438 }
1439 
1440 /**
1441  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback048
1442  * @tc.desc: Test frame node method
1443  * @tc.type: FUNC
1444  */
1445 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback048, TestSize.Level1)
1446 {
1447     /**
1448      * @tc.steps: step1. build a object to TriggerVisibleAreaChangeCallback
1449      * @tc.expected: expect The function is run ok.
1450      */
1451     VisibleCallbackInfo callbackInfo;
1452     constexpr uint32_t minInterval = 100; // 100ms
1453     int flag = 0;
__anon26ad9ddd0c02(bool input1, double input2) 1454     callbackInfo.callback = [&flag](bool input1, double input2) { flag += 1; };
1455     callbackInfo.period = minInterval;
1456     FRAME_NODE2->SetVisibleAreaUserCallback({ 0.2, 0.8, 0.21, 0.79, 0.5 }, callbackInfo);
1457     FRAME_NODE2->ProcessThrottledVisibleCallback();
1458     EXPECT_EQ(FRAME_NODE2->throttledCallbackOnTheWay_, false);
1459 }
1460 
1461 /**
1462  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback049
1463  * @tc.desc: Test the function GetValidLeafChildNumber
1464  * @tc.type: FUNC
1465  */
1466 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback049, TestSize.Level1)
1467 {
1468     /**
1469      * @tc.steps: step1. build a object to TriggerVisibleAreaChangeCallback
1470      * @tc.expected: expect The function is run ok.
1471      */
1472     int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
1473     const RefPtr<FrameNode> node =
1474         FrameNode::CreateFrameNode("TriggerVisibleAreaChangeCallback001", nodeId, AceType::MakeRefPtr<Pattern>(), true);
1475 
1476     /**
1477      * @tc.steps2: Call the function GetValidLeafChildNumber.
1478      * @tc.expected: Value returned as expected.
1479      */
1480     EXPECT_EQ(FRAME_NODE2->GetValidLeafChildNumber(node, 1), 1);
1481     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>(), true);
1482     GET_CHILD1->UpdateInspectorId("child1");
1483     node->AddChild(GET_CHILD1);
1484     EXPECT_EQ(FRAME_NODE2->GetValidLeafChildNumber(node, 1), 1);
1485 
1486     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>(), true);
1487     GET_CHILD2->UpdateInspectorId("child2");
1488     node->AddChild(GET_CHILD2);
1489     EXPECT_EQ(FRAME_NODE2->GetValidLeafChildNumber(node, 3), 2);
1490 }
1491 
1492 /**
1493  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback050
1494  * @tc.desc: Test the function MarkAndCheckNewOpIncNode
1495  * @tc.type: FUNC
1496  */
1497 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback050, TestSize.Level1)
1498 {
1499     /**
1500      * @tc.steps: step1. creat node and generate a node tree.
1501      */
1502     RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
1503     RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
1504     RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
1505     GET_PARENT->AddChild(GET_CHILD1);
1506     GET_PARENT->AddChild(GET_CHILD2);
1507     GET_CHILD1->MarkAndCheckNewOpIncNode();
1508     EXPECT_FALSE(GET_PARENT->GetSuggestOpIncActivatedOnce());
1509 
1510     /**
1511      * @tc.steps2: set suggestOpIncByte_ and call the function MarkAndCheckNewOpIncNode.
1512      * @tc.expected: Value returned as expected.
1513      */
1514     GET_PARENT->suggestOpIncByte_ = 7;
1515     GET_CHILD1->SetSuggestOpIncActivatedOnce();
1516     GET_PARENT->SetSuggestOpIncActivatedOnce();
1517     GET_CHILD1->MarkAndCheckNewOpIncNode();
1518     EXPECT_TRUE(GET_PARENT->GetSuggestOpIncActivatedOnce());
1519     GET_CHILD1->suggestOpIncByte_ = 1;
1520     GET_CHILD1->MarkAndCheckNewOpIncNode();
1521 }
1522 
1523 /**
1524  * @tc.name: FrameNodeTouchTest051
1525  * @tc.desc: Test frameNode FindSuggestOpIncNode
1526  * @tc.type: FUNC
1527  */
1528 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest051, TestSize.Level1)
1529 {
1530     /**
1531      * @tc.steps: step1. initialize parameters.
1532      */
1533     std::string tag = "test";
1534     auto frameNode = FrameNode::CreateFrameNode(tag, 1, AceType::MakeRefPtr<Pattern>(), true);
1535     auto frameNode1 = FrameNode::CreateFrameNode("test1", 2, AceType::MakeRefPtr<Pattern>(), true);
1536     frameNode->AddChild(frameNode1);
1537     frameNode->GetBaselineDistance();
1538 
1539     /**
1540      * @tc.steps: step2. set frame size and call FindSuggestOpIncNode
1541      * @tc.expected: expect result value.
1542      */
1543     frameNode->geometryNode_->SetFrameSize(SizeF(20, 20));
1544     auto result = frameNode->FindSuggestOpIncNode(tag, SizeF(0, 0), 1);
1545     EXPECT_EQ(result, 3);
1546     result = frameNode->FindSuggestOpIncNode(tag, SizeF(0, 0), 1);
1547     EXPECT_EQ(result, 2);
1548     SystemProperties::debugEnabled_ = true;
1549     frameNode->suggestOpIncByte_ = 0;
1550     result = frameNode->FindSuggestOpIncNode(tag, SizeF(0, 0), 1);
1551     EXPECT_EQ(result, 3);
1552 }
1553 
1554 /**
1555  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback052
1556  * @tc.desc: Test the function IsOpIncValidNode
1557  * @tc.type: FUNC
1558  */
1559 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback052, TestSize.Level1)
1560 {
1561     /**
1562      * @tc.steps: step1. initialize parameters.
1563      */
1564 
1565     SizeF boundary(1, 1);
1566     int32_t childNumber = 2;
1567 
1568     /**
1569      * @tc.steps2: call the function IsOpIncValidNode.
1570      * @tc.expected: Value returned as expected.
1571      */
1572     auto result = FRAME_NODE2->IsOpIncValidNode(boundary, childNumber);
1573     EXPECT_EQ(result, 2);
1574 
1575     FRAME_NODE2->geometryNode_->SetFrameSize(SizeF(20, 20));
1576     result = FRAME_NODE2->IsOpIncValidNode(boundary, childNumber);
1577     EXPECT_EQ(result, 3);
1578 
1579     SizeF boundary1(40, 40);
1580     FRAME_NODE2->geometryNode_->SetFrameSize(SizeF(20, 20));
1581     result = FRAME_NODE2->IsOpIncValidNode(boundary1, childNumber);
1582     EXPECT_EQ(result, 2);
1583 }
1584 
1585 /**
1586  * @tc.name: FrameNodeTestNg_TriggerVisibleAreaChangeCallback053
1587  * @tc.desc: Test the function MarkSuggestOpIncGroup
1588  * @tc.type: FUNC
1589  */
1590 HWTEST_F(FrameNodeTestNg, FrameNodeTriggerVisibleAreaChangeCallback053, TestSize.Level1)
1591 {
1592     /**
1593      * @tc.steps1: call the function MarkSuggestOpIncGroup.
1594      * @tc.expected: Value returned as expected.
1595      */
1596     EXPECT_TRUE(FRAME_NODE2->MarkSuggestOpIncGroup(true, true));
1597 
1598     FRAME_NODE2->SetCanSuggestOpInc(true);
1599     FRAME_NODE2->SetSuggestOpIncMarked(true);
1600     FRAME_NODE2->SetOpIncGroupCheckedThrough(true);
1601     EXPECT_TRUE(FRAME_NODE2->MarkSuggestOpIncGroup(true, true));
1602 
1603     FRAME_NODE2->SetSuggestOpIncMarked(false);
1604     FRAME_NODE2->SetCanSuggestOpInc(false);
1605     FRAME_NODE2->SetOpIncGroupCheckedThrough(false);
1606     EXPECT_TRUE(FRAME_NODE2->MarkSuggestOpIncGroup(true, true));
1607 }
1608 
1609 /**
1610  * @tc.name: FrameNodeTestNg_IsPaintRectWithTransformValid054
1611  * @tc.desc: Test frame node method IsPaintRectWithTransformValid
1612  * @tc.type: FUNC
1613  */
1614 HWTEST_F(FrameNodeTestNg, FrameNodeIsPaintRectWithTransformValid054, TestSize.Level1)
1615 {
1616     /**
1617      * @tc.steps: step1. callback IsPaintRectWithTransformValid.
1618      * @tc.expected: expect The function return value is true when width or height is nearZero.
1619      */
1620     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1621     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1622     node->renderContext_ = mockRenderContext;
1623 
1624     mockRenderContext->rect_ = RectF(0, 0, 0, 10);
1625     auto test1 = node->IsPaintRectWithTransformValid();
1626     EXPECT_TRUE(test1);
1627 
1628     mockRenderContext->rect_ = RectF(0, 0, 10, 0);
1629     auto test2 = node->IsPaintRectWithTransformValid();
1630     EXPECT_TRUE(test2);
1631 
1632     mockRenderContext->rect_ = RectF(0, 0, 10, 10);
1633     auto test3 = node->IsPaintRectWithTransformValid();
1634     EXPECT_FALSE(test3);
1635 
1636     mockRenderContext->rect_ = RectF(0, 0, 0, 0);
1637     auto test4 = node->IsPaintRectWithTransformValid();
1638     EXPECT_TRUE(test4);
1639 }
1640 
1641 /**
1642  * @tc.name: FrameNodeSetJSCustomProperty055
1643  * @tc.desc: Test SetJSCustomProperty isCNode true, expect result updateFlag is false.
1644  * @tc.type: FUNC
1645  */
1646 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSCustomProperty055, TestSize.Level1)
1647 {
1648     /**
1649      * @tc.steps: step1. initialize parameters.
1650      */
1651     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1652 
1653     /**
1654      * @tc.steps: step2. set isCNode true
1655      * @tc.expected: expect result updateFlag is false.
1656      */
1657     frameNode->setIsCNode(true);
__anon26ad9ddd0d02() 1658     std::function<bool()> func = []() -> bool { return true; };
__anon26ad9ddd0e02(const std::string& key) 1659     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1660         return "getFuncA";
1661     };
1662     frameNode->SetJSCustomProperty(func, getFuncA);
1663     std::string value;
1664     bool updateFlagValue = frameNode->GetCapiCustomProperty("updateFlag", value);
1665     EXPECT_EQ(updateFlagValue, false);
1666 }
1667 
1668 /**
1669  * @tc.name: FrameNodeSetJSCustomProperty056
1670  * @tc.desc: Test SetJSCustomProperty isCNode false and func true, expect result updateFlag is true.
1671  * @tc.type: FUNC
1672  */
1673 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSCustomProperty056, TestSize.Level1)
1674 {
1675     /**
1676      * @tc.steps: step1. initialize parameters.
1677      */
1678     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1679 
1680     /**
1681      * @tc.steps: step2. set isCNode false and func true.
1682      * @tc.expected: expect result updateFlag is true.
1683      */
1684     frameNode->setIsCNode(false);
__anon26ad9ddd0f02() 1685     std::function<bool()> func = []() -> bool { return true; };
__anon26ad9ddd1002(const std::string& key) 1686     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1687         return "getFuncA";
1688     };
1689     frameNode->SetJSCustomProperty(func, getFuncA);
1690     frameNode->setIsCNode(true);
1691     std::string flagValue;
1692     bool updateFlagValue = frameNode->GetCapiCustomProperty("updateFlag", flagValue);
1693     EXPECT_EQ(updateFlagValue, true);
1694     EXPECT_EQ(flagValue, "1");
1695 }
1696 
1697 /**
1698  * @tc.name: FrameNodeSetJSCustomProperty057
1699  * @tc.desc: Test SetJSCustomProperty isCNode false and func false, expect result updateFlag is false.
1700  * @tc.type: FUNC
1701  */
1702 HWTEST_F(FrameNodeTestNg, FrameNodeSetJSCustomProperty057, TestSize.Level1)
1703 {
1704     /**
1705      * @tc.steps: step1. initialize parameters.
1706      */
1707     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1708 
1709     /**
1710      * @tc.steps: step2. set isCNode false and func false.
1711      * @tc.expected: expect result updateFlag is false.
1712      */
1713     frameNode->setIsCNode(false);
__anon26ad9ddd1102() 1714     std::function<bool()> func = []() -> bool { return false; };
__anon26ad9ddd1202(const std::string& key) 1715     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1716         return "getFuncA";
1717     };
1718     frameNode->SetJSCustomProperty(func, getFuncA);
1719     frameNode->setIsCNode(true);
1720     std::string flagValue;
1721     bool updateFlagValue = frameNode->GetCapiCustomProperty("updateFlag", flagValue);
1722     EXPECT_EQ(updateFlagValue, false);
1723 }
1724 
1725 /**
1726  * @tc.name: FrameNodeGetJSCustomProperty058
1727  * @tc.desc: Test GetJSCustomProperty getCustomProperty_ value getFuncA, expect result value getFuncA.
1728  * @tc.type: FUNC
1729  */
1730 HWTEST_F(FrameNodeTestNg, FrameNodeGetJSCustomProperty058, TestSize.Level1)
1731 {
1732     /**
1733      * @tc.steps: step1. initialize parameters.
1734      */
1735     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1736 
1737     /**
1738      * @tc.steps: step2. set getCustomProperty_ value getFuncA.
1739      * @tc.expected: expect result value getFuncA.
1740      */
__anon26ad9ddd1302() 1741     std::function<bool()> func = []() -> bool { return true; };
__anon26ad9ddd1402(const std::string& key) 1742     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1743         return "getFuncA";
1744     };
1745     frameNode->SetJSCustomProperty(func, getFuncA);
1746     std::string getValue;
1747     bool result = frameNode->GetJSCustomProperty("key", getValue);
1748     EXPECT_EQ(result, true);
1749     EXPECT_EQ(getValue, "getFuncA");
1750 }
1751 
1752 /**
1753  * @tc.name: FrameNodeGetJSCustomProperty059
1754  * @tc.desc: Test GetJSCustomProperty getCustomProperty_ nullptr
1755  * @tc.type: FUNC
1756  */
1757 HWTEST_F(FrameNodeTestNg, FrameNodeGetJSCustomProperty059, TestSize.Level1)
1758 {
1759     /**
1760      * @tc.steps: step1. initialize parameters.
1761      */
1762     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1763 
1764     /**
1765      * @tc.steps: step2. set getCustomProperty_ nullptr
1766      * @tc.expected: expect result GetJSCustomProperty false.
1767      */
__anon26ad9ddd1502() 1768     std::function<bool()> func = []() -> bool { return true; };
1769     frameNode->SetJSCustomProperty(func, nullptr);
1770     std::string getValue;
1771     bool result = frameNode->GetJSCustomProperty("key", getValue);
1772     EXPECT_EQ(result, false);
1773 }
1774 
1775 /**
1776  * @tc.name: FrameNodeGetCapiCustomProperty060
1777  * @tc.desc: Test GetCapiCustomProperty no key value value value added.
1778  * @tc.type: FUNC
1779  */
1780 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty060, TestSize.Level1)
1781 {
1782     /**
1783      * @tc.steps: step1. initialize parameters.
1784      */
1785     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1786 
1787     /**
1788      * @tc.steps: step2. GetCapiCustomProperty
1789      * @tc.expected: expect result value false.
1790      */
1791     frameNode->setIsCNode(false);
1792     std::string value;
1793     bool result = frameNode->GetCapiCustomProperty("key", value);
1794     EXPECT_EQ(result, false);
1795 }
1796 
1797 /**
1798  * @tc.name: FrameNodeGetCapiCustomProperty061
1799  * @tc.desc: Test GetCapiCustomProperty the key value value value exists.
1800  * @tc.type: FUNC
1801  */
1802 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty061, TestSize.Level1)
1803 {
1804     /**
1805      * @tc.steps: step1. initialize parameters.
1806      */
1807     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1808 
1809     /**
1810      * @tc.steps: step2. add the key value as value1.
1811      * @tc.expected: expect result value1.
1812      */
1813     frameNode->setIsCNode(true);
1814     frameNode->AddCustomProperty("key", "value1");
1815     std::string value;
1816     bool result = frameNode->GetCapiCustomProperty("key", value);
1817     EXPECT_EQ(result, true);
1818     EXPECT_EQ(value, "value1");
1819 }
1820 
1821 /**
1822  * @tc.name: FrameNodeGetCapiCustomProperty062
1823  * @tc.desc: Test GetCapiCustomProperty the key value does not exist.
1824  * @tc.type: FUNC
1825  */
1826 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty062, TestSize.Level1)
1827 {
1828     /**
1829      * @tc.steps: step1. initialize parameters.
1830      */
1831     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1832 
1833     /**
1834      * @tc.steps: step2. set key is value1
1835      * @tc.expected: expect result value.
1836      */
1837     frameNode->setIsCNode(true);
1838     frameNode->AddCustomProperty("key", "value1");
1839     std::string value;
1840     bool result = frameNode->GetCapiCustomProperty("key1", value);
1841     EXPECT_EQ(result, false);
1842 }
1843 
1844 /**
1845  * @tc.name: FrameNodeRemoveCustomProperty063
1846  * @tc.desc: Test RemoveCustomProperty.
1847  * @tc.type: FUNC
1848  */
1849 HWTEST_F(FrameNodeTestNg, FrameNodeRemoveCustomProperty063, TestSize.Level1)
1850 {
1851     /**
1852      * @tc.steps: step1. initialize parameters.
1853      */
1854     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1855 
1856     /**
1857      * @tc.steps: step2. set key is value1, remove key.
1858      * @tc.expected: expect result false.
1859      */
1860     frameNode->setIsCNode(true);
1861     frameNode->AddCustomProperty("key", "value1");
1862     frameNode->RemoveCustomProperty("key");
1863     std::string value;
1864     bool result = frameNode->GetCapiCustomProperty("key", value);
1865     EXPECT_EQ(result, false);
1866 }
1867 } // namespace OHOS::Ace::NG
1868