From 2f65f31387989db0b03d8834017c19dc3faca461 Mon Sep 17 00:00:00 2001 From: zhangxiao72 Date: Tue, 14 Jun 2022 11:25:37 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E5=8C=96=E6=95=B4?= =?UTF-8?q?=E6=94=B9ace=5Fengine=5Fstandard=20=E4=BF=AE=E6=94=B9=E4=B8=BAa?= =?UTF-8?q?ce=5Fengine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1de5a46dde0908a18513e44c93f0576a8217b161 Signed-off-by: zhangxiao72 --- wm/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/BUILD.gn b/wm/BUILD.gn index eb74ce04..9856e226 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -73,7 +73,7 @@ ohos_shared_library("libwm") { "ability_base:want", "ability_runtime:ability_context_native", "ability_runtime:ability_manager", - "ace_engine_standard:ace_uicontent", + "ace_engine:ace_uicontent", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "graphic_standard:surface", From 0d6fb9b20cd3df8dccb78ba9615aacaa65d6d814 Mon Sep 17 00:00:00 2001 From: xpeng Date: Tue, 28 Jun 2022 10:39:41 +0800 Subject: [PATCH 02/12] Optimize logic of auto rotation Signed-off-by: xpeng Change-Id: I18c304be2a4187743ba59eb53fb74748c49c30c2 --- dmserver/src/screen_rotation_controller.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dmserver/src/screen_rotation_controller.cpp b/dmserver/src/screen_rotation_controller.cpp index 140999ba..635976db 100644 --- a/dmserver/src/screen_rotation_controller.cpp +++ b/dmserver/src/screen_rotation_controller.cpp @@ -109,6 +109,7 @@ void ScreenRotationController::HandleGravitySensorEventCallback(SensorEvent *eve currentDisplayRotation_ = GetCurrentDisplayRotation(); HandleUnspecifiedOrientation(orientation); if (!IsSensorRelatedOrientation(orientation)) { + lastOrientationType_ = orientation; return; } @@ -128,6 +129,7 @@ void ScreenRotationController::HandleGravitySensorEventCallback(SensorEvent *eve ProcessRotationWhenSensorDataNotValid(orientation); return; } + lastOrientationType_ = orientation; if ((ConvertToDeviceRotation(currentSensorRotation) == currentDisplayRotation_) && (orientation == Orientation::SENSOR || orientation == Orientation::AUTO_ROTATION_RESTRICTED)) { return; From 178ab21b46db755e77adf8056990a99d0b53a530 Mon Sep 17 00:00:00 2001 From: yichengzhao Date: Thu, 23 Jun 2022 20:51:37 +0800 Subject: [PATCH 03/12] notify windowproperty change Signed-off-by: yichengzhao Change-Id: Ic5fdc3d2efaa5f6d547747a554a5ff0e988df0e8 --- interfaces/innerkits/wm/wm_common.h | 1 + wmserver/include/window_controller.h | 1 + wmserver/src/window_controller.cpp | 25 +++++++++++++++++++++---- wmserver/src/window_node_container.cpp | 5 ++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 24da28ce..bf277c7a 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -297,6 +297,7 @@ enum class WindowUpdateType : int32_t { WINDOW_UPDATE_FOCUSED, WINDOW_UPDATE_BOUNDS, WINDOW_UPDATE_ACTIVE, + WINDOW_UPDATE_PROPERTY, }; struct SystemConfig { diff --git a/wmserver/include/window_controller.h b/wmserver/include/window_controller.h index 66971809..f069fe17 100644 --- a/wmserver/include/window_controller.h +++ b/wmserver/include/window_controller.h @@ -83,6 +83,7 @@ private: WMError UpdateTouchHotAreas(const sptr& node, const std::vector& rects); void NotifyTouchOutside(const sptr& node); uint32_t GetEmbedNodeId(const std::vector>& windowNodes, const sptr& node); + void NotifyWindowPropertyChanged(const sptr& node); sptr windowRoot_; sptr inputWindowMonitor_; std::atomic windowId_ { INVALID_WINDOW_ID }; diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 93b36835..e6feb3c0 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -779,18 +779,22 @@ WMError WindowController::UpdateProperty(sptr& property, Propert } WLOGFI("window: [%{public}s, %{public}u] update property for action: %{public}u", node->GetWindowName().c_str(), node->GetWindowId(), static_cast(action)); + WMError ret = WMError::WM_OK; switch (action) { case PropertyChangeAction::ACTION_UPDATE_RECT: { node->SetDecoStatus(property->GetDecoStatus()); node->SetOriginRect(property->GetOriginRect()); node->SetDragType(property->GetDragType()); - return ResizeRect(windowId, property->GetRequestRect(), property->GetWindowSizeChangeReason()); + ret = ResizeRect(windowId, property->GetRequestRect(), property->GetWindowSizeChangeReason()); + break; } case PropertyChangeAction::ACTION_UPDATE_MODE: { - return SetWindowMode(windowId, property->GetWindowMode()); + ret = SetWindowMode(windowId, property->GetWindowMode()); + break; } case PropertyChangeAction::ACTION_UPDATE_FLAGS: { - return SetWindowFlags(windowId, property->GetWindowFlags()); + ret = SetWindowFlags(windowId, property->GetWindowFlags()); + break; } case PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS: { auto& props = property->GetSystemBarProperty(); @@ -850,7 +854,20 @@ WMError WindowController::UpdateProperty(sptr& property, Propert default: break; } - return WMError::WM_OK; + if (ret == WMError::WM_OK) { + NotifyWindowPropertyChanged(node); + } + return ret; +} + +void WindowController::NotifyWindowPropertyChanged(const sptr& node) +{ + auto windowNodeContainer = windowRoot_->GetOrCreateWindowNodeContainer(node->GetDisplayId()); + if (windowNodeContainer == nullptr) { + WLOGFE("windowNodeContainer is null"); + return; + } + windowNodeContainer->NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_PROPERTY); } WMError WindowController::GetModeChangeHotZones(DisplayId displayId, diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index a2e77c39..88f638b7 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -992,7 +992,7 @@ void WindowNodeContainer::FillWindowInfo(sptr& windowInfo, const spt windowInfo->mode_ = node->GetWindowMode(); windowInfo->type_ = node->GetWindowType(); auto property = node->GetWindowProperty(); - if (!property) { + if (property != nullptr) { windowInfo->isDecorEnable_ = property->GetDecorEnable(); } } @@ -1018,6 +1018,9 @@ void WindowNodeContainer::NotifyAccessibilityWindowInfo(const sptr& case WindowUpdateType::WINDOW_UPDATE_REMOVED: isNeedNotify = true; break; + case WindowUpdateType::WINDOW_UPDATE_PROPERTY: + isNeedNotify = true; + break; default: break; } From 6961ba0814ad49d1a40f667b5f34ad450a0ac488 Mon Sep 17 00:00:00 2001 From: xiaojianfeng Date: Tue, 28 Jun 2022 15:12:13 +0800 Subject: [PATCH 04/12] fix toggle split window states bug Signed-off-by: xiaojianfeng Change-Id: Iab9fcb834ac0ee71fe3a38efedec4b661de07515 --- wm/src/window_impl.cpp | 3 +- wmserver/include/window_node_container.h | 2 + wmserver/include/window_pair.h | 10 +--- wmserver/src/window_node_container.cpp | 76 +++++++++++++++--------- wmserver/src/window_pair.cpp | 7 +-- wmserver/src/window_root.cpp | 7 +-- 6 files changed, 56 insertions(+), 49 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 0dcecf56..51ab9274 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -2023,8 +2023,7 @@ void WindowImpl::UpdateWindowState(WindowState state) WLOGFD("MinimizeAbility, id: %{public}u", GetWindowId()); AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(abilityContext->GetToken(), true); } else { - state_ = WindowState::STATE_HIDDEN; - NotifyAfterBackground(); + Hide(static_cast(WindowStateChangeReason::TOGGLING)); } break; } diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 6803edeb..6115d75a 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -76,6 +76,7 @@ public: void MinimizeAllAppWindows(DisplayId displayId); void MinimizeOldestAppWindow(); WMError ToggleShownStateForAllAppWindows(std::function restoreFunc, bool restore); + void BackUpAllAppWindows(); void RestoreAllAppWindows(std::function restoreFunc); bool IsAppWindowsEmpty() const; void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason); @@ -160,6 +161,7 @@ private: std::vector backupWindowIds_; std::map backupWindowMode_; std::map backupDividerWindowRect_; + std::map> backupDisplaySplitWindowMode_; sptr zorderPolicy_ = new WindowZorderPolicy(); std::unordered_map> layoutPolicies_; WindowLayoutMode layoutMode_ = WindowLayoutMode::CASCADE; diff --git a/wmserver/include/window_pair.h b/wmserver/include/window_pair.h index 86d8391c..e1a25daf 100644 --- a/wmserver/include/window_pair.h +++ b/wmserver/include/window_pair.h @@ -17,6 +17,7 @@ #define OHOS_ROSEN_WINDOW_PAIR_H #include +#include "class_var_definition.h" #include "window_inner_manager.h" #include "window_node.h" #include "window_layout_policy.h" @@ -171,13 +172,6 @@ public: */ bool IsDockSliceInExitSplitModeArea(const std::vector& exitSplitPoints); - /** - * Set all app windows are restoring. - * - * @param ratio Indicates whether all app windows are restoring. - */ - void SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring); - void SetInitalDividerRect(const Rect& rect); private: @@ -252,8 +246,8 @@ private: sptr divider_; WindowPairStatus status_ = {WindowPairStatus::STATUS_EMPTY}; DisplayGroupWindowTree& displayGroupWindowTree_; - bool isAllAppWindowsRestoring_ { false }; Rect initalDividerRect_ {0, 0, 0, 0}; + DEFINE_VAR_DEFAULT_FUNC_SET(bool, AllSplitAppWindowsRestoring, isAllSplitAppWindowsRestoring, false) }; } // namespace Rosen } // namespace OHOS diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index a2e77c39..0d64518f 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -1387,44 +1387,29 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows( std::function restoreFunc, bool restore) { WLOGFI("ToggleShownStateForAllAppWindows"); + sptr recentWindowNode = nullptr; for (auto node : aboveAppWindowNode_->children_) { if (node->GetWindowType() == WindowType::WINDOW_TYPE_LAUNCHER_RECENT) { - return WMError::WM_DO_NOTHING; + recentWindowNode = node; + if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { + return WMError::WM_OK; + } } } // to do, backup reentry: 1.ToggleShownStateForAllAppWindows fast; 2.this display should reset backupWindowIds_. if (!restore && appWindowNode_->children_.empty() && !backupWindowIds_.empty()) { backupWindowIds_.clear(); backupWindowMode_.clear(); + backupDisplaySplitWindowMode_.clear(); backupDividerWindowRect_.clear(); } if (!restore && !appWindowNode_->children_.empty() && backupWindowIds_.empty()) { WLOGFI("backup"); - std::set displayIdSet; - backupWindowMode_.clear(); - for (auto& appNode : appWindowNode_->children_) { - // exclude exceptional window - if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) { - WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId()); - continue; - } - // minimize window - WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId()); - backupWindowIds_.emplace_back(appNode->GetWindowId()); - backupWindowMode_[appNode->GetWindowId()] = appNode->GetWindowMode(); - displayIdSet.insert(appNode->GetDisplayId()); - if (appNode->GetWindowToken()) { - appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN); - } - } - backupDividerWindowRect_.clear(); - for (auto displayId : displayIdSet) { - auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId); - if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) { - continue; - } - backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect(); + if (recentWindowNode != nullptr && recentWindowNode->GetWindowToken() != nullptr) { + WLOGFI("hide recent"); + recentWindowNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN); } + BackUpAllAppWindows(); } else if (restore && !backupWindowIds_.empty()) { WLOGFI("restore"); RestoreAllAppWindows(restoreFunc); @@ -1434,6 +1419,40 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows( return WMError::WM_OK; } +void WindowNodeContainer::BackUpAllAppWindows() +{ + std::set displayIdSet; + backupWindowMode_.clear(); + backupDisplaySplitWindowMode_.clear(); + for (auto& appNode : appWindowNode_->children_) { + // exclude exceptional window + if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) { + WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId()); + continue; + } + // minimize window + WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId()); + backupWindowIds_.emplace_back(appNode->GetWindowId()); + auto windowMode = appNode->GetWindowMode(); + backupWindowMode_[appNode->GetWindowId()] = windowMode; + if (WindowHelper::IsSplitWindowMode(windowMode)) { + backupDisplaySplitWindowMode_[appNode->GetWindowId()].insert(windowMode); + } + displayIdSet.insert(appNode->GetDisplayId()); + if (appNode->GetWindowToken()) { + appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN); + } + } + backupDividerWindowRect_.clear(); + for (auto displayId : displayIdSet) { + auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId); + if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) { + continue; + } + backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect(); + } +} + void WindowNodeContainer::RestoreAllAppWindows(std::function restoreFunc) { std::vector backupWindowIds(backupWindowIds_); @@ -1442,7 +1461,10 @@ void WindowNodeContainer::RestoreAllAppWindows(std::functionGetWindowPairByDisplayId(displayId); if (windowPair != nullptr) { - windowPair->SetAllAppWindowsRestoring(true); + if (backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_PRIMARY) > 0 && + backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_SECONDARY) > 0) { + windowPair->SetAllSplitAppWindowsRestoring(true); + } windowPairs.emplace_back(windowPair); } } @@ -1454,7 +1476,7 @@ void WindowNodeContainer::RestoreAllAppWindows(std::functionSetAllAppWindowsRestoring(false); + windowPair->SetAllSplitAppWindowsRestoring(false); } layoutPolicy_->SetSplitDividerWindowRects(backupDividerWindowRect_); backupWindowIds_.clear(); diff --git a/wmserver/src/window_pair.cpp b/wmserver/src/window_pair.cpp index 095b4add..359b17ac 100644 --- a/wmserver/src/window_pair.cpp +++ b/wmserver/src/window_pair.cpp @@ -331,7 +331,7 @@ void WindowPair::UpdateIfSplitRelated(sptr& node) status_, node->GetWindowId(), node->GetWindowMode()); if (status_ == WindowPairStatus::STATUS_EMPTY) { Insert(node); - if (!isAllAppWindowsRestoring_) { + if (!isAllSplitAppWindowsRestoring_) { // find pairable window from trees or send broadcast sptr pairableNode = GetPairableWindow(node); // insert pairable node @@ -487,11 +487,6 @@ void WindowPair::HandleRemoveWindow(sptr& node) } } -void WindowPair::SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring) -{ - isAllAppWindowsRestoring_ = isAllAppWindowsRestoring; -} - void WindowPair::SetInitalDividerRect(const Rect& rect) { initalDividerRect_ = rect; diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index 59b64bac..f71a2973 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -395,12 +395,7 @@ WMError WindowRoot::ToggleShownStateForAllAppWindows() WindowManagerService::GetInstance().HandleAddWindow(property); return true; }; - WMError tmpRes = WMError::WM_OK; - if (isAllAppWindowsEmpty) { - tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, true); - } else { - tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, false); - } + WMError tmpRes = tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, isAllAppWindowsEmpty); res = (res == WMError::WM_OK) ? tmpRes : res; }); return res; From 0532e97dae4ee9f4fcda61deac0e391ec8f2c103 Mon Sep 17 00:00:00 2001 From: wlj Date: Tue, 28 Jun 2022 14:25:57 +0800 Subject: [PATCH 05/12] fix split test Signed-off-by: wlj Change-Id: Ibb7407a419fdcf7b84a2fa17e2cd779ea2464250 --- resources/config/rk3568/window_manager_config.xml | 2 +- wm/test/systemtest/window_split_test.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/resources/config/rk3568/window_manager_config.xml b/resources/config/rk3568/window_manager_config.xml index 70ca77e2..db2b08f9 100644 --- a/resources/config/rk3568/window_manager_config.xml +++ b/resources/config/rk3568/window_manager_config.xml @@ -25,7 +25,7 @@ - 0.1 0.9 + 0.1 0.9 0.5 0.33 0.67 \ No newline at end of file diff --git a/wm/test/systemtest/window_split_test.cpp b/wm/test/systemtest/window_split_test.cpp index 56f569a3..4bb0413f 100644 --- a/wm/test/systemtest/window_split_test.cpp +++ b/wm/test/systemtest/window_split_test.cpp @@ -281,9 +281,6 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3) ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode()); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode()); - utils::TestWindowInfo dividerInfo; dividerInfo.name = "divider0"; dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE; @@ -304,7 +301,11 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3) divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); - posY += 10; + if (rect.width_ < rect.height_) { + posX += 10; + } else { + posY += 10; + } pointerEvent = utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_MOVE); divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); From 5d821d6f651b762753a8a6237b15d667fab1f9c1 Mon Sep 17 00:00:00 2001 From: xpeng Date: Tue, 28 Jun 2022 15:57:58 +0800 Subject: [PATCH 06/12] Update logic for UNSPECIFIED Signed-off-by: xpeng Change-Id: I5eab5f7a5ad4f501c187c68a8db38a5d3c1b2228 --- dmserver/include/display_manager_service.h | 2 +- .../include/display_manager_service_inner.h | 2 +- dmserver/src/display_manager_service.cpp | 4 ++-- .../src/display_manager_service_inner.cpp | 4 ++-- dmserver/src/screen_rotation_controller.cpp | 19 +++++++++++++------ utils/include/display_change_listener.h | 2 +- wmserver/include/window_controller.h | 2 +- wmserver/include/window_manager_service.h | 4 ++-- wmserver/include/window_node_container.h | 2 +- wmserver/src/window_controller.cpp | 4 ++-- wmserver/src/window_manager_service.cpp | 8 ++++---- wmserver/src/window_node_container.cpp | 5 ++++- 12 files changed, 34 insertions(+), 24 deletions(-) diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index 430a002c..1611bbc5 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -98,7 +98,7 @@ public: bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override; static float GetCustomVirtualPixelRatio(); void RegisterDisplayChangeListener(sptr listener); - void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation); + void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation); private: DisplayManagerService(); ~DisplayManagerService() = default; diff --git a/dmserver/include/display_manager_service_inner.h b/dmserver/include/display_manager_service_inner.h index 90e4d1d2..ed8e6c4f 100644 --- a/dmserver/include/display_manager_service_inner.h +++ b/dmserver/include/display_manager_service_inner.h @@ -46,7 +46,7 @@ public: bool SetOrientationFromWindow(DisplayId displayId, Orientation orientation); bool SetRotationFromWindow(DisplayId displayId, Rotation targetRotation); void SetGravitySensorSubscriptionEnabled(); - void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation); + void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation); }; } // namespace OHOS::Rosen diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index d96c7b09..21153b61 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -133,10 +133,10 @@ void DisplayManagerService::NotifyDisplayStateChange(DisplayId defaultDisplayId, } } -void DisplayManagerService::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void DisplayManagerService::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { if (displayChangeListener_ != nullptr) { - displayChangeListener_->OnGetFullScreenWindowRequestedOrientation(displayId, orientation); + displayChangeListener_->OnGetWindowPreferredOrientation(displayId, orientation); } } diff --git a/dmserver/src/display_manager_service_inner.cpp b/dmserver/src/display_manager_service_inner.cpp index 43020920..1d95e999 100644 --- a/dmserver/src/display_manager_service_inner.cpp +++ b/dmserver/src/display_manager_service_inner.cpp @@ -148,9 +148,9 @@ bool DisplayManagerServiceInner::SetRotationFromWindow(DisplayId displayId, Rota SetRotationFromWindow(displayInfo->GetScreenId(), targetRotation); } -void DisplayManagerServiceInner::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void DisplayManagerServiceInner::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { - DisplayManagerService::GetInstance().GetFullScreenWindowRequestedOrientation(displayId, orientation); + DisplayManagerService::GetInstance().GetWindowPreferredOrientation(displayId, orientation); } void DisplayManagerServiceInner::SetGravitySensorSubscriptionEnabled() diff --git a/dmserver/src/screen_rotation_controller.cpp b/dmserver/src/screen_rotation_controller.cpp index 635976db..d4c414fb 100644 --- a/dmserver/src/screen_rotation_controller.cpp +++ b/dmserver/src/screen_rotation_controller.cpp @@ -36,7 +36,7 @@ DisplayId ScreenRotationController::defaultDisplayId_ = 0; bool ScreenRotationController::isGravitySensorSubscribed_ = false; SensorUser ScreenRotationController::user_; Rotation ScreenRotationController::currentDisplayRotation_; -bool ScreenRotationController::isScreenRotationLocked_ = false; +bool ScreenRotationController::isScreenRotationLocked_ = true; long ScreenRotationController::lastCallbackTime_ = 0; uint32_t ScreenRotationController::defaultDeviceRotationOffset_ = 0; Orientation ScreenRotationController::lastOrientationType_ = Orientation::UNSPECIFIED; @@ -55,10 +55,16 @@ void ScreenRotationController::SubscribeGravitySensor() } user_.userData = nullptr; user_.callback = &HandleGravitySensorEventCallback; - SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_); + if (SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_) != 0) { + WLOGFE("Subscribe gravity sensor failed"); + return; + } SetBatch(SENSOR_TYPE_ID_GRAVITY, &user_, ORIENTATION_SENSOR_SAMPLING_RATE, ORIENTATION_SENSOR_REPORTING_RATE); SetMode(SENSOR_TYPE_ID_GRAVITY, &user_, SENSOR_ON_CHANGE); - ActivateSensor(SENSOR_TYPE_ID_GRAVITY, &user_); + if (ActivateSensor(SENSOR_TYPE_ID_GRAVITY, &user_) != 0) { + WLOGFE("Activate gravity sensor failed"); + return; + } isGravitySensorSubscribed_ = true; } @@ -166,7 +172,7 @@ Rotation ScreenRotationController::GetCurrentDisplayRotation() Orientation ScreenRotationController::GetRequestedOrientation() { Orientation orientation = Orientation::UNSPECIFIED; - DisplayManagerServiceInner::GetInstance().GetFullScreenWindowRequestedOrientation(defaultDisplayId_, orientation); + DisplayManagerServiceInner::GetInstance().GetWindowPreferredOrientation(defaultDisplayId_, orientation); return orientation; } @@ -183,6 +189,7 @@ Rotation ScreenRotationController::CalcTargetDisplayRotation( case Orientation::SENSOR_HORIZONTAL: { return ProcessAutoRotationLandscapeOrientation(sensorRotation); } + case Orientation::UNSPECIFIED: case Orientation::AUTO_ROTATION_RESTRICTED: { if (isScreenRotationLocked_) { return currentDisplayRotation_; @@ -262,7 +269,7 @@ Rotation ScreenRotationController::ConvertToDeviceRotation(Rotation sensorRotati bool ScreenRotationController::IsSensorRelatedOrientation(Orientation orientation) { - if ((orientation >= Orientation::BEGIN && orientation <= Orientation::REVERSE_HORIZONTAL) || + if ((orientation >= Orientation::VERTICAL && orientation <= Orientation::REVERSE_HORIZONTAL) || orientation == Orientation::LOCKED) { return false; } @@ -274,7 +281,7 @@ void ScreenRotationController::HandleUnspecifiedOrientation(Orientation orientat if (lastOrientationType_ == orientation) { return; } - if (orientation == Orientation::UNSPECIFIED) { + if (orientation == Orientation::UNSPECIFIED && isScreenRotationLocked_) { SetScreenRotation(Rotation::ROTATION_0); lastOrientationType_ = orientation; } diff --git a/utils/include/display_change_listener.h b/utils/include/display_change_listener.h index 62a5a8d2..abd0c7af 100644 --- a/utils/include/display_change_listener.h +++ b/utils/include/display_change_listener.h @@ -35,7 +35,7 @@ class IDisplayChangeListener : public RefBase { public: virtual void OnDisplayStateChange(DisplayId defaultDisplayId, sptr info, const std::map>& displayInfoMap, DisplayStateChangeType type) = 0; - virtual void OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) = 0; + virtual void OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) = 0; }; } } diff --git a/wmserver/include/window_controller.h b/wmserver/include/window_controller.h index 66971809..15b8aeed 100644 --- a/wmserver/include/window_controller.h +++ b/wmserver/include/window_controller.h @@ -62,7 +62,7 @@ public: void CancelStartingWindow(sptr abilityToken); void MinimizeWindowsByLauncher(std::vector& windowIds, bool isAnimated, sptr& finishCallback); - Orientation GetFullScreenWindowRequestedOrientation(DisplayId displayId); + Orientation GetWindowPreferredOrientation(DisplayId displayId); private: uint32_t GenWindowId(); void FlushWindowInfo(uint32_t windowId); diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 0366f24c..08347cd5 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -42,7 +42,7 @@ class DisplayChangeListener : public IDisplayChangeListener { public: virtual void OnDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type) override; - virtual void OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) override; + virtual void OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) override; }; class WindowManagerServiceHandler : public AAFwk::WindowManagerServiceHandlerStub { @@ -103,7 +103,7 @@ public: void CancelStartingWindow(sptr abilityToken); void MinimizeWindowsByLauncher(std::vector windowIds, bool isAnimated, sptr& finishCallback) override; - void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation); + void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation); protected: WindowManagerService(); virtual ~WindowManagerService() = default; diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 6803edeb..b7695d7b 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -67,7 +67,7 @@ public: bool IsForbidDockSliceMove(DisplayId displayId) const; bool IsDockSliceInExitSplitModeArea(DisplayId displayId) const; void ExitSplitMode(DisplayId displayId); - Orientation GetFullScreenWindowRequestedOrientation(); + Orientation GetWindowPreferredOrientation(); bool isVerticalDisplay(DisplayId displayId) const; WMError RaiseZOrderForAppWindow(sptr& node, sptr& parentNode); diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 93b36835..b951efd3 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -964,11 +964,11 @@ void WindowController::MinimizeWindowsByLauncher(std::vector& windowId } } -Orientation WindowController::GetFullScreenWindowRequestedOrientation(DisplayId displayId) +Orientation WindowController::GetWindowPreferredOrientation(DisplayId displayId) { sptr windowNodeContainer = windowRoot_->GetOrCreateWindowNodeContainer(displayId); if (windowNodeContainer != nullptr) { - return windowNodeContainer->GetFullScreenWindowRequestedOrientation(); + return windowNodeContainer->GetWindowPreferredOrientation(); } return Orientation::UNSPECIFIED; } diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 73838370..571e16ff 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -554,9 +554,9 @@ void DisplayChangeListener::OnDisplayStateChange(DisplayId defaultDisplayId, spt WindowManagerService::GetInstance().NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type); } -void DisplayChangeListener::OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void DisplayChangeListener::OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { - WindowManagerService::GetInstance().GetFullScreenWindowRequestedOrientation(displayId, orientation); + WindowManagerService::GetInstance().GetWindowPreferredOrientation(displayId, orientation); } void WindowManagerService::ProcessPointDown(uint32_t windowId, bool isStartDrag) @@ -659,10 +659,10 @@ void WindowManagerService::MinimizeWindowsByLauncher(std::vector windo }).get(); } -void WindowManagerService::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) +void WindowManagerService::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) { wmsTaskLooper_->ScheduleTask([this, displayId, &orientation]() mutable { - orientation = windowController_->GetFullScreenWindowRequestedOrientation(displayId); + orientation = windowController_->GetWindowPreferredOrientation(displayId); }).wait(); } diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index a2e77c39..91df1d5e 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -1817,7 +1817,7 @@ sptr WindowNodeContainer::GetDisplayInfo(DisplayId displayId) return displayGroupInfo_->GetDisplayInfo(displayId); } -Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation() +Orientation WindowNodeContainer::GetWindowPreferredOrientation() { std::vector> windowNodes; TraverseContainer(windowNodes); @@ -1825,6 +1825,9 @@ Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation() if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { return node->GetRequestedOrientation(); } + if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) { + return Orientation::UNSPECIFIED; + } } return Orientation::UNSPECIFIED; } From 8d67d15b66190dad8b90541a9f94fd30fa753bfe Mon Sep 17 00:00:00 2001 From: l00574490 Date: Tue, 28 Jun 2022 17:32:21 +0800 Subject: [PATCH 07/12] add st Signed-off-by: l00574490 Change-Id: I838164e6153c3b52e541c299534c85a9e1fe885b --- .../window_mode_support_info_test.cpp | 96 +++++++++++-------- 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/wm/test/systemtest/window_mode_support_info_test.cpp b/wm/test/systemtest/window_mode_support_info_test.cpp index bd93d8e9..94165378 100644 --- a/wm/test/systemtest/window_mode_support_info_test.cpp +++ b/wm/test/systemtest/window_mode_support_info_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * 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 @@ -29,8 +29,8 @@ public: static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo floatingScreenAppInfo_; + utils::TestWindowInfo fullAppInfo_1_; + utils::TestWindowInfo fullAppInfo_2_; private: static constexpr uint32_t WAIT_SYANC_US = 100000; }; @@ -49,7 +49,7 @@ void WindowModeSupportInfoTest::TearDownTestCase() void WindowModeSupportInfoTest::SetUp() { - fullScreenAppInfo_ = { + fullAppInfo_1_ = { .name = "FullWindow", .rect = utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -58,8 +58,8 @@ void WindowModeSupportInfoTest::SetUp() .parentLimit = false, .parentName = "", }; - floatingScreenAppInfo_ = { - .name = "FloatingWindow", + fullAppInfo_2_ = { + .name = "FullWindow2", .rect = utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, @@ -81,8 +81,8 @@ namespace { */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); - + const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); + window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetModeSupportInfo()); window->Destroy(); @@ -90,12 +90,44 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTe /** * @tc.name: WindowModeSupportInfo02 - * @tc.desc: modeSupportInfo test for single window + * @tc.desc: modeSupportInfo test for single window, only support fullScreen mode * @tc.type: FUNC */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); + + window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); + + window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); + + window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); + ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); + + window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); + ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); + + window->Destroy(); +} + +/** + * @tc.name: WindowModeSupportInfo03 + * @tc.desc: modeSupportInfo test for single window, support both fullScreen and floating mode + * @tc.type: FUNC + */ +HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3) +{ + const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); @@ -127,13 +159,13 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo03 + * @tc.name: WindowModeSupportInfo04 * @tc.desc: modeSupportInfo test for single window in case current window mode is not supported. * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); @@ -151,23 +183,15 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo04 + * @tc.name: WindowModeSupportInfo05 * @tc.desc: modeSupportInfo test for layout cascade * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = utils::CreateTestWindow(fullAppInfo_1_); window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - const sptr& window2 = utils::CreateTestWindow(utils::TestWindowInfo { - .name = "FullWindow2", - .rect = utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentName = "", - }); + const sptr& window2 = utils::CreateTestWindow(fullAppInfo_2_); window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); @@ -182,13 +206,13 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo05 + * @tc.name: WindowModeSupportInfo06 * @tc.desc: modeSupportInfo test for layout tile * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); @@ -202,23 +226,15 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo06 + * @tc.name: WindowModeSupportInfo07 * @tc.desc: modeSupportInfo test for split * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo07, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = utils::CreateTestWindow(fullAppInfo_1_); window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); - const sptr& window2 = utils::CreateTestWindow(utils::TestWindowInfo { - .name = "FullWindow2", - .rect = utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentName = "", - }); + const sptr& window2 = utils::CreateTestWindow(fullAppInfo_2_); window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); From 03094d9c1743b812bdaf25462211f0d116c6f3fd Mon Sep 17 00:00:00 2001 From: maojiangping Date: Wed, 29 Jun 2022 11:47:26 +0800 Subject: [PATCH 08/12] Fix codex issues. Signed-off-by: maojiangping Change-Id: Ie17b432e8e5fa2d91f8b8018efc3817b869ed7b2 --- dm/test/systemtest/screenshot_cmd_test.cpp | 2 +- dm/test/systemtest/screenshot_test.cpp | 12 +- dm/test/unittest/screenshot_test.cpp | 2 +- wm/test/systemtest/window_drag_test.cpp | 30 +-- wm/test/systemtest/window_effect_test.cpp | 10 +- wm/test/systemtest/window_focus_test.cpp | 70 +++--- wm/test/systemtest/window_gamut_test.cpp | 14 +- wm/test/systemtest/window_immersive_test.cpp | 48 ++-- .../systemtest/window_input_method_test.cpp | 24 +- wm/test/systemtest/window_input_test.cpp | 12 +- wm/test/systemtest/window_layout_test.cpp | 210 +++++++++--------- .../window_mode_support_info_test.cpp | 30 +-- wm/test/systemtest/window_move_drag_test.cpp | 12 +- .../systemtest/window_multi_ability_test.cpp | 36 +-- .../window_occupied_area_change_test.cpp | 24 +- wm/test/systemtest/window_rotation_test.cpp | 16 +- .../window_split_immersive_test.cpp | 14 +- wm/test/systemtest/window_split_test.cpp | 64 +++--- .../systemtest/window_touch_outside_test.cpp | 24 +- .../window_visibility_info_test.cpp | 38 ++-- 20 files changed, 346 insertions(+), 346 deletions(-) diff --git a/dm/test/systemtest/screenshot_cmd_test.cpp b/dm/test/systemtest/screenshot_cmd_test.cpp index 1c0ccb60..72f16b37 100644 --- a/dm/test/systemtest/screenshot_cmd_test.cpp +++ b/dm/test/systemtest/screenshot_cmd_test.cpp @@ -32,7 +32,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenshotCmdTest"}; } -using utils = DisplayTestUtils; +using Utils = DisplayTestUtils; class ScreenshotCmdTest : public testing::Test { public: static void SetUpTestCase(); diff --git a/dm/test/systemtest/screenshot_test.cpp b/dm/test/systemtest/screenshot_test.cpp index ee31ee98..fe7823bf 100644 --- a/dm/test/systemtest/screenshot_test.cpp +++ b/dm/test/systemtest/screenshot_test.cpp @@ -28,7 +28,7 @@ namespace Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenshotTest"}; } -using utils = DisplayTestUtils; +using Utils = DisplayTestUtils; class ScreenshotTest : public testing::Test { public: static void SetUpTestCase(); @@ -109,7 +109,7 @@ HWTEST_F(ScreenshotTest, ScreenShotValid03, Function | MediumTest | Level2) ASSERT_NE(nullptr, screenshot); Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); + ASSERT_TRUE(Utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); } /** @@ -137,20 +137,20 @@ HWTEST_F(ScreenshotTest, ScreenShotValid05, Function | MediumTest | Level2) defaultImage_, defaultRot_); ASSERT_NE(nullptr, screenshot); Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqual(defaultImage_, screenSize)); + ASSERT_TRUE(Utils::SizeEqual(defaultImage_, screenSize)); Media::Size halfDefault_ = {defaultImage_.width / 2, defaultImage_.height / 2}; Media::Rect halfRect = {defaultScreen_.left, defaultScreen_.top, halfDefault_.width, halfDefault_.height}; screenshot = dm.GetScreenshot(defaultId_, halfRect, defaultImage_, defaultRot_); ASSERT_NE(nullptr, screenshot); screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqual(defaultImage_, screenSize)); + ASSERT_TRUE(Utils::SizeEqual(defaultImage_, screenSize)); Media::Size halfSize = {halfDefault_.width, halfDefault_.height}; screenshot = dm.GetScreenshot(defaultId_, defaultScreen_, halfSize, defaultRot_); ASSERT_NE(nullptr, screenshot); screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqual(halfSize, screenSize)); + ASSERT_TRUE(Utils::SizeEqual(halfSize, screenSize)); } /** @@ -165,7 +165,7 @@ HWTEST_F(ScreenshotTest, ScreenShotValid06, Function | MediumTest | Level2) defaultImage_, defaultRot_); ASSERT_NE(nullptr, screenshot); Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()}; - ASSERT_TRUE(utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); + ASSERT_TRUE(Utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize)); } /** diff --git a/dm/test/unittest/screenshot_test.cpp b/dm/test/unittest/screenshot_test.cpp index 57f50f2c..17da915b 100644 --- a/dm/test/unittest/screenshot_test.cpp +++ b/dm/test/unittest/screenshot_test.cpp @@ -26,7 +26,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = TestUtils; +using Utils = TestUtils; constexpr int32_t TEST_IMAGE_HEIGHT = 1080; constexpr int32_t TEST_IMAGE_WIDTH = 1920; using Mocker = SingletonMocker; diff --git a/wm/test/systemtest/window_drag_test.cpp b/wm/test/systemtest/window_drag_test.cpp index 34ec76d9..af107f63 100644 --- a/wm/test/systemtest/window_drag_test.cpp +++ b/wm/test/systemtest/window_drag_test.cpp @@ -23,7 +23,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_CALLBACK_US = 100000; // 100000 us class TestDragListener : public IWindowDragListener { @@ -49,9 +49,9 @@ public: static sptr firstWindowDragListener_; static sptr secondWindowDragListener_; - utils::TestWindowInfo dragWindowInfo_; - utils::TestWindowInfo firstWindowInfo_; - utils::TestWindowInfo secondWindowInfo_; + Utils::TestWindowInfo dragWindowInfo_; + Utils::TestWindowInfo firstWindowInfo_; + Utils::TestWindowInfo secondWindowInfo_; }; sptr WindowDragTest::firstWindowDragListener_ = @@ -77,7 +77,7 @@ void WindowDragTest::SetUp() firstWindowInfo_ = { .name = "firstWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -87,7 +87,7 @@ void WindowDragTest::SetUp() secondWindowInfo_ = { .name = "secondWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -105,12 +105,12 @@ namespace { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(300, 300); usleep(WAIT_CALLBACK_US); @@ -129,12 +129,12 @@ HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(300, 300); usleep(WAIT_CALLBACK_US); @@ -159,17 +159,17 @@ HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); secondWindowInfo_.rect = {500, 500, 500, 500}; - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); secondWindow->RegisterDragListener(secondWindowDragListener_); secondWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(300, 300); usleep(WAIT_CALLBACK_US); @@ -203,12 +203,12 @@ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) { * @tc.type: FUNC */ HWTEST_F(WindowDragTest, DragEnd, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = utils::CreateTestWindow(dragWindowInfo_); + const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); dragWindow->Show(); dragWindow->MoveTo(199, 199); usleep(WAIT_CALLBACK_US); diff --git a/wm/test/systemtest/window_effect_test.cpp b/wm/test/systemtest/window_effect_test.cpp index 8d13f28b..3981b16d 100644 --- a/wm/test/systemtest/window_effect_test.cpp +++ b/wm/test/systemtest/window_effect_test.cpp @@ -21,14 +21,14 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowEffectTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; }; void WindowEffectTest::SetUpTestCase() @@ -43,7 +43,7 @@ void WindowEffectTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -64,7 +64,7 @@ namespace { */ HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(WMError::WM_OK, window->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_LOW)); ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_LOW, window->GetWindowBackgroundBlur()); @@ -78,7 +78,7 @@ HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3) */ HWTEST_F(WindowEffectTest, WindowEffect02, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(WMError::WM_OK, window->SetAlpha(1.0f)); ASSERT_EQ(1.0f, window->GetAlpha()); diff --git a/wm/test/systemtest/window_focus_test.cpp b/wm/test/systemtest/window_focus_test.cpp index 29b86105..1a4b05db 100644 --- a/wm/test/systemtest/window_focus_test.cpp +++ b/wm/test/systemtest/window_focus_test.cpp @@ -27,7 +27,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowFocusTest"}; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_ASYNC_US = 100000; // 100000us class TestFocusChangedListener : public IFocusChangedListener { @@ -45,9 +45,9 @@ public: virtual void SetUp() override; virtual void TearDown() override; static sptr testFocusChangedListener_; - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo floatAppInfo_; - utils::TestWindowInfo subAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo floatAppInfo_; + Utils::TestWindowInfo subAppInfo_; }; sptr WindowFocusTest::testFocusChangedListener_ = @@ -72,7 +72,7 @@ void WindowFocusTest::SetUpTestCase() WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowFocusTest::TearDownTestCase() @@ -83,7 +83,7 @@ void WindowFocusTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -92,7 +92,7 @@ void WindowFocusTest::SetUp() }; floatAppInfo_ = { .name = "ParentWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -101,7 +101,7 @@ void WindowFocusTest::SetUp() }; subAppInfo_ = { .name = "SubWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -126,23 +126,23 @@ HWTEST_F(WindowFocusTest, FocusChangedTest01, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "FocusChangedTest01_1"; fullScreenAppInfo_.focusable_ = false; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); floatAppInfo_.name = "FocusChangedTest01_2"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, window2); floatAppInfo_.name = "FocusChangedTest01_3"; floatAppInfo_.rect = { 250, 150, 300, 500 }; - const sptr& window3 = utils::CreateTestWindow(floatAppInfo_); + const sptr& window3 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, window3); subAppInfo_.name = "FocusChangedTest01_4"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = window3->GetWindowName(); - const sptr& subWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& subWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_EQ(WMError::WM_OK, window3->Show()); // Await 100ms and get callback result in listener. @@ -181,14 +181,14 @@ HWTEST_F(WindowFocusTest, FocusChangedTest02, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest02_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); subAppInfo_.name = "FocusChangedTest02_2"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow->GetWindowName(); - const sptr& subWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& subWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, subWindow->Show()); usleep(WAIT_ASYNC_US); @@ -212,20 +212,20 @@ HWTEST_F(WindowFocusTest, FocusChangedTest03, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest03_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); subAppInfo_.name = "FocusChangedTest03_2"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); - const sptr& aboveSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, aboveSubWindow); ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show()); floatAppInfo_.name = "FocusChangedTest03_3"; floatAppInfo_.rect = { 200, 200, 100, 100 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); usleep(WAIT_ASYNC_US); @@ -251,7 +251,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest04_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); @@ -259,13 +259,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3) subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); floatAppInfo_.name = "FocusChangedTest04_3"; floatAppInfo_.rect = { 200, 200, 100, 100 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); usleep(WAIT_ASYNC_US); @@ -291,13 +291,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest05_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); floatAppInfo_.name = "FocusChangedTest05_2"; floatAppInfo_.rect = { 200, 200, 100, 100 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); @@ -305,7 +305,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3) subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow2->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); usleep(WAIT_ASYNC_US); @@ -340,7 +340,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest06_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow); ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); @@ -348,7 +348,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3) subAppInfo_.rect = { 100, 200, 100, 100 }; subAppInfo_.parentName = mainWindow->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); @@ -356,7 +356,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3) subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - const sptr& aboveSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, aboveSubWindow); ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show()); usleep(WAIT_ASYNC_US); @@ -377,19 +377,19 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest07_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); floatAppInfo_.name = "FocusChangedTest07_2"; floatAppInfo_.rect = { 250, 150, 300, 500 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); floatAppInfo_.name = "FocusChangedTest07_3"; floatAppInfo_.rect = { 300, 400, 10, 400 }; - const sptr& mainWindow3 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow3 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow3); ASSERT_EQ(WMError::WM_OK, mainWindow3->Show()); @@ -397,21 +397,21 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3) subAppInfo_.rect = { 20, 100, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow1 = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow1 = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow1); subAppInfo_.name = "FocusChangedTest07_5"; subAppInfo_.rect = { 400, 200, 100, 100 }; subAppInfo_.parentName = mainWindow2->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - const sptr& aboveSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, aboveSubWindow); subAppInfo_.name = "FocusChangedTest07_6"; subAppInfo_.rect = { 310, 410, 100, 100 }; subAppInfo_.parentName = mainWindow3->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow2 = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow2 = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow2); ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show()); @@ -448,13 +448,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3) { floatAppInfo_.name = "FocusChangedTest08_1"; floatAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& mainWindow1 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow1); ASSERT_EQ(WMError::WM_OK, mainWindow1->Show()); floatAppInfo_.name = "FocusChangedTest08_2"; floatAppInfo_.rect = { 250, 150, 300, 500 }; - const sptr& mainWindow2 = utils::CreateTestWindow(floatAppInfo_); + const sptr& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_NE(nullptr, mainWindow2); ASSERT_EQ(WMError::WM_OK, mainWindow2->Show()); @@ -462,7 +462,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3) subAppInfo_.rect = { 20, 100, 100, 100 }; subAppInfo_.parentName = mainWindow1->GetWindowName(); subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; - const sptr& belowSubWindow = utils::CreateTestWindow(subAppInfo_); + const sptr& belowSubWindow = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, belowSubWindow); ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show()); usleep(WAIT_ASYNC_US); diff --git a/wm/test/systemtest/window_gamut_test.cpp b/wm/test/systemtest/window_gamut_test.cpp index 195bffcb..f0bad10d 100644 --- a/wm/test/systemtest/window_gamut_test.cpp +++ b/wm/test/systemtest/window_gamut_test.cpp @@ -21,7 +21,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; constexpr uint32_t MAX_WAIT_COUNT = 100; constexpr uint32_t WAIT_DUR = 10 * 1000; @@ -31,7 +31,7 @@ public: static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; }; void WindowGamutTest::SetUpTestCase() @@ -46,7 +46,7 @@ void WindowGamutTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -67,7 +67,7 @@ namespace { */ HWTEST_F(WindowGamutTest, IsSupportWideGamut01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(true, window->IsSupportWideGamut()); @@ -81,7 +81,7 @@ HWTEST_F(WindowGamutTest, IsSupportWideGamut01, Function | MediumTest | Level3) */ HWTEST_F(WindowGamutTest, GetColorSpace01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(ColorSpace::COLOR_SPACE_DEFAULT, window->GetColorSpace()); @@ -101,7 +101,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace01, Function | MediumTest | Level3) ColorSpace::COLOR_SPACE_WIDE_GAMUT }; ColorSpace colorSpace; - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ColorSpace colorSpaceBackup = window->GetColorSpace(); // backup origin @@ -130,7 +130,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace01, Function | MediumTest | Level3) */ HWTEST_F(WindowGamutTest, SetColorSpace02, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppInfo_); ColorSpace colorSpaceBackup = window->GetColorSpace(); diff --git a/wm/test/systemtest/window_immersive_test.cpp b/wm/test/systemtest/window_immersive_test.cpp index 919c00bf..5185e218 100644 --- a/wm/test/systemtest/window_immersive_test.cpp +++ b/wm/test/systemtest/window_immersive_test.cpp @@ -48,7 +48,7 @@ namespace { const float RATIO = 0.3; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_ASYNC_US = 100000; // 100000us class TestSystemBarChangedListener : public ISystemBarChangedListener { @@ -79,8 +79,8 @@ public: static vector fullScreenExpecteds_; static sptr testSystemBarChangedListener_; static sptr testAvoidAreaChangedListener_; - utils::TestWindowInfo fullScreenAppinfo_; - utils::TestWindowInfo avoidBarInfo_; + Utils::TestWindowInfo fullScreenAppinfo_; + Utils::TestWindowInfo avoidBarInfo_; uint32_t leftAvoidW_; uint32_t leftAvoidH_; uint32_t topAvoidW_; @@ -200,7 +200,7 @@ void WindowImmersiveTest::SetUpTestCase() WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowImmersiveTest::TearDownTestCase() @@ -211,7 +211,7 @@ void WindowImmersiveTest::SetUp() { fullScreenAppinfo_ = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, // immersive setting .needAvoid = false, // immersive setting @@ -225,11 +225,11 @@ void WindowImmersiveTest::SetUp() .mode = WindowMode::WINDOW_MODE_FLOATING, }; // makesure left avoid win w < h - leftAvoidW_ = std::min(utils::displayRect_.width_, static_cast(utils::displayRect_.height_ * RATIO)); - leftAvoidH_ = utils::displayRect_.height_; + leftAvoidW_ = std::min(Utils::displayRect_.width_, static_cast(Utils::displayRect_.height_ * RATIO)); + leftAvoidH_ = Utils::displayRect_.height_; // makesure top avoid win h < w - topAvoidW_ = utils::displayRect_.width_; - topAvoidH_ = std::min(utils::displayRect_.height_, static_cast(utils::displayRect_.width_ * RATIO)); + topAvoidW_ = Utils::displayRect_.width_; + topAvoidH_ = std::min(Utils::displayRect_.height_, static_cast(Utils::displayRect_.width_ * RATIO)); WindowManager::GetInstance().RegisterSystemBarChangedListener(testSystemBarChangedListener_); activeWindows_.clear(); @@ -253,7 +253,7 @@ namespace { HWTEST_F(WindowImmersiveTest, ImmersiveTest01, Function | MediumTest | Level3) { fullScreenAppinfo_.name = "immer01"; - const sptr& window = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window); SetWindowSystemProps(window, TEST_PROPS_1); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -268,11 +268,11 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest01, Function | MediumTest | Level3) */ HWTEST_F(WindowImmersiveTest, ImmersiveTest02, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); fullScreenAppinfo_.name = "Immer02"; - const sptr& window2 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window2 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window2); SetWindowSystemProps(window2, TEST_PROPS_2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -292,12 +292,12 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest02, Function | MediumTest | Level3) */ HWTEST_F(WindowImmersiveTest, ImmersiveTest03, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); fullScreenAppinfo_.name = "Immer03"; fullScreenAppinfo_.needAvoid = true; // no immersive setting - const sptr& window2 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window2 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window2); SetWindowSystemProps(window2, TEST_PROPS_2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -316,7 +316,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest03, Function | MediumTest | Level3) HWTEST_F(WindowImmersiveTest, ImmersiveTest04, Function | MediumTest | Level3) { fullScreenAppinfo_.needAvoid = true; // no immersive setting - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -338,7 +338,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest04, Function | MediumTest | Level3) HWTEST_F(WindowImmersiveTest, ImmersiveTest05, Function | MediumTest | Level3) { fullScreenAppinfo_.needAvoid = true; // no immersive setting - const sptr& window1 = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window1); SetWindowSystemProps(window1, TEST_PROPS_1); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -362,7 +362,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveNegativeTest01, Function | MediumTest | L { WindowType::WINDOW_TYPE_KEYGUARD, SYS_BAR_PROP_1, SYS_BAR_REGION_NULL }, { WindowType::WINDOW_TYPE_POINTER, SYS_BAR_PROP_2, SYS_BAR_REGION_NULL }, }; - const sptr& window = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(window); SetWindowSystemProps(window, TEST_PROPS_NEGATIVE); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -379,17 +379,17 @@ HWTEST_F(WindowImmersiveTest, ImmersiveNegativeTest01, Function | MediumTest | L HWTEST_F(WindowImmersiveTest, GetAvoidAreaByTypeTest01, Function | MediumTest | Level3) { // Add full screenwindow for call GetAvoidArea, and push_back in activeWindows_ - const sptr& win = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& win = Utils::CreateTestWindow(fullScreenAppinfo_); activeWindows_.push_back(win); // Test GetAvoidArea AvoidArea avoidarea; WMError ret = win->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea); ASSERT_EQ(WMError::WM_OK, ret); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.leftRect_)); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.rightRect_)); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.topRect_)); - ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.bottomRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.leftRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.rightRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.topRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.bottomRect_)); ASSERT_EQ(WMError::WM_OK, win->Hide()); } @@ -400,10 +400,10 @@ HWTEST_F(WindowImmersiveTest, GetAvoidAreaByTypeTest01, Function | MediumTest | */ HWTEST_F(WindowImmersiveTest, DockWindowTest01, Function | MediumTest | Level3) { - const sptr& dockWindow = utils::CreateDockWindow(); + const sptr& dockWindow = Utils::CreateDockWindow(); ASSERT_EQ(WMError::WM_OK, dockWindow->Show()); - const sptr& window = utils::CreateTestWindow(fullScreenAppinfo_); + const sptr& window = Utils::CreateTestWindow(fullScreenAppinfo_); usleep(WAIT_ASYNC_US); auto act = testSystemBarChangedListener_->tints_; diff --git a/wm/test/systemtest/window_input_method_test.cpp b/wm/test/systemtest/window_input_method_test.cpp index 222496d4..0f57c7f9 100644 --- a/wm/test/systemtest/window_input_method_test.cpp +++ b/wm/test/systemtest/window_input_method_test.cpp @@ -21,15 +21,15 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowInputMethodTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo inputMethodWindowInfo_; - utils::TestWindowInfo keyGuardWindowInfo_; + Utils::TestWindowInfo inputMethodWindowInfo_; + Utils::TestWindowInfo keyGuardWindowInfo_; }; void WindowInputMethodTest::SetUpTestCase() @@ -37,7 +37,7 @@ void WindowInputMethodTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowInputMethodTest::TearDownTestCase() @@ -48,7 +48,7 @@ void WindowInputMethodTest::SetUp() { inputMethodWindowInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -57,7 +57,7 @@ void WindowInputMethodTest::SetUp() }; keyGuardWindowInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_KEYGUARD, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -79,7 +79,7 @@ namespace { HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Level3) { inputMethodWindowInfo_.name = "input_method.1"; - const sptr& window = utils::CreateTestWindow(inputMethodWindowInfo_); + const sptr& window = Utils::CreateTestWindow(inputMethodWindowInfo_); ASSERT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, window->GetType()); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WMError::WM_OK, window->Hide()); @@ -93,7 +93,7 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Lev HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3) { keyGuardWindowInfo_.name = "keyGuard.1"; - const sptr& window = utils::CreateTestWindow(keyGuardWindowInfo_); + const sptr& window = Utils::CreateTestWindow(keyGuardWindowInfo_); ASSERT_EQ(WindowType::WINDOW_TYPE_KEYGUARD, window->GetType()); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WMError::WM_OK, window->Hide()); @@ -108,12 +108,12 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow03, Function | MediumTest | Lev { inputMethodWindowInfo_.name = "input_method.2"; keyGuardWindowInfo_.name = "keyGuard.2"; - const sptr& inputMethodWindow = utils::CreateTestWindow(inputMethodWindowInfo_); - const sptr& keyGuardWindow = utils::CreateTestWindow(keyGuardWindowInfo_); + const sptr& inputMethodWindow = Utils::CreateTestWindow(inputMethodWindowInfo_); + const sptr& keyGuardWindow = Utils::CreateTestWindow(keyGuardWindowInfo_); keyGuardWindow->Show(); inputMethodWindow->Show(); - ASSERT_TRUE(utils::RectEqualTo(keyGuardWindow, utils::displayRect_)); - ASSERT_TRUE(utils::RectEqualTo(inputMethodWindow, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(keyGuardWindow, Utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(inputMethodWindow, Utils::customAppRect_)); } } // namespace } // namespace Rosen diff --git a/wm/test/systemtest/window_input_test.cpp b/wm/test/systemtest/window_input_test.cpp index b1577c60..5f57f2a0 100644 --- a/wm/test/systemtest/window_input_test.cpp +++ b/wm/test/systemtest/window_input_test.cpp @@ -24,14 +24,14 @@ namespace Rosen { namespace { constexpr uint32_t WAIT_ASYNC_US = 100000; // 100ms } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowInputTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullScreenWindow_; + Utils::TestWindowInfo fullScreenWindow_; }; void WindowInputTest::SetUpTestCase() @@ -39,7 +39,7 @@ void WindowInputTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowInputTest::TearDownTestCase() @@ -50,7 +50,7 @@ void WindowInputTest::SetUp() { fullScreenWindow_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -72,7 +72,7 @@ namespace { HWTEST_F(WindowInputTest, SetTouchHotAreas01, Function | MediumTest | Level3) { fullScreenWindow_.name = "window_hot_areas.1"; - const sptr& window = utils::CreateTestWindow(fullScreenWindow_); + const sptr& window = Utils::CreateTestWindow(fullScreenWindow_); ASSERT_EQ(WMError::WM_OK, window->Show()); std::vector requestedTouchHotAreas; @@ -121,7 +121,7 @@ HWTEST_F(WindowInputTest, SetTouchHotAreas01, Function | MediumTest | Level3) HWTEST_F(WindowInputTest, SetTouchHotAreas02, Function | MediumTest | Level3) { fullScreenWindow_.name = "window_hot_areas.2"; - const sptr& window = utils::CreateTestWindow(fullScreenWindow_); + const sptr& window = Utils::CreateTestWindow(fullScreenWindow_); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_ASYNC_US); diff --git a/wm/test/systemtest/window_layout_test.cpp b/wm/test/systemtest/window_layout_test.cpp index 65f0313b..d84a018b 100644 --- a/wm/test/systemtest/window_layout_test.cpp +++ b/wm/test/systemtest/window_layout_test.cpp @@ -22,7 +22,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowLayoutTest : public testing::Test { public: static void SetUpTestCase(); @@ -44,30 +44,30 @@ void WindowLayoutTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); // calc expected rects Rect expected = { // 0. only statusBar 0, - utils::statusBarRect_.height_, - utils::displayRect_.width_, - utils::displayRect_.height_ - utils::statusBarRect_.height_, + Utils::statusBarRect_.height_, + Utils::displayRect_.width_, + Utils::displayRect_.height_ - Utils::statusBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); expected = { // 1. both statusBar and naviBar 0, - utils::statusBarRect_.height_, - utils::displayRect_.width_, - utils::displayRect_.height_ - utils::statusBarRect_.height_ - utils::naviBarRect_.height_, + Utils::statusBarRect_.height_, + Utils::displayRect_.width_, + Utils::displayRect_.height_ - Utils::statusBarRect_.height_ - Utils::naviBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); expected = { // 2. only naviBar 0, 0, - utils::displayRect_.width_, - utils::displayRect_.height_ - utils::naviBarRect_.height_, + Utils::displayRect_.width_, + Utils::displayRect_.height_ - Utils::naviBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); } @@ -102,7 +102,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -111,11 +111,11 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -126,24 +126,24 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - Rect res = utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_); + Rect res = Utils::GetFloatingLimitedRect(Utils::customAppRect_, virtualPixelRatio_); if (window->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(window, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(window, res)); + ASSERT_TRUE(Utils::RectEqualTo(window, res)); } ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -156,40 +156,40 @@ HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3) { // app window - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, .parentLimit = false, .parentName = "", }; - sptr appWin = utils::CreateTestWindow(info); + sptr appWin = Utils::CreateTestWindow(info); activeWindows_.push_back(appWin); // statusBar window - sptr statBar = utils::CreateStatusBarWindow(); + sptr statBar = Utils::CreateStatusBarWindow(); activeWindows_.push_back(statBar); ASSERT_EQ(WMError::WM_OK, appWin->Show()); - Rect res = utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_); + Rect res = Utils::GetFloatingLimitedRect(Utils::customAppRect_, virtualPixelRatio_); if (appWin->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(appWin, res)); + ASSERT_TRUE(Utils::RectEqualTo(appWin, res)); } ASSERT_EQ(WMError::WM_OK, statBar->Show()); if (appWin->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(appWin, res)); + ASSERT_TRUE(Utils::RectEqualTo(appWin, res)); } ASSERT_EQ(WMError::WM_OK, statBar->Hide()); if (appWin->IsDecorEnable()) { - ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_))); + ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_))); } else { - ASSERT_TRUE(utils::RectEqualTo(appWin, res)); + ASSERT_TRUE(Utils::RectEqualTo(appWin, res)); } } @@ -201,33 +201,33 @@ HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, LayoutWindow06, Function | MediumTest | Level3) { // statusBar window - sptr statBar = utils::CreateStatusBarWindow(); + sptr statBar = Utils::CreateStatusBarWindow(); activeWindows_.push_back(statBar); // naviBar window - sptr naviBar = utils::CreateNavigationBarWindow(); + sptr naviBar = Utils::CreateNavigationBarWindow(); activeWindows_.push_back(naviBar); // sys window - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_PANEL, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, .parentLimit = true, .parentName = "", }; - sptr sysWin = utils::CreateTestWindow(info); + sptr sysWin = Utils::CreateTestWindow(info); activeWindows_.push_back(sysWin); ASSERT_EQ(WMError::WM_OK, statBar->Show()); ASSERT_EQ(WMError::WM_OK, sysWin->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, naviBar->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, statBar->Hide()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_)); } /** @@ -238,33 +238,33 @@ HWTEST_F(WindowLayoutTest, LayoutWindow06, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, LayoutWindow07, Function | MediumTest | Level3) { // statusBar window - sptr statBar = utils::CreateStatusBarWindow(); + sptr statBar = Utils::CreateStatusBarWindow(); activeWindows_.push_back(statBar); // naviBar window - sptr naviBar = utils::CreateNavigationBarWindow(); + sptr naviBar = Utils::CreateNavigationBarWindow(); activeWindows_.push_back(naviBar); // sys window - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_PANEL, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, .parentLimit = true, .parentName = "", }; - sptr sysWin = utils::CreateTestWindow(info); + sptr sysWin = Utils::CreateTestWindow(info); activeWindows_.push_back(sysWin); ASSERT_EQ(WMError::WM_OK, statBar->Show()); ASSERT_EQ(WMError::WM_OK, sysWin->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); ASSERT_EQ(WMError::WM_OK, naviBar->Show()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); ASSERT_EQ(WMError::WM_OK, statBar->Hide()); - ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_)); + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); } /** @@ -274,7 +274,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow07, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -283,11 +283,11 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -298,7 +298,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -307,17 +307,17 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Resize(2u, 2u)); // 2: custom min size Rect finalExcept = { expect.posX_, expect.posY_, 2u, 2u}; // 2: custom min size - finalExcept = utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_); - ASSERT_TRUE(utils::RectEqualTo(window, finalExcept)); + finalExcept = Utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_); + ASSERT_TRUE(Utils::RectEqualTo(window, finalExcept)); ASSERT_EQ(WMError::WM_OK, window->Hide()); } @@ -328,7 +328,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -337,15 +337,15 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Maximize()); - ASSERT_TRUE(utils::RectEqualTo(window, utils::displayRect_)); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::displayRect_)); ASSERT_EQ(WMError::WM_OK, window->Recover()); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); ASSERT_EQ(WMError::WM_OK, window->Minimize()); ASSERT_EQ(WMError::WM_OK, window->Close()); } @@ -357,7 +357,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -367,47 +367,47 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); // init tile window rects and get max tile window num - utils::InitTileWindowRects(window); - uint32_t maxTileNum = utils::GetMaxTileWinNum(); + Utils::InitTileWindowRects(window); + uint32_t maxTileNum = Utils::GetMaxTileWinNum(); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_)); info.name = "test1"; - const sptr& test1 = utils::CreateTestWindow(info); + const sptr& test1 = Utils::CreateTestWindow(info); activeWindows_.push_back(test1); ASSERT_EQ(WMError::WM_OK, test1->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 1) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::singleTileRect_)); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[1])); info.name = "test2"; - const sptr& test2 = utils::CreateTestWindow(info); + const sptr& test2 = Utils::CreateTestWindow(info); activeWindows_.push_back(test2); ASSERT_EQ(WMError::WM_OK, test2->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 2) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::doubleTileRects_[1])); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::tripleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::tripleTileRects_[1])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::tripleTileRects_[2])); // 2 is second rect idx + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::tripleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::tripleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::tripleTileRects_[2])); // 2 is second rect idx WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); } @@ -418,7 +418,7 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {-1, -100, -1, -100}, // -1, -100, -1, -100 is typical negative case nums .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -427,45 +427,45 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); ASSERT_EQ(WMError::WM_OK, window->Show()); // init tile window rects and get max tile window num - utils::InitTileWindowRects(window); - uint32_t maxTileNum = utils::GetMaxTileWinNum(); + Utils::InitTileWindowRects(window); + uint32_t maxTileNum = Utils::GetMaxTileWinNum(); usleep(WAIT_SYANC_US); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_)); info.name = "test1"; - const sptr& test1 = utils::CreateTestWindow(info); + const sptr& test1 = Utils::CreateTestWindow(info); activeWindows_.push_back(test1); ASSERT_EQ(WMError::WM_OK, test1->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 1) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::singleTileRect_)); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::singleTileRect_)); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[1])); info.name = "test2"; - const sptr& test2 = utils::CreateTestWindow(info); + const sptr& test2 = Utils::CreateTestWindow(info); activeWindows_.push_back(test2); ASSERT_EQ(WMError::WM_OK, test2->Show()); usleep(WAIT_SYANC_US); if (maxTileNum == 2) { - ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::doubleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::doubleTileRects_[1])); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); return; } - ASSERT_TRUE(utils::RectEqualTo(window, utils::tripleTileRects_[0])); - ASSERT_TRUE(utils::RectEqualTo(test1, utils::tripleTileRects_[1])); - ASSERT_TRUE(utils::RectEqualTo(test2, utils::tripleTileRects_[2])); // 2 is second rect idx + ASSERT_TRUE(Utils::RectEqualTo(window, Utils::tripleTileRects_[0])); + ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::tripleTileRects_[1])); + ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::tripleTileRects_[2])); // 2 is second rect idx WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); } @@ -476,7 +476,7 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3) */ HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3) { - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -485,12 +485,12 @@ HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); } /** @@ -502,7 +502,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3) { const uint32_t negativeW = 0; const uint32_t negativeH = 0; - utils::TestWindowInfo info = { + Utils::TestWindowInfo info = { .name = "main", .rect = {0, 0, 0, 0}, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -511,17 +511,17 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3) .parentLimit = false, .parentName = "", }; - const sptr& window = utils::CreateTestWindow(info); + const sptr& window = Utils::CreateTestWindow(info); activeWindows_.push_back(window); - Rect expect = utils::GetDefaultFloatingRect(window); + Rect expect = Utils::GetDefaultFloatingRect(window); ASSERT_EQ(WMError::WM_OK, window->Show()); usleep(WAIT_SYANC_US); - ASSERT_TRUE(utils::RectEqualTo(window, expect)); + ASSERT_TRUE(Utils::RectEqualTo(window, expect)); window->Resize(negativeW, negativeH); usleep(WAIT_SYANC_US); Rect expect2 = {expect.posX_, expect.posY_, negativeW, negativeH}; - expect2 = utils::CalcLimitedRect(expect2, virtualPixelRatio_); - ASSERT_TRUE(utils::RectEqualTo(window, expect2)); + expect2 = Utils::CalcLimitedRect(expect2, virtualPixelRatio_); + ASSERT_TRUE(Utils::RectEqualTo(window, expect2)); } } } // namespace Rosen diff --git a/wm/test/systemtest/window_mode_support_info_test.cpp b/wm/test/systemtest/window_mode_support_info_test.cpp index 94165378..10222bae 100644 --- a/wm/test/systemtest/window_mode_support_info_test.cpp +++ b/wm/test/systemtest/window_mode_support_info_test.cpp @@ -22,15 +22,15 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowModeSupportInfoTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; - utils::TestWindowInfo fullAppInfo_1_; - utils::TestWindowInfo fullAppInfo_2_; + Utils::TestWindowInfo fullAppInfo_1_; + Utils::TestWindowInfo fullAppInfo_2_; private: static constexpr uint32_t WAIT_SYANC_US = 100000; }; @@ -40,7 +40,7 @@ void WindowModeSupportInfoTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowModeSupportInfoTest::TearDownTestCase() @@ -51,7 +51,7 @@ void WindowModeSupportInfoTest::SetUp() { fullAppInfo_1_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -60,7 +60,7 @@ void WindowModeSupportInfoTest::SetUp() }; fullAppInfo_2_ = { .name = "FullWindow2", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -81,7 +81,7 @@ namespace { */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetModeSupportInfo()); @@ -95,7 +95,7 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTe */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -127,7 +127,7 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTe */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); @@ -165,7 +165,7 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTe */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); @@ -189,9 +189,9 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullAppInfo_1_); + const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - const sptr& window2 = utils::CreateTestWindow(fullAppInfo_2_); + const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); @@ -212,7 +212,7 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) { - const sptr& window = utils::CreateTestWindow(fullAppInfo_1_); + const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); @@ -232,9 +232,9 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTe */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo07, Function | MediumTest | Level3) { - const sptr& window1 = utils::CreateTestWindow(fullAppInfo_1_); + const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); - const sptr& window2 = utils::CreateTestWindow(fullAppInfo_2_); + const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); diff --git a/wm/test/systemtest/window_move_drag_test.cpp b/wm/test/systemtest/window_move_drag_test.cpp index 214865ea..6b0de20f 100644 --- a/wm/test/systemtest/window_move_drag_test.cpp +++ b/wm/test/systemtest/window_move_drag_test.cpp @@ -30,7 +30,7 @@ namespace { constexpr float DRAG_HOTZONE_RATIO = 0.6; constexpr int WAIT_SYANC_MS = 100000; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowMoveDragTest : public testing::Test { public: static void SetUpTestCase(); @@ -81,7 +81,7 @@ void WindowMoveDragTest::SetUp() WLOGFI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n", (unsigned long long)display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); hotZone_ = static_cast(HOTZONE * virtualPixelRatio_); @@ -127,19 +127,19 @@ void WindowMoveDragTest::DoMoveOrDrag(bool isMove, bool isDrag) std::shared_ptr pointerEvent = CreatePointerEvent(startPointX_, startPointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_DOWN); window_->ConsumePointerEvent(pointerEvent); - ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), startPointRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), startPointRect_)); pointerEvent = CreatePointerEvent(pointX_, pointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_MOVE); window_->ConsumePointerEvent(pointerEvent); CalExpectRects(); usleep(WAIT_SYANC_MS); - ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), expectRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), expectRect_)); ASSERT_EQ(isMove, window_->startMoveFlag_); ASSERT_EQ(isDrag, window_->startDragFlag_); pointerEvent = CreatePointerEvent(pointX_, pointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_UP); window_->ConsumePointerEvent(pointerEvent); - ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), expectRect_)); + ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), expectRect_)); } void WindowMoveDragTest::CalExpectRects() @@ -180,7 +180,7 @@ void WindowMoveDragTest::CalExpectRects() hasStartMove_ = false; } } - bool isVertical = (utils::displayRect_.width_ < utils::displayRect_.height_) ? true : false; + bool isVertical = (Utils::displayRect_.width_ < Utils::displayRect_.height_) ? true : false; expectRect_ = WindowHelper::GetFixedWindowRectByLimitSize(oriRect, startPointRect_, isVertical, virtualPixelRatio_); } diff --git a/wm/test/systemtest/window_multi_ability_test.cpp b/wm/test/systemtest/window_multi_ability_test.cpp index 48db7bc5..0d8c9811 100644 --- a/wm/test/systemtest/window_multi_ability_test.cpp +++ b/wm/test/systemtest/window_multi_ability_test.cpp @@ -23,7 +23,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowMultiAbilityTest : public testing::Test { public: static void SetUpTestCase(); @@ -54,7 +54,7 @@ static void ShowHideWindowSceneCallable(int i) { unsigned int sleepTimeMs = i * SLEEP_MS; usleep(sleepTimeMs); - sptr scene = utils::CreateWindowScene(); + sptr scene = Utils::CreateWindowScene(); const int loop = 10; int j = 0; for (; j < loop; j++) { @@ -74,7 +74,7 @@ static void CreateDestroyWindowSceneCallable(int i) int j = 0; for (; j < loop; j++) { usleep(sleepTimeMs); - sptr scene = utils::CreateWindowScene(); + sptr scene = Utils::CreateWindowScene(); usleep(sleepTimeMs); ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); usleep(sleepTimeMs); @@ -94,11 +94,11 @@ static void CreateDestroyWindowSceneCallable(int i) */ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow01, Function | MediumTest | Level2) { - sptr scene1 = utils::CreateWindowScene(); - sptr scene2 = utils::CreateWindowScene(); - sptr scene3 = utils::CreateWindowScene(); - sptr scene4 = utils::CreateWindowScene(); - sptr scene5 = utils::CreateWindowScene(); + sptr scene1 = Utils::CreateWindowScene(); + sptr scene2 = Utils::CreateWindowScene(); + sptr scene3 = Utils::CreateWindowScene(); + sptr scene4 = Utils::CreateWindowScene(); + sptr scene5 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene1->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene2->GoForeground()); @@ -162,27 +162,27 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow03, Function | MediumTest | L */ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow04, Function | MediumTest | Level3) { - sptr scene1 = utils::CreateWindowScene(); + sptr scene1 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene1->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene1->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy()); - sptr scene2 = utils::CreateWindowScene(); + sptr scene2 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene2->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene2->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy()); - sptr scene3 = utils::CreateWindowScene(); + sptr scene3 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene3->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy()); - sptr scene4 = utils::CreateWindowScene(); + sptr scene4 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene4->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene4->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy()); - sptr scene5 = utils::CreateWindowScene(); + sptr scene5 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene5->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene5->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy()); @@ -195,19 +195,19 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow04, Function | MediumTest | L */ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow05, Function | MediumTest | Level3) { - sptr scene1 = utils::CreateWindowScene(); + sptr scene1 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene1->GoForeground()); - sptr scene2 = utils::CreateWindowScene(); - sptr scene3 = utils::CreateWindowScene(); + sptr scene2 = Utils::CreateWindowScene(); + sptr scene3 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene1->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy()); - sptr scene4 = utils::CreateWindowScene(); + sptr scene4 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene2->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene4->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene2->GoBackground()); - sptr scene5 = utils::CreateWindowScene(); + sptr scene5 = Utils::CreateWindowScene(); ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy()); ASSERT_EQ(WMError::WM_OK, scene5->GoForeground()); ASSERT_EQ(WMError::WM_OK, scene5->GoBackground()); diff --git a/wm/test/systemtest/window_occupied_area_change_test.cpp b/wm/test/systemtest/window_occupied_area_change_test.cpp index 4fea3ec0..8162cb9b 100644 --- a/wm/test/systemtest/window_occupied_area_change_test.cpp +++ b/wm/test/systemtest/window_occupied_area_change_test.cpp @@ -26,7 +26,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowOccupiedAreaChangeTest"}; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_ASYNC_US = 100000; // 100000us class TestOccupiedAreaChangeListener : public IOccupiedAreaChangeListener { @@ -43,8 +43,8 @@ public: virtual void SetUp() override; virtual void TearDown() override; static sptr testOccupiedAreaChangeListener_; - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo imeAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo imeAppInfo_; }; sptr WindowOccupiedAreaChangeTest::testOccupiedAreaChangeListener_ = @@ -65,7 +65,7 @@ void WindowOccupiedAreaChangeTest::SetUpTestCase() WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); } void WindowOccupiedAreaChangeTest::TearDownTestCase() @@ -76,7 +76,7 @@ void WindowOccupiedAreaChangeTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -85,7 +85,7 @@ void WindowOccupiedAreaChangeTest::SetUp() }; imeAppInfo_ = { .name = "ImeWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, .mode = WindowMode::WINDOW_MODE_FLOATING, }; @@ -104,13 +104,13 @@ namespace { HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "KeyboardHeightChangeTest01"; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); imeAppInfo_.name = "imeWindow1"; imeAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(imeAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(imeAppInfo_); ASSERT_NE(nullptr, window2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -133,13 +133,13 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, Function | Me HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "KeyboardHeightChangeTest02"; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); imeAppInfo_.name = "imeWindow2"; imeAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(imeAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(imeAppInfo_); ASSERT_NE(nullptr, window2); ASSERT_EQ(WMError::WM_OK, window1->Show()); @@ -162,13 +162,13 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, Function | Me HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest03, Function | MediumTest | Level3) { fullScreenAppInfo_.name = "KeyboardHeightChangeTest03"; - const sptr& window1 = utils::CreateTestWindow(fullScreenAppInfo_); + const sptr& window1 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_NE(nullptr, window1); window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_); imeAppInfo_.name = "imeWindow3"; imeAppInfo_.rect = { 10, 200, 300, 400 }; - const sptr& window2 = utils::CreateTestWindow(imeAppInfo_); + const sptr& window2 = Utils::CreateTestWindow(imeAppInfo_); ASSERT_NE(nullptr, window2); ASSERT_EQ(WMError::WM_OK, window1->Show()); diff --git a/wm/test/systemtest/window_rotation_test.cpp b/wm/test/systemtest/window_rotation_test.cpp index 5b6d390a..b2bab19c 100644 --- a/wm/test/systemtest/window_rotation_test.cpp +++ b/wm/test/systemtest/window_rotation_test.cpp @@ -27,7 +27,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class DisplayListener : public DisplayManager::IDisplayListener { public: virtual void OnCreate(DisplayId) override; @@ -51,7 +51,7 @@ public: virtual void SetUp() override; virtual void TearDown() override; std::vector> activeWindows_; - utils::TestWindowInfo fullInfo_; + Utils::TestWindowInfo fullInfo_; sptr displayListener_; sptr screenListener_; private: @@ -97,7 +97,7 @@ void WindowRotationTest::SetUp() { fullInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -132,7 +132,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3 { fullInfo_.name = "fullscreen.1"; fullInfo_.orientation_ = Orientation::UNSPECIFIED; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); @@ -163,7 +163,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3 { fullInfo_.name = "fullscreen.2"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); @@ -201,7 +201,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3 fullInfo_.name = "fullscreen.4"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; fullInfo_.mode = WindowMode::WINDOW_MODE_FLOATING; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); @@ -233,7 +233,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest4, Function | MediumTest | Level3 defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL); fullInfo_.name = "fullscreen.5"; fullInfo_.orientation_ = Orientation::HORIZONTAL; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); @@ -276,7 +276,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, Function | MediumTest | Level3 defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL); fullInfo_.name = "fullscreen.5"; fullInfo_.orientation_ = Orientation::HORIZONTAL; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode()); diff --git a/wm/test/systemtest/window_split_immersive_test.cpp b/wm/test/systemtest/window_split_immersive_test.cpp index 61b305f8..7a899cb5 100644 --- a/wm/test/systemtest/window_split_immersive_test.cpp +++ b/wm/test/systemtest/window_split_immersive_test.cpp @@ -23,7 +23,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowSplitImmersiveTest : public testing::Test { public: @@ -35,8 +35,8 @@ public: void HideAndUnregister(const sptr& fullWindow, const sptr& priWindow, const sptr& top); std::vector> activeWindows_; - utils::TestWindowInfo fullInfo_; - utils::TestWindowInfo splitInfo_; + Utils::TestWindowInfo fullInfo_; + Utils::TestWindowInfo splitInfo_; private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time @@ -54,7 +54,7 @@ void WindowSplitImmersiveTest::SetUp() { fullInfo_ = { .name = "fullscreen.1", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -64,7 +64,7 @@ void WindowSplitImmersiveTest::SetUp() splitInfo_ = { .name = "primary.1", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -92,14 +92,14 @@ namespace { HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, Function | MediumTest | Level3) { // create fullscreen win and show - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); // enter split mode splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); diff --git a/wm/test/systemtest/window_split_test.cpp b/wm/test/systemtest/window_split_test.cpp index 4bb0413f..18ce4183 100644 --- a/wm/test/systemtest/window_split_test.cpp +++ b/wm/test/systemtest/window_split_test.cpp @@ -21,7 +21,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; class WindowSplitTest : public testing::Test { public: static void SetUpTestCase(); @@ -29,8 +29,8 @@ public: virtual void SetUp() override; virtual void TearDown() override; std::vector> activeWindows_; - utils::TestWindowInfo fullInfo_; - utils::TestWindowInfo splitInfo_; + Utils::TestWindowInfo fullInfo_; + Utils::TestWindowInfo splitInfo_; private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time @@ -48,7 +48,7 @@ void WindowSplitTest::SetUp() { fullInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -58,7 +58,7 @@ void WindowSplitTest::SetUp() splitInfo_ = { .name = "", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = true, @@ -89,12 +89,12 @@ HWTEST_F(WindowSplitTest, SplitWindow01, Function | MediumTest | Level3) splitInfo_.name = "primary.1"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -120,11 +120,11 @@ HWTEST_F(WindowSplitTest, SplitWindow02, Function | MediumTest | Level3) splitInfo_.name = "secondary.2"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& secWindow = utils::CreateTestWindow(splitInfo_); + const sptr& secWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(secWindow); ASSERT_EQ(WMError::WM_OK, secWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -150,21 +150,21 @@ HWTEST_F(WindowSplitTest, SplitScreen03, Function | MediumTest | Level3) splitInfo_.name = "primary.3"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - ASSERT_TRUE(utils::InitSplitRects()); + ASSERT_TRUE(Utils::InitSplitRects()); - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - utils::UpdateSplitRects(fullWindow); + Utils::UpdateSplitRects(fullWindow); - ASSERT_TRUE(utils::RectEqualTo(fullWindow, utils::splitRects_.secondaryRect)); - ASSERT_TRUE(utils::RectEqualTo(priWindow, utils::splitRects_.primaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.secondaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(priWindow, Utils::splitRects_.primaryRect)); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); @@ -183,21 +183,21 @@ HWTEST_F(WindowSplitTest, SplitScreen04, Function | MediumTest | Level3) splitInfo_.name = "secondary.4"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; - ASSERT_TRUE(utils::InitSplitRects()); + ASSERT_TRUE(Utils::InitSplitRects()); - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& secWindow = utils::CreateTestWindow(splitInfo_); + const sptr& secWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(secWindow); ASSERT_EQ(WMError::WM_OK, secWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - utils::UpdateSplitRects(fullWindow); + Utils::UpdateSplitRects(fullWindow); - ASSERT_TRUE(utils::RectEqualTo(fullWindow, utils::splitRects_.primaryRect)); - ASSERT_TRUE(utils::RectEqualTo(secWindow, utils::splitRects_.secondaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.primaryRect)); + ASSERT_TRUE(Utils::RectEqualTo(secWindow, Utils::splitRects_.secondaryRect)); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); @@ -216,12 +216,12 @@ HWTEST_F(WindowSplitTest, SplitScreen05, Function | MediumTest | Level3) splitInfo_.name = "primary.5"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -229,13 +229,13 @@ HWTEST_F(WindowSplitTest, SplitScreen05, Function | MediumTest | Level3) ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode()); ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode()); - utils::TestWindowInfo dividerInfo; + Utils::TestWindowInfo dividerInfo; dividerInfo.name = "divider0"; dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE; dividerInfo.mode = WindowMode::WINDOW_MODE_FLOATING; dividerInfo.focusable_ = false; - const sptr& divider = utils::CreateTestWindow(dividerInfo); + const sptr& divider = Utils::CreateTestWindow(dividerInfo); activeWindows_.push_back(divider); ASSERT_EQ(WMError::WM_OK, divider->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -271,23 +271,23 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3) splitInfo_.name = "primary.6"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - const sptr& fullWindow = utils::CreateTestWindow(fullInfo_); + const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); activeWindows_.push_back(fullWindow); ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - const sptr& priWindow = utils::CreateTestWindow(splitInfo_); + const sptr& priWindow = Utils::CreateTestWindow(splitInfo_); activeWindows_.push_back(priWindow); ASSERT_EQ(WMError::WM_OK, priWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - utils::TestWindowInfo dividerInfo; + Utils::TestWindowInfo dividerInfo; dividerInfo.name = "divider0"; dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE; dividerInfo.mode = WindowMode::WINDOW_MODE_FLOATING; dividerInfo.focusable_ = false; - const sptr& divider = utils::CreateTestWindow(dividerInfo); + const sptr& divider = Utils::CreateTestWindow(dividerInfo); activeWindows_.push_back(divider); ASSERT_EQ(WMError::WM_OK, divider->Show()); sleep(SPLIT_TEST_SLEEP_S); @@ -297,7 +297,7 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3) int32_t posX, posY; posX = posY = 0; std::shared_ptr pointerEvent = - utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_DOWN); + Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_DOWN); divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); @@ -306,13 +306,13 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3) } else { posY += 10; } - pointerEvent = utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_MOVE); + pointerEvent = Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_MOVE); divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); Rect moveRect = divider->GetRect(); ASSERT_TRUE(rect.posX_ != moveRect.posX_ || rect.posY_ != moveRect.posY_); - pointerEvent = utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_UP); + pointerEvent = Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_UP); divider->ConsumePointerEvent(pointerEvent); sleep(SPLIT_TEST_SLEEP_S); Rect newRect = divider->GetRect(); diff --git a/wm/test/systemtest/window_touch_outside_test.cpp b/wm/test/systemtest/window_touch_outside_test.cpp index 0a4e197f..39b076e2 100644 --- a/wm/test/systemtest/window_touch_outside_test.cpp +++ b/wm/test/systemtest/window_touch_outside_test.cpp @@ -26,7 +26,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { -using utils = WindowTestUtils; +using Utils = WindowTestUtils; const int WAIT_CALLBACK_US = 10000; // 10000 us class WindowTouchOutsideTestListener : public ITouchOutsideListener { @@ -47,9 +47,9 @@ public: static sptr windowlistener1_; static sptr windowlistener2_; - utils::TestWindowInfo firstWindowInfo_; - utils::TestWindowInfo secondWindowInfo_; - utils::TestWindowInfo thirdWindowInfo_; + Utils::TestWindowInfo firstWindowInfo_; + Utils::TestWindowInfo secondWindowInfo_; + Utils::TestWindowInfo thirdWindowInfo_; }; sptr WindowTouchOutsideTest::windowlistener1_ = @@ -112,7 +112,7 @@ namespace { */ HWTEST_F(WindowTouchOutsideTest, onTouchIutside, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); firstWindow->Show(); SingletonContainer::Get().ProcessPointDown(firstWindow->GetWindowId()); @@ -128,9 +128,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchIutside, Function | MediumTest | Level3) */ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); firstWindow->Show(); secondWindow->Show(); SingletonContainer::Get().ProcessPointDown(secondWindow->GetWindowId()); @@ -147,9 +147,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3) */ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); secondWindow->Show(); SingletonContainer::Get().ProcessPointDown(secondWindow->GetWindowId()); usleep(WAIT_CALLBACK_US); @@ -165,13 +165,13 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest | */ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, Function | MediumTest | Level3) { - const sptr &firstWindow = utils::CreateTestWindow(firstWindowInfo_); + const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = utils::CreateTestWindow(secondWindowInfo_); + const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener2_); firstWindow->Show(); secondWindow->Show(); - const sptr &thirdWindow = utils::CreateTestWindow(thirdWindowInfo_); + const sptr &thirdWindow = Utils::CreateTestWindow(thirdWindowInfo_); thirdWindow->Show(); SingletonContainer::Get().ProcessPointDown(thirdWindow->GetWindowId()); usleep(WAIT_CALLBACK_US); diff --git a/wm/test/systemtest/window_visibility_info_test.cpp b/wm/test/systemtest/window_visibility_info_test.cpp index 085583c8..1286ba4b 100644 --- a/wm/test/systemtest/window_visibility_info_test.cpp +++ b/wm/test/systemtest/window_visibility_info_test.cpp @@ -35,7 +35,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowVisibilityInfoTest"}; } -using utils = WindowTestUtils; +using Utils = WindowTestUtils; constexpr int WAIT_ASYNC_MS_TIME_OUT = 2000; // 2000ms #define CHECK_DISPLAY_POWER_STATE_RETURN() \ @@ -110,9 +110,9 @@ public: } static void WaitForCallback(); - utils::TestWindowInfo fullScreenAppInfo_; - utils::TestWindowInfo floatAppInfo_; - utils::TestWindowInfo subAppInfo_; + Utils::TestWindowInfo fullScreenAppInfo_; + Utils::TestWindowInfo floatAppInfo_; + Utils::TestWindowInfo subAppInfo_; }; void WindowVisibilityInfoTest::SetUpTestCase() @@ -123,7 +123,7 @@ void WindowVisibilityInfoTest::SetUpTestCase() display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); Rect displayRect = {0, 0, static_cast(display->GetWidth()), static_cast(display->GetHeight())}; - utils::InitByDisplayRect(displayRect); + Utils::InitByDisplayRect(displayRect); WindowManager::GetInstance().RegisterVisibilityChangedListener(visibilityChangedListener_); DisplayManager::GetInstance().RegisterDisplayPowerEventListener(displayPowerEventListener_); } @@ -138,7 +138,7 @@ void WindowVisibilityInfoTest::SetUp() { fullScreenAppInfo_ = { .name = "FullWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, .needAvoid = false, @@ -147,7 +147,7 @@ void WindowVisibilityInfoTest::SetUp() }; floatAppInfo_ = { .name = "ParentWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -156,7 +156,7 @@ void WindowVisibilityInfoTest::SetUp() }; subAppInfo_ = { .name = "SubWindow", - .rect = utils::customAppRect_, + .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -189,12 +189,12 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, Function | Medium { floatAppInfo_.name = "window1"; floatAppInfo_.rect = {250, 150, 300, 500}; - sptr window1 = utils::CreateTestWindow(floatAppInfo_); + sptr window1 = Utils::CreateTestWindow(floatAppInfo_); subAppInfo_.name = "subWindow1"; subAppInfo_.rect = {400, 200, 100, 100}; subAppInfo_.parentName = window1->GetWindowName(); - sptr subWindow1 = utils::CreateTestWindow(subAppInfo_); + sptr subWindow1 = Utils::CreateTestWindow(subAppInfo_); ASSERT_EQ(WMError::WM_OK, window1->Show()); WaitForCallback(); @@ -251,10 +251,10 @@ end: HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest02, Function | MediumTest | Level1) { fullScreenAppInfo_.name = "window1"; - sptr window1 = utils::CreateTestWindow(fullScreenAppInfo_); + sptr window1 = Utils::CreateTestWindow(fullScreenAppInfo_); fullScreenAppInfo_.name = "window2"; - sptr window2 = utils::CreateTestWindow(fullScreenAppInfo_); + sptr window2 = Utils::CreateTestWindow(fullScreenAppInfo_); ASSERT_EQ(WMError::WM_OK, window1->Show()); WaitForCallback(); @@ -282,20 +282,20 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest03, Function | Medium { floatAppInfo_.name = "window1"; floatAppInfo_.rect = {0, 0, 300, 600}; - sptr window1 = utils::CreateTestWindow(floatAppInfo_); + sptr window1 = Utils::CreateTestWindow(floatAppInfo_); subAppInfo_.name = "subWindow1"; subAppInfo_.rect = {400, 200, 100, 100}; subAppInfo_.parentName = window1->GetWindowName(); - sptr subWindow1 = utils::CreateTestWindow(subAppInfo_); + sptr subWindow1 = Utils::CreateTestWindow(subAppInfo_); floatAppInfo_.name = "window2"; - sptr window2 = utils::CreateTestWindow(floatAppInfo_); + sptr window2 = Utils::CreateTestWindow(floatAppInfo_); subAppInfo_.name = "subWindow2"; subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA; subAppInfo_.parentName = window2->GetWindowName(); - sptr subWindow2 = utils::CreateTestWindow(subAppInfo_); + sptr subWindow2 = Utils::CreateTestWindow(subAppInfo_); ASSERT_EQ(WMError::WM_OK, window2->Show()); WaitForCallback(); @@ -337,15 +337,15 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest04, Function | Medium { floatAppInfo_.name = "window1"; floatAppInfo_.rect = {0, 0, 300, 600}; - sptr window1 = utils::CreateTestWindow(floatAppInfo_); + sptr window1 = Utils::CreateTestWindow(floatAppInfo_); floatAppInfo_.name = "window2"; floatAppInfo_.rect = {0, 0, 300, 300}; - sptr window2 = utils::CreateTestWindow(floatAppInfo_); + sptr window2 = Utils::CreateTestWindow(floatAppInfo_); floatAppInfo_.name = "window3"; floatAppInfo_.rect = {0, 300, 300, 300}; - sptr window3 = utils::CreateTestWindow(floatAppInfo_); + sptr window3 = Utils::CreateTestWindow(floatAppInfo_); ASSERT_EQ(WMError::WM_OK, window1->Show()); WaitForCallback(); From 20fe7a211102e1a498de27beb32ac810efa0df58 Mon Sep 17 00:00:00 2001 From: chyyy0213 Date: Thu, 23 Jun 2022 15:17:56 +0800 Subject: [PATCH 09/12] add animation property config Signed-off-by: chyyy0213 Change-Id: I867f7189636ae398753848bd4f09bcb10317602b Signed-off-by: chyyy0213 --- interfaces/innerkits/wm/window.h | 8 +- interfaces/innerkits/wm/window_option.h | 3 - interfaces/innerkits/wm/wm_common.h | 19 ++ interfaces/kits/napi/window_runtime/BUILD.gn | 1 + .../napi/window_runtime/api/@ohos.window.d.ts | 110 +++++++- .../window_runtime/window_napi/js_window.cpp | 239 +++++++++++++++++- .../window_runtime/window_napi/js_window.h | 13 + .../window_napi/js_window_utils.cpp | 15 ++ .../window_napi/js_window_utils.h | 1 + utils/include/window_property.h | 11 +- utils/include/wm_common_inner.h | 1 + utils/src/window_property.cpp | 49 +++- wm/include/window_adapter.h | 1 - wm/include/window_impl.h | 8 +- wm/src/window_adapter.cpp | 7 - wm/src/window_impl.cpp | 36 ++- wm/src/window_option.cpp | 10 - .../windowscene_fuzzer/windowscene_fuzzer.cpp | 3 - wm/test/systemtest/window_effect_test.cpp | 2 +- wm/test/unittest/mock_window_adapter.h | 1 - wm/test/unittest/window_effect_test.cpp | 55 +--- wmserver/include/window_manager_service.h | 1 - wmserver/include/window_node.h | 3 +- .../include/zidl/window_manager_interface.h | 1 - wmserver/include/zidl/window_manager_proxy.h | 1 - wmserver/src/window_controller.cpp | 16 +- wmserver/src/window_manager_service.cpp | 13 +- wmserver/src/window_node.cpp | 11 +- wmserver/src/window_node_container.cpp | 6 +- wmserver/src/zidl/window_manager_proxy.cpp | 26 -- wmserver/src/zidl/window_manager_stub.cpp | 7 - 31 files changed, 508 insertions(+), 170 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index c1451688..b850114b 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -169,7 +169,9 @@ public: virtual WMError SetWindowType(WindowType type) = 0; virtual WMError SetWindowMode(WindowMode mode) = 0; virtual WMError SetWindowBackgroundBlur(WindowBlurLevel level) = 0; - virtual WMError SetAlpha(float alpha) = 0; + virtual void SetAlpha(float alpha) = 0; + virtual void SetTransform(const Transform& trans) = 0; + virtual Transform GetTransform() const = 0; virtual WMError AddWindowFlag(WindowFlag flag) = 0; virtual WMError RemoveWindowFlag(WindowFlag flag) = 0; virtual WMError SetWindowFlags(uint32_t flags) = 0; @@ -178,8 +180,8 @@ public: virtual WMError SetLayoutFullScreen(bool status) = 0; virtual WMError SetFullScreen(bool status) = 0; virtual WMError Destroy() = 0; - virtual WMError Show(uint32_t reason = 0) = 0; - virtual WMError Hide(uint32_t reason = 0) = 0; + virtual WMError Show(uint32_t reason = 0, bool isCustomAnimation = false) = 0; + virtual WMError Hide(uint32_t reason = 0, bool isCustomAnimation = false) = 0; virtual WMError MoveTo(int32_t x, int32_t y) = 0; virtual WMError Resize(uint32_t width, uint32_t height) = 0; diff --git a/interfaces/innerkits/wm/window_option.h b/interfaces/innerkits/wm/window_option.h index fb2dd7ed..83dffb17 100644 --- a/interfaces/innerkits/wm/window_option.h +++ b/interfaces/innerkits/wm/window_option.h @@ -33,7 +33,6 @@ public: void SetWindowType(WindowType type); void SetWindowMode(WindowMode mode); void SetWindowBackgroundBlur(WindowBlurLevel level); - void SetAlpha(float alpha); void SetFocusable(bool isFocusable); void SetTouchable(bool isTouchable); void SetDisplayId(DisplayId displayId); @@ -58,7 +57,6 @@ public: WindowType GetWindowType() const; WindowMode GetWindowMode() const; WindowBlurLevel GetWindowBackgroundBlur() const; - float GetAlpha() const; bool GetFocusable() const; bool GetTouchable() const; DisplayId GetDisplayId() const; @@ -75,7 +73,6 @@ private: WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; WindowMode mode_ { WindowMode::WINDOW_MODE_FULLSCREEN }; WindowBlurLevel level_ { WindowBlurLevel::WINDOW_BLUR_OFF }; - float alpha_ { 1.0f }; bool focusable_ { true }; bool touchable_ { true }; DisplayId displayId_ { 0 }; diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 24da28ce..487edcc2 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -172,6 +172,25 @@ namespace { constexpr int32_t INVALID_UID = -1; } +class Transform { +public: + Transform() + : pivotX_(0.5f), pivotY_(0.5f), scaleX_(1.f), scaleY_(1.f), rotationX_(0.f), rotationY_(0.f), rotationZ_(0.f), + translateX_(0.f), translateY_(0.f), translateZ_(0.f) + {} + ~Transform() {} + float pivotX_; + float pivotY_; + float scaleX_; + float scaleY_; + float rotationX_; + float rotationY_; + float rotationZ_; + float translateX_; + float translateY_; + float translateZ_; +}; + struct SystemBarProperty { bool enable_; uint32_t backgroundColor_; diff --git a/interfaces/kits/napi/window_runtime/BUILD.gn b/interfaces/kits/napi/window_runtime/BUILD.gn index 2d3c1a75..c06c8e0a 100644 --- a/interfaces/kits/napi/window_runtime/BUILD.gn +++ b/interfaces/kits/napi/window_runtime/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("window_native_kit") { configs = [ ":window_native_kit_config" ] deps = [ + "//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", "//foundation/windowmanager/utils:libwmutil", "//foundation/windowmanager/wm:libwm", "//foundation/windowmanager/wmserver:libwms", diff --git a/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts b/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts index dfd3821b..55fe7e34 100644 --- a/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts +++ b/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts @@ -91,6 +91,82 @@ declare namespace window { */ TYPE_KEYBOARD } + + /** + * Describes the scale Transition Options of window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @systemapi + */ + declare interface ScaleOptions { + /** + * The scale param of x direction. Default is 1.f + */ + x?: number; + /** + * The scale param of y direction. Default is 1.f + */ + y?: number; + /** + * The scale param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotX?: number; + /** + * The scale param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotY?: number; + } + + /** + * Describes the rotate Transition Options of window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @systemapi + */ + declare interface RotateOptions { + /** + * The rotate degree of x direction. Default value is 0.f + */ + x?: number; + /** + * The rotate degree of y direction. Default value is 0.f + */ + y?: number; + /** + * The rotate degree of z direction. Default value is 0.f + */ + z?: number; + /** + * The param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotX?: number; + /** + * The param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f + */ + pivotY?: number; + } + + /** + * Describes the translate Transition Options of window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + * @systemapi + */ + declare interface TranslateOptions { + /** + * The translate pixel param of x direction. Default is 0.f + */ + x?: number; + /** + * The translate pixel param of y direction. Default is 0.f + */ + y?: number; + /** + * The translate pixel param of z direction. Default is 0.f + */ + z?: number; + } + /** * Describes the window mode of an application * @systemapi Hide this for inner system use. @@ -961,7 +1037,7 @@ declare namespace window { * @since 9 */ setPreferredOrientation(orientation: Orientation, callback: AsyncCallback): void; - + /** * disable window decoration. It must be called before loadContent. * @systemapi @@ -985,7 +1061,7 @@ declare namespace window { * @systemapi * @since 9 */ - setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback): void; + setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback): void; /** * set the flag of the window is forbidden to move in split screen mode @@ -994,7 +1070,35 @@ declare namespace window { * @systemapi * @since 9 */ - setForbidSplitMove(isForbidSplitMove: boolean): Promise; + setForbidSplitMove(isForbidSplitMove: boolean): Promise; + /** + * Sets opacity of window + * @param opacity Interval is 0.f-1.f. + * @systemapi + * @since 9 + */ + setOpacitySync(opacity: number): void; + /** + * Sets scale options of window. + * @param scaleOptions scale param of window. + * @systemapi + * @since 9 + */ + setScaleSync(scaleOptions: ScaleOptions): void; + /** + * Sets rotate options of window. + * @param rotateOptions rotate param of window. + * @systemapi + * @since 9 + */ + setRotateSync(rotateOptions: RotateOptions): void; + /** + * Sets whether is transparent or not. + * @param translateOptions translate param of window. + * @systemapi + * @since 9 + */ + setTranslateSync(translateOptions: TranslateOptions): void; } enum WindowStageEventType { diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index a2df4b41..cb8148f0 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -15,8 +15,10 @@ #include "js_window.h" #include +#include #include "js_window_utils.h" #include "window.h" +#include "window_helper.h" #include "window_manager_hilog.h" #include "window_option.h" namespace OHOS { @@ -29,24 +31,28 @@ namespace { static thread_local std::map> g_jsWindowMap; std::recursive_mutex g_mutex; +static int ctorCnt = 0; +static int dtorCnt = 0; +static int finalizerCnt = 0; JsWindow::JsWindow(const sptr& window) : windowToken_(window), registerManager_(std::make_unique()) { NotifyNativeWinDestroyFunc func = [](std::string windowName) { std::lock_guard lock(g_mutex); if (windowName.empty() || g_jsWindowMap.count(windowName) == 0) { - WLOGE("[NAPI]Can not find window %{public}s ", windowName.c_str()); + WLOGFE("[NAPI]Can not find window %{public}s ", windowName.c_str()); return; } g_jsWindowMap.erase(windowName); - WLOGE("[NAPI]Destroy window %{public}s in js window", windowName.c_str()); + WLOGFI("[NAPI]Destroy window %{public}s in js window", windowName.c_str()); }; windowToken_->RegisterWindowDestroyedListener(func); + WLOGFI("[NAPI] JsWindow constructor Count: %{public}d", ++ctorCnt); } JsWindow::~JsWindow() { - WLOGFI("[NAPI]~JsWindow"); + WLOGFI("[NAPI]~JsWindow deconstructor Count:%{public}d", ++dtorCnt); windowToken_ = nullptr; } @@ -60,7 +66,7 @@ std::string JsWindow::GetWindowName() void JsWindow::Finalizer(NativeEngine* engine, void* data, void* hint) { - WLOGFI("[NAPI]Finalizer"); + WLOGFI("[NAPI]Finalizer Count:%{public}d", ++finalizerCnt); auto jsWin = std::unique_ptr(static_cast(data)); if (jsWin == nullptr) { WLOGFE("[NAPI]jsWin is nullptr"); @@ -313,6 +319,34 @@ NativeValue* JsWindow::SetForbidSplitMove(NativeEngine* engine, NativeCallbackIn return (me != nullptr) ? me->OnSetForbidSplitMove(*engine, *info) : nullptr; } +NativeValue* JsWindow::SetOpacitySync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetOpacitySync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetOpacitySync(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetScaleSync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetScaleSync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetScaleSync(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetRotateSync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetRotateSync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetRotateSync(*engine, *info) : nullptr; +} + +NativeValue* JsWindow::SetTranslateSync(NativeEngine* engine, NativeCallbackInfo* info) +{ + WLOGFI("[NAPI]SetTranslateSync"); + JsWindow* me = CheckParamsAndGetThis(engine, info); + return (me != nullptr) ? me->OnSetTranslateSync(*engine, *info) : nullptr; +} + NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info) { WMError errCode = WMError::WM_OK; @@ -1643,6 +1677,199 @@ NativeValue* JsWindow::OnSetForbidSplitMove(NativeEngine& engine, NativeCallback return result; } +NativeValue* JsWindow::OnSetOpacitySync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetOpacitySync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeNumber* nativeVal = ConvertNativeValueTo(info.argv[0]); + if (nativeVal == nullptr) { + WLOGFE("[NAPI]Failed to convert parameter to alpha"); + return engine.CreateUndefined(); + } + float alpha = static_cast(*nativeVal); + windowToken_->SetAlpha(alpha); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetOpacitySync end, alpha = %{public}f", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), alpha); + return engine.CreateUndefined(); +} + +bool JsWindow::ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans) +{ + auto surfaceNode = windowToken_->GetSurfaceNode(); + if (surfaceNode == nullptr) { + WLOGFE("[NAPI] surfaceNode is nullptr"); + return false; + } + double data = 0.0f; + if (ParseJsDoubleValue(jsObject, engine, "pivotX", data)) { + surfaceNode->SetPivotX(data); + trans.pivotX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "pivotY", data)) { + surfaceNode->SetPivotY(data); + trans.pivotY_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "x", data)) { + surfaceNode->SetScaleX(data); + trans.scaleX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "y", data)) { + surfaceNode->SetScaleY(data); + trans.scaleY_ = data; + } + return true; +} + +NativeValue* JsWindow::OnSetScaleSync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetScaleSync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeObject* nativeObj = ConvertNativeValueTo(info.argv[0]); + if (nativeObj == nullptr) { + WLOGFE("[NAPI]Failed to convert object to ScaleOptions"); + return engine.CreateUndefined(); + } + auto trans = windowToken_->GetTransform(); + if (!ParseScaleOption(engine, nativeObj, trans)) { + return engine.CreateUndefined(); + } + windowToken_->SetTransform(trans); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetScaleSync end", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str()); + WLOGFI("[NAPI]scaleX = %{public}f, scaleY = %{public}f, pivotX = %{public}f pivotY = %{public}f", + trans.scaleX_, trans.scaleY_, trans.pivotX_, trans.pivotY_); + return engine.CreateUndefined(); +} + +bool JsWindow::ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans) +{ + auto surfaceNode = windowToken_->GetSurfaceNode(); + if (surfaceNode == nullptr) { + WLOGFE("[NAPI] surfaceNode is nullptr"); + return false; + } + double data = 0.0f; + if (ParseJsDoubleValue(jsObject, engine, "pivotX", data)) { + surfaceNode->SetPivotX(data); + trans.pivotX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "pivotY", data)) { + surfaceNode->SetPivotY(data); + trans.pivotY_ = data; + } + double coeff = 0.5 * 3.14 / 180; // 0.5 means half; 3.14 means pi; 180 means degree + if (ParseJsDoubleValue(jsObject, engine, "x", data)) { + float w = std::cos(data * coeff); + float x = std::sin(data * coeff); + surfaceNode->SetRotation(Quaternion(x, 0, 0, w)); + trans.rotationX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "y", data)) { + float w = std::cos(data * coeff); + float y = std::sin(data * coeff); + surfaceNode->SetRotation(Quaternion(0, y, 0, w)); + trans.rotationY_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "z", data)) { + float w = std::cos(data * coeff); + float z = std::sin(data * coeff); + surfaceNode->SetRotation(Quaternion(0, 0, z, w)); + trans.rotationZ_ = data; + } + return true; +} + +NativeValue* JsWindow::OnSetRotateSync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetRotateSync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeObject* nativeObj = ConvertNativeValueTo(info.argv[0]); + if (nativeObj == nullptr) { + WLOGFE("[NAPI]Failed to convert object to RotateOptions"); + return engine.CreateUndefined(); + } + // cannot use sync task since next transform base on current transform + auto trans = windowToken_->GetTransform(); + if (!ParseRotateOption(engine, nativeObj, trans)) { + return engine.CreateUndefined(); + } + windowToken_->SetTransform(trans); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetRotateSync end", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str()); + WLOGFI("[NAPI]rotateX = %{public}f, rotateY = %{public}f," \ + "rotateZ = %{public}f pivotX = %{public}f pivotY = %{public}f", + trans.rotationX_, trans.rotationY_, trans.rotationZ_, trans.pivotX_, trans.pivotY_); + return engine.CreateUndefined(); +} + +bool JsWindow::ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans) +{ + auto surfaceNode = windowToken_->GetSurfaceNode(); + if (surfaceNode == nullptr) { + WLOGFE("[NAPI] surfaceNode is nullptr"); + return false; + } + double data = 0.0f; + if (ParseJsDoubleValue(jsObject, engine, "x", data)) { + surfaceNode->SetTranslateX(data); + trans.translateX_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "y", data)) { + surfaceNode->SetTranslateY(data); + trans.translateY_ = data; + } + if (ParseJsDoubleValue(jsObject, engine, "z", data)) { + surfaceNode->SetTranslateZ(data); + trans.translateZ_ = data; + } + return true; +} + +NativeValue* JsWindow::OnSetTranslateSync(NativeEngine& engine, NativeCallbackInfo& info) +{ + if (info.argc != 1 || windowToken_ == nullptr) { + WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc); + return engine.CreateUndefined(); + } + if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) { + WLOGFE("[NAPI]SetTranslateSync is not allowed since window is not system window"); + return engine.CreateUndefined(); + } + NativeObject* nativeObj = ConvertNativeValueTo(info.argv[0]); + if (nativeObj == nullptr) { + WLOGFE("[NAPI]Failed to convert object to TranslateOptions"); + return engine.CreateUndefined(); + } + auto trans = windowToken_->GetTransform(); + if (!ParseTranslateOption(engine, nativeObj, trans)) { + return engine.CreateUndefined(); + } + windowToken_->SetTransform(trans); + WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetRotateSync end," \ + "translateX = %{public}f, translateY = %{public}f, translateZ = %{public}f", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), + trans.translateX_, trans.translateY_, trans.translateZ_); + return engine.CreateUndefined(); +} + std::shared_ptr FindJsWindowObject(std::string windowName) { WLOGFI("[NAPI]Try to find window %{public}s in g_jsWindowMap", windowName.c_str()); @@ -1716,6 +1943,10 @@ void BindFunctions(NativeEngine& engine, NativeObject* object) BindNativeFunction(engine, *object, "dump", JsWindow::Dump); BindNativeFunction(engine, *object, "setForbidSplitMove", JsWindow::SetForbidSplitMove); BindNativeFunction(engine, *object, "setPreferredOrientation", JsWindow::SetPreferredOrientation); + BindNativeFunction(engine, *object, "setOpacitySync", JsWindow::SetOpacitySync); + BindNativeFunction(engine, *object, "setScaleSync", JsWindow::SetScaleSync); + BindNativeFunction(engine, *object, "setRotateSync", JsWindow::SetRotateSync); + BindNativeFunction(engine, *object, "setTranslateSync", JsWindow::SetTranslateSync); } } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 6a83610f..e6c2296f 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -69,8 +69,16 @@ public: static NativeValue* Dump(NativeEngine* engine, NativeCallbackInfo* info); static NativeValue* SetForbidSplitMove(NativeEngine* engine, NativeCallbackInfo* info); + // animation config + static NativeValue* SetOpacitySync(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetScaleSync(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetRotateSync(NativeEngine* engine, NativeCallbackInfo* info); + static NativeValue* SetTranslateSync(NativeEngine* engine, NativeCallbackInfo* info); private: std::string GetWindowName(); + bool ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans); + bool ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans); + bool ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans); NativeValue* OnShow(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnDestroy(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnHide(NativeEngine& engine, NativeCallbackInfo& info); @@ -108,6 +116,11 @@ private: NativeValue* OnDump(NativeEngine& engine, NativeCallbackInfo& info); NativeValue* OnSetForbidSplitMove(NativeEngine& engine, NativeCallbackInfo& info); + // animation Config + NativeValue* OnSetOpacitySync(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetScaleSync(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetRotateSync(NativeEngine& engine, NativeCallbackInfo& info); + NativeValue* OnSetTranslateSync(NativeEngine& engine, NativeCallbackInfo& info); sptr windowToken_ = nullptr; std::unique_ptr registerManager_ = nullptr; }; 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 9253f519..7baa240e 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 @@ -484,5 +484,20 @@ bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability) } return true; } + +bool ParseJsDoubleValue(NativeObject* jsObject, NativeEngine& engine, const std::string& name, double data) +{ + NativeValue* value = jsObject->GetProperty(name.c_str()); + if (value->TypeOf() != NATIVE_UNDEFINED) { + if (!ConvertFromJsValue(engine, value, data)) { + WLOGFE("[NAPI]Failed to convert parameter to scale %{public}s", name.c_str()); + return false; + } + } else { + WLOGFI("[NAPI]no property with: %{public}s", name.c_str()); + return false; + } + return true; +} } // namespace Rosen } // namespace OHOS 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 4765a8ad..b8c5c77a 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 @@ -165,6 +165,7 @@ const std::map JS_TO_NATIVE_ORIENTATION_MAP { NativeValue* WindowStageEventTypeInit(NativeEngine* engine); NativeValue* WindowLayoutModeInit(NativeEngine* engine); bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability); + bool ParseJsDoubleValue(NativeObject* jsObject, NativeEngine& engine, const std::string& name, double data); template inline bool ConvertNativeValueToVector(NativeEngine& engine, NativeValue* nativeValue, std::vector& out) { diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 7aec8721..32cc6e85 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -19,8 +19,7 @@ #include #include #include -#include "parcel.h" - +#include #include "class_var_definition.h" #include "dm_common.h" #include "wm_common.h" @@ -74,6 +73,7 @@ public: void SetTouchHotAreas(const std::vector& rects); void SetAccessTokenId(uint32_t accessTokenId); WindowSizeChangeReason GetWindowSizeChangeReason() const; + void SetTransform(const Transform& trans); const std::string& GetWindowName() const; Rect GetRequestRect() const; @@ -109,7 +109,7 @@ public: const Rect& GetOriginRect() const; void GetTouchHotAreas(std::vector& rects) const; uint32_t GetAccessTokenId() const; - + Transform GetTransform() const; virtual bool Marshalling(Parcel& parcel) const override; static WindowProperty* Unmarshalling(Parcel& parcel); @@ -120,7 +120,8 @@ private: static void MapUnmarshalling(Parcel& parcel, WindowProperty* property); bool MarshallingTouchHotAreas(Parcel& parcel) const; static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty* property); - + bool MarshallingTransform(Parcel& parcel) const; + static void UnmarshallingTransform(Parcel& parcel, WindowProperty* property); std::string windowName_; Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect @@ -158,7 +159,9 @@ private: DragType dragType_ = DragType::DRAG_UNDEFINED; std::vector touchHotAreas_; // coordinates relative to window. uint32_t accessTokenId_ { 0 }; + Transform trans_; DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED); + DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, CustomAnimation, isCustomAnimation, false); }; } } diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index 2e95688c..f5b0808c 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -84,6 +84,7 @@ enum class PropertyChangeAction : uint32_t { ACTION_UPDATE_SET_BRIGHTNESS = 1 << 10, ACTION_UPDATE_MODE_SUPPORT_INFO = 1 << 11, ACTION_UPDATE_TOUCH_HOT_AREA = 1 << 12, + ACTION_UPDATE_TRANSFORM_PROPERTY = 1 << 13, }; struct ModeChangeHotZonesConfig { diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index fa4f73d9..49a03836 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -103,6 +103,11 @@ void WindowProperty::SetAlpha(float alpha) alpha_ = alpha; } +void WindowProperty::SetTransform(const Transform& trans) +{ + trans_ = trans; +} + void WindowProperty::SetBrightness(float brightness) { brightness_ = brightness; @@ -270,6 +275,11 @@ float WindowProperty::GetAlpha() const return alpha_; } +Transform WindowProperty::GetTransform() const +{ + return trans_; +} + float WindowProperty::GetBrightness() const { return brightness_; @@ -407,7 +417,6 @@ bool WindowProperty::MapMarshalling(Parcel& parcel) const void WindowProperty::MapUnmarshalling(Parcel& parcel, WindowProperty* property) { - std::unordered_map sysBarPropMap; uint32_t size = parcel.ReadUint32(); for (uint32_t i = 0; i < size; i++) { WindowType type = static_cast(parcel.ReadUint32()); @@ -440,6 +449,31 @@ void WindowProperty::UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty* } } +bool WindowProperty::MarshallingTransform(Parcel& parcel) const +{ + return parcel.WriteFloat(trans_.pivotX_) && parcel.WriteFloat(trans_.pivotY_) && + parcel.WriteFloat(trans_.scaleX_) && parcel.WriteFloat(trans_.scaleY_) && + parcel.WriteFloat(trans_.rotationX_) && parcel.WriteFloat(trans_.rotationY_) && + parcel.WriteFloat(trans_.rotationZ_) && parcel.WriteFloat(trans_.translateX_) && + parcel.WriteFloat(trans_.translateY_) && parcel.WriteFloat(trans_.translateZ_); +} + +void WindowProperty::UnmarshallingTransform(Parcel& parcel, WindowProperty* property) +{ + Transform trans; + trans.pivotX_ = parcel.ReadFloat(); + trans.pivotY_ = parcel.ReadFloat(); + trans.scaleX_ = parcel.ReadFloat(); + trans.scaleY_ = parcel.ReadFloat(); + trans.rotationX_ = parcel.ReadFloat(); + trans.rotationY_ = parcel.ReadFloat(); + trans.rotationZ_ = parcel.ReadFloat(); + trans.translateX_ = parcel.ReadFloat(); + trans.translateY_ = parcel.ReadFloat(); + trans.translateZ_ = parcel.ReadFloat(); + property->SetTransform(trans); +} + bool WindowProperty::Marshalling(Parcel& parcel) const { return parcel.WriteString(windowName_) && parcel.WriteInt32(windowRect_.posX_) && @@ -460,7 +494,8 @@ bool WindowProperty::Marshalling(Parcel& parcel) const parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) && parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast(dragType_)) && parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) && - parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_); + parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) && + parcel.WriteBool(isCustomAnimation_) && MarshallingTransform(parcel); } WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) @@ -509,6 +544,8 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetStretchable(parcel.ReadBool()); UnmarshallingTouchHotAreas(parcel, property); property->SetAccessTokenId(parcel.ReadUint32()); + property->SetCustomAnimation(parcel.ReadBool()); + UnmarshallingTransform(parcel, property); return property; } @@ -560,6 +597,9 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: ret &= MarshallingTouchHotAreas(parcel); break; + case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY: + ret &= MarshallingTransform(parcel); + break; default: break; } @@ -613,6 +653,9 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: UnmarshallingTouchHotAreas(parcel, this); break; + case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY: + UnmarshallingTransform(parcel, this); + break; default: break; } @@ -655,6 +698,8 @@ void WindowProperty::CopyFrom(const sptr& property) isStretchable_ = property->isStretchable_; touchHotAreas_ = property->touchHotAreas_; accessTokenId_ = property->accessTokenId_; + isCustomAnimation_ = property->isCustomAnimation_; + trans_ = property->trans_; } } } diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 2be221d5..f749dc9e 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -43,7 +43,6 @@ public: virtual WMError RequestFocus(uint32_t windowId); virtual WMError GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, AvoidArea& avoidRect); virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level); - virtual WMError SetAlpha(uint32_t windowId, float alpha); virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId); virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag = false); virtual void ProcessPointUp(uint32_t windowId); diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 0ac4b1cb..b2f78193 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -127,13 +127,15 @@ public: virtual WMError SetWindowType(WindowType type) override; virtual WMError SetWindowMode(WindowMode mode) override; virtual WMError SetWindowBackgroundBlur(WindowBlurLevel level) override; - virtual WMError SetAlpha(float alpha) override; + virtual void SetAlpha(float alpha) override; + virtual void SetTransform(const Transform& trans) override; virtual WMError AddWindowFlag(WindowFlag flag) override; virtual WMError RemoveWindowFlag(WindowFlag flag) override; virtual WMError SetWindowFlags(uint32_t flags) override; virtual WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) override; virtual WMError SetLayoutFullScreen(bool status) override; virtual WMError SetFullScreen(bool status) override; + virtual Transform GetTransform() const override; inline void SetWindowState(WindowState state) { state_ = state; @@ -143,8 +145,8 @@ public: WMError Create(const std::string& parentName, const std::shared_ptr& context = nullptr); virtual WMError Destroy() override; - virtual WMError Show(uint32_t reason = 0) override; - virtual WMError Hide(uint32_t reason = 0) override; + virtual WMError Show(uint32_t reason = 0, bool isCustomAnimation = false) override; + virtual WMError Hide(uint32_t reason = 0, bool isCustomAnimation = false) override; virtual WMError MoveTo(int32_t x, int32_t y) override; virtual WMError Resize(uint32_t width, uint32_t height) override; virtual WMError SetKeepScreenOn(bool keepScreenOn) override; diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 2d2285a5..c044c26c 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -113,13 +113,6 @@ WMError WindowAdapter::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLeve return windowManagerServiceProxy_->SetWindowBackgroundBlur(windowId, level); } -WMError WindowAdapter::SetAlpha(uint32_t windowId, float alpha) -{ - INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); - - return windowManagerServiceProxy_->SetAlpha(windowId, alpha); -} - void WindowAdapter::ProcessPointDown(uint32_t windowId, bool isStartDrag) { INIT_PROXY_CHECK_RETURN(); diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 0dcecf56..eae5470c 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -48,7 +48,8 @@ const WindowImpl::ColorSpaceConvertMap WindowImpl::colorSpaceConvertMap[] = { std::map>> WindowImpl::windowMap_; std::map>> WindowImpl::subWindowMap_; std::map>> WindowImpl::appFloatingWindowMap_; - +static int ctorCnt = 0; +static int dtorCnt = 0; WindowImpl::WindowImpl(const sptr& option) { property_ = new (std::nothrow) WindowProperty(); @@ -57,7 +58,6 @@ WindowImpl::WindowImpl(const sptr& option) property_->SetWindowType(option->GetWindowType()); property_->SetWindowMode(option->GetWindowMode()); property_->SetWindowBackgroundBlur(option->GetWindowBackgroundBlur()); - property_->SetAlpha(option->GetAlpha()); property_->SetFullScreen(option->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN); property_->SetFocusable(option->GetFocusable()); property_->SetTouchable(option->GetTouchable()); @@ -81,6 +81,7 @@ WindowImpl::WindowImpl(const sptr& option) struct RSSurfaceNodeConfig rsSurfaceNodeConfig; rsSurfaceNodeConfig.SurfaceNodeName = property_->GetWindowName(); surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig); + WLOGFI("WindowImpl constructor Count: %{public}d name: %{public}s", ++ctorCnt, property_->GetWindowName().c_str()); } void WindowImpl::InitListenerHandler() @@ -104,7 +105,8 @@ WindowImpl::~WindowImpl() if (eventHandler_ != nullptr) { eventHandler_.reset(); } - WLOGFI("windowName: %{public}s, windowId: %{public}d", GetWindowName().c_str(), GetWindowId()); + WLOGFI("windowName: %{public}s, windowId: %{public}d, dtorCnt: %{public}d, surfaceNode:%{public}d", + GetWindowName().c_str(), GetWindowId(), ++dtorCnt, static_cast(surfaceNode_.use_count())); Destroy(); } @@ -364,14 +366,29 @@ WMError WindowImpl::SetWindowBackgroundBlur(WindowBlurLevel level) return SingletonContainer::Get().SetWindowBackgroundBlur(property_->GetWindowId(), level); } -WMError WindowImpl::SetAlpha(float alpha) +void WindowImpl::SetAlpha(float alpha) { WLOGFI("[Client] Window %{public}u alpha %{public}f", property_->GetWindowId(), alpha); if (!IsWindowValid()) { - return WMError::WM_ERROR_INVALID_WINDOW; + return; } property_->SetAlpha(alpha); - return SingletonContainer::Get().SetAlpha(property_->GetWindowId(), alpha); + surfaceNode_->SetAlpha(alpha); +} + +void WindowImpl::SetTransform(const Transform& trans) +{ + WLOGFI("[Client] Window %{public}u SetTransform", property_->GetWindowId()); + if (!IsWindowValid()) { + return; + } + property_->SetTransform(trans); + UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY); +} + +Transform WindowImpl::GetTransform() const +{ + return property_->GetTransform(); } WMError WindowImpl::AddWindowFlag(WindowFlag flag) @@ -833,7 +850,7 @@ WMError WindowImpl::Destroy(bool needNotifyServer) return ret; } -WMError WindowImpl::Show(uint32_t reason) +WMError WindowImpl::Show(uint32_t reason, bool isCustomAnimation) { WLOGFI("[Client] Window [name:%{public}s, id:%{public}u] Show, reason:%{public}u", name_.c_str(), property_->GetWindowId(), reason); @@ -864,6 +881,8 @@ WMError WindowImpl::Show(uint32_t reason) return WMError::WM_OK; } SetDefaultOption(); + // set true success when transitionController exist; set false when complete transition + property_->SetCustomAnimation(isCustomAnimation); WMError ret = SingletonContainer::Get().AddWindow(property_); RecordLifeCycleExceptionEvent(LifeCycleEvent::SHOW_EVENT, ret); if (ret == WMError::WM_OK || ret == WMError::WM_ERROR_DEATH_RECIPIENT) { @@ -876,7 +895,7 @@ WMError WindowImpl::Show(uint32_t reason) return ret; } -WMError WindowImpl::Hide(uint32_t reason) +WMError WindowImpl::Hide(uint32_t reason, bool isCustomAnimation) { WLOGFI("[Client] Window [name:%{public}s, id:%{public}u] Hide", name_.c_str(), property_->GetWindowId()); if (!IsWindowValid()) { @@ -892,6 +911,7 @@ WMError WindowImpl::Hide(uint32_t reason) WLOGFI("window is already hidden id: %{public}u", property_->GetWindowId()); return WMError::WM_OK; } + property_->SetCustomAnimation(isCustomAnimation); WMError ret = SingletonContainer::Get().RemoveWindow(property_->GetWindowId()); RecordLifeCycleExceptionEvent(LifeCycleEvent::HIDE_EVENT, ret); if (ret != WMError::WM_OK) { diff --git a/wm/src/window_option.cpp b/wm/src/window_option.cpp index 9c7011d2..60477a89 100644 --- a/wm/src/window_option.cpp +++ b/wm/src/window_option.cpp @@ -50,11 +50,6 @@ void WindowOption::SetWindowBackgroundBlur(WindowBlurLevel level) level_ = level; } -void WindowOption::SetAlpha(float alpha) -{ - alpha_ = alpha; -} - void WindowOption::SetFocusable(bool isFocusable) { focusable_ = isFocusable; @@ -122,11 +117,6 @@ WindowBlurLevel WindowOption::GetWindowBackgroundBlur() const return level_; } -float WindowOption::GetAlpha() const -{ - return alpha_; -} - bool WindowOption::GetFocusable() const { return focusable_; diff --git a/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp b/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp index c0faa60d..3acf1b7d 100644 --- a/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp +++ b/wm/test/fuzztest/windowscene_fuzzer/windowscene_fuzzer.cpp @@ -77,9 +77,6 @@ size_t InitWindowOption1(WindowOption &windowOption, const uint8_t *data, size_t uint32_t level; startPos += GetObject(level, data + startPos, size - startPos); windowOption.SetWindowBackgroundBlur(static_cast(level)); - float alpha; - startPos += GetObject(alpha, data + startPos, size - startPos); - windowOption.SetAlpha(alpha); bool focusable; startPos += GetObject(focusable, data + startPos, size - startPos); windowOption.SetFocusable(focusable); diff --git a/wm/test/systemtest/window_effect_test.cpp b/wm/test/systemtest/window_effect_test.cpp index 8d13f28b..47bbb564 100644 --- a/wm/test/systemtest/window_effect_test.cpp +++ b/wm/test/systemtest/window_effect_test.cpp @@ -80,7 +80,7 @@ HWTEST_F(WindowEffectTest, WindowEffect02, Function | MediumTest | Level3) { const sptr& window = utils::CreateTestWindow(fullScreenAppInfo_); - ASSERT_EQ(WMError::WM_OK, window->SetAlpha(1.0f)); + window->SetAlpha(1.0f); ASSERT_EQ(1.0f, window->GetAlpha()); window->Destroy(); diff --git a/wm/test/unittest/mock_window_adapter.h b/wm/test/unittest/mock_window_adapter.h index 4b7d529a..02feff5a 100644 --- a/wm/test/unittest/mock_window_adapter.h +++ b/wm/test/unittest/mock_window_adapter.h @@ -30,7 +30,6 @@ public: MOCK_METHOD0(ClearWindowAdapter, void()); MOCK_METHOD1(DestroyWindow, WMError(uint32_t windowId)); MOCK_METHOD2(SetWindowBackgroundBlur, WMError(uint32_t windowId, WindowBlurLevel level)); - MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha)); MOCK_METHOD2(UpdateProperty, WMError(sptr& windowProperty, PropertyChangeAction action)); }; } diff --git a/wm/test/unittest/window_effect_test.cpp b/wm/test/unittest/window_effect_test.cpp index 655a2105..5c38abfe 100644 --- a/wm/test/unittest/window_effect_test.cpp +++ b/wm/test/unittest/window_effect_test.cpp @@ -57,26 +57,10 @@ HWTEST_F(WindowEffectTest, WindowEffect01, Function | SmallTest | Level2) /** * @tc.name: WindowEffect02 - * @tc.desc: windowOption: set window alpha/ get window alpha - * @tc.type: FUNC - */ -HWTEST_F(WindowEffectTest, WindowEffect02, Function | SmallTest | Level2) -{ - sptr option = new WindowOption(); - option->SetAlpha(0.0f); - ASSERT_EQ(0.0f, option->GetAlpha()); - option->SetAlpha(0.5f); - ASSERT_EQ(0.5f, option->GetAlpha()); - option->SetAlpha(1.0f); - ASSERT_EQ(1.0f, option->GetAlpha()); -} - -/** - * @tc.name: WindowEffect03 * @tc.desc: WindowImp: Create window with no default option, get and check Property * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect02, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); @@ -92,20 +76,18 @@ HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2) } /** - * @tc.name: WindowEffect04 + * @tc.name: WindowEffect03 * @tc.desc: Create window with no default option, get and check Property * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); - option->SetAlpha(0.1f); - sptr window = new WindowImpl(option); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create("")); - + window->SetAlpha(0.1f); ASSERT_EQ(0.1f, window->GetAlpha()); EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); @@ -113,11 +95,11 @@ HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2) } /** - * @tc.name: WindowEffect05 + * @tc.name: WindowEffect04 * @tc.desc: set window effect parameters throw window, and check parameters. * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); @@ -135,32 +117,11 @@ HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2) } /** - * @tc.name: WindowEffect06 - * @tc.desc: set window effect parameters throw window, and check parameters. - * @tc.type: FUNC - */ -HWTEST_F(WindowEffectTest, WindowEffect06, Function | SmallTest | Level2) -{ - std::unique_ptr m = std::make_unique(); - sptr option = new WindowOption(); - sptr window = new WindowImpl(option); - - EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); - ASSERT_EQ(WMError::WM_OK, window->Create("")); - EXPECT_CALL(m->Mock(), SetAlpha(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); - ASSERT_EQ(WMError::WM_OK, window->SetAlpha(0.1f)); - ASSERT_EQ(0.1f, window->GetAlpha()); - - EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); - window->Destroy(); -} - -/** - * @tc.name: WindowEffect07 + * @tc.name: WindowEffect05 * @tc.desc: WindowImp: Create window with default option, get and check Property * @tc.type: FUNC */ -HWTEST_F(WindowEffectTest, WindowEffect07, Function | SmallTest | Level2) +HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); sptr option = new WindowOption(); diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 0366f24c..b8fc7d3e 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -77,7 +77,6 @@ public: WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override; WMError RequestFocus(uint32_t windowId) override; WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override; - WMError SetAlpha(uint32_t windowId, float alpha) override; AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType) override; void ProcessPointDown(uint32_t windowId, bool isStartDrag) override; void ProcessPointUp(uint32_t windowId) override; diff --git a/wmserver/include/window_node.h b/wmserver/include/window_node.h index b955e0da..72c76b75 100644 --- a/wmserver/include/window_node.h +++ b/wmserver/include/window_node.h @@ -54,7 +54,6 @@ public: void SetSystemBarProperty(WindowType type, const SystemBarProperty& property); void SetWindowMode(WindowMode mode); void SetWindowBackgroundBlur(WindowBlurLevel level); - void SetAlpha(float alpha); void SetBrightness(float brightness); void SetFocusable(bool focusable); void SetTouchable(bool touchable); @@ -85,7 +84,6 @@ public: WindowType GetWindowType() const; WindowMode GetWindowMode() const; WindowBlurLevel GetWindowBackgroundBlur() const; - float GetAlpha() const; float GetBrightness() const; bool IsTurnScreenOn() const; bool IsKeepScreenOn() const; @@ -106,6 +104,7 @@ public: void GetTouchHotAreas(std::vector& rects) const; uint32_t GetAccessTokenId() const; + bool EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed); sptr parent_; std::vector> children_; std::shared_ptr surfaceNode_; diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index 6a2576b6..1280b14a 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -69,7 +69,6 @@ public: virtual WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) = 0; virtual WMError RequestFocus(uint32_t windowId) = 0; virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) = 0; - virtual WMError SetAlpha(uint32_t windowId, float alpha) = 0; virtual AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) = 0; virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) = 0; virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag) = 0; diff --git a/wmserver/include/zidl/window_manager_proxy.h b/wmserver/include/zidl/window_manager_proxy.h index 4d58628b..2ee5d352 100644 --- a/wmserver/include/zidl/window_manager_proxy.h +++ b/wmserver/include/zidl/window_manager_proxy.h @@ -37,7 +37,6 @@ public: WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override; WMError RequestFocus(uint32_t windowId) override; WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override; - WMError SetAlpha(uint32_t windowId, float alpha) override; AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) override; WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override; void ProcessPointDown(uint32_t windowId, bool isStartDrag) override; diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 93b36835..bebe2bd3 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -397,21 +397,6 @@ WMError WindowController::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurL return WMError::WM_OK; } -WMError WindowController::SetAlpha(uint32_t windowId, float dstAlpha) -{ - auto node = windowRoot_->GetWindowNode(windowId); - if (node == nullptr) { - WLOGFE("could not find window"); - return WMError::WM_ERROR_NULLPTR; - } - - WLOGFI("WindowEffect WindowController SetAlpha alpha: %{public}f", dstAlpha); - node->SetAlpha(dstAlpha); - - FlushWindowInfo(windowId); - return WMError::WM_OK; -} - void WindowController::NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type) { @@ -847,6 +832,7 @@ WMError WindowController::UpdateProperty(sptr& property, Propert property->GetTouchHotAreas(rects); return UpdateTouchHotAreas(node, rects); } + case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY: default: break; } diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 73838370..246b9f14 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -455,13 +455,6 @@ WMError WindowManagerService::SetWindowBackgroundBlur(uint32_t windowId, WindowB }).get(); } -WMError WindowManagerService::SetAlpha(uint32_t windowId, float alpha) -{ - return wmsTaskLooper_->ScheduleTask([this, windowId, alpha]() { - return windowController_->SetAlpha(windowId, alpha); - }).get(); -} - AvoidArea WindowManagerService::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType) { return wmsTaskLooper_->ScheduleTask([this, windowId, avoidAreaType]() { @@ -613,6 +606,12 @@ WMError WindowManagerService::UpdateProperty(sptr& windowPropert WLOGFE("property is invalid"); return WMError::WM_ERROR_NULLPTR; } + if (action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) { + wmsTaskLooper_->PostTask([this, windowProperty, action]() mutable { + windowController_->UpdateProperty(windowProperty, action); + }); + return WMError::WM_OK; + } return wmsTaskLooper_->ScheduleTask([this, &windowProperty, action]() { WM_SCOPED_TRACE("wms:UpdateProperty"); WMError res = windowController_->UpdateProperty(windowProperty, action); diff --git a/wmserver/src/window_node.cpp b/wmserver/src/window_node.cpp index fbbb02e2..e4d89d49 100644 --- a/wmserver/src/window_node.cpp +++ b/wmserver/src/window_node.cpp @@ -100,13 +100,6 @@ void WindowNode::SetWindowBackgroundBlur(WindowBlurLevel level) surfaceNode_->SetBackgroundFilter(RSFilter::CreateBlurFilter(blurRadiusX, blurRadiusY)); } -void WindowNode::SetAlpha(float alpha) -{ - property_->SetAlpha(alpha); - WLOGFI("WindowEffect WinodwNode SetAlpha alpha:%{public}f", alpha); - surfaceNode_->SetAlpha(alpha); -} - void WindowNode::SetBrightness(float brightness) { property_->SetBrightness(brightness); @@ -273,9 +266,9 @@ WindowBlurLevel WindowNode::GetWindowBackgroundBlur() const return property_->GetWindowBackgroundBlur(); } -float WindowNode::GetAlpha() const +bool WindowNode::EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed) { - return property_->GetAlpha(); + return (propertyEnabled && (!animationPlayed) && (!property_->GetCustomAnimation()) && (!isAppCrash_)); } float WindowNode::GetBrightness() const diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index a2e77c39..e31230e1 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -387,6 +387,10 @@ void WindowNodeContainer::UpdateWindowTree(sptr& node) bool WindowNodeContainer::UpdateRSTree(sptr& node, DisplayId displayId, bool isAdd, bool animationPlayed) { WM_FUNCTION_TRACE(); + if (node->GetWindowProperty()->GetCustomAnimation()) { + WLOGFI("not need to update RsTree since SystemWindowAnimation is playing"); + return false; + } if (node->GetWindowType() == WindowType::WINDOW_TYPE_APP_COMPONENT) { WLOGFI("WINDOW_TYPE_APP_COMPONENT not need to update RsTree"); return true; @@ -413,7 +417,7 @@ bool WindowNodeContainer::UpdateRSTree(sptr& node, DisplayId display } }; - if (IsWindowAnimationEnabled && !animationPlayed && !node->isAppCrash_) { + if (node->EnableDefaultAnimation(IsWindowAnimationEnabled, animationPlayed)) { WLOGFI("add or remove window with animation"); // default transition duration: 350ms static const RSAnimationTimingProtocol timingProtocol(350); diff --git a/wmserver/src/zidl/window_manager_proxy.cpp b/wmserver/src/zidl/window_manager_proxy.cpp index db85b1e8..93449f2f 100644 --- a/wmserver/src/zidl/window_manager_proxy.cpp +++ b/wmserver/src/zidl/window_manager_proxy.cpp @@ -187,32 +187,6 @@ WMError WindowManagerProxy::SetWindowBackgroundBlur(uint32_t windowId, WindowBlu return static_cast(ret); } -WMError WindowManagerProxy::SetAlpha(uint32_t windowId, float alpha) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return WMError::WM_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(windowId)) { - WLOGFE("Write windowId failed"); - return WMError::WM_ERROR_IPC_FAILED; - } - if (!data.WriteFloat(alpha)) { - WLOGFE("Write alpha failed"); - return WMError::WM_ERROR_IPC_FAILED; - } - if (Remote()->SendRequest(static_cast(WindowManagerMessage::TRANS_ID_SET_ALPHA), - data, reply, option) != ERR_NONE) { - return WMError::WM_ERROR_IPC_FAILED; - } - - int32_t ret = reply.ReadInt32(); - return static_cast(ret); -} - AvoidArea WindowManagerProxy::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) { MessageParcel data; diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index 2ae7c7cf..24cb813b 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -81,13 +81,6 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M reply.WriteInt32(static_cast(errCode)); break; } - case WindowManagerMessage::TRANS_ID_SET_ALPHA: { - uint32_t windowId = data.ReadUint32(); - float alpha = data.ReadFloat(); - WMError errCode = SetAlpha(windowId, alpha); - reply.WriteInt32(static_cast(errCode)); - break; - } case WindowManagerMessage::TRANS_ID_GET_AVOID_AREA: { uint32_t windowId = data.ReadUint32(); AvoidAreaType avoidAreaType = static_cast(data.ReadUint32()); From 36f7770a1b7c24ec2c70e67756b96df4b5d3791a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E7=AB=8B=E6=B3=A2?= <“leowei80@qq.com”> Date: Tue, 28 Jun 2022 19:45:42 -0700 Subject: [PATCH 10/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug:=E9=94=80=E6=AF=81?= =?UTF-8?q?=E7=88=B6=E7=AA=97=E5=8F=A3=E6=97=B6=E5=AD=90=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=94=80=E6=AF=81=E5=B9=B2=E5=87=80.=20leowe?= =?UTF-8?q?i80@qq.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 魏立波 --- wm/src/window_impl.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 51ab9274..2eef9e36 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -728,12 +728,13 @@ void WindowImpl::DestroyFloatingWindow() // Destroy app floating window if exist if (appFloatingWindowMap_.count(GetWindowId()) > 0) { - auto floatingWindows = appFloatingWindowMap_.at(GetWindowId()); - for (auto& floatingWindow : floatingWindows) { - if (floatingWindow == nullptr) { + auto& floatingWindows = appFloatingWindowMap_.at(GetWindowId()); + for (auto iter = floatingWindows.begin(); iter != floatingWindows.end(); iter = floatingWindows.begin()) { + if ((*iter) == nullptr) { + floatingWindows.erase(iter); continue; } - floatingWindow->Destroy(); + (*iter)->Destroy(); } appFloatingWindowMap_.erase(GetWindowId()); } @@ -755,12 +756,13 @@ void WindowImpl::DestroySubWindow() } if (subWindowMap_.count(GetWindowId()) > 0) { // remove from subWindowMap_ and windowMap_ - std::vector>& subWindows = subWindowMap_.at(GetWindowId()); - for (auto& subWindow : subWindows) { - if (subWindow == nullptr) { + auto& subWindows = subWindowMap_.at(GetWindowId()); + for (auto iter = subWindows.begin(); iter != subWindows.end(); iter = subWindows.begin()) { + if ((*iter) == nullptr) { + subWindows.erase(iter); continue; } - subWindow->Destroy(false); + (*iter)->Destroy(false); } subWindowMap_[GetWindowId()].clear(); subWindowMap_.erase(GetWindowId()); From 8dfe22908aa416757135e9de06dd05bc788c4a6d Mon Sep 17 00:00:00 2001 From: l00574490 Date: Thu, 23 Jun 2022 21:50:29 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=8C=85=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l00574490 Change-Id: I210656846119aaa4d9179f0d9cb9c70597f9909b --- interfaces/innerkits/wm/window.h | 4 +- utils/include/window_helper.h | 24 +++ utils/include/window_property.h | 12 ++ utils/include/window_transition_info.h | 3 + utils/include/wm_common_inner.h | 12 +- utils/src/window_property.cpp | 55 ++++- utils/src/window_transition_info.cpp | 11 + wm/include/window_agent.h | 1 + wm/include/window_impl.h | 10 +- wm/include/zidl/window_interface.h | 2 + wm/include/zidl/window_proxy.h | 1 + wm/src/window_agent.cpp | 9 + wm/src/window_impl.cpp | 153 +++++++++---- wm/src/zidl/window_proxy.cpp | 21 ++ wm/src/zidl/window_stub.cpp | 5 + .../window_mode_support_info_test.cpp | 72 ++----- wmserver/include/minimize_app.h | 1 + wmserver/include/starting_window.h | 3 +- wmserver/include/window_layout_policy.h | 11 +- wmserver/include/window_manager_service.h | 1 - wmserver/include/window_node.h | 2 + wmserver/include/window_node_container.h | 2 + wmserver/include/window_root.h | 3 +- wmserver/src/starting_window.cpp | 21 +- wmserver/src/window_controller.cpp | 3 +- wmserver/src/window_layout_policy.cpp | 204 ++++++++---------- wmserver/src/window_layout_policy_cascade.cpp | 23 +- wmserver/src/window_layout_policy_tile.cpp | 15 +- wmserver/src/window_manager_config.cpp | 6 +- wmserver/src/window_manager_service.cpp | 29 --- wmserver/src/window_node.cpp | 10 + wmserver/src/window_node_container.cpp | 29 ++- wmserver/src/window_pair.cpp | 10 +- wmserver/src/window_root.cpp | 12 +- 34 files changed, 481 insertions(+), 299 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index b850114b..adc85481 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -232,8 +232,8 @@ public: virtual void OnNewWant(const AAFwk::Want& want) = 0; virtual void SetRequestedOrientation(Orientation) = 0; virtual Orientation GetRequestedOrientation() = 0; - virtual void SetModeSupportInfo(uint32_t modeSupportInfo) = 0; - virtual uint32_t GetModeSupportInfo() const = 0; + virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0; + virtual uint32_t GetRequestModeSupportInfo() const = 0; virtual WMError SetTouchHotAreas(const std::vector& rects) = 0; virtual void GetRequestedTouchHotAreas(std::vector& rects) const = 0; diff --git a/utils/include/window_helper.h b/utils/include/window_helper.h index f1653100..c879ce70 100644 --- a/utils/include/window_helper.h +++ b/utils/include/window_helper.h @@ -332,6 +332,30 @@ public: return isOk; } + static bool IsRectSatisfiedWithSizeLimits(const Rect& rect, const WindowSizeLimits& sizeLimits) + { + if (rect.height_ == 0) { + return false; + } + auto curRatio = static_cast(rect.width_) / static_cast(rect.height_); + if (sizeLimits.minWidth_ <= rect.width_ && rect.width_ <= sizeLimits.maxWidth_ && + sizeLimits.minHeight_ <= rect.height_ && rect.height_ <= sizeLimits.maxHeight_ && + sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) { + return true; + } + return false; + } + + static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t modeSupportInfo) + { + uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + if (isShowWhenLocked && (splitModeInfo == modeSupportInfo)) { + return true; + } + return false; + } + private: WindowHelper() = default; ~WindowHelper() = default; diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 32cc6e85..9244d2e0 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -67,11 +67,13 @@ public: void SetWindowSizeChangeReason(WindowSizeChangeReason reason); void SetTokenState(bool hasToken); void SetModeSupportInfo(uint32_t modeSupportInfo); + void SetRequestModeSupportInfo(uint32_t requestModeSupportInfo); void SetDragType(DragType dragType); void SetStretchable(bool stretchable); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); void SetAccessTokenId(uint32_t accessTokenId); + void SetSizeLimits(const WindowSizeLimits& sizeLimits); WindowSizeChangeReason GetWindowSizeChangeReason() const; void SetTransform(const Transform& trans); @@ -104,12 +106,15 @@ public: const PointInfo& GetHitOffset() const; uint32_t GetAnimationFlag() const; uint32_t GetModeSupportInfo() const; + uint32_t GetRequestModeSupportInfo() const; DragType GetDragType() const; bool GetStretchable() const; const Rect& GetOriginRect() const; void GetTouchHotAreas(std::vector& rects) const; uint32_t GetAccessTokenId() const; Transform GetTransform() const; + WindowSizeLimits GetSizeLimits() const; + virtual bool Marshalling(Parcel& parcel) const override; static WindowProperty* Unmarshalling(Parcel& parcel); @@ -122,6 +127,9 @@ private: static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty* property); bool MarshallingTransform(Parcel& parcel) const; static void UnmarshallingTransform(Parcel& parcel, WindowProperty* property); + bool MarshallingWindowSizeLimits(Parcel& parcel) const; + static void UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property); + std::string windowName_; Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect @@ -147,7 +155,10 @@ private: uint32_t parentId_ { 0 }; PointInfo hitOffset_ { 0, 0 }; uint32_t animationFlag_ { static_cast(WindowAnimation::DEFAULT) }; + // modeSupportInfo_ means supported modes in runtime, which can be changed uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + // requestModeSupportInfo_ is configured in abilityInfo, usually can't be changed + uint32_t requestModeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED; std::unordered_map sysBarPropMap_ { { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() }, @@ -162,6 +173,7 @@ private: Transform trans_; DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED); DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, CustomAnimation, isCustomAnimation, false); + WindowSizeLimits sizeLimits_; }; } } diff --git a/utils/include/window_transition_info.h b/utils/include/window_transition_info.h index 3d4de65c..ad959acf 100644 --- a/utils/include/window_transition_info.h +++ b/utils/include/window_transition_info.h @@ -52,6 +52,8 @@ public: void SetWindowType(WindowType windowType); WindowType GetWindowType(); void SetShowFlagWhenLocked(bool isShow); + void SetWindowSupportModes(const std::vector supportModes); + std::vector GetWindowSupportModes(); bool GetShowFlagWhenLocked(); void SetTransitionReason(TransitionReason reason); TransitionReason GetTransitionReason(); @@ -68,6 +70,7 @@ private: bool isShowWhenLocked_ = false; bool isRecent_ = false; TransitionReason reason_ = TransitionReason::ABILITY_TRANSITION; + std::vector supportWindowModes_; }; } // Rosen } // OHOS diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index f5b0808c..18287c1f 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -16,6 +16,7 @@ #ifndef OHOS_ROSEN_WM_COMMON_INNER_H #define OHOS_ROSEN_WM_COMMON_INNER_H +#include #include #include "wm_common.h" @@ -94,16 +95,19 @@ struct ModeChangeHotZonesConfig { uint32_t secondaryRange_; }; -struct FloatingWindowLimitsConfig { - bool isFloatingWindowLimitsConfigured_; +struct WindowSizeLimits { uint32_t maxWidth_; uint32_t maxHeight_; uint32_t minWidth_; uint32_t minHeight_; float maxRatio_; float minRatio_; - FloatingWindowLimitsConfig() : isFloatingWindowLimitsConfigured_(false), maxWidth_(0), maxHeight_(0), minWidth_(0), - minHeight_(0), maxRatio_(0.0f), minRatio_(0.0f) {} + WindowSizeLimits() : maxWidth_(UINT32_MAX), maxHeight_(UINT32_MAX), minWidth_(0), + minHeight_(0), maxRatio_(FLT_MAX), minRatio_(0.0f) {} + WindowSizeLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, + uint32_t minHeight, float maxRatio, float minRatio) + : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth), + minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio) {} }; struct ModeChangeHotZones { diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index 49a03836..046c7ac3 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -51,7 +51,7 @@ void WindowProperty::SetWindowType(WindowType type) void WindowProperty::SetWindowMode(WindowMode mode) { - if (!WindowHelper::IsValidWindowMode(mode)) { + if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { return; } if (!WindowHelper::IsSplitWindowMode(mode_)) { @@ -62,6 +62,9 @@ void WindowProperty::SetWindowMode(WindowMode mode) void WindowProperty::SetLastWindowMode(WindowMode mode) { + if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { + return; + } lastMode_ = mode; } @@ -138,6 +141,11 @@ void WindowProperty::SetWindowFlags(uint32_t flags) flags_ = flags; } +void WindowProperty::SetSizeLimits(const WindowSizeLimits& sizeLimits) +{ + sizeLimits_ = sizeLimits; +} + void WindowProperty::AddWindowFlag(WindowFlag flag) { flags_ |= static_cast(flag); @@ -197,6 +205,9 @@ WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const void WindowProperty::ResumeLastWindowMode() { + if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, lastMode_)) { + return; + } mode_ = lastMode_; } @@ -335,6 +346,11 @@ void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo) modeSupportInfo_ = modeSupportInfo; } +void WindowProperty::SetRequestModeSupportInfo(uint32_t requestModeSupportInfo) +{ + requestModeSupportInfo_ = requestModeSupportInfo; +} + uint32_t WindowProperty::GetWindowId() const { return windowId_; @@ -360,6 +376,11 @@ uint32_t WindowProperty::GetModeSupportInfo() const return modeSupportInfo_; } +uint32_t WindowProperty::GetRequestModeSupportInfo() const +{ + return requestModeSupportInfo_; +} + bool WindowProperty::GetTokenState() const { return tokenState_; @@ -380,6 +401,11 @@ bool WindowProperty::GetStretchable() const return isStretchable_; } +WindowSizeLimits WindowProperty::GetSizeLimits() const +{ + return sizeLimits_; +} + void WindowProperty::SetTouchHotAreas(const std::vector& rects) { touchHotAreas_ = rects; @@ -474,6 +500,23 @@ void WindowProperty::UnmarshallingTransform(Parcel& parcel, WindowProperty* prop property->SetTransform(trans); } +bool WindowProperty::MarshallingWindowSizeLimits(Parcel& parcel) const +{ + if (parcel.WriteUint32(sizeLimits_.maxWidth_) && parcel.WriteUint32(sizeLimits_.maxHeight_) && + parcel.WriteUint32(sizeLimits_.minWidth_) && parcel.WriteUint32(sizeLimits_.minHeight_) && + parcel.WriteFloat(sizeLimits_.maxRatio_) && parcel.WriteFloat(sizeLimits_.minRatio_)) { + return true; + } + return false; +} + +void WindowProperty::UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property) +{ + WindowSizeLimits sizeLimits = { parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(), + parcel.ReadFloat(), parcel.ReadFloat() }; + property->SetSizeLimits(sizeLimits); +} + bool WindowProperty::Marshalling(Parcel& parcel) const { return parcel.WriteString(windowName_) && parcel.WriteInt32(windowRect_.posX_) && @@ -492,10 +535,12 @@ bool WindowProperty::Marshalling(Parcel& parcel) const parcel.WriteUint32(static_cast(windowSizeChangeReason_)) && parcel.WriteBool(tokenState_) && parcel.WriteUint32(callingWindow_) && parcel.WriteUint32(static_cast(requestedOrientation_)) && parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) && - parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast(dragType_)) && + parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(requestModeSupportInfo_) && + parcel.WriteUint32(static_cast(dragType_)) && parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) && parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) && - parcel.WriteBool(isCustomAnimation_) && MarshallingTransform(parcel); + parcel.WriteBool(isCustomAnimation_) && MarshallingTransform(parcel) && + MarshallingWindowSizeLimits(parcel); } WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) @@ -537,6 +582,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetTurnScreenOn(parcel.ReadBool()); property->SetKeepScreenOn(parcel.ReadBool()); property->SetModeSupportInfo(parcel.ReadUint32()); + property->SetRequestModeSupportInfo(parcel.ReadUint32()); property->SetDragType(static_cast(parcel.ReadUint32())); uint32_t w = parcel.ReadUint32(); uint32_t h = parcel.ReadUint32(); @@ -546,6 +592,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetAccessTokenId(parcel.ReadUint32()); property->SetCustomAnimation(parcel.ReadBool()); UnmarshallingTransform(parcel, property); + UnmarshallingWindowSizeLimits(parcel, property); return property; } @@ -693,6 +740,7 @@ void WindowProperty::CopyFrom(const sptr& property) turnScreenOn_ = property->turnScreenOn_; keepScreenOn_ = property->keepScreenOn_; modeSupportInfo_ = property->modeSupportInfo_; + requestModeSupportInfo_ = property->requestModeSupportInfo_; dragType_ = property->dragType_; originRect_ = property->originRect_; isStretchable_ = property->isStretchable_; @@ -700,6 +748,7 @@ void WindowProperty::CopyFrom(const sptr& property) accessTokenId_ = property->accessTokenId_; isCustomAnimation_ = property->isCustomAnimation_; trans_ = property->trans_; + sizeLimits_ = property->sizeLimits_; } } } diff --git a/utils/src/window_transition_info.cpp b/utils/src/window_transition_info.cpp index e8784341..6774fb1e 100644 --- a/utils/src/window_transition_info.cpp +++ b/utils/src/window_transition_info.cpp @@ -26,6 +26,7 @@ WindowTransitionInfo::WindowTransitionInfo(sptr in displayId_ = info->displayId_; isShowWhenLocked_ = info->isShowWhenLocked_; isRecent_ = info->isRecent_; + supportWindowModes_ = { 0, 1, 2 }; // 0:fullScreen 1:split 2:floating } void WindowTransitionInfo::SetBundleName(std::string name) @@ -103,6 +104,16 @@ void WindowTransitionInfo::SetShowFlagWhenLocked(bool isShow) isShowWhenLocked_ = isShow; } +void WindowTransitionInfo::SetWindowSupportModes(const std::vector supportModes) +{ + supportWindowModes_.assign(supportModes.begin(), supportModes.end()); +} + +std::vector WindowTransitionInfo::GetWindowSupportModes() +{ + return supportWindowModes_; +} + bool WindowTransitionInfo::GetShowFlagWhenLocked() { return isShowWhenLocked_; diff --git a/wm/include/window_agent.h b/wm/include/window_agent.h index 818accd6..78a350bf 100644 --- a/wm/include/window_agent.h +++ b/wm/include/window_agent.h @@ -29,6 +29,7 @@ public: ~WindowAgent() = default; void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override; void UpdateWindowMode(WindowMode mode) override; + void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; void UpdateFocusStatus(bool focused) override; void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; void UpdateWindowState(WindowState state) override; diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index b2f78193..f15d6bd1 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -116,7 +116,7 @@ public: virtual const std::string& GetWindowName() const override; virtual uint32_t GetWindowId() const override; virtual uint32_t GetWindowFlags() const override; - uint32_t GetModeSupportInfo() const override; + uint32_t GetRequestModeSupportInfo() const override; inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback() { return notifyNativefunc_; @@ -191,9 +191,10 @@ public: virtual void RegisterTouchOutsideListener(const sptr& listener) override; virtual void UnregisterTouchOutsideListener(const sptr& listener) override; virtual void SetAceAbilityHandler(const sptr& handler) override; - virtual void SetModeSupportInfo(uint32_t modeSupportInfo) override; + virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override; void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason); void UpdateMode(WindowMode mode); + void UpdateModeSupportInfo(uint32_t modeSupportInfo); virtual void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; virtual void ConsumePointerEvent(std::shared_ptr& inputEvent) override; virtual void RequestFrame() override; @@ -339,7 +340,10 @@ private: void UpdateDragType(); void InitListenerHandler(); bool CheckCameraFloatingWindowMultiCreated(WindowType type); - void SetOrientationFromAbility(); + void GetConfigurationFromAbilityInfo(); + void UpdateTitleButtonVisibility(); + void SetModeSupportInfo(uint32_t modeSupportInfo); + uint32_t GetModeSupportInfo() const; // colorspace, gamut using ColorSpaceConvertMap = struct { diff --git a/wm/include/zidl/window_interface.h b/wm/include/zidl/window_interface.h index bb516d18..e8836552 100644 --- a/wm/include/zidl/window_interface.h +++ b/wm/include/zidl/window_interface.h @@ -31,6 +31,7 @@ public: enum class WindowMessage : uint32_t { TRANS_ID_UPDATE_WINDOW_RECT, TRANS_ID_UPDATE_WINDOW_MODE, + TRANS_ID_UPDATE_MODE_SUPPORT_INFO, TRANS_ID_UPDATE_FOCUS_STATUS, TRANS_ID_UPDATE_AVOID_AREA, TRANS_ID_UPDATE_WINDOW_STATE, @@ -45,6 +46,7 @@ public: virtual void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) = 0; virtual void UpdateWindowMode(WindowMode mode) = 0; + virtual void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) = 0; virtual void UpdateFocusStatus(bool focused) = 0; virtual void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; virtual void UpdateWindowState(WindowState state) = 0; diff --git a/wm/include/zidl/window_proxy.h b/wm/include/zidl/window_proxy.h index ac492560..c0990ada 100644 --- a/wm/include/zidl/window_proxy.h +++ b/wm/include/zidl/window_proxy.h @@ -30,6 +30,7 @@ public: void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override; void UpdateWindowMode(WindowMode mode) override; + void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; void UpdateFocusStatus(bool focused) override; void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; void UpdateWindowState(WindowState state) override; diff --git a/wm/src/window_agent.cpp b/wm/src/window_agent.cpp index e99a5966..46c91c3d 100644 --- a/wm/src/window_agent.cpp +++ b/wm/src/window_agent.cpp @@ -46,6 +46,15 @@ void WindowAgent::UpdateWindowMode(WindowMode mode) window_->UpdateMode(mode); } +void WindowAgent::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +{ + if (window_ == nullptr) { + WLOGFE("window_ is nullptr"); + return; + } + window_->UpdateModeSupportInfo(modeSupportInfo); +} + void WindowAgent::UpdateFocusStatus(bool focused) { if (window_ == nullptr) { diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 105a29e5..90edd807 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -278,6 +278,11 @@ uint32_t WindowImpl::GetWindowFlags() const return property_->GetWindowFlags(); } +uint32_t WindowImpl::GetRequestModeSupportInfo() const +{ + return property_->GetRequestModeSupportInfo(); +} + uint32_t WindowImpl::GetModeSupportInfo() const { return property_->GetModeSupportInfo(); @@ -465,9 +470,11 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo, } else { uiContent->Initialize(this, contentInfo, storage); } - // make uiContent_ available after Initialize/Restore + // make uiContent available after Initialize/Restore uiContent_ = std::move(uiContent); + if (state_ == WindowState::STATE_SHOWN) { + UpdateTitleButtonVisibility(); Ace::ViewportConfig config; Rect rect = GetRect(); config.SetSize(rect.width_, rect.height_); @@ -578,7 +585,9 @@ WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarPropert WMError WindowImpl::SetLayoutFullScreen(bool status) { WLOGFI("[Client] Window %{public}u SetLayoutFullScreen: %{public}u", property_->GetWindowId(), status); - if (!IsWindowValid()) { + if (!IsWindowValid() || + !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } WMError ret = SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); @@ -608,6 +617,11 @@ WMError WindowImpl::SetLayoutFullScreen(bool status) WMError WindowImpl::SetFullScreen(bool status) { WLOGFI("[Client] Window %{public}u SetFullScreen: %{public}d", property_->GetWindowId(), status); + if (!IsWindowValid() || + !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); + return WMError::WM_ERROR_INVALID_WINDOW; + } SystemBarProperty statusProperty = GetSystemBarPropertyByType( WindowType::WINDOW_TYPE_STATUS_BAR); SystemBarProperty naviProperty = GetSystemBarPropertyByType( @@ -660,6 +674,68 @@ WMError WindowImpl::UpdateProperty(PropertyChangeAction action) return SingletonContainer::Get().UpdateProperty(property_, action); } +void WindowImpl::GetConfigurationFromAbilityInfo() +{ + auto abilityContext = AbilityRuntime::Context::ConvertTo(context_); + if (abilityContext == nullptr) { + WLOGFE("id:%{public}u is not ability Window", property_->GetWindowId()); + return; + } + auto abilityInfo = abilityContext->GetAbilityInfo(); + if (abilityInfo == nullptr) { + WLOGFE("id:%{public}u Ability window get ability info failed", property_->GetWindowId()); + return; + } + + // get support modes configuration + uint32_t modeSupportInfo = 0; + const auto& supportModes = abilityInfo->windowModes; + for (auto& mode : supportModes) { + if (static_cast(mode) == static_cast(0)) { // 0 : fullScreen + modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; + } else if (static_cast(mode) == static_cast(1)) { // 1 : split + modeSupportInfo |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + } else if (static_cast(mode) == static_cast(2)) { // 2 : floating + modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + } + } + if (modeSupportInfo == 0) { + WLOGFI("mode config param is 0, set all modes"); + modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + } + SetRequestModeSupportInfo(modeSupportInfo); + + // get window size limits configuration + WindowSizeLimits sizeLimits; + sizeLimits.maxWidth_ = abilityInfo->maxWindowWidth; + sizeLimits.maxHeight_ = abilityInfo->maxWindowHeight; + sizeLimits.minWidth_ = abilityInfo->minWindowWidth; + sizeLimits.minHeight_ = abilityInfo->minWindowHeight; + sizeLimits.maxRatio_ = static_cast(abilityInfo->maxWindowRatio); + sizeLimits.minRatio_ = static_cast(abilityInfo->minWindowRatio); + property_->SetSizeLimits(sizeLimits); + + // get orientation configuration + DisplayOrientation displayOrientation = static_cast( + static_cast(abilityInfo->orientation)); + if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) { + WLOGFE("id:%{public}u Do not support this Orientation type", property_->GetWindowId()); + return; + } + Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation); + if (orientation < Orientation::BEGIN || orientation > Orientation::END) { + WLOGFE("Set orientation from ability failed"); + return; + } + property_->SetRequestedOrientation(orientation); +} + +void WindowImpl::UpdateTitleButtonVisibility() +{ + WLOGFI("[Client] UpdateTitleButtonVisibility"); +} + WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr& context) { WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str()); @@ -705,7 +781,7 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr< WLOGFI("get stretchable enable:%{public}d", windowSystemConfig_.isStretchable_); property_->SetStretchable(windowSystemConfig_.isStretchable_); } - SetOrientationFromAbility(); + GetConfigurationFromAbilityInfo(); } WMError ret = SingletonContainer::Get().CreateWindow(windowAgent, property_, surfaceNode_, windowId, token); @@ -883,6 +959,19 @@ WMError WindowImpl::Show(uint32_t reason, bool isCustomAnimation) SetDefaultOption(); // set true success when transitionController exist; set false when complete transition property_->SetCustomAnimation(isCustomAnimation); + + // show failed when current mode is not support or window only supports split mode and can show when locked + bool isShowWhenLocked = GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED); + if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), GetMode()) || + WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetModeSupportInfo())) { + WLOGFE("current mode is not be supported, windowId: %{public}u", property_->GetWindowId()); + NotifyForegroundFailed(); + return WMError::WM_ERROR_INVALID_WINDOW; + } + + // update title button visibility when show + UpdateTitleButtonVisibility(); + WMError ret = SingletonContainer::Get().AddWindow(property_); RecordLifeCycleExceptionEvent(LifeCycleEvent::SHOW_EVENT, ret); if (ret == WMError::WM_OK || ret == WMError::WM_ERROR_DEATH_RECIPIENT) { @@ -1216,6 +1305,9 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason) return WMError::WM_ERROR_NO_MEM; } auto abilityInfo = abilityContext->GetAbilityInfo(); + if (abilityInfo == nullptr) { + return WMError::WM_ERROR_NULLPTR; + } fromInfo->SetBundleName(context_->GetBundleName()); fromInfo->SetAbilityName(abilityInfo->name); fromInfo->SetWindowMode(property_->GetWindowMode()); @@ -1227,32 +1319,6 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason) return SingletonContainer::Get().NotifyWindowTransition(fromInfo, toInfo); } -void WindowImpl::SetOrientationFromAbility() -{ - auto abilityContext = AbilityRuntime::Context::ConvertTo(context_); - if (abilityContext == nullptr) { - WLOGFE("id:%{public}d is not ability Window", property_->GetWindowId()); - return; - } - auto abilityInfo = abilityContext->GetAbilityInfo(); - if (abilityInfo == nullptr) { - WLOGFE("id:%{public}d Ability window get ability info failed", property_->GetWindowId()); - return; - } - DisplayOrientation displayOrientation = static_cast( - static_cast(abilityInfo->orientation)); - if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) { - WLOGFE("id:%{public}d Do not support this Orientation type", property_->GetWindowId()); - return; - } - Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation); - if (orientation < Orientation::BEGIN || orientation > Orientation::END) { - WLOGFE("Set orientation from ability failed"); - return; - } - property_->SetRequestedOrientation(orientation); -} - WMError WindowImpl::Minimize() { WLOGFI("[Client] Window %{public}u Minimize", property_->GetWindowId()); @@ -1546,20 +1612,15 @@ void WindowImpl::SetAceAbilityHandler(const sptr& handler) aceAbilityHandler_ = handler; } +void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo) +{ + property_->SetRequestModeSupportInfo(modeSupportInfo); + SetModeSupportInfo(modeSupportInfo); +} + void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo) { property_->SetModeSupportInfo(modeSupportInfo); - UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); - if (!WindowHelper::IsWindowModeSupported(modeSupportInfo, GetMode())) { - WLOGFI("current window mode is not supported, force to transform to appropriate mode. window id:%{public}u", - GetWindowId()); - WindowMode mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo); - if (mode != WindowMode::WINDOW_MODE_UNDEFINED) { - SetWindowMode(mode); - } else { - WLOGFE("invalid modeSupportInfo %{public}u", modeSupportInfo); - } - } } void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) @@ -1579,7 +1640,7 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize return; } property_->SetWindowRect(rect); - const Rect& originRect = property_->GetOriginRect(); + // update originRect when floating window show for the first time. if (!isOriginRectSet_ && WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) { property_->SetOriginRect(rect); @@ -1591,12 +1652,13 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize if (reason == WindowSizeChangeReason::DRAG || reason == WindowSizeChangeReason::DRAG_END || reason == WindowSizeChangeReason::DRAG_START || reason == WindowSizeChangeReason::RECOVER || reason == WindowSizeChangeReason::MOVE) { - rectToAce = originRect; + rectToAce = property_->GetOriginRect(); } else { property_->SetOriginRect(rect); } } WLOGFI("sizeChange callback size: %{public}lu", (unsigned long)windowChangeListeners_.size()); + NotifySizeChange(rectToAce, reason); if (uiContent_ != nullptr) { Ace::ViewportConfig config; @@ -1621,6 +1683,13 @@ void WindowImpl::UpdateMode(WindowMode mode) } } +void WindowImpl::UpdateModeSupportInfo(uint32_t modeSupportInfo) +{ + WLOGI("modeSupportInfo: %{public}u, winId: %{public}u", modeSupportInfo, GetWindowId()); + SetModeSupportInfo(modeSupportInfo); + UpdateTitleButtonVisibility(); +} + void WindowImpl::ConsumeKeyEvent(std::shared_ptr& keyEvent) { NotifyKeyEvent(keyEvent); diff --git a/wm/src/zidl/window_proxy.cpp b/wm/src/zidl/window_proxy.cpp index 5b3a448c..1d3cd3e4 100644 --- a/wm/src/zidl/window_proxy.cpp +++ b/wm/src/zidl/window_proxy.cpp @@ -76,6 +76,27 @@ void WindowProxy::UpdateWindowMode(WindowMode mode) return; } +void WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + if (!data.WriteUint32(modeSupportInfo)) { + WLOGFE("Write WindowMode failed"); + return; + } + + if (Remote()->SendRequest(static_cast(WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + } + return; +} + void WindowProxy::UpdateFocusStatus(bool focused) { MessageParcel data; diff --git a/wm/src/zidl/window_stub.cpp b/wm/src/zidl/window_stub.cpp index c8d00110..fdb2ae7d 100644 --- a/wm/src/zidl/window_stub.cpp +++ b/wm/src/zidl/window_stub.cpp @@ -45,6 +45,11 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce UpdateWindowMode(mode); break; } + case WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO: { + uint32_t modeSupportInfo = data.ReadUint32(); + UpdateWindowModeSupportInfo(modeSupportInfo); + break; + } case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: { bool focused = data.ReadBool(); UpdateFocusStatus(focused); diff --git a/wm/test/systemtest/window_mode_support_info_test.cpp b/wm/test/systemtest/window_mode_support_info_test.cpp index 10222bae..a6289f2e 100644 --- a/wm/test/systemtest/window_mode_support_info_test.cpp +++ b/wm/test/systemtest/window_mode_support_info_test.cpp @@ -76,15 +76,15 @@ void WindowModeSupportInfoTest::TearDown() namespace { /** * @tc.name: WindowModeSupportInfo01 - * @tc.desc: SetModeSupportInfo | GetModeSupportInfo + * @tc.desc: SetRequestModeSupportInfo | GetRequestModeSupportInfo * @tc.type: FUNC */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetModeSupportInfo()); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestModeSupportInfo()); window->Destroy(); } @@ -97,26 +97,20 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTe { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); window->Destroy(); } @@ -129,56 +123,40 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTe { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); window->Destroy(); } /** * @tc.name: WindowModeSupportInfo04 - * @tc.desc: modeSupportInfo test for single window in case current window mode is not supported. + * @tc.desc: modeSupportInfo test for single window, window mode is not supported when show, show failed * @tc.type: FUNC */ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode()); + ASSERT_NE(WMError::WM_OK, window->Show()); ASSERT_EQ(WMError::WM_OK, window->Hide()); - - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window->GetMode()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - window->Destroy(); } @@ -190,9 +168,9 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) { const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); - window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window1->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); - window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window2->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); @@ -213,7 +191,7 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); - window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); @@ -224,30 +202,6 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTe WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); usleep(WAIT_SYANC_US); } - -/** - * @tc.name: WindowModeSupportInfo07 - * @tc.desc: modeSupportInfo test for split - * @tc.type: FUNC - */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo07, Function | MediumTest | Level3) -{ - const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); - window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); - const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); - window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WMError::WM_OK, window1->Show()); - ASSERT_EQ(WMError::WM_OK, window2->Show()); - usleep(WAIT_SYANC_US); - - window1->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window1->GetMode()); - ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window2->GetMode()); - - window1->Destroy(); - window2->Destroy(); -} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wmserver/include/minimize_app.h b/wmserver/include/minimize_app.h index 0d0c0f8e..af827c69 100644 --- a/wmserver/include/minimize_app.h +++ b/wmserver/include/minimize_app.h @@ -29,6 +29,7 @@ enum class MinimizeReason : uint32_t { MINIMIZE_BUTTON, MINIMIZE_ALL, LAYOUT_TILE, + LAYOUT_CASCADE, MAX_APP_COUNT, SPLIT_REPLACE, SPLIT_QUIT, diff --git a/wmserver/include/starting_window.h b/wmserver/include/starting_window.h index fff19014..da718e8a 100644 --- a/wmserver/include/starting_window.h +++ b/wmserver/include/starting_window.h @@ -30,7 +30,8 @@ public: StartingWindow() = delete; ~StartingWindow() = default; - static sptr CreateWindowNode(sptr info, uint32_t winId); + static sptr CreateWindowNode(sptr info, + uint32_t winId, WindowLayoutMode layoutMode); static void HandleClientWindowCreate(sptr& node, sptr& window, uint32_t& windowId, const std::shared_ptr& surfaceNode, sptr& property, int32_t pid, int32_t uid); diff --git a/wmserver/include/window_layout_policy.h b/wmserver/include/window_layout_policy.h index c9f178a3..5421d22b 100644 --- a/wmserver/include/window_layout_policy.h +++ b/wmserver/include/window_layout_policy.h @@ -61,7 +61,6 @@ public: void ProcessDisplayCreate(DisplayId displayId, const std::map& displayRectMap); void ProcessDisplayDestroy(DisplayId displayId, const std::map& displayRectMap); void ProcessDisplaySizeChangeOrRotation(DisplayId displayId, const std::map& displayRectMap); - void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig); void SetSplitRatioConfig(const SplitRatioConfig& splitRatioConfig); protected: @@ -91,16 +90,15 @@ protected: void UpdateFloatingWindowSizeForStretchableWindow(const sptr& node, const Rect& displayRect, Rect& winRect) const; - void UpdateFloatingWindowSizeByCustomizedLimits(const sptr& node, + void UpdateFloatingWindowSizeBySizeLimits(const sptr& node, const Rect& displayRect, Rect& winRect) const; void UpdateFloatingWindowSizeBySystemLimits(const sptr& node, const Rect& displayRect, Rect& winRect) const; void LimitWindowPositionWhenInitRectOrMove(const sptr& node, Rect& winRect) const; void LimitWindowPositionWhenDrag(const sptr& node, Rect& winRect) const; - void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect, - const FloatingWindowLimitsConfig& limitConfig); - FloatingWindowLimitsConfig GetCustomizedLimitsConfig(const Rect& displayRect, float virtualPixelRatio); - FloatingWindowLimitsConfig GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio); + void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect); + void UpdateWindowSizeLimits(const sptr& node); + WindowSizeLimits GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio); const std::set avoidTypes_ { WindowType::WINDOW_TYPE_STATUS_BAR, @@ -122,7 +120,6 @@ protected: Rect displayGroupRect_; Rect displayGroupLimitRect_; bool isMultiDisplay_ = false; - FloatingWindowLimitsConfig floatingWindowLimitsConfig_; SplitRatioConfig splitRatioConfig_; }; } diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 34c2bbfe..536c9812 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -118,7 +118,6 @@ private: const std::map>& displayInfoMap, DisplayStateChangeType type); WMError GetFocusWindowInfo(sptr& abilityToken); void ConfigureWindowManagerService(); - void ConfigFloatWindowLimits(); static inline SingletonDelegator delegator; std::map accessTokenIdMaps_; diff --git a/wmserver/include/window_node.h b/wmserver/include/window_node.h index 72c76b75..8fb948f1 100644 --- a/wmserver/include/window_node.h +++ b/wmserver/include/window_node.h @@ -71,6 +71,7 @@ public: void SetDragType(DragType dragType); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); + void SetWindowSizeLimits(const WindowSizeLimits& sizeLimits); const sptr& GetWindowToken() const; uint32_t GetWindowId() const; @@ -103,6 +104,7 @@ public: void ResetWindowSizeChangeReason(); void GetTouchHotAreas(std::vector& rects) const; uint32_t GetAccessTokenId() const; + WindowSizeLimits GetWindowSizeLimits() const; bool EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed); sptr parent_; diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 849a29d6..c98da05e 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -109,6 +109,7 @@ public: void UpdateAvoidAreaListener(sptr& windowNode, bool haveAvoidAreaListener); void BeforeProcessWindowAvoidAreaChangeWhenDisplayChange() const; void ProcessWindowAvoidAreaChangeWhenDisplayChange() const; + WindowLayoutMode GetCurrentLayoutMode() const; private: void TraverseWindowNode(sptr& root, std::vector>& windowNodes) const; @@ -150,6 +151,7 @@ private: const std::vector& curShowingDisplays); void FillWindowInfo(sptr& windowInfo, const sptr& node) const; bool CheckWindowNodeWhetherInWindowTree(const sptr& node) const; + void UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up); float displayBrightness_ = UNDEFINED_BRIGHTNESS; uint32_t brightnessWindow_ = INVALID_WINDOW_ID; diff --git a/wmserver/include/window_root.h b/wmserver/include/window_root.h index 660802fd..8e7128e9 100644 --- a/wmserver/include/window_root.h +++ b/wmserver/include/window_root.h @@ -93,10 +93,10 @@ public: uint32_t GetWindowIdByObject(const sptr& remoteObject); sptr GetWindowForDumpAceHelpInfo() const; void DestroyLeakStartingWindow(); - void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig); void SetSplitRatios(const std::vector& splitRatioNumbers); void SetExitSplitRatios(const std::vector& exitSplitRatios); void MinimizeTargetWindows(std::vector& windowIds); + WindowLayoutMode GetCurrentLayoutMode(DisplayId displayId); private: void OnRemoteDied(const sptr& remoteObject); WMError DestroyWindowInner(sptr& node); @@ -134,7 +134,6 @@ private: this, std::placeholders::_1)); Callback callback_; uint32_t maxAppWindowNumber_ = 100; - FloatingWindowLimitsConfig floatingWindowLimitsConfig_; SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}}; }; } diff --git a/wmserver/src/starting_window.cpp b/wmserver/src/starting_window.cpp index c183d372..ca88a923 100644 --- a/wmserver/src/starting_window.cpp +++ b/wmserver/src/starting_window.cpp @@ -32,12 +32,28 @@ SurfaceDraw StartingWindow::surfaceDraw_; static bool g_hasInit = false; std::recursive_mutex StartingWindow::mutex_; -sptr StartingWindow::CreateWindowNode(sptr info, uint32_t winId) +sptr StartingWindow::CreateWindowNode(sptr info, + uint32_t winId, WindowLayoutMode layoutMode) { sptr property = new(std::nothrow) WindowProperty(); - if (property == nullptr) { + if (property == nullptr || info == nullptr) { return nullptr; } + + uint32_t modeSupportInfo = 0; + for (auto mode : info->GetWindowSupportModes()) { + modeSupportInfo |= mode; + } + + // if mode isn't be supported or don't support floating mode in tile mode, create starting window failed + if ((!WindowHelper::IsWindowModeSupported(modeSupportInfo, info->GetWindowMode())) || + ((!WindowHelper::IsWindowModeSupported(modeSupportInfo, WindowMode::WINDOW_MODE_FLOATING)) && + (layoutMode == WindowLayoutMode::TILE)) || + (WindowHelper::IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), modeSupportInfo))) { + WLOGFI("window mode is not be supported or not support floating mode in tile, cancel starting window"); + return nullptr; + } + property->SetRequestRect(info->GetWindowRect()); property->SetWindowMode(info->GetWindowMode()); property->SetDisplayId(info->GetDisplayId()); @@ -56,7 +72,6 @@ sptr StartingWindow::CreateWindowNode(sptr inf if (CreateLeashAndStartingSurfaceNode(node) != WMError::WM_OK) { return nullptr; } - return node; } diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 1bfb4cda..fa65c722 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -52,12 +52,13 @@ void WindowController::StartingWindow(sptr info, sptr(TraceTaskId::STARTING_WINDOW), "wms:async:ShowStartingWindow"); auto node = windowRoot_->FindWindowNodeWithToken(info->GetAbilityToken()); + auto layoutMode = windowRoot_->GetCurrentLayoutMode(info->GetDisplayId()); if (node == nullptr) { if (!isColdStart) { WLOGFE("no windowNode exists but is hot start!"); return; } - node = StartingWindow::CreateWindowNode(info, GenWindowId()); + node = StartingWindow::CreateWindowNode(info, GenWindowId(), layoutMode); if (node == nullptr) { return; } diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 60e76d18..7e11e7cf 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -455,16 +455,20 @@ void WindowLayoutPolicy::CalcAndSetNodeHotZone(const Rect& winRect, const sptrSetTouchHotAreas(hotAreas); } -void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect, - const FloatingWindowLimitsConfig& limitConfig) +void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr& node, Rect& winRect) { - if (limitConfig.maxWidth_ == limitConfig.minWidth_ && - limitConfig.maxHeight_ == limitConfig.minHeight_) { + const auto& sizeLimits = node->GetWindowSizeLimits(); + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ && + sizeLimits.maxHeight_ == sizeLimits.minHeight_) { WLOGFI("window rect can not be changed"); return; } + if (winRect.height_ == 0) { + WLOGFE("the height of window is zero"); + return; + } float curRatio = static_cast(winRect.width_) / static_cast(winRect.height_); - if (limitConfig.minRatio_ <= curRatio && curRatio <= limitConfig.maxRatio_) { + if (sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) { WLOGFI("window ratio is satisfied with limit ratio, curRatio: %{public}f", curRatio); return; } @@ -490,10 +494,10 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr< limitMaxPosX = dockWinRect.posX_ - static_cast(windowTitleBarH); } - float newRatio = curRatio < limitConfig.minRatio_ ? limitConfig.minRatio_ : limitConfig.maxRatio_; + float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_; if ((winRect.posX_ + static_cast(winRect.width_) == limitMinPosX) || (winRect.posX_ == limitMaxPosX)) { // height can not be changed - if (limitConfig.maxHeight_ == limitConfig.minHeight_) { + if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) { return; } winRect.height_ = static_cast(static_cast(winRect.width_) / newRatio); @@ -501,7 +505,7 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr< if ((winRect.posY_ == limitMinPosY) || (winRect.posX_ == limitMaxPosY)) { // width can not be changed - if (limitConfig.maxWidth_ == limitConfig.minWidth_) { + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) { return; } winRect.width_ = static_cast(static_cast(winRect.height_) * newRatio); @@ -510,79 +514,76 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr< winRect.posX_, winRect.posY_, winRect.width_, winRect.height_); } -FloatingWindowLimitsConfig WindowLayoutPolicy::GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio) +WindowSizeLimits WindowLayoutPolicy::GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio) { - FloatingWindowLimitsConfig limitConfig; - limitConfig.maxWidth_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); - limitConfig.maxHeight_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); - limitConfig.minWidth_ = static_cast(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio); - limitConfig.minHeight_ = static_cast(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio); + WindowSizeLimits systemLimits; + systemLimits.maxWidth_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); + systemLimits.maxHeight_ = static_cast(MAX_FLOATING_SIZE * virtualPixelRatio); + systemLimits.minWidth_ = static_cast(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio); + systemLimits.minHeight_ = static_cast(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio); if (displayRect.width_ > displayRect.height_) { - std::swap(limitConfig.minWidth_, limitConfig.minHeight_); + std::swap(systemLimits.minWidth_, systemLimits.minHeight_); } WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u " - "maxRatio: %{public}f, minRatio: %{public}f", limitConfig.maxWidth_, limitConfig.maxHeight_, - limitConfig.minWidth_, limitConfig.minHeight_, limitConfig.maxRatio_, limitConfig.minRatio_); - return limitConfig; + "maxRatio: %{public}f, minRatio: %{public}f", systemLimits.maxWidth_, systemLimits.maxHeight_, + systemLimits.minWidth_, systemLimits.minHeight_, systemLimits.maxRatio_, systemLimits.minRatio_); + return systemLimits; } -FloatingWindowLimitsConfig WindowLayoutPolicy::GetCustomizedLimitsConfig(const Rect& displayRect, - float virtualPixelRatio) +void WindowLayoutPolicy::UpdateWindowSizeLimits(const sptr& node) { - const auto& systemLimits = GetSystemLimitsConfig(displayRect, virtualPixelRatio); - FloatingWindowLimitsConfig newLimitConfig = systemLimits; + const auto& displayRect = displayGroupInfo_->GetDisplayRect(node->GetDisplayId()); + const auto& virtualPixelRatio = GetVirtualPixelRatio(node->GetDisplayId()); + const auto& systemLimits = GetSystemSizeLimits(displayRect, virtualPixelRatio); + const auto& customizedLimits = node->GetWindowSizeLimits(); + WindowSizeLimits newLimits = systemLimits; + // configured limits of floating window - uint32_t configuredMaxWidth = static_cast(floatingWindowLimitsConfig_.maxWidth_ * virtualPixelRatio); - uint32_t configuredMaxHeight = static_cast(floatingWindowLimitsConfig_.maxHeight_ * virtualPixelRatio); - uint32_t configuredMinWidth = static_cast(floatingWindowLimitsConfig_.minWidth_ * virtualPixelRatio); - uint32_t configuredMinHeight = static_cast(floatingWindowLimitsConfig_.minHeight_ * virtualPixelRatio); - float configuredMaxRatio = floatingWindowLimitsConfig_.maxRatio_; - float configuredMinRatio = floatingWindowLimitsConfig_.minRatio_; + uint32_t configuredMaxWidth = static_cast(customizedLimits.maxWidth_ * virtualPixelRatio); + uint32_t configuredMaxHeight = static_cast(customizedLimits.maxHeight_ * virtualPixelRatio); + uint32_t configuredMinWidth = static_cast(customizedLimits.minWidth_ * virtualPixelRatio); + uint32_t configuredMinHeight = static_cast(customizedLimits.minHeight_ * virtualPixelRatio); + float configuerdMaxRatio = customizedLimits.maxRatio_; + float configuerdMinRatio = customizedLimits.minRatio_; // calculate new limit size if (systemLimits.minWidth_ <= configuredMaxWidth && configuredMaxWidth <= systemLimits.maxWidth_) { - newLimitConfig.maxWidth_ = configuredMaxWidth; + newLimits.maxWidth_ = configuredMaxWidth; } if (systemLimits.minHeight_ <= configuredMaxHeight && configuredMaxHeight <= systemLimits.maxHeight_) { - newLimitConfig.maxHeight_ = configuredMaxHeight; + newLimits.maxHeight_ = configuredMaxHeight; } - if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimitConfig.maxWidth_) { - newLimitConfig.minWidth_ = configuredMinWidth; + if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimits.maxWidth_) { + newLimits.minWidth_ = configuredMinWidth; } - if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimitConfig.maxHeight_) { - newLimitConfig.minHeight_ = configuredMinHeight; + if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimits.maxHeight_) { + newLimits.minHeight_ = configuredMinHeight; } // calculate new limit ratio - newLimitConfig.maxRatio_ = static_cast(newLimitConfig.maxWidth_) / - static_cast(newLimitConfig.minHeight_); - newLimitConfig.minRatio_ = static_cast(newLimitConfig.minWidth_) / - static_cast(newLimitConfig.maxHeight_); - if (newLimitConfig.minRatio_ <= configuredMaxRatio && configuredMaxRatio <= newLimitConfig.maxRatio_) { - newLimitConfig.maxRatio_ = configuredMaxRatio; + newLimits.maxRatio_ = static_cast(newLimits.maxWidth_) / static_cast(newLimits.minHeight_); + newLimits.minRatio_ = static_cast(newLimits.minWidth_) / static_cast(newLimits.maxHeight_); + if (newLimits.minRatio_ <= configuerdMaxRatio && configuerdMaxRatio <= newLimits.maxRatio_) { + newLimits.maxRatio_ = configuerdMaxRatio; } - if (newLimitConfig.minRatio_ <= configuredMinRatio && configuredMinRatio <= newLimitConfig.maxRatio_) { - newLimitConfig.minRatio_ = configuredMinRatio; + if (newLimits.minRatio_ <= configuerdMinRatio && configuerdMinRatio <= newLimits.maxRatio_) { + newLimits.minRatio_ = configuerdMinRatio; } // recalculate limit size by new ratio - uint32_t newMaxWidth = static_cast(static_cast(newLimitConfig.maxHeight_) * - newLimitConfig.maxRatio_); - newLimitConfig.maxWidth_ = std::min(newMaxWidth, newLimitConfig.maxWidth_); - uint32_t newMinWidth = static_cast(static_cast(newLimitConfig.minHeight_) * - newLimitConfig.minRatio_); - newLimitConfig.minWidth_ = std::max(newMinWidth, newLimitConfig.minWidth_); - uint32_t newMaxHeight = static_cast(static_cast(newLimitConfig.maxWidth_) / - newLimitConfig.minRatio_); - newLimitConfig.maxHeight_ = std::min(newMaxHeight, newLimitConfig.maxHeight_); - uint32_t newMinHeight = static_cast(static_cast(newLimitConfig.minWidth_) / - newLimitConfig.maxRatio_); - newLimitConfig.minHeight_ = std::max(newMinHeight, newLimitConfig.minHeight_); + uint32_t newMaxWidth = static_cast(static_cast(newLimits.maxHeight_) * newLimits.maxRatio_); + newLimits.maxWidth_ = std::min(newMaxWidth, newLimits.maxWidth_); + uint32_t newMinWidth = static_cast(static_cast(newLimits.minHeight_) * newLimits.minRatio_); + newLimits.minWidth_ = std::max(newMinWidth, newLimits.minWidth_); + uint32_t newMaxHeight = static_cast(static_cast(newLimits.maxWidth_) / newLimits.minRatio_); + newLimits.maxHeight_ = std::min(newMaxHeight, newLimits.maxHeight_); + uint32_t newMinHeight = static_cast(static_cast(newLimits.minWidth_) / newLimits.maxRatio_); + newLimits.minHeight_ = std::max(newMinHeight, newLimits.minHeight_); WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u, " - "maxRatio: %{public}f, minRatio: %{public}f", newLimitConfig.maxWidth_, newLimitConfig.maxHeight_, - newLimitConfig.minWidth_, newLimitConfig.minHeight_, newLimitConfig.maxRatio_, newLimitConfig.minRatio_); - return newLimitConfig; + "maxRatio: %{public}f, minRatio: %{public}f", newLimits.maxWidth_, newLimits.maxHeight_, + newLimits.minWidth_, newLimits.minHeight_, newLimits.maxRatio_, newLimits.minRatio_); + node->SetWindowSizeLimits(newLimits); } void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr& node, @@ -604,12 +605,12 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr } } // limit minimum size of window - const auto& systemLimits = const_cast(this)-> - GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId())); - float scale = std::min(static_cast(winRect.width_) / systemLimits.minWidth_, - static_cast(winRect.height_) / systemLimits.minHeight_); + + const auto& sizeLimits = node->GetWindowSizeLimits(); + float scale = std::min(static_cast(winRect.width_) / sizeLimits.minWidth_, + static_cast(winRect.height_) / sizeLimits.minHeight_); if (scale == 0) { - WLOGE("invalid systemLimits"); + WLOGE("invalid sizeLimits"); return; } if (scale < 1.0f) { @@ -618,45 +619,47 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr } } -void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr& node, +void WindowLayoutPolicy::UpdateFloatingWindowSizeBySizeLimits(const sptr& node, const Rect& displayRect, Rect& winRect) const { // get new limit config with the settings of system and app - const auto& customizedLimits = const_cast(this)-> - GetCustomizedLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId())); + const auto& sizeLimits = node->GetWindowSizeLimits(); - // limit minimum and maximum size of floating (not system type) window - winRect.width_ = std::max(customizedLimits.minWidth_, winRect.width_); - winRect.height_ = std::max(customizedLimits.minHeight_, winRect.height_); - winRect.width_ = std::min(customizedLimits.maxWidth_, winRect.width_); - winRect.height_ = std::min(customizedLimits.maxHeight_, winRect.height_); + // limit minimum size of floating (not system type) window + if (!WindowHelper::IsSystemWindow(node->GetWindowType()) || + node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) { + winRect.width_ = std::max(sizeLimits.minWidth_, winRect.width_); + winRect.height_ = std::max(sizeLimits.minHeight_, winRect.height_); + } + winRect.width_ = std::min(sizeLimits.maxWidth_, winRect.width_); + winRect.height_ = std::min(sizeLimits.maxHeight_, winRect.height_); WLOGFD("After limit by size, winRect: %{public}d %{public}d %{public}u %{public}u", winRect.posX_, winRect.posY_, winRect.width_, winRect.height_); // width and height can not be changed - if (customizedLimits.maxWidth_ == customizedLimits.minWidth_ && - customizedLimits.maxHeight_ == customizedLimits.minHeight_) { - winRect.width_ = customizedLimits.maxWidth_; - winRect.height_ = customizedLimits.maxHeight_; + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ && + sizeLimits.maxHeight_ == sizeLimits.minHeight_) { + winRect.width_ = sizeLimits.maxWidth_; + winRect.height_ = sizeLimits.maxHeight_; WLOGFD("window rect can not be changed"); return; } float curRatio = static_cast(winRect.width_) / static_cast(winRect.height_); - if ((customizedLimits.minWidth_ <= winRect.width_ && winRect.width_ <= customizedLimits.maxWidth_) && - (customizedLimits.minHeight_ <= winRect.height_ && winRect.height_ <= customizedLimits.maxHeight_) && - (customizedLimits.minRatio_ <= curRatio && curRatio <= customizedLimits.maxRatio_)) { - WLOGFD("window size and ratio is satisfied with limit ratio, curSize: [%{public}d, %{public}d], " + // there is no need to fix size by ratio if this is not main floating window + if (!WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()) || + (sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_)) { + WLOGFD("window is system window or ratio is satisfied with limits, curSize: [%{public}d, %{public}d], " "curRatio: %{public}f", winRect.width_, winRect.height_, curRatio); return; } - float newRatio = curRatio < customizedLimits.minRatio_ ? customizedLimits.minRatio_ : customizedLimits.maxRatio_; - if (customizedLimits.maxWidth_ == customizedLimits.minWidth_) { + float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_; + if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) { winRect.height_ = static_cast(static_cast(winRect.width_) / newRatio); return; } - if (customizedLimits.maxHeight_ == customizedLimits.minHeight_) { + if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) { winRect.width_ = static_cast(static_cast(winRect.height_) * newRatio); return; } @@ -673,25 +676,6 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr& node, - const Rect& displayRect, Rect& winRect) const -{ - const auto& systemLimits = const_cast(this)-> - GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId())); - - // limit minimum size of floating (not system type) window - 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_); - } - // limit maximum size of all floating window - winRect.width_ = std::min(systemLimits.maxWidth_, winRect.width_); - winRect.height_ = std::min(systemLimits.maxHeight_, winRect.height_); - WLOGFI("After limit by system config, winRect: %{public}d %{public}d %{public}u %{public}u", - winRect.posX_, winRect.posY_, winRect.width_, winRect.height_); -} - void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr& node, const Rect& displayRect, Rect& winRect) const @@ -700,12 +684,7 @@ void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr& node, return; } Rect oriWinRect = winRect; - if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ && - (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) { - UpdateFloatingWindowSizeByCustomizedLimits(node, displayRect, winRect); - } else { - UpdateFloatingWindowSizeBySystemLimits(node, displayRect, winRect); - } + UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect); if (node->GetStretchable() && WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) { @@ -736,12 +715,8 @@ void WindowLayoutPolicy::LimitMainFloatingWindowPosition(const sptr& // if drag or move window, limit size and position if (reason == WindowSizeChangeReason::DRAG) { LimitWindowPositionWhenDrag(node, winRect); - if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ && - (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) { - const auto& limitConfig = const_cast(this)-> GetCustomizedLimitsConfig( - displayGroupInfo_->GetDisplayRect(node->GetDisplayId()), GetVirtualPixelRatio(node->GetDisplayId())); - const_cast(this)-> - FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect, limitConfig); + if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) { + const_cast(this)->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect); } } else { // Limit window position, such as init window rect when show @@ -989,11 +964,6 @@ void WindowLayoutPolicy::SetSplitRatioConfig(const SplitRatioConfig& splitRatioC splitRatioConfig_ = splitRatioConfig; } -void WindowLayoutPolicy::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig) -{ - floatingWindowLimitsConfig_ = floatingWindowLimitsConfig; -} - Rect WindowLayoutPolicy::GetInitalDividerRect(DisplayId displayId) const { return INVALID_EMPTY_RECT; diff --git a/wmserver/src/window_layout_policy_cascade.cpp b/wmserver/src/window_layout_policy_cascade.cpp index 5b5bc0a1..e0a68fc0 100644 --- a/wmserver/src/window_layout_policy_cascade.cpp +++ b/wmserver/src/window_layout_policy_cascade.cpp @@ -14,6 +14,8 @@ */ #include "window_layout_policy_cascade.h" + +#include "minimize_app.h" #include "window_helper.h" #include "window_inner_manager.h" #include "window_manager_hilog.h" @@ -179,6 +181,10 @@ void WindowLayoutPolicyCascade::AddWindowNode(const sptr& node) WLOGFE("window property is nullptr."); return; } + + // update window size limits when add window + UpdateWindowSizeLimits(node); + if (WindowHelper::IsEmptyRect(property->GetRequestRect())) { SetCascadeRect(node); } @@ -466,6 +472,12 @@ void WindowLayoutPolicyCascade::Reorder() WLOGFI("get node failed or not app window."); continue; } + // if window don't support floating mode, or default rect of cascade is not satisfied with limits + if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || + !WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) { + MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_CASCADE); + continue; + } if (isFirstReorderedWindow) { isFirstReorderedWindow = false; } else { @@ -473,13 +485,12 @@ void WindowLayoutPolicyCascade::Reorder() } node->SetRequestRect(rect); node->SetDecoStatus(true); - if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING && - WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { - node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - if (node->GetWindowToken()) { - node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING); - } + if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING) { + node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + if (node->GetWindowToken()) { + node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING); } + } WLOGFI("Cascade reorder Id: %{public}d, rect:[%{public}d, %{public}d, %{public}d, %{public}d]", node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_); } diff --git a/wmserver/src/window_layout_policy_tile.cpp b/wmserver/src/window_layout_policy_tile.cpp index 87423252..438099bf 100644 --- a/wmserver/src/window_layout_policy_tile.cpp +++ b/wmserver/src/window_layout_policy_tile.cpp @@ -118,6 +118,10 @@ void WindowLayoutPolicyTile::InitTileWindowRects(DisplayId displayId) void WindowLayoutPolicyTile::AddWindowNode(const sptr& node) { WM_FUNCTION_TRACE(); + + // update window size limits when add window + UpdateWindowSizeLimits(node); + if (WindowHelper::IsMainWindow(node->GetWindowType())) { DisplayId displayId = node->GetDisplayId(); ForegroundNodeQueuePushBack(node, displayId); @@ -206,6 +210,12 @@ void WindowLayoutPolicyTile::ForegroundNodeQueuePushBack(const sptr& if (iter != foregroundNodes.end()) { return; } + + if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { + WLOGFD("window don't support tile mode, winId: %{public}d", node->GetWindowId()); + MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE); + return; + } WLOGFI("add win in tile, displayId: %{public}" PRIu64", winId: %{public}d", displayId, node->GetWindowId()); while (foregroundNodes.size() >= maxTileWinNumMap_[displayId]) { auto removeNode = foregroundNodes.front(); @@ -247,7 +257,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI auto rectIt = presetRect.begin(); for (auto node : foregroundNodesMap_[displayId]) { auto& rect = (*rectIt); - if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { + if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) && + WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) { node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); if (node->GetWindowToken()) { node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -257,6 +268,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI WLOGFI("set rect for qwin id: %{public}d [%{public}d %{public}d %{public}d %{public}d]", node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_); rectIt++; + } else { + MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE); } } } diff --git a/wmserver/src/window_manager_config.cpp b/wmserver/src/window_manager_config.cpp index f958df33..f217047d 100644 --- a/wmserver/src/window_manager_config.cpp +++ b/wmserver/src/window_manager_config.cpp @@ -73,14 +73,12 @@ bool WindowManagerConfig::LoadConfigXml() continue; } if (!xmlStrcmp(nodeName, reinterpret_cast("maxAppWindowNumber")) || - !xmlStrcmp(nodeName, reinterpret_cast("modeChangeHotZones")) || - !xmlStrcmp(nodeName, reinterpret_cast("floatingWindowLimitSize"))) { + !xmlStrcmp(nodeName, reinterpret_cast("modeChangeHotZones"))) { ReadIntNumbersConfigInfo(curNodePtr); continue; } - if (!xmlStrcmp(nodeName, reinterpret_cast("floatingWindowLimitRatio")) || - !xmlStrcmp(nodeName, reinterpret_cast("splitRatios")) || + if (!xmlStrcmp(nodeName, reinterpret_cast("splitRatios")) || !xmlStrcmp(nodeName, reinterpret_cast("exitSplitRatios"))) { ReadFloatNumbersConfigInfo(curNodePtr); continue; diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 3cff8032..7421b291 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -237,33 +237,6 @@ int WindowManagerService::Dump(int fd, const std::vector& args) }).get(); } -void WindowManagerService::ConfigFloatWindowLimits() -{ - const auto& intNumbersConfig = WindowManagerConfig::GetIntNumbersConfig(); - const auto& floatNumbersConfig = WindowManagerConfig::GetFloatNumbersConfig(); - - FloatingWindowLimitsConfig floatingWindowLimitsConfig; - if (intNumbersConfig.count("floatingWindowLimitSize") != 0) { - auto numbers = intNumbersConfig.at("floatingWindowLimitSize"); - if (numbers.size() == 4) { // 4, limitSize - floatingWindowLimitsConfig.maxWidth_ = static_cast(numbers[0]); // 0 max width - floatingWindowLimitsConfig.maxHeight_ = static_cast(numbers[1]); // 1 max height - floatingWindowLimitsConfig.minWidth_ = static_cast(numbers[2]); // 2 min width - floatingWindowLimitsConfig.minHeight_ = static_cast(numbers[3]); // 3 min height - floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true; - } - } - if (floatNumbersConfig.count("floatingWindowLimitRatio") != 0) { - auto numbers = floatNumbersConfig.at("floatingWindowLimitRatio"); - if (numbers.size() == 2) { // 2, limitRatio - floatingWindowLimitsConfig.maxRatio_ = static_cast(numbers[0]); // 0 max ratio - floatingWindowLimitsConfig.minRatio_ = static_cast(numbers[1]); // 1 min ratio - floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true; - } - } - windowRoot_->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig); -} - void WindowManagerService::ConfigureWindowManagerService() { const auto& enableConfig = WindowManagerConfig::GetEnableConfig(); @@ -301,8 +274,6 @@ void WindowManagerService::ConfigureWindowManagerService() } } - ConfigFloatWindowLimits(); - if (floatNumbersConfig.count("splitRatios") != 0) { windowRoot_->SetSplitRatios(floatNumbersConfig.at("splitRatios")); } diff --git a/wmserver/src/window_node.cpp b/wmserver/src/window_node.cpp index e4d89d49..ebe6e0d9 100644 --- a/wmserver/src/window_node.cpp +++ b/wmserver/src/window_node.cpp @@ -196,6 +196,16 @@ void WindowNode::SetTouchHotAreas(const std::vector& rects) touchHotAreas_ = rects; } +void WindowNode::SetWindowSizeLimits(const WindowSizeLimits& sizeLimits) +{ + property_->SetSizeLimits(sizeLimits); +} + +WindowSizeLimits WindowNode::GetWindowSizeLimits() const +{ + return property_->GetSizeLimits(); +} + DragType WindowNode::GetDragType() const { return property_->GetDragType(); diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index a1ec32f2..0a26923b 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -1562,6 +1562,25 @@ WMError WindowNodeContainer::SwitchLayoutPolicy(WindowLayoutMode dstMode, Displa return WMError::WM_OK; } +void WindowNodeContainer::UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up) +{ + if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestModeSupportInfo(), + WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) { + WLOGFD("window doesn't support split mode, winId: %{public}d", node->GetWindowId()); + return; + } + uint32_t modeSupportInfo; + if (up) { + modeSupportInfo = node->GetModeSupportInfo() & (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + } else { + modeSupportInfo = node->GetModeSupportInfo() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY; + } + node->SetModeSupportInfo(modeSupportInfo); + if (node->GetWindowToken() != nullptr) { + node->GetWindowToken()->UpdateWindowModeSupportInfo(modeSupportInfo); + } +} + void WindowNodeContainer::RaiseInputMethodWindowPriorityIfNeeded(const sptr& node) const { if (node->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT || !isScreenLocked_) { @@ -1604,6 +1623,8 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up) } } + UpdateModeSupportInfoWhenKeyguardChange(needReZOrderNode, up); + parentNode->children_.insert(position, needReZOrderNode); if (up && WindowHelper::IsSplitWindowMode(needReZOrderNode->GetWindowMode())) { needReZOrderNode->GetWindowProperty()->ResumeLastWindowMode(); @@ -1617,8 +1638,7 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up) } windowPair->UpdateIfSplitRelated(needReZOrderNode); } - WLOGFI("ShowWhenLocked window %{public}u re-zorder when keyguard change %{public}u", - needReZOrderNode->GetWindowId(), up); + WLOGFI("window %{public}u re-zorder when keyguard change %{public}u", needReZOrderNode->GetWindowId(), up); } } @@ -1867,5 +1887,10 @@ void WindowNodeContainer::UpdateCameraFloatWindowStatus(const sptr& WindowManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(node->GetAccessTokenId(), isShowing); } } + +WindowLayoutMode WindowNodeContainer::GetCurrentLayoutMode() const +{ + return layoutMode_; +} } // namespace Rosen } // namespace OHOS diff --git a/wmserver/src/window_pair.cpp b/wmserver/src/window_pair.cpp index 359b17ac..7b853be6 100644 --- a/wmserver/src/window_pair.cpp +++ b/wmserver/src/window_pair.cpp @@ -183,10 +183,6 @@ void WindowPair::ExitSplitMode() hideWindow = secondary_; fullScreenWindow = primary_; } - if (WindowHelper::IsWindowModeSupported(fullScreenWindow->GetModeSupportInfo(), - WindowMode::WINDOW_MODE_FULLSCREEN)) { - fullScreenWindow->GetWindowProperty()->SetLastWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - } MinimizeApp::AddNeedMinimizeApp(hideWindow, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReason(MinimizeReason::SPLIT_QUIT); WLOGFI("Exit Split Mode, Minimize Window %{public}u", hideWindow->GetWindowId()); @@ -385,16 +381,14 @@ void WindowPair::SwitchPosition() WLOGFI("Switch the pair pos, pri: %{public}u pri-mode: %{public}u, sec: %{public}u sec-mode: %{public}u,", primary_->GetWindowId(), primary_->GetWindowMode(), secondary_->GetWindowId(), secondary_->GetWindowMode()); if (primary_->GetWindowMode() == secondary_->GetWindowMode() && - primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY && - WindowHelper::IsWindowModeSupported(primary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_SECONDARY)) { + primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) { primary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); if (primary_->GetWindowToken() != nullptr) { primary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); } std::swap(primary_, secondary_); } else if (primary_->GetWindowMode() == secondary_->GetWindowMode() && - primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY && - WindowHelper::IsWindowModeSupported(secondary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) { + primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) { secondary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); if (secondary_->GetWindowToken() != nullptr) { secondary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index f71a2973..d13e9626 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -117,7 +117,6 @@ sptr WindowRoot::CreateWindowNodeContainer(sptrGetLayoutPolicy()->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig_); container->GetLayoutPolicy()->SetSplitRatioConfig(splitRatioConfig_); return container; } @@ -481,7 +480,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr& node, boo return res; } // limit number of main window - int mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + uint32_t mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); if (mainWindowNumber >= maxAppWindowNumber_ && node->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) { container->MinimizeOldestAppWindow(); } @@ -1310,9 +1309,14 @@ WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId, return WMError::WM_OK; } -void WindowRoot::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig) +WindowLayoutMode WindowRoot::GetCurrentLayoutMode(DisplayId displayId) { - floatingWindowLimitsConfig_ = floatingWindowLimitsConfig; + auto container = GetOrCreateWindowNodeContainer(displayId); + if (container == nullptr) { + WLOGFE("GetCurrentLayoutMode failed, window container could not be found"); + return WindowLayoutMode::BASE; + } + return container->GetCurrentLayoutMode(); } } // namespace Rosen } // namespace OHOS From 18d25b68a1b65377717aedcf9317ceebea4ef354 Mon Sep 17 00:00:00 2001 From: dubj Date: Wed, 29 Jun 2022 14:40:30 +0800 Subject: [PATCH 12/12] =?UTF-8?q?touchOutside=E6=8E=A5=E5=8F=A3=E5=8A=A0co?= =?UTF-8?q?nst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dubj Change-Id: If2005b0e9453be985b3931f4d13981c749480b30 --- interfaces/innerkits/wm/window.h | 2 +- .../window_napi/js_window_listener.cpp | 15 ++++++++------- .../window_napi/js_window_listener.h | 5 +++-- wm/test/systemtest/window_touch_outside_test.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index b850114b..58205233 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -122,7 +122,7 @@ public: class ITouchOutsideListener : virtual public RefBase { public: - virtual void OnTouchOutside() = 0; + virtual void OnTouchOutside() const = 0; }; class Window : public RefBase { diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index cdbc05b4..e9e9954a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -15,6 +15,7 @@ #include "js_window_listener.h" #include "js_runtime_utils.h" #include "window_manager_hilog.h" + namespace OHOS { namespace Rosen { using namespace AbilityRuntime; @@ -47,7 +48,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason) WLOGFI("[NAPI]OnSizeChange, wh[%{public}u, %{public}u], reason = %{public}u", rect.width_, rect.height_, reason); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), rect, eng = engine_] (NativeEngine &engine, + [self = weakRef_, rect, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -83,7 +84,7 @@ void JsWindowListener::OnSystemBarPropertyChange(DisplayId displayId, const Syst WLOGFI("[NAPI]OnSystemBarPropertyChange"); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), displayId, tints, eng = engine_] (NativeEngine &engine, + [self = weakRef_, displayId, tints, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -114,7 +115,7 @@ void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaTy WLOGFI("[NAPI]OnAvoidAreaChanged"); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), avoidArea, type, eng = engine_] (NativeEngine &engine, + [self = weakRef_, avoidArea, type, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -145,7 +146,7 @@ void JsWindowListener::LifeCycleCallBack(LifeCycleEventType eventType) { WLOGFI("[NAPI]LifeCycleCallBack, envent type: %{public}u", eventType); std::unique_ptr complete = std::make_unique( - [self = wptr(this), eventType, eng = engine_] (NativeEngine &engine, + [self = weakRef_, eventType, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -189,7 +190,7 @@ void JsWindowListener::OnSizeChange(const sptr& info) info->rect_.posX_, info->rect_.posY_, info->rect_.width_, info->rect_.height_); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( - [self = wptr(this), info, eng = engine_] (NativeEngine &engine, + [self = weakRef_, info, eng = engine_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { @@ -207,10 +208,10 @@ void JsWindowListener::OnSizeChange(const sptr& info) *engine_, std::make_unique(callback, std::move(execute), std::move(complete))); } -void JsWindowListener::OnTouchOutside() +void JsWindowListener::OnTouchOutside() const { std::unique_ptr complete = std::make_unique ( - [self = wptr(this)] (NativeEngine &engine, AsyncTask &task, int32_t status) { + [self = weakRef_] (NativeEngine &engine, AsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr) { WLOGFE("[NAPI]this listener is nullptr"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index 8a39f121..617a1be2 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -47,7 +47,7 @@ class JsWindowListener : public IWindowChangeListener, public ITouchOutsideListener { public: JsWindowListener(NativeEngine* engine, std::shared_ptr callback) - : engine_(engine), jsCallBack_(callback) {} + : engine_(engine), jsCallBack_(callback), weakRef_(wptr (this)) {} ~JsWindowListener(); void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) override; void OnSizeChange(Rect rect, WindowSizeChangeReason reason) override; @@ -58,12 +58,13 @@ public: void AfterFocused() override; void AfterUnfocused() override; void OnSizeChange(const sptr& info) override; - void OnTouchOutside() override; + void OnTouchOutside() const override; void CallJsMethod(const char* methodName, NativeValue* const* argv = nullptr, size_t argc = 0); private: void LifeCycleCallBack(LifeCycleEventType eventType); NativeEngine* engine_ = nullptr; std::shared_ptr jsCallBack_ = nullptr; + wptr weakRef_ = nullptr; DEFINE_VAR_DEFAULT_FUNC_SET(bool, IsDeprecatedInterface, isDeprecatedInterface, false) }; } // namespace Rosen diff --git a/wm/test/systemtest/window_touch_outside_test.cpp b/wm/test/systemtest/window_touch_outside_test.cpp index 39b076e2..89727851 100644 --- a/wm/test/systemtest/window_touch_outside_test.cpp +++ b/wm/test/systemtest/window_touch_outside_test.cpp @@ -31,11 +31,11 @@ const int WAIT_CALLBACK_US = 10000; // 10000 us class WindowTouchOutsideTestListener : public ITouchOutsideListener { public: - void OnTouchOutside() override + void OnTouchOutside() const override { isTouchOutside_ = true; } - bool isTouchOutside_ { false }; + mutable bool isTouchOutside_ { false }; }; class WindowTouchOutsideTest : public testing::Test { @@ -106,11 +106,11 @@ void WindowTouchOutsideTest::TearDownTestCase() namespace { /** - * @tc.name: onTouchIutside + * @tc.name: onTouchInside * @tc.desc: can't not receive a inside touch event * @tc.type: FUNC */ -HWTEST_F(WindowTouchOutsideTest, onTouchIutside, Function | MediumTest | Level3) +HWTEST_F(WindowTouchOutsideTest, onTouchInside, Function | MediumTest | Level3) { const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); firstWindow->RegisterTouchOutsideListener(windowlistener1_);