From 23b86563c94b993fadbf53e1ad292b52beb1f3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Thu, 4 Sep 2025 11:36:30 +0800 Subject: [PATCH 1/4] fix alarm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 Change-Id: I180947a0648d3e2c98463bf66a6d0030a7ed9b44 --- .../session/host/src/system_session.cpp | 2 +- .../unittest/move_drag_controller_test.cpp | 40 ++++++++----------- .../unittest/window_layout_policy_test.cpp | 12 +++--- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index 689682af96..9bbafe2b2e 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -284,7 +284,7 @@ bool SystemSession::CheckKeyEventDispatch(const std::shared_ptr& parentSessionState != SessionState::STATE_ACTIVE) || (state_ != SessionState::STATE_FOREGROUND && state_ != SessionState::STATE_ACTIVE)) { - TLOGE(WmsLogTag::WMS_DIALOG, "Dialog's parent info : [persistentId: %{publicd}d, state:%{public}d];" + TLOGE(WmsLogTag::WMS_DIALOG, "Dialog's parent info : [persistentId: %{public}d, state:%{public}d];" "Dialog info:[persistentId: %{public}d, state:%{public}d]", parentSession->GetPersistentId(), parentSessionState, GetPersistentId(), GetSessionState()); return false; diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index c0018cc2f1..872403bd24 100644 --- a/window_scene/test/unittest/move_drag_controller_test.cpp +++ b/window_scene/test/unittest/move_drag_controller_test.cpp @@ -191,18 +191,6 @@ HWTEST_F(MoveDragControllerTest, GetTargetRect, TestSize.Level1) ASSERT_EQ(pos, res.posY_); } -/** - * @tc.name: InitMoveDragProperty - * @tc.desc: test function : InitMoveDragProperty - * @tc.type: FUNC - */ -HWTEST_F(MoveDragControllerTest, InitMoveDragProperty, TestSize.Level1) -{ - int32_t res = 0; - moveDragController->InitMoveDragProperty(); - ASSERT_EQ(0, res); -} - /** * @tc.name: InitCrossDisplayProperty * @tc.desc: test function : InitCrossDisplayProperty @@ -335,8 +323,7 @@ HWTEST_F(MoveDragControllerTest, CalcMoveTargetRect, TestSize.Level1) std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); WSRect originalRect = { 100, 100, 1000, 1000 }; - moveDragController->CalcMoveTargetRect(pointerEvent, originalRect); - ASSERT_EQ(0, res); + EXPECT_FALSE(moveDragController->CalcMoveTargetRect(pointerEvent, originalRect)); pointerEvent = MMI::PointerEvent::Create(); int32_t pointerId = pointerEvent->GetPointerId(); @@ -347,8 +334,7 @@ HWTEST_F(MoveDragControllerTest, CalcMoveTargetRect, TestSize.Level1) int32_t pointerWindowY = 10; moveDragController->SetOriginalMoveDragPos( pointerId, pointerType, pointerPosX, pointerPosY, pointerWindowX, pointerWindowY, originalRect); - moveDragController->CalcMoveTargetRect(pointerEvent, originalRect); - ASSERT_EQ(0, res); + EXPECT_TRUE(moveDragController->CalcMoveTargetRect(pointerEvent, originalRect)); } /** @@ -924,14 +910,17 @@ HWTEST_F(MoveDragControllerTest, TestConsumeMoveEventWithStartMove, TestSize.Lev HWTEST_F(MoveDragControllerTest, ProcessWindowDragHotAreaFunc, TestSize.Level1) { bool isSendHotAreaMessage = true; + bool draghotareafunc = false; SizeChangeReason reason = SizeChangeReason::UNDEFINED; moveDragController->ProcessWindowDragHotAreaFunc(isSendHotAreaMessage, reason); - ASSERT_EQ(true, isSendHotAreaMessage); - auto dragHotAreaFunc = [](DisplayId displayId, int32_t type, SizeChangeReason reason) { type = 0; }; + auto dragHotAreaFunc = [&draghotareafunc](DisplayId displayId, int32_t type, SizeChangeReason reason) { + draghotareafunc = true; + type = 0; + }; auto preFunc = moveDragController->windowDragHotAreaFunc_; moveDragController->windowDragHotAreaFunc_ = dragHotAreaFunc; moveDragController->ProcessWindowDragHotAreaFunc(isSendHotAreaMessage, reason); - ASSERT_EQ(true, isSendHotAreaMessage); + ASSERT_EQ(true, draghotareafunc); moveDragController->windowDragHotAreaFunc_ = preFunc; } @@ -1424,16 +1413,19 @@ HWTEST_F(MoveDragControllerTest, HasPointDown, TestSize.Level1) */ HWTEST_F(MoveDragControllerTest, ProcessSessionRectChange, TestSize.Level1) { - int32_t res = 0; + bool iscallback = false; auto preCallback = moveDragController->moveDragCallback_; SizeChangeReason reason = SizeChangeReason::UNDEFINED; - MoveDragCallback callBack = [](SizeChangeReason reason) { return; }; - moveDragController->moveDragCallback_ = callBack; - moveDragController->ProcessSessionRectChange(reason); + MoveDragCallback callBack = [&iscallback](SizeChangeReason reason) { + iscallback = true; + return; + }; moveDragController->moveDragCallback_ = nullptr; moveDragController->ProcessSessionRectChange(reason); + moveDragController->moveDragCallback_ = callBack; + moveDragController->ProcessSessionRectChange(reason); + ASSERT_EQ(iscallback, true); moveDragController->moveDragCallback_ = preCallback; - ASSERT_EQ(0, res); } /** diff --git a/wmserver/test/unittest/window_layout_policy_test.cpp b/wmserver/test/unittest/window_layout_policy_test.cpp index 4cfd2fc17d..1f2f983bb3 100644 --- a/wmserver/test/unittest/window_layout_policy_test.cpp +++ b/wmserver/test/unittest/window_layout_policy_test.cpp @@ -200,10 +200,10 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow01, windowInfo_.dragType_ = DragType::DRAG_LEFT_OR_RIGHT; windowInfo_.reason_ = WindowSizeChangeReason::DRAG; sptr node = CreateWindowNode(windowInfo_); + node->property_->SetStretchable(true); Rect newWinRect = { 50, 50, 200, 200 }; // rect: 50, 50, 200, 200 layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, { 0, 0, 0, 0 }, newWinRect); - Rect expRect = { 50, 50, 200, 300 }; // rect: 50, 50, 200, 300 - ASSERT_EQ(expRect, expRect); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_OR_RIGHT); } /** @@ -217,10 +217,10 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow02, windowInfo_.dragType_ = DragType::DRAG_LEFT_TOP_CORNER; windowInfo_.reason_ = WindowSizeChangeReason::DRAG; sptr node = CreateWindowNode(windowInfo_); + node->property_->SetStretchable(true); Rect newWinRect = { 50, 50, 200, 200 }; // rect: 50, 50, 200, 200 layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, { 0, 0, 0, 0 }, newWinRect); - Rect expRect = { 50, 50, 200, 300 }; // rect: 50, 50, 200, 300 - ASSERT_EQ(expRect, expRect); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_OR_RIGHT); } /** @@ -234,10 +234,10 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow03, windowInfo_.dragType_ = DragType::DRAG_BOTTOM_OR_TOP; windowInfo_.reason_ = WindowSizeChangeReason::DRAG; sptr node = CreateWindowNode(windowInfo_); + node->property_->SetStretchable(true); Rect newWinRect = { 50, 50, 150, 300 }; // rect: 50, 50, 150, 300 layoutPolicy_->UpdateFloatingWindowSizeForStretchableWindow(node, { 0, 0, 0, 0 }, newWinRect); - Rect expRect = { 50, 50, 200, 300 }; // rect: 50, 50, 200, 300 - ASSERT_EQ(expRect, expRect); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_OR_RIGHT); } /** -- Gitee From 54739d336d5aa789449a6c39580fb4432acc72fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Thu, 4 Sep 2025 06:52:40 +0000 Subject: [PATCH 2/4] update window_scene/test/unittest/move_drag_controller_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- .../unittest/move_drag_controller_test.cpp | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index 872403bd24..9d21ba52bd 100644 --- a/window_scene/test/unittest/move_drag_controller_test.cpp +++ b/window_scene/test/unittest/move_drag_controller_test.cpp @@ -318,7 +318,6 @@ HWTEST_F(MoveDragControllerTest, UpdateGravityWhenDrag, TestSize.Level0) */ HWTEST_F(MoveDragControllerTest, CalcMoveTargetRect, TestSize.Level1) { - int32_t res = 0; moveDragController->InitMoveDragProperty(); std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); WSRect originalRect = { 100, 100, 1000, 1000 }; @@ -910,18 +909,15 @@ HWTEST_F(MoveDragControllerTest, TestConsumeMoveEventWithStartMove, TestSize.Lev HWTEST_F(MoveDragControllerTest, ProcessWindowDragHotAreaFunc, TestSize.Level1) { bool isSendHotAreaMessage = true; - bool draghotareafunc = false; + bool isDragHotAreaFuncCalled = false; SizeChangeReason reason = SizeChangeReason::UNDEFINED; - moveDragController->ProcessWindowDragHotAreaFunc(isSendHotAreaMessage, reason); - auto dragHotAreaFunc = [&draghotareafunc](DisplayId displayId, int32_t type, SizeChangeReason reason) { - draghotareafunc = true; - type = 0; + auto dragHotAreaFunc = [&isDragHotAreaFuncCalled](DisplayId displayId, int32_t type, SizeChangeReason reason) { + isDragHotAreaFuncCalled = true; }; auto preFunc = moveDragController->windowDragHotAreaFunc_; moveDragController->windowDragHotAreaFunc_ = dragHotAreaFunc; moveDragController->ProcessWindowDragHotAreaFunc(isSendHotAreaMessage, reason); - ASSERT_EQ(true, draghotareafunc); - moveDragController->windowDragHotAreaFunc_ = preFunc; + EXPECT_TRUE(isDragHotAreaFuncCalled); } /** @@ -1413,19 +1409,15 @@ HWTEST_F(MoveDragControllerTest, HasPointDown, TestSize.Level1) */ HWTEST_F(MoveDragControllerTest, ProcessSessionRectChange, TestSize.Level1) { - bool iscallback = false; + bool isCallbackCalled = false; auto preCallback = moveDragController->moveDragCallback_; SizeChangeReason reason = SizeChangeReason::UNDEFINED; - MoveDragCallback callBack = [&iscallback](SizeChangeReason reason) { - iscallback = true; - return; + MoveDragCallback callBack = [&isCallbackCalled](SizeChangeReason reason) { + isCallbackCalled = true; }; - moveDragController->moveDragCallback_ = nullptr; - moveDragController->ProcessSessionRectChange(reason); moveDragController->moveDragCallback_ = callBack; moveDragController->ProcessSessionRectChange(reason); - ASSERT_EQ(iscallback, true); - moveDragController->moveDragCallback_ = preCallback; + EXPECT_TRUE(isCallbackCalled); } /** -- Gitee From 768ee27baa72f9f1ea1c67940319f57379fc840f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Thu, 4 Sep 2025 06:59:45 +0000 Subject: [PATCH 3/4] update window_scene/test/unittest/move_drag_controller_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- window_scene/test/unittest/move_drag_controller_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index 9d21ba52bd..118703320e 100644 --- a/window_scene/test/unittest/move_drag_controller_test.cpp +++ b/window_scene/test/unittest/move_drag_controller_test.cpp @@ -914,7 +914,6 @@ HWTEST_F(MoveDragControllerTest, ProcessWindowDragHotAreaFunc, TestSize.Level1) auto dragHotAreaFunc = [&isDragHotAreaFuncCalled](DisplayId displayId, int32_t type, SizeChangeReason reason) { isDragHotAreaFuncCalled = true; }; - auto preFunc = moveDragController->windowDragHotAreaFunc_; moveDragController->windowDragHotAreaFunc_ = dragHotAreaFunc; moveDragController->ProcessWindowDragHotAreaFunc(isSendHotAreaMessage, reason); EXPECT_TRUE(isDragHotAreaFuncCalled); -- Gitee From b9708dace5ba8f67843d60880048e745e3604d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Thu, 4 Sep 2025 07:13:01 +0000 Subject: [PATCH 4/4] update window_scene/test/unittest/move_drag_controller_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- window_scene/test/unittest/move_drag_controller_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index 118703320e..2b42064bf7 100644 --- a/window_scene/test/unittest/move_drag_controller_test.cpp +++ b/window_scene/test/unittest/move_drag_controller_test.cpp @@ -1409,7 +1409,6 @@ HWTEST_F(MoveDragControllerTest, HasPointDown, TestSize.Level1) HWTEST_F(MoveDragControllerTest, ProcessSessionRectChange, TestSize.Level1) { bool isCallbackCalled = false; - auto preCallback = moveDragController->moveDragCallback_; SizeChangeReason reason = SizeChangeReason::UNDEFINED; MoveDragCallback callBack = [&isCallbackCalled](SizeChangeReason reason) { isCallbackCalled = true; -- Gitee