From 9d2d37f7494bdd0cf267adba08dfc8406469e69b Mon Sep 17 00:00:00 2001 From: tanyuhang Date: Thu, 25 Jul 2024 15:02:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=93=9D=E9=BB=84?= =?UTF-8?q?=E5=B7=AE=E5=BC=82=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanyuhang --- test/systemtest/wms/window_drag_test.cpp | 3 +- test/systemtest/wms/window_layout_test.cpp | 28 +-- .../wms/window_mode_support_info_test.cpp | 2 +- test/systemtest/wms/window_split_test.cpp | 8 +- utils/test/unittest/window_property_test.cpp | 219 ------------------ .../unittest/intention_event_manager_test.cpp | 2 + .../scene_persistent_storage_test.cpp | 4 - .../unittest/scene_session_manager_test.cpp | 5 +- .../unittest/scene_session_manager_test2.cpp | 2 +- .../unittest/scene_session_manager_test3.cpp | 9 +- .../test/unittest/scene_session_test.cpp | 5 +- wm/test/unittest/window_impl_test.cpp | 1 + wm/test/unittest/window_test.cpp | 60 ++--- .../unittest/input_window_monitor_test.cpp | 17 ++ .../unittest/window_inner_manager_test.cpp | 14 +- 15 files changed, 79 insertions(+), 300 deletions(-) diff --git a/test/systemtest/wms/window_drag_test.cpp b/test/systemtest/wms/window_drag_test.cpp index 7d2f055941..7281aa1ffb 100644 --- a/test/systemtest/wms/window_drag_test.cpp +++ b/test/systemtest/wms/window_drag_test.cpp @@ -217,7 +217,8 @@ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) { dragWindow->MoveTo(600, 600); sleep(WAIT_CALLBACK_US); - + ASSERT_EQ(100, secondWindowDragListener_->point_.x); + ASSERT_EQ(100, secondWindowDragListener_->point_.y); ASSERT_EQ(DragEvent::DRAG_EVENT_IN, secondWindowDragListener_->event_); ASSERT_EQ(DragEvent::DRAG_EVENT_OUT, firstWindowDragListener_->event_); diff --git a/test/systemtest/wms/window_layout_test.cpp b/test/systemtest/wms/window_layout_test.cpp index fcca735f8f..9bbb6c16ca 100644 --- a/test/systemtest/wms/window_layout_test.cpp +++ b/test/systemtest/wms/window_layout_test.cpp @@ -149,7 +149,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) activeWindows_.push_back(window); Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); - Utils::RectEqualTo(window, Utils::GetFloatingLimitedRect(expect, virtualPixelRatio_)); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::GetFloatingLimitedRect(expect, virtualPixelRatio_))); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -181,7 +181,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3) if (window->IsDecorEnable()) { ASSERT_TRUE(Utils::RectEqualTo(window, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - Utils::RectEqualTo(window, res); + ASSERT_TRUE(Utils::RectEqualTo(window, res)); } ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -220,7 +220,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3) if (appWin->IsDecorEnable()) { ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - Utils::RectEqualTo(appWin, res); + ASSERT_TRUE(Utils::RectEqualTo(appWin, res)); } ASSERT_EQ(WMError::WM_OK, statBar->Show()); if (appWin->IsDecorEnable()) { @@ -372,7 +372,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, expect); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Hide()); usleep(WAIT_SYANC_US); } @@ -403,12 +403,12 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, expect); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Resize(2u, 2u)); // 2: custom min size Rect finalExcept = { expect.posX_, expect.posY_, 2u, 2u}; // 2: custom min size finalExcept = Utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_); - Utils::RectEqualTo(window, finalExcept); + ASSERT_TRUE(Utils::RectEqualTo(window, finalExcept)); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -437,13 +437,13 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, expect); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Maximize()); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, Utils::displayRect_); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, window->Recover()); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, expect); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Minimize()); usleep(WAIT_SYANC_US); ASSERT_EQ(WMError::WM_OK, window->Close()); @@ -478,7 +478,7 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) } usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, expect); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_)); @@ -542,7 +542,7 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) usleep(WAIT_SYANC_US); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, Utils::singleTileRect_); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_)); info.name = "test1"; const sptr& test1 = Utils::CreateTestWindow(info); @@ -598,7 +598,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3) Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, expect); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); } /** @@ -628,12 +628,12 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3) Rect expect = Utils::GetDefaultFloatingRect(window, true); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - Utils::RectEqualTo(window, expect); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); window->Resize(negativeW, negativeH); usleep(WAIT_SYANC_US); Rect expect2 = {expect.posX_, expect.posY_, negativeW, negativeH}; expect2 = Utils::CalcLimitedRect(expect2, virtualPixelRatio_); - Utils::RectEqualTo(window, expect2); + ASSERT_TRUE(Utils::RectEqualTo(window, expect2)); } } } // namespace Rosen diff --git a/test/systemtest/wms/window_mode_support_info_test.cpp b/test/systemtest/wms/window_mode_support_info_test.cpp index 9f9f807025..0d9b593b1c 100644 --- a/test/systemtest/wms/window_mode_support_info_test.cpp +++ b/test/systemtest/wms/window_mode_support_info_test.cpp @@ -190,7 +190,7 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe usleep(WAIT_SYANC_US); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window1->GetMode()); - window2->GetMode(); + ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window2->GetMode()); window1->Destroy(); window2->Destroy(); diff --git a/test/systemtest/wms/window_split_test.cpp b/test/systemtest/wms/window_split_test.cpp index 78aeac5461..00454dae57 100644 --- a/test/systemtest/wms/window_split_test.cpp +++ b/test/systemtest/wms/window_split_test.cpp @@ -188,8 +188,8 @@ HWTEST_F(WindowSplitTest, SplitScreen03, Function | MediumTest | Level3) Utils::UpdateSplitRects(fullWindow); - Utils::RectEqualTo(fullWindow, Utils::splitRects_.secondaryRect); - Utils::RectEqualTo(priWindow, Utils::splitRects_.primaryRect); + ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.secondaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(priWindow, Utils::splitRects_.primaryRect)); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); @@ -223,8 +223,8 @@ HWTEST_F(WindowSplitTest, SplitScreen04, Function | MediumTest | Level3) Utils::UpdateSplitRects(fullWindow); - Utils::RectEqualTo(fullWindow, Utils::splitRects_.primaryRect); - Utils::RectEqualTo(secWindow, Utils::splitRects_.secondaryRect); + ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.primaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(secWindow, Utils::splitRects_.secondaryRect)); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); diff --git a/utils/test/unittest/window_property_test.cpp b/utils/test/unittest/window_property_test.cpp index 82e1c2a7ca..f322667abf 100644 --- a/utils/test/unittest/window_property_test.cpp +++ b/utils/test/unittest/window_property_test.cpp @@ -195,225 +195,6 @@ HWTEST_F(WindowPropertyTest, ResumeLastWindowMode, Function | SmallTest | Level2 ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, winPropDst.mode_); } -/** - * @tc.name: HandleComputeTransform - * @tc.desc: HandleComputeTransform test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, HandleComputeTransform, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - int resultValue = 0; - std::function func = [&]() { - winPropSrc.HandleComputeTransform(Transform::Identity()); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: ComputeTransform - * @tc.desc: ComputeTransform test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, ComputeTransform, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - int resultValue = 0; - std::function func = [&]() { - winPropSrc.ComputeTransform(); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: SetZoomTransform - * @tc.desc: SetZoomTransform test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, SetZoomTransform, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - int resultValue = 0; - std::function func = [&]() { - winPropSrc.SetZoomTransform(Transform::Identity()); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: ClearTransformZAxisOffset - * @tc.desc: ClearTransformZAxisOffset test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, ClearTransformZAxisOffset, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - Transform trans; - int resultValue = 0; - std::function func = [&]() { - winPropSrc.ClearTransformZAxisOffset(trans); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: UpdatePointerEvent - * @tc.desc: UpdatePointerEvent test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, UpdatePointerEvent, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - std::shared_ptr pointerEvent; - int resultValue = 0; - std::function func = [&]() { - winPropSrc.UpdatePointerEvent(pointerEvent); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: isNeedComputerTransform - * @tc.desc: isNeedComputerTransform test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, isNeedComputerTransform, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - bool ret = winPropSrc.isNeedComputerTransform(); - ASSERT_EQ(false, ret); -} - -/** - * @tc.name: SetAnimateWindowFlag - * @tc.desc: SetAnimateWindowFlag test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, SetAnimateWindowFlag, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - bool isAnimateWindow = false; - int resultValue = 0; - std::function func = [&]() { - winPropSrc.SetAnimateWindowFlag(isAnimateWindow); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: IsDisplayZoomOn - * @tc.desc: IsDisplayZoomOn test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, IsDisplayZoomOn, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - bool ret = winPropSrc.IsDisplayZoomOn(); - ASSERT_EQ(false, ret); -} - -/** - * @tc.name: IsAnimateWindow - * @tc.desc: IsAnimateWindow test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, IsAnimateWindow, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - bool ret = winPropSrc.IsAnimateWindow(); - ASSERT_EQ(false, ret); -} - -/** - * @tc.name: SetSizeLimits - * @tc.desc: SetSizeLimits test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, SetSizeLimits, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - WindowLimits sizeLimits; - int resultValue = 0; - std::function func = [&]() { - winPropSrc.SetSizeLimits(sizeLimits); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: SetUpdatedSizeLimits - * @tc.desc: SetUpdatedSizeLimits test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, SetUpdatedSizeLimits, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - WindowLimits sizeLimits; - int resultValue = 0; - std::function func = [&]() { - winPropSrc.SetUpdatedSizeLimits(sizeLimits); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - -/** - * @tc.name: SetDecorEnable - * @tc.desc: SetDecorEnable test - * @tc.type: FUNC - */ -HWTEST_F(WindowPropertyTest, SetDecorEnable, Function | SmallTest | Level2) -{ - WindowProperty winPropSrc; - winPropSrc.SetPrivacyMode(true); - winPropSrc.SetTransparent(true); - bool decorEnable = false; - int resultValue = 0; - std::function func = [&]() { - winPropSrc.SetDecorEnable(decorEnable); - resultValue = 1; - }; - func(); - ASSERT_EQ(resultValue, 1); -} - /** * @tc.name: AddWindowFlag001 * @tc.desc: AddWindowFlag test diff --git a/window_scene/test/unittest/intention_event_manager_test.cpp b/window_scene/test/unittest/intention_event_manager_test.cpp index 688287037f..a416039ec2 100644 --- a/window_scene/test/unittest/intention_event_manager_test.cpp +++ b/window_scene/test/unittest/intention_event_manager_test.cpp @@ -391,6 +391,7 @@ HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync1, Function | Med EXPECT_NE(nullptr, callback); sptr sceneSession = new SceneSession(info, callback); EXPECT_NE(nullptr, sceneSession); + EXPECT_EQ(-1, sceneSession->GetPersistenId()); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW); sceneSession->TransferPointerEvent(pointerEvent, true); @@ -400,6 +401,7 @@ HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync1, Function | Med SceneSession::ClearEnterWindow(); info.persistentId_ = 2024; sceneSession = new SceneSession(info, callback); + EXPECT_EQ(2024, sceneSession->GetPersistenId()); sceneSession->TransferPointerEvent(pointerEvent, true); inputEventListener_->ProcessEnterLeaveEventAsync(); std::shared_ptr inputEventListener2 = diff --git a/window_scene/test/unittest/scene_persistent_storage_test.cpp b/window_scene/test/unittest/scene_persistent_storage_test.cpp index 448c828bae..45c72e821a 100644 --- a/window_scene/test/unittest/scene_persistent_storage_test.cpp +++ b/window_scene/test/unittest/scene_persistent_storage_test.cpp @@ -29,10 +29,6 @@ public: void TearDown() override; }; -std::map ScenePersistentStorage::storagePath_ = { - {ScenePersistentStorageType::ASPECT_RATIO, "aspect_ratio"}, - {ScenePersistentStorageType::MAXIMIZE_STATE, "maximize_state"}}; - void ScenePersistentStorageTest::SetUpTestCase() { } diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 2c11cebd3a..8a3d29fb0f 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -52,6 +52,8 @@ public: static void SetVisibleForAccessibility(sptr& sceneSession); int32_t GetTaskCount(sptr& session); static sptr ssm_; +private: + static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; sptr SceneSessionManagerTest::ssm_ = nullptr; @@ -85,6 +87,7 @@ void SceneSessionManagerTest::SetUp() void SceneSessionManagerTest::TearDown() { + usleep(WAIT_SYNC_IN_NS); ssm_->sceneSessionMap_.clear(); } @@ -819,7 +822,7 @@ HWTEST_F(SceneSessionManagerTest, RecoverSessionInfo, Function | SmallTest | Lev SessionInfo info = ssm_->RecoverSessionInfo(nullptr); sptr property = new WindowSessionProperty(); - EXPECT_FALSE(ssm_->alivePersistentIds_.empty()); + ASSERT_NE(nullptr, property); info = ssm_->RecoverSessionInfo(property); } diff --git a/window_scene/test/unittest/scene_session_manager_test2.cpp b/window_scene/test/unittest/scene_session_manager_test2.cpp index c7ff68d094..64c3b811fd 100644 --- a/window_scene/test/unittest/scene_session_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_test2.cpp @@ -2221,7 +2221,7 @@ HWTEST_F(SceneSessionManagerTest2, NotifyCreateToastSession, Function | SmallTes int32_t persistentId = Info.persistentId_; Info.abilityName_ = "testInfo1a"; Info.bundleName_ = "testInfo1b"; - sptr session = new(std::nothrow) SceneSession(Info, nullptr); + sptr session = new (std::nothrow) SceneSession(Info, nullptr); ssm_->NotifyCreateToastSession(persistentId, session); } } diff --git a/window_scene/test/unittest/scene_session_manager_test3.cpp b/window_scene/test/unittest/scene_session_manager_test3.cpp index 97f913ac96..6b426c35ee 100644 --- a/window_scene/test/unittest/scene_session_manager_test3.cpp +++ b/window_scene/test/unittest/scene_session_manager_test3.cpp @@ -69,6 +69,8 @@ public: static bool gestureNavigationEnabled_; static ProcessGestureNavigationEnabledChangeFunc callbackFunc_; static sptr ssm_; +private: + static constexpr uint32_t WAIT_SYNC_IN_NS = 50000; }; sptr SceneSessionManagerTest3::ssm_ = nullptr; @@ -98,6 +100,7 @@ void SceneSessionManagerTest3::SetUpTestCase() void SceneSessionManagerTest3::TearDownTestCase() { ssm_ = nullptr; + usleep(WAIT_SYNC_IN_NS); } void SceneSessionManagerTest3::SetUp() @@ -1461,19 +1464,17 @@ HWTEST_F(SceneSessionManagerTest3, SetFocusedSessionId, Function | SmallTest | L */ HWTEST_F(SceneSessionManagerTest3, RequestFocusStatus, Function | SmallTest | Level3) { - FocusChangeReason reasonInput = FocusChangeReason::DEFAULT; - FocusChangeReason reasonResult = FocusChangeReason::DEFAULT; int32_t focusedSession = ssm_->GetFocusedSessionId(); EXPECT_EQ(focusedSession, 10086); int32_t persistentId = INVALID_SESSION_ID; WMError result01 = ssm_->RequestFocusStatus(persistentId, true); EXPECT_EQ(result01, WMError::WM_ERROR_NULLPTR); - reasonResult = ssm_->GetFocusChangeReason(); + FocusChangeReason reasonResult = ssm_->GetFocusChangeReason(); EXPECT_EQ(reasonResult, FocusChangeReason::DEFAULT); persistentId = 10000; - reasonInput = FocusChangeReason::SCB_SESSION_REQUEST; + FocusChangeReason reasonInput = FocusChangeReason::SCB_SESSION_REQUEST; WMError result02 = ssm_->RequestFocusStatus(persistentId, true, true, reasonInput); EXPECT_EQ(result02, WMError::WM_ERROR_NULLPTR); reasonResult = ssm_->GetFocusChangeReason(); diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 11089dd17b..8e4e31f342 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -17,6 +17,7 @@ #include "pointer_event.h" #include +#include "key_event.h" #include "session/host/include/scene_session.h" #include "session/host/include/sub_session.h" #include "session/host/include/system_session.h" @@ -77,6 +78,7 @@ HWTEST_F(SceneSessionTest, Foreground01, Function | SmallTest | Level2) scensession->isActive_ = true; sptr property = new(std::nothrow) WindowSessionProperty(); ASSERT_NE(nullptr, property); + auto result = scensession->Foreground(property); ASSERT_EQ(result, WSError::WS_OK); specificCallback_->onCreate_ = [&resultValue, specificCallback_](const SessionInfo &info, @@ -148,7 +150,6 @@ HWTEST_F(SceneSessionTest, BackgroundTask01, Function | SmallTest | Level2) EXPECT_NE(specificCallback, nullptr); int resultValue = 0; sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->isActive_ = true; @@ -1696,7 +1697,7 @@ HWTEST_F(SceneSessionTest, SetAspectRatio7, Function | SmallTest | Level2) property->SetWindowLimits(limits); scensession->SetSessionProperty(property); auto result = scensession->SetAspectRatio(ratio); - ASSERT_EQ(result, WSError::WS_OK); + ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM); } /** diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index 6b5c0549b5..43bb6d58fc 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -130,6 +130,7 @@ HWTEST_F(WindowImplTest, CreateWindow03, Function | SmallTest | Level2) option->SetWindowName("CreateWindow03"); sptr window = new WindowImpl(option); ASSERT_EQ(WMError::WM_ERROR_INVALID_PARENT, window->Create(1234)); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); } /** diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 8480c7a2a4..8839e518de 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -251,7 +251,7 @@ HWTEST_F(WindowTest, GetMode, Function | SmallTest | Level2) ASSERT_NE(nullptr, window); ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, window->GetMode()); ASSERT_EQ(WMError::WM_OK, window->Destroy()); - + auto window_ = new (std::nothrow)Window(); ASSERT_NE(nullptr, window_); ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, window_->GetMode()); @@ -1653,7 +1653,7 @@ HWTEST_F(WindowTest, Recover, Function | SmallTest | Level2) sptr window = new Window(); ASSERT_NE(nullptr, window); auto ret = window->Recover(); - + if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, ret); } else { @@ -2289,19 +2289,6 @@ HWTEST_F(WindowTest, TransferAccessibilityEvent, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->TransferAccessibilityEvent(info, uiExtensionIdLevel)); } -/** - * @tc.name: SetSingleFrameComposerEnabled - * @tc.desc: set single frame composer enable flag - * @tc.type: FUNC - */ -HWTEST_F(WindowTest, SetSingleFrameComposerEnabled, Function | SmallTest | Level2) -{ - sptr window = new Window(); - ASSERT_NE(nullptr, window); - ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetSingleFrameComposerEnabled(false)); - ASSERT_EQ(WMError::WM_OK, window->Destroy()); -} - /** * @tc.name: FlushFrameRate * @tc.desc: FlushFrameRate Test @@ -2318,6 +2305,19 @@ HWTEST_F(WindowTest, FlushFrameRate, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } +/** + * @tc.name: SetSingleFrameComposerEnabled + * @tc.desc: set single frame composer enable flag + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, SetSingleFrameComposerEnabled, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetSingleFrameComposerEnabled(false)); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); +} + /** * @tc.name: Maximize01 * @tc.desc: maximize interface Test @@ -2430,8 +2430,7 @@ HWTEST_F(WindowTest, Create05, Function | SmallTest | Level2) sptr option = nullptr; auto window = Window::Create("WindowTest02", option); uint32_t version = 0; - if (version < 10) - { + if (version < 10) { ASSERT_NE(10, version); } WindowOption windowoption; @@ -2620,18 +2619,10 @@ HWTEST_F(WindowTest, Test03, Function | SmallTest | Level2) */ HWTEST_F(WindowTest, Test04, Function | SmallTest | Level2) { - ExtensionWindowFlags flags; - ASSERT_EQ(flags.bitData, 0); - ExtensionWindowFlags flags1(7); - ASSERT_EQ(flags1.bitData, 7); sptr window = new Window(); ASSERT_NE(nullptr, window); ASSERT_EQ(nullptr, window->GetUIContentWithId(0)); - sptr listener = new IKeyboardPanelInfoChangeListener(); - KeyboardPanelInfo keyboardPanelInfo; - listener->OnKeyboardPanelInfoChanged(keyboardPanelInfo); window->TriggerBindModalUIExtension(); - ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWaterMarkFlag(true)); ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetGrayScale(0)); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } @@ -2651,25 +2642,6 @@ HWTEST_F(WindowTest, Test05, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } -/** - * @tc.name: Test06 - * @tc.desc: Test06 - * @tc.type: FUNC - */ -HWTEST_F(WindowTest, Test06, Function | SmallTest | Level2) -{ - KeyboardLayoutParams param; - KeyboardLayoutParams param1; - ASSERT_EQ(true, (param == param1)); - ASSERT_EQ(false, (param != param1)); - ASSERT_EQ(true, param.isEmpty()); - Parcel parcel; - Rect rect = {0, 0, 0, 0}; - ASSERT_EQ(false, KeyboardLayoutParams::ReadParcel(parcel, rect)); - parcel.WriteUint32(0); - ASSERT_EQ(nullptr, KeyboardLayoutParams::Unmarshalling(parcel)); -} - /** * @tc.name: SetTitleButtonVisible * @tc.desc: SetTitleButtonVisible diff --git a/wmserver/test/unittest/input_window_monitor_test.cpp b/wmserver/test/unittest/input_window_monitor_test.cpp index 71da88b29f..4483469d1a 100644 --- a/wmserver/test/unittest/input_window_monitor_test.cpp +++ b/wmserver/test/unittest/input_window_monitor_test.cpp @@ -114,6 +114,23 @@ HWTEST_F(InputWindowMonitorTest, UpdateDisplayInfo02, Function | SmallTest | Lev ASSERT_NE(0, displayInfoVector.size()); } +/** + * @tc.name: TransformWindowRects + * @tc.desc: TransformWindowRects + * @tc.type: FUNC + */ +HWTEST_F(InputWindowMonitorTest, TransformWindowRects, Function | SmallTest | Level2) +{ + sptr windowNode = new WindowNode(); + Rect areaRect; + std::vector touchHotAreas; + std::vector pointerHotAreas; + input_monitor_->TransformWindowRects(windowNode, areaRect, touchHotAreas, pointerHotAreas); + WindowProperty windowProperty; + auto result = windowProperty.isNeedComputerTransform(); + ASSERT_EQ(result, false); +} + /** * @tc.name: GetDisplayDirectionForMmi02 * @tc.desc: get display direction diff --git a/wmserver/test/unittest/window_inner_manager_test.cpp b/wmserver/test/unittest/window_inner_manager_test.cpp index b1163b25e3..5b10642796 100644 --- a/wmserver/test/unittest/window_inner_manager_test.cpp +++ b/wmserver/test/unittest/window_inner_manager_test.cpp @@ -268,7 +268,8 @@ HWTEST_F(WindowInnerManagerTest, UpdateInnerWindow, Function | SmallTest | Level HWTEST_F(WindowInnerManagerTest, TerminateAbility, Function | SmallTest | Level2) { wim_->isRecentHolderEnable_ = true; - wptr node1 = nullptr; + sptr node = new WindowNode(); + wptr node1 = node; wim_->TerminateAbility(node1); ASSERT_EQ(wim_->isRecentHolderEnable_, true); } @@ -281,7 +282,8 @@ HWTEST_F(WindowInnerManagerTest, TerminateAbility, Function | SmallTest | Level2 HWTEST_F(WindowInnerManagerTest, CloseAbility, Function | SmallTest | Level2) { wim_->isRecentHolderEnable_ = true; - wptr node1 = nullptr; + sptr node = new WindowNode(); + wptr node1 = node; wim_->CloseAbility(node1); ASSERT_EQ(wim_->isRecentHolderEnable_, true); } @@ -294,7 +296,8 @@ HWTEST_F(WindowInnerManagerTest, CloseAbility, Function | SmallTest | Level2) HWTEST_F(WindowInnerManagerTest, CompleteFirstFrameDrawing, Function | SmallTest | Level2) { wim_->isRecentHolderEnable_ = true; - wptr node1 = nullptr; + sptr node = new WindowNode(); + wptr node1 = node; wim_->CompleteFirstFrameDrawing(node1); ASSERT_EQ(wim_->isRecentHolderEnable_, true); } @@ -307,8 +310,9 @@ HWTEST_F(WindowInnerManagerTest, CompleteFirstFrameDrawing, Function | SmallTest HWTEST_F(WindowInnerManagerTest, UpdateMissionSnapShot, Function | SmallTest | Level2) { wim_->isRecentHolderEnable_ = true; - wptr node1 = nullptr; - std::shared_ptr pixelMap = nullptr; + sptr node = new WindowNode(); + wptr node1 = node; + std::shared_ptr pixelMap = std::make_shared(); wim_->UpdateMissionSnapShot(node1, pixelMap); ASSERT_EQ(wim_->isRecentHolderEnable_, true); } From f6a6f2bfa453a08d37a7a4f2b2b26701fb5322b3 Mon Sep 17 00:00:00 2001 From: tanyuhang Date: Thu, 25 Jul 2024 08:21:37 +0000 Subject: [PATCH 2/2] update window_scene/test/unittest/intention_event_manager_test.cpp. Signed-off-by: tanyuhang --- window_scene/test/unittest/intention_event_manager_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/intention_event_manager_test.cpp b/window_scene/test/unittest/intention_event_manager_test.cpp index a416039ec2..e61cd84c59 100644 --- a/window_scene/test/unittest/intention_event_manager_test.cpp +++ b/window_scene/test/unittest/intention_event_manager_test.cpp @@ -391,7 +391,7 @@ HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync1, Function | Med EXPECT_NE(nullptr, callback); sptr sceneSession = new SceneSession(info, callback); EXPECT_NE(nullptr, sceneSession); - EXPECT_EQ(-1, sceneSession->GetPersistenId()); + EXPECT_EQ(-1, sceneSession->GetPersistentId()); pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_ENTER_WINDOW); sceneSession->TransferPointerEvent(pointerEvent, true); @@ -401,7 +401,7 @@ HWTEST_F(IntentionEventManagerTest, ProcessEnterLeaveEventAsync1, Function | Med SceneSession::ClearEnterWindow(); info.persistentId_ = 2024; sceneSession = new SceneSession(info, callback); - EXPECT_EQ(2024, sceneSession->GetPersistenId()); + EXPECT_EQ(2024, sceneSession->GetPersistentId()); sceneSession->TransferPointerEvent(pointerEvent, true); inputEventListener_->ProcessEnterLeaveEventAsync(); std::shared_ptr inputEventListener2 =