mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2025-02-17 06:08:13 +00:00
!1153 feat:Enter text editor and change drag data to 8dp or restore
Merge pull request !1153 from Bumblebee/mrsong_branch
This commit is contained in:
commit
bc7c1666c9
@ -54,7 +54,6 @@ constexpr int32_t TIME_WAIT_FOR_ANIMATION_END { 1000 };
|
||||
constexpr int32_t WINDOW_ID { -1 };
|
||||
constexpr bool HAS_CANCELED_ANIMATION { true };
|
||||
constexpr bool HAS_CUSTOM_ANIMATION { true };
|
||||
constexpr bool NOT_HAS_CUSTOM_ANIMATION { false };
|
||||
constexpr bool DRAG_WINDOW_VISIBLE { true };
|
||||
const std::string UD_KEY { "Unified data key" };
|
||||
const std::string FILTER_INFO { "Undefined filter info" };
|
||||
@ -404,13 +403,73 @@ HWTEST_F(InteractionDragDrawingTest, InteractionDragDrawingTest_Touchscreen_Anim
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->UpdateDragStyle(DragCursorStyle::COPY);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
DragDropResult dropResult { DragResult::DRAG_FAIL, NOT_HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
DragDropResult dropResult { DragResult::DRAG_FAIL, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) != std::future_status::timeout);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_ANIMATION_END));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: EnterTextEditorArea001
|
||||
* @tc.desc: normal test for pixelMap 8dp bit movement effect
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InteractionDragDrawingTest, EnterTextEditorArea001, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->EnterTextEditorArea(true);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_ANIMATION_END));
|
||||
ret = InteractionManager::GetInstance()->EnterTextEditorArea(false);
|
||||
EXPECT_EQ(ret, RET_OK);
|
||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) != std::future_status::timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: EnterTextEditorArea002
|
||||
* @tc.desc: abnormal test for pixelMap 8dp bit movement effect
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InteractionDragDrawingTest, EnterTextEditorArea002, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
std::promise<bool> promiseFlag;
|
||||
std::future<bool> futureFlag = promiseFlag.get_future();
|
||||
auto callback = [&promiseFlag](const DragNotifyMsg& notifyMessage) {
|
||||
FI_HILOGD("displayX:%{public}d, displayY:%{public}d, result:%{public}d, target:%{public}d",
|
||||
notifyMessage.displayX, notifyMessage.displayY, notifyMessage.result, notifyMessage.targetPid);
|
||||
promiseFlag.set_value(true);
|
||||
};
|
||||
std::optional<DragData> dragData = CreateDragData(
|
||||
MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN, POINTER_ID, DRAG_NUM_ONE);
|
||||
ASSERT_TRUE(dragData);
|
||||
int32_t ret = InteractionManager::GetInstance()->StartDrag(dragData.value(), callback);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->EnterTextEditorArea(false);
|
||||
EXPECT_EQ(ret, RET_ERR);
|
||||
DragDropResult dropResult { DragResult::DRAG_SUCCESS, HAS_CUSTOM_ANIMATION, WINDOW_ID };
|
||||
ret = InteractionManager::GetInstance()->StopDrag(dropResult);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ASSERT_TRUE(futureFlag.wait_for(std::chrono::milliseconds(PROMISE_WAIT_SPAN_MS)) != std::future_status::timeout);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
|
@ -1903,23 +1903,6 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_UpdatePreviewStyleWithAn
|
||||
std::future_status::timeout);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: InteractionManagerTest_EnterTextEditorArea
|
||||
* @tc.desc: pixelMap 8dp bit movement effect
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(InteractionManagerTest, EnterTextEditorArea, TestSize.Level1)
|
||||
{
|
||||
CALL_TEST_DEBUG;
|
||||
int32_t ret = InteractionManager::GetInstance()->EnterTextEditorArea(true);
|
||||
FI_HILOGD("ret:%{public}d", ret);
|
||||
ASSERT_EQ(ret, RET_OK);
|
||||
ret = InteractionManager::GetInstance()->EnterTextEditorArea(false);
|
||||
FI_HILOGD("ret:%{public}d", ret);
|
||||
ASSERT_EQ(ret, RET_ERR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InteractionManagerTest_GetExtraInfo
|
||||
* @tc.desc: Get extraInfo
|
||||
|
@ -95,6 +95,7 @@ int32_t DragManager::StopDrag(DragResult result, bool hasCustomAnimation)
|
||||
DRAG_DATA_MGR.ResetDragData();
|
||||
dragResult_ = static_cast<DragResult>(result);
|
||||
StateChangedNotify(DragState::STOP);
|
||||
dragDrawing_.SetTextEditorAreaFlag(false);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,7 @@ public:
|
||||
void OnStopDragFail(std::shared_ptr<Rosen::RSSurfaceNode> surfaceNode,
|
||||
std::shared_ptr<Rosen::RSNode> rootNode) override;
|
||||
void OnStopAnimation() override;
|
||||
void SetTextEditorAreaFlag(bool textEditorAreaFlag);
|
||||
int32_t EnterTextEditorArea(bool enable);
|
||||
bool GetAllowDragState();
|
||||
void SetScreenId(uint64_t screenId);
|
||||
@ -173,6 +174,8 @@ private:
|
||||
void DoDrawMouse();
|
||||
int32_t UpdateDefaultDragStyle(DragCursorStyle style);
|
||||
int32_t UpdateValidDragStyle(DragCursorStyle style);
|
||||
int32_t SetNodesLocation(int32_t positionX, int32_t positionY);
|
||||
int32_t CreateEventRunner(int32_t positionX, int32_t positionY);
|
||||
int32_t ModifyPreviewStyle(std::shared_ptr<Rosen::RSCanvasNode> node, const PreviewStyle &previewStyle);
|
||||
|
||||
private:
|
||||
@ -188,6 +191,9 @@ private:
|
||||
void* dragExtHandle_ { nullptr };
|
||||
bool needDestroyDragWindow_ { false };
|
||||
uint64_t screenId_ { 0 };
|
||||
bool textEditorAreaFlag_ { false };
|
||||
int32_t resetPixelMapX_ { 0 };
|
||||
int32_t resetPixelMapY_ { 0 };
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
@ -93,6 +93,7 @@ constexpr int32_t GLOBAL_WINDOW_ID { -1 };
|
||||
constexpr int32_t MOUSE_DRAG_CURSOR_CIRCLE_STYLE { 41 };
|
||||
constexpr int32_t CURSOR_CIRCLE_MIDDLE { 2 };
|
||||
constexpr size_t EXTRA_INFO_MAX_SIZE { 200 };
|
||||
const Rosen::RSAnimationTimingCurve SPRING = Rosen::RSAnimationTimingCurve::CreateSpring(0.347f, 0.99f, 0.0f);
|
||||
const std::string DEVICE_TYPE_DEFAULT { "default" };
|
||||
const std::string DEVICE_TYPE_PHONE { "phone" };
|
||||
const std::string THREAD_NAME { "os_AnimationEventRunner" };
|
||||
@ -1211,13 +1212,83 @@ void DragDrawing::ProcessFilter()
|
||||
}
|
||||
}
|
||||
|
||||
void DragDrawing::SetTextEditorAreaFlag(bool textEditorAreaFlag)
|
||||
{
|
||||
textEditorAreaFlag_ = textEditorAreaFlag;
|
||||
}
|
||||
|
||||
int32_t DragDrawing::SetNodesLocation(int32_t positionX, int32_t positionY)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
Rosen::RSAnimationTimingProtocol protocol;
|
||||
int32_t adjustSize = TWELVE_SIZE * GetScaling();
|
||||
CHKPR(g_drawingInfo.parentNode, RET_ERR);
|
||||
CHKPR(g_drawingInfo.pixelMap, RET_ERR);
|
||||
Rosen::RSNode::Animate(protocol, SPRING, [&]() {
|
||||
g_drawingInfo.parentNode->SetBounds(positionX, positionY, g_drawingInfo.pixelMap->GetWidth() + adjustSize,
|
||||
g_drawingInfo.pixelMap->GetHeight() + adjustSize);
|
||||
g_drawingInfo.parentNode->SetFrame(positionX, positionY, g_drawingInfo.pixelMap->GetWidth() + adjustSize,
|
||||
g_drawingInfo.pixelMap->GetHeight() + adjustSize);
|
||||
});
|
||||
startNum_ = START_TIME;
|
||||
needDestroyDragWindow_ = false;
|
||||
StartVsync();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragDrawing::CreateEventRunner(int32_t positionX, int32_t positionY)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (handler_ == nullptr) {
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPR(runner, RET_ERR);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
}
|
||||
if (!handler_->PostTask(std::bind(&DragDrawing::SetNodesLocation, this, positionX, positionY))) {
|
||||
FI_HILOGE("Send animationExtFunc failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragDrawing::EnterTextEditorArea(bool enable)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
if (enable) {
|
||||
return RET_OK;
|
||||
CHKPR(g_drawingInfo.pixelMap, RET_ERR);
|
||||
if (!textEditorAreaFlag_) {
|
||||
resetPixelMapX_ = g_drawingInfo.pixelMapX;
|
||||
resetPixelMapY_ = g_drawingInfo.pixelMapY;
|
||||
}
|
||||
return RET_ERR;
|
||||
int32_t adjustSize = EIGHT_SIZE * GetScaling();
|
||||
g_drawingInfo.pixelMapX = -(g_drawingInfo.pixelMap->GetWidth() / 2);
|
||||
g_drawingInfo.pixelMapY = -adjustSize;
|
||||
adjustSize = TWELVE_SIZE * GetScaling();
|
||||
int32_t positionX = g_drawingInfo.displayX + g_drawingInfo.pixelMapX;
|
||||
int32_t positionY = g_drawingInfo.displayY + g_drawingInfo.pixelMapY - adjustSize;
|
||||
if (textEditorAreaFlag_ && !enable) {
|
||||
g_drawingInfo.pixelMapX = resetPixelMapX_;
|
||||
g_drawingInfo.pixelMapY = resetPixelMapY_;
|
||||
positionX = g_drawingInfo.displayX + g_drawingInfo.pixelMapX;
|
||||
positionY = g_drawingInfo.displayY + g_drawingInfo.pixelMapY - adjustSize;
|
||||
if (CreateEventRunner(positionX, positionY) == RET_OK) {
|
||||
FI_HILOGD("CreateEventRunner successfully");
|
||||
return RET_OK;
|
||||
}
|
||||
FI_HILOGE("CreateEventRunner failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
if (!enable || textEditorAreaFlag_) {
|
||||
FI_HILOGD("enable is false or textEditorAreaFlag_ is true");
|
||||
return RET_ERR;
|
||||
}
|
||||
if (CreateEventRunner(positionX, positionY) != RET_OK) {
|
||||
FI_HILOGE("CreateEventRunner failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGD("CreateEventRunner successfully");
|
||||
textEditorAreaFlag_ = true;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
float DragDrawing::RadiusVp2Sigma(float radiusVp, float dipScale)
|
||||
|
Loading…
x
Reference in New Issue
Block a user