• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "test/unittest/core/base/frame_node_test_ng.h"
16 
17 #include "base/memory/ace_type.h"
18 #include "base/memory/referenced.h"
19 #include "frameworks/core/components_ng/pattern/image/image_pattern.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS::Ace::NG {
25 namespace {
26 const PanDirection DRAG_DIRECTION = { PanDirection::LEFT };
27 constexpr int32_t FINGERS_NUMBER = 2;
28 constexpr float DISTANCE = 10.5f;
29 constexpr float DEFAULT_OPACITY = 0.95f;
30 constexpr float PARA_OPACITY_VALUE_1 = 0.1f;
31 constexpr float PARA_OPACITY_VALUE_2 = 0.2f;
32 constexpr float PARA_OPACITY_VALUE_3 = 0.3f;
33 constexpr float PARA_OPACITY_VALUE_4 = 0.4f;
34 constexpr float PARA_OPACITY_VALUE_5 = 0.5f;
35 constexpr float PARA_OPACITY_VALUE_6 = 0.6f;
36 constexpr float PARA_OPACITY_VALUE_7 = 0.7f;
37 constexpr float PARA_OPACITY_VALUE_8 = 1.0f;
38 constexpr float MIN_OPACITY { 0.0f };
39 constexpr float MAX_OPACITY { 1.0f };
40 } // namespace
41 
42 /**
43  * @tc.name: FrameNodeTestNg_TouchTest041
44  * @tc.desc: Test frameNode TouchTest
45  * @tc.type: FUNC
46  */
47 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest041, TestSize.Level1)
48 {
49     /**
50      * @tc.steps: step1. construct TouchTest parameters.
51      */
52     PointF globalPoint;
53     PointF parentLocalPoint;
54     TouchRestrict touchRestrict;
55     TouchTestResult result;
56     ResponseLinkResult responseLinkResult;
57     /**
58      * @tc.steps: step2. set isActive_ and debugEnabled_ is true and FRAME_NODE2 eventHub is HTMBLOCK.
59      * @tc.expected: expect The function return value is STOP_BUBBLING.
60      */
61     FRAME_NODE2->isActive_ = true;
62     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
63     SystemProperties::debugEnabled_ = true;
64     auto eventHub = FRAME_NODE2->GetOrCreateGestureEventHub();
65     eventHub->SetHitTestMode(HitTestMode::HTMBLOCK);
66     auto test = FRAME_NODE2->TouchTest(
67         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
68     EXPECT_EQ(test, HitTestResult::OUT_OF_REGION);
69 }
70 
71 /**
72  * @tc.name: FrameNodeTestNg_TouchTest042
73  * @tc.desc: Test frameNode TouchTest
74  * @tc.type: FUNC
75  */
76 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest042, TestSize.Level1)
77 {
78     /**
79      * @tc.steps: step1. construct TouchTest parameters.
80      */
81     PointF globalPoint;
82     PointF parentLocalPoint;
83     TouchRestrict touchRestrict;
84     TouchTestResult result;
85     ResponseLinkResult responseLinkResult;
86 
87     /**
88      * @tc.steps: step2. set debugEnabled_ is true.
89      */
90     FRAME_NODE2->isActive_ = true;
91     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
92     SystemProperties::debugEnabled_ = true;
93     auto test = FRAME_NODE2->TouchTest(
94         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
95 
96     /**
97      * @tc.steps: step3. create childnode.
98      */
99     auto childNode = FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true);
100     childNode->SetExclusiveEventForChild(true);
101     auto mockRenderContextforChild = AceType::MakeRefPtr<MockRenderContext>();
102     childNode->renderContext_ = mockRenderContextforChild;
103     auto localPoint = PointF(10, 10);
104     mockRenderContextforChild->rect_ = RectF(0, 0, 100, 100);
105     EXPECT_CALL(*mockRenderContextforChild, GetPointWithTransform(_))
106         .WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
107     auto childEventHub = childNode->GetOrCreateGestureEventHub();
108     childEventHub->SetHitTestMode(HitTestMode::HTMBLOCK);
109     childNode->SetActive(true);
110 
111     /**
112      * @tc.steps: step4. add childnode to the framenode.
113      * @tc.expected: expect The function return value is STOP_BUBBLING.
114      */
115     std::list<RefPtr<FrameNode>> children;
116     children.push_back(childNode);
117     FRAME_NODE2->frameChildren_ = { children.begin(), children.end() };
118     test = FRAME_NODE2->TouchTest(
119         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
120     EXPECT_EQ(test, HitTestResult::OUT_OF_REGION);
121 }
122 
123 /**
124  * @tc.name: FrameNodeTestNg_TouchTest043
125  * @tc.desc: Test frameNode TouchTest
126  * @tc.type: FUNC
127  */
128 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest043, TestSize.Level1)
129 {
130     /**
131      * @tc.steps: step1. construct TouchTest parameters.
132      */
133     PointF globalPoint;
134     PointF parentLocalPoint;
135     TouchRestrict touchRestrict;
136     TouchTestResult result;
137     ResponseLinkResult responseLinkResult;
138     /**
139      * @tc.steps:    step2. eventHub_->GetGestureEventHub() != nullptr and callback != null.
140      * @tc.expected: expect The function return value is STOP_BUBBLING.
141      */
142     FRAME_NODE2->isActive_ = true;
143     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
144     SystemProperties::debugEnabled_ = true;
__anonc0fd8ca60202(const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) 145     auto gestureJudgeFunc = [](const RefPtr<GestureInfo>& gestureInfo, const std::shared_ptr<BaseGestureEvent>& info) {
146         return GestureJudgeResult::REJECT;
147     };
148     auto gestureEventHub = FRAME_NODE2->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
149     gestureEventHub->SetOnGestureJudgeBegin(gestureJudgeFunc);
150     auto test = FRAME_NODE2->TouchTest(
151         globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
152     EXPECT_EQ(test, HitTestResult::OUT_OF_REGION);
153 }
154 
155 /**
156  * @tc.name: FrameNodeTouchTest044
157  * @tc.desc: Test method TransferExecuteAction
158  * @tc.type: FUNC
159  */
160 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest044, TestSize.Level1)
161 {
162     /**
163      * @tc.steps: step1. construct parameters.
164      */
165     FRAME_NODE2->isActive_ = true;
166     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
167     SystemProperties::debugEnabled_ = true;
168     auto eventHub = FRAME_NODE2->GetOrCreateGestureEventHub();
169     eventHub->SetHitTestMode(HitTestMode::HTMBLOCK);
170     std::map<std::string, std::string> actionArguments;
171 
172     /**
173      * @tc.steps: step2. call TransferExecuteAction.
174      * @tc.expected: expect result is false.
175      */
176     bool result = FRAME_NODE2->TransferExecuteAction(1, actionArguments, 1, 1);
177     EXPECT_FALSE(result);
178 }
179 
180 /**
181  * @tc.name: FrameNodeTouchTest045
182  * @tc.desc: Test method GetUiExtensionId
183  * @tc.type: FUNC
184  */
185 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest045, TestSize.Level1)
186 {
187     /**
188      * @tc.steps: step1. construct parameters.
189      */
190     FRAME_NODE2->isActive_ = true;
191     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
192     SystemProperties::debugEnabled_ = true;
193 
194     /**
195      * @tc.steps: step2. call GetUiExtensionId.
196      * @tc.expected: expect result is -1.
197      */
198     int32_t result = FRAME_NODE2->GetUiExtensionId();
199     EXPECT_EQ(result, -1);
200 }
201 
202 /**
203  * @tc.name: FrameNodeTouchTest046
204  * @tc.desc: Test method WrapExtensionAbilityId
205  * @tc.type: FUNC
206  */
207 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest046, TestSize.Level1)
208 {
209     /**
210      * @tc.steps: step1. construct parameters.
211      */
212     FRAME_NODE2->isActive_ = true;
213     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
214     SystemProperties::debugEnabled_ = true;
215 
216     int32_t extensionOffset = 1;
217     int32_t abilityId = 1;
218 
219     /**
220      * @tc.steps: step2. call WrapExtensionAbilityId.
221      * @tc.expected: expect result is -1.
222      */
223     int32_t result = FRAME_NODE2->WrapExtensionAbilityId(extensionOffset, abilityId);
224     EXPECT_EQ(result, -1);
225 }
226 
227 /**
228  * @tc.name: FrameNodeTouchTest048
229  * @tc.desc: Test method DumpViewDataPageNode
230  * @tc.type: FUNC
231  */
232 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest048, TestSize.Level1)
233 {
234     /**
235      * @tc.steps: step1. construct parameters.
236      */
237     FRAME_NODE2->isActive_ = true;
238     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
239     SystemProperties::debugEnabled_ = true;
240     auto viewDataWrap = ViewDataWrap::CreateViewDataWrap();
241 
242     /**
243      * @tc.steps: step2. call DumpViewDataPageNode.
244      * @tc.expected: expect renderContext_ not nullptr.
245      */
246 
247     FRAME_NODE2->DumpViewDataPageNode(viewDataWrap);
248     EXPECT_NE(FRAME_NODE2->renderContext_, nullptr);
249 }
250 
251 /**
252  * @tc.name: FrameNodeTouchTest049
253  * @tc.desc: Test method GetResponseRegionList
254  * @tc.type: FUNC
255  */
256 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest049, TestSize.Level1)
257 {
258     /**
259      * @tc.steps: step1. construct parameters.
260      */
261     FRAME_NODE2->isActive_ = true;
262     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
263 
264     DimensionRect responseRect(Dimension(0), Dimension(0), DimensionOffset(OFFSETF));
265     std::vector<DimensionRect> mouseResponseRegion;
266     mouseResponseRegion.emplace_back(responseRect);
267 
268     /**
269      * @tc.steps: step2. call GetResponseRegionList.
270      * @tc.expected: expect MouseResponseRegion is not empty.
271      */
272     auto gestureEventHub = FRAME_NODE2->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
273     gestureEventHub->SetMouseResponseRegion(mouseResponseRegion);
274 
275     auto paintRect = FRAME_NODE2->renderContext_->GetPaintRectWithoutTransform();
276     FRAME_NODE2->GetResponseRegionList(paintRect, 1);
277     EXPECT_FALSE(gestureEventHub->GetMouseResponseRegion().empty());
278 }
279 
280 /**
281  * @tc.name: FrameNodeTouchTest050
282  * @tc.desc: Test method GetResponseRegionList
283  * @tc.type: FUNC
284  */
285 HWTEST_F(FrameNodeTestNg, FrameNodeTouchTest050, TestSize.Level1)
286 {
287     /**
288      * @tc.steps: step1. construct parameters.
289      */
290     FRAME_NODE2->isActive_ = true;
291 
292     /**
293      * @tc.steps: step2. call GetResponseRegionList.
294      * @tc.expected: expect GetResponseRegion is not empty.
295      */
296     std::vector<DimensionRect> responseRegion;
297     responseRegion.push_back(DimensionRect());
298     auto gestureEventHub = FRAME_NODE2->GetOrCreateEventHub<EventHub>()->GetOrCreateGestureEventHub();
299     gestureEventHub->SetResponseRegion(responseRegion);
300     auto paintRect = FRAME_NODE2->renderContext_->GetPaintRectWithoutTransform();
301     FRAME_NODE2->GetResponseRegionList(paintRect, 1);
302     EXPECT_FALSE(gestureEventHub->GetResponseRegion().empty());
303 }
304 
305 /**
306  * @tc.name: FrameNodeTestNg_DumpAdvanceInfo001
307  * @tc.desc: Test frame node method DumpAdvanceInfo
308  * @tc.type: FUNC
309  */
310 HWTEST_F(FrameNodeTestNg, DumpAdvanceInfo001, TestSize.Level1)
311 {
312     /**
313      * @tc.steps: step1. initialize parameters.
314      */
315     FRAME_NODE3->isActive_ = true;
316     FRAME_NODE3->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
317     SystemProperties::debugEnabled_ = true;
318 
319     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
320     FRAME_NODE3->renderContext_ = mockRenderContext;
321     FRAME_NODE3->DumpInfo();
322 
323     /**
324      * @tc.steps: step2. initialize layoutProperty_ and call DumpAdvanceInfo.
325      * @tc.expected: expect DumpAdvanceInfo run ok.
326      */
327     auto layoutProperty = AceType::MakeRefPtr<LayoutProperty>();
328     FRAME_NODE2->layoutProperty_ = layoutProperty;
329     FRAME_NODE3->layoutProperty_->geometryTransition_ =
330         ElementRegister::GetInstance()->GetOrCreateGeometryTransition("test", false, true);
331     FRAME_NODE3->DumpAdvanceInfo();
332     EXPECT_NE(FRAME_NODE3->renderContext_, nullptr);
333 }
334 
335 /**
336  * @tc.name: FrameNodeTestNg_GetOnChildTouchTestRet001
337  * @tc.desc: Test frame node method GetOnChildTouchTestRet
338  * @tc.type: FUNC
339  */
340 HWTEST_F(FrameNodeTestNg, GetOnChildTouchTestRet001, TestSize.Level1)
341 {
342     /**
343      * @tc.steps: step1. initialize parameters.
344      */
345     std::vector<TouchTestInfo> touchInfos;
346     TouchTestInfo info;
347     touchInfos.emplace_back(info);
348 
349     TouchResult touchResult;
350     touchResult.strategy = TouchTestStrategy::DEFAULT;
351     touchResult.id = "test1";
352 
__anonc0fd8ca60302(const std::vector<TouchTestInfo>& touchInfo) 353     OnChildTouchTestFunc callback = [](const std::vector<TouchTestInfo>& touchInfo) {
354         TouchResult res;
355         res.strategy = TouchTestStrategy::DEFAULT;
356         res.id = "test1";
357         return res;
358     };
359 
360     /**
361      * @tc.steps: step2. set parent node and initialize gestureHub.
362      */
363     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
364     auto gestureHub = GET_PARENT->GetOrCreateGestureEventHub();
365     gestureHub->SetOnTouchTestFunc(std::move(callback));
366 
367     /**
368      * @tc.steps: step3. call GetOnChildTouchTestRet.
369      * @tc.expected: expect GetOnChildTouchTestRet run ok.
370      */
371     TouchResult test = GET_PARENT->GetOnChildTouchTestRet(touchInfos);
372     EXPECT_EQ(test.id, touchResult.id);
373 }
374 
375 /**
376  * @tc.name: FrameNodeTestNg_GetOnTouchTestFunc001
377  * @tc.desc: Test frame node method GetOnTouchTestFunc
378  * @tc.type: FUNC
379  */
380 HWTEST_F(FrameNodeTestNg, GetOnTouchTestFunc001, TestSize.Level1)
381 {
382     /**
383      * @tc.steps: step1. set parent node and call GetOnTouchTestFunc.
384      */
385     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
386     OnChildTouchTestFunc test = GET_PARENT->GetOnTouchTestFunc();
387 
388     /**
389      * @tc.expected: expect GetOnTouchTestFunc ruturn nullptr.
390      */
391     EXPECT_EQ(test, nullptr);
392 
__anonc0fd8ca60402(const std::vector<TouchTestInfo>& touchInfo) 393     OnChildTouchTestFunc callback = [](const std::vector<TouchTestInfo>& touchInfo) {
394         TouchResult result;
395         return result;
396     };
397 
398     /**
399      * @tc.steps: step2. set parent node and initialize gestureHub.
400      */
401     auto gestureHub = GET_PARENT->GetOrCreateGestureEventHub();
402     gestureHub->SetOnTouchTestFunc(std::move(callback));
403 
404     /**
405      * @tc.steps: step3. call GetOnTouchTestFunc.
406      * @tc.expected: expect GetOnTouchTestFunc run ok.
407      */
408     OnChildTouchTestFunc res = GET_PARENT->GetOnTouchTestFunc();
409     EXPECT_NE(res, nullptr);
410 }
411 
412 /**
413  * @tc.name: FrameNodeTestNg_GetDispatchFrameNode001
414  * @tc.desc: Test frame node method GetDispatchFrameNode
415  * @tc.type: FUNC
416  */
417 HWTEST_F(FrameNodeTestNg, GetDispatchFrameNode001, TestSize.Level1)
418 {
419     /**
420      * @tc.steps: step1. creat node and generate a node tree.
421      */
422     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
423     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
424     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
425     GET_CHILD1->UpdateInspectorId("child1");
426     GET_CHILD2->UpdateInspectorId("child2");
427     GET_PARENT->frameChildren_.insert(GET_CHILD1);
428     GET_PARENT->frameChildren_.insert(GET_CHILD2);
429 
430     /**
431      * @tc.steps: step2. initialize parentEventHub and set HitTestMode.
432      */
433     auto parentEventHub = GET_PARENT->GetOrCreateGestureEventHub();
434     parentEventHub->SetHitTestMode(HitTestMode::HTMBLOCK);
435     TouchResult touchResult;
436 
437     /**
438      * @tc.steps: step3. call GetDispatchFrameNode.
439      * @tc.expected: expect GetDispatchFrameNode ruturn nullptr.
440      */
441     auto test = GET_PARENT->GetDispatchFrameNode(touchResult);
442     EXPECT_EQ(test, nullptr);
443 }
444 
445 /**
446  * @tc.name: FrameNodeTestNg_GetDispatchFrameNode002
447  * @tc.desc: Test frame node method GetDispatchFrameNode
448  * @tc.type: FUNC
449  */
450 HWTEST_F(FrameNodeTestNg, GetDispatchFrameNode002, TestSize.Level1)
451 {
452     /**
453      * @tc.steps: step1. creat node and generate a node tree.
454      */
455     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
456     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
457     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
458     GET_CHILD1->UpdateInspectorId("child1");
459     GET_CHILD2->UpdateInspectorId("child2");
460     GET_PARENT->frameChildren_.insert(GET_CHILD1);
461     GET_PARENT->frameChildren_.insert(GET_CHILD2);
462 
463     /**
464      * @tc.steps: step2. initialize parentEventHub, set HitTestMode and TouchTestStrategy.
465      */
466     auto parentEventHub = GET_PARENT->GetOrCreateGestureEventHub();
467     parentEventHub->SetHitTestMode(HitTestMode::HTMDEFAULT);
468     TouchResult touchResult;
469     touchResult.strategy = TouchTestStrategy::FORWARD_COMPETITION;
470     touchResult.id = "child1";
471 
472     /**
473      * @tc.steps: step3. call GetDispatchFrameNode.
474      * @tc.expected: expect GetDispatchFrameNode run ok.
475      */
476     auto test = GET_PARENT->GetDispatchFrameNode(touchResult);
477     EXPECT_EQ(test, GET_CHILD1);
478 }
479 
480 /**
481  * @tc.name: FrameNodeTestNg_GetDispatchFrameNode003
482  * @tc.desc: Test frame node method GetDispatchFrameNode
483  * @tc.type: FUNC
484  */
485 HWTEST_F(FrameNodeTestNg, GetDispatchFrameNode003, TestSize.Level1)
486 {
487     /**
488      * @tc.steps: step1. creat node and generate a node tree.
489      */
490     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
491     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
492     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
493     GET_CHILD1->UpdateInspectorId("child1");
494     GET_CHILD2->UpdateInspectorId("child2");
495     GET_PARENT->frameChildren_.insert(GET_CHILD1);
496     GET_PARENT->frameChildren_.insert(GET_CHILD2);
497 
498     /**
499      * @tc.steps: step2. initialize parentEventHub, set HitTestMode and TouchTestStrategy.
500      */
501     auto parentEventHub = GET_PARENT->GetOrCreateGestureEventHub();
502     parentEventHub->SetHitTestMode(HitTestMode::HTMDEFAULT);
503     TouchResult touchResult;
504     touchResult.strategy = TouchTestStrategy::DEFAULT;
505 
506     /**
507      * @tc.steps: step3. call GetDispatchFrameNode.
508      * @tc.expected: expect GetDispatchFrameNode ruturn nullptr.
509      */
510     auto test = GET_PARENT->GetDispatchFrameNode(touchResult);
511     EXPECT_EQ(test, nullptr);
512 }
513 
514 /**
515  * @tc.name: FrameNodeTestNg_CollectTouchInfos001
516  * @tc.desc: Test frame node method CollectTouchInfos
517  * @tc.type: FUNC
518  */
519 HWTEST_F(FrameNodeTestNg, CollectTouchInfos001, TestSize.Level1)
520 {
521     /**
522      * @tc.steps: step1. initialize parameters.
523      */
524     PointF globalPoint;
525     PointF parentRevertPoint;
526     std::vector<TouchTestInfo> touchInfos;
527 
528     /**
529      * @tc.steps: step2. creat node and generate a node tree.
530      */
531     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
532     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
533     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
534     GET_CHILD1->UpdateInspectorId("child1");
535     GET_CHILD2->UpdateInspectorId("child2");
536     GET_PARENT->frameChildren_.insert(GET_CHILD1);
537     GET_PARENT->frameChildren_.insert(GET_CHILD2);
538 
__anonc0fd8ca60502(const std::vector<TouchTestInfo>& touchInfo) 539     OnChildTouchTestFunc callback = [](const std::vector<TouchTestInfo>& touchInfo) {
540         TouchResult result;
541         return result;
542     };
543 
544     /**
545      * @tc.steps: step3. initialize gestureHub and set HitTestMode.
546      */
547     auto gestureHub = GET_PARENT->GetOrCreateGestureEventHub();
548     gestureHub->SetHitTestMode(HitTestMode::HTMDEFAULT);
549     gestureHub->SetOnTouchTestFunc(std::move(callback));
550 
551     /**
552      * @tc.steps: step4. call CollectTouchInfos.
553      * @tc.expected: expect CollectTouchInfos run ok.
554      */
555     GET_PARENT->CollectTouchInfos(globalPoint, parentRevertPoint, touchInfos);
556     EXPECT_EQ(touchInfos.size(), 2);
557 }
558 
559 /**
560  * @tc.name: FrameNodeTestNg_CollectTouchInfos002
561  * @tc.desc: Test frame node method CollectTouchInfos
562  * @tc.type: FUNC
563  */
564 HWTEST_F(FrameNodeTestNg, CollectTouchInfos002, TestSize.Level1)
565 {
566     /**
567      * @tc.steps: step1. initialize parameters.
568      */
569     PointF globalPoint;
570     PointF parentRevertPoint;
571     std::vector<TouchTestInfo> touchInfos;
572 
573     /**
574      * @tc.steps: step2. creat node and generate a node tree.
575      */
576     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
577     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
578     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
579     GET_CHILD1->UpdateInspectorId("child1");
580     GET_CHILD2->UpdateInspectorId("child2");
581     GET_PARENT->frameChildren_.insert(GET_CHILD1);
582     GET_PARENT->frameChildren_.insert(GET_CHILD2);
583 
584     /**
585      * @tc.steps: step3. initialize gestureHub and set HitTestMode.
586      */
587     auto gestureHub = GET_PARENT->GetOrCreateGestureEventHub();
588     gestureHub->SetHitTestMode(HitTestMode::HTMBLOCK);
589 
590     /**
591      * @tc.steps: step4. call CollectTouchInfos.
592      * @tc.expected: expect CollectTouchInfos return touchInfos.size is 0.
593      */
594     GET_PARENT->CollectTouchInfos(globalPoint, parentRevertPoint, touchInfos);
595     EXPECT_EQ(touchInfos.size(), 0);
596 }
597 
598 /**
599  * @tc.name: FrameNodeTestNg_CollectTouchInfos003
600  * @tc.desc: Test frame node method CollectTouchInfos
601  * @tc.type: FUNC
602  */
603 HWTEST_F(FrameNodeTestNg, CollectTouchInfos003, TestSize.Level1)
604 {
605     /**
606      * @tc.steps: step1. initialize parameters.
607      */
608     PointF globalPoint;
609     PointF parentRevertPoint;
610     std::vector<TouchTestInfo> touchInfos;
611 
612     /**
613      * @tc.steps: step2. creat node and generate a node tree.
614      */
615     const RefPtr<FrameNode> GET_PARENT = FrameNode::CreateFrameNode("parent", 4, AceType::MakeRefPtr<Pattern>());
616     const RefPtr<FrameNode> GET_CHILD1 = FrameNode::CreateFrameNode("child1", 5, AceType::MakeRefPtr<Pattern>());
617     const RefPtr<FrameNode> GET_CHILD2 = FrameNode::CreateFrameNode("child2", 6, AceType::MakeRefPtr<Pattern>());
618     GET_CHILD1->UpdateInspectorId("child1");
619     GET_CHILD2->UpdateInspectorId("child2");
620     GET_PARENT->frameChildren_.insert(GET_CHILD1);
621     GET_PARENT->frameChildren_.insert(GET_CHILD2);
622 
623     /**
624      * @tc.steps: step3. initialize gestureHub and set HitTestMode.
625      */
626     auto gestureHub = GET_PARENT->GetOrCreateGestureEventHub();
627     gestureHub->SetHitTestMode(HitTestMode::HTMDEFAULT);
628 
629     /**
630      * @tc.steps: step4. call CollectTouchInfos.
631      * @tc.expected: expect CollectTouchInfos return touchInfos.size is 0.
632      */
633     GET_PARENT->CollectTouchInfos(globalPoint, parentRevertPoint, touchInfos);
634     EXPECT_EQ(touchInfos.size(), 0);
635 }
636 
637 /**
638  * @tc.name: FrameNodeTestNg_GetPreviewScaleVal001
639  * @tc.desc: Test frame node method GetPreviewScaleVal
640  * @tc.type: FUNC
641  */
642 HWTEST_F(FrameNodeTestNg, GetPreviewScaleVal001, TestSize.Level1)
643 {
644     auto frameNode = FRAME_NODE;
645     /**
646      * @tc.steps: step1. initialize parameters.
647      */
648     frameNode->isActive_ = true;
649     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
650     SystemProperties::debugEnabled_ = true;
651 
652     /**
653      * @tc.steps: step2. call GetPreviewScaleVal
654      * @tc.expected: expect GetPreviewScaleVal return scale value.
655      */
656     auto geometryNode = frameNode->GetGeometryNode();
657     geometryNode->SetFrameSize(CONTAINER_SIZE_ZERO);
658     EXPECT_FLOAT_EQ(frameNode->GetPreviewScaleVal(), 1.0f);
659 
660     double screenWidth = 1216.0;
661     ScreenSystemManager::GetInstance().SetWindowInfo(screenWidth, 1.0, 1.0);
662     geometryNode->SetFrameSize(CONTAINER_SIZE_SMALL);
663     EXPECT_FLOAT_EQ(frameNode->GetPreviewScaleVal(), 1.0f);
664 
665     /**
666      * @tc.steps: step3. set a large size and call GetPreviewScaleVal.
667      * @tc.expected: expect GetPreviewScaleVal return scale value.
668      */
669     geometryNode->SetFrameSize(CONTAINER_SIZE_HUGE);
670     EXPECT_LT(frameNode->GetPreviewScaleVal(), 1.0f);
671 }
672 
673 /**
674  * @tc.name: FrameNodeTestNg_GetPreviewScaleVal002
675  * @tc.desc: Test frame node method GetPreviewScaleVal
676  * @tc.type: FUNC
677  */
678 HWTEST_F(FrameNodeTestNg, GetPreviewScaleVal002, TestSize.Level1)
679 {
680     auto frameNode = FRAME_NODE;
681     /**
682      * @tc.steps: step1. initialize parameters.
683      */
684     frameNode->isActive_ = true;
685     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
686     SystemProperties::debugEnabled_ = true;
687 
688     /**
689      * @tc.steps: step2. set frame size to huge and drag preview options to disable scale then call GetPreviewScaleVal
690      * @tc.expected: expect GetPreviewScaleVal return scale value.
691      */
692     auto geometryNode = frameNode->GetGeometryNode();
693     geometryNode->SetFrameSize(CONTAINER_SIZE_HUGE);
694     NG::DragPreviewOption option { false };
695     frameNode->SetDragPreviewOptions(option);
696     EXPECT_FLOAT_EQ(frameNode->GetPreviewScaleVal(), 1.0f);
697 
698     /**
699      * @tc.steps: step3. set set drag preview options to auto and call GetPreviewScaleVal.
700      * @tc.expected: expect GetPreviewScaleVal return scale value.
701      */
702     option = { true };
703     frameNode->SetDragPreviewOptions(option);
704     EXPECT_LT(frameNode->GetPreviewScaleVal(), 1.0f);
705 }
706 
707 /**
708  * @tc.name: FrameNodeTestNg_GetPreviewApplyVal001
709  * @tc.desc: Test frame node method GetPreviewApplyVal001
710  * @tc.type: FUNC
711  */
712 HWTEST_F(FrameNodeTestNg, GetPreviewApplyVal001, TestSize.Level1)
713 {
714     auto frameNode = FRAME_NODE;
715     /**
716      * @tc.steps: step1. initialize parameters.
717      */
718     frameNode->isActive_ = true;
719     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
720     SystemProperties::debugEnabled_ = true;
721 
722     /**
723      * @tc.steps: step2. set drag preview options and call GetDragPreviewOption.
724      * @tc.expected: expect GetDragPreviewOption return apply .
725      */
726     auto geometryNode = frameNode->GetGeometryNode();
727     geometryNode->SetFrameSize(CONTAINER_SIZE_HUGE);
728     NG::DragPreviewOption previewOption;
__anonc0fd8ca60602(WeakPtr<NG::FrameNode> frameNode) 729     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {};
730     frameNode->SetDragPreviewOptions(previewOption);
731     EXPECT_NE(frameNode->GetDragPreviewOption().onApply, nullptr);
732 }
733 
734 /**
735  * @tc.name: FrameNodeTestNg_GetPreviewScaleVal003
736  * @tc.desc: Test frame node method GetPreviewScaleVal
737  * @tc.type: FUNC
738  */
739 HWTEST_F(FrameNodeTestNg, GetPreviewScaleVal003, TestSize.Level1)
740 {
741     auto frameNode = FRAME_NODE_WEB_ETS_TAG;
742     /**
743      * @tc.steps: step1. initialize parameters.
744      */
745     frameNode->isActive_ = true;
746     frameNode->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
747     SystemProperties::debugEnabled_ = true;
748 
749     /**
750      * @tc.steps: step2. call GetPreviewScaleVal
751      * @tc.expected: expect GetPreviewScaleVal return scale value.
752      */
753     auto geometryNode = frameNode->GetGeometryNode();
754     geometryNode->SetFrameSize(CONTAINER_SIZE_HUGE);
755 
756     EXPECT_FLOAT_EQ(frameNode->GetPreviewScaleVal(), 1.0f);
757 }
758 
759 /**
760  * @tc.name: FrameNodeTestNg_IsPreviewNeedScale001
761  * @tc.desc: Test frame node method IsPreviewNeedScale
762  * @tc.type: FUNC
763  */
764 HWTEST_F(FrameNodeTestNg, IsPreviewNeedScale001, TestSize.Level1)
765 {
766     auto frameNode = FRAME_NODE;
767     /**
768      * @tc.steps: step1. initialize parameters.
769      */
770     FRAME_NODE->isActive_ = true;
771     FRAME_NODE->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
772     SystemProperties::debugEnabled_ = true;
773 
774     /**
775      * @tc.steps: step2. call IsPreviewNeedScale
776      * @tc.expected: expect IsPreviewNeedScale return false.
777      */
778     auto geometryNode = frameNode->GetGeometryNode();
779     geometryNode->SetFrameSize(CONTAINER_SIZE_SMALL);
780     EXPECT_FALSE(FRAME_NODE->IsPreviewNeedScale());
781 
782     /**
783      * @tc.steps: step2. set a large size and call IsPreviewNeedScale.
784      * @tc.expected: expect IsPreviewNeedScale return true.
785      */
786     geometryNode->SetFrameSize(CONTAINER_SIZE_HUGE);
787     EXPECT_TRUE(FRAME_NODE->IsPreviewNeedScale());
788 }
789 
790 /**
791  * @tc.name: FrameNodeTestNg_GetOffsetInScreen001
792  * @tc.desc: Test frame node method GetOffsetInScreen
793  * @tc.type: FUNC
794  */
795 HWTEST_F(FrameNodeTestNg, GetOffsetInScreen001, TestSize.Level1)
796 {
797     /**
798      * @tc.steps: step1. initialize parameters.
799      */
800     FRAME_NODE->isActive_ = true;
801     FRAME_NODE->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
802     SystemProperties::debugEnabled_ = true;
803     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
804     ASSERT_NE(mockRenderContext, nullptr);
805     mockRenderContext->rect_ = RectF(DEFAULT_X, DEFAULT_Y, DEFAULT_X, DEFAULT_Y);
806     FRAME_NODE->renderContext_ = mockRenderContext;
807 
808     /**
809      * @tc.steps: step2. call GetOffsetInScreen.
810      * @tc.expected: expect GetOffsetInScreen return the result which is not (0, 0).
811      */
812     EXPECT_EQ(FRAME_NODE->GetOffsetInScreen(), OffsetF(0.0f, 0.0f));
813 }
814 
815 /**
816  * @tc.name: FrameNodeTestNg_GetPixelMap001
817  * @tc.desc: Test frame node method GetPixelMap
818  * @tc.type: FUNC
819  */
820 HWTEST_F(FrameNodeTestNg, GetPixelMap001, TestSize.Level1)
821 {
822     /**
823      * @tc.steps: step1. initialize parameters.
824      */
825     FRAME_NODE->isActive_ = true;
826     FRAME_NODE->GetOrCreateEventHub<EventHub>()->SetEnabled(true);
827     SystemProperties::debugEnabled_ = true;
828     auto gestureHub = FRAME_NODE->GetOrCreateGestureEventHub();
829     ASSERT_NE(gestureHub, nullptr);
830     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
831     ASSERT_NE(mockRenderContext, nullptr);
832     FRAME_NODE->renderContext_ = mockRenderContext;
833 
834     /**
835      * @tc.steps: step2. Don't initialize pixelMap and rosenNode.
836      * @tc.expected: expect GetPixelMap() == nullptr.
837      */
838     EXPECT_EQ(FRAME_NODE->GetDragPixelMap(), nullptr);
839 
840     /**
841      * @tc.steps: step3. set a pixelMap of gestureHub, and call GetPixelMap.
842      * @tc.expected: expect GetPixelMap() != nullptr.
843      */
844     void* voidPtr = static_cast<void*>(new char[0]);
845     RefPtr<PixelMap> pixelMap = PixelMap::CreatePixelMap(voidPtr);
846     ASSERT_NE(pixelMap, nullptr);
847     gestureHub->SetPixelMap(pixelMap);
848     EXPECT_NE(FRAME_NODE->GetDragPixelMap(), nullptr);
849 
850     /**
851      * @tc.steps: step4. set a pixelMap of the renderContext, and call GetPixelMap.
852      * @tc.expected: expect GetPixelMap() != nullptr.
853      */
854     gestureHub->SetPixelMap(nullptr);
855     EXPECT_EQ(FRAME_NODE->GetDragPixelMap(), nullptr);
856 }
857 
858 /**
859  * @tc.name: FindChildByNameTest001
860  * @tc.desc: Test FindChildByName with one tree
861  * @tc.type: FUNC
862  */
863 HWTEST_F(FrameNodeTestNg, FindChildByNameTest001, TestSize.Level1)
864 {
865     /**
866      * @tc.steps: step1. Create frameNode and set the parent and children.
867      */
868     const std::string parentNodeName = "nodeParent";
869     const std::string thisNodeName = "nodeThis";
870     const std::string childrenNodeName = "nodeChildren";
871     const std::string testChildNodeName = "test";
872     auto nodeParent = FrameNode::CreateFrameNode(parentNodeName, 10, AceType::MakeRefPtr<Pattern>(), true);
873     auto nodeThis = FrameNode::CreateFrameNode(thisNodeName, 20, AceType::MakeRefPtr<Pattern>());
874     auto nodeChildren = FrameNode::CreateFrameNode(childrenNodeName, 30, AceType::MakeRefPtr<Pattern>());
875 
876     /**
877      * @tc.steps: step1. Set the node's relation.
878      */
879     nodeParent->AddChild(nodeThis);
880     nodeParent->AddChild(nodeChildren);
881 
882     /**
883      * @tc.steps: step3. Init inspectorId.
884      */
885     nodeParent->UpdateInspectorId(parentNodeName);
886     nodeChildren->UpdateInspectorId(childrenNodeName);
887     nodeThis->UpdateInspectorId(thisNodeName);
888 
889     /**
890      * @tc.steps: step4. Traversal the frameNodeTree.
891      */
892     auto finalResult = FrameNode::FindChildByName(nodeParent, childrenNodeName);
893     EXPECT_EQ(finalResult, nodeChildren);
894 
895     auto noChildResult = FrameNode::FindChildByName(nodeParent, testChildNodeName);
896     EXPECT_EQ(noChildResult, nullptr);
897 
898     nodeParent->Clean();
899     auto noHaveResult = FrameNode::FindChildByName(nodeParent, childrenNodeName);
900     EXPECT_EQ(noHaveResult, nullptr);
901 }
902 
903 /**
904  * @tc.name: FindChildByNameTest002
905  * @tc.desc: Test FindChildByName with two tree
906  * @tc.type: FUNC
907  */
908 HWTEST_F(FrameNodeTestNg, FindChildByNameTest002, TestSize.Level1)
909 {
910     /**
911      * @tc.steps: step1. Create frameNode and set the parent and children.
912      */
913     const std::string parentNodeName = "nodeParent";
914     const std::string nodeOneName = "nodeOne";
915     const std::string nodeOneChildName = "nodeOneChildren";
916     const std::string nodeTwoName = "nodeTwo";
917     const std::string nodeTwoChildName = "nodeTwoChildren";
918     const std::string testChildNodeName = "test";
919     auto nodeParent = FrameNode::CreateFrameNode(parentNodeName, 10, AceType::MakeRefPtr<Pattern>(), true);
920     auto nodeOne = FrameNode::CreateFrameNode(nodeOneName, 20, AceType::MakeRefPtr<Pattern>());
921     auto nodeOneChildren = FrameNode::CreateFrameNode(nodeOneChildName, 30, AceType::MakeRefPtr<Pattern>());
922     auto nodeTwo = FrameNode::CreateFrameNode(nodeTwoName, 40, AceType::MakeRefPtr<Pattern>());
923     auto nodeTwoChildren = FrameNode::CreateFrameNode(nodeTwoChildName, 50, AceType::MakeRefPtr<Pattern>());
924 
925     /**
926      * @tc.steps: step1. Set the node's relation.
927      */
928     nodeParent->AddChild(nodeOne);
929     nodeParent->AddChild(nodeTwo);
930     nodeOne->AddChild(nodeOneChildren);
931     nodeTwo->AddChild(nodeTwoChildren);
932 
933     /**
934      * @tc.steps: step3. Init inspectorId.
935      */
936     nodeParent->UpdateInspectorId(parentNodeName);
937     nodeOne->UpdateInspectorId(nodeOneName);
938     nodeOneChildren->UpdateInspectorId(nodeOneChildName);
939     nodeTwo->UpdateInspectorId(nodeTwoName);
940     nodeTwoChildren->UpdateInspectorId(nodeTwoChildName);
941 
942     /**
943      * @tc.steps: step4. Traversal the frameNodeTree.
944      */
945     auto finalResult = FrameNode::FindChildByName(nodeParent, nodeOneChildName);
946     EXPECT_EQ(finalResult, nodeOneChildren);
947 
948     auto noChildResult = FrameNode::FindChildByName(nodeParent, testChildNodeName);
949     EXPECT_EQ(noChildResult, nullptr);
950 
951     nodeParent->Clean();
952     auto noHaveResult = FrameNode::FindChildByName(nodeParent, nodeTwoChildName);
953     EXPECT_EQ(noHaveResult, nullptr);
954 }
955 
956 /**
957  * @tc.name: SetOnSizeChangeCallback001
958  * @tc.desc: Test SetOnSizeChangeCallback
959  * @tc.type: FUNC
960  */
961 HWTEST_F(FrameNodeTestNg, SetOnSizeChangeCallback001, TestSize.Level1)
962 {
963     /**
964      * @tc.steps: step1. build a object to SetOnSizeChangeCallback
965      * @tc.expected: expect cover branch lastFrameNodeRect_ non null and function is run ok.
966      */
__anonc0fd8ca60702(const RectF& oldRect, const RectF& rect) 967     OnSizeChangedFunc callback = [](const RectF& oldRect, const RectF& rect) {};
968     FRAME_NODE2->SetOnSizeChangeCallback(std::move(callback));
969     EXPECT_NE(FRAME_NODE2->lastFrameNodeRect_, nullptr);
970     auto eventHub = FRAME_NODE2->GetOrCreateEventHub<NG::EventHub>();
971     EXPECT_NE(eventHub, nullptr);
972     EXPECT_TRUE(eventHub->HasOnSizeChanged());
973 
974     /**
975      * @tc.steps: step2.test while callback is nullptr
976      * @tc.expected:expect cover branch lastFrameNodeRect_ non null and function is run ok.
977      */
978     FRAME_NODE2->lastFrameNodeRect_ = std::make_unique<RectF>();
979     FRAME_NODE2->SetOnSizeChangeCallback(nullptr);
980     EXPECT_NE(FRAME_NODE2->lastFrameNodeRect_, nullptr);
981     EXPECT_NE(eventHub, nullptr);
982     EXPECT_FALSE(eventHub->HasOnSizeChanged());
983 }
984 
985 /**
986  * @tc.name: TriggerOnSizeChangeCallback001
987  * @tc.desc: Test frame node method
988  * @tc.type: FUNC
989  */
990 HWTEST_F(FrameNodeTestNg, TriggerOnSizeChangeCallback001, TestSize.Level1)
991 {
992     /**
993      * @tc.steps: step1. set a flag and init a callback(onSizeChanged)
994      */
995     bool flag = false;
__anonc0fd8ca60802(const RectF& oldRect, const RectF& rect) 996     OnSizeChangedFunc onSizeChanged = [&flag](const RectF& oldRect, const RectF& rect) { flag = !flag; };
997 
998     /**
999      * @tc.steps: step2. call TriggerOnSizeChangeCallback before set callback
1000      * @tc.expected: expect flag is still false
1001      */
1002     FRAME_NODE2->TriggerOnSizeChangeCallback();
1003     EXPECT_FALSE(flag);
1004 
1005     /**
1006      * @tc.steps: step3.set callback and release lastFrameNodeRect_
1007      * @tc.expected: expect flag is still false
1008      */
1009     FRAME_NODE2->GetOrCreateEventHub<EventHub>()->SetOnSizeChanged(std::move(onSizeChanged));
1010     FRAME_NODE2->lastFrameNodeRect_ = nullptr;
1011     FRAME_NODE2->TriggerOnSizeChangeCallback();
1012     EXPECT_FALSE(flag);
1013 
1014     /**
1015      * @tc.steps: step4.set lastFrameNodeRect_
1016      * @tc.expected: expect flag is still false
1017      */
1018     FRAME_NODE2->lastFrameNodeRect_ = std::make_unique<RectF>();
1019     FRAME_NODE2->TriggerOnSizeChangeCallback();
1020     EXPECT_FALSE(flag);
1021 }
1022 
1023 /**
1024  * @tc.name: OnTouchInterceptTest001
1025  * @tc.desc: Test onTouchIntercept method
1026  * @tc.type: FUNC
1027  */
1028 HWTEST_F(FrameNodeTestNg, OnTouchInterceptTest001, TestSize.Level1)
1029 {
1030     /**
1031      * @tc.steps: step1. construct TouchTest parameters.
1032      */
1033     PointF globalPoint;
1034     PointF parentLocalPoint;
1035     TouchRestrict touchRestrict;
1036     TouchTestResult result;
1037     ResponseLinkResult responseLinkResult;
1038 
1039     /**
1040      * @tc.steps: step2. create node and set callback.
1041      */
1042     auto childNode = FrameNode::CreateFrameNode("main", 2, AceType::MakeRefPtr<Pattern>(), true);
1043     childNode->SetExclusiveEventForChild(true);
1044     auto mockRenderContextforChild = AceType::MakeRefPtr<MockRenderContext>();
1045     childNode->renderContext_ = mockRenderContextforChild;
1046     auto localPoint = PointF(10, 10);
1047     mockRenderContextforChild->rect_ = RectF(0, 0, 100, 100);
1048     EXPECT_CALL(*mockRenderContextforChild, GetPointWithTransform(_))
1049         .WillRepeatedly(DoAll(SetArgReferee<0>(localPoint)));
1050     auto childEventHub = childNode->GetOrCreateGestureEventHub();
1051     childEventHub->SetHitTestMode(HitTestMode::HTMBLOCK);
1052     childNode->SetActive(true);
1053     EXPECT_NE(childNode->GetOrCreateEventHub<EventHub>()->GetGestureEventHub(), nullptr);
__anonc0fd8ca60902(TouchEventInfo& event) 1054     auto callback = [](TouchEventInfo& event) -> HitTestMode { return HitTestMode::HTMNONE; };
1055     childEventHub->SetOnTouchIntercept(callback);
1056 
1057     /**
1058      * @tc.steps: step3. trigger touch test.
1059      * @tc.expected: expect the touch test mode is correct.
1060      */
1061     HitTestMode hitTestModeofChilds[] = { HitTestMode::HTMDEFAULT, HitTestMode::HTMBLOCK, HitTestMode::HTMTRANSPARENT,
1062         HitTestMode::HTMNONE, HitTestMode::HTMTRANSPARENT_SELF };
1063     int32_t i = 0;
1064     for (auto hitTestModeofChild : hitTestModeofChilds) {
1065         childEventHub->SetHitTestMode(hitTestModeofChild);
1066         childNode->TouchTest(
1067             globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
1068         auto mode = childEventHub->GetHitTestMode();
1069         EXPECT_EQ(mode, hitTestModeofChilds[i++]);
1070     }
1071 
1072     /**
1073      * @tc.steps: step4. modify callback and trigger touch test.
1074      * @tc.expected: expect the touch test mode is correct.
1075      */
1076     i = 0;
__anonc0fd8ca60a02(TouchEventInfo& event) 1077     auto blockCallback = [](TouchEventInfo& event) -> HitTestMode { return HitTestMode::HTMBLOCK; };
1078     childEventHub->SetOnTouchIntercept(blockCallback);
1079     for (auto hitTestModeofChild : hitTestModeofChilds) {
1080         childEventHub->SetHitTestMode(hitTestModeofChild);
1081         childNode->TouchTest(
1082             globalPoint, parentLocalPoint, parentLocalPoint, touchRestrict, result, 1, responseLinkResult);
1083         auto mode = childEventHub->GetHitTestMode();
1084         EXPECT_EQ(mode, hitTestModeofChilds[i++]);
1085     }
1086 }
1087 
1088 /**
1089  * @tc.name: FrameNodeTestNg0040
1090  * @tc.desc: Test frame node method
1091  * @tc.type: FUNC
1092  */
1093 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg0040, TestSize.Level1)
1094 {
1095     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1096     std::set<std::string> allowDropSet;
1097     frameNode->SetAllowDrop(allowDropSet);
1098     std::set<std::string> allowDrop = frameNode->GetAllowDrop();
1099     EXPECT_TRUE(allowDrop.empty());
1100 }
1101 
1102 /**
1103  * @tc.name: FrameNodeTestNg0050
1104  * @tc.desc: Test frame node method
1105  * @tc.type: FUNC
1106  */
1107 HWTEST_F(FrameNodeTestNg, FrameNodeTestNg0050, TestSize.Level1)
1108 {
1109     auto context = PipelineContext::GetCurrentContext();
1110     ASSERT_NE(context, nullptr);
1111     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1112     ASSERT_NE(node, nullptr);
1113     node->GetOrCreateGestureEventHub();
1114     node->AttachContext(AceType::RawPtr(context));
1115     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1116     node->renderContext_ = mockRenderContext;
1117     EXPECT_EQ(node->context_, AceType::RawPtr(context));
1118 
1119     node->DetachContext(true);
1120     EXPECT_EQ(node->context_, nullptr);
1121 }
1122 
1123 /**
1124  * @tc.name: FrameNodeTestNg_GetPositionToScreen001
1125  * @tc.desc: Test frame node method GetPositionToScreen
1126  * @tc.type: FUNC
1127  */
1128 HWTEST_F(FrameNodeTestNg, GetPositionToScreen001, TestSize.Level1)
1129 {
1130     OffsetF Offset = { 0, 0 };
1131     FRAME_NODE2->SetParent(FRAME_NODE3);
1132     auto screenOffset = FRAME_NODE2->GetPositionToScreen();
1133     EXPECT_EQ(screenOffset, Offset);
1134 }
1135 
1136 /**
1137  * @tc.name: FrameNodeTestNg_GetPositionToParentWithTransform001
1138  * @tc.desc: Test frame node method GetPositionToParentWithTransform
1139  * @tc.type: FUNC
1140  */
1141 HWTEST_F(FrameNodeTestNg, GetPositionToParentWithTransform001, TestSize.Level1)
1142 {
1143     OffsetF Offset = { 0, 0 };
1144     FRAME_NODE2->SetParent(FRAME_NODE3);
1145     auto parentOffsetWithTransform = FRAME_NODE2->GetPositionToParentWithTransform();
1146     EXPECT_EQ(parentOffsetWithTransform, Offset);
1147 }
1148 
1149 /**
1150  * @tc.name: FrameNodeTestNg_GetPositionToParentWithTransform001
1151  * @tc.desc: Test frame node method GetPositionToParentWithTransform
1152  * @tc.type: FUNC
1153  */
1154 HWTEST_F(FrameNodeTestNg, GetPositionToScreenWithTransform001, TestSize.Level1)
1155 {
1156     OffsetF Offset = { 0, 0 };
1157     FRAME_NODE2->SetParent(FRAME_NODE3);
1158     auto screenOffsetWithTransform = FRAME_NODE2->GetPositionToScreenWithTransform();
1159     EXPECT_EQ(screenOffsetWithTransform, Offset);
1160 }
1161 
1162 /**
1163  * @tc.name: FrameNodeTestNg_GetPositionToWindowWithTransform001
1164  * @tc.desc: Test frame node method GetPositionToWindowWithTransform
1165  * @tc.type: FUNC
1166  */
1167 HWTEST_F(FrameNodeTestNg, GetPositionToWindowWithTransform001, TestSize.Level1)
1168 {
1169     OffsetF Offset = { 0, 0 };
1170     FRAME_NODE2->SetParent(FRAME_NODE3);
1171     auto windowOffsetWithTransform = FRAME_NODE2->GetPositionToWindowWithTransform();
1172     EXPECT_EQ(windowOffsetWithTransform, Offset);
1173 }
1174 
1175 /**
1176  * @tc.name: GetPreviewOptionFromModifier001
1177  * @tc.desc: Test UpdatePreviewOptionFromModifier
1178  * @tc.type: FUNC
1179  * @tc.author:
1180  */
1181 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier001, TestSize.Level1)
1182 {
1183     /**
1184      * @tc.steps: step1. Create FrameNode.
1185      */
1186     auto frameNode = FrameNode::CreateFrameNode(
1187         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1188     EXPECT_NE(frameNode, nullptr);
1189     auto eventHub = AceType::MakeRefPtr<EventHub>();
1190     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1191     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1192     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1193         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1194     /**
1195      * @tc.steps: step2. get DragPreviewOption.
1196      */
1197     auto dragPreviewOption = frameNode->GetDragPreviewOption();
1198     /**
1199      * @tc.steps: step3. set opacity.
1200      */
1201     dragPreviewOption.options.opacity = -50.0f;
1202     frameNode->SetDragPreviewOptions(dragPreviewOption);
1203     /**
1204      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1205      * @tc.expected: opacity in DragPreviewOption is equal to 0.95f.
1206      */
1207     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1208     dragPreviewOption = frameNode->GetDragPreviewOption();
1209     EXPECT_EQ(dragPreviewOption.options.opacity, 0.95f);
1210 }
1211 
1212 /**
1213  * @tc.name: GetPreviewOptionFromModifier002
1214  * @tc.desc: Test UpdatePreviewOptionFromModifier
1215  * @tc.type: FUNC
1216  * @tc.author:
1217  */
1218 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier002, TestSize.Level1)
1219 {
1220     /**
1221      * @tc.steps: step1. Create FrameNode.
1222      */
1223     auto frameNode = FrameNode::CreateFrameNode(
1224         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1225     EXPECT_NE(frameNode, nullptr);
1226     auto eventHub = AceType::MakeRefPtr<EventHub>();
1227     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1228     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1229     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1230         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1231     /**
1232      * @tc.steps: step2. get DragPreviewOption.
1233      */
1234     NG::DragPreviewOption previewOption;
__anonc0fd8ca60b02(WeakPtr<NG::FrameNode> frameNode) 1235     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1236         auto node = frameNode.Upgrade();
1237         CHECK_NULL_VOID(node);
1238         if ((PARA_OPACITY_VALUE_1 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_1 > MIN_OPACITY)) {
1239             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_1);
1240         } else {
1241             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1242         }
1243     };
1244     /**
1245      * @tc.steps: step3. set opacity.
1246      */
1247     frameNode->SetDragPreviewOptions(previewOption);
1248     /**
1249      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1250      * @tc.expected: opacity in DragPreviewOption is equal to 0.1f.
1251      */
1252     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1253     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 0.1f);
1254 }
1255 
1256 /**
1257  * @tc.name: GetPreviewOptionFromModifier003
1258  * @tc.desc: Test UpdatePreviewOptionFromModifier
1259  * @tc.type: FUNC
1260  * @tc.author:
1261  */
1262 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier003, TestSize.Level1)
1263 {
1264     /**
1265      * @tc.steps: step1. Create FrameNode.
1266      */
1267     auto frameNode = FrameNode::CreateFrameNode(
1268         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1269     EXPECT_NE(frameNode, nullptr);
1270     auto eventHub = AceType::MakeRefPtr<EventHub>();
1271     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1272     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1273     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1274         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1275     /**
1276      * @tc.steps: step2. get DragPreviewOption.
1277      */
1278     NG::DragPreviewOption previewOption;
__anonc0fd8ca60c02(WeakPtr<NG::FrameNode> frameNode) 1279     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1280         auto node = frameNode.Upgrade();
1281         CHECK_NULL_VOID(node);
1282         if ((PARA_OPACITY_VALUE_2 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_2 > MIN_OPACITY)) {
1283             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_2);
1284         } else {
1285             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1286         }
1287     };
1288     /**
1289      * @tc.steps: step3. set opacity.
1290      */
1291     frameNode->SetDragPreviewOptions(previewOption);
1292     /**
1293      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1294      * @tc.expected: opacity in DragPreviewOption is equal to 0.2f.
1295      */
1296     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1297     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 0.2f);
1298 }
1299 
1300 /**
1301  * @tc.name: GetPreviewOptionFromModifier004
1302  * @tc.desc: Test UpdatePreviewOptionFromModifier
1303  * @tc.type: FUNC
1304  * @tc.author:
1305  */
1306 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier004, TestSize.Level1)
1307 {
1308     /**
1309      * @tc.steps: step1. Create FrameNode.
1310      */
1311     auto frameNode = FrameNode::CreateFrameNode(
1312         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1313     EXPECT_NE(frameNode, nullptr);
1314     auto eventHub = AceType::MakeRefPtr<EventHub>();
1315     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1316     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1317     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1318         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1319     /**
1320      * @tc.steps: step2. get DragPreviewOption.
1321      */
1322     auto dragPreviewOption = frameNode->GetDragPreviewOption();
1323     /**
1324      * @tc.steps: step3. set opacity.
1325      */
1326     dragPreviewOption.options.opacity = 0.0f;
1327     frameNode->SetDragPreviewOptions(dragPreviewOption);
1328     /**
1329      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1330      * @tc.expected: opacity in DragPreviewOption is equal to 0.95f.
1331      */
1332     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1333     dragPreviewOption = frameNode->GetDragPreviewOption();
1334     EXPECT_EQ(dragPreviewOption.options.opacity, 0.95f);
1335 }
1336 
1337 /**
1338  * @tc.name: GetPreviewOptionFromModifier005
1339  * @tc.desc: Test UpdatePreviewOptionFromModifier
1340  * @tc.type: FUNC
1341  * @tc.author:
1342  */
1343 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier005, TestSize.Level1)
1344 {
1345     /**
1346      * @tc.steps: step1. Create FrameNode.
1347      */
1348     auto frameNode = FrameNode::CreateFrameNode(
1349         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1350     EXPECT_NE(frameNode, nullptr);
1351     auto eventHub = AceType::MakeRefPtr<EventHub>();
1352     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1353     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1354     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1355         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1356     /**
1357      * @tc.steps: step2. get DragPreviewOption.
1358      */
1359     NG::DragPreviewOption previewOption;
__anonc0fd8ca60d02(WeakPtr<NG::FrameNode> frameNode) 1360     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1361         auto node = frameNode.Upgrade();
1362         CHECK_NULL_VOID(node);
1363         if ((PARA_OPACITY_VALUE_3 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_3 > MIN_OPACITY)) {
1364             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_3);
1365         } else {
1366             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1367         }
1368     };
1369     /**
1370      * @tc.steps: step3. set opacity.
1371      */
1372     frameNode->SetDragPreviewOptions(previewOption);
1373     /**
1374      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1375      * @tc.expected: opacity in DragPreviewOption is equal to 0.3f.
1376      */
1377     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1378     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 0.3f);
1379 }
1380 
1381 /**
1382  * @tc.name: GetPreviewOptionFromModifier006
1383  * @tc.desc: Test UpdatePreviewOptionFromModifier
1384  * @tc.type: FUNC
1385  * @tc.author:
1386  */
1387 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier006, TestSize.Level1)
1388 {
1389     /**
1390      * @tc.steps: step1. Create FrameNode.
1391      */
1392     auto frameNode = FrameNode::CreateFrameNode(
1393         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1394     EXPECT_NE(frameNode, nullptr);
1395     auto eventHub = AceType::MakeRefPtr<EventHub>();
1396     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1397     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1398     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1399         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1400     /**
1401      * @tc.steps: step2. get DragPreviewOption.
1402      */
1403     NG::DragPreviewOption previewOption;
__anonc0fd8ca60e02(WeakPtr<NG::FrameNode> frameNode) 1404     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1405         auto node = frameNode.Upgrade();
1406         CHECK_NULL_VOID(node);
1407         if ((PARA_OPACITY_VALUE_4 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_4 > MIN_OPACITY)) {
1408             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_4);
1409         } else {
1410             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1411         }
1412     };
1413     /**
1414      * @tc.steps: step3. set opacity.
1415      */
1416     frameNode->SetDragPreviewOptions(previewOption);
1417     /**
1418      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1419      * @tc.expected: opacity in DragPreviewOption is equal to 0.4f.
1420      */
1421     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1422     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 0.4f);
1423 }
1424 
1425 /**
1426  * @tc.name: GetPreviewOptionFromModifier007
1427  * @tc.desc: Test UpdatePreviewOptionFromModifier
1428  * @tc.type: FUNC
1429  * @tc.author:
1430  */
1431 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier007, TestSize.Level1)
1432 {
1433     /**
1434      * @tc.steps: step1. Create FrameNode.
1435      */
1436     auto frameNode = FrameNode::CreateFrameNode(
1437         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1438     EXPECT_NE(frameNode, nullptr);
1439     auto eventHub = AceType::MakeRefPtr<EventHub>();
1440     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1441     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1442     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1443         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1444     /**
1445      * @tc.steps: step2. get DragPreviewOption.
1446      */
1447     NG::DragPreviewOption previewOption;
__anonc0fd8ca60f02(WeakPtr<NG::FrameNode> frameNode) 1448     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1449         auto node = frameNode.Upgrade();
1450         CHECK_NULL_VOID(node);
1451         if ((PARA_OPACITY_VALUE_5 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_5 > MIN_OPACITY)) {
1452             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_5);
1453         } else {
1454             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1455         }
1456     };
1457     /**
1458      * @tc.steps: step3. set opacity.
1459      */
1460     frameNode->SetDragPreviewOptions(previewOption);
1461     /**
1462      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1463      * @tc.expected: opacity in DragPreviewOption is equal to 0.5f.
1464      */
1465     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1466     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 0.5f);
1467 }
1468 
1469 /**
1470  * @tc.name: GetPreviewOptionFromModifier008
1471  * @tc.desc: Test UpdatePreviewOptionFromModifier
1472  * @tc.type: FUNC
1473  * @tc.author:
1474  */
1475 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier008, TestSize.Level1)
1476 {
1477     /**
1478      * @tc.steps: step1. Create FrameNode.
1479      */
1480     auto frameNode = FrameNode::CreateFrameNode(
1481         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1482     EXPECT_NE(frameNode, nullptr);
1483     auto eventHub = AceType::MakeRefPtr<EventHub>();
1484     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1485     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1486     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1487         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1488     /**
1489      * @tc.steps: step2. get DragPreviewOption.
1490      */
1491     NG::DragPreviewOption previewOption;
__anonc0fd8ca61002(WeakPtr<NG::FrameNode> frameNode) 1492     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1493         auto node = frameNode.Upgrade();
1494         CHECK_NULL_VOID(node);
1495         if ((PARA_OPACITY_VALUE_6 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_6 > MIN_OPACITY)) {
1496             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_6);
1497         } else {
1498             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1499         }
1500     };
1501     /**
1502      * @tc.steps: step3. set opacity.
1503      */
1504     frameNode->SetDragPreviewOptions(previewOption);
1505     /**
1506      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1507      * @tc.expected: opacity in DragPreviewOption is equal to 0.6f.
1508      */
1509     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1510     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 0.6f);
1511 }
1512 
1513 /**
1514  * @tc.name: GetPreviewOptionFromModifier009
1515  * @tc.desc: Test UpdatePreviewOptionFromModifier
1516  * @tc.type: FUNC
1517  * @tc.author:
1518  */
1519 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier009, TestSize.Level1)
1520 {
1521     /**
1522      * @tc.steps: step1. Create FrameNode.
1523      */
1524     auto frameNode = FrameNode::CreateFrameNode(
1525         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1526     EXPECT_NE(frameNode, nullptr);
1527     auto eventHub = AceType::MakeRefPtr<EventHub>();
1528     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1529     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1530     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1531         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1532     /**
1533      * @tc.steps: step2. get DragPreviewOption.
1534      */
1535     NG::DragPreviewOption previewOption;
__anonc0fd8ca61102(WeakPtr<NG::FrameNode> frameNode) 1536     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1537         auto node = frameNode.Upgrade();
1538         CHECK_NULL_VOID(node);
1539         if ((PARA_OPACITY_VALUE_7 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_7 > MIN_OPACITY)) {
1540             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_7);
1541         } else {
1542             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1543         }
1544     };
1545     /**
1546      * @tc.steps: step3. set opacity.
1547      */
1548     frameNode->SetDragPreviewOptions(previewOption);
1549     /**
1550      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1551      * @tc.expected: opacity in DragPreviewOption is equal to 0.7f.
1552      */
1553     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1554     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 0.7f);
1555 }
1556 
1557 /**
1558  * @tc.name: GetPreviewOptionFromModifier010
1559  * @tc.desc: Test UpdatePreviewOptionFromModifier
1560  * @tc.type: FUNC
1561  * @tc.author:
1562  */
1563 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier010, TestSize.Level1)
1564 {
1565     /**
1566      * @tc.steps: step1. Create FrameNode.
1567      */
1568     auto frameNode = FrameNode::CreateFrameNode(
1569         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1570     EXPECT_NE(frameNode, nullptr);
1571     auto eventHub = AceType::MakeRefPtr<EventHub>();
1572     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1573     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1574     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1575         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1576     /**
1577      * @tc.steps: step2. get DragPreviewOption.
1578      */
1579     NG::DragPreviewOption previewOption;
__anonc0fd8ca61202(WeakPtr<NG::FrameNode> frameNode) 1580     previewOption.onApply = [](WeakPtr<NG::FrameNode> frameNode) {
1581         auto node = frameNode.Upgrade();
1582         CHECK_NULL_VOID(node);
1583         if ((PARA_OPACITY_VALUE_8 <= MAX_OPACITY) && (PARA_OPACITY_VALUE_8 > MIN_OPACITY)) {
1584             node->GetRenderContext()->UpdateOpacity(PARA_OPACITY_VALUE_8);
1585         } else {
1586             node->GetRenderContext()->UpdateOpacity(DEFAULT_OPACITY);
1587         }
1588     };
1589     /**
1590      * @tc.steps: step3. set opacity.
1591      */
1592     frameNode->SetDragPreviewOptions(previewOption);
1593     /**
1594      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1595      * @tc.expected: opacity in DragPreviewOption is equal to 1.0f.
1596      */
1597     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1598     EXPECT_EQ(frameNode->GetDragPreviewOption().options.opacity, 1.0f);
1599 }
1600 
1601 /**
1602  * @tc.name: GetPreviewOptionFromModifier011
1603  * @tc.desc: Test UpdatePreviewOptionFromModifier
1604  * @tc.type: FUNC
1605  * @tc.author:
1606  */
1607 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier011, TestSize.Level1)
1608 {
1609     /**
1610      * @tc.steps: step1. Create FrameNode.
1611      */
1612     auto frameNode = FrameNode::CreateFrameNode(
1613         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1614     EXPECT_NE(frameNode, nullptr);
1615     auto eventHub = AceType::MakeRefPtr<EventHub>();
1616     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1617     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1618     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1619         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1620     /**
1621      * @tc.steps: step2. get DragPreviewOption.
1622      */
1623     auto dragPreviewOption = frameNode->GetDragPreviewOption();
1624     /**
1625      * @tc.steps: step3. set opacity.
1626      */
1627     dragPreviewOption.options.opacity = 2.0f;
1628     frameNode->SetDragPreviewOptions(dragPreviewOption);
1629     /**
1630      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1631      * @tc.expected: opacity in DragPreviewOption is equal to 0.95f.
1632      */
1633     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1634     dragPreviewOption = frameNode->GetDragPreviewOption();
1635     EXPECT_EQ(dragPreviewOption.options.opacity, 0.95f);
1636 }
1637 
1638 /**
1639  * @tc.name: GetPreviewOptionFromModifier012
1640  * @tc.desc: Test UpdatePreviewOptionFromModifier
1641  * @tc.type: FUNC
1642  * @tc.author:
1643  */
1644 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier012, TestSize.Level1)
1645 {
1646     /**
1647      * @tc.steps: step1. Create FrameNode.
1648      */
1649     auto frameNode = FrameNode::CreateFrameNode(
1650         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1651     EXPECT_NE(frameNode, nullptr);
1652     auto eventHub = AceType::MakeRefPtr<EventHub>();
1653     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1654     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1655     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1656         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1657     /**
1658      * @tc.steps: step2. get DragPreviewOption.
1659      */
1660     auto dragPreviewOption = frameNode->GetDragPreviewOption();
1661     /**
1662      * @tc.steps: step3. set opacity.
1663      */
1664     dragPreviewOption.options.opacity = 50.0f;
1665     frameNode->SetDragPreviewOptions(dragPreviewOption);
1666     /**
1667      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1668      * @tc.expected: opacity in DragPreviewOption is equal to 0.95f.
1669      */
1670     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1671     dragPreviewOption = frameNode->GetDragPreviewOption();
1672     EXPECT_EQ(dragPreviewOption.options.opacity, 0.95f);
1673 }
1674 
1675 /**
1676  * @tc.name: GetPreviewOptionFromModifier013
1677  * @tc.desc: Test UpdatePreviewOptionFromModifier
1678  * @tc.type: FUNC
1679  * @tc.author:
1680  */
1681 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier013, TestSize.Level1)
1682 {
1683     /**
1684      * @tc.steps: step1. Create FrameNode.
1685      */
1686     auto frameNode = FrameNode::CreateFrameNode(
1687         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1688     EXPECT_NE(frameNode, nullptr);
1689     auto eventHub = AceType::MakeRefPtr<EventHub>();
1690     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1691     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1692     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1693         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1694     /**
1695      * @tc.steps: step2. get DragPreviewOption.
1696      */
1697     auto dragPreviewOption = frameNode->GetDragPreviewOption();
1698     /**
1699      * @tc.steps: step3. set opacity.
1700      */
1701     dragPreviewOption.options.opacity = 60.0f;
1702     frameNode->SetDragPreviewOptions(dragPreviewOption);
1703     /**
1704      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1705      * @tc.expected: opacity in DragPreviewOption is equal to 0.95f.
1706      */
1707     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1708     dragPreviewOption = frameNode->GetDragPreviewOption();
1709     EXPECT_EQ(dragPreviewOption.options.opacity, 0.95f);
1710 }
1711 
1712 /**
1713  * @tc.name: GetPreviewOptionFromModifier014
1714  * @tc.desc: Test UpdatePreviewOptionFromModifier
1715  * @tc.type: FUNC
1716  * @tc.author:
1717  */
1718 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier014, TestSize.Level1)
1719 {
1720     /**
1721      * @tc.steps: step1. Create FrameNode.
1722      */
1723     auto frameNode = FrameNode::CreateFrameNode(
1724         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1725     EXPECT_NE(frameNode, nullptr);
1726     auto eventHub = AceType::MakeRefPtr<EventHub>();
1727     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1728     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1729     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1730         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1731     /**
1732      * @tc.steps: step2. get DragPreviewOption.
1733      */
1734     auto dragPreviewOption = frameNode->GetDragPreviewOption();
1735     /**
1736      * @tc.steps: step3. set opacity.
1737      */
1738     dragPreviewOption.options.opacity = -60.0f;
1739     frameNode->SetDragPreviewOptions(dragPreviewOption);
1740     /**
1741      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1742      * @tc.expected: opacity in DragPreviewOption is equal to 0.95f.
1743      */
1744     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1745     dragPreviewOption = frameNode->GetDragPreviewOption();
1746     EXPECT_EQ(dragPreviewOption.options.opacity, 0.95f);
1747 }
1748 
1749 /**
1750  * @tc.name: GetPreviewOptionFromModifier015
1751  * @tc.desc: Test UpdatePreviewOptionFromModifier
1752  * @tc.type: FUNC
1753  * @tc.author:
1754  */
1755 HWTEST_F(FrameNodeTestNg, GetPreviewOptionFromModifier015, TestSize.Level1)
1756 {
1757     /**
1758      * @tc.steps: step1. Create FrameNode.
1759      */
1760     auto frameNode = FrameNode::CreateFrameNode(
1761         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1762     EXPECT_NE(frameNode, nullptr);
1763     auto eventHub = AceType::MakeRefPtr<EventHub>();
1764     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1765     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1766     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1767         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1768     /**
1769      * @tc.steps: step2. get DragPreviewOption.
1770      */
1771     auto dragPreviewOption = frameNode->GetDragPreviewOption();
1772     /**
1773      * @tc.steps: step3. set auto scrolling when drag to the edge of scrollable component.
1774      */
1775     dragPreviewOption.enableEdgeAutoScroll = false;
1776     frameNode->SetDragPreviewOptions(dragPreviewOption);
1777     /**
1778      * @tc.steps: step4. call UpdatePreviewOptionFromModifier
1779      * @tc.expected: enableEdgeAutoScroll is false.
1780      */
1781     dragEventActuator->UpdatePreviewOptionFromModifier(frameNode);
1782     dragPreviewOption = frameNode->GetDragPreviewOption();
1783     EXPECT_EQ(dragPreviewOption.enableEdgeAutoScroll, false);
1784 }
1785 
1786 /**
1787  * @tc.name: FrameNodeJSCustomProperty
1788  * @tc.desc: Test JSCustomProperty.
1789  * @tc.type: FUNC
1790  */
1791 HWTEST_F(FrameNodeTestNg, FrameNodeJSCustomProperty, TestSize.Level1)
1792 {
1793     /**
1794      * @tc.steps: step1. initialize parameters.
1795      */
1796     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1797     std::string getValue;
1798     /**
1799      * @tc.steps: step2. set isCNode true
1800      * @tc.expected: expect result is false.
1801      */
1802     frameNode->setIsCNode(true);
__anonc0fd8ca61302() 1803     std::function<bool()> func = []() -> bool { return true; };
__anonc0fd8ca61402(const std::string& key) 1804     std::function<std::string(const std::string&)> getFuncA = [](const std::string& key) -> std::string {
1805         return "getFuncA";
1806     };
1807     frameNode->SetJSCustomProperty(func, getFuncA);
1808     bool result = frameNode->GetCapiCustomProperty("key", getValue);
1809     EXPECT_EQ(result, false);
1810 
1811     /**
1812      * @tc.steps: step3. set isCNode false and func true.
1813      * @tc.expected: expect result1 is false.
1814      */
1815     frameNode->setIsCNode(false);
__anonc0fd8ca61502() 1816     func = []() -> bool { return true; };
__anonc0fd8ca61602(const std::string& key) 1817     getFuncA = [](const std::string& key) -> std::string {
1818         return "getFuncA";
1819     };
1820     frameNode->SetJSCustomProperty(func, getFuncA);
1821     frameNode->setIsCNode(true);
1822     bool result1 = frameNode->GetCapiCustomProperty("key", getValue);
1823     EXPECT_EQ(result1, false);
1824 
1825     /**
1826      * @tc.steps: step4. set isCNode false and func false.
1827      * @tc.expected: expect result2 is false.
1828      */
1829     frameNode->setIsCNode(false);
__anonc0fd8ca61702() 1830     func = []() -> bool { return false; };
__anonc0fd8ca61802(const std::string& key) 1831     getFuncA = [](const std::string& key) -> std::string {
1832         return "getFuncA";
1833     };
1834     frameNode->SetJSCustomProperty(func, getFuncA);
1835     frameNode->setIsCNode(true);
1836     bool result2 = frameNode->GetCapiCustomProperty("key", getValue);
1837     EXPECT_EQ(result2, false);
1838 
1839     /**
1840      * @tc.steps: step5. set getCustomProperty_ value getFuncA.
1841      * @tc.expected: expect result3 value getFuncA.
1842      */
__anonc0fd8ca61902() 1843     func = []() -> bool { return true; };
__anonc0fd8ca61a02(const std::string& key) 1844     getFuncA = [](const std::string& key) -> std::string {
1845         return "getFuncA";
1846     };
1847     frameNode->SetJSCustomProperty(func, getFuncA);
1848     frameNode->SetCustomPropertyMapFlagByKey("key");
1849     bool result3 = frameNode->GetJSCustomProperty("key", getValue);
1850     EXPECT_EQ(result3, true);
1851     EXPECT_EQ(getValue, "getFuncA");
1852 }
1853 
1854 /**
1855  * @tc.name: FrameNodeJSCustomProperty001
1856  * @tc.desc: Test JSCustomProperty.
1857  * @tc.type: FUNC
1858  */
1859 HWTEST_F(FrameNodeTestNg, FrameNodeJSCustomProperty001, TestSize.Level1)
1860 {
1861     /**
1862      * @tc.steps: step1. initialize parameters.
1863      */
1864     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1865 
1866     /**
1867      * @tc.steps: step2. set isCNode false
1868      * @tc.expected: expect result updateFlag is false.
1869      */
1870     frameNode->setIsCNode(false);
__anonc0fd8ca61b02() 1871     std::function<bool()> func = []() -> bool { return true; };
__anonc0fd8ca61c02(const std::string& key) 1872     std::function<std::string(const std::string&)> getFuncAFromJS = [](const std::string& key) -> std::string {
1873         return "getFuncAFromJS";
1874     };
__anonc0fd8ca61d02() 1875     std::function<std::string()> getFuncBFromJS = []() -> std::string { return "getFuncBFromJS"; };
1876     frameNode->SetJSCustomProperty(func, getFuncAFromJS, std::move(getFuncBFromJS));
1877 
1878     InspectorFilter filter;
1879     auto jsonValue = JsonUtil::Create(true);
1880     frameNode->ToJsonValue(jsonValue, filter);
1881     EXPECT_EQ(jsonValue->GetString("customProperty"), "getFuncBFromJS");
1882 
1883     /**
1884      * @tc.steps: step3. set isCNode ture
1885      * @tc.expected: expect result updateFlag is false.
1886      */
1887     frameNode->setIsCNode(true);
1888     frameNode->SetJSCustomProperty(func, getFuncAFromJS, std::move(getFuncBFromJS));
1889     std::string flagValue;
1890     bool updateFlagValue1 = frameNode->GetCapiCustomProperty("updateFlag", flagValue);
1891     auto jsonValueIsCNode = JsonUtil::Create(true);
1892     frameNode->ToJsonValue(jsonValueIsCNode, filter);
1893     EXPECT_EQ(updateFlagValue1, false);
1894     EXPECT_NE(jsonValueIsCNode->GetString("customProperty"), "getFuncBFromJS");
1895 
1896     /**
1897      * @tc.steps: step4. Remove updateFlag value and set isCNode false. Then add custom property.
1898      * @tc.expected: expect the custom property can be set.
1899      */
1900     frameNode->RemoveCustomProperty("updateFlag");
1901     frameNode->setIsCNode(false);
1902     frameNode->AddCustomProperty("key", "value1");
1903     bool result = frameNode->GetCapiCustomProperty("key", flagValue);
1904     EXPECT_EQ(result, true);
1905     result = frameNode->GetCustomPropertyByKey("key", flagValue);
1906     EXPECT_EQ(result, true);
1907     EXPECT_EQ(flagValue, "value1");
1908 }
1909 
1910 /**
1911  * @tc.name: FrameNodeCapiCustomProperty
1912  * @tc.desc: Test CapiCustomProperty.
1913  * @tc.type: FUNC
1914  */
1915 HWTEST_F(FrameNodeTestNg, FrameNodeCapiCustomProperty, TestSize.Level1)
1916 {
1917     /**
1918      * @tc.steps: step1. initialize parameters.
1919      */
1920     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1921     std::string value;
1922 
1923     /**
1924      * @tc.steps: step2. GetCapiCustomProperty
1925      * @tc.expected: expect result value false.
1926      */
1927     frameNode->setIsCNode(false);
1928     bool result = frameNode->GetCapiCustomProperty("key", value);
1929     EXPECT_EQ(result, false);
1930 
1931     /**
1932      * @tc.steps: step3. add the key value as value1.
1933      * @tc.expected: expect result value1.
1934      */
1935     frameNode->setIsCNode(true);
1936     frameNode->AddCustomProperty("key", "value1");
1937     result = frameNode->GetCapiCustomProperty("key", value);
1938     EXPECT_EQ(result, true);
1939     EXPECT_EQ(value, "value1");
1940 
1941     /**
1942      * @tc.steps: step4. set key is value1
1943      * @tc.expected: expect result value.
1944      */
1945     frameNode->setIsCNode(true);
1946     frameNode->AddCustomProperty("key", "value1");
1947     result = frameNode->GetCapiCustomProperty("key1", value);
1948     EXPECT_EQ(result, false);
1949 
1950     /**
1951      * @tc.steps: step5. set key is value1, remove key.
1952      * @tc.expected: expect result false.
1953      */
1954     frameNode->setIsCNode(true);
1955     frameNode->AddCustomProperty("key", "value1");
1956     frameNode->RemoveCustomProperty("key");
1957     result = frameNode->GetCapiCustomProperty("key", value);
1958     EXPECT_EQ(result, false);
1959 }
1960 
1961 /**
1962  * @tc.name: FrameNodeCapiCustomProperty
1963  * @tc.desc: Test CapiCustomProperty.
1964  * @tc.type: FUNC
1965  */
1966 HWTEST_F(FrameNodeTestNg, FrameDumpOnSizeChangeInfo, TestSize.Level1)
1967 {
1968     /**
1969      * @tc.steps: step1. create frameNode.
1970      * @tc.expected: expect is not nullptr.
1971      */
1972     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
1973     EXPECT_NE(frameNode, nullptr);
1974 
1975     /**
1976      * @tc.steps: step2. onSizeChangeDumpInfos push_back.
1977      * @tc.expected: expect is not nullptr.
1978      */
1979     frameNode->onSizeChangeDumpInfos.clear();
1980     frameNode->onSizeChangeDumpInfos.push_back({1625491200, RectF{}, RectF{}});
1981     frameNode->onSizeChangeDumpInfos.push_back({1625494800, RectF{}, RectF{}});
1982     EXPECT_EQ(frameNode->onSizeChangeDumpInfos.size(), 2);
1983 
1984     /**
1985      * @tc.steps: step3. create json.
1986      * @tc.expected: expect is not nullptr.
1987      */
1988     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
1989     EXPECT_NE(json, nullptr);
1990 
1991     /**
1992      * @tc.steps: step4. test DumpOnSizeChangeInfo.
1993      * @tc.expected: expect is "".
1994      */
1995     frameNode->DumpOnSizeChangeInfo(json);
1996     EXPECT_EQ(json->GetString(), "");
1997 }
1998 
1999 /**
2000  * @tc.name: FrameNodeDumpOverlayInfo001
2001  * @tc.desc: Test DumpOverlayInfo.
2002  * @tc.type: FUNC
2003  */
2004 HWTEST_F(FrameNodeTestNg, FrameDumpOverlayInfo001, TestSize.Level1)
2005 {
2006     /**
2007      * @tc.steps: step1. create frameNode.
2008      * @tc.expected: expect is nullptr.
2009      */
2010     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2011     EXPECT_NE(frameNode, nullptr);
2012 
2013     /**
2014      * @tc.steps: step2. create json.
2015      * @tc.expected: expect is nullptr.
2016      */
2017     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2018     EXPECT_NE(json, nullptr);
2019 
2020     /**
2021      * @tc.steps: step3. test DumpOverlayInfo.
2022      * @tc.expected: expect is FALSE.
2023      */
2024     frameNode->DumpOverlayInfo(json);
2025     const auto& valueNode = json->GetValue("IsOverlayNode");
2026     bool hasKeyNode = !(valueNode->IsNull());
2027     EXPECT_FALSE(hasKeyNode);
2028 
2029     const auto& valueOffset = json->GetValue("OverlayOffset");
2030     bool hasKeyOffset = !(valueNode->IsNull());
2031     EXPECT_FALSE(hasKeyOffset);
2032 }
2033 
2034 /**
2035  * @tc.name: FrameNodeDumpOverlayInfo002
2036  * @tc.desc: Test DumpOverlayInfo.
2037  * @tc.type: FUNC
2038  */
2039 HWTEST_F(FrameNodeTestNg, FrameDumpOverlayInfo002, TestSize.Level1)
2040 {
2041     /**
2042      * @tc.steps: step1. create frameNode.
2043      * @tc.expected: expect is nullptr.
2044      */
2045     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2046     EXPECT_NE(frameNode, nullptr);
2047 
2048     /**
2049      * @tc.steps: step2. create json.
2050      * @tc.expected: expect is nullptr.
2051      */
2052     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2053     EXPECT_NE(json, nullptr);
2054 
2055     /**
2056      * @tc.steps: step3. set layoutProperty.
2057      * @tc.expected: expect is TRUE.
2058      */
2059     auto layoutProperty = frameNode->GetLayoutProperty();
2060     layoutProperty->SetIsOverlayNode(true);
2061 
2062     /**
2063      * @tc.steps: step4. test DumpOverlayInfo.
2064      * @tc.expected: expect is TRUE.
2065      */
2066     frameNode->DumpOverlayInfo(json);
2067     const auto& valueNode = json->GetValue("IsOverlayNode");
2068     bool hasKeyNode = !(valueNode->IsNull());
2069     EXPECT_TRUE(hasKeyNode);
2070 
2071     const auto& valueOffset = json->GetValue("OverlayOffset");
2072     bool hasKeyOffset = !(valueOffset->IsNull());
2073     EXPECT_TRUE(hasKeyOffset);
2074 }
2075 
2076 /**
2077  * @tc.name: FrameNodeDumpDragInfo
2078  * @tc.desc: Test DumpDragInfo.
2079  * @tc.type: FUNC
2080  */
2081 HWTEST_F(FrameNodeTestNg, FrameDumpOverlayInfo, TestSize.Level1)
2082 {
2083     /**
2084      * @tc.steps: step1. create frameNode.
2085      * @tc.expected: expect is nullptr.
2086      */
2087     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2088     EXPECT_NE(frameNode, nullptr);
2089 
2090     /**
2091      * @tc.steps: step2. create json.
2092      * @tc.expected: expect is nullptr.
2093      */
2094     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2095     EXPECT_NE(json, nullptr);
2096 
2097     /**
2098      * @tc.steps: step3. test DumpDragInfo.
2099      * @tc.expected: expect is TRUE.
2100      */
2101     frameNode->DumpDragInfo(json);
2102     const auto& valueDrag = json->GetValue("Draggable");
2103     bool hasKeyDrag = !(valueDrag->IsNull());
2104     EXPECT_TRUE(hasKeyDrag);
2105 
2106     const auto& valueUser = json->GetValue("UserSet");
2107     bool hasKeyUser = !(valueUser->IsNull());
2108     EXPECT_TRUE(hasKeyUser);
2109 
2110     const auto& valueCustomer = json->GetValue("CustomerSet");
2111     bool hasKeyCustomer = !(valueCustomer->IsNull());
2112     EXPECT_TRUE(hasKeyCustomer);
2113 
2114     const auto& valuePreview = json->GetValue("DragPreview");
2115     bool hasKeyPreview = !(valuePreview->IsNull());
2116     EXPECT_TRUE(hasKeyPreview);
2117 
2118     const auto& valueEvent = json->GetValue("Event");
2119     bool hasKeyEvent = !(valueEvent->IsNull());
2120     EXPECT_TRUE(hasKeyEvent);
2121 }
2122 
2123 /**
2124  * @tc.name: FrameNodeDumpAlignRulesInfo
2125  * @tc.desc: Test DumpAlignRulesInfo.
2126  * @tc.type: FUNC
2127  */
2128 HWTEST_F(FrameNodeTestNg, FrameNodeDumpAlignRulesInfo, TestSize.Level1)
2129 {
2130     /**
2131      * @tc.steps: step1. create frameNode.
2132      * @tc.expected: expect is nullptr.
2133      */
2134     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2135     EXPECT_NE(frameNode, nullptr);
2136 
2137     /**
2138      * @tc.steps: step2. create json.
2139      * @tc.expected: expect is nullptr.
2140      */
2141     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2142     EXPECT_NE(json, nullptr);
2143 
2144     /**
2145      * @tc.steps: step3. set layoutProperty.
2146      * @tc.expected: expect is TRUE.
2147      */
2148     auto layoutProperty = frameNode->GetLayoutProperty();
2149 
2150     /**
2151      * @tc.steps: step5. test DumpAlignRulesInfo.
2152      * @tc.expected: expect is FALSE.
2153      */
2154     frameNode->DumpAlignRulesInfo(json);
2155     const auto& valueAlignRules = json->GetValue("AlignRules");
2156     bool hasKeyAlignRules = !(valueAlignRules->IsNull());
2157     EXPECT_FALSE(hasKeyAlignRules);
2158 }
2159 
2160 /**
2161  * @tc.name: FrameNodeDumpSafeAreaInfo
2162  * @tc.desc: Test DumpSafeAreaInfo.
2163  * @tc.type: FUNC
2164  */
2165 HWTEST_F(FrameNodeTestNg, FrameNodeDumpSafeAreaInfo, TestSize.Level1)
2166 {
2167     /**
2168      * @tc.steps: step1. create frameNode.
2169      * @tc.expected: expect is nullptr.
2170      */
2171     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2172     EXPECT_NE(frameNode, nullptr);
2173 
2174     /**
2175      * @tc.steps: step2. create json.
2176      * @tc.expected: expect is nullptr.
2177      */
2178     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2179     EXPECT_NE(json, nullptr);
2180 
2181     /**
2182      * @tc.steps: step3. set layoutProperty.
2183      * @tc.expected: expect is TRUE.
2184      */
2185     auto layoutProperty = frameNode->GetLayoutProperty();
2186 
2187     /**
2188      * @tc.steps: step5. test DumpSafeAreaInfo.
2189      * @tc.expected: expect is FALSE.
2190      */
2191     frameNode->DumpSafeAreaInfo(json);
2192 
2193     SafeAreaExpandOpts opts;
2194     opts.switchToNone = true;
2195     frameNode->GetLayoutProperty()->UpdateSafeAreaExpandOpts(opts);
2196     SafeAreaInsets safeArea;
2197     frameNode->GetLayoutProperty()->UpdateSafeAreaInsets(safeArea);
2198     frameNode->DumpSafeAreaInfo(json);
2199 
2200     /**
2201      * @tc.steps: step6. safeAreaExpandOpts_ is nullptr.
2202      * @tc.expected: expect is FALSE.
2203      */
2204     const auto& valueExpandOpts = json->GetValue("SafeAreaExpandOpts");
2205     bool hasKeyExpandOpts = !(valueExpandOpts->IsNull());
2206     EXPECT_TRUE(hasKeyExpandOpts);
2207 
2208     /**
2209      * @tc.steps: step7. safeAreaInsets_ is nullptr.
2210      * @tc.expected: expect is FALSE.
2211      */
2212     const auto& valueInsets = json->GetValue("SafeAreaInsets");
2213     bool hasKeyInsets = !(valueInsets->IsNull());
2214     EXPECT_TRUE(hasKeyInsets);
2215 
2216     /**
2217      * @tc.steps: step8. OrParentExpansive_ is nullptr.
2218      * @tc.expected: expect is FALSE.
2219      */
2220     const auto& valueSelf = json->GetValue("selfAdjust");
2221     bool hasKeySelf = !(valueSelf->IsNull());
2222     EXPECT_FALSE(hasKeySelf);
2223 
2224     const auto& valueParent = json->GetValue("parentAdjust");
2225     bool hasKeyParent = !(valueParent->IsNull());
2226     EXPECT_FALSE(hasKeyParent);
2227 
2228     /**
2229      * @tc.steps: step9. safeSafeAreaManager_ is nullptr.
2230      * @tc.expected: expect is FALSE.
2231      */
2232     const auto& valueIgnore = json->GetValue("ignoreSafeArea");
2233     bool hasKeyIgnore = !(valueIgnore->IsNull());
2234     EXPECT_FALSE(hasKeyIgnore);
2235 
2236     const auto& valueNeedAvoid = json->GetValue("isNeedAvoidWindow");
2237     bool hasKeyNeedAvoid = !(valueNeedAvoid->IsNull());
2238     EXPECT_FALSE(hasKeyNeedAvoid);
2239 
2240     const auto& valueFullScreen = json->GetValue("isFullScreen");
2241     bool hasKeyFullScreen = !(valueFullScreen->IsNull());
2242     EXPECT_FALSE(hasKeyFullScreen);
2243 
2244     const auto& valueKeyboard = json->GetValue("isKeyboardAvoidMode");
2245     bool hasKeyKeyboard = !(valueKeyboard->IsNull());
2246     EXPECT_FALSE(hasKeyKeyboard);
2247 
2248     const auto& valueUseCutout = json->GetValue("isUseCutout");
2249     bool hasKeyUseCutout = !(valueUseCutout->IsNull());
2250     EXPECT_FALSE(hasKeyUseCutout);
2251 }
2252 
2253 /**
2254  * @tc.name: FrameNodeBuildLayoutInfo
2255  * @tc.desc: Test BuildLayoutInfo.
2256  * @tc.type: FUNC
2257  */
2258 HWTEST_F(FrameNodeTestNg, FrameNodeBuildLayoutInfo, TestSize.Level1)
2259 {
2260     /**
2261      * @tc.steps: step1. create frameNode.
2262      * @tc.expected: expect is nullptr.
2263      */
2264     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2265     EXPECT_NE(frameNode, nullptr);
2266 
2267     /**
2268      * @tc.steps: step2. create json.
2269      * @tc.expected: expect is nullptr.
2270      */
2271     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2272     EXPECT_NE(json, nullptr);
2273 
2274     /**
2275      * @tc.steps: step3. set layoutProperty.
2276      * @tc.expected: expect is TRUE.
2277      */
2278     auto layoutProperty = frameNode->GetLayoutProperty();
2279 
2280     /**
2281      * @tc.steps: step4. set geometryNode.
2282      * @tc.expected: expect is TRUE.
2283      */
2284     auto geometryNode = frameNode->GetGeometryNode();
2285 
2286     /**
2287      * @tc.steps: step5. test BuildLayoutInfo.
2288      * @tc.expected: expect is FALSE.
2289      */
2290     frameNode->BuildLayoutInfo(json);
2291 
2292     auto layoutConstraintF_ = LayoutConstraintF();
2293     layoutConstraintF_.maxSize = CONTAINER_SIZE;
2294     layoutConstraintF_.percentReference = CONTAINER_SIZE;
2295     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF_);
2296     frameNode->geometryNode_->SetFrameOffset(OffsetF(1.0f, 0.0f));
2297     frameNode->layoutProperty_->UpdateVisibility(VisibleType::INVISIBLE);
2298     PaddingProperty padding;
2299     padding.left = CalcLength(0.0f);
2300     padding.right = CalcLength(0.0f);
2301     padding.top = CalcLength(0.0f);
2302     padding.bottom = CalcLength(0.0f);
2303     frameNode->layoutProperty_->UpdatePadding(padding);
2304     frameNode->layoutProperty_->UpdateSafeAreaPadding(padding);
2305     BorderWidthProperty overCountBorderWidth;
2306     overCountBorderWidth.SetBorderWidth(Dimension(10, DimensionUnit::VP));
2307     frameNode->layoutProperty_->UpdateBorderWidth(overCountBorderWidth);
2308     MarginProperty marginProperty;
2309     frameNode->layoutProperty_->UpdateMargin(marginProperty);
2310     NG::RectF testRect = { 10.0f, 10.0f, 10.0f, 10.0f };
2311     frameNode->layoutProperty_->SetLayoutRect(testRect);
2312     frameNode->BuildLayoutInfo(json);
2313 
2314     /**
2315      * @tc.steps: step5. ParentLayoutConstraint is nullptr.
2316      * @tc.expected: expect is FALSE.
2317      */
2318     const auto& valueConstraint = json->GetValue("ParentLayoutConstraint");
2319     bool hasKeyConstraint = !(valueConstraint->IsNull());
2320     EXPECT_TRUE(hasKeyConstraint);
2321 
2322     const auto& valuetop = json->GetValue("top");
2323     bool hasKeytop = !(valuetop->IsNull());
2324     EXPECT_TRUE(hasKeytop);
2325 
2326     const auto& valueleft = json->GetValue("left");
2327     bool hasKeyleft = !(valueleft->IsNull());
2328     EXPECT_TRUE(hasKeyleft);
2329 
2330     const auto& valueActive = json->GetValue("Active");
2331     bool hasKeyActive = !(valueActive->IsNull());
2332     EXPECT_TRUE(hasKeyActive);
2333 
2334     const auto& valueVisible = json->GetValue("Visible");
2335     bool hasKeyVisible = !(valueVisible->IsNull());
2336     EXPECT_TRUE(hasKeyVisible);
2337 
2338     const auto& valuePadding = json->GetValue("Padding");
2339     bool hasKeyPadding = !(valuePadding->IsNull());
2340     EXPECT_TRUE(hasKeyPadding);
2341 
2342     const auto& valueBorder = json->GetValue("Border");
2343     bool hasKeyBorder = !(valueBorder->IsNull());
2344     EXPECT_TRUE(hasKeyBorder);
2345 
2346     const auto& valueMargin = json->GetValue("Margin");
2347     bool hasKeyMargin = !(valueMargin->IsNull());
2348     EXPECT_TRUE(hasKeyMargin);
2349 
2350     const auto& valueLayout = json->GetValue("LayoutRect");
2351     bool hasKeyLayout = !(valueLayout->IsNull());
2352     EXPECT_TRUE(hasKeyLayout);
2353 }
2354 
2355 /**
2356  * @tc.name: FrameNodeMarkRemoving001
2357  * @tc.desc: Test MarkRemoving.
2358  * @tc.type: FUNC
2359  */
2360 HWTEST_F(FrameNodeTestNg, FrameNodeMarkRemoving001, TestSize.Level1)
2361 {
2362     /**
2363      * @tc.steps: step1. create frameNode.
2364      * @tc.expected: expect is nullptr.
2365      */
2366     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2367     EXPECT_NE(frameNode, nullptr);
2368 
2369     /**
2370      * @tc.steps: step2. test MarkRemoving.
2371      * @tc.expected: expect is false.
2372      */
2373     auto pendingRemove = frameNode->MarkRemoving();
2374     EXPECT_FALSE(pendingRemove);
2375 }
2376 
2377 /**
2378  * @tc.name: FrameNodeMarkRemoving002
2379  * @tc.desc: Test MarkRemoving.
2380  * @tc.type: FUNC
2381  */
2382 HWTEST_F(FrameNodeTestNg, FrameNodeMarkRemoving002, TestSize.Level1)
2383 {
2384     /**
2385      * @tc.steps: step1. create frameNode.
2386      * @tc.expected: expect is nullptr.
2387      */
2388     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2389     EXPECT_NE(frameNode, nullptr);
2390 
2391     /**
2392      * @tc.steps: step2. set layoutProperty.
2393      * @tc.expected: expect is nullptr.
2394      */
2395     auto layoutProperty = frameNode->GetLayoutProperty();
2396 
2397     /**
2398      * @tc.steps: step3. test MarkRemoving.
2399      * @tc.expected: expect is false.
2400      */
2401     auto pendingRemove = frameNode->MarkRemoving();
2402     EXPECT_FALSE(pendingRemove);
2403 }
2404 
2405 /**
2406  * @tc.name: FrameNodeMarkRemoving003
2407  * @tc.desc: Test MarkRemoving.
2408  * @tc.type: FUNC
2409  */
2410 HWTEST_F(FrameNodeTestNg, FrameNodeMarkRemoving003, TestSize.Level1)
2411 {
2412     /**
2413      * @tc.steps: step1. create frameNode.
2414      * @tc.expected: expect is nullptr.
2415      */
2416     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2417     EXPECT_NE(frameNode, nullptr);
2418 
2419     /**
2420      * @tc.steps: step2. set geometryNode.
2421      * @tc.expected: expect is nullptr.
2422      */
2423     auto geometryNode = frameNode->GetGeometryNode();
2424 
2425     /**
2426      * @tc.steps: step3. test MarkRemoving.
2427      * @tc.expected: expect is false.
2428      */
2429     auto pendingRemove = frameNode->MarkRemoving();
2430     EXPECT_FALSE(pendingRemove);
2431 }
2432 
2433 /**
2434  * @tc.name: FrameNodeMarkRemoving004
2435  * @tc.desc: Test MarkRemoving.
2436  * @tc.type: FUNC
2437  */
2438 HWTEST_F(FrameNodeTestNg, FrameNodeMarkRemoving004, TestSize.Level1)
2439 {
2440     /**
2441      * @tc.steps: step1. create frameNode.
2442      * @tc.expected: expect is nullptr.
2443      */
2444     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2445     EXPECT_NE(frameNode, nullptr);
2446 
2447     /**
2448      * @tc.steps: step2. set geometryNode and layoutProperty.
2449      * @tc.expected: expect is nullptr.
2450      */
2451     auto geometryNode = frameNode->GetGeometryNode();
2452     auto layoutProperty = frameNode->GetLayoutProperty();
2453 
2454     /**
2455      * @tc.steps: step3. test MarkRemoving.
2456      * @tc.expected: expect is false.
2457      */
2458     auto pendingRemove = frameNode->MarkRemoving();
2459     EXPECT_FALSE(pendingRemove);
2460 }
2461 
2462 /**
2463  * @tc.name: FrameNodeOnConfigurationUpdate
2464  * @tc.desc: Test of OnConfigurationUpdate
2465  * @tc.type: FUNC
2466  */
2467 HWTEST_F(FrameNodeTestNg, FrameNodeOnConfigurationUpdate, TestSize.Level1)
2468 {
2469     /**
2470      * @tc.steps: step1. create childNode and itemNode
2471      * @tc.expected: childNode and itemNode is not null
2472      */
2473     auto childNode = FrameNode::CreateFrameNode(
2474         "child", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
2475     auto itemNode = FrameNode::CreateFrameNode(
2476         "itemNode", ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
2477     childNode->AddChild(itemNode);
2478 
2479     /**
2480      * @tc.steps: step2. create configurationChange.
2481      */
2482     ConfigurationChange configurationChange;
2483 
2484     /**
2485      * @tc.steps: step3. childNode Update Configuration.
2486      * @tc.expected: update success
2487      */
2488     childNode->OnConfigurationUpdate(configurationChange);
2489 
2490     /**
2491      * @tc.steps: step4. set languageUpdate is true.
2492      * @tc.expected: update success
2493      */
2494     configurationChange.languageUpdate = true;
2495     childNode->OnConfigurationUpdate(configurationChange);
2496 
2497     /**
2498      * @tc.steps: step5. set colorModeUpdate is true
2499      * @tc.expected: update success
2500      */
2501     configurationChange.colorModeUpdate = true;
2502     childNode->OnConfigurationUpdate(configurationChange);
2503 
2504     /**
2505      * @tc.steps: step6. set directionUpdate is true
2506      * @tc.expected: update success
2507      */
2508     configurationChange.directionUpdate = true;
2509     childNode->OnConfigurationUpdate(configurationChange);
2510 
2511     /**
2512      * @tc.steps: step7. set dpiUpdate is true
2513      * @tc.expected: update success
2514      */
2515     configurationChange.dpiUpdate = true;
2516     childNode->OnConfigurationUpdate(configurationChange);
2517 
2518     /**
2519      * @tc.steps: step8. set fontUpdate is true
2520      * @tc.expected: update success
2521      */
2522     configurationChange.fontUpdate = true;
2523     configurationChange.iconUpdate = true;
2524     configurationChange.skinUpdate = true;
2525     configurationChange.fontWeightScaleUpdate = true;
2526     childNode->OnConfigurationUpdate(configurationChange);
2527 
2528     /**
2529      * @tc.steps: step9. set fontScaleUpdate is true
2530      * @tc.expected: update success
2531      */
2532     configurationChange.fontScaleUpdate = true;
2533     childNode->OnConfigurationUpdate(configurationChange);
2534 
2535     childNode->SetBackgroundLayoutConstraint(itemNode);
2536     childNode->ForceUpdateLayoutPropertyFlag(PROPERTY_UPDATE_MEASURE_SELF);
2537     childNode->GetPaintRectWithTransform();
2538     childNode->GetTransformScale();
2539     childNode->SetJSViewActive(true);
2540 
2541     /**
2542      * @tc.steps: step10. create layoutProperty
2543      * @tc.expected: layoutProperty is nullptr
2544      */
2545     auto layoutProperty = childNode->GetLayoutProperty();
2546     EXPECT_FALSE(layoutProperty->IsOverlayNode());
2547     layoutProperty->SetIsOverlayNode(true);
2548     childNode->DumpOverlayInfo();
2549     EXPECT_TRUE(layoutProperty->IsOverlayNode());
2550 }
2551 
2552 /**
2553  * @tc.name: FrameNodeOnRemoveFromParent001
2554  * @tc.desc: Test OnRemoveFromParent.
2555  * @tc.type: FUNC
2556  */
2557 HWTEST_F(FrameNodeTestNg, FrameNodeOnRemoveFromParent001, TestSize.Level1)
2558 {
2559     /**
2560      * @tc.steps: step1. create frameNode.
2561      * @tc.expected: expect is nullptr.
2562      */
2563     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2564     EXPECT_NE(frameNode, nullptr);
2565 
2566     /**
2567      * @tc.steps: step2. set allowTransition.
2568      * @tc.expected: expect is true.
2569      */
2570     auto allowTransition = true;
2571 
2572     /**
2573      * @tc.steps: step3. test OnRemoveFromParent.
2574      * @tc.expected: expect is true.
2575      */
2576     auto removeFrom = frameNode->OnRemoveFromParent(allowTransition);
2577     EXPECT_TRUE(removeFrom);
2578 }
2579 
2580 /**
2581  * @tc.name: FrameNodeOnRemoveFromParent002
2582  * @tc.desc: Test OnRemoveFromParent.
2583  * @tc.type: FUNC
2584  */
2585 HWTEST_F(FrameNodeTestNg, FrameNodeOnRemoveFromParent002, TestSize.Level1)
2586 {
2587     /**
2588      * @tc.steps: step1. create frameNode.
2589      * @tc.expected: expect is nullptr.
2590      */
2591     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2592     EXPECT_NE(frameNode, nullptr);
2593 
2594     /**
2595      * @tc.steps: step2. set allowTransition.
2596      * @tc.expected: expect is false.
2597      */
2598     auto allowTransition = false;
2599 
2600     /**
2601      * @tc.steps: step3. test OnRemoveFromParent.
2602      * @tc.expected: expect is true.
2603      */
2604     auto removeFrom = frameNode->OnRemoveFromParent(allowTransition);
2605     EXPECT_TRUE(removeFrom);
2606 }
2607 
2608 /**
2609  * @tc.name: FrameNodeFindChildByName
2610  * @tc.desc: Test FindChildByName.
2611  * @tc.type: FUNC
2612  */
2613 HWTEST_F(FrameNodeTestNg, FrameNodeFindChildByName, TestSize.Level1)
2614 {
2615     /**
2616      * @tc.steps: step1. create frameNode.
2617      * @tc.expected: expect is not nullptr.
2618      */
2619     const std::string parentName = "Parent";
2620     const std::string oneName = "One";
2621     const std::string oneChildName = "OneChild";
2622     const std::string twoName = "Two";
2623     const std::string twoChildName = "TwoChild";
2624     const std::string testName = "test";
2625     auto parent = FrameNode::CreateFrameNode(parentName, 10, AceType::MakeRefPtr<Pattern>(), true);
2626     auto one = FrameNode::CreateFrameNode(oneName, 20, AceType::MakeRefPtr<Pattern>());
2627     auto oneChild = FrameNode::CreateFrameNode(oneChildName, 30, AceType::MakeRefPtr<Pattern>());
2628     auto two = FrameNode::CreateFrameNode(twoName, 40, AceType::MakeRefPtr<Pattern>());
2629     auto twoChild = FrameNode::CreateFrameNode(twoChildName, 50, AceType::MakeRefPtr<Pattern>());
2630 
2631     EXPECT_NE(parent, nullptr);
2632     EXPECT_NE(one, nullptr);
2633     EXPECT_NE(oneChild, nullptr);
2634     EXPECT_NE(two, nullptr);
2635     EXPECT_NE(twoChild, nullptr);
2636 
2637     /**
2638      * @tc.steps: step1. Set the node's relation.
2639      * @tc.expected: expect is null nullptr.
2640      */
2641     parent->AddChild(one);
2642     parent->AddChild(two);
2643     one->AddChild(oneChild);
2644     two->AddChild(twoChild);
2645 
2646     EXPECT_NE(parent, nullptr);
2647     EXPECT_NE(one, nullptr);
2648     EXPECT_NE(two, nullptr);
2649 
2650     /**
2651      * @tc.steps: step3. update InspectorId.
2652      * @tc.expected: update success
2653      */
2654     parent->UpdateInspectorId(parentName);
2655     one->UpdateInspectorId(oneName);
2656     oneChild->UpdateInspectorId(oneChildName);
2657     two->UpdateInspectorId(twoName);
2658     twoChild->UpdateInspectorId(twoChildName);
2659 
2660     /**
2661      * @tc.steps: step3. find oneChild.
2662      * @tc.expected: success
2663      */
2664     auto finalResult = FrameNode::FindChildByName(parent, oneName);
2665     EXPECT_NE(finalResult, oneChild);
2666 
2667     /**
2668      * @tc.steps: step3. find testName.
2669      * @tc.expected: fail
2670      */
2671     auto noChildResult = FrameNode::FindChildByName(parent, testName);
2672     EXPECT_EQ(noChildResult, nullptr);
2673 
2674     /**
2675      * @tc.steps: step3. clear parent to find twoChild.
2676      * @tc.expected: fail
2677      */
2678     parent->Clean();
2679     auto noHaveResult = FrameNode::FindChildByName(parent, twoChildName);
2680     EXPECT_EQ(noHaveResult, nullptr);
2681 }
2682 
2683 /**
2684  * @tc.name: FrameNodeSwapDirty
2685  * @tc.desc: Test SwapDirtyLayoutWrapperOnMainThread
2686  * @tc.type: FUNC
2687  */
2688 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirty001, TestSize.Level1)
2689 {
2690     /**
2691      * @tc.steps: step1. creat frameNode and layoutProperty
2692      */
2693     RefPtr<LayoutWrapper> layoutWrapper = FRAME_NODE2->CreateLayoutWrapper(true, true);
2694     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2695     auto layoutProperty = frameNode->GetLayoutProperty<LayoutProperty>();
2696     EXPECT_NE(layoutProperty, nullptr);
2697 
2698     /**
2699      * @tc.steps: step2. setBorderWidth and updateBorderWidth.
2700      * @tc.expected: expect borderWidth property is not nullptr.
2701      */
2702     BorderWidthProperty overCountBorderWidth;
2703     overCountBorderWidth.SetBorderWidth(Dimension(10, DimensionUnit::VP));
2704     layoutProperty->UpdateBorderWidth(overCountBorderWidth);
2705     frameNode->SetLayoutProperty(layoutProperty);
2706 
2707     /**
2708      * @tc.steps: step3. callback SwapDirtyLayoutWrapperOnMainThread
2709      * @tc.expected: expect GetBorderWidthProperty is not nullptr.
2710      */
2711     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
2712     EXPECT_NE(layoutProperty->GetBorderWidthProperty(), nullptr);
2713 }
2714 
2715 /**
2716  * @tc.name: FrameNodeSwapDirty
2717  * @tc.desc: Test SwapDirtyLayoutWrapperOnMainThread
2718  * @tc.type: FUNC
2719  */
2720 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirty002, TestSize.Level1)
2721 {
2722     /**
2723      * @tc.steps: step1. creat frameNode and layoutProperty
2724      */
2725     RefPtr<LayoutWrapper> layoutWrapper = FRAME_NODE2->CreateLayoutWrapper(true, true);
2726     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2727     auto layoutProperty = frameNode->GetLayoutProperty<LayoutProperty>();
2728     EXPECT_NE(layoutProperty, nullptr);
2729 
2730     /**
2731      * @tc.steps: step2. setBorderWidth and updateBorderWidth.
2732      * @tc.expected: expect borderWidth property is not nullptr.
2733      */
2734     BorderWidthProperty overCountBorderWidth;
2735     overCountBorderWidth.SetBorderWidth(Dimension(10, DimensionUnit::VP));
2736     layoutProperty->UpdateBorderWidth(overCountBorderWidth);
2737     frameNode->SetLayoutProperty(layoutProperty);
2738 
2739     /**
2740      * @tc.steps: step3. updatae layoutConstraint and set eventHub_.
2741      * @tc.expected: nullptr.
2742      */
2743     auto layoutConstraintF_ = LayoutConstraintF();
2744     layoutConstraintF_.maxSize = CONTAINER_SIZE;
2745     layoutConstraintF_.percentReference = CONTAINER_SIZE;
2746     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF_);
2747     layoutProperty->UpdateLayoutConstraint(layoutConstraintF_);
2748 
2749     frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateFocusHub();
2750     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
2751     EXPECT_NE(frameNode->eventHub_, nullptr);
2752 }
2753 
2754 /**
2755  * @tc.name: FrameNodeSwapDirty
2756  * @tc.desc: Test SwapDirtyLayoutWrapperOnMainThread
2757  * @tc.type: FUNC
2758  */
2759 HWTEST_F(FrameNodeTestNg, FrameNodeSwapDirty003, TestSize.Level1)
2760 {
2761     /**
2762      * @tc.steps: step1. creat frameNode and layoutProperty
2763      */
2764     RefPtr<LayoutWrapper> layoutWrapper = FRAME_NODE2->CreateLayoutWrapper(true, true);
2765     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2766     auto layoutProperty = frameNode->GetLayoutProperty<LayoutProperty>();
2767     EXPECT_NE(layoutProperty, nullptr);
2768 
2769     /**
2770      * @tc.steps: step2. setBorderWidth and updateBorderWidth.
2771      * @tc.expected: expect borderWidth property is not nullptr.
2772      */
2773     BorderWidthProperty overCountBorderWidth;
2774     overCountBorderWidth.SetBorderWidth(Dimension(10, DimensionUnit::VP));
2775     layoutProperty->UpdateBorderWidth(overCountBorderWidth);
2776     frameNode->SetLayoutProperty(layoutProperty);
2777 
2778     /**
2779      * @tc.steps: step5. set currentFocus_ is true and call SwapDirtyLayoutWrapperOnMainThread.
2780      * @tc.expected: expect cover branch IsCurrentFocus() is true and function is run ok .
2781      */
2782     auto layoutConstraintF_ = LayoutConstraintF();
2783     layoutConstraintF_.maxSize = CONTAINER_SIZE;
2784     layoutConstraintF_.percentReference = CONTAINER_SIZE;
2785     frameNode->geometryNode_->SetParentLayoutConstraint(layoutConstraintF_);
2786     layoutProperty->UpdateLayoutConstraint(layoutConstraintF_);
2787 
2788     frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateFocusHub()->currentFocus_ = true;
2789     frameNode->SwapDirtyLayoutWrapperOnMainThread(layoutWrapper);
2790     EXPECT_TRUE(frameNode->GetOrCreateEventHub<EventHub>()->GetOrCreateFocusHub()->IsCurrentFocus());
2791 }
2792 
2793 /**
2794  * @tc.name: FrameNodeDumpSimplifyCommonInfo
2795  * @tc.desc: Test DumpSimplifyCommonInfo.
2796  * @tc.type: FUNC
2797  */
2798 HWTEST_F(FrameNodeTestNg, FrameNodeDumpSimplifyCommonInfo, TestSize.Level1)
2799 {
2800     /**
2801      * @tc.steps: step1. create frameNode.
2802      * @tc.expected: expect is nullptr.
2803      */
2804     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2805     EXPECT_NE(frameNode, nullptr);
2806 
2807     /**
2808      * @tc.steps: step2. create json.
2809      * @tc.expected: expect is nullptr.
2810      */
2811     std::shared_ptr<JsonValue> json = JsonUtil::CreateSharedPtrJson(true);
2812     EXPECT_NE(json, nullptr);
2813 
2814     /**
2815      * @tc.steps: step3. test DumpOverlayInfo.
2816      * @tc.expected: expect is FALSE.
2817      */
2818     frameNode->DumpSimplifyCommonInfo(json);
2819     const auto& valueFrameRect = json->GetValue("FrameRect");
2820     bool hasvalueFrameRect = !(valueFrameRect->IsNull());
2821     EXPECT_FALSE(hasvalueFrameRect);
2822 
2823     const auto& valueTransform = json->GetValue("PaintRectWithoutTransform");
2824     bool hasKeyTransform = !(valueTransform->IsNull());
2825     EXPECT_FALSE(hasKeyTransform);
2826 
2827     const auto& valueColor = json->GetValue("BackgroundColor");
2828     bool hasKeyColor = !(valueColor->IsNull());
2829     EXPECT_FALSE(hasKeyColor);
2830 
2831     const auto& valueOffset = json->GetValue("Offset");
2832     bool hasKeyOffset = !(valueOffset->IsNull());
2833     EXPECT_FALSE(hasKeyOffset);
2834 
2835     const auto& valueVisible = json->GetValue("Visible");
2836     bool hasKeyVisible = !(valueVisible->IsNull());
2837     EXPECT_FALSE(hasKeyVisible);
2838 
2839     const auto& valueLayoutRect = json->GetValue("LayoutRect");
2840     bool hasKeyLayoutRect = !(valueLayoutRect->IsNull());
2841     EXPECT_FALSE(hasKeyLayoutRect);
2842 
2843     const auto& valueConstraint = json->GetValue("UserDefinedConstraint");
2844     bool hasKeyConstraint = !(valueConstraint->IsNull());
2845     EXPECT_FALSE(hasKeyConstraint);
2846 
2847     const auto& valueContent = json->GetValue("ContentConstraint");
2848     bool hasKeyContent = !(valueContent->IsNull());
2849     EXPECT_FALSE(hasKeyContent);
2850 
2851     const auto& valueParentLayout = json->GetValue("ParentLayoutConstraint");
2852     bool hasKeyParentLayout = !(valueParentLayout->IsNull());
2853     EXPECT_FALSE(hasKeyParentLayout);
2854 }
2855 
2856 /**
2857  * @tc.name: FrameNodeDumpCommonInfo
2858  * @tc.desc: Test DumpCommonInfo.
2859  * @tc.type: FUNC
2860  */
2861 HWTEST_F(FrameNodeTestNg, FrameNodeDumpCommonInfo, TestSize.Level1)
2862 {
2863     /**
2864      * @tc.steps: step1. create frameNode.
2865      * @tc.expected: expect is nullptr.
2866      */
2867     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2868     EXPECT_NE(frameNode, nullptr);
2869 
2870     /**
2871      * @tc.steps: step2. create json.
2872      * @tc.expected: expect is nullptr.
2873      */
2874     std::unique_ptr<JsonValue> json = JsonUtil::Create(true);
2875     EXPECT_NE(json, nullptr);
2876 
2877     /**
2878      * @tc.steps: step3. test DumpCommonInfo.
2879      * @tc.expected: expect is FALSE.
2880      */
2881     frameNode->DumpCommonInfo(json);
2882 
2883     frameNode->renderContext_->UpdateBackgroundColor(Color::BLUE);
2884     MeasureProperty constraint;
2885     frameNode->layoutProperty_->UpdateCalcLayoutProperty(constraint);
2886     frameNode->propInspectorId_ = "test";
2887     frameNode->DumpCommonInfo(json);
2888     MarginProperty marginProperty;
2889     frameNode->layoutProperty_->UpdateMargin(marginProperty);
2890     frameNode->DumpCommonInfo(json);
2891     BorderWidthProperty overCountBorderWidth;
2892     overCountBorderWidth.SetBorderWidth(Dimension(10, DimensionUnit::VP));
2893     frameNode->layoutProperty_->UpdateBorderWidth(overCountBorderWidth);
2894     frameNode->DumpCommonInfo(json);
2895     PaddingProperty padding;
2896     frameNode->layoutProperty_->UpdatePadding(padding);
2897     frameNode->DumpCommonInfo(json);
2898 
2899     const auto& valueFrameRect = json->GetValue("FrameRect");
2900     bool hasvalueFrameRect = !(valueFrameRect->IsNull());
2901     EXPECT_TRUE(hasvalueFrameRect);
2902 
2903     const auto& valuePaintRect = json->GetValue("PaintRect without transform");
2904     bool hasvaluePaintRect = !(valuePaintRect->IsNull());
2905     EXPECT_TRUE(hasvaluePaintRect);
2906 
2907     const auto& valueBackgroundColor= json->GetValue("BackgroundColor");
2908     bool hasvalueBackgroundColor = !(valueBackgroundColor->IsNull());
2909     EXPECT_TRUE(hasvalueBackgroundColor);
2910 
2911     frameNode->DumpInfo(json);
2912     frameNode->DumpAdvanceInfo(json);
2913     const auto& valueConstraint = json->GetValue("ParentLayoutConstraint");
2914     bool hasKeyConstraint = !(valueConstraint->IsNull());
2915     EXPECT_FALSE(hasKeyConstraint);
2916 }
2917 
2918 /**
2919  * @tc.name: FrameNodeGetJSCustomProperty001
2920  * @tc.desc: Test GetJSCustomProperty.
2921  * @tc.type: FUNC
2922  */
2923 HWTEST_F(FrameNodeTestNg, FrameNodeGetJSCustomProperty001, TestSize.Level1)
2924 {
2925     /**
2926      * @tc.steps: step1. create frameNode.
2927      * @tc.expected: expect is not nullptr.
2928      */
2929     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2930     EXPECT_NE(frameNode, nullptr);
2931 
2932     /**
2933      * @tc.steps: step2. test GetJSCustomProperty.
2934      * @tc.expected: expect false.
2935      */
2936     const std::string key  = "testKey";
2937     std::string value = "testValue";
2938     auto hasKey = frameNode->GetJSCustomProperty(key, value);
2939 
2940     EXPECT_FALSE(hasKey);
2941 }
2942 
2943 /**
2944  * @tc.name: FrameNodeGetJSCustomProperty002
2945  * @tc.desc: Test GetJSCustomProperty
2946  * @tc.type: FUNC
2947  */
2948 HWTEST_F(FrameNodeTestNg, FrameNodeGetJSCustomProperty002, TestSize.Level1)
2949 {
2950     /**
2951      * @tc.steps: step1. create frameNode.
2952      * @tc.expected: expect is not nullptr.
2953      */
2954     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2955     EXPECT_NE(frameNode, nullptr);
2956 
2957     /**
2958      * @tc.steps: step2. set getCustomProperty_ value test.
2959      * @tc.expected: expect result value test.
2960      */
__anonc0fd8ca61e02() 2961     std::function<bool()> func = []() -> bool { return true; };
__anonc0fd8ca61f02(const std::string& key) 2962     std::function<std::string(const std::string&)> getFunc = [](const std::string& key) -> std::string {
2963         return "test";};
2964     frameNode->SetJSCustomProperty(func, getFunc);
2965 
2966     /**
2967      * @tc.steps: step2. test GetJSCustomProperty.
2968      * @tc.expected: expect true.
2969      */
2970     const std::string key  = "testKey";
2971     std::string value = "testValue";
2972     frameNode->SetCustomPropertyMapFlagByKey("testKey");
2973     auto hasKey = frameNode->GetJSCustomProperty(key, value);
2974 
2975     EXPECT_TRUE(hasKey);
2976     EXPECT_EQ(value, "test");
2977 }
2978 
2979 /**
2980  * @tc.name: FrameNodeOnRecycle001
2981  * @tc.desc: Test OnRecycle when accessibility not enabled
2982  * @tc.type: FUNC
2983  */
2984 HWTEST_F(FrameNodeTestNg, FrameNodeOnRecycle001, TestSize.Level1)
2985 {
2986     /**
2987      * @tc.steps: step1. create frameNode.
2988      * @tc.expected: expect is not nullptr.
2989      */
2990     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
2991     EXPECT_NE(frameNode, nullptr);
2992 
2993     /**
2994      * @tc.steps: step2. set infoInstance.
2995      * @tc.expected: expect is not nullptr.
2996      */
2997     AceApplicationInfo::GetInstance().SetAccessibilityEnabled(false);
2998 
2999     /**
3000      * @tc.steps: step3. change accessibilityProperty.
3001      * @tc.expected: expect is not nullptr.
3002      */
3003     auto accessibilityProperty = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
3004     EXPECT_NE(accessibilityProperty, nullptr);
3005     accessibilityProperty->SetAccessibilityFocusState(true);
3006 
3007     /**
3008      * @tc.steps: step4. change renderContext.
3009      * @tc.expected: expect is not nullptr.
3010      */
3011     auto renderContext = frameNode->GetRenderContext();
3012     EXPECT_NE(renderContext, nullptr);
3013     renderContext->UpdateAccessibilityFocus(true);
3014 
3015     /**
3016      * @tc.steps: step5. test OnRecycle.
3017      * @tc.expected: expect not focused
3018      */
3019     frameNode->OnRecycle();
3020     EXPECT_TRUE(accessibilityProperty->GetAccessibilityFocusState());
3021     EXPECT_TRUE(renderContext->GetAccessibilityFocus().value_or(false));
3022 }
3023 
3024 /**
3025  * @tc.name: FrameNodeOnRecycle002
3026  * @tc.desc: Test OnRecycle when accessibility not focus.
3027  * @tc.type: FUNC
3028  */
3029 HWTEST_F(FrameNodeTestNg, FrameNodeOnRecycle002, TestSize.Level1)
3030 {
3031     /**
3032      * @tc.steps: step1. create frameNode.
3033      * @tc.expected: expect is not nullptr.
3034      */
3035     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3036     EXPECT_NE(frameNode, nullptr);
3037 
3038     /**
3039      * @tc.steps: step2. set infoInstance.
3040      * @tc.expected: expect is not nullptr.
3041      */
3042     AceApplicationInfo::GetInstance().SetAccessibilityEnabled(true);
3043 
3044     /**
3045      * @tc.steps: step3. change accessibilityProperty.
3046      * @tc.expected: expect is not nullptr.
3047      */
3048     auto accessibilityProperty = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
3049     EXPECT_NE(accessibilityProperty, nullptr);
3050     accessibilityProperty->SetAccessibilityFocusState(false);
3051 
3052     /**
3053      * @tc.steps: step4. change renderContext.
3054      * @tc.expected: expect is not nullptr.
3055      */
3056     auto renderContext = frameNode->GetRenderContext();
3057     EXPECT_NE(renderContext, nullptr);
3058     renderContext->UpdateAccessibilityFocus(true);
3059 
3060     /**
3061      * @tc.steps: step5. test OnRecycle.
3062      * @tc.expected: expect not focused
3063      */
3064     frameNode->OnRecycle();
3065     EXPECT_FALSE(accessibilityProperty->GetAccessibilityFocusState());
3066     EXPECT_TRUE(renderContext->GetAccessibilityFocus().value_or(false));
3067 }
3068 
3069 /**
3070  * @tc.name: FrameNodeOnRecycle003
3071  * @tc.desc: Test OnRecycle when renderContext not accessibilityFocus.
3072  * @tc.type: FUNC
3073  */
3074 HWTEST_F(FrameNodeTestNg, FrameNodeOnRecycle003, TestSize.Level1)
3075 {
3076     /**
3077      * @tc.steps: step1. create frameNode.
3078      * @tc.expected: expect is not nullptr.
3079      */
3080     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3081     EXPECT_NE(frameNode, nullptr);
3082 
3083     /**
3084      * @tc.steps: step2. set infoInstance.
3085      * @tc.expected: expect is not nullptr.
3086      */
3087     AceApplicationInfo::GetInstance().SetAccessibilityEnabled(true);
3088 
3089     /**
3090      * @tc.steps: step3. change accessibilityProperty.
3091      * @tc.expected: expect is not nullptr.
3092      */
3093     auto accessibilityProperty = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
3094     EXPECT_NE(accessibilityProperty, nullptr);
3095     accessibilityProperty->SetAccessibilityFocusState(true);
3096 
3097     /**
3098      * @tc.steps: step4. change renderContext.
3099      * @tc.expected: expect is not nullptr.
3100      */
3101     auto renderContext = frameNode->GetRenderContext();
3102     EXPECT_NE(renderContext, nullptr);
3103     renderContext->UpdateAccessibilityFocus(false);
3104 
3105     /**
3106      * @tc.steps: step5. test OnRecycle.
3107      * @tc.expected: expect not focused
3108      */
3109     frameNode->OnRecycle();
3110     EXPECT_FALSE(accessibilityProperty->GetAccessibilityFocusState());
3111     EXPECT_FALSE(renderContext->GetAccessibilityFocus().value_or(false));
3112 }
3113 
3114 /**
3115  * @tc.name: FrameNodeOnRecycle004
3116  * @tc.desc: Test OnRecycle.
3117  * @tc.type: FUNC
3118  */
3119 HWTEST_F(FrameNodeTestNg, FrameNodeOnRecycle004, TestSize.Level1)
3120 {
3121     /**
3122      * @tc.steps: step1. create frameNode.
3123      * @tc.expected: expect is not nullptr.
3124      */
3125     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3126     EXPECT_NE(frameNode, nullptr);
3127 
3128     /**
3129      * @tc.steps: step2. set infoInstance.
3130      * @tc.expected: expect is not nullptr.
3131      */
3132     AceApplicationInfo::GetInstance().SetAccessibilityEnabled(true);
3133 
3134     /**
3135      * @tc.steps: step3. change accessibilityProperty.
3136      * @tc.expected: expect is not nullptr.
3137      */
3138     auto accessibilityProperty = frameNode->GetAccessibilityProperty<NG::AccessibilityProperty>();
3139     EXPECT_NE(accessibilityProperty, nullptr);
3140     accessibilityProperty->SetAccessibilityFocusState(true);
3141 
3142     /**
3143      * @tc.steps: step4. change renderContext.
3144      * @tc.expected: expect is not nullptr.
3145      */
3146     auto renderContext = frameNode->GetRenderContext();
3147     EXPECT_NE(renderContext, nullptr);
3148     renderContext->UpdateAccessibilityFocus(true);
3149 
3150     /**
3151      * @tc.steps: step5. test OnRecycle.
3152      * @tc.expected: expect not focused
3153      */
3154     frameNode->OnRecycle();
3155     EXPECT_FALSE(accessibilityProperty->GetAccessibilityFocusState());
3156     EXPECT_FALSE(renderContext->GetAccessibilityFocus().value_or(false));
3157 }
3158 
3159 /**
3160  * @tc.name: FrameNodeGetCapiCustomProperty001
3161  * @tc.desc: Test GetCapiCustomProperty.
3162  * @tc.type: FUNC
3163  */
3164 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty001, TestSize.Level1)
3165 {
3166     /**
3167      * @tc.steps: step1. create frameNode.
3168      * @tc.expected: expect is not nullptr.
3169      */
3170     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3171     EXPECT_NE(frameNode, nullptr);
3172 
3173     /**
3174      * @tc.steps: step2. GetCapiCustomProperty
3175      * @tc.expected: expect result value false.
3176      */
3177     frameNode->setIsCNode(false);
3178     std::string value;
3179     bool hasKey = frameNode->GetCapiCustomProperty("key", value);
3180     EXPECT_FALSE(hasKey);
3181 }
3182 
3183 /**
3184  * @tc.name: FrameNodeGetCapiCustomProperty002
3185  * @tc.desc: Test GetCapiCustomProperty.
3186  * @tc.type: FUNC
3187  */
3188 HWTEST_F(FrameNodeTestNg, FrameNodeGetCapiCustomProperty002, TestSize.Level1)
3189 {
3190     /**
3191      * @tc.steps: step1. create frameNode.
3192      * @tc.expected: expect is not nullptr.
3193      */
3194     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3195     EXPECT_NE(frameNode, nullptr);
3196 
3197     /**
3198      * @tc.steps: step2. GetCapiCustomProperty.
3199      * @tc.expected: expect result true.
3200      */
3201     frameNode->setIsCNode(true);
3202     frameNode->AddCustomProperty("key", "value");
3203     std::string value;
3204     bool result = frameNode->GetCapiCustomProperty("key", value);
3205     EXPECT_TRUE(result);
3206     EXPECT_EQ(value, "value");
3207 }
3208 
3209 /**
3210  * @tc.name: UpdateIgnoreCountTest001
3211  * @tc.desc: Test UpdateIgnoreCount.
3212  * @tc.type: FUNC
3213  */
3214 HWTEST_F(FrameNodeTestNg, UpdateIgnoreCountTest001, TestSize.Level1)
3215 {
3216     auto parent = FrameNode::CreateFrameNode("parent", 1, AceType::MakeRefPtr<Pattern>(), true);
3217     parent->SetActive(true);
3218     auto node = FrameNode::CreateFrameNode("node", 2, AceType::MakeRefPtr<Pattern>(), false);
3219     node->SetActive(true);
3220     node->MountToParent(parent);
3221 
3222     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), false);
3223     node->UpdateIgnoreCount(2);
3224     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), true);
3225 }
3226 
3227 /**
3228  * @tc.name: UpdateIgnoreCountTest002
3229  * @tc.desc: Test UpdateIgnoreCount when MountToParent.
3230  * @tc.type: FUNC
3231  */
3232 HWTEST_F(FrameNodeTestNg, UpdateIgnoreCountTest002, TestSize.Level1)
3233 {
3234     auto parent = FrameNode::CreateFrameNode("parent", 1, AceType::MakeRefPtr<Pattern>(), true);
3235     parent->SetActive(true);
3236     auto node = FrameNode::CreateFrameNode("node", 2, AceType::MakeRefPtr<Pattern>(), false);
3237     node->SetActive(true);
3238 
3239     node->UpdateIgnoreCount(2);
3240     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), false);
3241     node->MountToParent(parent);
3242     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), true);
3243 }
3244 
3245 /**
3246  * @tc.name: UpdateIgnoreCountTest003
3247  * @tc.desc: Test UpdateIgnoreCount when RemoveChild.
3248  * @tc.type: FUNC
3249  */
3250 HWTEST_F(FrameNodeTestNg, UpdateIgnoreCountTest003, TestSize.Level1)
3251 {
3252     auto parent = FrameNode::CreateFrameNode("parent", 1, AceType::MakeRefPtr<Pattern>(), true);
3253     parent->SetActive(true);
3254     auto node = FrameNode::CreateFrameNode("node", 2, AceType::MakeRefPtr<Pattern>(), false);
3255     node->SetActive(true);
3256     node->MountToParent(parent);
3257     node->UpdateIgnoreCount(2);
3258 
3259     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), true);
3260     parent->RemoveChild(node);
3261     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), true);
3262     parent->TraverseForIgnore();
3263     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), false);
3264 }
3265 
3266 /**
3267  * @tc.name: UpdateIgnoreCountTest004
3268  * @tc.desc: Test UpdateIgnoreCount when SetActive.
3269  * @tc.type: FUNC
3270  */
3271 HWTEST_F(FrameNodeTestNg, UpdateIgnoreCountTest004, TestSize.Level1)
3272 {
3273     auto parent = FrameNode::CreateFrameNode("parent", 1, AceType::MakeRefPtr<Pattern>(), true);
3274     parent->SetActive(true);
3275     auto node = FrameNode::CreateFrameNode("node", 2, AceType::MakeRefPtr<Pattern>(), false);
3276     node->SetActive(true);
3277     node->MountToParent(parent);
3278     node->UpdateIgnoreCount(2);
3279 
3280     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), true);
3281     node->SetActive(false);
3282     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), false);
3283     node->SetActive(true);
3284     EXPECT_EQ(parent->SubtreeWithIgnoreChild(), true);
3285 }
3286 
3287 /**
3288  * @tc.name: TestPreMeasure
3289  * @tc.desc: Test PreMeasure.
3290  * @tc.type: FUNC
3291  */
3292 HWTEST_F(FrameNodeTestNg, TestPreMeasure, TestSize.Level1)
3293 {
3294     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3295     EXPECT_EQ(frameNode->PreMeasure(LayoutConstraintF()), false);
3296     frameNode->SetIgnoreLayoutProcess(true);
3297     frameNode->SetHasPreMeasured();
3298     EXPECT_EQ(frameNode->PreMeasure(LayoutConstraintF()), false);
3299     frameNode->SetEscapeDelayForIgnore(true);
3300     EXPECT_EQ(frameNode->PreMeasure(LayoutConstraintF()), false);
3301 }
3302 
3303 /**
3304  * @tc.name: FrameNodeSetCustomPropertyMapFlagByKey001
3305  * @tc.desc: Test SetCustomPropertyMapFlagByKey.
3306  * @tc.type: FUNC
3307  */
3308 HWTEST_F(FrameNodeTestNg, FrameNodeSetCustomPropertyMapFlagByKey001, TestSize.Level1)
3309 {
3310     /**
3311      * @tc.steps: step1. create frameNode.
3312      * @tc.expected: expect is not nullptr.
3313      */
3314     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3315     EXPECT_NE(frameNode, nullptr);
3316 
3317     /**
3318      * @tc.steps: step2. SetCustomPropertyMapFlagByKey.
3319      * @tc.expected: expect result true, value empty and flag 0.
3320      */
3321     frameNode->setIsCNode(true);
3322     frameNode->SetCustomPropertyMapFlagByKey("key");
3323     std::string value;
3324     bool result = frameNode->GetCapiCustomProperty("key", value);
3325     std::string flagValue = frameNode->customPropertyMap_["key"][1];
3326     EXPECT_TRUE(result);
3327     EXPECT_EQ(value, "");
3328     EXPECT_EQ(flagValue, "0");
3329 
3330     /**
3331      * @tc.steps: step2. SetCustomPropertyMapFlagByKey.
3332      * @tc.expected: expect result true, value not empty and flag right.
3333      */
3334     frameNode->AddCustomProperty("key1", "value1");
3335     std::string value1;
3336     bool result1 = frameNode->GetCapiCustomProperty("key1", value1);
3337     std::string flagValue1 = frameNode->customPropertyMap_["key1"][1];
3338     EXPECT_TRUE(result1);
3339     EXPECT_EQ(value1, "value1");
3340     EXPECT_EQ(flagValue1, "1");
3341     frameNode->SetCustomPropertyMapFlagByKey("key1");
3342     result1 = frameNode->GetCapiCustomProperty("key1", value1);
3343     flagValue1 = frameNode->customPropertyMap_["key1"][1];
3344     EXPECT_TRUE(result1);
3345     EXPECT_EQ(value1, "value1");
3346     EXPECT_EQ(flagValue1, "0");
3347 }
3348 
3349 /**
3350  * @tc.name: FrameNodeIsJsCustomPropertyUpdated001
3351  * @tc.desc: Test IsJsCustomPropertyUpdated.
3352  * @tc.type: FUNC
3353  */
3354 HWTEST_F(FrameNodeTestNg, FrameNodeIsJsCustomPropertyUpdated001, TestSize.Level1)
3355 {
3356     /**
3357      * @tc.steps: step1. create frameNode.
3358      * @tc.expected: expect is not nullptr.
3359      */
3360     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3361     EXPECT_NE(frameNode, nullptr);
3362 
3363     /**
3364      * @tc.steps: step2. customPropertyMap_ is empty, test IsJsCustomPropertyUpdated.
3365      * @tc.expected: expect result true.
3366      */
3367     bool result = frameNode->IsJsCustomPropertyUpdated();
3368     EXPECT_TRUE(result);
3369 
3370     /**
3371      * @tc.steps: step2. frameNode has one customProperty and flag 1.
3372      * @tc.expected: expect result true.
3373      */
3374     frameNode->AddCustomProperty("key", "value");
3375     result = frameNode->IsJsCustomPropertyUpdated();
3376     EXPECT_TRUE(result);
3377 
3378     /**
3379      * @tc.steps: step3. frameNode has another customProperty and flag 0.
3380      * @tc.expected: expect result false.
3381      */
3382     frameNode->AddCustomProperty("key1", "value1");
3383     frameNode->SetCustomPropertyMapFlagByKey("key1");
3384     result = frameNode->IsJsCustomPropertyUpdated();
3385     EXPECT_FALSE(result);
3386 }
3387 
3388 /**
3389  * @tc.name: FrameNodeUpdateBackground001
3390  * @tc.desc: Test UpdateBackground.
3391  * @tc.type: FUNC
3392  */
3393 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateBackground001, TestSize.Level1)
3394 {
3395     /**
3396      * @tc.steps: step1. create frameNode.
3397      * @tc.expected: expect is not nullptr.
3398      */
3399     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3400     ASSERT_NE(frameNode, nullptr);
3401     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
3402     frameNode->renderContext_ = mockRenderContext;
__anonc0fd8ca62002() 3403     std::function<RefPtr<UINode>()> func = []() -> RefPtr<UINode> {
3404         return FrameNode::CreateFrameNode("backgroundNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3405     };
3406     frameNode->builderFunc_ = func;
3407 
3408     /**
3409      * @tc.steps: step2. do not set the BuilderBackgroundFlag.
3410      * @tc.expected: do nothing.
3411      */
3412     EXPECT_CALL(*mockRenderContext, UpdateCustomBackground()).Times(0);
3413     frameNode->UpdateBackground();
3414     EXPECT_NE(frameNode->builderFunc_, nullptr);
3415 }
3416 
3417 /**
3418  * @tc.name: FrameNodeUpdateBackground002
3419  * @tc.desc: Test UpdateBackground.
3420  * @tc.type: FUNC
3421  */
3422 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateBackground002, TestSize.Level1)
3423 {
3424     /**
3425      * @tc.steps: step1. create frameNode.
3426      * @tc.expected: expect is not nullptr.
3427      */
3428     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3429     ASSERT_NE(frameNode, nullptr);
3430     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
3431     frameNode->renderContext_ = mockRenderContext;
__anonc0fd8ca62102() 3432     std::function<RefPtr<UINode>()> func = []() -> RefPtr<UINode> {
3433         return FrameNode::CreateFrameNode("backgroundNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3434     };
3435     frameNode->builderFunc_ = func;
3436 
3437     /**
3438      * @tc.steps: step2. set the BuilderBackgroundFlag to false.
3439      * @tc.expected: UpdateCustomBackground function is called.
3440      */
3441     EXPECT_CALL(*mockRenderContext, UpdateCustomBackground()).Times(1);
3442     mockRenderContext->UpdateBuilderBackgroundFlag(false);
3443     frameNode->UpdateBackground();
3444 }
3445 
3446 /**
3447  * @tc.name: FrameNodeUpdateBackground003
3448  * @tc.desc: Test UpdateBackground.
3449  * @tc.type: FUNC
3450  */
3451 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateBackground003, TestSize.Level1)
3452 {
3453     /**
3454      * @tc.steps: step1. create frameNode.
3455      * @tc.expected: expect is not nullptr.
3456      */
3457     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3458     ASSERT_NE(frameNode, nullptr);
3459     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
3460     frameNode->renderContext_ = mockRenderContext;
__anonc0fd8ca62202() 3461     std::function<RefPtr<UINode>()> func = []() -> RefPtr<UINode> {
3462         return FrameNode::CreateFrameNode("backgroundNode", 1, AceType::MakeRefPtr<Pattern>(), true);
3463     };
3464     frameNode->builderFunc_ = func;
3465 
3466     /**
3467      * @tc.steps: step2. set the BuilderBackgroundFlag to true.
3468      * @tc.expected: frameNode->builderFunc_ is nullptr.
3469      */
3470     mockRenderContext->UpdateBuilderBackgroundFlag(true);
3471     frameNode->UpdateBackground();
3472     EXPECT_EQ(frameNode->builderFunc_, nullptr);
3473 }
3474 
3475 /**
3476  * @tc.name: FrameNodeUpdateBackground004
3477  * @tc.desc: Test UpdateBackground.
3478  * @tc.type: FUNC
3479  */
3480 HWTEST_F(FrameNodeTestNg, FrameNodeUpdateBackground004, TestSize.Level1)
3481 {
3482     /**
3483      * @tc.steps: step1. create frameNode.
3484      * @tc.expected: expect is not nullptr.
3485      */
3486     auto frameNode = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3487     ASSERT_NE(frameNode, nullptr);
3488     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
3489     frameNode->renderContext_ = mockRenderContext;
3490 
3491     /**
3492      * @tc.steps: step4. set the BuilderBackgroundFlag to true while frameNode->builderFunc_ is nullptr.
3493      * @tc.expected: do nothing.
3494      */
3495     EXPECT_CALL(*mockRenderContext, UpdateCustomBackground()).Times(0);
3496     mockRenderContext->UpdateBuilderBackgroundFlag(true);
3497     frameNode->builderFunc_ = nullptr;
3498     frameNode->backgroundNode_ = nullptr;
3499     frameNode->UpdateBackground();
3500     EXPECT_EQ(frameNode->backgroundNode_, nullptr);
3501 }
3502 
3503 /**
3504  * @tc.name: AttachContext010
3505  * @tc.desc: Test frame node method
3506  * @tc.type: FUNC
3507  */
3508 HWTEST_F(FrameNodeTestNg, AttachContext010, TestSize.Level1)
3509 {
3510     auto context = PipelineContext::GetCurrentContext();
3511     ASSERT_NE(context, nullptr);
3512     auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr<Pattern>(), true);
3513     ASSERT_NE(node, nullptr);
3514     node->GetOrCreateGestureEventHub();
3515     SystemProperties::multiInstanceEnabled_ = true;
3516     node->isDeleteRsNode_ = false;
3517     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
3518     node->renderContext_ = mockRenderContext;
3519     node->AttachContext(AceType::RawPtr(context));
3520     SystemProperties::multiInstanceEnabled_ = false;
3521     EXPECT_EQ(node->context_, AceType::RawPtr(context));
3522 }
3523 } // namespace OHOS::Ace::NG