• 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 <memory>
17 #include <ostream>
18 #include <utility>
19 
20 #include "gtest/gtest.h"
21 
22 #define protected public
23 #define private public
24 
25 #include "test/mock/base/mock_system_properties.h"
26 #include "test/mock/core/common/mock_container.h"
27 #include "test/mock/core/pipeline/mock_pipeline_context.h"
28 
29 #include "base/log/dump_log.h"
30 #include "base/log/log_wrapper.h"
31 #include "core/common/builder_util.h"
32 #include "core/components_ng/base/frame_node.h"
33 #include "core/components_ng/base/ui_node.h"
34 #include "core/components_ng/event/event_hub.h"
35 #include "core/components_ng/event/focus_hub.h"
36 #include "core/components_ng/pattern/pattern.h"
37 #include "core/components_ng/property/property.h"
38 #include "core/pipeline_ng/pipeline_context.h"
39 #include "core/components_ng/base/view_abstract.h"
40 #include "core/components_ng/pattern/navigation/navigation_pattern.h"
41 
42 using namespace testing;
43 using namespace testing::ext;
44 
45 namespace OHOS::Ace::NG {
46 namespace {
47 const RefPtr<FrameNode> TEN0 = FrameNode::CreateFrameNode("zero", 10, AceType::MakeRefPtr<Pattern>(), true);
48 const RefPtr<FrameNode> ZERO = FrameNode::CreateFrameNode("zero", 0, AceType::MakeRefPtr<Pattern>(), true);
49 const RefPtr<FrameNode> ONE = FrameNode::CreateFrameNode("one", 1, AceType::MakeRefPtr<Pattern>(), true);
50 const RefPtr<FrameNode> TWO = FrameNode::CreateFrameNode("two", 2, AceType::MakeRefPtr<Pattern>());
51 const RefPtr<FrameNode> THREE = FrameNode::CreateFrameNode("three", 3, AceType::MakeRefPtr<Pattern>());
52 const RefPtr<FrameNode> FOUR = FrameNode::CreateFrameNode("four", 4, AceType::MakeRefPtr<Pattern>());
53 const RefPtr<FrameNode> FIVE = FrameNode::CreateFrameNode("five", 5, AceType::MakeRefPtr<Pattern>());
54 const RefPtr<FrameNode> F_ONE = FrameNode::CreateFrameNode("one", 5, AceType::MakeRefPtr<Pattern>());
55 const int32_t TEST_ID_ONE = 21;
56 const int32_t TEST_ID_TWO = 22;
57 constexpr size_t SIZE_ZERO = 0;
58 constexpr size_t SIZE_ONE = 1;
59 } // namespace
60 
61 class TestNode : public UINode {
62     DECLARE_ACE_TYPE(TestNode, UINode);
63 
64 public:
CreateTestNode(int32_t nodeId)65     static RefPtr<TestNode> CreateTestNode(int32_t nodeId)
66     {
67         auto spanNode = MakeRefPtr<TestNode>(nodeId);
68         return spanNode;
69     }
70 
IsAtomicNode() const71     bool IsAtomicNode() const override
72     {
73         return true;
74     }
75 
TestNode(int32_t nodeId)76     explicit TestNode(int32_t nodeId) : UINode("TestNode", nodeId) {}
77 
TouchTest(const PointF & globalPoint,const PointF & parentLocalPoint,const PointF & parentRevertPoint,TouchRestrict & touchRestrict,TouchTestResult & result,int32_t touchId,ResponseLinkResult & responseLinkResult,bool isDispatch=false)78     HitTestResult TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const PointF& parentRevertPoint,
79         TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId, ResponseLinkResult& responseLinkResult,
80         bool isDispatch = false) override
81     {
82         return hitTestResult_;
83     }
84 
MouseTest(const PointF & globalPoint,const PointF & parentLocalPoint,MouseTestResult & onMouseResult,MouseTestResult & onHoverResult,RefPtr<FrameNode> & hoverNode)85     HitTestResult MouseTest(const PointF& globalPoint, const PointF& parentLocalPoint, MouseTestResult& onMouseResult,
86         MouseTestResult& onHoverResult, RefPtr<FrameNode>& hoverNode) override
87     {
88         return hitTestResult_;
89     }
90 
AxisTest(const PointF & globalPoint,const PointF & parentLocalPoint,const PointF & parentRevertPoint,TouchRestrict & touchRestrict,AxisTestResult & axisResult)91     HitTestResult AxisTest(const PointF &globalPoint, const PointF &parentLocalPoint, const PointF &parentRevertPoint,
92         TouchRestrict &touchRestrict, AxisTestResult &axisResult) override
93     {
94         return hitTestResult_;
95     }
96 
97     ~TestNode() override = default;
98 
99 private:
100     HitTestResult hitTestResult_;
101 };
102 
103 class UINodeTestNg : public testing::Test {
104 public:
105     static void SetUpTestSuite();
106     static void TearDownTestSuite();
107 };
108 
SetUpTestSuite()109 void UINodeTestNg::SetUpTestSuite()
110 {
111     MockPipelineContext::SetUp();
112 }
113 
TearDownTestSuite()114 void UINodeTestNg::TearDownTestSuite()
115 {
116     MockPipelineContext::TearDown();
117 }
118 
119 /**
120  * @tc.name: UINodeTestNg001
121  * @tc.desc: Test ui node method
122  * @tc.type: FUNC
123  */
124 HWTEST_F(UINodeTestNg, UINodeTestNg001, TestSize.Level1)
125 {
126     /**
127      * @tc.steps: step1. AddChild
128      * @tc.expected: children_.size = 2
129      */
130     ONE->AddChild(TWO, 1, false);
131     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
132     auto testNode2 = TestNode::CreateTestNode(TEST_ID_TWO);
133     ONE->AddChild(testNode, 1, false);
134     ONE->AddChild(testNode, 1, false);
135     ONE->AddChild(testNode2, 1, false);
136     EXPECT_EQ(ONE->children_.size(), 3);
137     /**
138      * @tc.steps: step2. remove child three
139      */
140     auto iter = ONE->RemoveChild(FOUR);
141     EXPECT_EQ(iter, ONE->children_.end());
142     ONE->RemoveChild(testNode);
143     ONE->RemoveChild(testNode2, true);
144     /**
145      * @tc.steps: step3. remove child two
146      * @tc.expected: distance = 0
147      */
148     auto distance = ONE->RemoveChildAndReturnIndex(TWO);
149     EXPECT_EQ(distance, 0);
150 }
151 
152 /**
153  * @tc.name: UINodeTestNg002
154  * @tc.desc: Test ui node method
155  * @tc.type: FUNC
156  */
157 HWTEST_F(UINodeTestNg, UINodeTestNg002, TestSize.Level1)
158 {
159     ONE->RemoveChildAtIndex(-1);
160     ONE->AddChild(TWO, 1, false);
161     /**
162      * @tc.steps: step1. RemoveChildAtIndex
163      * @tc.expected: children_.size = 0
164      */
165     ONE->RemoveChildAtIndex(0);
166     EXPECT_EQ(ONE->children_.size(), 0);
167     /**
168      * @tc.steps: step2. GetChildAtIndex
169      * @tc.expected: return nullptr
170      */
171     auto result = ONE->GetChildAtIndex(0);
172     EXPECT_EQ(result, nullptr);
173     ONE->AddChild(TWO, 1, false);
174     auto node = ONE->GetChildAtIndex(0);
175     EXPECT_EQ(strcmp(node->GetTag().c_str(), "two"), 0);
176 }
177 
178 /**
179  * @tc.name: UINodeTestNg003
180  * @tc.desc: Test ui node method
181  * @tc.type: FUNC
182  */
183 HWTEST_F(UINodeTestNg, UINodeTestNg003, TestSize.Level1)
184 {
185     ONE->AddChild(TWO, 1, false);
186     /**
187      * @tc.steps: step1. ReplaceChild
188      * @tc.expected: size = 2
189      */
190     ONE->ReplaceChild(nullptr, THREE);
191     ONE->ReplaceChild(TWO, FOUR);
192     EXPECT_EQ(ONE->children_.size(), 2);
193     /**
194      * @tc.steps: step2. set TWO's hostPageId_ 1 and Clean
195      * @tc.expected: children_ = 0
196      */
197     TWO->hostPageId_ = 1;
198     ONE->MountToParent(TWO, 1, false);
199     ONE->Clean();
200     EXPECT_EQ(ONE->children_.size(), 0);
201 }
202 
203 /**
204  * @tc.name: UINodeTestNg004
205  * @tc.desc: Test ui node method
206  * @tc.type: FUNC
207  */
208 HWTEST_F(UINodeTestNg, UINodeTestNg004, TestSize.Level1)
209 {
210     /**
211      * @tc.steps: step1. GetFocusParent
212      * @tc.expected: parent is nullptr
213      */
214     auto frameNode = ONE->GetFocusParent();
215     EXPECT_EQ(frameNode, nullptr);
216     FocusType focusTypes[3] = { FocusType::SCOPE, FocusType::NODE, FocusType::DISABLE };
217     auto parent = FrameNode::CreateFrameNode("parent", 2, AceType::MakeRefPtr<Pattern>());
218     RefPtr<FrameNode> frameNodes[3] = { parent, nullptr, nullptr };
219     /**
220      * @tc.steps: step2. GetFocusParent adjust FocusType
221      * @tc.expected: result is parent and nullptr
222      */
223     for (int i = 0; i < 3; ++i) {
224         RefPtr<EventHub> eventHub = AceType::MakeRefPtr<EventHub>();
225         auto focusHub = AceType::MakeRefPtr<FocusHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)), focusTypes[i]);
226         parent->focusHub_ = focusHub;
227         parent->eventHub_ = eventHub;
228         ONE->parent_ = parent;
229         auto result = ONE->GetFocusParent();
230         EXPECT_EQ(result, frameNodes[i]);
231     }
232     /**
233      * @tc.steps: step3. create test node and try GetFirstFocusHubChild
234      * @tc.expected: result is null
235      */
236     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
237     EXPECT_EQ(testNode->GetFirstFocusHubChild(), nullptr);
238     /**
239      * @tc.steps: step4. config node parent and GetFocusParent;
240      * @tc.expected: result is null
241      */
242     ONE->parent_ = testNode;
243     testNode->parent_ = parent;
244     auto result = ONE->GetFocusParent();
245     EXPECT_EQ(result, nullptr);
246 }
247 
248 /**
249  * @tc.name: UINodeTestNg005
250  * @tc.desc: Test ui node method
251  * @tc.type: FUNC
252  */
253 HWTEST_F(UINodeTestNg, UINodeTestNg005, TestSize.Level1)
254 {
255     /**
256      * @tc.steps: step1. GetFocusChildren
257      * @tc.expected: THREE's children size is 2
258      */
259     std::list<RefPtr<FrameNode>> children;
260     RefPtr<EventHub> eventHubTwo = AceType::MakeRefPtr<EventHub>();
261     auto focusHubTwo = AceType::MakeRefPtr<FocusHub>(AceType::WeakClaim(AceType::RawPtr(eventHubTwo)), FocusType::NODE);
262     RefPtr<EventHub> eventHubFour = AceType::MakeRefPtr<EventHub>();
263     auto focusHubFour = AceType::MakeRefPtr<FocusHub>(
264         AceType::WeakClaim(AceType::RawPtr(eventHubFour)), FocusType::DISABLE);
265     TWO->focusHub_ = focusHubTwo;
266     TWO->eventHub_ = eventHubTwo;
267     FOUR->focusHub_ = focusHubFour;
268     FOUR->eventHub_ = eventHubFour;
269     THREE->AddChild(TWO, 1, false);
270     THREE->AddChild(FOUR, 1, false);
271     THREE->AddChild(TestNode::CreateTestNode(TEST_ID_ONE), 1, false);
272     THREE->GetFocusChildren(children);
273     EXPECT_EQ(THREE->children_.size(), 3);
274     THREE->Clean();
275 }
276 
277 /**
278  * @tc.name: UINodeTestNg006
279  * @tc.desc: Test ui node method
280  * @tc.type: FUNC
281  */
282 HWTEST_F(UINodeTestNg, UINodeTestNg006, TestSize.Level1)
283 {
284     /**
285      * @tc.steps: step1. AttachToMainTree and DetachFromMainTree
286      * @tc.expected: onMainTree_ is false
287      */
288     bool mainTrees[2] = { true, false };
289     TWO->AddChild(THREE, 1, false);
290     for (int i = 0; i < 2; ++i) {
291         TWO->onMainTree_ = mainTrees[i];
292         TWO->AttachToMainTree();
293         TWO->DetachFromMainTree();
294         EXPECT_FALSE(TWO->onMainTree_);
295     }
296     TWO->Clean();
297 }
298 
299 /**
300  * @tc.name: UINodeTestNg007
301  * @tc.desc: Test ui node method
302  * @tc.type: FUNC
303  */
304 HWTEST_F(UINodeTestNg, UINodeTestNg007, TestSize.Level1)
305 {
306     /**
307      * @tc.steps: step1. MovePosition
308      * @tc.expected: children_.size is 2
309      */
310     int32_t slots[4] = { 1, -1, 1, 2 };
311     THREE->AddChild(FOUR);
312     THREE->AddChild(FIVE);
313     TWO->parent_ = THREE;
314     for (int i = 0; i < 4; ++i) {
315         TWO->MovePosition(slots[i]);
316     }
317     EXPECT_EQ(THREE->children_.size(), 3);
318     THREE->Clean();
319 }
320 
321 /**
322  * @tc.name: UINodeTestNg008
323  * @tc.desc: Test ui node method
324  * @tc.type: FUNC
325  */
326 HWTEST_F(UINodeTestNg, UINodeTestNg008, TestSize.Level1)
327 {
328     PropertyChangeFlag FLAG = 1;
329     ONE->children_.clear();
330     TWO->children_.clear();
331     THREE->children_.clear();
332     ONE->AddChild(TWO, 1, false);
333     ONE->parent_ = THREE;
334     ONE->UINode::UpdateLayoutPropertyFlag();
335     ONE->UINode::AdjustParentLayoutFlag(FLAG);
336     ONE->UINode::MarkNeedSyncRenderTree();
337     ONE->UINode::RebuildRenderContextTree();
338     ONE->DumpTree(0);
339     EXPECT_EQ(ONE->children_.size(), 1);
340 }
341 
342 /**
343  * @tc.name: UINodeTestNg009
344  * @tc.desc: Test ui node method
345  * @tc.type: FUNC
346  */
347 HWTEST_F(UINodeTestNg, UINodeTestNg009, TestSize.Level1)
348 {
349     /**
350      * @tc.steps: step1. FrameCount and GetChildIndexById
351      * @tc.expected: count is 2, pos is 0
352      */
353     int32_t count = ONE->FrameCount();
354     EXPECT_EQ(count, 1);
355     int32_t id1 = ONE->GetChildIndexById(4);
356     int32_t id2 = ONE->GetChildIndexById(2);
357     EXPECT_EQ(id1, -1);
358     EXPECT_EQ(id2, 0);
359     /**
360      * @tc.steps: step2. GetChildFlatIndex
361      * @tc.expected: count is 2, pos is 0
362      */
363     auto pair1 = ONE->GetChildFlatIndex(1);
364     EXPECT_EQ(pair1.second, 0);
365     auto pair2 = ONE->GetChildFlatIndex(2);
366     EXPECT_EQ(pair2.second, 0);
367 }
368 
369 /**
370  * @tc.name: UINodeTestNg010
371  * @tc.desc: Test ui node method
372  * @tc.type: FUNC
373  */
374 HWTEST_F(UINodeTestNg, UINodeTestNg010, TestSize.Level1)
375 {
376     /**
377      * @tc.steps: step1. call the GetChildIndex and set input is null
378      * @tc.expected: the return value is -1
379      */
380     int retIndex = ZERO->GetChildIndex(nullptr);
381     EXPECT_EQ(retIndex, -1);
382     /**
383      * @tc.steps: step2. add one child for ZERO and call GetChildIndex
384      * @tc.expected: step2. the return value is 0
385      */
386     ZERO->AddChild(ONE);
387     retIndex = ZERO->GetChildIndex(ONE);
388     EXPECT_EQ(retIndex, 0);
389     /**
390      * @tc.steps: step3. add two child for ZERO and call GetChildIndex
391      * @tc.expected: the return value is 1
392      */
393     ZERO->AddChild(TWO);
394     retIndex = ZERO->GetChildIndex(TWO);
395     EXPECT_EQ(retIndex, 1);
396     /**
397      * @tc.steps: step4. add three child for ZERO and call GetChildIndex
398      * @tc.expected: the return value is 2
399      */
400     ZERO->AddChild(THREE);
401     retIndex = ZERO->GetChildIndex(THREE);
402     EXPECT_EQ(retIndex, 2);
403     ZERO->Clean();
404 }
405 
406 /**
407  * @tc.name: UINodeTestNg011
408  * @tc.desc: Test ui node method
409  * @tc.type: FUNC
410  */
411 HWTEST_F(UINodeTestNg, UINodeTestNg011, TestSize.Level1)
412 {
413     /**
414      * @tc.steps: step1. call the MountToParent and set hostPageId_ is 0
415      * @tc.expected: step2. mount failure
416      */
417     ZERO->hostPageId_ = 0;
418     ONE->MountToParent(ZERO, 1, false);
419     int retPageId = ONE->GetPageId();
420     EXPECT_NE(retPageId, 0);
421     ONE->Clean();
422     /**
423      * @tc.steps: step2. call the MountToParent and set hostPageId_ is 0
424      * @tc.expected: mount sucess and pageid is 1
425      */
426     ZERO->hostPageId_ = 1;
427     ZERO->SetInDestroying();
428     ONE->MountToParent(ZERO, 1, false);
429     retPageId = ONE->GetPageId();
430     EXPECT_EQ(retPageId, 1);
431     ZERO->SetDestroying(false);
432     ONE->Clean();
433     ZERO->Clean();
434 }
435 
436 /**
437  * @tc.name: UINodeTestNg012
438  * @tc.desc: Test ui node method
439  * @tc.type: FUNC
440  */
441 HWTEST_F(UINodeTestNg, UINodeTestNg012, TestSize.Level1)
442 {
443     /**
444      * @tc.steps: step1. call the GetFirstFocusHubChild function
445      * @tc.expected: the return value is null
446      */
447     RefPtr<FocusHub> retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
448     EXPECT_EQ(retFirstFocusHubChild, nullptr);
449     /**
450      * @tc.steps: step2. call the GetFirstFocusHubChild functionand and set focus type is DISABLE
451      * @tc.expected: the return value is null
452      */
453     RefPtr<EventHub> eventHubZero = AceType::MakeRefPtr<EventHub>();
454     auto focusHubZero = AceType::MakeRefPtr<FocusHub>(
455         AceType::WeakClaim(AceType::RawPtr(eventHubZero)), FocusType::DISABLE);
456 
457     ZERO->focusHub_ = focusHubZero;
458     ZERO->eventHub_ = eventHubZero;
459     retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
460     EXPECT_EQ(retFirstFocusHubChild, nullptr);
461     /**
462      * @tc.steps: step3. call the GetFirstFocusHubChild functionand set focus type is NODE
463      * @tc.expected: the return focusHub type is NODE
464      */
465     focusHubZero = AceType::MakeRefPtr<FocusHub>(AceType::WeakClaim(AceType::RawPtr(eventHubZero)), FocusType::NODE);
466 
467     ZERO->focusHub_ = focusHubZero;
468     ZERO->eventHub_ = eventHubZero;
469     retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
470     EXPECT_EQ(retFirstFocusHubChild->GetFocusType(), FocusType::NODE);
471     ZERO->Clean();
472     /**
473      * @tc.steps: step4. call the GetFirstFocusHubChild functionand set focus type is SCOPE
474      * @tc.expected: the return focusHub type is SCOPE
475      */
476     focusHubZero = AceType::MakeRefPtr<FocusHub>(AceType::WeakClaim(AceType::RawPtr(eventHubZero)), FocusType::SCOPE);
477 
478     ZERO->focusHub_ = focusHubZero;
479     ZERO->eventHub_ = eventHubZero;
480     retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
481     EXPECT_EQ(retFirstFocusHubChild->GetFocusType(), FocusType::SCOPE);
482     ZERO->Clean();
483 }
484 
485 /**
486  * @tc.name: UINodeTestNg013
487  * @tc.desc: Test ui node method
488  * @tc.type: FUNC
489  */
490 HWTEST_F(UINodeTestNg, UINodeTestNg013, TestSize.Level1)
491 {
492     /**
493      * @tc.steps: step1. add one child to ZERO and set focus type is NODE
494      * @tc.expected: the return focusHub type is NODE
495      */
496     RefPtr<EventHub> eventHubZero = AceType::MakeRefPtr<EventHub>();
497     auto focusHubZero = AceType::MakeRefPtr<FocusHub>(
498         AceType::WeakClaim(AceType::RawPtr(eventHubZero)), FocusType::DISABLE);
499     RefPtr<EventHub> eventHubOne = AceType::MakeRefPtr<EventHub>();
500     auto focusHubOne = AceType::MakeRefPtr<FocusHub>(AceType::WeakClaim(AceType::RawPtr(eventHubOne)), FocusType::NODE);
501 
502     ZERO->focusHub_ = focusHubZero;
503     ZERO->eventHub_ = eventHubZero;
504     ONE->focusHub_ = focusHubOne;
505     ONE->eventHub_ = eventHubOne;
506 
507     ZERO->AddChild(ONE, 1, false);
508     RefPtr<FocusHub> retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
509     EXPECT_EQ(retFirstFocusHubChild->GetFocusType(), FocusType::NODE);
510     ZERO->Clean();
511     /**
512      * @tc.steps: step2. add one child to ZERO and set focus type is DISABLE
513      * @tc.expected: the return value is null
514      */
515     focusHubOne = AceType::MakeRefPtr<FocusHub>(AceType::WeakClaim(AceType::RawPtr(eventHubOne)), FocusType::DISABLE);
516 
517     ONE->focusHub_ = focusHubOne;
518     ONE->eventHub_ = eventHubOne;
519     ZERO->AddChild(ONE, 1, false);
520     retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
521     EXPECT_EQ(retFirstFocusHubChild, nullptr);
522     ZERO->Clean();
523 }
524 
525 /**
526  * @tc.name: UINodeTestNg014
527  * @tc.desc: Test ui node method
528  * @tc.type: FUNC
529  */
530 HWTEST_F(UINodeTestNg, UINodeTestNg014, TestSize.Level1)
531 {
532     /**
533      * @tc.steps: step1. add one child to ZERO and set focus type is SCOPE
534      * @tc.expected: the return focusHub type is SCOPE
535      */
536     RefPtr<EventHub> eventHubZero = AceType::MakeRefPtr<EventHub>();
537     auto focusHubZero = AceType::MakeRefPtr<FocusHub>(
538         AceType::WeakClaim(AceType::RawPtr(eventHubZero)), FocusType::DISABLE);
539     RefPtr<EventHub> eventHubOne = AceType::MakeRefPtr<EventHub>();
540     auto focusHubOne = AceType::MakeRefPtr<FocusHub>(
541         AceType::WeakClaim(AceType::RawPtr(eventHubOne)), FocusType::SCOPE);
542 
543     ZERO->focusHub_ = focusHubZero;
544     ZERO->eventHub_ = eventHubZero;
545     ONE->focusHub_ = focusHubOne;
546     ONE->eventHub_ = eventHubOne;
547 
548     ZERO->AddChild(ONE, 1, false);
549     RefPtr<FocusHub> retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
550     EXPECT_EQ(retFirstFocusHubChild->GetFocusType(), FocusType::SCOPE);
551     ZERO->Clean();
552     /**
553      * @tc.steps: step2. add one child to ZERO and set focus type is DISABLE
554      * @tc.expected: the return value is null
555      */
556     focusHubOne = AceType::MakeRefPtr<FocusHub>(AceType::WeakClaim(AceType::RawPtr(eventHubOne)), FocusType::DISABLE);
557 
558     ONE->focusHub_ = focusHubOne;
559     ONE->eventHub_ = eventHubOne;
560     ZERO->AddChild(ONE, 1, false);
561     retFirstFocusHubChild = ZERO->GetFirstFocusHubChild();
562     EXPECT_EQ(retFirstFocusHubChild, nullptr);
563     ZERO->Clean();
564 }
565 
566 /**
567  * @tc.name: UINodeTestNg015
568  * @tc.desc: Test ui node method
569  * @tc.type: FUNC
570  */
571 HWTEST_F(UINodeTestNg, UINodeTestNg015, TestSize.Level1)
572 {
573     /**
574      * @tc.steps: step1. call the MovePosition and set parent_ is null
575      * @tc.expected: parentNode is null
576      */
577     ZERO->parent_ = nullptr;
578     ZERO->MovePosition(1);
579     RefPtr<UINode> retParent = ZERO->GetParent();
580     EXPECT_EQ(retParent, nullptr);
581 }
582 
583 /**
584  * @tc.name: UINodeTestNg016
585  * @tc.desc: Test ui node method
586  * @tc.type: FUNC
587  */
588 HWTEST_F(UINodeTestNg, UINodeTestNg016, TestSize.Level1)
589 {
590     /**
591      * @tc.steps: step1. set propertyChangeFlag_ is PROPERTY_UPDATE_NORMAL and call the MarkDirtyNode
592      * @tc.expected: the MarkDirtyNode function is run ok and children_.size() is 1
593      */
594     PropertyChangeFlag extraFLAG = PROPERTY_UPDATE_NORMAL;
595     ZERO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_NORMAL;
596     ONE->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_NORMAL;
597 
598     ZERO->AddChild(ONE, 1, false);
599     ZERO->UINode::MarkDirtyNode(extraFLAG);
600     EXPECT_EQ(ZERO->children_.size(), 1);
601     ZERO->Clean();
602     /**
603      * @tc.steps: step2. set propertyChangeFlag_ is PROPERTY_UPDATE_MEASURE and call the MarkDirtyNode
604      * @tc.expected: the MarkDirtyNode function is run ok and children_.size() is 1
605      */
606     extraFLAG = PROPERTY_UPDATE_MEASURE;
607     ZERO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_MEASURE;
608     ONE->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_MEASURE;
609     ZERO->AddChild(ONE, 1, false);
610     ZERO->UINode::MarkDirtyNode(extraFLAG);
611     EXPECT_EQ(ZERO->children_.size(), 1);
612     ZERO->Clean();
613     /**
614      * @tc.steps: step3. set propertyChangeFlag_ is PROPERTY_UPDATE_LAYOUT and call the MarkDirtyNode
615      * @tc.expected: the MarkDirtyNode function is run ok and children_.size() is 1
616      */
617     extraFLAG = PROPERTY_UPDATE_LAYOUT;
618     ZERO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_LAYOUT;
619     ONE->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_LAYOUT;
620     ZERO->AddChild(ONE, 1, false);
621     ZERO->UINode::MarkDirtyNode(extraFLAG);
622     EXPECT_EQ(ZERO->children_.size(), 1);
623     ZERO->Clean();
624 }
625 
626 /**
627  * @tc.name: UINodeTestNg017
628  * @tc.desc: Test ui node method
629  * @tc.type: FUNC
630  */
631 HWTEST_F(UINodeTestNg, UINodeTestNg017, TestSize.Level1)
632 {
633     /**
634      * @tc.steps: step1. set propertyChangeFlag_ is PROPERTY_UPDATE_NORMAL and call the MarkNeedFrameFlushDirty
635      * @tc.expected: the MarkNeedFrameFlushDirty function is run ok
636      */
637     PropertyChangeFlag extraFLAG = PROPERTY_UPDATE_NORMAL;
638     ZERO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_NORMAL;
639     ONE->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_NORMAL;
640 
641     ZERO->UINode::MarkNeedFrameFlushDirty(extraFLAG);
642     EXPECT_EQ(ZERO->parent_.Upgrade(), nullptr);
643     /**
644      * @tc.steps: step2. set one parent_ for ONE and call the MarkNeedFrameFlushDirty
645      * @tc.expected: the MarkNeedFrameFlushDirty function is run ok and parent_ is not null
646      */
647     ZERO->parent_ = ONE;
648     ZERO->UINode::MarkNeedFrameFlushDirty(extraFLAG);
649     ASSERT_NE(ZERO->parent_.Upgrade(), nullptr);
650     ZERO->Clean();
651     ZERO->parent_.Reset();
652     /**
653      * @tc.steps: step3. set propertyChangeFlag_ is PROPERTY_UPDATE_MEASURE and call the MarkNeedFrameFlushDirty
654      * @tc.expected: the MarkNeedFrameFlushDirty function is run ok
655      */
656     extraFLAG = PROPERTY_UPDATE_MEASURE;
657     ZERO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_MEASURE;
658     ONE->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_MEASURE;
659 
660     ZERO->UINode::MarkNeedFrameFlushDirty(extraFLAG);
661     EXPECT_EQ(ZERO->parent_.Upgrade(), nullptr);
662     /**
663      * @tc.steps: step4. set one parent_ for ONE and call the MarkNeedFrameFlushDirty
664      * @tc.expected: the MarkNeedFrameFlushDirty function is run ok and parent_ is not null
665      */
666     ZERO->parent_ = ONE;
667     ZERO->UINode::MarkNeedFrameFlushDirty(extraFLAG);
668     ASSERT_NE(ZERO->parent_.Upgrade(), nullptr);
669     ZERO->Clean();
670     ZERO->parent_.Reset();
671     /**
672      * @tc.steps: step5. set propertyChangeFlag_ is PROPERTY_UPDATE_LAYOUT and call the MarkNeedFrameFlushDirty
673      * @tc.expected: the MarkNeedFrameFlushDirty function is run ok
674      */
675     extraFLAG = PROPERTY_UPDATE_LAYOUT;
676     ZERO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_LAYOUT;
677     ONE->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_LAYOUT;
678 
679     ZERO->UINode::MarkNeedFrameFlushDirty(extraFLAG);
680     EXPECT_EQ(ZERO->parent_.Upgrade(), nullptr);
681     /**
682      * @tc.steps: step6. set one parent_ for ONE and call the MarkNeedFrameFlushDirty
683      * @tc.expected: the MarkNeedFrameFlushDirty function is run ok and parent_ is not null
684      */
685     ZERO->parent_ = ONE;
686     ZERO->UINode::MarkNeedFrameFlushDirty(extraFLAG);
687     ASSERT_NE(ZERO->parent_.Upgrade(), nullptr);
688     ZERO->Clean();
689     ZERO->parent_.Reset();
690 }
691 
692 /**
693  * @tc.name: UINodeTestNg018
694  * @tc.desc: Test ui node method
695  * @tc.type: FUNC
696  */
697 HWTEST_F(UINodeTestNg, UINodeTestNg018, TestSize.Level1)
698 {
699     /**
700      * @tc.steps: step1. set ZERO->parent_ is null and call MarkNeedSyncRenderTree
701      * @tc.expected: the MarkNeedSyncRenderTree function is run ok
702      */
703     ZERO->UINode::MarkNeedSyncRenderTree();
704     EXPECT_EQ(ZERO->parent_.Upgrade(), nullptr);
705     /**
706      * @tc.steps: step2. set ZERO->parent_ is null and call RebuildRenderContextTree
707      * @tc.expected: the RebuildRenderContextTree function is run ok
708      */
709     ZERO->UINode::RebuildRenderContextTree();
710     EXPECT_EQ(ZERO->parent_.Upgrade(), nullptr);
711 }
712 
713 /**
714  * @tc.name: UINodeTestNg019
715  * @tc.desc: Test ui node method
716  * @tc.type: FUNC
717  */
718 HWTEST_F(UINodeTestNg, UINodeTestNg019, TestSize.Level1)
719 {
720     /**
721      * @tc.steps: step1. call the DetachFromMainTree
722      * @tc.expected: onMainTree_ is false
723      */
724     bool mainTree = true;
725     ZERO->onMainTree_ = mainTree;
726     ZERO->DetachFromMainTree();
727     EXPECT_FALSE(ZERO->onMainTree_);
728     ZERO->Clean();
729     ZERO->UINode::OnDetachFromMainTree();
730 }
731 
732 /**
733  * @tc.name: UINodeTestNg020
734  * @tc.desc: Test ui node method
735  * @tc.type: FUNC
736  */
737 HWTEST_F(UINodeTestNg, UINodeTestNg020, TestSize.Level1)
738 {
739     /**
740      * @tc.steps: step1. add one child for ZERO and call AdjustLayoutWrapperTree
741      * @tc.expected: children_.size is 1 and the AdjustLayoutWrapperTree function is run ok
742      */
743     ZERO->AddChild(ONE, 1, false);
744     RefPtr<LayoutWrapperNode> retLayoutWrapper = ZERO->UINode::CreateLayoutWrapper(true, true);
745     ZERO->UINode::AdjustLayoutWrapperTree(retLayoutWrapper, true, true);
746     EXPECT_EQ(ZERO->children_.size(), 1);
747     ZERO->Clean();
748 }
749 
750 /**
751  * @tc.name: UINodeTestNg021
752  * @tc.desc: Test ui node method
753  * @tc.type: FUNC
754  */
755 HWTEST_F(UINodeTestNg, UINodeTestNg021, TestSize.Level1)
756 {
757     /**
758      * @tc.steps: step1. add one child for ZERO and call GenerateOneDepthVisibleFrame
759      * @tc.expected: children_.size is 1 and the GenerateOneDepthVisibleFrame function is run ok
760      */
761     std::list<RefPtr<FrameNode>> visibleList;
762 
763     ZERO->AddChild(ONE, 1, false);
764     ZERO->GenerateOneDepthVisibleFrame(visibleList);
765     EXPECT_EQ(ZERO->children_.size(), 1);
766     ZERO->Clean();
767 }
768 
769 /**
770  * @tc.name: UINodeTestNg022
771  * @tc.desc: Test ui node method
772  * @tc.type: FUNC
773  */
774 HWTEST_F(UINodeTestNg, UINodeTestNg022, TestSize.Level1)
775 {
776     /**
777      * @tc.steps: step1. add one child for ZERO and call GenerateOneDepthAllFrame
778      * @tc.expected: children_.size is 1 and the GenerateOneDepthAllFrame function is run ok
779      */
780     std::list<RefPtr<FrameNode>> visibleList;
781 
782     ZERO->AddChild(ONE, 1, false);
783     ZERO->GenerateOneDepthAllFrame(visibleList);
784     EXPECT_EQ(ZERO->children_.size(), 1);
785     ZERO->Clean();
786 }
787 
788 /**
789  * @tc.name: UINodeTestNg023
790  * @tc.desc: Test ui node method
791  * @tc.type: FUNC
792  */
793 HWTEST_F(UINodeTestNg, UINodeTestNg023, TestSize.Level1)
794 {
795     /**
796      * @tc.steps: step1. add one child for ZERO and call TouchTest
797      * @tc.expected: the return value is meetings expectations
798      */
799     TouchTestResult result;
800     ResponseLinkResult responseLinkResult;
801     TouchRestrict restrict;
802     const PointF GLOBAL_POINT { 20.0f, 20.0f };
803     const PointF LOCAL_POINT { 15.0f, 15.0f };
804     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
805     ZERO->AddChild(testNode, 1, false);
806     HitTestResult retResult =
807         ZERO->UINode::TouchTest(GLOBAL_POINT, LOCAL_POINT, LOCAL_POINT, restrict, result, 1, responseLinkResult);
808     EXPECT_EQ(retResult, HitTestResult::OUT_OF_REGION);
809     testNode->hitTestResult_ = HitTestResult::STOP_BUBBLING;
810     retResult =
811         ZERO->UINode::TouchTest(GLOBAL_POINT, LOCAL_POINT, LOCAL_POINT, restrict, result, 1, responseLinkResult);
812     EXPECT_EQ(retResult, HitTestResult::STOP_BUBBLING);
813     testNode->hitTestResult_ = HitTestResult::BUBBLING;
814     retResult =
815         ZERO->UINode::TouchTest(GLOBAL_POINT, LOCAL_POINT, LOCAL_POINT, restrict, result, 1, responseLinkResult);
816     EXPECT_EQ(retResult, HitTestResult::BUBBLING);
817     ZERO->Clean();
818 }
819 
820 /**
821  * @tc.name: UINodeTestNg026
822  * @tc.desc: Test ui node method
823  * @tc.type: FUNC
824  */
825 HWTEST_F(UINodeTestNg, UINodeTestNg026, TestSize.Level1)
826 {
827     /**
828      * @tc.steps: step1. add one child for ZERO and call TotalChildCount
829      * @tc.expected: the return retCount is 1
830      */
831     ZERO->AddChild(ONE, 1, false);
832     int32_t retCount = ZERO->UINode::FrameCount();
833     EXPECT_EQ(retCount, 1);
834     /**
835      * @tc.steps: step2. add two child for ZERO and call TotalChildCount
836      * @tc.expected: the return retCount is 2
837      */
838     ZERO->AddChild(TWO, 2, false);
839     retCount = ZERO->TotalChildCount();
840     EXPECT_EQ(retCount, 2);
841     /**
842      * @tc.steps: step3. add three child for ZERO and call TotalChildCount
843      * @tc.expected: the return retCount is 3
844      */
845     ZERO->AddChild(THREE, 3, false);
846     retCount = ZERO->TotalChildCount();
847     EXPECT_EQ(retCount, 3);
848     /**
849      * @tc.steps: step4. add four child for ZERO and call TotalChildCount
850      * @tc.expected: the return retCount is 4
851      */
852     ZERO->AddChild(FOUR, 4, false);
853     retCount = ZERO->TotalChildCount();
854     EXPECT_EQ(retCount, 4);
855     ZERO->Clean();
856     /**
857      * @tc.steps: step5. clean ZERO's child and TotalChildCount
858      * @tc.expected: the return retCount is 0
859      */
860     retCount = ZERO->TotalChildCount();
861     EXPECT_EQ(retCount, 0);
862 }
863 
864 /**
865  * @tc.name: UINodeTestNg027
866  * @tc.desc: Test ui node method
867  * @tc.type: FUNC
868  */
869 HWTEST_F(UINodeTestNg, UINodeTestNg027, TestSize.Level1)
870 {
871     /**
872      * @tc.steps: step1. add one child for ZERO and call Build
873      * @tc.expected: the Build function is run ok
874      */
875     ZERO->AddChild(ONE, 1, false);
876     ZERO->Build(nullptr);
877     EXPECT_EQ(ZERO->children_.size(), 1);
878     ZERO->Clean();
879 }
880 
881 /**
882  * @tc.name: UINodeTestNg028
883  * @tc.desc: Test ui node method
884  * @tc.type: FUNC
885  */
886 HWTEST_F(UINodeTestNg, UINodeTestNg028, TestSize.Level1)
887 {
888     /**
889      * @tc.steps: step1. add one child for ZERO and call SetActive
890      * @tc.expected: the SetActive function is run ok
891      */
892     ZERO->AddChild(ONE, 1, false);
893     ZERO->UINode::SetActive(true);
894     EXPECT_EQ(ZERO->children_.size(), 1);
895     ZERO->Clean();
896 }
897 
898 /**
899  * @tc.name: UINodeTestNg029
900  * @tc.desc: Test ui node method
901  * @tc.type: FUNC
902  */
903 HWTEST_F(UINodeTestNg, UINodeTestNg029, TestSize.Level1)
904 {
905     /**
906      * @tc.steps: step1. add one child for ZERO and call TryVisibleChangeOnDescendant
907      * @tc.expected: the TryVisibleChangeOnDescendant function is run ok
908      */
909     ZERO->AddChild(ONE, 1, false);
910     ZERO->UINode::TryVisibleChangeOnDescendant(VisibleType::INVISIBLE, VisibleType::VISIBLE);
911     EXPECT_EQ(ZERO->children_.size(), 1);
912     ZERO->Clean();
913 }
914 
915 /**
916  * @tc.name: UINodeTestNg030
917  * @tc.desc: Test ui node method
918  * @tc.type: FUNC
919  */
920 HWTEST_F(UINodeTestNg, UINodeTestNg030, TestSize.Level1)
921 {
922     /**
923      * @tc.steps: step1. add ONE child for ZERO and call GetChildFlatIndex
924      * @tc.expected: pair1.second is 0
925      */
926     ZERO->AddChild(ONE, 1, false);
927     auto pair = ZERO->GetChildFlatIndex(1);
928     EXPECT_TRUE(pair.first);
929     EXPECT_EQ(pair.second, 0);
930     ZERO->Clean();
931     /**
932      * @tc.steps: step1. AddChild TESTUINode to ZERO and GetChildFlatIndex
933      * @tc.expected: the return pair1.first is false and pair1.second is 1
934      */
935     ZERO->AddChild(TEN0, 1, false);
936     pair = ZERO->GetChildFlatIndex(10);
937     EXPECT_FALSE(pair.first);
938     EXPECT_EQ(pair.second, 1);
939     ZERO->Clean();
940 }
941 
942 /**
943  * @tc.name: UINodeTestNg031
944  * @tc.desc: Test ui node method
945  * @tc.type: FUNC
946  */
947 HWTEST_F(UINodeTestNg, UINodeTestNg031, TestSize.Level1)
948 {
949     /**
950      * @tc.steps: step1. add one child to ZERO and ChildrenUpdatedFrom
951      * @tc.expected: childrenUpdatedFrom_ is 1
952      */
953     ZERO->ChildrenUpdatedFrom(1);
954     EXPECT_EQ(ZERO->childrenUpdatedFrom_, 1);
955     ZERO->Clean();
956 }
957 
958 /**
959  * @tc.name: UINodeTestNg032
960  * @tc.desc: Test ui node method
961  * @tc.type: FUNC
962  */
963 HWTEST_F(UINodeTestNg, UINodeTestNg032, TestSize.Level1)
964 {
965     /**
966      * @tc.steps: step1. add one child to ZERO and MarkRemoving
967      * @tc.expected: the return retMark is false
968      */
969     ZERO->AddChild(ONE, 1, false);
970     bool retMark = ZERO->UINode::MarkRemoving();
971     EXPECT_FALSE(retMark);
972     ZERO->Clean();
973 }
974 
975 /**
976  * @tc.name: UINodeTestNg033
977  * @tc.desc: Test ui node method
978  * @tc.type: FUNC
979  */
980 HWTEST_F(UINodeTestNg, UINodeTestNg033, TestSize.Level1)
981 {
982     /**
983      * @tc.steps: step1. call the SetChildrenInDestroying
984      * @tc.expected: children_.size = 0
985      */
986     ZERO->SetChildrenInDestroying();
987     EXPECT_EQ(ZERO->children_.size(), 0);
988     ZERO->Clean();
989     /**
990      * @tc.steps: step1. add two child to ZERO and call SetChildrenInDestroying
991      * @tc.expected: step1. children_.size = 3
992      */
993     ZERO->AddChild(ONE, 1, false);
994     ZERO->AddChild(TWO, 2, false);
995     ZERO->children_.emplace_back(nullptr);
996     ZERO->SetChildrenInDestroying();
997     EXPECT_EQ(ZERO->children_.size(), 3);
998     ONE->SetDestroying(false);
999     TWO->SetDestroying(false);
1000     ZERO->children_.clear();
1001     ZERO->Clean();
1002 }
1003 
1004 /**
1005  * @tc.name: UINodeTestNg034
1006  * @tc.desc: Test ui node method
1007  * @tc.type: FUNC
1008  */
1009 HWTEST_F(UINodeTestNg, UINodeTestNg034, TestSize.Level1)
1010 {
1011     /**
1012      * @tc.steps: step1. add two child to ZERO and call RemoveChildAtIndex
1013      * @tc.expected: children_.size = 1
1014      */
1015     ZERO->AddChild(ONE, 1, false);
1016     ZERO->RemoveChildAtIndex(1);
1017     EXPECT_EQ(ZERO->children_.size(), 1);
1018     ZERO->Clean();
1019 }
1020 
1021 /**
1022  * @tc.name: UINodeTestNg035
1023  * @tc.desc: Test ui node method
1024  * @tc.type: FUNC
1025  */
1026 HWTEST_F(UINodeTestNg, UINodeTestNg035, TestSize.Level1)
1027 {
1028     /**
1029      * @tc.steps: step1. call the AddChild funtion and set child is null
1030      * @tc.expected: children_.size = 0
1031      */
1032     ZERO->AddChild(nullptr, 1, false);
1033     EXPECT_EQ(ZERO->children_.size(), 0);
1034     /**
1035      * @tc.steps: step2. AddChild
1036      * @tc.expected: children_.size = 1
1037      */
1038     ZERO->AddChild(TWO, 1, false);
1039     EXPECT_EQ(ZERO->children_.size(), 1);
1040     /**
1041      * @tc.steps: step3. call the RemoveChild funtion and set input is null
1042      * @tc.expected: the return value is children_.end()
1043      */
1044     auto interator = ZERO->RemoveChild(nullptr);
1045     EXPECT_EQ(interator, ZERO->children_.end());
1046     ZERO->Clean();
1047 }
1048 
1049 /**
1050  * @tc.name: UINodeTestNg036
1051  * @tc.desc: Test ui node method
1052  * @tc.type: FUNC
1053  */
1054 HWTEST_F(UINodeTestNg, UINodeTestNg036, TestSize.Level1)
1055 {
1056     /**
1057      * @tc.steps: step1. GetChildAtIndex and set input is -1
1058      * @tc.expected: the return value is return nullptr
1059      */
1060     RefPtr<UINode> retChildAtIndex = ZERO->GetChildAtIndex(-1);
1061     EXPECT_EQ(retChildAtIndex, nullptr);
1062 }
1063 
1064 /**
1065  * @tc.name: UINodeTestNg037
1066  * @tc.desc: Test ui node method
1067  * @tc.type: FUNC
1068  */
1069 HWTEST_F(UINodeTestNg, UINodeTestNg037, TestSize.Level1)
1070 {
1071     /**
1072      * @tc.steps: step1. ReplaceChild
1073      * @tc.expected: children_.size() is 0
1074      */
1075     ZERO->ReplaceChild(nullptr, nullptr);
1076     EXPECT_EQ(ZERO->children_.size(), 0);
1077 }
1078 
1079 /**
1080  * @tc.name: UINodeTestNg038
1081  * @tc.desc: Test ui node method
1082  * @tc.type: FUNC
1083  */
1084 HWTEST_F(UINodeTestNg, UINodeTestNg038, TestSize.Level1)
1085 {
1086     /**
1087      * @tc.steps: step1. call the MarkDirtyNode.
1088      * @tc.expected: the MarkDirtyNode function is run ok.
1089      */
1090     PropertyChangeFlag FLAG = PROPERTY_UPDATE_NORMAL;
1091     ZERO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_NORMAL;
1092     ONE->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_NORMAL;
1093     TWO->layoutProperty_->propertyChangeFlag_ = PROPERTY_UPDATE_NORMAL;
1094 
1095     ONE->parent_ = ZERO;
1096     TWO->parent_ = ONE;
1097     ZERO->MarkNeedFrameFlushDirty(FLAG);
1098     EXPECT_NE(ONE->parent_.Upgrade(), nullptr);
1099     EXPECT_NE(TWO->parent_.Upgrade(), nullptr);
1100     ZERO->Clean();
1101 }
1102 
1103 /**
1104  * @tc.name: UINodeTestNg039
1105  * @tc.desc: Test ui node method
1106  * @tc.type: FUNC
1107  */
1108 HWTEST_F(UINodeTestNg, UINodeTestNg039, TestSize.Level1)
1109 {
1110     /**
1111      * @tc.steps: step1. call the CreateLayoutWrapper
1112      * @tc.expected: the return value is null
1113      */
1114     RefPtr<LayoutWrapperNode> retLayoutWrapper = ZERO->UINode::CreateLayoutWrapper(true, true);
1115     EXPECT_EQ(retLayoutWrapper, nullptr);
1116     /**
1117      * @tc.steps: step2. add one child for ZERO and call CreateLayoutWrapper
1118      * @tc.expected: the return value is null
1119      */
1120     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
1121     ZERO->AddChild(testNode, 1, false);
1122     retLayoutWrapper = ZERO->UINode::CreateLayoutWrapper(true, true);
1123     testNode->AddChild(ONE, 1, false);
1124     retLayoutWrapper = ZERO->UINode::CreateLayoutWrapper(true, true);
1125     EXPECT_NE(retLayoutWrapper, nullptr);
1126     ZERO->Clean();
1127 }
1128 
1129 /**
1130  * @tc.name: UINodeTestNg040
1131  * @tc.desc: Test ui node method
1132  * @tc.type: FUNC
1133  */
1134 HWTEST_F(UINodeTestNg, UINodeTestNg040, TestSize.Level1)
1135 {
1136     /**
1137      * @tc.steps: step1. set onMainTree_ is true and call AddChild
1138      * @tc.expected: children_.size() is 2
1139      */
1140     auto context = MockPipelineContext::GetCurrent();
1141     ASSERT_NE(context, nullptr);
1142     auto it = std::find(ZERO->children_.begin(), ZERO->children_.end(), ZERO);
1143     ZERO->onMainTree_ = true;
1144     ZERO->context_ = AceType::RawPtr(context);
1145     ZERO->DoAddChild(it, ONE, false);
1146     EXPECT_EQ(ZERO->children_.size(), 1);
1147     ZERO->DoAddChild(it, TWO, true);
1148     EXPECT_EQ(ZERO->children_.size(), 2);
1149     ZERO->onMainTree_ = false;
1150     ZERO->context_ = nullptr;
1151 }
1152 
1153 /**
1154  * @tc.name: UINodeTestNg042
1155  * @tc.desc: Test ui node method
1156  * @tc.type: FUNC
1157  */
1158 HWTEST_F(UINodeTestNg, UINodeTestNg042, TestSize.Level1)
1159 {
1160     /**
1161      * @tc.steps: step1. create some node
1162      */
1163     auto parent = FrameNode::CreateFrameNode(V2::COMMON_VIEW_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
1164     auto child = FrameNode::CreateFrameNode(V2::COMMON_VIEW_ETS_TAG, 3, AceType::MakeRefPtr<Pattern>());
1165     auto child2 = FrameNode::CreateFrameNode(V2::COMMON_VIEW_ETS_TAG, 4, AceType::MakeRefPtr<Pattern>());
1166     /**
1167      * @tc.steps: step2. call AddDisappearingChild with different condition
1168      * @tc.expected: disappearingChildren_.size() is 2
1169      */
1170     parent->AddDisappearingChild(child);
1171     child2->isDisappearing_ = true;
1172     parent->AddDisappearingChild(child2);
1173     parent->AddDisappearingChild(child);
1174     EXPECT_EQ(parent->disappearingChildren_.size(), 2);
1175     /**
1176      * @tc.steps: step3. call RemoveDisappearingChild with different condition
1177      * @tc.expected: disappearingChildren_.size() is 1
1178      */
1179     parent->RemoveDisappearingChild(child);
1180     child->isDisappearing_ = true;
1181     parent->RemoveDisappearingChild(child);
1182     child = nullptr;
1183     parent->RemoveDisappearingChild(child);
1184     EXPECT_EQ(parent->disappearingChildren_.size(), 1);
1185 }
1186 
1187 /**
1188  * @tc.name: UINodeTestNg043
1189  * @tc.desc: Test ui node method
1190  * @tc.type: FUNC
1191  */
1192 HWTEST_F(UINodeTestNg, UINodeTestNg043, TestSize.Level1)
1193 {
1194     /**
1195      * @tc.steps: step1. create some node
1196      */
1197     auto parent = FrameNode::CreateFrameNode("parent", 1, AceType::MakeRefPtr<Pattern>(), true);
1198     auto child = FrameNode::CreateFrameNode("child", 3, AceType::MakeRefPtr<Pattern>());
1199     parent->AddChild(child);
1200     /**
1201      * @tc.steps: step2. call GetFrameChildByIndex
1202      * @tc.expected: return nullptr
1203      */
1204 
1205     LayoutConstraintF parentLayoutConstraint;
1206     parentLayoutConstraint.maxSize.SetWidth(0);
1207     parentLayoutConstraint.maxSize.SetHeight(0);
1208     PerformanceCheckNodeMap un_Map;
1209     un_Map.emplace(0, PerformanceCheckNode());
1210     parent->UINode::OnSetCacheCount(3, parentLayoutConstraint);
1211     parent->UINode::DoRemoveChildInRenderTree(0, true);
1212     parent->UINode::DoRemoveChildInRenderTree(0, false);
1213     parent->UINode::DoRemoveChildInRenderTree(5, false);
1214     parent->UINode::GetFrameChildByIndex(0, false);
1215     EXPECT_FALSE(parent->UINode::GetDisappearingChildById("", 0));
1216     EXPECT_FALSE(parent->UINode::GetFrameChildByIndex(5, false));
1217 }
1218 
1219 /**
1220  * @tc.name: UINodeTestNg044
1221  * @tc.desc: Test ui node method of instanceid
1222  * @tc.type: FUNC
1223  */
1224 HWTEST_F(UINodeTestNg, UINodeTestNg044, TestSize.Level1)
1225 {
1226     /**
1227      * @tc.steps: step1. create a uinode
1228      */
1229     auto context = MockPipelineContext::GetCurrent();
1230     ASSERT_NE(context, nullptr);
1231     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
1232     ASSERT_NE(testNode, nullptr);
1233 
1234     int32_t testId = 0;
__anonc16a47900202(int32_t newId) 1235     testNode->RegisterUpdateJSInstanceCallback([&testId](int32_t newId) { testId = newId; });
1236 
1237     /**
1238      * @tc.steps: step2. attach context
1239      */
1240     testNode->AttachContext(AceType::RawPtr(context), true);
1241     EXPECT_EQ(testNode->context_, AceType::RawPtr(context));
1242     EXPECT_EQ(testNode->instanceId_, context->GetInstanceId());
1243     EXPECT_EQ(testId, context->GetInstanceId());
1244 
1245     /**
1246      * @tc.steps: step3. detach context
1247      */
1248     testNode->DetachContext(true);
1249     EXPECT_EQ(testNode->context_, nullptr);
1250 }
1251 
1252 /**
1253  * @tc.name: GetCurrentCustomNodeInfo001
1254  * @tc.desc: Test ui node method GetCurrentCustomNodeInfo
1255  * @tc.type: FUNC
1256  */
1257 HWTEST_F(UINodeTestNg, GetCurrentCustomNodeInfo001, TestSize.Level1)
1258 {
1259     /**
1260      * @tc.steps: step1. create frame node
1261      */
1262     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1263     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1264     auto parent = FrameNode::CreateFrameNode("parent_test", parentId, AceType::MakeRefPtr<Pattern>(), true);
1265     auto child = FrameNode::CreateFrameNode("child_test", childId, AceType::MakeRefPtr<Pattern>());
1266     parent->AddChild(child);
1267 
1268     /**
1269      * @tc.steps: step2. call GetCurrentCustomNodeInfo
1270      * @tc.expected: return ""
1271      */
1272     std::string rusult = parent->UINode::GetCurrentCustomNodeInfo();
1273     EXPECT_EQ(rusult, "");
1274 }
1275 
1276 /**
1277  * @tc.name: GetCurrentCustomNodeInfo002
1278  * @tc.desc: Test ui node method GetCurrentCustomNodeInfo
1279  * @tc.type: FUNC
1280  */
1281 HWTEST_F(UINodeTestNg, GetCurrentCustomNodeInfo002, TestSize.Level1)
1282 {
1283     /**
1284      * @tc.steps: step1. create custome node
1285      */
1286     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1287     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1288     auto childTwoId = ElementRegister::GetInstance()->MakeUniqueId();
1289     auto parent = CustomNode::CreateCustomNode(parentId, "parent");
1290     auto child = CustomNode::CreateCustomNode(childId, "child");
1291     auto childTwo = CustomNode::CreateCustomNode(childTwoId, "child_two");
1292     parent->AddChild(child);
1293     parent->AddChild(childTwo);
1294 
1295     /**
1296      * @tc.steps: step2. cover branch parent is custome and call GetCurrentCustomNodeInfo
1297      * @tc.expected: return ""
1298      */
1299     std::string rusult = parent->UINode::GetCurrentCustomNodeInfo();
1300     EXPECT_EQ(rusult, "");
1301 }
1302 
1303 /**
1304  * @tc.name: GetFilePath001
1305  * @tc.desc: Test ui node method GetCurrentCustomNodeInfo
1306  * @tc.type: FUNC
1307  */
1308 HWTEST_F(UINodeTestNg, GetFilePath001, TestSize.Level1)
1309 {
1310     /**
1311      * @tc.steps: step1. create frame node
1312      */
1313     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1314     auto node = FrameNode::CreateFrameNode("filePathNode", parentId, AceType::MakeRefPtr<Pattern>(), true);
1315     ASSERT_NE(node, nullptr);
1316     node->tag_ = V2::COMMON_VIEW_ETS_TAG;
1317 
1318     node->SetFilePath("abc");
1319     EXPECT_EQ(node->GetFilePath(), "");
1320     node->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1321     node->SetFilePath("abc");
1322     EXPECT_EQ(node->GetFilePath(), "abc");
1323 }
1324 
1325 /**
1326  * @tc.name: GetFilePath002
1327  * @tc.desc: Test ui node method GetCurrentCustomNodeInfo
1328  * @tc.type: FUNC
1329  */
1330 HWTEST_F(UINodeTestNg, GetFilePath002, TestSize.Level1)
1331 {
1332     /**
1333      * @tc.steps: step1. create frame node
1334      */
1335     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1336     auto node = FrameNode::CreateFrameNode("filePathNode", parentId, AceType::MakeRefPtr<Pattern>(), true);
1337     node->tag_ = V2::COMMON_VIEW_ETS_TAG;
1338 
1339     node->SetFilePath("a/b/c");
1340     EXPECT_EQ(node->GetFilePath(), "");
1341     node->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1342     node->SetFilePath("a/b/c");
1343     EXPECT_EQ(node->GetFilePath(), "a/b/c");
1344 }
1345 
1346 /**
1347  * @tc.name: GetPerformanceCheckData001
1348  * @tc.desc: Test ui node method GetCurrentCustomNodeInfo
1349  * @tc.type: FUNC
1350  */
1351 HWTEST_F(UINodeTestNg, GetPerformanceCheckData001, TestSize.Level1)
1352 {
1353     /**
1354      * @tc.steps: step1. create frame node
1355      */
1356     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1357     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1358     parent->tag_ = V2::COMMON_VIEW_ETS_TAG;
1359     parent->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1360 
1361     /**
1362      * @tc.steps: step2. construct parameter performanceCheckNodeMap and call GetPerformanceCheckData
1363      * @tc.expected: isBuildByJS_ is false
1364      */
1365     auto nodeId = ElementRegister::GetInstance()->MakeUniqueId();
1366     PerformanceCheckNodeMap nodeMap;
1367     PerformanceCheckNode performanceCheckNode = PerformanceCheckNode();
1368     nodeMap.emplace(nodeId, performanceCheckNode);
1369 
1370     parent->UINode::GetPerformanceCheckData(nodeMap);
1371     EXPECT_FALSE(parent->isBuildByJS_);
1372 
1373     /**
1374      * @tc.steps: step3. change parent tag_ and call GetPerformanceCheckData
1375      * @tc.expected: isBuildByJS_ is true
1376      */
1377     parent->tag_ = V2::MENU_ETS_TAG;
1378     parent->SetBuildByJs(true);
1379     parent->UINode::GetPerformanceCheckData(nodeMap);
1380     EXPECT_TRUE(parent->isBuildByJS_);
1381 }
1382 
1383 /**
1384  * @tc.name: GetPerformanceCheckData002
1385  * @tc.desc: Test ui node method GetCurrentCustomNodeInfo
1386  * @tc.type: FUNC
1387  */
1388 HWTEST_F(UINodeTestNg, GetPerformanceCheckData002, TestSize.Level1)
1389 {
1390     /**
1391      * @tc.steps: step1. create parent and childframe node
1392      */
1393     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1394     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1395     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1396     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
1397 
1398     parent->tag_ = V2::JS_FOR_EACH_ETS_TAG;
1399     parent->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1400     child->tag_ = V2::COMMON_VIEW_ETS_TAG;
1401     child->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1402     parent->AddChild(child);
1403 
1404     /**
1405      * @tc.steps: step2.  construct parameter performanceCheckNodeMap and call GetPerformanceCheckData
1406      * @tc.expected: isBuildByJS_ is false
1407      */
1408     auto nodeId = ElementRegister::GetInstance()->MakeUniqueId();
1409     PerformanceCheckNodeMap nodeMap;
1410     PerformanceCheckNode performanceCheckNode = PerformanceCheckNode();
1411     nodeMap.emplace(nodeId, performanceCheckNode);
1412 
1413     parent->UINode::GetPerformanceCheckData(nodeMap);
1414     EXPECT_FALSE(parent->isBuildByJS_);
1415 
1416     /**
1417      * @tc.steps: step3. change child tag_ and call GetPerformanceCheckData
1418      * @tc.expected: isBuildByJS_ is false
1419      */
1420     child->tag_ = V2::JS_FOR_EACH_ETS_TAG;
1421     parent->UINode::GetPerformanceCheckData(nodeMap);
1422     EXPECT_FALSE(parent->isBuildByJS_);
1423 }
1424 
1425 /**
1426  * @tc.name: GetPerformanceCheckData003
1427  * @tc.desc: Test ui node method GetCurrentCustomNodeInfo
1428  * @tc.type: FUNC
1429  */
1430 HWTEST_F(UINodeTestNg, GetPerformanceCheckData003, TestSize.Level1)
1431 {
1432     /**
1433      * @tc.steps: step1. create frame node
1434      */
1435     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1436     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1437     auto childTwoId = ElementRegister::GetInstance()->MakeUniqueId();
1438     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1439     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
1440     auto childTwo = FrameNode::CreateFrameNode("childTwo", childTwoId, AceType::MakeRefPtr<Pattern>(), true);
1441     parent->tag_ = V2::JS_FOR_EACH_ETS_TAG;
1442     parent->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1443     child->tag_ = V2::COMMON_VIEW_ETS_TAG;
1444     child->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1445     childTwo->tag_ = V2::COMMON_VIEW_ETS_TAG;
1446     childTwo->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1447     parent->AddChild(child);
1448     parent->AddChild(childTwo);
1449 
1450     /**
1451      * @tc.steps: step2.  construct parameter performanceCheckNodeMap and call GetPerformanceCheckData
1452      * @tc.expected: isBuildByJS_ is false
1453      */
1454     auto nodeId = ElementRegister::GetInstance()->MakeUniqueId();
1455     PerformanceCheckNodeMap nodeMap;
1456     PerformanceCheckNode performanceCheckNode = PerformanceCheckNode();
1457     nodeMap.emplace(nodeId, performanceCheckNode);
1458 
1459     parent->UINode::GetPerformanceCheckData(nodeMap);
1460     EXPECT_FALSE(parent->isBuildByJS_);
1461 
1462     /**
1463      * @tc.steps: step3. change child tag_ and call GetPerformanceCheckData
1464      * @tc.expected: isBuildByJS_ is false
1465      */
1466     child->tag_ = V2::JS_FOR_EACH_ETS_TAG;
1467     parent->UINode::GetPerformanceCheckData(nodeMap);
1468     EXPECT_FALSE(parent->isBuildByJS_);
1469 }
1470 
1471 /**
1472  * @tc.name: UpdateConfigurationUpdate001
1473  * @tc.desc: Test ui node method UpdateConfigurationUpdate
1474  * @tc.type: FUNC
1475  */
1476 HWTEST_F(UINodeTestNg, UpdateConfigurationUpdate001, TestSize.Level1)
1477 {
1478     /**
1479      * @tc.steps: step1. create frame node
1480      */
1481     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1482     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1483     parent->tag_ = V2::COMMON_VIEW_ETS_TAG;
1484     parent->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1485 
1486     /**
1487      * @tc.steps: step2.  construct parameter configurationChange and call UpdateConfigurationUpdate
1488      * @tc.expected: cover branch needCallChildrenUpdate_ is true
1489      */
1490     ConfigurationChange configurationChange;
1491     parent->UINode::UpdateConfigurationUpdate(configurationChange);
1492     EXPECT_TRUE(parent->needCallChildrenUpdate_);
1493 
1494     /**
1495      * @tc.steps: step3. create child frame node and call UpdateConfigurationUpdate
1496      * @tc.expected: cover branch children is not empty
1497      */
1498     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1499     auto childTwoId = ElementRegister::GetInstance()->MakeUniqueId();
1500     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
1501     auto childTwo = FrameNode::CreateFrameNode("childTwo", childTwoId, AceType::MakeRefPtr<Pattern>(), true);
1502     child->tag_ = V2::COMMON_VIEW_ETS_TAG;
1503     child->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1504     childTwo->tag_ = V2::COMMON_VIEW_ETS_TAG;
1505     childTwo->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1506     parent->AddChild(child);
1507     parent->AddChild(childTwo);
1508     parent->UINode::UpdateConfigurationUpdate(configurationChange);
1509     EXPECT_TRUE(parent->needCallChildrenUpdate_);
1510 
1511     /**
1512      * @tc.steps: step4. set needCallChildrenUpdate_ and call UpdateConfigurationUpdate
1513      * @tc.expected: cover branch needCallChildrenUpdate_ is false
1514      */
1515     parent->SetNeedCallChildrenUpdate(false);
1516     parent->UINode::UpdateConfigurationUpdate(configurationChange);
1517     EXPECT_FALSE(parent->needCallChildrenUpdate_);
1518 }
1519 
1520 /**
1521  * @tc.name: DumpTreeById001
1522  * @tc.desc: Test ui node method DumpTreeById
1523  * @tc.type: FUNC
1524  */
1525 HWTEST_F(UINodeTestNg, DumpTreeById001, TestSize.Level1)
1526 {
1527     /**
1528      * @tc.steps: step1. create frame node
1529      */
1530     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1531     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1532     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1533     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
1534 
1535     parent->tag_ = V2::JS_FOR_EACH_ETS_TAG;
1536     parent->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1537     child->tag_ = V2::COMMON_VIEW_ETS_TAG;
1538     child->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1539     parent->AddChild(child);
1540     /**
1541      * @tc.steps: step2. call DumpTreeById
1542      * @tc.expected: cover branch GetDumpFile is nullptr and result is false
1543      */
1544     bool result = parent->UINode::DumpTreeById(0, "");
1545     EXPECT_FALSE(result);
1546 
1547     /**
1548      * @tc.steps: step3. set DumpFile and call DumpTreeById
1549      * @tc.expected: cover branch GetDumpFile is not nullptr and result is true
1550      */
1551     std::unique_ptr<std::ostream> ostream = std::make_unique<std::ostringstream>();
1552     ASSERT_NE(ostream, nullptr);
1553     DumpLog::GetInstance().SetDumpFile(std::move(ostream));
1554 
1555     result = parent->UINode::DumpTreeById(0, "");
1556     EXPECT_TRUE(result);
1557 }
1558 
1559 /**
1560  * @tc.name: DumpTreeById002
1561  * @tc.desc: Test ui node method DumpTreeById
1562  * @tc.type: FUNC
1563  */
1564 HWTEST_F(UINodeTestNg, DumpTreeById002, TestSize.Level1)
1565 {
1566     /**
1567      * @tc.steps: step1. create frame node
1568      */
1569     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1570     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1571     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1572     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
1573 
1574     parent->tag_ = V2::JS_FOR_EACH_ETS_TAG;
1575     parent->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1576     child->tag_ = V2::COMMON_VIEW_ETS_TAG;
1577     child->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
1578     parent->AddChild(child);
1579 
1580     std::unique_ptr<std::ostream> ostream = std::make_unique<std::ostringstream>();
1581     ASSERT_NE(ostream, nullptr);
1582     DumpLog::GetInstance().SetDumpFile(std::move(ostream));
1583 
1584     /**
1585      * @tc.steps: step2. construt parameter and call DumpTreeById
1586      * @tc.expected: result is false
1587      */
1588     bool result = parent->UINode::DumpTreeById(0, "DumpTreeById002");
1589     EXPECT_FALSE(result);
1590 
1591     /**
1592      * @tc.steps: step3. change parameter and call DumpTreeById
1593      * @tc.expected: result is false
1594      */
1595     result = parent->UINode::DumpTreeById(1, "");
1596     EXPECT_TRUE(result);
1597 }
1598 
1599 /**
1600  * @tc.name: UINodeTestNg045
1601  * @tc.desc: IsContextTransparent()、GetPageNodeCountAndDepth()
1602  * @tc.type: FUNC
1603  */
1604 HWTEST_F(UINodeTestNg, UINodeTestNg045, TestSize.Level1)
1605 {
1606     /**
1607      * @tc.steps: step1. create frame node
1608      */
1609     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1610     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1611     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1612     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
1613 
1614     /**
1615      * @tc.steps: step2. call IsContextTransparent
1616      * @tc.expected: result is True
1617      */
1618     parent->AddChild(child);
1619     EXPECT_TRUE(parent->UINode::IsContextTransparent());
1620     int32_t count = 0;
1621     int32_t depth = 0;
1622 
1623     parent->GetPageNodeCountAndDepth(&count, &depth);
1624     EXPECT_EQ(parent->depth_, Infinity<int32_t>());
1625     EXPECT_EQ(parent->depth_, Infinity<int32_t>());
1626 
1627     auto child1 = FrameNode::CreateFrameNode(
1628         "child1", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>(), true);
1629     auto child2 = FrameNode::CreateFrameNode(
1630         "child2", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>(), true);
1631     child2->tag_ = V2::JS_VIEW_ETS_TAG;
1632     child1->AddChild(child2);
1633     child1->AddChild(ONE);
1634     std::list<int32_t> removedElmtId;
1635     parent->UINode::CollectRemovedChildren(child1->GetChildren(), removedElmtId, true);
1636     parent->UINode::GetFrameChildByIndexWithoutExpanded(0);
1637     parent->UINode::SetJSViewActive(false);
1638     parent->UINode::RenderCustomChild(0);
1639     std::vector<RefPtr<UINode>> res;
1640     parent->DFSAllChild(child1, res);
1641     EXPECT_EQ(res.size(), 2);
1642 }
1643 
1644 /**
1645  * @tc.name: UINodeTestNg046
1646  * @tc.desc: IsContextTransparent()、GetPageNodeCountAndDepth()
1647  * @tc.type: FUNC
1648  */
1649 HWTEST_F(UINodeTestNg, UINodeTestNg046, TestSize.Level1)
1650 {
1651     /**
1652      * @tc.steps: step1. create frame node
1653      */
1654     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
1655     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1656     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
1657     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
1658 
1659     /**
1660      * @tc.steps: step2. call IsContextTransparent
1661      * @tc.expected: result is True
1662      */
1663     parent->AddChild(child);
1664     parent->AddChild(ONE);
1665 
1666     auto child1 = FrameNode::CreateFrameNode(
1667         "child1", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>(), true);
1668     auto child2 = FrameNode::CreateFrameNode(
1669         "child2", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>(), true);
1670     child2->tag_ = V2::JS_VIEW_ETS_TAG;
1671     child1->AddChild(child2);
1672     std::list<int32_t> removedElmtId;
1673     EXPECT_TRUE(parent->UINode::GetContextWithCheck());
1674     EXPECT_EQ(parent->UINode::GetFrameNodeIndex(child, true), 0);
1675     EXPECT_EQ(parent->UINode::GetFrameNodeIndex(child1, false), -1);
1676 }
1677 
1678 /**
1679  * @tc.name: UINodeTestNg047
1680  * @tc.desc: Test ui node method AddChildBefore
1681  * @tc.type: FUNC
1682  */
1683 HWTEST_F(UINodeTestNg, UINodeTestNg047, TestSize.Level1)
1684 {
1685     /**
1686      * @tc.steps: step1. AddChild,child not exsit and siblingNode exsit
1687      * @tc.expected: children_.size = 3
1688      */
1689     EXPECT_EQ(ONE->children_.size(), 0);
1690     ONE->Clean();
1691     EXPECT_EQ(ONE->children_.size(), 0);
1692     ONE->AddChild(TWO, 1, false);
1693     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
1694     auto testNode2 = TestNode::CreateTestNode(TEST_ID_TWO);
1695     ONE->AddChild(testNode, 1, false);
1696     ONE->AddChildBefore(testNode2, testNode);
1697     EXPECT_EQ(ONE->children_.size(), 3);
1698     ONE->Clean();
1699 
1700     /**
1701      * @tc.steps: step2. AddChild, both child and siblingNode not exsit
1702      * @tc.expected: children_.size = 3
1703      */
1704     ONE->AddChild(TWO, 1, false);
1705     const int32_t testId3 = 23;
1706     auto testNode3 = TestNode::CreateTestNode(testId3);
1707     ONE->AddChild(testNode, 1, false);
1708     ONE->AddChildBefore(testNode3, testNode2);
1709     EXPECT_EQ(ONE->children_.size(), 3);
1710     ONE->Clean();
1711 
1712     /**
1713      * @tc.steps: step3. AddChild,  child  exsit
1714      * @tc.expected: children_.size = 3
1715      */
1716     ONE->AddChild(TWO, 1, false);
1717     ONE->AddChild(testNode, 1, false);
1718     ONE->AddChild(testNode3, 1, false);
1719     ONE->AddChildBefore(testNode, testNode3);
1720     EXPECT_EQ(ONE->children_.size(), 3);
1721     ONE->Clean();
1722 }
1723 
1724 /**
1725  * @tc.name: UINodeTestNg048
1726  * @tc.desc: Test ui node method AddChildAfter
1727  * @tc.type: FUNC
1728  */
1729 HWTEST_F(UINodeTestNg, UINodeTestNg048, TestSize.Level1)
1730 {
1731     /**
1732      * @tc.steps: step1. AddChild,child exsit
1733      * @tc.expected: children_.size = 3
1734      */
1735     EXPECT_EQ(ONE->children_.size(), 0);
1736     ONE->Clean();
1737     EXPECT_EQ(ONE->children_.size(), 0);
1738     ONE->AddChild(TWO, 1, false);
1739     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
1740     auto testNode2 = TestNode::CreateTestNode(TEST_ID_TWO);
1741     ONE->AddChild(testNode, 1, false);
1742     ONE->AddChildAfter(testNode2, testNode);
1743     EXPECT_EQ(ONE->children_.size(), 3);
1744     ONE->Clean();
1745 
1746     /**
1747      * @tc.steps: step3. AddChild, both child and siblingNode not exsit
1748      * @tc.expected: children_.size = 3
1749      */
1750     ONE->AddChild(TWO, 1, false);
1751     const int32_t testId3 = 23;
1752     auto testNode3 = TestNode::CreateTestNode(testId3);
1753     ONE->AddChild(testNode, 1, false);
1754     ONE->AddChildBefore(testNode3, testNode2);
1755     EXPECT_EQ(ONE->children_.size(), 3);
1756     ONE->Clean();
1757 
1758     /**
1759      * @tc.steps: step2. AddChild, addModalUiextension is false and modalUiextensionCount_ > 0
1760      * @tc.expected: children_.size = 0
1761      */
1762     ONE->UpdateModalUiextensionCount(true);
1763     ONE->AddChild(TWO, 1, false, false, false);
1764     ONE->RemoveImmediately();
1765     EXPECT_EQ(ONE->children_.size(), 1);
1766 }
1767 
1768 /**
1769  * @tc.name: UINodeTestNg050
1770  * @tc.desc: Test ui node method GetContextWithCheck
1771  * @tc.type: FUNC
1772  */
1773 HWTEST_F(UINodeTestNg, UINodeTestNg050, TestSize.Level1)
1774 {
1775     /**
1776      * @tc.steps: step1. add child and GetContextWithCheck
1777      * @tc.expected: ret != nullptr
1778      */
1779     ONE->AddChild(TWO, 1, false);
1780     PipelineContext* ret = ONE->GetContextWithCheck();
1781     ASSERT_TRUE(ret != nullptr);
1782     ONE->Clean();
1783 }
1784 
1785 /**
1786  * @tc.name: UINodeTestNg051
1787  * @tc.desc: Test ui node method CurrentFrameCount/GenerateAccessibilityId
1788  * @tc.type: FUNC
1789  */
1790 HWTEST_F(UINodeTestNg, UINodeTestNg051, TestSize.Level1)
1791 {
1792     /**
1793      * @tc.steps: step1. add child and excute CurrentFrameCount
1794      * @tc.expected: count == 0
1795      */
1796     ONE->AddChild(TWO, 1, false);
1797     int32_t count = ONE->CurrentFrameCount();
1798     ASSERT_TRUE(count == 1);
1799     int64_t idCurrent = ONE->GenerateAccessibilityId();
1800     int64_t id = ONE->GenerateAccessibilityId();
1801     ASSERT_TRUE(id == idCurrent + 1);
1802     ONE->Clean();
1803 }
1804 
1805 /**
1806  * @tc.name: UINodeTestNg052
1807  * @tc.desc: Test ui node method of AttachContext
1808  * @tc.type: FUNC
1809  */
1810 HWTEST_F(UINodeTestNg, UINodeTestNg052, TestSize.Level1)
1811 {
1812     /**
1813      * @tc.steps: step1. create a uinode
1814      */
1815     auto context = MockPipelineContext::GetCurrent();
1816     ASSERT_NE(context, nullptr);
1817     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
1818     ASSERT_NE(testNode, nullptr);
1819     testNode->AddChild(TWO, 1, false);
1820     /**
1821      * @tc.steps: step2. attach context
1822      */
1823     testNode->AttachContext(AceType::RawPtr(context), true);
1824     EXPECT_EQ(testNode->context_, AceType::RawPtr(context));
1825     /**
1826      * @tc.steps: step3. detach context
1827      */
1828     testNode->DetachContext(true);
1829     EXPECT_EQ(testNode->context_, nullptr);
1830 }
1831 
1832 /**
1833  * @tc.name: UINodeTestNg053
1834  * @tc.desc: Test ui node method GetBestBreakPoint1
1835  * @tc.type: FUNC
1836  */
1837 HWTEST_F(UINodeTestNg, UINodeTestNg053, TestSize.Level1)
1838 {
1839     /**
1840      * @tc.steps: step1. GetChildAtIndex and retParent nullptr  0000
1841      * @tc.expected: GetChildAtIndex and retParent nullptr
1842      */
1843     ZERO->parent_ = nullptr;
1844     RefPtr<UINode> retParent = ZERO->GetParent();
1845     RefPtr<UINode> retChildAtIndex = ZERO->GetChildAtIndex(-1);
1846     ZERO->GetBestBreakPoint(retChildAtIndex, retParent);
1847     EXPECT_EQ(retParent, nullptr);
1848     EXPECT_EQ(retChildAtIndex, nullptr);
1849 
1850     /**
1851      * @tc.steps: step2. GetChildAtIndex and retParent not nullptr 1100
1852      * @tc.expected: retParent2 nullptr and retChildAtIndex2 point to ZERO
1853      */
1854     ZERO->parent_ = nullptr;
1855     auto testNode25 = TestNode::CreateTestNode(25);
1856     ZERO->AddChild(testNode25, 1, false);
1857     RefPtr<UINode> retChildAtIndex2 = ZERO->GetChildAtIndex(0);
1858     RefPtr<UINode> retParent2 = ZERO;
1859     testNode25->GetBestBreakPoint(retChildAtIndex2, retParent2);
1860     EXPECT_EQ(retParent2, 0);
1861     EXPECT_EQ(retChildAtIndex2->GetTag(), ZERO->GetTag());
1862     ZERO->Clean();
1863 
1864     /**
1865      * @tc.steps: step3. GetChildAtIndex and retParent not nullptr,child IsDisappearing is true 1010
1866      * @tc.expected: retParent3  and retChildAtIndex3 point to ZERO
1867      */
1868     ASSERT_TRUE(ZERO->children_.size() == 0);
1869     ZERO->parent_ = nullptr;
1870     ZERO->AddChild(ONE, 1, false);
1871     ZERO->AddDisappearingChild(ONE, 0);
1872     RefPtr<UINode> retChildAtIndex3 = ZERO->GetChildAtIndex(0);
1873     RefPtr<UINode> retParent3 = ONE->GetParent();
1874     ONE->GetBestBreakPoint(retChildAtIndex3, retParent3);
1875     EXPECT_EQ(retParent3, 1);
1876     EXPECT_EQ(retChildAtIndex3->GetTag(), ONE->GetTag());
1877     ZERO->Clean();
1878 
1879     /**
1880      * @tc.steps: step4. GetChildAtIndex and retParent not nullptr, child testNode IsDisappearing is true 1110
1881      * @tc.expected: retParent4 point to ZERO and retChildAtIndex4 point to testNode
1882      */
1883     ZERO->parent_ = nullptr;
1884     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
1885     ZERO->AddChild(testNode, 1, false);
1886     testNode->AddChild(TWO, 1, false);
1887     ZERO->AddDisappearingChild(testNode, 0);
1888     RefPtr<UINode> retChildAtIndex4 = testNode->GetChildAtIndex(0);
1889     RefPtr<UINode> retParent4 = testNode;
1890     TWO->GetBestBreakPoint(retChildAtIndex4, retParent4);
1891     EXPECT_EQ(retParent4->GetTag(), ZERO->GetTag());
1892     EXPECT_EQ(retChildAtIndex4->GetTag(), testNode->GetTag());
1893     ZERO->Clean();
1894 
1895     /**
1896      * @tc.steps: step5. GetChildAtIndex and retParent not nullptr,all child  Disappearing  true 1011
1897      * @tc.expected: retParent5  and retChildAtIndex5 do not change
1898      */
1899     ZERO->parent_ = nullptr;
1900     auto testNode1 = TestNode::CreateTestNode(TEST_ID_ONE);
1901     ZERO->AddChild(testNode1, 1, false);
1902     testNode1->AddChild(TWO, 1, false);
1903     ZERO->AddDisappearingChild(testNode1, 0);
1904     testNode1->AddDisappearingChild(TWO, 0);
1905     RefPtr<UINode> retChildAtIndex5 = testNode1->GetChildAtIndex(0);
1906     RefPtr<UINode> retParent5 = testNode1;
1907     TWO->GetBestBreakPoint(retChildAtIndex5, retParent5);
1908     EXPECT_EQ(retParent5->GetTag(), testNode1->GetTag());
1909     EXPECT_EQ(retChildAtIndex5->GetTag(), TWO->GetTag());
1910     ZERO->Clean();
1911 }
1912 
1913 /**
1914  * @tc.name: UINodeTestNg054
1915  * @tc.desc: Test ui node method GetBestBreakPoint2
1916  * @tc.type: FUNC
1917  */
1918 HWTEST_F(UINodeTestNg, UINodeTestNg054, TestSize.Level1)
1919 {
1920     /**
1921      * @tc.steps: step1. GetChildAtIndex and retParent not nullptr,all child  Disappearing  true 1111
1922      * @tc.expected: retParent point to  testNode3 and retChildAtIndex point to  testNode4
1923      */
1924     ZERO->parent_ = nullptr;
1925     auto testNode3 = TestNode::CreateTestNode(TEST_ID_ONE);
1926     auto testNode4 = TestNode::CreateTestNode(TEST_ID_TWO);
1927     auto testNode5 = TestNode::CreateTestNode(23);
1928     ZERO->AddChild(testNode3, 1, false);
1929     testNode3->AddChild(testNode4, 1, false);
1930     testNode4->AddChild(testNode5, 1, false);
1931     ZERO->AddDisappearingChild(testNode3, 0);
1932     testNode3->AddDisappearingChild(testNode4, 0);
1933     RefPtr<UINode> retChildAtIndex = testNode4->GetChildAtIndex(0);
1934     RefPtr<UINode> retParent = testNode4;
1935     testNode4->GetBestBreakPoint(retChildAtIndex, retParent);
1936     EXPECT_EQ(retParent->GetTag(), testNode3->GetTag());
1937     EXPECT_EQ(retChildAtIndex->GetTag(), testNode4->GetTag());
1938     ZERO->Clean();
1939 }
1940 
1941 /**
1942  * @tc.name: UINodeTestNg055
1943  * @tc.desc: Test ui node method RemoveFromParentCleanly
1944  * @tc.type: FUNC
1945  */
1946 HWTEST_F(UINodeTestNg, UINodeTestNg055, TestSize.Level1)
1947 {
1948     /**
1949      * @tc.steps: step1. child isDisappearing_ is false, not in ModifyChildren
1950      * @tc.expected: testNode3 has been deleted
1951      */
1952     ZERO->parent_ = nullptr;
1953     auto testNode1 = TestNode::CreateTestNode(TEST_ID_ONE);
1954     auto testNode2 = TestNode::CreateTestNode(TEST_ID_TWO);
1955     const RefPtr<FrameNode> testNode3 =
1956         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
1957     ZERO->AddChild(testNode1, 1, false);
1958     testNode1->AddChild(testNode2, 1, false);
1959     testNode2->AddChild(testNode3, 1, false);
1960     testNode3->RemoveFromParentCleanly(testNode3, testNode2);
1961     EXPECT_EQ(testNode2->children_.size(), 0);
1962     const RefPtr<FrameNode> testNode4 =
1963         FrameNode::CreateFrameNode("testNode4", 1, AceType::MakeRefPtr<Pattern>(), true);
1964     testNode2->AddChild(testNode3, 1, false);
1965     testNode4->RemoveFromParentCleanly(testNode4, testNode2);
1966     EXPECT_EQ(testNode2->children_.size(), 1);
1967     ZERO->Clean();
1968 
1969     /**
1970      * @tc.steps: step2. child isDisappearing_ is true
1971      * @tc.expected: child isDisappearing_ is false
1972      */
1973     ZERO->parent_ = nullptr;
1974     auto testNode5 = TestNode::CreateTestNode(25);
1975     auto testNode6 = TestNode::CreateTestNode(26);
1976     const RefPtr<FrameNode> testNode7 =
1977         FrameNode::CreateFrameNode("testNode7", 1, AceType::MakeRefPtr<Pattern>(), true);
1978     ZERO->AddChild(testNode5, 1, false);
1979     testNode5->AddChild(testNode6, 1, false);
1980     testNode6->AddChild(testNode7, 1, false);
1981     testNode6->AddDisappearingChild(testNode7, 0);
1982     testNode7->RemoveFromParentCleanly(testNode7, testNode6);
1983     EXPECT_EQ(testNode7->isDisappearing_, false);
1984     ZERO->Clean();
1985 }
1986 
1987 /**
1988  * @tc.name: UINodeTestNg057
1989  * @tc.desc: Test ui node method DumpViewDataPageNodes
1990  * @tc.type: FUNC
1991  */
1992 HWTEST_F(UINodeTestNg, UINodeTestNg057, TestSize.Level1)
1993 {
1994     /**
1995      * @tc.steps: step1. construct a uinode and add child,skipSubAutoFillContainer is false
1996      * @tc.expected: expect no exception
1997      */
1998     const RefPtr<FrameNode> testNode1 =
1999         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2000     const RefPtr<FrameNode> testNode2 =
2001         FrameNode::CreateFrameNode("testNode2", 1, AceType::MakeRefPtr<Pattern>(), true);
2002     testNode1->AddChild(testNode2, 1, false);
2003     testNode1->AddChild(nullptr, 1, false);
2004     auto viewDataWrap = ViewDataWrap::CreateViewDataWrap();
2005     testNode1->DumpViewDataPageNodes(viewDataWrap, false);
2006     ZERO->Clean();
2007 
2008     /**
2009      * @tc.steps: step2. construct a uinode and add child,skipSubAutoFillContainer is true
2010      * @tc.expected: expect no exception
2011      */
2012     const RefPtr<FrameNode> testNode3 =
2013         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2014     const RefPtr<FrameNode> testNode4 =
2015         FrameNode::CreateFrameNode("testNode2", 1, AceType::MakeRefPtr<Pattern>(), true);
2016     const RefPtr<FrameNode> testNodePage = FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<Pattern>(), true);
2017     testNode3->AddChild(testNode4, 1, false);
2018     testNode3->AddChild(nullptr, 1, false);
2019     testNode3->AddChild(testNodePage, 1, false);
2020     auto viewDataWrap2 = ViewDataWrap::CreateViewDataWrap();
2021     testNode3->DumpViewDataPageNodes(viewDataWrap2, true);
2022     ZERO->Clean();
2023     EXPECT_TRUE(DumpLog::GetInstance().result_.find("testNode2"));
2024 }
2025 
2026 /**
2027  * @tc.name: UINodeTestNg058
2028  * @tc.desc: Test ui node method DumpTree
2029  * @tc.type: FUNC
2030  */
2031 HWTEST_F(UINodeTestNg, UINodeTestNg058, TestSize.Level1)
2032 {
2033     /**
2034      * @tc.steps: step1. construct a FrameNode with Disappearing child and OverlayNode child
2035      * @tc.expected: expect no exception
2036      */
2037     ZERO->parent_ = nullptr;
2038     const RefPtr<FrameNode> testNode1 =
2039         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2040     const RefPtr<FrameNode> testNode2 =
2041         FrameNode::CreateFrameNode("testNode2", 1, AceType::MakeRefPtr<Pattern>(), true);
2042     const RefPtr<FrameNode> testNode3 =
2043         FrameNode::CreateFrameNode("testNode3", 1, AceType::MakeRefPtr<Pattern>(), true);
2044     const RefPtr<FrameNode> testNode4 =
2045         FrameNode::CreateFrameNode("testNode4", 1, AceType::MakeRefPtr<Pattern>(), true);
2046     ZERO->AddChild(testNode1, 1, false);
2047     ZERO->AddChild(testNode2, 1, false);
2048     ZERO->AddDisappearingChild(testNode1, 0);
2049     testNode1->SetOverlayNode(testNode3);
2050     testNode1->AddDisappearingChild(testNode4, 0);
2051     testNode1->DumpTree(0);
2052     ZERO->Clean();
2053     EXPECT_TRUE(DumpLog::GetInstance().result_.find("testNode1"));
2054 }
2055 
2056 /**
2057  * @tc.name: UINodeTestNg059
2058  * @tc.desc: Test ui node method DumpTreeById
2059  * @tc.type: FUNC
2060  */
2061 HWTEST_F(UINodeTestNg, UINodeTestNg059, TestSize.Level1)
2062 {
2063     /**
2064      * @tc.steps: step1. construct a FrameNode with Disappearing child
2065      * @tc.expected: expect no exception
2066      */
2067     ZERO->parent_ = nullptr;
2068     const RefPtr<FrameNode> testNode1 =
2069         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2070     const RefPtr<FrameNode> testNode2 =
2071         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2072     const RefPtr<FrameNode> testNode3 =
2073         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2074     const RefPtr<FrameNode> testNode4 =
2075         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2076     ZERO->AddChild(testNode1, 1, false);
2077     ZERO->AddChild(testNode2, 1, false);
2078     ZERO->AddDisappearingChild(testNode1, 0);
2079     testNode1->AddChild(testNode3, 0);
2080     testNode1->AddDisappearingChild(testNode4, 0);
2081     testNode1->DumpTreeById(0, "3");
2082     testNode1->DumpTreeById(0, "4");
2083     ZERO->Clean();
2084     EXPECT_TRUE(DumpLog::GetInstance().result_.find("testNode1"));
2085 }
2086 
2087 /**
2088  * @tc.name: UINodeTestNg060
2089  * @tc.desc: Test ui node method AdjustLayoutWrapperTree
2090  * @tc.type: FUNC
2091  */
2092 HWTEST_F(UINodeTestNg, UINodeTestNg060, TestSize.Level1)
2093 {
2094     /**
2095      * @tc.steps: step1. construct a FrameNode with child
2096      * @tc.expected: expect no exception
2097      */
2098     const RefPtr<FrameNode> testNode1 =
2099         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2100     const RefPtr<FrameNode> testNode2 =
2101         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2102     const RefPtr<FrameNode> testNode3 =
2103         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2104     const RefPtr<FrameNode> testNode4 =
2105         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2106     testNode1->AddChild(testNode2, 1, false);
2107     testNode1->AddChild(testNode3, 1, false);
2108     testNode1->AddChild(testNode4, 1, false);
2109     RefPtr<LayoutWrapperNode> retLayoutWrapper = testNode1->UINode::CreateLayoutWrapper(true, true);
2110     testNode1->UINode::AdjustLayoutWrapperTree(retLayoutWrapper, false, false);
2111     EXPECT_EQ(testNode1->GetChildren().size(), 3);
2112 }
2113 
2114 /**
2115  * @tc.name: UINodeTestNg061
2116  * @tc.desc: Test ui node method CreateExportTextureInfoIfNeeded
2117  * @tc.type: FUNC
2118  */
2119 HWTEST_F(UINodeTestNg, UINodeTestNg061, TestSize.Level1)
2120 {
2121     /**
2122      * @tc.steps: step1. construct a FrameNode
2123      * @tc.expected: expect no exception
2124      */
2125     const RefPtr<FrameNode> testNode1 =
2126         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2127     testNode1->UINode::CreateExportTextureInfoIfNeeded();
2128     EXPECT_EQ(testNode1->GetExportTextureInfo() != nullptr, true);
2129     testNode1->UINode::CreateExportTextureInfoIfNeeded();
2130     EXPECT_EQ(testNode1->GetExportTextureInfo() != nullptr, true);
2131 }
2132 
2133 /**
2134  * @tc.name: UINodeTestNg062
2135  * @tc.desc: Test ui node method SetJSViewActive
2136  * @tc.type: FUNC
2137  */
2138 HWTEST_F(UINodeTestNg, UINodeTestNg062, TestSize.Level1)
2139 {
2140     /**
2141      * @tc.steps: step1. create custome node,SetIsV2 false,isLazyForEachNode true
2142      */
2143     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
2144     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
2145     auto childTwoId = ElementRegister::GetInstance()->MakeUniqueId();
2146     auto parent = CustomNode::CreateCustomNode(parentId, "parent");
2147     auto child = CustomNode::CreateCustomNode(childId, "child");
2148     auto childTwo = CustomNode::CreateCustomNode(childTwoId, "child_two");
2149     parent->AddChild(child);
2150     parent->AddChild(childTwo);
2151     parent->UINode::SetJSViewActive(true, true);
2152     child->SetIsV2(true);
2153     parent->UINode::SetJSViewActive(true, true);
2154     EXPECT_TRUE(child->GetJsActive());
2155 }
2156 
2157 /**
2158  * @tc.name: UINodeTestNg063
2159  * @tc.desc: Test ui node method OnRecycle/OnReuse/PaintDebugBoundaryTreeAll/IsContextTransparent
2160  * @tc.type: FUNC
2161  */
2162 HWTEST_F(UINodeTestNg, UINodeTestNg063, TestSize.Level1)
2163 {
2164     /**
2165      * @tc.steps: step1. create custome node,SetIsV2 false,isLazyForEachNode true
2166      */
2167     const RefPtr<FrameNode> testNode1 =
2168         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2169     const RefPtr<FrameNode> testNode2 =
2170         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2171     const RefPtr<FrameNode> testNode3 =
2172         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2173     const RefPtr<FrameNode> testNode4 =
2174         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2175     testNode1->AddChild(testNode2, 1, false);
2176     testNode1->AddChild(testNode3, 1, false);
2177     testNode1->AddChild(testNode4, 1, false);
2178     testNode1->OnRecycle();
2179     testNode1->OnReuse();
2180     testNode1->PaintDebugBoundaryTreeAll(true);
2181     bool ret = testNode1->IsContextTransparent();
2182     EXPECT_EQ(ret, true);
2183 }
2184 
2185 /**
2186  * @tc.name: UINodeTestNg064
2187  * @tc.desc: Test ui node method DFSAllChild
2188  * @tc.type: FUNC
2189  */
2190 HWTEST_F(UINodeTestNg, UINodeTestNg064, TestSize.Level1)
2191 {
2192     /**
2193      * @tc.steps: step1. create node without child
2194      */
2195     const RefPtr<FrameNode> testNode1 =
2196         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2197     std::vector<RefPtr<UINode>> ret;
2198     testNode1->DFSAllChild(testNode1, ret);
2199     EXPECT_EQ(ret.size(), 1);
2200     ret.clear();
2201 
2202     /**
2203      * @tc.steps: step2. create node with child
2204      */
2205     const RefPtr<FrameNode> testNode2 =
2206         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2207     const RefPtr<FrameNode> testNode3 =
2208         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2209     const RefPtr<FrameNode> testNode4 =
2210         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2211     testNode1->AddChild(testNode2, 1, false);
2212     testNode1->AddChild(testNode3, 1, false);
2213     testNode1->AddChild(testNode4, 1, false);
2214     testNode1->DFSAllChild(testNode1, ret);
2215     EXPECT_EQ(ret.size(), 3);
2216     ret.clear();
2217 }
2218 
2219 /**
2220  * @tc.name: UINodeTestNg065
2221  * @tc.desc: Test ui node method GetPageNodeCountAndDepth
2222  * @tc.type: FUNC
2223  */
2224 HWTEST_F(UINodeTestNg, UINodeTestNg065, TestSize.Level1)
2225 {
2226     /**
2227      * @tc.steps: step1. create FrameNode with child
2228      */
2229     const RefPtr<FrameNode> testNode1 =
2230         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2231     const RefPtr<FrameNode> testNode2 =
2232         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2233     const RefPtr<FrameNode> testNode3 =
2234         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2235     const RefPtr<FrameNode> testNode4 =
2236         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2237     testNode1->AddChild(testNode2, 1, false);
2238     testNode1->AddChild(testNode3, 1, false);
2239     testNode1->AddChild(testNode4, 1, false);
2240     int32_t* count = new int32_t(0);
2241     int32_t* depth = new int32_t(0);
2242     testNode1->GetPageNodeCountAndDepth(count, depth);
2243     EXPECT_EQ(*count, 4);
2244     delete count;
2245     delete depth;
2246 }
2247 
2248 /**
2249  * @tc.name: UINodeTestNg066
2250  * @tc.desc: Test ui node method CollectRemovedChildren/UpdateNodeStatus
2251  * @tc.type: FUNC
2252  */
2253 HWTEST_F(UINodeTestNg, UINodeTestNg066, TestSize.Level1)
2254 {
2255     /**
2256      * @tc.steps: step1. create FrameNode with child
2257      */
2258     const RefPtr<FrameNode> testNode1 =
2259         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2260     const RefPtr<FrameNode> testNode2 =
2261         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2262     const RefPtr<FrameNode> testNode3 =
2263         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2264     const RefPtr<FrameNode> testNode4 =
2265         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2266     const RefPtr<FrameNode> testNode5 =
2267         FrameNode::CreateFrameNode("testNode5", 5, AceType::MakeRefPtr<Pattern>(), true);
2268     testNode1->AddChild(testNode2, 1, false);
2269     testNode1->AddChild(testNode3, 1, false);
2270     testNode1->AddChild(testNode4, 1, false);
2271     testNode2->AddChild(testNode5, 1, false);
2272     testNode2->SetIsRootBuilderNode(true);
2273     std::list<int32_t> removedElmtId;
2274     testNode1->CollectRemovedChildren(testNode1->GetChildren(), removedElmtId, true);
2275     EXPECT_EQ(removedElmtId.size(), 2);
2276     testNode2->CollectRemovedChildren(testNode2->GetChildren(), removedElmtId, true);
2277     EXPECT_EQ(removedElmtId.size(), 3);
2278 }
2279 
2280 /**
2281  * @tc.name: UINodeTestNg067
2282  * @tc.desc: Test ui node method GetFrameChildByIndexWithoutExpanded
2283  * @tc.type: FUNC
2284  */
2285 HWTEST_F(UINodeTestNg, UINodeTestNg067, TestSize.Level1)
2286 {
2287     /**
2288      * @tc.steps: step1. create FrameNode with child
2289      */
2290     auto testNode1 = TestNode::CreateTestNode(21);
2291     auto testNode2 = TestNode::CreateTestNode(22);
2292     auto testNode3 = TestNode::CreateTestNode(23);
2293     auto testNode4 = TestNode::CreateTestNode(24);
2294     testNode1->AddChild(testNode2, 1, false);
2295     testNode1->AddChild(testNode3, 1, false);
2296     testNode1->AddChild(testNode4, 1, false);
2297     RefPtr<UINode> ret = testNode1->GetFrameChildByIndexWithoutExpanded(4);
2298     EXPECT_EQ(ret == nullptr, true);
2299 }
2300 
2301 /**
2302  * @tc.name: UINodeTestNg068
2303  * @tc.desc: Test ui node method Build
2304  * @tc.type: FUNC
2305  */
2306 HWTEST_F(UINodeTestNg, UINodeTestNg068, TestSize.Level1)
2307 {
2308     /**
2309      * @tc.steps: step1. create custome node,SetIsV2 false,isLazyForEachNode true
2310      */
2311     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
2312     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
2313     auto childTwoId = ElementRegister::GetInstance()->MakeUniqueId();
2314     auto parent = CustomNode::CreateCustomNode(parentId, "parent");
2315     auto child = CustomNode::CreateCustomNode(childId, "child");
2316     auto childTwo = CustomNode::CreateCustomNode(childTwoId, "child_two");
2317     auto childThree = TestNode::CreateTestNode(24);
2318     ExtraInfo extraInfo;
2319     extraInfo.page = "1";
2320     childTwo->SetExtraInfo(extraInfo);
2321     parent->AddChild(child);
2322     parent->AddChild(childTwo);
2323     parent->AddChild(childThree);
2324     std::shared_ptr<std::list<ExtraInfo>> extraInfos;
2325     parent->UINode::Build(extraInfos);
2326     extraInfos = std::make_shared<std::list<ExtraInfo>>();
2327     parent->UINode::Build(extraInfos);
2328     EXPECT_EQ(parent->GetChildren().size(), 3);
2329 }
2330 
2331 /**
2332  * @tc.name: UINodeTestNg069
2333  * @tc.desc: Test ui node method GenerateOneDepthVisibleFrameWithTransition/GenerateOneDepthVisibleFrameWithOffset
2334  * @tc.type: FUNC
2335  */
2336 HWTEST_F(UINodeTestNg, UINodeTestNg069, TestSize.Level1)
2337 {
2338     /**
2339      * @tc.steps: step1. create FrameNode node,AddChild,AddDisappearingChild
2340      */
2341     const RefPtr<FrameNode> testNode1 =
2342         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2343     const RefPtr<FrameNode> testNode2 =
2344         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2345     const RefPtr<FrameNode> testNode3 =
2346         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2347     const RefPtr<FrameNode> testNode4 =
2348         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2349     const RefPtr<FrameNode> testNode5 =
2350         FrameNode::CreateFrameNode("testNode5", 5, AceType::MakeRefPtr<Pattern>(), true);
2351     testNode1->AddChild(testNode2, 1, false);
2352     testNode1->AddChild(testNode3, 1, false);
2353     testNode1->AddChild(testNode4, 1, false);
2354     OffsetT<float> offset;
2355     std::list<RefPtr<FrameNode>> visibleList;
2356     testNode1->GenerateOneDepthVisibleFrameWithOffset(visibleList, offset);
2357     testNode1->AddDisappearingChild(testNode2, 1);
2358     testNode1->AddDisappearingChild(testNode3, 2);
2359     testNode1->AddDisappearingChild(testNode4, 3);
2360     testNode1->AddDisappearingChild(testNode5, 4);
2361     testNode1->GenerateOneDepthVisibleFrameWithTransition(visibleList);
2362     testNode1->GenerateOneDepthVisibleFrameWithOffset(visibleList, offset);
2363     EXPECT_EQ(testNode1->GetChildren().size(), 3);
2364 }
2365 
2366 /**
2367  * @tc.name: UINodeTestNg070
2368  * @tc.desc: Test ui node method TouchTest/MouseTest
2369  * @tc.type: FUNC
2370  */
2371 HWTEST_F(UINodeTestNg, UINodeTestNg070, TestSize.Level1)
2372 {
2373     /**
2374      * @tc.steps: step1. create FrameNode node and construct params
2375      */
2376     auto testNode1 = TestNode::CreateTestNode(21);
2377     const RefPtr<FrameNode> testNode2 =
2378         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2379     const RefPtr<FrameNode> testNode3 =
2380         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2381     const RefPtr<FrameNode> testNode4 =
2382         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2383     testNode1->AddChild(testNode2, 1, false);
2384     testNode1->AddChild(testNode3, 1, false);
2385     testNode1->AddChild(testNode4, 1, false);
2386     PointT<float> globalPoint;
2387     PointT<float> parentLocalPoint;
2388     PointT<float> parentRevertPoint;
2389     TouchRestrict touchRestrict;
2390     MouseTestResult onMouseResult;
2391     MouseTestResult onHoverResult;
2392     RefPtr<FrameNode> hoverNode;
2393     HitTestResult ret =
2394         testNode1->UINode::MouseTest(globalPoint, parentLocalPoint, onMouseResult, onHoverResult, hoverNode);
2395     EXPECT_EQ(ret == HitTestResult::BUBBLING, true);
2396     AxisTestResult onAxisResult;
2397     HitTestResult ret2 =
2398         testNode1->UINode::AxisTest(globalPoint, parentLocalPoint, parentRevertPoint, touchRestrict, onAxisResult);
2399     EXPECT_EQ(ret2 == HitTestResult::OUT_OF_REGION, true);
2400 }
2401 
2402 /**
2403  * @tc.name: UINodeTestNg071
2404  * @tc.desc: Test ui node method SetAccessibilityNodeVirtual
2405  * @tc.type: FUNC
2406  */
2407 HWTEST_F(UINodeTestNg, UINodeTestNg071, TestSize.Level1)
2408 {
2409     /**
2410      * @tc.steps: step1. create FrameNode node and construct params
2411      */
2412     auto testNode1 = TestNode::CreateTestNode(21);
2413     auto child = TestNode::CreateTestNode(22);
2414     testNode1->SetAccessibilityNodeVirtual();
2415     EXPECT_EQ(testNode1->IsAccessibilityVirtualNode(), true);
2416     testNode1->SetAccessibilityVirtualNodeParent(child);
2417     auto weakResult = testNode1->GetVirtualNodeParent();
2418     auto result = weakResult.Upgrade();
2419     ASSERT_NE(result, nullptr);
2420 }
2421 
2422 /**
2423  * @tc.name: UINodeTestNg072
2424  * @tc.desc: Test ui node method
2425  * @tc.type: FUNC
2426  */
2427 HWTEST_F(UINodeTestNg, UINodeTestNg072, TestSize.Level1)
2428 {
2429     /**
2430      * @tc.steps: step1. create FrameNode node and construct params
2431      */
2432     ZERO->hostPageId_ = 0;
2433     ZERO->SetInDestroying();
2434     EXPECT_NE(ZERO->OnRemoveFromParent(false), false);
2435     ZERO->SetDestroying(false);
2436     ZERO->Clean();
2437 }
2438 
2439 /**
2440  * @tc.name: UINodeTestNg073
2441  * @tc.desc: Test ui node method
2442  * @tc.type: FUNC
2443  */
2444 HWTEST_F(UINodeTestNg, UINodeTestNg073, TestSize.Level1)
2445 {
2446     /**
2447      * @tc.steps: step1. create frame node
2448      */
2449     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
2450     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
2451     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
2452     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), false);
2453 
2454     child->tag_ = V2::IMAGE_ETS_TAG;
2455     parent->AddChild(child);
2456     std::list<RefPtr<UINode>> nodes;
2457 
2458     /**
2459      * @tc.steps: step2. call GetFirstBuilderNode
2460      * @tc.expected: child isRootBuilderNode_ is true, nodes size is 1
2461      */
2462     child->SetIsRootBuilderNode(true);
2463     BuilderUtils::GetFirstBuilderNode(parent, nodes);
2464     EXPECT_EQ(nodes.size(), SIZE_ONE);
2465 
2466     child->SetIsRootBuilderNode(false);
2467     auto son = FrameNode::CreateFrameNode(
2468         "son", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>(), false);
2469     child->AddChild(son);
2470     son->SetIsRootBuilderNode(true);
2471     child->tag_ = V2::NODE_CONTAINER_ETS_TAG;
2472     nodes.clear();
2473     BuilderUtils::GetFirstBuilderNode(parent, nodes);
2474     EXPECT_EQ(nodes.size(), SIZE_ZERO);
2475     child->tag_ = V2::JS_NODE_SLOT_ETS_TAG;
2476     BuilderUtils::GetFirstBuilderNode(parent, nodes);
2477     EXPECT_EQ(nodes.size(), SIZE_ZERO);
2478 
2479     child->tag_ = V2::IMAGE_ETS_TAG;
2480     BuilderUtils::GetFirstBuilderNode(parent, nodes);
2481     EXPECT_EQ(nodes.size(), SIZE_ONE);
2482 }
2483 
2484 /**
2485  * @tc.name: GetPerformanceCheckData004
2486  * @tc.desc: Test ui node method GetPerformanceCheckData
2487  * @tc.type: FUNC
2488  */
2489 HWTEST_F(UINodeTestNg, GetPerformanceCheckData004, TestSize.Level1)
2490 {
2491     /**
2492      * @tc.steps: step1. create parent and childframe node
2493      */
2494     auto parentId = ElementRegister::GetInstance()->MakeUniqueId();
2495     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
2496     auto childIdId2 = ElementRegister::GetInstance()->MakeUniqueId();
2497     auto parent = FrameNode::CreateFrameNode("parent", parentId, AceType::MakeRefPtr<Pattern>(), true);
2498     auto child = FrameNode::CreateFrameNode("child", childId, AceType::MakeRefPtr<Pattern>(), true);
2499     auto child2 = FrameNode::CreateFrameNode("child2", childIdId2, AceType::MakeRefPtr<Pattern>(), true);
2500 
2501     parent->tag_ = V2::JS_FOR_EACH_ETS_TAG;
2502     parent->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
2503     child->tag_ = V2::COMMON_VIEW_ETS_TAG;
2504     child->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
2505     parent->AddChild(child);
2506 
2507     /**
2508      * @tc.steps: step2.  construct parameter performanceCheckNodeMap and call GetPerformanceCheckData
2509      * @tc.expected: isBuildByJS_ is false
2510      */
2511     auto nodeId = ElementRegister::GetInstance()->MakeUniqueId();
2512     PerformanceCheckNodeMap nodeMap;
2513     PerformanceCheckNode performanceCheckNode = PerformanceCheckNode();
2514     nodeMap.emplace(nodeId, performanceCheckNode);
2515     child->UINode::GetPerformanceCheckData(nodeMap);
2516     child2->tag_ = V2::COMMON_VIEW_ETS_TAG;
2517     child2->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
2518     child->AddChild(child2, 1, false);
2519     auto childId4 = ElementRegister::GetInstance()->MakeUniqueId();
2520     auto child4 = FrameNode::CreateFrameNode("child4", childId4, AceType::MakeRefPtr<Pattern>(), true);
2521     child4->tag_ = V2::JS_FOR_EACH_ETS_TAG;
2522     child4->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
2523     child->AddChild(child4, 1, false);
2524     // grandChildren exist
2525     auto childIdId3 = ElementRegister::GetInstance()->MakeUniqueId();
2526     auto child3 = FrameNode::CreateFrameNode("child3", childIdId3, AceType::MakeRefPtr<Pattern>(), true);
2527     child3->nodeInfo_ = std::make_unique<PerformanceCheckNode>();
2528     child2->AddChild(child3);
2529     child->UINode::GetPerformanceCheckData(nodeMap);
2530 
2531     /**
2532      * @tc.steps: step3. change child tag_ and call GetPerformanceCheckData
2533      * @tc.expected: isBuildByJS_ is false
2534      */
2535     child->tag_ = V2::JS_FOR_EACH_ETS_TAG;
2536     child->UINode::GetPerformanceCheckData(nodeMap);
2537     EXPECT_EQ(child->nodeInfo_->nodeTag, "ForEach");
2538 }
2539 
2540 /**
2541  * @tc.name: CollectCleanedChildren
2542  * @tc.desc: Test ui node method CollectCleanedChildren
2543  * @tc.type: FUNC
2544  */
2545 HWTEST_F(UINodeTestNg, CollectCleanedChildren, TestSize.Level1)
2546 {
2547     /**
2548      * @tc.steps: step1. set API13.
2549      */
2550     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
2551     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_THIRTEEN);
2552 
2553     /**
2554      * @tc.steps: step2. create FrameNode with child
2555      */
2556     const RefPtr<FrameNode> testNode1 =
2557         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2558     const RefPtr<FrameNode> testNode2 =
2559         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2560     const RefPtr<FrameNode> testNode3 =
2561         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2562     const RefPtr<FrameNode> testNode4 =
2563         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2564     const RefPtr<FrameNode> testNode5 =
2565         FrameNode::CreateFrameNode("testNode5", 5, AceType::MakeRefPtr<Pattern>(), true);
2566 
2567     /**
2568      * @tc.steps: step3. add child
2569      */
2570     testNode1->AddChild(testNode2, 1, false);
2571     testNode1->AddChild(testNode3, 1, false);
2572     testNode1->AddChild(testNode4, 1, false);
2573     testNode2->AddChild(testNode5, 1, false);
2574 
2575     /**
2576      * @tc.steps: step4. test CollectCleanedChildren.
2577      */
2578     testNode2->isDisappearing_ = true;
2579     std::list<int32_t> removedElmtId2;
2580     std::list<int32_t> reservedElmtIds;
2581     testNode1->CollectCleanedChildren(testNode1->GetChildren(), removedElmtId2, reservedElmtIds, true);
2582     EXPECT_EQ(removedElmtId2.size(), 4);
2583     testNode2->CollectCleanedChildren(testNode2->GetChildren(), removedElmtId2, reservedElmtIds, false);
2584     EXPECT_EQ(removedElmtId2.size(), 5);
2585 
2586     /**
2587      * @tc.steps: step5. revert to the origin API.
2588      */
2589     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
2590 }
2591 
2592 /**
2593  * @tc.name: CollectRemovedChildren001
2594  * @tc.desc: Test ui node method CollectRemovedChildren
2595  * @tc.type: FUNC
2596  */
2597 HWTEST_F(UINodeTestNg, CollectRemovedChildren001, TestSize.Level1)
2598 {
2599     /**
2600      * @tc.steps: step1. set API12.
2601      */
2602     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
2603     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_TWELVE);
2604 
2605     /**
2606      * @tc.steps: step2. create FrameNode with child
2607      */
2608     const RefPtr<FrameNode> testNode1 =
2609         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2610     const RefPtr<FrameNode> testNode2 =
2611         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2612     const RefPtr<FrameNode> testNode3 =
2613         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2614     const RefPtr<FrameNode> testNode4 =
2615         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2616     const RefPtr<FrameNode> testNode5 =
2617         FrameNode::CreateFrameNode("testNode5", 5, AceType::MakeRefPtr<Pattern>(), true);
2618 
2619     /**
2620      * @tc.steps: step3. add child
2621      */
2622     testNode1->AddChild(testNode2, 1, false);
2623     testNode1->AddChild(testNode3, 1, false);
2624     testNode1->AddChild(testNode4, 1, false);
2625     testNode2->AddChild(testNode5, 1, false);
2626 
2627     /**
2628      * @tc.steps: step4. test CollectRemovedChildren.
2629      */
2630     testNode2->isDisappearing_ = true;
2631     std::list<int32_t> removedElmtId1;
2632     testNode1->CollectRemovedChildren(testNode1->GetChildren(), removedElmtId1, true);
2633     EXPECT_EQ(removedElmtId1.size(), 2);
2634     testNode2->CollectRemovedChildren(testNode2->GetChildren(), removedElmtId1, true);
2635     EXPECT_EQ(removedElmtId1.size(), 3);
2636 
2637     /**
2638      * @tc.steps: step5. revert to the origin API.
2639      */
2640     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
2641 }
2642 
2643 /**
2644  * @tc.name: CollectRemovedChildren002
2645  * @tc.desc: Test ui node method CollectRemovedChildren
2646  * @tc.type: FUNC
2647  */
2648 HWTEST_F(UINodeTestNg, CollectRemovedChildren002, TestSize.Level1)
2649 {
2650     /**
2651      * @tc.steps: step1. set API13.
2652      */
2653     int originApiVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion();
2654     AceApplicationInfo::GetInstance().apiVersion_ = static_cast<int32_t>(PlatformVersion::VERSION_THIRTEEN);
2655 
2656     /**
2657      * @tc.steps: step2. create FrameNode with child
2658      */
2659     const RefPtr<FrameNode> testNode1 =
2660         FrameNode::CreateFrameNode("testNode1", 1, AceType::MakeRefPtr<Pattern>(), true);
2661     const RefPtr<FrameNode> testNode2 =
2662         FrameNode::CreateFrameNode("testNode2", 2, AceType::MakeRefPtr<Pattern>(), true);
2663     const RefPtr<FrameNode> testNode3 =
2664         FrameNode::CreateFrameNode("testNode3", 3, AceType::MakeRefPtr<Pattern>(), true);
2665     const RefPtr<FrameNode> testNode4 =
2666         FrameNode::CreateFrameNode("testNode4", 4, AceType::MakeRefPtr<Pattern>(), true);
2667     const RefPtr<FrameNode> testNode5 =
2668         FrameNode::CreateFrameNode("testNode5", 5, AceType::MakeRefPtr<Pattern>(), true);
2669 
2670     /**
2671      * @tc.steps: step3. add child
2672      */
2673     testNode1->AddChild(testNode2, 1, false);
2674     testNode1->AddChild(testNode3, 1, false);
2675     testNode1->AddChild(testNode4, 1, false);
2676     testNode2->AddChild(testNode5, 1, false);
2677 
2678     /**
2679      * @tc.steps: step4. test CollectRemovedChildren.
2680      */
2681     testNode2->isDisappearing_ = true;
2682     std::list<int32_t> removedElmtId2;
2683     testNode1->CollectRemovedChildren(testNode1->GetChildren(), removedElmtId2, true);
2684     EXPECT_EQ(removedElmtId2.size(), 4);
2685     testNode2->CollectRemovedChildren(testNode2->GetChildren(), removedElmtId2, false);
2686     EXPECT_EQ(removedElmtId2.size(), 5);
2687 
2688     /**
2689      * @tc.steps: step5. revert to the origin API.
2690      */
2691     AceApplicationInfo::GetInstance().SetApiTargetVersion(originApiVersion);
2692 }
2693 
2694 /**
2695  * @tc.name: IsAutoFillContainerNode001
2696  * @tc.desc: Test ui node method IsAutoFillContainerNode
2697  * @tc.type: FUNC
2698  */
2699 HWTEST_F(UINodeTestNg, IsAutoFillContainerNode001, TestSize.Level1)
2700 {
2701     const RefPtr<FrameNode> testNode1 =
2702         FrameNode::CreateFrameNode(V2::PAGE_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), false);
2703     EXPECT_TRUE(testNode1->IsAutoFillContainerNode());
2704     const RefPtr<FrameNode> testNode2 =
2705         FrameNode::CreateFrameNode(V2::NAVDESTINATION_VIEW_ETS_TAG, 2, AceType::MakeRefPtr<Pattern>(), false);
2706     EXPECT_TRUE(testNode2->IsAutoFillContainerNode());
2707     const RefPtr<FrameNode> testNode3 =
2708         FrameNode::CreateFrameNode(V2::DIALOG_ETS_TAG, 3, AceType::MakeRefPtr<Pattern>(), false);
2709     EXPECT_TRUE(testNode3->IsAutoFillContainerNode());
2710     const RefPtr<FrameNode> testNode4 =
2711         FrameNode::CreateFrameNode(V2::SHEET_PAGE_TAG, 4, AceType::MakeRefPtr<Pattern>(), false);
2712     EXPECT_TRUE(testNode4->IsAutoFillContainerNode());
2713     const RefPtr<FrameNode> testNode5 =
2714         FrameNode::CreateFrameNode(V2::MODAL_PAGE_TAG, 5, AceType::MakeRefPtr<Pattern>(), false);
2715     EXPECT_TRUE(testNode5->IsAutoFillContainerNode());
2716     const RefPtr<FrameNode> testNode6 =
2717         FrameNode::CreateFrameNode(V2::POPUP_ETS_TAG, 6, AceType::MakeRefPtr<Pattern>(), false);
2718     EXPECT_TRUE(testNode6->IsAutoFillContainerNode());
2719     const RefPtr<FrameNode> testNode7 =
2720         FrameNode::CreateFrameNode("OTHER_TAG", 7, AceType::MakeRefPtr<Pattern>(), false);
2721     EXPECT_FALSE(testNode7->IsAutoFillContainerNode());
2722 }
2723 
2724 /**
2725  * @tc.name: AddFunc_API01
2726  * @tc.desc: CanAddChildWhenTopNodeIsModalUec
2727  * @tc.type: FUNC
2728  */
2729 HWTEST_F(UINodeTestNg, AddFunc_API01, TestSize.Level1)
2730 {
2731     /**
2732      * @tc.steps: step1. prepare the environment variables for the function.
2733      */
2734     const RefPtr<FrameNode> testNode =
2735         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2736     testNode->AddChild(TWO, 1, false);
2737     testNode->AddChild(THREE, 1, false);
2738     std::list<RefPtr<UINode>>::iterator itr = testNode->children_.end();
2739     testNode->CanAddChildWhenTopNodeIsModalUec(itr);
2740 
2741     /**
2742      * @tc.steps: step2. change function parameters.
2743      */
2744     itr = testNode->children_.begin();
2745     testNode->CanAddChildWhenTopNodeIsModalUec(itr);
2746     itr = testNode->children_.begin();
2747     itr++;
2748     TWO->isAllowAddChildBelowModalUec_ = false;
2749     TWO->tag_ = V2::MODAL_PAGE_TAG;
2750     THREE->isAllowAddChildBelowModalUec_ = false;
2751     THREE->tag_ = V2::MODAL_PAGE_TAG;
2752 
2753     /**
2754      * @tc.steps: step3. test CanAddChildWhenTopNodeIsModalUec.
2755      */
2756     bool res = testNode->CanAddChildWhenTopNodeIsModalUec(itr);
2757     EXPECT_EQ(res, true);
2758 }
2759 
2760 /**
2761  * @tc.name: AddFunc_API02
2762  * @tc.desc: AddChildAfter
2763  * @tc.type: FUNC
2764  */
2765 HWTEST_F(UINodeTestNg, AddFunc_API02, TestSize.Level1)
2766 {
2767     /**
2768      * @tc.steps: step1. prepare the environment variables for the function.
2769      */
2770     const RefPtr<FrameNode> testNode =
2771         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2772     EXPECT_EQ(testNode->children_.size(), 0);
2773     auto node = TestNode::CreateTestNode(TEST_ID_ONE);
2774     auto node2 = TestNode::CreateTestNode(TEST_ID_TWO);
2775     testNode->AddChild(node, 1, false);
2776 
2777     /**
2778      * @tc.steps: step2. test CanAddChildWhenTopNodeIsModalUec.
2779      */
2780     testNode->AddChildAfter(node, node);
2781     EXPECT_EQ(testNode->children_.size(), 1);
2782     testNode->AddChildAfter(node2, node);
2783     EXPECT_EQ(testNode->children_.size(), 2);
2784     testNode->Clean(false);
2785 }
2786 
2787 /**
2788  * @tc.name: AddFunc_API03
2789  * @tc.desc: RemoveChild
2790  * @tc.type: FUNC
2791  */
2792 HWTEST_F(UINodeTestNg, AddFunc_API03, TestSize.Level1)
2793 {
2794     /**
2795      * @tc.steps: step1. prepare the environment variables for the function.
2796      */
2797     ONE->AddChild(TWO, 1, false);
2798     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
2799     auto testNode2 = TestNode::CreateTestNode(TEST_ID_TWO);
2800     ONE->AddChild(testNode, 1, false);
2801     ONE->AddChild(testNode2, 1, false);
2802     EXPECT_EQ(ONE->children_.size(), 3);
2803     ONE->isDestroyingState_ = true;
2804     auto context = MockPipelineContext::GetCurrent();
2805     ONE->AttachContext(AceType::RawPtr(context), true);
2806 
2807 
2808     /**
2809      * @tc.steps: step2. observe the changes in the number of children after removal.
2810      */
2811     auto iter = ONE->RemoveChild(TWO);
2812     EXPECT_EQ(iter, ONE->children_.end());
2813     ONE->isDestroyingState_ = false;
2814     iter = ONE->RemoveChild(testNode);
2815     EXPECT_EQ(iter, ONE->children_.end());
2816 }
2817 
2818 /**
2819  * @tc.name: AddFunc_API04
2820  * @tc.desc: Clean
2821  * @tc.type: FUNC
2822  */
2823 HWTEST_F(UINodeTestNg, AddFunc_API04, TestSize.Level1)
2824 {
2825     /**
2826      * @tc.steps: step1. prepare the environment variables for the function.
2827      */
2828     ONE->AddChild(TWO, 1, false);
2829     auto iter = ONE->RemoveChild(TWO);
2830     EXPECT_NE(iter, ONE->children_.end());
2831     ONE->RemoveChildAtIndex(0);
2832     EXPECT_EQ(ONE->children_.size(), 0);
2833 
2834     /**
2835      * @tc.steps: step2. add child nodes, to compare the number of child nodes after cleaning.
2836      */
2837     const RefPtr<FrameNode> testNode =
2838         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2839     const RefPtr<FrameNode> testNode2 =
2840         FrameNode::CreateFrameNode("testNode2", 1, AceType::MakeRefPtr<Pattern>(), true);
2841     testNode->AddChild(testNode2, 1, false);
2842 
2843     /**
2844      * @tc.steps: step3. test Clean.
2845      */
2846     testNode2->isDestroyingState_ = true;
2847     testNode->Clean(true, false);
2848     EXPECT_EQ(testNode->children_.size(), 0);
2849 }
2850 
2851 /**
2852  * @tc.name: AddFunc_API05
2853  * @tc.desc: MountToParentAfter
2854  * @tc.type: FUNC
2855  */
2856 HWTEST_F(UINodeTestNg, AddFunc_API05, TestSize.Level1)
2857 {
2858     /**
2859      * @tc.steps: step1. prepare the environment variables for the function.
2860      */
2861     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
2862     ONE->isInDestroying_ = true;
2863     ONE->hostPageId_ = 3;
2864 
2865     /**
2866      * @tc.steps: step2. test MountToParentAfter.
2867      */
2868     ONE->MountToParentAfter(ONE, testNode);
2869     EXPECT_EQ(testNode->hostPageId_, 0);
2870     EXPECT_EQ(testNode->isInDestroying_, false);
2871 }
2872 
2873 /**
2874  * @tc.name: AddFunc_API06
2875  * @tc.desc: MountToParentBefore
2876  * @tc.type: FUNC
2877  */
2878 HWTEST_F(UINodeTestNg, AddFunc_API06, TestSize.Level1)
2879 {
2880     /**
2881      * @tc.steps: step1. prepare the environment variables for the function.
2882      */
2883     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
2884     ONE->isInDestroying_ = true;
2885     ONE->hostPageId_ = 5;
2886 
2887     /**
2888      * @tc.steps: step2. test MountToParentBefore.
2889      */
2890     ONE->MountToParentBefore(ONE, testNode);
2891     EXPECT_EQ(testNode->hostPageId_, 0);
2892     EXPECT_EQ(testNode->isInDestroying_, false);
2893 }
2894 
2895 /**
2896  * @tc.name: AddFunc_API07
2897  * @tc.desc: OnRemoveFromParent
2898  * @tc.type: FUNC
2899  */
2900 HWTEST_F(UINodeTestNg, AddFunc_API07, TestSize.Level1)
2901 {
2902     /**
2903      * @tc.steps: step1. prepare the environment variables for the function.
2904      */
2905     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
2906 
2907     /**
2908      * @tc.steps: step2. set the variables to meet the conditional values and test the function.
2909      */
2910     testNode->isDestroyingState_ = true;
2911     auto context = MockPipelineContext::GetCurrent();
2912     testNode->AttachContext(AceType::RawPtr(context), true);
2913     bool res = testNode->OnRemoveFromParent(true);
2914     EXPECT_EQ(res, false);
2915     testNode->isDestroyingState_ = false;
2916     res = testNode->OnRemoveFromParent(true);
2917     EXPECT_EQ(res, true);
2918 }
2919 
2920 /**
2921  * @tc.name: AddFunc_API08
2922  * @tc.desc: GetParentCustomNode
2923  * @tc.type: FUNC
2924  */
2925 HWTEST_F(UINodeTestNg, AddFunc_API08, TestSize.Level1)
2926 {
2927     /**
2928      * @tc.steps: step1. prepare the environment variables for the function.
2929      */
2930     const RefPtr<FrameNode> testNode =
2931         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2932     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
2933     auto child = CustomNode::CreateCustomNode(childId, "child");
2934 
2935     /**
2936      * @tc.steps: step2. set the variables to meet the conditional values and test the function.
2937      */
2938     child->AddChild(testNode, 1, false);
2939     auto res = testNode->GetParentCustomNode();
2940     EXPECT_NE(res, nullptr);
2941 }
2942 
2943 /**
2944  * @tc.name: AddFunc_API09
2945  * @tc.desc: GetFocusParentWithBoundary、GetCurrentChildrenFocusHub
2946  * @tc.type: FUNC
2947  */
2948 HWTEST_F(UINodeTestNg, AddFunc_API09, TestSize.Level1)
2949 {
2950     /**
2951      * @tc.steps: step1. prepare the environment variables for the function.
2952      */
2953     const RefPtr<FrameNode> testNode =
2954         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
2955     std::list<RefPtr<UINode>>::iterator itr = testNode->children_.begin();
2956     testNode->DoAddChild(itr, ONE, true);
2957 
2958     /**
2959      * @tc.steps: step2. test GetFocusParentWithBoundary.
2960      */
2961     testNode->tag_ = V2::SCREEN_ETS_TAG;
2962     ONE->parent_ = testNode;
2963     auto res = ONE->GetFocusParentWithBoundary();
2964 
2965     /**
2966      * @tc.steps: step3. set the variables to meet the conditional values and test the function.
2967      */
2968     const RefPtr<FrameNode> testNode2 =
2969         FrameNode::CreateFrameNode("testNode2", 1, AceType::MakeRefPtr<Pattern>(), true);
2970     const RefPtr<FrameNode> testNode3 =
2971         FrameNode::CreateFrameNode("testNode3", 1, AceType::MakeRefPtr<Pattern>(), true);
2972     testNode2->AddChild(testNode3, 1, false);
2973     std::list<RefPtr<FocusHub>> focusNodes;
2974     testNode2->GetCurrentChildrenFocusHub(focusNodes);
2975     EXPECT_EQ(res, nullptr);
2976 }
2977 
2978 /**
2979  * @tc.name: AddFunc_API10
2980  * @tc.desc: DoAddChild、AttachToMainTree
2981  * @tc.type: FUNC
2982  */
2983 HWTEST_F(UINodeTestNg, AddFunc_API10, TestSize.Level1)
2984 {
2985     /**
2986      * @tc.steps: step1. prepare the environment variables for the function.
2987      */
2988     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
2989     std::list<RefPtr<UINode>>::iterator itr = testNode->children_.begin();
2990 
2991     /**
2992      * @tc.steps: step2. test DoAddChild.
2993      */
2994     testNode->isAccessibilityVirtualNode_ = true;
2995     testNode->themeScopeId_ = 2;
2996     testNode->isAllowUseParentTheme_ = true;
2997     testNode->DoAddChild(itr, ONE, false);
2998 
2999     /**
3000      * @tc.steps: step2. set the variables to meet the conditional values and test AttachToMainTree.
3001      */
3002     TWO->AddChild(THREE, 1, false);
3003     bool recursive = true;
3004     PipelineContext* ret = TWO->GetContextWithCheck();
3005     ret->isOpenInvisibleFreeze_ = true;
3006     TWO->onMainTree_ = false;
3007     TWO->AttachToMainTree(recursive, ret);
3008     EXPECT_TRUE(TWO->onMainTree_);
3009     TWO->DetachFromMainTree();
3010     TWO->Clean();
3011 }
3012 
3013 /**
3014  * @tc.name: AddFunc_API11
3015  * @tc.desc: AttachToMainTree
3016  * @tc.type: FUNC
3017  */
3018 HWTEST_F(UINodeTestNg, AddFunc_API11, TestSize.Level1)
3019 {
3020     /**
3021      * @tc.steps: step1. prepare the environment variables for the function.
3022      */
3023     TWO->AddChild(THREE, 1, false);
3024     TWO->onMainTree_ = false;
3025     TWO->nodeStatus_ = NodeStatus::BUILDER_NODE_OFF_MAINTREE;
3026 
3027     /**
3028      * @tc.steps: step2. test AttachToMainTree.
3029      */
3030     TWO->AttachToMainTree();
3031     EXPECT_TRUE(TWO->onMainTree_);
3032     TWO->DetachFromMainTree();
3033     TWO->Clean();
3034 }
3035 
3036 /**
3037  * @tc.name: AddFunc_API12
3038  * @tc.desc: DetachFromMainTree、SetFreeze
3039  * @tc.type: FUNC
3040  */
3041 HWTEST_F(UINodeTestNg, AddFunc_API12, TestSize.Level1)
3042 {
3043     /**
3044      * @tc.steps: step1. test SetFreeze.
3045      */
3046     ONE->SetUserFreeze(true);
3047     ONE->SetFreeze(true, true, true);
3048     ONE->SetFreeze(true, true, false);
3049 
3050     /**
3051      * @tc.steps: step2. set the variables to meet the conditional values.
3052      */
3053     TWO->AddChild(THREE, 1, false);
3054     TWO->onMainTree_ = false;
3055     TWO->nodeStatus_ = NodeStatus::BUILDER_NODE_OFF_MAINTREE;
3056 
3057     /**
3058      * @tc.steps: step3. test DetachFromMainTree.
3059      */
3060     TWO->AttachToMainTree();
3061     EXPECT_TRUE(TWO->onMainTree_);
3062     TWO->isDestroyingState_ = true;
3063     TWO->DetachFromMainTree();
3064     TWO->Clean();
3065 }
3066 
3067 /**
3068  * @tc.name: AddFunc_API13
3069  * @tc.desc: DumpTree、DumpTreeJsonForDiff
3070 	 * @tc.type: FUNC
3071  */
3072 HWTEST_F(UINodeTestNg, AddFunc_API13, TestSize.Level1)
3073 {
3074     /**
3075      * @tc.steps: step1. prepare the environment variables for the function.
3076      */
3077     const RefPtr<FrameNode> testNode =
3078         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3079     testNode->isDisappearing_ =true;
3080     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
3081 
3082     /**
3083      * @tc.steps: step2. test DumpTreeJsonForDiff and DumpTree.
3084      */
3085     testNode->DumpTreeJsonForDiff(json);
3086     testNode->DumpTree(0, true);
3087     EXPECT_TRUE(DumpLog::GetInstance().result_.find("_"));
3088 }
3089 
3090 /**
3091  * @tc.name: AddFunc_API14
3092  * @tc.desc: DumpSimplifyTree、DumpTreeById
3093  * @tc.type: FUNC
3094  */
3095 HWTEST_F(UINodeTestNg, AddFunc_API14, TestSize.Level1)
3096 {
3097     /**
3098      * @tc.steps: step1. prepare the environment variables for the function.
3099      */
3100     const RefPtr<FrameNode> testNode =
3101         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3102     testNode->AddChild(ONE, 1, false);
3103     std::shared_ptr<JsonValue> json = JsonUtil::CreateSharedPtrJson(true);
3104     auto child = FrameNode::CreateFrameNode(V2::COMMON_VIEW_ETS_TAG, 3, AceType::MakeRefPtr<Pattern>());
3105     auto child2 = FrameNode::CreateFrameNode(V2::COMMON_VIEW_ETS_TAG, 4, AceType::MakeRefPtr<Pattern>());
3106     testNode->AddDisappearingChild(child);
3107     testNode->AddDisappearingChild(child2);
3108 
3109     /**
3110      * @tc.steps: step2. test DumpSimplifyTree and DumpTreeById.
3111      */
3112     testNode->DumpSimplifyTree(0, json);
3113     std::string str = "11";
3114     testNode->nodeId_ = 11;
3115     auto res = testNode->DumpTreeById(1, str, true);
3116     EXPECT_TRUE(res);
3117 }
3118 
3119 /**
3120  * @tc.name: AddFunc_API15
3121  * @tc.desc: MouseTest、AddDisappearingChild、NotifyChange、UpdateThemeScopeUpdate
3122  * @tc.type: FUNC
3123  */
3124 HWTEST_F(UINodeTestNg, AddFunc_API15, TestSize.Level1)
3125 {
3126     /**
3127      * @tc.steps: step1. prepare the environment variables for the function.
3128      */
3129     const RefPtr<FrameNode> testNode =
3130         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3131     PointT<float> globalPoint;
3132     PointT<float> parentLocalPoint;
3133     MouseTestResult onMouseResult;
3134     MouseTestResult onHoverResult;
3135     RefPtr<FrameNode> hoverNode;
3136     auto testNode2 = TestNode::CreateTestNode(TEST_ID_TWO);
3137     testNode2->hitTestResult_ = HitTestResult::STOP_BUBBLING;
3138     testNode->AddChild(testNode2, 1, false);
3139 
3140     /**
3141      * @tc.steps: step2. set the variables to meet the conditional values and test NotifyChange.
3142      */
3143     const RefPtr<FrameNode> testNode4 =
3144         FrameNode::CreateFrameNode("testNode4", 1, AceType::MakeRefPtr<Pattern>(), true);
3145     int32_t changeIdx = 0;
3146     int32_t count = 0;
3147     int64_t id = 0;
3148     testNode4->AddChild(ONE, 1, false);
3149     ONE->UINode::NotifyChange(changeIdx, count, id, SelectOverlayNode::NotificationType::START_CHANGE_POSITION);
3150 
3151     /**
3152      * @tc.steps: step3. set the variables to meet the conditional values and test UpdateThemeScopeUpdate.
3153      */
3154     const RefPtr<FrameNode> testNode5 =
3155         FrameNode::CreateFrameNode("testNode5", 1, AceType::MakeRefPtr<Pattern>(), true);
3156     int32_t themeScopeId = 3;
3157     testNode5->themeScopeId_ = 5;
3158     testNode5->UpdateThemeScopeUpdate(themeScopeId);
3159     themeScopeId = 5;
3160     testNode5->needCallChildrenUpdate_ = true;
3161     testNode5->UpdateThemeScopeUpdate(themeScopeId);
3162 
3163     /**
3164      * @tc.steps: step4. test AddDisappearingChild and MouseTest.
3165      */
3166     auto parent = FrameNode::CreateFrameNode(V2::COMMON_VIEW_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), true);
3167     parent->AddDisappearingChild(parent);
3168     HitTestResult ret =
3169         testNode->UINode::MouseTest(globalPoint, parentLocalPoint, onMouseResult, onHoverResult, hoverNode);
3170     EXPECT_EQ(ret == HitTestResult::STOP_BUBBLING, true);
3171 }
3172 
3173 /**
3174  * @tc.name: AddFunc_API16
3175  * @tc.desc: AxisTest
3176  * @tc.type: FUNC
3177  */
3178 HWTEST_F(UINodeTestNg, AddFunc_API16, TestSize.Level1)
3179 {
3180     /**
3181      * @tc.steps: step1. prepare the environment variables for the function.
3182      */
3183     const RefPtr<FrameNode> testNode =
3184         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3185     const RefPtr<FrameNode> testNode4 =
3186         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3187     auto testNode2 = TestNode::CreateTestNode(TEST_ID_ONE);
3188     testNode2->hitTestResult_ = HitTestResult::BUBBLING;
3189     testNode->AddChild(testNode2, 1, false);
3190     auto testNode3 = TestNode::CreateTestNode(TEST_ID_TWO);
3191     testNode3->hitTestResult_ = HitTestResult::STOP_BUBBLING;
3192     testNode4->AddChild(testNode3, 1, false);
3193 
3194     /**
3195      * @tc.steps: step2. set the variables to meet the conditional values and test AxisTest.
3196      */
3197     TouchRestrict touchRestrict;
3198     AxisTestResult onAxisResult;
3199     PointT<float> globalPoint;
3200     PointT<float> parentLocalPoint;
3201     PointT<float> parentRevertPoint;
3202     HitTestResult ret =
3203         testNode->UINode::AxisTest(globalPoint, parentLocalPoint, parentRevertPoint, touchRestrict, onAxisResult);
3204     EXPECT_EQ(ret == HitTestResult::BUBBLING, true);
3205 }
3206 
3207 /**
3208  * @tc.name: AddFunc_API17
3209  * @tc.desc: CollectReservedChildren、GetContainerComponentText
3210  * @tc.type: FUNC
3211  */
3212 HWTEST_F(UINodeTestNg, AddFunc_API17, TestSize.Level1)
3213 {
3214     /**
3215      * @tc.steps: step1. prepare the environment variables for the function and test CollectReservedChildren.
3216      */
3217     const RefPtr<FrameNode> testNode =
3218         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3219     std::list<int32_t> reservedElmtId;
3220     testNode->CollectReservedChildren(reservedElmtId);
3221     testNode->tag_ = V2::JS_VIEW_ETS_TAG;
3222     testNode->CollectReservedChildren(reservedElmtId);
3223 
3224     /**
3225      * @tc.steps: step2. set the variables to meet the conditional values and test GetContainerComponentText.
3226      */
3227     const RefPtr<FrameNode> testNode2 =
3228         FrameNode::CreateFrameNode("testNode2", 1, AceType::MakeRefPtr<Pattern>(), true);
3229     testNode2->AddChild(ONE, 1, false);
3230     ONE->tag_ = V2::TEXT_ETS_TAG;
3231     std::u16string text;
3232     testNode2->GetContainerComponentText(text);
3233     ONE->tag_ = V2::TEXT_COMPONENT_TAG;
3234     testNode2->GetContainerComponentText(text);
3235 
3236     /**
3237      * @tc.steps: step3. set the variables to meet the conditional values.
3238      */
3239     TouchRestrict touchRestrict;
3240     AxisTestResult onAxisResult;
3241     PointT<float> globalPoint;
3242     PointT<float> parentLocalPoint;
3243     PointT<float> parentRevertPoint;
3244     auto testNode3 = TestNode::CreateTestNode(TEST_ID_TWO);
3245     testNode3->hitTestResult_ = HitTestResult::STOP_BUBBLING;
3246 
3247     /**
3248      * @tc.steps: step4. test AxisTest.
3249      */
3250     testNode->AddChild(testNode3, 1, false);
3251     HitTestResult ret =
3252         testNode->UINode::AxisTest(globalPoint, parentLocalPoint, parentRevertPoint, touchRestrict, onAxisResult);
3253     EXPECT_EQ(ret == HitTestResult::STOP_BUBBLING, true);
3254 }
3255 
3256 /**
3257  * @tc.name: AddFunc_API18
3258  * @tc.desc: SetDestroying、HasSkipNode
3259  * @tc.type: FUNC
3260  */
3261 HWTEST_F(UINodeTestNg, AddFunc_API18, TestSize.Level1)
3262 {
3263     /**
3264      * @tc.steps: step1. prepare the environment variables for the function.
3265      */
3266     const RefPtr<FrameNode> testNode =
3267         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3268     auto testNode2 = TestNode::CreateTestNode(TEST_ID_ONE);
3269     testNode->AddChild(testNode2, 1, false);
3270     bool isDestroying = false;
3271     bool cleanStatus = false;
3272     testNode->isInDestroying_ = false;
3273 
3274     /**
3275      * @tc.steps: step2. test SetDestroying.
3276      */
3277     testNode->SetDestroying(isDestroying, cleanStatus);
3278     testNode->isInDestroying_ = true;
3279     testNode2->isCNode_ = true;
3280     testNode->SetDestroying(isDestroying, cleanStatus);
3281 
3282     /**
3283      * @tc.steps: step3. set the variables to meet the conditional values.
3284      */
3285     const RefPtr<FrameNode> testNode3 =
3286         FrameNode::CreateFrameNode("testNode3", 1, AceType::MakeRefPtr<Pattern>(), true);
3287     const RefPtr<FrameNode> testNode4 =
3288         FrameNode::CreateFrameNode("testNode4", 1, AceType::MakeRefPtr<Pattern>(), true);
3289     testNode->AddChild(testNode3, 1, false);
3290     testNode3->AddChild(testNode4, 1, false);
3291 
3292     /**
3293      * @tc.steps: step4. test HasSkipNode.
3294      */
3295     bool res = testNode->HasSkipNode();
3296     EXPECT_FALSE(res);
3297     testNode4->tag_ = V2::WEB_ETS_TAG;
3298     res = testNode->HasSkipNode();
3299     EXPECT_TRUE(res);
3300     testNode3->tag_ = V2::WEB_ETS_TAG;
3301     res = testNode->HasSkipNode();
3302     EXPECT_TRUE(res);
3303 }
3304 
3305 /**
3306  * @tc.name: AddFunc_API19
3307  * @tc.desc: TraversingCheck、LessThanAPITargetVersion
3308  * @tc.type: FUNC
3309  */
3310 HWTEST_F(UINodeTestNg, AddFunc_API19, TestSize.Level1)
3311 {
3312     /**
3313      * @tc.steps: step1. prepare the environment variables for the function and test LessThanAPITargetVersion.
3314      */
3315     const RefPtr<FrameNode> testNode =
3316         FrameNode::CreateFrameNode("testNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3317     bool res = testNode->LessThanAPITargetVersion(PlatformVersion::VERSION_THIRTEEN);
3318     EXPECT_TRUE(res);
3319     const RefPtr<FrameNode> testNode2 =
3320         FrameNode::CreateFrameNode("testNode2", 1, AceType::MakeRefPtr<Pattern>(), true);
3321     int32_t apiTargetVersion  = 1;
3322     AceApplicationInfo::GetInstance().SetApiTargetVersion(apiTargetVersion);
3323     auto context = MockPipelineContext::GetCurrent();
3324     testNode2->context_ = AceType::RawPtr(context);
3325     res = testNode2->LessThanAPITargetVersion(PlatformVersion::VERSION_SIX);
3326 
3327     /**
3328      * @tc.steps: step2. set the variables to meet the conditional values and test TraversingCheck.
3329      */
3330     const RefPtr<FrameNode> testNode3 =
3331         FrameNode::CreateFrameNode("testNode3", 0, AceType::MakeRefPtr<Pattern>());
3332     const RefPtr<FrameNode> testNode4 =
3333         FrameNode::CreateFrameNode("testNode4", 0, AceType::MakeRefPtr<Pattern>());
3334     bool withAbort = false;
3335     testNode3->isTraversing_ = true;
3336     testNode3->TraversingCheck(testNode4, withAbort);
3337     testNode3->TraversingCheck(nullptr, withAbort);
3338     EXPECT_TRUE(res);
3339 }
3340 
3341 /**
3342  * @tc.name: GetInteractionEventBindingInfo001
3343  * @tc.desc: Test ui node method GetInteractionEventBindingInfo when register onClick with JS.
3344  * @tc.type: FUNC
3345  */
3346 HWTEST_F(UINodeTestNg, GetInteractionEventBindingInfo001, TestSize.Level1)
3347 {
3348     /**
3349      * @tc.steps: step1. create uiNode.
3350      * @tc.expected: uiNode is not null.
3351      */
3352     char tagRoot[] = "root";
3353     auto patternRoot = AceType::MakeRefPtr<Pattern>();
3354     auto frameNodeRoot = FrameNode::CreateFrameNode(tagRoot, 1, patternRoot, true);
3355     ViewStackProcessor::GetInstance()->Push(frameNodeRoot);
3356     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3357     ASSERT_NE(uiNode, nullptr);
3358 
3359     /**
3360      * @tc.steps: step2. Bind onClick with JS.
3361      * @tc.expected: InteractionEventBindingInfo.baseEventRegistered = true.
3362      */
3363     uiNode->setIsCNode(false);
3364     ViewStackProcessor::GetInstance()->Push(uiNode);
3365     GestureEventFunc tapEventFunc;
3366     ViewAbstract::SetOnClick(std::move(tapEventFunc));
3367     EXPECT_TRUE(uiNode->GetInteractionEventBindingInfo().baseEventRegistered);
3368     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nodeEventRegistered);
3369     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nativeEventRegistered);
3370     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().builtInEventRegistered);
3371 }
3372 
3373 /**
3374  * @tc.name: GetInteractionEventBindingInfo002
3375  * @tc.desc: Test ui node method GetInteractionEventBindingInfo when register onClick with attributeModifier.
3376  * @tc.type: FUNC
3377  */
3378 HWTEST_F(UINodeTestNg, GetInteractionEventBindingInfo002, TestSize.Level1)
3379 {
3380     /**
3381      * @tc.steps: step1. create uiNode.
3382      * @tc.expected: uiNode is not null.
3383      */
3384     char tagRoot[] = "root";
3385     auto patternRoot = AceType::MakeRefPtr<Pattern>();
3386     auto frameNodeRoot = FrameNode::CreateFrameNode(tagRoot, 1, patternRoot, true);
3387     ViewStackProcessor::GetInstance()->Push(frameNodeRoot);
3388     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3389     ASSERT_NE(uiNode, nullptr);
3390 
3391     /**
3392      * @tc.steps: step2. Bind onClick with attributeModifier.
3393      * @tc.expected: InteractionEventBindingInfo.baseEventRegistered = true.
3394      */
3395     uiNode->setIsCNode(false);
3396     ViewStackProcessor::GetInstance()->Push(uiNode);
3397     auto topUINode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3398     ASSERT_NE(topUINode, nullptr);
3399     auto frameNode = AceType::DynamicCast<FrameNode>(topUINode);
3400     ASSERT_NE(frameNode, nullptr);
3401     GestureEventFunc tapEventFunc;
3402     ViewAbstract::SetOnClick(AceType::RawPtr(frameNode), std::move(tapEventFunc));
3403     EXPECT_TRUE(uiNode->GetInteractionEventBindingInfo().baseEventRegistered);
3404     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nodeEventRegistered);
3405     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nativeEventRegistered);
3406     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().builtInEventRegistered);
3407 }
3408 
3409 /**
3410  * @tc.name: GetInteractionEventBindingInfo003
3411  * @tc.desc: Test ui node method GetInteractionEventBindingInfo when register onClick with capi.
3412  * @tc.type: FUNC
3413  */
3414 HWTEST_F(UINodeTestNg, GetInteractionEventBindingInfo003, TestSize.Level1)
3415 {
3416     /**
3417      * @tc.steps: step1. create uiNode.
3418      * @tc.expected: uiNode is not null.
3419      */
3420     char tagRoot[] = "root";
3421     auto patternRoot = AceType::MakeRefPtr<Pattern>();
3422     auto frameNodeRoot = FrameNode::CreateFrameNode(tagRoot, 1, patternRoot, true);
3423     ViewStackProcessor::GetInstance()->Push(frameNodeRoot);
3424     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3425     ASSERT_NE(uiNode, nullptr);
3426 
3427     /**
3428      * @tc.steps: step2. Bind onClick with capi.
3429      * @tc.expected: InteractionEventBindingInfo.nativeEventRegistered = true.
3430      */
3431     uiNode->setIsCNode(true);
3432     ViewStackProcessor::GetInstance()->Push(uiNode);
3433     auto topUINode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3434     ASSERT_NE(topUINode, nullptr);
3435     auto frameNode = AceType::DynamicCast<FrameNode>(topUINode);
3436     ASSERT_NE(frameNode, nullptr);
3437     GestureEventFunc tapEventFunc;
3438     ViewAbstract::SetOnClick(AceType::RawPtr(frameNode), std::move(tapEventFunc));
3439     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().baseEventRegistered);
3440     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nodeEventRegistered);
3441     EXPECT_TRUE(uiNode->GetInteractionEventBindingInfo().nativeEventRegistered);
3442     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().builtInEventRegistered);
3443     ViewAbstract::DisableOnClick(AceType::RawPtr(frameNode));
3444     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nativeEventRegistered);
3445 }
3446 
3447 /**
3448  * @tc.name: GetInteractionEventBindingInfo004
3449  * @tc.desc: Test ui node method GetInteractionEventBindingInfo when register onClick with frameNode commomEvens.
3450  * @tc.type: FUNC
3451  */
3452 HWTEST_F(UINodeTestNg, GetInteractionEventBindingInfo004, TestSize.Level1)
3453 {
3454     /**
3455      * @tc.steps: step1. create uiNode.
3456      * @tc.expected: uiNode is not null.
3457      */
3458     char tagRoot[] = "root";
3459     auto patternRoot = AceType::MakeRefPtr<Pattern>();
3460     auto frameNodeRoot = FrameNode::CreateFrameNode(tagRoot, 1, patternRoot, true);
3461     ViewStackProcessor::GetInstance()->Push(frameNodeRoot);
3462     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3463     ASSERT_NE(uiNode, nullptr);
3464 
3465     /**
3466      * @tc.steps: step2. Bind onClick with frameNode commomEvens.
3467      * @tc.expected: InteractionEventBindingInfo.nodeEventRegistered = true.
3468      */
3469     uiNode->setIsCNode(false);
3470     ViewStackProcessor::GetInstance()->Push(uiNode);
3471     auto topUINode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3472     ASSERT_NE(topUINode, nullptr);
3473     auto frameNode = AceType::DynamicCast<FrameNode>(topUINode);
3474     ASSERT_NE(frameNode, nullptr);
3475     GestureEventFunc tapEventFunc;
3476     ViewAbstract::SetJSFrameNodeOnClick(AceType::RawPtr(frameNode), std::move(tapEventFunc));
3477     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().baseEventRegistered);
3478     EXPECT_TRUE(uiNode->GetInteractionEventBindingInfo().nodeEventRegistered);
3479     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nativeEventRegistered);
3480     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().builtInEventRegistered);
3481 }
3482 
3483 /**
3484  * @tc.name: GetInteractionEventBindingInfo005
3485  * @tc.desc: Test ui node method GetInteractionEventBindingInfo when register onClick with buitIn.
3486  * @tc.type: FUNC
3487  */
3488 HWTEST_F(UINodeTestNg, GetInteractionEventBindingInfo005, TestSize.Level1)
3489 {
3490     /**
3491      * @tc.steps: step1. create uiNode.
3492      * @tc.expected: uiNode is not null.
3493      */
3494     char tagRoot[] = "root";
3495     auto patternRoot = AceType::MakeRefPtr<Pattern>();
3496     auto frameNodeRoot = FrameNode::CreateFrameNode(tagRoot, 1, patternRoot, true);
3497     ViewStackProcessor::GetInstance()->Push(frameNodeRoot);
3498     auto uiNode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3499     ASSERT_NE(uiNode, nullptr);
3500 
3501     /**
3502      * @tc.steps: step2. Bind onClick with buitIn.
3503      * @tc.expected: InteractionEventBindingInfo.builtInEventRegistered = true.
3504      */
3505     uiNode->setIsCNode(false);
3506     ViewStackProcessor::GetInstance()->Push(uiNode);
3507     auto topUINode = ViewStackProcessor::GetInstance()->GetMainElementNode();
3508     ASSERT_NE(topUINode, nullptr);
3509     auto frameNode = AceType::DynamicCast<FrameNode>(topUINode);
3510     ASSERT_NE(frameNode, nullptr);
3511     auto eventHub = frameNode->GetOrCreateEventHub<EventHub>();
3512     EXPECT_TRUE(eventHub);
3513     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(eventHub);
3514     EXPECT_TRUE(gestureEventHub);
__anonc16a47900302(GestureEvent& info) 3515     auto clickCallback = [](GestureEvent& info) {};
3516     auto clickEvent = AceType::MakeRefPtr<ClickEvent>(std::move(clickCallback));
3517     gestureEventHub->AddClickEvent(clickEvent);
3518     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().baseEventRegistered);
3519     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nodeEventRegistered);
3520     EXPECT_FALSE(uiNode->GetInteractionEventBindingInfo().nativeEventRegistered);
3521     EXPECT_TRUE(uiNode->GetInteractionEventBindingInfo().builtInEventRegistered);
3522 }
3523 
3524 /**
3525  * @tc.name: UINodeTestNg049
3526  * @tc.desc: Test ui node method of instanceid
3527  * @tc.type: FUNC
3528  */
3529 HWTEST_F(UINodeTestNg, UINodeTestNg049, TestSize.Level1)
3530 {
3531     /**
3532      * @tc.steps: step1. create a uinode
3533      */
3534     auto context = MockPipelineContext::GetCurrent();
3535     ASSERT_NE(context, nullptr);
3536     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
3537     ASSERT_NE(testNode, nullptr);
3538 
3539     int32_t testId = 0;
__anonc16a47900402(int32_t newId) 3540     testNode->RegisterUpdateJSInstanceCallback([&testId](int32_t newId) { testId = newId; });
3541 
3542     /**
3543      * @tc.steps: step2. attach context
3544      */
3545     g_isMultiInstanceEnabled = true;
3546     testNode->AttachContext(AceType::RawPtr(context), true);
3547     EXPECT_EQ(testNode->context_, AceType::RawPtr(context));
3548     EXPECT_EQ(testNode->instanceId_, context->GetInstanceId());
3549     EXPECT_EQ(testId, context->GetInstanceId());
3550 
3551     /**
3552      * @tc.steps: step3. detach context
3553      */
3554     testNode->DetachContext(true);
3555     EXPECT_EQ(testNode->context_, nullptr);
3556 }
3557 
3558 /**
3559  * @tc.name: AddChildOPTTest001
3560  * @tc.desc: Test AddChild optimize
3561  * @tc.type: FUNC
3562  */
3563 HWTEST_F(UINodeTestNg, AddChildOPTTest001, TestSize.Level1)
3564 {
3565     ONE->Clean();
3566     auto testNode = TestNode::CreateTestNode(TEST_ID_ONE);
3567     auto testNode2 = TestNode::CreateTestNode(TEST_ID_TWO);
3568     ONE->AddChild(TWO, 1, false);
3569     ONE->AddChild(testNode, 1, false);
3570     ONE->AddChild(testNode2, 1, false);
3571     ONE->AddChildBefore(testNode, testNode2);
3572     EXPECT_EQ(ONE->children_.size(), 3);
3573     ONE->Clean();
3574     ONE->AddChild(TWO, 1, false);
3575     ONE->AddChild(testNode, 1, false);
3576     ONE->AddChild(testNode2, 1, false);
3577     ONE->AddChildAfter(testNode2, testNode);
3578     EXPECT_EQ(ONE->children_.size(), 3);
3579     ONE->Clean();
3580 }
3581 
3582 /**
3583  * @tc.name: FindTopNavDestination001
3584  * @tc.desc: Test FindTopNavDestination.
3585  * @tc.type: FUNC
3586  */
3587 HWTEST_F(UINodeTestNg, FindTopNavDestination001, TestSize.Level1)
3588 {
3589     /**
3590      * @tc.steps1: initialize parameters.
3591      * @tc.expected: All pointer is non-null.
3592      */
3593     auto stageNode = FrameNode::CreateFrameNode("testFrameNode", 0, AceType::MakeRefPtr<StagePattern>());
3594     auto firstNode =
3595         FrameNode::CreateFrameNode("page", 1, AceType::MakeRefPtr<PagePattern>(AceType::MakeRefPtr<PageInfo>()));
3596     stageNode->AddChild(firstNode);
3597     auto navigationGroupNode = NavigationGroupNode::GetOrCreateGroupNode(
__anonc16a47900502() 3598         V2::NAVIGATION_VIEW_ETS_TAG, 11, []() { return AceType::MakeRefPtr<NavigationPattern>(); }
3599     );
3600     RefPtr<NavigationPattern> navigationPattern = navigationGroupNode->GetPattern<NavigationPattern>();
3601     navigationPattern->navigationStack_ = AceType::MakeRefPtr<NavigationStack>();
3602     firstNode->AddChild(navigationGroupNode);
3603 
3604     /**
3605      * @tc.steps2: make some NavDestinationNode.
3606      */
3607     auto navDestinationNode1 = FrameNode::CreateFrameNode(
3608         V2::NAVDESTINATION_VIEW_ETS_TAG, 21, AceType::MakeRefPtr<Pattern>(), true);
3609     auto navDestinationNode2 = FrameNode::CreateFrameNode(
3610         V2::NAVDESTINATION_VIEW_ETS_TAG, 22, AceType::MakeRefPtr<Pattern>(), true);
3611     auto navDestinationNode3 = FrameNode::CreateFrameNode(
3612         V2::NAVDESTINATION_VIEW_ETS_TAG, 23, AceType::MakeRefPtr<Pattern>(), true);
3613     auto navDestinationNode4 = FrameNode::CreateFrameNode(
3614         V2::NAVDESTINATION_VIEW_ETS_TAG, 24, AceType::MakeRefPtr<Pattern>(), true);
3615     NavPathList navPathList;
3616     navPathList.emplace_back(std::make_pair("pageOne", navDestinationNode1));
3617     navPathList.emplace_back(std::make_pair("pageTwo", navDestinationNode2));
3618     navPathList.emplace_back(std::make_pair("pageThree", navDestinationNode3));
3619     navPathList.emplace_back(std::make_pair("pageFour", navDestinationNode4));
3620     navigationPattern->navigationStack_->SetNavPathList(navPathList);
3621 
3622     RefPtr<FrameNode> topNavNode;
3623     stageNode->FindTopNavDestination(topNavNode);
3624     ASSERT_NE(topNavNode, nullptr);
3625     EXPECT_EQ(topNavNode, navDestinationNode4);
3626 }
3627 
3628 /**
3629  * @tc.name: UINodeTestNg074
3630  * @tc.desc: Test ui node method
3631  * @tc.type: FUNC
3632  */
3633 HWTEST_F(UINodeTestNg, UINodeTestNg074, TestSize.Level1)
3634 {
3635     /**
3636      * @tc.steps1: step1. create node with darkMode
3637      * @tc.expected: node isDarkMethod_ is true
3638      */
3639     MockContainer::SetUp();
3640     EXPECT_FALSE(ONE->isDarkMode_);
3641     g_isConfigChangePerform = true;
3642     MockContainer::SetMockColorMode(ColorMode::DARK);
3643     auto lightNode = FrameNode::CreateFrameNode("lightNode", 1000, AceType::MakeRefPtr<Pattern>());
3644     EXPECT_TRUE(lightNode->isDarkMode_);
3645 
3646     /**
3647      * @tc.steps2: step1. create node with lightMode
3648      * @tc.expected: node isDarkMethod_ is false
3649      */
3650     MockContainer::SetMockColorMode(ColorMode::LIGHT);
3651     auto darkNode = FrameNode::CreateFrameNode("darkNode", 1001, AceType::MakeRefPtr<Pattern>());
3652     EXPECT_FALSE(darkNode->isDarkMode_);
3653 
3654     /**
3655      * @tc.steps3: step1. create node with no container
3656      * @tc.expected: node isDarkMethod_ is false
3657      */
3658     MockContainer::TearDown();
3659     auto noContainerNode = FrameNode::CreateFrameNode("noContainerNode", 1002, AceType::MakeRefPtr<Pattern>());
3660     EXPECT_FALSE(noContainerNode->isDarkMode_);
3661     g_isConfigChangePerform = false;
3662 }
3663 } // namespace OHOS::Ace::NG
3664