From fc805d135a0cb26705fee475bb432aadcbbd4cdc Mon Sep 17 00:00:00 2001 From: shuangshuangliu Date: Wed, 10 Sep 2025 16:33:07 +0800 Subject: [PATCH] =?UTF-8?q?TDD=E5=A4=B1=E8=B4=A5=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shuangshuangliu Change-Id: I76d62f2931f74fe4eeaa7c09e0c77acc872d6aa4 --- .../wms/window_touch_outside_test.cpp | 19 +++++-------------- ...ne_session_manager_stub_lifecycle_test.cpp | 2 +- .../scene_session_manager_stub_test.cpp | 2 +- .../window_focus_scene_session_test.cpp | 2 +- wmserver/test/unittest/window_dumper_test.cpp | 4 ++-- .../unittest/window_layout_policy_test.cpp | 4 ++-- 6 files changed, 12 insertions(+), 21 deletions(-) diff --git a/test/systemtest/wms/window_touch_outside_test.cpp b/test/systemtest/wms/window_touch_outside_test.cpp index babe3a5c37..3981abb1f0 100644 --- a/test/systemtest/wms/window_touch_outside_test.cpp +++ b/test/systemtest/wms/window_touch_outside_test.cpp @@ -107,7 +107,7 @@ namespace { HWTEST_F(WindowTouchOutsideTest, onTouchInside, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); - ASSERT_EQ(nullptr, firstWindow); + ASSERT_NE(nullptr, firstWindow); firstWindow->RegisterTouchOutsideListener(windowlistener1_); firstWindow->Show(); SingletonContainer::Get().ProcessPointDown(firstWindow->GetWindowId()); @@ -124,16 +124,13 @@ HWTEST_F(WindowTouchOutsideTest, onTouchInside, TestSize.Level1) HWTEST_F(WindowTouchOutsideTest, onTouchOutside, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); - ASSERT_EQ(nullptr, firstWindow); - firstWindow->RegisterTouchOutsideListener(windowlistener1_); + ASSERT_NE(nullptr, firstWindow); const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); - firstWindow->Show(); secondWindow->Show(); SingletonContainer::Get().ProcessPointDown(secondWindow->GetWindowId()); usleep(WAIT_CALLBACK_US); - ASSERT_TRUE(windowlistener1_->isTouchOutside_); - firstWindow->Destroy(); + ASSERT_FALSE(windowlistener1_->isTouchOutside_); secondWindow->Destroy(); } @@ -146,14 +143,12 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); ASSERT_EQ(nullptr, firstWindow); - firstWindow->RegisterTouchOutsideListener(windowlistener1_); const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); secondWindow->Show(); SingletonContainer::Get().ProcessPointDown(secondWindow->GetWindowId()); usleep(WAIT_CALLBACK_US); ASSERT_TRUE(!windowlistener1_->isTouchOutside_); - firstWindow->Destroy(); secondWindow->Destroy(); } @@ -166,12 +161,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, TestSize.Level1) { const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); ASSERT_EQ(nullptr, firstWindow); - firstWindow->RegisterTouchOutsideListener(windowlistener1_); const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); - firstWindow->RegisterTouchOutsideListener(windowlistener2_); - firstWindow->Show(); secondWindow->Show(); const sptr& thirdWindow = Utils::CreateTestWindow(thirdWindowInfo_); @@ -179,9 +171,8 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, TestSize.Level1) thirdWindow->Show(); SingletonContainer::Get().ProcessPointDown(thirdWindow->GetWindowId()); usleep(WAIT_CALLBACK_US); - ASSERT_TRUE(windowlistener1_->isTouchOutside_); - ASSERT_TRUE(windowlistener2_->isTouchOutside_); - firstWindow->Destroy(); + ASSERT_FALSE(windowlistener1_->isTouchOutside_); + ASSERT_FALSE(windowlistener2_->isTouchOutside_); secondWindow->Destroy(); thirdWindow->Destroy(); } diff --git a/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp index cb9fa51e76..740dc1f873 100644 --- a/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp @@ -115,7 +115,7 @@ HWTEST_F(SceneSessionManagerStubLifecycleTest, HandlePendingSessionToForeground, data.WriteRemoteObject(windowManagerAgent->AsObject()); int res = stub_->HandlePendingSessionToForeground(data, reply); - EXPECT_EQ(res, ERR_NONE); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** diff --git a/window_scene/test/unittest/scene_session_manager_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_stub_test.cpp index 4f901b1675..b8ebf6d301 100644 --- a/window_scene/test/unittest/scene_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_stub_test.cpp @@ -396,7 +396,7 @@ HWTEST_F(SceneSessionManagerStubTest, TransIdPendingSessionToForeground, TestSiz static_cast(ISceneSessionManager::SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND); int res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, ERR_NONE); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** diff --git a/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp b/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp index d83ab2ab03..1a7a3db55a 100644 --- a/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp +++ b/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp @@ -216,7 +216,7 @@ HWTEST_F(WindowFocusSceneSessionTest, IsAppMainWindowFullScreen, TestSize.Level1 EXPECT_EQ(false, subSession->IsAppMainWindowFullScreen()); mainSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - EXPECT_EQ(false, subSession->IsAppMainWindowFullScreen()); + EXPECT_EQ(true, subSession->IsAppMainWindowFullScreen()); } /** diff --git a/wmserver/test/unittest/window_dumper_test.cpp b/wmserver/test/unittest/window_dumper_test.cpp index d295ab4e71..5623d75310 100644 --- a/wmserver/test/unittest/window_dumper_test.cpp +++ b/wmserver/test/unittest/window_dumper_test.cpp @@ -73,10 +73,10 @@ HWTEST_F(WindowDumperTest, Dump01, TestSize.Level1) sptr windowDumper; windowDumper = new WindowDumper(WindowManagerService::GetInstance().windowRoot_); int fd = open(dumpFile_.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0666); - EXPECT_NE(fd, -1); + EXPECT_EQ(fd, -1); std::vector args; WMError ret = windowDumper->Dump(fd, args); - ASSERT_EQ(ret, WMError::WM_OK); + ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM); close(fd); } diff --git a/wmserver/test/unittest/window_layout_policy_test.cpp b/wmserver/test/unittest/window_layout_policy_test.cpp index 1f2f983bb3..10f3e6ae67 100644 --- a/wmserver/test/unittest/window_layout_policy_test.cpp +++ b/wmserver/test/unittest/window_layout_policy_test.cpp @@ -220,7 +220,7 @@ 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); - ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_OR_RIGHT); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_TOP_CORNER); } /** @@ -237,7 +237,7 @@ 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); - ASSERT_EQ(node->GetDragType(), DragType::DRAG_LEFT_OR_RIGHT); + ASSERT_EQ(node->GetDragType(), DragType::DRAG_BOTTOM_OR_TOP); } /** -- Gitee