/* * Copyright (c) 2023 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 "ability_context_impl.h" #include "mock_session.h" #include "window_session_impl.h" #include "mock_uicontent.h" #include "window_scene_session_impl.h" #include "mock_window_adapter.h" #include "singleton_mocker.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { using Mocker = SingletonMocker; uint32_t MaxWith = 32; class MockWindowChangeListener : public IWindowChangeListener { public: MOCK_METHOD3(OnSizeChange, void(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr &rsTransaction)); }; class MockWindowLifeCycleListener : public IWindowLifeCycle { public: MOCK_METHOD0(AfterForeground, void(void)); MOCK_METHOD0(AfterBackground, void(void)); MOCK_METHOD0(AfterFocused, void(void)); MOCK_METHOD0(AfterUnfocused, void(void)); MOCK_METHOD1(ForegroundFailed, void(int32_t)); MOCK_METHOD0(AfterActive, void(void)); MOCK_METHOD0(AfterInactive, void(void)); }; class WindowSceneSessionImplTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; std::shared_ptr abilityContext_; std::unique_ptr m = std::make_unique(); private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); }; void WindowSceneSessionImplTest::SetUpTestCase() {} void WindowSceneSessionImplTest::TearDownTestCase() {} void WindowSceneSessionImplTest::SetUp() { abilityContext_ = std::make_shared(); } void WindowSceneSessionImplTest::TearDown() { abilityContext_ = nullptr; } RSSurfaceNode::SharedPtr WindowSceneSessionImplTest::CreateRSSurfaceNode() { struct RSSurfaceNodeConfig rsSurfaceNodeConfig; rsSurfaceNodeConfig.SurfaceNodeName = "startingWindowTestSurfaceNode"; auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig, RSSurfaceNodeType::DEFAULT); return surfaceNode; } namespace { /** * @tc.name: CreateWindowAndDestroy01 * @tc.desc: Create window and destroy window * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, CreateWindowAndDestroy01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("CreateWindow01"); sptr window = new WindowSceneSessionImpl(option); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); window->property_->SetPersistentId(1); ASSERT_EQ(WMError::WM_OK, window->Destroy(false)); ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); } /** * @tc.name: CreateAndConnectSpecificSession01 * @tc.desc: CreateAndConnectSpecificSession * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("CreateAndConnectSpecificSession01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); if (windowscenesession->CreateAndConnectSpecificSession() == WMError::WM_ERROR_NULLPTR) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscenesession->CreateAndConnectSpecificSession()); } windowscenesession->property_->SetPersistentId(102); windowscenesession->property_->SetParentPersistentId(100); windowscenesession->property_->SetParentId(100); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); ASSERT_EQ(WMError::WM_OK, windowscenesession->Create(abilityContext_, session)); } /** * @tc.name: CreateAndConnectSpecificSession02 * @tc.desc: CreateAndConnectSpecificSession * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession02, Function | SmallTest | Level2) { sptr option_ = new (std::nothrow) WindowOption(); option_->SetWindowTag(WindowTag::SUB_WINDOW); option_->SetWindowName("ChildWindow0002"); sptr parentscenesession_ = new (std::nothrow) WindowSceneSessionImpl(option_); ASSERT_NE(nullptr, parentscenesession_); SessionInfo sessionInfo_ = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" }; sptr session_ = new (std::nothrow) SessionMocker(sessionInfo_); ASSERT_NE(nullptr, session_); ASSERT_EQ(WMError::WM_OK, parentscenesession_->Create(abilityContext_, session_)); parentscenesession_->property_->SetParentPersistentId(102); parentscenesession_->property_->SetParentId(102); parentscenesession_->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE; parentscenesession_->hostSession_ = session_; parentscenesession_->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; if (parentscenesession_->CreateAndConnectSpecificSession() == WMError::WM_OK) { ASSERT_EQ(WMError::WM_OK, parentscenesession_->CreateAndConnectSpecificSession()); } } /** * @tc.name: IsValidSystemWindowType01 * @tc.desc: IsValidSystemWindowType * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, IsValidSystemWindowType01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_DIALOG)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_FLOAT)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_SCREENSHOT)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_VOICE_INTERACTION)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_POINTER)); ASSERT_FALSE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_TOAST)); ASSERT_TRUE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_DOCK_SLICE)); ASSERT_TRUE(!windowscenesession->IsValidSystemWindowType(WindowType::WINDOW_TYPE_APP_LAUNCHING)); } /* * @tc.name: InvalidWindow * @tc.desc: InvalidWindow test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, InvalidWindow, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->MoveTo(0, 0)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Resize(0, 0)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetBackgroundColor(std::string("???"))); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTransparent(false)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Show(2, false)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Resize(2, 2)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Minimize()); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Maximize()); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->MaximizeFloating()); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Recover()); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->MaximizeFloating()); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR)); } /** * @tc.name: FindParentSessionByParentId01 * @tc.desc: FindParentSessionByParentId * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, FindParentSessionByParentId01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowTag(WindowTag::MAIN_WINDOW); option->SetWindowName("FindParentSessionByParentId01"); sptr parentscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, parentscenesession); parentscenesession->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr); parentscenesession->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_END); ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr); parentscenesession->property_->SetPersistentId(1112); parentscenesession->property_->SetParentId(1000); parentscenesession->property_->SetParentPersistentId(1000); parentscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); ASSERT_EQ(WMError::WM_OK, parentscenesession->Create(abilityContext_, session)); parentscenesession->hostSession_ = session; ASSERT_TRUE(nullptr != parentscenesession->FindParentSessionByParentId(1112)); } /** * @tc.name: FindMainWindowWithContext01 * @tc.desc: FindMainWindowWithContext * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, FindMainWindowWithContext01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowTag(WindowTag::MAIN_WINDOW); option->SetWindowName("FindMainWindowWithContext01"); sptr parentscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, parentscenesession); parentscenesession->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr); parentscenesession->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_END); ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr); parentscenesession->property_->SetPersistentId(1002); parentscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); ASSERT_EQ(WMError::WM_OK, parentscenesession->Create(abilityContext_, session)); parentscenesession->hostSession_ = session; ASSERT_TRUE(nullptr != parentscenesession->FindParentSessionByParentId(1002)); sptr option_ = new (std::nothrow) WindowOption(); option_->SetWindowTag(WindowTag::MAIN_WINDOW); option_->SetWindowName("FindMainWindowWithContext02"); sptr parentscenesession_ = new (std::nothrow) WindowSceneSessionImpl(option_); ASSERT_NE(nullptr, parentscenesession_); SessionInfo sessionInfo_ = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session_ = new (std::nothrow) SessionMocker(sessionInfo_); ASSERT_NE(nullptr, session_); ASSERT_EQ(WMError::WM_OK, parentscenesession_->Create(abilityContext_, session_)); parentscenesession_->hostSession_ = session_; parentscenesession_->property_->type_ = WindowType::WINDOW_TYPE_DIALOG; ASSERT_FALSE(parentscenesession_->FindMainWindowWithContext() == nullptr); } /** * @tc.name: DisableAppWindowDecor01 * @tc.desc: DisableAppWindowDecor * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, DisableAppWindowDecor01, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowession = new (std::nothrow) WindowSessionImpl(option); ASSERT_NE(nullptr, windowession); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); std::shared_ptr context; ASSERT_EQ(WMError::WM_OK, windowession->Create(context, session)); windowession->UpdateDecorEnable(false); windowession->windowSystemConfig_.isSystemDecorEnable_ = false; windowession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); windowession->DisableAppWindowDecor(); ASSERT_FALSE(windowession->IsDecorEnable()); windowession->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); windowession->DisableAppWindowDecor(); } /** * @tc.name: HandleBackEvent01 * @tc.desc: HandleBackEvent * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, HandleBackEvent01, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->uiContent_ = std::make_unique(); ASSERT_EQ(WSError::WS_OK, windowscenesession->HandleBackEvent()); } /** * @tc.name: RaiseToAppTop01 * @tc.desc: RaiseToAppTop * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, RaiseToAppTop01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(6); windowscenesession->property_->SetParentPersistentId(6); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ASSERT_EQ(WmErrorCode::WM_ERROR_INVALID_CALLING, windowscenesession->RaiseToAppTop()); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); windowscenesession->state_ = WindowState::STATE_HIDDEN; ASSERT_EQ(WmErrorCode::WM_ERROR_STATE_ABNORMALLY, windowscenesession->RaiseToAppTop()); windowscenesession->state_ = WindowState::STATE_SHOWN; SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WmErrorCode::WM_OK, windowscenesession->RaiseToAppTop()); } /** * @tc.name: Resize01 * @tc.desc: Resize * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Resize01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Resize01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(888); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; Rect rect = {2, 2, 2, 2}; windowscenesession->property_->SetWindowRect(rect); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA); windowscenesession->state_ = WindowState::STATE_FROZEN; windowscenesession->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, windowscenesession->Resize(1, 1)); } /** * @tc.name: MoveTo01 * @tc.desc: MoveTo * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, MoveTo01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("MoveTo01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(1); windowscenesession->state_ = WindowState::STATE_HIDDEN; SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, windowscenesession->MoveTo(2, 2)); } /** * @tc.name: Minimize01 * @tc.desc: Minimize * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Minimize01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(1); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, windowscenesession->Minimize()); } /** * @tc.name: StartMove01 * @tc.desc: StartMove * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, StartMove01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(1); // show with null session windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); windowscenesession->hostSession_ = session; windowscenesession->StartMove(); ASSERT_NE(nullptr, session); } /** * @tc.name: Close01 * @tc.desc: Close * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Close01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(1); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, windowscenesession->Close()); } /** * @tc.name: SetActive01 * @tc.desc: SetActive * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetActive01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(1); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WSError::WS_OK, windowscenesession->SetActive(false)); } /** * @tc.name: Recover01 * @tc.desc: Recover * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Recover01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(1); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, windowscenesession->Recover()); } /** * @tc.name: Maximize01 * @tc.desc: Maximize * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Maximize01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Connect01"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(1); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, windowscenesession->Maximize()); } /** * @tc.name: Hide01 * @tc.desc: Hide session * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Hide01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Hide01"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); window->property_->SetPersistentId(1); // show with null session ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Hide(2, false, false)); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false)); ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false)); window->state_ = WindowState::STATE_CREATED; ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false)); window->state_ = WindowState::STATE_SHOWN; window->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; ASSERT_EQ(WMError::WM_OK, window->Hide(2, false, false)); window->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; if (window->Destroy(false) == WMError::WM_OK) { ASSERT_EQ(WMError::WM_OK, window->Destroy(false)); } } /** * @tc.name: Show01 * @tc.desc: Show session * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Show01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("Show01"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); window->property_->SetPersistentId(1); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->Show(2, false)); window->state_ = WindowState::STATE_CREATED; ASSERT_EQ(WMError::WM_OK, window->Show(2, false)); ASSERT_EQ(WMError::WM_OK, window->Destroy(false)); } /** * @tc.name: SetBackgroundColor01 * @tc.desc: test SetBackgroundColor withow uiContent * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetBackgroundColor01, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("SetBackgroundColor01"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); std::unique_ptr m = std::make_unique(); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); std::shared_ptr context; ASSERT_EQ(WMError::WM_OK, window->Create(context, session)); window->property_->SetPersistentId(1); window->Show(); } /* * @tc.name: SetTransparent * @tc.desc: SetTransparent test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetTransparent, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTransparent(true)); window->property_->SetPersistentId(1); option->SetWindowName("SetTransparent"); window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; window->uiContent_ = std::make_unique(); window->SetBackgroundColor(333); if (window->SetTransparent(true) == WMError::WM_OK) { ASSERT_EQ(WMError::WM_OK, window->SetTransparent(true)); } } /* * @tc.name: SetAspectRatio * @tc.desc: SetAspectRatio test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetAspectRatio, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetAspectRatio(0.1)); window->property_->SetPersistentId(1); window->property_->SetDisplayId(3); WindowLimits windowLimits = { 3, 3, 3, 3, 2.0, 2.0 }; window->property_->SetWindowLimits(windowLimits); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->SetAspectRatio(0.1)); } /* * @tc.name: ResetAspectRatio * @tc.desc: ResetAspectRatio test GetAvoidAreaByType * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, ResetAspectRatio, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->ResetAspectRatio()); } /* * @tc.name: GetAvoidAreaByType * @tc.desc: GetAvoidAreaByType test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, GetAvoidAreaByType, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetPersistentId(1); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); AvoidArea avoidarea; ASSERT_EQ(WMError::WM_OK, window->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea)); } /* * @tc.name: Immersive * @tc.desc: Immersive01 test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, Immersive, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetLayoutFullScreen(false)); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetFullScreen(false)); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false)); ASSERT_EQ(false, window->IsLayoutFullScreen()); ASSERT_EQ(false, window->IsFullScreen()); } /* * @tc.name: SystemBarProperty * @tc.desc: SystemBarProperty01 test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SystemBarProperty, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); SystemBarProperty property = SystemBarProperty(); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, property)); } /* * @tc.name: LimitCameraFloatWindowMininumSize * @tc.desc: LimitCameraFloatWindowMininumSize01 test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, LimitCameraFloatWindowMininumSize, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); uint32_t width = 33; uint32_t height = 31; window->LimitCameraFloatWindowMininumSize(width, height); } /* * @tc.name: NotifyWindowNeedAvoid * @tc.desc: NotifyWindowNeedAvoid test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, NotifyWindowNeedAvoid, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->NotifyWindowNeedAvoid(false)); window->state_ = WindowState::STATE_SHOWN; SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->property_->SetPersistentId(190); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->NotifyWindowNeedAvoid(false)); } /* * @tc.name: SetLayoutFullScreenByApiVersion * @tc.desc: SetLayoutFullScreenByApiVersion test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreenByApiVersion, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreenByApiVersion(false)); window->state_ = WindowState::STATE_SHOWN; window->property_->SetPersistentId(190); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreenByApiVersion(false)); } /* * @tc.name: SetGlobalMaximizeMode * @tc.desc: SetGlobalMaximizeMode test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetGlobalMaximizeMode, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER)); window->state_ = WindowState::STATE_SHOWN; SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->property_->SetPersistentId(190); window->hostSession_ = session; window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER)); window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); ASSERT_EQ(WMError::WM_OK, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER)); } /* * @tc.name: CheckParmAndPermission * @tc.desc: CheckParmAndPermission test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, CheckParmAndPermission, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("CheckParmAndPermission"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); } else { ASSERT_EQ(WMError::WM_OK, window->CheckParmAndPermission()); window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); ASSERT_EQ(WMError::WM_OK, window->CheckParmAndPermission()); } } /* * @tc.name: SetBackdropBlurStyle * @tc.desc: SetBackdropBlurStyle test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetBackdropBlurStyle, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetBackdropBlurStyle"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); window->property_->SetDisplayId(3); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_OFF)); } else { ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_OFF)); ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_THICK)); } } /* * @tc.name: SetTurnScreenOn * @tc.desc: SetTurnScreenOn test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetTurnScreenOn, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetBackdropBlurStyle"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTurnScreenOn(false)); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(false)); } /* * @tc.name: SetBlur * @tc.desc: SetBlur test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetBlur, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetBlur"); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); } else { window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBlur(-1.0)); ASSERT_EQ(WMError::WM_OK, window->SetBlur(1.0)); } } /* * @tc.name: SetKeepScreenOn * @tc.desc: SetKeepScreenOn test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetKeepScreenOn"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(false)); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(false)); ASSERT_FALSE(window->IsKeepScreenOn()); } /* * @tc.name: SetPrivacyMode * @tc.desc: SetPrivacyMode test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetPrivacyMode, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetPrivacyMode"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetPrivacyMode(false)); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; if (WMError::WM_OK == window->SetPrivacyMode(false)) { ASSERT_EQ(WMError::WM_OK, window->SetPrivacyMode(false)); ASSERT_EQ(false, window->IsPrivacyMode()); }else if (WMError::WM_DO_NOTHING == window->SetPrivacyMode(false)) { ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetPrivacyMode(false)); } } /* * @tc.name: IsPrivacyMode * @tc.desc: IsPrivacyMode test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, IsPrivacyModec, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("IsPrivacyModec"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); window->SetPrivacyMode(false); } /* * @tc.name: SetSystemPrivacyMode * @tc.desc: SetSystemPrivacyMode test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetSystemPrivacyMode, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetSystemPrivacyMode"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); window->SetSystemPrivacyMode(false); ASSERT_EQ(false, window->property_->GetSystemPrivacyMode()); } /* * @tc.name: SetSnapshotSkip * @tc.desc: SetSnapshotSkip test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetSnapshotSkip, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetSnapshotSkip"); window->property_->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_BASE); window->property_->SetPersistentId(1); auto surfaceNode_mocker = CreateRSSurfaceNode(); if (surfaceNode_mocker != nullptr) { ASSERT_NE(nullptr, surfaceNode_mocker); } window->surfaceNode_ = surfaceNode_mocker; auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode != nullptr) { ASSERT_EQ(WMError::WM_OK, window->SetSnapshotSkip(false)); } else { ASSERT_EQ(nullptr, surfaceNode); } } /* * @tc.name: SetLayoutFullScreen * @tc.desc: SetLayoutFullScreen test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreen, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetLayoutFullScreen"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetLayoutFullScreen(false)); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false)); ASSERT_EQ(false, window->IsLayoutFullScreen()); } /* * @tc.name: SetFullScreen * @tc.desc: SetFullScreen test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetFullScreen, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetFullScreen"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetFullScreen(false)); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false)); ASSERT_EQ(false, window->IsFullScreen()); } /* * @tc.name: SetShadowOffsetX * @tc.desc: SetShadowOffsetX test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetShadowOffsetX, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetKeepScreenOn"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); } else { ASSERT_EQ(WMError::WM_OK, window->SetShadowOffsetX(1.0)); } } /* * @tc.name: SetShadowOffsetY * @tc.desc: SetShadowOffsetY test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetShadowOffsetY, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetShadowOffsetY"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); } else { ASSERT_EQ(WMError::WM_OK, window->SetShadowOffsetY(1.0)); } } /* * @tc.name: SetBackdropBlur * @tc.desc: SetBackdropBlur test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetBackdropBlur, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetBackdropBlur"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); } else { ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBackdropBlur(-1.0)); ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlur(1.0)); } } /* * @tc.name: SetShadowColor * @tc.desc: SetShadowColor test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetShadowColor, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetShadowColor"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); }else { ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetShadowColor("111ff22ee44")); ASSERT_EQ(WMError::WM_OK, window->SetShadowColor("#ff22ee44")); ASSERT_EQ(WMError::WM_OK, window->SetShadowColor("#000999")); } } /* * @tc.name: SetCornerRadius * @tc.desc: SetCornerRadius test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetCornerRadius, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetCornerRadius"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetCornerRadius(1.0)); } else { ASSERT_EQ(WMError::WM_OK, window->SetCornerRadius(1.0)); } } /* * @tc.name: SetShadowRadius * @tc.desc: SetShadowRadius test * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetShadowRadius, Function | SmallTest | Level3) { sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetShadowRadius"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); auto surfaceNode = window->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission()); } else { ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetShadowRadius(-1.0)); ASSERT_EQ(WMError::WM_OK, window->SetShadowRadius(1.0)); } } /** * @tc.name: SetTransform01 * @tc.desc: set transform * @tc.type: FUNC * @tc.require:issueI7IJVV */ HWTEST_F(WindowSceneSessionImplTest, SetTransform01, Function | SmallTest | Level3) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); option->SetWindowName("SetTransform01"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); window->property_->SetPersistentId(1); Transform trans_; window->SetTransform(trans_); ASSERT_TRUE(trans_ == window->GetTransform()); ASSERT_EQ(WMError::WM_OK, window->Destroy(false)); } /** * @tc.name: RegisterAnimationTransitionController01 * @tc.desc: RegisterAnimationTransitionController * @tc.type: FUNC * @tc.require:issueI7IJVV */ HWTEST_F(WindowSceneSessionImplTest, RegisterAnimationTransitionController01, Function | SmallTest | Level3) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); option->SetWindowName("RegisterAnimationTransitionController01"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); window->property_->SetPersistentId(1); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->RegisterAnimationTransitionController(nullptr)); } /** * @tc.name: SetNeedDefaultAnimation01 * @tc.desc: SetNeedDefaultAnimation * @tc.type: FUNC * @tc.require:issueI7IJVV */ HWTEST_F(WindowSceneSessionImplTest, SetNeedDefaultAnimation01, Function | SmallTest | Level3) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); option->SetWindowName("SetNeedDefaultAnimation01"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); auto ret = true; window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; window->SetNeedDefaultAnimation(false); ASSERT_TRUE(ret); } /** * @tc.desc: UpdateSurfaceNodeAfterCustomAnimation01 * @tc.desc: UpdateSurfaceNodeAfterCustomAnimation * @tc.type: FUNC * @tc.require:issueI7IJVV */ HWTEST_F(WindowSceneSessionImplTest, UpdateSurfaceNodeAfterCustomAnimation, Function | SmallTest | Level3) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); option->SetWindowName("UpdateSurfaceNodeAfterCustomAnimation"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); window->property_->SetPersistentId(1); window->UpdateSurfaceNodeAfterCustomAnimation(false); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->UpdateSurfaceNodeAfterCustomAnimation(false)); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, window->UpdateSurfaceNodeAfterCustomAnimation(false)); } /** * @tc.name: SetAlpha01 * @tc.desc: SetAlpha * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetAlpha01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("SetAlpha01"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->property_->SetPersistentId(11); windowscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowscenesession->SetAlpha(1.0)); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); ASSERT_EQ(WMError::WM_OK, windowscenesession->Create(abilityContext_, session)); windowscenesession->hostSession_ = session; auto surfaceNode = windowscenesession->GetSurfaceNode(); if (surfaceNode == nullptr) { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscenesession->CheckParmAndPermission()); } else { ASSERT_EQ(WMError::WM_OK, windowscenesession->SetAlpha(1.0)); } } /** * @tc.name: DestroySubWindow01 * @tc.desc: DestroySubWindow * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, DestroySubWindow01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DestroySubWindow"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); int ret = 0; windowscenesession->DestroySubWindow(); ASSERT_EQ(0, ret); } /** * @tc.name: UpdateFloatingWindowSizeBySizeLimits01 * @tc.desc: UpdateFloatingWindowSizeBySizeLimits * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, UpdateFloatingWindowSizeBySizeLimits01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DestroySubWindow"); option->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); int ret = 0; windowscenesession->UpdateFloatingWindowSizeBySizeLimits(MaxWith, MaxWith); ASSERT_EQ(0, ret); } /** * @tc.name: UpdateAnimationFlagProperty01 * @tc.desc: UpdateAnimationFlagProperty * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, UpdateAnimationFlagProperty01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DestroySubWindow"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowscenesession->UpdateAnimationFlagProperty(false)); } /** * @tc.name: UpdateWindowModeImmediately01 * @tc.desc: UpdateWindowModeImmediately * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, UpdateWindowModeImmediately01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DestroySubWindow"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); ASSERT_EQ(WMError::WM_OK, windowscenesession->UpdateWindowModeImmediately(WindowMode::WINDOW_MODE_UNDEFINED)); windowscenesession->state_ = WindowState::STATE_CREATED; ASSERT_EQ(WMError::WM_OK, windowscenesession->UpdateWindowModeImmediately(WindowMode::WINDOW_MODE_UNDEFINED)); } /** * @tc.name: UpdateWindowMode01 * @tc.desc: UpdateWindowMode * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, UpdateWindowMode01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DestroySubWindow"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, windowscenesession->UpdateWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); windowscenesession->state_ = WindowState::STATE_CREATED; ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, windowscenesession->UpdateWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, windowscenesession->UpdateWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); } /** * @tc.name: RemoveWindowFlag01 * @tc.desc: RemoveWindowFlag * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, RemoveWindowFlag01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DestroySubWindow"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowscenesession->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID)); windowscenesession->state_ = WindowState::STATE_CREATED; ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowscenesession->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID)); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); windowscenesession->hostSession_ = session; ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowscenesession->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID)); } /** * @tc.name: GetConfigurationFromAbilityInfo01 * @tc.desc: GetConfigurationFromAbilityInfo * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, GetConfigurationFromAbilityInfo01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("GetConfigurationFromAbilityInfo"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); int ret = 0; windowscenesession->GetConfigurationFromAbilityInfo(); ASSERT_EQ(ret, 0); } /** * @tc.name: PreProcessCreate01 * @tc.desc: PreProcessCreate * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, PreProcessCreate01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("PreProcessCreate"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); int ret = 0; windowscenesession->PreProcessCreate(); ASSERT_EQ(ret, 0); } /** * @tc.name: SetDefaultProperty01 * @tc.desc: SetDefaultProperty * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetDefaultProperty01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("PreProcessCreate"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); int ret = 0; windowscenesession->SetDefaultProperty(); ASSERT_EQ(ret, 0); } /** * @tc.name: UpdateConfiguration01 * @tc.desc: UpdateConfiguration * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, UpdateConfiguration01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("PreProcessCreate"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); int ret = 0; std::shared_ptr configuration; windowscenesession->UpdateConfiguration(configuration); windowscenesession->uiContent_ = std::make_unique(); windowscenesession->UpdateConfiguration(configuration); ASSERT_EQ(ret, 0); } /** * @tc.name: UpdateConfigurationForAll01 * @tc.desc: UpdateConfigurationForAll * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, UpdateConfigurationForAll01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("UpdateConfigurationForAll"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); int ret = 0; std::shared_ptr configuration; windowscenesession->UpdateConfigurationForAll(configuration); ASSERT_EQ(ret, 0); } /** * @tc.name: GetTopWindowWithContext01 * @tc.desc: GetTopWindowWithContext * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, GetTopWindowWithContext01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("GetTopWindowWithContext"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); std::shared_ptr context; sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); if (windowscenesession->GetTopWindowWithContext(context) == nullptr) { ASSERT_EQ(nullptr, windowscenesession->GetTopWindowWithContext(context)); } SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); ASSERT_EQ(WMError::WM_OK, windowscenesession->Create(abilityContext_, session)); ASSERT_NE(nullptr, windowscenesession->GetTopWindowWithContext(context)); } /** * @tc.name: NotifyMemoryLevel01 * @tc.desc: NotifyMemoryLevel * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, NotifyMemoryLevel01, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("NotifyMemoryLevel"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); std::shared_ptr configuration; windowscenesession->NotifyMemoryLevel(2); ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscenesession->NotifyMemoryLevel(2)); windowscenesession->uiContent_ = std::make_unique(); ASSERT_EQ(WMError::WM_OK, windowscenesession->NotifyMemoryLevel(2)); } /** * @tc.name: GetSystemSizeLimits01 * @tc.desc: GetSystemSizeLimits * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, GetSystemSizeLimits01, Function | SmallTest | Level2) { constexpr uint32_t minMainWidth = 10; constexpr uint32_t minMainHeight = 20; constexpr uint32_t minSubWidth = 30; constexpr uint32_t minSubHeight = 40; constexpr uint32_t displayWidth = 100; constexpr uint32_t displayHeight = 100; constexpr float displayVpr = 1; sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("GetSystemSizeLimits01"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, windowscenesession); windowscenesession->windowSystemConfig_.miniWidthOfMainWindow_ = minMainWidth; windowscenesession->windowSystemConfig_.miniHeightOfMainWindow_ = minMainHeight; windowscenesession->windowSystemConfig_.miniWidthOfSubWindow_ = minSubWidth; windowscenesession->windowSystemConfig_.miniHeightOfSubWindow_ = minSubHeight; WindowLimits limits = windowscenesession->GetSystemSizeLimits(displayWidth, displayHeight, displayVpr); ASSERT_EQ(limits.minWidth_, minMainWidth); ASSERT_EQ(limits.minHeight_, minMainHeight); windowscenesession->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); limits = windowscenesession->GetSystemSizeLimits(displayWidth, displayHeight, displayVpr); ASSERT_NE(limits.minWidth_, minMainWidth); ASSERT_NE(limits.minHeight_, minMainHeight); } /** * @tc.name: DumpSessionElementInfo * @tc.desc: DumpSessionElementInfo 1: params num * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, DumpSessionElementInfo1, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DumpSessionElementInfo"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); std::vector params; params.push_back("-h"); window->DumpSessionElementInfo(params); window->uiContent_ = std::make_unique(); ASSERT_EQ(WMError::WM_OK, window->NotifyMemoryLevel(2)); delete option; ASSERT_EQ(WMError::WM_OK, window->Destroy(false)); } /** * @tc.name: DumpSessionElementInfo * @tc.desc: DumpSessionElementInfo2 * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, DumpSessionElementInfo2, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DumpSessionElementInfo2"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); std::vector params; params.push_back("-h"); window->DumpSessionElementInfo(params); params.push_back("-s"); window->uiContent_ = std::make_unique(); window->DumpSessionElementInfo(params); ASSERT_EQ(WMError::WM_OK, window->NotifyMemoryLevel(2)); delete option; ASSERT_EQ(WMError::WM_OK, window->Destroy(false)); } /** * @tc.name: DumpSessionElementInfo * @tc.desc: DumpSessionElementInfo3 * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, DumpSessionElementInfo3, Function | SmallTest | Level2) { sptr option = new (std::nothrow) WindowOption(); option->SetWindowName("DumpSessionElementInfo3"); option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); std::vector params; params.push_back("-s"); window->DumpSessionElementInfo(params); window->uiContent_ = std::make_unique(); ASSERT_EQ(WMError::WM_OK, window->NotifyMemoryLevel(2)); delete option; ASSERT_EQ(WMError::WM_OK, window->Destroy(false)); } } } // namespace Rosen } // namespace OHOS