• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "test/unittest/core/event/drag_event_test_ng.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS::Ace::NG {
22 /**
23  * @tc.name: DragEventActuatorRestartDragTaskTest001
24  * @tc.desc: Test RestartDragTask function.
25  * @tc.type: FUNC
26  */
27 HWTEST_F(DragEventTestNg, DragEventActuatorRestartDragTaskTest001, TestSize.Level1)
28 {
29     /**
30      * @tc.steps: step1. Create DragEventActuator.
31      */
32     auto eventHub = AceType::MakeRefPtr<EventHub>();
33     ASSERT_NE(eventHub, nullptr);
34     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
35     ASSERT_NE(framenode, nullptr);
36     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
37     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
38     ASSERT_NE(gestureEventHub, nullptr);
39     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
40         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
41     ASSERT_NE(dragEventActuator, nullptr);
42 
43     /**
44      * @tc.steps: step2. Execute RestartDragTask when actionStart_ is null.
45      */
46     auto info = GestureEvent();
47     dragEventActuator->RestartDragTask(info);
48     ASSERT_EQ(dragEventActuator->actionStart_, nullptr);
49 
50     /**
51      * @tc.steps: step3. Execute RestartDragTask when actionStart_ is not null.
52      */
53 
54     int unknownPropertyValue = UNKNOWN;
__anonfd430c6c0102(GestureEvent& gestureInfo) 55     dragEventActuator->actionStart_ = [&unknownPropertyValue](GestureEvent& gestureInfo) mutable {
56         unknownPropertyValue++;
57     };
58     dragEventActuator->RestartDragTask(info);
59     ASSERT_NE(unknownPropertyValue, UNKNOWN);
60 }
61 
62 /**
63  * @tc.name: DragEventActuatorDragingStatusTest001
64  * @tc.desc: Test IsGlobalStatusSuitableForDragging and IsCurrentCodeStatusSuitableForDragging function.
65  * @tc.type: FUNC
66  */
67 HWTEST_F(DragEventTestNg, DragEventActuatorDragingStatusTest001, TestSize.Level1)
68 {
69     /**
70      * @tc.steps: step1. Create DragEventActuator.
71      */
72     auto eventHub = AceType::MakeRefPtr<EventHub>();
73     ASSERT_NE(eventHub, nullptr);
74     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
75     ASSERT_NE(framenode, nullptr);
76     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
77     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
78     ASSERT_NE(gestureEventHub, nullptr);
79     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
80         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
81     ASSERT_NE(dragEventActuator, nullptr);
82 
83     /**
84      * @tc.steps: step2. Execute IsGlobalStatusSuitableForDragging.
85      */
86     auto pipeline = PipelineContext::GetCurrentContext();
87     CHECK_NULL_VOID(pipeline);
88     auto dragDropManager = pipeline->GetDragDropManager();
89     CHECK_NULL_VOID(dragDropManager);
90     dragDropManager->ResetDragging(DragDropMgrState::DRAGGING);
91     auto globalStatus = DragDropFuncWrapper::IsGlobalStatusSuitableForDragging();
92     ASSERT_EQ(globalStatus, false);
93 
94     /**
95      * @tc.steps: step3. Execute IsCurrentNodeStatusSuitableForDragging.
96      */
97     TouchRestrict dragTouchRestrict = { TouchRestrict::CLICK };
98     dragTouchRestrict.inputEventType = InputEventType::AXIS;
99     auto nodeStatus = dragEventActuator->IsCurrentNodeStatusSuitableForDragging(framenode, dragTouchRestrict);
100     ASSERT_EQ(nodeStatus, false);
101 }
102 
103 /**
104  * @tc.name: DragEventActuatorSetDragDampStartPointInfoTest001
105  * @tc.desc: Test SetDragDampStartPointInfo function.
106  * @tc.type: FUNC
107  */
108 HWTEST_F(DragEventTestNg, DragEventActuatorSetDragDampStartPointInfoTest001, TestSize.Level1)
109 {
110     /**
111      * @tc.steps: step1. Create DragEventActuator.
112      */
113     auto eventHub = AceType::MakeRefPtr<EventHub>();
114     ASSERT_NE(eventHub, nullptr);
115     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
116     ASSERT_NE(framenode, nullptr);
117     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
118     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
119     ASSERT_NE(gestureEventHub, nullptr);
120     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
121         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
122     ASSERT_NE(dragEventActuator, nullptr);
123 
124     /**
125      * @tc.steps: step2. Invoke SetDragDampStartPointInfo.
126      * @tc.expected: cover SetDragDampStartPointInfo.
127      */
128     GestureEvent info = GestureEvent();
129     dragEventActuator->SetDragDampStartPointInfo(info.GetGlobalPoint(), info.GetPointerId());
130     auto pipeline = PipelineContext::GetCurrentContext();
131     CHECK_NULL_VOID(pipeline);
132     auto dragDropManager = pipeline->GetDragDropManager();
133     CHECK_NULL_VOID(dragDropManager);
134     ASSERT_EQ(dragDropManager->currentPointerId_, info.GetPointerId());
135 }
136 
137 /**
138  * @tc.name: DragEventActuatorHandleDragDampingMoveTest001
139  * @tc.desc: Test HandleDragDampingMove function.
140  * @tc.type: FUNC
141  */
142 HWTEST_F(DragEventTestNg, DragEventActuatorHandleDragDampingMoveTest001, TestSize.Level1)
143 {
144     /**
145      * @tc.steps: step1. Create DragEventActuator.
146      */
147     auto eventHub = AceType::MakeRefPtr<EventHub>();
148     ASSERT_NE(eventHub, nullptr);
149     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
150     ASSERT_NE(framenode, nullptr);
151     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
152     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
153     ASSERT_NE(gestureEventHub, nullptr);
154     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
155         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
156     ASSERT_NE(dragEventActuator, nullptr);
157 
158     /**
159      * @tc.steps: step2. Invoke DragDampingMove with DragDropMgrState::IDLE and same Pointer.
160      * @tc.expected: cover DragDampingMove.
161      */
162     auto pipeline = PipelineContext::GetCurrentContext();
163     CHECK_NULL_VOID(pipeline);
164     auto dragDropManager = pipeline->GetDragDropManager();
165     CHECK_NULL_VOID(dragDropManager);
166     TouchEventInfo info(TOUCH_EVENT_INFO_TYPE);
167     auto point = Point(info.GetTouches().front().GetGlobalLocation().GetX(),
168                        info.GetTouches().front().GetGlobalLocation().GetY());
169     dragDropManager->SetDraggingPointer(info.GetTouches().front().GetFingerId());
170     dragDropManager->ResetDragging(DragDropMgrState::IDLE);
171     dragEventActuator->HandleDragDampingMove(point, info.GetTouches().front().GetFingerId());
172     ASSERT_FALSE(dragDropManager->IsAboutToPreview());
173     ASSERT_FALSE(dragDropManager->IsDragging());
174     EXPECT_FALSE(!dragDropManager->IsSameDraggingPointer(info.GetTouches().front().GetFingerId()));
175 
176     /**
177      * @tc.steps: step3. Invoke DragDampingMove with DragDropMgrState::DRAGGING and same Pointer.
178      * @tc.expected: cover DragDampingMove.
179      */
180     dragDropManager->ResetDragging(DragDropMgrState::DRAGGING);
181     dragEventActuator->HandleDragDampingMove(point, info.GetTouches().front().GetFingerId());
182     EXPECT_FALSE(dragDropManager->IsAboutToPreview());
183     EXPECT_TRUE(dragDropManager->IsDragging());
184     EXPECT_FALSE(!dragDropManager->IsSameDraggingPointer(info.GetTouches().front().GetFingerId()));
185 
186     /**
187      * @tc.steps: step4. Invoke DragDampingMove with DragDropMgrState::ABOUT_TO_PREVIEW and same Pointer.
188      * @tc.expected: cover DragDampingMove.
189      */
190     dragDropManager->ResetDragging(DragDropMgrState::ABOUT_TO_PREVIEW);
191     dragEventActuator->HandleDragDampingMove(point, info.GetTouches().front().GetFingerId());
192     EXPECT_TRUE(dragDropManager->IsAboutToPreview());
193     EXPECT_FALSE(dragDropManager->IsDragging());
194     EXPECT_FALSE(!dragDropManager->IsSameDraggingPointer(info.GetTouches().front().GetFingerId()));
195 
196     /**
197      * @tc.steps: step5. Invoke DragDampingMove.
198      * @tc.expected: cover DragDampingMove.
199      */
200     dragDropManager->ResetDragging(DragDropMgrState::IDLE);
201     point.SetX(10.0);
202     point.SetY(10.0);
203     dragEventActuator->HandleDragDampingMove(point, info.GetTouches().front().GetFingerId());
204     auto startPoint = dragDropManager->GetDragDampStartPoint();
205     auto delta = Point(point.GetX(), point.GetY()) - startPoint;
206     auto distance = SystemProperties::GetDragStartPanDistanceThreshold();
207     EXPECT_TRUE(delta.GetDistance() > Dimension(distance, DimensionUnit::VP).ConvertToPx());
208 
209     point.SetX(1.0);
210     point.SetY(1.0);
211     dragEventActuator->HandleDragDampingMove(point, info.GetTouches().front().GetFingerId());
212     startPoint = dragDropManager->GetDragDampStartPoint();
213     delta = Point(point.GetX(), point.GetY()) - startPoint;
214     distance = SystemProperties::GetDragStartPanDistanceThreshold();
215     EXPECT_TRUE(delta.GetDistance() < Dimension(distance, DimensionUnit::VP).ConvertToPx());
216 }
217 
218 /**
219  * @tc.name: DragEventActuatorUpdatePreviewAttrTest001
220  * @tc.desc: Test UpdatePreviewAttr function.
221  * @tc.type: FUNC
222  */
223 HWTEST_F(DragEventTestNg, DragEventActuatorUpdatePreviewAttrTest001, TestSize.Level1)
224 {
225     /**
226      * @tc.steps: step1. Create DragEventActuator.
227      */
228     auto eventHub = AceType::MakeRefPtr<EventHub>();
229     ASSERT_NE(eventHub, nullptr);
230     auto frameNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), false);
231     ASSERT_NE(frameNode, nullptr);
232     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
233     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
234     ASSERT_NE(gestureEventHub, nullptr);
235     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
236         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
237     ASSERT_NE(dragEventActuator, nullptr);
238 
239     /**
240      * @tc.steps: step2. Invoke UpdatePreviewAttr.
241      * @tc.expected: cover UpdatePreviewAttr with TextDraggable true.
242      */
243     auto frameTag = frameNode->GetTag();
244     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
245     EXPECT_NE(gestureHub, nullptr);
246     auto imageNode = FrameNode::GetOrCreateFrameNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
__anonfd430c6c0202() 247         []() { return AceType::MakeRefPtr<ImagePattern>(); });
248     EXPECT_NE(imageNode, nullptr);
249     gestureHub->SetTextDraggable(true);
250     dragEventActuator->UpdatePreviewAttr(frameNode, imageNode);
251     EXPECT_TRUE(gestureHub->IsTextCategoryComponent(frameTag));
252     EXPECT_TRUE(gestureHub->GetTextDraggable());
253 }
254 
255 /**
256  * @tc.name: DragEventActuatorSetPixelMapTest001
257  * @tc.desc: Test SetPixelMap function.
258  * @tc.type: FUNC
259  */
260 HWTEST_F(DragEventTestNg, DragEventActuatorSetPixelMapTest001, TestSize.Level1)
261 {
262     /**
263      * @tc.steps: step1. Create DragEventActuator.
264      */
265     auto eventHub = AceType::MakeRefPtr<EventHub>();
266     ASSERT_NE(eventHub, nullptr);
267     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
268     ASSERT_NE(framenode, nullptr);
269     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
270     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
271     ASSERT_NE(gestureEventHub, nullptr);
272     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
273         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
274     ASSERT_NE(dragEventActuator, nullptr);
275 
276     /**
277      * @tc.steps: step2. Invoke SetHasPixelMap.
278      * @tc.desc: GetHasPixelMap true.
279      */
280     auto pipelineContext = PipelineContext::GetCurrentContext();
281     ASSERT_NE(pipelineContext, nullptr);
282     auto manager = pipelineContext->GetOverlayManager();
283     ASSERT_NE(manager, nullptr);
284     manager->SetHasPixelMap(true);
285     dragEventActuator->SetPixelMap(dragEventActuator);
286     ASSERT_TRUE(manager->GetHasPixelMap());
287 }
288 
289 /**
290  * @tc.name: DragEventActuatorBlurStyleToEffectionTest001
291  * @tc.desc: Test BlurStyleToEffection function.
292  * @tc.type: FUNC
293  */
294 HWTEST_F(DragEventTestNg, DragEventActuatorBlurStyleToEffectionTest001, TestSize.Level1)
295 {
296     /**
297      * @tc.steps: step1. Create DragEventActuator.
298      */
299     auto eventHub = AceType::MakeRefPtr<EventHub>();
300     ASSERT_NE(eventHub, nullptr);
301     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
302     ASSERT_NE(frameNode, nullptr);
303     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
304     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
305     ASSERT_NE(gestureEventHub, nullptr);
306     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
307         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
308     ASSERT_NE(dragEventActuator, nullptr);
309 
310     /**
311      * @tc.steps: step2. Invoke BlurStyleToEffection.
312      */
313     auto imageNode = FrameNode::GetOrCreateFrameNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
__anonfd430c6c0302() 314         []() { return AceType::MakeRefPtr<ImagePattern>(); });
315     ASSERT_NE(imageNode, nullptr);
316     auto imageContext = imageNode->GetRenderContext();
317     ASSERT_NE(imageContext, nullptr);
318     auto blurstyletmp = imageContext->GetBackBlurStyle();
319     blurstyletmp->colorMode = ThemeColorMode::DARK;
320     DragDropFuncWrapper::BlurStyleToEffection(blurstyletmp);
321     ASSERT_NE(blurstyletmp->colorMode, ThemeColorMode::SYSTEM);
322 }
323 
324 /**
325  * @tc.name: DragEventActuatorHidePixelMapTest001
326  * @tc.desc: Test HidePixelMap function.
327  * @tc.type: FUNC
328  */
329 HWTEST_F(DragEventTestNg, DragEventActuatorHidePixelMapTest001, TestSize.Level1)
330 {
331     /**
332      * @tc.steps: step1. Create DragEventActuator.
333      */
334     auto eventHub = AceType::MakeRefPtr<EventHub>();
335     ASSERT_NE(eventHub, nullptr);
336     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
337     ASSERT_NE(frameNode, nullptr);
338     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
339     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
340     ASSERT_NE(gestureEventHub, nullptr);
341     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
342         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
343     ASSERT_NE(dragEventActuator, nullptr);
344 
345     /**
346      * @tc.steps: step2. Invoke HidePixelMap.
347      */
348     auto pipelineContext = PipelineContext::GetCurrentContext();
349     ASSERT_NE(pipelineContext, nullptr);
350     auto manager = pipelineContext->GetOverlayManager();
351     EXPECT_NE(manager, nullptr);
352     dragEventActuator->HidePixelMap(true, 0, 0, false);
353     EXPECT_FALSE(manager->hasPixelMap_);
354 }
355 
356 /**
357  * @tc.name: DragEventActuatorSetTextPixelMapTest001
358  * @tc.desc: Test SetTextPixelMap function.
359  * @tc.type: FUNC
360  */
361 HWTEST_F(DragEventTestNg, DragEventActuatorSetTextPixelMapTest001, TestSize.Level1)
362 {
363     /**
364      * @tc.steps: step1. Create DragEventActuator.
365      */
366     auto eventHub = AceType::MakeRefPtr<EventHub>();
367     ASSERT_NE(eventHub, nullptr);
368     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
369     ASSERT_NE(frameNode, nullptr);
370     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
371     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
372     ASSERT_NE(gestureEventHub, nullptr);
373     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
374         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
375     ASSERT_NE(dragEventActuator, nullptr);
376 
377     /**
378      * @tc.steps: step2. Invoke HidePixelMap.
379      */
380     dragEventActuator->SetTextPixelMap(gestureEventHub);
381     EXPECT_EQ(dragEventActuator->textPixelMap_, nullptr);
382 }
383 
384 /**
385  * @tc.name: DragEventActuatorSetImageNodeInitAttrTest001
386  * @tc.desc: Test SetImageNodeInitAttr function.
387  * @tc.type: FUNC
388  */
389 HWTEST_F(DragEventTestNg, DragEventActuatorSetImageNodeInitAttrTest001, TestSize.Level1)
390 {
391     /**
392      * @tc.steps: step1. Create DragEventActuator.
393      */
394     auto eventHub = AceType::MakeRefPtr<EventHub>();
395     ASSERT_NE(eventHub, nullptr);
396     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
397     ASSERT_NE(frameNode, nullptr);
398     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
399     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
400     ASSERT_NE(gestureEventHub, nullptr);
401     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
402         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
403     ASSERT_NE(dragEventActuator, nullptr);
404 
405     /**
406      * @tc.steps: step2. Invoke SetImageNodeInitAttr.
407      * @tc.desc: defaultAnimationBeforeLifting = true, layoutProperty != nullptr.
408      */
409     auto imageNode = FrameNode::GetOrCreateFrameNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
__anonfd430c6c0402() 410         []() { return AceType::MakeRefPtr<ImagePattern>(); });
411     EXPECT_NE(imageNode, nullptr);
412     auto imageContext = imageNode->GetRenderContext();
413     EXPECT_NE(imageContext, nullptr);
414     auto dragPreviewOption = frameNode->GetDragPreviewOption();
415     dragPreviewOption.defaultAnimationBeforeLifting = true;
416     auto layoutProperty = frameNode->GetLayoutProperty();
417     auto shadow = Shadow::CreateShadow(ShadowStyle::None);
418 
419     DragAnimationHelper::SetImageNodeInitAttr(frameNode, imageNode);
420     EXPECT_TRUE(dragPreviewOption.defaultAnimationBeforeLifting);
421     EXPECT_NE(layoutProperty, nullptr);
422     EXPECT_FALSE(dragPreviewOption.options.shadow.has_value());
423 
424     /**
425      * @tc.steps: step3. Invoke SetImageNodeInitAttr.
426      * @tc.desc: defaultAnimationBeforeLifting = true, layoutProperty = nullptr.
427      */
428     frameNode->layoutProperty_ = nullptr;
429     DragAnimationHelper::SetImageNodeInitAttr(frameNode, imageNode);
430     EXPECT_EQ(frameNode->GetLayoutProperty(), nullptr);
431 
432     /**
433      * @tc.steps: step3. Invoke SetImageNodeInitAttr.
434      * @tc.desc: defaultAnimationBeforeLifting = false, layoutProperty = nullptr.
435      */
436     dragPreviewOption.defaultAnimationBeforeLifting = false;
437     DragAnimationHelper::SetImageNodeInitAttr(frameNode, imageNode);
438     EXPECT_FALSE(dragPreviewOption.defaultAnimationBeforeLifting);
439 
440     /**
441      * @tc.steps: step3. Invoke SetImageNodeInitAttr.
442      * @tc.desc: dragPreviewOption.options.shadow.has_value() = true.
443      */
444     dragPreviewOption.options.shadow = Shadow::CreateShadow(ShadowStyle::OuterDefaultXS);
445     DragAnimationHelper::SetImageNodeInitAttr(frameNode, imageNode);
446     EXPECT_TRUE(dragPreviewOption.options.shadow.has_value());
447 }
448 
449 /**
450  * @tc.name: DragEventActuatorSetImageNodeFinishAttrTest001
451  * @tc.desc: Test SetImageNodeFinishAttr function.
452  * @tc.type: FUNC
453  */
454 HWTEST_F(DragEventTestNg, DragEventActuatorSetImageNodeFinishAttrTest001, TestSize.Level1)
455 {
456     /**
457      * @tc.steps: step1. Create DragEventActuator.
458      */
459     auto eventHub = AceType::MakeRefPtr<EventHub>();
460     ASSERT_NE(eventHub, nullptr);
461     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
462     ASSERT_NE(frameNode, nullptr);
463     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
464     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
465     ASSERT_NE(gestureEventHub, nullptr);
466     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
467         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
468     ASSERT_NE(dragEventActuator, nullptr);
469 
470     /**
471      * @tc.steps: step2. Invoke SetImageNodeFinishAttr.
472      */
473     auto imageNode = FrameNode::GetOrCreateFrameNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
__anonfd430c6c0502() 474         []() { return AceType::MakeRefPtr<ImagePattern>(); });
475     EXPECT_NE(imageNode, nullptr);
476     auto imageContext = imageNode->GetRenderContext();
477     EXPECT_NE(imageContext, nullptr);
478     auto dragPreviewOption = frameNode->GetDragPreviewOption();
479 
480     DragAnimationHelper::SetImageNodeFinishAttr(frameNode, imageNode);
481     EXPECT_FALSE(dragPreviewOption.options.shadow->GetIsFilled());
482     EXPECT_FALSE(dragPreviewOption.options.shadow.has_value());
483 
484     /**
485      * @tc.steps: step3. Invoke SetImageNodeFinishAttr.
486      */
487     dragPreviewOption.options.shadow->isFilled_ = true;
488     DragAnimationHelper::SetImageNodeFinishAttr(frameNode, imageNode);
489     EXPECT_TRUE(dragPreviewOption.options.shadow->GetIsFilled());
490     EXPECT_FALSE(dragPreviewOption.options.shadow.has_value());
491 
492     /**
493      * @tc.steps: step4. Invoke SetImageNodeFinishAttr.
494      */
495     dragPreviewOption.options.shadow = Shadow::CreateShadow(ShadowStyle::OuterDefaultXS);
496     dragPreviewOption.options.shadow->isFilled_ = false;
497     DragAnimationHelper::SetImageNodeFinishAttr(frameNode, imageNode);
498     EXPECT_FALSE(dragPreviewOption.options.shadow->GetIsFilled());
499     EXPECT_TRUE(dragPreviewOption.options.shadow.has_value());
500 
501     /**
502      * @tc.steps: step5. Invoke SetImageNodeFinishAttr.
503      */
504     dragPreviewOption.options.shadow = Shadow::CreateShadow(ShadowStyle::OuterDefaultXS);
505     dragPreviewOption.options.shadow->isFilled_ = true;
506     DragAnimationHelper::SetImageNodeFinishAttr(frameNode, imageNode);
507     EXPECT_TRUE(dragPreviewOption.options.shadow->GetIsFilled());
508     EXPECT_TRUE(dragPreviewOption.options.shadow.has_value());
509 }
510 
511 /**
512  * @tc.name: DragEventActuatorGetOrCreateGatherNodeTest001
513  * @tc.desc: Test GetOrCreateGatherNode function.
514  * @tc.type: FUNC
515  */
516 HWTEST_F(DragEventTestNg, DragEventActuatorGetOrCreateGatherNodeTest001, TestSize.Level1)
517 {
518     /**
519      * @tc.steps: step1. Create DragEventActuator.
520      */
521     auto eventHub = AceType::MakeRefPtr<EventHub>();
522     ASSERT_NE(eventHub, nullptr);
523     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
524     ASSERT_NE(frameNode, nullptr);
525     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
526     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
527     ASSERT_NE(gestureEventHub, nullptr);
528     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
529         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
530     ASSERT_NE(dragEventActuator, nullptr);
531 
532     /**
533      * @tc.steps: step2. Invoke GetOrCreateGatherNode with dragEventActuator->IsNeedGather() false.
534      */
535     std::vector<GatherNodeChildInfo> gatherNodeChildInfo(2);
536     auto pipeline = PipelineContext::GetCurrentContext();
537     auto overlayManager = pipeline->GetOverlayManager();
538     EXPECT_NE(overlayManager, nullptr);
539     auto gatherNode = dragEventActuator->GetOrCreateGatherNode(overlayManager, dragEventActuator, gatherNodeChildInfo);
540     EXPECT_EQ(gatherNode, nullptr);
541 }
542 
543 /**
544  * @tc.name: DragEventActuatorResetNodeTest001
545  * @tc.desc: Test ResetNode function.
546  * @tc.type: FUNC
547  */
548 HWTEST_F(DragEventTestNg, DragEventActuatorResetNodeTest001, TestSize.Level1)
549 {
550     /**
551      * @tc.steps: step1. Create DragEventActuator.
552      */
553     auto eventHub = AceType::MakeRefPtr<EventHub>();
554     ASSERT_NE(eventHub, nullptr);
555     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
556     ASSERT_NE(frameNode, nullptr);
557     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
558     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
559     ASSERT_NE(gestureEventHub, nullptr);
560     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
561         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
562     ASSERT_NE(dragEventActuator, nullptr);
563 
564     /**
565      * @tc.steps: step2. Invoke ResetNode.
566      */
567     auto dragPreviewOption = frameNode->GetDragPreviewOption();
568     dragPreviewOption.defaultAnimationBeforeLifting = false;
569     DragDropFuncWrapper::ResetNode(frameNode);
570     dragPreviewOption = frameNode->GetDragPreviewOption();
571     EXPECT_FALSE(dragPreviewOption.defaultAnimationBeforeLifting);
572 
573     /**
574      * @tc.steps: step3. Invoke ResetNode.
575      */
576     dragPreviewOption.defaultAnimationBeforeLifting = true;
577     frameNode->layoutProperty_ = nullptr;
578     DragDropFuncWrapper::ResetNode(frameNode);
579     EXPECT_EQ(frameNode->GetLayoutProperty(), nullptr);
580 }
581 
582 /**
583  * @tc.name: DragEventActuatorHandleTouchUpEventTest001
584  * @tc.desc: Test HandleTouchUpEvent function.
585  * @tc.type: FUNC
586  */
587 HWTEST_F(DragEventTestNg, DragEventActuatorHandleTouchUpEventTest001, TestSize.Level1)
588 {
589     /**
590      * @tc.steps: step1. Create DragEventActuator.
591      */
592     auto eventHub = AceType::MakeRefPtr<EventHub>();
593     ASSERT_NE(eventHub, nullptr);
594     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
595     ASSERT_NE(frameNode, nullptr);
596     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
597     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
598     ASSERT_NE(gestureEventHub, nullptr);
599     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
600         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
601     ASSERT_NE(dragEventActuator, nullptr);
602 
603     /**
604      * @tc.steps: step2. Invoke HandleTouchUpEvent.
605      */
606     dragEventActuator->HandleTouchUpEvent();
607     auto pipelineContext = PipelineContext::GetCurrentContext();
608     EXPECT_NE(pipelineContext, nullptr);
609     auto dragDropManager = pipelineContext->GetDragDropManager();
610     EXPECT_NE(dragDropManager, nullptr);
611     EXPECT_FALSE(dragEventActuator->IsNeedGather());
612 }
613 
614 /**
615  * @tc.name: DragEventActuatorCreateBadgeTextNodeTest001
616  * @tc.desc: Test CreateBadgeTextNode function.
617  * @tc.type: FUNC
618  */
619 HWTEST_F(DragEventTestNg, DragEventActuatorCreateBadgeTextNodeTest001, TestSize.Level1)
620 {
621     /**
622      * @tc.steps: step1. Create DragEventActuator.
623      */
624     auto eventHub = AceType::MakeRefPtr<EventHub>();
625     ASSERT_NE(eventHub, nullptr);
626     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
627     ASSERT_NE(frameNode, nullptr);
628     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
629     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
630     ASSERT_NE(gestureEventHub, nullptr);
631     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
632         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
633     ASSERT_NE(dragEventActuator, nullptr);
634 
635     /**
636      * @tc.steps: step2. Invoke CreateBadgeTextNode.
637      */
638     auto textNode = DragAnimationHelper::CreateBadgeTextNode(1);
639     EXPECT_EQ(textNode, nullptr);
640 }
641 
642 /**
643  * @tc.name: DragEventActuatorHandleTouchMoveEventTest001
644  * @tc.desc: Test HandleTouchMoveEvent function.
645  * @tc.type: FUNC 6
646  */
647 HWTEST_F(DragEventTestNg, DragEventActuatorHandleTouchMoveEventTest001, TestSize.Level1)
648 {
649     /**
650      * @tc.steps: step1. Create DragEventActuator.
651      */
652     auto eventHub = AceType::MakeRefPtr<EventHub>();
653     ASSERT_NE(eventHub, nullptr);
654     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
655     ASSERT_NE(frameNode, nullptr);
656     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
657     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
658     ASSERT_NE(gestureEventHub, nullptr);
659     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
660         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
661     ASSERT_NE(dragEventActuator, nullptr);
662 
663     /**
664      * @tc.steps: step2. Invoke HandleTouchMoveEvent.
665      */
666     dragEventActuator->longPressRecognizer_ = nullptr;
667     dragEventActuator->HandleTouchMoveEvent();
668     EXPECT_EQ(dragEventActuator->longPressRecognizer_, nullptr);
669 
670     /**
671      * @tc.steps: step3. Invoke HandleTouchMoveEvent.
672      */
673     dragEventActuator->longPressRecognizer_ =
674         AceType::MakeRefPtr<LongPressRecognizer>(LONG_PRESS_DURATION, FINGERS_NUMBER, false, true);
675     dragEventActuator->isOnBeforeLiftingAnimation_ = false;
676     dragEventActuator->HandleTouchMoveEvent();
677     EXPECT_NE(dragEventActuator->longPressRecognizer_, nullptr);
678     EXPECT_FALSE(dragEventActuator->isOnBeforeLiftingAnimation_);
679 
680     /**
681      * @tc.steps: step4. Invoke HandleTouchMoveEvent.
682      */
683     dragEventActuator->isOnBeforeLiftingAnimation_ = true;
684     dragEventActuator->longPressRecognizer_->disposal_ = GestureDisposal::ACCEPT;
685     dragEventActuator->HandleTouchMoveEvent();
686     EXPECT_NE(dragEventActuator->longPressRecognizer_, nullptr);
687     EXPECT_TRUE(dragEventActuator->isOnBeforeLiftingAnimation_);
688     EXPECT_FALSE(dragEventActuator->longPressRecognizer_->GetGestureDisposal() == GestureDisposal::REJECT);
689 
690     /**
691      * @tc.steps: step5. Invoke HandleTouchMoveEvent.
692      */
693     dragEventActuator->longPressRecognizer_->disposal_ = GestureDisposal::REJECT;
694     dragEventActuator->isOnBeforeLiftingAnimation_ = true;
695     dragEventActuator->HandleTouchMoveEvent();
696     EXPECT_NE(dragEventActuator->longPressRecognizer_, nullptr);
697     EXPECT_FALSE(dragEventActuator->isOnBeforeLiftingAnimation_);
698     EXPECT_TRUE(dragEventActuator->longPressRecognizer_->GetGestureDisposal() == GestureDisposal::REJECT);
699 }
700 
701 /**
702  * @tc.name: DragEventActuatorMountGatherNodeTest001
703  * @tc.desc: Test MountGatherNode function.
704  * @tc.type: FUNC 3
705  */
706 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest001, TestSize.Level1)
707 {
708     /**
709      * @tc.steps: step1. Create DragEventActuator.
710      */
711     auto eventHub = AceType::MakeRefPtr<EventHub>();
712     EXPECT_NE(eventHub, nullptr);
713     auto frameNode1 = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
714     EXPECT_NE(frameNode1, nullptr);
715     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode1));
716     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
717     EXPECT_NE(gestureEventHub, nullptr);
718     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
719         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
720     EXPECT_NE(dragEventActuator, nullptr);
721 
722     /**
723      * @tc.steps: step2. Create manager, gatherNode, gatherNodeChildrenInfo.
724      */
725     auto pipelineContext = PipelineContext::GetCurrentContext();
726     EXPECT_NE(pipelineContext, nullptr);
727     auto manager = pipelineContext->GetOverlayManager();
728     EXPECT_NE(manager, nullptr);
729     auto gestureHub = dragEventActuator->gestureEventHub_.Upgrade();
730     EXPECT_NE(gestureHub, nullptr);
731     auto frameNode2 = gestureHub->GetFrameNode();
732     EXPECT_NE(frameNode2, nullptr);
733     manager->gatherNodeWeak_ = frameNode2;
734     auto gatherNode = manager->GetGatherNode();
735     EXPECT_NE(gatherNode, nullptr);
736     std::vector<GatherNodeChildInfo> gatherNodeChildrenInfo(2);
737     dragEventActuator->MountGatherNode(manager, frameNode1, gatherNode, gatherNodeChildrenInfo);
738 
739     /**
740      * @tc.steps: step3. Invoke MountGatherNode.
741      */
742     dragEventActuator->MountGatherNode(nullptr, frameNode1, gatherNode, gatherNodeChildrenInfo);
743     EXPECT_FALSE(gatherNode->isLayoutDirtyMarked_);
744 
745     /**
746      * @tc.steps: step4. Invoke MountGatherNode.
747      */
748     dragEventActuator->MountGatherNode(manager, nullptr, gatherNode, gatherNodeChildrenInfo);
749     EXPECT_FALSE(gatherNode->isLayoutDirtyMarked_);
750 
751     /**
752      * @tc.steps: step5. Invoke MountGatherNode.
753      */
754     dragEventActuator->MountGatherNode(nullptr, frameNode1, nullptr, gatherNodeChildrenInfo);
755     EXPECT_FALSE(gatherNode->isLayoutDirtyMarked_);
756 }
757 
758 /**
759  * @tc.name: DragEventActuatorMountGatherNodeTest002
760  * @tc.desc: Test HandleDragDampingMove function.
761  * @tc.type: FUNC
762  */
763 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest002, TestSize.Level1)
764 {
765     /**
766      * @tc.steps: step1. Create DragEventActuator.
767      */
768     auto eventHub = AceType::MakeRefPtr<EventHub>();
769     ASSERT_NE(eventHub, nullptr);
770     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
771     ASSERT_NE(framenode, nullptr);
772     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
773     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
774     ASSERT_NE(gestureEventHub, nullptr);
775     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
776         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
777     ASSERT_NE(dragEventActuator, nullptr);
778 
779     /**
780      * @tc.steps: step2. Invoke DragDampingMove with DragDropMgrState::IDLE and same Pointer.
781      * @tc.expected: cover DragDampingMove.
782      */
783     auto pipeline = PipelineContext::GetCurrentContext();
784     CHECK_NULL_VOID(pipeline);
785     auto dragDropManager = pipeline->GetDragDropManager();
786     CHECK_NULL_VOID(dragDropManager);
787     TouchEventInfo info(TOUCH_EVENT_INFO_TYPE);
788     auto point = Point(
789         info.GetTouches().front().GetGlobalLocation().GetX(), info.GetTouches().front().GetGlobalLocation().GetY());
790     dragDropManager->SetDraggingPointer(info.GetTouches().front().GetFingerId());
791     dragDropManager->ResetDragging(DragDropMgrState::IDLE);
792     dragEventActuator->isRedragStart_ = false;
793     dragEventActuator->HandleDragDampingMove(point, info.GetTouches().front().GetFingerId(), true);
794     EXPECT_EQ(dragEventActuator->isRedragStart_, true);
795 }
796 
797 /**
798  * @tc.name: DragEventActuatorMountGatherNodeTest004
799  * @tc.desc: Test SetDragPreviewOptions.
800  * @tc.type: FUNC
801  */
802 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest004, TestSize.Level1)
803 {
804     /**
805      * @tc.steps: step1. Create DragEventActuator.
806      */
807     auto eventHub = AceType::MakeRefPtr<EventHub>();
808     ASSERT_NE(eventHub, nullptr);
809     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
810     ASSERT_NE(framenode, nullptr);
811     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
812     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
813     ASSERT_NE(gestureEventHub, nullptr);
814     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
815         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
816     ASSERT_NE(dragEventActuator, nullptr);
817     DragPreviewOption previewOption;
818     previewOption.isDefaultRadiusEnabled = true;
819     framenode->SetDragPreviewOptions(previewOption);
820     dragEventActuator->UpdatePreviewOptionDefaultAttr(framenode);
821     EXPECT_EQ(previewOption.isDefaultRadiusEnabled, true);
822 }
823 
824 /**
825  * @tc.name: DragEventActuatorMountGatherNodeTest005
826  * @tc.desc: Test SetEventColumn.
827  * @tc.type: FUNC
828  */
829 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest005, TestSize.Level1)
830 {
831     /**
832      * @tc.steps: step1. Create DragEventActuator.
833      */
834     auto eventHub = AceType::MakeRefPtr<EventHub>();
835     ASSERT_NE(eventHub, nullptr);
836     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
837     ASSERT_NE(framenode, nullptr);
838     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
839     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
840     ASSERT_NE(gestureEventHub, nullptr);
841     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
842         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
843     ASSERT_NE(dragEventActuator, nullptr);
844     auto pipelineContext = PipelineContext::GetCurrentContext();
845     CHECK_NULL_VOID(pipelineContext);
846     auto manager = pipelineContext->GetOverlayManager();
847     manager->hasEvent_ = true;
848     dragEventActuator->SetEventColumn(dragEventActuator);
849     EXPECT_EQ(manager->hasEvent_, true);
850 }
851 
852 /**
853  * @tc.name: DragEventActuatorMountGatherNodeTest006
854  * @tc.desc: Test BindClickEvent.
855  * @tc.type: FUNC
856  */
857 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest006, TestSize.Level1)
858 {
859     /**
860      * @tc.steps: step1. Create DragEventActuator.
861      */
862     auto eventHub = AceType::MakeRefPtr<EventHub>();
863     ASSERT_NE(eventHub, nullptr);
864     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
865     ASSERT_NE(framenode, nullptr);
866     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
867     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
868     ASSERT_NE(gestureEventHub, nullptr);
869     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
870         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
871     ASSERT_NE(dragEventActuator, nullptr);
872     dragEventActuator->BindClickEvent(framenode);
873     auto columnGestureHub = framenode->GetOrCreateGestureEventHub();
874     auto event = columnGestureHub->clickEventActuator_->clickEvents_;
875     GestureEvent info;
876     for (auto item : event) {
877         (*item)(info);
878     }
879     EXPECT_EQ(columnGestureHub->GetHitTestMode(), HitTestMode::HTMBLOCK);
880 }
881 
882 /**
883  * @tc.name: DragEventActuatorMountGatherNodeTest007
884  * @tc.desc: Test BindClickEvent.
885  * @tc.type: FUNC
886  */
887 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest007, TestSize.Level1)
888 {
889     /**
890      * @tc.steps: step1. Create DragEventActuator.
891      */
892     auto eventHub = AceType::MakeRefPtr<EventHub>();
893     ASSERT_NE(eventHub, nullptr);
894     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
895     ASSERT_NE(framenode, nullptr);
896     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
897     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
898     ASSERT_NE(gestureEventHub, nullptr);
899     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
900         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
901     ASSERT_NE(dragEventActuator, nullptr);
902     dragEventActuator->BindClickEvent(framenode);
903     auto columnGestureHub = framenode->GetOrCreateGestureEventHub();
904     auto event = columnGestureHub->clickEventActuator_->clickEvents_;
905     GestureEvent info;
906     auto gestureHub = dragEventActuator->gestureEventHub_.Upgrade();
907     gestureHub->textDraggable_ = true;
908     for (auto item : event) {
909         (*item)(info);
910     }
911     EXPECT_EQ(columnGestureHub->GetHitTestMode(), HitTestMode::HTMBLOCK);
912 }
913 
914 /**
915  * @tc.name: DragEventActuatorMountGatherNodeTest008
916  * @tc.desc: Test SetImageNodeInitAttr.
917  * @tc.type: FUNC
918  */
919 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest008, TestSize.Level1)
920 {
921     /**
922      * @tc.steps: step1. Create DragEventActuator.
923      */
924     auto eventHub = AceType::MakeRefPtr<EventHub>();
925     ASSERT_NE(eventHub, nullptr);
926     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
927     auto framenode1 = FrameNode::CreateFrameNode("test1", 1, AceType::MakeRefPtr<Pattern>(), false);
928     ASSERT_NE(framenode, nullptr);
929     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
930     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
931     ASSERT_NE(gestureEventHub, nullptr);
932     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
933         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
934     auto dragPreviewOption = framenode->GetDragPreviewOption();
935     dragPreviewOption.defaultAnimationBeforeLifting = true;
936     framenode->SetDragPreviewOptions(dragPreviewOption);
937     ASSERT_NE(dragEventActuator, nullptr);
938     DragAnimationHelper::SetImageNodeInitAttr(framenode, framenode1);
939     framenode->layoutProperty_ = nullptr;
940     DragAnimationHelper::SetImageNodeInitAttr(framenode, framenode1);
941     dragPreviewOption = framenode->GetDragPreviewOption();
942     EXPECT_EQ(dragPreviewOption.defaultAnimationBeforeLifting, true);
943 }
944 
945 /**
946  * @tc.name: DragEventActuatorMountGatherNodeTest009
947  * @tc.desc: Test GetFrameNodePreviewPixelMap.
948  * @tc.type: FUNC
949  */
950 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest009, TestSize.Level1)
951 {
952     /**
953      * @tc.steps: step1. Create DragEventActuator.
954      */
955     auto eventHub = AceType::MakeRefPtr<EventHub>();
956     ASSERT_NE(eventHub, nullptr);
957     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
958     ASSERT_NE(framenode, nullptr);
959     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
960     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
961     ASSERT_NE(gestureEventHub, nullptr);
962     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
963         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
964     ASSERT_NE(dragEventActuator, nullptr);
965     framenode->dragPreviewInfo_.inspectorId = "test";
966     dragEventActuator->GetFrameNodePreviewPixelMap(framenode);
967     RefPtr<PixelMap> pixelMap = PixelMap::CreatePixelMap(static_cast<void*>(new char[0]));
968     framenode->dragPreviewInfo_.pixelMap = pixelMap;
969     framenode->dragPreviewInfo_.inspectorId = "";
970     dragEventActuator->GetFrameNodePreviewPixelMap(framenode);
971     EXPECT_EQ(gestureEventHub->GetDragPreviewPixelMap(), nullptr);;
972 }
973 
974 /**
975  * @tc.name: DragEventActuatorMountGatherNodeTest010
976  * @tc.desc: Test OnCollectTouchTarget.
977  * @tc.type: FUNC
978  */
979 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest010, TestSize.Level1)
980 {
981     /**
982      * @tc.steps: step1. Create DragEventActuator.
983      */
984     auto eventHub = AceType::MakeRefPtr<EventHub>();
985     ASSERT_NE(eventHub, nullptr);
986     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
987     ASSERT_NE(framenode, nullptr);
988     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
989     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
990     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
991         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
992     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
993     ASSERT_NE(getEventTargetImpl, nullptr);
994     TouchTestResult finalResult;
995     ResponseLinkResult responseLinkResult;
996     framenode->GetOrCreateFocusHub();
997     dragEventActuator->OnCollectTouchTarget(
998         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
999     EXPECT_EQ(dragEventActuator->panRecognizer_->onActionEnd_, nullptr);
1000     EXPECT_TRUE(finalResult.empty());
1001     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
1002     GestureEventFunc actionStart = [&unknownPropertyValue](
__anonfd430c6c0602( GestureEvent& info) 1003                                        GestureEvent& info) { unknownPropertyValue = info.GetScale(); };
1004     GestureEventFunc actionUpdate = [&unknownPropertyValue](
__anonfd430c6c0702( GestureEvent& info) 1005                                         GestureEvent& info) { unknownPropertyValue = info.GetScale(); };
1006     GestureEventFunc actionEnd = [&unknownPropertyValue](
__anonfd430c6c0802( GestureEvent& info) 1007                                      GestureEvent& info) { unknownPropertyValue = info.GetScale(); };
__anonfd430c6c0902() 1008     GestureEventNoParameter actionCancel = [&unknownPropertyValue]() {
1009         unknownPropertyValue = GESTURE_EVENT_PROPERTY_VALUE;
1010     };
1011     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1012         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1013     dragEventActuator->ReplaceDragEvent(dragEvent);
1014     dragEventActuator->SetCustomDragEvent(dragEvent);
1015     ASSERT_NE(dragEventActuator->userCallback_, nullptr);
1016     dragEventActuator->OnCollectTouchTarget(
1017         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1018     GestureEvent info = GestureEvent();
1019     auto gestureHub = dragEventActuator->gestureEventHub_.Upgrade();
1020     gestureHub->textDraggable_ = true;
1021     (*(dragEventActuator->panRecognizer_->onActionEnd_))(info);
1022     EXPECT_EQ(gestureHub->textDraggable_, true);
1023 }
1024 
1025 /**
1026  * @tc.name: DragEventActuatorMountGatherNodeTest011
1027  * @tc.desc: Create DragEventActuator and invoke onActionCancel callback.
1028  * @tc.type: FUNC
1029  */
1030 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest011, TestSize.Level1)
1031 {
1032     /**
1033      * @tc.steps: step1. Create DragEventActuator.
1034      */
1035     auto eventHub = AceType::MakeRefPtr<EventHub>();
1036     ASSERT_NE(eventHub, nullptr);
1037     auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<TextPattern>());
1038     ASSERT_NE(frameNode, nullptr);
1039     frameNode->SetDraggable(true);
1040     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1041     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1042     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1043         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1044     /**
1045      * @tc.steps: step2. Create DragEvent and set as DragEventActuator's DragEvent.
1046      * @tc.expected: dragEventActuator's userCallback_ is not null.
1047      */
1048     double unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
__anonfd430c6c0a02(GestureEvent& info) 1049     GestureEventFunc actionStart = [](GestureEvent& info) {};
__anonfd430c6c0b02(GestureEvent& info) 1050     GestureEventFunc actionUpdate = [](GestureEvent& info) {};
__anonfd430c6c0c02(GestureEvent& info) 1051     GestureEventFunc actionEnd = [](GestureEvent& info) {};
__anonfd430c6c0d02() 1052     GestureEventNoParameter actionCancel = [&unknownPropertyValue]() {
1053         unknownPropertyValue = GESTURE_EVENT_PROPERTY_VALUE;
1054     };
1055     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1056         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1057     dragEventActuator->ReplaceDragEvent(dragEvent);
1058     dragEventActuator->SetCustomDragEvent(dragEvent);
1059     ASSERT_NE(dragEventActuator->userCallback_, nullptr);
1060     /**
1061      * @tc.steps: step3. Invoke OnCollectTouchTarget when userCallback_ is not null.
1062      * @tc.expected: longPressRecognizer is not nullptr and panRecognizer's callback onActionCancel is not nullptr.
1063      */
1064     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
1065     TouchTestResult finalResult;
1066     ResponseLinkResult responseLinkResult;
1067     frameNode->GetOrCreateFocusHub();
1068     dragEventActuator->OnCollectTouchTarget(
1069         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1070     dragEventActuator->panRecognizer_->onActionCancel_ = std::make_unique<GestureEventFunc>(
__anonfd430c6c0e02(GestureEvent& info) 1071         [&unknownPropertyValue](GestureEvent& info) { unknownPropertyValue = GESTURE_EVENT_PROPERTY_VALUE; });
1072     ASSERT_NE(dragEventActuator->panRecognizer_->onActionCancel_, nullptr);
1073     unknownPropertyValue = GESTURE_EVENT_PROPERTY_DEFAULT_VALUE;
1074     dragEventActuator->isNotInPreviewState_ = true;
1075     auto gestureHub = dragEventActuator->gestureEventHub_.Upgrade();
1076     gestureHub->textDraggable_ = false;
1077     GestureEvent info = GestureEvent();
1078     (*(dragEventActuator->panRecognizer_->onActionCancel_))(info);
1079     EXPECT_EQ(unknownPropertyValue, GESTURE_EVENT_PROPERTY_VALUE);
1080 }
1081 
1082 /**
1083  * @tc.name: DragEventActuatorMountGatherNodeTest012
1084  * @tc.desc: Create DragEventActuator and invoke longPressUpdate callback.
1085  * @tc.type: FUNC
1086  */
1087 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest012, TestSize.Level1)
1088 {
1089     /**
1090      * @tc.steps: step1. Create DragEventActuator.
1091      */
1092     auto eventHub = AceType::MakeRefPtr<EventHub>();
1093     ASSERT_NE(eventHub, nullptr);
1094     auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<TextPattern>());
1095     ASSERT_NE(frameNode, nullptr);
1096     DragDropInfo dragDropInfo;
1097     frameNode->SetDragPreview(dragDropInfo);
1098     frameNode->SetDraggable(true);
1099     frameNode->GetOrCreateFocusHub();
1100     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1101     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1102     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1103         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1104     /**
1105      * @tc.steps: step2. Create DragEvent and set as DragEventActuator's DragEvent.
1106      * @tc.expected: dragEventActuator's userCallback_ is not null.
1107      */
__anonfd430c6c0f02(GestureEvent& info) 1108     GestureEventFunc actionStart = [](GestureEvent& info) {};
__anonfd430c6c1002(GestureEvent& info) 1109     GestureEventFunc actionUpdate = [](GestureEvent& info) {};
__anonfd430c6c1102(GestureEvent& info) 1110     GestureEventFunc actionEnd = [](GestureEvent& info) {};
__anonfd430c6c1202() 1111     GestureEventNoParameter actionCancel = []() {};
1112     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1113         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1114     dragEventActuator->ReplaceDragEvent(dragEvent);
1115     dragEventActuator->SetCustomDragEvent(dragEvent);
1116     ASSERT_NE(dragEventActuator->userCallback_, nullptr);
1117     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
1118     TouchTestResult finalResult;
1119     ResponseLinkResult responseLinkResult;
1120     frameNode->GetOrCreateFocusHub();
1121     dragEventActuator->OnCollectTouchTarget(
1122         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1123     ASSERT_NE(dragEventActuator->previewLongPressRecognizer_->onAction_, nullptr);
1124     SystemProperties::debugEnabled_ = true;
1125     GestureEvent info = GestureEvent();
1126     dragEventActuator->userCallback_->actionLongPress_ = actionEnd;
1127     (*(dragEventActuator->longPressRecognizer_->onAction_))(info);
1128     EXPECT_EQ(dragEventActuator->GetIsNotInPreviewState(), true);
1129     dragEventActuator->userCallback_ = nullptr;
1130     (*(dragEventActuator->longPressRecognizer_->onAction_))(info);
1131     EXPECT_EQ(dragEventActuator->GetIsNotInPreviewState(), true);
1132 }
1133 
1134 /**
1135  * @tc.name: DragEventActuatorMountGatherNodeTest013
1136  * @tc.desc: Create DragEventActuator and invoke longPressUpdate callback.
1137  * @tc.type: FUNC
1138  */
1139 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest013, TestSize.Level1)
1140 {
1141     /**
1142      * @tc.steps: step1. Create DragEventActuator.
1143      */
1144     auto eventHub = AceType::MakeRefPtr<EventHub>();
1145     ASSERT_NE(eventHub, nullptr);
1146     auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<TextPattern>());
1147     ASSERT_NE(frameNode, nullptr);
1148     DragDropInfo dragDropInfo;
1149     frameNode->SetDragPreview(dragDropInfo);
1150     frameNode->SetDraggable(true);
1151     frameNode->GetOrCreateFocusHub();
1152     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1153     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1154     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1155         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1156     /**
1157      * @tc.steps: step2. Create DragEvent and set as DragEventActuator's DragEvent.
1158      * @tc.expected: dragEventActuator's userCallback_ is not null.
1159      */
__anonfd430c6c1302(GestureEvent& info) 1160     GestureEventFunc actionStart = [](GestureEvent& info) {};
__anonfd430c6c1402(GestureEvent& info) 1161     GestureEventFunc actionUpdate = [](GestureEvent& info) {};
__anonfd430c6c1502(GestureEvent& info) 1162     GestureEventFunc actionEnd = [](GestureEvent& info) {};
__anonfd430c6c1602() 1163     GestureEventNoParameter actionCancel = []() {};
1164     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1165         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1166     dragEventActuator->ReplaceDragEvent(dragEvent);
1167     dragEventActuator->SetCustomDragEvent(dragEvent);
1168     ASSERT_NE(dragEventActuator->userCallback_, nullptr);
1169     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
1170     TouchTestResult finalResult;
1171     ResponseLinkResult responseLinkResult;
1172     frameNode->GetOrCreateFocusHub();
1173     dragEventActuator->OnCollectTouchTarget(
1174         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1175     ASSERT_NE(dragEventActuator->previewLongPressRecognizer_->onAction_, nullptr);
1176     SystemProperties::debugEnabled_ = true;
1177     GestureEvent info = GestureEvent();
1178     auto gestureHub = dragEventActuator->gestureEventHub_.Upgrade();
1179     gestureHub->textDraggable_ = true;
1180     dragEventActuator->userCallback_->actionLongPress_ = actionEnd;
1181     (*(dragEventActuator->longPressRecognizer_->onAction_))(info);
1182     EXPECT_EQ(dragEventActuator->GetIsNotInPreviewState(), true);
1183 }
1184 
1185 /**
1186  * @tc.name: DragEventActuatorMountGatherNodeTest014
1187  * @tc.desc: Create DragEventActuator and invoke longPressUpdate callback.
1188  * @tc.type: FUNC
1189  */
1190 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest014, TestSize.Level1)
1191 {
1192     auto eventHub = AceType::MakeRefPtr<EventHub>();
1193     ASSERT_NE(eventHub, nullptr);
1194     auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<TextPattern>());
1195     ASSERT_NE(frameNode, nullptr);
1196     DragDropInfo dragDropInfo;
1197     frameNode->SetDragPreview(dragDropInfo);
1198     frameNode->SetDraggable(true);
1199     frameNode->GetOrCreateFocusHub();
1200     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1201     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1202     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1203         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
__anonfd430c6c1702(GestureEvent& info) 1204     GestureEventFunc actionStart = [](GestureEvent& info) {};
__anonfd430c6c1802(GestureEvent& info) 1205     GestureEventFunc actionUpdate = [](GestureEvent& info) {};
__anonfd430c6c1902(GestureEvent& info) 1206     GestureEventFunc actionEnd = [](GestureEvent& info) {};
__anonfd430c6c1a02() 1207     GestureEventNoParameter actionCancel = []() {};
1208     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1209         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1210     dragEventActuator->ReplaceDragEvent(dragEvent);
1211     dragEventActuator->SetCustomDragEvent(dragEvent);
1212     ASSERT_NE(dragEventActuator->userCallback_, nullptr);
1213     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
1214     TouchTestResult finalResult;
1215     ResponseLinkResult responseLinkResult;
1216     frameNode->GetOrCreateFocusHub();
1217     dragEventActuator->OnCollectTouchTarget(
1218         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1219     ASSERT_NE(dragEventActuator->previewLongPressRecognizer_->onAction_, nullptr);
1220     SystemProperties::debugEnabled_ = true;
1221     EXPECT_EQ(gestureEventHub->GetTextDraggable(), false);
1222     EXPECT_EQ(dragEventActuator->IsAllowedDrag(), true);
1223     auto pipeline = PipelineContext::GetCurrentContext();
1224     CHECK_NULL_VOID(pipeline);
1225 
1226     auto overlayManager = pipeline->GetOverlayManager();
1227     CHECK_NULL_VOID(overlayManager);
1228     overlayManager->hasPixelMap_ = true;
1229     GestureEvent info = GestureEvent();
1230     (*(dragEventActuator->previewLongPressRecognizer_->onAction_))(info);
1231     EXPECT_EQ(dragEventActuator->GetIsNotInPreviewState(), false);
1232 }
1233 
1234 /**
1235  * @tc.name: DragEventActuatorMountGatherNodeTest015
1236  * @tc.desc: Create DragEventActuator and invoke longPressUpdate callback.
1237  * @tc.type: FUNC
1238  */
1239 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest015, TestSize.Level1)
1240 {
1241     /**
1242      * @tc.steps: step1. Create DragEventActuator.
1243      */
1244     auto eventHub = AceType::MakeRefPtr<EventHub>();
1245     ASSERT_NE(eventHub, nullptr);
1246     auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<TextPattern>());
1247     ASSERT_NE(frameNode, nullptr);
1248     DragDropInfo dragDropInfo;
1249     frameNode->SetDragPreview(dragDropInfo);
1250     frameNode->SetDraggable(true);
1251     frameNode->GetOrCreateFocusHub();
1252     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1253     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1254     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1255         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1256 
__anonfd430c6c1b02(GestureEvent& info) 1257     GestureEventFunc actionStart = [](GestureEvent& info) {};
__anonfd430c6c1c02(GestureEvent& info) 1258     GestureEventFunc actionUpdate = [](GestureEvent& info) {};
__anonfd430c6c1d02(GestureEvent& info) 1259     GestureEventFunc actionEnd = [](GestureEvent& info) {};
__anonfd430c6c1e02() 1260     GestureEventNoParameter actionCancel = []() {};
1261     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1262         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1263     dragEventActuator->ReplaceDragEvent(dragEvent);
1264     dragEventActuator->SetCustomDragEvent(dragEvent);
1265     ASSERT_NE(dragEventActuator->userCallback_, nullptr);
1266     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
1267     TouchTestResult finalResult;
1268     ResponseLinkResult responseLinkResult;
1269     frameNode->GetOrCreateFocusHub();
1270     dragEventActuator->OnCollectTouchTarget(
1271         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1272     ASSERT_NE(dragEventActuator->previewLongPressRecognizer_->onAction_, nullptr);
1273     SystemProperties::debugEnabled_ = true;
1274     EXPECT_EQ(gestureEventHub->GetTextDraggable(), false);
1275     EXPECT_EQ(dragEventActuator->IsAllowedDrag(), true);
1276     auto pipeline = PipelineContext::GetCurrentContext();
1277     ASSERT_NE(pipeline, nullptr);
1278     auto dragDropManager = pipeline->GetDragDropManager();
1279     ASSERT_NE(dragDropManager, nullptr);
1280     dragDropManager->dragDropState_ = DragDropMgrState::ABOUT_TO_PREVIEW;
1281     GestureEvent info = GestureEvent();
1282     (*(dragEventActuator->previewLongPressRecognizer_->onAction_))(info);
1283     EXPECT_EQ(dragEventActuator->GetIsNotInPreviewState(), false);
1284 }
1285 
1286 /**
1287  * @tc.name: DragEventActuatorMountGatherNodeTest016
1288  * @tc.desc: Create DragEventActuator and invoke longPressUpdate callback.
1289  * @tc.type: FUNC
1290  */
1291 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest016, TestSize.Level1)
1292 {
1293     /**
1294      * @tc.steps: step1. Create DragEventActuator.
1295      */
1296     auto eventHub = AceType::MakeRefPtr<EventHub>();
1297     ASSERT_NE(eventHub, nullptr);
1298     auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<TextPattern>());
1299     ASSERT_NE(frameNode, nullptr);
1300     DragDropInfo dragDropInfo;
1301     frameNode->SetDragPreview(dragDropInfo);
1302     frameNode->SetDraggable(true);
1303     frameNode->GetOrCreateFocusHub();
1304     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1305     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1306     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1307         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
__anonfd430c6c1f02(GestureEvent& info) 1308     GestureEventFunc actionStart = [](GestureEvent& info) {};
__anonfd430c6c2002(GestureEvent& info) 1309     GestureEventFunc actionUpdate = [](GestureEvent& info) {};
__anonfd430c6c2102(GestureEvent& info) 1310     GestureEventFunc actionEnd = [](GestureEvent& info) {};
__anonfd430c6c2202() 1311     GestureEventNoParameter actionCancel = []() {};
1312     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1313         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1314     dragEventActuator->ReplaceDragEvent(dragEvent);
1315     dragEventActuator->SetCustomDragEvent(dragEvent);
1316     ASSERT_NE(dragEventActuator->userCallback_, nullptr);
1317     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
1318     TouchTestResult finalResult;
1319     ResponseLinkResult responseLinkResult;
1320     frameNode->GetOrCreateFocusHub();
1321     dragEventActuator->OnCollectTouchTarget(
1322         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1323     ASSERT_NE(dragEventActuator->previewLongPressRecognizer_->onAction_, nullptr);
1324     SystemProperties::debugEnabled_ = true;
1325     EXPECT_EQ(gestureEventHub->GetTextDraggable(), false);
1326     EXPECT_EQ(dragEventActuator->IsAllowedDrag(), true);
1327     auto pipeline = PipelineContext::GetCurrentContext();
1328     ASSERT_NE(pipeline, nullptr);
1329     auto dragDropManager = pipeline->GetDragDropManager();
1330     ASSERT_NE(dragDropManager, nullptr);
1331     dragDropManager->dragDropState_ = DragDropMgrState::DRAGGING;
1332     GestureEvent info = GestureEvent();
1333     (*(dragEventActuator->previewLongPressRecognizer_->onAction_))(info);
1334     EXPECT_EQ(dragEventActuator->GetIsNotInPreviewState(), false);
1335 }
1336 
1337 /**
1338  * @tc.name: DragEventActuatorMountGatherNodeTest017
1339  * @tc.desc: Test BlurStyleToEffection.
1340  * @tc.type: FUNC
1341  */
1342 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest017, TestSize.Level1)
1343 {
1344     /**
1345      * @tc.steps: step1. Create DragEventActuator.
1346      */
1347     auto eventHub = AceType::MakeRefPtr<EventHub>();
1348     ASSERT_NE(eventHub, nullptr);
1349     auto frameNode = FrameNode::CreateFrameNode(
1350         V2::TEXT_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<ImagePattern>());
1351     ASSERT_NE(frameNode, nullptr);
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     std::vector<float> vecGrayScale = { 0.0f, 0.0f };
1358     BlurStyleOption blurStyleInfo = { BlurStyle::NO_MATERIAL, ThemeColorMode::SYSTEM, AdaptiveColor::DEFAULT, 1.0,
1359         { vecGrayScale } };
1360     std::optional<BlurStyleOption> optBlurStyleInfo(blurStyleInfo);
1361     auto optEffectOption = DragDropFuncWrapper::BlurStyleToEffection(optBlurStyleInfo);
1362     auto pipeline = PipelineContext::GetCurrentContext();
1363     ASSERT_NE(pipeline, nullptr);
1364     EXPECT_EQ(optEffectOption.has_value(), false);
1365 
1366     auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
1367     MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
1368     EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr<BlurStyleTheme>()));
1369     auto blurStyleTheme = pipeline->GetTheme<BlurStyleTheme>();
1370     ASSERT_NE(blurStyleTheme, nullptr);
1371     auto resAdapter = RefPtr<ResourceAdapter>();
1372     auto themeConstants = AceType::MakeRefPtr<ThemeConstants>(resAdapter);
1373     std::unordered_map<std::string, ResValueWrapper> attributes;
1374     ResValueWrapper resValueWrapper;
1375     resValueWrapper.type = ThemeConstantsType::THEME;
1376     resValueWrapper.value = AceType::MakeRefPtr<ThemeStyle>();
1377     attributes.insert(std::pair<std::string, ResValueWrapper>(THEME_BLUR_STYLE_COMMON, resValueWrapper));
1378     themeConstants->currentThemeStyle_ = AceType::MakeRefPtr<ThemeStyle>();
1379     themeConstants->currentThemeStyle_->SetAttributes(attributes);
1380     auto blThemeInstance = BlurStyleTheme::Builder().Build(themeConstants);
1381     EXPECT_CALL(*themeManager, GetTheme(BlurStyleTheme::TypeId())).WillRepeatedly(Return(blThemeInstance));
1382 
1383     optBlurStyleInfo->colorMode = ThemeColorMode::LIGHT;
1384     optEffectOption = DragDropFuncWrapper::BlurStyleToEffection(optBlurStyleInfo);
1385     ASSERT_NE(optEffectOption.has_value(), true);
1386     EXPECT_EQ(resValueWrapper.type, ThemeConstantsType::THEME);
1387 }
1388 
1389 /**
1390  * @tc.name: DragEventActuatorMountGatherNodeTest018
1391  * @tc.desc: Test SetFilter.
1392  * @tc.type: FUNC
1393  */
1394 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest018, TestSize.Level1)
1395 {
1396     auto eventHub = AceType::MakeRefPtr<EventHub>();
1397     ASSERT_NE(eventHub, nullptr);
1398     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1399     ASSERT_NE(framenode, nullptr);
1400     auto parentNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1401     ASSERT_NE(parentNode, nullptr);
1402     framenode->SetParent(parentNode);
1403     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1404     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1405     ASSERT_NE(gestureEventHub, nullptr);
1406     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1407         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1408     ASSERT_NE(dragEventActuator, nullptr);
1409     auto dragEventActuatorTwo = AceType::MakeRefPtr<DragEventActuator>(
1410         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1411     ASSERT_NE(dragEventActuatorTwo, nullptr);
1412     dragEventActuator->SetFilter(dragEventActuatorTwo);
1413     parentNode->depth_ = 1;
1414     dragEventActuator->SetFilter(dragEventActuatorTwo);
1415     EXPECT_EQ(parentNode->depth_, 1);
1416 }
1417 
1418 /**
1419  * @tc.name: DragEventActuatorMountGatherNodeTest019
1420  * @tc.desc: Test SetFilter.
1421  * @tc.type: FUNC
1422  */
1423 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest019, TestSize.Level1)
1424 {
1425     auto eventHub = AceType::MakeRefPtr<EventHub>();
1426     ASSERT_NE(eventHub, nullptr);
1427     auto framenode = FrameNode::CreateFrameNode(V2::WEB_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), false);
1428     ASSERT_NE(framenode, nullptr);
1429     auto parentNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1430     ASSERT_NE(parentNode, nullptr);
1431     framenode->SetParent(parentNode);
1432     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1433     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1434     ASSERT_NE(gestureEventHub, nullptr);
1435     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1436         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1437     ASSERT_NE(dragEventActuator, nullptr);
1438     auto dragEventActuatorTwo = AceType::MakeRefPtr<DragEventActuator>(
1439         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1440     ASSERT_NE(dragEventActuatorTwo, nullptr);
1441     parentNode->depth_ = 1;
1442     MockContainer::SetUp();
1443     dragEventActuator->SetFilter(dragEventActuatorTwo);
1444     auto container = MockContainer::Current();
1445     container->isSceneBoardWindow_ = true;
1446     auto pipelineContext = PipelineContext::GetCurrentContext();
1447     ASSERT_NE(pipelineContext, nullptr);
1448     auto manager = pipelineContext->GetOverlayManager();
1449     ASSERT_NE(manager, nullptr);
1450     manager->hasFilter_ = false;
1451     dragEventActuator->SetFilter(dragEventActuatorTwo);
1452     manager->isOnAnimation_ = true;
1453     manager->hasFilter_ = false;
1454     dragEventActuator->SetFilter(dragEventActuatorTwo);
1455     manager->hasFilter_ = true;
1456     dragEventActuator->SetFilter(dragEventActuatorTwo);
1457     container->isSceneBoardWindow_ = false;
1458     MockContainer::TearDown();
1459     EXPECT_EQ(manager->hasFilter_, true);
1460 }
1461 
1462 /**
1463  * @tc.name: DragEventActuatorMountGatherNodeTest021
1464  * @tc.desc: Test SetPixelMap.
1465  * @tc.type: FUNC
1466  */
1467 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest021, TestSize.Level1)
1468 {
1469     auto eventHub = AceType::MakeRefPtr<EventHub>();
1470     ASSERT_NE(eventHub, nullptr);
1471     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1472     ASSERT_NE(framenode, nullptr);
1473     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1474     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1475     ASSERT_NE(gestureEventHub, nullptr);
1476     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1477         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1478     ASSERT_NE(dragEventActuator, nullptr);
1479 
1480     auto pipelineContext = PipelineContext::GetCurrentContext();
1481     ASSERT_NE(pipelineContext, nullptr);
1482     auto manager = pipelineContext->GetOverlayManager();
1483     ASSERT_NE(manager, nullptr);
1484     manager->SetHasPixelMap(false);
1485     void* voidPtr = static_cast<void*>(new char[0]);
1486     RefPtr<PixelMap> pixelMap = PixelMap::CreatePixelMap(voidPtr);
1487     gestureEventHub->SetPixelMap(pixelMap);
1488     dragEventActuator->SetPixelMap(dragEventActuator);
1489     MockContainer::SetUp();
1490     auto container = MockContainer::Current();
1491     container->isSceneBoardWindow_ = true;
1492     manager->SetHasPixelMap(false);
1493     dragEventActuator->SetPixelMap(dragEventActuator);
1494     manager->SetHasPixelMap(false);
1495     container->isSceneBoardWindow_ = false;
1496     dragEventActuator->SetPixelMap(dragEventActuator);
1497     MockContainer::TearDown();
1498     EXPECT_EQ(container->isSceneBoardWindow_, false);
1499 }
1500 
1501 /**
1502  * @tc.name: DragEventActuatorMountGatherNodeTest022
1503  * @tc.desc: Test UpdatePreviewOptionFromModifier function.
1504  * @tc.type: FUNC
1505  */
1506 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest022, TestSize.Level1)
1507 {
1508     auto eventHub = AceType::MakeRefPtr<EventHub>();
1509     ASSERT_NE(eventHub, nullptr);
1510     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1511     ASSERT_NE(framenode, nullptr);
1512     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1513     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1514     ASSERT_NE(gestureEventHub, nullptr);
1515     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1516         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1517     ASSERT_NE(dragEventActuator, nullptr);
1518     NG::DragPreviewOption previewOptions;
__anonfd430c6c2302(WeakPtr<NG::FrameNode> frameNodes) 1519     previewOptions.onApply = [](WeakPtr<NG::FrameNode> frameNodes) {
1520         auto node = frameNodes.Upgrade();
1521         auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1522         mockRenderContext->UpdateOpacity(-0.1f);
1523         BorderRadiusProperty borderRadius;
1524         borderRadius.SetRadius(Dimension(0.1));
1525         Shadow shadow;
1526         shadow.SetIsFilled(true);
1527         shadow.SetOffset(Offset(5, 5));
1528         shadow.SetBlurRadius(10.0);
1529         shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
1530         mockRenderContext->UpdateBackShadow(shadow);
1531         mockRenderContext->UpdateBorderRadius(borderRadius);
1532         node->renderContext_ = mockRenderContext;
1533     };
1534     framenode->SetDragPreviewOptions(previewOptions);
1535     dragEventActuator->UpdatePreviewOptionFromModifier(framenode);
1536 
__anonfd430c6c2402(WeakPtr<NG::FrameNode> frameNodes) 1537     previewOptions.onApply = [](WeakPtr<NG::FrameNode> frameNodes) {
1538         auto node = frameNodes.Upgrade();
1539         auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1540         mockRenderContext->UpdateOpacity(1.1f);
1541         node->renderContext_ = mockRenderContext;
1542     };
1543     framenode->SetDragPreviewOptions(previewOptions);
1544     dragEventActuator->UpdatePreviewOptionFromModifier(framenode);
1545 
__anonfd430c6c2502(WeakPtr<NG::FrameNode> frameNodes) 1546     previewOptions.onApply = [](WeakPtr<NG::FrameNode> frameNodes) {
1547         auto node = frameNodes.Upgrade();
1548         auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1549         node->renderContext_ = mockRenderContext;
1550     };
1551     framenode->SetDragPreviewOptions(previewOptions);
1552     dragEventActuator->UpdatePreviewOptionFromModifier(framenode);
1553     EXPECT_EQ(previewOptions.isMultiSelectionEnabled, false);
1554 }
1555 
1556 /**
1557  * @tc.name: DragEventActuatorMountGatherNodeTest023
1558  * @tc.desc: Test UpdatePreviewOptionFromModifier function.
1559  * @tc.type: FUNC
1560  */
1561 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest023, TestSize.Level1)
1562 {
1563     auto eventHub = AceType::MakeRefPtr<EventHub>();
1564     ASSERT_NE(eventHub, nullptr);
1565     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1566     ASSERT_NE(framenode, nullptr);
1567     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1568     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1569     ASSERT_NE(gestureEventHub, nullptr);
1570     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1571         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1572     ASSERT_NE(dragEventActuator, nullptr);
1573     NG::DragPreviewOption previewOptions;
__anonfd430c6c2602(WeakPtr<NG::FrameNode> frameNodes) 1574     previewOptions.onApply = [](WeakPtr<NG::FrameNode> frameNodes) {
1575         auto node = frameNodes.Upgrade();
1576         auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1577         BlurStyleOption styleOption;
1578         styleOption.blurStyle = BlurStyle::COMPONENT_THICK;
1579         styleOption.scale = 0.5;
1580         styleOption.colorMode = ThemeColorMode::LIGHT;
1581         mockRenderContext->UpdateBackBlurStyle(styleOption);
1582         node->renderContext_ = mockRenderContext;
1583     };
1584     framenode->SetDragPreviewOptions(previewOptions);
1585     dragEventActuator->UpdatePreviewOptionFromModifier(framenode);
1586 
__anonfd430c6c2702(WeakPtr<NG::FrameNode> frameNodes) 1587     previewOptions.onApply = [](WeakPtr<NG::FrameNode> frameNodes) {
1588         auto node = frameNodes.Upgrade();
1589         auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1590         CalcDimension radius;
1591         radius.SetValue(80.0f);
1592         Color color = Color::FromARGB(13, 255, 255, 255);
1593         EffectOption effoption = { radius, 1.0, 1.08, color };
1594         const auto& groupProperty = mockRenderContext->GetOrCreateBackground();
1595         groupProperty->propEffectOption = effoption;
1596         node->renderContext_ = mockRenderContext;
1597     };
1598     framenode->SetDragPreviewOptions(previewOptions);
1599     dragEventActuator->UpdatePreviewOptionFromModifier(framenode);
1600     EXPECT_EQ(previewOptions.isMultiSelectionEnabled, false);
1601 }
1602 
1603 /**
1604  * @tc.name: DragEventActuatorMountGatherNodeTest024
1605  * @tc.desc: Test SetFilter.
1606  * @tc.type: FUNC
1607  */
1608 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest024, TestSize.Level1)
1609 {
1610     auto eventHub = AceType::MakeRefPtr<EventHub>();
1611     ASSERT_NE(eventHub, nullptr);
1612     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1613     ASSERT_NE(framenode, nullptr);
1614     auto parentNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1615     ASSERT_NE(parentNode, nullptr);
1616     framenode->SetParent(parentNode);
1617     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1618     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1619     ASSERT_NE(gestureEventHub, nullptr);
1620     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1621         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1622     ASSERT_NE(dragEventActuator, nullptr);
1623     DragDropFuncWrapper::ApplyNewestOptionExecutedFromModifierToNode(framenode, parentNode);
1624     Dimension dimen(2.0);
1625     BlurBackGroundInfo bgBackEffect = { { dimen, 1.0f, 1.0f, Color::TRANSPARENT, AdaptiveColor::DEFAULT,
1626         { { 2.0f, 2.0f } } } };
1627     Shadow shadow;
1628     shadow.SetIsFilled(false);
1629     shadow.SetOffset(Offset(5, 5));
1630     shadow.SetBlurRadius(10.0);
1631     shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
1632     BorderRadiusProperty borderRadius;
1633     borderRadius.SetRadius(Dimension(0.1));
1634     OptionsAfterApplied optionTmp = { 0, shadow, "test", true, borderRadius, { bgBackEffect } };
1635     NG::DragPreviewOption previewOptions;
1636     previewOptions.options = optionTmp;
1637     parentNode->SetDragPreviewOptions(previewOptions);
1638     DragDropFuncWrapper::ApplyNewestOptionExecutedFromModifierToNode(framenode, parentNode);
1639     EXPECT_EQ(previewOptions.isMultiSelectionEnabled, false);
1640 }
1641 
1642 /**
1643  * @tc.name: DragEventActuatorMountGatherNodeTest025
1644  * @tc.desc: Test SetEventColumn.
1645  * @tc.type: FUNC
1646  */
1647 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest025, TestSize.Level1)
1648 {
1649     auto eventHub = AceType::MakeRefPtr<EventHub>();
1650     ASSERT_NE(eventHub, nullptr);
1651     auto frameNode = AceType::MakeRefPtr<FrameNode>(V2::TEXT_ETS_TAG, -1, AceType::MakeRefPtr<TextPattern>());
1652     ASSERT_NE(frameNode, nullptr);
1653     DragDropInfo dragDropInfo;
1654     frameNode->SetDragPreview(dragDropInfo);
1655     frameNode->GetOrCreateFocusHub();
1656     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1657     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1658     ASSERT_NE(gestureEventHub, nullptr);
1659     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1660         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1661     ASSERT_NE(dragEventActuator, nullptr);
__anonfd430c6c2802(GestureEvent& info) 1662     GestureEventFunc actionStart = [](GestureEvent& info) {};
__anonfd430c6c2902(GestureEvent& info) 1663     GestureEventFunc actionUpdate = [](GestureEvent& info) {};
__anonfd430c6c2a02(GestureEvent& info) 1664     GestureEventFunc actionEnd = [](GestureEvent& info) {};
__anonfd430c6c2b02() 1665     GestureEventNoParameter actionCancel = []() {};
1666     auto dragEvent = AceType::MakeRefPtr<DragEvent>(
1667         std::move(actionStart), std::move(actionUpdate), std::move(actionEnd), std::move(actionCancel));
1668     dragEventActuator->ReplaceDragEvent(dragEvent);
1669     dragEventActuator->SetCustomDragEvent(dragEvent);
1670     auto getEventTargetImpl = eventHub->CreateGetEventTargetImpl();
1671     TouchTestResult finalResult;
1672     ResponseLinkResult responseLinkResult;
1673     dragEventActuator->OnCollectTouchTarget(
1674         COORDINATE_OFFSET, DRAG_TOUCH_RESTRICT, getEventTargetImpl, finalResult, responseLinkResult);
1675     GestureEvent info = GestureEvent();
1676     SystemProperties::debugEnabled_ = false;
1677     frameNode->SetDraggable(false);
1678     gestureEventHub->SetTextDraggable(true);
1679     gestureEventHub->SetIsTextDraggable(true);
1680     dragEventActuator->SetIsNotInPreviewState(true);
1681     (*(dragEventActuator->previewLongPressRecognizer_->onAction_))(info);
1682     auto pipelineContext = PipelineContext::GetCurrentContext();
1683     ASSERT_NE(pipelineContext, nullptr);
1684     auto manager = pipelineContext->GetOverlayManager();
1685     manager->hasEvent_ = false;
1686     MockContainer::SetUp();
1687     auto container = MockContainer::Current();
1688     container->isSceneBoardWindow_ = true;
1689     (*(dragEventActuator->previewLongPressRecognizer_->onAction_))(info);
1690     container->isSceneBoardWindow_ = false;
1691     manager->hasEvent_ = false;
1692     (*(dragEventActuator->previewLongPressRecognizer_->onAction_))(info);
1693     (*(dragEventActuator->previewLongPressRecognizer_->onAction_))(info);
1694     MockContainer::TearDown();
1695     EXPECT_EQ(manager->hasEvent_, true);
1696 }
1697 
1698 /**
1699  * @tc.name: DragEventActuatorMountGatherNodeTest026
1700  * @tc.desc: Test SetImageNodeInitAttr
1701  * @tc.type: FUNC
1702  */
1703 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest026, TestSize.Level1)
1704 {
1705     auto eventHub = AceType::MakeRefPtr<EventHub>();
1706     ASSERT_NE(eventHub, nullptr);
1707     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1708     ASSERT_NE(framenode, nullptr);
1709     auto framenodeOne = FrameNode::CreateFrameNode("test1", 1, AceType::MakeRefPtr<Pattern>(), false);
1710     ASSERT_NE(framenodeOne, nullptr);
1711     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1712     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1713     ASSERT_NE(gestureEventHub, nullptr);
1714     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1715         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1716     auto dragPreviewOption = framenode->GetDragPreviewOption();
1717     dragPreviewOption.defaultAnimationBeforeLifting = true;
1718     framenode->SetDragPreviewOptions(dragPreviewOption);
1719     ASSERT_NE(dragEventActuator, nullptr);
1720     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1721     mockRenderContext->UpdateOpacity(1.1f);
1722     framenodeOne->renderContext_ = mockRenderContext;
1723     Dimension dimen(2.0);
1724     BlurBackGroundInfo bgBackEffect = { { dimen, 1.0f, 1.0f, Color::TRANSPARENT, AdaptiveColor::DEFAULT,
1725         { { 2.0f, 2.0f } } } };
1726     Shadow shadow;
1727     shadow.SetIsFilled(false);
1728     shadow.SetOffset(Offset(5, 5));
1729     shadow.SetBlurRadius(10.0);
1730     shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
1731     BorderRadiusProperty borderRadius;
1732     borderRadius.SetRadius(Dimension(0.1));
1733     OptionsAfterApplied optionTmp = { 0, shadow, "test", true, borderRadius, { bgBackEffect } };
1734     NG::DragPreviewOption previewOptions;
1735     previewOptions.options = optionTmp;
1736     framenode->SetDragPreviewOptions(previewOptions);
1737     DragAnimationHelper::SetImageNodeInitAttr(framenode, framenodeOne);
1738     DragAnimationHelper::SetImageNodeFinishAttr(framenode, framenodeOne);
1739     previewOptions.options.shadow->isFilled_ = true;
1740     framenode->SetDragPreviewOptions(previewOptions);
1741     DragAnimationHelper::SetImageNodeFinishAttr(framenode, framenodeOne);
1742 
1743     DragDropInfo dragDropInfo;
1744     RefPtr<PixelMap> pixelMap = PixelMap::CreatePixelMap(static_cast<void*>(new char[0]));
1745     dragDropInfo.pixelMap = pixelMap;
1746     dragDropInfo.inspectorId = "";
1747     gestureEventHub->dragPreviewPixelMap_ = pixelMap;
1748     framenode->SetDragPreview(dragDropInfo);
1749     GatherNodeChildInfo gatherNodeChildInfo;
1750     dragEventActuator->CreateImageNode(framenode, gatherNodeChildInfo);
1751     EXPECT_EQ(shadow.GetBlurRadius(), 10.0);
1752 }
1753 
1754 /**
1755  * @tc.name: DragEventActuatorMountGatherNodeTest027
1756  * @tc.desc: Test MountGatherNode function.
1757  * @tc.type: FUNC
1758  */
1759 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest027, TestSize.Level1)
1760 {
1761     auto eventHub = AceType::MakeRefPtr<EventHub>();
1762     ASSERT_NE(eventHub, nullptr);
1763     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1764     ASSERT_NE(frameNode, nullptr);
1765     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1766     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1767     ASSERT_NE(gestureEventHub, nullptr);
1768     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1769         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1770     ASSERT_NE(dragEventActuator, nullptr);
1771     auto pipelineContext = PipelineContext::GetCurrentContext();
1772     ASSERT_NE(pipelineContext, nullptr);
1773     auto manager = pipelineContext->GetOverlayManager();
1774     ASSERT_NE(manager, nullptr);
1775     auto gestureHub = dragEventActuator->gestureEventHub_.Upgrade();
1776     ASSERT_NE(gestureHub, nullptr);
1777     auto frameNodeOne = gestureHub->GetFrameNode();
1778     ASSERT_NE(frameNodeOne, nullptr);
1779     manager->gatherNodeWeak_ = frameNodeOne;
1780     auto gatherNode = manager->GetGatherNode();
1781     ASSERT_NE(gatherNode, nullptr);
1782     std::vector<GatherNodeChildInfo> gatherNodeChildrenInfo(2);
1783     MockContainer::SetUp();
1784     auto container = MockContainer::Current();
1785     container->isSceneBoardWindow_ = true;
1786     dragEventActuator->MountGatherNode(manager, frameNode, gatherNode, gatherNodeChildrenInfo);
1787     container->isSceneBoardWindow_ = false;
1788     MockContainer::TearDown();
1789     EXPECT_EQ(container->isSceneBoardWindow_, false);
1790 }
1791 
1792 /**
1793  * @tc.name: DragEventActuatorMountGatherNodeTest028
1794  * @tc.desc: Test IsBelongToMultiItemNode function.
1795  * @tc.type: FUNC
1796  */
1797 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest028, TestSize.Level1)
1798 {
1799     auto eventHub = AceType::MakeRefPtr<EventHub>();
1800     ASSERT_NE(eventHub, nullptr);
1801     auto frameNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1802     ASSERT_NE(frameNode, nullptr);
1803     auto parentNode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1804     ASSERT_NE(parentNode, nullptr);
1805     frameNode->SetParent(parentNode);
1806 
1807     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(frameNode));
1808     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1809     ASSERT_NE(gestureEventHub, nullptr);
1810     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1811         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1812     dragEventActuator->IsBelongToMultiItemNode(frameNode);
1813     DragPreviewOption previewOption;
1814     previewOption.isMultiSelectionEnabled = true;
1815     parentNode->SetDragPreviewOptions(previewOption);
1816     dragEventActuator->IsBelongToMultiItemNode(frameNode);
1817     auto eventHubp = parentNode->GetOrCreateEventHub<EventHub>();
1818     ASSERT_NE(eventHubp, nullptr);
__anonfd430c6c2c02(const RefPtr<OHOS::Ace::DragEvent>&, const std::string&) 1819     auto func = [](const RefPtr<OHOS::Ace::DragEvent>&, const std::string&) { return DragDropInfo(); };
1820     eventHubp->onDragStart_ = func;
1821     dragEventActuator->IsBelongToMultiItemNode(frameNode);
1822     auto childNode = FrameNode::CreateFrameNode(V2::GRID_ITEM_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), false);
1823     ASSERT_NE(childNode, nullptr);
1824     auto parentNodeTwo = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1825     ASSERT_NE(parentNodeTwo, nullptr);
1826     childNode->SetParent(parentNodeTwo);
1827     dragEventActuator->FindItemParentNode(frameNode);
1828     dragEventActuator->FindItemParentNode(childNode);
1829     EXPECT_EQ(previewOption.isMultiSelectionEnabled, true);
1830 }
1831 
1832 /**
1833  * @tc.name: DragEventActuatorMountGatherNodeTest029
1834  * @tc.desc: Test PrepareShadowParametersForDragData
1835  * @tc.type: FUNC
1836  */
1837 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest029, TestSize.Level1)
1838 {
1839     auto eventHub = AceType::MakeRefPtr<EventHub>();
1840     ASSERT_NE(eventHub, nullptr);
1841     auto framenode = FrameNode::CreateFrameNode(V2::RICH_EDITOR_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), false);
1842     ASSERT_NE(framenode, nullptr);
1843     auto framenodeOne = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 1, AceType::MakeRefPtr<Pattern>(), false);
1844     ASSERT_NE(framenodeOne, nullptr);
1845     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1846     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1847     ASSERT_NE(gestureEventHub, nullptr);
1848     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1849         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1850     ASSERT_NE(dragEventActuator, nullptr);
1851     Dimension dimen(2.0);
1852     BlurBackGroundInfo bgBackEffect = { { dimen, 1.0f, 1.0f, Color::TRANSPARENT, AdaptiveColor::DEFAULT,
1853         { { 2.0f, 2.0f } } } };
1854     Shadow shadow;
1855     shadow.SetIsFilled(false);
1856     shadow.SetOffset(Offset(5, 5));
1857     shadow.SetBlurRadius(10.0);
1858     shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
1859     BorderRadiusProperty borderRadius;
1860     borderRadius.SetRadius(Dimension(0.1));
1861     OptionsAfterApplied optionTmp = { 0, shadow, "test", true, borderRadius, { bgBackEffect } };
1862     NG::DragPreviewOption previewOptions;
1863     previewOptions.options = optionTmp;
1864     previewOptions.options.shadow->isFilled_ = true;
1865     framenode->SetDragPreviewOptions(previewOptions);
1866     framenodeOne->SetDragPreviewOptions(previewOptions);
1867     std::unique_ptr<JsonValue> arkExtraInfoJson = std::make_unique<JsonValue>();
1868     float scale = 1.0f;
1869     auto gestureHub = framenode->GetOrCreateGestureEventHub();
1870     auto gestureHubOne = framenodeOne->GetOrCreateGestureEventHub();
1871     dragEventActuator->PrepareShadowParametersForDragData(framenode, arkExtraInfoJson, scale);
1872     gestureHub->textDraggable_ = true;
1873     dragEventActuator->PrepareShadowParametersForDragData(framenode, arkExtraInfoJson, scale);
1874     gestureHub->isTextDraggable_ = true;
1875     dragEventActuator->PrepareShadowParametersForDragData(framenode, arkExtraInfoJson, scale);
1876     gestureHubOne->isTextDraggable_ = true;
1877     gestureHubOne->textDraggable_ = true;
1878     dragEventActuator->PrepareShadowParametersForDragData(framenodeOne, arkExtraInfoJson, scale);
1879     EXPECT_EQ(gestureHubOne->textDraggable_, true);
1880 }
1881 
1882 /**
1883  * @tc.name: DragEventActuatorMountGatherNodeTest030
1884  * @tc.desc: Test PrepareShadowParametersForDragData
1885  * @tc.type: FUNC
1886  */
1887 HWTEST_F(DragEventTestNg, DragEventActuatorMountGatherNodeTest030, TestSize.Level1)
1888 {
1889     auto eventHub = AceType::MakeRefPtr<EventHub>();
1890     ASSERT_NE(eventHub, nullptr);
1891     auto framenode = FrameNode::CreateFrameNode("test", 1, AceType::MakeRefPtr<Pattern>(), false);
1892     ASSERT_NE(framenode, nullptr);
1893     eventHub->host_ = AceType::WeakClaim(AceType::RawPtr(framenode));
1894     auto gestureEventHub = AceType::MakeRefPtr<GestureEventHub>(AceType::WeakClaim(AceType::RawPtr(eventHub)));
1895     ASSERT_NE(gestureEventHub, nullptr);
1896     auto dragEventActuator = AceType::MakeRefPtr<DragEventActuator>(
1897         AceType::WeakClaim(AceType::RawPtr(gestureEventHub)), DRAG_DIRECTION, FINGERS_NUMBER, DISTANCE);
1898     ASSERT_NE(dragEventActuator, nullptr);
1899     Dimension dimen(2.0);
1900     BlurBackGroundInfo bgBackEffect = { { dimen, 1.0f, 1.0f, Color::TRANSPARENT, AdaptiveColor::DEFAULT,
1901         { { 2.0f, 2.0f } } } };
1902     Shadow shadow;
1903     shadow.SetIsFilled(false);
1904     shadow.SetOffset(Offset(0, 0));
1905     shadow.SetBlurRadius(-10.0);
1906     shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
1907     BorderRadiusProperty borderRadius;
1908     borderRadius.SetRadius(Dimension(0.1));
1909     OptionsAfterApplied optionTmp = { 0, shadow, "test", true, borderRadius, { bgBackEffect } };
1910     NG::DragPreviewOption previewOptions;
1911     previewOptions.options = optionTmp;
1912     previewOptions.options.shadow->isFilled_ = true;
1913     framenode->SetDragPreviewOptions(previewOptions);
1914     std::unique_ptr<JsonValue> arkExtraInfoJson = std::make_unique<JsonValue>();
1915     float scale = 1.0f;
1916     dragEventActuator->PrepareShadowParametersForDragData(framenode, arkExtraInfoJson, scale);
1917     Shadow shadows;
1918     shadows.SetIsFilled(false);
1919     shadows.SetOffset(Offset(5, 5));
1920     optionTmp = { 0, shadows, "test", true, borderRadius, { bgBackEffect } };
1921     previewOptions.options = optionTmp;
1922     framenode->SetDragPreviewOptions(previewOptions);
1923     dragEventActuator->PrepareShadowParametersForDragData(framenode, arkExtraInfoJson, scale);
1924     EXPECT_EQ(previewOptions.options.opacity, 0.0f);
1925 }
1926 }