• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "test/unittest/core/manager/drag_drop_manager_test_ng.h"
17 
18 #include "test/mock/core/render/mock_render_context.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 namespace OHOS::Ace::NG {
23 
TestFunction(const DragPointerEvent & event)24 void  TestFunction(const DragPointerEvent& event) {}
25 
SetUpTestCase()26 void DragDropManagerTestNg::SetUpTestCase()
27 {
28     MockPipelineContext::SetUp();
29     MockContainer::SetUp();
30 }
31 
TearDownTestCase()32 void DragDropManagerTestNg::TearDownTestCase()
33 {
34     MockPipelineContext::TearDown();
35     MockContainer::TearDown();
36 }
37 
38 /**
39  * @tc.name: DragDropManagerTest001
40  * @tc.desc: CreateAndShowItemDragOverlay via pixelMap and gestureEvent
41  * @tc.type: FUNC
42  * @tc.author:
43  */
44 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest001, TestSize.Level1)
45 {
46     /**
47      * @tc.steps: step1. construct a DragDropManager
48      */
49     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
50 
51     /**
52      * @tc.steps: step2. call CreateAndShowItemDragOverlay
53      * @tc.expected: step2. return a dragDropProxy successfully
54      *                      DragWindow.DrawPixelMap() will be called
55      */
56     void* voidPtr = static_cast<void*>(new char[0]);
57     RefPtr<PixelMap> pixelMap = PixelMap::CreatePixelMap(voidPtr);
58     GestureEvent gestureEvent;
59     RefPtr<EventHub> eventhub;
60     auto dragDropProxy = dragDropManager->CreateAndShowItemDragOverlay(pixelMap, gestureEvent, eventhub);
61     EXPECT_TRUE(dragDropProxy);
62 
63     /**
64      * @tc.steps: step3. call CreateAndShowItemDragOverlay with null.
65      * @tc.expected: step3. return dragDropProxy to false.
66      */
67     pixelMap = nullptr;
68     dragDropProxy = dragDropManager->CreateAndShowItemDragOverlay(pixelMap, gestureEvent, eventhub);
69     EXPECT_FALSE(dragDropProxy);
70 }
71 
72 /**
73  * @tc.name: DragDropManagerTest002
74  * @tc.desc: CreateAndShowItemDragOverlay via customNode and gestureEvent
75  * @tc.type: FUNC
76  * @tc.author:
77  */
78 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest002, TestSize.Level1)
79 {
80     /**
81      * @tc.steps: step1. construct a DragDropManager
82      */
83     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
84 
85     /**
86      * @tc.steps: step2. call CreateAndShowItemDragOverlay
87      * @tc.expected: step2. return a dragDropProxy successfully
88      *                      DragWindow.DrawFrameNode() will be called
89      */
90     RefPtr<UINode> customNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
91     GestureEvent gestureEvent;
92     RefPtr<EventHub> eventhub;
93     auto dragDropProxy = dragDropManager->CreateAndShowItemDragOverlay(customNode, gestureEvent, eventhub);
94     EXPECT_TRUE(dragDropProxy);
95 
96     /**
97      * @tc.expected: step2. the customNode's parent is root
98      */
99     auto root = customNode->GetParent();
100     auto rootTag = root->GetTag();
101     EXPECT_EQ(rootTag, ROOT_ETS_TAG);
102 }
103 
104 /**
105  * @tc.name: DragDropManagerTest003
106  * @tc.desc: Test UpdateItemDragPosition
107  * @tc.type: FUNC
108  * @tc.author:
109  */
110 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest003, TestSize.Level1)
111 {
112     /**
113      * @tc.steps: step1. construct a DragDropManager
114      */
115     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
116 
117     /**
118      * @tc.steps: step2. call CreateAndShowItemDragOverlay
119      * @tc.expected: step2. return a dragDropProxy successfully
120      */
121     RefPtr<UINode> customNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
122     GestureEvent gestureEvent;
123     RefPtr<EventHub> eventhub;
124     auto dragDropProxy = dragDropManager->CreateAndShowItemDragOverlay(customNode, gestureEvent, eventhub);
125     EXPECT_TRUE(dragDropProxy);
126     auto pipelineContext = MockPipelineContext::GetCurrentContext();
127     ASSERT_NE(pipelineContext, nullptr);
128     pipelineContext->SetDisplayWindowRectInfo({ 0, 0, 800, 800 }); // 800: window width and height
129     /**
130      * @tc.steps: step3. call UpdateItemDragPosition
131      * @tc.expected: step3. itemDragOverlayNode_'s position is updated to (GLOBAL_X, GLOBAL_Y)
132      */
133     dragDropManager->UpdateItemDragPosition(GLOBAL_X, GLOBAL_Y);
134     auto renderContext = dragDropManager->itemDragOverlayNode_->GetRenderContext();
135     EXPECT_EQ(renderContext->GetPosition().value(), OffsetT<Dimension>(Dimension(GLOBAL_X), Dimension(GLOBAL_Y)));
136 }
137 
138 /**
139  * @tc.name: DragDropManagerTest004
140  * @tc.desc: Test Functions relevant to Clipboard
141              Call this functions in order (AddDataToClipboard->GetExtraInfoFromClipboard->RestoreClipboardData)
142  * @tc.type: FUNC
143  * @tc.author:
144  */
145 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest004, TestSize.Level1)
146 {
147     /**
148      * @tc.steps: step1. construct a DragDropManager
149      */
150     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
151 
152     /**
153      * @tc.steps: step2. call AddDataToClipboard
154      * @tc.expected: step2. ClipBoard.SetData() & ClipBoard.GetData() will be called with printing logs
155      *                      they're defined in "components_ng/test/mock/clipboard/mock_clipboard.cpp"
156      */
157     dragDropManager->AddDataToClipboard(EXTRA_INFO);
158 
159     /**
160      * @tc.steps: step3. call GetExtraInfoFromClipboard after calling AddDataToClipboard
161      * @tc.expected: step3. get the extraInfo successfully
162      *                      ClipBoard.GetData() will be called with printing a log
163      *                      it's defined in "components_ng/test/mock/clipboard/mock_clipboard.cpp"
164      */
165     std::string extraInfo;
166     dragDropManager->GetExtraInfoFromClipboard(extraInfo);
167     EXPECT_EQ(extraInfo, EXTRA_INFO);
168 
169     /**
170      * @tc.steps: step4. call GetExtraInfoFromClipboard
171      * @tc.expected: step4. extraInfo is equal to EXTRA_INFO
172      */
173     dragDropManager->clipboard_ = nullptr;
174     dragDropManager->GetExtraInfoFromClipboard(extraInfo);
175     EXPECT_EQ(extraInfo, EXTRA_INFO);
176 
177     /**
178      * @tc.steps: step5. call AddDataToClipboard with empty.
179      * @tc.expected: step5. extraInfo is equal to EXTRA_INFO
180      */
181     dragDropManager->AddDataToClipboard(extraInfo);
182     EXPECT_EQ(extraInfo, EXTRA_INFO);
183 }
184 
185 /**
186  * @tc.name: DragDropManagerTest005
187  * @tc.desc: Test Functions relevant to Clipboard
188              Call this functions not in order (to test boundary cases)
189  * @tc.type: FUNC
190  * @tc.author:
191  */
192 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest005, TestSize.Level1)
193 {
194     /**
195      * @tc.steps: step1. construct a DragDropManager
196      */
197     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
198 
199     /**
200      * @tc.steps: step3. call AddDataToClipboard twice
201      *                   case: clipboard_ & addDataCallback_ has exited,
202      * @tc.expected: step3. EXTRA_INFO_2 will be added
203      */
204     dragDropManager->AddDataToClipboard(EXTRA_INFO);
205     dragDropManager->AddDataToClipboard(EXTRA_INFO_2);
206     std::string extraInfo;
207     dragDropManager->GetExtraInfoFromClipboard(extraInfo);
208     EXPECT_EQ(extraInfo, EXTRA_INFO_2);
209 
210     /**
211      * @tc.steps: step4. call GetExtraInfoFromClipboard twice
212      *                   case: clipboard_ & addDataCallback_ has exited
213      * @tc.expected: step4. get the extraInfo successfully
214      */
215     dragDropManager->GetExtraInfoFromClipboard(extraInfo);
216     EXPECT_EQ(extraInfo, EXTRA_INFO_2);
217 }
218 
219 /**
220  * @tc.name: DragDropManagerTest006
221  * @tc.desc: Test DestroyDragWindow & CheckDragDropProxy
222  * @tc.type: FUNC
223  * @tc.author:
224  */
225 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest006, TestSize.Level1)
226 {
227     /**
228      * @tc.steps: step1. construct a DragDropManager
229      */
230     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
231 
232     /**
233      * @tc.steps: step2. call DestroyDragWindow without creating dragWindow
234      * @tc.expected: step2. no fatal error happens
235      */
236     dragDropManager->DestroyDragWindow();
237 
238     /**
239      * @tc.steps: step3. call CheckDragDropProxy without creating dragWindow
240      * @tc.expected: step3. currentId is -1 at first
241      */
242     auto flag = dragDropManager->CheckDragDropProxy(INVALID_CURRENT_ID);
243     EXPECT_TRUE(flag);
244 
245     /**
246      * @tc.steps: step4. call CreateFrameworkDragDropProxy
247      * @tc.expected: step4. return a dragDropProxy successfully
248      */
249     auto dragDropProxy = dragDropManager->CreateFrameworkDragDropProxy();
250     EXPECT_TRUE(dragDropProxy);
251 
252     /**
253      * @tc.steps: step5. call CheckDragDropProxy after creating dragWindow
254      * @tc.expected: step5. currentId recover to -1
255      *                      MockDragWindow.Destroy() will be called
256      */
257     dragDropManager->DestroyDragWindow();
258     flag = dragDropManager->CheckDragDropProxy(INVALID_CURRENT_ID);
259     EXPECT_TRUE(flag);
260 
261     /**
262      * @tc.steps: step6. call CheckDragDropProxy (use proxy to create drag window)
263      * @tc.expected: step6. currentId recover to -1
264      */
265     auto dragDropManager2 = AceType::MakeRefPtr<DragDropManager>();
266     auto dragDropProxy2 = dragDropManager2->CreateFrameworkDragDropProxy();
267     EXPECT_TRUE(dragDropProxy2);
268     dragDropManager2->DestroyDragWindow();
269     flag = dragDropManager2->CheckDragDropProxy(INVALID_CURRENT_ID);
270     EXPECT_TRUE(flag);
271 }
272 
273 /**
274  * @tc.name: DragDropManagerTest007
275  * @tc.desc: Test OnDragStart & onDragCancel & OnItemDragStart & onItemDragCancel
276  * @tc.type: FUNC
277  * @tc.author:
278  */
279 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest007, TestSize.Level1)
280 {
281     /**
282      * @tc.steps: step1. construct a DragDropManager
283      */
284     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
285 
286     /**
287      * @tc.steps: step2. call OnDragStart
288      * @tc.expected: step2. draggedFrameNode_ &  preTargetFrameNode_ are assigned to the frameNode created previously
289      */
290     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
291     dragDropManager->OnDragStart({ GLOBAL_X, GLOBAL_Y }, frameNode);
292     auto draggedNode = dragDropManager->draggedFrameNode_;
293     auto preTargetNode = dragDropManager->preTargetFrameNode_;
294     ASSERT_TRUE(draggedNode);
295     ASSERT_TRUE(preTargetNode);
296     auto draggedNodeTag = draggedNode->GetTag();
297     auto preTargetNodeTag = preTargetNode->GetTag();
298     EXPECT_EQ(draggedNodeTag, NODE_TAG);
299     EXPECT_EQ(preTargetNodeTag, NODE_TAG);
300 
301     /**
302      * @tc.steps: step3. call onDragCancel
303      * @tc.expected: step3. draggedFrameNode_ &  preTargetFrameNode_ are assigned to nullptr
304      */
305     dragDropManager->onDragCancel();
306     draggedNode = dragDropManager->draggedFrameNode_;
307     preTargetNode = dragDropManager->preTargetFrameNode_;
308     EXPECT_FALSE(draggedNode);
309     EXPECT_FALSE(preTargetNode);
310 
311     /**
312      * @tc.steps: step4. call OnItemDragStart
313      * @tc.expected: step4. preGridTargetNodeTag is assigned to the gridFrameNode created previously
314      */
315     auto gridFrameNode = AceType::MakeRefPtr<FrameNode>(GRID_TAG, -1, AceType::MakeRefPtr<Pattern>());
316     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, gridFrameNode);
317     auto preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
318     ASSERT_TRUE(preGridTargetNode);
319     auto preGridTargetNodeTag = preGridTargetNode->GetTag();
320     EXPECT_EQ(preGridTargetNodeTag, GRID_TAG);
321 
322     /**
323      * @tc.steps: step5. call onItemDragCancel
324      * @tc.expected: step5. preGridTargetFrameNode_ is assigned to nullptr
325      */
326     dragDropManager->onItemDragCancel();
327     preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
328     EXPECT_FALSE(preGridTargetNode);
329 }
330 
331 /**
332  * @tc.name: DragDropManagerTest009
333  * @tc.desc: Test OnItemDragMove DragType is Grid
334  * @tc.type: FUNC
335  * @tc.author:
336  */
337 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest008, TestSize.Level1)
338 {
339     /**
340      * @tc.steps: step1. construct a DragDropManager
341      */
342     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
343 
344     /**
345      * @tc.steps: step2. construct a frameNode whose tag is Grid set its ItemDragEvent and GeometryNode
346      */
347     auto frameNode = AceType::MakeRefPtr<FrameNode>(GRID_TAG, -1, AceType::MakeRefPtr<GridPattern>());
348     auto eventHub = frameNode->GetEventHub<GridEventHub>();
349     ASSERT_TRUE(eventHub);
350     RefPtr<UINode> customNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
351     GestureEvent gestureEvent;
352     auto dragDropProxy = dragDropManager->CreateAndShowItemDragOverlay(customNode, gestureEvent, eventHub);
353     EXPECT_TRUE(dragDropProxy);
354 
355     // Set OnItemDragLeave callback
356     std::string itemInfoLeave;
__anond75c6b370102(const ItemDragInfo& , int32_t ) 357     auto onItemDragLeave = [&itemInfoLeave](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */) {
358         itemInfoLeave = ITEM_INFO_LEAVE;
359     };
360     eventHub->SetOnItemDragLeave(std::move(onItemDragLeave));
361 
362     // Set OnItemDragMove callback
363     std::string itemInfoMove;
364     auto onItemDragMove = [&itemInfoMove](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
__anond75c6b370202(const ItemDragInfo& , int32_t , int32_t ) 365                               int32_t /* insertIndex */) { itemInfoMove = ITEM_INFO_MOVE; };
366     eventHub->SetOnItemDragMove(std::move(onItemDragMove));
367 
368     // Set OnItemDragEnter callback
369     std::string itemInfoEnter;
__anond75c6b370302(const ItemDragInfo& ) 370     auto onItemDragEnter = [&itemInfoEnter](const ItemDragInfo& /* dragInfo */) { itemInfoEnter = ITEM_INFO_ENTER; };
371     eventHub->SetOnItemDragEnter(std::move(onItemDragEnter));
372 
373     // Set geometry node to make sure (GLOBAL_X, GLOBAL_Y) in geoNode.frameRect_
374     auto geoNode = AceType::MakeRefPtr<GeometryNode>();
375     geoNode->SetMarginFrameOffset(FRAME_OFFSET);
376     geoNode->SetFrameSize(FRAME_SIZE);
377     frameNode->SetGeometryNode(geoNode);
378 
379     /**
380      * @tc.steps: step4. call OnItemDragMove
381      *                   case: gridDragFrameNodes_ is empty & preGridTargetFrameNode_ is not null
382      * @tc.expected: step4. frameNode's onItemDragLeave_ will be called
383      *                      itemInfoLeave will be assigned to ITEM_INFO_LEAVE
384      */
385     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, frameNode);
386     auto preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
387     ASSERT_TRUE(preGridTargetNode);
388     dragDropManager->OnItemDragMove(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
389     EXPECT_EQ(itemInfoLeave, ITEM_INFO_LEAVE);
390     preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
391     EXPECT_FALSE(preGridTargetNode);
392 
393     /**
394      * @tc.steps: step5. call AddGridDragFrameNode
395      *                   after that, gridDragFrameNodes_ is not empty
396      */
397     dragDropManager->AddGridDragFrameNode(frameNode->GetId(), frameNode);
398 
399     /**
400      * @tc.steps: step6. call OnItemDragMove
401      *                   case: gridDragFrameNodes_ is not empty & preGridTargetFrameNode_ equals the frameNode
402      * @tc.expected: step6. frameNode's OnItemDragMove_ will be called
403      *                      itemInfoMove will be assigned to ITEM_INFO_MOVE
404      */
405     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, frameNode);
406     preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
407     EXPECT_TRUE(preGridTargetNode);
408     dragDropManager->OnItemDragMove(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
409 
410     /**
411      * @tc.steps: step7. call OnItemDragMove
412      *                   case: gridDragFrameNodes_ is not empty & preGridTargetFrameNode_ not equals the frameNode
413      * @tc.expected: step7. frameNode's onDragItemEnter_ will be called
414      *                      itemInfoEnter will be assigned to ITEM_INFO_ENTER
415      *                      preGridTargetFrameNode_'s onDragItemLeave will be called
416      *                      leaveExtraInfoNew will be assigned to ITEM_INFO_ENTER
417      *                      preGridTargetFrameNode_ is assigned to frameNode
418      */
419     auto newFrameNode = AceType::MakeRefPtr<FrameNode>(GRID_TAG, -1, AceType::MakeRefPtr<GridPattern>());
420     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, newFrameNode);
421     preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
422     EXPECT_TRUE(preGridTargetNode);
423     // Set newFrameNode's onDragLeave callback
424     auto eventHubNew = newFrameNode->GetEventHub<GridEventHub>();
425     ASSERT_TRUE(eventHubNew);
426     std::string itemInfoLeaveNew;
__anond75c6b370402(const ItemDragInfo& , int32_t ) 427     auto onItemDragLeaveNew = [&itemInfoLeaveNew](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */) {
428         itemInfoLeaveNew = ITEM_INFO_ENTER;
429     };
430     eventHubNew->SetOnItemDragLeave(std::move(onItemDragLeaveNew));
431     dragDropManager->OnItemDragMove(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
432     EXPECT_EQ(itemInfoLeaveNew, ITEM_INFO_ENTER);
433     preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
434     ASSERT_FALSE(preGridTargetNode);
435 }
436 
437 /**
438  * @tc.name: DragDropManagerTest010
439  * @tc.desc: Test OnItemDragMove DragType is List
440  * @tc.type: FUNC
441  * @tc.author:
442  */
443 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest009, TestSize.Level1)
444 {
445     /**
446      * @tc.steps: step1. construct a DragDropManager
447      */
448     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
449 
450     /**
451      * @tc.steps: step2. construct a frameNode whose tag is List set its ItemDragEvent and GeometryNode
452      */
453     auto frameNode = AceType::MakeRefPtr<FrameNode>(LIST_TAG, -1, AceType::MakeRefPtr<ListPattern>());
454     auto eventHub = frameNode->GetEventHub<ListEventHub>();
455     ASSERT_TRUE(eventHub);
456 
457     // Set OnItemDragLeave callback
458     std::string itemInfoLeave;
__anond75c6b370502(const ItemDragInfo& , int32_t ) 459     auto onItemDragLeave = [&itemInfoLeave](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */) {
460         itemInfoLeave = ITEM_INFO_LEAVE;
461     };
462     eventHub->SetOnItemDragLeave(std::move(onItemDragLeave));
463 
464     // Set OnItemDragMove callback
465     std::string itemInfoMove;
466     auto onItemDragMove = [&itemInfoMove](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
__anond75c6b370602(const ItemDragInfo& , int32_t , int32_t ) 467                               int32_t /* insertIndex */) { itemInfoMove = ITEM_INFO_MOVE; };
468     eventHub->SetOnItemDragMove(std::move(onItemDragMove));
469 
470     // Set OnItemDragEnter callback
471     std::string itemInfoEnter;
__anond75c6b370702(const ItemDragInfo& ) 472     auto onItemDragEnter = [&itemInfoEnter](const ItemDragInfo& /* dragInfo */) { itemInfoEnter = ITEM_INFO_ENTER; };
473     eventHub->SetOnItemDragEnter(std::move(onItemDragEnter));
474 
475     // Set geometry node to make sure (GLOBAL_X, GLOBAL_Y) in geoNode.frameRect_
476     auto geoNode = AceType::MakeRefPtr<GeometryNode>();
477     geoNode->SetMarginFrameOffset(FRAME_OFFSET);
478     geoNode->SetFrameSize(FRAME_SIZE);
479     frameNode->SetGeometryNode(geoNode);
480 
481     /**
482      * @tc.steps: step3. call OnItemDragMove
483      *                   case: listDragFrameNodes_ is empty & preGridTargetFrameNode_ is not null
484      * @tc.expected: step3. frameNode's onItemDragLeave_ will be called
485      *                      itemInfoLeave will be assigned to ITEM_INFO_LEAVE
486      */
487     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, frameNode);
488     auto preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
489     ASSERT_TRUE(preGridTargetNode);
490     dragDropManager->OnItemDragMove(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_LIST);
491     EXPECT_EQ(itemInfoLeave, ITEM_INFO_LEAVE);
492     preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
493     EXPECT_FALSE(preGridTargetNode);
494 
495     /**
496      * @tc.steps: step4. call AddGridDragFrameNode
497      *                   after that, listDragFrameNodes_ is not empty
498      *                   need adding grid maybe a bug
499      */
500     dragDropManager->AddGridDragFrameNode(frameNode->GetId(), frameNode);
501 
502     /**
503      * @tc.steps: step5. call OnItemDragMove
504      *                   case: listDragFrameNodes_ is not empty & preGridTargetFrameNode_ equals the frameNode
505      * @tc.expected: step5. a gridEventHub is trying to get by the frameNode,
506      *                      but it's list type, so will return early(maybe that is a bug)
507      *                      itemInfoMove will not be assigned DragWindow.MoveTo() will be called
508      */
509     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, frameNode);
510     preGridTargetNode = dragDropManager->preGridTargetFrameNode_;
511     EXPECT_TRUE(preGridTargetNode);
512     dragDropManager->OnItemDragMove(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_LIST);
513     EXPECT_EQ(itemInfoMove, "");
514     // to force call the FireOnItemDragEvent with DragType::LIST and DragEventType::MOVE
515     OHOS::Ace::ItemDragInfo itemDragInfo;
516     dragDropManager->FireOnItemDragEvent(frameNode, DragType::LIST, itemDragInfo, DragEventType::MOVE, DRAGGED_INDEX);
517     EXPECT_EQ(itemInfoMove, ITEM_INFO_MOVE);
518 
519     /**
520      * @tc.steps: step6. call OnItemDragMove
521      *                   case: listDragFrameNodes_ is not empty & preGridTargetFrameNode_ not equals the frameNode
522      * @tc.expected: step6. frameNode's onDragItemEnter_ will be called
523      *                      itemInfoEnter will be assigned to ITEM_INFO_ENTER
524      *                      preGridTargetFrameNode_'s onDragItemLeave will be called
525      *                      leaveExtraInfoNew will be assigned to ITEM_INFO_ENTER
526      *                      preGridTargetFrameNode_ is assigned to frameNode
527      */
528     auto newFrameNode = AceType::MakeRefPtr<FrameNode>(LIST_TAG, -1, AceType::MakeRefPtr<ListPattern>());
529     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, newFrameNode);
530     EXPECT_TRUE(dragDropManager->preGridTargetFrameNode_);
531     // Set newFrameNode's onDragLeave callback
532     auto eventHubNew = newFrameNode->GetEventHub<ListEventHub>();
533     ASSERT_TRUE(eventHubNew);
534     std::string itemInfoLeaveNew;
__anond75c6b370802(const ItemDragInfo& , int32_t ) 535     auto onItemDragLeaveNew = [&itemInfoLeaveNew](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */) {
536         itemInfoLeaveNew = ITEM_INFO_ENTER;
537     };
538     eventHubNew->SetOnItemDragLeave(std::move(onItemDragLeaveNew));
539     EXPECT_EQ(itemInfoEnter, "");
540     EXPECT_EQ(itemInfoLeaveNew, "");
541     ASSERT_TRUE(dragDropManager->preGridTargetFrameNode_);
542     auto preGridTargetNodeTag = dragDropManager->preGridTargetFrameNode_->GetTag();
543     EXPECT_EQ(preGridTargetNodeTag, LIST_TAG);
544 
545     /**
546      * @tc.steps: step7. call OnItemDragMove
547      *                   case: listDragFrameNodes_ is not empty & preGridTargetFrameNode_ is null
548      * @tc.expected: step7. frameNode's onDragItemEnter_ will be called
549      *                      itemInfoEnter will be assigned to ITEM_INFO_ENTER
550      */
551     dragDropManager->onItemDragCancel();
552     EXPECT_FALSE(dragDropManager->preGridTargetFrameNode_);
553     itemInfoEnter = "";
554     dragDropManager->OnItemDragMove(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_LIST);
555     EXPECT_EQ(itemInfoEnter, "");
556 }
557 
558 /**
559  * @tc.name: DragDropManagerTest011
560  * @tc.desc: Test OnItemDragEnd type is grid
561  * @tc.type: FUNC
562  * @tc.author:
563  */
564 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest011, TestSize.Level1)
565 {
566     /**
567      * @tc.steps: step1. construct a DragDropManager
568      */
569     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
570 
571     /**
572      * @tc.steps: step2. construct a frameNode which type is grid and set its GeometryNode
573      */
574     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<GridPattern>());
575     auto eventHub = frameNode->GetEventHub<GridEventHub>();
576     ASSERT_TRUE(eventHub);
577 
578     // Set geometry node to make sure (GLOBAL_X, GLOBAL_Y) in geoNode.frameRect_
579     auto geoNode = AceType::MakeRefPtr<GeometryNode>();
580     geoNode->SetMarginFrameOffset(FRAME_OFFSET);
581     geoNode->SetFrameSize(FRAME_SIZE);
582     frameNode->SetGeometryNode(geoNode);
583 
584     /**
585      * @tc.steps: step3. call OnItemDragEnd
586      *                   case: gridDragFrameNodes_ is empty
587      * @tc.expected: step3. preGridTargetFrameNode_ is null
588      */
589     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
590     auto preGridTargetFrameNode = dragDropManager->preGridTargetFrameNode_;
591     EXPECT_FALSE(preGridTargetFrameNode);
592 
593     // case: gridDragFrameNodes_ is empty & preGridTargetFrameNode_ is not null
594     auto preGridTargetNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<GridPattern>());
595     auto preGridEvent = preGridTargetNode->GetEventHub<GridEventHub>();
596     std::string preGridDropInfo;
597     auto onPreGridItemDrop = [&preGridDropInfo](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
__anond75c6b370902(const ItemDragInfo& , int32_t , int32_t , bool ) 598                                  int32_t /* insertIndex */, bool /* isSuccess */) { preGridDropInfo = EXTRA_INFO; };
599     preGridEvent->SetOnItemDrop(std::move(onPreGridItemDrop));
600     dragDropManager->preGridTargetFrameNode_ = preGridTargetNode;
601     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
602     EXPECT_EQ(preGridDropInfo, "");
603 
604     /**
605      * @tc.steps: step4. call AddDragFrameNode
606      *                   after that, gridDragFrameNodes_ is not empty
607      */
608     dragDropManager->AddGridDragFrameNode(frameNode->GetId(), frameNode);
609 
610     /**
611      * @tc.steps: step5. call OnItemDragEnd
612      *                   case: eventHub dose not have onDrop_
613      * @tc.expected: step5. preGridTargetFrameNode_ is null
614      */
615     dragDropManager->preGridTargetFrameNode_ = nullptr;
616     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
617     preGridTargetFrameNode = dragDropManager->preGridTargetFrameNode_;
618     EXPECT_FALSE(preGridTargetFrameNode);
619 
620     /**
621      * @tc.steps: step6. call OnItemDragEnd
622      *                   case: eventHub dose have onDrop_
623      * @tc.expected: step6. frameNode's OnDrop_ will be called
624      *                      itemDropInfo will be assigned to EXTRA_INFO
625      *                      preGridTargetFrameNode_ be assigned to nullptr
626      */
627     std::string itemDropInfo;
628     auto onItemDrop = [&itemDropInfo](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
__anond75c6b370a02(const ItemDragInfo& , int32_t , int32_t , bool ) 629                           int32_t /* insertIndex */, bool /* isSuccess */) { itemDropInfo = EXTRA_INFO; };
630     eventHub->SetOnItemDrop(onItemDrop);
631     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
632     preGridTargetFrameNode = dragDropManager->preGridTargetFrameNode_;
633     EXPECT_FALSE(preGridTargetFrameNode);
634 
635     // case: preGridTargetFrameNode_ == dragFrameNode
636     dragDropManager->preGridTargetFrameNode_ = frameNode;
637     itemDropInfo.clear();
638     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
639 
640     // case: preGridTargetFrameNode_ != dragFrameNode
641     dragDropManager->preGridTargetFrameNode_ = preGridTargetNode;
642     itemDropInfo.clear();
643     preGridDropInfo.clear();
644     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
645     EXPECT_EQ(preGridDropInfo, "");
646 }
647 
648 /**
649  * @tc.name: DragDropManagerTest012
650  * @tc.desc: Test OnItemDragEnd type is list
651  * @tc.type: FUNC
652  * @tc.author:
653  */
654 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest012, TestSize.Level1)
655 {
656     /**
657      * @tc.steps: step1. construct a DragDropManager
658      */
659     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
660 
661     /**
662      * @tc.steps: step2. construct a frameNode which type is list and set its GeometryNode
663      */
664     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<ListPattern>());
665     auto eventHub = frameNode->GetEventHub<ListEventHub>();
666     ASSERT_TRUE(eventHub);
667 
668     // Set geometry node to make sure (GLOBAL_X, GLOBAL_Y) in geoNode.frameRect_
669     auto geoNode = AceType::MakeRefPtr<GeometryNode>();
670     geoNode->SetMarginFrameOffset(FRAME_OFFSET);
671     geoNode->SetFrameSize(FRAME_SIZE);
672     frameNode->SetGeometryNode(geoNode);
673 
674     /**
675      * @tc.steps: step3. call OnItemDragEnd
676      *                   case: listDragFrameNodes_ is empty
677      * @tc.expected: step3. preGridTargetFrameNode_ is null
678      */
679     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_LIST);
680     auto preGridTargetFrameNode = dragDropManager->preGridTargetFrameNode_;
681     EXPECT_FALSE(preGridTargetFrameNode);
682 
683     /**
684      * @tc.steps: step4. call AddDragFrameNode
685      *                   after that, listDragFrameNodes_ is not empty
686      */
687     dragDropManager->AddListDragFrameNode(frameNode->GetId(), frameNode);
688 
689     /**
690      * @tc.steps: step5. call OnItemDragEnd
691      * @tc.expected: step5. frameNode's OnDrop_ will be called
692      *                      itemDropInfo will be assigned to EXTRA_INFO
693      *                      preGridTargetFrameNode_ be assigned to nullptr
694      */
695     std::string itemDropInfo;
696     auto onItemDrop = [&itemDropInfo](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
__anond75c6b370b02(const ItemDragInfo& , int32_t , int32_t , bool ) 697                           int32_t /* insertIndex */, bool /* isSuccess */) { itemDropInfo = EXTRA_INFO; };
698     eventHub->SetOnItemDrop(onItemDrop);
699     dragDropManager->preGridTargetFrameNode_ = frameNode;
700     EXPECT_TRUE(dragDropManager->preGridTargetFrameNode_);
701     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_LIST);
702     preGridTargetFrameNode = dragDropManager->preGridTargetFrameNode_;
703     EXPECT_FALSE(preGridTargetFrameNode);
704 }
705 
706 /**
707  * @tc.name: DragDropManagerTest013
708  * @tc.desc: Test corner case
709  * @tc.type: FUNC
710  * @tc.author:
711  */
712 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest013, TestSize.Level1)
713 {
714     /**
715      * @tc.steps: step1. construct a DragDropManager
716      */
717     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
718 
719     /**
720      * @tc.steps: step2. call FindDragFrameNodeByPosition with frameNodes contains nullptr
721      * @tc.expected: step2.
722      */
723     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
724     auto frameNodeNull = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
725     dragDropManager->AddDragFrameNode(frameNodeNull->GetId(), frameNodeNull);
726     frameNodeNull.Reset();
727     auto frameNodeGeoNullId = ElementRegister::GetInstance()->MakeUniqueId();
728     auto frameNodeGeoNull =
729         AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeGeoNullId, AceType::MakeRefPtr<Pattern>());
730     frameNodeGeoNull->SetGeometryNode(nullptr);
731     dragDropManager->AddDragFrameNode(frameNodeGeoNull->GetId(), frameNodeGeoNull);
732     EXPECT_EQ(static_cast<int32_t>(dragDropManager->dragFrameNodes_.size()), 2);
733     auto targetFrameNode = dragDropManager->FindDragFrameNodeByPosition(GLOBAL_X, GLOBAL_Y);
734     EXPECT_FALSE(targetFrameNode);
735 
736     /**
737      * @tc.steps: step3. call FireOnDragEvent with type=DragEventType::DROP
738      * @tc.expected: step3. FireOnDrop will be called
739      */
740     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
741     auto eventHub = frameNode->GetEventHub<EventHub>();
742     std::string onDropInfo;
__anond75c6b370c02(const RefPtr<OHOS::Ace::DragEvent>& , const std::string& ) 743     auto onDrop = [&onDropInfo](const RefPtr<OHOS::Ace::DragEvent>& /* dragEvent */, const std::string& /* info */) {
744         onDropInfo = EXTRA_INFO;
745     };
746     eventHub->SetOnDrop(std::move(onDrop));
747     DragPointerEvent point;
748     TouchEvent event;
749     event.x = 1.0f;
750     event.y = 2.0f;
751     dragDropManager->velocityTracker_.UpdateTouchPoint(event, false);
752     dragDropManager->FireOnDragEvent(frameNode, point, DragEventType::DROP, EXTRA_INFO);
753     EXPECT_EQ(onDropInfo, EXTRA_INFO);
754 
755     /**
756      * @tc.steps: step4. call FireOnItemDropEvent with type=DragEventType::DROP
757      * @tc.expected: step4. FireOnItemDrop will be called
758      */
759     ItemDragInfo itemDragInfo;
760     auto gridNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<GridPattern>());
761     auto gridEvent = gridNode->GetEventHub<GridEventHub>();
762     std::string onItemDropInfo;
763     ItemDropFunc onItemDrop = [&onItemDropInfo](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
__anond75c6b370d02(const ItemDragInfo& , int32_t , int32_t , bool ) 764                                   int32_t /* insertIndex */, bool /* isSuccess */) { onItemDropInfo = EXTRA_INFO; };
765     gridEvent->SetOnItemDrop(std::move(onItemDrop));
766     dragDropManager->FireOnItemDropEvent(gridNode, DragType::GRID, itemDragInfo, 0, 0, true);
767     EXPECT_EQ(onItemDropInfo, EXTRA_INFO);
768 
769     auto listNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<ListPattern>());
770     auto listEvent = listNode->GetEventHub<ListEventHub>();
771     std::string onItemDropInfoList;
772     ItemDropFunc onItemDropList = [&onItemDropInfoList](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
773                                       int32_t /* insertIndex */,
__anond75c6b370e02(const ItemDragInfo& , int32_t , int32_t , bool ) 774                                       bool /* isSuccess */) { onItemDropInfoList = EXTRA_INFO; };
775     listEvent->SetOnItemDrop(std::move(onItemDropList));
776     dragDropManager->FireOnItemDropEvent(listNode, DragType::LIST, itemDragInfo, 0, 0, true);
777     EXPECT_EQ(onItemDropInfoList, EXTRA_INFO);
778 }
779 
780 /**
781  * @tc.name: DragDropManagerTest014
782  * @tc.desc: Test OnTextDragEnd
783  * @tc.type: FUNC
784  * @tc.author:
785  */
786 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest014, TestSize.Level1)
787 {
788     /**
789      * @tc.steps: step1. Create DragDropManager.
790      * @tc.expected: dragDropManager is not null.
791      */
792     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
793     ASSERT_NE(dragDropManager, nullptr);
794 
795     /**
796      * @tc.steps: step2. call OnTextDragEnd.
797      * @tc.expected: dragDropManager->currentId_ equals -1.
798      */
799     float globalX = 20.0f;
800     float globalY = 20.0f;
801     std::string extraInfo;
802     dragDropManager->OnTextDragEnd(globalX, globalY, extraInfo);
803     EXPECT_EQ(dragDropManager->currentId_, -1);
804 
805     /**
806      * @tc.steps: step3. construct TextFrameNode.
807      * @tc.expected: frameNode is not null.
808      */
809     auto frameNode = AceType::MakeRefPtr<FrameNode>(GRID_TAG, -1, AceType::MakeRefPtr<TextPattern>());
810     ASSERT_NE(frameNode, nullptr);
811 
812     /**
813      * @tc.steps: step4. updat edragDropManager->textFieldDragFrameNodes_ .
814      */
815     dragDropManager->textFieldDragFrameNodes_.insert(std::make_pair(100, WeakPtr<NG::FrameNode>(frameNode)));
816 
817     /**
818      * @tc.steps: step5. call OnTextDragEnd.
819      * @tc.expected: dragDropManager->currentId_ equals -1.
820      */
821     dragDropManager->OnTextDragEnd(globalX, globalY, extraInfo);
822     auto dragFrameNode = dragDropManager->FindDragFrameNodeByPosition(globalX, globalY);
823     EXPECT_EQ(dragDropManager->currentId_, -1);
824 }
825 
826 /**
827  * @tc.name: DragDropManagerTest015
828  * @tc.desc: Test RestoreClipboardData
829  * @tc.type: FUNC
830  * @tc.author:
831  */
832 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest015, TestSize.Level1)
833 {
834     /**
835      * @tc.steps: step1. Create DragDropManager.
836      * @tc.expected: dragDropManager is not null.
837      */
838     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
839     ASSERT_NE(dragDropManager, nullptr);
840 
841     /**
842      * @tc.steps: step2. call CancelItemDrag.
843      * @tc.expected: dragDropManager->deleteDataCallback_ is not null.
844      */
845     dragDropManager->RestoreClipboardData();
846     ASSERT_NE(dragDropManager->deleteDataCallback_, nullptr);
847 
848     /**
849      * @tc.steps: step3. call CancelItemDrag(clipboard_ is null branch).
850      * @tc.expected: step3. dragDropManager->deleteDataCallback_ is not null.
851      */
852     dragDropManager->clipboard_ = nullptr;
853     dragDropManager->RestoreClipboardData();
854     ASSERT_NE(dragDropManager->deleteDataCallback_, nullptr);
855 
856     /**
857      * @tc.steps: step4. call CancelItemDrag(deleteDataCallback_ is not null branch).
858      * @tc.expected: step4. dragDropManager->deleteDataCallback_ is not null.
859      */
__anond75c6b370f02(const std::string& data) 860     auto callback = [weakManager = AceType::WeakClaim(AceType::RawPtr(dragDropManager))](const std::string& data) {
861         auto dragDropManagerPtr = weakManager.Upgrade();
862         ASSERT_NE(dragDropManagerPtr, nullptr);
863         auto json = JsonUtil::ParseJsonString(data);
864         if (json->Contains("preData")) {
865             dragDropManagerPtr->clipboard_->SetData(json->GetString("preData"));
866         }
867     };
868     dragDropManager->deleteDataCallback_ = callback;
869     dragDropManager->RestoreClipboardData();
870     ASSERT_NE(dragDropManager->deleteDataCallback_, nullptr);
871 }
872 
873 /**
874  * @tc.name: DragDropManagerTest017
875  * @tc.desc: Test UpdateDragEvent
876  * @tc.type: FUNC
877  * @tc.author:
878  */
879 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest017, TestSize.Level1)
880 {
881     /**
882      * @tc.steps: step1. Create DragDropManager.
883      * @tc.expected: dragDropManager is not null.
884      */
885     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
886     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
887     dragDropManager->OnDragStart({ GLOBAL_X, GLOBAL_Y }, frameNode);
888     ASSERT_NE(dragDropManager, nullptr);
889 
890     /**
891      * @tc.steps: step2. construct a OHOS::Ace::DragEvent.
892      * @tc.expected: event is not null.
893      */
894     auto event = AceType::MakeRefPtr<OHOS::Ace::DragEvent>();
895     ASSERT_NE(event, nullptr);
896 
897     /**
898      * @tc.steps: step3. call UpdateDragEvent.
899      * @tc.expected: pipeline is not null.
900      */
901     dragDropManager->UpdateDragEvent(event, DragPointerEvent(1, 1));
902     auto pipeline = PipelineContext::GetCurrentContext();
903     ASSERT_NE(pipeline, nullptr);
904 }
905 
906 /**
907  * @tc.name: DragDropManagerTest021
908  * @tc.desc: Test CreateTextDragDropProxy
909  * @tc.type: FUNC
910  * @tc.author:
911  */
912 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest021, TestSize.Level1)
913 {
914     /**
915      * @tc.steps: step1. construct a DragDropManager
916      * @tc.expected: dragDropManager is not null.
917      */
918     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
919     ASSERT_NE(dragDropManager, nullptr);
920 
921     /**
922      * @tc.steps: step2. Call CreateTextDragDropProxy.
923      * @tc.expected: CreateTextDragDropProxy the returns true value is not null.
924      */
925     auto textDragDropProxy = dragDropManager->CreateTextDragDropProxy();
926     ASSERT_NE(textDragDropProxy, nullptr);
927 }
928 
929 /**
930  * @tc.name: DragDropManagerTest022
931  * @tc.desc: Test FindDragFrameNodeByPosition in default branches
932  * @tc.type: FUNC
933  * @tc.author:
934  */
935 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest022, TestSize.Level1)
936 {
937     /**
938      * @tc.steps: step1. construct a DragDropManager
939      */
940     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
941 
942     /**
943      * @tc.steps: step2. call FindDragFrameNodeByPosition with frameNodes contains nullptr
944      * @tc.expected: step2.
945      */
946     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
947     auto frameNodeNull = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
948     dragDropManager->AddDragFrameNode(frameNodeNull->GetId(), frameNodeNull);
949     frameNodeNull.Reset();
950     auto frameNodeGeoNullId = ElementRegister::GetInstance()->MakeUniqueId();
951     auto frameNodeGeoNull =
952         AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeGeoNullId, AceType::MakeRefPtr<Pattern>());
953     frameNodeGeoNull->SetGeometryNode(nullptr);
954     dragDropManager->AddDragFrameNode(frameNodeGeoNull->GetId(), frameNodeGeoNull);
955     EXPECT_EQ(static_cast<int32_t>(dragDropManager->dragFrameNodes_.size()), 2);
956     auto targetFrameNode = dragDropManager->FindDragFrameNodeByPosition(GLOBAL_X, GLOBAL_Y);
957     EXPECT_FALSE(targetFrameNode);
958 }
959 
960 /**
961  * @tc.name: DragDropManagerTest023
962  * @tc.desc: Test OnDragStart(Point)
963  * @tc.type: FUNC
964  * @tc.author:
965  */
966 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest023, TestSize.Level1)
967 {
968     /**
969      * @tc.steps: step1. construct a DragDropManager
970      * @tc.expected: dragDropManager is not null.
971      */
972     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
973     ASSERT_NE(dragDropManager, nullptr);
974 
975     /**
976      * @tc.steps: step2. Call OnDragStart with Point.
977      * @tc.expected: dragDropManager->dragDropState_ is equal to DragDropMgrState::DRAGGING.
978      */
979     dragDropManager->OnDragStart(Point(15.0f, 15.0f));
980     EXPECT_EQ(dragDropManager->dragDropState_, DragDropMgrState::DRAGGING);
981 
982     /**
983      * @tc.steps: step3. Call OnDragStart with Point and FrameNode.
984      * @tc.expected: dragDropManager->dragDropState_ is equal to DragDropMgrState::DRAGGING.
985      */
986     RefPtr<FrameNode> frameNode = nullptr;
987     dragDropManager->OnDragStart(Point(15.0f, 15.0f), frameNode);
988     EXPECT_EQ(dragDropManager->dragDropState_, DragDropMgrState::DRAGGING);
989 }
990 
991 /**
992  * @tc.name: DragDropManagerTest024
993  * @tc.desc: Test ClearVelocityInfo
994  * @tc.type: FUNC
995  * @tc.author:
996  */
997 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest024, TestSize.Level1)
998 {
999     /**
1000      * @tc.steps: step1. construct a DragDropManager
1001      * @tc.expected: dragDropManager is not null.
1002      */
1003     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1004     ASSERT_NE(dragDropManager, nullptr);
1005 
1006     /**
1007      * @tc.steps: step2. Call ClearVelocityInfo.
1008      * @tc.expected: dragDropManager->velocityTracker_.isFirstPoint_ is equal to true.
1009      */
1010     dragDropManager->UpdateVelocityTrackerPoint(Point(15.0f, 15.0f), true);
1011     dragDropManager->ClearVelocityInfo();
1012     EXPECT_EQ(dragDropManager->velocityTracker_.isFirstPoint_, true);
1013 }
1014 
1015 /**
1016  * @tc.name: DragDropManagerTest025
1017  * @tc.desc: Test OnItemDragEnd out of eventHub is not an empty branche
1018  * @tc.type: FUNC
1019  * @tc.author:
1020  */
1021 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest025, TestSize.Level1)
1022 {
1023     /**
1024      * @tc.steps: step1. construct a DragDropManager.
1025      * @tc.expected: dragDropManager is not null.
1026      */
1027     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1028     ASSERT_NE(dragDropManager, nullptr);
1029 
1030     /**
1031      * @tc.steps: step2. construct a GridFrameNode.
1032      * @tc.expected: frameNode is not null.
1033      */
1034     auto gridFrameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<GridPattern>());
1035     ASSERT_TRUE(gridFrameNode);
1036 
1037     /**
1038      * @tc.steps: step3. Call OnItemDragEnd with DRAG_TYPE_GRID.
1039      * @tc.expected: dragDropManager->draggedFrameNode_ is false.
1040      */
1041     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, gridFrameNode);
1042     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_GRID);
1043     EXPECT_FALSE(dragDropManager->draggedFrameNode_);
1044 
1045     /**
1046      * @tc.steps: step4. construct a ListFrameNode.
1047      * @tc.expected: frameNode is not null.
1048      */
1049     auto listFrameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<ListPattern>());
1050     ASSERT_TRUE(listFrameNode);
1051 
1052     /**
1053      * @tc.steps: step5. Call OnItemDragEnd with DRAG_TYPE_LIST.
1054      * @tc.expected: dragDropManager->draggedFrameNode_ is false.
1055      */
1056     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, listFrameNode);
1057     dragDropManager->OnItemDragEnd(GLOBAL_X, GLOBAL_Y, DRAGGED_INDEX, DRAG_TYPE_LIST);
1058     EXPECT_FALSE(dragDropManager->draggedFrameNode_);
1059 }
1060 
1061 /**
1062  * @tc.name: DragDropManagerTest026
1063  * @tc.desc: Test GetExtraInfo
1064  * @tc.type: FUNC
1065  * @tc.author:
1066  */
1067 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest026, TestSize.Level1)
1068 {
1069     /**
1070      * @tc.steps: step1. construct a DragDropManager
1071      * @tc.expected: dragDropManager is not null.
1072      */
1073     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1074     ASSERT_NE(dragDropManager, nullptr);
1075 
1076     /**
1077      * @tc.steps: step2. Call GetExtraInfo.
1078      * @tc.expected: extraInfo is empty.
1079      */
1080     auto extraInfo = dragDropManager->GetExtraInfo();
1081     EXPECT_TRUE(extraInfo.empty());
1082 }
1083 
1084 /**
1085  * @tc.name: DragDropManagerTest027
1086  * @tc.desc: Test SetExtraInfo
1087  * @tc.type: FUNC
1088  * @tc.author:
1089  */
1090 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest027, TestSize.Level1)
1091 {
1092     /**
1093      * @tc.steps: step1. construct a DragDropManager
1094      * @tc.expected: dragDropManager is not null.
1095      */
1096     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1097     ASSERT_NE(dragDropManager, nullptr);
1098 
1099     /**
1100      * @tc.steps: step2. Call SetExtraInfo.
1101      * @tc.expected: dragDropManager->extraInfo_ is equal to "extraInfo".
1102      */
1103     dragDropManager->SetExtraInfo("extraInfo");
1104     EXPECT_EQ(dragDropManager->extraInfo_, "extraInfo");
1105 }
1106 
1107 /**
1108  * @tc.name: DragDropManagerTest028
1109  * @tc.desc: Test ClearExtraInfo
1110  * @tc.type: FUNC
1111  * @tc.author:
1112  */
1113 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest028, TestSize.Level1)
1114 {
1115     /**
1116      * @tc.steps: step1. construct a DragDropManager
1117      * @tc.expected: dragDropManager is not null.
1118      */
1119     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1120     ASSERT_NE(dragDropManager, nullptr);
1121 
1122     /**
1123      * @tc.steps: step2. Call ClearExtraInfo.
1124      * @tc.expected: dragDropManager->extraInfo_ is empty.
1125      */
1126     dragDropManager->SetExtraInfo("extraInfo");
1127     dragDropManager->ClearExtraInfo();
1128     EXPECT_TRUE(dragDropManager->extraInfo_.empty());
1129 }
1130 
1131 /**
1132  * @tc.name: DragDropManagerTest029
1133  * @tc.desc: Test CancelItemDrag in draggedGridFrameNode branches
1134  * @tc.type: FUNC
1135  * @tc.author:
1136  */
1137 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest029, TestSize.Level1)
1138 {
1139     /**
1140      * @tc.steps: step1. Create DragDropManager.
1141      * @tc.expected: dragDropManager is not null.
1142      */
1143     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1144     ASSERT_NE(dragDropManager, nullptr);
1145 
1146     /**
1147      * @tc.steps: step2. call CancelItemDrag.
1148      * @tc.expected: dragDropManager->draggedGridFrameNode_ is false.
1149      */
1150     dragDropManager->CancelItemDrag();
1151     EXPECT_FALSE(dragDropManager->draggedGridFrameNode_);
1152 
1153     /**
1154      * @tc.steps: step3. Create FrameNode.
1155      * @tc.expected: frameNode is not null.
1156      */
1157     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
1158     ASSERT_NE(frameNode, nullptr);
1159 
1160     /**
1161      * @tc.steps: step4. call CancelItemDrag.
1162      * @tc.expected: dragDropManager->draggedGridFrameNode_ is true.
1163      */
1164     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, frameNode);
1165     dragDropManager->CancelItemDrag();
1166     EXPECT_TRUE(dragDropManager->draggedGridFrameNode_);
1167 }
1168 
1169 /**
1170  * @tc.name: DragDropManagerTest0291
1171  * @tc.desc: Test CancelItemDrag in listEventHub branches
1172  * @tc.type: FUNC
1173  * @tc.author:
1174  */
1175 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest0291, TestSize.Level1)
1176 {
1177     /**
1178      * @tc.steps: step1. Create DragDropManager.
1179      * @tc.expected: dragDropManager is not null.
1180      */
1181     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1182     ASSERT_NE(dragDropManager, nullptr);
1183 
1184     /**
1185      * @tc.steps: step2. Create FrameNode.
1186      * @tc.expected: listFrameNode is not null.
1187      */
1188     auto listFrameNode = AceType::MakeRefPtr<FrameNode>(LIST_TAG, -1, AceType::MakeRefPtr<ListPattern>());
1189     ASSERT_NE(listFrameNode, nullptr);
1190 
1191     /**
1192      * @tc.steps: step3. update draggedGridFrameNode_ with listFrameNode.
1193      */
1194     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, listFrameNode);
1195 
1196     /**
1197      * @tc.steps: step4. call CancelItemDrag.
1198      * * @tc.expected: listEventHub is TRUE.
1199      */
1200     dragDropManager->CancelItemDrag();
1201     auto listEventHub = dragDropManager->draggedGridFrameNode_->GetEventHub<ListEventHub>();
1202     EXPECT_TRUE(listEventHub);
1203 }
1204 
1205 /**
1206  * @tc.name: DragDropManagerTest0292
1207  * @tc.desc: Test CancelItemDrag in gridEventHub branches
1208  * @tc.type: FUNC
1209  * @tc.author:
1210  */
1211 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest0292, TestSize.Level1)
1212 {
1213     /**
1214      * @tc.steps: step1. Create DragDropManager.
1215      * @tc.expected: dragDropManager is not null.
1216      */
1217     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1218     ASSERT_NE(dragDropManager, nullptr);
1219 
1220     /**
1221      * @tc.steps: step2. Create FrameNode.
1222      * @tc.expected: gridFrameNode is not null.
1223      */
1224     auto gridFrameNode = AceType::MakeRefPtr<FrameNode>(GRID_TAG, -1, AceType::MakeRefPtr<GridPattern>());
1225     ASSERT_NE(gridFrameNode, nullptr);
1226 
1227     /**
1228      * @tc.steps: step3. update draggedGridFrameNode_ with gridFrameNode.
1229      */
1230     dragDropManager->OnItemDragStart(GLOBAL_X, GLOBAL_Y, gridFrameNode);
1231 
1232     /**
1233      * @tc.steps: step4. call CancelItemDrag.
1234      * * @tc.expected: gridEventHub is TRUE.
1235      */
1236     dragDropManager->CancelItemDrag();
1237     auto gridEventHub = dragDropManager->draggedGridFrameNode_->GetEventHub<GridEventHub>();
1238     EXPECT_TRUE(gridEventHub);
1239 }
1240 
1241 /**
1242  * @tc.name: DragDropManagerTest030
1243  * @tc.desc: Test FireOnItemDragEvent in DragType::GRID branches
1244  * @tc.type: FUNC
1245  * @tc.author:
1246  */
1247 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest030, TestSize.Level1)
1248 {
1249     /**
1250      * @tc.steps: step1. Create DragDropManager.
1251      * @tc.expected: dragDropManager is not null.
1252      */
1253     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1254     ASSERT_NE(dragDropManager, nullptr);
1255 
1256     /**
1257      * @tc.steps: step2. Create FrameNode.
1258      * @tc.expected: gridFrameNode is not null.
1259      */
1260     auto gridFrameNode = AceType::MakeRefPtr<FrameNode>(GRID_TAG, -1, AceType::MakeRefPtr<GridPattern>());
1261     ASSERT_NE(gridFrameNode, nullptr);
1262 
1263     /**
1264      * @tc.steps: step3. call FireOnItemDragEvent with DragEventType::ENTER.
1265      * * @tc.expected: eventHub is TRUE.
1266      */
1267     OHOS::Ace::ItemDragInfo itemDragInfo;
1268     dragDropManager->FireOnItemDragEvent(gridFrameNode, DragType::GRID, itemDragInfo, DragEventType::ENTER, 0, 0);
1269     auto eventHub = gridFrameNode->GetEventHub<GridEventHub>();
1270     EXPECT_TRUE(eventHub);
1271 
1272     /**
1273      * @tc.steps: step4. call FireOnItemDragEvent with DragEventType::MOVE.
1274      * * @tc.expected: eventHub is TRUE.
1275      */
1276     dragDropManager->FireOnItemDragEvent(gridFrameNode, DragType::GRID, itemDragInfo, DragEventType::MOVE, 0, 0);
1277     EXPECT_TRUE(eventHub);
1278 
1279     /**
1280      * @tc.steps: step5. call FireOnItemDragEvent with DragEventType::default.
1281      * * @tc.expected: eventHub is TRUE.
1282      */
1283     dragDropManager->FireOnItemDragEvent(gridFrameNode, DragType::GRID, itemDragInfo, DragEventType(10), 0, 0);
1284     EXPECT_TRUE(eventHub);
1285 }
1286 
1287 /**
1288  * @tc.name: DragDropManagerTest031
1289  * @tc.desc: Test FindTargetInChildNodes is an empty branch of parentNode
1290  * @tc.type: FUNC
1291  * @tc.author:
1292  */
1293 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest031, TestSize.Level1)
1294 {
1295     /**
1296      * @tc.steps: step1. Create DragDropManager.
1297      * @tc.expected: dragDropManager is not null.
1298      */
1299     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1300     ASSERT_NE(dragDropManager, nullptr);
1301 
1302     /**
1303      * @tc.steps: step2. call FindTargetInChildNodes(parentNode is empty).
1304      * @tc.expected: childFindResult is false.
1305      */
1306     RefPtr<UINode> customNode = nullptr;
1307     std::vector<RefPtr<FrameNode>> hitFrameNodes;
1308     auto childFindResult = dragDropManager->FindTargetInChildNodes(customNode, hitFrameNodes, true);
1309     EXPECT_FALSE(childFindResult);
1310 }
1311 
1312 /**
1313  * @tc.name: DragDropManagerTest033
1314  * @tc.desc: Test FindTargetInChildNodes
1315  * @tc.type: FUNC
1316  * @tc.author:
1317  */
1318 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest033, TestSize.Level1)
1319 {
1320     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1321     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1322     auto frameNodeNull = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<GridPattern>());
1323     auto geometryNode = AceType::MakeRefPtr<GeometryNode>();
1324     geometryNode->SetFrameSize(FRAME_SIZE);
1325     frameNodeNull->SetGeometryNode(geometryNode);
1326     auto pipelineTmp = NG::PipelineContext::GetCurrentContext();
1327     auto parentNodeTmp = pipelineTmp->GetRootElement();
1328     auto parentFrameNodeTmp = AceType::DynamicCast<FrameNode>(parentNodeTmp);
1329     parentFrameNodeTmp->frameChildren_.insert(WeakPtr<NG::FrameNode>(frameNodeNull));
1330     dragDropManager->AddGridDragFrameNode(frameNodeNull->GetId(), frameNodeNull);
1331     std::map<int32_t, WeakPtr<FrameNode>> frameNodes = dragDropManager->gridDragFrameNodes_;
1332     PointF point(GLOBAL_X, GLOBAL_Y);
1333     std::vector<RefPtr<FrameNode>> hitFrameNodes;
1334     for (auto iterOfFrameNode = frameNodes.begin(); iterOfFrameNode != frameNodes.end(); iterOfFrameNode++) {
1335         auto frameNode = iterOfFrameNode->second.Upgrade();
1336         auto geometryNode = frameNode->GetGeometryNode();
1337         if (!geometryNode) {
1338             continue;
1339         }
1340         auto globalFrameRect = geometryNode->GetFrameRect();
1341         globalFrameRect.SetOffset(frameNode->GetTransformRelativeOffset());
1342         if (globalFrameRect.IsInRegion(point)) {
1343             hitFrameNodes.push_back(frameNode);
1344         }
1345     }
1346     auto pipeline = NG::PipelineContext::GetCurrentContext();
1347     auto manager = pipeline->GetOverlayManager();
1348     auto parentNode = pipeline->GetRootElement();
1349     auto parentFrameNode = AceType::DynamicCast<FrameNode>(parentNode);
1350     auto children = parentFrameNode->GetFrameChildren();
1351     EXPECT_FALSE(children.empty());
1352     for (auto iter = children.rbegin(); iter != children.rend(); iter++) {
1353         auto child = iter->Upgrade();
1354         if (child == nullptr) {
1355             continue;
1356         }
1357         auto childNode = AceType::DynamicCast<UINode>(child);
1358         auto childFindResult = dragDropManager->FindTargetInChildNodes(childNode, hitFrameNodes, true);
1359         EXPECT_FALSE(childFindResult);
1360     }
1361     for (auto iter : hitFrameNodes) {
1362         EXPECT_NE(parentFrameNode, iter);
1363     }
1364     auto result = dragDropManager->FindTargetInChildNodes(parentNode, hitFrameNodes, true);
1365     EXPECT_FALSE(result);
1366 }
1367 
1368 /**
1369  * @tc.name: DragDropManagerTest034
1370  * @tc.desc: Test PrintDragFrameNode.
1371  * @tc.type: FUNC
1372  * @tc.author:
1373  */
1374 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest034, TestSize.Level1)
1375 {
1376     /**
1377      * @tc.steps: step1. construct a DragDropManager
1378      * @tc.expected: dragDropManager is not null.
1379      */
1380     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1381     ASSERT_NE(dragDropManager, nullptr);
1382 
1383     OHOS::Ace::DragPointerEvent point;
1384     RefPtr<FrameNode> dragFrameNode = nullptr;
1385     dragDropManager->OnDragStart({ GLOBAL_X, GLOBAL_Y }, dragFrameNode);
1386 
1387     /**
1388      * @tc.steps: step2. call PrintDragFrameNode with dragFrameNode and point.
1389      * * @tc.expected: dragDropManager->draggedFrameNode_ is false.
1390      */
1391     dragDropManager->PrintDragFrameNode(point, dragFrameNode);
1392     ASSERT_FALSE(dragDropManager->draggedFrameNode_);
1393 }
1394 
1395 /**
1396  * @tc.name: DragDropManagerTest035
1397  * @tc.desc: Test FireOnItemDropEvent is empty branchs.
1398  * @tc.type: FUNC
1399  * @tc.author:
1400  */
1401 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest035, TestSize.Level1)
1402 {
1403     /**
1404      * @tc.steps: step1. construct a DragDropManager.
1405      * @tc.expected: dragDropManager is not null.
1406      */
1407     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1408     ASSERT_NE(dragDropManager, nullptr);
1409 
1410     /**
1411      * @tc.steps: step1. construct a DragDropManager.
1412      * @tc.expected: step2. FireOnItemDropEvent.
1413      */
1414     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
1415     auto draggedNode = dragDropManager->draggedFrameNode_;
1416     auto preTargetNode = dragDropManager->preTargetFrameNode_;
1417     OHOS::Ace::ItemDragInfo itemDragInfo;
1418 
1419     /**
1420      * @tc.steps: step2. call OnDragStart with DragType::GRID and frameNode.
1421      * @tc.expected: step2. draggedNode is false.
1422      */
1423     dragDropManager->FireOnItemDropEvent(frameNode, DragType::GRID, itemDragInfo, 0, 0, true);
1424     ASSERT_FALSE(draggedNode);
1425 
1426     /**
1427      * @tc.steps: step2. call OnDragStart with DragType::LIST and frameNode.
1428      * @tc.expected: step2. raggedNode is false.
1429      */
1430     dragDropManager->FireOnItemDropEvent(frameNode, DragType::LIST, itemDragInfo, 0, 0, true);
1431     ASSERT_FALSE(draggedNode);
1432 }
1433 
1434 /**
1435  * @tc.name: DragDropManagerTest037
1436  * @tc.desc: Test GetItemIndex out of eventHub->CheckPostionInGrid is a true branch.
1437  * @tc.type: FUNC
1438  * @tc.author:
1439  */
1440 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest037, TestSize.Level1)
1441 {
1442     /**
1443      * @tc.steps: step1. construct a DragDropManager.
1444      * @tc.expected: dragDropManager is not null.
1445      */
1446     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1447     ASSERT_NE(dragDropManager, nullptr);
1448 
1449     /**
1450      * @tc.steps: step2. construct a GeometryNode,updates MarginFrameOffset and FrameSize.
1451      * @tc.expected: geometryNode is not null.
1452      */
1453     auto geometryNode = AceType::MakeRefPtr<GeometryNode>();
1454     ASSERT_NE(geometryNode, nullptr);
1455     geometryNode->SetMarginFrameOffset(FRAME_OFFSET);
1456     geometryNode->SetFrameSize(FRAME_SIZE);
1457 
1458     /**
1459      * @tc.steps: step3. construct a FrameNode with GeometryNode.
1460      * @tc.expected: gridNode is not null.
1461      */
1462     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1463     auto gridNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<GridPattern>());
1464     ASSERT_NE(dragDropManager, nullptr);
1465     gridNode->SetGeometryNode(geometryNode);
1466 
1467     /**
1468      * @tc.steps: step4. construct a GridEventHub and updates OnItemDrop and AttachHost.
1469      */
1470     ItemDragInfo itemDragInfo;
1471     auto gridEvent = gridNode->GetEventHub<GridEventHub>();
1472     std::string onItemDropInfo;
1473     ItemDropFunc onItemDrop = [&onItemDropInfo](const ItemDragInfo& /* dragInfo */, int32_t /* itemIndex */,
__anond75c6b371002(const ItemDragInfo& , int32_t , int32_t , bool ) 1474                                   int32_t /* insertIndex */, bool /* isSuccess */) { onItemDropInfo = EXTRA_INFO; };
1475     gridEvent->SetOnItemDrop(std::move(onItemDrop));
1476     gridEvent->AttachHost(WeakPtr<NG::FrameNode>(gridNode));
1477 
1478     /**
1479      * @tc.steps: step5. call GetItemIndex with DragEventType::GRID and gridNode.
1480      * @tc.expected: retFlag is true.
1481      */
1482     dragDropManager->draggedGridFrameNode_ = gridNode;
1483     dragDropManager->GetItemIndex(gridNode, DragType::GRID, 0, 0);
1484     auto mockRenderContext = AceType::MakeRefPtr<MockRenderContext>();
1485     ASSERT_NE(mockRenderContext, nullptr);
1486     gridNode->renderContext_ = mockRenderContext;
1487     mockRenderContext->rect_ = { 0.0f, 0.0f, 1.0f, 1.0f };
1488     bool retFlag = gridEvent->CheckPostionInGrid(0, 0);
1489     EXPECT_TRUE(retFlag);
1490 }
1491 
1492 /**
1493  * @tc.name: DragDropManagerTest038
1494  * @tc.desc: Test GetItemIndex out of itemFrameNode is a true branch.
1495  * @tc.type: FUNC
1496  * @tc.author:
1497  */
1498 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest038, TestSize.Level1)
1499 {
1500     /**
1501      * @tc.steps: step1. construct a DragDropManager.
1502      * @tc.expected: dragDropManager is not null.
1503      */
1504     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1505     ASSERT_NE(dragDropManager, nullptr);
1506 
1507     /**
1508      * @tc.steps: step2. construct a GeometryNode,updates MarginFrameOffset and FrameSize.
1509      * @tc.expected: geometryNode is not null.
1510      */
1511     auto geometryNode = AceType::MakeRefPtr<GeometryNode>();
1512     ASSERT_NE(geometryNode, nullptr);
1513     geometryNode->SetMarginFrameOffset(FRAME_OFFSET);
1514     geometryNode->SetFrameSize(FRAME_SIZE);
1515 
1516     /**
1517      * @tc.steps: step3. construct a FrameNode with GeometryNode.
1518      * @tc.expected: gridNode is not null.
1519      */
1520     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1521     auto gridNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<GridPattern>());
1522     ASSERT_NE(gridNode, nullptr);
1523     gridNode->SetGeometryNode(geometryNode);
1524 
1525     /**
1526      * @tc.steps: step4. construct a FrameNode.
1527      */
1528     auto childId = ElementRegister::GetInstance()->MakeUniqueId();
1529     auto childNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, childId, AceType::MakeRefPtr<Pattern>());
1530     childNode->SetGeometryNode(geometryNode);
1531     childNode->isActive_ = true;
1532 
1533     /**
1534      * @tc.steps: step5. gridNode AddChild with childNode.
1535      */
1536     gridNode->AddChild(childNode);
1537 
1538     /**
1539      * @tc.steps: step6. call GetItemIndex with DragEventType::GRID and gridNode.
1540      * @tc.expected: retFlag is true.
1541      */
1542     dragDropManager->draggedGridFrameNode_ = gridNode;
1543     dragDropManager->GetItemIndex(gridNode, DragType::GRID, 0, 0);
1544     bool retFlag = gridNode->FindChildByPosition(0, 0);
1545     EXPECT_TRUE(retFlag);
1546 }
1547 
1548 /**
1549  * @tc.name: DragDropManagerTest039
1550  * @tc.desc: Test CheckParentVisible out of parent is a true branch.
1551  * @tc.type: FUNC
1552  * @tc.author:
1553  */
1554 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest039, TestSize.Level1)
1555 {
1556     /**
1557      * @tc.steps: step1. construct a DragDropManager.
1558      * @tc.expected: dragDropManager is not null.
1559      */
1560     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1561     ASSERT_NE(dragDropManager, nullptr);
1562 
1563     /**
1564      * @tc.steps: step2. construct a frameNode and update attributes.
1565      * IsVisible is false branch
1566      */
1567     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1568     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
1569     frameNode->GetLayoutProperty()->UpdateVisibility(VisibleType::INVISIBLE, true);
1570     auto eventHub = frameNode->GetEventHub<EventHub>();
1571     eventHub->SetEnabled(true);
1572 
1573     /**
1574      * @tc.steps: step3. update nodesForDragNotify_.
1575      * @tc.expected: nodesForDragNotify_ is not empty.
1576      */
1577     dragDropManager->RegisterDragStatusListener(frameNode->GetId(), AceType::WeakClaim(AceType::RawPtr(frameNode)));
1578     EXPECT_FALSE(dragDropManager->nodesForDragNotify_.empty());
1579 
1580     /**
1581      * @tc.steps: step4. update NotifyDragEvent.
1582      * @tc.expected: notifyEvent attributes to be the set value.
1583      */
1584     RefPtr<NotifyDragEvent> notifyEvent = AceType::MakeRefPtr<NotifyDragEvent>();
1585     dragDropManager->UpdateNotifyDragEvent(notifyEvent, Point(1.0f, 1.0f), DragEventType::START);
1586     EXPECT_DOUBLE_EQ(notifyEvent->GetX(), 1.0);
1587     EXPECT_DOUBLE_EQ(notifyEvent->GetY(), 1.0);
1588 
1589     /**
1590      * @tc.steps: step5. call NotifyDragRegisterFrameNode branches of CheckParentVisible out of isVisible.
1591      * @tc.expected: isVisible is false.
1592      */
1593     dragDropManager->NotifyDragRegisterFrameNode(
1594         dragDropManager->nodesForDragNotify_, DragEventType::START, notifyEvent);
1595     bool isVisible = frameNode->IsVisible();
1596     EXPECT_FALSE(isVisible);
1597 
1598     /**
1599      * @tc.steps: step6. update nodesForDragNotify_.
1600      * @tc.expected: nodesForDragNotify_ is not empty.
1601      */
1602     dragDropManager->UnRegisterDragStatusListener(frameNode->GetId());
1603     EXPECT_TRUE(dragDropManager->nodesForDragNotify_.empty());
1604     dragDropManager->RegisterDragStatusListener(frameNode->GetId(), AceType::WeakClaim(AceType::RawPtr(frameNode)));
1605     EXPECT_FALSE(dragDropManager->nodesForDragNotify_.empty());
1606 
1607     /**
1608      * @tc.steps: step7. update frameNode attribute.
1609      * @tc.expected: parent is not null.
1610      */
1611     auto customNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
1612     frameNode->GetLayoutProperty()->UpdateVisibility(VisibleType::VISIBLE, true);
1613     frameNode->SetParent(WeakPtr<NG::UINode>(customNode));
1614     auto parent = frameNode->GetParent();
1615     EXPECT_TRUE(parent);
1616     parent->SetDepth(32);
1617     dragDropManager->UpdateNotifyDragEvent(notifyEvent, Point(1.0f, 1.0f), DragEventType::START);
1618 
1619     /**
1620      * @tc.steps: step8. call NotifyDragRegisterFrameNode branches of CheckParentVisible out of parentFrameNode.
1621      * @tc.expected: parent->GetDepth() returns a value that is not equal to 1.
1622      */
1623     dragDropManager->NotifyDragRegisterFrameNode(
1624         dragDropManager->nodesForDragNotify_, DragEventType::START, notifyEvent);
1625     EXPECT_NE(parent->GetDepth(), 1);
1626 }
1627 
1628 /**
1629  * @tc.name: DragDropManagerTest0391
1630  * @tc.desc: Test CheckParentVisible out of parentFrameNode  is a true branch.
1631  * @tc.type: FUNC
1632  * @tc.author:
1633  */
1634 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest0391, TestSize.Level1)
1635 {
1636     /**
1637      * @tc.steps: step1. construct a DragDropManager.
1638      * @tc.expected: dragDropManager is not null.
1639      */
1640     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1641     ASSERT_NE(dragDropManager, nullptr);
1642 
1643     /**
1644      * @tc.steps: step2. construct a frameNode and update attributes.
1645      * IsVisible is false branch
1646      */
1647     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1648     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
1649     auto customNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, -1, AceType::MakeRefPtr<Pattern>());
1650     customNode->GetLayoutProperty()->UpdateVisibility(VisibleType::INVISIBLE, true);
1651     frameNode->SetParent(WeakPtr<NG::UINode>(customNode));
1652     auto parent = frameNode->GetParent();
1653     EXPECT_TRUE(parent);
1654     parent->SetDepth(32);
1655     EXPECT_NE(parent->GetDepth(), 1);
1656 
1657     /**
1658      * @tc.steps: step4. update nodesForDragNotify_ and NotifyDragEvent.
1659      * @tc.expected: nodesForDragNotify_ is not empty.
1660      */
1661     RefPtr<NotifyDragEvent> notifyEvent = AceType::MakeRefPtr<NotifyDragEvent>();
1662     dragDropManager->RegisterDragStatusListener(frameNode->GetId(), AceType::WeakClaim(AceType::RawPtr(frameNode)));
1663     EXPECT_FALSE(dragDropManager->nodesForDragNotify_.empty());
1664     dragDropManager->UpdateNotifyDragEvent(notifyEvent, Point(1.0f, 1.0f), DragEventType::START);
1665 
1666     /**
1667      * @tc.steps: step5. call NotifyDragRegisterFrameNode branches of CheckParentVisible out of parentFrameNode(is
1668      * false).
1669      * @tc.expected: customNode->IsVisible() returns a value that is not equal to false.
1670      */
1671     dragDropManager->NotifyDragRegisterFrameNode(
1672         dragDropManager->nodesForDragNotify_, DragEventType::START, notifyEvent);
1673     EXPECT_FALSE(customNode->IsVisible());
1674 }
1675 
1676 /**
1677  * @tc.name: DragDropManagerTest040
1678  * @tc.desc: Test FindHitFrameNodes in frameNode branchs
1679  * @tc.type: FUNC
1680  * @tc.author:
1681  */
1682 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest040, TestSize.Level1)
1683 {
1684     /**
1685      * @tc.steps: step1. construct a DragDropManager.
1686      * @tc.expected: dragDropManager is not null.
1687      */
1688     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1689     ASSERT_NE(dragDropManager, nullptr);
1690 
1691     /**
1692      * @tc.steps: step2. construct a frameNode and update attributes.
1693      * @tc.expected: geometryNode is null.
1694      */
1695     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1696     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
1697     frameNode->SetActive(true);
1698     frameNode->geometryNode_ = nullptr;
1699     auto geometryNode = frameNode->GetGeometryNode();
1700     EXPECT_FALSE(geometryNode);
1701 
1702     /**
1703      * @tc.steps: step3. update nodesForDragNotify_.
1704      * @tc.expected: nodesForDragNotify_ is not empty.
1705      */
1706     dragDropManager->RegisterDragStatusListener(frameNode->GetId(), AceType::WeakClaim(AceType::RawPtr(frameNode)));
1707     EXPECT_FALSE(dragDropManager->nodesForDragNotify_.empty());
1708 
1709     /**
1710      * @tc.steps: step4. call FindHitFrameNodes out of geometryNode are false branches.
1711      * @tc.expected: frameNodeList is empty.
1712      */
1713     auto frameNodeList = dragDropManager->FindHitFrameNodes(Point(1.0f, 1.0f));
1714     EXPECT_TRUE(frameNodeList.empty());
1715 
1716     /**
1717      * @tc.steps: step5. clear nodesForDragNotify_.
1718      */
1719     dragDropManager->UnRegisterDragStatusListener(frameNode->GetId());
1720     EXPECT_TRUE(dragDropManager->nodesForDragNotify_.empty());
1721 
1722     /**
1723      * @tc.steps: step6. updates frameNode and nodesForDragNotify_.
1724      */
1725     frameNode->SetActive(false);
1726     frameNode->GetLayoutProperty()->UpdateVisibility(VisibleType::INVISIBLE, true);
1727     dragDropManager->RegisterDragStatusListener(frameNode->GetId(), AceType::WeakClaim(AceType::RawPtr(frameNode)));
1728 
1729     /**
1730      * @tc.steps: step7. call FindHitFrameNodes out of IsVisible are false branches.
1731      * @tc.expected: frameNodeList is empty.
1732      */
1733     frameNodeList = dragDropManager->FindHitFrameNodes(Point(1.0f, 1.0f));
1734     EXPECT_TRUE(frameNodeList.empty());
1735 }
1736 
1737 /**
1738  * @tc.name: DragDropManagerTest041
1739  * @tc.desc: Test SetDragDampStartPoint and GetDragDampStartPoint
1740  * @tc.type: FUNC
1741  * @tc.author:
1742  */
1743 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest041, TestSize.Level1)
1744 {
1745     /**
1746      * @tc.steps: step1. construct a DragDropManager.
1747      * @tc.expected: dragDropManager is not null.
1748      */
1749     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1750     ASSERT_NE(dragDropManager, nullptr);
1751 
1752     /**
1753      * @tc.steps: step2. create a point, than call SetDragDampStartPoint.
1754      * @tc.expected: The values of dragDampStartPoint_ and point are equal
1755      */
1756     Point point(1.0f, 1.0f);
1757     dragDropManager->SetDragDampStartPoint(point);
1758     EXPECT_EQ(dragDropManager->dragDampStartPoint_, point);
1759 
1760     /**
1761      * @tc.steps: step3. create a point, than call GetDragDampStartPoint.
1762      * @tc.expected: The return values of dragDampStartPoint_ and point are equal
1763      */
1764     Point point2(2.0f, 2.0f);
1765     dragDropManager->dragDampStartPoint_ = point2;
1766     auto returnPoint = dragDropManager->GetDragDampStartPoint();
1767     EXPECT_EQ(returnPoint, point2);
1768 }
1769 
1770 /**
1771  * @tc.name: DragDropManagerTest042
1772  * @tc.desc: ResetPreTargetFrameNode
1773  * @tc.type: FUNC
1774  * @tc.author:
1775  */
1776 HWTEST_F(DragDropManagerTestNg, DragDropManagerTest042, TestSize.Level1)
1777 {
1778     /**
1779      * @tc.steps: step1. construct a DragDropManager.
1780      * @tc.expected: dragDropManager is not null.
1781      */
1782     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1783     ASSERT_NE(dragDropManager, nullptr);
1784 
1785     /**
1786      * @tc.steps: step2. create a frameNode, then set preTargetFrameNode_.
1787      * @tc.expected: The values of preTargetFrameNode_ and frameNode are equal
1788      */
1789     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1790     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
1791     ASSERT_NE(frameNode, nullptr);
1792 
1793     dragDropManager->preTargetFrameNode_ = frameNode;
1794     ASSERT_EQ(dragDropManager->preTargetFrameNode_, frameNode);
1795     auto container = MockContainer::Current();
1796     ASSERT_NE(container, nullptr);
1797     auto instanceId = container->GetInstanceId();
1798     /**
1799      * @tc.steps: step3. call ResetPreTargetFrameNode in ScenceBoardWindow.
1800      * @tc.expected: The value of preTargetFrameNode_ is frameNode
1801      */
1802     container->isUIExtensionWindow_ = false;
1803     container->isScenceBoardWindow_ = true;
1804     dragDropManager->ResetPreTargetFrameNode(instanceId);
1805     EXPECT_EQ(dragDropManager->preTargetFrameNode_, frameNode);
1806 
1807     /**
1808      * @tc.steps: step4. call ResetPreTargetFrameNode in UIExtensionWindow.
1809      * @tc.expected: The value of preTargetFrameNode_ is frameNode
1810      */
1811     container->isUIExtensionWindow_ = true;
1812     container->isScenceBoardWindow_ = false;
1813     dragDropManager->ResetPreTargetFrameNode(instanceId);
1814     EXPECT_EQ(dragDropManager->preTargetFrameNode_, frameNode);
1815 
1816     /**
1817      * @tc.steps: step5. call ResetPreTargetFrameNode.
1818      * @tc.expected: The value of preTargetFrameNode_ is nullptr
1819      */
1820     container->isUIExtensionWindow_ = false;
1821     container->isScenceBoardWindow_ = false;
1822     dragDropManager->ResetPreTargetFrameNode(instanceId);
1823     EXPECT_EQ(dragDropManager->preTargetFrameNode_, nullptr);
1824 }
1825 
1826 /**
1827  * @tc.name: CheckIsFolderSubwindowBoundary001
1828  * @tc.desc: ResetPreTargetFrameNode
1829  * @tc.type: FUNC
1830  * @tc.author:
1831  */
1832 HWTEST_F(DragDropManagerTestNg, CheckIsFolderSubwindowBoundary001, TestSize.Level1)
1833 {
1834     /**
1835      * @tc.steps: step1. construct a DragDropManager.
1836      * @tc.expected: dragDropManager is not null.
1837      */
1838     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1839     ASSERT_NE(dragDropManager, nullptr);
1840     bool result = dragDropManager->CheckIsFolderSubwindowBoundary(0.0f, 0.0f, 0);
1841     EXPECT_EQ(result, false);
1842 }
1843 
1844 /**
1845  * @tc.name: HandleUIExtensionDragEvent001
1846  * @tc.desc: ResetPreTargetFrameNode
1847  * @tc.type: FUNC
1848  * @tc.author:
1849  */
1850 HWTEST_F(DragDropManagerTestNg, HandleUIExtensionDragEvent001, TestSize.Level1)
1851 {
1852     /**
1853      * @tc.steps: step1. construct a DragDropManager.
1854      * @tc.expected: dragDropManager is not null.
1855      */
1856     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1857     ASSERT_NE(dragDropManager, nullptr);
1858     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1859     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
1860     DragPointerEvent pointerEvent;
1861     DragEventType type = DragEventType::ENTER;
1862     dragDropManager->HandleUIExtensionDragEvent(frameNode, pointerEvent, type);
1863     EXPECT_NE(pointerEvent.action, PointerAction::PULL_IN_WINDOW);
1864 }
1865 
1866 /**
1867  * @tc.name: HandleUIExtensionDragEvent002
1868  * @tc.desc: ResetPreTargetFrameNode
1869  * @tc.type: FUNC
1870  * @tc.author:
1871  */
1872 HWTEST_F(DragDropManagerTestNg, HandleUIExtensionDragEvent002, TestSize.Level1)
1873 {
1874     /**
1875      * @tc.steps: step1. construct a DragDropManager.
1876      * @tc.expected: dragDropManager is not null.
1877      */
1878     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1879     ASSERT_NE(dragDropManager, nullptr);
1880     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1881     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
1882     DragPointerEvent pointerEvent;
1883     DragEventType type = DragEventType::LEAVE;
1884     dragDropManager->HandleUIExtensionDragEvent(frameNode, pointerEvent, type);
1885     EXPECT_NE(pointerEvent.action, PointerAction::PULL_OUT_WINDOW);
1886 }
1887 
1888 /**
1889  * @tc.name: HandleUIExtensionDragEvent003
1890  * @tc.desc: ResetPreTargetFrameNode
1891  * @tc.type: FUNC
1892  * @tc.author:
1893  */
1894 HWTEST_F(DragDropManagerTestNg, HandleUIExtensionDragEvent003, TestSize.Level1)
1895 {
1896     /**
1897      * @tc.steps: step1. construct a DragDropManager.
1898      * @tc.expected: dragDropManager is not null.
1899      */
1900     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1901     ASSERT_NE(dragDropManager, nullptr);
1902     auto frameNodeNullId = ElementRegister::GetInstance()->MakeUniqueId();
1903     auto frameNode = AceType::MakeRefPtr<FrameNode>(NODE_TAG, frameNodeNullId, AceType::MakeRefPtr<Pattern>());
1904     DragPointerEvent pointerEvent;
1905     DragEventType type =  DragEventType::PULL_CANCEL;
1906     dragDropManager->HandleUIExtensionDragEvent(frameNode, pointerEvent, type);
1907     EXPECT_NE(pointerEvent.action, PointerAction::PULL_CANCEL);
1908 }
1909 
1910 /**
1911  * @tc.name: CalculateScale001
1912  * @tc.desc: ResetPreTargetFrameNode
1913  * @tc.type: FUNC
1914  * @tc.author:
1915  */
1916 HWTEST_F(DragDropManagerTestNg, CalculateScale001, TestSize.Level1)
1917 {
1918     /**
1919      * @tc.steps: step1. construct a DragDropManager.
1920      * @tc.expected: dragDropManager is not null.
1921      */
1922     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1923     ASSERT_NE(dragDropManager, nullptr);
1924     float with = 100.0f;
1925     float height = 100.0f;
1926     float widthLimit = 50.0f;
1927     float heightLimit = 50.0f;
1928     auto scaleDataInfo = dragDropManager->CalculateScale(with, height, widthLimit, heightLimit);
1929     EXPECT_EQ(scaleDataInfo->isNeedScale, true);
1930 
1931     with = 100.0f;
1932     height = 50.0f;
1933     widthLimit = 50.0f;
1934     heightLimit = 50.0f;
1935     scaleDataInfo = dragDropManager->CalculateScale(with, height, widthLimit, heightLimit);
1936     EXPECT_EQ(scaleDataInfo->isNeedScale, true);
1937 
1938     with = 0.0f;
1939     height = 50.0f;
1940     widthLimit = 50.0f;
1941     heightLimit = 50.0f;
1942     scaleDataInfo = dragDropManager->CalculateScale(with, height, widthLimit, heightLimit);
1943     EXPECT_EQ(scaleDataInfo->isNeedScale, false);
1944 
1945     with = 50.0f;
1946     height = 0.0f;
1947     widthLimit = 50.0f;
1948     heightLimit = 50.0f;
1949     scaleDataInfo = dragDropManager->CalculateScale(with, height, widthLimit, heightLimit);
1950     EXPECT_EQ(scaleDataInfo->isNeedScale, false);
1951 }
1952 
1953 /**
1954  * @tc.name: NotifyPullEventListener001
1955  * @tc.desc: ResetPreTargetFrameNode
1956  * @tc.type: FUNC
1957  * @tc.author:
1958  */
1959 HWTEST_F(DragDropManagerTestNg, NotifyPullEventListener001, TestSize.Level1)
1960 {
1961     /**
1962      * @tc.steps: step1. construct a DragDropManager.
1963      * @tc.expected: dragDropManager is not null.
1964      */
1965     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1966     ASSERT_NE(dragDropManager, nullptr);
1967     DragPointerEvent pointerEvent;
1968     bool result = false;
1969     dragDropManager->NotifyPullEventListener(pointerEvent);
1970     EXPECT_EQ(result, false);
1971 
1972     std::function<void(const DragPointerEvent&)> testFunction;
1973     dragDropManager->pullEventListener_.insert({2, testFunction});
1974     dragDropManager->NotifyPullEventListener(pointerEvent);
1975     EXPECT_EQ(result, false);
1976 }
1977 
1978 /**
1979  * @tc.name: UnRegisterPullEventListener001
1980  * @tc.desc: ResetPreTargetFrameNode
1981  * @tc.type: FUNC
1982  */
1983 HWTEST_F(DragDropManagerTestNg, UnRegisterPullEventListener001, TestSize.Level1)
1984 {
1985     auto dragDropManager = AceType::MakeRefPtr<DragDropManager>();
1986     ASSERT_NE(dragDropManager, nullptr);
1987 
1988     const int32_t EXISTING_ID = 100;
__anond75c6b371102(const DragPointerEvent&) 1989     auto testListener = [](const DragPointerEvent&) {};
1990     dragDropManager->pullEventListener_.emplace(EXISTING_ID, testListener);
1991     ASSERT_EQ(dragDropManager->pullEventListener_.size(), 1);
1992 
1993     dragDropManager->UnRegisterPullEventListener(EXISTING_ID);
1994     EXPECT_EQ(dragDropManager->pullEventListener_.size(), 0);
1995 }
1996 } // namespace OHOS::Ace::NG
1997