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