diff --git a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp index 4e3d030fb73ba096a32f00f98c85c1474910fcf2..81e5d7c97b42363c47db4e43c5584c3e9082dc40 100644 --- a/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp +++ b/frameworks/core/components_ng/manager/drag_drop/drag_drop_func_wrapper.cpp @@ -67,18 +67,21 @@ static bool CheckInternalDragging(const RefPtr& container) void GetShadowInfoArray( std::shared_ptr dragAction, std::vector& shadowInfos) { - auto minScaleWidth = NG::DragDropFuncWrapper::GetScaleWidth(dragAction->instanceId); for (auto& pixelMap : dragAction->pixelMapList) { double scale = 1.0; + int32_t width = 0; + int32_t height = 0; if (Referenced::RawPtr(pixelMap)) { - if (pixelMap->GetWidth() > minScaleWidth && dragAction->previewOption.isScaleEnabled) { - scale = minScaleWidth / pixelMap->GetWidth(); + width = pixelMap->GetWidth(); + height = pixelMap->GetHeight(); + if (width > 0 && height > 0 && dragAction->previewOption.isScaleEnabled) { + auto scaleData = DragDropManager::GetScaleInfo(width, height, false); + CHECK_NULL_VOID(scaleData); + scale = scaleData->scale; } auto pixelMapScale = dragAction->windowScale * scale; pixelMap->Scale(pixelMapScale, pixelMapScale, AceAntiAliasingOption::HIGH); } - int32_t width = pixelMap->GetWidth(); - int32_t height = pixelMap->GetHeight(); double x = dragAction->touchPointX; double y = dragAction->touchPointY; if (!dragAction->hasTouchPoint) { diff --git a/test/unittest/core/manager/drag_drop/drag_drop_func_wrapper_test_ng_coverage.cpp b/test/unittest/core/manager/drag_drop/drag_drop_func_wrapper_test_ng_coverage.cpp index 47cfa7c6eed728ecdb7653084a887dac42a4263a..489d8fb16aecd448a133cfad4969270b2bc435dd 100644 --- a/test/unittest/core/manager/drag_drop/drag_drop_func_wrapper_test_ng_coverage.cpp +++ b/test/unittest/core/manager/drag_drop/drag_drop_func_wrapper_test_ng_coverage.cpp @@ -18,6 +18,7 @@ #include "gtest/gtest.h" #define private public +#include "test/mock/base/mock_pixel_map.h" #include "test/mock/core/common/mock_theme_manager.h" #include "test/mock/core/render/mock_render_context.h" #include "test/mock/base/mock_drag_window.h" @@ -1917,4 +1918,26 @@ HWTEST_F(DragDropFuncWrapperTestNgCoverage, UpdateDragDropInitiatingStatus003, T DragDropGlobalController::GetInstance().UpdateDragDropInitiatingStatus(frameNode, DragDropInitiatingStatus::MOVING); EXPECT_EQ(DragDropGlobalController::GetInstance().currentDragNode_, frameNode); } + +/** + * @tc.name: Test DragDropFuncWrapperTestNgCoverage044 + * @tc.desc: Test StartDragAction func + * @tc.type: FUNC + * @tc.author: + */ +HWTEST_F(DragDropFuncWrapperTestNgCoverage, DragDropFuncWrapperTestNgCoverage044, TestSize.Level1) +{ + auto dragAction = std::make_shared(); + auto container = Container::Current(); + AceEngine& aceEngine = AceEngine::Get(); + aceEngine.AddContainer(0, container); + dragAction->instanceId = 0; + RefPtr mockPixelMap = AceType::MakeRefPtr(); + ASSERT_NE(mockPixelMap, nullptr); + dragAction->pixelMapList.push_back(mockPixelMap); + EXPECT_CALL(*mockPixelMap, GetWidth()).Times(1).WillOnce(testing::Return(10.0f)); + EXPECT_CALL(*mockPixelMap, GetHeight()).Times(1).WillOnce(testing::Return(10.0f)); + int32_t ret = DragDropFuncWrapper::StartDragAction(dragAction); + EXPECT_EQ(ret, -1); +} } // namespace OHOS::Ace::NG