From 6f8db7655a4bb8ec5125c50771b74f677b19df17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Sat, 30 Aug 2025 16:21:57 +0800 Subject: [PATCH 1/4] fix TDD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 Change-Id: I8a8e413d3960ab733322c3bf548450c90c1a2e6b --- .../unittest/move_drag_controller_test.cpp | 40 ++++++++----------- .../unittest/window_layout_policy_test.cpp | 6 +-- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index c0018cc2f1..7eb2236501 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 @@ -330,13 +318,11 @@ 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 }; - moveDragController->CalcMoveTargetRect(pointerEvent, originalRect); - ASSERT_EQ(0, res); + EXPECT_FALSE(moveDragController->CalcMoveTargetRect(pointerEvent, originalRect)); pointerEvent = MMI::PointerEvent::Create(); int32_t pointerId = pointerEvent->GetPointerId(); @@ -348,7 +334,7 @@ HWTEST_F(MoveDragControllerTest, CalcMoveTargetRect, TestSize.Level1) 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..36d025ddd5 100644 --- a/wmserver/test/unittest/window_layout_policy_test.cpp +++ b/wmserver/test/unittest/window_layout_policy_test.cpp @@ -203,7 +203,7 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow01, 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(newWinRect, expRect); } /** @@ -220,7 +220,7 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow02, 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(newWinRect, expRect); } /** @@ -237,7 +237,7 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow03, 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(newWinRect, expRect); } /** -- Gitee From f9ab1251680d8ebc930cb75145f7a5220589840b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Wed, 3 Sep 2025 06:15:53 +0000 Subject: [PATCH 2/4] update wmserver/test/unittest/window_layout_policy_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- wmserver/test/unittest/window_layout_policy_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wmserver/test/unittest/window_layout_policy_test.cpp b/wmserver/test/unittest/window_layout_policy_test.cpp index 36d025ddd5..337dc25dd1 100644 --- a/wmserver/test/unittest/window_layout_policy_test.cpp +++ b/wmserver/test/unittest/window_layout_policy_test.cpp @@ -200,6 +200,7 @@ 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 @@ -217,6 +218,7 @@ 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 @@ -234,6 +236,7 @@ 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 -- Gitee From 2df2ef07eb5e87acabdd43c2550b345ab6d5cce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Wed, 3 Sep 2025 10:55:32 +0000 Subject: [PATCH 3/4] update wmserver/test/unittest/window_layout_policy_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- wmserver/test/unittest/window_layout_policy_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wmserver/test/unittest/window_layout_policy_test.cpp b/wmserver/test/unittest/window_layout_policy_test.cpp index 337dc25dd1..e935ccc4e0 100644 --- a/wmserver/test/unittest/window_layout_policy_test.cpp +++ b/wmserver/test/unittest/window_layout_policy_test.cpp @@ -204,7 +204,7 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow01, 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(newWinRect, expRect); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_OR_RIGHT); } /** @@ -222,7 +222,7 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow02, 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(newWinRect, expRect); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_TOP_CORNER); } /** @@ -240,7 +240,7 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow03, 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(newWinRect, expRect); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_BOTTOM_OR_TOP); } /** -- Gitee From 4e84d764b5c1cfc304f76a508deb594abb135cdc 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 01:51:19 +0000 Subject: [PATCH 4/4] update wmserver/test/unittest/window_layout_policy_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- wmserver/test/unittest/window_layout_policy_test.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/wmserver/test/unittest/window_layout_policy_test.cpp b/wmserver/test/unittest/window_layout_policy_test.cpp index e935ccc4e0..10f3e6ae67 100644 --- a/wmserver/test/unittest/window_layout_policy_test.cpp +++ b/wmserver/test/unittest/window_layout_policy_test.cpp @@ -203,7 +203,6 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow01, 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(node->GetDragType(), DragType::DRAG_LEFT_OR_RIGHT); } @@ -221,7 +220,6 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow02, 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(node->GetDragType(), DragType::DRAG_LEFT_TOP_CORNER); } @@ -239,7 +237,6 @@ HWTEST_F(WindowLayoutPolicyTest, UpdateFloatingWindowSizeForStretchableWindow03, 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(node->GetDragType(), DragType::DRAG_BOTTOM_OR_TOP); } -- Gitee