From 4a8da435ed033fe3a04a607aed2ba2c27d0a101b Mon Sep 17 00:00:00 2001 From: qianlf Date: Tue, 21 Jun 2022 11:16:49 +0800 Subject: [PATCH] Add camera floating window type and test Signed-off-by: qianlf Change-Id: I272890078a0aad4abdb585202753df586c94097a --- interfaces/innerkits/wm/wm_common.h | 1 + .../window_manager_napi/js_window_manager.cpp | 4 +- .../window_napi/js_window_utils.cpp | 2 + .../window_napi/js_window_utils.h | 5 +- utils/include/window_helper.h | 5 + wm/include/window_impl.h | 1 + wm/src/window_impl.cpp | 29 +- wm/test/systemtest/BUILD.gn | 13 + .../window_app_floating_window_test.cpp | 312 ++++++++++++++++++ wmserver/include/window_zorder_policy.h | 1 + wmserver/src/window_layout_policy.cpp | 3 +- 11 files changed, 369 insertions(+), 7 deletions(-) create mode 100644 wm/test/systemtest/window_app_floating_window_test.cpp diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 3c36a3ea..82912f9b 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -59,6 +59,7 @@ enum class WindowType : uint32_t { WINDOW_TYPE_BOOT_ANIMATION, WINDOW_TYPE_FREEZE_DISPLAY, WINDOW_TYPE_VOICE_INTERACTION, + WINDOW_TYPE_FLOAT_CAMERA, ABOVE_APP_SYSTEM_WINDOW_END, SYSTEM_WINDOW_END = ABOVE_APP_SYSTEM_WINDOW_END, }; diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index a65777c4..e0e4e4c6 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -166,7 +166,7 @@ static void CreateSystemWindowTask(void* contextPtr, std::string windowName, Win WLOGFE("[NAPI]Context is nullptr"); return; } - if (winType == WindowType::WINDOW_TYPE_FLOAT) { + if (winType == WindowType::WINDOW_TYPE_FLOAT || winType == WindowType::WINDOW_TYPE_FLOAT_CAMERA) { auto abilityContext = Context::ConvertTo(context->lock()); if (abilityContext != nullptr) { if (!CheckCallingPermission("ohos.permission.SYSTEM_FLOAT_WINDOW")) { @@ -538,7 +538,7 @@ NativeValue* JsWindowManager::OnSetWindowLayoutMode(NativeEngine& engine, Native if (winLayoutMode != WindowLayoutMode::CASCADE && winLayoutMode != WindowLayoutMode::TILE) { errCode = WMError::WM_ERROR_INVALID_PARAM; } - + WLOGFI("[NAPI]LayoutMode = %{public}u, err = %{public}d", winLayoutMode, errCode); AsyncTask::CompleteCallback complete = [=](NativeEngine& engine, AsyncTask& task, int32_t status) { diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index dd608251..0971dd62 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -62,6 +62,8 @@ NativeValue* WindowTypeInit(NativeEngine* engine) static_cast(ApiWindowType::TYPE_NAVIGATION_BAR))); object->SetProperty("TYPE_FLOAT", CreateJsValue(*engine, static_cast(ApiWindowType::TYPE_FLOAT))); + object->SetProperty("TYPE_FLOAT_CAMERA", CreateJsValue(*engine, + static_cast(ApiWindowType::TYPE_FLOAT_CAMERA))); object->SetProperty("TYPE_WALLPAPER", CreateJsValue(*engine, static_cast(ApiWindowType::TYPE_WALLPAPER))); object->SetProperty("TYPE_DESKTOP", CreateJsValue(*engine, diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 3e631957..aef4219c 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -44,7 +44,8 @@ enum class ApiWindowType : uint32_t { TYPE_LAUNCHER_DOCK, TYPE_VOICE_INTERACTION, TYPE_POINTER, - TYPE_END = TYPE_POINTER, + TYPE_FLOAT_CAMERA, + TYPE_END = TYPE_FLOAT_CAMERA, }; enum class LifeCycleEventType : uint32_t { @@ -64,6 +65,7 @@ const std::map NATIVE_JS_TO_WINDOW_TYPE_MAP { { WindowType::WINDOW_TYPE_VOLUME_OVERLAY, ApiWindowType::TYPE_VOLUME_OVERLAY }, { WindowType::WINDOW_TYPE_NAVIGATION_BAR, ApiWindowType::TYPE_NAVIGATION_BAR }, { WindowType::WINDOW_TYPE_FLOAT, ApiWindowType::TYPE_FLOAT }, + { WindowType::WINDOW_TYPE_FLOAT_CAMERA, ApiWindowType::TYPE_FLOAT_CAMERA }, { WindowType::WINDOW_TYPE_WALLPAPER, ApiWindowType::TYPE_WALLPAPER }, { WindowType::WINDOW_TYPE_DESKTOP, ApiWindowType::TYPE_DESKTOP }, { WindowType::WINDOW_TYPE_LAUNCHER_RECENT, ApiWindowType::TYPE_LAUNCHER_RECENT }, @@ -82,6 +84,7 @@ const std::map JS_TO_NATIVE_WINDOW_TYPE_MAP { { ApiWindowType::TYPE_VOLUME_OVERLAY, WindowType::WINDOW_TYPE_VOLUME_OVERLAY }, { ApiWindowType::TYPE_NAVIGATION_BAR, WindowType::WINDOW_TYPE_NAVIGATION_BAR }, { ApiWindowType::TYPE_FLOAT, WindowType::WINDOW_TYPE_FLOAT }, + { ApiWindowType::TYPE_FLOAT_CAMERA, WindowType::WINDOW_TYPE_FLOAT_CAMERA }, { ApiWindowType::TYPE_WALLPAPER, WindowType::WINDOW_TYPE_WALLPAPER }, { ApiWindowType::TYPE_DESKTOP, WindowType::WINDOW_TYPE_DESKTOP }, { ApiWindowType::TYPE_LAUNCHER_RECENT, WindowType::WINDOW_TYPE_LAUNCHER_RECENT }, diff --git a/utils/include/window_helper.h b/utils/include/window_helper.h index 531a44ea..1d67ab03 100644 --- a/utils/include/window_helper.h +++ b/utils/include/window_helper.h @@ -39,6 +39,11 @@ public: return (IsMainWindow(type) || IsSubWindow(type)); } + static inline bool IsAppFloatingWindow(WindowType type) + { + return (type == WindowType::WINDOW_TYPE_FLOAT) || (type == WindowType::WINDOW_TYPE_FLOAT_CAMERA); + } + static inline bool IsBelowSystemWindow(WindowType type) { return (type >= WindowType::BELOW_APP_SYSTEM_WINDOW_BASE && type < WindowType::BELOW_APP_SYSTEM_WINDOW_END); diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 5c6d70af..217738b0 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -313,6 +313,7 @@ private: void UpdatePointerEventForStretchableWindow(std::shared_ptr& pointerEvent); void UpdateDragType(); void InitListenerHandler(); + bool CheckCameraFloatingWindowMultiCreated(WindowType type); // colorspace, gamut using ColorSpaceConvertMap = struct { diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index bf745af0..dcaa1a01 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -625,7 +625,7 @@ WMError WindowImpl::SetFullScreen(bool status) void WindowImpl::MapFloatingWindowToAppIfNeeded() { - if (GetType() != WindowType::WINDOW_TYPE_FLOAT || context_.get() == nullptr) { + if (!WindowHelper::IsAppFloatingWindow(GetType()) || context_.get() == nullptr) { return; } @@ -634,7 +634,8 @@ void WindowImpl::MapFloatingWindowToAppIfNeeded() if (win->GetType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && context_.get() == win->GetContext().get()) { appFloatingWindowMap_[win->GetWindowId()].push_back(this); - WLOGFI("Map FloatingWindow %{public}u to AppMainWindow %{public}u", GetWindowId(), win->GetWindowId()); + WLOGFI("Map FloatingWindow %{public}u to AppMainWindow %{public}u, type is %{public}u", + GetWindowId(), win->GetWindowId(), GetType()); return; } } @@ -663,6 +664,12 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr< property_->SetParentId(parentId); } } + + if (CheckCameraFloatingWindowMultiCreated(property_->GetWindowType())) { + WLOGFE("Camera Floating Window already exists."); + return WMError::WM_ERROR_INVALID_WINDOW; + } + context_ = context; sptr window(this); sptr windowAgent(new WindowAgent(window)); @@ -723,7 +730,8 @@ void WindowImpl::DestroyFloatingWindow() // Destroy app floating window if exist if (appFloatingWindowMap_.count(GetWindowId()) > 0) { - for (auto& floatingWindow : appFloatingWindowMap_.at(GetWindowId())) { + auto floatingWindows = appFloatingWindowMap_.at(GetWindowId()); + for (auto& floatingWindow : floatingWindows) { if (floatingWindow == nullptr) { continue; } @@ -2243,6 +2251,7 @@ void WindowImpl::SetDefaultOption() } case WindowType::WINDOW_TYPE_TOAST: case WindowType::WINDOW_TYPE_FLOAT: + case WindowType::WINDOW_TYPE_FLOAT_CAMERA: case WindowType::WINDOW_TYPE_VOICE_INTERACTION: case WindowType::WINDOW_TYPE_LAUNCHER_DOCK: case WindowType::WINDOW_TYPE_SEARCHING_BAR: { @@ -2320,5 +2329,19 @@ void WindowImpl::GetRequestedTouchHotAreas(std::vector& rects) const { property_->GetTouchHotAreas(rects); } + +bool WindowImpl::CheckCameraFloatingWindowMultiCreated(WindowType type) +{ + if (type != WindowType::WINDOW_TYPE_FLOAT_CAMERA) { + return false; + } + + for (auto& winPair : windowMap_) { + if (winPair.second.second->GetType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) { + return true; + } + } + return false; +} } // namespace Rosen } // namespace OHOS diff --git a/wm/test/systemtest/BUILD.gn b/wm/test/systemtest/BUILD.gn index 3dc930a2..8c89f3a4 100644 --- a/wm/test/systemtest/BUILD.gn +++ b/wm/test/systemtest/BUILD.gn @@ -20,6 +20,7 @@ group("systemtest") { testonly = true deps = [ + ":wm_window_app_floating_window_test", ":wm_window_drag_test", ":wm_window_effect_test", ":wm_window_focus_test", @@ -243,6 +244,17 @@ ohos_systemtest("wm_window_mode_support_info_test") { ## SystemTest wm_window_mode_support_info_test }}} +## SystemTest wm_window_app_floating_window_test {{{ +ohos_systemtest("wm_window_app_floating_window_test") { + module_out_path = module_out_path + + sources = [ "window_app_floating_window_test.cpp" ] + + deps = [ ":wm_systemtest_common" ] +} + +## SystemTest wm_window_app_floating_window_test }}} + ## Build wm_systemtest_common.a {{{ config("wm_systemtest_common_public_config") { include_dirs = [ @@ -307,6 +319,7 @@ ohos_static_library("wm_systemtest_common") { "ability_base:base", "ability_base:want", "ability_base:zuri", + "ability_runtime:ability_context_native", "bundle_framework:appexecfwk_base", ] } diff --git a/wm/test/systemtest/window_app_floating_window_test.cpp b/wm/test/systemtest/window_app_floating_window_test.cpp new file mode 100644 index 00000000..df14fa72 --- /dev/null +++ b/wm/test/systemtest/window_app_floating_window_test.cpp @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2022 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. + */ + +// gtest +#include +#include "ability_context_impl.h" +#include "window.h" +#include "window_option.h" +#include "window_scene.h" +#include "window_test_utils.h" +#include "wm_common.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class WindowAppFloatingWindowTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + virtual void SetUp() override; + virtual void TearDown() override; + + static inline float virtualPixelRatio_ = 1.0; + static inline std::shared_ptr abilityContext_ = nullptr; +}; + +void WindowAppFloatingWindowTest::SetUpTestCase() +{ + auto display = DisplayManager::GetInstance().GetDisplayById(0); + ASSERT_TRUE((display != nullptr)); + Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; + WindowTestUtils::InitByDisplayRect(displayRect); + virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); +} + +void WindowAppFloatingWindowTest::TearDownTestCase() +{ +} + +void WindowAppFloatingWindowTest::SetUp() +{ +} + +void WindowAppFloatingWindowTest::TearDown() +{ +} + +static sptr CreateWindowScene() +{ + sptr listener = nullptr; + WindowAppFloatingWindowTest::abilityContext_ = std::make_shared(); + + sptr scene = new WindowScene(); + scene->Init(0, WindowAppFloatingWindowTest::abilityContext_, listener); + return scene; +} + +static sptr CreateAppFloatingWindow(WindowType type, Rect rect, std::string name = "") +{ + sptr option = new WindowOption(); + option->SetWindowType(type); + option->SetWindowRect(rect); + + static int cnt = 0; + std::string winName = (name == "") ? "FloatingWindowTest" + std::to_string(cnt++) : name; + + return Window::Create(winName, option, WindowAppFloatingWindowTest::abilityContext_); +} + +static inline Rect GetRectWithVpr(int32_t x, int32_t y, uint32_t w, uint32_t h) +{ + auto vpr = WindowAppFloatingWindowTest::virtualPixelRatio_; + return {x, y, static_cast(w * vpr), static_cast(h * vpr)}; +} + +/** + * @tc.name: AppFloatingWindow01 + * @tc.desc: AppFloatingWindow life cycle + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow01, Function | MediumTest | Level2) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Hide()); + ASSERT_EQ(WMError::WM_OK, scene->GoBackground()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} + +/** + * @tc.name: AppFloatingWindow02 + * @tc.desc: AppFloatingWindow life cycle, main window hide first + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow02, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, scene->GoBackground()); + ASSERT_EQ(false, scene->GetMainWindow()->GetShowState()); + ASSERT_EQ(true, fltWin->GetShowState()); + ASSERT_EQ(WMError::WM_OK, fltWin->Hide()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} + +/** + * @tc.name: AppFloatingWindow03 + * @tc.desc: AppFloatingWindow life cycle, app floating window hide first + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow03, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Hide()); + ASSERT_EQ(false, fltWin->GetShowState()); + ASSERT_EQ(true, scene->GetMainWindow()->GetShowState()); + ASSERT_EQ(WMError::WM_OK, scene->GoBackground()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} + +/** + * @tc.name: AppFloatingWindow04 + * @tc.desc: AppFloatingWindow life cycle, main window destroy first + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow04, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); + ASSERT_EQ(nullptr, scene->GetMainWindow()); + ASSERT_EQ(false, fltWin->GetShowState()); + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); +} + +/** + * @tc.name: AppFloatingWindow05 + * @tc.desc: Camera AppFloatingWindow life cycle + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow05, Function | MediumTest | Level2) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Hide()); + ASSERT_EQ(WMError::WM_OK, scene->GoBackground()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} + +/** + * @tc.name: AppFloatingWindow06 + * @tc.desc: Camera AppFloatingWindow life cycle, main window hide first + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow06, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, scene->GoBackground()); + ASSERT_EQ(false, scene->GetMainWindow()->GetShowState()); + ASSERT_EQ(true, fltWin->GetShowState()); + ASSERT_EQ(WMError::WM_OK, fltWin->Hide()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} + +/** + * @tc.name: AppFloatingWindow07 + * @tc.desc: Camera AppFloatingWindow life cycle, app floating window hide first + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow07, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Hide()); + ASSERT_EQ(false, fltWin->GetShowState()); + ASSERT_EQ(true, scene->GetMainWindow()->GetShowState()); + ASSERT_EQ(WMError::WM_OK, scene->GoBackground()); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} + +/** + * @tc.name: AppFloatingWindow08 + * @tc.desc: Camera AppFloatingWindow life cycle, main window destroy first + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow08, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); + ASSERT_EQ(nullptr, scene->GetMainWindow()); + ASSERT_EQ(false, fltWin->GetShowState()); + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); +} + +/** + * @tc.name: AppFloatingWindow09 + * @tc.desc: Camera AppFloatingWindow rect check + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow09, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(10, 20, 10, 10); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + Rect exceptRect = WindowTestUtils::GetFloatingLimitedRect(fltWindRect, virtualPixelRatio_); + ASSERT_TRUE(WindowTestUtils::RectEqualTo(fltWin, exceptRect)); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} +} // namespace Rosen +} // namespace OHOS diff --git a/wmserver/include/window_zorder_policy.h b/wmserver/include/window_zorder_policy.h index af41d1e8..8df41594 100644 --- a/wmserver/include/window_zorder_policy.h +++ b/wmserver/include/window_zorder_policy.h @@ -52,6 +52,7 @@ private: { WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, 106 }, { WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, 107 }, { WindowType::WINDOW_TYPE_FLOAT, 108 }, + { WindowType::WINDOW_TYPE_FLOAT_CAMERA, 108 }, { WindowType::WINDOW_TYPE_TOAST, 109 }, { WindowType::WINDOW_TYPE_STATUS_BAR, 110 }, { WindowType::WINDOW_TYPE_PANEL, 111 }, diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 0a8b5afc..68929bd1 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -678,7 +678,8 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeBySystemLimits(const sptrGetDisplayId())); // limit minimum size of floating (not system type) window - if (!WindowHelper::IsSystemWindow(node->GetWindowType())) { + if (!WindowHelper::IsSystemWindow(node->GetWindowType()) || + node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) { winRect.width_ = std::max(systemLimits.minWidth_, winRect.width_); winRect.height_ = std::max(systemLimits.minHeight_, winRect.height_); }