From e2a99be5b1ab5ed0e9a6dc1fbaff39bf878683ac Mon Sep 17 00:00:00 2001 From: xu Date: Tue, 13 Aug 2024 17:02:11 +0800 Subject: [PATCH] add TDD ut case Signed-off-by: xu Change-Id: I60ba84fa195ae4b56b2b5a2ed1644d4b411afe89 --- .../unittest/scene_session_manager_test5.cpp | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 9a64b244c5..c652fedfb2 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1212,6 +1212,72 @@ HWTEST_F(SceneSessionManagerTest5, FindMainWindowWithToken02, Function | SmallTe sptr scensession = sptr::MakeSptr(info, nullptr); ssm_->FindMainWindowWithToken(targetToken); } + +/** + * @tc.name: RequestSceneSessionBackground + * @tc.desc: RequestSceneSessionBackground + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest5, RequestSceneSessionBackground03, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "test1"; + info.bundleName_ = "test2"; + info.persistentId_ = 0; + sptr property = new (std::nothrow) WindowSessionProperty(); + ASSERT_NE(property, nullptr); + property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + sptr session = new (std::nothrow) Session(info); + ASSERT_NE(session, nullptr); + std::shared_ptr> promise = std::make_shared>(); + sptr sceneSession = sptr::MakeSptr(info, nullptr); + session->SetSessionInfoPersistentId(0); + ssm_->RequestSceneSessionBackground(sceneSession, false, false, true); +} + +/** + * @tc.name: DestroyToastSession + * @tc.desc: DestroyToastSession + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest5, DestroyToastSession02, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "test1"; + info.bundleName_ = "test2"; + info.screenId_ = SCREEN_ID_INVALID; + sptr property = new (std::nothrow) WindowSessionProperty(); + ASSERT_NE(property, nullptr); + property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); + sptr sceneSession = nullptr; + ssm_->DestroyToastSession(sceneSession); + sceneSession = sptr::MakeSptr(info, nullptr); + sceneSession->state_ = SessionState::STATE_FOREGROUND; + ssm_->DestroyToastSession(sceneSession); +} + +/** + * @tc.name: CheckModalSubWindowPermission + * @tc.desc: CheckModalSubWindowPermission + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest5, CheckModalSubWindowPermission02, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "test1"; + info.bundleName_ = "test2"; + sptr property = new (std::nothrow) WindowSessionProperty(); + ASSERT_NE(property, nullptr); + property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + property->SetWindowFlags(123); + property->SetTopmost(true); + ssm_->CheckModalSubWindowPermission(property); + property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); + ssm_->CheckModalSubWindowPermission(property); +} } } // namespace Rosen } // namespace OHOS