• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <optional>
17 
18 #include "gtest/gtest.h"
19 #define private public
20 
21 #include "test/mock/base/mock_drag_window.h"
22 #include "test/mock/core/common/mock_container.h"
23 #include "test/mock/core/common/mock_interaction_interface.h"
24 #include "test/mock/core/pipeline/mock_pipeline_context.h"
25 #include "test/unittest/core/event/drag_event/drag_event_test_ng_issue_utils.h"
26 
27 #include "base/image/pixel_map.h"
28 #include "base/memory/ace_type.h"
29 #include "base/memory/referenced.h"
30 #include "base/subwindow/subwindow_manager.h"
31 #include "core/common/interaction/interaction_interface.h"
32 #include "core/components/common/layout/grid_system_manager.h"
33 #include "core/components/theme/blur_style_theme.h"
34 #include "core/components_ng/base/frame_node.h"
35 #include "core/components_ng/base/geometry_node.h"
36 #include "core/components_ng/base/ui_node.h"
37 #include "core/components_ng/base/view_abstract.h"
38 #include "core/components_ng/event/event_hub.h"
39 #include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
40 #include "core/components_ng/manager/drag_drop/drag_drop_global_controller.h"
41 #include "core/components_ng/manager/drag_drop/drag_drop_manager.h"
42 #include "core/components_ng/manager/drag_drop/drag_drop_proxy.h"
43 #include "core/components_ng/pattern/grid/grid_item_pattern.h"
44 #include "core/components_ng/pattern/grid/grid_pattern.h"
45 
46 using namespace testing;
47 using namespace testing::ext;
48 namespace OHOS::Ace::NG {
49 namespace {
50 RefPtr<DragWindow> MOCK_DRAG_WINDOW;
51 constexpr size_t DEFAULT_CHILD_COUNT = 4;
52 constexpr float GRID_WIDTH = 480.0f;
53 constexpr float GRID_HEIGHT = 800.0f;
54 constexpr float ITEM_WIDTH = 120.0f;
55 constexpr float ITEM_HEIGHT = 200.0f;
56 } // namespace
57 
58 // test case
59 struct DragMultiCase {
60     bool isAllowDrag = false;
61     bool isSelected = false;
62     bool isMultiSelectionEnabled = false;
63     bool expectResult = false;
64 };
65 
66 const std::vector<DragMultiCase> DRAG_MULTI_CASES = {
67     { false, false, false, false},
68     { false, false, true, false},
69     { false, true, false, false},
70     { false, true, true, false},
71     { true, false, false, false},
72     { true, false, true, false},
73     { true, true, false, false},
74     { true, true, true, true},
75 };
76 
77 class DragDropFuncWrapperTestNgCoverage : public testing::Test {
78 public:
79     static void SetUpTestCase();
80     static void TearDownTestCase();
81 };
82 
SetUpTestCase()83 void DragDropFuncWrapperTestNgCoverage::SetUpTestCase()
84 {
85     MockPipelineContext::SetUp();
86     MockContainer::SetUp();
87     MOCK_DRAG_WINDOW = DragWindow::CreateDragWindow("", 0, 0, 0, 0);
88 }
89 
TearDownTestCase()90 void DragDropFuncWrapperTestNgCoverage::TearDownTestCase()
91 {
92     MockPipelineContext::TearDown();
93     MockContainer::TearDown();
94     MOCK_DRAG_WINDOW = nullptr;
95 }
96 
CreateGridNodeWithChild(size_t childCount)97 RefPtr<FrameNode> CreateGridNodeWithChild(size_t childCount)
98 {
99     auto frameNode = FrameNode::GetOrCreateFrameNode(V2::GRID_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
100         []() {return AceType::MakeRefPtr<GridPattern>(); });
101     ViewAbstract::SetWidth(Referenced::RawPtr(frameNode), CalcLength(GRID_WIDTH));
102     ViewAbstract::SetHeight(Referenced::RawPtr(frameNode), CalcLength(GRID_HEIGHT));
103 
104     for (size_t i = 0; i < childCount; ++i) {
105         auto chidNodeId = ElementRegister::GetInstance()->MakeUniqueId();
106         auto childNode = FrameNode::GetOrCreateFrameNode(V2::GRID_ITEM_ETS_TAG, chidNodeId,
107             []() { return AceType::MakeRefPtr<GridItemPattern>(nullptr, GridItemStyle::NONE); });
108         ViewAbstract::SetWidth(Referenced::RawPtr(childNode), CalcLength(ITEM_WIDTH));
109         ViewAbstract::SetHeight(Referenced::RawPtr(childNode), CalcLength(ITEM_HEIGHT));
110         childNode->MountToParent(frameNode);
111     }
112     return frameNode;
113 }
114 
115 
ProcessDragItemGroupScene()116 RefPtr<FrameNode> ProcessDragItemGroupScene()
117 {
118     auto gridNode = CreateGridNodeWithChild(DEFAULT_CHILD_COUNT);
119     CHECK_NULL_RETURN(gridNode, nullptr);
120     auto pattern = gridNode->GetPattern<GridPattern>();
121     CHECK_NULL_RETURN(pattern, nullptr);
122     pattern->info_.endIndex_ = DEFAULT_CHILD_COUNT;
123     auto gestureEventHub = gridNode->GetOrCreateGestureEventHub();
124     CHECK_NULL_RETURN(gestureEventHub, nullptr);
125     gestureEventHub->InitDragDropEvent();
126     return gridNode;
127 }
128 
SetFrameNodeAllowDrag(RefPtr<FrameNode> & frameNode)129 void SetFrameNodeAllowDrag(RefPtr<FrameNode>& frameNode)
130 {
131     CHECK_NULL_VOID(frameNode);
132     frameNode->draggable_ = true;
133     auto gestureHub = frameNode->GetOrCreateGestureEventHub();
134     CHECK_NULL_VOID(gestureHub);
135     auto eventHub = gestureHub->eventHub_.Upgrade();
136     CHECK_NULL_VOID(eventHub);
137     auto func = [](const RefPtr<OHOS::Ace::DragEvent>&, const std::string&) { return DragDropInfo(); };
138     eventHub->onDragStart_ = func;
139 }
140 /**
141  * @tc.name: DragDropFuncWrapperTestNgCoverage001
142  * @tc.desc: Test DecideWhetherToStopDragging with valid parameters
143  * @tc.type: FUNC
144  * @tc.author:
145  */
146 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage001, TestSize.Level1)
147 {
148     DragPointerEvent pointerEvent;
149     std::string extraParams = "test";
150     int32_t currentPointerId = 1;
151     int32_t containerId = 100;
152 
153     auto pipelineContext = PipelineContext::GetContextByContainerId(containerId);
154     ASSERT_NE(pipelineContext, nullptr);
155     auto manager = pipelineContext->GetDragDropManager();
156     ASSERT_NE(manager, nullptr);
157     manager->SetDraggingPressedState(false);
158 
159     DragDropFuncWrapper::DecideWhetherToStopDragging(pointerEvent, extraParams, currentPointerId, containerId);
160 
161     EXPECT_FALSE(manager->IsDraggingPressed(currentPointerId));
162 }
163 
164 /**
165  * @tc.name: DragDropFuncWrapperTestNgCoverage002
166  * @tc.desc: Test DecideWhetherToStopDragging with invalid containerId
167  * @tc.type: FUNC
168  * @tc.author:
169  */
170 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage002, TestSize.Level1)
171 {
172     DragPointerEvent pointerEvent;
173     std::string extraParams = "test";
174     int32_t currentPointerId = 1;
175     int32_t invalidContainerId = -1;
176 
177     DragDropFuncWrapper::DecideWhetherToStopDragging(pointerEvent, extraParams, currentPointerId, invalidContainerId);
178 
179     // No assertion needed as it should safely exit with CHECK_NULL_VOID
180 }
181 
182 /**
183  * @tc.name: DragDropFuncWrapperTestNgCoverage003
184  * @tc.desc: Test UpdateDragPreviewOptionsFromModifier with various opacity values
185  * @tc.type: FUNC
186  * @tc.author:
187  */
188 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage003, TestSize.Level1)
189 {
__anonc8fb89d30502(WeakPtr<FrameNode> frameNode) 190     auto applyOnNodeSync = [](WeakPtr<FrameNode> frameNode) {
191         auto node = frameNode.Upgrade();
192         CHECK_NULL_VOID(node);
193         node->GetRenderContext()->UpdateOpacity(0.5f);
194     };
195 
196     DragPreviewOption option;
197     DragDropFuncWrapper::UpdateDragPreviewOptionsFromModifier(applyOnNodeSync, option);
198 
199     EXPECT_EQ(option.options.opacity, 0.5f);
200 }
201 
202 /**
203  * @tc.name: DragDropFuncWrapperTestNgCoverage004
204  * @tc.desc: Test UpdateDragPreviewOptionsFromModifier with default opacity
205  * @tc.type: FUNC
206  * @tc.author:
207  */
208 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage004, TestSize.Level1)
209 {
__anonc8fb89d30602(WeakPtr<FrameNode> frameNode) 210     auto applyOnNodeSync = [](WeakPtr<FrameNode> frameNode) {
211         auto node = frameNode.Upgrade();
212         CHECK_NULL_VOID(node);
213         node->GetRenderContext()->UpdateOpacity(10.0f); // Invalid value
214     };
215 
216     DragPreviewOption option;
217     DragDropFuncWrapper::UpdateDragPreviewOptionsFromModifier(applyOnNodeSync, option);
218 
219     EXPECT_EQ(option.options.opacity, 0.95f); // Default opacity
220 }
221 
222 /**
223  * @tc.name: DragDropFuncWrapperTestNgCoverage005
224  * @tc.desc: Test UpdatePreviewOptionDefaultAttr without default shadow and radius
225  * @tc.type: FUNC
226  * @tc.author:
227  */
228 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage005, TestSize.Level1)
229 {
230     DragPreviewOption option;
231     option.isDefaultShadowEnabled = false;
232     option.isDefaultRadiusEnabled = false;
233 
234     DragDropFuncWrapper::UpdatePreviewOptionDefaultAttr(option);
235 
236     EXPECT_EQ(option.options.opacity, 0.95f);
237     EXPECT_FALSE(option.options.shadow.has_value());
238     EXPECT_FALSE(option.options.borderRadius.has_value());
239 }
240 
241 /**
242  * @tc.name: DragDropFuncWrapperTestNgCoverage006
243  * @tc.desc: Test PrepareRadiusParametersForDragData with empty radius
244  * @tc.type: FUNC
245  * @tc.author:
246  */
247 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage006, TestSize.Level1)
248 {
249     DragPreviewOption option;
250     option.options.borderRadius = std::nullopt;
251 
252     auto arkExtraInfoJson = std::make_unique<JsonValue>();
253     DragDropFuncWrapper::PrepareRadiusParametersForDragData(arkExtraInfoJson, option);
254 
255     // No assertion needed as it should safely exit with CHECK_NULL_VOID
256 }
257 
258 /**
259  * @tc.name: DragDropFuncWrapperTestNgCoverage007
260  * @tc.desc: Test PrepareShadowParametersForDragData with empty shadow
261  * @tc.type: FUNC
262  * @tc.author:
263  */
264 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage007, TestSize.Level1)
265 {
266     DragPreviewOption option;
267     option.options.shadow = std::nullopt;
268 
269     auto arkExtraInfoJson = std::make_unique<JsonValue>();
270     DragDropFuncWrapper::PrepareShadowParametersForDragData(arkExtraInfoJson, option);
271 
272     EXPECT_FALSE(arkExtraInfoJson->GetBool("shadow_enable"));
273 }
274 
275 /**
276  * @tc.name: DragDropFuncWrapperTestNgCoverage008
277  * @tc.desc: Test GetDefaultShadow with invalid pipeline context
278  * @tc.type: FUNC
279  * @tc.author:
280  */
281 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage008, TestSize.Level1)
282 {
283     auto shadow = DragDropFuncWrapper::GetDefaultShadow();
284     EXPECT_FALSE(shadow.has_value());
285 }
286 
287 /**
288  * @tc.name: DragDropFuncWrapperTestNgCoverage009
289  * @tc.desc: Test RadiusToSigma with valid radius
290  * @tc.type: FUNC
291  * @tc.author:
292  */
293 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage009, TestSize.Level1)
294 {
295     float radius = 5.0f;
296     float sigma = DragDropFuncWrapper::RadiusToSigma(radius);
297     EXPECT_GT(sigma, 0.0f);
298 }
299 
300 /**
301  * @tc.name: DragDropFuncWrapperTestNgCoverage010
302  * @tc.desc: Test RadiusToSigma with zero radius
303  * @tc.type: FUNC
304  * @tc.author:
305  */
306 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage010, TestSize.Level1)
307 {
308     float radius = 0.0f;
309     float sigma = DragDropFuncWrapper::RadiusToSigma(radius);
310     EXPECT_EQ(sigma, 0.0f);
311 }
312 
313 /**
314  * @tc.name: DragDropFuncWrapperTestNgCoverage011
315  * @tc.desc: Test BlurStyleToEffection with invalid pipeline context
316  * @tc.type: FUNC
317  * @tc.author:
318  */
319 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage011, TestSize.Level1)
320 {
321     BlurStyleOption blurStyleOp;
322     blurStyleOp.blurStyle = BlurStyle::BACKGROUND_THICK;
323     blurStyleOp.scale = 0.5;
324     blurStyleOp.colorMode = ThemeColorMode::LIGHT;
325 
326     auto effection = DragDropFuncWrapper::BlurStyleToEffection(blurStyleOp);
327     EXPECT_FALSE(effection.has_value());
328 }
329 
330 /**
331  * @tc.name: DragDropFuncWrapperTestNgCoverage012
332  * @tc.desc: Test BlurStyleToEffection with invalid blurStyleOp
333  * @tc.type: FUNC
334  * @tc.author:
335  */
336 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage012, TestSize.Level1)
337 {
338     std::optional<BlurStyleOption> blurStyleOp = std::nullopt;
339 
340     auto effection = DragDropFuncWrapper::BlurStyleToEffection(blurStyleOp);
341     EXPECT_FALSE(effection.has_value());
342 }
343 
344 /**
345  * @tc.name: DragDropFuncWrapperTestNgCoverage013
346  * @tc.desc: Test UpdatePreviewOptionDefaultAttr with default shadow and radius
347  * @tc.type: FUNC
348  * @tc.author:
349  */
350 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage013, TestSize.Level1)
351 {
352     DragPreviewOption option;
353     option.isDefaultShadowEnabled = true;
354     option.isDefaultRadiusEnabled = true;
355 
356     DragDropFuncWrapper::UpdatePreviewOptionDefaultAttr(option);
357 
358     EXPECT_EQ(option.options.opacity, 0.95f);
359     EXPECT_EQ(option.options.shadow, DragDropFuncWrapper::GetDefaultShadow());
360     EXPECT_EQ(option.options.borderRadius, DragDropFuncWrapper::GetDefaultBorderRadius());
361 }
362 
363 /**
364  * @tc.name: DragDropFuncWrapperTestNgCoverage014
365  * @tc.desc: Test UpdateExtraInfo with blur background effect
366  * @tc.type: FUNC
367  * @tc.author:
368  */
369 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage014, TestSize.Level1)
370 {
371     DragPreviewOption option;
372     option.options.opacity = 0.8f;
373     option.options.blurbgEffect.backGroundEffect = EffectOption();
374 
375     auto arkExtraInfoJson = std::make_unique<JsonValue>();
376     DragDropFuncWrapper::UpdateExtraInfo(arkExtraInfoJson, option);
377 
378     EXPECT_EQ(arkExtraInfoJson->GetDouble("dip_opacity"), 0);
379 }
380 
381 /**
382  * @tc.name: DragDropFuncWrapperTestNgCoverage015
383  * @tc.desc: Test PrepareRadiusParametersForDragData with valid radius
384  * @tc.type: FUNC
385  * @tc.author:
386  */
387 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage015, TestSize.Level1)
388 {
389     DragPreviewOption option;
390     option.options.borderRadius->radiusTopLeft = 12.0_vp;
391     option.options.borderRadius->radiusTopRight = 12.0_vp;
392     option.options.borderRadius->radiusBottomRight = 12.0_vp;
393     option.options.borderRadius->radiusBottomLeft = 12.0_vp;
394 
395     auto arkExtraInfoJson = std::make_unique<JsonValue>();
396     DragDropFuncWrapper::PrepareRadiusParametersForDragData(arkExtraInfoJson, option);
397 
398     EXPECT_EQ(arkExtraInfoJson->GetDouble("drag_corner_radius1"), 0);
399     EXPECT_EQ(arkExtraInfoJson->GetDouble("drag_corner_radius2"), 0);
400     EXPECT_EQ(arkExtraInfoJson->GetDouble("drag_corner_radius3"), 0);
401     EXPECT_EQ(arkExtraInfoJson->GetDouble("drag_corner_radius4"), 0);
402 }
403 
404 /**
405  * @tc.name: DragDropFuncWrapperTestNgCoverage016
406  * @tc.desc: Test PrepareShadowParametersForDragData with valid shadow
407  * @tc.type: FUNC
408  * @tc.author:
409  */
410 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage016, TestSize.Level1)
411 {
412     DragPreviewOption option;
413     Shadow shadow;
414     shadow.SetIsFilled(true);
415     option.options.shadow = shadow;
416 
417     auto arkExtraInfoJson = std::make_unique<JsonValue>();
418     DragDropFuncWrapper::PrepareShadowParametersForDragData(arkExtraInfoJson, option);
419 
420     EXPECT_FALSE(arkExtraInfoJson->GetBool("shadow_enable"));
421 }
422 
423 /**
424  * @tc.name: DragDropFuncWrapperTestNgCoverage017
425  * @tc.desc: Test ParseShadowInfo with valid shadow
426  * @tc.type: FUNC
427  * @tc.author:
428  */
429 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage017, TestSize.Level1)
430 {
431     Shadow shadow;
432     shadow.SetIsFilled(true);
433     shadow.SetOffset(Offset(5, 5));
434     shadow.SetBlurRadius(10.0);
435     shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
436 
437     auto arkExtraInfoJson = std::make_unique<JsonValue>();
438     DragDropFuncWrapper::ParseShadowInfo(shadow, arkExtraInfoJson);
439 
440     EXPECT_FALSE(arkExtraInfoJson->GetBool("shadow_is_filled"));
441     EXPECT_EQ(arkExtraInfoJson->GetDouble("drag_shadow_OffsetX"), 0);
442     EXPECT_EQ(arkExtraInfoJson->GetDouble("drag_shadow_OffsetY"), 0);
443 }
444 
445 /**
446  * @tc.name: DragDropFuncWrapperTestNgCoverage018
447  * @tc.desc: Test GetDefaultShadow with valid pipeline context
448  * @tc.type: FUNC
449  * @tc.author:
450  */
451 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage018, TestSize.Level1)
452 {
453     auto shadow = DragDropFuncWrapper::GetDefaultShadow();
454     EXPECT_FALSE(shadow.has_value());
455 }
456 
457 /**
458  * @tc.name: DragDropFuncWrapperTestNgCoverage019
459  * @tc.desc: Test BlurStyleToEffection with valid BlurStyleOption
460  * @tc.type: FUNC
461  * @tc.author:
462  */
463 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage019, TestSize.Level1)
464 {
465     BlurStyleOption blurStyleOp;
466     blurStyleOp.blurStyle = BlurStyle::BACKGROUND_THICK;
467     blurStyleOp.scale = 0.5;
468     blurStyleOp.colorMode = ThemeColorMode::LIGHT;
469 
470     auto effection = DragDropFuncWrapper::BlurStyleToEffection(blurStyleOp);
471     EXPECT_FALSE(effection.has_value());
472 }
473 
474 /**
475  * @tc.name: DragDropFuncWrapperTestNgCoverage020
476  * @tc.desc: Test DecideWhetherToStopDragging
477  * @tc.type: FUNC
478  * @tc.author:
479  */
480 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage020, TestSize.Level1)
481 {
482     int32_t instanceId = -1;
483     int32_t globalX = -1;
484     int32_t globalY = -1;
485     std::string extraParams;
486     int32_t pointerId = -1;
487 
488     ContainerScope scope(instanceId);
489     auto container = Container::CurrentSafely();
490     CHECK_NULL_VOID(container);
491     auto pipelineContext = container->GetPipelineContext();
492     CHECK_NULL_VOID(pipelineContext);
493     auto taskExecutor = container->GetTaskExecutor();
494     CHECK_NULL_VOID(taskExecutor);
495 
496     taskExecutor->PostTask(
__anonc8fb89d30702() 497     [instanceId, globalX, globalY, extraParams, pointerId, context = pipelineContext]() {
498         context->OnDragEvent({globalX, globalY }, DragEventAction::DRAG_EVENT_START_FOR_CONTROLLER);
499         NG::DragDropFuncWrapper::DecideWhetherToStopDragging(
500             { globalX, globalY }, extraParams, pointerId, instanceId);
501     },
502     TaskExecutor::TaskType::UI, "ArkUIDragHandleDragEventStart");
503     EXPECT_EQ(instanceId, -1);
504 }
505 
506 /**
507  * @tc.name: DragDropFuncWrapperTestNgCoverage022
508  * @tc.desc: Test PrepareShadowParametersForDragData with Invalid shadow
509  * @tc.type: FUNC
510  * @tc.author:
511  */
512 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage022, TestSize.Level1)
513 {
514     DragPreviewOption option;
515     Shadow shadow;
516     shadow.SetIsFilled(true);
517     shadow.SetOffset(Offset(5, 5));
518     shadow.SetBlurRadius(10.0);
519     shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
520     option.options.shadow = shadow;
521 
522     auto arkExtraInfoJson = std::make_unique<JsonValue>();
523     DragDropFuncWrapper::PrepareShadowParametersForDragData(arkExtraInfoJson, option);
524 
525     EXPECT_TRUE(arkExtraInfoJson->GetValue("shadow_enable"));
526 }
527 
528 
529 /**
530  * @tc.name: DragDropFuncWrapperTestNgCoverage023
531  * @tc.desc: Test PrepareShadowParametersForDragData with empty shadow
532  * @tc.type: FUNC
533  * @tc.author:
534  */
535 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage023, TestSize.Level1)
536 {
537     /**
538      * @tc.steps: step1. Create frameNode.
539      */
540     auto frameNode = FrameNode::CreateFrameNode(
541         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<StagePattern>());
542     /**
543      * @tc.steps: step2. Test GetDefaultBorderRadius
544      */
545     NG::DragPreviewOption dragPreviewOptions { false, false, false, false, true };
546     dragPreviewOptions.options.borderRadius = DragDropFuncWrapper::GetDefaultBorderRadius();
547     frameNode->SetDragPreviewOptions(dragPreviewOptions);
548     auto dragPreviewOption = frameNode->GetDragPreviewOption();
549     auto borderRadius = dragPreviewOption.options.borderRadius;
550     EXPECT_EQ(borderRadius.value().radiusTopLeft.value().Value(), 12.0);
551     EXPECT_EQ(borderRadius.value().radiusTopRight.value().Value(), 12.0);
552     EXPECT_EQ(borderRadius.value().radiusBottomRight.value().Value(), 12.0);
553     EXPECT_EQ(borderRadius.value().radiusBottomLeft.value().Value(), 12.0);
554     /**
555      * @tc.steps: step3. Test PrepareRadiusParametersForDragData
556      */
557     auto arkExtraInfoJson = JsonUtil::Create(true);
558     DragDropFuncWrapper::PrepareRadiusParametersForDragData(arkExtraInfoJson, dragPreviewOption);
559     auto radiusTopLeft = arkExtraInfoJson->GetDouble("drag_corner_radius1", -1);
560     auto radiusTopRight = arkExtraInfoJson->GetDouble("drag_corner_radius2", -1);
561     auto radiusBottomRight = arkExtraInfoJson->GetDouble("drag_corner_radius3", -1);
562     auto radiusBottomLeft = arkExtraInfoJson->GetDouble("drag_corner_radius4", -1);
563     EXPECT_EQ(radiusTopLeft, 12.0);
564     EXPECT_EQ(radiusTopRight, 12.0);
565     EXPECT_EQ(radiusBottomRight, 12.0);
566     EXPECT_EQ(radiusBottomLeft, 12.0);
567 }
568 
569 /**
570  * @tc.name: DragDropFuncWrapperTestNgCoverage024
571  * @tc.desc: Test PrepareRadiusParametersForDragData with valid radius
572  * @tc.type: FUNC
573  * @tc.author:
574  */
575 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage024, TestSize.Level1)
576 {
577     /**
578      * @tc.steps: step1. Create frameNode.
579      */
580     auto frameNode = FrameNode::CreateFrameNode(
581         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<StagePattern>());
582     /**
583      * @tc.steps: step2. Test GetDefaultBorderRadius
584      */
585     NG::DragPreviewOption dragPreviewOptions { false, false, false, false, true };
586     dragPreviewOptions.options.borderRadius = DragDropFuncWrapper::GetDefaultBorderRadius();
587     frameNode->SetDragPreviewOptions(dragPreviewOptions);
588     auto dragPreviewOption = frameNode->GetDragPreviewOption();
589     dragPreviewOption.options.borderRadius->radiusTopLeft = std::nullopt;
590     dragPreviewOption.options.borderRadius->radiusTopRight = std::nullopt;
591     dragPreviewOption.options.borderRadius->radiusBottomRight = std::nullopt;
592     dragPreviewOption.options.borderRadius->radiusBottomLeft = std::nullopt;
593     /**
594      * @tc.steps: step3. Test PrepareRadiusParametersForDragData
595      */
596     auto arkExtraInfoJson = JsonUtil::Create(true);
597     DragDropFuncWrapper::PrepareRadiusParametersForDragData(arkExtraInfoJson, dragPreviewOption);
598     auto radiusTopLeft = arkExtraInfoJson->GetDouble("drag_corner_radius1", -1);
599     auto radiusTopRight = arkExtraInfoJson->GetDouble("drag_corner_radius2", -1);
600     auto radiusBottomRight = arkExtraInfoJson->GetDouble("drag_corner_radius3", -1);
601     auto radiusBottomLeft = arkExtraInfoJson->GetDouble("drag_corner_radius4", -1);
602     EXPECT_EQ(radiusTopLeft, -1);
603     EXPECT_EQ(radiusTopRight, -1);
604     EXPECT_EQ(radiusBottomRight, -1);
605     EXPECT_EQ(radiusBottomLeft, -1);
606 }
607 
608 /**
609  * @tc.name: DragDropFuncWrapperTestNgCoverage026
610  * @tc.desc: Test UpdateExtraInfo with invalid radius
611  * @tc.type: FUNC
612  * @tc.author:
613  */
614 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage026, TestSize.Level1)
615 {
616     DragPreviewOption option;
617     option.options.opacity = 0.8f;
618     option.options.blurbgEffect.backGroundEffect = EffectOption();
619     option.options.blurbgEffect.backGroundEffect.radius.SetValue(1.0F);
620 
621     auto arkExtraInfoJson = std::make_unique<JsonValue>();
622     DragDropFuncWrapper::UpdateExtraInfo(arkExtraInfoJson, option);
623 
624     EXPECT_EQ(arkExtraInfoJson->GetDouble("dip_opacity"), 0);
625 }
626 /**
627  * @tc.name: DragDropFuncWrapperTestNgCoverage027
628  * @tc.desc: Test UpdateDragPreviewOptionsFromModifier with BackgroundEffect values
629  * @tc.type: FUNC
630  * @tc.author:
631  */
632 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage027, TestSize.Level1)
633 {
__anonc8fb89d30802(WeakPtr<FrameNode> frameNode) 634     auto applyOnNodeSync = [](WeakPtr<FrameNode> frameNode) {
635         auto node = frameNode.Upgrade();
636         CHECK_NULL_VOID(node);
637         CalcDimension radius;
638         radius.SetValue(80.0f);
639         Color color = Color::FromARGB(13, 255, 255, 255);
640         EffectOption effoption = { radius, 1.0, 1.08, color };
641         node->GetRenderContext()->UpdateBackgroundEffect(effoption);
642     };
643 
644     DragPreviewOption option;
645     DragDropFuncWrapper::UpdateDragPreviewOptionsFromModifier(applyOnNodeSync, option);
646 
647     EXPECT_TRUE(option.options.blurbgEffect.backGroundEffect.radius.IsValid());
648 }
649 
650 /**
651  * @tc.name: DragDropFuncWrapperTestNgCoverage028
652  * @tc.desc: Test UpdateDragPreviewOptionsFromModifier with  BackShadow ,BorderRadius,without,bgEffect,with
653  * BackBlurStyle ;
654  * @tc.type: FUNC
655  * @tc.author:
656  */
657 HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage028, TestSize.Level1)
658 {
__anonc8fb89d30902(WeakPtr<FrameNode> frameNode) 659     auto applyOnNodeSync = [](WeakPtr<FrameNode> frameNode) {
660         auto node = frameNode.Upgrade();
661         CHECK_NULL_VOID(node);
662         Shadow shadow;
663         shadow.SetIsFilled(true);
664         shadow.SetOffset(Offset(5, 5));
665         shadow.SetBlurRadius(10.0);
666         shadow.SetColor(Color::FromARGB(255, 255, 0, 0));
667         BlurStyleOption styleOption;
668         styleOption.blurStyle = BlurStyle::COMPONENT_THICK;
669         styleOption.scale = 0.5;
670         styleOption.colorMode = ThemeColorMode::LIGHT;
671         BorderRadiusProperty borderRadius;
672         borderRadius.SetRadius(Dimension(50.0));
673         node->GetRenderContext()->UpdateBorderRadius(borderRadius);
674         node->GetRenderContext()->UpdateBackShadow(shadow);
675         node->GetRenderContext()->UpdateBackBlurStyle(styleOption);
676         node->GetRenderContext()->UpdateBackgroundEffect(std::nullopt);
677 
678 
679     };
680 
681     DragPreviewOption option;
682     DragDropFuncWrapper::UpdateDragPreviewOptionsFromModifier(applyOnNodeSync, option);
683 
684     EXPECT_TRUE(option.options.shadow.has_value());
685     EXPECT_TRUE(option.options.borderRadius.has_value());
686     EXPECT_FALSE(option.options.blurbgEffect.backGroundEffect.radius.IsValid());
687 }
688 
689 /**
690  * @tc.name: TestIsSelectedItemNode
691  * @tc.desc: Test IsSelectedItemNode func
692  * @tc.type: FUNC
693  * @tc.author:
694  */
695 HWTEST_F(DragDropFuncWrapperTestNgCoverage, TestIsSelectedItemNode, TestSize.Level1)
696 {
697     int32_t caseNum = 0;
698     for (const auto& testCase : DRAG_MULTI_CASES) {
699         /**
700          * @tc.steps: step1. Create grid with gridItem frame node tree.
701          * @tc.expected: instance is not null.
702          */
703         auto gridNode = ProcessDragItemGroupScene();
704         ASSERT_NE(gridNode, nullptr);
705         auto gridItem = AceType::DynamicCast<FrameNode>(gridNode->GetChildByIndex(0));
706         ASSERT_NE(gridItem, nullptr);
707         auto gridItemPattern = gridItem->GetPattern<GridItemPattern>();
708         ASSERT_NE(gridItemPattern, nullptr);
709 
710         /**
711          * @tc.steps: step2. Set GridItemNode selected
712          */
713         gridItemPattern->SetSelected(testCase.isSelected);
714 
715         /**
716          * @tc.steps: step3. Set GridItemNode isMultiSelectionEnabled
717          */
718         auto dragPreviewOption = gridItem->GetDragPreviewOption();
719         dragPreviewOption.isMultiSelectionEnabled = testCase.isMultiSelectionEnabled;
720         gridItem->SetDragPreviewOptions(dragPreviewOption);
721 
722         /**
723          * @tc.steps: step4. Set GridItemNode isAllowDrag
724          */
725         if (testCase.isAllowDrag) {
726             SetFrameNodeAllowDrag(gridItem);
727         }
728         EXPECT_TRUE(IsDragEventStateEqual(caseNum, DragDropFuncWrapper::IsSelectedItemNode(gridItem),
729             testCase.expectResult));
730         caseNum++;
731     }
732 }
733 
734 /**
735  * @tc.name: Test IsBelongToMultiItemNode
736  * @tc.desc: Test IsBelongToMultiItemNode func
737  * @tc.type: FUNC
738  * @tc.author:
739  */
740 HWTEST_F(DragDropFuncWrapperTestNgCoverage, TestIsBelongToMultiItemNode, TestSize.Level1)
741 {
742     /**
743      * @tc.steps: step1. Create grid with gridItem frame node tree.
744      * @tc.expected: instance is not null.
745      */
746     auto gridNode = ProcessDragItemGroupScene();
747     ASSERT_NE(gridNode, nullptr);
748     auto gridItem = AceType::DynamicCast<FrameNode>(gridNode->GetChildByIndex(0));
749     ASSERT_NE(gridItem, nullptr);
750 
751     /**
752      * @tc.steps: step2. Create frameNode.
753      * @tc.expected: IsBelongToMultiItemNode return false.
754      */
755     auto frameNode = FrameNode::CreateFrameNode(
756         V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<StagePattern>());
757     ASSERT_NE(frameNode, nullptr);
758     frameNode->MountToParent(gridItem);
759     EXPECT_FALSE(DragDropFuncWrapper::IsBelongToMultiItemNode(frameNode));
760 
761     /**
762      * @tc.steps: step3. Set frameNode is selected and allowDrag.
763      * @tc.expected: IsBelongToMultiItemNode return true.
764      */
765     auto gridItemPattern = gridItem->GetPattern<GridItemPattern>();
766     ASSERT_NE(gridItemPattern, nullptr);
767     gridItemPattern->SetSelected(true);
768     auto dragPreviewOption = gridItem->GetDragPreviewOption();
769     dragPreviewOption.isMultiSelectionEnabled = true;
770     gridItem->SetDragPreviewOptions(dragPreviewOption);
771     SetFrameNodeAllowDrag(gridItem);
772 
773     EXPECT_TRUE(DragDropFuncWrapper::IsBelongToMultiItemNode(frameNode));
774 }
775 
776 /**
777  * @tc.name: Test CheckIsNeedGather
778  * @tc.desc: Test CheckIsNeedGather func
779  * @tc.type: FUNC
780  * @tc.author:
781  */
782 HWTEST_F(DragDropFuncWrapperTestNgCoverage, CheckIsNeedGather, TestSize.Level1)
783 {
784     int32_t caseNum = 0;
785     for (const auto& testCase : DRAG_MULTI_CASES) {
786         /**
787          * @tc.steps: step1. Create grid with gridItem frame node tree.
788          * @tc.expected: instance is not null.
789          */
790         auto gridNode = ProcessDragItemGroupScene();
791         ASSERT_NE(gridNode, nullptr);
792         auto gridItem = AceType::DynamicCast<FrameNode>(gridNode->GetChildByIndex(0));
793         ASSERT_NE(gridItem, nullptr);
794         auto gridItemPattern = gridItem->GetPattern<GridItemPattern>();
795         ASSERT_NE(gridItemPattern, nullptr);
796 
797         /**
798          * @tc.steps: step2. Set GridItemNode selected
799          */
800         gridItemPattern->SetSelected(testCase.isSelected);
801 
802         /**
803          * @tc.steps: step3. Set GridItemNode isMultiSelectionEnabled
804          */
805         auto dragPreviewOption = gridItem->GetDragPreviewOption();
806         dragPreviewOption.isMultiSelectionEnabled = testCase.isMultiSelectionEnabled;
807         gridItem->SetDragPreviewOptions(dragPreviewOption);
808 
809         /**
810          * @tc.steps: step4. Set GridItemNode isAllowDrag
811          */
812         if (testCase.isAllowDrag) {
813             SetFrameNodeAllowDrag(gridItem);
814         }
815         EXPECT_TRUE(IsDragEventStateEqual(caseNum, DragDropFuncWrapper::CheckIsNeedGather(gridItem),
816             testCase.expectResult));
817         caseNum++;
818     }
819 }
820 
821 /**
822  * @tc.name: Test FindItemParentNode
823  * @tc.desc: Test FindItemParentNode func
824  * @tc.type: FUNC
825  * @tc.author:
826  */
827 HWTEST_F(DragDropFuncWrapperTestNgCoverage, FindItemParentNode, TestSize.Level1)
828 {
829     /**
830      * @tc.steps: step1. Create grid with gridItem frame node tree.
831      * @tc.expected: instance is not null.
832      * @tc.expected: FindItemParentNode return false.
833      */
834     auto gridNode = ProcessDragItemGroupScene();
835     ASSERT_NE(gridNode, nullptr);
836     auto gridItem = AceType::DynamicCast<FrameNode>(gridNode->GetChildByIndex(0));
837     ASSERT_NE(gridItem, nullptr);
838 
839     /**
840      * @tc.steps: step2.run FindItemParentNode func
841      * @tc.expected: FindItemParentNode return gridNode.
842      */
843     SetFrameNodeAllowDrag(gridItem);
844     EXPECT_EQ(DragDropFuncWrapper::FindItemParentNode(gridItem), gridNode);
845 
846     /**
847      * @tc.steps: step3.test other class frameNode
848      * @tc.expected: FindItemParentNode return nullptr.
849      */
850     auto frameNode = FrameNode::GetOrCreateFrameNode(V2::TEXT_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
__anonc8fb89d30a02() 851         []() {return AceType::MakeRefPtr<Pattern>(); });
852     ASSERT_NE(frameNode, nullptr);
853     frameNode->MountToParent(gridNode);
854     EXPECT_EQ(DragDropFuncWrapper::FindItemParentNode(frameNode), nullptr);
855 }
856 
857 /**
858  * @tc.name: Test RequestDragEndPending
859  * @tc.desc: Test RequestDragEndPending func
860  * @tc.type: FUNC
861  * @tc.author:
862  */
863 HWTEST_F(DragDropFuncWrapperTestNgCoverage, RequestDragEndPending, TestSize.Level1)
864 {
865     int32_t requestId = DragDropFuncWrapper::RequestDragEndPending();
866     EXPECT_EQ(requestId, -1);
867 
868     DragDropGlobalController::GetInstance().SetIsOnOnDropPhase(true);
869     requestId = DragDropFuncWrapper::RequestDragEndPending();
870     EXPECT_NE(requestId, -1);
871 
872     DragDropGlobalController::GetInstance().SetIsOnOnDropPhase(false);
873     requestId = DragDropFuncWrapper::RequestDragEndPending();
874     EXPECT_EQ(requestId, -1);
875 }
876 
877 /**
878  * @tc.name: Test NotifyDragResult
879  * @tc.desc: Test NotifyDragResult func
880  * @tc.type: FUNC
881  * @tc.author:
882  */
883 HWTEST_F(DragDropFuncWrapperTestNgCoverage, NotifyDragResult, TestSize.Level1)
884 {
885     int32_t requestId = 1;
886     DragDropGlobalController::GetInstance().requestId_ = 0;
887     int32_t ret = DragDropFuncWrapper::NotifyDragResult(requestId, static_cast<int32_t>(DragRet::DRAG_SUCCESS));
888     EXPECT_EQ(ret, -1);
889     EXPECT_EQ(DragDropGlobalController::GetInstance().dragResult_, DragRet::DRAG_FAIL);
890 
891     DragDropGlobalController::GetInstance().SetIsOnOnDropPhase(true);
892     ret = DragDropFuncWrapper::NotifyDragResult(requestId, static_cast<int32_t>(DragRet::DRAG_SUCCESS));
893     EXPECT_EQ(ret, -1);
894     EXPECT_EQ(DragDropGlobalController::GetInstance().dragResult_, DragRet::DRAG_FAIL);
895 
896     DragDropGlobalController::GetInstance().requestId_ = requestId;
897     ret = DragDropFuncWrapper::NotifyDragResult(requestId, static_cast<int32_t>(DragRet::DRAG_SUCCESS));
898     EXPECT_EQ(ret, 0);
899     EXPECT_EQ(DragDropGlobalController::GetInstance().dragResult_, DragRet::DRAG_SUCCESS);
900     DragDropGlobalController::GetInstance().SetIsOnOnDropPhase(false);
901 }
902 
903 /**
904  * @tc.name: Test NotifyDragEndPendingDone
905  * @tc.desc: Test NotifyDragEndPendingDone func
906  * @tc.type: FUNC
907  * @tc.author:
908  */
909 HWTEST_F(DragDropFuncWrapperTestNgCoverage, NotifyDragEndPendingDone, TestSize.Level1)
910 {
911     int32_t requestId = 1;
912     DragDropGlobalController::GetInstance().requestId_ = 0;
913     DragDropGlobalController::GetInstance().dragResult_ = DragRet::DRAG_SUCCESS;
914     int32_t ret = DragDropFuncWrapper::NotifyDragEndPendingDone(requestId);
915     EXPECT_EQ(ret, -1);
916     EXPECT_EQ(DragDropGlobalController::GetInstance().dragResult_, DragRet::DRAG_SUCCESS);
917 
918     DragDropGlobalController::GetInstance().SetIsOnOnDropPhase(true);
919     ret = DragDropFuncWrapper::NotifyDragEndPendingDone(requestId);
920     EXPECT_EQ(ret, -1);
921     EXPECT_EQ(DragDropGlobalController::GetInstance().dragResult_, DragRet::DRAG_SUCCESS);
922 
923     DragDropGlobalController::GetInstance().requestId_ = requestId;
924     ret = DragDropFuncWrapper::NotifyDragEndPendingDone(requestId);
925     EXPECT_EQ(ret, 0);
926     EXPECT_EQ(DragDropGlobalController::GetInstance().dragResult_, DragRet::DRAG_FAIL);
927     DragDropGlobalController::GetInstance().SetIsOnOnDropPhase(false);
928 }
929 
930 /**
931  * @tc.name: Test GetAnonyString
932  * @tc.desc: Test GetAnonyString func
933  * @tc.type: FUNC
934  * @tc.author:
935  */
936 HWTEST_F(DragDropFuncWrapperTestNgCoverage, GetAnonyString, TestSize.Level1)
937 {
938     std::string fullString = "";
939     std::string anonyStr = "";
940     std::string ret = NG::DragDropFuncWrapper::GetAnonyString(fullString);
941     EXPECT_EQ(ret, anonyStr);
942 
943     fullString = "test";
944     anonyStr = "t******t";
945     ret = NG::DragDropFuncWrapper::GetAnonyString(fullString);
946     EXPECT_EQ(ret, anonyStr);
947 
948     fullString = "testFullString";
949     anonyStr = "test******ring";
950     ret = NG::DragDropFuncWrapper::GetAnonyString(fullString);
951     EXPECT_EQ(ret, anonyStr);
952 }
953 
954 /**
955  * @tc.name: Test GetPointerEventAction
956  * @tc.desc: Test GetPointerEventAction func
957  * @tc.type: FUNC
958  * @tc.author:
959  */
960 HWTEST_F(DragDropFuncWrapperTestNgCoverage, GetPointerEventAction, TestSize.Level1)
961 {
962     TouchEvent touchPoint;
963     DragPointerEvent event;
964 
965     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
966     EXPECT_EQ(event.action, PointerAction::UNKNOWN);
967 
968     touchPoint.type = TouchType::CANCEL;
969     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
970     EXPECT_EQ(event.action, PointerAction::CANCEL);
971 
972     touchPoint.type = TouchType::DOWN;
973     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
974     EXPECT_EQ(event.action, PointerAction::DOWN);
975 
976     touchPoint.type = TouchType::MOVE;
977     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
978     EXPECT_EQ(event.action, PointerAction::MOVE);
979 
980     touchPoint.type = TouchType::UP;
981     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
982     EXPECT_EQ(event.action, PointerAction::UP);
983 
984     touchPoint.type = TouchType::PULL_MOVE;
985     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
986     EXPECT_EQ(event.action, PointerAction::PULL_MOVE);
987 
988     touchPoint.type = TouchType::PULL_UP;
989     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
990     EXPECT_EQ(event.action, PointerAction::PULL_UP);
991 
992     touchPoint.type = TouchType::PULL_IN_WINDOW;
993     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
994     EXPECT_EQ(event.action, PointerAction::PULL_IN_WINDOW);
995 
996     touchPoint.type = TouchType::PULL_OUT_WINDOW;
997     NG::DragDropFuncWrapper::GetPointerEventAction(touchPoint, event);
998     EXPECT_EQ(event.action, PointerAction::PULL_OUT_WINDOW);
999 }
1000 
1001 /**
1002  * @tc.name: Test GetFrameNodeByInspectorId
1003  * @tc.desc: Test GetFrameNodeByInspectorId func
1004  * @tc.type: FUNC
1005  * @tc.author:
1006  */
1007 HWTEST_F(DragDropFuncWrapperTestNgCoverage, GetFrameNodeByInspectorId, TestSize.Level1)
1008 {
1009     std::string inspectorId = "";
1010     RefPtr<FrameNode> ret = NG::DragDropFuncWrapper::GetFrameNodeByInspectorId(inspectorId);
1011     EXPECT_EQ(ret, nullptr);
1012 
1013     inspectorId = "test";
1014     auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG,
1015         ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
1016     auto frameNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG,
1017         ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
1018     frameNode->UpdateInspectorId(inspectorId);
1019     auto context = PipelineContext::GetCurrentContext();
1020     context->rootNode_ = rootNode;
1021     rootNode->AddChild(frameNode);
1022     ret = NG::DragDropFuncWrapper::GetFrameNodeByInspectorId(inspectorId);
1023     EXPECT_EQ(ret, frameNode);
1024 
1025     frameNode->GetLayoutProperty()->UpdateVisibility(VisibleType::GONE);
1026     ret = NG::DragDropFuncWrapper::GetFrameNodeByInspectorId(inspectorId);
1027     EXPECT_EQ(ret, nullptr);
1028 
1029     frameNode->GetLayoutProperty()->UpdateVisibility(VisibleType::INVISIBLE);
1030     ret = NG::DragDropFuncWrapper::GetFrameNodeByInspectorId(inspectorId);
1031     EXPECT_EQ(ret, nullptr);
1032 }
1033 
1034 /**
1035  * @tc.name: Test GetPointRelativeToMainWindow
1036  * @tc.desc: Test GetPointRelativeToMainWindow func
1037  * @tc.type: FUNC
1038  * @tc.author:
1039  */
1040 HWTEST_F(DragDropFuncWrapperTestNgCoverage, GetPointRelativeToMainWindow, TestSize.Level1)
1041 {
1042     Point point = { 0, 0 };
1043     OffsetF ret = NG::DragDropFuncWrapper::GetPointRelativeToMainWindow(point);
1044     EXPECT_EQ(ret.GetX(), point.GetX());
1045     EXPECT_EQ(ret.GetY(), point.GetY());
1046 }
1047 
1048 /**
1049  * @tc.name: Test GetFrameNodeByKey
1050  * @tc.desc: Test GetFrameNodeByKey func
1051  * @tc.type: FUNC
1052  * @tc.author:
1053  */
1054 HWTEST_F(DragDropFuncWrapperTestNgCoverage, GetFrameNodeByKey, TestSize.Level1)
1055 {
1056     auto frameNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG,
1057         ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr<Pattern>());
1058     std::string key = "";
1059     RefPtr<FrameNode> ret = NG::DragDropFuncWrapper::GetFrameNodeByKey(frameNode, key);
1060     EXPECT_NE(ret, nullptr);
1061 }
1062 } // namespace OHOS::Ace::NG
1063