diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 6a9fca35b8219c7ffe9f51e5b56b30f2745948e8..80213deefca8ef86fc5bb837415bb8e65f4b2a6d 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -48,6 +48,7 @@ group("unittest") { ":wm_window_inspector_test", ":wm_window_manager_agent_proxy_test", ":wm_window_manager_stub_proxy_test", + ":wm_window_option_new_test", ":wm_window_option_test", ":wm_window_scene_effect_test", ":wm_window_scene_test", @@ -366,6 +367,16 @@ ohos_unittest("wm_window_option_test") { external_deps = test_external_deps } +ohos_unittest("wm_window_option_new_test") { + module_out_path = module_out_path + + sources = [ "window_option_new_test.cpp" ] + + deps = [ ":wm_unittest_common" ] + + external_deps = test_external_deps +} + ohos_unittest("wm_window_scene_test") { module_out_path = module_out_path diff --git a/wm/test/unittest/window_option_new_test.cpp b/wm/test/unittest/window_option_new_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d689bad9091a59caa14b272e1bf8e4692eea1c49 --- /dev/null +++ b/wm/test/unittest/window_option_new_test.cpp @@ -0,0 +1,694 @@ +/* + * Copyright (c) 2021 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 "window_option.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +namespace { +const SystemBarProperty SYS_BAR_PROP_DEFAULT; +const SystemBarProperty SYS_BAR_PROP_1(true, 0xE5111111, 0xE5222222); +const SystemBarProperty SYS_BAR_PROP_2(false, 0xE5222222, 0xE5333333); +const std::unordered_map& SYS_BAR_PROPS_TEST = { + { WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP_1 }, + { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SYS_BAR_PROP_2 }, +}; +const std::unordered_map& SYS_BAR_PROPS_DEFAULT = { + { WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP_DEFAULT }, + { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SYS_BAR_PROP_DEFAULT }, +}; +} // namespace +class WindowOptionNewTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + virtual void SetUp() override; + virtual void TearDown() override; +}; +void WindowOptionNewTest::SetUpTestCase() {} + +void WindowOptionNewTest::TearDownTestCase() {} + +void WindowOptionNewTest::SetUp() {} + +void WindowOptionNewTest::TearDown() {} + +namespace { +/** + * @tc.name: WindowRect01 + * @tc.desc: SetWindowRect/GetWindowRect + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowRect01, TestSize.Level1) +{ + sptr option = new WindowOption(); + struct Rect rect = { 1, 2, 3u, 4u }; + option->SetWindowRect(rect); + + EXPECT_EQ(1, option->GetWindowRect().posX_); + EXPECT_EQ(2, option->GetWindowRect().posY_); + EXPECT_EQ(3u, option->GetWindowRect().width_); + EXPECT_EQ(4u, option->GetWindowRect().height_); +} + +/** + * @tc.name: WindowType01 + * @tc.desc: SetWindowType/GetWindowType + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowType01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, option->GetWindowType()); +} + +/** + * @tc.name: WindowMode01 + * @tc.desc: SetWindowMode/GetWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowMode01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + EXPECT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, option->GetWindowMode()); +} + +/** + * @tc.name: WindowMode02 + * @tc.desc: SetWindowMode/GetWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowMode02, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); + EXPECT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, option->GetWindowMode()); + option->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); + EXPECT_NE(WindowMode::WINDOW_MODE_UNDEFINED, option->GetWindowMode()); +} + +/** + * @tc.name: WindowMode03 + * @tc.desc: SetWindowMode/GetWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowMode03, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); + EXPECT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, option->GetWindowMode()); +} + +/** + * @tc.name: WindowMode04 + * @tc.desc: SetWindowMode/GetWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowMode04, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); + EXPECT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, option->GetWindowMode()); +} + +/** + * @tc.name: WindowMode05 + * @tc.desc: SetWindowMode/GetWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowMode05, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + EXPECT_EQ(WindowMode::WINDOW_MODE_FLOATING, option->GetWindowMode()); +} + +/** + * @tc.name: WindowMode06 + * @tc.desc: SetWindowMode/GetWindowMode + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowMode06, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); + EXPECT_EQ(WindowMode::WINDOW_MODE_PIP, option->GetWindowMode()); +} + +/** + * @tc.name: Focusable01 + * @tc.desc: SetFocusable/GetFocusable + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Focusable01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetFocusable(true); + EXPECT_EQ(true, option->GetFocusable()); +} + +/** + * @tc.name: Touchable01 + * @tc.desc: SetTouchable/GetTouchable + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Touchable01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetTouchable(true); + EXPECT_EQ(true, option->GetTouchable()); +} + +/** + * @tc.name: DisplayId01 + * @tc.desc: SetDisplayId/GetDisplayId + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, DisplayId01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetDisplayId(1); + EXPECT_EQ(1, option->GetDisplayId()); +} + +/** + * @tc.name: ParentId01 + * @tc.desc: SetParentId/GetParentId + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, ParentId01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetParentId(1); + EXPECT_EQ(1, option->GetParentId()); +} + +/** + * @tc.name: WindowName01 + * @tc.desc: SetWindowName/GetWindowName + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowName01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowName("Sub Window"); + EXPECT_EQ("Sub Window", option->GetWindowName()); +} + +/** + * @tc.name: BundleName01 + * @tc.desc: SetBundleName/GetBundleName + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, BundleName01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetBundleName("settings"); + EXPECT_EQ("settings", option->GetBundleName()); +} + +/** + * @tc.name: WindowFlag01 + * @tc.desc: SetWindowFlags/GetWindowFlags + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowFlag01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowFlags(1u); + EXPECT_EQ(1u, option->GetWindowFlags()); +} + +/** + * @tc.name: WindowFlag02 + * @tc.desc: AddWindowFlag/GetWindowFlags + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowFlag02, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID); + EXPECT_EQ(static_cast(WindowFlag::WINDOW_FLAG_NEED_AVOID), option->GetWindowFlags()); +} + +/** + * @tc.name: WindowFlag03 + * @tc.desc: AddWindowFlag/RemoveWindowFlag/GetWindowFlags + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, WindowFlag03, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID); + EXPECT_EQ(static_cast(WindowFlag::WINDOW_FLAG_NEED_AVOID), option->GetWindowFlags()); + + option->AddWindowFlag(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); + option->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID); + EXPECT_EQ(static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT), option->GetWindowFlags()); +} + +/** + * @tc.name: SetGetSystemBarProperty01 + * @tc.desc: SetSystemBarProperty with test param and get + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetGetSystemBarProperty01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP_1); + option->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, SYS_BAR_PROP_2); + EXPECT_EQ(SYS_BAR_PROPS_TEST, option->GetSystemBarProperty()); +} + +/** + * @tc.name: SetGetSystemBarProperty02 + * @tc.desc: SetSystemBarProperty with invalid type and get + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetGetSystemBarProperty02, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetSystemBarProperty(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, SYS_BAR_PROP_1); + option->SetSystemBarProperty(WindowType::WINDOW_TYPE_MEDIA, SYS_BAR_PROP_2); + EXPECT_EQ(SYS_BAR_PROPS_DEFAULT, option->GetSystemBarProperty()); +} + +/** + * @tc.name: SetGetSystemBarProperty03 + * @tc.desc: GetSystemBarProperty with no set + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetGetSystemBarProperty03, TestSize.Level1) +{ + sptr option = new WindowOption(); + EXPECT_EQ(SYS_BAR_PROPS_DEFAULT, option->GetSystemBarProperty()); +} + +/** + * @tc.name: HitOffset + * @tc.desc: HitOffset setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, HitOffset, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetHitOffset(1, 1); + PointInfo point = { 1, 1 }; + EXPECT_EQ(point.x, option->GetHitOffset().x); + EXPECT_EQ(point.y, option->GetHitOffset().y); +} + +/** + * @tc.name: KeepScreenOn + * @tc.desc: KeepScreenOn setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, KeepScreenOn, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetKeepScreenOn(true); + EXPECT_EQ(true, option->IsKeepScreenOn()); + option->SetKeepScreenOn(false); + EXPECT_EQ(false, option->IsKeepScreenOn()); +} + +/** + * @tc.name: viewKeepScreenOn + * @tc.desc: viewKeepScreenOn setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, ViewKeepScreenOn, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetViewKeepScreenOn(true); + EXPECT_EQ(true, option->IsViewKeepScreenOn()); + option->SetViewKeepScreenOn(false); + EXPECT_EQ(false, option->IsViewKeepScreenOn()); +} + +/** + * @tc.name: TurnScreenOn + * @tc.desc: TurnScreenOn setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, TurnScreenOn, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetTurnScreenOn(true); + EXPECT_EQ(true, option->IsTurnScreenOn()); + option->SetTurnScreenOn(false); + EXPECT_EQ(false, option->IsTurnScreenOn()); +} + +/** + * @tc.name: Brightness + * @tc.desc: Brightness setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Brightness01, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetBrightness(MINIMUM_BRIGHTNESS); + EXPECT_EQ(MINIMUM_BRIGHTNESS, option->GetBrightness()); +} + +/** + * @tc.name: Brightness + * @tc.desc: Brightness setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Brightness02, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetBrightness(MAXIMUM_BRIGHTNESS); + EXPECT_EQ(MAXIMUM_BRIGHTNESS, option->GetBrightness()); +} + +/** + * @tc.name: Brightness + * @tc.desc: Brightness setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Brightness03, TestSize.Level1) +{ + sptr option = new WindowOption(); + float brightness = -0.5; + option->SetBrightness(brightness); + EXPECT_EQ(brightness, option->GetBrightness()); +} + +/** + * @tc.name: Brightness + * @tc.desc: Brightness setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Brightness04, TestSize.Level1) +{ + sptr option = new WindowOption(); + float brightness = 2.0; + option->SetBrightness(brightness); + EXPECT_EQ(brightness, option->GetBrightness()); +} + +/** + * @tc.name: CallingWindow + * @tc.desc: CallingWindow setter/getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, CallingWindow, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetCallingWindow(1); + EXPECT_EQ(1, option->GetCallingWindow()); +} + +/** + * @tc.name: SetAndGetWindowSessionType + * @tc.desc: SetAndGetWindowSessionType fun + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetAndGetWindowSessionType, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowSessionType(WindowSessionType::SCENE_SESSION); + auto res = option->GetWindowSessionType(); + EXPECT_EQ(WindowSessionType::SCENE_SESSION, res); +} + +/** + * @tc.name: GetWindowSessionType + * @tc.desc: GetWindowSessionType fun + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, GetWindowSessionType, TestSize.Level1) +{ + sptr option = new WindowOption(); + option->SetWindowSessionType(WindowSessionType::SCENE_SESSION); + auto res = option->GetWindowSessionType(); + EXPECT_EQ(WindowSessionType::SCENE_SESSION, res); +} + +/** + * @tc.name: Test01 + * @tc.desc: Test01 + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Test01, TestSize.Level1) +{ + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + option->SetIsUIExtFirstSubWindow(true); + option->SetSubWindowTitle("Test"); + std::string ret = option->GetSubWindowTitle(); + EXPECT_EQ(true, ret == "Test"); +} + +/** + * @tc.name: Test02 + * @tc.desc: Test02 + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Test02, TestSize.Level1) +{ + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + option->SetIsUIExtFirstSubWindow(true); + option->SetSubWindowDecorEnable(true); + bool ret1 = option->GetSubWindowDecorEnable(); + EXPECT_EQ(true, ret1); +} + +/** + * @tc.name: Test03 + * @tc.desc: Test03 + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, Test03, TestSize.Level1) +{ + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + option->SetIsUIExtFirstSubWindow(true); + option->SetOnlySupportSceneBoard(true); + bool ret2 = option->GetOnlySupportSceneBoard(); + EXPECT_EQ(true, ret2); +} + +/** + * @tc.name: RealParentId + * @tc.desc: RealParentId setter and getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetRealParentId, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + ASSERT_NE(nullptr, option); + option->SetRealParentId(114); + EXPECT_EQ(114, option->GetRealParentId()); + option->SetRealParentId(514); + EXPECT_EQ(514, option->GetRealParentId()); +} + +/** + * @tc.name: SetParentWindowType + * @tc.desc: SetParentWindowType setter and getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetParentWindowType, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + ASSERT_NE(nullptr, option); + option->SetParentWindowType(WindowType::WINDOW_TYPE_TOAST); + EXPECT_EQ(WindowType::WINDOW_TYPE_TOAST, option->GetParentWindowType()); + option->SetParentWindowType(WindowType::WINDOW_TYPE_APP_COMPONENT); + EXPECT_EQ(WindowType::WINDOW_TYPE_APP_COMPONENT, option->GetParentWindowType()); +} + +/** + * @tc.name: UIExtensionUsage + * @tc.desc: UIExtensionUsage setter and getter test + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetUIExtensionUsage, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + ASSERT_NE(nullptr, option); + option->SetUIExtensionUsage(0); + EXPECT_EQ(0, option->GetUIExtensionUsage()); + option->SetUIExtensionUsage(1); + EXPECT_EQ(1, option->GetUIExtensionUsage()); + option->SetUIExtensionUsage(static_cast(UIExtensionUsage::UIEXTENSION_USAGE_END)); + EXPECT_EQ(static_cast(UIExtensionUsage::EMBEDDED), option->GetUIExtensionUsage()); +} + +/** + * @tc.name: SetDialogDecorEnable + * @tc.desc: SetDialogDecorEnable + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetDialogDecorEnable, TestSize.Level1) +{ + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + option->SetDialogDecorEnable(true); + EXPECT_EQ(true, option->GetDialogDecorEnable()); + option->SetDialogDecorEnable(false); + EXPECT_EQ(false, option->GetDialogDecorEnable()); +} + +/** + * @tc.name: SetDialogTitle + * @tc.desc: SetDialogTitle + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetDialogTitle, TestSize.Level1) +{ + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + option->SetDialogTitle("Test"); + std::string ret = option->GetDialogTitle(); + EXPECT_EQ(true, ret == "Test"); +} + +/** + * @tc.name: SetWindowTopmost + * @tc.desc: SetWindowTopmost + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetWindowTopmost, TestSize.Level1) +{ + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + option->SetWindowTopmost(true); + EXPECT_EQ(true, option->GetWindowTopmost()); + option->SetWindowTopmost(false); + EXPECT_EQ(false, option->GetWindowTopmost()); +} + +/** + * @tc.name: SetAndIsSystemKeyboard + * @tc.desc: test SetIsSystemKeyboard and IsSystemKeyboard + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetAndIsSystemKeyboard, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + EXPECT_EQ(false, option->IsSystemKeyboard()); + option->SetIsSystemKeyboard(true); + EXPECT_EQ(true, option->IsSystemKeyboard()); +} + +/** + * @tc.name: SetDensity + * @tc.desc: test SetDensity and GetDensity + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetDensity, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + ASSERT_NE(nullptr, option); + EXPECT_EQ(1.0f, option->GetDensity()); + float density = 5.0f; + option->SetDensity(density); + EXPECT_EQ(density, option->GetDensity()); +} + +/** + * @tc.name: SetIsDensityFollowHost + * @tc.desc: test SetIsDensityFollowHost and GetIsDensityFollowHost + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetIsDensityFollowHost, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + ASSERT_NE(nullptr, option); + EXPECT_EQ(false, option->GetIsDensityFollowHost()); + option->SetIsDensityFollowHost(true); + EXPECT_EQ(true, option->GetIsDensityFollowHost()); +} + +/** + * @tc.name: SetDefaultDensityEnabled + * @tc.desc: test SetIsDensityFollowHost and IsDefaultDensityEnabled + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetDefaultDensityEnabled, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + ASSERT_NE(nullptr, option); + EXPECT_EQ(false, option->IsDefaultDensityEnabled()); + option->SetDefaultDensityEnabled(true); + EXPECT_EQ(true, option->IsDefaultDensityEnabled()); +} + +/** + * @tc.name: SetSubWindowZLevel + * @tc.desc: test SetSubWindowZLevel + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetSubWindowZLevel, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetSubWindowZLevel(1); + EXPECT_EQ(1, option->zLevel_); +} + +/** + * @tc.name: GetSubWindowZLevel + * @tc.desc: test GetSubWindowZLevel + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, GetSubWindowZLevel, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->zLevel_ = 1; + EXPECT_EQ(1, option->GetSubWindowZLevel()); +} + +/** + * @tc.name: SetZIndex + * @tc.desc: test SetZIndex + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetZIndex, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetZIndex(0); + EXPECT_EQ(0, option->GetZIndex()); +} + +/** + * @tc.name: SetConstrainedModal + * @tc.desc: test SetConstrainedModal and GetIsDensityFollowHost + * @tc.type: FUNC + */ +HWTEST_F(WindowOptionNewTest, SetConstrainedModal, TestSize.Level1) +{ + sptr option = sptr::MakeSptr(); + EXPECT_EQ(false, option->IsConstrainedModal()); + option->SetConstrainedModal(true); + EXPECT_EQ(false, option->IsConstrainedModal()); + option->SetUIExtensionUsage(static_cast(UIExtensionUsage::MODAL)); + option->SetConstrainedModal(true); + EXPECT_EQ(true, option->IsConstrainedModal()); +} +} // namespace +} // namespace Rosen +} // namespace OHOS