/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include "interfaces/include/ws_common.h" #include "session_manager/include/scene_session_manager.h" #include "session_info.h" #include "session/host/include/scene_session.h" #include "session/host/include/main_session.h" #include "window_manager_agent.h" #include "session_manager.h" #include "zidl/window_manager_agent_interface.h" #include "mock/mock_session_stage.h" #include "mock/mock_window_event_channel.h" #include "context.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { const std::string EMPTY_DEVICE_ID = ""; constexpr int WAIT_SLEEP_TIME = 1; using ConfigItem = WindowSceneConfig::ConfigItem; ConfigItem ReadConfig(const std::string& xmlStr) { ConfigItem config; xmlDocPtr docPtr = xmlParseMemory(xmlStr.c_str(), xmlStr.length() + 1); if (docPtr == nullptr) { return config; } xmlNodePtr rootPtr = xmlDocGetRootElement(docPtr); if (rootPtr == nullptr || rootPtr->name == nullptr || xmlStrcmp(rootPtr->name, reinterpret_cast("Configs"))) { xmlFreeDoc(docPtr); return config; } std::map configMap; config.SetValue(configMap); WindowSceneConfig::ReadConfig(rootPtr, *config.mapValue_); xmlFreeDoc(docPtr); return config; } } class SceneSessionManagerTest2 : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; static bool gestureNavigationEnabled_; static ProcessGestureNavigationEnabledChangeFunc callbackFunc_; static sptr ssm_; private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; sptr SceneSessionManagerTest2::ssm_ = nullptr; bool SceneSessionManagerTest2::gestureNavigationEnabled_ = true; ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest2::callbackFunc_ = [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) { } void ProcessStatusBarEnabledChangeFuncTest(bool enable) { } void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) { } void SceneSessionManagerTest2::SetUpTestCase() { ssm_ = &SceneSessionManager::GetInstance(); } void SceneSessionManagerTest2::TearDownTestCase() { ssm_ = nullptr; } void SceneSessionManagerTest2::SetUp() { } void SceneSessionManagerTest2::TearDown() { usleep(WAIT_SYNC_IN_NS); } namespace { /** * @tc.name: SetGestureNavigaionEnabled * @tc.desc: SceneSessionManager set gesture navigation enabled * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, SetGestureNavigaionEnabled, Function | SmallTest | Level3) { ASSERT_NE(callbackFunc_, nullptr); WMError result00 = ssm_->SetGestureNavigaionEnabled(true); ASSERT_EQ(result00, WMError::WM_OK); ssm_->SetGestureNavigationEnabledChangeListener(callbackFunc_); WMError result01 = ssm_->SetGestureNavigaionEnabled(true); ASSERT_EQ(result01, WMError::WM_OK); sleep(WAIT_SLEEP_TIME); ASSERT_EQ(gestureNavigationEnabled_, true); WMError result02 = ssm_->SetGestureNavigaionEnabled(false); ASSERT_EQ(result02, WMError::WM_OK); sleep(WAIT_SLEEP_TIME); ASSERT_EQ(gestureNavigationEnabled_, false); ssm_->SetGestureNavigationEnabledChangeListener(nullptr); WMError result03 = ssm_->SetGestureNavigaionEnabled(true); ASSERT_EQ(result03, WMError::WM_OK); } /** * @tc.name: RegisterWindowManagerAgent * @tc.desc: SceneSesionManager rigister window manager agent * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, RegisterWindowManagerAgent, Function | SmallTest | Level3) { sptr windowManagerAgent = new WindowManagerAgent(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm_->RegisterWindowManagerAgent(type, windowManagerAgent)); ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm_->UnregisterWindowManagerAgent( type, windowManagerAgent)); } /** * @tc.name: ConfigWindowSizeLimits01 * @tc.desc: call ConfigWindowSizeLimits and check the systemConfig_. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSizeLimits01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "10" "20" "" "" "30" "40" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSizeLimits(); ASSERT_EQ(ssm_->systemConfig_.miniWidthOfMainWindow_, static_cast(10)); ASSERT_EQ(ssm_->systemConfig_.miniHeightOfMainWindow_, static_cast(20)); ASSERT_EQ(ssm_->systemConfig_.miniWidthOfSubWindow_, static_cast(30)); ASSERT_EQ(ssm_->systemConfig_.miniHeightOfSubWindow_, static_cast(40)); } /** * @tc.name: ConfigWindowEffect01 * @tc.desc: call ConfigWindowEffect all success focused * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "off" "off" "off" "" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.radius_, 0.5); } /** * @tc.name: ConfigWindowEffect02 * @tc.desc: call ConfigWindowEffect * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "off" "off" "" "" "" "0" "0" "" "" "0" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 0); } /** * @tc.name: ConfigWindowEffect03 * @tc.desc: call ConfigWindowEffect ConfigAppWindowShadow unfocused * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect03, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5); } /** * @tc.name: ConfigWindowEffect04 * @tc.desc: call ConfigWindowEffect all * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect04, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "off" "off" "off" "" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.focusedShadow_.radius_, 0.5); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5); } /** * @tc.name: ConfigWindowEffect05 * @tc.desc: call ConfigWindowEffect all offsetX.size is not 1 * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect05, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "" "0" "1" "2" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5); } /** * @tc.name: ConfigWindowEffect06 * @tc.desc: call ConfigWindowEffect offsetY.size is not 1 * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect06, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "" "0" "1" "2" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5); } /** * @tc.name: ConfigWindowEffect07 * @tc.desc: call ConfigWindowEffect alpha.size is not 1 * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect07, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "" "0" "1" "2" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5); } /** * @tc.name: ConfigWindowEffect08 * @tc.desc: call ConfigWindowEffect radius.size is not 1 * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect08, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "" "0" "1" "2" "" "" "0" "#000000" "1" "1" "0" "0.5" "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.alpha_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetX_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.offsetY_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.unfocusedShadow_.radius_, 0.5); } /** * @tc.name: ConfigDecor * @tc.desc: call ConfigDecor fullscreen * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, Function | SmallTest | Level3) { std::string xmlStr1 = "" "" "" "fullscreen" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); std::string xmlStr = "" "" "" "fullscreen" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, static_cast(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN)); } /** * @tc.name: ConfigDecor * @tc.desc: call ConfigDecor * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); } /** * @tc.name: ConfigDecor * @tc.desc: call ConfigDecor floating * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor03, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "floating" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); } /** * @tc.name: ConfigDecor * @tc.desc: call ConfigDecor pip * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor04, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "pip" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); } /** * @tc.name: ConfigDecor * @tc.desc: call ConfigDecor split * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor05, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "split" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); } /** * @tc.name: ConfigDecor * @tc.desc: call ConfigDecor default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor06, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "111" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WINDOW_MODE_SUPPORT_ALL); } /** * @tc.name: ConfigWindowSceneXml01 * @tc.desc: call defaultWindowMode * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "10" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); std::string xmlStr1 = "" "" "102" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_, static_cast(static_cast(102))); } /** * @tc.name: ConfigWindowSceneXml02 * @tc.desc: call defaultWindowMode * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "1 1" "phone" "" "windowRotation" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); std::string xmlStr1 = "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_, static_cast(static_cast(1))); } /** * @tc.name: ConfigWindowSceneXml03 * @tc.desc: call defaultMaximizeMode * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml03, Function | SmallTest | Level3) { std::string xmlStr = "" "" "1 1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); std::string xmlStr1 = "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(SceneSession::maximizeMode_, static_cast(static_cast(1))); } /** * @tc.name: ConfigWindowSceneXml04 * @tc.desc: call defaultMaximizeMode * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml04, Function | SmallTest | Level3) { std::string xmlStr = "" "" "111" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); std::string xmlStr1 = "" "" "0" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(SceneSession::maximizeMode_, static_cast(static_cast(0))); } /** * @tc.name: ConfigWindowSceneXml05 * @tc.desc: call maxFloatingWindowSize * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml05, Function | SmallTest | Level3) { std::string xmlStr = "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); std::string xmlStr1 = "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.maxFloatingWindowSize_, static_cast(1)); } /** * @tc.name: ConfigWindowSceneXml06 * @tc.desc: call uiType * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml06, Function | SmallTest | Level3) { std::string xmlStr = "" "" "ut" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.uiType_, "ut"); } /** * @tc.name: ConfigWindowSceneXml07 * @tc.desc: call backgroundScreenLock * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml07, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.backgroundScreenLock_, true); } /** * @tc.name: ConfigWindowSceneXml08 * @tc.desc: call rotationMode * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml08, Function | SmallTest | Level3) { std::string xmlStr = "" "" "rotation" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.rotationMode_, "rotation"); } /** * @tc.name: ConfigKeyboardAnimation01 * @tc.desc: call ConfigKeyboardAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "abv" "0.2 0.0 0.2 1.0" "" "" "" "" "abv" "0.2 0.0 0.2 1.0" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); std::string xmlStr1 = "" "" "" "" "" "500" "0.2 0.0 0.2 1.0" "" "" "" "" "300" "0.2 0.0 0.2 1.0" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.animationIn_.duration_, static_cast(500)); ASSERT_EQ(ssm_->systemConfig_.animationOut_.duration_, static_cast(300)); } /** * @tc.name: ConfigKeyboardAnimation02 * @tc.desc: call ConfigKeyboardAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "500" "600" "" "" "" "" "300" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.animationOut_.duration_, static_cast(300)); } /** * @tc.name: ConfigKeyboardAnimation03 * @tc.desc: call ConfigKeyboardAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation03, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "500" "" "" "" "" "300" "400" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.animationIn_.duration_, static_cast(500)); } /** * @tc.name: ConfigKeyboardAnimation04 * @tc.desc: call ConfigKeyboardAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigKeyboardAnimation04, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "500" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.animationIn_.duration_, static_cast(500)); } /** * @tc.name: ConfigWindowAnimation01 * @tc.desc: call ConfigWindowAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "350" "" "" "0.7 0.7" "0 0 1 0" "0 0" "0" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0); } /** * @tc.name: ConfigWindowAnimation02 * @tc.desc: call ConfigWindowAnimation no change * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "350" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350); } /** * @tc.name: ConfigWindowAnimation03 * @tc.desc: call ConfigWindowAnimation no timing * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation03, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "" "0.7 0.7" "0 0 1 0" "0 0" "0" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0); } /** * @tc.name: ConfigWindowAnimation04 * @tc.desc: call ConfigWindowAnimation default timing is not int * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation04, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "aaa" "" "" "0.7 0.7" "0 0 1 0" "0 0" "0" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0); } /** * @tc.name: ConfigWindowAnimation05 * @tc.desc: call ConfigWindowAnimation default timing is error size * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation05, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "350 350" "" "" "0.7 0.7" "0 0 1 0" "0 0" "0" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleX_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.scaleY_, static_cast(0.7)); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.rotationZ_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.angle_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateX_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.translateY_, 0); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.opacity_, 0); } /** * @tc.name: ConfigWindowAnimation06 * @tc.desc: call ConfigWindowAnimation default change is not int * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation06, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "350" "" "" "a a" "a a a a" "a a" "a" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350); } /** * @tc.name: ConfigWindowAnimation07 * @tc.desc: call ConfigWindowAnimation default change error size * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation07, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "350" "" "" "0.7 0.7 0.7" "0 0 1 0 1" "0 0 1" "0 1" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.windowAnimation_.duration_, 350); } /** * @tc.name: ConfigStartingWindowAnimation01 * @tc.desc: call ConfigStartingWindowAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "200" "" "" "1" "0" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.duration_, 200); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityStart_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityEnd_, 0); } /** * @tc.name: ConfigStartingWindowAnimation02 * @tc.desc: call ConfigStartingWindowAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "200" "" "" "1" "0" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.duration_, 200); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityStart_, 1); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.opacityEnd_, 0); } /** * @tc.name: ConfigStartingWindowAnimation03 * @tc.desc: call ConfigStartingWindowAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation03, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "aaa" "" "" "aaa" "aaa" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false); } /** * @tc.name: ConfigStartingWindowAnimation04 * @tc.desc: call ConfigStartingWindowAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation04, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "200 200" "" "" "1 1" "0 1" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false); } /** * @tc.name: ConfigStartingWindowAnimation05 * @tc.desc: call ConfigStartingWindowAnimation default * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation05, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" "aaa aaa" "" "" "a a" "a a" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->appWindowSceneConfig_.startingWindowAnimationConfig_.enabled_, false); } /** * @tc.name: ConfigSnapshotScale01 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "0.7" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigSnapshotScale(); ASSERT_EQ(ssm_->snapshotScale_, static_cast(0.7)); } /** * @tc.name: ConfigSnapshotScale02 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "0.7 0.7" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigSnapshotScale(); ASSERT_EQ(ssm_->snapshotScale_, 0.7f); } /** * @tc.name: ConfigSnapshotScale03 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale03, Function | SmallTest | Level3) { std::string xmlStr = "" "" "aaa" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigSnapshotScale(); ASSERT_EQ(ssm_->snapshotScale_, 0.7f); } /** * @tc.name: ConfigSnapshotScale04 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale04, Function | SmallTest | Level3) { std::string xmlStr = "" "" "-0.1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigSnapshotScale(); ASSERT_EQ(ssm_->snapshotScale_, 0.7f); } /** * @tc.name: ConfigSnapshotScale05 * @tc.desc: call ConfigSnapshotScale and check the snapshotScale_. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale05, Function | SmallTest | Level3) { std::string xmlStr = "" "" "1.5" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigSnapshotScale(); ASSERT_EQ(ssm_->snapshotScale_, 0.7f); } /** * @tc.name: ConfigSystemUIStatusBar01 * @tc.desc: call ConfigSystemUIStatusBar default. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigSystemUIStatusBar01, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "1" "#4c000000" "#ffffee" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); SceneSessionManager* sceneSessionManager = new SceneSessionManager(); sceneSessionManager->ConfigWindowSceneXml(); ASSERT_EQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_, 1); ASSERT_STREQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_.c_str(), "#4c000000"); ASSERT_STREQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_. immersiveStatusBarContentColor_.c_str(), "#ffffee"); delete sceneSessionManager; } /** * @tc.name: DumpSessionAll * @tc.desc: ScreenSesionManager dump all session info * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, DumpSessionAll, Function | SmallTest | Level3) { SessionInfo sessionInfo; sessionInfo.bundleName_ = "SceneSessionManagerTest2"; sessionInfo.abilityName_ = "DumpSessionAll"; sptr windowSessionProperty = new WindowSessionProperty(); sptr sceneSession = ssm_->RequestSceneSession(sessionInfo, windowSessionProperty); ASSERT_EQ(nullptr, sceneSession); std::vector infos; WSError result = ssm_->DumpSessionAll(infos); ASSERT_EQ(WSError::WS_OK, result); ASSERT_FALSE(infos.empty()); } /** * @tc.name: DumpSessionWithId * @tc.desc: ScreenSesionManager dump session with id * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, DumpSessionWithId, Function | SmallTest | Level3) { SessionInfo sessionInfo; sessionInfo.bundleName_ = "SceneSessionManagerTest2"; sessionInfo.abilityName_ = "DumpSessionWithId"; sptr windowSessionProperty = new WindowSessionProperty(); sptr sceneSession = ssm_->RequestSceneSession(sessionInfo, windowSessionProperty); ASSERT_EQ(nullptr, sceneSession); std::vector infos; WSError result = ssm_->DumpSessionWithId(windowSessionProperty->GetPersistentId(), infos); ASSERT_EQ(WSError::WS_OK, result); ASSERT_FALSE(infos.empty()); } /** * @tc.name: Init * @tc.desc: SceneSesionManager init * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, Init, Function | SmallTest | Level3) { int ret = 0; ssm_->Init(); ssm_->RegisterAppListener(); ASSERT_EQ(ret, 0); } /** * @tc.name: LoadWindowSceneXml * @tc.desc: SceneSesionManager load window scene xml * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, LoadWindowSceneXml, Function | SmallTest | Level3) { int ret = 0; ssm_->LoadWindowSceneXml(); ssm_->ConfigWindowSceneXml(); ssm_->SetEnableInputEvent(true); ssm_->SetEnableInputEvent(false); ASSERT_EQ(ssm_->IsInputEventEnabled(), false); ASSERT_EQ(ret, 0); } /** * @tc.name: UpdateRecoveredSessionInfo * @tc.desc: SceneSessionManager load window scene xml * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, UpdateRecoveredSessionInfo, Function | SmallTest | Level3) { int ret = 0; std::vector recoveredPersistentIds; ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds); recoveredPersistentIds.push_back(0); ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds); SessionInfo info; info.abilityName_ = "test1"; info.bundleName_ = "test2"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); if (sceneSession == nullptr) { return; } ssm_->sceneSessionMap_.insert({0, sceneSession}); ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds); ssm_->sceneSessionMap_.erase(0); ASSERT_EQ(ret, 0); } /** * @tc.name: ConfigWindowSceneXml * @tc.desc: SceneSesionManager config window scene xml run * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml, Function | SmallTest | Level3) { int ret = 0; ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ret, 0); } /** * @tc.name: SetSessionContinueState * @tc.desc: SceneSesionManager set session continue state * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState, Function | SmallTest | Level3) { MessageParcel *data = new MessageParcel(); sptr token = data->ReadRemoteObject(); auto continueState = static_cast(data->ReadInt32()); WSError result02 = ssm_->SetSessionContinueState(nullptr, continueState); WSError result01 = ssm_->SetSessionContinueState(token, continueState); ASSERT_EQ(result02, WSError::WS_ERROR_INVALID_PARAM); ASSERT_EQ(result01, WSError::WS_ERROR_INVALID_PARAM); delete data; } /** * @tc.name: SetSessionContinueState002 * @tc.desc: SceneSesionManager set session continue state * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState002, Function | SmallTest | Level3) { MessageParcel *data = new MessageParcel(); sptr token = data->ReadRemoteObject(); auto continueState = static_cast(0); SessionInfo info; info.abilityName_ = "test1"; info.bundleName_ = "test2"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); if (sceneSession == nullptr) { delete data; return; } ssm_->sceneSessionMap_.insert({1000, sceneSession}); ssm_->SetSessionContinueState(token, continueState); ASSERT_NE(sceneSession, nullptr); delete data; } /** * @tc.name: StartWindowInfoReportLoop * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, StartWindowInfoReportLoop, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); ssm_->StartWindowInfoReportLoop(); ssm_->eventHandler_ = nullptr; ssm_->StartWindowInfoReportLoop(); ssm_->isReportTaskStart_ = true; ssm_->StartWindowInfoReportLoop(); } /** * @tc.name: GetFocusWindowInfo * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetFocusWindowInfo, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); FocusChangeInfo info; ssm_->GetFocusWindowInfo(info); } /** * @tc.name: GetFocusWindowInfo * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetFocusWindowInfo2, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); FocusChangeInfo fcinfo; ssm_->GetFocusWindowInfo(fcinfo); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({0, sceneSession}); ssm_->GetFocusWindowInfo(fcinfo); } /** * @tc.name: SetSessionLabel * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, SetSessionLabel, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); ssm_->SetSessionLabel(nullptr, "test"); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->SetSessionLabel(nullptr, "test"); } /** * @tc.name: SetSessionIcon * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, SetSessionIcon, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); ssm_->SetSessionIcon(nullptr, nullptr); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->SetSessionIcon(nullptr, nullptr); } /** * @tc.name: InitWithRenderServiceAdded * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, InitWithRenderServiceAdded, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); ssm_->InitWithRenderServiceAdded(); } /** * @tc.name: PendingSessionToForeground * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, PendingSessionToForeground, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); ssm_->PendingSessionToForeground(nullptr); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->PendingSessionToForeground(nullptr); } /** * @tc.name: GetFocusSessionElement * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetFocusSessionElement, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); AppExecFwk::ElementName element; ssm_->GetFocusSessionElement(element); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->GetFocusSessionElement(element); } /** * @tc.name: GetAllAbilityInfos * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetAllAbilityInfos, Function | SmallTest | Level3) { WSError ret; AAFwk::Want want; AppExecFwk::ElementName elementName = want.GetElement(); int32_t userId = 1; std::vector scbAbilityInfos; ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos); ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); elementName.bundleName_ = "test"; ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos); ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); elementName.abilityName_ = "test"; ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos); ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); elementName.bundleName_ = ""; ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos); ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); ssm_->bundleMgr_ = nullptr; ret = ssm_->GetAllAbilityInfos(want, userId, scbAbilityInfos); ASSERT_EQ(WSError::WS_ERROR_NULLPTR, ret); } /** * @tc.name: GetIsLayoutFullScreen * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetIsLayoutFullScreen, Function | SmallTest | Level3) { WSError ret; bool isLayoutFullScreen = true; ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen); ASSERT_EQ(WSError::WS_OK, ret); isLayoutFullScreen = false; ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen); ASSERT_EQ(WSError::WS_OK, ret); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); isLayoutFullScreen = true; ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen); ASSERT_EQ(WSError::WS_OK, ret); isLayoutFullScreen = false; ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen); ASSERT_EQ(WSError::WS_OK, ret); } /** * @tc.name: UpdateSessionAvoidAreaListener * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, UpdateSessionAvoidAreaListener, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } int32_t persistentId = 100; ssm_->UpdateSessionAvoidAreaListener(persistentId, true); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->UpdateSessionAvoidAreaListener(persistentId, true); ssm_->UpdateSessionAvoidAreaListener(persistentId, false); } /** * @tc.name: UpdateSessionTouchOutsideListener * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, UpdateSessionTouchOutsideListener, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } int32_t persistentId = 100; ssm_->UpdateSessionTouchOutsideListener(persistentId, true); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->UpdateSessionTouchOutsideListener(persistentId, true); ssm_->UpdateSessionTouchOutsideListener(persistentId, false); } /** * @tc.name: GetSessionSnapshotById * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetSessionSnapshotById, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); SessionSnapshot snapshot; ssm_->GetSessionSnapshotById(100, snapshot); } /** * @tc.name: ClearSession * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ClearSession, Function | SmallTest | Level3) { WSError ret; ret = ssm_->ClearSession(100); ASSERT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, ret); } /** * @tc.name: ClearAllSessions * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ClearAllSessions, Function | SmallTest | Level3) { WSError ret; ret = ssm_->ClearAllSessions(); ASSERT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, ret); } /** * @tc.name: GetTopWindowId * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetTopWindowId, Function | SmallTest | Level3) { WMError ret; { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } uint32_t persistentId = 100; uint32_t topWinId = 200; ret = ssm_->GetTopWindowId(persistentId, topWinId); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ret = ssm_->GetTopWindowId(persistentId, topWinId); ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret); } /** * @tc.name: InitPersistentStorage * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, InitPersistentStorage, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } ssm_->InitPersistentStorage(); } /** * @tc.name: GetSessionSnapshotFilePath * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetSessionSnapshotFilePath, Function | SmallTest | Level3) { string ret; { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } ret = ssm_->GetSessionSnapshotFilePath(100); ASSERT_EQ("", ret); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ret = ssm_->GetSessionSnapshotFilePath(100); ASSERT_EQ("", ret); } /** * @tc.name: GetAccessibilityWindowInfo * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, GetAccessibilityWindowInfo, Function | SmallTest | Level3) { WMError ret; { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } std::vector> infos; ret = ssm_->GetAccessibilityWindowInfo(infos); ASSERT_EQ(WMError::WM_OK, ret); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ret = ssm_->GetAccessibilityWindowInfo(infos); ASSERT_EQ(WMError::WM_OK, ret); } /** * @tc.name: OnScreenshot * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, OnScreenshot, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } DisplayId displayId = 0; ssm_->OnScreenshot(displayId); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->OnScreenshot(displayId); sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); ssm_->OnScreenshot(displayId); sceneSession->SetSessionState(SessionState::STATE_ACTIVE); ssm_->OnScreenshot(displayId); sceneSession->SetSessionState(SessionState::STATE_DISCONNECT); ssm_->OnScreenshot(displayId); sceneSession->SetSessionState(SessionState::STATE_END); ssm_->OnScreenshot(displayId); } /** * @tc.name: ProcessSubSessionForeground * @tc.desc: Test if pip window can be created; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ProcessSubSessionForeground, Function | SmallTest | Level3) { { std::unique_lock lock(ssm_->sceneSessionMapMutex_); ssm_->sceneSessionMap_.clear(); } sptr sceneSession = nullptr; ssm_->ProcessSubSessionForeground(sceneSession); SessionInfo info; info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sceneSession = new (std::nothrow) SceneSession(info, nullptr); ASSERT_NE(nullptr, sceneSession); ssm_->ProcessSubSessionForeground(sceneSession); sptr sub1 = nullptr; sptr sub2 = new (std::nothrow) SceneSession(info, nullptr); std::vector> subs; std::vector> dialogs; subs.push_back(sub1); subs.push_back(sub2); dialogs.push_back(sub1); dialogs.push_back(sub2); sceneSession->subSession_ = subs; ssm_->ProcessSubSessionForeground(sceneSession); sptr sub3 = new (std::nothrow) SceneSession(info, nullptr); sub3->state_ = SessionState::STATE_FOREGROUND; subs.push_back(sub3); dialogs.push_back(sub3); sceneSession->subSession_ = subs; ssm_->ProcessSubSessionForeground(sceneSession); sptr sub4 = new (std::nothrow) SceneSession(info, nullptr); sub4->state_ = SessionState::STATE_FOREGROUND; sub4->persistentId_ = 100; subs.push_back(sub4); dialogs.push_back(sub4); sceneSession->subSession_ = subs; ssm_->ProcessSubSessionForeground(sceneSession); ssm_->sceneSessionMap_.insert({0, sceneSession}); ssm_->sceneSessionMap_.insert({100, sceneSession}); ssm_->ProcessSubSessionForeground(sceneSession); ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; ssm_->ProcessSubSessionForeground(sceneSession); ASSERT_NE(nullptr, ssm_); } /** * @tc.name: ConfigSystemUIStatusBar * @tc.desc: call ConfigSystemUIStatusBar default. * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ConfigSystemUIStatusBar02, Function | SmallTest | Level3) { std::string xmlStr = "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); SceneSessionManager* sceneSessionManager = new SceneSessionManager(); ASSERT_NE(sceneSessionManager, nullptr); sceneSessionManager->ConfigWindowSceneXml(); delete sceneSessionManager; } /** * @tc.name: CreateAndConnectSpecificSession * @tc.desc: CreateAndConnectSpecificSession * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, CreateAndConnectSpecificSession02, Function | SmallTest | Level3) { sptr sessionStage; sptr eventChannel; std::shared_ptr node = nullptr; sptr property; sptr session; SystemSessionConfig systemConfig; sptr token; int32_t id = 0; ASSERT_NE(ssm_, nullptr); ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, systemConfig, token); property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(property, nullptr); property->SetWindowType(WindowType::APP_WINDOW_BASE); ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, systemConfig, token); } /** * @tc.name: ClosePipWindowIfExist * @tc.desc: ClosePipWindowIfExist * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, ClosePipWindowIfExist, Function | SmallTest | Level3) { sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(property, nullptr); ssm_->ClosePipWindowIfExist(WindowType::WINDOW_TYPE_PIP); SessionInfo info; info.sessionState_ = {1}; Rect reqRect = { 0, 0, 10, 10 }; property->SetRequestRect(reqRect); property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); ASSERT_EQ(false, ssm_->isEnablePiPCreate(property)); } /** * @tc.name: RecoverAndConnectSpecificSession * @tc.desc: RecoverAndConnectSpecificSession * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, RecoverAndConnectSpecificSession, Function | SmallTest | Level3) { sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(property, nullptr); property->SetParentId(1); sptr sessionStage; sptr eventChannel; std::shared_ptr surfaceNode; sptr session; sptr token; auto result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } /** * @tc.name: CacheSubSessionForRecovering * @tc.desc: CacheSubSessionForRecovering * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, CacheSubSessionForRecovering, Function | SmallTest | Level3) { sptr property; ASSERT_NE(ssm_, nullptr); ssm_->recoveringFinished_ = false; SessionInfo info; info.abilityName_ = "test1"; info.bundleName_ = "test2"; sptr sceneSession = ssm_->CreateSceneSession(info, property); ASSERT_NE(sceneSession, nullptr); ssm_->CacheSubSessionForRecovering(nullptr, property); ssm_->CacheSubSessionForRecovering(sceneSession, property); property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(property, nullptr); ssm_->CacheSubSessionForRecovering(nullptr, property); ssm_->CacheSubSessionForRecovering(sceneSession, property); property->SetWindowType(WindowType::APP_WINDOW_BASE); ssm_->CacheSubSessionForRecovering(sceneSession, property); property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); ssm_->CacheSubSessionForRecovering(sceneSession, property); property->SetParentPersistentId(1); ssm_->CacheSubSessionForRecovering(sceneSession, property); } /** * @tc.name: NotifyCreateToastSession * @tc.desc: NotifyCreateToastSession * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, NotifyCreateToastSession, Function | SmallTest | Level3) { sptr property = new (std::nothrow) WindowSessionProperty(); ASSERT_NE(property, nullptr); ssm_->NotifyCreateToastSession(1, nullptr); SessionInfo Info; Info.persistentId_ = 1; int32_t persistentId = Info.persistentId_; Info.abilityName_ = "testInfo1a"; Info.bundleName_ = "testInfo1b"; sptr session = new (std::nothrow) SceneSession(Info, nullptr); ssm_->NotifyCreateToastSession(persistentId, session); } /** * @tc.name: UpdateGestureBackEnabled * @tc.desc: UpdateGestureBackEnabled * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, UpdateGestureBackEnabled, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); SessionInfo sessionInfo; sessionInfo.bundleName_ = "SceneSessionManagerTest2"; sessionInfo.abilityName_ = "UpdateGestureBackEnabled"; sptr property; sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, property); ASSERT_NE(nullptr, sceneSession); ASSERT_NE(nullptr, sceneSession->property_); ssm_->sceneSessionMap_.insert({1, sceneSession}); sceneSession->persistentId_ = 1; ASSERT_EQ(ssm_->GetSceneSession(1), sceneSession); sceneSession->isEnableGestureBack_ = false; sceneSession->isEnableGestureBackHadSet_ = false; ssm_->UpdateGestureBackEnabled(1); sleep(WAIT_SLEEP_TIME); sceneSession->isEnableGestureBackHadSet_ = true; sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); ssm_->NotifyEnterRecentTask(false); ASSERT_EQ(ssm_->enterRecent_.load(), false); sceneSession->UpdateFocus(true); ASSERT_EQ(sceneSession->IsFocused(), true); ssm_->UpdateGestureBackEnabled(1); sleep(WAIT_SLEEP_TIME); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); ssm_->UpdateGestureBackEnabled(1); sleep(WAIT_SLEEP_TIME); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ssm_->UpdateGestureBackEnabled(1); sleep(WAIT_SLEEP_TIME); ssm_->sceneSessionMap_.erase(1); } /** * @tc.name: NotifyEnterRecentTask * @tc.desc: NotifyEnterRecentTask; * @tc.type: FUNC */ HWTEST_F(SceneSessionManagerTest2, NotifyEnterRecentTask, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); SessionInfo sessionInfo; sessionInfo.bundleName_ = "NotifyEnterRecentTask"; sessionInfo.abilityName_ = "NotifyEnterRecentTask"; sptr property = sptr::MakeSptr(); sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); sceneSession->SetSessionProperty(property); ssm_->sceneSessionMap_.insert({1, sceneSession}); ssm_->gestureBackEnableWindowIdSet_.insert(1); ssm_->gestureBackEnableWindowIdSet_.insert(2); ASSERT_EQ(ssm_->NotifyEnterRecentTask(true), WSError::WS_OK); ASSERT_EQ(ssm_->NotifyEnterRecentTask(false), WSError::WS_OK); ssm_->sceneSessionMap_.erase(1); } } } // namespace Rosen } // namespace OHOS