!6188 新增接口-支持设置是否开启沉浸式

Merge pull request !6188 from yanghongnan/master
This commit is contained in:
openharmony_ci 2024-05-13 13:58:12 +00:00 committed by Gitee
commit 22b4c24015
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
14 changed files with 298 additions and 6 deletions

View File

@ -1975,6 +1975,20 @@ public:
* @return WM_OK means set success, others means set failed
*/
virtual WMError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WMError::WM_OK; }
/**
* @brief Set whether to enable immersive mode.
* @param enable the value true means to enable immersive mode, and false means the opposite.
* @return WM_OK means set success, others means set failed.
*/
virtual WMError SetImmersiveModeEnabledState(bool enable) { return WMError::WM_OK; }
/**
* @brief Get whether the immersive mode is enabled or not.
*
* @return true means the immersive mode is enabled, and false means the opposite.
*/
virtual bool GetImmersiveModeEnabledState() const { return true; }
};
}
}

View File

@ -825,6 +825,20 @@ napi_value JsWindow::SetWindowGrayScale(napi_env env, napi_callback_info info)
return (me != nullptr) ? me->OnSetWindowGrayScale(env, info) : nullptr;
}
napi_value JsWindow::SetImmersiveModeEnabledState(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]SetImmersiveModeEnabledState");
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
return (me != nullptr) ? me->OnSetImmersiveModeEnabledState(env, info) : nullptr;
}
napi_value JsWindow::GetImmersiveModeEnabledState(napi_env env, napi_callback_info info)
{
TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]GetImmersiveModeEnabledState");
JsWindow* me = CheckParamsAndGetThis<JsWindow>(env, info);
return (me != nullptr) ? me->OnGetImmersiveModeEnabledState(env, info) : nullptr;
}
static void UpdateSystemBarProperties(std::map<WindowType, SystemBarProperty>& systemBarProperties,
const std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, sptr<Window> windowToken)
{
@ -5759,6 +5773,60 @@ napi_value JsWindow::OnSetWindowGrayScale(napi_env env, napi_callback_info info)
return result;
}
napi_value JsWindow::OnSetImmersiveModeEnabledState(napi_env env, napi_callback_info info)
{
size_t argc = 4;
napi_value argv[4] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != 1) {
TLOGW(WmsLogTag::WMS_IMMS, "Argc is invalid: %{public}zu", argc);
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
if (windowToken_ == nullptr) {
TLOGE(WmsLogTag::WMS_IMMS, "windowToken_ is nullptr");
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
if (!WindowHelper::IsMainWindow(windowToken_->GetType()) &&
!WindowHelper::IsSubWindow(windowToken_->GetType())) {
TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]OnSetImmersiveModeEnabledState is not allowed since invalid window type");
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING);
}
napi_value nativeVal = argv[0];
if (nativeVal == nullptr) {
TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to enable");
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
}
bool enable = true;
napi_get_value_bool(env, nativeVal, &enable);
TLOGI(WmsLogTag::WMS_IMMS, "[NAPI]OnSetImmersiveModeEnabledState to %{public}d", static_cast<int32_t>(enable));
WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetImmersiveModeEnabledState(enable));
if (ret != WmErrorCode::WM_OK) {
TLOGE(WmsLogTag::WMS_IMMS, "Window immersive mode set enabled failed, ret = %{public}d", ret);
return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY);
}
TLOGI(WmsLogTag::WMS_IMMS, "window [%{public}u, %{public}s] OnSetImmersiveModeEnabledState end",
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
return NapiGetUndefined(env);
}
napi_value JsWindow::OnGetImmersiveModeEnabledState(napi_env env, napi_callback_info info)
{
if (windowToken_ == nullptr) {
TLOGE(WmsLogTag::WMS_IMMS, "windowToken_ is nullptr");
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
}
if (!WindowHelper::IsMainWindow(windowToken_->GetType()) &&
!WindowHelper::IsSubWindow(windowToken_->GetType())) {
TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]OnGetImmersiveModeEnabledState is not allowed since invalid window type");
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING);
}
bool isEnabled = windowToken_->GetImmersiveModeEnabledState();
TLOGI(WmsLogTag::WMS_IMMS, "window [%{public}u, %{public}s] get isImmersiveMode end, isEnabled = %{public}u",
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isEnabled);
return CreateJsValue(env, isEnabled);
}
void BindFunctions(napi_env env, napi_value object, const char *moduleName)
{
BindNativeFunction(env, object, "show", moduleName, JsWindow::Show);
@ -5868,6 +5936,8 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName)
BindNativeFunction(env, object, "setTitleButtonVisible", moduleName, JsWindow::SetTitleButtonVisible);
BindNativeFunction(env, object, "setWindowMask", moduleName, JsWindow::SetWindowMask);
BindNativeFunction(env, object, "setWindowGrayScale", moduleName, JsWindow::SetWindowGrayScale);
BindNativeFunction(env, object, "setImmersiveModeEnabledState", moduleName, JsWindow::SetImmersiveModeEnabledState);
BindNativeFunction(env, object, "getImmersiveModeEnabledState", moduleName, JsWindow::GetImmersiveModeEnabledState);
}
} // namespace Rosen
} // namespace OHOS

View File

@ -152,6 +152,8 @@ public:
static napi_value SetTitleButtonVisible(napi_env env, napi_callback_info info);
static napi_value SetWindowMask(napi_env env, napi_callback_info info);
static napi_value SetWindowGrayScale(napi_env env, napi_callback_info info);
static napi_value SetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
static napi_value GetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
private:
std::string GetWindowName();
@ -214,6 +216,8 @@ private:
napi_value OnGetWindowDecorHeight(napi_env env, napi_callback_info info);
napi_value OnGetTitleButtonRect(napi_env env, napi_callback_info info);
napi_value OnSetTitleButtonVisible(napi_env env, napi_callback_info info);
napi_value OnSetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
napi_value OnGetImmersiveModeEnabledState(napi_env env, napi_callback_info info);
// colorspace, gamut
napi_value OnIsSupportWideGamut(napi_env env, napi_callback_info info);

View File

@ -329,6 +329,10 @@ public:
}
virtual WMError SetGrayScale(float grayScale) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
virtual WMError SetImmersiveModeEnabledState(bool enable) { return WMError::WM_OK; }
virtual bool GetImmersiveModeEnabledState() const { return true; }
};
}
}

View File

@ -217,6 +217,8 @@ public:
virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) override;
virtual WMError SetSingleFrameComposerEnabled(bool enable) override;
virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override;
virtual WMError SetImmersiveModeEnabledState(bool enable) override;
virtual bool GetImmersiveModeEnabledState() const override;
private:
static std::map<std::string, std::pair<uint32_t, sptr<Window>>> windowMap_;

View File

@ -900,5 +900,15 @@ WMError WindowImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetImmersiveModeEnabledState(bool enable)
{
return WMError::WM_OK;
}
bool WindowImpl::GetImmersiveModeEnabledState() const
{
return true;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -510,6 +510,9 @@ void CheckWindowImplFunctionsPart4(sptr<WindowImpl> window, const uint8_t* data,
window->SetNeedRemoveWindowInputChannel(boolVal);
window->SetRequestedOrientation(static_cast<Orientation>(data[0]));
startPos += GetObject(boolVal, data + startPos, size - startPos);
window->SetImmersiveModeEnabledState(boolVal);
std::vector<OHOS::Rosen::Rect> rectVector;
OHOS::Rosen::Rect rect;
startPos += GetObject(rect, data + startPos, size - startPos);

View File

@ -203,6 +203,8 @@ public:
virtual void StartMove() override;
virtual WMError SetGlobalMaximizeMode(MaximizeMode mode) override;
virtual MaximizeMode GetGlobalMaximizeMode() const override;
virtual WMError SetImmersiveModeEnabledState(bool enable) override;
virtual bool GetImmersiveModeEnabledState() const override;
virtual WMError RequestFocus() const override;
virtual void SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer) override;
@ -601,6 +603,7 @@ private:
static std::map<uint32_t, std::vector<sptr<WindowImpl>>> subWindowMap_;
static std::map<uint32_t, std::vector<sptr<WindowImpl>>> appFloatingWindowMap_;
static std::map<uint32_t, std::vector<sptr<WindowImpl>>> appDialogWindowMap_;
static bool enableImmersiveMode_;
sptr<WindowProperty> property_;
WindowState state_ { WindowState::STATE_INITIAL };
WindowState subWindowState_ {WindowState::STATE_INITIAL};

View File

@ -151,6 +151,8 @@ public:
void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) override;
void UpdateDensity() override;
WMError AdjustKeyboardLayout(const KeyboardLayoutParams& params) override;
virtual WMError SetImmersiveModeEnabledState(bool enable) override;
virtual bool GetImmersiveModeEnabledState() const override;
protected:
void DestroySubWindow();
@ -180,6 +182,7 @@ private:
bool IsValidSystemWindowType(const WindowType& type);
WMError CheckParmAndPermission();
static uint32_t maxFloatingWindowSize_;
static bool enableImmersiveMode_;
void TransformSurfaceNode(const Transform& trans);
void AdjustWindowAnimationFlag(bool withAnimation = false);
void RegisterSessionRecoverListener(bool isSpecificSession);

View File

@ -74,6 +74,7 @@ std::map<uint32_t, sptr<IDialogDeathRecipientListener>> WindowImpl::dialogDeathR
std::recursive_mutex WindowImpl::globalMutex_;
int g_constructorCnt = 0;
int g_deConstructorCnt = 0;
bool WindowImpl::enableImmersiveMode_ = true;
WindowImpl::WindowImpl(const sptr<WindowOption>& option)
{
property_ = new (std::nothrow) WindowProperty();
@ -872,6 +873,7 @@ WMError WindowImpl::SetLayoutFullScreen(bool status)
}
}
}
enableImmersiveMode_ = status;
return ret;
}
@ -2023,6 +2025,34 @@ MaximizeMode WindowImpl::GetGlobalMaximizeMode() const
return SingletonContainer::Get<WindowAdapter>().GetMaximizeMode();
}
WMError WindowImpl::SetImmersiveModeEnabledState(bool enable)
{
TLOGD(WmsLogTag::WMS_IMMS, "WindowImpl id: %{public}u SetImmersiveModeEnabledState: %{public}u",
property_->GetWindowId(), static_cast<uint32_t>(enable));
if (!IsWindowValid() ||
!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
TLOGE(WmsLogTag::WMS_IMMS, "invalid window or fullscreen mode is not be supported, winId:%{public}u",
property_->GetWindowId());
return WMError::WM_ERROR_INVALID_WINDOW;
}
const WindowType curWindowType = GetType();
if (!WindowHelper::IsMainWindow(curWindowType) && !WindowHelper::IsSubWindow(curWindowType)) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
enableImmersiveMode_ = enable;
const WindowMode mode = GetMode();
if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) {
return SetLayoutFullScreen(enableImmersiveMode_);
}
return WMError::WM_OK;
}
bool WindowImpl::GetImmersiveModeEnabledState() const
{
return enableImmersiveMode_;
}
WMError WindowImpl::NotifyWindowTransition(TransitionReason reason)
{
sptr<WindowTransitionInfo> fromInfo = new(std::nothrow) WindowTransitionInfo();

View File

@ -77,6 +77,7 @@ constexpr float MAX_GRAY_SCALE = 1.0f;
}
uint32_t WindowSceneSessionImpl::maxFloatingWindowSize_ = 1920;
std::mutex WindowSceneSessionImpl::keyboardPanelInfoChangeListenerMutex_;
bool WindowSceneSessionImpl::enableImmersiveMode_ = true;
WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr<WindowOption>& option) : WindowSessionImpl(option)
{
@ -1570,7 +1571,7 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status)
}
bool preStatus = property_->IsLayoutFullScreen();
property_->SetIsLayoutFullScreen(status);
property_->SetIsLayoutFullScreen(true);
UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE);
if (WindowHelper::IsMainWindow(GetType()) &&
@ -1594,7 +1595,7 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status)
TLOGE(WmsLogTag::WMS_IMMS, "SetLayoutFullScreenByApiVersion errCode:%{public}d winId:%{public}u",
static_cast<int32_t>(ret), GetWindowId());
}
enableImmersiveMode_ = status;
return ret;
}
@ -1784,7 +1785,7 @@ WMError WindowSceneSessionImpl::Maximize()
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (WindowHelper::IsMainWindow(GetType())) {
SetFullScreen(true);
SetLayoutFullScreen(enableImmersiveMode_);
}
return WMError::WM_OK;
}
@ -1802,8 +1803,7 @@ WMError WindowSceneSessionImpl::Maximize(MaximizeLayoutOption option)
if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
property_->SetIsLayoutFullScreen(option.decor == ShowType::HIDE);
return SetFullScreen(true);
return SetLayoutFullScreen(enableImmersiveMode_);
}
WMError WindowSceneSessionImpl::MaximizeFloating()
@ -1822,7 +1822,7 @@ WMError WindowSceneSessionImpl::MaximizeFloating()
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (GetGlobalMaximizeMode() != MaximizeMode::MODE_AVOID_SYSTEM_BAR) {
SetFullScreen(true);
SetLayoutFullScreen(enableImmersiveMode_);
property_->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL);
} else {
hostSession_->OnSessionEvent(SessionEvent::EVENT_MAXIMIZE_FLOATING);
@ -3317,5 +3317,34 @@ WMError WindowSceneSessionImpl::AdjustKeyboardLayout(const KeyboardLayoutParams&
}
return WMError::WM_OK;
}
WMError WindowSceneSessionImpl::SetImmersiveModeEnabledState(bool enable)
{
TLOGD(WmsLogTag::WMS_IMMS, "id: %{public}u, SetImmersiveModeEnabledState: %{public}u", GetWindowId(), enable);
if (hostSession_ == nullptr) {
return WMError::WM_ERROR_NULLPTR;
}
if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
const WindowType curWindowType = GetType();
if (!WindowHelper::IsMainWindow(curWindowType) && !WindowHelper::IsSubWindow(curWindowType)) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
enableImmersiveMode_ = enable;
WindowMode mode = GetMode();
if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) {
return SetLayoutFullScreen(enableImmersiveMode_);
}
return WMError::WM_OK;
}
bool WindowSceneSessionImpl::GetImmersiveModeEnabledState() const
{
TLOGD(WmsLogTag::WMS_IMMS, "id: %{public}u GetImmersiveModeEnabledState = %{public}u",
GetWindowId(), enableImmersiveMode_);
return enableImmersiveMode_;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -2303,6 +2303,67 @@ HWTEST_F(WindowImplTest, SetLayoutFullScreen, Function | SmallTest | Level3)
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/*
* @tc.name: SetImmersiveModeEnabledState
* @tc.desc: SetImmersiveModeEnabledState test
* @tc.type: FUNC
*/
HWTEST_F(WindowImplTest, SetImmersiveModeEnabledState, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new WindowOption();
option->SetWindowName("SetImmersiveModeEnabledState");
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
sptr<WindowImpl> window = new WindowImpl(option);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetWindowFlags(0));
EXPECT_CALL(m->Mock(), GetSystemConfig(_)).WillOnce(Return(WMError::WM_OK));
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID));
window->UpdateModeSupportInfo(0);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(true));
window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Show());
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_DO_NOTHING));
ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetImmersiveModeEnabledState(true));
window->property_->SetWindowFlags(window->property_->GetWindowFlags() |
(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2)
.WillOnce(Return(WMError::WM_OK))
.WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true));
ASSERT_EQ(true, window->GetImmersiveModeEnabledState());
window->property_->SetWindowFlags(window->property_->GetWindowFlags() |
(static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2)
.WillOnce(Return(WMError::WM_OK))
.WillOnce(Return(WMError::WM_DO_NOTHING));
ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetImmersiveModeEnabledState(true));
window->property_->SetWindowFlags(window->property_->GetWindowFlags() &
(~static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2)
.WillOnce(Return(WMError::WM_OK))
.WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(false));
ASSERT_EQ(false, window->GetImmersiveModeEnabledState());
window->property_->SetWindowFlags(window->property_->GetWindowFlags() &
(~static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_NEED_AVOID)));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2)
.WillOnce(Return(WMError::WM_OK))
.WillOnce(Return(WMError::WM_DO_NOTHING));
ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetImmersiveModeEnabledState(false));
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/*
* @tc.name: SetFullScreen
* @tc.desc: SetFullScreen test

View File

@ -1514,6 +1514,51 @@ HWTEST_F(WindowSceneSessionImplTest, SetSnapshotSkip, Function | SmallTest | Lev
}
}
/*
* @tc.name: SetImmersiveModeEnabledState
* @tc.desc: SetImmersiveModeEnabledState test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetImmersiveModeEnabledState, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetImmersiveModeEnabledState(false));
window->property_->SetPersistentId(1);
SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->hostSession_ = session;
window->property_->SetWindowName("SetImmersiveModeEnabledState");
window->property_->SetWindowType(WindowType::WINDOW_TYPE_PIP);
window->state_ = WindowState::STATE_CREATED;
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(false));
window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true));
ASSERT_EQ(true, window->GetImmersiveModeEnabledState());
ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(false));
ASSERT_EQ(false, window->GetImmersiveModeEnabledState());
window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true));
ASSERT_EQ(true, window->IsLayoutFullScreen());
ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false));
ASSERT_EQ(false, window->IsLayoutFullScreen());
ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true));
ASSERT_EQ(true, window->IsLayoutFullScreen());
ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(false));
ASSERT_EQ(false, window->IsLayoutFullScreen());
window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true));
ASSERT_EQ(false, window->IsLayoutFullScreen());
ASSERT_EQ(true, window->GetImmersiveModeEnabledState());
ASSERT_EQ(WMError::WM_OK, window->MaximizeFloating());
ASSERT_EQ(true, window->IsLayoutFullScreen());
}
/*
* @tc.name: SetLayoutFullScreen
* @tc.desc: SetLayoutFullScreen test

View File

@ -424,6 +424,20 @@ HWTEST_F(WindowTest, GetAvoidAreaByType, Function | SmallTest | Level2)
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: SetImmersiveModeEnabledState
* @tc.desc: get
* @tc.type: FUNC
*/
HWTEST_F(WindowTest, SetImmersiveModeEnabledState, Function | SmallTest | Level2)
{
sptr<Window> window = new Window();
ASSERT_NE(nullptr, window);
auto ret = window->SetImmersiveModeEnabledState(true);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: SetLayoutFullScreen
* @tc.desc: get