From 96c0ccc75e19c19c48d47a370c8a574be470c922 Mon Sep 17 00:00:00 2001 From: hubijie Date: Thu, 8 Aug 2024 10:53:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9FUT?= =?UTF-8?q?=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87=E8=A1=A5=E5=85=85?= =?UTF-8?q?=20=20Signed-off-by:=20hubijie=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/unittest/scene_session_test.cpp | 42 ++++++++++- .../test/unittest/scene_session_test2.cpp | 72 +++++++++++++++++++ .../test/unittest/scene_session_test3.cpp | 9 +++ .../test/unittest/scene_session_test5.cpp | 11 +++ 4 files changed, 133 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index e6fc0486be..7686f4f9a6 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -776,6 +776,10 @@ HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, Function | SmallTest | Level2) int ret = 1; scensession->GetKeyboardAvoidArea(overlapRect, avoidArea); ASSERT_EQ(ret, 1); + + scensession->SetSessionProperty(nullptr); + scensession->GetKeyboardAvoidArea(overlapRect, avoidArea); + ASSERT_EQ(nullptr, scensession->GetSessionProperty()); } /** @@ -833,6 +837,14 @@ HWTEST_F(SceneSessionTest, SetSystemBarProperty, Function | SmallTest | Level2) scensession->property_ = property; ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), WSError::WS_OK); + + NotifySystemBarPropertyChangeFunc fun = + scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + EXPECT_NE(nullptr, scensession->sessionChangeCallback_); + scensession->sessionChangeCallback_->OnSystemBarPropertyChange_ = []( + const std::unordered_map& propertyMap){}; + ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), + WSError::WS_OK); } /** @@ -856,6 +868,11 @@ HWTEST_F(SceneSessionTest, OnShowWhenLocked, Function | SmallTest | Level2) int ret = 0; scensession->OnShowWhenLocked(false); ASSERT_EQ(ret, 0); + + scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + EXPECT_NE(scensession->sessionChangeCallback_, nullptr); + scensession->sessionChangeCallback_->OnShowWhenLocked = [](bool showWhenLocked){}; + ASSERT_EQ(scensession->OnShowWhenLocked(false), WSError::WS_OK); } /** @@ -931,6 +948,14 @@ HWTEST_F(SceneSessionTest, GetAvoidAreaByType, Function | SmallTest | Level2) scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD); scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE); EXPECT_NE(scensession, nullptr); + + property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + scensession->property_ = property; + scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT); + scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM); + scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD); + scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE); + EXPECT_NE(scensession, nullptr); } /** @@ -1040,6 +1065,11 @@ HWTEST_F(SceneSessionTest, OnNeedAvoid, Function | SmallTest | Level2) scensession = new (std::nothrow) SceneSession(info, specificCallback_); EXPECT_NE(scensession, nullptr); ASSERT_EQ(scensession->OnNeedAvoid(false), WSError::WS_OK); + + scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + EXPECT_NE(scensession->sessionChangeCallback_, nullptr); + scensession->sessionChangeCallback_->OnNeedAvoid_ = [](bool state){}; + ASSERT_EQ(scensession->OnNeedAvoid(false), WSError::WS_OK); } /** @@ -1181,6 +1211,10 @@ HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, Function | SmallTest | Lev scensession->property_ = property; scensession->NotifyPropertyWhenConnect(); ASSERT_EQ(ret, 1); + + scensession->SetSessionProperty(nullptr); + scensession->NotifyPropertyWhenConnect(); + ASSERT_EQ(scensession->GetSessionProperty(), nullptr); } /** @@ -1483,7 +1517,13 @@ HWTEST_F(SceneSessionTest, UpdateInputMethodSessionRect, Function | SmallTest | EXPECT_NE(sceneSession, nullptr); sceneSession->SetSessionProperty(nullptr); - sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect); + auto res = sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect); + ASSERT_EQ(res, false); + + property->SetKeyboardSessionGravity(SessionGravity::SESSION_GRAVITY_FLOAT, p); + sceneSession->SetSessionProperty(property); + res = sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect); + ASSERT_EQ(res, false); } /** diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 30bfd152ee..04b39585a7 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -1095,6 +1095,16 @@ HWTEST_F(SceneSessionTest2, SetPiPControlEvent, Function | SmallTest | Level2) sceneSession->SetSessionProperty(property); res = sceneSession->SetPiPControlEvent(controlType, status); ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR); + + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + sceneSession->property_ = property; + ASSERT_EQ(sceneSession->SetPiPControlEvent(controlType, status), WSError::WS_ERROR_INVALID_TYPE); + + sceneSession->sessionStage_ = sptr::MakeSptr(); + property->SetWindowType(WindowType::WINDOW_TYPE_PIP); + property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); + sceneSession->property_ = property; + ASSERT_EQ(sceneSession->SetPiPControlEvent(controlType, status), WSError::WS_OK); } /** @@ -1349,6 +1359,9 @@ HWTEST_F(SceneSessionTest2, OnSessionEvent01, Function | SmallTest | Level2) EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr); auto result = sceneSession->OnSessionEvent(event); ASSERT_EQ(result, WSError::WS_OK); + + event = SessionEvent::EVENT_END_MOVE; + ASSERT_EQ(sceneSession->OnSessionEvent(event), WSError::WS_OK); } /** @@ -1416,6 +1429,9 @@ HWTEST_F(SceneSessionTest2, RaiseAppMainWindowToTop, Function | SmallTest | Leve bool showWhenLocked = true; sceneSession->OnShowWhenLocked(showWhenLocked); sceneSession->NotifyPropertyWhenConnect(); + + sceneSession->focusedOnShow_ = false; + sceneSession->RaiseAppMainWindowToTop(); } /** @@ -1478,6 +1494,27 @@ HWTEST_F(SceneSessionTest2, GetAINavigationBarArea, Function | SmallTest | Level WSRect rect; AvoidArea avoidArea; sceneSession->GetAINavigationBarArea(rect, avoidArea); + + sceneSession->SetIsDisplayStatusBarTemporarily(true); + sceneSession->GetAINavigationBarArea(rect, avoidArea); + ASSERT_EQ(sceneSession->GetIsDisplayStatusBarTemporarily(), true); + + auto property = sptr::MakeSptr(); + EXPECT_NE(property, nullptr); + property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); + sceneSession->property_ = property; + sceneSession->GetAINavigationBarArea(rect, avoidArea); + + sceneSession->SetSessionProperty(nullptr); + sceneSession->GetAINavigationBarArea(rect, avoidArea); + + property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + sceneSession->SetSessionProperty(property); + sceneSession->specificCallback_->onGetAINavigationBarArea_ = [](uint64_t displayId) { + WSRect rect = {1, 1, 1, 1}; + return rect; + } + sceneSession->GetAINavigationBarArea(rect, avoidArea); } /** @@ -1525,6 +1562,17 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level float vpr = 0.0; sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr); sceneSession->SetPipActionEvent("pointerEvent", 0); + + auto property = sptr::MakeSptr(); + EXPECT_NE(property, nullptr); + property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + sceneSession->SetSessionProperty(property); + ASSERT_EQ(WSError::WS_ERROR_INVALID_TYPE, sceneSession->SetPipActionEvent("pointerEvent", 0)); + + sceneSession->sessionStage_ = sptr::MakeSptr(); + property->SetWindowType(WindowType::WINDOW_TYPE_PIP); + property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); + ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0)); } /** @@ -1793,6 +1841,30 @@ HWTEST_F(SceneSessionTest2, GetSubWindowModalType, Function | SmallTest | Level2 result = sceneSession->GetSubWindowModalType(); ASSERT_EQ(result, SubWindowModalType::TYPE_DIALOG); } + +/** + * @tc.name: CheckGetAvoidAreaAvailable + * @tc.desc: CheckGetAvoidAreaAvailable + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest2, CheckGetAvoidAreaAvailable, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "CheckGetAvoidAreaAvailable"; + info.bundleName_ = "CheckGetAvoidAreaAvailable"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + + sptr property = new (std::nothrow) WindowSessionProperty(); + EXPECT_NE(property, nullptr); + property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + sceneSession->SetSessionProperty(property); + sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM); + + property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + sceneSession->SetSessionProperty(property); + sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM); +} } } } \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index 1135eb19cc..8168ce5f9b 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -308,6 +308,15 @@ HWTEST_F(SceneSessionTest3, NotifyClientToUpdateRectTask, Function | SmallTest | property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); sceneSession->SetSessionProperty(property); ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask(nullptr)); + + property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); + sceneSession->SetSessionProperty(property); + sceneSession->isKeyboardPanelEnabled_ = true; + ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask(nullptr)); + + std::shared_ptr rs; + ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask(rs)); + } /** diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 156b85e769..05ad9a2d02 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -622,6 +622,17 @@ HWTEST_F(SceneSessionTest5, CheckAspectRatioValid, Function | SmallTest | Level2 windowLimits.maxHeight_ = 10000; windowLimits.minHeight_ = -10000; EXPECT_EQ(WSError::WS_OK, session->SetAspectRatio(0.0f)); + + session->SetSessionProperty(nullptr); + EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session->SetAspectRatio(0.0f)); + + sptr property = new (std::nothrow) WindowSessionProperty(); + EXPECT_NE(property, nullptr); + WindowLimits limits = {8, 1, 6, 1, 1, 1.0f, 1.0f}; + property->SetWindowLimits(limits); + session->SetSessionProperty(property); + EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, session->SetAspectRatio(0.1f)); + EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, session->SetAspectRatio(10.0f)); } /** From d9e3cefcc9c0667a2f2145b29f22e98d09e34715 Mon Sep 17 00:00:00 2001 From: hubijie Date: Thu, 8 Aug 2024 11:52:16 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9FUT?= =?UTF-8?q?=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87=E8=A1=A5=E5=85=85?= =?UTF-8?q?=20=20Signed-off-by:=20hubijie=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/test/unittest/scene_session_test.cpp | 1 - window_scene/test/unittest/scene_session_test3.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 7686f4f9a6..642051cd2f 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -838,7 +838,6 @@ HWTEST_F(SceneSessionTest, SetSystemBarProperty, Function | SmallTest | Level2) ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), WSError::WS_OK); - NotifySystemBarPropertyChangeFunc fun = scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); EXPECT_NE(nullptr, scensession->sessionChangeCallback_); scensession->sessionChangeCallback_->OnSystemBarPropertyChange_ = []( diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index 8168ce5f9b..fa77ed98c9 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -316,7 +316,6 @@ HWTEST_F(SceneSessionTest3, NotifyClientToUpdateRectTask, Function | SmallTest | std::shared_ptr rs; ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask(rs)); - } /** From b98a39afe5af022b8d6ecd5c733ecfe57eb66fbb Mon Sep 17 00:00:00 2001 From: hubijie Date: Thu, 8 Aug 2024 06:43:53 +0000 Subject: [PATCH 3/4] update window_scene/test/unittest/scene_session_test2.cpp. Signed-off-by: hubijie --- window_scene/test/unittest/scene_session_test2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 04b39585a7..c49a479220 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -1513,7 +1513,7 @@ HWTEST_F(SceneSessionTest2, GetAINavigationBarArea, Function | SmallTest | Level sceneSession->specificCallback_->onGetAINavigationBarArea_ = [](uint64_t displayId) { WSRect rect = {1, 1, 1, 1}; return rect; - } + }; sceneSession->GetAINavigationBarArea(rect, avoidArea); } From 1b74961152f51de72041b882b7c96a73fa51f988 Mon Sep 17 00:00:00 2001 From: hubijie Date: Thu, 8 Aug 2024 06:56:47 +0000 Subject: [PATCH 4/4] update window_scene/test/unittest/scene_session_test.cpp. Signed-off-by: hubijie --- window_scene/test/unittest/scene_session_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 642051cd2f..1fd8d102bf 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -870,7 +870,7 @@ HWTEST_F(SceneSessionTest, OnShowWhenLocked, Function | SmallTest | Level2) scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); EXPECT_NE(scensession->sessionChangeCallback_, nullptr); - scensession->sessionChangeCallback_->OnShowWhenLocked = [](bool showWhenLocked){}; + scensession->sessionChangeCallback_->OnShowWhenLocked_ = [](bool showWhenLocked){}; ASSERT_EQ(scensession->OnShowWhenLocked(false), WSError::WS_OK); }