From 9ef9c014c6cc1db77559a92caf1d5aab3b918bf2 Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Sun, 27 Apr 2025 17:47:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=94=AE=E7=9B=98=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BA=E5=8F=98=E5=8C=96=E9=80=9A=E7=9F=A5=E9=80=9A=E8=B7=AF?= =?UTF-8?q?=E5=90=88=E4=B8=80--=E5=9F=BA=E6=9C=AC=E9=80=9A=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- interfaces/innerkits/wm/window.h | 4 +- .../cj/window_runtime/window_listener.cpp | 3 +- .../kits/cj/window_runtime/window_listener.h | 3 +- .../js_extension_window_listener.cpp | 3 +- .../js_extension_window_listener.h | 3 +- .../window_napi/js_window_listener.cpp | 3 +- .../window_napi/js_window_listener.h | 3 +- .../js_scene_session_manager.cpp | 4 +- .../include/zidl/session_stage_interface.h | 3 +- .../include/zidl/session_stage_proxy.h | 3 +- .../src/zidl/session_stage_proxy.cpp | 12 +- .../container/src/zidl/session_stage_stub.cpp | 15 +- .../session/host/include/keyboard_session.h | 6 + .../session/host/include/scene_session.h | 7 + .../session/host/src/keyboard_session.cpp | 159 +++++++++++++++++- .../session/host/src/scene_session.cpp | 5 + .../include/scene_session_manager.h | 3 +- .../src/scene_session_manager.cpp | 28 ++- wm/include/root_scene.h | 3 +- wm/include/window_extension_session_impl.h | 3 +- wm/include/window_session_impl.h | 5 +- wm/src/root_scene.cpp | 5 +- wm/src/window_extension_session_impl.cpp | 3 +- wm/src/window_session_impl.cpp | 14 +- 24 files changed, 273 insertions(+), 27 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index bb68869383..e9445cb24a 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -230,8 +230,10 @@ public: * * @param avoidArea Area needed to be avoided. * @param type Type of avoid area. + * @param info Keyboard occupied area info. */ - virtual void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) {} + virtual void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, + const sptr& info = nullptr) {} }; /** diff --git a/interfaces/kits/cj/window_runtime/window_listener.cpp b/interfaces/kits/cj/window_runtime/window_listener.cpp index 1627ceec00..8795e9ee7a 100644 --- a/interfaces/kits/cj/window_runtime/window_listener.cpp +++ b/interfaces/kits/cj/window_runtime/window_listener.cpp @@ -127,7 +127,8 @@ void CjWindowListener::OnModeChange(WindowMode mode, bool hasDeco) { } -void CjWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) +void CjWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, + const sptr& info) { auto thisListener = weakRef_.promote(); if (thisListener == nullptr) { diff --git a/interfaces/kits/cj/window_runtime/window_listener.h b/interfaces/kits/cj/window_runtime/window_listener.h index f4045dd310..4f029c2dc8 100644 --- a/interfaces/kits/cj/window_runtime/window_listener.h +++ b/interfaces/kits/cj/window_runtime/window_listener.h @@ -76,7 +76,8 @@ public: void OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; void OnModeChange(WindowMode mode, bool hasDeco) override; - void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; + void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, + const sptr& info = nullptr) override; void AfterForeground() override; void AfterBackground() override; void AfterFocused() override; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index ff6968c30b..900577cc1a 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -155,7 +155,8 @@ void JsExtensionWindowListener::OnModeChange(WindowMode mode, bool hasDeco) TLOGI(WmsLogTag::WMS_UIEXT, "%{public}u", mode); } -void JsExtensionWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) +void JsExtensionWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, + const sptr& info) { TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]"); // js callback should run in js thread diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.h b/interfaces/kits/napi/extension_window/js_extension_window_listener.h index 7813b3f669..e256dd5157 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.h @@ -45,7 +45,8 @@ public: const std::shared_ptr& rsTransaction = nullptr) override; void OnRectChange(Rect rect, WindowSizeChangeReason reason) override; void OnModeChange(WindowMode mode, bool hasDeco) override; - void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; + void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, + const sptr& info = nullptr) override; void AfterForeground() override; void AfterBackground() override; void AfterFocused() override; 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 217fe95f05..acfdcdb18d 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 @@ -145,7 +145,8 @@ void JsWindowListener::OnSystemBarPropertyChange(DisplayId displayId, const Syst } } -void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) +void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, + const sptr& info) { WLOGFD("[NAPI]"); // js callback should run in js thread 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 fad7ac961f..e49f48be14 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 @@ -92,7 +92,8 @@ public: void OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; void OnModeChange(WindowMode mode, bool hasDeco) override; - void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; + void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, + const sptr& info = nullptr) override; void AfterForeground() override; void AfterBackground() override; void AfterFocused() override; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index e63afd8769..7112ea003b 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -684,8 +684,8 @@ void JsSceneSessionManager::RegisterRootSceneCallbacksOnSSManager() return RootScene::staticRootScene_->IsLastFrameLayoutFinished(); }); SceneSessionManager::GetInstance().RegisterNotifyRootSceneAvoidAreaChangeFunc( - [](const sptr& avoidArea, AvoidAreaType type) { - RootScene::staticRootScene_->NotifyAvoidAreaChangeForRoot(avoidArea, type); + [](const sptr& avoidArea, AvoidAreaType type, const sptr& info = nullptr) { + RootScene::staticRootScene_->NotifyAvoidAreaChangeForRoot(avoidArea, type, info); }); SceneSessionManager::GetInstance().RegisterNotifyRootSceneOccupiedAreaChangeFunc( [](const sptr& info) { diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index c2c0212fbd..5dbfd9a87d 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -54,7 +54,8 @@ public: */ virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }, - const std::map& avoidAreas = {}) = 0; + const std::map& avoidAreas = {}, + const sptr& info = nullptr) = 0; virtual void UpdateDensity() = 0; virtual WSError UpdateOrientation() = 0; diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 9414b44707..0d9c4ba174 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -34,7 +34,8 @@ public: WSError SetActive(bool active) override; WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }, - const std::map& avoidAreas = {}) override; + const std::map& avoidAreas = {}, + const sptr& occupiedAreaInfo = nullptr) override; void UpdateDensity() override; WSError UpdateOrientation() override; WSError UpdateSessionViewportConfig(const SessionViewportConfig& config) override; diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index ffe81a55f6..19c4dd672a 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -172,7 +172,8 @@ WSError SessionStageProxy::UpdateDisplayId(uint64_t displayId) } WSError SessionStageProxy::UpdateRect(const WSRect& rect, SizeChangeReason reason, - const SceneAnimationConfig& config, const std::map& avoidAreas) + const SceneAnimationConfig& config, const std::map& avoidAreas, + const sptr& occupiedAreaInfo) { MessageParcel data; MessageParcel reply; @@ -229,6 +230,15 @@ WSError SessionStageProxy::UpdateRect(const WSRect& rect, SizeChangeReason reaso } } + bool hasOccupiedAreaInfo = occupiedAreaInfo != nullptr; + if (!data.WriteBool(hasOccupiedAreaInfo)) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Write hasOccupiedAreaInfo failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (hasOccupiedAreaInfo && !data.WriteParcelable(occupiedAreaInfo)) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Write occupiedAreaInfo failed"); + return WSError::WS_ERROR_IPC_FAILED; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index af01718978..ef0f907dd1 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -290,7 +290,20 @@ int SessionStageStub::HandleUpdateRect(MessageParcel& data, MessageParcel& reply } avoidAreas[static_cast(type)] = *area; } - WSError errCode = UpdateRect(rect, reason, config, avoidAreas); + bool hasOccupiedAreaInfo = false; + sptr occupiedAreaInfo = nullptr; + if (!data.ReadBool(hasOccupiedAreaInfo)) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Read hasOccupiedAreaInfo failed"); + return ERR_INVALID_DATA; + } + if (hasOccupiedAreaInfo) { + occupiedAreaInfo = data.ReadParcelable(); + if (occupiedAreaInfo == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Read occupiedAreaInfo failed"); + return ERR_INVALID_DATA; + } + } + WSError errCode = UpdateRect(rect, reason, config, avoidAreas, occupiedAreaInfo); reply.WriteUint32(static_cast(errCode)); return ERR_NONE; } diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index 4eda9112fd..4100d86b28 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -77,6 +77,7 @@ public: WSError UpdateSizeChangeReason(SizeChangeReason reason) override; bool GetIsKeyboardSyncTransactionOpen() const { return isKeyboardSyncTransactionOpen_; } void SetSkipEventOnCastPlus(bool isSkip) override; + bool GetIsKeyboardSyncTransactionOpen() const { return isKeyboardSyncTransactionOpen_; } protected: void EnableCallingSessionAvoidArea() override; @@ -111,6 +112,11 @@ private: void SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool needFlush = true) override; bool IsNeedRaiseSubWindow(const sptr& callingSession, const WSRect& callingSessionRect); void PostKeyboardAnimationSyncTimeoutTask(); + bool GetKeyboardSyncTransactionStatus() override; + bool CalculateRectAndAvoidArea(sptr& occupiedAreaInfo, + const bool& needCheckVisible) override; + bool CalculateRectAndAvoidAreaInner(const sptr& callingSession, const WSRect& rect, + const WSRect& panelRect, sptr& occupiedAreaInfo); sptr keyboardCallback_ = nullptr; bool isKeyboardSyncTransactionOpen_ = false; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 5bc0edc071..b31c07da41 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -739,6 +739,13 @@ public: void NotifyKeyboardAnimationCompleted(bool isShowAnimation, const WSRect& beginRect, const WSRect& endRect); void NotifyKeyboardDidShowRegistered(bool registered) override; void NotifyKeyboardDidHideRegistered(bool registered) override; + IsLastFrameLayoutFinishedFunc GetIsLastFrameLayoutFinishedFunc(); + virtual bool GetKeyboardSyncTransactionStatus() { return false; } + virtual bool CalculateRectAndAvoidArea(sptr& occupiedAreaInfo, + const bool& needCheckVisible) { return true; } + virtual void NotifyOccupiedArea(const sptr& occupiedAreaInfo, + const bool& isKeyboardSyncTransactionOpen = false, + std::shared_ptr rsTransaction = nullptr) {} /* * Window Focus diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index cf0fdaac5e..27afbbf6d4 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -406,6 +406,46 @@ void KeyboardSession::NotifyOccupiedAreaChangeInfo(const sptr& cal } } +void KeyboardSession::NotifyOccupiedArea(const sptr& occupiedAreaInfo, + const bool& isKeyboardSyncTransactionOpen, + std::shared_ptr rsTransaction) +{ + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- start to notify occupied area change info"); + NotifyKeyboardPanelInfoChange(GetPanelRect(), true); + sptr callingSession = GetSceneSession(GetCallingSessionId()); + if (callingSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Calling session is nullptr"); + return; + } + if (sessionStage_ == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "sessionStage_ is nullptr"); + return; + } + if (occupiedAreaInfo == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "occupiedAreaInfo is nullptr"); + return; + } + + if (isKeyboardSyncTransactionOpen) { + rsTransaction = (rsTransaction == nullptr) ? GetRSTransaction() : rsTransaction; + } + SceneAnimationConfig config { + .rsTransaction_ = rsTransaction, + }; + sessionStage_->UpdateRect(SessionHelper::TransferToWSRect(GetSessionProperty()->GetWindowRect()), + SizeChangeReason::AVOID_AREA_CHANGE, config, {}, occupiedAreaInfo); + + if (callingSession->IsSystemSession()) { + NotifyRootSceneOccupiedAreaChange(occupiedAreaInfo); + } else { + callingSession->NotifyOccupiedAreaChangeInfo(occupiedAreaInfo, rsTransaction); + } + TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling id: %{public}d, occupiedAreaRect: %{public}s" + ", textFieldPositionY_: %{public}f, textFieldHeight_: %{public}f", + callingSession->GetPersistentId(), occupiedAreaInfo->rect_.ToString().c_str(), + occupiedAreaInfo->textFieldPositionY_, occupiedAreaInfo->textFieldHeight_); +} + void KeyboardSession::NotifyKeyboardPanelInfoChange(WSRect rect, bool isKeyboardPanelShow) { if (!sessionStage_) { @@ -420,6 +460,102 @@ void KeyboardSession::NotifyKeyboardPanelInfoChange(WSRect rect, bool isKeyboard sessionStage_->NotifyKeyboardPanelInfoChange(keyboardPanelInfo); } +bool KeyboardSession::CalculateRectAndAvoidArea(sptr& occupiedAreaInfo, + const bool& needCheckVisible) +{ + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- calculate occupied area, id: %{public}d", GetCallingSessionId()); + if (!keyboardAvoidAreaActive_) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, isSystemKeyboard: %{public}d, state: %{public}d, " + "gravity: %{public}d", GetPersistentId(), IsSystemKeyboard(), GetSessionState(), GetKeyboardGravity()); + return false; + } + if (!IsSessionForeground() || (needCheckVisible && !IsVisibleForeground())) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is not foreground"); + return false; + } + sptr callingSession = GetSceneSession(GetCallingSessionId()); + if (callingSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Calling session is nullptr"); + return false; + } + + bool isCallingSessionFloating = (callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) && + !callingSession->GetIsMidScene(); + if (!CheckIfNeedRaiseCallingSession(callingSession, isCallingSessionFloating)) { + return false; + } + + WSRect callingSessionRect = callingSession->GetSessionRect(); + int32_t oriPosYBeforeRaisedByKeyboard = callingSession->GetOriPosYBeforeRaisedByKeyboard(); + if (oriPosYBeforeRaisedByKeyboard != 0 && isCallingSessionFloating) { + callingSessionRect.posY_ = oriPosYBeforeRaisedByKeyboard; + } + // update panel rect for avoid area caculate + WSRect panelAvoidRect = GetPanelRect(); + RecalculatePanelRectForAvoidArea(panelAvoidRect); + if (SessionHelper::IsEmptyRect(SessionHelper::GetOverlap(panelAvoidRect, callingSessionRect, 0, 0)) && + oriPosYBeforeRaisedByKeyboard == 0) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "No overlap area, keyboardRect: %{public}s, callingRect: %{public}s", + panelAvoidRect.ToString().c_str(), callingSessionRect.ToString().c_str()); + return CalculateRectAndAvoidAreaInner(callingSession, callingSessionRect, panelAvoidRect, occupiedAreaInfo); + } + + bool occupiedAreaChanged = true; + WSRect newRect = callingSessionRect; + int32_t statusHeight = callingSession->GetStatusBarHeight(); + if (IsNeedRaiseSubWindow(callingSession, newRect) && + isCallingSessionFloating && callingSessionRect.posY_ > statusHeight) { + if (oriPosYBeforeRaisedByKeyboard == 0) { + oriPosYBeforeRaisedByKeyboard = callingSessionRect.posY_; + callingSession->SetOriPosYBeforeRaisedByKeyboard(callingSessionRect.posY_); + } + // calculate new rect of calling session + newRect.posY_ = std::max(panelAvoidRect.posY_ - newRect.height_, statusHeight); + newRect.posY_ = std::min(oriPosYBeforeRaisedByKeyboard, newRect.posY_); + occupiedAreaChanged = CalculateRectAndAvoidAreaInner(callingSession, newRect, panelAvoidRect, occupiedAreaInfo); + if (!IsSystemKeyboard()) { + callingSession->UpdateSessionRect(newRect, SizeChangeReason::UNDEFINED); + } + } else { + occupiedAreaChanged = CalculateRectAndAvoidAreaInner(callingSession, newRect, panelAvoidRect, occupiedAreaInfo); + } + + TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardRect: %{public}s, callSession OriRect: %{public}s, newRect: %{public}s" + ", oriPosYBeforeRaisedByKeyboard: %{public}d, isCallingSessionFloating: %{public}d", + panelAvoidRect.ToString().c_str(), callingSessionRect.ToString().c_str(), newRect.ToString().c_str(), + oriPosYBeforeRaisedByKeyboard, isCallingSessionFloating); + return occupiedAreaChanged; +} + +bool KeyboardSession::CalculateRectAndAvoidAreaInner(const sptr& callingSession, const WSRect& rect, + const WSRect& panelRect, sptr& occupiedAreaInfo) +{ + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- calculate occupied area inner, id: %{public}d", GetCallingSessionId()); + // if keyboard will occupy calling, notify calling window the occupied area and safe height + const WSRect& safeRect = !callingSession->GetIsMidScene() ? SessionHelper::GetOverlap(panelRect, rect, 0, 0) : + CalculateSafeRectForMidScene(rect, panelRect, callingSession->GetScaleX(), callingSession->GetScaleY()); + const WSRect& lastSafeRect = callingSession->GetLastSafeRect(); + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- lastSafeRect: %{public}s", lastSafeRect.ToString().c_str()); + if (lastSafeRect == safeRect) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "SafeRect is same to lastSafeRect: %{public}s", safeRect.ToString().c_str()); + return false; + } + callingSession->SetLastSafeRect(safeRect); + double textFieldPositionY = 0.0; + double textFieldHeight = 0.0; + auto sessionProperty = GetSessionProperty(); + if (sessionProperty != nullptr) { + textFieldPositionY = sessionProperty->GetTextFieldPositionY(); + textFieldHeight = sessionProperty->GetTextFieldHeight(); + } + occupiedAreaInfo = sptr::MakeSptr(OccupiedAreaType::TYPE_INPUT, + SessionHelper::TransferToRect(safeRect), safeRect.height_, textFieldPositionY, textFieldHeight); + TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling id: %{public}d, safeRect: %{public}s, keyboardRect: %{public}s" + ", textFieldPositionY_: %{public}f, textFieldHeight_: %{public}f", callingSession->GetPersistentId(), + safeRect.ToString().c_str(), panelRect.ToString().c_str(), textFieldPositionY, textFieldHeight); + return true; +} + bool KeyboardSession::CheckIfNeedRaiseCallingSession(sptr callingSession, bool isCallingSessionFloating) { if (callingSession == nullptr) { @@ -658,8 +794,22 @@ void KeyboardSession::CloseKeyboardSyncTransaction(uint32_t callingId, const WSR } // The callingId may change in WindowManager. Use scb's callingId to properly handle callingWindow raise/restore. if (isKeyboardShow) { - session->RaiseCallingSession(callingId, keyboardPanelRect, false, rsTransaction); - session->UpdateKeyboardAvoidArea(); + bool isLayoutFinished = false; + // If vsync acquisition fails or the vsync period terminates, immediately notify all registered listeners. + IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc = session->GetIsLastFrameLayoutFinishedFunc(); + if (isLastFrameLayoutFinishedFunc == nullptr || + isLastFrameLayoutFinishedFunc(isLayoutFinished) != WSError::WS_OK || isLayoutFinished) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "isLastFrameLayoutFinishedFunc_ failed or vsync finished," + "id: %{public}d, isLayoutFinished: %{public}d", session->GetCallingSessionId(), isLayoutFinished); + + sptr occupiedAreaInfo = nullptr; + bool occupiedAreaChanged = session->CalculateRectAndAvoidArea( + occupiedAreaInfo, session->isKeyboardSyncTransactionOpen_); + if (occupiedAreaChanged) { + session->NotifyOccupiedArea( + occupiedAreaInfo, session->isKeyboardSyncTransactionOpen_, rsTransaction); + } + } } else { session->RestoreCallingSession(callingId, rsTransaction); session->GetSessionProperty()->SetCallingSessionId(INVALID_WINDOW_ID); @@ -683,6 +833,11 @@ void KeyboardSession::CloseKeyboardSyncTransaction(uint32_t callingId, const WSR }, "CloseKeyboardSyncTransaction"); } +bool KeyboardSession::GetKeyboardSyncTransactionStatus() +{ + return isKeyboardSyncTransactionOpen_; +} + std::shared_ptr KeyboardSession::GetRSTransaction() { auto transactionController = RSSyncTransactionController::GetInstance(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 00bc831878..aa29781344 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -6489,6 +6489,11 @@ void SceneSession::SetIsLastFrameLayoutFinishedFunc(IsLastFrameLayoutFinishedFun isLastFrameLayoutFinishedFunc_ = std::move(func); } +IsLastFrameLayoutFinishedFunc SceneSession::GetIsLastFrameLayoutFinishedFunc() +{ + return isLastFrameLayoutFinishedFunc_; +} + void SceneSession::SetIsAINavigationBarAvoidAreaValidFunc(IsAINavigationBarAvoidAreaValidFunc&& func) { isAINavigationBarAvoidAreaValid_ = std::move(func); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index eed8b83957..e2293cd7be 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -140,7 +140,8 @@ using IsRootSceneLastFrameLayoutFinishedFunc = std::function; using NotifyStartPiPFailedFunc = std::function; using NotifyAppUseControlListFunc = std::function& controlList)>; -using NotifyRootSceneAvoidAreaChangeFunc = std::function& avoidArea, AvoidAreaType type)>; +using NotifyRootSceneAvoidAreaChangeFunc = std::function& avoidArea, AvoidAreaType type, + const sptr& info)>; using NotifyWatchGestureConsumeResultFunc = std::function; using NotifyWatchFocusActiveChangeFunc = std::function; using NotifyRootSceneOccupiedAreaChangeFunc = std::function& info)>; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c0fc7d5da7..3f2b26c7ef 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1440,8 +1440,9 @@ void SceneSessionManager::CreateRootSceneSession() specificCb->onUpdateAvoidArea_ = [this](int32_t persistentId) { this->UpdateAvoidArea(persistentId); }; - specificCb->onNotifyAvoidAreaChange_ = [this](const sptr& avoidArea, AvoidAreaType type) { - onNotifyAvoidAreaChangeForRootFunc_(avoidArea, type); + specificCb->onNotifyAvoidAreaChange_ = [this](const sptr& avoidArea, AvoidAreaType type, + const sptr& info = nullptr) { + onNotifyAvoidAreaChangeForRootFunc_(avoidArea, type, info); }; rootSceneSession_ = sptr::MakeSptr(specificCb); rootSceneSession_->isKeyboardPanelEnabled_ = isKeyboardPanelEnabled_; @@ -1841,7 +1842,7 @@ sptr SceneSessionManager::CreateKeyboa this->HandleKeyboardAvoidChange(nullptr, displayId, reason); }; keyboardCb->onNotifyOccupiedAreaChange = [this](const sptr& info) { - this->onNotifyOccupiedAreaChangeForRootFunc_(info); + onNotifyAvoidAreaChangeForRootFunc_({}, AvoidAreaType::TYPE_START, info); }; return keyboardCb; } @@ -11523,6 +11524,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_map startingAppZOrderList; processingFlushUIParams_.store(true); + auto keyboardSession = GetKeyboardSession(screenId, false); { std::shared_lock lock(sceneSessionMapMutex_); for (const auto& [_, sceneSession] : sceneSessionMap_) { @@ -11539,6 +11541,26 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapsecond.zOrder_); sceneSession->SetStartingBeforeVisible(false); } + // Calculate keyboard occupied area + if (keyboardSession != nullptr + && keyboardSession->GetPersistentId() == sceneSession->GetPersistentId()) { + sptr occupiedAreaInfo = nullptr; + bool occupiedAreaChanged = keyboardSession->CalculateRectAndAvoidArea( + occupiedAreaInfo, keyboardSession->GetKeyboardSyncTransactionStatus()); + if (occupiedAreaInfo == nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- flush ui params, occupiedAreaInfo is nullptr," + " occupiedAreaChanged = %{public}d", occupiedAreaChanged); + } else { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- flush ui params, occupiedAreaInfo=%{public}s," + " occupiedAreaChanged = %{public}d", occupiedAreaInfo->rect_.ToString().c_str(), + occupiedAreaChanged); + } + // Notify keyboard occupied area change info + if (occupiedAreaChanged) { + keyboardSession->NotifyOccupiedArea( + occupiedAreaInfo, keyboardSession->GetKeyboardSyncTransactionStatus()); + } + } sessionMapDirty_ |= sceneSession->UpdateUIParam(iter->second); } else { sessionMapDirty_ |= sceneSession->UpdateUIParam(); diff --git a/wm/include/root_scene.h b/wm/include/root_scene.h index 4d87b1fcc0..6c287ad785 100644 --- a/wm/include/root_scene.h +++ b/wm/include/root_scene.h @@ -71,7 +71,8 @@ public: void RegisterUpdateRootSceneRectCallback(UpdateRootSceneRectCallback&& callback); WMError RegisterAvoidAreaChangeListener(const sptr& listener) override; WMError UnregisterAvoidAreaChangeListener(const sptr& listener) override; - void NotifyAvoidAreaChangeForRoot(const sptr& avoidArea, AvoidAreaType type); + void NotifyAvoidAreaChangeForRoot(const sptr& avoidArea, AvoidAreaType type, + const sptr& info = nullptr); void RegisterUpdateRootSceneAvoidAreaCallback(UpdateRootSceneAvoidAreaCallback&& callback); std::string GetClassType() const override { return "RootScene"; } bool IsSystemWindow() const override { return WindowHelper::IsSystemWindow(GetType()); } diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index fd26d62685..6c99bee504 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -70,7 +70,8 @@ public: void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) override {} WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }, - const std::map& avoidAreas = {}) override; + const std::map& avoidAreas = {}, + const sptr& occupiedAreaInfo = nullptr) override; WMError GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea, const Rect& rect = Rect::EMPTY_RECT, int32_t apiVersion = API_VERSION_INVALID) override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 07d95e5189..6160e0a12e 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -169,7 +169,8 @@ public: WSError SetActive(bool active) override; WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }, - const std::map& avoidAreas = {}) override; + const std::map& avoidAreas = {}, + const sptr& occupiedAreaInfo = nullptr) override; void UpdateDensity() override; void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) override; WSError UpdateOrientation() override; @@ -901,6 +902,8 @@ private: */ bool isKeyboardDidShowRegistered_ = false; bool isKeyboardDidHideRegistered_ = false; + std::mutex keyboardOccupiedAreaMutex_; + sptr keyboardOccupiedAreaInfo_ = nullptr; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/src/root_scene.cpp b/wm/src/root_scene.cpp index 721275900c..a39ebda3e7 100644 --- a/wm/src/root_scene.cpp +++ b/wm/src/root_scene.cpp @@ -358,13 +358,14 @@ WMError RootScene::UnregisterAvoidAreaChangeListener(const sptr& avoidArea, AvoidAreaType type) +void RootScene::NotifyAvoidAreaChangeForRoot(const sptr& avoidArea, AvoidAreaType type, + const sptr& info) { TLOGI(WmsLogTag::WMS_IMMS, "type %{public}d area %{public}s.", type, avoidArea->ToString().c_str()); std::lock_guard lock(mutex_); for (auto& listener : avoidAreaChangeListeners_) { if (listener != nullptr) { - listener->OnAvoidAreaChanged(*avoidArea, type); + listener->OnAvoidAreaChanged(*avoidArea, type, info); } } } diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 00176141d1..20553a35ad 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -662,7 +662,8 @@ WMError WindowExtensionSessionImpl::SetUIContentInner(const std::string& content } WSError WindowExtensionSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reason, - const SceneAnimationConfig& config, const std::map& avoidAreas) + const SceneAnimationConfig& config, const std::map& avoidAreas, + const sptr& occupiedAreaInfo) { auto wmReason = static_cast(reason); Rect wmRect = {rect.posX_, rect.posY_, rect.width_, rect.height_}; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index df193b994c..6cb6df2b1d 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -823,7 +823,8 @@ WSError WindowSessionImpl::SetActive(bool active) /** @note @window.layout */ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reason, - const SceneAnimationConfig& config, const std::map& avoidAreas) + const SceneAnimationConfig& config, const std::map& avoidAreas, + const sptr& occupiedAreaInfo) { // delete after replace ws_common.h with wm_common.h auto wmReason = static_cast(reason); @@ -834,6 +835,10 @@ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reaso } property_->SetWindowRect(wmRect); property_->SetRequestRect(wmRect); + { + std::lock_guard occupiedAreaLock(keyboardOccupiedAreaMutex_); + keyboardOccupiedAreaInfo_ = occupiedAreaInfo; + } TLOGI(WmsLogTag::WMS_LAYOUT, "%{public}s, preRect:%{public}s, reason:%{public}u, hasRSTransaction:%{public}d" ", duration:%{public}d, [name:%{public}s, id:%{public}d], clientDisplayId: %{public}" PRIu64, @@ -1484,7 +1489,12 @@ void WindowSessionImpl::UpdateViewportConfig(const Rect& rect, WindowSizeChangeR HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "WindowSessionimpl::UpdateViewportConfig id:%d [%d, %d, %u, %u] reason:%u orientation:%d", GetPersistentId(), rect.posX_, rect.posY_, rect.width_, rect.height_, reason, orientation); - uiContent->UpdateViewportConfig(config, reason, rsTransaction, lastAvoidAreaMap_); + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- updateviewportconfig, id: %{public}d, occupiedAreaRect: %{public}s" + ", textFieldPositionY_: %{public}f, textFieldHeight_: %{public}f", + GetPersistentId(), keyboardOccupiedAreaInfo_->rect_.ToString().c_str(), + keyboardOccupiedAreaInfo_->textFieldPositionY_, keyboardOccupiedAreaInfo_->textFieldHeight_); + uiContent->UpdateViewportConfig(config, reason, rsTransaction, lastAvoidAreaMap_, keyboardOccupiedAreaInfo_); + // uiContent->UpdateViewportConfig(config, reason, rsTransaction, lastAvoidAreaMap_); if (WindowHelper::IsUIExtensionWindow(GetType())) { TLOGD(WmsLogTag::WMS_LAYOUT, "Id: %{public}d, reason: %{public}d, windowRect: %{public}s, " -- Gitee From 49df815105a0c8367f364a52cbfa3ee4e78910be Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Sun, 27 Apr 2025 19:24:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=94=AE=E7=9B=98=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BA=E5=8F=98=E5=8C=96=E9=80=9A=E7=9F=A5=E9=80=9A=E8=B7=AF?= =?UTF-8?q?=E5=90=88=E4=B8=80--=E5=88=A0=E9=99=A4=E9=94=AE=E7=9B=98?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=8F=98=E5=8C=96=E9=80=9A=E7=9F=A5=E9=80=9A?= =?UTF-8?q?=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- .../session/host/include/keyboard_session.h | 3 +++ .../session/host/include/scb_system_session.h | 2 -- .../session/host/src/scb_system_session.cpp | 19 ------------------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index 4100d86b28..a1963fb40d 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -113,6 +113,9 @@ private: bool IsNeedRaiseSubWindow(const sptr& callingSession, const WSRect& callingSessionRect); void PostKeyboardAnimationSyncTimeoutTask(); bool GetKeyboardSyncTransactionStatus() override; + void NotifyOccupiedArea(const sptr& occupiedAreaInfo, + const bool& isKeyboardSyncTransactionOpen = false, + std::shared_ptr rsTransaction = nullptr) override; bool CalculateRectAndAvoidArea(sptr& occupiedAreaInfo, const bool& needCheckVisible) override; bool CalculateRectAndAvoidAreaInner(const sptr& callingSession, const WSRect& rect, diff --git a/window_scene/session/host/include/scb_system_session.h b/window_scene/session/host/include/scb_system_session.h index 37483fb0ed..338ad461ac 100644 --- a/window_scene/session/host/include/scb_system_session.h +++ b/window_scene/session/host/include/scb_system_session.h @@ -36,7 +36,6 @@ public: WSError SetSystemSceneBlockingFocus(bool blocking) override; void BindKeyboardSession(sptr session) override; sptr GetKeyboardSession() const override; - void SetKeyboardPanelRectUpdateCallback(const KeyboardPanelRectUpdateCallback& func); void SetSkipSelfWhenShowOnVirtualScreen(bool isSkip) override; void SetSkipEventOnCastPlus(bool isSkip) override; void SyncScenePanelGlobalPosition(bool needSync) override; @@ -54,7 +53,6 @@ protected: void NotifyClientToUpdateAvoidArea() override; private: - KeyboardPanelRectUpdateCallback keyboardPanelRectUpdateCallback_; bool isNeedSyncGlobalPos_ = true; // can only accessed in main thread /* diff --git a/window_scene/session/host/src/scb_system_session.cpp b/window_scene/session/host/src/scb_system_session.cpp index 76ebf2ee4a..880a51918e 100644 --- a/window_scene/session/host/src/scb_system_session.cpp +++ b/window_scene/session/host/src/scb_system_session.cpp @@ -74,20 +74,11 @@ WSError SCBSystemSession::NotifyClientToUpdateRect(const std::string& updateReas } session->specificCallback_->onClearDisplayStatusBarTemporarilyFlags_(); } - if (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYBOARD_PANEL && - session->keyboardPanelRectUpdateCallback_ && session->isKeyboardPanelEnabled_) { - session->keyboardPanelRectUpdateCallback_(); - } return ret; }, "NotifyClientToUpdateRect"); return WSError::WS_OK; } -void SCBSystemSession::SetKeyboardPanelRectUpdateCallback(const KeyboardPanelRectUpdateCallback& func) -{ - keyboardPanelRectUpdateCallback_ = func; -} - void SCBSystemSession::BindKeyboardSession(sptr session) { if (session == nullptr) { @@ -95,12 +86,6 @@ void SCBSystemSession::BindKeyboardSession(sptr session) return; } keyboardSession_ = session; - KeyboardPanelRectUpdateCallback onKeyboardPanelRectUpdate = [this]() { - if (this->keyboardSession_ != nullptr) { - this->keyboardSession_->OnKeyboardPanelUpdated(); - } - }; - SetKeyboardPanelRectUpdateCallback(onKeyboardPanelRectUpdate); TLOGI(WmsLogTag::WMS_KEYBOARD, "Success, id: %{public}d", keyboardSession_->GetPersistentId()); } @@ -236,10 +221,6 @@ bool SCBSystemSession::IsVisibleForeground() const void SCBSystemSession::NotifyClientToUpdateAvoidArea() { SceneSession::NotifyClientToUpdateAvoidArea(); - if (GetWindowType() == WindowType::WINDOW_TYPE_KEYBOARD_PANEL && - keyboardPanelRectUpdateCallback_ && isKeyboardPanelEnabled_) { - keyboardPanelRectUpdateCallback_(); - } } void SCBSystemSession::SyncScenePanelGlobalPosition(bool needSync) -- Gitee From e1abbf3cf4af5ec284d2af55dd679e9a68052723 Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Sun, 27 Apr 2025 22:19:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=94=AE=E7=9B=98=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BA=E5=8F=98=E5=8C=96=E9=80=9A=E7=9F=A5=E9=80=9A=E8=B7=AF?= =?UTF-8?q?=E5=90=88=E4=B8=80--=E5=AE=BF=E4=B8=BB=E5=8F=98=E5=8C=96&PC?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E6=80=81=E5=88=87=E5=9B=BA=E5=AE=9A=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- .../js_scene_session_manager.cpp | 2 +- .../session/host/include/scb_system_session.h | 1 - .../session/host/include/scene_session.h | 2 - .../session/host/src/keyboard_session.cpp | 57 +++++++++++++++++-- .../session/host/src/scene_session.cpp | 6 -- .../src/scene_session_manager.cpp | 32 +---------- 6 files changed, 54 insertions(+), 46 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 7112ea003b..3be378245f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -685,7 +685,7 @@ void JsSceneSessionManager::RegisterRootSceneCallbacksOnSSManager() }); SceneSessionManager::GetInstance().RegisterNotifyRootSceneAvoidAreaChangeFunc( [](const sptr& avoidArea, AvoidAreaType type, const sptr& info = nullptr) { - RootScene::staticRootScene_->NotifyAvoidAreaChangeForRoot(avoidArea, type, info); + RootScene::staticRootScene_->NotifyAvoidAreaChangeForRoot(avoidArea, type, info); }); SceneSessionManager::GetInstance().RegisterNotifyRootSceneOccupiedAreaChangeFunc( [](const sptr& info) { diff --git a/window_scene/session/host/include/scb_system_session.h b/window_scene/session/host/include/scb_system_session.h index 338ad461ac..2f67851fd6 100644 --- a/window_scene/session/host/include/scb_system_session.h +++ b/window_scene/session/host/include/scb_system_session.h @@ -19,7 +19,6 @@ #include "session/host/include/scene_session.h" namespace OHOS::Rosen { -using KeyboardPanelRectUpdateCallback = std::function; class SCBSystemSession : public SceneSession { public: SCBSystemSession(const SessionInfo& info, const sptr& specificCallback); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index b31c07da41..6f1d1e5f9a 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -51,7 +51,6 @@ using GetSceneSessionVectorByTypeAndDisplayIdCallback = std::function; using GetSceneSessionVectorByTypeCallback = std::function>(WindowType type)>; using UpdateAvoidAreaCallback = std::function; -using UpdateOccupiedAreaIfNeedCallback = std::function; using NotifyWindowInfoUpdateCallback = std::function; using NotifyWindowPidChangeCallback = std::function; using NotifySessionTouchOutsideCallback = std::function; @@ -150,7 +149,6 @@ public: GetSceneSessionVectorByTypeCallback onGetSceneSessionVectorByType_; UpdateAvoidAreaCallback onUpdateAvoidArea_; GetStatusBarDefaultVisibilityByDisplayIdFunc onGetStatusBarDefaultVisibilityByDisplayId_; - UpdateOccupiedAreaIfNeedCallback onUpdateOccupiedAreaIfNeed_; NotifyWindowInfoUpdateCallback onWindowInfoUpdate_; NotifyWindowPidChangeCallback onWindowInputPidChangeCallback_; NotifySessionTouchOutsideCallback onSessionTouchOutside_; diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 27afbbf6d4..cd23e5b220 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -311,7 +311,19 @@ WSError KeyboardSession::AdjustKeyboardLayout(const KeyboardLayoutParams& params } // avoidHeight is set, notify avoidArea in case ui params don't flush if (params.landscapeAvoidHeight_ >= 0 && params.portraitAvoidHeight_ >= 0) { - session->NotifyClientToUpdateAvoidArea(); + sptr occupiedAreaInfo = nullptr; + bool occupiedAreaChanged = session->CalculateRectAndAvoidArea(occupiedAreaInfo, true); + if (occupiedAreaInfo == nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- AdjustKeyboardLayout, occupiedAreaInfo is nullptr," + " occupiedAreaChanged = %{public}d", occupiedAreaChanged); + } else { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- AdjustKeyboardLayout, occupiedAreaInfo=%{public}s," + " occupiedAreaChanged = %{public}d", occupiedAreaInfo->rect_.ToString().c_str(), + occupiedAreaChanged); + } + if (occupiedAreaChanged) { + session->NotifyOccupiedArea(occupiedAreaInfo); + } } // notify keyboard layout param if (session->adjustKeyboardLayoutFunc_) { @@ -470,7 +482,9 @@ bool KeyboardSession::CalculateRectAndAvoidArea(sptr& oc return false; } if (!IsSessionForeground() || (needCheckVisible && !IsVisibleForeground())) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is not foreground"); + TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is not foreground, sessionState: %{public}d" + ", needCheckVisible: {public}d, isVisible: {public}d", + GetSessionState(), needCheckVisible, IsVisibleForeground()); return false; } sptr callingSession = GetSceneSession(GetCallingSessionId()); @@ -663,7 +677,20 @@ void KeyboardSession::RestoreCallingSession(uint32_t callingId, const std::share } const WSRect& emptyRect = { 0, 0, 0, 0 }; int32_t oriPosYBeforeRaisedByKeyboard = callingSession->GetOriPosYBeforeRaisedByKeyboard(); - NotifyOccupiedAreaChangeInfo(callingSession, emptyRect, emptyRect, rsTransaction); + + sptr occupiedAreaInfo = nullptr; + bool occupiedAreaChanged = CalculateRectAndAvoidAreaInner(callingSession, emptyRect, emptyRect, occupiedAreaInfo); + if (occupiedAreaInfo == nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- RestoreCallingSession, occupiedAreaInfo is nullptr," + " occupiedAreaChanged = %{public}d", occupiedAreaChanged); + } else { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- RestoreCallingSession, occupiedAreaInfo=%{public}s," + " occupiedAreaChanged = %{public}d", occupiedAreaInfo->rect_.ToString().c_str(), + occupiedAreaChanged); + } + if (occupiedAreaChanged) { + NotifyOccupiedArea(occupiedAreaInfo, true, rsTransaction); + } if (oriPosYBeforeRaisedByKeyboard != 0 && callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) { WSRect callingSessionRestoringRect = callingSession->GetSessionRect(); @@ -732,7 +759,19 @@ void KeyboardSession::UseFocusIdIfCallingSessionIdInvalid() void KeyboardSession::EnableCallingSessionAvoidArea() { - RaiseCallingSession(GetCallingSessionId(), GetPanelRect(), true, nullptr); + sptr occupiedAreaInfo = nullptr; + bool occupiedAreaChanged = CalculateRectAndAvoidArea(occupiedAreaInfo, true); + if (occupiedAreaInfo == nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- EnableCallingSessionAvoidArea, occupiedAreaInfo is nullptr," + " occupiedAreaChanged = %{public}d", occupiedAreaChanged); + } else { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- EnableCallingSessionAvoidArea, occupiedAreaInfo=%{public}s," + " occupiedAreaChanged = %{public}d", occupiedAreaInfo->rect_.ToString().c_str(), + occupiedAreaChanged); + } + if (occupiedAreaChanged) { + NotifyOccupiedArea(occupiedAreaInfo); + } } void KeyboardSession::NotifySystemKeyboardAvoidChange(SystemKeyboardAvoidChangeReason reason) @@ -804,7 +843,15 @@ void KeyboardSession::CloseKeyboardSyncTransaction(uint32_t callingId, const WSR sptr occupiedAreaInfo = nullptr; bool occupiedAreaChanged = session->CalculateRectAndAvoidArea( - occupiedAreaInfo, session->isKeyboardSyncTransactionOpen_); + occupiedAreaInfo, !(session->isKeyboardSyncTransactionOpen_)); + if (occupiedAreaInfo == nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- close keyboard sync, occupiedAreaInfo is nullptr," + " occupiedAreaChanged = %{public}d", occupiedAreaChanged); + } else { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- close keyboard sync, occupiedAreaInfo=%{public}s," + " occupiedAreaChanged = %{public}d", occupiedAreaInfo->rect_.ToString().c_str(), + occupiedAreaChanged); + } if (occupiedAreaChanged) { session->NotifyOccupiedArea( occupiedAreaInfo, session->isKeyboardSyncTransactionOpen_, rsTransaction); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index aa29781344..9cf45894d8 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1404,9 +1404,6 @@ WSError SceneSession::NotifyClientToUpdateRect(const std::string& updateReason, if (ret != WSError::WS_OK) { return ret; } - if (session->specificCallback_ && session->specificCallback_->onUpdateOccupiedAreaIfNeed_) { - session->specificCallback_->onUpdateOccupiedAreaIfNeed_(session->GetPersistentId()); - } return ret; }, __func__); return WSError::WS_OK; @@ -7108,9 +7105,6 @@ void SceneSession::NotifyClientToUpdateAvoidArea() if ((IsImmersiveType() || !IsDirtyWindow()) && specificCallback_->onUpdateAvoidArea_) { specificCallback_->onUpdateAvoidArea_(GetPersistentId()); } - if (specificCallback_->onUpdateOccupiedAreaIfNeed_) { - specificCallback_->onUpdateOccupiedAreaIfNeed_(GetPersistentId()); - } } bool SceneSession::IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3f2b26c7ef..78f4afe0b0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1680,9 +1680,6 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onGetStatusBarDefaultVisibilityByDisplayId_ = [this](DisplayId displayId) { return this->GetStatusBarDefaultVisibilityByDisplayId(displayId); }; - specificCb->onUpdateOccupiedAreaIfNeed_ = [this](int32_t persistentId) { - this->UpdateOccupiedAreaIfNeed(persistentId); - }; specificCb->onWindowInfoUpdate_ = [this](int32_t persistentId, WindowUpdateType type) { this->NotifyWindowInfoChange(persistentId, type); }; @@ -10437,33 +10434,6 @@ void SceneSessionManager::UpdateGestureBackEnabled(int32_t persistentId) taskScheduler_->PostAsyncTask(task, "UpdateGestureBackEnabled: PID: " + std::to_string(persistentId)); } -void SceneSessionManager::UpdateOccupiedAreaIfNeed(int32_t persistentId) -{ - auto task = [this, persistentId]() { - sptr keyboardSession = nullptr; - std::shared_lock lock(sceneSessionMapMutex_); - for (auto item = sceneSessionMap_.rbegin(); item != sceneSessionMap_.rend(); ++item) { - auto sceneSession = item->second; - if (sceneSession != nullptr && - sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { - keyboardSession = sceneSession; - break; - } - } - if (keyboardSession == nullptr) { - TLOGNE(WmsLogTag::WMS_KEYBOARD, "keyboardSession is nullptr."); - return; - } - if (keyboardSession->GetCallingSessionId() != static_cast(persistentId)) { - return; - } - - keyboardSession->OnCallingSessionUpdated(); - return; - }; - taskScheduler_->PostAsyncTask(task, "UpdateOccupiedAreaIfNeed:PID:" + std::to_string(persistentId)); -} - WSError SceneSessionManager::NotifyStatusBarShowStatus(int32_t persistentId, bool isVisible) { TLOGD(WmsLogTag::WMS_IMMS, "win %{public}u isVisible %{public}u", @@ -11546,7 +11516,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapGetPersistentId() == sceneSession->GetPersistentId()) { sptr occupiedAreaInfo = nullptr; bool occupiedAreaChanged = keyboardSession->CalculateRectAndAvoidArea( - occupiedAreaInfo, keyboardSession->GetKeyboardSyncTransactionStatus()); + occupiedAreaInfo, !(keyboardSession->GetKeyboardSyncTransactionStatus())); if (occupiedAreaInfo == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- flush ui params, occupiedAreaInfo is nullptr," " occupiedAreaChanged = %{public}d", occupiedAreaChanged); -- Gitee From 050d8f0a6dd396128549ad74157861bff7e0cfc3 Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Sun, 4 May 2025 14:09:05 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81=EF=BC=8C=E5=88=A0=E9=99=A4=E5=8E=9F=E6=9C=89?= =?UTF-8?q?=E9=80=9A=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- dm/test/unittest/screen_manager_test.cpp | 2 +- .../include/display_manager_interface_code.h | 1 + .../test/unittest/display_dumper_test.cpp | 16 + .../unittest/display_manager_service_test.cpp | 123 +++ .../unittest/display_manager_stub_test.cpp | 20 + .../display_power_controller_test.cpp | 31 + interfaces/innerkits/dm/dm_common.h | 9 + interfaces/innerkits/wm/window.h | 10 +- interfaces/innerkits/wm/wm_common.h | 6 +- interfaces/kits/napi/window_runtime/BUILD.gn | 1 + .../window_manager_napi/js_window_manager.cpp | 5 + .../window_runtime/window_napi/js_window.cpp | 3 +- previewer/include/window.h | 1 + .../extension/extension_connection_test.cpp | 86 +- .../modal_system_ui_extension_test.cpp | 26 +- .../wms/window_animation_transition_test.cpp | 35 +- .../window_app_floating_window_scb_test.cpp | 20 +- .../wms/window_app_floating_window_test.cpp | 20 +- test/systemtest/wms/window_callback_test.cpp | 16 +- test/systemtest/wms/window_decor_test.cpp | 4 +- .../wms/window_dialogwindow_test.cpp | 31 +- .../wms/window_display_zoom_test.cpp | 28 +- test/systemtest/wms/window_drag_test.cpp | 43 +- test/systemtest/wms/window_effect_test.cpp | 28 +- test/systemtest/wms/window_focus_test.cpp | 74 +- test/systemtest/wms/window_gamut_test.cpp | 35 +- ...window_gesture_navigation_enabled_test.cpp | 25 +- test/systemtest/wms/window_immersive_test.cpp | 49 +- .../wms/window_input_method_test.cpp | 17 +- test/systemtest/wms/window_input_test.cpp | 12 +- .../wms/window_layout_integration_test.cpp | 66 +- test/systemtest/wms/window_layout_test.cpp | 45 +- .../wms/window_mode_support_info_test.cpp | 50 +- test/systemtest/wms/window_move_drag_test.cpp | 63 +- .../wms/window_multi_ability_test.cpp | 20 +- .../window_nointeraction_listener_test.cpp | 62 +- .../wms/window_occupied_area_change_test.cpp | 55 +- test/systemtest/wms/window_pc_test.cpp | 6 +- .../wms/window_raisetoapptop_test.cpp | 61 +- test/systemtest/wms/window_recover_test.cpp | 18 +- test/systemtest/wms/window_rotation_test.cpp | 55 +- .../wms/window_specialwindow_test.cpp | 8 +- .../wms/window_split_immersive_test.cpp | 10 +- test/systemtest/wms/window_split_test.cpp | 20 +- .../wms/window_status_change_test.cpp | 10 +- test/systemtest/wms/window_subwindow_test.cpp | 44 +- .../wms/window_system_toast_test.cpp | 22 +- .../wms/window_systemsubwindow_test.cpp | 55 +- test/systemtest/wms/window_test_utils.cpp | 159 ++-- test/systemtest/wms/window_test_utils.h | 10 +- .../wms/window_touch_outside_test.cpp | 42 +- .../wms/window_visibility_info_test.cpp | 42 +- .../systemtest/wms/window_water_mark_test.cpp | 17 +- utils/include/perform_reporter.h | 2 + utils/include/window_property.h | 5 + utils/include/wm_common_inner.h | 1 + utils/src/perform_reporter.cpp | 4 +- utils/src/window_property.cpp | 21 +- utils/test/unittest/cutout_info_test.cpp | 30 +- utils/test/unittest/display_info_test.cpp | 18 +- utils/test/unittest/dms_reporter_test.cpp | 18 +- utils/test/unittest/perform_reporter_test.cpp | 63 +- utils/test/unittest/permission_test.cpp | 28 +- .../test/unittest/persistent_storage_test.cpp | 18 +- .../test/unittest/screen_group_info_test.cpp | 20 +- utils/test/unittest/screen_info_test.cpp | 20 +- utils/test/unittest/string_util_test.cpp | 18 +- utils/test/unittest/surface_draw_test.cpp | 28 +- utils/test/unittest/surface_reader_test.cpp | 16 +- utils/test/unittest/utils_all_test.cpp | 30 +- .../unittest/window_frame_trace_impl_test.cpp | 10 +- utils/test/unittest/window_helper_test.cpp | 100 ++- utils/test/unittest/window_property_test.cpp | 34 +- .../unittest/window_transition_info_test.cpp | 116 ++- utils/test/unittest/wm_math_test.cpp | 18 +- .../unittest/wm_occlusion_region_test.cpp | 96 +- .../common/include/window_session_property.h | 5 + .../common/src/window_session_property.cpp | 28 +- window_scene/interfaces/include/ws_common.h | 6 +- .../interfaces/include/ws_common_inner.h | 3 +- .../js_scene_session.cpp | 116 ++- .../scene_session_manager/js_scene_session.h | 6 + .../js_scene_session_manager.cpp | 8 +- .../scene_session_manager/js_scene_utils.cpp | 2 +- .../js_screen_session.cpp | 35 + .../js_screen_session.h | 1 + .../js_screen_session_manager.cpp | 17 + .../js_screen_session_manager.h | 2 + .../js_screen_utils.cpp | 18 + .../screen_session_manager/js_screen_utils.h | 1 + .../super_fold_sensor_manager.h | 2 + .../include/multi_screen_change_utils.h | 1 + .../include/screen_session_manager.h | 22 +- .../zidl/screen_session_manager_interface.h | 1 + .../zidl/screen_session_manager_proxy.h | 1 + .../secondary_display_fold_policy.cpp | 5 +- .../super_fold_sensor_manager.cpp | 16 +- .../src/multi_screen_change_utils.cpp | 16 + .../src/screen_session_manager.cpp | 185 +++- .../src/zidl/screen_session_manager_proxy.cpp | 21 + .../src/zidl/screen_session_manager_stub.cpp | 4 + .../include/screen_session_manager_client.h | 2 + .../screen_session_manager_client_interface.h | 2 + .../screen_session_manager_client_proxy.h | 1 + .../zidl/screen_session_manager_client_stub.h | 1 + .../src/screen_session_manager_client.cpp | 28 +- .../screen_session_manager_client_proxy.cpp | 26 + .../screen_session_manager_client_stub.cpp | 12 + .../host/include/ability_info_manager.h | 5 + .../session/host/include/keyboard_session.h | 12 +- .../host/include/pc_fold_screen_manager.h | 2 + .../session/host/include/scene_session.h | 23 +- window_scene/session/host/include/session.h | 3 + .../session/host/src/ability_info_manager.cpp | 17 + .../session/host/src/keyboard_session.cpp | 204 ++--- .../host/src/pc_fold_screen_controller.cpp | 2 +- .../host/src/pc_fold_screen_manager.cpp | 12 + .../session/host/src/scene_session.cpp | 182 +++- window_scene/session/host/src/session.cpp | 11 + .../session/screen/include/screen_session.h | 7 +- .../session/screen/src/screen_session.cpp | 50 +- .../include/scene_session_manager.h | 8 +- .../src/extension_session_manager.cpp | 2 +- .../src/scene_session_manager.cpp | 150 +++- .../multi_screen_manager_test.cpp | 36 +- ...multi_screen_power_change_manager_test.cpp | 175 +++- .../dms_unittest/screen_scene_config_test.cpp | 97 +- ...creen_session_manager_client_stub_test.cpp | 40 + .../screen_session_manager_lite_test.cpp | 2 +- .../screen_session_manager_test.cpp | 285 +++++- .../test/dms_unittest/screen_session_test.cpp | 423 ++++++++- window_scene/test/dms_unittest/test_client.h | 1 + window_scene/test/mock/mock_ibundle_mgr.h | 3 + window_scene/test/mock/mock_session_stage.h | 7 +- window_scene/test/unittest/BUILD.gn | 18 + .../unittest/ability_info_manager_test.cpp | 91 ++ .../scene_session_animation_test.cpp | 188 ++-- .../session_proxy_animation_test.cpp | 2 +- ...window_session_property_animation_test.cpp | 8 +- .../test/unittest/dfx_hisysevent_test.cpp | 18 +- .../test/unittest/distributed_client_test.cpp | 15 +- .../intention_event_manager_test.cpp | 50 +- .../scene_input_manager_test.cpp | 34 +- .../scene_session_dirty_manager_test.cpp | 44 +- .../scene_session_dirty_manager_test2.cpp | 44 +- .../unittest/hidumper_controller_test.cpp | 16 +- .../unittest/keyboard_session_layout_test.cpp | 24 +- .../test/unittest/keyboard_session_test.cpp | 221 ++--- .../test/unittest/keyboard_session_test2.cpp | 57 +- .../test/unittest/keyboard_session_test3.cpp | 91 +- .../layout/keyboard_session_layout_test.cpp | 24 +- .../layout/scb_system_session_layout_test.cpp | 16 +- .../layout/scene_session_layout_test.cpp | 53 +- .../scene_session_manager_layout_test.cpp | 29 +- .../unittest/layout/session_layout_test.cpp | 39 +- .../session_stage_proxy_layout_test.cpp | 2 +- .../layout/session_stub_layout_test.cpp | 10 +- .../unittest/main_session_lifecycle_test.cpp | 19 +- .../test/unittest/main_session_test.cpp | 88 +- .../mock_session_manager_service_test.cpp | 26 +- .../unittest/move_drag_controller_test.cpp | 59 +- .../unittest/multi_instance_manager_test.cpp | 48 +- .../multi_user/session_manager_lite_test.cpp | 1 + .../multi_user/session_manager_test.cpp | 2 +- .../pc_fold_screen_controller_test.cpp | 219 +++-- .../test/unittest/root_scene_session_test.cpp | 28 +- .../scene_session_manager_rotation_test.cpp | 34 +- .../rotation/scene_session_rotation_test.cpp | 22 +- .../session_stage_proxy_rotation_test.cpp | 24 +- .../session_stage_stub_rotation_test.cpp | 22 +- .../window_session_property_rotation_test.cpp | 8 +- .../scb_system_session_layout_test.cpp | 16 +- .../test/unittest/scb_system_session_test.cpp | 17 +- .../unittest/scene_board_judgement_test.cpp | 4 +- .../test/unittest/scene_persistence_test.cpp | 30 +- .../scene_persistent_storage_test.cpp | 22 +- .../unittest/scene_session_converter_test.cpp | 18 +- .../unittest/scene_session_layout_test.cpp | 53 +- .../unittest/scene_session_lifecycle_test.cpp | 113 ++- .../scene_session_manager_layout_test.cpp | 29 +- .../scene_session_manager_lifecycle_test.cpp | 91 +- .../scene_session_manager_lifecycle_test2.cpp | 23 +- .../scene_session_manager_lite_stub_test.cpp | 301 +++---- .../scene_session_manager_lite_test.cpp | 22 +- ...e_session_manager_proxy_lifecycle_test.cpp | 28 +- .../scene_session_manager_proxy_test.cpp | 97 +- ...ne_session_manager_stub_lifecycle_test.cpp | 33 +- .../scene_session_manager_stub_test.cpp | 43 +- .../scene_session_manager_supplement_test.cpp | 85 +- .../unittest/scene_session_manager_test.cpp | 219 +++-- .../unittest/scene_session_manager_test10.cpp | 193 ++-- .../unittest/scene_session_manager_test11.cpp | 114 +-- .../unittest/scene_session_manager_test12.cpp | 212 ++--- .../unittest/scene_session_manager_test2.cpp | 830 +++++++++--------- .../unittest/scene_session_manager_test3.cpp | 259 +++--- .../unittest/scene_session_manager_test4.cpp | 58 +- .../unittest/scene_session_manager_test5.cpp | 110 ++- .../unittest/scene_session_manager_test6.cpp | 189 ++-- .../unittest/scene_session_manager_test7.cpp | 28 +- .../unittest/scene_session_manager_test8.cpp | 103 +-- .../unittest/scene_session_manager_test9.cpp | 38 +- .../test/unittest/scene_session_test.cpp | 130 ++- .../test/unittest/scene_session_test2.cpp | 74 +- .../test/unittest/scene_session_test3.cpp | 105 +-- .../test/unittest/scene_session_test5.cpp | 314 +++++-- .../test/unittest/scene_session_test6.cpp | 104 ++- .../scene_system_ability_listener_test.cpp | 28 +- .../test/unittest/session_layout_test.cpp | 39 +- .../test/unittest/session_lifecycle_test.cpp | 45 +- .../session_listener_controller_test.cpp | 21 +- .../session_manager_agent_controller_test.cpp | 99 +-- .../unittest/session_manager_lite_test.cpp | 15 +- .../unittest/session_manager_lite_ut_test.cpp | 15 +- ...ion_manager_service_recover_proxy_test.cpp | 8 +- .../test/unittest/session_manager_test.cpp | 22 +- .../test/unittest/session_manager_ut_test.cpp | 22 +- .../test/unittest/session_permission_test.cpp | 26 +- .../unittest/session_proxy_immersive_test.cpp | 54 +- .../unittest/session_proxy_lifecycle_test.cpp | 6 +- .../test/unittest/session_proxy_mock_test.cpp | 29 +- .../unittest/session_proxy_property_test.cpp | 40 +- .../test/unittest/session_proxy_test.cpp | 12 +- .../unittest/session_specific_window_test.cpp | 15 +- .../session_stage_proxy_layout_test.cpp | 2 +- .../session_stage_proxy_lifecycle_test.cpp | 23 +- .../unittest/session_stage_proxy_test.cpp | 25 +- .../session_stage_stub_lifecycle_test.cpp | 23 +- .../test/unittest/session_stage_stub_test.cpp | 29 +- .../unittest/session_stub_immersive_test.cpp | 30 +- .../unittest/session_stub_layout_test.cpp | 10 +- .../unittest/session_stub_lifecycle_test.cpp | 16 +- .../test/unittest/session_stub_mock_test.cpp | 12 +- .../unittest/session_stub_property_test.cpp | 15 +- .../test/unittest/session_stub_test.cpp | 52 +- window_scene/test/unittest/session_test.cpp | 117 ++- window_scene/test/unittest/session_test2.cpp | 50 +- window_scene/test/unittest/session_test3.cpp | 56 +- window_scene/test/unittest/session_test4.cpp | 89 +- .../unittest/ssmgr_specific_window_test.cpp | 170 ++-- .../unittest/sub_session_lifecycle_test.cpp | 23 +- .../test/unittest/sub_session_test.cpp | 27 +- .../system_session_lifecycle_test.cpp | 25 +- .../test/unittest/system_session_test.cpp | 55 +- .../test/unittest/task_scheduler_test.cpp | 5 +- .../extension_data_handler_mock.h | 12 +- .../extension_data_handler_test.cpp | 22 +- .../extension_session_manager_test.cpp | 38 +- .../ui_extension/extension_session_test.cpp | 28 +- .../test/unittest/window_event_channel_base.h | 48 +- .../window_event_channel_proxy_mock_test.cpp | 48 +- .../window_event_channel_proxy_test.cpp | 30 +- .../window_event_channel_stub_mock_test.cpp | 26 +- .../window_event_channel_stub_test.cpp | 26 +- .../unittest/window_event_channel_test.cpp | 20 +- .../window_focus_scene_session_test.cpp | 20 +- .../test/unittest/window_manager_lru_test.cpp | 21 +- .../window_manager_service_dump_test.cpp | 41 +- .../window_pattern_snapshot_test.cpp | 37 +- ...indow_pattern_starting_window_rdb_test.cpp | 12 +- .../window_pattern_starting_window_test.cpp | 24 +- .../test/unittest/window_recover/BUILD.gn | 3 +- .../window_recover_session_test.cpp | 78 +- .../unittest/window_scene_config_test.cpp | 50 +- .../unittest/window_session_property_test.cpp | 35 +- .../test/unittest/ws_ffrt_helper_test.cpp | 18 +- wm/include/window_scene_session_impl.h | 2 + wm/include/window_session_impl.h | 3 + wm/src/window_adapter.cpp | 1 - wm/src/window_scene_session_impl.cpp | 42 + wm/src/window_session_impl.cpp | 55 +- .../window_scene_session_impl_test.cpp | 42 + wm/test/unittest/window_scene_test.cpp | 36 + .../unittest/window_session_impl_test5.cpp | 29 + wmserver/src/window_controller.cpp | 4 + 274 files changed, 7096 insertions(+), 5688 deletions(-) create mode 100644 window_scene/test/unittest/ability_info_manager_test.cpp diff --git a/dm/test/unittest/screen_manager_test.cpp b/dm/test/unittest/screen_manager_test.cpp index 024ebbb31e..901eb42da3 100644 --- a/dm/test/unittest/screen_manager_test.cpp +++ b/dm/test/unittest/screen_manager_test.cpp @@ -807,7 +807,7 @@ HWTEST_F(ScreenManagerTest, MakeMirrorForRecord03, TestSize.Level1) DMError result = ScreenManager::GetInstance().MakeMirrorForRecord(mainScreenId, miirrorScreenId, screenGroupId); - EXPECT_EQ(result, DMError::DM_OK); + EXPECT_EQ(result, DMError::DM_ERROR_NULLPTR); } } } // namespace Rosen diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index 7559762f08..dfad9fe605 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -166,6 +166,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_SET_DEFAULT_MODE_WHEN_SWITCH_USER, TRANS_ID_NOTIFY_EXTEND_SCREEN_CREATE_FINISH, TRANS_ID_NOTIFY_EXTEND_SCREEN_DESTROY_FINISH, + TRANS_ID_NOTIFY_SCREEN_MASK_APPEAR, }; } #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H diff --git a/dmserver/test/unittest/display_dumper_test.cpp b/dmserver/test/unittest/display_dumper_test.cpp index 25a046d9d1..e36932eef2 100644 --- a/dmserver/test/unittest/display_dumper_test.cpp +++ b/dmserver/test/unittest/display_dumper_test.cpp @@ -317,6 +317,22 @@ HWTEST_F(DisplayDumperTest, IsValidDigitString03, TestSize.Level1) ASSERT_EQ(ret, false); } +/** + * @tc.name: IsValidDigitString04 + * @tc.desc: IsValidDigitString empty + * @tc.type: FUNC + */ +HWTEST_F(DisplayDumperTest, IsValidDigitString04, TestSize.Level1) +{ + sptr displayDumper; + displayDumper = new DisplayDumper(DisplayManagerService::GetInstance().abstractDisplayController_, + DisplayManagerService::GetInstance().abstractScreenController_, + DisplayManagerService::GetInstance().mutex_); + std::string idStr = "1909"; + bool ret = displayDumper->IsValidDigitString(idStr); + EXPECT_EQ(ret, true); +} + /** * @tc.name: DumpAllScreenInfo01 * @tc.desc: DumpAllScreenInfo diff --git a/dmserver/test/unittest/display_manager_service_test.cpp b/dmserver/test/unittest/display_manager_service_test.cpp index 9de3b81161..7f43d3d32e 100644 --- a/dmserver/test/unittest/display_manager_service_test.cpp +++ b/dmserver/test/unittest/display_manager_service_test.cpp @@ -176,6 +176,50 @@ HWTEST_F(DisplayManagerServiceTest, HasPrivateWindow, TestSize.Level1) ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->HasPrivateWindow(1, hasPrivateWindow)); } +/** + * @tc.name: GetScreenIdByDisplayId + * @tc.desc: DMS get screen id by display id + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetScreenIdByDisplayId, TestSize.Level1) +{ + std::string name = "testDisplay"; + sptr info = new SupportedScreenModes(); + sptr absScreen = new AbstractScreen(dms_->abstractScreenController_, name, 0, 0); + sptr absDisplay = new AbstractDisplay(0, info, absScreen); + dms_->abstractDisplayController_->abstractDisplayMap_.clear(); + dms_->abstractDisplayController_->abstractDisplayMap_ = { + {0, absDisplay} + }; + + absDisplay->screenId_ = 0; + EXPECT_EQ(SCREEN_ID_INVALID, dms_->GetScreenIdByDisplayId(1)); + EXPECT_EQ(0, dms_->GetScreenIdByDisplayId(0)); +} + +/** + * @tc.name: GetScreenInfoById01 + * @tc.desc: DMS get screen info by id + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetScreenInfoById01, TestSize.Level1) +{ + ScreenId screenId = dms_->GetScreenIdByDisplayId(1000); + auto ret = dms_->GetScreenInfoById(screenId); + EXPECT_EQ(ret, nullptr); +} + +/** + * @tc.name: GetScreenBrightness + * @tc.desc: DMS get screen brightness + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetScreenBrightness, TestSize.Level1) +{ + auto ret = dms_->GetScreenBrightness(0); + EXPECT_GT(static_cast(ret), -1); +} + /** * @tc.name: GetDisplayInfo * @tc.desc: DMS get display info @@ -654,6 +698,85 @@ HWTEST_F(DisplayManagerServiceTest, StopExpand, TestSize.Level1) auto ret = dms_->StopExpand(expandScreenIds); ASSERT_EQ(ret, DMError::DM_OK); } + +/** + * @tc.name: GetVisibleAreaDisplayInfoById01 + * @tc.desc: GetVisibleAreaDisplayInfoById + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetVisibleAreaDisplayInfoById01, TestSize.Level1) +{ + DisplayId displayId = DISPLAY_ID_INVALID; + auto ret = dms_->GetVisibleAreaDisplayInfoById(displayId); + EXPECT_EQ(ret, nullptr); +} + +/** + * @tc.name: GetVisibleAreaDisplayInfoById02 + * @tc.desc: GetVisibleAreaDisplayInfoById + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetVisibleAreaDisplayInfoById02, TestSize.Level1) +{ + DisplayId displayId = 2; + std::string name = "testDisplay"; + sptr info = new SupportedScreenModes(); + sptr absScreen = new AbstractScreen(dms_->abstractScreenController_, name, 0, 0); + sptr absDisplay = new AbstractDisplay(0, info, absScreen); + dms_->abstractDisplayController_->abstractDisplayMap_.insert({displayId, absDisplay}); + auto ret = dms_->GetVisibleAreaDisplayInfoById(displayId); + EXPECT_NE(ret, nullptr); +} + +/** + * @tc.name: SetScreenBrightness + * @tc.desc: SetScreenBrightness + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, SetScreenBrightness, TestSize.Level1) +{ + uint64_t screenId = 1; + uint32_t level = 2; + dms_->SetScreenBrightness(screenId, level); + EXPECT_TRUE(dms_->SetScreenBrightness(screenId, level)); +} + +/** + * @tc.name: GetAllDisplayPhysicalResolution01 + * @tc.desc: Test GetAllDisplayPhysicalResolution function when allDisplayPhysicalResolution_ is empty. + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetAllDisplayPhysicalResolution01, TestSize.Level1) +{ + dms_->allDisplayPhysicalResolution_.clear(); + auto result = dms_->GetAllDisplayPhysicalResolution(); + EXPECT_FALSE(result.empty()); +} + +/** + * @tc.name: GetAllDisplayPhysicalResolution02 + * @tc.desc: Test GetAllDisplayPhysicalResolution function when allDisplayPhysicalResolution_ is not empty. + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetAllDisplayPhysicalResolution02, TestSize.Level1) +{ + dms_->allDisplayPhysicalResolution_.emplace_back(DisplayPhysicalResolution()); + auto result = dms_->GetAllDisplayPhysicalResolution(); + EXPECT_FALSE(result.empty()); +} + +/** + * @tc.name: GetAllDisplayPhysicalResolution03 + * @tc.desc: Test GetAllDisplayPhysicalResolution function when default display info is null. + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerServiceTest, GetAllDisplayPhysicalResolution03, TestSize.Level1) +{ + dms_->allDisplayPhysicalResolution_.clear(); + dms_->GetDefaultDisplayInfo(); + auto result = dms_->GetAllDisplayPhysicalResolution(); + EXPECT_FALSE(result.empty()); +} } } // namespace Rosen } // namespace OHOS diff --git a/dmserver/test/unittest/display_manager_stub_test.cpp b/dmserver/test/unittest/display_manager_stub_test.cpp index b1eb2996e3..b024c9d3cf 100644 --- a/dmserver/test/unittest/display_manager_stub_test.cpp +++ b/dmserver/test/unittest/display_manager_stub_test.cpp @@ -1001,6 +1001,26 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest47, TestSize.Level1) int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest48 + * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerStubTest, OnRemoteRequest48, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); + + uint32_t code = static_cast( + DisplayManagerMessage::TRANS_ID_GET_ALL_PHYSICAL_DISPLAY_RESOLUTION); + + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/dmserver/test/unittest/display_power_controller_test.cpp b/dmserver/test/unittest/display_power_controller_test.cpp index e2d70ff2a8..dbd392f7aa 100644 --- a/dmserver/test/unittest/display_power_controller_test.cpp +++ b/dmserver/test/unittest/display_power_controller_test.cpp @@ -115,6 +115,21 @@ HWTEST_F(DisplayPowerControllerTest, SetDisplayState03, TestSize.Level1) ASSERT_EQ(true, ret); } +/** + * @tc.name: SetDisplayState04 + * @tc.desc: test function : SetDisplayState + * @tc.type: FUNC + */ +HWTEST_F(DisplayPowerControllerTest, SetDisplayState04, TestSize.Level1) +{ + dpc_ = new DisplayPowerController(mutex_, [](DisplayId, sptr, + const std::map>&, DisplayStateChangeType) {}); + + DisplayState state = dpc_->GetDisplayState(0); + auto ret = dpc_->SetDisplayState(state); + EXPECT_EQ(false, ret); +} + /** * @tc.name: GetDisplayState * @tc.desc: test function : GetDisplayState @@ -159,6 +174,22 @@ HWTEST_F(DisplayPowerControllerTest, NotifyDisplayEvent02, TestSize.Level1) dpc_->NotifyDisplayEvent(event); ASSERT_EQ(true, dpc_->isKeyguardDrawn_); } + +/** + * @tc.name: NotifyDisplayEvent03 + * @tc.desc: test function : NotifyDisplayEvent + * @tc.type: FUNC + */ +HWTEST_F(DisplayPowerControllerTest, NotifyDisplayEvent03, TestSize.Level1) +{ + dpc_ = new DisplayPowerController(mutex_, [](DisplayId, sptr, + const std::map>&, DisplayStateChangeType) {}); + + bool isKeyguardDrawn = dpc_->isKeyguardDrawn_; + DisplayEvent event = DisplayEvent::SCREEN_LOCK_END_DREAM; + dpc_->NotifyDisplayEvent(event); + EXPECT_EQ(isKeyguardDrawn, dpc_->isKeyguardDrawn_); +} } } } \ No newline at end of file diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 78aa053fed..8e981669d6 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -503,6 +503,15 @@ enum class VirtualScreenType: uint32_t { HICAR, }; +/** + * @brief Enumerates the screen mode change events. + */ +enum class ScreenModeChangeEvent: uint32_t { + UNKNOWN = 0, + BEGIN, + END, +}; + struct Point { int32_t posX_; int32_t posY_; diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index e9445cb24a..94d1a6a2c4 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -233,7 +233,7 @@ public: * @param info Keyboard occupied area info. */ virtual void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type, - const sptr& info = nullptr) {} + const sptr& info) {} }; /** @@ -947,6 +947,14 @@ public: */ virtual bool GetTouchable() const { return false; } + /** + * @brief Set follow screen change property of window. + * + * @param isFollowScreenChange Window follow screen change. + * @return WMError. + */ + virtual WMError SetFollowScreenChange(bool isFollowScreenChange) { return WMError::WM_OK; } + /** * @brief Get SystemBarProperty By WindowType. * diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 958c2db50a..d5e5c7677c 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -1373,12 +1373,12 @@ struct PiPControlEnableInfo { }; struct PiPTemplateInfo : public Parcelable { - uint32_t pipTemplateType; - uint32_t priority; + uint32_t pipTemplateType{0}; + uint32_t priority{0}; std::vector controlGroup; std::vector pipControlStatusInfoList; std::vector pipControlEnableInfoList; - uint32_t defaultWindowSizeType; + uint32_t defaultWindowSizeType{0}; PiPTemplateInfo() {} diff --git a/interfaces/kits/napi/window_runtime/BUILD.gn b/interfaces/kits/napi/window_runtime/BUILD.gn index 7b88770417..7baf9c6128 100644 --- a/interfaces/kits/napi/window_runtime/BUILD.gn +++ b/interfaces/kits/napi/window_runtime/BUILD.gn @@ -138,6 +138,7 @@ ohos_shared_library("window_napi") { "../../../../utils:libwmutil_base", "../../../../wm:libwm", "../common:wm_napi_util", + "../../../../window_scene/interfaces/innerkits:libwsutils", ] external_deps = [ diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index 4fe0c79c2b..886c9985c0 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -32,6 +32,7 @@ #include "window_option.h" #include "pixel_map_napi.h" #include "permission.h" +#include "scene_board_judgement.h" #include "singleton_container.h" #include "sys_cap_util.h" @@ -1241,6 +1242,10 @@ napi_value JsWindowManager::OnGetAllWindowLayoutInfo(napi_env env, napi_callback napi_value JsWindowManager::OnGetVisibleWindowInfo(napi_env env, napi_callback_info info) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "device not support!"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); + } uint32_t apiVersion = SysCapUtil::GetApiCompatibleVersion(); if (apiVersion < API_VERSION_18 && !Permission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_ATTRIBUTE, "permission denied!, api%{public}u", apiVersion); 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 a14feb2585..644f3e68ae 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -7476,8 +7476,7 @@ napi_value JsWindow::OnGetWindowStatus(napi_env env, napi_callback_info info) } auto objValue = CreateJsValue(env, windowStatus); if (objValue != nullptr) { - TLOGI(WmsLogTag::WMS_PC, "window [%{public}u, %{public}s] end", - window->GetWindowId(), window->GetWindowName().c_str()); + TLOGI(WmsLogTag::WMS_PC, "id:[%{public}u] end", window->GetWindowId()); return objValue; } else { TLOGE(WmsLogTag::WMS_PC, "create js value windowStatus failed"); diff --git a/previewer/include/window.h b/previewer/include/window.h index 759bdabbd7..75fc51f603 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -160,6 +160,7 @@ public: virtual bool IsFullScreen() const = 0; virtual WMError SetWindowMode(WindowMode mode) = 0; virtual WMError SetWindowType(WindowType type) = 0; + virtual WMError SetFollowScreenChange(bool isFollowScreenChange) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError SetAlpha(float alpha) = 0; virtual WMError SetTransform(const Transform& trans) = 0; virtual const Transform& GetTransform() const = 0; diff --git a/test/systemtest/extension/extension_connection_test.cpp b/test/systemtest/extension/extension_connection_test.cpp index 8ba58df194..649ca49347 100644 --- a/test/systemtest/extension/extension_connection_test.cpp +++ b/test/systemtest/extension/extension_connection_test.cpp @@ -13,13 +13,13 @@ * limitations under the License. */ -#include #include +#include -#include "window_extension_connection.h" +#include "iremote_object_mocker.h" #include "window_extension_connection.cpp" +#include "window_extension_connection.h" #include "wm_common.h" -#include "iremote_object_mocker.h" using namespace testing; using namespace testing::ext; @@ -29,21 +29,20 @@ namespace Rosen { class MockWindowExtensionProxy : public IRemoteProxy { public: - explicit MockWindowExtensionProxy(const sptr& impl) - : IRemoteProxy(impl) {}; + explicit MockWindowExtensionProxy(const sptr& impl) : IRemoteProxy(impl) {}; ~MockWindowExtensionProxy() {}; MOCK_METHOD(void, SetBounds, (const Rect& rect), (override)); MOCK_METHOD(void, Hide, (), (override)); MOCK_METHOD(void, Show, (), (override)); MOCK_METHOD(void, RequestFocus, (), (override)); - MOCK_METHOD(void, GetExtensionWindow, (sptr& token), (override)); + MOCK_METHOD(void, GetExtensionWindow, (sptr & token), (override)); }; class ExtensionCallback : public Rosen::IWindowExtensionCallback { public: ExtensionCallback() = default; - ~ExtensionCallback() = default; + ~ExtensionCallback() = default; void OnWindowReady(const std::shared_ptr& rsSurfaceNode) override; void OnExtensionDisconnected() override; void OnKeyEvent(const std::shared_ptr& event) override; @@ -57,21 +56,13 @@ void ExtensionCallback::OnWindowReady(const std::shared_ptr& event) -{ -} +void ExtensionCallback::OnKeyEvent(const std::shared_ptr& event) {} -void ExtensionCallback::OnPointerEvent(const std::shared_ptr& event) -{ -} +void ExtensionCallback::OnPointerEvent(const std::shared_ptr& event) {} -void ExtensionCallback::OnBackPress() -{ -} +void ExtensionCallback::OnBackPress() {} class ExtensionConnectionTest : public testing::Test { public: @@ -79,21 +70,18 @@ public: static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; + private: sptr connection_ = nullptr; }; -void ExtensionConnectionTest::SetUpTestCase() -{ -} +void ExtensionConnectionTest::SetUpTestCase() {} -void ExtensionConnectionTest::TearDownTestCase() -{ -} +void ExtensionConnectionTest::TearDownTestCase() {} void ExtensionConnectionTest::SetUp() { - connection_ = new(std::nothrow)WindowExtensionConnection(); + connection_ = new (std::nothrow) WindowExtensionConnection(); ASSERT_NE(nullptr, connection_); } @@ -113,7 +101,7 @@ HWTEST_F(ExtensionConnectionTest, WindowExtensionConnection01, TestSize.Level1) AppExecFwk::ElementName element; element.SetBundleName("com.test.windowextension"); element.SetAbilityName("WindowExtAbility"); - Rosen::Rect rect {100, 100, 60, 60}; + Rosen::Rect rect{ 100, 100, 60, 60 }; ASSERT_TRUE(connection_->ConnectExtension(element, rect, 100, INVALID_WINDOW_ID, nullptr) != ERR_OK); connection_->Show(); connection_->RequestFocus(); @@ -128,9 +116,9 @@ HWTEST_F(ExtensionConnectionTest, WindowExtensionConnection01, TestSize.Level1) */ HWTEST_F(ExtensionConnectionTest, Show, TestSize.Level1) { - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); - auto mockProxy = new(std::nothrow) MockWindowExtensionProxy(remoteObject); + auto mockProxy = new (std::nothrow) MockWindowExtensionProxy(remoteObject); ASSERT_NE(nullptr, mockProxy); ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->proxy_ = mockProxy; @@ -145,9 +133,9 @@ HWTEST_F(ExtensionConnectionTest, Show, TestSize.Level1) */ HWTEST_F(ExtensionConnectionTest, Hide, TestSize.Level1) { - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); - auto mockProxy = new(std::nothrow) MockWindowExtensionProxy(remoteObject); + auto mockProxy = new (std::nothrow) MockWindowExtensionProxy(remoteObject); ASSERT_NE(nullptr, mockProxy); ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->proxy_ = mockProxy; @@ -162,9 +150,9 @@ HWTEST_F(ExtensionConnectionTest, Hide, TestSize.Level1) */ HWTEST_F(ExtensionConnectionTest, RequestFocus, TestSize.Level1) { - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); - auto mockProxy = new(std::nothrow) MockWindowExtensionProxy(remoteObject); + auto mockProxy = new (std::nothrow) MockWindowExtensionProxy(remoteObject); ASSERT_NE(nullptr, mockProxy); ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->proxy_ = mockProxy; @@ -179,9 +167,9 @@ HWTEST_F(ExtensionConnectionTest, RequestFocus, TestSize.Level1) */ HWTEST_F(ExtensionConnectionTest, SetBounds, TestSize.Level1) { - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); - auto mockProxy = new(std::nothrow) MockWindowExtensionProxy(remoteObject); + auto mockProxy = new (std::nothrow) MockWindowExtensionProxy(remoteObject); ASSERT_NE(nullptr, mockProxy); ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->proxy_ = mockProxy; @@ -200,7 +188,7 @@ HWTEST_F(ExtensionConnectionTest, OnRemoteDied01, TestSize.Level1) sptr remoteObject = nullptr; ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->deathRecipient_ = - new(std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); + new (std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); ASSERT_NE(nullptr, connection_->pImpl_->deathRecipient_); connection_->pImpl_->deathRecipient_->OnRemoteDied(remoteObject); } @@ -212,11 +200,11 @@ HWTEST_F(ExtensionConnectionTest, OnRemoteDied01, TestSize.Level1) */ HWTEST_F(ExtensionConnectionTest, OnRemoteDied02, TestSize.Level1) { - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->deathRecipient_ = - new(std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); + new (std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); ASSERT_NE(nullptr, connection_->pImpl_->deathRecipient_); connection_->pImpl_->deathRecipient_->OnRemoteDied(remoteObject); } @@ -228,13 +216,13 @@ HWTEST_F(ExtensionConnectionTest, OnRemoteDied02, TestSize.Level1) */ HWTEST_F(ExtensionConnectionTest, OnRemoteDied03, TestSize.Level1) { - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->deathRecipient_ = - new(std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); + new (std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); ASSERT_NE(nullptr, connection_->pImpl_->deathRecipient_); - connection_->pImpl_->deathRecipient_->callback_ = new(std::nothrow) ExtensionCallback(); + connection_->pImpl_->deathRecipient_->callback_ = new (std::nothrow) ExtensionCallback(); ASSERT_NE(nullptr, connection_->pImpl_->deathRecipient_->callback_); connection_->pImpl_->deathRecipient_->OnRemoteDied(remoteObject); } @@ -261,7 +249,7 @@ HWTEST_F(ExtensionConnectionTest, OnAbilityConnectDone01, TestSize.Level1) HWTEST_F(ExtensionConnectionTest, OnAbilityConnectDone02, TestSize.Level1) { AppExecFwk::ElementName element; - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); int resultCode = 0; ASSERT_NE(nullptr, connection_->pImpl_); @@ -276,13 +264,13 @@ HWTEST_F(ExtensionConnectionTest, OnAbilityConnectDone02, TestSize.Level1) HWTEST_F(ExtensionConnectionTest, OnAbilityConnectDone03, TestSize.Level1) { AppExecFwk::ElementName element; - sptr remoteObject = new(std::nothrow) IRemoteObjectMocker(); + sptr remoteObject = new (std::nothrow) IRemoteObjectMocker(); ASSERT_NE(nullptr, remoteObject); - auto mockProxy = new(std::nothrow) MockWindowExtensionProxy(remoteObject); + auto mockProxy = new (std::nothrow) MockWindowExtensionProxy(remoteObject); ASSERT_NE(nullptr, mockProxy); ASSERT_NE(nullptr, connection_->pImpl_); connection_->pImpl_->deathRecipient_ = - new(std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); + new (std::nothrow) WindowExtensionConnection::Impl::WindowExtensionClientRecipient(nullptr); ASSERT_NE(nullptr, connection_->pImpl_->deathRecipient_); connection_->pImpl_->proxy_ = mockProxy; int resultCode = 0; @@ -312,10 +300,10 @@ HWTEST_F(ExtensionConnectionTest, OnAbilityDisconnectDone02, TestSize.Level1) AppExecFwk::ElementName element; int resultCode = 0; ASSERT_NE(nullptr, connection_->pImpl_); - connection_->pImpl_->componentCallback_ = new(std::nothrow) ExtensionCallback(); + connection_->pImpl_->componentCallback_ = new (std::nothrow) ExtensionCallback(); ASSERT_NE(nullptr, connection_->pImpl_->componentCallback_); connection_->pImpl_->OnAbilityDisconnectDone(element, resultCode); } -} -} // Rosen -} // OHOS \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/extension/modal_system_ui_extension_test.cpp b/test/systemtest/extension/modal_system_ui_extension_test.cpp index 10b8c8b785..ed231393f3 100644 --- a/test/systemtest/extension/modal_system_ui_extension_test.cpp +++ b/test/systemtest/extension/modal_system_ui_extension_test.cpp @@ -16,8 +16,8 @@ #include #include "iremote_object_mocker.h" -#include "modal_system_ui_extension.h" #include "mock_message_parcel.h" +#include "modal_system_ui_extension.h" #include "wm_common.h" using namespace testing; @@ -33,21 +33,13 @@ public: void TearDown() override; }; -void ModalSystemUiExtensionTest::SetUpTestCase() -{ -} +void ModalSystemUiExtensionTest::SetUpTestCase() {} -void ModalSystemUiExtensionTest::TearDownTestCase() -{ -} +void ModalSystemUiExtensionTest::TearDownTestCase() {} -void ModalSystemUiExtensionTest::SetUp() -{ -} +void ModalSystemUiExtensionTest::SetUp() {} -void ModalSystemUiExtensionTest::TearDown() -{ -} +void ModalSystemUiExtensionTest::TearDown() {} namespace { /** @@ -57,7 +49,7 @@ namespace { */ HWTEST_F(ModalSystemUiExtensionTest, ModalSystemUiExtensionConnection01, TestSize.Level1) { - auto connection = new(std::nothrow)ModalSystemUiExtension(); + auto connection = new (std::nothrow) ModalSystemUiExtension(); if (connection == nullptr) { return; } @@ -143,6 +135,6 @@ HWTEST_F(ModalSystemUiExtensionTest, DialogAbilityConnectionSendWant, TestSize.L remoteObject->sendRequestResult_ = 1; EXPECT_FALSE(connection->SendWant(remoteObject)); } -} -} // Rosen -} // OHOS \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_animation_transition_test.cpp b/test/systemtest/wms/window_animation_transition_test.cpp index d209451862..04dea9f188 100644 --- a/test/systemtest/wms/window_animation_transition_test.cpp +++ b/test/systemtest/wms/window_animation_transition_test.cpp @@ -15,17 +15,17 @@ // gtest #include -#include "window.h" -#include "wm_common.h" #include "common_test_utils.h" +#include "window.h" #include "window_test_utils.h" +#include "wm_common.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAnimationTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAnimationTest" }; } using Utils = WindowTestUtils; @@ -35,6 +35,7 @@ public: explicit TestAnimationTransitionController(sptr window) : window_(window) {} void AnimationForShown() override; void AnimationForHidden() override; + private: sptr window_ = nullptr; }; @@ -67,33 +68,27 @@ void TestAnimationTransitionController::AnimationForHidden() window_->SetTransform(trans); } -void WindowAnimationTransitionTest::SetUpTestCase() -{ -} +void WindowAnimationTransitionTest::SetUpTestCase() {} -void WindowAnimationTransitionTest::TearDownTestCase() -{ -} +void WindowAnimationTransitionTest::TearDownTestCase() {} void WindowAnimationTransitionTest::SetUp() { CommonTestUtils::GuaranteeFloatWindowPermission("wms_window_animation_transition_test"); windowInfo_ = { - .name = "AnimationTestWindow", - .rect = {0, 0, 200, 200}, - .type = WindowType::WINDOW_TYPE_FLOAT, - .mode = WindowMode::WINDOW_MODE_FLOATING, - .needAvoid = false, - .parentLimit = false, - .parentId = INVALID_WINDOW_ID, + .name = "AnimationTestWindow", + .rect = { 0, 0, 200, 200 }, + .type = WindowType::WINDOW_TYPE_FLOAT, + .mode = WindowMode::WINDOW_MODE_FLOATING, + .needAvoid = false, + .parentLimit = false, + .parentId = INVALID_WINDOW_ID, }; trans_.pivotX_ = 1.0f; trans_.pivotY_ = 0.6f; } -void WindowAnimationTransitionTest::TearDown() -{ -} +void WindowAnimationTransitionTest::TearDown() {} namespace { /** @@ -171,6 +166,6 @@ HWTEST_F(WindowAnimationTransitionTest, AnimationTransitionTest04, TestSize.Leve ASSERT_TRUE(defaultTrans_ == window->GetTransform()); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_app_floating_window_scb_test.cpp b/test/systemtest/wms/window_app_floating_window_scb_test.cpp index 168f302360..0496e68fe0 100644 --- a/test/systemtest/wms/window_app_floating_window_scb_test.cpp +++ b/test/systemtest/wms/window_app_floating_window_scb_test.cpp @@ -16,13 +16,13 @@ // gtest #include #include "ability_context_impl.h" +#include "common_test_utils.h" #include "ipc_skeleton.h" #include "scene_board_judgement.h" #include "window.h" #include "window_manager.h" #include "window_option.h" #include "window_scene.h" -#include "common_test_utils.h" #include "window_test_utils.h" #include "wm_common.h" @@ -32,7 +32,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAppFloatingWindowTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAppFloatingWindowTest" }; } class TestCameraFloatWindowChangedListener : public ICameraFloatWindowChangedListener { @@ -50,7 +50,7 @@ public: void TearDown() override; static inline float virtualPixelRatio_ = 1.0; - static inline Rect displayRect_ {0, 0, 0, 0}; + static inline Rect displayRect_{ 0, 0, 0, 0 }; static inline std::shared_ptr abilityContext_ = nullptr; static sptr testCameraFloatWindowChangedListener_; }; @@ -75,18 +75,14 @@ void WindowAppFloatingWindowTest::SetUpTestCase() virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); } -void WindowAppFloatingWindowTest::TearDownTestCase() -{ -} +void WindowAppFloatingWindowTest::TearDownTestCase() {} void WindowAppFloatingWindowTest::SetUp() { CommonTestUtils::GuaranteeFloatWindowPermission("wms_window_app_floating_window_test"); } -void WindowAppFloatingWindowTest::TearDown() -{ -} +void WindowAppFloatingWindowTest::TearDown() {} static sptr CreateWindowScene() { @@ -113,7 +109,7 @@ static sptr CreateAppFloatingWindow(WindowType type, Rect rect, std::str static inline Rect GetRectWithVpr(int32_t x, int32_t y, uint32_t w, uint32_t h) { auto vpr = WindowAppFloatingWindowTest::virtualPixelRatio_; - return {x, y, static_cast(w * vpr), static_cast(h * vpr)}; + return { x, y, static_cast(w * vpr), static_cast(h * vpr) }; } /** @@ -329,12 +325,12 @@ HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow09, TestSize.Level1) ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->GoForeground()); ASSERT_EQ(WMError::WM_OK, fltWin->Show()); - Rect exceptRect = {10, 20, 0, 0}; + Rect exceptRect = { 10, 20, 0, 0 }; uint32_t smallWidth = displayRect_.height_ <= displayRect_.width_ ? displayRect_.height_ : displayRect_.width_; float hwRatio = static_cast(displayRect_.height_) / static_cast(displayRect_.width_); if (smallWidth <= static_cast(600 * virtualPixelRatio_)) { // sw <= 600dp if (displayRect_.width_ <= displayRect_.height_) { - exceptRect.width_= static_cast(smallWidth * 0.3); + exceptRect.width_ = static_cast(smallWidth * 0.3); } else { exceptRect.width_ = static_cast(smallWidth * 0.5); } diff --git a/test/systemtest/wms/window_app_floating_window_test.cpp b/test/systemtest/wms/window_app_floating_window_test.cpp index 23a226cd9a..1a39085763 100644 --- a/test/systemtest/wms/window_app_floating_window_test.cpp +++ b/test/systemtest/wms/window_app_floating_window_test.cpp @@ -16,13 +16,13 @@ // gtest #include #include "ability_context_impl.h" +#include "common_test_utils.h" #include "ipc_skeleton.h" #include "scene_board_judgement.h" #include "window.h" #include "window_manager.h" #include "window_option.h" #include "window_scene.h" -#include "common_test_utils.h" #include "window_test_utils.h" #include "wm_common.h" @@ -32,7 +32,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAppFloatingWindowTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAppFloatingWindowTest" }; } class TestCameraFloatWindowChangedListener : public ICameraFloatWindowChangedListener { @@ -50,7 +50,7 @@ public: void TearDown() override; static inline float virtualPixelRatio_ = 1.0; - static inline Rect displayRect_ {0, 0, 0, 0}; + static inline Rect displayRect_{ 0, 0, 0, 0 }; static inline std::shared_ptr abilityContext_ = nullptr; static sptr testCameraFloatWindowChangedListener_; }; @@ -75,18 +75,14 @@ void WindowAppFloatingWindowTest::SetUpTestCase() virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); } -void WindowAppFloatingWindowTest::TearDownTestCase() -{ -} +void WindowAppFloatingWindowTest::TearDownTestCase() {} void WindowAppFloatingWindowTest::SetUp() { CommonTestUtils::GuaranteeFloatWindowPermission("wms_window_app_floating_window_test"); } -void WindowAppFloatingWindowTest::TearDown() -{ -} +void WindowAppFloatingWindowTest::TearDown() {} static sptr CreateWindowScene() { @@ -113,7 +109,7 @@ static sptr CreateAppFloatingWindow(WindowType type, Rect rect, std::str static inline Rect GetRectWithVpr(int32_t x, int32_t y, uint32_t w, uint32_t h) { auto vpr = WindowAppFloatingWindowTest::virtualPixelRatio_; - return {x, y, static_cast(w * vpr), static_cast(h * vpr)}; + return { x, y, static_cast(w * vpr), static_cast(h * vpr) }; } /** @@ -319,12 +315,12 @@ HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow09, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); ASSERT_EQ(WMError::WM_OK, fltWin->Show()); - Rect exceptRect = {10, 20, 0, 0}; + Rect exceptRect = { 10, 20, 0, 0 }; uint32_t smallWidth = displayRect_.height_ <= displayRect_.width_ ? displayRect_.height_ : displayRect_.width_; float hwRatio = static_cast(displayRect_.height_) / static_cast(displayRect_.width_); if (smallWidth <= static_cast(600 * virtualPixelRatio_)) { // sw <= 600dp if (displayRect_.width_ <= displayRect_.height_) { - exceptRect.width_= static_cast(smallWidth * 0.3); + exceptRect.width_ = static_cast(smallWidth * 0.3); } else { exceptRect.width_ = static_cast(smallWidth * 0.5); } diff --git a/test/systemtest/wms/window_callback_test.cpp b/test/systemtest/wms/window_callback_test.cpp index 21e9a8562a..f3e2fd4bd3 100644 --- a/test/systemtest/wms/window_callback_test.cpp +++ b/test/systemtest/wms/window_callback_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -//gtest +// gtest #include #include "ability_context_impl.h" @@ -201,8 +201,7 @@ HWTEST_F(WindowCallbackTest, WindowTitleButtonRectChange01, TestSize.Level1) ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->RegisterWindowTitleButtonRectChangeListener(listener)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->UnregisterWindowTitleButtonRectChangeListener(listener)); - sptr listener1 = - sptr::MakeSptr(); + sptr listener1 = sptr::MakeSptr(); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->RegisterWindowTitleButtonRectChangeListener(listener1)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->UnregisterWindowTitleButtonRectChangeListener(listener1)); @@ -229,8 +228,7 @@ HWTEST_F(WindowCallbackTest, WindowTitleButtonRectChange02, TestSize.Level1) window->property_->SetPersistentId(10022); window->hostSession_ = session; - sptr listener = - sptr::MakeSptr(); + sptr listener = sptr::MakeSptr(); window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(WMError::WM_OK, window->RegisterWindowTitleButtonRectChangeListener(listener)); @@ -267,8 +265,7 @@ HWTEST_F(WindowCallbackTest, WindowTitleButtonRectChange03, TestSize.Level1) window->property_->SetPersistentId(10023); window->hostSession_ = session; - sptr listener = - sptr::MakeSptr(); + sptr listener = sptr::MakeSptr(); window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(WMError::WM_OK, window->RegisterWindowTitleButtonRectChangeListener(listener)); @@ -305,8 +302,7 @@ HWTEST_F(WindowCallbackTest, WindowTitleButtonRectChange04, TestSize.Level1) window->property_->SetPersistentId(10024); window->hostSession_ = session; - sptr listener = - sptr::MakeSptr(); + sptr listener = sptr::MakeSptr(); window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(WMError::WM_OK, window->RegisterWindowTitleButtonRectChangeListener(listener)); @@ -462,6 +458,6 @@ HWTEST_F(WindowCallbackTest, MainWindowClose04, TestSize.Level1) window->Destroy(true, true); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_decor_test.cpp b/test/systemtest/wms/window_decor_test.cpp index 62c93dbb1c..edfde02997 100644 --- a/test/systemtest/wms/window_decor_test.cpp +++ b/test/systemtest/wms/window_decor_test.cpp @@ -433,8 +433,6 @@ HWTEST_F(WindowDecorTest, DisableAppWindowDecor03, TestSize.Level1) window->Destroy(true, true); } - -} - +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_dialogwindow_test.cpp b/test/systemtest/wms/window_dialogwindow_test.cpp index a23c83a370..e07472aded 100644 --- a/test/systemtest/wms/window_dialogwindow_test.cpp +++ b/test/systemtest/wms/window_dialogwindow_test.cpp @@ -36,21 +36,13 @@ public: static inline std::shared_ptr abilityContext_ = nullptr; }; -void WindowDialogWindowTest::SetUpTestCase() -{ -} +void WindowDialogWindowTest::SetUpTestCase() {} -void WindowDialogWindowTest::TearDownTestCase() -{ -} +void WindowDialogWindowTest::TearDownTestCase() {} -void WindowDialogWindowTest::SetUp() -{ -} +void WindowDialogWindowTest::SetUp() {} -void WindowDialogWindowTest::TearDown() -{ -} +void WindowDialogWindowTest::TearDown() {} static sptr CreateWindowScene() { @@ -88,7 +80,7 @@ HWTEST_F(WindowDialogWindowTest, DialogWindow01, TestSize.Level1) sptr scene = CreateWindowScene(); ASSERT_NE(scene, nullptr); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr dialogWindow = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect); ASSERT_NE(nullptr, dialogWindow); @@ -113,7 +105,7 @@ HWTEST_F(WindowDialogWindowTest, DialogWindow02, TestSize.Level1) sptr scene = CreateWindowScene(); ASSERT_NE(scene, nullptr); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr dialogWindow0 = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect); ASSERT_NE(nullptr, dialogWindow0); @@ -141,7 +133,7 @@ HWTEST_F(WindowDialogWindowTest, DialogWindow03, TestSize.Level1) sptr scene = CreateWindowScene(); ASSERT_NE(scene, nullptr); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr dialogWindow0 = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect, "dialog0"); sptr dialogWindow1 = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect, "dialog0"); ASSERT_NE(nullptr, dialogWindow0); @@ -171,13 +163,12 @@ HWTEST_F(WindowDialogWindowTest, DialogWindow04, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); } - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr dialogWindow0 = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect, "dialog0"); ASSERT_NE(nullptr, dialogWindow0); ASSERT_EQ(WMError::WM_OK, dialogWindow0->Show()); ASSERT_EQ(WMError::WM_OK, dialogWindow0->Destroy()); - sptr dialogWindow1 = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect, "dialog0"); ASSERT_NE(nullptr, dialogWindow1); ASSERT_EQ(WMError::WM_OK, dialogWindow1->Show()); @@ -198,7 +189,7 @@ HWTEST_F(WindowDialogWindowTest, DialogWindow05, TestSize.Level1) sptr scene = CreateWindowScene(); ASSERT_NE(scene, nullptr); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr dialogWindow = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect); ASSERT_NE(nullptr, dialogWindow); @@ -223,7 +214,7 @@ HWTEST_F(WindowDialogWindowTest, DialogWindow06, TestSize.Level1) sptr scene = CreateWindowScene(); ASSERT_NE(scene, nullptr); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr dialogWindow = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect); ASSERT_NE(nullptr, dialogWindow); @@ -251,7 +242,7 @@ HWTEST_F(WindowDialogWindowTest, DialogWindow07, TestSize.Level1) sptr scene = CreateWindowScene(); ASSERT_NE(scene, nullptr); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr dialogWindow = CreateDialogWindow(scene, WindowType::WINDOW_TYPE_DIALOG, rect); ASSERT_NE(nullptr, dialogWindow); diff --git a/test/systemtest/wms/window_display_zoom_test.cpp b/test/systemtest/wms/window_display_zoom_test.cpp index b335d75388..34234f976c 100644 --- a/test/systemtest/wms/window_display_zoom_test.cpp +++ b/test/systemtest/wms/window_display_zoom_test.cpp @@ -15,9 +15,9 @@ // gtest #include -#include "window_test_utils.h" #include "window_accessibility_controller.h" #include "window_impl.h" +#include "window_test_utils.h" #include "wm_common.h" using namespace testing; using namespace testing::ext; @@ -34,19 +34,15 @@ public: Utils::TestWindowInfo windowInfo_; }; -void WindowDisplayZoomTest::SetUpTestCase() -{ -} +void WindowDisplayZoomTest::SetUpTestCase() {} -void WindowDisplayZoomTest::TearDownTestCase() -{ -} +void WindowDisplayZoomTest::TearDownTestCase() {} void WindowDisplayZoomTest::SetUp() { windowInfo_ = { .name = "zoomWindow", - .rect = {0, 0, 300, 100}, + .rect = { 0, 0, 300, 100 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -56,9 +52,7 @@ void WindowDisplayZoomTest::SetUp() }; } -void WindowDisplayZoomTest::TearDown() -{ -} +void WindowDisplayZoomTest::TearDown() {} namespace { /** @@ -135,8 +129,8 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom02, TestSize.Level1) Rect rect = window->GetRect(); expect.pivotX_ = (0 - rect.posX_) * 1.0 / rect.width_; expect.pivotY_ = (0 - rect.posY_) * 1.0 / rect.height_; - expect.scaleX_ = expect.scaleY_ = 2; // scale value - expect.translateX_ = expect.translateY_ = -100; // translate value + expect.scaleX_ = expect.scaleY_ = 2; // scale value + expect.translateX_ = expect.translateY_ = -100; // translate value WindowAccessibilityController::GetInstance().SetAnchorOffset(200, 200); sleep(1); @@ -231,7 +225,7 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, TestSize.Level1) Transform animate; animate.translateX_ = -100; // translate x value - animate.translateZ_ = 100; // translate z value + animate.translateZ_ = 100; // translate z value window->SetTransform(animate); sleep(1); @@ -242,9 +236,7 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, TestSize.Level1) expect.scaleX_ = expect.scaleY_ = 1.7; // scale value Transform actual = implPtr->GetWindowProperty()->GetZoomTransform(); - auto isExpec = [](float a, float b) -> bool { - return abs(a - b) < 0.1; - }; + auto isExpec = [](float a, float b) -> bool { return abs(a - b) < 0.1; }; ASSERT_EQ(true, isExpec(actual.pivotX_, expect.pivotX_)); ASSERT_EQ(true, isExpec(actual.pivotY_, expect.pivotY_)); ASSERT_EQ(true, isExpec(actual.scaleX_, expect.scaleX_)); @@ -254,6 +246,6 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, TestSize.Level1) window->Destroy(); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_drag_test.cpp b/test/systemtest/wms/window_drag_test.cpp index ff6d4fdedf..3ba02878b4 100644 --- a/test/systemtest/wms/window_drag_test.cpp +++ b/test/systemtest/wms/window_drag_test.cpp @@ -24,11 +24,11 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { using Utils = WindowTestUtils; -const int WAIT_CALLBACK_US = 1; // 1s +const int WAIT_CALLBACK_US = 1; // 1s class TestDragListener : public IWindowDragListener { public: - PointInfo point_ { 0, 0 }; + PointInfo point_{ 0, 0 }; DragEvent event_ = DragEvent::DRAG_EVENT_END; void OnDrag(int32_t x, int32_t y, DragEvent event) override; }; @@ -55,10 +55,8 @@ public: std::vector> activeWindows_; }; -sptr WindowDragTest::firstWindowDragListener_ = - new TestDragListener(); -sptr WindowDragTest::secondWindowDragListener_ = - new TestDragListener(); +sptr WindowDragTest::firstWindowDragListener_ = new TestDragListener(); +sptr WindowDragTest::secondWindowDragListener_ = new TestDragListener(); void WindowDragTest::SetUpTestCase() {} @@ -68,7 +66,7 @@ void WindowDragTest::SetUp() { dragWindowInfo_ = { .name = "dragWindow", - .rect = {200, 200, 380, 380}, + .rect = { 200, 200, 380, 380 }, .type = WindowType::WINDOW_TYPE_DRAGGING_EFFECT, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = false, @@ -101,7 +99,8 @@ void WindowDragTest::SetUp() activeWindows_.clear(); } -void WindowDragTest::TearDown() { +void WindowDragTest::TearDown() +{ while (!activeWindows_.empty()) { ASSERT_EQ(WMError::WM_OK, activeWindows_.back()->Destroy()); activeWindows_.pop_back(); @@ -114,15 +113,16 @@ namespace { * @tc.desc: Drag a window to another window * @tc.type: FUNC */ -HWTEST_F(WindowDragTest, DragIn, TestSize.Level1) { - const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); +HWTEST_F(WindowDragTest, DragIn, TestSize.Level1) +{ + const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); ASSERT_NE(firstWindow, nullptr); activeWindows_.push_back(firstWindow); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); + const sptr& dragWindow = Utils::CreateTestWindow(dragWindowInfo_); ASSERT_NE(dragWindow, nullptr); activeWindows_.push_back(dragWindow); dragWindow->Show(); @@ -141,15 +141,16 @@ HWTEST_F(WindowDragTest, DragIn, TestSize.Level1) { * @tc.desc: Window Move * @tc.type: FUNC */ -HWTEST_F(WindowDragTest, DragMove, TestSize.Level1) { - const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); +HWTEST_F(WindowDragTest, DragMove, TestSize.Level1) +{ + const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); ASSERT_NE(firstWindow, nullptr); activeWindows_.push_back(firstWindow); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); + const sptr& dragWindow = Utils::CreateTestWindow(dragWindowInfo_); ASSERT_NE(dragWindow, nullptr); activeWindows_.push_back(dragWindow); dragWindow->Show(); @@ -174,22 +175,23 @@ HWTEST_F(WindowDragTest, DragMove, TestSize.Level1) { * @tc.desc: Drag the drag window out of the current window * @tc.type: FUNC */ -HWTEST_F(WindowDragTest, DragOut, TestSize.Level1) { - const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); +HWTEST_F(WindowDragTest, DragOut, TestSize.Level1) +{ + const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); ASSERT_NE(firstWindow, nullptr); activeWindows_.push_back(firstWindow); firstWindow->RegisterDragListener(firstWindowDragListener_); firstWindow->SetTurnScreenOn(true); firstWindow->Show(); - secondWindowInfo_.rect = {500, 500, 500, 500}; - const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); + secondWindowInfo_.rect = { 500, 500, 500, 500 }; + const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(secondWindow, nullptr); activeWindows_.push_back(secondWindow); secondWindow->RegisterDragListener(secondWindowDragListener_); secondWindow->Show(); - const sptr &dragWindow = Utils::CreateTestWindow(dragWindowInfo_); + const sptr& dragWindow = Utils::CreateTestWindow(dragWindowInfo_); ASSERT_NE(secondWindow, nullptr); activeWindows_.push_back(dragWindow); dragWindow->Show(); @@ -222,7 +224,8 @@ HWTEST_F(WindowDragTest, DragOut, TestSize.Level1) { * @tc.desc: End window drag * @tc.type: FUNC */ -HWTEST_F(WindowDragTest, DragEnd, TestSize.Level1) { +HWTEST_F(WindowDragTest, DragEnd, TestSize.Level1) +{ const sptr firstWindow = Utils::CreateTestWindow(firstWindowInfo_); ASSERT_NE(nullptr, firstWindow); firstWindow->RegisterDragListener(firstWindowDragListener_); diff --git a/test/systemtest/wms/window_effect_test.cpp b/test/systemtest/wms/window_effect_test.cpp index cdc62ed347..30ffc1459b 100644 --- a/test/systemtest/wms/window_effect_test.cpp +++ b/test/systemtest/wms/window_effect_test.cpp @@ -15,10 +15,10 @@ // gtest #include -#include "display_manager_proxy.h" #include "common_test_utils.h" -#include "window_test_utils.h" +#include "display_manager_proxy.h" #include "window_accessibility_controller.h" +#include "window_test_utils.h" #include "wm_common.h" using namespace testing; using namespace testing::ext; @@ -33,29 +33,26 @@ public: virtual void SetUp() override; virtual void TearDown() override; Utils::TestWindowInfo windowInfo_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void WindowEffectTest::SetUpTestCase() -{ -} +void WindowEffectTest::SetUpTestCase() {} -void WindowEffectTest::TearDownTestCase() -{ -} +void WindowEffectTest::TearDownTestCase() {} void WindowEffectTest::SetUp() { CommonTestUtils::GuaranteeFloatWindowPermission("wms_window_effect_test"); windowInfo_ = { - .name = "TestWindow", - .rect = {0, 0, 100, 200}, - .type = WindowType::WINDOW_TYPE_FLOAT, - .mode = WindowMode::WINDOW_MODE_FLOATING, - .needAvoid = false, - .parentLimit = false, - .parentId = INVALID_WINDOW_ID, + .name = "TestWindow", + .rect = { 0, 0, 100, 200 }, + .type = WindowType::WINDOW_TYPE_FLOAT, + .mode = WindowMode::WINDOW_MODE_FLOATING, + .needAvoid = false, + .parentLimit = false, + .parentId = INVALID_WINDOW_ID, }; } @@ -203,7 +200,6 @@ HWTEST_F(WindowEffectTest, WindowEffect07, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } - } // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_focus_test.cpp b/test/systemtest/wms/window_focus_test.cpp index 11c4708403..a1a84f9fc8 100644 --- a/test/systemtest/wms/window_focus_test.cpp +++ b/test/systemtest/wms/window_focus_test.cpp @@ -15,21 +15,21 @@ // gtest #include -#include "wm_common.h" +#include "scene_board_judgement.h" #include "window_manager.h" #include "window_test_utils.h" -#include "scene_board_judgement.h" +#include "wm_common.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowFocusTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowFocusTest" }; } using Utils = WindowTestUtils; -const int WAIT_ASYNC_US = 100000; // 100000us +const int WAIT_ASYNC_US = 100000; // 100000us class TestFocusChangedListener : public IFocusChangedListener { public: @@ -51,8 +51,7 @@ public: Utils::TestWindowInfo subAppInfo_; }; -sptr WindowFocusTest::testFocusChangedListener_ = - new TestFocusChangedListener(); +sptr WindowFocusTest::testFocusChangedListener_ = new TestFocusChangedListener(); void TestFocusChangedListener::OnFocused(const sptr& focusChangeInfo) { @@ -70,47 +69,48 @@ void WindowFocusTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); - WLOGI("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()}; + WLOGI("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); } -void WindowFocusTest::TearDownTestCase() -{ -} +void WindowFocusTest::TearDownTestCase() {} void WindowFocusTest::SetUp() { fullScreenAppInfo_ = { - .name = "FullWindow", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .showWhenLocked = true, - .parentId = INVALID_WINDOW_ID, + .name = "FullWindow", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .mode = WindowMode::WINDOW_MODE_FULLSCREEN, + .needAvoid = false, + .parentLimit = false, + .showWhenLocked = true, + .parentId = INVALID_WINDOW_ID, }; floatAppInfo_ = { - .name = "ParentWindow", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FLOATING, - .needAvoid = false, - .parentLimit = false, - .showWhenLocked = true, - .parentId = INVALID_WINDOW_ID, + .name = "ParentWindow", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .mode = WindowMode::WINDOW_MODE_FLOATING, + .needAvoid = false, + .parentLimit = false, + .showWhenLocked = true, + .parentId = INVALID_WINDOW_ID, }; subAppInfo_ = { - .name = "SubWindow", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW, - .mode = WindowMode::WINDOW_MODE_FLOATING, - .needAvoid = false, - .parentLimit = false, - .showWhenLocked = false, - .parentId = INVALID_WINDOW_ID, + .name = "SubWindow", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW, + .mode = WindowMode::WINDOW_MODE_FLOATING, + .needAvoid = false, + .parentLimit = false, + .showWhenLocked = false, + .parentId = INVALID_WINDOW_ID, }; WindowManager::GetInstance().RegisterFocusChangedListener(testFocusChangedListener_); } @@ -518,6 +518,6 @@ HWTEST_F(WindowFocusTest, WindowShowWithoutFocusTest, TestSize.Level1) window2->Destroy(); subWindow->Destroy(); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_gamut_test.cpp b/test/systemtest/wms/window_gamut_test.cpp index 9676770a8e..3ceee692fe 100644 --- a/test/systemtest/wms/window_gamut_test.cpp +++ b/test/systemtest/wms/window_gamut_test.cpp @@ -35,30 +35,24 @@ public: Utils::TestWindowInfo fullScreenAppInfo_; }; -void WindowGamutTest::SetUpTestCase() -{ -} +void WindowGamutTest::SetUpTestCase() {} -void WindowGamutTest::TearDownTestCase() -{ -} +void WindowGamutTest::TearDownTestCase() {} void WindowGamutTest::SetUp() { fullScreenAppInfo_ = { - .name = "FullWindow", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentId = INVALID_WINDOW_ID, + .name = "FullWindow", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .mode = WindowMode::WINDOW_MODE_FULLSCREEN, + .needAvoid = false, + .parentLimit = false, + .parentId = INVALID_WINDOW_ID, }; } -void WindowGamutTest::TearDown() -{ -} +void WindowGamutTest::TearDown() {} namespace { /** @@ -101,10 +95,7 @@ HWTEST_F(WindowGamutTest, GetColorSpace01, TestSize.Level1) HWTEST_F(WindowGamutTest, SetColorSpace01, TestSize.Level1) { uint32_t i, j; - const ColorSpace colorSpacesToTest[] = { - ColorSpace::COLOR_SPACE_DEFAULT, - ColorSpace::COLOR_SPACE_WIDE_GAMUT - }; + const ColorSpace colorSpacesToTest[] = { ColorSpace::COLOR_SPACE_DEFAULT, ColorSpace::COLOR_SPACE_WIDE_GAMUT }; ColorSpace colorSpace; fullScreenAppInfo_.name = "window_setColorSpace01"; sptr window = Utils::CreateTestWindow(fullScreenAppInfo_); @@ -114,7 +105,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace01, TestSize.Level1) for (j = 0; j < sizeof(colorSpacesToTest) / sizeof(ColorSpace); j++) { window->SetColorSpace(colorSpacesToTest[j]); // async func - for (i = 0; i < MAX_WAIT_COUNT; i++) { // wait some time for async set ok + for (i = 0; i < MAX_WAIT_COUNT; i++) { // wait some time for async set ok colorSpace = window->GetColorSpace(); if (colorSpace != colorSpacesToTest[j]) { usleep(WAIT_DUR); @@ -144,7 +135,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace02, TestSize.Level1) ColorSpace invalidColorSpace = static_cast(static_cast(ColorSpace::COLOR_SPACE_WIDE_GAMUT) + 1); - window->SetColorSpace(invalidColorSpace); // invalid param + window->SetColorSpace(invalidColorSpace); // invalid param ASSERT_EQ(colorSpaceBackup, window->GetColorSpace()); diff --git a/test/systemtest/wms/window_gesture_navigation_enabled_test.cpp b/test/systemtest/wms/window_gesture_navigation_enabled_test.cpp index a8c5de7303..2d0091b086 100644 --- a/test/systemtest/wms/window_gesture_navigation_enabled_test.cpp +++ b/test/systemtest/wms/window_gesture_navigation_enabled_test.cpp @@ -17,9 +17,9 @@ #include #include "future.h" +#include "scene_board_judgement.h" #include "window_manager.h" #include "wm_common.h" -#include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; @@ -28,8 +28,8 @@ namespace OHOS { namespace Rosen { namespace { constexpr int WAIT_FUTURE_RESULT = 20000; // 20s -constexpr int WAIT_SLEEP_TIME = 1; // 1s -} +constexpr int WAIT_SLEEP_TIME = 1; // 1s +} // namespace class TestGestureNavigationEnabledChangedListener : public IGestureNavigationEnabledChangedListener { public: @@ -56,21 +56,15 @@ public: sptr GestureNavigationEnabledTest::lisenter_ = nullptr; void GestureNavigationEnabledTest::SetUpTestCase() { - lisenter_= new (std::nothrow)TestGestureNavigationEnabledChangedListener(); + lisenter_ = new (std::nothrow) TestGestureNavigationEnabledChangedListener(); ASSERT_NE(lisenter_, nullptr); } -void GestureNavigationEnabledTest::TearDownTestCase() -{ -} +void GestureNavigationEnabledTest::TearDownTestCase() {} -void GestureNavigationEnabledTest::SetUp() -{ -} +void GestureNavigationEnabledTest::SetUp() {} -void GestureNavigationEnabledTest::TearDown() -{ -} +void GestureNavigationEnabledTest::TearDown() {} namespace { /** @@ -82,7 +76,7 @@ HWTEST_F(GestureNavigationEnabledTest, SetGestureNavigationEnabled, TestSize.Lev { ASSERT_NE(lisenter_, nullptr); - auto& windowManager = WindowManager::GetInstance(); + auto& windowManager = WindowManager::GetInstance(); windowManager.SetGestureNavigationEnabled(false); sleep(WAIT_SLEEP_TIME); @@ -106,7 +100,6 @@ HWTEST_F(GestureNavigationEnabledTest, SetGestureNavigationEnabled, TestSize.Lev windowManager.UnregisterGestureNavigationEnabledChangedListener(lisenter_); sleep(WAIT_SLEEP_TIME); } -} +} // namespace } // namespace Rosen } // namespace OHOS - diff --git a/test/systemtest/wms/window_immersive_test.cpp b/test/systemtest/wms/window_immersive_test.cpp index 9c822bfbd9..972159d2cf 100644 --- a/test/systemtest/wms/window_immersive_test.cpp +++ b/test/systemtest/wms/window_immersive_test.cpp @@ -25,7 +25,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowImmersiveTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowImmersiveTest" }; const Rect SYS_BAR_REGION_NULL = { 0, 0, 0, 0 }; const SystemBarProperty SYS_BAR_PROP_DEFAULT; @@ -46,12 +46,12 @@ const SystemBarRegionTints TEST_PROPS_2 = { { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SYS_BAR_PROP_3, SYS_BAR_REGION_NULL }, }; -const Rect EMPTY_RECT = {0, 0, 0, 0}; +const Rect EMPTY_RECT = { 0, 0, 0, 0 }; const float RATIO = 0.3; -} +} // namespace using Utils = WindowTestUtils; -const int WAIT_ASYNC_US = 100000; // 100000us +const int WAIT_ASYNC_US = 100000; // 100000us class TestSystemBarChangedListener : public ISystemBarChangedListener { public: @@ -109,14 +109,18 @@ void WindowImmersiveTest::DumpFailedInfo(const SystemBarRegionTints& expect) WLOGI("WindowImmersiveTest Expected:"); for (auto tint : expect) { WLOGI("WindowType: %{public}4d, Enable: %{public}4d, Color: %{public}x | %{public}x", - static_cast(tint.type_), tint.prop_.enable_, - tint.prop_.backgroundColor_, tint.prop_.contentColor_); + static_cast(tint.type_), + tint.prop_.enable_, + tint.prop_.backgroundColor_, + tint.prop_.contentColor_); } WLOGI("WindowImmersiveTest Act: "); for (auto tint : act) { WLOGI("WindowType: %{public}4d, Enable: %{public}4d, Color: %{public}x | %{public}x", - static_cast(tint.type_), tint.prop_.enable_, - tint.prop_.backgroundColor_, tint.prop_.contentColor_); + static_cast(tint.type_), + tint.prop_.enable_, + tint.prop_.backgroundColor_, + tint.prop_.contentColor_); } } @@ -128,8 +132,10 @@ void WindowImmersiveTest::DumpFailedInfo(bool expectStatus, bool expectNav) WLOGI("WindowImmersiveTest Act: "); for (auto tint : act) { WLOGI("WindowType: %{public}4d, Enable: %{public}4d, Color: %{public}x | %{public}x", - static_cast(tint.type_), tint.prop_.enable_, - tint.prop_.backgroundColor_, tint.prop_.contentColor_); + static_cast(tint.type_), + tint.prop_.enable_, + tint.prop_.backgroundColor_, + tint.prop_.contentColor_); } } @@ -164,8 +170,8 @@ bool WindowImmersiveTest::SystemBarEnableState(bool expectStatus, bool expectNav auto act = testSystemBarChangedListener_->tints_; bool check = false; for (auto tint : act) { - if ((tint.type_ == WindowType::WINDOW_TYPE_STATUS_BAR && tint.prop_.enable_ == expectStatus) - || (tint.type_ == WindowType::WINDOW_TYPE_NAVIGATION_BAR && tint.prop_.enable_ == expectNav)) { + if ((tint.type_ == WindowType::WINDOW_TYPE_STATUS_BAR && tint.prop_.enable_ == expectStatus) || + (tint.type_ == WindowType::WINDOW_TYPE_NAVIGATION_BAR && tint.prop_.enable_ == expectNav)) { check = true; } else { check = false; @@ -179,7 +185,7 @@ bool WindowImmersiveTest::SystemBarEnableState(bool expectStatus, bool expectNav void TestSystemBarChangedListener::OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) { - WLOGI("TestSystemBarChangedListener Display ID: %{public}" PRIu64"", displayId); + WLOGI("TestSystemBarChangedListener Display ID: %{public}" PRIu64 "", displayId); WLOGI("TestSystemBarChangedListener tints size: %{public}zu", tints.size()); for (auto tint : tints) { auto type = tint.type_; @@ -200,15 +206,16 @@ void WindowImmersiveTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); - WLOGI("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()}; + WLOGI("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); } -void WindowImmersiveTest::TearDownTestCase() -{ -} +void WindowImmersiveTest::TearDownTestCase() {} void WindowImmersiveTest::SetUp() { @@ -217,7 +224,7 @@ void WindowImmersiveTest::SetUp() .rect = Utils::customAppRect_, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FULLSCREEN, // immersive setting - .needAvoid = false, // immersive setting + .needAvoid = false, // immersive setting .parentLimit = false, .parentId = INVALID_WINDOW_ID, }; @@ -458,6 +465,6 @@ HWTEST_F(WindowImmersiveTest, DockWindowTest01, TestSize.Level1) } ASSERT_EQ(WMError::WM_OK, dockWindow->Destroy()); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_input_method_test.cpp b/test/systemtest/wms/window_input_method_test.cpp index 230742c06f..87e3b3aadd 100644 --- a/test/systemtest/wms/window_input_method_test.cpp +++ b/test/systemtest/wms/window_input_method_test.cpp @@ -15,9 +15,9 @@ // gtest #include +#include "scene_board_judgement.h" #include "window_test_utils.h" #include "wm_common.h" -#include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; @@ -41,17 +41,13 @@ void WindowInputMethodTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); - Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; + Rect displayRect = { 0, 0, display->GetWidth(), display->GetHeight() }; Utils::InitByDisplayRect(displayRect); } -void WindowInputMethodTest::TearDownTestCase() -{ -} +void WindowInputMethodTest::TearDownTestCase() {} -void WindowInputMethodTest::SetUp() -{ -} +void WindowInputMethodTest::SetUp() {} void WindowInputMethodTest::TearDown() { @@ -95,15 +91,14 @@ HWTEST_F(WindowInputMethodTest, ShowKeyboard01, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, fullWindow->ChangeKeyboardViewMode(KeyboardViewMode::LIGHT_IMMERSIVE_MODE)); sleep(TEST_SLEEP_SECOND); - ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, - fullWindow->ChangeKeyboardViewMode(static_cast(-1))); + ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, fullWindow->ChangeKeyboardViewMode(static_cast(-1))); sleep(TEST_SLEEP_SECOND); ASSERT_EQ(WMError::WM_OK, fullWindow->Hide()); sleep(TEST_SLEEP_SECOND); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, - fullWindow->ChangeKeyboardViewMode(KeyboardViewMode::DARK_IMMERSIVE_MODE)); + fullWindow->ChangeKeyboardViewMode(KeyboardViewMode::DARK_IMMERSIVE_MODE)); sleep(TEST_SLEEP_SECOND); fullWindow->Destroy(); } diff --git a/test/systemtest/wms/window_input_test.cpp b/test/systemtest/wms/window_input_test.cpp index 2f8ddb5f93..12ee48e0d9 100644 --- a/test/systemtest/wms/window_input_test.cpp +++ b/test/systemtest/wms/window_input_test.cpp @@ -24,7 +24,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr uint32_t WAIT_ASYNC_US = 100000; // 100ms +constexpr uint32_t WAIT_ASYNC_US = 100000; // 100ms } using Utils = WindowTestUtils; class WindowInputTest : public testing::Test { @@ -40,13 +40,11 @@ void WindowInputTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); - Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; + Rect displayRect = { 0, 0, display->GetWidth(), display->GetHeight() }; Utils::InitByDisplayRect(displayRect); } -void WindowInputTest::TearDownTestCase() -{ -} +void WindowInputTest::TearDownTestCase() {} void WindowInputTest::SetUp() { @@ -61,9 +59,7 @@ void WindowInputTest::SetUp() }; } -void WindowInputTest::TearDown() -{ -} +void WindowInputTest::TearDown() {} namespace { /** diff --git a/test/systemtest/wms/window_layout_integration_test.cpp b/test/systemtest/wms/window_layout_integration_test.cpp index 87ecaf21ac..b6bd779e1a 100644 --- a/test/systemtest/wms/window_layout_integration_test.cpp +++ b/test/systemtest/wms/window_layout_integration_test.cpp @@ -19,9 +19,9 @@ #include "common_test_utils.h" #include "mock_session.h" #include "session/host/include/scene_session.h" -#include "window_test_utils.h" #include "window_adapter.h" #include "window_scene_session_impl.h" +#include "window_test_utils.h" #include "wm_common.h" using namespace testing; @@ -36,28 +36,19 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::shared_ptr abilityContext_; static constexpr uint32_t WAIT_SERVERAL_FRAMES = 70000; }; +void WindowLayoutTest::SetUpTestCase() {} -void WindowLayoutTest::SetUpTestCase() -{ -} - -void WindowLayoutTest::TearDownTestCase() -{ -} - -void WindowLayoutTest::SetUp() -{ -} +void WindowLayoutTest::TearDownTestCase() {} -void WindowLayoutTest::TearDown() -{ -} +void WindowLayoutTest::SetUp() {} +void WindowLayoutTest::TearDown() {} namespace { @@ -72,7 +63,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo01, TestSize.Level1) option->SetWindowName("moveWindowTo01"); option->SetWindowType(WindowType::WINDOW_TYPE_TOAST); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - + sptr window = sptr::MakeSptr(option); window->property_->SetPersistentId(10001); @@ -129,7 +120,8 @@ HWTEST_F(WindowLayoutTest, moveWindowTo02, TestSize.Level1) sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "bundleName_moveWindowTo02", - "moduleName_moveWindowTo02", "abilityName_moveWindowTo02" }; + "moduleName_moveWindowTo02", + "abilityName_moveWindowTo02" }; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); Rect rectOld; @@ -177,13 +169,14 @@ HWTEST_F(WindowLayoutTest, moveWindowTo03, TestSize.Level1) option->SetWindowName("moveWindowTo03"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - + sptr window = sptr::MakeSptr(option); window->property_->SetPersistentId(10003); SessionInfo sessionInfo = { "bundleName_moveWindowTo03", - "moduleName_moveWindowTo03", "abilityName_moveWindowTo03" }; + "moduleName_moveWindowTo03", + "abilityName_moveWindowTo03" }; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); Rect rectOld; @@ -238,13 +231,14 @@ HWTEST_F(WindowLayoutTest, moveWindowTo04, TestSize.Level1) option->SetWindowName("moveWindowTo04"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - + sptr window = sptr::MakeSptr(option); window->property_->SetPersistentId(10004); SessionInfo sessionInfo = { "bundleName_moveWindowTo04", - "moduleName_moveWindowTo04", "abilityName_moveWindowTo04" }; + "moduleName_moveWindowTo04", + "abilityName_moveWindowTo04" }; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); Rect rectOld; @@ -299,7 +293,7 @@ HWTEST_F(WindowLayoutTest, resize01, TestSize.Level1) option->SetWindowName("resize01"); option->SetWindowType(WindowType::WINDOW_TYPE_TOAST); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - + sptr window = sptr::MakeSptr(option); Rect rect; @@ -350,7 +344,7 @@ HWTEST_F(WindowLayoutTest, resize02, TestSize.Level1) option->SetWindowName("resize02"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - + sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "bundleName_resize02", "moduleName_resize02", "abilityName_resize02" }; @@ -384,7 +378,7 @@ HWTEST_F(WindowLayoutTest, resize03, TestSize.Level1) option->SetWindowName("resize03"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - + sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "bundleName_resize03", "moduleName_resize03", "abilityName_resize03" }; @@ -418,7 +412,7 @@ HWTEST_F(WindowLayoutTest, resize04, TestSize.Level1) option->SetWindowName("resize04"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - + sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "bundleName_resize04", "moduleName_resize04", "abilityName_resize04" }; @@ -452,7 +446,7 @@ HWTEST_F(WindowLayoutTest, resize05, TestSize.Level1) option->SetWindowName("resize05"); option->SetWindowType(WindowType::WINDOW_TYPE_TOAST); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - + sptr window = sptr::MakeSptr(option); Rect rect; @@ -492,7 +486,7 @@ HWTEST_F(WindowLayoutTest, resize06, TestSize.Level1) option->SetWindowName("resize06"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - + sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "bundleName_resize06", "moduleName_resize06", "abilityName_resize06" }; @@ -526,7 +520,7 @@ HWTEST_F(WindowLayoutTest, resize07, TestSize.Level1) option->SetWindowName("resize07"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - + sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "bundleName_resize07", "moduleName_resize07", "abilityName_resize07" }; @@ -560,7 +554,7 @@ HWTEST_F(WindowLayoutTest, resize08, TestSize.Level1) option->SetWindowName("resize08"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - + sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "bundleName_resize08", "moduleName_resize08", "abilityName_resize08" }; @@ -594,7 +588,7 @@ HWTEST_F(WindowLayoutTest, SetWindowLimitsDataRoute, TestSize.Level1) option->SetWindowName("SetWindowLimitsDataRoute"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - + sptr windowSceneSessionImpl = sptr::MakeSptr(option); windowSceneSessionImpl->property_->SetPersistentId(1); windowSceneSessionImpl->property_->SetDisplayId(0); @@ -605,7 +599,7 @@ HWTEST_F(WindowLayoutTest, SetWindowLimitsDataRoute, TestSize.Level1) windowSceneSessionImpl->hostSession_ = session; windowSceneSessionImpl->state_ = WindowState::STATE_SHOWN; - WindowLimits windowLimits1 = {4000, 4000, 2000, 2000, 0.0f, 0.0f}; + WindowLimits windowLimits1 = { 4000, 4000, 2000, 2000, 0.0f, 0.0f }; WMError ret = windowSceneSessionImpl->SetWindowLimits(windowLimits1, false); EXPECT_EQ(WMError::WM_OK, ret); auto windowProperty = windowSceneSessionImpl->GetProperty(); @@ -631,7 +625,7 @@ HWTEST_F(WindowLayoutTest, SetAspectRatioDataRoute, TestSize.Level1) option->SetWindowName("SetAspectRatioDataRoute"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - + sptr windowSceneSessionImpl = sptr::MakeSptr(option); windowSceneSessionImpl->property_->SetPersistentId(1); windowSceneSessionImpl->property_->SetDisplayId(0); @@ -642,7 +636,7 @@ HWTEST_F(WindowLayoutTest, SetAspectRatioDataRoute, TestSize.Level1) windowSceneSessionImpl->hostSession_ = session; windowSceneSessionImpl->state_ = WindowState::STATE_SHOWN; - WindowLimits windowLimits1 = {4000, 4000, 2000, 2000, 0.0f, 0.0f}; + WindowLimits windowLimits1 = { 4000, 4000, 2000, 2000, 0.0f, 0.0f }; WMError ret = windowSceneSessionImpl->SetWindowLimits(windowLimits1, false); EXPECT_EQ(WMError::WM_OK, ret); const float ratio = 1.5; @@ -677,7 +671,7 @@ HWTEST_F(WindowLayoutTest, moveToDataRoute, TestSize.Level1) WMError ret = windowSceneSessionImpl->MoveTo(500, 500); usleep(WAIT_SERVERAL_FRAMES); EXPECT_EQ(WMError::WM_OK, ret); - + Rect rect = windowSceneSessionImpl->property_->GetRequestRect(); EXPECT_EQ(500, rect.posX_); EXPECT_EQ(500, rect.posY_); @@ -752,7 +746,7 @@ HWTEST_F(WindowLayoutTest, AdjustRectByAspectRatio, TestSize.Level1) windowSceneSessionImpl->hostSession_ = session; windowSceneSessionImpl->state_ = WindowState::STATE_SHOWN; - WindowLimits windowLimits1 = {3000, 3000, 1200, 1200, 0.0f, 0.0f}; + WindowLimits windowLimits1 = { 3000, 3000, 1200, 1200, 0.0f, 0.0f }; WMError wmRet1 = windowSceneSessionImpl->SetWindowLimits(windowLimits1, false); EXPECT_EQ(WMError::WM_OK, wmRet1); @@ -783,6 +777,6 @@ HWTEST_F(WindowLayoutTest, AdjustRectByAspectRatio, TestSize.Level1) TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio end ###"); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_layout_test.cpp b/test/systemtest/wms/window_layout_test.cpp index 4fd9ce1b8e..b63583d12d 100644 --- a/test/systemtest/wms/window_layout_test.cpp +++ b/test/systemtest/wms/window_layout_test.cpp @@ -19,12 +19,11 @@ #include "common_test_utils.h" #include "mock_session.h" #include "session/host/include/scene_session.h" -#include "window_test_utils.h" #include "window_adapter.h" #include "window_scene_session_impl.h" +#include "window_test_utils.h" #include "wm_common.h" - using namespace testing; using namespace testing::ext; @@ -41,6 +40,7 @@ public: std::vector> activeWindows_; static vector fullScreenExpecteds_; static inline float virtualPixelRatio_ = 0.0; + private: static constexpr uint32_t WAIT_SYANC_US = 100000; static constexpr uint32_t WAIT_SERVERAL_FRAMES = 36000; @@ -58,27 +58,30 @@ void WindowLayoutTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_NE(display, nullptr); ASSERT_TRUE((display != nullptr)); - Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; + Rect displayRect = { 0, 0, display->GetWidth(), display->GetHeight() }; Utils::InitByDisplayRect(displayRect); virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); // calc expected rects - Rect expected = { // 0. only statusBar + Rect expected = { + // 0. only statusBar 0, Utils::statusBarRect_.height_, Utils::displayRect_.width_, Utils::displayRect_.height_ - Utils::statusBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); - expected = { // 1. both statusBar and naviBar + expected = { + // 1. both statusBar and naviBar 0, Utils::statusBarRect_.height_, Utils::displayRect_.width_, Utils::displayRect_.height_ - Utils::statusBarRect_.height_ - Utils::naviBarRect_.height_, }; fullScreenExpecteds_.push_back(expected); - expected = { // 2. only naviBar + expected = { + // 2. only naviBar 0, 0, Utils::displayRect_.width_, @@ -93,7 +96,7 @@ void WindowLayoutTest::InitAvoidArea() { Utils::TestWindowInfo info = { .name = "avoidArea", - .rect = {0, 0, 0, 0}, + .rect = { 0, 0, 0, 0 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -109,9 +112,7 @@ void WindowLayoutTest::InitAvoidArea() window->Destroy(); } -void WindowLayoutTest::TearDownTestCase() -{ -} +void WindowLayoutTest::TearDownTestCase() {} void WindowLayoutTest::SetUp() { @@ -122,7 +123,7 @@ void WindowLayoutTest::SetUp() void WindowLayoutTest::TearDown() { - for (auto window: activeWindows_) { + for (auto window : activeWindows_) { window->Destroy(); } sleep(WAIT_SYANC_S); @@ -144,7 +145,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, TestSize.Level1) Utils::TestWindowInfo info = { .name = "main1", - .rect = {0, 0, 0, 0}, + .rect = { 0, 0, 0, 0 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -333,7 +334,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow07, TestSize.Level1) ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, statBar->Show()); } sysWin->Show(); - + ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); if (WMError::WM_OK == naviBar->Show()) { @@ -360,7 +361,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, TestSize.Level1) { Utils::TestWindowInfo info = { .name = "main8", - .rect = {0, 0, 0, 0}, + .rect = { 0, 0, 0, 0 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -389,7 +390,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, TestSize.Level1) { Utils::TestWindowInfo info = { .name = "main9", - .rect = {0, 0, 0, 0}, + .rect = { 0, 0, 0, 0 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -408,8 +409,8 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, TestSize.Level1) usleep(WAIT_SYANC_US); 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 + 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)); ASSERT_EQ(WMError::WM_OK, window->Hide()); @@ -424,7 +425,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, TestSize.Level1) { Utils::TestWindowInfo info = { .name = "main10", - .rect = {0, 0, 0, 0}, + .rect = { 0, 0, 0, 0 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -583,7 +584,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative01, TestSize.Level1) WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); Utils::TestWindowInfo info = { .name = "mainNegative1", - .rect = {0, 0, 0, 0}, + .rect = { 0, 0, 0, 0 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -612,7 +613,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, TestSize.Level1) const uint32_t negativeH = 0; Utils::TestWindowInfo info = { .name = "mainNegative2", - .rect = {0, 0, 0, 0}, + .rect = { 0, 0, 0, 0 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -629,11 +630,11 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, TestSize.Level1) ASSERT_TRUE(Utils::RectEqualTo(window, expect)); window->Resize(negativeW, negativeH); usleep(WAIT_SYANC_US); - Rect expect2 = {expect.posX_, expect.posY_, negativeW, negativeH}; + Rect expect2 = { expect.posX_, expect.posY_, negativeW, negativeH }; expect2 = Utils::CalcLimitedRect(expect2, virtualPixelRatio_); ASSERT_TRUE(Utils::RectEqualTo(window, expect2)); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_mode_support_info_test.cpp b/test/systemtest/wms/window_mode_support_info_test.cpp index 107a236aa3..a18e67da07 100644 --- a/test/systemtest/wms/window_mode_support_info_test.cpp +++ b/test/systemtest/wms/window_mode_support_info_test.cpp @@ -15,10 +15,10 @@ // gtest #include +#include "scene_board_judgement.h" #include "window_manager.h" #include "window_test_utils.h" #include "wm_common.h" -#include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; @@ -33,6 +33,7 @@ public: virtual void TearDown() override; Utils::TestWindowInfo fullAppInfo_1_; Utils::TestWindowInfo fullAppInfo_2_; + private: static constexpr uint32_t WAIT_SYANC_US = 100000; }; @@ -41,39 +42,35 @@ void WindowModeSupportTypeTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); - Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; + Rect displayRect = { 0, 0, display->GetWidth(), display->GetHeight() }; Utils::InitByDisplayRect(displayRect); } -void WindowModeSupportTypeTest::TearDownTestCase() -{ -} +void WindowModeSupportTypeTest::TearDownTestCase() {} void WindowModeSupportTypeTest::SetUp() { fullAppInfo_1_ = { - .name = "FullWindow", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentId = INVALID_WINDOW_ID, + .name = "FullWindow", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .mode = WindowMode::WINDOW_MODE_FULLSCREEN, + .needAvoid = false, + .parentLimit = false, + .parentId = INVALID_WINDOW_ID, }; fullAppInfo_2_ = { - .name = "FullWindow2", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentId = INVALID_WINDOW_ID, + .name = "FullWindow2", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .mode = WindowMode::WINDOW_MODE_FULLSCREEN, + .needAvoid = false, + .parentLimit = false, + .parentId = INVALID_WINDOW_ID, }; } -void WindowModeSupportTypeTest::TearDown() -{ -} +void WindowModeSupportTypeTest::TearDown() {} namespace { /** @@ -132,7 +129,7 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType03, TestSize.Level1) return; } window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | - WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetWindowMode()); @@ -164,8 +161,8 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType04, TestSize.Level1) return; } window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); ASSERT_NE(WMError::WM_OK, window->Show()); ASSERT_EQ(WMError::WM_OK, window->Hide()); window->Destroy(); @@ -194,8 +191,7 @@ HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType05, TestSize.Level1) ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window1->GetWindowMode()); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window2->GetWindowMode()); - } - else { + } else { ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window2->GetWindowMode()); } window1->Destroy(); diff --git a/test/systemtest/wms/window_move_drag_test.cpp b/test/systemtest/wms/window_move_drag_test.cpp index eb6d017bb4..14e8587ea6 100755 --- a/test/systemtest/wms/window_move_drag_test.cpp +++ b/test/systemtest/wms/window_move_drag_test.cpp @@ -26,10 +26,10 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowMoveDragTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowMoveDragTest" }; constexpr float POINT_HOTZONE_RATIO = 0.5; constexpr int WAIT_SYANC_MS = 100000; -} +} // namespace using Utils = WindowTestUtils; class WindowMoveDragTest : public testing::Test { public: @@ -39,17 +39,15 @@ public: virtual void TearDown() override; private: - std::shared_ptr CreatePointerEvent(int32_t posX, - int32_t posY, - uint32_t pointerId, - int32_t pointerAction); + std::shared_ptr + CreatePointerEvent(int32_t posX, int32_t posY, uint32_t pointerId, int32_t pointerAction); void DoMoveOrDrag(bool isMove, bool isDrag); static inline std::vector> activeWindows_; static inline uint32_t pointerId_ = 0; static inline int32_t startPointX_ = 0; static inline int32_t startPointY_ = 0; - static inline Rect startPointRect_ = {0, 0, 0, 0}; - static inline Rect expectRect_ = {0, 0, 0, 0}; + static inline Rect startPointRect_ = { 0, 0, 0, 0 }; + static inline Rect expectRect_ = { 0, 0, 0, 0 }; static inline sptr window_ = nullptr; static inline float virtualPixelRatio_ = 0.0; static inline uint32_t hotZone_ = 0; @@ -59,22 +57,23 @@ void WindowMoveDragTest::SetUpTestCase() { startPointX_ = 0; startPointY_ = 0; - startPointRect_ = {0, 0, 0, 0}; - expectRect_ = {0, 0, 0, 0}; + startPointRect_ = { 0, 0, 0, 0 }; + expectRect_ = { 0, 0, 0, 0 }; usleep(WAIT_SYANC_MS); } -void WindowMoveDragTest::TearDownTestCase() -{ -} +void WindowMoveDragTest::TearDownTestCase() {} void WindowMoveDragTest::SetUp() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_NE(display, nullptr); WLOGI("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()}; + (unsigned long long)display->GetId(), + display->GetWidth(), + display->GetHeight(), + display->GetRefreshRate()); + Rect displayRect = { 0, 0, display->GetWidth(), display->GetHeight() }; Utils::InitByDisplayRect(displayRect); virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); @@ -99,10 +98,8 @@ void WindowMoveDragTest::TearDown() usleep(WAIT_SYANC_MS); } -std::shared_ptr WindowMoveDragTest::CreatePointerEvent(int32_t posX, - int32_t posY, - uint32_t pointerId, - int32_t pointerAction) +std::shared_ptr WindowMoveDragTest::CreatePointerEvent(int32_t posX, int32_t posY, + uint32_t pointerId, int32_t pointerAction) { MMI::PointerEvent::PointerItem pointerItem; pointerItem.SetPointerId(pointerId); @@ -189,8 +186,8 @@ HWTEST_F(WindowMoveDragTest, DragWindow03, TestSize.Level1) usleep(WAIT_SYANC_MS); startPointRect_ = window_->GetRect(); startPointX_ = startPointRect_.posX_ - static_cast(hotZone_ * POINT_HOTZONE_RATIO); - startPointY_ = startPointRect_.posY_ + - static_cast(startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO); + startPointY_ = + startPointRect_.posY_ + static_cast(startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO); DoMoveOrDrag(false, true); ASSERT_EQ(WMError::WM_OK, window_->Hide()); @@ -208,8 +205,8 @@ HWTEST_F(WindowMoveDragTest, DragWindow04, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, window_->Show()); usleep(WAIT_SYANC_MS); startPointRect_ = window_->GetRect(); - startPointX_ = startPointRect_.posX_ + - static_cast(startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO); + startPointX_ = + startPointRect_.posX_ + static_cast(startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO); startPointY_ = startPointRect_.posY_ + static_cast(startPointRect_.height_ * POINT_HOTZONE_RATIO); DoMoveOrDrag(false, true); @@ -228,8 +225,8 @@ HWTEST_F(WindowMoveDragTest, DragWindow05, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, window_->Show()); usleep(WAIT_SYANC_MS); startPointRect_ = window_->GetRect(); - startPointX_ = startPointRect_.posX_ + - static_cast(startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO); + startPointX_ = + startPointRect_.posX_ + static_cast(startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO); startPointY_ = startPointRect_.posY_ - static_cast(hotZone_ * POINT_HOTZONE_RATIO); DoMoveOrDrag(false, true); @@ -247,10 +244,10 @@ HWTEST_F(WindowMoveDragTest, DragWindow06, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, window_->Show()); usleep(WAIT_SYANC_MS); startPointRect_ = window_->GetRect(); - startPointX_ = startPointRect_.posX_ + - static_cast(startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO); - startPointY_ = startPointRect_.posY_ + - static_cast(startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO); + startPointX_ = + startPointRect_.posX_ + static_cast(startPointRect_.width_ + hotZone_ * POINT_HOTZONE_RATIO); + startPointY_ = + startPointRect_.posY_ + static_cast(startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO); DoMoveOrDrag(false, true); ASSERT_EQ(WMError::WM_OK, window_->Hide()); @@ -286,8 +283,8 @@ HWTEST_F(WindowMoveDragTest, DragWindow08, TestSize.Level1) usleep(WAIT_SYANC_MS); startPointRect_ = window_->GetRect(); startPointX_ = startPointRect_.posX_ + static_cast(startPointRect_.width_ * POINT_HOTZONE_RATIO); - startPointY_ = startPointRect_.posY_ + - static_cast(startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO); + startPointY_ = + startPointRect_.posY_ + static_cast(startPointRect_.height_ + hotZone_ * POINT_HOTZONE_RATIO); DoMoveOrDrag(false, true); ASSERT_EQ(WMError::WM_OK, window_->Hide()); @@ -306,7 +303,7 @@ HWTEST_F(WindowMoveDragTest, DragWindow09, TestSize.Level1) startPointRect_ = window_->GetRect(); startPointX_ = startPointRect_.posX_ + static_cast(startPointRect_.width_ * POINT_HOTZONE_RATIO); startPointY_ = startPointRect_.posY_ + - static_cast(WINDOW_TITLE_BAR_HEIGHT * POINT_HOTZONE_RATIO * virtualPixelRatio_); + static_cast(WINDOW_TITLE_BAR_HEIGHT * POINT_HOTZONE_RATIO * virtualPixelRatio_); DoMoveOrDrag(false, false); ASSERT_EQ(WMError::WM_OK, window_->Hide()); @@ -329,6 +326,6 @@ HWTEST_F(WindowMoveDragTest, DragWindow10, TestSize.Level1) DoMoveOrDrag(false, false); ASSERT_EQ(WMError::WM_OK, window_->Hide()); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_multi_ability_test.cpp b/test/systemtest/wms/window_multi_ability_test.cpp index 8a7da39318..9376c65059 100644 --- a/test/systemtest/wms/window_multi_ability_test.cpp +++ b/test/systemtest/wms/window_multi_ability_test.cpp @@ -15,8 +15,8 @@ // gtest #include -#include "window_test_utils.h" #include "scene_board_judgement.h" +#include "window_test_utils.h" using namespace testing; using namespace testing::ext; @@ -32,21 +32,13 @@ public: virtual void TearDown() override; }; -void WindowMultiAbilityTest::SetUpTestCase() -{ -} +void WindowMultiAbilityTest::SetUpTestCase() {} -void WindowMultiAbilityTest::TearDownTestCase() -{ -} +void WindowMultiAbilityTest::TearDownTestCase() {} -void WindowMultiAbilityTest::SetUp() -{ -} +void WindowMultiAbilityTest::SetUp() {} -void WindowMultiAbilityTest::TearDown() -{ -} +void WindowMultiAbilityTest::TearDown() {} static void DoSceneResource(sptr windowscene) { @@ -91,7 +83,7 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow01, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, scene3->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene2->GoBackground()); ASSERT_EQ(WMError::WM_OK, scene1->GoBackground()); - }else { + } else { ASSERT_NE(WMError::WM_OK, scene5->GoBackground()); ASSERT_NE(WMError::WM_OK, scene4->GoBackground()); ASSERT_NE(WMError::WM_OK, scene3->GoBackground()); diff --git a/test/systemtest/wms/window_nointeraction_listener_test.cpp b/test/systemtest/wms/window_nointeraction_listener_test.cpp index 302f39855a..6309ef87d2 100644 --- a/test/systemtest/wms/window_nointeraction_listener_test.cpp +++ b/test/systemtest/wms/window_nointeraction_listener_test.cpp @@ -23,13 +23,13 @@ #include #include "display_manager.h" -#include "window_manager.h" -#include "window_test_utils.h" -#include "pointer_event.h" #include "key_event.h" -#include "wm_common.h" +#include "pointer_event.h" +#include "window_manager.h" #include "window_scene_session_impl.h" #include "window_session_impl.h" +#include "window_test_utils.h" +#include "wm_common.h" using namespace testing; using namespace testing::ext; @@ -37,7 +37,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowNoInteractionTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowNoInteractionTest" }; } using Utils = WindowTestUtils; @@ -53,12 +53,12 @@ public: void OnWindowNoInteractionCallback() override; void SetTimeout(int64_t timeout) override; int64_t GetTimeout() const override; - bool isCallbackCalled_ { false }; + bool isCallbackCalled_{ false }; private: std::mutex& mutex_; std::condition_variable& cv_; - int64_t timeout_ { 0 }; // ms + int64_t timeout_{ 0 }; // ms }; void NoInteractionTesterListener::OnWindowNoInteractionCallback() @@ -100,30 +100,23 @@ public: static void WaitForCallback(sptr& listener); }; -void WindowNoInteractionTest::SetUpTestCase() -{ -} +void WindowNoInteractionTest::SetUpTestCase() {} -void WindowNoInteractionTest::TearDownTestCase() -{ -} +void WindowNoInteractionTest::TearDownTestCase() {} -void WindowNoInteractionTest::SetUp() -{ -} +void WindowNoInteractionTest::SetUp() {} -void WindowNoInteractionTest::TearDown() -{ -} +void WindowNoInteractionTest::TearDown() {} void WindowNoInteractionTest::WaitForCallback(sptr& listener) { std::unique_lock lock(mutex_); if (listener->isCallbackCalled_ == false) { auto now = std::chrono::system_clock::now(); - if (!cv_.wait_until(lock, now + std::chrono::milliseconds(NO_INTERACTION_LISTENER_TEST_WATCHER_TIMEOUT), - [&listener]() { return listener->isCallbackCalled_; })) { - WLOGI("wait_until time out"); + if (!cv_.wait_until(lock, + now + std::chrono::milliseconds(NO_INTERACTION_LISTENER_TEST_WATCHER_TIMEOUT), + [&listener]() { return listener->isCallbackCalled_; })) { + WLOGI("wait_until time out"); } } } @@ -144,7 +137,7 @@ HWTEST_F(WindowNoInteractionTest, RegisterUnregisterNormal, TestSize.Level1) sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); - + // unregister listener result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); @@ -208,7 +201,7 @@ HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowShow, TestSize.Level1) WaitForCallback(noInteractionTesterListener); ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); ResetCallbackCalledFLag(noInteractionTesterListener); - + // unregister listener result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); @@ -240,11 +233,11 @@ HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowHide, TestSize.Level1) window->ConsumeKeyEvent(keyEvent); }); t.detach(); - + WaitForCallback(noInteractionTesterListener); ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); ResetCallbackCalledFLag(noInteractionTesterListener); - + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); } @@ -275,11 +268,11 @@ HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowShow, TestSize.Level1) window->ConsumeKeyEvent(keyEvent); }); t.detach(); - + WaitForCallback(noInteractionTesterListener); ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); ResetCallbackCalledFLag(noInteractionTesterListener); - + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); } @@ -314,7 +307,7 @@ HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowHide, TestSize.Level1) WaitForCallback(noInteractionTesterListener); ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); ResetCallbackCalledFLag(noInteractionTesterListener); - + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); } @@ -345,11 +338,11 @@ HWTEST_F(WindowNoInteractionTest, PointerEventDown, TestSize.Level1) window->ConsumePointerEvent(pointerEvent); }); t.detach(); - + WaitForCallback(noInteractionTesterListener); ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); ResetCallbackCalledFLag(noInteractionTesterListener); - + // unregister listener result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); @@ -384,7 +377,7 @@ HWTEST_F(WindowNoInteractionTest, PointerEventUp, TestSize.Level1) WaitForCallback(noInteractionTesterListener); ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); ResetCallbackCalledFLag(noInteractionTesterListener); - + // unregister listener result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); @@ -408,13 +401,12 @@ HWTEST_F(WindowNoInteractionTest, NoInteraction, TestSize.Level1) WaitForCallback(noInteractionTesterListener); ASSERT_EQ(true, noInteractionTesterListener->isCallbackCalled_); ResetCallbackCalledFLag(noInteractionTesterListener); - + // unregister listener result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); ASSERT_EQ(WMError::WM_OK, result); } -} +} // namespace } // namespace Rosen } // namespace OHOS - diff --git a/test/systemtest/wms/window_occupied_area_change_test.cpp b/test/systemtest/wms/window_occupied_area_change_test.cpp index f505e3a300..fce2b0fc0b 100644 --- a/test/systemtest/wms/window_occupied_area_change_test.cpp +++ b/test/systemtest/wms/window_occupied_area_change_test.cpp @@ -16,26 +16,26 @@ // gtest #include #include "display_manager_proxy.h" -#include "wm_common.h" #include "window_test_utils.h" +#include "wm_common.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowOccupiedAreaChangeTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowOccupiedAreaChangeTest" }; } using Utils = WindowTestUtils; -const int WAIT_ASYNC_US = 100000; // 100000us +const int WAIT_ASYNC_US = 100000; // 100000us class TestOccupiedAreaChangeListener : public IOccupiedAreaChangeListener { public: OccupiedAreaType type_ = OccupiedAreaType::TYPE_INPUT; Rect rect_ = { 0, 0, 0, 0 }; void OnSizeChange(const sptr& info, - const std::shared_ptr& rsTransaction = nullptr) override; + const std::shared_ptr& rsTransaction = nullptr) override; }; class WindowOccupiedAreaChangeTest : public testing::Test { @@ -53,10 +53,12 @@ sptr WindowOccupiedAreaChangeTest::testOccupiedA new TestOccupiedAreaChangeListener(); void TestOccupiedAreaChangeListener::OnSizeChange(const sptr& info, - const std::shared_ptr& rsTransaction) + const std::shared_ptr& rsTransaction) { WLOGI("OccupiedAreaChangeInfo: [%{public}u, {%{public}u, %{public}u}]", - info->type_, info->rect_.width_, info->rect_.height_); + info->type_, + info->rect_.width_, + info->rect_.height_); type_ = info->type_; rect_ = info->rect_; } @@ -65,38 +67,37 @@ void WindowOccupiedAreaChangeTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); - WLOGI("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()}; + WLOGI("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); } -void WindowOccupiedAreaChangeTest::TearDownTestCase() -{ -} +void WindowOccupiedAreaChangeTest::TearDownTestCase() {} void WindowOccupiedAreaChangeTest::SetUp() { fullScreenAppInfo_ = { - .name = "FullWindow", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = false, - .parentLimit = false, - .parentId = INVALID_WINDOW_ID, + .name = "FullWindow", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .mode = WindowMode::WINDOW_MODE_FULLSCREEN, + .needAvoid = false, + .parentLimit = false, + .parentId = INVALID_WINDOW_ID, }; imeAppInfo_ = { - .name = "ImeWindow", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, - .mode = WindowMode::WINDOW_MODE_FLOATING, + .name = "ImeWindow", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, + .mode = WindowMode::WINDOW_MODE_FLOATING, }; } -void WindowOccupiedAreaChangeTest::TearDown() -{ -} +void WindowOccupiedAreaChangeTest::TearDown() {} namespace { /** @@ -194,6 +195,6 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest03, TestSize.Leve ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.width_, 0); ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.height_, 0); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_pc_test.cpp b/test/systemtest/wms/window_pc_test.cpp index bb4b365077..e0a309285b 100644 --- a/test/systemtest/wms/window_pc_test.cpp +++ b/test/systemtest/wms/window_pc_test.cpp @@ -72,7 +72,7 @@ HWTEST_F(WindowPCTest, setHandwritingFlag01, TestSize.Level1) window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(WMError::WM_OK, window->SetWindowFlags(static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING))); - + window->Destroy(true, true); } @@ -98,7 +98,7 @@ HWTEST_F(WindowPCTest, setHandwritingFlag02, TestSize.Level1) window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; ASSERT_EQ(WMError::WM_OK, window->SetWindowFlags(static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING))); - + window->Destroy(true, true); } @@ -530,6 +530,6 @@ HWTEST_F(WindowPCTest, SetMainWindowTopmost03, TestSize.Level1) window->Destroy(true, true); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_raisetoapptop_test.cpp b/test/systemtest/wms/window_raisetoapptop_test.cpp index d1ddcedfc0..d0dc266413 100644 --- a/test/systemtest/wms/window_raisetoapptop_test.cpp +++ b/test/systemtest/wms/window_raisetoapptop_test.cpp @@ -16,8 +16,8 @@ // gtest #include #include "common_test_utils.h" -#include "window_test_utils.h" #include "window_impl.h" +#include "window_test_utils.h" #include "wm_common.h" using namespace testing; @@ -35,25 +35,22 @@ public: std::vector> activeWindows_; Utils::TestWindowInfo fullInfo_; + private: static constexpr uint32_t TEST_SLEEP_S = 1; }; -void WindowRaiseToAppTopTest::SetUpTestCase() -{ -} +void WindowRaiseToAppTopTest::SetUpTestCase() {} -void WindowRaiseToAppTopTest::TearDownTestCase() -{ -} +void WindowRaiseToAppTopTest::TearDownTestCase() {} void WindowRaiseToAppTopTest::SetUp() { fullInfo_ = { - .name = "", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .parentId = INVALID_WINDOW_ID, + .name = "", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .parentId = INVALID_WINDOW_ID, }; activeWindows_.clear(); } @@ -74,7 +71,7 @@ namespace { */ HWTEST_F(WindowRaiseToAppTopTest, NormalRaise1, TestSize.Level1) { - fullInfo_.name = "mainWindow.1"; + fullInfo_.name = "mainWindow.1"; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); if (mainWindow == nullptr) { return; @@ -84,18 +81,18 @@ HWTEST_F(WindowRaiseToAppTopTest, NormalRaise1, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "subWindow.1"; + fullInfo_.name = "subWindow.1"; fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - fullInfo_.parentId = mainWindow->GetWindowId(); + fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow1 = Utils::CreateTestWindow(fullInfo_); ASSERT_NE(nullptr, subWindow1); activeWindows_.push_back(subWindow1); ASSERT_EQ(WMError::WM_OK, subWindow1->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "subWindow.2"; + fullInfo_.name = "subWindow.2"; fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - fullInfo_.parentId = mainWindow->GetWindowId(); + fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow2 = Utils::CreateTestWindow(fullInfo_); ASSERT_NE(nullptr, subWindow2); activeWindows_.push_back(subWindow2); @@ -115,7 +112,7 @@ HWTEST_F(WindowRaiseToAppTopTest, NormalRaise1, TestSize.Level1) */ HWTEST_F(WindowRaiseToAppTopTest, RaiseWithDialog1, TestSize.Level1) { - fullInfo_.name = "mainWindow.1"; + fullInfo_.name = "mainWindow.1"; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); if (mainWindow == nullptr) { return; @@ -125,27 +122,27 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWithDialog1, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "subWindow.1"; + fullInfo_.name = "subWindow.1"; fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - fullInfo_.parentId = mainWindow->GetWindowId(); + fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow1 = Utils::CreateTestWindow(fullInfo_); ASSERT_NE(nullptr, subWindow1); activeWindows_.push_back(subWindow1); ASSERT_EQ(WMError::WM_OK, subWindow1->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "subWindow.2"; + fullInfo_.name = "subWindow.2"; fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - fullInfo_.parentId = mainWindow->GetWindowId(); + fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow2 = Utils::CreateTestWindow(fullInfo_); ASSERT_NE(nullptr, subWindow2); activeWindows_.push_back(subWindow2); ASSERT_EQ(WMError::WM_OK, subWindow2->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "dialog.2"; + fullInfo_.name = "dialog.2"; fullInfo_.type = WindowType::WINDOW_TYPE_DIALOG; - fullInfo_.parentId = INVALID_WINDOW_ID; + fullInfo_.parentId = INVALID_WINDOW_ID; sptr dialog = Utils::CreateTestWindow(fullInfo_); ASSERT_NE(nullptr, dialog); activeWindows_.push_back(dialog); @@ -163,7 +160,7 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWithDialog1, TestSize.Level1) */ HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, TestSize.Level1) { - fullInfo_.name = "mainWindow.1"; + fullInfo_.name = "mainWindow.1"; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); if (mainWindow == nullptr) { return; @@ -173,9 +170,9 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "subWindow.1"; + fullInfo_.name = "subWindow.1"; fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - fullInfo_.parentId = mainWindow->GetWindowId(); + fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow1 = Utils::CreateTestWindow(fullInfo_); if (subWindow1 == nullptr) { return; @@ -185,9 +182,9 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, subWindow1->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "subWindow.2"; + fullInfo_.name = "subWindow.2"; fullInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW; - fullInfo_.parentId = mainWindow->GetWindowId(); + fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow2 = Utils::CreateTestWindow(fullInfo_); ASSERT_NE(nullptr, subWindow2); activeWindows_.push_back(subWindow2); @@ -215,7 +212,7 @@ HWTEST_F(WindowRaiseToAppTopTest, RaiseWhenHide, TestSize.Level1) HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, TestSize.Level1) { CommonTestUtils::GuaranteeFloatWindowPermission("window_raisetoapptop_test"); - fullInfo_.name = "mainWindow.1"; + fullInfo_.name = "mainWindow.1"; fullInfo_.type = WindowType::WINDOW_TYPE_FLOAT; sptr mainWindow = Utils::CreateTestWindow(fullInfo_); if (mainWindow == nullptr) { @@ -226,9 +223,9 @@ HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, mainWindow->Show()); sleep(TEST_SLEEP_S); - fullInfo_.name = "subWindow.1"; + fullInfo_.name = "subWindow.1"; fullInfo_.type = WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW; - fullInfo_.parentId = mainWindow->GetWindowId(); + fullInfo_.parentId = mainWindow->GetWindowId(); sptr subWindow1 = Utils::CreateTestWindow(fullInfo_); if (subWindow1 == nullptr) { return; @@ -241,6 +238,6 @@ HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, TestSize.Level1) auto result = subWindow1->RaiseToAppTop(); ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, result); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_recover_test.cpp b/test/systemtest/wms/window_recover_test.cpp index 863ba62ed7..9ec6fcf48d 100644 --- a/test/systemtest/wms/window_recover_test.cpp +++ b/test/systemtest/wms/window_recover_test.cpp @@ -14,17 +14,17 @@ */ // gtest -#include #include -#include "window_test_utils.h" +#include #include "ability_context_impl.h" #include "context_impl.h" #include "iremote_object_mocker.h" #include "mock_session.h" #include "mock_window_adapter.h" -#include "window_session_impl.h" -#include "window_scene_session_impl.h" #include "singleton_mocker.h" +#include "window_scene_session_impl.h" +#include "window_session_impl.h" +#include "window_test_utils.h" using namespace testing; using namespace testing::ext; @@ -98,9 +98,8 @@ HWTEST_F(WindowRecoverTest, RecoverAndReconnectSceneSession, TestSize.Level1) std::shared_ptr surfaceNode = nullptr; sptr property = nullptr; sptr token = nullptr; - EXPECT_CALL(m->Mock(), RecoverAndReconnectSceneSession(_, _, _, _, _, _)).WillOnce(DoAll( - SaveArg<2>(&surfaceNode), SaveArg<4>(&property), SaveArg<5>(&token), Return(WMError::WM_OK) - )); + EXPECT_CALL(m->Mock(), RecoverAndReconnectSceneSession(_, _, _, _, _, _)) + .WillOnce(DoAll(SaveArg<2>(&surfaceNode), SaveArg<4>(&property), SaveArg<5>(&token), Return(WMError::WM_OK))); windowSceneSession->RecoverAndReconnectSceneSession(); ASSERT_EQ(surfaceNode, windowSceneSession->surfaceNode_); ASSERT_EQ(property, windowSceneSession->property_); @@ -142,9 +141,8 @@ HWTEST_F(WindowRecoverTest, RecoverAndConnectSpecificSession, TestSize.Level1) std::shared_ptr surfaceNode = nullptr; sptr property = nullptr; sptr token = nullptr; - EXPECT_CALL(m->Mock(), RecoverAndConnectSpecificSession(_, _, _, _, _, _)).WillOnce(DoAll( - SaveArg<2>(&surfaceNode), SaveArg<3>(&property), SaveArg<5>(&token) - )); + EXPECT_CALL(m->Mock(), RecoverAndConnectSpecificSession(_, _, _, _, _, _)) + .WillOnce(DoAll(SaveArg<2>(&surfaceNode), SaveArg<3>(&property), SaveArg<5>(&token))); windowSceneSession->RecoverAndConnectSpecificSession(); ASSERT_EQ(surfaceNode, windowSceneSession->surfaceNode_); ASSERT_EQ(property, windowSceneSession->property_); diff --git a/test/systemtest/wms/window_rotation_test.cpp b/test/systemtest/wms/window_rotation_test.cpp index df62f5f031..ef58812b25 100644 --- a/test/systemtest/wms/window_rotation_test.cpp +++ b/test/systemtest/wms/window_rotation_test.cpp @@ -21,9 +21,9 @@ #include "display_manager_proxy.h" #include "future.h" #include "screen_manager.h" -#include "window_manager.h" #include "window_accessibility_controller.h" #include "window_impl.h" +#include "window_manager.h" #include "wm_common.h" using namespace testing; @@ -58,57 +58,46 @@ public: Utils::TestWindowInfo fullInfo_; sptr displayListener_; sptr screenListener_; + private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; static constexpr long FUTURE_GET_RESULT_TIMEOUT = 1000; static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void DisplayListener::OnCreate(DisplayId displayId) -{ -} +void DisplayListener::OnCreate(DisplayId displayId) {} -void DisplayListener::OnDestroy(DisplayId displayId) -{ -} +void DisplayListener::OnDestroy(DisplayId displayId) {} void DisplayListener::OnChange(DisplayId displayId) { changeFuture_.SetValue(displayId); } -void ScreenListener::OnConnect(ScreenId screenId) -{ -} +void ScreenListener::OnConnect(ScreenId screenId) {} -void ScreenListener::OnDisconnect(ScreenId screenId) -{ -} +void ScreenListener::OnDisconnect(ScreenId screenId) {} void ScreenListener::OnChange(ScreenId screenId) { changeFuture_.SetValue(screenId); } -void WindowRotationTest::SetUpTestCase() -{ -} +void WindowRotationTest::SetUpTestCase() {} -void WindowRotationTest::TearDownTestCase() -{ -} +void WindowRotationTest::TearDownTestCase() {} void WindowRotationTest::SetUp() { fullInfo_ = { - .name = "", - .rect = Utils::customAppRect_, - .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - .mode = WindowMode::WINDOW_MODE_FULLSCREEN, - .needAvoid = true, - .parentLimit = false, - .showWhenLocked = true, - .parentId = INVALID_WINDOW_ID, + .name = "", + .rect = Utils::customAppRect_, + .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + .mode = WindowMode::WINDOW_MODE_FULLSCREEN, + .needAvoid = true, + .parentLimit = false, + .showWhenLocked = true, + .parentId = INVALID_WINDOW_ID, }; activeWindows_.clear(); @@ -137,7 +126,7 @@ namespace { */ HWTEST_F(WindowRotationTest, WindowRotationTest1, TestSize.Level1) { - fullInfo_.name = "fullscreen.1"; + fullInfo_.name = "fullscreen.1"; fullInfo_.orientation_ = Orientation::UNSPECIFIED; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); if (fullWindow == nullptr) { @@ -173,7 +162,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, TestSize.Level1) */ HWTEST_F(WindowRotationTest, WindowRotationTest2, TestSize.Level1) { - fullInfo_.name = "fullscreen.2"; + fullInfo_.name = "fullscreen.2"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); if (fullWindow == nullptr) { @@ -214,7 +203,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, TestSize.Level1) ASSERT_NE(display, nullptr); auto curDisplayOrientation = display->GetOrientation(); - fullInfo_.name = "fullscreen.3"; + fullInfo_.name = "fullscreen.3"; fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL; fullInfo_.mode = WindowMode::WINDOW_MODE_FLOATING; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); @@ -252,7 +241,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest4, TestSize.Level1) defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL); sleep(SPLIT_TEST_SLEEP_S); - fullInfo_.name = "fullscreen.4"; + fullInfo_.name = "fullscreen.4"; fullInfo_.orientation_ = Orientation::HORIZONTAL; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); if (fullWindow == nullptr) { @@ -295,7 +284,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, TestSize.Level1) defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL); sleep(SPLIT_TEST_SLEEP_S); - fullInfo_.name = "fullscreen.5"; + fullInfo_.name = "fullscreen.5"; fullInfo_.orientation_ = Orientation::HORIZONTAL; const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); if (fullWindow == nullptr) { @@ -329,6 +318,6 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, TestSize.Level1) defaultScreen->SetOrientation(Orientation::UNSPECIFIED); sleep(SPLIT_TEST_SLEEP_S); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_specialwindow_test.cpp b/test/systemtest/wms/window_specialwindow_test.cpp index 86d7476258..23f059e262 100644 --- a/test/systemtest/wms/window_specialwindow_test.cpp +++ b/test/systemtest/wms/window_specialwindow_test.cpp @@ -434,7 +434,7 @@ HWTEST_F(WindowSpecialWindowTest, setWindowMask01, TestSize.Level1) window->hostSession_ = session; std::vector> windowMask; - windowMask = {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}; + windowMask = { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } }; window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(WMError::WM_OK, window->SetWindowMask(windowMask)); window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; @@ -466,7 +466,7 @@ HWTEST_F(WindowSpecialWindowTest, setWindowMask02, TestSize.Level1) window->hostSession_ = session; std::vector> windowMask; - windowMask = {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}; + windowMask = { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } }; window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(WMError::WM_OK, window->SetWindowMask(windowMask)); window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; @@ -498,7 +498,7 @@ HWTEST_F(WindowSpecialWindowTest, setWindowMask03, TestSize.Level1) window->hostSession_ = session; std::vector> windowMask; - windowMask = {{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}; + windowMask = { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } }; window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(WMError::WM_OK, window->SetWindowMask(windowMask)); window->windowSystemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; @@ -509,6 +509,6 @@ HWTEST_F(WindowSpecialWindowTest, setWindowMask03, TestSize.Level1) window->Destroy(true, true); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_split_immersive_test.cpp b/test/systemtest/wms/window_split_immersive_test.cpp index 02be742396..91966de0da 100644 --- a/test/systemtest/wms/window_split_immersive_test.cpp +++ b/test/systemtest/wms/window_split_immersive_test.cpp @@ -43,13 +43,9 @@ private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time }; -void WindowSplitImmersiveTest::SetUpTestCase() -{ -} +void WindowSplitImmersiveTest::SetUpTestCase() {} -void WindowSplitImmersiveTest::TearDownTestCase() -{ -} +void WindowSplitImmersiveTest::TearDownTestCase() {} void WindowSplitImmersiveTest::SetUp() { @@ -124,6 +120,6 @@ HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, priWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_split_test.cpp b/test/systemtest/wms/window_split_test.cpp index 6a66995b69..7191caff17 100644 --- a/test/systemtest/wms/window_split_test.cpp +++ b/test/systemtest/wms/window_split_test.cpp @@ -37,13 +37,9 @@ private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time }; -void WindowSplitTest::SetUpTestCase() -{ -} +void WindowSplitTest::SetUpTestCase() {} -void WindowSplitTest::TearDownTestCase() -{ -} +void WindowSplitTest::TearDownTestCase() {} void WindowSplitTest::SetUp() { @@ -86,7 +82,7 @@ namespace { */ HWTEST_F(WindowSplitTest, SplitWindow01, TestSize.Level1) { - fullInfo_.name = "fullscreen.1"; + fullInfo_.name = "fullscreen.1"; fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; splitInfo_.name = "primary.1"; splitInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; @@ -111,7 +107,6 @@ HWTEST_F(WindowSplitTest, SplitWindow01, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, fullWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetWindowMode()); ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetWindowMode()); @@ -129,7 +124,7 @@ HWTEST_F(WindowSplitTest, SplitWindow01, TestSize.Level1) */ HWTEST_F(WindowSplitTest, SplitWindow02, TestSize.Level1) { - fullInfo_.name = "fullscreen.2"; + fullInfo_.name = "fullscreen.2"; fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; splitInfo_.name = "secondary.2"; splitInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN; @@ -152,7 +147,6 @@ HWTEST_F(WindowSplitTest, SplitWindow02, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, secWindow->Show()); sleep(SPLIT_TEST_SLEEP_S); - ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, secWindow->GetWindowMode()); ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, fullWindow->GetWindowMode()); @@ -170,7 +164,7 @@ HWTEST_F(WindowSplitTest, SplitWindow02, TestSize.Level1) */ HWTEST_F(WindowSplitTest, SplitScreen03, TestSize.Level1) { - fullInfo_.name = "fullscreen.3"; + fullInfo_.name = "fullscreen.3"; fullInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; splitInfo_.name = "primary.3"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; @@ -207,7 +201,7 @@ HWTEST_F(WindowSplitTest, SplitScreen03, TestSize.Level1) */ HWTEST_F(WindowSplitTest, SplitScreen04, TestSize.Level1) { - fullInfo_.name = "fullscreen.4"; + fullInfo_.name = "fullscreen.4"; splitInfo_.name = "secondary.4"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; @@ -236,6 +230,6 @@ HWTEST_F(WindowSplitTest, SplitScreen04, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, secWindow->Hide()); sleep(SPLIT_TEST_SLEEP_S); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_status_change_test.cpp b/test/systemtest/wms/window_status_change_test.cpp index e595e41ed6..d7716fef52 100644 --- a/test/systemtest/wms/window_status_change_test.cpp +++ b/test/systemtest/wms/window_status_change_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -//gtest +// gtest #include #include "ability_context_impl.h" @@ -61,7 +61,7 @@ HWTEST_F(WindowStatusChangeTest, ChangeWindowStatus01, TestSize.Level1) option->SetWindowName("Window1_1"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - + sptr window = sptr::MakeSptr(option); SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; @@ -86,7 +86,7 @@ HWTEST_F(WindowStatusChangeTest, ChangeWindowStatus01, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, window->Maximize(MaximizePresentation::EXIT_IMMERSIVE)); ASSERT_EQ(false, window->GetImmersiveModeEnabledState()); - + window->Destroy(true, true); } @@ -321,7 +321,7 @@ HWTEST_F(WindowStatusChangeTest, ChangeWindowStatus06, TestSize.Level1) window->Destroy(true, true); } -} +} // namespace } // namespace Rosen -} // namespace OHOSgit \ No newline at end of file +} // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_subwindow_test.cpp b/test/systemtest/wms/window_subwindow_test.cpp index 23cd6c2b55..cb111dfac0 100644 --- a/test/systemtest/wms/window_subwindow_test.cpp +++ b/test/systemtest/wms/window_subwindow_test.cpp @@ -14,8 +14,8 @@ */ // gtest -#include #include +#include #include "window.h" #include "window_option.h" #include "window_scene.h" @@ -34,21 +34,13 @@ public: virtual void TearDown() override; }; -void WindowSubWindowTest::SetUpTestCase() -{ -} +void WindowSubWindowTest::SetUpTestCase() {} -void WindowSubWindowTest::TearDownTestCase() -{ -} +void WindowSubWindowTest::TearDownTestCase() {} -void WindowSubWindowTest::SetUp() -{ -} +void WindowSubWindowTest::SetUp() {} -void WindowSubWindowTest::TearDown() -{ -} +void WindowSubWindowTest::TearDown() {} static sptr CreateWindowScene() { @@ -84,7 +76,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow01, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); if (subWindow == nullptr) { @@ -112,7 +104,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow02, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); if (subWindow == nullptr) { @@ -140,7 +132,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow03, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 2000, 100, 200}; + struct Rect rect = { 0, 2000, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags); if (subWindow == nullptr) { @@ -168,7 +160,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow04, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 2000, 3000, 2000}; + struct Rect rect = { 0, 2000, 3000, 2000 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags); if (subWindow == nullptr) { @@ -196,7 +188,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow05, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_MEDIA, rect, flags); if (subWindow == nullptr) { @@ -230,7 +222,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow06, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); if (subWindow0 == nullptr) { return; @@ -263,7 +255,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow07, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); if (subWindow == nullptr) { @@ -291,7 +283,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow08, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); if (subWindow == nullptr) { @@ -311,7 +303,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow09, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); if (subWindow == nullptr) { @@ -341,7 +333,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow10, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); sptr subWindow = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); if (subWindow == nullptr) { @@ -369,7 +361,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow11, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); if (subWindow0 == nullptr) { return; @@ -434,7 +426,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow12, TestSize.Level1) { sptr scene = CreateWindowScene(); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0"); sptr subWindow1 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0"); if (subWindow0 == nullptr) { @@ -469,7 +461,7 @@ HWTEST_F(WindowSubWindowTest, SubWindow13, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); } - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; sptr subWindow0 = CreateSubWindow(scene, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub1"); if (subWindow0 == nullptr) { return; diff --git a/test/systemtest/wms/window_system_toast_test.cpp b/test/systemtest/wms/window_system_toast_test.cpp index d3e4c6d408..dd2bb51461 100644 --- a/test/systemtest/wms/window_system_toast_test.cpp +++ b/test/systemtest/wms/window_system_toast_test.cpp @@ -38,7 +38,7 @@ public: void TearDown() override; static inline float virtualPixelRatio_ = 1.0; - static inline Rect displayRect_ {0, 0, 0, 0}; + static inline Rect displayRect_{ 0, 0, 0, 0 }; static inline std::shared_ptr abilityContext_ = nullptr; }; @@ -52,17 +52,11 @@ void WindowSystemToastWindowTest::SetUpTestCase() virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0); } -void WindowSystemToastWindowTest::TearDownTestCase() -{ -} +void WindowSystemToastWindowTest::TearDownTestCase() {} -void WindowSystemToastWindowTest::SetUp() -{ -} +void WindowSystemToastWindowTest::SetUp() {} -void WindowSystemToastWindowTest::TearDown() -{ -} +void WindowSystemToastWindowTest::TearDown() {} static sptr CreateWindowScene() { @@ -89,7 +83,7 @@ static sptr CreateSystemToastWindow(WindowType type, Rect rect, std::str static inline Rect GetRectWithVpr(int32_t x, int32_t y, uint32_t w, uint32_t h) { auto vpr = WindowSystemToastWindowTest::virtualPixelRatio_; - return {x, y, static_cast(w * vpr), static_cast(h * vpr)}; + return { x, y, static_cast(w * vpr), static_cast(h * vpr) }; } /** @@ -123,7 +117,7 @@ HWTEST_F(WindowSystemToastWindowTest, SystemToastWindow01, TestSize.Level1) } ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); - } +} /** * @tc.name: SystemToastWindow02 @@ -227,5 +221,5 @@ HWTEST_F(WindowSystemToastWindowTest, SystemToastWindow04, TestSize.Level1) ASSERT_EQ(false, fltWin->GetWindowState() == WindowState::STATE_SHOWN); ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); } -} -} \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_systemsubwindow_test.cpp b/test/systemtest/wms/window_systemsubwindow_test.cpp index a75ed07e07..752bf4d37d 100644 --- a/test/systemtest/wms/window_systemsubwindow_test.cpp +++ b/test/systemtest/wms/window_systemsubwindow_test.cpp @@ -14,13 +14,13 @@ */ // gtest -#include #include +#include #include "common_test_utils.h" -#include "window_test_utils.h" #include "window.h" #include "window_option.h" #include "window_scene.h" +#include "window_test_utils.h" #include "wm_common.h" using namespace testing; @@ -62,21 +62,13 @@ public: }; }; -void WindowSystemSubWindowTest::SetUpTestCase() -{ -} +void WindowSystemSubWindowTest::SetUpTestCase() {} -void WindowSystemSubWindowTest::TearDownTestCase() -{ -} +void WindowSystemSubWindowTest::TearDownTestCase() {} -void WindowSystemSubWindowTest::SetUp() -{ -} +void WindowSystemSubWindowTest::SetUp() {} -void WindowSystemSubWindowTest::TearDown() -{ -} +void WindowSystemSubWindowTest::TearDown() {} static sptr CreateBaseWindow(WindowType type, struct Rect rect, uint32_t flags) { @@ -92,8 +84,11 @@ static sptr CreateBaseWindow(WindowType type, struct Rect rect, uint32_t return window; } -static sptr CreateAppSubWindow(sptr parentWindow, WindowType type, struct Rect rect, - uint32_t flags, std::string name = "") +static sptr CreateAppSubWindow(sptr parentWindow, + WindowType type, + struct Rect rect, + uint32_t flags, + std::string name = "") { sptr subOp = new WindowOption(); subOp->SetWindowType(type); @@ -136,13 +131,13 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow01, TestSize.Level1) WindowType::WINDOW_TYPE_DESKTOP, }; for (auto itor = windowTypes.begin(); itor != windowTypes.end(); itor++) { - struct Rect baseRect = {0, 0, 100, 200}; + struct Rect baseRect = { 0, 0, 100, 200 }; uint32_t baseFlags = 0; sptr baseWindow = CreateBaseWindow(static_cast(*itor), baseRect, baseFlags); if (baseWindow == nullptr) { continue; } - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSystemSubWindow(baseWindow, rect, flags); if (subWindow == nullptr) { @@ -173,14 +168,14 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow02, TestSize.Level1) if (static_cast(*itor) == WindowType::WINDOW_TYPE_FLOAT) { CommonTestUtils::GuaranteeFloatWindowPermission("wms_window_systemsubwindow_test"); } - struct Rect baseRect = {0, 0, 100, 200}; + struct Rect baseRect = { 0, 0, 100, 200 }; uint32_t baseFlags = 0; sptr baseWindow = CreateBaseWindow(static_cast(*itor), baseRect, baseFlags); if (baseWindow == nullptr) { continue; } - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSystemSubWindow(baseWindow, rect, flags); if (subWindow == nullptr) { @@ -209,7 +204,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow03, TestSize.Level1) std::vector windowTypes = { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; for (auto itor = windowTypes.begin(); itor != windowTypes.end(); itor++) { - struct Rect baseRect = {0, 0, 100, 200}; + struct Rect baseRect = { 0, 0, 100, 200 }; uint32_t baseFlags = 0; sptr baseWindow = CreateBaseWindow(static_cast(*itor), baseRect, baseFlags); if (baseWindow == nullptr) { @@ -217,7 +212,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow03, TestSize.Level1) } ASSERT_NE(nullptr, baseWindow); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSystemSubWindow(baseWindow, rect, flags); if (subWindow == nullptr) { @@ -240,7 +235,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow04, TestSize.Level1) WindowType::WINDOW_TYPE_APP_COMPONENT, }; for (auto itor = windowTypes.begin(); itor != windowTypes.end(); itor++) { - struct Rect baseRect = {0, 0, 100, 200}; + struct Rect baseRect = { 0, 0, 100, 200 }; uint32_t baseFlags = 0; sptr baseWindow = CreateBaseWindow(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, baseRect, baseFlags); if (baseWindow == nullptr) { @@ -254,7 +249,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow04, TestSize.Level1) } ASSERT_NE(nullptr, appSubWindow); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSystemSubWindow(appSubWindow, rect, flags); ASSERT_EQ(nullptr, subWindow); @@ -270,7 +265,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow04, TestSize.Level1) */ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow05, TestSize.Level1) { - struct Rect baseRect = {0, 0, 100, 200}; + struct Rect baseRect = { 0, 0, 100, 200 }; uint32_t baseFlags = 0; sptr baseWindow = CreateBaseWindow(WindowType::WINDOW_TYPE_DOCK_SLICE, baseRect, baseFlags); if (baseWindow == nullptr) { @@ -284,7 +279,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow05, TestSize.Level1) } ASSERT_NE(nullptr, systemSubWindow); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSystemSubWindow(systemSubWindow, rect, flags); if (subWindow == nullptr) { @@ -309,7 +304,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow05, TestSize.Level1) */ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow06, TestSize.Level1) { - struct Rect baseRect = {0, 0, 100, 200}; + struct Rect baseRect = { 0, 0, 100, 200 }; uint32_t baseFlags = 0; sptr baseWindow = CreateBaseWindow(WindowType::WINDOW_TYPE_DOCK_SLICE, baseRect, baseFlags); if (baseWindow == nullptr) { @@ -317,7 +312,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow06, TestSize.Level1) } ASSERT_NE(nullptr, baseWindow); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSystemSubWindow(baseWindow, rect, flags); if (subWindow == nullptr) { @@ -351,7 +346,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow06, TestSize.Level1) */ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow07, TestSize.Level1) { - struct Rect baseRect = {0, 0, 100, 200}; + struct Rect baseRect = { 0, 0, 100, 200 }; uint32_t baseFlags = 0; sptr baseWindow = CreateBaseWindow(WindowType::WINDOW_TYPE_DIALOG, baseRect, baseFlags); if (baseWindow == nullptr) { @@ -359,7 +354,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow07, TestSize.Level1) } ASSERT_NE(nullptr, baseWindow); - struct Rect rect = {0, 0, 100, 200}; + struct Rect rect = { 0, 0, 100, 200 }; uint32_t flags = 0; sptr subWindow = CreateSystemSubWindow(baseWindow, rect, flags); if (subWindow == nullptr) { diff --git a/test/systemtest/wms/window_test_utils.cpp b/test/systemtest/wms/window_test_utils.cpp index 220f786892..8abd12cda6 100755 --- a/test/systemtest/wms/window_test_utils.cpp +++ b/test/systemtest/wms/window_test_utils.cpp @@ -13,32 +13,32 @@ * limitations under the License. */ -#include "display_manager_proxy.h" #include "window_test_utils.h" #include +#include "display_manager_proxy.h" #include "window_helper.h" -#include "wm_common_inner.h" #include "wm_common.h" +#include "wm_common_inner.h" namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowTestUtils"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowTestUtils" }; constexpr uint32_t EDGE_INTERVAL = 48; constexpr uint32_t MID_INTERVAL = 24; -} - -Rect WindowTestUtils::displayRect_ = {0, 0, 0, 0}; -Rect WindowTestUtils::statusBarRect_ = {0, 0, 0, 0}; -Rect WindowTestUtils::naviBarRect_ = {0, 0, 0, 0}; -Rect WindowTestUtils::customAppRect_ = {0, 0, 0, 0}; -Rect WindowTestUtils::limitDisplayRect_ = {0, 0, 0, 0}; -Rect WindowTestUtils::dockWindowRect_ = {0, 0, 0, 0}; -SplitRects WindowTestUtils::splitRects_ = { - .primaryRect = {0, 0, 0, 0}, - .secondaryRect = {0, 0, 0, 0}, - .dividerRect = {0, 0, 0, 0}, +} // namespace + +Rect WindowTestUtils::displayRect_ = { 0, 0, 0, 0 }; +Rect WindowTestUtils::statusBarRect_ = { 0, 0, 0, 0 }; +Rect WindowTestUtils::naviBarRect_ = { 0, 0, 0, 0 }; +Rect WindowTestUtils::customAppRect_ = { 0, 0, 0, 0 }; +Rect WindowTestUtils::limitDisplayRect_ = { 0, 0, 0, 0 }; +Rect WindowTestUtils::dockWindowRect_ = { 0, 0, 0, 0 }; +SplitRects WindowTestUtils::splitRects_ = { + .primaryRect = { 0, 0, 0, 0 }, + .secondaryRect = { 0, 0, 0, 0 }, + .dividerRect = { 0, 0, 0, 0 }, }; -Rect WindowTestUtils::singleTileRect_ = {0, 0, 0, 0}; +Rect WindowTestUtils::singleTileRect_ = { 0, 0, 0, 0 }; std::vector WindowTestUtils::doubleTileRects_ = std::vector(2); std::vector WindowTestUtils::tripleTileRects_ = std::vector(3); AvoidArea WindowTestUtils::systemAvoidArea_ = {}; @@ -139,19 +139,19 @@ Rect WindowTestUtils::GetDefaultFloatingRect(const sptr& window, bool av UpdateSplitRects(window); } constexpr uint32_t half = 2; - constexpr float ratio = DEFAULT_ASPECT_RATIO; // 0.67: default height/width ratio + constexpr float ratio = DEFAULT_ASPECT_RATIO; // 0.67: default height/width ratio float vpr = GetVirtualPixelRatio(0); /* * Calculate default width and height, if width or height is * smaller than minWidth or minHeight, use the minimum limits */ - uint32_t defaultW = std::max(static_cast(displayRect_.width_ * ratio), - static_cast(MIN_FLOATING_WIDTH * vpr)); - uint32_t defaultH = std::max(static_cast(displayRect_.height_ * ratio), - static_cast(MIN_FLOATING_HEIGHT * vpr)); + uint32_t defaultW = + std::max(static_cast(displayRect_.width_ * ratio), static_cast(MIN_FLOATING_WIDTH * vpr)); + uint32_t defaultH = + std::max(static_cast(displayRect_.height_ * ratio), static_cast(MIN_FLOATING_HEIGHT * vpr)); // calculate default x and y - Rect resRect = {0, 0, defaultW, defaultH}; + Rect resRect = { 0, 0, defaultW, defaultH }; if (defaultW <= limitDisplayRect_.width_ && defaultH <= limitDisplayRect_.height_) { resRect.posX_ = limitDisplayRect_.posX_ + static_cast((limitDisplayRect_.width_ - defaultW) / half); resRect.posY_ = limitDisplayRect_.posY_ + static_cast((limitDisplayRect_.height_ - defaultH) / half); @@ -168,7 +168,7 @@ Rect WindowTestUtils::CalcLimitedRect(const Rect& rect, float virtualPixelRatio) uint32_t minFloatingH = static_cast(MIN_FLOATING_HEIGHT * virtualPixelRatio); Rect resRect = { std::min(std::max(rect.posX_, maxPosRemain - static_cast(rect.width_)), - static_cast(displayRect_.width_) - maxPosRemain), + static_cast(displayRect_.width_) - maxPosRemain), std::min(std::max(rect.posY_, maxPosRemain), static_cast(displayRect_.height_) - maxPosRemain), std::min(std::max(minFloatingW, rect.width_), maxLimitLen), std::min(std::max(minFloatingH, rect.height_), maxLimitLen), @@ -211,15 +211,15 @@ void WindowTestUtils::InitByDisplayRect(const Rect& displayRect) if (displayRect_.width_ < displayRect_.height_) { isVerticalDisplay_ = true; } - statusBarRect_ = {0, 0, displayRect_.width_, displayRect_.height_ * barRatio}; - naviBarRect_ = {0, displayRect_.height_ * (1 - barRatio), displayRect_.width_, displayRect_.height_ * barRatio}; - dockWindowRect_ = {0, displayRect_.height_ * (1 - barRatio), displayRect_.width_, displayRect_.height_ * barRatio}; - customAppRect_ = { - displayRect_.width_ * spaceRation, - displayRect_.height_ * spaceRation, - displayRect_.width_ * DEFAULT_ASPECT_RATIO, - displayRect_.height_ * DEFAULT_ASPECT_RATIO + statusBarRect_ = { 0, 0, displayRect_.width_, displayRect_.height_ * barRatio }; + naviBarRect_ = { 0, displayRect_.height_ * (1 - barRatio), displayRect_.width_, displayRect_.height_ * barRatio }; + dockWindowRect_ = { + 0, displayRect_.height_ * (1 - barRatio), displayRect_.width_, displayRect_.height_ * barRatio }; + customAppRect_ = { displayRect_.width_ * spaceRation, + displayRect_.height_ * spaceRation, + displayRect_.width_ * DEFAULT_ASPECT_RATIO, + displayRect_.height_ * DEFAULT_ASPECT_RATIO }; } std::shared_ptr WindowTestUtils::CreatePointerEvent(int32_t posX, int32_t posY, uint32_t pointerId, @@ -255,7 +255,7 @@ void WindowTestUtils::InitTileWindowRects(const sptr& window, bool avoid { float virtualPixelRatio = GetVirtualPixelRatio(0); uint32_t edgeInterval = static_cast(EDGE_INTERVAL * virtualPixelRatio); // 48 is edge interval - uint32_t midInterval = static_cast(MID_INTERVAL * virtualPixelRatio); // 24 is mid interval + uint32_t midInterval = static_cast(MID_INTERVAL * virtualPixelRatio); // 24 is mid interval constexpr float ratio = DEFAULT_ASPECT_RATIO; constexpr int half = 2; limitDisplayRect_ = displayRect_; @@ -276,14 +276,14 @@ void WindowTestUtils::InitTileWindowRects(const sptr& window, bool avoid x = edgeInterval; w = (limitDisplayRect_.width_ - edgeInterval * half - midInterval) / half; // calc doubleRect - doubleTileRects_[0] = {x, y, w, h}; - doubleTileRects_[1] = {x + w + midInterval, y, w, h}; + doubleTileRects_[0] = { x, y, w, h }; + doubleTileRects_[1] = { x + w + midInterval, y, w, h }; WLOGI("doubleRects_: %{public}d %{public}d %{public}d %{public}d", x, y, w, h); // calc tripleRect w = (limitDisplayRect_.width_ - edgeInterval * half - midInterval * half) / 3; // 3 is triple rects num - tripleTileRects_[0] = {x, y, w, h}; - tripleTileRects_[1] = {x + w + midInterval, y, w, h}; - tripleTileRects_[2] = {x + w * half + midInterval * half, y, w, h}; // 2 is third index + tripleTileRects_[0] = { x, y, w, h }; + tripleTileRects_[1] = { x + w + midInterval, y, w, h }; + tripleTileRects_[2] = { x + w * half + midInterval * half, y, w, h }; // 2 is third index WLOGI("tripleRects_: %{public}d %{public}d %{public}d %{public}d", x, y, w, h); } @@ -293,9 +293,17 @@ bool WindowTestUtils::RectEqualTo(const sptr& window, const Rect& r) Rect l = window->GetRect(); bool res = ((l.posX_ == r.posX_) && (l.posY_ == r.posY_) && (l.width_ == r.width_) && (l.height_ == r.height_)); if (!res) { - WLOGFE("GetLayoutRect: %{public}d %{public}d %{public}d %{public}d, " \ - "Expect: %{public}d %{public}d %{public}d %{public}d", l.posX_, l.posY_, l.width_, l.height_, - r.posX_, r.posY_, r.width_, r.height_); + WLOGFE( + "GetLayoutRect: %{public}d %{public}d %{public}d %{public}d, " + "Expect: %{public}d %{public}d %{public}d %{public}d", + l.posX_, + l.posY_, + l.width_, + l.height_, + r.posX_, + r.posY_, + r.width_, + r.height_); } return res; } @@ -304,9 +312,17 @@ bool WindowTestUtils::RectEqualToRect(const Rect& l, const Rect& r) { bool res = ((l.posX_ == r.posX_) && (l.posY_ == r.posY_) && (l.width_ == r.width_) && (l.height_ == r.height_)); if (!res) { - WLOGFE("GetLayoutRect: %{public}d %{public}d %{public}d %{public}d, " \ - "Expect: %{public}d %{public}d %{public}d %{public}d", l.posX_, l.posY_, l.width_, l.height_, - r.posX_, r.posY_, r.width_, r.height_); + WLOGFE( + "GetLayoutRect: %{public}d %{public}d %{public}d %{public}d, " + "Expect: %{public}d %{public}d %{public}d %{public}d", + l.posX_, + l.posY_, + l.width_, + l.height_, + r.posX_, + r.posY_, + r.width_, + r.height_); } return res; } @@ -319,8 +335,9 @@ AvoidPosType WindowTestUtils::GetAvoidPosType(const Rect& rect) return AvoidPosType::AVOID_POS_UNKNOWN; } auto displayInfo = display->GetDisplayInfo(); - Rect displayRect = {displayInfo->GetOffsetX(), displayInfo->GetOffsetY(), displayInfo->GetWidth(), - displayInfo->GetHeight()}; + Rect displayRect = { + displayInfo->GetOffsetX(), displayInfo->GetOffsetY(), displayInfo->GetWidth(), displayInfo->GetHeight() + }; return WindowHelper::GetAvoidPosType(rect, displayRect); } @@ -331,10 +348,13 @@ bool WindowTestUtils::InitSplitRects() WLOGFE("GetDefaultDisplay: failed!"); return false; } - WLOGI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", - display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); + WLOGI("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()}; + Rect displayRect = { 0, 0, display->GetWidth(), display->GetHeight() }; displayRect_ = displayRect; limitDisplayRect_ = displayRect; @@ -345,10 +365,12 @@ bool WindowTestUtils::InitSplitRects() isVerticalDisplay_ = true; } if (isVerticalDisplay_) { - splitRects_.dividerRect = { 0, - static_cast((displayRect_.height_ - dividerWidth) * DEFAULT_SPLIT_RATIO), - displayRect_.width_, - dividerWidth, }; + splitRects_.dividerRect = { + 0, + static_cast((displayRect_.height_ - dividerWidth) * DEFAULT_SPLIT_RATIO), + displayRect_.width_, + dividerWidth, + }; } else { splitRects_.dividerRect = { static_cast((displayRect_.width_ - dividerWidth) * DEFAULT_SPLIT_RATIO), 0, @@ -368,11 +390,13 @@ void WindowTestUtils::UpdateSplitRects(const sptr& window) testUtils->UpdateLimitDisplayRect(testUtils->avoidArea_.bottomRect_); if (isVerticalDisplay_) { - splitRects_.dividerRect.posY_ = limitDisplayRect_.posY_ + + splitRects_.dividerRect.posY_ = + limitDisplayRect_.posY_ + static_cast((limitDisplayRect_.height_ - splitRects_.dividerRect.height_) * DEFAULT_SPLIT_RATIO); testUtils->UpdateLimitSplitRects(splitRects_.dividerRect.posY_); } else { - splitRects_.dividerRect.posX_ = limitDisplayRect_.posX_ + + splitRects_.dividerRect.posX_ = + limitDisplayRect_.posX_ + static_cast((limitDisplayRect_.width_ - splitRects_.dividerRect.width_) * DEFAULT_SPLIT_RATIO); testUtils->UpdateLimitSplitRects(splitRects_.dividerRect.posX_); } @@ -380,8 +404,7 @@ void WindowTestUtils::UpdateSplitRects(const sptr& window) void WindowTestUtils::UpdateLimitDisplayRect(const Rect& avoidRect) { - if (((avoidRect.posX_ == 0) && (avoidRect.posY_ == 0) && - (avoidRect.width_ == 0) && (avoidRect.height_ == 0))) { + if (((avoidRect.posX_ == 0) && (avoidRect.posY_ == 0) && (avoidRect.width_ == 0) && (avoidRect.height_ == 0))) { return; } auto avoidPosType = GetAvoidPosType(avoidRect); @@ -449,30 +472,30 @@ void WindowTestUtils::UpdateLimitSplitRect(Rect& limitSplitRect) Rect curLimitRect = limitSplitRect; limitSplitRect.posX_ = std::max(limitDisplayRect_.posX_, curLimitRect.posX_); limitSplitRect.posY_ = std::max(limitDisplayRect_.posY_, curLimitRect.posY_); - limitSplitRect.width_ = std::min(limitDisplayRect_.posX_ + limitDisplayRect_.width_, - curLimitRect.posX_ + curLimitRect.width_) - - limitSplitRect.posX_; - limitSplitRect.height_ = std::min(limitDisplayRect_.posY_ + limitDisplayRect_.height_, - curLimitRect.posY_ + curLimitRect.height_) - - limitSplitRect.posY_; + limitSplitRect.width_ = + std::min(limitDisplayRect_.posX_ + limitDisplayRect_.width_, curLimitRect.posX_ + curLimitRect.width_) - + limitSplitRect.posX_; + limitSplitRect.height_ = + std::min(limitDisplayRect_.posY_ + limitDisplayRect_.height_, curLimitRect.posY_ + curLimitRect.height_) - + limitSplitRect.posY_; } float WindowTestUtils::GetVirtualPixelRatio(DisplayId displayId) { auto display = DisplayManager::GetInstance().GetDisplayById(displayId); if (display == nullptr) { - WLOGFE("GetVirtualPixel fail. Get display fail. displayId:%{public}" PRIu64", use Default vpr:1.0", displayId); - return 1.0; // Use DefaultVPR 1.0 + WLOGFE("GetVirtualPixel fail. Get display fail. displayId:%{public}" PRIu64 ", use Default vpr:1.0", displayId); + return 1.0; // Use DefaultVPR 1.0 } float virtualPixelRatio = display->GetVirtualPixelRatio(); if (virtualPixelRatio == 0.0) { - WLOGFE("GetVirtualPixel fail. vpr is 0.0. displayId:%{public}" PRIu64", use Default vpr:1.0", displayId); - return 1.0; // Use DefaultVPR 1.0 + WLOGFE("GetVirtualPixel fail. vpr is 0.0. displayId:%{public}" PRIu64 ", use Default vpr:1.0", displayId); + return 1.0; // Use DefaultVPR 1.0 } - WLOGI("GetVirtualPixel success. displayId:%{public}" PRIu64", vpr:%{public}f", displayId, virtualPixelRatio); + WLOGI("GetVirtualPixel success. displayId:%{public}" PRIu64 ", vpr:%{public}f", displayId, virtualPixelRatio); return virtualPixelRatio; } -} // namespace ROSEN +} // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_test_utils.h b/test/systemtest/wms/window_test_utils.h index 3431bda5cb..707701b81e 100644 --- a/test/systemtest/wms/window_test_utils.h +++ b/test/systemtest/wms/window_test_utils.h @@ -16,8 +16,8 @@ #ifndef FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H #define FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H -#include "pointer_event.h" #include "display_manager.h" +#include "pointer_event.h" #include "window.h" #include "window_layout_policy.h" #include "window_option.h" @@ -41,11 +41,11 @@ public: WindowMode mode; bool needAvoid; bool parentLimit; - bool forbidSplitMove {false}; + bool forbidSplitMove{ false }; bool showWhenLocked; uint32_t parentId; - bool focusable_ { true }; - Orientation orientation_ { Orientation::UNSPECIFIED }; + bool focusable_{ true }; + Orientation orientation_{ Orientation::UNSPECIFIED }; }; static Rect displayRect_; static Rect limitDisplayRect_; @@ -88,6 +88,6 @@ private: static AvoidPosType GetAvoidPosType(const Rect& rect); AvoidArea avoidArea_; }; -} // namespace ROSEN +} // namespace Rosen } // namespace OHOS #endif // FRAMEWORKS_WM_TEST_ST_WINDOW_TEST_UTILS_H diff --git a/test/systemtest/wms/window_touch_outside_test.cpp b/test/systemtest/wms/window_touch_outside_test.cpp index f4cc2711ff..9939be2fb9 100644 --- a/test/systemtest/wms/window_touch_outside_test.cpp +++ b/test/systemtest/wms/window_touch_outside_test.cpp @@ -17,9 +17,9 @@ #include #include "singleton_container.h" -#include "wm_common.h" #include "window_adapter.h" #include "window_test_utils.h" +#include "wm_common.h" using namespace testing; using namespace testing::ext; @@ -27,7 +27,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { using Utils = WindowTestUtils; -const int WAIT_CALLBACK_US = 10000; // 10000 us +const int WAIT_CALLBACK_US = 10000; // 10000 us class WindowTouchOutsideTestListener : public ITouchOutsideListener { public: @@ -35,7 +35,7 @@ public: { isTouchOutside_ = true; } - mutable bool isTouchOutside_ { false }; + mutable bool isTouchOutside_{ false }; }; class WindowTouchOutsideTest : public testing::Test { @@ -52,14 +52,12 @@ public: Utils::TestWindowInfo thirdWindowInfo_; }; -sptr WindowTouchOutsideTest::windowlistener1_ = - new WindowTouchOutsideTestListener(); -sptr WindowTouchOutsideTest::windowlistener2_ = - new WindowTouchOutsideTestListener(); +sptr WindowTouchOutsideTest::windowlistener1_ = new WindowTouchOutsideTestListener(); +sptr WindowTouchOutsideTest::windowlistener2_ = new WindowTouchOutsideTestListener(); void WindowTouchOutsideTest::SetUp() { - firstWindowInfo_ = { + firstWindowInfo_ = { .name = "firstWindow", .rect = { 100, 100, 200, 200 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, @@ -96,13 +94,9 @@ void WindowTouchOutsideTest::TearDown() windowlistener2_->isTouchOutside_ = false; } -void WindowTouchOutsideTest::SetUpTestCase() -{ -} +void WindowTouchOutsideTest::SetUpTestCase() {} -void WindowTouchOutsideTest::TearDownTestCase() -{ -} +void WindowTouchOutsideTest::TearDownTestCase() {} namespace { /** @@ -112,7 +106,7 @@ namespace { */ HWTEST_F(WindowTouchOutsideTest, onTouchInside, TestSize.Level1) { - const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); + const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); if (firstWindow == nullptr) { return; } @@ -131,12 +125,12 @@ HWTEST_F(WindowTouchOutsideTest, onTouchInside, TestSize.Level1) */ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, TestSize.Level1) { - const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); + const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); if (firstWindow == nullptr) { return; } firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); + const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); firstWindow->Show(); secondWindow->Show(); @@ -154,12 +148,12 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, TestSize.Level1) */ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, TestSize.Level1) { - const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); + const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); if (firstWindow == nullptr) { return; } firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); + const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); secondWindow->Show(); SingletonContainer::Get().ProcessPointDown(secondWindow->GetWindowId()); @@ -176,19 +170,19 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, TestSize.Level1) */ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, TestSize.Level1) { - const sptr &firstWindow = Utils::CreateTestWindow(firstWindowInfo_); + const sptr& firstWindow = Utils::CreateTestWindow(firstWindowInfo_); if (firstWindow == nullptr) { return; } firstWindow->RegisterTouchOutsideListener(windowlistener1_); - const sptr &secondWindow = Utils::CreateTestWindow(secondWindowInfo_); + const sptr& secondWindow = Utils::CreateTestWindow(secondWindowInfo_); ASSERT_NE(nullptr, secondWindow); firstWindow->RegisterTouchOutsideListener(windowlistener2_); firstWindow->Show(); secondWindow->Show(); - const sptr &thirdWindow = Utils::CreateTestWindow(thirdWindowInfo_); + const sptr& thirdWindow = Utils::CreateTestWindow(thirdWindowInfo_); ASSERT_NE(nullptr, thirdWindow); thirdWindow->Show(); SingletonContainer::Get().ProcessPointDown(thirdWindow->GetWindowId()); @@ -200,5 +194,5 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, TestSize.Level1) thirdWindow->Destroy(); } } // namespace -} // Rosen -} // OHOS \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_visibility_info_test.cpp b/test/systemtest/wms/window_visibility_info_test.cpp index a3148fb5ba..3a4dd1d9fe 100644 --- a/test/systemtest/wms/window_visibility_info_test.cpp +++ b/test/systemtest/wms/window_visibility_info_test.cpp @@ -35,9 +35,9 @@ namespace OHOS { namespace Rosen { namespace { constexpr uint32_t COLOR_RED = 0xffff0000; -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowVisibilityInfoTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowVisibilityInfoTest" }; constexpr uint8_t ALPHA = 255; -} +} // namespace using Utils = WindowTestUtils; constexpr int WAIT_ASYNC_MS_TIME_OUT = 5000; // 5000ms, filling color is slow @@ -47,7 +47,8 @@ public: VisibilityChangedListenerImpl(std::mutex& mutex, std::condition_variable& cv) : mutex_(mutex), cv_(cv) {} void OnWindowVisibilityChanged(const std::vector>& windowVisibilityInfo) override; std::vector> windowVisibilityInfos_; - bool isCallbackCalled_ { false }; + bool isCallbackCalled_{ false }; + private: std::mutex& mutex_; std::condition_variable& cv_; @@ -61,8 +62,11 @@ void VisibilityChangedListenerImpl::OnWindowVisibilityChanged( windowVisibilityInfos_ = std::move(windowVisibilityInfo); for (auto& info : windowVisibilityInfos_) { WLOGI("windowId:%{public}u, visibleState:%{public}d, pid:%{public}d, uid:%{public}d, windowType:%{public}u", - info->windowId_, static_cast(info->visibilityState_), info->pid_, info->uid_, - static_cast(info->windowType_)); + info->windowId_, + static_cast(info->visibilityState_), + info->pid_, + info->uid_, + static_cast(info->windowType_)); } isCallbackCalled_ = true; cv_.notify_all(); @@ -117,10 +121,14 @@ void WindowVisibilityInfoTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); - WLOGI("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, - static_cast(display->GetWidth()), static_cast(display->GetHeight())}; + WLOGI("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, static_cast(display->GetWidth()), static_cast(display->GetHeight()) + }; Utils::InitByDisplayRect(displayRect); WindowManager::GetInstance().RegisterVisibilityChangedListener(visibilityChangedListener_); auto displayId = DisplayManager::GetInstance().GetDefaultDisplayId(); @@ -166,9 +174,7 @@ void WindowVisibilityInfoTest::SetUp() }; } -void WindowVisibilityInfoTest::TearDown() -{ -} +void WindowVisibilityInfoTest::TearDown() {} void WindowVisibilityInfoTest::WaitForCallback() { @@ -176,8 +182,9 @@ void WindowVisibilityInfoTest::WaitForCallback() visibilityChangedListener_->isCallbackCalled_ = false; visibilityChangedListener_->windowVisibilityInfos_.clear(); auto now = std::chrono::system_clock::now(); - if (!cv_.wait_until(lock, now + std::chrono::milliseconds(WAIT_ASYNC_MS_TIME_OUT), - []() { return visibilityChangedListener_->isCallbackCalled_; })) { + if (!cv_.wait_until(lock, now + std::chrono::milliseconds(WAIT_ASYNC_MS_TIME_OUT), []() { + return visibilityChangedListener_->isCallbackCalled_; + })) { WLOGI("wait_until time out"); } } @@ -192,14 +199,14 @@ namespace { HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, TestSize.Level1) { floatAppInfo_.name = "window1"; - floatAppInfo_.rect = {0, 0, 300, 100}; + floatAppInfo_.rect = { 0, 0, 300, 100 }; sptr window1 = Utils::CreateTestWindow(floatAppInfo_); if (window1 == nullptr) { return; } subAppInfo_.name = "subWindow1"; - subAppInfo_.rect = {0, 600, 300, 100}; + subAppInfo_.rect = { 0, 600, 300, 100 }; subAppInfo_.parentId = window1->GetWindowId(); sptr subWindow1 = Utils::CreateTestWindow(subAppInfo_); ASSERT_NE(nullptr, subWindow1); @@ -233,7 +240,6 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, TestSize.Level1) subWindow1->Destroy(); sleep(2); } -} +} // namespace } // namespace Rosen } // namespace OHOS - diff --git a/test/systemtest/wms/window_water_mark_test.cpp b/test/systemtest/wms/window_water_mark_test.cpp index 07ce44b597..4a5bfd9fa7 100644 --- a/test/systemtest/wms/window_water_mark_test.cpp +++ b/test/systemtest/wms/window_water_mark_test.cpp @@ -25,8 +25,8 @@ #include "display_manager.h" #include "display_manager_proxy.h" #include "surface_draw.h" -#include "window_test_utils.h" #include "window_manager.h" +#include "window_test_utils.h" #include "wm_common.h" using namespace testing; @@ -38,8 +38,8 @@ namespace { constexpr uint32_t COLOR_RED = 0xffff0000; constexpr uint8_t ALPHA = 255; constexpr int NORMAL_SLEEP_TIME = 3; // 1s -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowWaterMarkTest"}; -} +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowWaterMarkTest" }; +} // namespace using Utils = WindowTestUtils; @@ -76,7 +76,7 @@ public: sptr WaterMarkTest::lisenter_ = nullptr; void WaterMarkTest::SetUpTestCase() { - lisenter_= new TestIWaterMarkFlagChangedListener(); + lisenter_ = new TestIWaterMarkFlagChangedListener(); WindowManager::GetInstance().RegisterWaterMarkFlagChangedListener(lisenter_); displayId_ = DisplayManager::GetInstance().GetDefaultDisplayId(); } @@ -100,9 +100,7 @@ void WaterMarkTest::SetUp() }; } -void WaterMarkTest::TearDown() -{ -} +void WaterMarkTest::TearDown() {} sptr WaterMarkTest::CreateWindow(const Utils::TestWindowInfo& appinfo) { @@ -142,7 +140,7 @@ namespace { HWTEST_F(WaterMarkTest, SetWaterMarkFlag01, TestSize.Level1) { appInfo_.name = "window1"; - appInfo_.rect = {200, 200, 300, 300}; + appInfo_.rect = { 200, 200, 300, 300 }; sptr window = CreateWindow(appInfo_); if (window == nullptr) { return; @@ -165,7 +163,6 @@ HWTEST_F(WaterMarkTest, SetWaterMarkFlag01, TestSize.Level1) window->Destroy(); sleep(NORMAL_SLEEP_TIME); } -} +} // namespace } // namespace Rosen } // namespace OHOS - diff --git a/utils/include/perform_reporter.h b/utils/include/perform_reporter.h index d5ccbd619f..70b729d947 100644 --- a/utils/include/perform_reporter.h +++ b/utils/include/perform_reporter.h @@ -46,6 +46,8 @@ struct WindowProfileInfo { int32_t windowVisibleState = -1; int32_t windowLocatedScreen = -1; int32_t windowSceneMode = -1; + std::string rect = ""; + int32_t zorder = -1; }; enum class KeyboardLifeCycleException { diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 103091dc82..87858076a4 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -153,6 +153,10 @@ public: double GetTextFieldPositionY() const; double GetTextFieldHeight() const; + + void SetFollowScreenChange(bool isFollowScreenChange); + bool GetFollowScreenChange() const; + private: bool MapMarshalling(Parcel& parcel) const; static void MapUnmarshalling(Parcel& parcel, WindowProperty* property); @@ -184,6 +188,7 @@ private: float brightness_ = UNDEFINED_BRIGHTNESS; bool turnScreenOn_ = false; bool keepScreenOn_ = false; + bool isFollowScreenChange_ = false; uint32_t callingWindow_ = INVALID_WINDOW_ID; DisplayId displayId_ { 0 }; uint32_t windowId_ = INVALID_WINDOW_ID; diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index 4b092de08c..e0cacc62db 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -90,6 +90,7 @@ enum class PropertyChangeAction : uint32_t { ACTION_UPDATE_SYSTEM_PRIVACY_MODE = 1 << 18, ACTION_UPDATE_SNAPSHOT_SKIP = 1 << 19, ACTION_UPDATE_TEXTFIELD_AVOID_INFO = 1 << 20, + ACTION_UPDATE_FOLLOW_SCREEN_CHANGE = 1 << 21, }; struct ModeChangeHotZonesConfig { diff --git a/utils/src/perform_reporter.cpp b/utils/src/perform_reporter.cpp index 7a8661f0f4..616e82cfad 100644 --- a/utils/src/perform_reporter.cpp +++ b/utils/src/perform_reporter.cpp @@ -307,7 +307,9 @@ int32_t WindowInfoReporter::ReportWindowProfileInfo(const WindowProfileInfo& win "BUNDLE_NAME", windowProfileInfo.bundleName, "WINDOW_VISIBLE_STATE", windowProfileInfo.windowVisibleState, "WINDOW_LOCATED_SCREEN", windowProfileInfo.windowLocatedScreen, - "WINDOW_SCENE_MODE", windowProfileInfo.windowSceneMode); + "WINDOW_SCENE_MODE", windowProfileInfo.windowSceneMode, + "WINDOW_ZORDER", windowProfileInfo.zorder, + "WINDOW_RECT", windowProfileInfo.rect); if (ret != 0) { WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); } diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index c7d3abd1ce..84b6d6db80 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -124,6 +124,16 @@ void WindowProperty::SetTransform(const Transform& trans) trans_ = trans; } +void WindowProperty::SetFollowScreenChange(bool isFollowScreenChange) +{ + isFollowScreenChange_ = isFollowScreenChange; +} + +bool WindowProperty::GetFollowScreenChange() const +{ + return isFollowScreenChange_; +} + void WindowProperty::HandleComputeTransform(const Transform& trans) { TransformHelper::Vector3 pivotPos = { windowRect_.posX_ + trans.pivotX_ * windowRect_.width_, @@ -737,7 +747,8 @@ bool WindowProperty::Marshalling(Parcel& parcel) const parcel.WriteBool(isDisplayZoomOn_) && parcel.WriteString(abilityInfo_.bundleName_) && parcel.WriteString(abilityInfo_.abilityName_) && parcel.WriteInt32(abilityInfo_.missionId_) && parcel.WriteBool(isSnapshotSkip_) && - parcel.WriteDouble(textFieldPositionY_) && parcel.WriteDouble(textFieldHeight_); + parcel.WriteDouble(textFieldPositionY_) && parcel.WriteDouble(textFieldHeight_) && + parcel.WriteBool(isFollowScreenChange_); } WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) @@ -797,6 +808,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetSnapshotSkip(parcel.ReadBool()); property->SetTextFieldPositionY(parcel.ReadDouble()); property->SetTextFieldHeight(parcel.ReadDouble()); + property->SetFollowScreenChange(parcel.ReadBool()); return property; } @@ -872,6 +884,9 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO: ret = ret && parcel.WriteDouble(textFieldPositionY_) && parcel.WriteDouble(textFieldHeight_); break; + case PropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE: + ret = ret && parcel.WriteBool(isFollowScreenChange_); + break; default: break; } @@ -955,6 +970,9 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action) SetTextFieldPositionY(parcel.ReadDouble()); SetTextFieldHeight(parcel.ReadDouble()); break; + case PropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE: + SetFollowScreenChange(parcel.ReadBool()); + break; default: break; } @@ -1006,6 +1024,7 @@ void WindowProperty::CopyFrom(const sptr& property) isSnapshotSkip_ = property->isSnapshotSkip_; textFieldPositionY_ = property->textFieldPositionY_; textFieldHeight_ = property->textFieldHeight_; + isFollowScreenChange_ = property->isFollowScreenChange_; } void WindowProperty::SetTextFieldPositionY(double textFieldPositionY) { diff --git a/utils/test/unittest/cutout_info_test.cpp b/utils/test/unittest/cutout_info_test.cpp index d52bdd9406..7983d303b2 100644 --- a/utils/test/unittest/cutout_info_test.cpp +++ b/utils/test/unittest/cutout_info_test.cpp @@ -29,21 +29,13 @@ public: void TearDown() override; }; -void CutoutInfoTest::SetUpTestCase() -{ -} +void CutoutInfoTest::SetUpTestCase() {} -void CutoutInfoTest::TearDownTestCase() -{ -} +void CutoutInfoTest::TearDownTestCase() {} -void CutoutInfoTest::SetUp() -{ -} +void CutoutInfoTest::SetUp() {} -void CutoutInfoTest::TearDown() -{ -} +void CutoutInfoTest::TearDown() {} namespace { /** @@ -54,7 +46,7 @@ namespace { HWTEST_F(CutoutInfoTest, WriteBoundingRectsVector01, TestSize.Level1) { sptr info = new CutoutInfo(); - DMRect rect = {0, 0, 0, 0}; + DMRect rect = { 0, 0, 0, 0 }; std::vector boundingRects; boundingRects.emplace_back(rect); Parcel parcel; @@ -71,8 +63,8 @@ HWTEST_F(CutoutInfoTest, WriteBoundingRectsVector02, TestSize.Level1) { sptr info = new CutoutInfo(); std::vector boundingRects; - for (int i = 0; i < 21 ; i++){ // MAX_CUTOUT_INFO_SIZE + 1 - DMRect rect = {0, 0, 0, 0}; + for (int i = 0; i < 21; i++) { // MAX_CUTOUT_INFO_SIZE + 1 + DMRect rect = { 0, 0, 0, 0 }; boundingRects.emplace_back(rect); } Parcel parcel; @@ -88,7 +80,7 @@ HWTEST_F(CutoutInfoTest, WriteBoundingRectsVector02, TestSize.Level1) HWTEST_F(CutoutInfoTest, ReadBoundingRectsVector01, TestSize.Level1) { sptr info = new CutoutInfo(); - DMRect rect = {0, 0, 0, 0}; + DMRect rect = { 0, 0, 0, 0 }; std::vector boundingRects; boundingRects.emplace_back(rect); Parcel parcel; @@ -105,14 +97,14 @@ HWTEST_F(CutoutInfoTest, ReadBoundingRectsVector02, TestSize.Level1) { sptr info = new CutoutInfo(); std::vector boundingRects; - for (int i = 0; i < 21 ; i++){ // MAX_CUTOUT_INFO_SIZE + 1 - DMRect rect = {0, 0, 0, 0}; + for (int i = 0; i < 21; i++) { // MAX_CUTOUT_INFO_SIZE + 1 + DMRect rect = { 0, 0, 0, 0 }; boundingRects.emplace_back(rect); } Parcel parcel; bool ret = info->ReadBoundingRectsVector(boundingRects, parcel); ASSERT_FALSE(ret); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/display_info_test.cpp b/utils/test/unittest/display_info_test.cpp index f186a1fc8f..85dbead6f7 100644 --- a/utils/test/unittest/display_info_test.cpp +++ b/utils/test/unittest/display_info_test.cpp @@ -30,21 +30,13 @@ public: virtual void TearDown() override; }; -void DisplayInfoTest::SetUpTestCase() -{ -} +void DisplayInfoTest::SetUpTestCase() {} -void DisplayInfoTest::TearDownTestCase() -{ -} +void DisplayInfoTest::TearDownTestCase() {} -void DisplayInfoTest::SetUp() -{ -} +void DisplayInfoTest::SetUp() {} -void DisplayInfoTest::TearDown() -{ -} +void DisplayInfoTest::TearDown() {} namespace { /** @@ -64,6 +56,6 @@ HWTEST_F(DisplayInfoTest, MarshallingUnmarshalling, TestSize.Level1) ASSERT_EQ(displayInfoDst->GetDisplayId(), 1); delete displayInfoDst; } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/dms_reporter_test.cpp b/utils/test/unittest/dms_reporter_test.cpp index 058368be24..c527c15b23 100644 --- a/utils/test/unittest/dms_reporter_test.cpp +++ b/utils/test/unittest/dms_reporter_test.cpp @@ -29,21 +29,13 @@ public: void TearDown() override; }; -void DmsReporterTest::SetUpTestCase() -{ -} +void DmsReporterTest::SetUpTestCase() {} -void DmsReporterTest::TearDownTestCase() -{ -} +void DmsReporterTest::TearDownTestCase() {} -void DmsReporterTest::SetUp() -{ -} +void DmsReporterTest::SetUp() {} -void DmsReporterTest::TearDown() -{ -} +void DmsReporterTest::TearDown() {} namespace { /** @@ -85,6 +77,6 @@ HWTEST_F(DmsReporterTest, ReportContinueApp, TestSize.Level1) ASSERT_EQ(res, 0); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/perform_reporter_test.cpp b/utils/test/unittest/perform_reporter_test.cpp index 7d4e1d43d4..78bbef5fcb 100644 --- a/utils/test/unittest/perform_reporter_test.cpp +++ b/utils/test/unittest/perform_reporter_test.cpp @@ -27,7 +27,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PerformReporterTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "PerformReporterTest" }; } class PerformReporterTest : public testing::Test { public: @@ -39,21 +39,13 @@ public: bool PerformDataCmp(const PerformReporter& pr, const uint32_t totalCount, const std::vector& splitCount); }; -void PerformReporterTest::SetUpTestCase() -{ -} +void PerformReporterTest::SetUpTestCase() {} -void PerformReporterTest::TearDownTestCase() -{ -} +void PerformReporterTest::TearDownTestCase() {} -void PerformReporterTest::SetUp() -{ -} +void PerformReporterTest::SetUp() {} -void PerformReporterTest::TearDown() -{ -} +void PerformReporterTest::TearDown() {} void PerformReporterTest::SimuReportProcess(PerformReporter& pr, const std::vector& durations) { @@ -65,7 +57,8 @@ void PerformReporterTest::SimuReportProcess(PerformReporter& pr, const std::vect } bool PerformReporterTest::PerformDataCmp(const PerformReporter& pr, - const uint32_t totalCount, const std::vector& splitCount) + const uint32_t totalCount, + const std::vector& splitCount) { if (pr.totalCount_ != totalCount) { WLOGFE("pr.totalCount_=%{public}u, expect=%{public}u", pr.totalCount_.load(), totalCount); @@ -73,7 +66,7 @@ bool PerformReporterTest::PerformDataCmp(const PerformReporter& pr, } size_t i = 0; - for (auto& iter: pr.timeSplitCount_) { + for (auto& iter : pr.timeSplitCount_) { if (iter.second != splitCount[i]) { std::ostringstream oss; oss << "pr.timeSplitCount_[" << iter.first << "]=" << iter.second << ", but expect=" << splitCount[i]; @@ -94,9 +87,9 @@ namespace { */ HWTEST_F(PerformReporterTest, StartEnd, TestSize.Level1) { - PerformReporter pr = PerformReporter("TestTag", {100, 200, 300}, 10); - SimuReportProcess(pr, {50, 150, 250, 350, 450}); - ASSERT_EQ(true, PerformDataCmp(pr, 5, {1, 1, 1, 2})); + PerformReporter pr = PerformReporter("TestTag", { 100, 200, 300 }, 10); + SimuReportProcess(pr, { 50, 150, 250, 350, 450 }); + ASSERT_EQ(true, PerformDataCmp(pr, 5, { 1, 1, 1, 2 })); } /** @@ -106,9 +99,9 @@ HWTEST_F(PerformReporterTest, StartEnd, TestSize.Level1) */ HWTEST_F(PerformReporterTest, StartEndClear, TestSize.Level1) { - PerformReporter pr = PerformReporter("TestTag", {100, 200, 300}, 3); - SimuReportProcess(pr, {50, 150, 250}); - ASSERT_EQ(true, PerformDataCmp(pr, 0, {0, 0, 0, 0})); + PerformReporter pr = PerformReporter("TestTag", { 100, 200, 300 }, 3); + SimuReportProcess(pr, { 50, 150, 250 }); + ASSERT_EQ(true, PerformDataCmp(pr, 0, { 0, 0, 0, 0 })); } /** @@ -118,9 +111,9 @@ HWTEST_F(PerformReporterTest, StartEndClear, TestSize.Level1) */ HWTEST_F(PerformReporterTest, StartEndInvSeq, TestSize.Level1) { - PerformReporter pr = PerformReporter("TestTag", {100, 200, 300}, 4); - SimuReportProcess(pr, {250, 150, 50}); - ASSERT_EQ(true, PerformDataCmp(pr, 3, {1, 1, 1, 0})); + PerformReporter pr = PerformReporter("TestTag", { 100, 200, 300 }, 4); + SimuReportProcess(pr, { 250, 150, 50 }); + ASSERT_EQ(true, PerformDataCmp(pr, 3, { 1, 1, 1, 0 })); } /** @@ -130,12 +123,12 @@ HWTEST_F(PerformReporterTest, StartEndInvSeq, TestSize.Level1) */ HWTEST_F(PerformReporterTest, PrivateClear, TestSize.Level1) { - PerformReporter pr = PerformReporter("TestTag", {100, 200, 300}, 10); - SimuReportProcess(pr, {50, 150, 250, 350, 450}); - ASSERT_EQ(true, PerformDataCmp(pr, 5, {1, 1, 1, 2})); + PerformReporter pr = PerformReporter("TestTag", { 100, 200, 300 }, 10); + SimuReportProcess(pr, { 50, 150, 250, 350, 450 }); + ASSERT_EQ(true, PerformDataCmp(pr, 5, { 1, 1, 1, 2 })); pr.clear(); - ASSERT_EQ(true, PerformDataCmp(pr, 0, {0, 0, 0, 0})); + ASSERT_EQ(true, PerformDataCmp(pr, 0, { 0, 0, 0, 0 })); } /** @@ -428,9 +421,8 @@ HWTEST_F(PerformReporterTest, ReportUIExtensionException, TestSize.Level1) oss << " provider bundleName: " << "testProviderBundleName1" << ","; oss << " provider windowName: " << "testWindowName1" << ","; oss << " errorCode: " << errorCode << ";"; - res = windowInfoReporter.ReportUIExtensionException(static_cast(exceptionType), pid, persistentId, - oss.str() - ); + res = windowInfoReporter.ReportUIExtensionException( + static_cast(exceptionType), pid, persistentId, oss.str()); ASSERT_EQ(res, 0); exceptionType = WindowDFXHelperType::WINDOW_UIEXTENSION_START_ABILITY_FAIL; @@ -442,9 +434,8 @@ HWTEST_F(PerformReporterTest, ReportUIExtensionException, TestSize.Level1) oss << "Start UIExtensionAbility failed" << ","; oss << " provider windowName: " << "testWindowName2" << ","; oss << " errorCode: " << errorCode << ";"; - res = windowInfoReporter.ReportUIExtensionException(static_cast(exceptionType), pid, persistentId, - oss.str() - ); + res = windowInfoReporter.ReportUIExtensionException( + static_cast(exceptionType), pid, persistentId, oss.str()); ASSERT_EQ(res, 0); } @@ -480,6 +471,8 @@ HWTEST_F(PerformReporterTest, ReportWindowProfileInfo017, TestSize.Level1) windowProfileInfo.windowLocatedScreen = 0; windowProfileInfo.windowSceneMode = 102; windowProfileInfo.windowVisibleState = 2; + windowProfileInfo.rect = "[0 0 60 90]"; + windowProfileInfo.zorder = 110; WindowInfoReporter windowInfoReporter; res = windowInfoReporter.ReportWindowProfileInfo(windowProfileInfo); ASSERT_EQ(res, 0); @@ -533,6 +526,6 @@ HWTEST_F(PerformReporterTest, ReportSpecWindowLifeCycleChange, Function | SmallT int32_t res = windowInfoReporter.ReportSpecWindowLifeCycleChange(reportInfo); ASSERT_EQ(res, 0); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/permission_test.cpp b/utils/test/unittest/permission_test.cpp index 2d356ff005..9dc7f24172 100644 --- a/utils/test/unittest/permission_test.cpp +++ b/utils/test/unittest/permission_test.cpp @@ -19,11 +19,11 @@ #include #include -#include -#include #include -#include +#include +#include #include +#include #include #include "window_manager_hilog.h" @@ -41,21 +41,13 @@ public: void TearDown() override; }; -void PermissionTest::SetUpTestCase() -{ -} +void PermissionTest::SetUpTestCase() {} -void PermissionTest::TearDownTestCase() -{ -} +void PermissionTest::TearDownTestCase() {} -void PermissionTest::SetUp() -{ -} +void PermissionTest::SetUp() {} -void PermissionTest::TearDown() -{ -} +void PermissionTest::TearDown() {} namespace { /** @@ -103,6 +95,6 @@ HWTEST_F(PermissionTest, CheckIsCallingBundleName, TestSize.Level1) bool result = Permission::CheckIsCallingBundleName("err"); ASSERT_EQ(false, result); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/persistent_storage_test.cpp b/utils/test/unittest/persistent_storage_test.cpp index 17c5bda785..bd2fd5718b 100644 --- a/utils/test/unittest/persistent_storage_test.cpp +++ b/utils/test/unittest/persistent_storage_test.cpp @@ -29,21 +29,13 @@ public: void TearDown() override; }; -void PersistentStorageTest::SetUpTestCase() -{ -} +void PersistentStorageTest::SetUpTestCase() {} -void PersistentStorageTest::TearDownTestCase() -{ -} +void PersistentStorageTest::TearDownTestCase() {} -void PersistentStorageTest::SetUp() -{ -} +void PersistentStorageTest::SetUp() {} -void PersistentStorageTest::TearDown() -{ -} +void PersistentStorageTest::TearDown() {} namespace { /** @@ -103,6 +95,6 @@ HWTEST_F(PersistentStorageTest, StorageOperate, TestSize.Level1) EXPECT_EQ(false, result4); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/screen_group_info_test.cpp b/utils/test/unittest/screen_group_info_test.cpp index cc43e71c53..8bf3c60200 100644 --- a/utils/test/unittest/screen_group_info_test.cpp +++ b/utils/test/unittest/screen_group_info_test.cpp @@ -30,21 +30,13 @@ public: virtual void TearDown() override; }; -void ScreenGroupInfoTest::SetUpTestCase() -{ -} +void ScreenGroupInfoTest::SetUpTestCase() {} -void ScreenGroupInfoTest::TearDownTestCase() -{ -} +void ScreenGroupInfoTest::TearDownTestCase() {} -void ScreenGroupInfoTest::SetUp() -{ -} +void ScreenGroupInfoTest::SetUp() {} -void ScreenGroupInfoTest::TearDown() -{ -} +void ScreenGroupInfoTest::TearDown() {} namespace { /** @@ -82,7 +74,7 @@ HWTEST_F(ScreenGroupInfoTest, InnerUnmarshalling, TestSize.Level1) { ScreenGroupInfo screenGroupInfoSrc; Parcel parcel; - parcel.WriteUint32(21); // MAX_SCREEN_GROUP_INFO_SIZE + 1 + parcel.WriteUint32(21); // MAX_SCREEN_GROUP_INFO_SIZE + 1 bool result = screenGroupInfoSrc.InnerUnmarshalling(parcel); ASSERT_FALSE(result); } @@ -99,6 +91,6 @@ HWTEST_F(ScreenGroupInfoTest, Marshalling, TestSize.Level1) bool result = screenGroupInfoSrc.InnerUnmarshalling(parcel); ASSERT_FALSE(result); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/screen_info_test.cpp b/utils/test/unittest/screen_info_test.cpp index 7560f559fa..124631d287 100644 --- a/utils/test/unittest/screen_info_test.cpp +++ b/utils/test/unittest/screen_info_test.cpp @@ -30,21 +30,13 @@ public: virtual void TearDown() override; }; -void ScreenInfoTest::SetUpTestCase() -{ -} +void ScreenInfoTest::SetUpTestCase() {} -void ScreenInfoTest::TearDownTestCase() -{ -} +void ScreenInfoTest::TearDownTestCase() {} -void ScreenInfoTest::SetUp() -{ -} +void ScreenInfoTest::SetUp() {} -void ScreenInfoTest::TearDown() -{ -} +void ScreenInfoTest::TearDown() {} namespace { /** @@ -89,10 +81,10 @@ HWTEST_F(ScreenInfoTest, InnerUnmarshalling, TestSize.Level1) { ScreenInfo screenInfoSrc; Parcel parcel; - parcel.WriteUint32(21); // MAX_SUPPORTED_SCREEN_MODES_SIZE + 1 + parcel.WriteUint32(21); // MAX_SUPPORTED_SCREEN_MODES_SIZE + 1 bool result = screenInfoSrc.InnerUnmarshalling(parcel); ASSERT_FALSE(result); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/string_util_test.cpp b/utils/test/unittest/string_util_test.cpp index 30d1f86adf..046976cbbb 100644 --- a/utils/test/unittest/string_util_test.cpp +++ b/utils/test/unittest/string_util_test.cpp @@ -30,21 +30,13 @@ public: virtual void TearDown() override; }; -void StringUtilTest::SetUpTestCase() -{ -} +void StringUtilTest::SetUpTestCase() {} -void StringUtilTest::TearDownTestCase() -{ -} +void StringUtilTest::TearDownTestCase() {} -void StringUtilTest::SetUp() -{ -} +void StringUtilTest::SetUp() {} -void StringUtilTest::TearDown() -{ -} +void StringUtilTest::TearDown() {} namespace { /** @@ -60,6 +52,6 @@ HWTEST_F(StringUtilTest, Trim, TestSize.Level1) ASSERT_EQ("123", StringUtil::Trim(" 123 ")); ASSERT_EQ("12 3", StringUtil::Trim(" 12 3 ")); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/surface_draw_test.cpp b/utils/test/unittest/surface_draw_test.cpp index 9fd51f330c..a51430a154 100644 --- a/utils/test/unittest/surface_draw_test.cpp +++ b/utils/test/unittest/surface_draw_test.cpp @@ -15,11 +15,11 @@ #include -#include "surface_draw.h" #include "display.h" #include "display_info.h" #include "display_manager.h" #include "display_manager_proxy.h" +#include "surface_draw.h" #include "window_impl.h" using namespace testing; @@ -29,8 +29,8 @@ namespace OHOS { namespace Rosen { namespace { const std::string IMAGE_PLACE_HOLDER_PNG_PATH = "/etc/window/resources/bg_place_holder.png"; -const int WAIT_FOR_SYNC_US = 1000 * 500; // 500ms -} +const int WAIT_FOR_SYNC_US = 1000 * 500; // 500ms +} // namespace class SurfaceDrawTest : public testing::Test { public: static void SetUpTestCase(); @@ -46,7 +46,7 @@ public: WindowMode mode; bool needAvoid; bool parentLimit; - bool forbidSplitMove {false}; + bool forbidSplitMove{ false }; bool showWhenLocked; uint32_t parentId; }; @@ -69,15 +69,13 @@ void SurfaceDrawTest::SetUpTestCase() displayHeight_ = display->GetHeight(); } -void SurfaceDrawTest::TearDownTestCase() -{ -} +void SurfaceDrawTest::TearDownTestCase() {} void SurfaceDrawTest::SetUp() { windowInfo_ = { .name = "main", - .rect = {100, 100, 250, 300}, + .rect = { 100, 100, 250, 300 }, .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, .mode = WindowMode::WINDOW_MODE_FLOATING, .needAvoid = true, @@ -86,13 +84,11 @@ void SurfaceDrawTest::SetUp() }; } -void SurfaceDrawTest::TearDown() -{ -} +void SurfaceDrawTest::TearDown() {} sptr SurfaceDrawTest::CreateTestWindow(const std::string& name) { - sptr option = new (std::nothrow)WindowOption(); + sptr option = new (std::nothrow) WindowOption(); if (option == nullptr) { return nullptr; } @@ -154,8 +150,8 @@ HWTEST_F(SurfaceDrawTest, DecodeImageToPixelMap01, TestSize.Level1) */ HWTEST_F(SurfaceDrawTest, DrawMasking01, TestSize.Level1) { - OHOS::Rosen::Rect screenRect = {0, 0, 0, 0}; - OHOS::Rosen::Rect transRect = {0, 0, 0, 0}; + OHOS::Rosen::Rect screenRect = { 0, 0, 0, 0 }; + OHOS::Rosen::Rect transRect = { 0, 0, 0, 0 }; ASSERT_FALSE(SurfaceDraw::DrawMasking(nullptr, screenRect, transRect)); sptr window = CreateTestWindow("testDrawMasking"); @@ -231,7 +227,7 @@ HWTEST_F(SurfaceDrawTest, GetSurfaceSnapshot01, TestSize.Level1) auto surfaceNode = window->GetSurfaceNode(); ASSERT_NE(surfaceNode, nullptr); - + std::shared_ptr pixelMap = SurfaceDraw::DecodeImageToPixelMap(IMAGE_PLACE_HOLDER_PNG_PATH); ASSERT_NE(pixelMap, nullptr); @@ -371,6 +367,6 @@ HWTEST_F(SurfaceDrawTest, DrawImageRect01, TestSize.Level1) SurfaceDraw::DrawImageRect(surfaceNode, rect, pixelMap, color, false); window->Destroy(); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/surface_reader_test.cpp b/utils/test/unittest/surface_reader_test.cpp index 9884e58c89..34212d372c 100644 --- a/utils/test/unittest/surface_reader_test.cpp +++ b/utils/test/unittest/surface_reader_test.cpp @@ -13,16 +13,16 @@ * limitations under the License. */ -#include "surface_reader.h" #include #include +#include "surface_reader.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { class SurfaceReaderTest : public testing::Test { - public: +public: SurfaceReaderTest() {} ~SurfaceReaderTest() {} }; @@ -36,7 +36,7 @@ namespace { HWTEST_F(SurfaceReaderTest, Init, TestSize.Level1) { GTEST_LOG_(INFO) << "SurfaceReaderTest: Init start"; - SurfaceReader* reader = new(std::nothrow) SurfaceReader(); + SurfaceReader* reader = new (std::nothrow) SurfaceReader(); bool res = reader->Init(); ASSERT_EQ(res, true); delete reader; @@ -50,7 +50,7 @@ HWTEST_F(SurfaceReaderTest, Init, TestSize.Level1) */ HWTEST_F(SurfaceReaderTest, OnVsync, TestSize.Level1) { - SurfaceReader* reader = new(std::nothrow) SurfaceReader(); + SurfaceReader* reader = new (std::nothrow) SurfaceReader(); bool res = reader->Init(); reader->OnVsync(); delete reader; @@ -64,7 +64,7 @@ HWTEST_F(SurfaceReaderTest, OnVsync, TestSize.Level1) */ HWTEST_F(SurfaceReaderTest, GetSurface, TestSize.Level1) { - SurfaceReader* reader = new(std::nothrow) SurfaceReader(); + SurfaceReader* reader = new (std::nothrow) SurfaceReader(); reader->Init(); sptr surface = reader->GetSurface(); ASSERT_NE(surface, nullptr); @@ -78,11 +78,11 @@ HWTEST_F(SurfaceReaderTest, GetSurface, TestSize.Level1) */ HWTEST_F(SurfaceReaderTest, SetHandler, TestSize.Level1) { - SurfaceReader* reader = new(std::nothrow) SurfaceReader(); + SurfaceReader* reader = new (std::nothrow) SurfaceReader(); reader->SetHandler(nullptr); ASSERT_TRUE(true); delete reader; } } // namespace -} -} +} // namespace Rosen +} // namespace OHOS diff --git a/utils/test/unittest/utils_all_test.cpp b/utils/test/unittest/utils_all_test.cpp index 28c1a91936..fdae056772 100644 --- a/utils/test/unittest/utils_all_test.cpp +++ b/utils/test/unittest/utils_all_test.cpp @@ -20,8 +20,8 @@ #include "agent_death_recipient.h" #include "iremote_object_mocker.h" -#include "singleton_container.h" #include "perform_reporter.h" +#include "singleton_container.h" #include "surface_reader_handler_impl.h" #include "sys_cap_util.h" @@ -47,21 +47,13 @@ public: std::map> oldDependencySetMap_; }; -void UtilsAllTest::SetUpTestCase() -{ -} +void UtilsAllTest::SetUpTestCase() {} -void UtilsAllTest::TearDownTestCase() -{ -} +void UtilsAllTest::TearDownTestCase() {} -void UtilsAllTest::SetUp() -{ -} +void UtilsAllTest::SetUp() {} -void UtilsAllTest::TearDown() -{ -} +void UtilsAllTest::TearDown() {} namespace { /** @@ -79,9 +71,7 @@ HWTEST_F(UtilsAllTest, ADROnRemoteDied01, TestSize.Level1) deathRecipient->OnRemoteDied(remoteObj); ASSERT_EQ(0, remoteObj->count_); - deathRecipient->callback_ = [&remoteObj](sptr& remote) { - remoteObj->count_ = 1; - }; + deathRecipient->callback_ = [&remoteObj](sptr& remote) { remoteObj->count_ = 1; }; deathRecipient->OnRemoteDied(remoteObj); ASSERT_EQ(1, remoteObj->count_); } @@ -93,7 +83,7 @@ HWTEST_F(UtilsAllTest, ADROnRemoteDied01, TestSize.Level1) */ HWTEST_F(UtilsAllTest, PRCount01, TestSize.Level1) { - std::vector timeSpiltsMs = {0, 1, 2}; + std::vector timeSpiltsMs = { 0, 1, 2 }; PerformReporter reporter = PerformReporter("test", timeSpiltsMs); reporter.count(0); @@ -188,7 +178,7 @@ HWTEST_F(UtilsAllTest, SCDependOn01, TestSize.Level1) */ HWTEST_F(UtilsAllTest, SRHOnImageAvailable, TestSize.Level1) { - sptr surfaceReaderHandlerImpl = new (std::nothrow)SurfaceReaderHandlerImpl(); + sptr surfaceReaderHandlerImpl = new (std::nothrow) SurfaceReaderHandlerImpl(); surfaceReaderHandlerImpl->flag_ = false; surfaceReaderHandlerImpl->OnImageAvailable(nullptr); ASSERT_EQ(true, surfaceReaderHandlerImpl->flag_); @@ -204,7 +194,7 @@ HWTEST_F(UtilsAllTest, SRHOnImageAvailable, TestSize.Level1) */ HWTEST_F(UtilsAllTest, SRHGetPixelMap, TestSize.Level1) { - sptr surfaceReaderHandlerImpl = new (std::nothrow)SurfaceReaderHandlerImpl(); + sptr surfaceReaderHandlerImpl = new (std::nothrow) SurfaceReaderHandlerImpl(); surfaceReaderHandlerImpl->flag_ = false; surfaceReaderHandlerImpl->GetPixelMap(); ASSERT_EQ(false, surfaceReaderHandlerImpl->flag_); @@ -221,6 +211,6 @@ HWTEST_F(UtilsAllTest, SysCapUtilGetClientName, TestSize.Level1) { ASSERT_NE("", SysCapUtil::GetClientName()); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/window_frame_trace_impl_test.cpp b/utils/test/unittest/window_frame_trace_impl_test.cpp index b4cdba7827..b3f8b9cb8d 100644 --- a/utils/test/unittest/window_frame_trace_impl_test.cpp +++ b/utils/test/unittest/window_frame_trace_impl_test.cpp @@ -13,15 +13,15 @@ * limitations under the License. */ -#include "window_frame_trace.h" #include #include +#include "window_frame_trace.h" using namespace testing; using namespace testing::ext; namespace FRAME_TRACE { class WindowFrameTraceImplTest : public testing::Test { - public: +public: WindowFrameTraceImplTest() {} ~WindowFrameTraceImplTest() {} }; @@ -41,7 +41,7 @@ HWTEST_F(WindowFrameTraceImplTest, AccessFrameTrace01, TestSize.Level1) ASSERT_EQ(res, true); bool res1 = trace.AccessFrameTrace(); ASSERT_EQ(res1, true); - WindowFrameTraceImpl *trace_ = WindowFrameTraceImpl::GetInstance(); + WindowFrameTraceImpl* trace_ = WindowFrameTraceImpl::GetInstance(); bool res2 = trace_->AccessFrameTrace(); ASSERT_EQ(res2, true); GTEST_LOG_(INFO) << "WindowFrameTraceImplTest: AccessFrameTrace01 end"; @@ -59,7 +59,7 @@ HWTEST_F(WindowFrameTraceImplTest, VsyncStartFrameTrace01, TestSize.Level1) int32_t res = 0; trace.VsyncStartFrameTrace(); ASSERT_EQ(res, 0); - WindowFrameTraceImpl *trace_ = WindowFrameTraceImpl::GetInstance(); + WindowFrameTraceImpl* trace_ = WindowFrameTraceImpl::GetInstance(); bool res2 = trace_->AccessFrameTrace(); trace_->VsyncStartFrameTrace(); ASSERT_EQ(res2, true); @@ -78,7 +78,7 @@ HWTEST_F(WindowFrameTraceImplTest, VsyncStopFrameTrace01, TestSize.Level1) int32_t res = 0; trace.VsyncStopFrameTrace(); ASSERT_EQ(res, 0); - WindowFrameTraceImpl *trace_ = WindowFrameTraceImpl::GetInstance(); + WindowFrameTraceImpl* trace_ = WindowFrameTraceImpl::GetInstance(); bool res2 = trace_->AccessFrameTrace(); trace_->VsyncStartFrameTrace(); trace_->VsyncStopFrameTrace(); diff --git a/utils/test/unittest/window_helper_test.cpp b/utils/test/unittest/window_helper_test.cpp index d64212d773..fcc731b108 100644 --- a/utils/test/unittest/window_helper_test.cpp +++ b/utils/test/unittest/window_helper_test.cpp @@ -30,21 +30,13 @@ public: virtual void TearDown() override; }; -void WindowHelperTest::SetUpTestCase() -{ -} +void WindowHelperTest::SetUpTestCase() {} -void WindowHelperTest::TearDownTestCase() -{ -} +void WindowHelperTest::TearDownTestCase() {} -void WindowHelperTest::SetUp() -{ -} +void WindowHelperTest::SetUp() {} -void WindowHelperTest::TearDown() -{ -} +void WindowHelperTest::TearDown() {} namespace { /** @@ -54,12 +46,15 @@ namespace { */ HWTEST_F(WindowHelperTest, WindowTypeWindowMode, TestSize.Level1) { - ASSERT_EQ(true, WindowHelper::IsMainFullScreenWindow(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - WindowMode::WINDOW_MODE_FULLSCREEN)); - ASSERT_EQ(false, WindowHelper::IsMainFullScreenWindow(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, - WindowMode::WINDOW_MODE_FULLSCREEN)); - ASSERT_EQ(false, WindowHelper::IsMainFullScreenWindow(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, - WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); + ASSERT_EQ(true, + WindowHelper::IsMainFullScreenWindow(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + WindowMode::WINDOW_MODE_FULLSCREEN)); + ASSERT_EQ(false, + WindowHelper::IsMainFullScreenWindow(WindowType::WINDOW_TYPE_APP_SUB_WINDOW, + WindowMode::WINDOW_MODE_FULLSCREEN)); + ASSERT_EQ(false, + WindowHelper::IsMainFullScreenWindow(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, + WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); ASSERT_EQ(true, WindowHelper::IsFloatingWindow(WindowMode::WINDOW_MODE_FLOATING)); ASSERT_EQ(false, WindowHelper::IsFloatingWindow(WindowMode::WINDOW_MODE_FULLSCREEN)); @@ -78,18 +73,24 @@ HWTEST_F(WindowHelperTest, WindowTypeWindowMode, TestSize.Level1) */ HWTEST_F(WindowHelperTest, WindowModeSupport, TestSize.Level1) { - ASSERT_EQ(true, WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, - WindowMode::WINDOW_MODE_FULLSCREEN)); - ASSERT_EQ(true, WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, - WindowMode::WINDOW_MODE_FLOATING)); - ASSERT_EQ(true, WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, - WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); - ASSERT_EQ(true, WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, - WindowMode::WINDOW_MODE_SPLIT_SECONDARY)); - ASSERT_EQ(true, WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, - WindowMode::WINDOW_MODE_PIP)); - ASSERT_EQ(false, WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, - WindowMode::WINDOW_MODE_UNDEFINED)); + ASSERT_EQ(true, + WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, + WindowMode::WINDOW_MODE_FULLSCREEN)); + ASSERT_EQ(true, + WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, + WindowMode::WINDOW_MODE_FLOATING)); + ASSERT_EQ(true, + WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, + WindowMode::WINDOW_MODE_SPLIT_PRIMARY)); + ASSERT_EQ(true, + WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, + WindowMode::WINDOW_MODE_SPLIT_SECONDARY)); + ASSERT_EQ( + true, + WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, WindowMode::WINDOW_MODE_PIP)); + ASSERT_EQ(false, + WindowHelper::IsWindowModeSupported(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, + WindowMode::WINDOW_MODE_UNDEFINED)); } /** @@ -99,10 +100,10 @@ HWTEST_F(WindowHelperTest, WindowModeSupport, TestSize.Level1) */ HWTEST_F(WindowHelperTest, WindowRect, TestSize.Level1) { - Rect rect0 = {0, 0, 0, 0}; + Rect rect0 = { 0, 0, 0, 0 }; ASSERT_EQ(true, WindowHelper::IsEmptyRect(rect0)); - Rect rect1 = {0, 0, 1, 1}; + Rect rect1 = { 0, 0, 1, 1 }; ASSERT_EQ(false, WindowHelper::IsEmptyRect(rect1)); } @@ -138,9 +139,9 @@ HWTEST_F(WindowHelperTest, WindowStringUtil, TestSize.Level1) */ HWTEST_F(WindowHelperTest, CalculateOriginPosition, TestSize.Level1) { - Rect rect1 { 0, 0, 10, 10 }, rect2 { 100, 100, 200, 200 }; - PointInfo point = WindowHelper::CalculateOriginPosition(rect1, rect2, PointInfo { 200, 200 }); - PointInfo expectPoint { 5, 5 }; + Rect rect1{ 0, 0, 10, 10 }, rect2{ 100, 100, 200, 200 }; + PointInfo point = WindowHelper::CalculateOriginPosition(rect1, rect2, PointInfo{ 200, 200 }); + PointInfo expectPoint{ 5, 5 }; ASSERT_EQ(true, point.x == expectPoint.x); ASSERT_EQ(true, point.y == expectPoint.y); @@ -151,17 +152,18 @@ HWTEST_F(WindowHelperTest, CalculateOriginPosition, TestSize.Level1) transform.translateX_ = 100; transform.translateY_ = 200; transform.translateZ_ = 50; - Rect rect { 50, 50, 240, 320 }; + Rect rect{ 50, 50, 240, 320 }; TransformHelper::Vector3 pivotPos = { rect.posX_ + transform.pivotX_ * rect.width_, - rect.posY_ + transform.pivotY_ * rect.height_, 0 }; + rect.posY_ + transform.pivotY_ * rect.height_, + 0 }; TransformHelper::Matrix4 mat = TransformHelper::CreateTranslation(-pivotPos); mat *= WindowHelper::ComputeWorldTransformMat4(transform); mat *= TransformHelper::CreateTranslation(pivotPos); TransformHelper::Vector3 expectOriginPoint(0, 0, 0); TransformHelper::Vector3 tranformedPoint = TransformHelper::Transform(expectOriginPoint, mat); - PointInfo actialOriginPoint = WindowHelper::CalculateOriginPosition(mat, - { static_cast(tranformedPoint.x_), static_cast(tranformedPoint.y_) }); + PointInfo actialOriginPoint = WindowHelper::CalculateOriginPosition( + mat, { static_cast(tranformedPoint.x_), static_cast(tranformedPoint.y_) }); const float errorRange = 2.f; ASSERT_LT(std::abs(expectOriginPoint.x_ - actialOriginPoint.x), errorRange); ASSERT_LT(std::abs(expectOriginPoint.y_ - actialOriginPoint.y), errorRange); @@ -175,10 +177,11 @@ HWTEST_F(WindowHelperTest, CalculateOriginPosition, TestSize.Level1) HWTEST_F(WindowHelperTest, TransformRect, TestSize.Level1) { Transform transform; - Rect rect { 0, 0, 10, 20 }; + Rect rect{ 0, 0, 10, 20 }; transform.scaleX_ = transform.scaleY_ = 2.0f; TransformHelper::Vector3 pivotPos = { rect.posX_ + transform.pivotX_ * rect.width_, - rect.posY_ + transform.pivotY_ * rect.height_, 0 }; + rect.posY_ + transform.pivotY_ * rect.height_, + 0 }; TransformHelper::Matrix4 mat = TransformHelper::CreateTranslation(-pivotPos); mat *= WindowHelper::ComputeWorldTransformMat4(transform); mat *= TransformHelper::CreateTranslation(pivotPos); @@ -198,9 +201,10 @@ HWTEST_F(WindowHelperTest, CalculateHotZoneScale, TestSize.Level1) transform.scaleX_ = 0.66f; transform.scaleY_ = 1.5f; transform.pivotX_ = transform.pivotY_ = 0.5f; - Rect rect { -1, -2, 2, 4 }; + Rect rect{ -1, -2, 2, 4 }; TransformHelper::Vector3 pivotPos = { rect.posX_ + transform.pivotX_ * rect.width_, - rect.posY_ + transform.pivotY_ * rect.height_, 0 }; + rect.posY_ + transform.pivotY_ * rect.height_, + 0 }; TransformHelper::Matrix4 mat = TransformHelper::CreateTranslation(-pivotPos); mat *= WindowHelper::ComputeWorldTransformMat4(transform); mat *= TransformHelper::CreateTranslation(pivotPos); @@ -240,9 +244,10 @@ HWTEST_F(WindowHelperTest, GetTransformFromWorldMat4, TestSize.Level1) transform1.scaleY_ = 1.5f; transform1.translateX_ = 12.f; transform1.translateY_ = 45.f; - Rect rect1 { 0, 0, 300, 400 }; + Rect rect1{ 0, 0, 300, 400 }; TransformHelper::Vector3 pivotPos1 = { rect1.posX_ + transform1.pivotX_ * rect1.width_, - rect1.posY_ + transform1.pivotY_ * rect1.height_, 0 }; + rect1.posY_ + transform1.pivotY_ * rect1.height_, + 0 }; TransformHelper::Matrix4 mat1 = TransformHelper::CreateTranslation(-pivotPos1); mat1 *= WindowHelper::ComputeWorldTransformMat4(transform1); mat1 *= TransformHelper::CreateTranslation(pivotPos1); @@ -251,7 +256,8 @@ HWTEST_F(WindowHelperTest, GetTransformFromWorldMat4, TestSize.Level1) Transform transform2; WindowHelper::GetTransformFromWorldMat4(mat1, rect2, transform2); TransformHelper::Vector3 pivotPos2 = { rect2.posX_ + transform2.pivotX_ * rect2.width_, - rect2.posY_ + transform2.pivotY_ * rect2.height_, 0 }; + rect2.posY_ + transform2.pivotY_ * rect2.height_, + 0 }; TransformHelper::Matrix4 mat2 = TransformHelper::CreateTranslation(-pivotPos2); mat2 *= WindowHelper::ComputeWorldTransformMat4(transform2); mat2 *= TransformHelper::CreateTranslation(pivotPos2); @@ -310,6 +316,6 @@ HWTEST_F(WindowHelperTest, CheckButtonStyleValid, TestSize.Level1) style.buttonBackgroundCornerRadius = MAX_BUTTON_BACKGROUND_CORNER_RADIUS; ASSERT_TRUE(WindowHelper::CheckButtonStyleValid(style)); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/window_property_test.cpp b/utils/test/unittest/window_property_test.cpp index 798c5af315..c12cc92857 100644 --- a/utils/test/unittest/window_property_test.cpp +++ b/utils/test/unittest/window_property_test.cpp @@ -31,21 +31,13 @@ public: virtual void TearDown() override; }; -void WindowPropertyTest::SetUpTestCase() -{ -} +void WindowPropertyTest::SetUpTestCase() {} -void WindowPropertyTest::TearDownTestCase() -{ -} +void WindowPropertyTest::TearDownTestCase() {} -void WindowPropertyTest::SetUp() -{ -} +void WindowPropertyTest::SetUp() {} -void WindowPropertyTest::TearDown() -{ -} +void WindowPropertyTest::TearDown() {} namespace { /** @@ -77,7 +69,7 @@ HWTEST_F(WindowPropertyTest, MarshallingUnmarshalling, TestSize.Level1) */ HWTEST_F(WindowPropertyTest, CopyFrom, TestSize.Level1) { - const sptr winPropSrc = new(std::nothrow) WindowProperty(); + const sptr winPropSrc = new (std::nothrow) WindowProperty(); winPropSrc->SetPrivacyMode(true); winPropSrc->SetTransparent(true); winPropSrc->SetTransform(Transform::Identity()); @@ -221,7 +213,7 @@ HWTEST_F(WindowPropertyTest, AddWindowFlag001, TestSize.Level1) HWTEST_F(WindowPropertyTest, GetRequestRect001, TestSize.Level1) { WindowProperty winPropSrc; - Rect requestRect { 0, 0, 0, 0 }; + Rect requestRect{ 0, 0, 0, 0 }; winPropSrc.SetRequestRect(requestRect); Rect res = winPropSrc.GetRequestRect(); ASSERT_EQ(res, requestRect); @@ -660,6 +652,20 @@ HWTEST_F(WindowPropertyTest, GetTextFieldHeight36, TestSize.Level1) double res = winPropSrc.GetTextFieldHeight(); ASSERT_EQ(res, textFieldHeight); } + +/** + * @tc.name: GetFollowScreenChange37 + * @tc.desc: GetFollowScreenChange test + * @tc.type: FUNC + */ +HWTEST_F(WindowPropertyTest, GetFollowScreenChange37, TestSize.Level1) +{ + WindowProperty winPropSrc; + bool isFollowScreenChange = true; + winPropSrc.SetFollowScreenChange(isFollowScreenChange); + bool res = winPropSrc.GetFollowScreenChange(); + ASSERT_EQ(res, isFollowScreenChange); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/window_transition_info_test.cpp b/utils/test/unittest/window_transition_info_test.cpp index b8e236bcb1..32ae29dc4e 100644 --- a/utils/test/unittest/window_transition_info_test.cpp +++ b/utils/test/unittest/window_transition_info_test.cpp @@ -17,8 +17,8 @@ #include #include -#include "window_transition_info.h" #include "iremote_object_mocker.h" +#include "window_transition_info.h" using namespace testing; using namespace testing::ext; @@ -36,21 +36,13 @@ public: void SetTransitionInfo(sptr info); }; -void WindowTransitionInfoTest::SetUpTestCase() -{ -} +void WindowTransitionInfoTest::SetUpTestCase() {} -void WindowTransitionInfoTest::TearDownTestCase() -{ -} +void WindowTransitionInfoTest::TearDownTestCase() {} -void WindowTransitionInfoTest::SetUp() -{ -} +void WindowTransitionInfoTest::SetUp() {} -void WindowTransitionInfoTest::TearDown() -{ -} +void WindowTransitionInfoTest::TearDown() {} void WindowTransitionInfoTest::SetTransitionInfo(sptr info) { @@ -69,10 +61,10 @@ namespace { */ HWTEST_F(WindowTransitionInfoTest, WindowTransitionInfo01, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); info->bundleName_ = "TestAbilityTransitionInfo1"; - sptr winTransitionInfo1 = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo1 = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo1); ASSERT_EQ(info->bundleName_, winTransitionInfo1->bundleName_); ASSERT_EQ(3, winTransitionInfo1->supportWindowModes_.size()); @@ -82,7 +74,7 @@ HWTEST_F(WindowTransitionInfoTest, WindowTransitionInfo01, TestSize.Level1) info->bundleName_ = "TestAbilityTransitionInfo2"; info->windowModes_.emplace_back(AppExecFwk::SupportWindowMode::SPLIT); - sptr winTransitionInfo2 = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo2 = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo2); ASSERT_EQ(info->bundleName_, winTransitionInfo2->bundleName_); ASSERT_EQ(1, winTransitionInfo2->supportWindowModes_.size()); @@ -96,11 +88,11 @@ HWTEST_F(WindowTransitionInfoTest, WindowTransitionInfo01, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, Marshalling01, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); winTransitionInfo->bundleName_ = "bundleNameValue"; @@ -109,7 +101,7 @@ HWTEST_F(WindowTransitionInfoTest, Marshalling01, TestSize.Level1) bool result = winTransitionInfo->Marshalling(parcel); ASSERT_EQ(true, result); - sptr remote = new(std::nothrow) RemoteMocker(); + sptr remote = new (std::nothrow) RemoteMocker(); winTransitionInfo->abilityToken_ = remote; result = winTransitionInfo->Marshalling(parcel); ASSERT_EQ(true, result); @@ -122,17 +114,17 @@ HWTEST_F(WindowTransitionInfoTest, Marshalling01, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, Unmarshalling, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); winTransitionInfo->bundleName_ = "bundleNameValue"; winTransitionInfo->abilityName_ = "abilityNameValue"; - sptr remote = new(std::nothrow) RemoteMocker(); + sptr remote = new (std::nothrow) RemoteMocker(); winTransitionInfo->abilityToken_ = remote; auto result = winTransitionInfo->Marshalling(parcel); ASSERT_EQ(true, result); @@ -151,11 +143,11 @@ HWTEST_F(WindowTransitionInfoTest, Unmarshalling, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetBundleName, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); std::string name = "bundleNameValue"; winTransitionInfo->SetBundleName(name); @@ -170,11 +162,11 @@ HWTEST_F(WindowTransitionInfoTest, GetBundleName, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetAbilityName, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); std::string name = "abilityNameValue"; winTransitionInfo->SetAbilityName(name); @@ -189,13 +181,13 @@ HWTEST_F(WindowTransitionInfoTest, GetAbilityName, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetWindowMode, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); - WindowMode mode = WindowMode{1}; + WindowMode mode = WindowMode{ 1 }; winTransitionInfo->SetWindowMode(mode); auto ret = winTransitionInfo->GetWindowMode(); ASSERT_EQ(ret, mode); @@ -208,13 +200,13 @@ HWTEST_F(WindowTransitionInfoTest, GetWindowMode, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetWindowRect, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); - Rect rect = {0, 0, 50, 100}; + Rect rect = { 0, 0, 50, 100 }; winTransitionInfo->SetWindowRect(rect); auto ret = winTransitionInfo->GetWindowRect(); ASSERT_EQ(ret, rect); @@ -227,11 +219,11 @@ HWTEST_F(WindowTransitionInfoTest, GetWindowRect, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetAbilityToken, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); sptr abilityToken; winTransitionInfo->SetAbilityToken(abilityToken); @@ -246,11 +238,11 @@ HWTEST_F(WindowTransitionInfoTest, GetAbilityToken, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetDisplayId, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); winTransitionInfo->SetDisplayId(0); auto ret = winTransitionInfo->GetDisplayId(); @@ -264,13 +256,13 @@ HWTEST_F(WindowTransitionInfoTest, GetDisplayId, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetWindowType, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); - WindowType windowType = WindowType{1}; + WindowType windowType = WindowType{ 1 }; winTransitionInfo->SetWindowType(windowType); auto ret = winTransitionInfo->GetWindowType(); ASSERT_EQ(ret, windowType); @@ -283,11 +275,11 @@ HWTEST_F(WindowTransitionInfoTest, GetWindowType, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetShowFlagWhenLocked, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); winTransitionInfo->SetShowFlagWhenLocked(false); auto ret = winTransitionInfo->GetShowFlagWhenLocked(); @@ -301,15 +293,13 @@ HWTEST_F(WindowTransitionInfoTest, GetShowFlagWhenLocked, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetWindowSupportModes, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); - std::vector supportModesIn = { - AppExecFwk::SupportWindowMode::FULLSCREEN, - AppExecFwk::SupportWindowMode::SPLIT, - AppExecFwk::SupportWindowMode::FLOATING - }; + std::vector supportModesIn = { AppExecFwk::SupportWindowMode::FULLSCREEN, + AppExecFwk::SupportWindowMode::SPLIT, + AppExecFwk::SupportWindowMode::FLOATING }; winTransitionInfo->SetWindowSupportModes(supportModesIn); auto supportModesOut = winTransitionInfo->GetWindowSupportModes(); ASSERT_EQ(supportModesOut.size(), 3); @@ -325,7 +315,7 @@ HWTEST_F(WindowTransitionInfoTest, GetWindowSupportModes, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetWindowSizeLimits, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); info->maxWindowRatio_ = 2.0f; info->minWindowRatio_ = 1.0f; @@ -333,7 +323,7 @@ HWTEST_F(WindowTransitionInfoTest, GetWindowSizeLimits, TestSize.Level1) info->minWindowWidth_ = 512; info->maxWindowHeight_ = 2048; info->minWindowHeight_ = 512; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); auto windowSizeLimits = winTransitionInfo->GetWindowSizeLimits(); ASSERT_FLOAT_EQ(windowSizeLimits.maxRatio_, 2.0f); @@ -351,9 +341,9 @@ HWTEST_F(WindowTransitionInfoTest, GetWindowSizeLimits, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetTransitionReason, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); auto reasonIn = TransitionReason::MINIMIZE; @@ -394,9 +384,9 @@ HWTEST_F(WindowTransitionInfoTest, GetTransitionReason, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetOrientation01, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); auto orientationIn = AppExecFwk::DisplayOrientation::UNSPECIFIED; @@ -442,9 +432,9 @@ HWTEST_F(WindowTransitionInfoTest, GetOrientation01, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetOrientation02, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); auto orientationIn = AppExecFwk::DisplayOrientation::AUTO_ROTATION_LANDSCAPE; @@ -485,11 +475,11 @@ HWTEST_F(WindowTransitionInfoTest, GetOrientation02, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetIsRecent, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); winTransitionInfo->SetIsRecent(false); auto ret = winTransitionInfo->GetIsRecent(); @@ -503,11 +493,11 @@ HWTEST_F(WindowTransitionInfoTest, GetIsRecent, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetApiCompatibleVersion, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); winTransitionInfo->SetApiCompatibleVersion(100); auto ret = winTransitionInfo->GetApiCompatibleVersion(); @@ -521,16 +511,16 @@ HWTEST_F(WindowTransitionInfoTest, GetApiCompatibleVersion, TestSize.Level1) */ HWTEST_F(WindowTransitionInfoTest, GetMissionId, TestSize.Level1) { - sptr info = new(std::nothrow) AAFwk::AbilityTransitionInfo(); + sptr info = new (std::nothrow) AAFwk::AbilityTransitionInfo(); ASSERT_NE(nullptr, info); Parcel parcel; - sptr winTransitionInfo = new(std::nothrow) WindowTransitionInfo(info); + sptr winTransitionInfo = new (std::nothrow) WindowTransitionInfo(info); ASSERT_NE(nullptr, winTransitionInfo); winTransitionInfo->SetMissionId(0); auto ret = winTransitionInfo->GetMissionId(); ASSERT_EQ(ret, 0); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/wm_math_test.cpp b/utils/test/unittest/wm_math_test.cpp index 2b54c43a1c..5a2a2afccb 100644 --- a/utils/test/unittest/wm_math_test.cpp +++ b/utils/test/unittest/wm_math_test.cpp @@ -31,21 +31,13 @@ public: virtual void TearDown() override; }; -void WmMathTest::SetUpTestCase() -{ -} +void WmMathTest::SetUpTestCase() {} -void WmMathTest::TearDownTestCase() -{ -} +void WmMathTest::TearDownTestCase() {} -void WmMathTest::SetUp() -{ -} +void WmMathTest::SetUp() {} -void WmMathTest::TearDown() -{ -} +void WmMathTest::TearDown() {} namespace { /** @@ -186,6 +178,6 @@ HWTEST_F(WmMathTest, Invert04, TestSize.Level1) mat.Invert(); ASSERT_EQ(false, MathHelper::NearZero(0.f - mat.mat_[1][0])); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/wm_occlusion_region_test.cpp b/utils/test/unittest/wm_occlusion_region_test.cpp index ece676631b..731434104e 100644 --- a/utils/test/unittest/wm_occlusion_region_test.cpp +++ b/utils/test/unittest/wm_occlusion_region_test.cpp @@ -31,21 +31,13 @@ public: void TearDown() override; }; -void WmOcclusionRegionTest::SetUpTestCase() -{ -} +void WmOcclusionRegionTest::SetUpTestCase() {} -void WmOcclusionRegionTest::TearDownTestCase() -{ -} +void WmOcclusionRegionTest::TearDownTestCase() {} -void WmOcclusionRegionTest::SetUp() -{ -} +void WmOcclusionRegionTest::SetUp() {} -void WmOcclusionRegionTest::TearDown() -{ -} +void WmOcclusionRegionTest::TearDown() {} namespace { /** @@ -147,14 +139,14 @@ HWTEST_F(WmOcclusionRegionTest, GetAndRange01, TestSize.Level1) ASSERT_EQ(0, res.at(0).start_); ASSERT_EQ(2, res.at(0).end_); - rootNode->left_ = new Node { 0, 1 }; + rootNode->left_ = new Node{ 0, 1 }; rootNode->left_->positive_count_ = 1; rootNode->GetAndRange(res, false, true); ASSERT_EQ(2, res.size()); ASSERT_EQ(0, res[1].start_); ASSERT_EQ(1, res[1].end_); - rootNode->right_ = new Node { 1, 3 }; + rootNode->right_ = new Node{ 1, 3 }; rootNode->right_->negative_count_ = 1; rootNode->GetAndRange(res, true, false); ASSERT_EQ(2, res.size()); @@ -162,7 +154,7 @@ HWTEST_F(WmOcclusionRegionTest, GetAndRange01, TestSize.Level1) ASSERT_EQ(3, res[1].end_); delete rootNode->right_; - rootNode->right_ = new Node { 1, 4 }; + rootNode->right_ = new Node{ 1, 4 }; rootNode->right_->positive_count_ = 1; rootNode->right_->negative_count_ = 1; rootNode->GetAndRange(res, false, false); @@ -206,7 +198,7 @@ HWTEST_F(WmOcclusionRegionTest, GetOrRange01, TestSize.Level1) rootNode->GetOrRange(res, false, false); ASSERT_EQ(0, res.size()); - rootNode->left_ = new Node { 0, 1 }; + rootNode->left_ = new Node{ 0, 1 }; rootNode->left_->positive_count_ = 0; rootNode->left_->negative_count_ = 1; rootNode->GetOrRange(res, false, false); @@ -217,7 +209,7 @@ HWTEST_F(WmOcclusionRegionTest, GetOrRange01, TestSize.Level1) rootNode->left_ = nullptr; res.clear(); - rootNode->right_ = new Node { 1, 3 }; + rootNode->right_ = new Node{ 1, 3 }; rootNode->right_->positive_count_ = 0; rootNode->right_->negative_count_ = 1; rootNode->GetOrRange(res, false, false); @@ -258,7 +250,7 @@ HWTEST_F(WmOcclusionRegionTest, GetXOrRange01, TestSize.Level1) rootNode->GetXOrRange(res, false, false); ASSERT_EQ(0, res.size()); - rootNode->left_ = new Node { 0, 1 }; + rootNode->left_ = new Node{ 0, 1 }; rootNode->left_->positive_count_ = 0; rootNode->left_->negative_count_ = 1; rootNode->GetXOrRange(res, false, false); @@ -270,7 +262,7 @@ HWTEST_F(WmOcclusionRegionTest, GetXOrRange01, TestSize.Level1) rootNode->left_ = nullptr; res.clear(); - rootNode->right_ = new Node { 1, 3 }; + rootNode->right_ = new Node{ 1, 3 }; rootNode->right_->positive_count_ = 0; rootNode->right_->negative_count_ = 1; rootNode->GetXOrRange(res, false, false); @@ -308,7 +300,7 @@ HWTEST_F(WmOcclusionRegionTest, GetSubRange01, TestSize.Level1) rootNode->GetSubRange(res, false, false); ASSERT_EQ(0, res.size()); - rootNode->left_ = new Node { 0, 1 }; + rootNode->left_ = new Node{ 0, 1 }; rootNode->left_->positive_count_ = 1; rootNode->left_->negative_count_ = 0; rootNode->GetSubRange(res, false, false); @@ -320,7 +312,7 @@ HWTEST_F(WmOcclusionRegionTest, GetSubRange01, TestSize.Level1) rootNode->left_ = nullptr; res.clear(); - rootNode->right_ = new Node { 1, 3 }; + rootNode->right_ = new Node{ 1, 3 }; rootNode->right_->positive_count_ = 1; rootNode->right_->negative_count_ = 0; rootNode->GetSubRange(res, false, false); @@ -342,18 +334,16 @@ HWTEST_F(WmOcclusionRegionTest, UpdateRects01, TestSize.Level1) ASSERT_NE(region, nullptr); Region::Rects rects; rects.preRects = { - Rect{0, 10, 1, 10}, - Rect{3, 10, 1, 10}, - Rect{1, 10, 3, 10}, + Rect{ 0, 10, 1, 10 }, + Rect{ 3, 10, 1, 10 }, + Rect{ 1, 10, 3, 10 }, }; std::vector ranges = { - Range{0, 1}, - Range{1, 2}, - Range{3, 4}, - }; - std::vector indexAt = { - 0, 1, 2, 2, 3 + Range{ 0, 1 }, + Range{ 1, 2 }, + Range{ 3, 4 }, }; + std::vector indexAt = { 0, 1, 2, 2, 3 }; Region regionRes; region->UpdateRects(rects, ranges, indexAt, regionRes); @@ -364,7 +354,11 @@ HWTEST_F(WmOcclusionRegionTest, UpdateRects01, TestSize.Level1) } ASSERT_EQ(2, regionRes.GetRegionRects().size()); auto regionRects = regionRes.GetRegionRects(); - std::vector resultRegionRectsLeft = { 3, 1, 10, }; + std::vector resultRegionRectsLeft = { + 3, + 1, + 10, + }; for (uint32_t i = 0; i < regionRects.size(); ++i) { ASSERT_EQ(resultRegionRectsLeft[i], regionRects[i].left_); } @@ -389,10 +383,10 @@ HWTEST_F(WmOcclusionRegionTest, MakeBound01, TestSize.Level1) ASSERT_EQ(10, region->bound_.bottom_); region->rects_ = { - Rect{5, 5, 5, 5}, - Rect{6, 4, 6, 6}, - Rect{7, 6, 2, 8}, - Rect{8, 7, 7, 3}, + Rect{ 5, 5, 5, 5 }, + Rect{ 6, 4, 6, 6 }, + Rect{ 7, 6, 2, 8 }, + Rect{ 8, 7, 7, 3 }, }; region->MakeBound(); ASSERT_EQ(5, region->bound_.left_); @@ -419,14 +413,34 @@ HWTEST_F(WmOcclusionRegionTest, RegionOpLocal01, TestSize.Level1) regionBase.RegionOpLocal(region1, region2, regionRes, op); ASSERT_EQ(0, regionRes.GetRegionRects().size()); - region1.rects_.emplace_back(Rect{ 6, 7, 8, 9, }); - region1.rects_.emplace_back(Rect{ 10, 9, 8, 7, }); - region1.rects_.emplace_back(Rect{ 5, 6, 7, 8, }); - region1.rects_.emplace_back(Rect{ 11, 10, 9, 8, }); + region1.rects_.emplace_back(Rect{ + 6, + 7, + 8, + 9, + }); + region1.rects_.emplace_back(Rect{ + 10, + 9, + 8, + 7, + }); + region1.rects_.emplace_back(Rect{ + 5, + 6, + 7, + 8, + }); + region1.rects_.emplace_back(Rect{ + 11, + 10, + 9, + 8, + }); regionBase.RegionOpLocal(region1, region2, regionRes, op); ASSERT_EQ(3, regionRes.GetRegionRects().size()); } -} -} +} // namespace +} // namespace WmOcclusion } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 6d8d2204d8..930148c2f4 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -221,6 +221,8 @@ public: bool GetIsAbilityHookOff() const; void SetIsAbilityHook(bool isAbilityHook); bool GetIsAbilityHook() const; + void SetFollowScreenChange(bool isFollowScreenChange); + bool GetFollowScreenChange() const; /* * Sub Window @@ -331,6 +333,7 @@ private: bool WriteActionUpdateAvoidAreaOption(Parcel& parcel); bool WriteActionUpdateBackgroundAlpha(Parcel& parcel); bool WriteActionUpdateExclusivelyHighlighted(Parcel& parcel); + bool WriteActionUpdateFollowScreenChange(Parcel& parcel); void ReadActionUpdateTurnScreenOn(Parcel& parcel); void ReadActionUpdateKeepScreenOn(Parcel& parcel); void ReadActionUpdateViewKeepScreenOn(Parcel& parcel); @@ -361,6 +364,7 @@ private: void ReadActionUpdateAvoidAreaOption(Parcel& parcel); void ReadActionUpdateBackgroundAlpha(Parcel& parcel); void ReadActionUpdateExclusivelyHighlighted(Parcel& parcel); + void ReadActionUpdateFollowScreenChange(Parcel& parcel); std::string windowName_; SessionInfo sessionInfo_; mutable std::mutex windowRectMutex_; @@ -386,6 +390,7 @@ private: bool isPrivacyMode_ { false }; bool isSystemPrivacyMode_ { false }; bool isSnapshotSkip_ { false }; + bool isFollowScreenChange_ { false }; float brightness_ = UNDEFINED_BRIGHTNESS; uint64_t displayId_ = 0; int32_t parentId_ = INVALID_SESSION_ID; // parentId of sceneSession, which is low 32 bite of parentPersistentId_ diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index a810fdc2ee..ef0ebf73e1 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -93,6 +93,8 @@ const std::map WindowSessionProperty::writeFun &WindowSessionProperty::WriteActionUpdateBackgroundAlpha), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_EXCLUSIVE_HIGHLIGHTED), &WindowSessionProperty::WriteActionUpdateExclusivelyHighlighted), + std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE), + &WindowSessionProperty::WriteActionUpdateFollowScreenChange), }; const std::map WindowSessionProperty::readFuncMap_ { @@ -164,6 +166,8 @@ const std::map WindowSessionProperty::readFuncM &WindowSessionProperty::ReadActionUpdateBackgroundAlpha), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_EXCLUSIVE_HIGHLIGHTED), &WindowSessionProperty::ReadActionUpdateExclusivelyHighlighted), + std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE), + &WindowSessionProperty::ReadActionUpdateFollowScreenChange), }; WindowSessionProperty::WindowSessionProperty(const sptr& property) @@ -568,6 +572,16 @@ void WindowSessionProperty::SetMaximizeMode(MaximizeMode mode) maximizeMode_ = mode; } +void WindowSessionProperty::SetFollowScreenChange(bool isFollowScreenChange) +{ + isFollowScreenChange_ = isFollowScreenChange; +} + +bool WindowSessionProperty::GetFollowScreenChange() const +{ + return isFollowScreenChange_; +} + void WindowSessionProperty::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) { if (type == WindowType::WINDOW_TYPE_STATUS_BAR || @@ -1210,7 +1224,7 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const parcel.WriteFloat(cornerRadius_) && parcel.WriteBool(isExclusivelyHighlighted_) && parcel.WriteBool(isAtomicService_) && parcel.WriteUint32(apiVersion_) && parcel.WriteBool(isFullScreenWaterfallMode_) && parcel.WriteBool(isAbilityHookOff_) && - parcel.WriteBool(isAbilityHook_); + parcel.WriteBool(isAbilityHook_) && parcel.WriteBool(isFollowScreenChange_); } WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) @@ -1305,6 +1319,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) property->SetIsFullScreenWaterfallMode(parcel.ReadBool()); property->SetIsAbilityHookOff(parcel.ReadBool()); property->SetIsAbilityHook(parcel.ReadBool()); + property->SetFollowScreenChange(parcel.ReadBool()); return property; } @@ -1406,6 +1421,7 @@ void WindowSessionProperty::CopyFrom(const sptr& property isFullScreenWaterfallMode_ = property->isFullScreenWaterfallMode_; isAbilityHookOff_ = property->isAbilityHookOff_; isAbilityHook_ = property->isAbilityHook_; + isFollowScreenChange_ = property->isFollowScreenChange_; } bool WindowSessionProperty::Write(Parcel& parcel, WSPropertyChangeAction action) @@ -1572,6 +1588,11 @@ bool WindowSessionProperty::WriteActionUpdateExclusivelyHighlighted(Parcel& parc return parcel.WriteBool(isExclusivelyHighlighted_); } +bool WindowSessionProperty::WriteActionUpdateFollowScreenChange(Parcel& parcel) +{ + return parcel.WriteBool(isFollowScreenChange_); +} + void WindowSessionProperty::Read(Parcel& parcel, WSPropertyChangeAction action) { const auto funcIter = readFuncMap_.find(static_cast(action)); @@ -1738,6 +1759,11 @@ void WindowSessionProperty::ReadActionUpdateExclusivelyHighlighted(Parcel& parce SetExclusivelyHighlighted(parcel.ReadBool()); } +void WindowSessionProperty::ReadActionUpdateFollowScreenChange(Parcel& parcel) +{ + SetFollowScreenChange(parcel.ReadBool()); +} + void WindowSessionProperty::SetTransform(const Transform& trans) { trans_ = trans; diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index 7c19fe4543..a79ffdb8d6 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -440,7 +440,7 @@ struct SessionInfo { */ int32_t currentRotation_ = 0; - AAFwk::Want SafelyGetWant() const + AAFwk::Want GetWantSafely() const { std::lock_guard lock(*wantMutex_); if (want != nullptr) { @@ -450,7 +450,7 @@ struct SessionInfo { } } - void SafelySetWant(const AAFwk::Want& newWant) const + void SetWantSafely(const AAFwk::Want& newWant) const { std::lock_guard lock(*wantMutex_); if (want == nullptr) { @@ -530,6 +530,8 @@ enum class SessionEvent : uint32_t { EVENT_MAXIMIZE_WITHOUT_ANIMATION, EVENT_MAXIMIZE_WATERFALL, EVENT_WATERFALL_TO_MAXIMIZE, + EVENT_COMPATIBLE_TO_MAXIMIZE, + EVENT_COMPATIBLE_TO_RECOVER, EVENT_END }; diff --git a/window_scene/interfaces/include/ws_common_inner.h b/window_scene/interfaces/include/ws_common_inner.h index 540bd95b59..10143367e8 100644 --- a/window_scene/interfaces/include/ws_common_inner.h +++ b/window_scene/interfaces/include/ws_common_inner.h @@ -62,7 +62,8 @@ enum class WSPropertyChangeAction : uint64_t { ACTION_UPDATE_EXCLUSIVE_HIGHLIGHTED = 1llu << 35, ACTION_UPDATE_SUB_WINDOW_Z_LEVEL = 1llu << 36, ACTION_UPDATE_VIEW_KEEP_SCREEN_ON = 1llu << 37, - ACTION_UPDATE_END = ACTION_UPDATE_VIEW_KEEP_SCREEN_ON, + ACTION_UPDATE_FOLLOW_SCREEN_CHANGE = 1llu << 38, + ACTION_UPDATE_END = ACTION_UPDATE_FOLLOW_SCREEN_CHANGE, }; enum class AreaType : uint32_t { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 4205cefc87..dd78ae2e8f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -96,6 +96,7 @@ const std::string HIGHLIGHT_CHANGE_CB = "highlightChange"; const std::string SET_PARENT_SESSION_CB = "setParentSession"; const std::string UPDATE_FLAG_CB = "updateFlag"; const std::string Z_LEVEL_CHANGE_CB = "zLevelChange"; +const std::string UPDATE_FOLLOW_SCREEN_CHANGE_CB = "sessionUpdateFollowScreenChange"; constexpr int ARG_COUNT_1 = 1; constexpr int ARG_COUNT_2 = 2; @@ -181,6 +182,7 @@ const std::map ListenerFuncMap { {UPDATE_FLAG_CB, ListenerFuncType::UPDATE_FLAG_CB}, {Z_LEVEL_CHANGE_CB, ListenerFuncType::Z_LEVEL_CHANGE_CB}, {UPDATE_PIP_TEMPLATE_INFO_CB, ListenerFuncType::UPDATE_PIP_TEMPLATE_INFO_CB}, + {UPDATE_FOLLOW_SCREEN_CHANGE_CB, ListenerFuncType::UPDATE_FOLLOW_SCREEN_CHANGE_CB}, }; const std::vector g_syncGlobalPositionPermission { @@ -299,15 +301,43 @@ static void ParseMetadataConfiguration(napi_env env, napi_value objValue, const } } +napi_value JsSceneSession::GetJsPanelSessionObj(napi_env env, const sptr& session) +{ + if (session->GetWindowType() != WindowType::WINDOW_TYPE_KEYBOARD_PANEL) { + TLOGD(WmsLogTag::WMS_KEYBOARD, "This is not panel session"); + return nullptr; + } + int32_t persistentId = session->GetPersistentId(); + auto iter = jsSceneSessionMap_.find(persistentId); + if (iter != jsSceneSessionMap_.end()) { + const auto& ref = iter->second; + if (ref != nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Js panel session exists already and reuse it, id: %{public}d", + persistentId); + napi_value panelSessionObj = nullptr; + napi_get_reference_value(env, ref, &panelSessionObj); + return panelSessionObj; + } + } + TLOGI(WmsLogTag::WMS_KEYBOARD, "Not find js panel session"); + return nullptr; +} + napi_value JsSceneSession::Create(napi_env env, const sptr& session) { - napi_value objValue = nullptr; + if (session == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "session is null"); + return NapiGetUndefined(env); + } + napi_value objValue = JsSceneSession::GetJsPanelSessionObj(env, session); + if (objValue != nullptr) { + return objValue; + } napi_create_object(env, &objValue); - if (objValue == nullptr || session == nullptr) { - WLOGFE("Object or session is null!"); + if (objValue == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "objValue is null"); return NapiGetUndefined(env); } - sptr jsSceneSession = sptr::MakeSptr(env, session); jsSceneSession->IncStrongRef(nullptr); napi_wrap(env, objValue, jsSceneSession.GetRefPtr(), JsSceneSession::Finalizer, nullptr, nullptr); @@ -442,6 +472,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c JsSceneSession::SaveSnapshotAsync); BindNativeFunction(env, objValue, "setBorderUnoccupied", moduleName, JsSceneSession::SetBorderUnoccupied); + BindNativeFunction(env, objValue, "setEnableAddSnapshot", moduleName, + JsSceneSession::SetEnableAddSnapshot); BindNativeFunction(env, objValue, "setFreezeImmediately", moduleName, JsSceneSession::SetFreezeImmediately); BindNativeFunction(env, objValue, "throwSlipDirectly", moduleName, @@ -2446,6 +2478,13 @@ napi_value JsSceneSession::SetBorderUnoccupied(napi_env env, napi_callback_info return (me != nullptr) ? me->OnSetBorderUnoccupied(env, info) : nullptr; } +napi_value JsSceneSession::SetEnableAddSnapshot(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_SCB, "[NAPI]"); + JsSceneSession* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetEnableAddSnapshot(env, info) : nullptr; +} + napi_value JsSceneSession::SetFreezeImmediately(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::DEFAULT, "in"); @@ -2794,6 +2833,9 @@ void JsSceneSession::ProcessRegisterCallback(ListenerFuncType listenerFuncType) case static_cast(ListenerFuncType::UPDATE_FLAG_CB): ProcessUpdateFlagRegister(); break; + case static_cast(ListenerFuncType::UPDATE_FOLLOW_SCREEN_CHANGE_CB): + ProcessSessionUpdateFollowScreenChange(); + break; default: break; } @@ -6332,6 +6374,33 @@ napi_value JsSceneSession::OnSetBorderUnoccupied(napi_env env, napi_callback_inf return NapiGetUndefined(env); } +napi_value JsSceneSession::OnSetEnableAddSnapshot(napi_env env, napi_callback_info info) +{ + size_t argc = ARGC_FOUR; + napi_value argv[ARGC_FOUR] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != ARGC_ONE) { + TLOGE(WmsLogTag::WMS_PATTERN, "Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + bool enableAddSnapshot = true; + if (!ConvertFromJsValue(env, argv[0], enableAddSnapshot)) { + TLOGE(WmsLogTag::WMS_PATTERN, "Failed to convert parameter to enableAddSnapshot"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_PATTERN, "session is nullptr, id:%{public}d", persistentId_); + return NapiGetUndefined(env); + } + session->SetEnableAddSnapshot(enableAddSnapshot); + return NapiGetUndefined(env); +} + napi_value JsSceneSession::OnSetFreezeImmediately(napi_env env, napi_callback_info info) { size_t argc = ARGC_FOUR; @@ -7038,6 +7107,45 @@ void JsSceneSession::OnUpdateFlag(const std::string& flag) }, __func__); } +void JsSceneSession::ProcessSessionUpdateFollowScreenChange() +{ + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "session is nullptr, id:%{public}d", persistentId_); + return; + } + session->RegisterFollowScreenChangeCallback([weakThis = wptr(this)](bool isFollowScreenChange) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::DEFAULT, "jsSceneSession is null"); + return; + } + jsSceneSession->OnUpdateFollowScreenChange(isFollowScreenChange); + }); +} + +void JsSceneSession::OnUpdateFollowScreenChange(bool isFollowScreenChange) +{ + TLOGI(WmsLogTag::DEFAULT, "follow screen change: %{public}u", isFollowScreenChange); + std::string info = "OnUpdateFollowScreenChange, isFollowScreenChange:" + std::to_string(isFollowScreenChange); + taskScheduler_->PostMainThreadTask([weakThis = wptr(this), persistentId = persistentId_, + isFollowScreenChange, env = env_] { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) { + TLOGNE(WmsLogTag::DEFAULT, "jsSceneSession id:%{public}d has been destroyed", persistentId); + return; + } + auto jsCallBack = jsSceneSession->GetJSCallback(UPDATE_FOLLOW_SCREEN_CHANGE_CB); + if (!jsCallBack) { + TLOGNE(WmsLogTag::DEFAULT, "jsCallBack is nullptr"); + return; + } + napi_value followScreenChangeObj = CreateJsValue(env, isFollowScreenChange); + napi_value argv[] = { followScreenChangeObj }; + napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); + }, info); +} + napi_value JsSceneSession::OnSetCurrentRotation(napi_env env, napi_callback_info info) { size_t argc = ARGC_FOUR; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index 34653996d3..c6643de33f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -97,6 +97,7 @@ enum class ListenerFuncType : uint32_t { Z_LEVEL_CHANGE_CB, SESSION_GET_TARGET_ORIENTATION_CONFIG_INFO_CB, UPDATE_PIP_TEMPLATE_INFO_CB, + UPDATE_FOLLOW_SCREEN_CHANGE_CB, }; class SceneSession; @@ -124,6 +125,7 @@ private: void ProcessPendingSessionToForegroundRegister(); void ProcessPendingSessionToBackgroundForDelegatorRegister(); void ProcessSessionLockStateChangeRegister(); + void ProcessSessionUpdateFollowScreenChange(); void OnSessionLockStateChange(bool isLockedState); sptr GenSceneSession(SessionInfo& info); void PendingSessionActivation(SessionInfo& info); @@ -216,6 +218,7 @@ private: static napi_value SaveSnapshotSync(napi_env env, napi_callback_info info); static napi_value SaveSnapshotAsync(napi_env env, napi_callback_info info); static napi_value SetBorderUnoccupied(napi_env env, napi_callback_info info); + static napi_value SetEnableAddSnapshot(napi_env env, napi_callback_info info); static napi_value SetFreezeImmediately(napi_env env, napi_callback_info info); static napi_value SendContainerModalEvent(napi_env env, napi_callback_info info); static napi_value SetExclusivelyHighlighted(napi_env env, napi_callback_info info); @@ -298,6 +301,7 @@ private: napi_value OnSaveSnapshotSync(napi_env env, napi_callback_info info); napi_value OnSaveSnapshotAsync(napi_env env, napi_callback_info info); napi_value OnSetBorderUnoccupied(napi_env env, napi_callback_info info); + napi_value OnSetEnableAddSnapshot(napi_env env, napi_callback_info info); napi_value OnSetFreezeImmediately(napi_env env, napi_callback_info info); napi_value OnMaskSupportEnterWaterfallMode(napi_env env, napi_callback_info info); napi_value OnUpdateFullScreenWaterfallMode(napi_env env, napi_callback_info info); @@ -312,6 +316,7 @@ private: napi_value OnNotifyRotationChange(napi_env env, napi_callback_info info); napi_value OnSetCurrentRotation(napi_env env, napi_callback_info info); napi_value OnSetSidebarBlurMaximize(napi_env env, napi_callback_info info); + static napi_value GetJsPanelSessionObj(napi_env env, const sptr& session); bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject); void ProcessChangeSessionVisibilityWithStatusBarRegister(); @@ -447,6 +452,7 @@ private: void OnGetTargetOrientationConfigInfo(uint32_t targetOrientation); void OnRotationChange(int32_t persistentId, bool isRegister); void OnUpdatePiPTemplateInfo(PiPTemplateInfo& pipTemplateInfo); + void OnUpdateFollowScreenChange(bool isFollowScreenChange); /* * Window Property diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 3be378245f..8c574f2bc5 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -687,10 +687,10 @@ void JsSceneSessionManager::RegisterRootSceneCallbacksOnSSManager() [](const sptr& avoidArea, AvoidAreaType type, const sptr& info = nullptr) { RootScene::staticRootScene_->NotifyAvoidAreaChangeForRoot(avoidArea, type, info); }); - SceneSessionManager::GetInstance().RegisterNotifyRootSceneOccupiedAreaChangeFunc( - [](const sptr& info) { - RootScene::staticRootScene_->NotifyOccupiedAreaChangeForRoot(info); - }); + // SceneSessionManager::GetInstance().RegisterNotifyRootSceneOccupiedAreaChangeFunc( + // [](const sptr& info) { + // RootScene::staticRootScene_->NotifyOccupiedAreaChangeForRoot(info); + // }); SceneSessionManager::GetInstance().RegisterGetRSNodeByStringIDFunc( [](const std::string& id) { return RootScene::staticRootScene_->GetRSNodeByStringID(id); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index bfccdae3b0..5f5351b388 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -1225,7 +1225,7 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) CreateSupportWindowModes(env, sessionInfo.supportedWindowModes)); napi_set_named_property(env, objValue, "specifiedFlag", CreateJsValue(env, sessionInfo.specifiedFlag_)); if (sessionInfo.want != nullptr) { - napi_set_named_property(env, objValue, "want", AppExecFwk::WrapWant(env, sessionInfo.SafelyGetWant())); + napi_set_named_property(env, objValue, "want", AppExecFwk::WrapWant(env, sessionInfo.GetWantSafely())); } return objValue; } diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp index 4d6a269519..e4036934f0 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp @@ -46,6 +46,7 @@ const std::string ON_SECONDARY_REFLEXION_CHANGE_CALLBACK = "secondaryReflexionCh const std::string ON_CAMERA_BACKSELFIE_CHANGE_CALLBACK = "cameraBackSelfieChange"; const std::string ON_EXTEND_SCREEN_CONNECT_STATUS_CHANGE_CALLBACK = "extendScreenConnectStatusChange"; const std::string ON_BEFORE_PROPERTY_CHANGE_CALLBACK = "beforeScreenPropertyChange"; +const std::string ON_SCREEN_CHANGE_CALLBACK = "screenModeChange"; constexpr size_t ARGC_ONE = 1; } // namespace @@ -987,4 +988,38 @@ void JsScreenSession::OnBeforeScreenPropertyChange(FoldStatus foldStatus) TLOGE(WmsLogTag::DMS, "OnBeforeScreenPropertyChange: env is nullptr"); } } + +void JsScreenSession::OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) +{ + const std::string callbackType = ON_SCREEN_CHANGE_CALLBACK; + TLOGD(WmsLogTag::DMS, "Call js callback: %{public}s.", callbackType.c_str()); + if (mCallback_.count(callbackType) == 0) { + TLOGE(WmsLogTag::DMS, "Callback %{public}s is unregistered!", callbackType.c_str()); + return; + } + auto jsCallbackRef = mCallback_[callbackType]; + auto asyncTask = [jsCallbackRef, callbackType, screenModeChangeEvent, env = env_]() { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "jsScreenSession::OnScreenModeChange"); + if (jsCallbackRef == nullptr) { + TLOGNE(WmsLogTag::DMS, "Call js callback failed, jsCallbackRef is null!"); + return; + } + auto method = jsCallbackRef->GetNapiValue(); + if (method == nullptr) { + TLOGNE(WmsLogTag::DMS, "Call js callback failed, method is null!"); + return; + } + napi_value event = CreateJsValue(env, static_cast(screenModeChangeEvent)); + napi_value argv[] = { event }; + napi_call_function(env, NapiGetUndefined(env), method, ArraySize(argv), argv, nullptr); + }; + if (env_ != nullptr) { + napi_status ret = napi_send_event(env_, asyncTask, napi_eprio_immediate); + if (ret != napi_status::napi_ok) { + TLOGE(WmsLogTag::DMS, "OnScreenModeChange: Failed to SendEvent."); + } + } else { + TLOGE(WmsLogTag::DMS, "OnScreenModeChange: env is nullptr"); + } +} } // namespace OHOS::Rosen diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h index 0b92b5de0e..bebfa87257 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h @@ -68,6 +68,7 @@ private: void OnExtendScreenConnectStatusChange(ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus) override; void OnBeforeScreenPropertyChange(FoldStatus foldStatus) override; + void OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) override; napi_env env_; sptr screenSession_; diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index ce852910db..5959ee67d5 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -74,6 +74,8 @@ napi_value JsScreenSessionManager::Init(napi_env env, napi_value exportObj) JsScreenUtils::CreateJsSuperFoldStatus(env)); napi_set_named_property(env, exportObj, "ExtendScreenConnectStatus", JsScreenUtils::CreateJsExtendScreenConnectStatus(env)); + napi_set_named_property(env, exportObj, "ScreenModeChangeEvent", + JsScreenUtils::CreateJsScreenModeChangeEvent(env)); const char* moduleName = "JsScreenSessionManager"; BindNativeFunction(env, exportObj, "on", moduleName, JsScreenSessionManager::RegisterCallback); @@ -126,6 +128,8 @@ napi_value JsScreenSessionManager::Init(napi_env env, napi_value exportObj) JsScreenSessionManager::NotifyExtendScreenCreateFinish); BindNativeFunction(env, exportObj, "notifyExtendScreenDestroyFinish", moduleName, JsScreenSessionManager::NotifyExtendScreenDestroyFinish); + BindNativeFunction(env, exportObj, "notifyScreenMaskAppear", moduleName, + JsScreenSessionManager::NotifyScreenMaskAppear); return NapiGetUndefined(env); } @@ -320,6 +324,13 @@ napi_value JsScreenSessionManager::NotifyExtendScreenDestroyFinish(napi_env env, return (me != nullptr) ? me->OnNotifyExtendScreenDestroyFinish(env, info) : nullptr; } +napi_value JsScreenSessionManager::NotifyScreenMaskAppear(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::DMS, "[NAPI]NotifyScreenMaskAppear"); + JsScreenSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnNotifyScreenMaskAppear(env, info) : nullptr; +} + void JsScreenSessionManager::OnScreenConnected(const sptr& screenSession) { if (screenConnectionCallback_ == nullptr) { @@ -1081,4 +1092,10 @@ napi_value JsScreenSessionManager::OnNotifyExtendScreenDestroyFinish(napi_env en ScreenSessionManagerClient::GetInstance().NotifyExtendScreenDestroyFinish(); return NapiGetUndefined(env); } + +napi_value JsScreenSessionManager::OnNotifyScreenMaskAppear(napi_env env, const napi_callback_info info) +{ + ScreenSessionManagerClient::GetInstance().NotifyScreenMaskAppear(); + return NapiGetUndefined(env); +} } // namespace OHOS::Rosen diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h index 0aa9c979ca..e44fe9b042 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.h @@ -67,6 +67,7 @@ private: static napi_value SetDefaultMultiScreenModeWhenSwitchUser(napi_env env, napi_callback_info info); static napi_value NotifyExtendScreenCreateFinish(napi_env env, napi_callback_info info); static napi_value NotifyExtendScreenDestroyFinish(napi_env env, napi_callback_info info); + static napi_value NotifyScreenMaskAppear(napi_env env, napi_callback_info info); napi_value OnRegisterCallback(napi_env env, const napi_callback_info info); napi_value OnUpdateScreenRotationProperty(napi_env env, const napi_callback_info info); @@ -94,6 +95,7 @@ private: napi_value OnSetDefaultMultiScreenModeWhenSwitchUser(napi_env env, napi_callback_info info); napi_value OnNotifyExtendScreenCreateFinish(napi_env env, const napi_callback_info info); napi_value OnNotifyExtendScreenDestroyFinish(napi_env env, napi_callback_info info); + napi_value OnNotifyScreenMaskAppear(napi_env env, napi_callback_info info); std::shared_ptr screenConnectionCallback_; std::shared_ptr shutdownCallback_; diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp index 43f7dafc65..8949441824 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp @@ -223,6 +223,24 @@ napi_value JsScreenUtils::CreateJsExtendScreenConnectStatus(napi_env env) return objValue; } +napi_value JsScreenUtils::CreateJsScreenModeChangeEvent(napi_env env) +{ + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + WLOGFE("Failed to create object!"); + return NapiGetUndefined(env); + } + + napi_set_named_property(env, objValue, "SCREEN_MODE_CHANGE_EVENT_UNKNOWN", CreateJsValue(env, + static_cast(ScreenModeChangeEvent::UNKNOWN))); + napi_set_named_property(env, objValue, "SCREEN_MODE_CHANGE_EVENT_BEGIN", CreateJsValue(env, + static_cast(ScreenModeChangeEvent::BEGIN))); + napi_set_named_property(env, objValue, "SCREEN_MODE_CHANGE_EVENT_END", CreateJsValue(env, + static_cast(ScreenModeChangeEvent::END))); + return objValue; +} + bool ConvertRRectFromJs(napi_env env, napi_value jsObject, RRect& bound) { napi_value jsLeft = nullptr, jsTop = nullptr, jsWidth = nullptr, jsHeight = nullptr, jsRadius = nullptr; diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h index 12cca38632..665e7aa002 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h @@ -38,6 +38,7 @@ public: static napi_value CreateJsScreenPropertyChangeType(napi_env env); static napi_value CreateJsSuperFoldStatus(napi_env env); static napi_value CreateJsExtendScreenConnectStatus(napi_env env); + static napi_value CreateJsScreenModeChangeEvent(napi_env env); }; } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h index 75b88d7ce1..06315d7265 100644 --- a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h +++ b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h @@ -58,6 +58,8 @@ public: void HandleScreenConnectChange(); void HandleScreenDisconnectChange(); + void HandleFoldStatusLocked(); + void HandleFoldStatusUnlocked(); private: diff --git a/window_scene/screen_session_manager/include/multi_screen_change_utils.h b/window_scene/screen_session_manager/include/multi_screen_change_utils.h index 35b94cee4b..a2a9b2972a 100644 --- a/window_scene/screen_session_manager/include/multi_screen_change_utils.h +++ b/window_scene/screen_session_manager/include/multi_screen_change_utils.h @@ -66,6 +66,7 @@ private: static void ScreenPropertyChange(sptr& innerScreen, sptr& externalScreen); static void ScreenSerialNumberChange(sptr& innerScreen, sptr& externalScreen); static void ScreenActiveModesChange(sptr& innerScreen, sptr& externalScreen); + static void SetScreenNotifyFlag(sptr& innerScreen, sptr& externalScreen); }; } // Rosen } // OHOS diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index 3c3f02442b..5414bb1ddf 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -95,7 +95,8 @@ public: ScreenId GetInternalScreenId() override; bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override; - bool SetScreenPowerForSuperFoldDevice(ScreenId screenId, ScreenPowerState state); + bool SetScreenPowerByIdForPC(ScreenId screenId, ScreenPowerState state); + bool SetScreenPowerByIdDefault(ScreenId screenId, ScreenPowerState state); DisplayState GetDisplayState(DisplayId displayId) override; bool SetScreenBrightness(uint64_t screenId, uint32_t level) override; uint32_t GetScreenBrightness(uint64_t screenId) override; @@ -274,6 +275,8 @@ public: void SetIsExtendScreenConnected(bool isExtendScreenConnected); void HandleExtendScreenConnect(ScreenId screenId); void HandleExtendScreenDisconnect(ScreenId screenId); + bool GetIsFoldStatusLocked(); + void SetIsFoldStatusLocked(bool isFoldStatusLocked); bool GetIsOuterOnlyMode(); void SetIsOuterOnlyMode(bool isOuterOnlyMode); bool GetIsOuterOnlyModeBeforePowerOff(); @@ -393,11 +396,14 @@ public: void SwitchScrollParam(FoldDisplayMode displayMode); void OnScreenChange(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason = ScreenChangeReason::DEFAULT); + void OnScreenChangeForPC(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason); + void OnScreenChangeDefault(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason); void OnFoldScreenChange(sptr& screenSession); void SetCoordinationFlag(bool isCoordinationFlag); bool GetCoordinationFlag(void); DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, uint32_t& actualRefreshRate) override; + void OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) override; void SetLastScreenMode(sptr firstSession, sptr secondarySession); /* @@ -441,6 +447,7 @@ public: std::string DumperClientScreenSessions(); void SetMultiScreenModeChangeTracker(std::string changeProc); void SetRSScreenPowerStatus(ScreenId screenId, ScreenPowerStatus status); + void NotifyScreenMaskAppear() override; protected: ScreenSessionManager(); @@ -536,11 +543,16 @@ private: std::shared_ptr GetDisplayNodeByDisplayId(DisplayId displayId); void RefreshMirrorScreenRegion(ScreenId screenId); void IsEnableRegionRotation(sptr screenSession); - void CalculateXYPosition(sptr screenSession); + void CalculateXYPosition(sptr firstScreenSession, + sptr secondaryScreenSession = nullptr); + void CalculateSecondryXYPosition(sptr firstScreenSession, + + sptr secondaryScreenSession); bool IsSpecialApp(); void SetMultiScreenRelativePositionInner(sptr& firstScreenSession, sptr& secondScreenSession, MultiScreenPositionOptions mainScreenOptions, MultiScreenPositionOptions secondScreenOption); + void HandleSuperFoldStatusLocked(bool isLocked); #ifdef DEVICE_STATUS_ENABLE void SetDragWindowScreenId(ScreenId screenId, ScreenId displayNodeScreenId); #endif // DEVICE_STATUS_ENABLE @@ -636,6 +648,7 @@ private: bool isCoordinationFlag_ = false; bool isFoldScreenOuterScreenReady_ = false; bool isCameraBackSelfie_ = false; + bool isDeviceShutDown_ = false; uint32_t hdmiScreenCount_ = 0; uint32_t virtualScreenCount_ = 0; uint32_t currentExpandScreenCount_ = 0; @@ -658,6 +671,7 @@ private: bool isExtendScreenConnected_ = false; bool isOuterOnlyMode_ = false; bool isOuterOnlyModeBeforePowerOff_ = false; + std::atomic isFoldStatusLocked_ = false; /** * On/Off screen @@ -685,6 +699,10 @@ private: std::mutex snapBypickerMutex_; std::mutex switchUserMutex_; std::condition_variable switchUserCV_; + std::mutex screenPowerMutex_; + std::mutex screenChangeMutex_; + std::mutex screenMaskMutex_; + std::condition_variable screenMaskCV_; std::mutex freezedPidListMutex_; std::set freezedPidList_; diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h index a045255a11..22afa89355 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h @@ -252,6 +252,7 @@ public: virtual void SetDefaultMultiScreenModeWhenSwitchUser() {}; virtual void NotifyExtendScreenCreateFinish() {}; virtual void NotifyExtendScreenDestroyFinish() {}; + virtual void NotifyScreenMaskAppear() {}; }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h index 13ee34a911..051b142d2f 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h @@ -223,6 +223,7 @@ public: void SetDefaultMultiScreenModeWhenSwitchUser() override; void NotifyExtendScreenCreateFinish() override; void NotifyExtendScreenDestroyFinish() override; + void NotifyScreenMaskAppear() override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp index c3e8f29508..c0248ea572 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/secondary_display_fold_policy.cpp @@ -100,6 +100,10 @@ void SecondaryDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode display TLOGE(WmsLogTag::DMS, "default screenSession is null"); return; } + { + std::lock_guard lock_mode(displayModeMutex_); + lastDisplayMode_ = displayMode; + } if (displayMode == FoldDisplayMode::UNKNOWN) { TLOGW(WmsLogTag::DMS, "displayMode is unknown"); } else { @@ -109,7 +113,6 @@ void SecondaryDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode display { std::lock_guard lock_mode(displayModeMutex_); currentDisplayMode_ = displayMode; - lastDisplayMode_ = displayMode; } if (displayMode == FoldDisplayMode::GLOBAL_FULL) { TLOGW(WmsLogTag::DMS, "Set device status to STATUS_GLOBAL_FULL"); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp index 287ad032b3..009ca7e6d5 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp @@ -230,7 +230,8 @@ void SuperFoldSensorManager::NotifyHallChanged(uint16_t Hall) void SuperFoldSensorManager::HandleSuperSensorChange(SuperFoldStatusChangeEvents events) { // trigger events - if (ScreenSessionManager::GetInstance().GetIsExtendScreenConnected()) { + if (ScreenSessionManager::GetInstance().GetIsExtendScreenConnected() || + ScreenSessionManager::GetInstance().GetIsFoldStatusLocked()) { return; } SuperFoldStateManager::GetInstance().HandleSuperFoldStatusChange(events); @@ -249,6 +250,19 @@ void SuperFoldSensorManager::HandleScreenDisconnectChange() NotifyFoldAngleChanged(curAngle_); } +void SuperFoldSensorManager::HandleFoldStatusLocked() +{ + TLOGI(WmsLogTag::DMS, "Fold status locked to stop statemachine."); + SuperFoldStateManager::GetInstance().HandleScreenConnectChange(); +} + +void SuperFoldSensorManager::HandleFoldStatusUnlocked() +{ + TLOGI(WmsLogTag::DMS, "Fold status unlocked to start statemachine."); + NotifyHallChanged(curHall_); + NotifyFoldAngleChanged(curAngle_); +} + float SuperFoldSensorManager::GetCurAngle() { return curAngle_; diff --git a/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp b/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp index c4b2279fb3..b1401bd7ff 100644 --- a/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_change_utils.cpp @@ -107,9 +107,11 @@ void MultiScreenChangeUtils::ScreenMainPositionChange(sptr& inner return; } innerScreen->SetStartPosition(0, 0); + innerScreen->SetXYPosition(0, 0); innerScreen->PropertyChange(innerScreen->GetScreenProperty(), ScreenPropertyChangeReason::RELATIVE_POSITION_CHANGE); externalScreen->SetStartPosition(0, 0); + externalScreen->SetXYPosition(0, 0); externalScreen->PropertyChange(externalScreen->GetScreenProperty(), ScreenPropertyChangeReason::RELATIVE_POSITION_CHANGE); { @@ -257,6 +259,17 @@ void MultiScreenChangeUtils::ScreenPropertyChange(sptr& innerScre externalScreen->SetScreenProperty(innerPhyProperty); } +void MultiScreenChangeUtils::SetScreenNotifyFlag(sptr& innerScreen, + sptr& externalScreen) +{ + if (innerScreen == nullptr || externalScreen == nullptr) { + TLOGE(WmsLogTag::DMS, "screen sessions null."); + return; + } + innerScreen->SetIsAvailableAreaNeedNotify(true); + externalScreen->SetIsAvailableAreaNeedNotify(true); +} + void MultiScreenChangeUtils::ScreenPhysicalInfoChange(sptr& innerScreen, sptr& externalScreen) { @@ -288,6 +301,9 @@ void MultiScreenChangeUtils::ScreenPhysicalInfoChange(sptr& inner /* change active mode */ ScreenActiveModesChange(innerScreen, externalScreen); + + /* set notify flag */ + SetScreenNotifyFlag(innerScreen, externalScreen); oss.str(""); oss << "after innerScreen screenId: " << innerScreen->GetScreenId() << ", rsId: " << innerScreen->GetRSScreenId() diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index d0e387af22..52a869411f 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -158,6 +158,7 @@ const std::string SCREEN_EXTEND = "extend"; const std::string SCREEN_MIRROR = "mirror"; const std::string MULTI_SCREEN_EXIT_STR = "exit"; const std::string MULTI_SCREEN_ENTER_STR = "enter"; +const int32_t CV_WAIT_SCREEN_MASK_MS = 1500; #endif const bool IS_COORDINATION_SUPPORT = OHOS::system::GetBoolParameter("const.window.foldabledevice.is_coordination_support", false); @@ -778,6 +779,50 @@ void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenE screenId, static_cast(reason)); return; } + if (g_isPcDevice) { + OnScreenChangeForPC(screenId, screenEvent, reason); + } else { + OnScreenChangeDefault(screenId, screenEvent, reason); + } +} + +void ScreenSessionManager::OnScreenChangeForPC(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) +{ + std::lock_guard lock(screenChangeMutex_); + std::ostringstream oss; + oss << "OnScreenChange triggered. screenId: " << static_cast(screenId) + << " screenEvent: " << static_cast(screenEvent); + screenEventTracker_.RecordEvent(oss.str()); + TLOGW(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " screenEvent: %{public}d", + screenId, static_cast(screenEvent)); + SetScreenCorrection(); + auto screenSession = GetOrCreateScreenSession(screenId); + if (!screenSession) { + TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); + return; + } + if (g_isPcDevice) { + auto physicalScreenSession = GetOrCreatePhysicalScreenSession(screenId); + if (!physicalScreenSession) { + TLOGE(WmsLogTag::DMS, "physicalScreenSession is nullptr"); + return; + } + } + OnFoldScreenChange(screenSession); + if (screenEvent == ScreenEvent::CONNECTED) { + connectScreenNumber_ ++; + HandleScreenConnectEvent(screenSession, screenId, screenEvent); + } else if (screenEvent == ScreenEvent::DISCONNECTED) { + connectScreenNumber_ --; + HandleScreenDisconnectEvent(screenSession, screenId, screenEvent); + } else { + TLOGE(WmsLogTag::DMS, "screenEvent error!"); + } + NotifyScreenModeChange(); +} + +void ScreenSessionManager::OnScreenChangeDefault(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) +{ std::ostringstream oss; oss << "OnScreenChange triggered. screenId: " << static_cast(screenId) << " screenEvent: " << static_cast(screenEvent); @@ -1672,31 +1717,38 @@ std::vector ScreenSessionManager::GetAllDisplayIds() return res; } -void ScreenSessionManager::CalculateXYPosition(sptr screenSession) +void ScreenSessionManager::CalculateXYPosition(sptr firstScreenSession, + sptr secondaryScreenSession) { - if (screenSession == nullptr) { - TLOGI(WmsLogTag::DMS, "screenSession is nullptr"); - return; - } - if (screenSession->GetScreenProperty().GetScreenType() == ScreenType::REAL && screenSession->isInternal_) { - screenSession->SetXYPosition(0, 0); + if (firstScreenSession != nullptr && + firstScreenSession->GetScreenCombination() == ScreenCombination::SCREEN_MAIN) { + firstScreenSession->SetXYPosition(0, 0); + CalculateSecondryXYPosition(firstScreenSession, secondaryScreenSession); + } else if (secondaryScreenSession != nullptr && + secondaryScreenSession->GetScreenCombination() == ScreenCombination::SCREEN_MAIN) { + secondaryScreenSession->SetXYPosition(0, 0); + CalculateSecondryXYPosition(secondaryScreenSession, firstScreenSession); } else { - ScreenId internalScreenId = GetInternalScreenId(); - sptr internalSession = GetScreenSession(internalScreenId); - if (internalSession == nullptr) { - TLOGI(WmsLogTag::DMS, "internalSession is nullptr"); - return; - } - ScreenProperty internalScreenProperty = internalSession->GetScreenProperty(); - ScreenProperty secondaryScreenProperty = screenSession->GetScreenProperty(); - int32_t internalX = internalScreenProperty.GetStartX(); - int32_t internalY = internalScreenProperty.GetStartY(); - int32_t secondaryX = secondaryScreenProperty.GetStartX(); - int32_t secondaryY = secondaryScreenProperty.GetStartY(); - secondaryX = secondaryX + ~internalX + 1; - secondaryY = secondaryY + ~internalY + 1; - screenSession->SetXYPosition(secondaryX, secondaryY); + TLOGE(WmsLogTag::DMS, "CalculateXYPosition error!"); + } +} + +void ScreenSessionManager::CalculateSecondryXYPosition(sptr firstScreenSession, + sptr secondaryScreenSession) +{ + if (firstScreenSession == nullptr || secondaryScreenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); + return; } + ScreenProperty firstScreenProperty = firstScreenSession->GetScreenProperty(); + ScreenProperty secondaryScreenProperty = secondaryScreenSession->GetScreenProperty(); + uint32_t firstStartX = firstScreenProperty.GetStartX(); + uint32_t firstStartY = firstScreenProperty.GetStartY(); + uint32_t secondaryStartX = secondaryScreenProperty.GetStartX(); + uint32_t secondaryStartY = secondaryScreenProperty.GetStartY(); + int32_t secondaryX = -firstStartX + secondaryStartX; + int32_t secondaryY = -firstStartY + secondaryStartY; + secondaryScreenSession->SetXYPosition(secondaryX, secondaryY); } sptr ScreenSessionManager::GetScreenInfoById(ScreenId screenId) @@ -2781,8 +2833,20 @@ bool ScreenSessionManager::SetScreenPowerById(ScreenId screenId, ScreenPowerStat TLOGI(WmsLogTag::DMS, "screen id:%{public}" PRIu64 ", state:%{public}u, reason:%{public}u", screenId, state, static_cast(reason)); + bool isPowerSet = false; + if (g_isPcDevice) { + isPowerSet = SetScreenPowerByIdForPC(screenId, state); + } else { + isPowerSet = SetScreenPowerByIdDefault(screenId, state); + } + return isPowerSet; +} + +bool ScreenSessionManager::SetScreenPowerByIdForPC(ScreenId screenId, ScreenPowerState state) +{ + std::lock_guard lock(screenPowerMutex_); if (FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { - return SetScreenPowerForSuperFoldDevice(screenId, state); + return SetScreenPowerByIdDefault(screenId, state); } switch (state) { case ScreenPowerState::POWER_ON: { @@ -2812,7 +2876,7 @@ bool ScreenSessionManager::SetScreenPowerById(ScreenId screenId, ScreenPowerStat return true; } -bool ScreenSessionManager::SetScreenPowerForSuperFoldDevice(ScreenId screenId, ScreenPowerState state) +bool ScreenSessionManager::SetScreenPowerByIdDefault(ScreenId screenId, ScreenPowerState state) { ScreenPowerStatus status; switch (state) { @@ -3154,6 +3218,11 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta if (!GetPowerStatus(state, reason, status)) { return false; } + if (g_isPcDevice && reason == PowerStateChangeReason::POWER_BUTTON && state == ScreenPowerState::POWER_OFF) { + isDeviceShutDown_ = true; + } else { + isDeviceShutDown_ = false; + } gotScreenOffNotify_ = false; keyguardDrawnDone_ = false; TLOGI(WmsLogTag::DMS, "keyguardDrawnDone_ is false"); @@ -6708,6 +6777,7 @@ void ScreenSessionManager::SetDisplayScale(ScreenId screenId, float scaleX, floa void ScreenSessionManager::SetFoldStatusLocked(bool locked) { #ifdef FOLD_ABILITY_ENABLE + HandleSuperFoldStatusLocked(locked); if (!g_foldScreenFlag) { return; } @@ -6923,6 +6993,32 @@ void ScreenSessionManager::HandleExtendScreenDisconnect(ScreenId screenId) #endif } +bool ScreenSessionManager::GetIsFoldStatusLocked() +{ + return isFoldStatusLocked_; +} + +void ScreenSessionManager::SetIsFoldStatusLocked(bool isFoldStatusLocked) +{ + isFoldStatusLocked_ = isFoldStatusLocked; +} + +void ScreenSessionManager::HandleSuperFoldStatusLocked(bool isLocked) +{ +#ifdef FOLD_ABILITY_ENABLE + if (!FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + TLOGI(WmsLogTag::DMS, "not super fold display device."); + return; + } + SetIsFoldStatusLocked(isLocked); + if (isLocked == true) { + SuperFoldSensorManager::GetInstance().HandleFoldStatusLocked(); + } else { + SuperFoldSensorManager::GetInstance().HandleFoldStatusUnlocked(); + } +#endif +} + bool ScreenSessionManager::GetIsOuterOnlyMode() { return isOuterOnlyMode_; @@ -7337,7 +7433,7 @@ void ScreenSessionManager::SwitchUser() if (g_isPcDevice && userSwitching_) { std::unique_lock lock(switchUserMutex_); if (switchUserCV_.wait_for(lock, std::chrono::milliseconds(CV_WAIT_USERSWITCH_MS)) == std::cv_status::timeout) { - TLOGI(WmsLogTag::DMS, "wait switchUserCV_timeout"); + TLOGI(WmsLogTag::DMS, "wait switchUserCV_ timeout"); userSwitching_ = false; } } @@ -7710,6 +7806,10 @@ void ScreenSessionManager::RecoverMultiScreenMode(sptr screenSess TLOGI(WmsLogTag::DMS, "not PC or not real screen, no need recover!"); return; } + if (isDeviceShutDown_) { + TLOGI(WmsLogTag::DMS, "device shut down, no need recover!"); + return; + } sptr internalSession = GetInternalScreenSession(); if (!RecoverRestoredMultiScreenMode(screenSession)) { if (internalSession == nullptr) { @@ -8678,11 +8778,10 @@ void ScreenSessionManager::SetMultiScreenRelativePositionInner(sptrSetStartPosition(mainScreenOptions.startX_, mainScreenOptions.startY_); - CalculateXYPosition(firstScreenSession); firstScreenSession->PropertyChange(firstScreenSession->GetScreenProperty(), ScreenPropertyChangeReason::RELATIVE_POSITION_CHANGE); secondScreenSession->SetStartPosition(secondScreenOption.startX_, secondScreenOption.startY_); - CalculateXYPosition(secondScreenSession); + CalculateXYPosition(firstScreenSession, secondScreenSession); secondScreenSession->PropertyChange(secondScreenSession->GetScreenProperty(), ScreenPropertyChangeReason::RELATIVE_POSITION_CHANGE); if (g_isPcDevice) { @@ -8691,6 +8790,7 @@ void ScreenSessionManager::SetMultiScreenRelativePositionInner(sptrSetStartPosition(mainScreenOptions.startX_, mainScreenOptions.startY_); secondPhysicalScreen->SetStartPosition(secondScreenOption.startX_, secondScreenOption.startY_); + CalculateXYPosition(firstPhysicalScreen, secondPhysicalScreen); } } std::shared_ptr firstDisplayNode = firstScreenSession->GetDisplayNode(); @@ -8743,6 +8843,14 @@ void ScreenSessionManager::MultiScreenModeChange(ScreenId mainScreenId, ScreenId #ifdef WM_MULTI_SCREEN_ENABLE TLOGW(WmsLogTag::DMS, "mainId=%{public}" PRIu64" secondId=%{public}" PRIu64" operateType: %{public}s", mainScreenId, secondaryScreenId, operateMode.c_str()); + OnScreenModeChange(ScreenModeChangeEvent::BEGIN); + if (g_isPcDevice) { + std::unique_lock lock(screenMaskMutex_); + if (screenMaskCV_.wait_for(lock, + std::chrono::milliseconds(CV_WAIT_SCREEN_MASK_MS)) == std::cv_status::timeout) { + TLOGI(WmsLogTag::DMS, "wait screenMaskMutex_ timeout"); + } + } sptr firstSession = nullptr; sptr secondarySession = nullptr; OperateModeChange(mainScreenId, secondaryScreenId, firstSession, secondarySession, operateMode); @@ -8764,6 +8872,8 @@ void ScreenSessionManager::MultiScreenModeChange(ScreenId mainScreenId, ScreenId } else { TLOGE(WmsLogTag::DMS, "params error"); } + NotifyScreenModeChange(); + OnScreenModeChange(ScreenModeChangeEvent::END); #endif } @@ -9695,4 +9805,25 @@ void ScreenSessionManager::SetRSScreenPowerStatus(ScreenId screenId, ScreenPower #endif } } + +void ScreenSessionManager::OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) +{ + TLOGI(WmsLogTag::DMS, "screenModeChangeEvent: %{public}d", static_cast(screenModeChangeEvent)); + auto clientProxy = GetClientProxy(); + if (!clientProxy) { + TLOGE(WmsLogTag::DMS, "clientProxy_ is null"); + return; + } + clientProxy->OnScreenModeChanged(screenModeChangeEvent); +} + +void ScreenSessionManager::NotifyScreenMaskAppear() +{ + if (!g_isPcDevice) { + TLOGW(WmsLogTag::DMS, "not pc device."); + return; + } + TLOGI(WmsLogTag::DMS, "screen mask appeared, notify block"); + screenMaskCV_.notify_all(); +} } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp index eef8891c2f..79c37dbc07 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -4192,4 +4192,25 @@ void ScreenSessionManagerProxy::NotifyExtendScreenDestroyFinish() } } +void ScreenSessionManagerProxy::NotifyScreenMaskAppear() +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is null"); + return; + } + + MessageParcel reply; + MessageParcel data; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_NOTIFY_SCREEN_MASK_APPEAR), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return; + } +} } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp index 13769271fe..d4ab088840 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp @@ -1164,6 +1164,10 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& NotifyExtendScreenDestroyFinish(); break; } + case DisplayManagerMessage::TRANS_ID_NOTIFY_SCREEN_MASK_APPEAR: { + NotifyScreenMaskAppear(); + break; + } default: TLOGW(WmsLogTag::DMS, "unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); diff --git a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h index c0b811dfc1..ecc1bc5d46 100644 --- a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h @@ -115,6 +115,7 @@ public: void SetDefaultMultiScreenModeWhenSwitchUser(); void NotifyExtendScreenCreateFinish(); void NotifyExtendScreenDestroyFinish(); + void NotifyScreenMaskAppear(); protected: ScreenSessionManagerClient() = default; @@ -142,6 +143,7 @@ private: void OnExtendScreenConnectStatusChanged(ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus) override; void OnBeforeScreenPropertyChanged(FoldStatus foldStatus) override; + void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) override; void SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) override; void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override; diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h index bcc0a4b958..6997dc08d1 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h @@ -56,6 +56,7 @@ public: TRANS_ID_SET_SCREEN_COMBINATION, TRANS_ID_ON_DUMP_SCREEN_SESSION, TRANS_ID_ON_BEFORE_PROPERTY_CHANGED, + TRANS_ID_ON_SCREEN_MODE_CHANGED, }; virtual void SwitchUserCallback(std::vector oldScbPids, int32_t currentScbPid) = 0; @@ -94,6 +95,7 @@ public: virtual void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, ScreenCombination extendCombination) = 0; virtual std::string OnDumperClientScreenSessions() = 0; + virtual void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) = 0; }; } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h index 1b1cc8ac81..c9a1a6592b 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h @@ -62,6 +62,7 @@ public: ScreenCombination extendCombination) override; std::string OnDumperClientScreenSessions() override; void OnBeforeScreenPropertyChanged(FoldStatus foldStatus) override; + void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) override; private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h index a7bd3085bf..f30fc94232 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h @@ -62,6 +62,7 @@ private: int HandleSyncScreenCombination(MessageParcel& data, MessageParcel& reply); int HandleOnDumperClientScreenSessions(MessageParcel& data, MessageParcel& reply); int HandleOnBeforeScreenPropertyChange(MessageParcel& data, MessageParcel& reply); + int HandleOnScreenModeChanged(MessageParcel& data, MessageParcel& reply); HandleScreenChangeMap HandleScreenChangeMap_ {}; }; diff --git a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp index b0a2cfb9f7..0aa1bd40b2 100644 --- a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp @@ -805,6 +805,10 @@ void ScreenSessionManagerClient::UpdatePropertyWhenSwitchUser(const sptr SetPhysicalRotation(rotation); screenSession->SetScreenComponentRotation(rotation); + screenSessionManager_->UpdateScreenDirectionInfo(screenId, rotation, rotation, rotation, + ScreenPropertyChangeType::UNSPECIFIED); + screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation, + ScreenPropertyChangeType::UNSPECIFIED); ScreenProperty property = screenSessionManager_->GetScreenProperty(screenId); if (property.GetValidHeight() == INT32_MAX || property.GetValidHeight() == 0) { WLOGFW("invalid property, validheight is bounds"); @@ -818,10 +822,6 @@ void ScreenSessionManagerClient::UpdatePropertyWhenSwitchUser(const sptr SetValidWidth(property.GetValidWidth()); } - screenSessionManager_->UpdateScreenDirectionInfo(screenId, rotation, rotation, rotation, - ScreenPropertyChangeType::UNSPECIFIED); - screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation, - ScreenPropertyChangeType::UNSPECIFIED); } void ScreenSessionManagerClient::NotifyClientScreenConnect(sptr& screenSession) @@ -1126,4 +1126,24 @@ void ScreenSessionManagerClient::OnBeforeScreenPropertyChanged(FoldStatus foldSt TLOGI(WmsLogTag::DMS, "fold status %{public}d", foldStatus); screenSession->BeforeScreenPropertyChange(foldStatus); } + +void ScreenSessionManagerClient::OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) +{ + auto screenSession = GetScreenSession(GetDefaultScreenId()); + if (!screenSession) { + WLOGFE("screenSession is null"); + return; + } + WLOGI("screenModeChangeEvent=%{public}d", static_cast(screenModeChangeEvent)); + screenSession->ScreenModeChange(screenModeChangeEvent); +} + +void ScreenSessionManagerClient::NotifyScreenMaskAppear() +{ + if (!screenSessionManager_) { + TLOGE(WmsLogTag::DMS, "screenSessionManager_ is null"); + return; + } + return screenSessionManager_->NotifyScreenMaskAppear(); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp index bc39632e48..b9a262e544 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp @@ -899,4 +899,30 @@ void ScreenSessionManagerClientProxy::OnBeforeScreenPropertyChanged(FoldStatus f return; } } + +void ScreenSessionManagerClientProxy::OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) +{ + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::DMS, "remote is nullptr"); + return; + } + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); + return; + } + if (!data.WriteUint32(static_cast(screenModeChangeEvent))) { + TLOGE(WmsLogTag::DMS, "Write screen mode change event failed"); + return; + } + if (remote->SendRequest( + static_cast(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_MODE_CHANGED), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::DMS, "SendRequest failed"); + return; + } +} } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp index 1806411660..b2873b8ed8 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp @@ -140,6 +140,10 @@ void ScreenSessionManagerClientStub::InitScreenChangeMap() [this](MessageParcel& data, MessageParcel& reply) { return HandleOnBeforeScreenPropertyChange(data, reply); }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_MODE_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnScreenModeChanged(data, reply); + }; } ScreenSessionManagerClientStub::ScreenSessionManagerClientStub() @@ -464,4 +468,12 @@ int ScreenSessionManagerClientStub::HandleOnBeforeScreenPropertyChange(MessagePa OnBeforeScreenPropertyChanged(foldStatus); return ERR_NONE; } + +int ScreenSessionManagerClientStub::HandleOnScreenModeChanged(MessageParcel& data, MessageParcel& reply) +{ + auto screenModeChangeEvent = static_cast(data.ReadUint32()); + TLOGI(WmsLogTag::DMS, "screenModeChangeEvent: %{public}d", screenModeChangeEvent); + OnScreenModeChanged(screenModeChangeEvent); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/ability_info_manager.h b/window_scene/session/host/include/ability_info_manager.h index 768c0352a4..f6580dfb76 100644 --- a/window_scene/session/host/include/ability_info_manager.h +++ b/window_scene/session/host/include/ability_info_manager.h @@ -27,12 +27,17 @@ namespace OHOS::AppExecFwk { class IBundleMgr; +struct AbilityInfo; +struct BundleInfo; } // namespace OHOS::AppExecFwk namespace OHOS::Rosen { class AbilityInfoManager { WM_DECLARE_SINGLE_INSTANCE(AbilityInfoManager); public: + static bool FindAbilityInfo(const AppExecFwk::BundleInfo& bundleInfo, + const std::string& moduleName, const std::string& abilityName, AppExecFwk::AbilityInfo& abilityInfo); + void Init(const sptr& bundleMgr); void SetCurrentUserId(int32_t userId); diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index a1963fb40d..ab9fc1435f 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -93,11 +93,6 @@ private: WSRect GetPanelRect() const; void SetCallingSessionId(uint32_t callingSessionId) override; - - void NotifyOccupiedAreaChangeInfo(const sptr& callingSession, const WSRect& rect, - const WSRect& occupiedArea, const std::shared_ptr& rsTransaction = nullptr); - void RaiseCallingSession(uint32_t callingId, const WSRect& keyboardPanelRect, bool needCheckVisible, - const std::shared_ptr& rsTransaction); void UpdateKeyboardAvoidArea(); void UseFocusIdIfCallingSessionIdInvalid(); void NotifyKeyboardPanelInfoChange(WSRect rect, bool isKeyboardPanelShow); @@ -113,12 +108,11 @@ private: bool IsNeedRaiseSubWindow(const sptr& callingSession, const WSRect& callingSessionRect); void PostKeyboardAnimationSyncTimeoutTask(); bool GetKeyboardSyncTransactionStatus() override; - void NotifyOccupiedArea(const sptr& occupiedAreaInfo, - const bool& isKeyboardSyncTransactionOpen = false, + void NotifyOccupiedAreaChangeInfo(const sptr& occupiedAreaInfo, std::shared_ptr rsTransaction = nullptr) override; - bool CalculateRectAndAvoidArea(sptr& occupiedAreaInfo, + bool RaiseCallingSession(sptr& occupiedAreaInfo, const bool& needCheckVisible) override; - bool CalculateRectAndAvoidAreaInner(const sptr& callingSession, const WSRect& rect, + bool CalculateOccupiedArea(const sptr& callingSession, const WSRect& callingSessionRect, const WSRect& panelRect, sptr& occupiedAreaInfo); sptr keyboardCallback_ = nullptr; diff --git a/window_scene/session/host/include/pc_fold_screen_manager.h b/window_scene/session/host/include/pc_fold_screen_manager.h index 9ea3b46a82..cb9c77f5a8 100644 --- a/window_scene/session/host/include/pc_fold_screen_manager.h +++ b/window_scene/session/host/include/pc_fold_screen_manager.h @@ -67,6 +67,7 @@ public: void UpdateSystemKeyboardStatus(bool hasSystemKeyboard); bool HasSystemKeyboard() const; + int32_t GetVirtualDisplayPosY() const; std::tuple GetDisplayRects() const; // animation parameters @@ -76,6 +77,7 @@ public: RSAnimationTimingCurve GetThrowSlipTimingCurve(); ScreenSide CalculateScreenSide(const WSRect& rect); + ScreenSide CalculateScreenSide(int32_t posY); bool IsCrossFoldCrease(const WSRect& rect); void ResetArrangeRule(); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 6f1d1e5f9a..4202c42ac2 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -128,6 +128,7 @@ using NotifyUpdateFlagFunc = std::function; using NotifyRotationChangeFunc = std::function; using NotifyHookSceneSessionActivationFunc = std::function& session, bool isNewWant)>; using NotifySceneSessionDestructFunc = std::function; +using NotifyFollowScreenChangeFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; @@ -164,6 +165,7 @@ public: NotifyAvoidAreaChangeCallback onNotifyAvoidAreaChange_; GetKeyboardOccupiedAreaWithRotationCallback onKeyboardRotationChange_; GetSceneSessionByIdCallback onGetSceneSessionByIdCallback_; + NotifyFollowScreenChangeFunc onUpdateFollowScreenChange_; }; // func for change window scene pattern property @@ -392,7 +394,7 @@ public: virtual WMError NotifySetParentSession(int32_t oldParentWindowId, int32_t newParentWindowId) { return WMError::WM_ERROR_INVALID_WINDOW; } void UpdateSubWindowLevel(uint32_t subWindowLevel); - int GetMaxSubWindowLevel() const; + uint32_t GetMaxSubWindowLevel() const; /* * Window Immersive @@ -521,6 +523,8 @@ public: RotationChangeResult NotifyRotationChange(const RotationChangeInfo& rotationChangeInfo); bool isRotationChangeCallbackRegistered = false; WSError SetCurrentRotation(int32_t currentRotation); + void RegisterFollowScreenChangeCallback(NotifyFollowScreenChangeFunc&& callback); + WSError UpdateFollowScreenChange(bool isFollowScreenChange); /* * Window Animation @@ -739,10 +743,9 @@ public: void NotifyKeyboardDidHideRegistered(bool registered) override; IsLastFrameLayoutFinishedFunc GetIsLastFrameLayoutFinishedFunc(); virtual bool GetKeyboardSyncTransactionStatus() { return false; } - virtual bool CalculateRectAndAvoidArea(sptr& occupiedAreaInfo, - const bool& needCheckVisible) { return true; } - virtual void NotifyOccupiedArea(const sptr& occupiedAreaInfo, - const bool& isKeyboardSyncTransactionOpen = false, + virtual bool RaiseCallingSession(sptr& occupiedAreaInfo, + const bool& needCheckVisible) { return false; } + virtual void NotifyOccupiedAreaChangeInfo(const sptr& occupiedAreaInfo, std::shared_ptr rsTransaction = nullptr) {} /* @@ -954,6 +957,11 @@ private: WSError InitializeMoveInputBar(); void HandleMoveDragSurfaceBounds(WSRect& rect, WSRect& globalRect, SizeChangeReason reason); void HandleMoveDragEnd(WSRect& rect, SizeChangeReason reason); + void WindowScaleTransfer(WSRect& rect, float scaleX, float scaleY); + void HookStartMoveRect(WSRect& newRect, const WSRect& sessionRect); + bool IsCompatibilityModeScale(float scaleX, float scaleY); + void CompatibilityModeWindowScaleTransfer(WSRect& rect, bool isScale); + void ThrowSlipToFullScreen(WSRect& endRect, WSRect& rect); bool MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeReason reason); void NotifyFullScreenAfterThrowSlip(const WSRect& rect); void SetDragResizeTypeDuringDrag(DragResizeType dragResizeType) { dragResizeTypeDuringDrag_ = dragResizeType; } @@ -1059,6 +1067,8 @@ private: WMError HandleBackgroundAlpha(const sptr& property, WSPropertyChangeAction action); WMError HandleActionUpdateExclusivelyHighlighted(const sptr& property, WSPropertyChangeAction action); + WMError HandleActionUpdateFollowScreenChange(const sptr& property, + WSPropertyChangeAction action); void HandleSpecificSystemBarProperty(WindowType type, const sptr& property); void SetWindowFlags(const sptr& property); void NotifySessionChangeByActionNotifyManager(const sptr& property, @@ -1080,6 +1090,7 @@ private: std::vector> toastSession_; std::atomic_bool needStartingWindowExitAnimation_ { true }; bool needDefaultAnimationFlag_ = true; + bool isFollowScreenChange_ = false; SessionEventParam sessionEventParam_ = { 0, 0, 0, 0, 0 }; std::atomic_bool isStartMoving_ { false }; std::atomic_bool isVisibleForAccessibility_ { true }; @@ -1191,6 +1202,8 @@ private: */ NotifyReqOrientationChangeFunc onRequestedOrientationChange_; NotifyRotationChangeFunc onUpdateRotationChangeFunc_; + bool GetFollowScreenChange() const; + void SetFollowScreenChange(bool isFollowScreenChange); /* * Window Animation diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 6d17565478..a5d3275e71 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -266,6 +266,8 @@ public: addSnapshotCallback_ = std::move(task); } } + void SetEnableAddSnapshot(bool enableAddSnapshot = true); + bool GetEnableAddSnapshot() const; SessionState GetSessionState() const; virtual void SetSessionState(SessionState state); @@ -1021,6 +1023,7 @@ private: /* * Window Scene Snapshot */ + std::atomic enableAddSnapshot_ = true; Task saveSnapshotCallback_ = []() {}; Task removeSnapshotCallback_ = []() {}; Task addSnapshotCallback_ = []() {}; diff --git a/window_scene/session/host/src/ability_info_manager.cpp b/window_scene/session/host/src/ability_info_manager.cpp index c1f0c01b36..f0abdf0105 100644 --- a/window_scene/session/host/src/ability_info_manager.cpp +++ b/window_scene/session/host/src/ability_info_manager.cpp @@ -23,6 +23,23 @@ namespace OHOS::Rosen { WM_IMPLEMENT_SINGLE_INSTANCE(AbilityInfoManager); +bool AbilityInfoManager::FindAbilityInfo(const AppExecFwk::BundleInfo& bundleInfo, + const std::string& moduleName, const std::string& abilityName, AppExecFwk::AbilityInfo& abilityInfo) +{ + auto& hapModulesList = bundleInfo.hapModuleInfos; + for (auto& hapModule : hapModulesList) { + auto& abilityInfoList = hapModule.abilityInfos; + for (auto& ability : abilityInfoList) { + if (ability.moduleName == moduleName && ability.name == abilityName) { + abilityInfo = ability; + return true; + } + } + } + TLOGW(WmsLogTag::DEFAULT, "ability info not found, bundle:%{public}s", bundleInfo.name.c_str()); + return false; +} + void AbilityInfoManager::Init(const sptr& bundleMgr) { if (bundleMgr == nullptr) { diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index cd23e5b220..aa0cbc2eb9 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -312,7 +312,7 @@ WSError KeyboardSession::AdjustKeyboardLayout(const KeyboardLayoutParams& params // avoidHeight is set, notify avoidArea in case ui params don't flush if (params.landscapeAvoidHeight_ >= 0 && params.portraitAvoidHeight_ >= 0) { sptr occupiedAreaInfo = nullptr; - bool occupiedAreaChanged = session->CalculateRectAndAvoidArea(occupiedAreaInfo, true); + bool occupiedAreaChanged = session->RaiseCallingSession(occupiedAreaInfo, true); if (occupiedAreaInfo == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- AdjustKeyboardLayout, occupiedAreaInfo is nullptr," " occupiedAreaChanged = %{public}d", occupiedAreaChanged); @@ -322,7 +322,7 @@ WSError KeyboardSession::AdjustKeyboardLayout(const KeyboardLayoutParams& params occupiedAreaChanged); } if (occupiedAreaChanged) { - session->NotifyOccupiedArea(occupiedAreaInfo); + session->NotifyOccupiedAreaChangeInfo(occupiedAreaInfo); } } // notify keyboard layout param @@ -387,39 +387,38 @@ static WSRect CalculateSafeRectForMidScene(const WSRect& windowRect, const WSRec return result; } -void KeyboardSession::NotifyOccupiedAreaChangeInfo(const sptr& callingSession, const WSRect& rect, - const WSRect& occupiedArea, const std::shared_ptr& rsTransaction) -{ - // if keyboard will occupy calling, notify calling window the occupied area and safe height - const WSRect& safeRect = !callingSession->GetIsMidScene() ? SessionHelper::GetOverlap(occupiedArea, rect, 0, 0) : - CalculateSafeRectForMidScene(rect, occupiedArea, callingSession->GetScaleX(), callingSession->GetScaleY()); - const WSRect& lastSafeRect = callingSession->GetLastSafeRect(); - if (lastSafeRect == safeRect) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "SafeRect is same to lastSafeRect: %{public}s", safeRect.ToString().c_str()); - return; - } - callingSession->SetLastSafeRect(safeRect); - double textFieldPositionY = 0.0; - double textFieldHeight = 0.0; - auto sessionProperty = GetSessionProperty(); - if (sessionProperty != nullptr) { - textFieldPositionY = sessionProperty->GetTextFieldPositionY(); - textFieldHeight = sessionProperty->GetTextFieldHeight(); - } - sptr info = sptr::MakeSptr(OccupiedAreaType::TYPE_INPUT, - SessionHelper::TransferToRect(safeRect), safeRect.height_, textFieldPositionY, textFieldHeight); - TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling id: %{public}d, safeRect: %{public}s, keyboardRect: %{public}s" - ", textFieldPositionY_: %{public}f, textFieldHeight_: %{public}f", callingSession->GetPersistentId(), - safeRect.ToString().c_str(), occupiedArea.ToString().c_str(), textFieldPositionY, textFieldHeight); - if (callingSession->IsSystemSession()) { - NotifyRootSceneOccupiedAreaChange(info); - } else { - callingSession->NotifyOccupiedAreaChangeInfo(info, rsTransaction); - } -} - -void KeyboardSession::NotifyOccupiedArea(const sptr& occupiedAreaInfo, - const bool& isKeyboardSyncTransactionOpen, +// void KeyboardSession::NotifyOccupiedAreaChangeInfo(const sptr& callingSession, const WSRect& rect, +// const WSRect& occupiedArea, const std::shared_ptr& rsTransaction) +// { +// // if keyboard will occupy calling, notify calling window the occupied area and safe height +// const WSRect& safeRect = !callingSession->GetIsMidScene() ? SessionHelper::GetOverlap(occupiedArea, rect, 0, 0) : +// CalculateSafeRectForMidScene(rect, occupiedArea, callingSession->GetScaleX(), callingSession->GetScaleY()); +// const WSRect& lastSafeRect = callingSession->GetLastSafeRect(); +// if (lastSafeRect == safeRect) { +// TLOGI(WmsLogTag::WMS_KEYBOARD, "SafeRect is same to lastSafeRect: %{public}s", safeRect.ToString().c_str()); +// return; +// } +// callingSession->SetLastSafeRect(safeRect); +// double textFieldPositionY = 0.0; +// double textFieldHeight = 0.0; +// auto sessionProperty = GetSessionProperty(); +// if (sessionProperty != nullptr) { +// textFieldPositionY = sessionProperty->GetTextFieldPositionY(); +// textFieldHeight = sessionProperty->GetTextFieldHeight(); +// } +// sptr info = sptr::MakeSptr(OccupiedAreaType::TYPE_INPUT, +// SessionHelper::TransferToRect(safeRect), safeRect.height_, textFieldPositionY, textFieldHeight); +// TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling id: %{public}d, safeRect: %{public}s, keyboardRect: %{public}s" +// ", textFieldPositionY_: %{public}f, textFieldHeight_: %{public}f", callingSession->GetPersistentId(), +// safeRect.ToString().c_str(), occupiedArea.ToString().c_str(), textFieldPositionY, textFieldHeight); +// if (callingSession->IsSystemSession()) { +// NotifyRootSceneOccupiedAreaChange(info); +// } else { +// callingSession->NotifyOccupiedAreaChangeInfo(info, rsTransaction); +// } +// } + +void KeyboardSession::NotifyOccupiedAreaChangeInfo(const sptr& occupiedAreaInfo, std::shared_ptr rsTransaction) { TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- start to notify occupied area change info"); @@ -429,17 +428,20 @@ void KeyboardSession::NotifyOccupiedArea(const sptr& occ TLOGE(WmsLogTag::WMS_KEYBOARD, "Calling session is nullptr"); return; } - if (sessionStage_ == nullptr) { - TLOGE(WmsLogTag::WMS_KEYBOARD, "sessionStage_ is nullptr"); - return; - } if (occupiedAreaInfo == nullptr) { TLOGE(WmsLogTag::WMS_KEYBOARD, "occupiedAreaInfo is nullptr"); return; } - if (isKeyboardSyncTransactionOpen) { - rsTransaction = (rsTransaction == nullptr) ? GetRSTransaction() : rsTransaction; + if (callingSession->IsSystemSession()) { + NotifyRootSceneOccupiedAreaChange(occupiedAreaInfo); + } else { + callingSession->NotifyOccupiedAreaChangeInfo(occupiedAreaInfo, rsTransaction); + } + + if (sessionStage_ == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "sessionStage_ is nullptr"); + return; } SceneAnimationConfig config { .rsTransaction_ = rsTransaction, @@ -447,11 +449,6 @@ void KeyboardSession::NotifyOccupiedArea(const sptr& occ sessionStage_->UpdateRect(SessionHelper::TransferToWSRect(GetSessionProperty()->GetWindowRect()), SizeChangeReason::AVOID_AREA_CHANGE, config, {}, occupiedAreaInfo); - if (callingSession->IsSystemSession()) { - NotifyRootSceneOccupiedAreaChange(occupiedAreaInfo); - } else { - callingSession->NotifyOccupiedAreaChangeInfo(occupiedAreaInfo, rsTransaction); - } TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling id: %{public}d, occupiedAreaRect: %{public}s" ", textFieldPositionY_: %{public}f, textFieldHeight_: %{public}f", callingSession->GetPersistentId(), occupiedAreaInfo->rect_.ToString().c_str(), @@ -472,77 +469,8 @@ void KeyboardSession::NotifyKeyboardPanelInfoChange(WSRect rect, bool isKeyboard sessionStage_->NotifyKeyboardPanelInfoChange(keyboardPanelInfo); } -bool KeyboardSession::CalculateRectAndAvoidArea(sptr& occupiedAreaInfo, - const bool& needCheckVisible) -{ - TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- calculate occupied area, id: %{public}d", GetCallingSessionId()); - if (!keyboardAvoidAreaActive_) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, isSystemKeyboard: %{public}d, state: %{public}d, " - "gravity: %{public}d", GetPersistentId(), IsSystemKeyboard(), GetSessionState(), GetKeyboardGravity()); - return false; - } - if (!IsSessionForeground() || (needCheckVisible && !IsVisibleForeground())) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is not foreground, sessionState: %{public}d" - ", needCheckVisible: {public}d, isVisible: {public}d", - GetSessionState(), needCheckVisible, IsVisibleForeground()); - return false; - } - sptr callingSession = GetSceneSession(GetCallingSessionId()); - if (callingSession == nullptr) { - TLOGE(WmsLogTag::WMS_KEYBOARD, "Calling session is nullptr"); - return false; - } - - bool isCallingSessionFloating = (callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) && - !callingSession->GetIsMidScene(); - if (!CheckIfNeedRaiseCallingSession(callingSession, isCallingSessionFloating)) { - return false; - } - - WSRect callingSessionRect = callingSession->GetSessionRect(); - int32_t oriPosYBeforeRaisedByKeyboard = callingSession->GetOriPosYBeforeRaisedByKeyboard(); - if (oriPosYBeforeRaisedByKeyboard != 0 && isCallingSessionFloating) { - callingSessionRect.posY_ = oriPosYBeforeRaisedByKeyboard; - } - // update panel rect for avoid area caculate - WSRect panelAvoidRect = GetPanelRect(); - RecalculatePanelRectForAvoidArea(panelAvoidRect); - if (SessionHelper::IsEmptyRect(SessionHelper::GetOverlap(panelAvoidRect, callingSessionRect, 0, 0)) && - oriPosYBeforeRaisedByKeyboard == 0) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "No overlap area, keyboardRect: %{public}s, callingRect: %{public}s", - panelAvoidRect.ToString().c_str(), callingSessionRect.ToString().c_str()); - return CalculateRectAndAvoidAreaInner(callingSession, callingSessionRect, panelAvoidRect, occupiedAreaInfo); - } - - bool occupiedAreaChanged = true; - WSRect newRect = callingSessionRect; - int32_t statusHeight = callingSession->GetStatusBarHeight(); - if (IsNeedRaiseSubWindow(callingSession, newRect) && - isCallingSessionFloating && callingSessionRect.posY_ > statusHeight) { - if (oriPosYBeforeRaisedByKeyboard == 0) { - oriPosYBeforeRaisedByKeyboard = callingSessionRect.posY_; - callingSession->SetOriPosYBeforeRaisedByKeyboard(callingSessionRect.posY_); - } - // calculate new rect of calling session - newRect.posY_ = std::max(panelAvoidRect.posY_ - newRect.height_, statusHeight); - newRect.posY_ = std::min(oriPosYBeforeRaisedByKeyboard, newRect.posY_); - occupiedAreaChanged = CalculateRectAndAvoidAreaInner(callingSession, newRect, panelAvoidRect, occupiedAreaInfo); - if (!IsSystemKeyboard()) { - callingSession->UpdateSessionRect(newRect, SizeChangeReason::UNDEFINED); - } - } else { - occupiedAreaChanged = CalculateRectAndAvoidAreaInner(callingSession, newRect, panelAvoidRect, occupiedAreaInfo); - } - - TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardRect: %{public}s, callSession OriRect: %{public}s, newRect: %{public}s" - ", oriPosYBeforeRaisedByKeyboard: %{public}d, isCallingSessionFloating: %{public}d", - panelAvoidRect.ToString().c_str(), callingSessionRect.ToString().c_str(), newRect.ToString().c_str(), - oriPosYBeforeRaisedByKeyboard, isCallingSessionFloating); - return occupiedAreaChanged; -} - -bool KeyboardSession::CalculateRectAndAvoidAreaInner(const sptr& callingSession, const WSRect& rect, - const WSRect& panelRect, sptr& occupiedAreaInfo) +bool KeyboardSession::CalculateOccupiedArea(const sptr& callingSession, + const WSRect& callingSessionRect, const WSRect& panelRect, sptr& occupiedAreaInfo) { TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- calculate occupied area inner, id: %{public}d", GetCallingSessionId()); // if keyboard will occupy calling, notify calling window the occupied area and safe height @@ -597,29 +525,31 @@ bool KeyboardSession::CheckIfNeedRaiseCallingSession(sptr callingS return true; } -void KeyboardSession::RaiseCallingSession(uint32_t callingId, const WSRect& keyboardPanelRect, bool needCheckVisible, - const std::shared_ptr& rsTransaction) +void KeyboardSession::RaiseCallingSession(sptr& occupiedAreaInfo, + const bool& needCheckVisible) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- calculate occupied area, id: %{public}d", GetCallingSessionId()); if (!keyboardAvoidAreaActive_) { TLOGI(WmsLogTag::WMS_KEYBOARD, "Id: %{public}d, isSystemKeyboard: %{public}d, state: %{public}d, " "gravity: %{public}d", GetPersistentId(), IsSystemKeyboard(), GetSessionState(), GetKeyboardGravity()); - return; + return false; } if (!IsSessionForeground() || (needCheckVisible && !IsVisibleForeground())) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is not foreground"); - return; + TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is not foreground, sessionState: %{public}d" + ", needCheckVisible: {public}d, isVisible: {public}d", + GetSessionState(), needCheckVisible, IsVisibleForeground()); + return false; } - sptr callingSession = GetSceneSession(callingId); + sptr callingSession = GetSceneSession(GetCallingSessionId()); if (callingSession == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "Calling session is null"); - return; + return false; } - NotifyKeyboardPanelInfoChange(keyboardPanelRect, true); bool isCallingSessionFloating = (callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) && !callingSession->GetIsMidScene(); if (!CheckIfNeedRaiseCallingSession(callingSession, isCallingSessionFloating)) { - return; + return false; } WSRect callingSessionRect = callingSession->GetSessionRect(); @@ -628,16 +558,16 @@ void KeyboardSession::RaiseCallingSession(uint32_t callingId, const WSRect& keyb callingSessionRect.posY_ = oriPosYBeforeRaisedByKeyboard; } // update panel rect for avoid area caculate - WSRect panelAvoidRect = keyboardPanelRect; + WSRect panelAvoidRect = GetPanelRect(); RecalculatePanelRectForAvoidArea(panelAvoidRect); if (SessionHelper::IsEmptyRect(SessionHelper::GetOverlap(panelAvoidRect, callingSessionRect, 0, 0)) && oriPosYBeforeRaisedByKeyboard == 0) { TLOGI(WmsLogTag::WMS_KEYBOARD, "No overlap area, keyboardRect: %{public}s, callingRect: %{public}s", keyboardPanelRect.ToString().c_str(), callingSessionRect.ToString().c_str()); - NotifyOccupiedAreaChangeInfo(callingSession, callingSessionRect, panelAvoidRect, rsTransaction); - return; + return CalculateOccupiedArea(callingSession, callingSessionRect, panelAvoidRect, occupiedAreaInfo); } + bool occupiedAreaChanged = true; WSRect newRect = callingSessionRect; int32_t statusHeight = callingSession->GetStatusBarHeight(); if (IsNeedRaiseSubWindow(callingSession, newRect) && @@ -649,18 +579,19 @@ void KeyboardSession::RaiseCallingSession(uint32_t callingId, const WSRect& keyb // calculate new rect of calling session newRect.posY_ = std::max(panelAvoidRect.posY_ - newRect.height_, statusHeight); newRect.posY_ = std::min(oriPosYBeforeRaisedByKeyboard, newRect.posY_); - NotifyOccupiedAreaChangeInfo(callingSession, newRect, panelAvoidRect, rsTransaction); + occupiedAreaChanged = CalculateOccupiedArea(callingSession, newRect, panelAvoidRect, occupiedAreaInfo); if (!IsSystemKeyboard()) { callingSession->UpdateSessionRect(newRect, SizeChangeReason::UNDEFINED); } } else { - NotifyOccupiedAreaChangeInfo(callingSession, newRect, panelAvoidRect, rsTransaction); + occupiedAreaChanged = CalculateOccupiedArea(callingSession, newRect, panelAvoidRect, occupiedAreaInfo); } TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardRect: %{public}s, callSession OriRect: %{public}s, newRect: %{public}s" ", oriPosYBeforeRaisedByKeyboard: %{public}d, isCallingSessionFloating: %{public}d", keyboardPanelRect.ToString().c_str(), callingSessionRect.ToString().c_str(), newRect.ToString().c_str(), oriPosYBeforeRaisedByKeyboard, isCallingSessionFloating); + return occupiedAreaChanged; } void KeyboardSession::RestoreCallingSession(uint32_t callingId, const std::shared_ptr& rsTransaction) @@ -689,7 +620,7 @@ void KeyboardSession::RestoreCallingSession(uint32_t callingId, const std::share occupiedAreaChanged); } if (occupiedAreaChanged) { - NotifyOccupiedArea(occupiedAreaInfo, true, rsTransaction); + NotifyOccupiedAreaChangeInfo(occupiedAreaInfo, rsTransaction); } if (oriPosYBeforeRaisedByKeyboard != 0 && callingSession->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) { @@ -760,7 +691,7 @@ void KeyboardSession::UseFocusIdIfCallingSessionIdInvalid() void KeyboardSession::EnableCallingSessionAvoidArea() { sptr occupiedAreaInfo = nullptr; - bool occupiedAreaChanged = CalculateRectAndAvoidArea(occupiedAreaInfo, true); + bool occupiedAreaChanged = RaiseCallingSession(occupiedAreaInfo, true); if (occupiedAreaInfo == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- EnableCallingSessionAvoidArea, occupiedAreaInfo is nullptr," " occupiedAreaChanged = %{public}d", occupiedAreaChanged); @@ -770,7 +701,7 @@ void KeyboardSession::EnableCallingSessionAvoidArea() occupiedAreaChanged); } if (occupiedAreaChanged) { - NotifyOccupiedArea(occupiedAreaInfo); + NotifyOccupiedAreaChangeInfo(occupiedAreaInfo); } } @@ -842,7 +773,7 @@ void KeyboardSession::CloseKeyboardSyncTransaction(uint32_t callingId, const WSR "id: %{public}d, isLayoutFinished: %{public}d", session->GetCallingSessionId(), isLayoutFinished); sptr occupiedAreaInfo = nullptr; - bool occupiedAreaChanged = session->CalculateRectAndAvoidArea( + bool occupiedAreaChanged = session->RaiseCallingSession( occupiedAreaInfo, !(session->isKeyboardSyncTransactionOpen_)); if (occupiedAreaInfo == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- close keyboard sync, occupiedAreaInfo is nullptr," @@ -853,8 +784,7 @@ void KeyboardSession::CloseKeyboardSyncTransaction(uint32_t callingId, const WSR occupiedAreaChanged); } if (occupiedAreaChanged) { - session->NotifyOccupiedArea( - occupiedAreaInfo, session->isKeyboardSyncTransactionOpen_, rsTransaction); + session->NotifyOccupiedAreaChangeInfo(occupiedAreaInfo, rsTransaction); } } } else { diff --git a/window_scene/session/host/src/pc_fold_screen_controller.cpp b/window_scene/session/host/src/pc_fold_screen_controller.cpp index 9b5f42036d..c02217de93 100755 --- a/window_scene/session/host/src/pc_fold_screen_controller.cpp +++ b/window_scene/session/host/src/pc_fold_screen_controller.cpp @@ -329,7 +329,7 @@ void PcFoldScreenController::ThrowSlipFloatingRectDirectly(WSRect& rect, const W rect.ToString().c_str(), floatingRect.ToString().c_str()); auto& manager = PcFoldScreenManager::GetInstance(); const ScreenSide side = manager.CalculateScreenSide(rect); - const ScreenSide floatingSide = manager.CalculateScreenSide(floatingRect); + const ScreenSide floatingSide = manager.CalculateScreenSide(floatingRect.posY_); rect = floatingRect; if (side == floatingSide) { return; diff --git a/window_scene/session/host/src/pc_fold_screen_manager.cpp b/window_scene/session/host/src/pc_fold_screen_manager.cpp index ad241842d9..3405bb8498 100644 --- a/window_scene/session/host/src/pc_fold_screen_manager.cpp +++ b/window_scene/session/host/src/pc_fold_screen_manager.cpp @@ -154,6 +154,12 @@ float PcFoldScreenManager::GetVpr() const return vpr_; } +int32_t PcFoldScreenManager::GetVirtualDisplayPosY() const +{ + std::shared_lock lock(rectsMutex_); + return defaultDisplayRect_.height_ + foldCreaseRect_.height_; +} + std::tuple PcFoldScreenManager::GetDisplayRects() const { std::shared_lock lock(rectsMutex_); @@ -188,6 +194,12 @@ ScreenSide PcFoldScreenManager::CalculateScreenSide(const WSRect& rect) ScreenSide::FOLD_B : ScreenSide::FOLD_C; } +ScreenSide PcFoldScreenManager::CalculateScreenSide(int32_t posY) +{ + const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = GetDisplayRects(); + return posY < foldCreaseRect.posY_ ? ScreenSide::FOLD_B : ScreenSide::FOLD_C; +} + bool PcFoldScreenManager::IsCrossFoldCrease(const WSRect& rect) { const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = GetDisplayRects(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 9cf45894d8..8a54b80509 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -695,8 +695,8 @@ WSError SceneSession::SetMoveAvailableArea(DisplayId displayId) DMRect statusBarRect = CalcRectForStatusBar(); if (systemConfig_.IsPadWindow() || systemConfig_.IsPhoneWindow()) { uint32_t statusBarHeight = statusBarRect.height_; - if (statusBarHeight > availableArea.posY_) { - availableArea.posY_ = statusBarHeight; + if (static_cast(statusBarHeight) > availableArea.posY_) { + availableArea.posY_ = static_cast(statusBarHeight); } sptr currentScreenSession = @@ -847,8 +847,9 @@ WSError SceneSession::OnSessionEvent(SessionEvent event) session->InitializeCrossMoveDrag(); session->moveDragController_->InitMoveDragProperty(); if (session->pcFoldScreenController_) { - session->pcFoldScreenController_->RecordStartMoveRect(session->GetSessionRect(), - session->IsFullScreenMovable()); + WSRect currRect; + session->HookStartMoveRect(currRect, session->GetSessionRect()); + session->pcFoldScreenController_->RecordStartMoveRect(currRect, session->IsFullScreenMovable()); } WSRect rect = session->winRect_; if (session->IsFullScreenMovable()) { @@ -1177,6 +1178,19 @@ void SceneSession::RegisterTouchOutsideCallback(NotifyTouchOutsideFunc&& callbac }, __func__); } +void SceneSession::RegisterFollowScreenChangeCallback(NotifyFollowScreenChangeFunc&& callback) +{ + PostTask([weakThis = wptr(this), callback = std::move(callback), where = __func__] { + auto session = weakThis.promote(); + if (!session || !session->specificCallback_ || !callback) { + TLOGNE(WmsLogTag::DEFAULT, "%{public}s session or specific callback or callback is null", where); + return; + } + session->specificCallback_->onUpdateFollowScreenChange_ = std::move(callback); + session->specificCallback_->onUpdateFollowScreenChange_(session->GetFollowScreenChange()); + }, __func__); +} + WSError SceneSession::SetGlobalMaximizeMode(MaximizeMode mode) { return PostSyncTask([weakThis = wptr(this), mode, where = __func__] { @@ -1478,6 +1492,9 @@ void SceneSession::SetSessionRectChangeCallback(const NotifySessionRectChangeFun } TLOGND(WmsLogTag::WMS_LAYOUT, "%{public}s, winName:%{public}s, reason:%{public}d, rect:%{public}s", where, session->GetWindowName().c_str(), reason, rect.ToString().c_str()); + if (session->GetClientDisplayId() == VIRTUAL_DISPLAY_ID && rect.posY_ == 0) { + rect.posY_ += PcFoldScreenManager::GetInstance().GetVirtualDisplayPosY(); + } auto rectAnimationConfig = session->GetRequestRectAnimationConfig(); session->sessionRectChangeFunc_(rect, reason, DISPLAY_ID_INVALID, rectAnimationConfig); } @@ -1658,7 +1675,6 @@ void SceneSession::UpdateSessionRectInner(const WSRect& rect, SizeChangeReason r TLOGI(WmsLogTag::WMS_LAYOUT, "Get displayId: %{public}" PRIu64, displayId); auto notifyRect = newRequestRect; if (PcFoldScreenManager::GetInstance().IsHalfFolded(GetScreenId())) { - newReason = SizeChangeReason::UNDEFINED; notifyRect = rect; } SetSessionRequestRect(notifyRect); @@ -2667,8 +2683,8 @@ void SceneSession::GetSystemBarAvoidAreaByRotation(Rotation rotation, AvoidAreaT } bool isStatusBarAvoidAreaEmpty = winType == WindowType::WINDOW_TYPE_STATUS_BAR && (rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270) && - !(static_cast(static_cast(properties.at(winType).settingFlag_) & - static_cast(SystemBarSettingFlag::ENABLE_SETTING))); + !(static_cast(static_cast(properties.at(winType).settingFlag_) & + static_cast(SystemBarSettingFlag::ENABLE_SETTING))); if (!properties.at(winType).enable_ || isStatusBarAvoidAreaEmpty) { TLOGI(WmsLogTag::WMS_IMMS, "win [%{public}d] avoid area is empty, type %{public}d", GetPersistentId(), type); return; @@ -3396,6 +3412,100 @@ void SceneSession::HandleMoveDragEnd(WSRect& rect, SizeChangeReason reason) OnSessionEvent(SessionEvent::EVENT_END_MOVE); } +/** + * the window is transformed according to the scale ratio + */ +void SceneSession::WindowScaleTransfer(WSRect& rect, float scaleX, float scaleY) +{ + const float HALF = 0.5f; + auto curWidth = rect.width_; + auto curHeight = rect.height_; + rect.width_ = static_cast(curWidth * scaleX); + rect.height_ = static_cast(curHeight * scaleY); + auto widthDifference = static_cast((curWidth - rect.width_) * HALF); + auto heightDifference = static_cast((curHeight - rect.height_) * HALF); + rect.posX_ = rect.posX_ + widthDifference; + rect.posY_ = rect.posY_ + heightDifference; + TLOGI(WmsLogTag::WMS_LAYOUT, "scaleX: %{public}f, scaleY: %{public}f, sizeDifference: [%{public}d, " + "%{public}d], rect: %{public}s", scaleX, scaleY, widthDifference, heightDifference, rect.ToString().c_str()); +} + +/** + * hook startMoveRect with showRect + */ +void SceneSession::HookStartMoveRect(WSRect& newRect, const WSRect& sessionRect) +{ + newRect = sessionRect; + if (!WindowHelper::IsMainWindow(GetWindowType())) { + TLOGD(WmsLogTag::WMS_LAYOUT, "is not mainWindow"); + return; + } + auto scaleX = GetScaleX(); + auto scaleY = GetScaleY(); + if (IsCompatibilityModeScale(scaleX, scaleY)) { + WindowScaleTransfer(newRect, scaleX, scaleY); + } +} + +/** + * check compatible mode application that includes scale ratio + * @return true: compatible mode application with scale ratio + */ +bool SceneSession::IsCompatibilityModeScale(float scaleX, float scaleY) +{ + auto property = GetSessionProperty(); + if (property->GetCompatibleModeInPc() && MathHelper::GreatNotEqual(scaleX, 0.0f) && + MathHelper::GreatNotEqual(scaleY, 0.0f) && (!NearEqual(scaleX, 1.0f) || !NearEqual(scaleY, 1.0f))) { + return true; + } + return false; +} + +/** + * throw slip to full screen + */ +void SceneSession::ThrowSlipToFullScreen(WSRect& endRect, WSRect& rect) +{ + if (pcFoldScreenController_ == nullptr) { + return; + } + // maximize end rect and notify last rect + throwSlipToFullScreenAnimCount_.fetch_add(1); + pcFoldScreenController_->ResizeToFullScreen(endRect, GetStatusBarHeight(), GetDockHeight()); + if (pcFoldScreenController_->IsThrowSlipDirectly()) { + pcFoldScreenController_->ThrowSlipFloatingRectDirectly( + rect, GetSessionRequestRect(), GetStatusBarHeight(), GetDockHeight()); + } +} + +/** + * the compatible mode window is being scaled and transformed + */ +void SceneSession::CompatibilityModeWindowScaleTransfer(WSRect& rect, bool isScale) +{ + if (!WindowHelper::IsMainWindow(GetWindowType())) { + TLOGD(WmsLogTag::WMS_LAYOUT, "is not mainWindow"); + return; + } + auto scaleX = GetScaleX(); + auto scaleY = GetScaleY(); + if (MathHelper::NearZero(scaleX) || MathHelper::NearZero(scaleY)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "scale ratio is 0"); + return; + } + if (!isScale) { + if (!MathHelper::NearZero(scaleX)) { + scaleX = 1 / scaleX; + } + if (!MathHelper::NearZero(scaleY)) { + scaleY = 1 / scaleY; + } + } + if (IsCompatibilityModeScale(scaleX, scaleY)) { + WindowScaleTransfer(rect, scaleX, scaleY); + } +} + /** * move with init velocity * @return true: successfully throw slip @@ -3405,24 +3515,20 @@ bool SceneSession::MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeR if (pcFoldScreenController_ == nullptr) { return false; } + CompatibilityModeWindowScaleTransfer(rect, true); bool ret = pcFoldScreenController_->ThrowSlip(GetScreenId(), rect, GetStatusBarHeight(), GetDockHeight()); if (!ret) { TLOGD(WmsLogTag::WMS_LAYOUT_PC, "no throw slip"); pcFoldScreenController_->ResetRecords(); + CompatibilityModeWindowScaleTransfer(rect, false); return false; } - + CompatibilityModeWindowScaleTransfer(rect, false); WSRect endRect = rect; std::function finishCallback = nullptr; bool needSetFullScreen = pcFoldScreenController_->IsStartFullScreen(); if (needSetFullScreen) { - // maximize end rect and notify last rect - throwSlipToFullScreenAnimCount_.fetch_add(1); - pcFoldScreenController_->ResizeToFullScreen(endRect, GetStatusBarHeight(), GetDockHeight()); - if (pcFoldScreenController_->IsThrowSlipDirectly()) { - pcFoldScreenController_->ThrowSlipFloatingRectDirectly( - rect, GetSessionRequestRect(), GetStatusBarHeight(), GetDockHeight()); - } + ThrowSlipToFullScreen(endRect, rect); finishCallback = [weakThis = wptr(this), rect, where = __func__] { auto session = weakThis.promote(); if (session == nullptr) { @@ -3525,7 +3631,9 @@ void SceneSession::ThrowSlipDirectly(ThrowSlipMode throwSlipMode, const WSRectF& return; } bool isFullScreen = session->IsFullScreenMovable(); - controller->RecordStartMoveRectDirectly(session->GetSessionRect(), throwSlipMode, velocity, isFullScreen); + WSRect currRect; + session->HookStartMoveRect(currRect, session->GetSessionRect()); + controller->RecordStartMoveRectDirectly(currRect, throwSlipMode, velocity, isFullScreen); const WSRect& oriGlobalRect = session->GetSessionGlobalRect(); WSRect globalRect = oriGlobalRect; if (!session->MoveUnderInteriaAndNotifyRectChange(globalRect, SizeChangeReason::UNDEFINED)) { @@ -4473,6 +4581,16 @@ bool SceneSession::IsNeedDefaultAnimation() const return needDefaultAnimationFlag_; } +bool SceneSession::GetFollowScreenChange() const +{ + return isFollowScreenChange_; +} + +void SceneSession::SetFollowScreenChange(bool isFollowScreenChange) +{ + isFollowScreenChange_ = isFollowScreenChange; +} + bool SceneSession::IsAppSession() const { if (GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) { @@ -5353,6 +5471,8 @@ WMError SceneSession::ProcessUpdatePropertyByAction(const sptr(WSPropertyChangeAction::ACTION_UPDATE_EXCLUSIVE_HIGHLIGHTED): return HandleActionUpdateExclusivelyHighlighted(property, action); + case static_cast(WSPropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE): + return HandleActionUpdateFollowScreenChange(property, action); default: TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!"); return WMError::WM_DO_NOTHING; @@ -5708,6 +5828,32 @@ WMError SceneSession::HandleActionUpdateExclusivelyHighlighted(const sptr& property, + WSPropertyChangeAction action) +{ + UpdateFollowScreenChange(property->GetFollowScreenChange()); + NotifySessionChangeByActionNotifyManager(property, action); + return WMError::WM_OK; +} + +WSError SceneSession::UpdateFollowScreenChange(bool isFollowScreenChange) +{ + SetFollowScreenChange(isFollowScreenChange); + auto task = [weakThis = wptr(this), isFollowScreenChange] { + auto session = weakThis.promote(); + if (!session || !session->specificCallback_) { + TLOGNE(WmsLogTag::DEFAULT, "session or specific callback is null"); + return; + } + if (session->specificCallback_->onUpdateFollowScreenChange_) { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession:UpdateFollowScreenChange"); + session->specificCallback_->onUpdateFollowScreenChange_(isFollowScreenChange); + } + }; + PostTask(std::move(task), "UpdateFollowScreenChange"); + return WSError::WS_OK; +} + void SceneSession::HandleSpecificSystemBarProperty(WindowType type, const sptr& property) { auto systemBarProperties = property->GetSystemBarProperty(); @@ -7492,9 +7638,9 @@ void SceneSession::UpdateSubWindowLevel(uint32_t subWindowLevel) } } -int SceneSession::GetMaxSubWindowLevel() const +uint32_t SceneSession::GetMaxSubWindowLevel() const { - int maxSubWindowLevel = 1; + uint32_t maxSubWindowLevel = 1; for (const auto& session : GetSubSession()) { if (session != nullptr) { maxSubWindowLevel = std::max(maxSubWindowLevel, session->GetMaxSubWindowLevel() + 1); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index d5a3d0fb60..c0680ebbde 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2473,6 +2473,17 @@ void Session::ResetSnapshot() scenePersistence_->ResetSnapshotCache(); } +void Session::SetEnableAddSnapshot(bool enableAddSnapshot) +{ + TLOGI(WmsLogTag::WMS_PATTERN, "enableAddSnapshot: %{public}d", enableAddSnapshot); + enableAddSnapshot_ = enableAddSnapshot; +} + +bool Session::GetEnableAddSnapshot() const +{ + return enableAddSnapshot_; +} + void Session::SaveSnapshot(bool useFfrt, bool needPersist) { if (scenePersistence_ == nullptr) { diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 6a561786eb..726336cbec 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -58,6 +58,7 @@ public: virtual void OnExtendScreenConnectStatusChange(ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus) = 0; virtual void OnBeforeScreenPropertyChange(FoldStatus foldStatus) = 0; + virtual void OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) = 0; }; enum class MirrorScreenType : int32_t { @@ -307,6 +308,7 @@ public: bool GetIsEnableRegionRotation(); void UpdateDisplayNodeRotation(int rotation); void BeforeScreenPropertyChange(FoldStatus foldStatus); + void ScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent); DisplayId GetDisplayId(); @@ -326,6 +328,9 @@ public: void SetScreenAvailableStatus(bool isScreenAvailable); bool IsScreenAvailable() const; + void SetIsAvailableAreaNeedNotify(bool isAvailableAreaNeedNotify); + bool GetIsAvailableAreaNeedNotify() const; + private: ScreenProperty property_; std::shared_ptr displayNode_; @@ -359,10 +364,10 @@ private: void SetScreenSnapshotRect(RSSurfaceCaptureConfig& config); bool IsWidthHeightMatch(float width, float height, float targetWidth, float targetHeight); std::mutex mirrorScreenRegionMutex_; - void OptimizeSecondaryDisplayMode(const RRect &bounds, FoldDisplayMode &foldDisplayMode); std::string innerName_ {"UNKOWN"}; bool isEnableRegionRotation_ = false; std::mutex isEnableRegionRotationMutex_; + bool isAvailableAreaNeedNotify_ = false; }; class ScreenSessionGroup : public ScreenSession { diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 1f66d32ac1..8ab8aa1778 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -623,7 +623,6 @@ ScreenProperty ScreenSession::UpdatePropertyByFoldControl(const ScreenProperty& property_.SetDpiPhyBounds(updatedProperty.GetPhyWidth(), updatedProperty.GetPhyHeight()); property_.SetPhyBounds(updatedProperty.GetPhyBounds()); property_.SetBounds(updatedProperty.GetBounds()); - OptimizeSecondaryDisplayMode(updatedProperty.GetBounds(), foldDisplayMode); if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { DisplayOrientation deviceOrientation = CalcDeviceOrientation(property_.GetScreenRotation(), foldDisplayMode); @@ -918,7 +917,6 @@ void ScreenSession::UpdateTouchBoundsAndOffset() void ScreenSession::UpdateToInputManager(RRect bounds, int rotation, int deviceRotation, FoldDisplayMode foldDisplayMode) { - OptimizeSecondaryDisplayMode(bounds, foldDisplayMode); bool needUpdateToInputManager = false; if (foldDisplayMode == FoldDisplayMode::FULL && property_.GetBounds() == bounds && property_.GetRotation() != static_cast(rotation)) { @@ -956,26 +954,8 @@ void ScreenSession::SetScreenComponentRotation(int rotation) TLOGI(WmsLogTag::DMS, "screenComponentRotation :%{public}f ", property_.GetScreenComponentRotation()); } -void ScreenSession::OptimizeSecondaryDisplayMode(const RRect &bounds, FoldDisplayMode &foldDisplayMode) -{ - if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { - return; - } - if (IsWidthHeightMatch(bounds.rect_.GetWidth(), bounds.rect_.GetHeight(), - MAIN_STATUS_WIDTH, SCREEN_HEIGHT)) { - foldDisplayMode = FoldDisplayMode::MAIN; - } else if (IsWidthHeightMatch(bounds.rect_.GetWidth(), bounds.rect_.GetHeight(), - FULL_STATUS_WIDTH, SCREEN_HEIGHT)) { - foldDisplayMode = FoldDisplayMode::FULL; - } else if (IsWidthHeightMatch(bounds.rect_.GetWidth(), bounds.rect_.GetHeight(), - GLOBAL_FULL_STATUS_WIDTH, SCREEN_HEIGHT)) { - foldDisplayMode = FoldDisplayMode::GLOBAL_FULL; - } -} - void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode) { - OptimizeSecondaryDisplayMode(bounds, foldDisplayMode); Rotation targetRotation = ConvertIntToRotation(rotation); DisplayOrientation displayOrientation = CalcDisplayOrientation(targetRotation, foldDisplayMode); property_.SetBounds(bounds); @@ -1035,7 +1015,6 @@ void ScreenSession::UpdateDisplayNodeRotation(int rotation) void ScreenSession::UpdatePropertyOnly(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode) { - OptimizeSecondaryDisplayMode(bounds, foldDisplayMode); Rotation targetRotation = ConvertIntToRotation(rotation); DisplayOrientation displayOrientation = CalcDisplayOrientation(targetRotation, foldDisplayMode); property_.SetBounds(bounds); @@ -1056,7 +1035,6 @@ void ScreenSession::UpdatePropertyOnly(RRect bounds, int rotation, FoldDisplayMo void ScreenSession::UpdateRotationOrientation(int rotation, FoldDisplayMode foldDisplayMode) { - OptimizeSecondaryDisplayMode(property_.GetBounds(), foldDisplayMode); Rotation targetRotation = ConvertIntToRotation(rotation); DisplayOrientation deviceOrientation = CalcDeviceOrientation(targetRotation, foldDisplayMode); property_.UpdateDeviceRotation(targetRotation); @@ -1979,9 +1957,10 @@ void ScreenSession::SetFrameGravity(Gravity gravity) bool ScreenSession::UpdateAvailableArea(DMRect area) { - if (property_.GetAvailableArea() == area) { + if (property_.GetAvailableArea() == area && !GetIsAvailableAreaNeedNotify()) { return false; } + SetIsAvailableAreaNeedNotify(false); property_.SetAvailableArea(area); return true; } @@ -2203,6 +2182,22 @@ void ScreenSession::BeforeScreenPropertyChange(FoldStatus foldStatus) } } +void ScreenSession::ScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) +{ + std::lock_guard lock(screenChangeListenerListMutex_); + if (screenChangeListenerList_.empty()) { + TLOGE(WmsLogTag::DMS, "screenChangeListenerList is empty."); + return; + } + for (auto& listener : screenChangeListenerList_) { + if (!listener) { + TLOGE(WmsLogTag::DMS, "screenChangeListener is null."); + continue; + } + listener->OnScreenModeChange(screenModeChangeEvent); + } +} + void ScreenSession::SetIsPhysicalMirrorSwitch(bool isPhysicalMirrorSwitch) { isPhysicalMirrorSwitch_ = isPhysicalMirrorSwitch; @@ -2335,4 +2330,13 @@ void ScreenSession::SetScreenOffScreenRendering() rsId_, offWidth, offHeight, offScreenResult.c_str()); } +void ScreenSession::SetIsAvailableAreaNeedNotify(bool isAvailableAreaNeedNotify) +{ + isAvailableAreaNeedNotify_ = isAvailableAreaNeedNotify; +} + +bool ScreenSession::GetIsAvailableAreaNeedNotify() const +{ + return isAvailableAreaNeedNotify_; +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index e2293cd7be..879e191186 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -463,7 +463,7 @@ public: * Keyboard Window */ void RequestInputMethodCloseKeyboard(int32_t persistentId); - void RegisterNotifyRootSceneOccupiedAreaChangeFunc(NotifyRootSceneOccupiedAreaChangeFunc&& func); + // void RegisterNotifyRootSceneOccupiedAreaChangeFunc(NotifyRootSceneOccupiedAreaChangeFunc&& func); void GetKeyboardOccupiedAreaWithRotation( int32_t persistentId, Rotation rotation, std::vector>& avoidAreas); void ReportKeyboardCreateException(sptr& keyboardSession); @@ -955,7 +955,7 @@ private: void EraseSceneSessionMapById(int32_t persistentId); void EraseSceneSessionAndMarkDirtyLocked(int32_t persistentId); WSError GetAbilityInfosFromBundleInfo(const std::vector& bundleInfos, - std::vector& scbAbilityInfos); + std::vector& scbAbilityInfos, int32_t userId = 0); void GetOrientationFromResourceManager(AppExecFwk::AbilityInfo& abilityInfo); void UpdatePrivateStateAndNotifyForAllScreens(); @@ -1185,6 +1185,8 @@ private: void NotifyCollaboratorAfterStart(sptr& sceneSession, sptr& sceneSessionInfo); void UpdateCollaboratorSessionWant(sptr& session, int32_t persistentId = 0); sptr GetCollaboratorByType(int32_t collaboratorType); + void GetCollaboratorAbilityInfos(const std::vector& bundleInfos, + std::vector& scbAbilityInfos, int32_t userId); std::vector skipSurfaceNodeIds_; std::atomic_bool processingFlushUIParams_ { false }; @@ -1217,7 +1219,7 @@ private: void HandleKeyboardAvoidChange(const sptr& sceneSession, DisplayId displayId, SystemKeyboardAvoidChangeReason reason); void UpdateKeyboardAvoidAreaActive(bool systemKeyboardAvoidAreaActive); - NotifyRootSceneOccupiedAreaChangeFunc onNotifyOccupiedAreaChangeForRootFunc_; + // NotifyRootSceneOccupiedAreaChangeFunc onNotifyOccupiedAreaChangeForRootFunc_; /* * Specific Window diff --git a/window_scene/session_manager/src/extension_session_manager.cpp b/window_scene/session_manager/src/extension_session_manager.cpp index b3dbdf49f4..388fd526a7 100644 --- a/window_scene/session_manager/src/extension_session_manager.cpp +++ b/window_scene/session_manager/src/extension_session_manager.cpp @@ -59,7 +59,7 @@ sptr ExtensionSessionManager::SetAbilitySessionInfo(const sp abilitySessionInfo->orientation = sessionInfo.config_.orientation_; abilitySessionInfo->isDensityFollowHost = sessionInfo.config_.isDensityFollowHost_; if (sessionInfo.want != nullptr) { - abilitySessionInfo->want = sessionInfo.SafelyGetWant(); + abilitySessionInfo->want = sessionInfo.GetWantSafely(); } return abilitySessionInfo; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 78f4afe0b0..7e6837c2a4 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -72,6 +72,8 @@ #include "user_switch_reporter.h" #include "window_helper.h" #include "xcollie/watchdog.h" +#include "xcollie/xcollie.h" +#include "xcollie/xcollie_define.h" #ifdef MEMMGR_WINDOW_ENABLE #include "mem_mgr_client.h" @@ -1481,10 +1483,10 @@ void SceneSessionManager::RegisterNotifyRootSceneAvoidAreaChangeFunc(NotifyRootS onNotifyAvoidAreaChangeForRootFunc_ = std::move(func); } -void SceneSessionManager::RegisterNotifyRootSceneOccupiedAreaChangeFunc(NotifyRootSceneOccupiedAreaChangeFunc&& func) -{ - onNotifyOccupiedAreaChangeForRootFunc_ = std::move(func); -} +// void SceneSessionManager::RegisterNotifyRootSceneOccupiedAreaChangeFunc(NotifyRootSceneOccupiedAreaChangeFunc&& func) +// { +// onNotifyOccupiedAreaChangeForRootFunc_ = std::move(func); +// } AvoidArea SceneSessionManager::GetRootSessionAvoidAreaByType(AvoidAreaType type) { @@ -2595,7 +2597,7 @@ sptr SceneSessionManager::SetAbilitySessionInfo(const sptrrequestId = sessionInfo.requestId; abilitySessionInfo->reuseDelegatorWindow = sessionInfo.reuseDelegatorWindow; if (sessionInfo.want != nullptr) { - abilitySessionInfo->want = sessionInfo.SafelyGetWant(); + abilitySessionInfo->want = sessionInfo.GetWantSafely(); } else { abilitySessionInfo->want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); @@ -2713,8 +2715,11 @@ int32_t SceneSessionManager::StartUIAbilityBySCBTimeoutCheck(const sptr coldStartFlag = std::make_shared(false); bool isTimeout = ffrtQueueHelper_->SubmitTaskAndWait([abilitySessionInfo, coldStartFlag, retCode, windowStateChangeReason] { + int timerId = HiviewDFX::XCollie::GetInstance().SetTimer("WMS:SSM:StartUIAbilityBySCB", + START_UI_ABILITY_TIMEOUT/1000, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG); auto result = AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilityBySCB(abilitySessionInfo, *coldStartFlag, windowStateChangeReason); + HiviewDFX::XCollie::GetInstance().CancelTimer(timerId); *retCode = static_cast(result); TLOGNI(WmsLogTag::WMS_LIFE, "start ui ability retCode: %{public}d", *retCode); }, START_UI_ABILITY_TIMEOUT); @@ -3771,11 +3776,11 @@ SessionInfo SceneSessionManager::RecoverSessionInfo(const sptr(sessionInfo.screenId_), sessionInfo.isAbilityHook_); + sessionInfo.screenId_, sessionInfo.isAbilityHook_); return sessionInfo; } @@ -7707,6 +7712,7 @@ void SceneSessionManager::RegisterSessionChangeByActionNotifyManagerFunc(sptrGetPersistentId(), WindowUpdateType::WINDOW_UPDATE_PROPERTY); break; case WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS: @@ -8710,7 +8716,7 @@ __attribute__((no_sanitize("cfi"))) WSError SceneSessionManager::GetAllAbilityIn TLOGE(WmsLogTag::DEFAULT, "invalid want:%{public}s", want.ToString().c_str()); return WSError::WS_ERROR_INVALID_PARAM; } - return GetAbilityInfosFromBundleInfo(bundleInfos, scbAbilityInfos); + return GetAbilityInfosFromBundleInfo(bundleInfos, scbAbilityInfos, userId); } __attribute__((no_sanitize("cfi"))) WSError SceneSessionManager::GetBatchAbilityInfos( @@ -8736,7 +8742,7 @@ __attribute__((no_sanitize("cfi"))) WSError SceneSessionManager::GetBatchAbility TLOGE(WmsLogTag::WMS_RECOVER, "Query batch ability infos from BMS failed!"); return WSError::WS_ERROR_INVALID_PARAM; } - return GetAbilityInfosFromBundleInfo(bundleInfos, scbAbilityInfos); + return GetAbilityInfosFromBundleInfo(bundleInfos, scbAbilityInfos, userId); } WSError SceneSessionManager::GetAbilityInfo(const std::string& bundleName, const std::string& moduleName, @@ -8787,12 +8793,13 @@ WSError SceneSessionManager::GetAbilityInfo(const std::string& bundleName, const } WSError SceneSessionManager::GetAbilityInfosFromBundleInfo(const std::vector& bundleInfos, - std::vector& scbAbilityInfos) + std::vector& scbAbilityInfos, int32_t userId) { if (bundleInfos.empty()) { TLOGE(WmsLogTag::DEFAULT, "bundleInfos is empty"); return WSError::WS_ERROR_INVALID_PARAM; } + std::vector collaboratorBundleInfos; for (auto& bundleInfo : bundleInfos) { auto& hapModulesList = bundleInfo.hapModuleInfos; auto sdkVersion = bundleInfo.targetVersion % 100; // %100 to get the real version @@ -8800,19 +8807,10 @@ WSError SceneSessionManager::GetAbilityInfosFromBundleInfo(const std::vectorabilityInfos[0]; - scbAbilityInfo.sdkVersion_ = sdkVersion; - scbAbilityInfo.codePath_ = bundleInfo.applicationInfo.codePath; - GetOrientationFromResourceManager(scbAbilityInfo.abilityInfo_); - scbAbilityInfos.push_back(scbAbilityInfo); - continue; - } + if (WindowHelper::IsNumber(bundleInfo.applicationInfo.codePath) && + CheckCollaboratorType(std::stoi(bundleInfo.applicationInfo.codePath))) { + collaboratorBundleInfos.emplace_back(bundleInfo); + continue; } for (auto& hapModule : hapModulesList) { auto& abilityInfoList = hapModule.abilityInfos; @@ -8832,9 +8830,57 @@ WSError SceneSessionManager::GetAbilityInfosFromBundleInfo(const std::vector& bundleInfos, + std::vector& scbAbilityInfos, int32_t userId) +{ + if (bundleInfos.empty()) { + TLOGD(WmsLogTag::DEFAULT, "bundleInfos is empty"); + return; + } + std::vector launcherAbilityInfos; + AAFwk::Want want; + want.SetAction(AAFwk::Want::ACTION_HOME); + want.AddEntity(AAFwk::Want::ENTITY_HOME); + if (!bundleMgr_ || bundleMgr_->QueryLauncherAbilityInfos(want, userId, launcherAbilityInfos) != ERR_OK) { + TLOGE(WmsLogTag::DEFAULT, "Query launcher ability infos from BMS failed!"); + return; + } + std::unordered_map abilityInfoMap; + for (auto& abilityInfo : launcherAbilityInfos) { + abilityInfoMap.emplace(abilityInfo.bundleName, abilityInfo); + } + for (auto& bundleInfo : bundleInfos) { + AppExecFwk::AbilityInfo abilityInfo; + auto& hapModulesList = bundleInfo.hapModuleInfos; + auto iter = abilityInfoMap.find(bundleInfo.name); + if (iter == abilityInfoMap.end()) { + TLOGW(WmsLogTag::DEFAULT, "launcher ability not found, bundle:%{public}s", bundleInfo.name.c_str()); + auto hapModuleListIter = std::find_if(hapModulesList.begin(), hapModulesList.end(), + [](const AppExecFwk::HapModuleInfo& hapModule) { return !hapModule.abilityInfos.empty(); }); + if (hapModuleListIter != hapModulesList.end()) { + abilityInfo = hapModuleListIter->abilityInfos[0]; + } else { + continue; + } + } else { + if (!AbilityInfoManager::FindAbilityInfo( + bundleInfo, iter->second.moduleName, iter->second.name, abilityInfo)) { + continue; + } + } + SCBAbilityInfo scbAbilityInfo; + scbAbilityInfo.abilityInfo_ = abilityInfo; + scbAbilityInfo.sdkVersion_ = bundleInfo.targetVersion % 100; // %100 to get the real version + scbAbilityInfo.codePath_ = bundleInfo.applicationInfo.codePath; + GetOrientationFromResourceManager(scbAbilityInfo.abilityInfo_); + scbAbilityInfos.push_back(scbAbilityInfo); + } +} + void SceneSessionManager::GetOrientationFromResourceManager(AppExecFwk::AbilityInfo& abilityInfo) { if (abilityInfo.orientationId == 0) { @@ -10537,9 +10583,14 @@ void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentI TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d layout finished %{public}d", persistentId, isLastFrameLayoutFinished); if (isLastFrameLayoutFinished) { - sceneSession->UpdateAvoidArea( - new AvoidArea(sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR)), - AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + auto area = sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + if (!CheckAvoidAreaForAINavigationBar(isAINavigationBarVisible_, area, + sceneSession->GetSessionRect().height_)) { + TLOGI(WmsLogTag::WMS_IMMS, "win [%{public}d] avoid area update rejected by wrong direction", + persistentId); + return; + } + sceneSession->UpdateAvoidArea(new AvoidArea(area), AvoidAreaType::TYPE_NAVIGATION_INDICATOR); } else { sceneSession->MarkAvoidAreaAsDirty(); } @@ -10739,6 +10790,7 @@ void DisplayChangeListener::OnDisplayStateChange(DisplayId defaultDisplayId, spt case DisplayStateChangeType::VIRTUAL_PIXEL_RATIO_CHANGE: { SceneSessionManager::GetInstance().ProcessVirtualPixelRatioChange(defaultDisplayId, displayInfo, displayInfoMap, type); + SceneSessionManager::GetInstance().FlushWindowInfoToMMI(); break; } case DisplayStateChangeType::UPDATE_ROTATION: { @@ -11133,11 +11185,14 @@ BrokerStates SceneSessionManager::NotifyStartAbility( } sessionInfo.want->SetParam("oh_persistentId", persistentId); std::shared_ptr ret = std::make_shared(0); - std::shared_ptr notifyWant = std::make_shared(sessionInfo.SafelyGetWant()); + std::shared_ptr notifyWant = std::make_shared(sessionInfo.GetWantSafely()); bool isTimeout = ffrtQueueHelper_->SubmitTaskAndWait([this, collaborator, accessTokenIDEx, notifyWant, abilityInfo = sessionInfo.abilityInfo, ret] { + int timerId = HiviewDFX::XCollie::GetInstance().SetTimer("WMS:SSM:NotifyStartAbility", + NOTIFY_START_ABILITY_TIMEOUT/1000, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG); auto result = collaborator->NotifyStartAbility(*abilityInfo, currentUserId_, *notifyWant, static_cast(accessTokenIDEx)); + HiviewDFX::XCollie::GetInstance().CancelTimer(timerId); *ret = static_cast(result); }, NOTIFY_START_ABILITY_TIMEOUT); @@ -11145,7 +11200,7 @@ BrokerStates SceneSessionManager::NotifyStartAbility( TLOGE(WmsLogTag::WMS_LIFE, "notify start ability timeout, id: %{public}d", persistentId); return BrokerStates::BROKER_NOT_START; } - sessionInfo.SafelySetWant(*notifyWant); + sessionInfo.SetWantSafely(*notifyWant); TLOGI(WmsLogTag::WMS_LIFE, "collaborator ret: %{public}d", *ret); if (*ret == 0) { return BrokerStates::BROKER_STARTED; @@ -11168,7 +11223,7 @@ void SceneSessionManager::NotifySessionCreate(sptr sceneSession, c } if (auto collaborator = GetCollaboratorByType(sceneSession->GetCollaboratorType())) { auto abilitySessionInfo = SetAbilitySessionInfo(sceneSession); - abilitySessionInfo->want = sessionInfo.SafelyGetWant(); + abilitySessionInfo->want = sessionInfo.GetWantSafely(); int32_t missionId = abilitySessionInfo->persistentId; std::string bundleName = sessionInfo.bundleName_; int64_t timestamp = containerStartAbilityTime_; @@ -11219,7 +11274,10 @@ void SceneSessionManager::NotifyClearSession(int32_t collaboratorType, int32_t p if (auto collaborator = GetCollaboratorByType(collaboratorType)) { const char* const where = __func__; ffrtQueueHelper_->SubmitTask([collaborator, persistentId, where] { + int timerId = HiviewDFX::XCollie::GetInstance().SetTimer("WMS:SSM:NotifyClearMission", + NOTIFY_START_ABILITY_TIMEOUT/1000, nullptr, nullptr, HiviewDFX::XCOLLIE_FLAG_LOG); int32_t ret = collaborator->NotifyClearMission(persistentId); + HiviewDFX::XCollie::GetInstance().CancelTimer(timerId); TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s called clear mission ret: %{public}d, persistent id: %{public}d", where, ret, persistentId); }); @@ -11515,7 +11573,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapGetPersistentId() == sceneSession->GetPersistentId()) { sptr occupiedAreaInfo = nullptr; - bool occupiedAreaChanged = keyboardSession->CalculateRectAndAvoidArea( + bool occupiedAreaChanged = keyboardSession->RaiseCallingSession( occupiedAreaInfo, !(keyboardSession->GetKeyboardSyncTransactionStatus())); if (occupiedAreaInfo == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "test--- flush ui params, occupiedAreaInfo is nullptr," @@ -11527,8 +11585,8 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapNotifyOccupiedArea( - occupiedAreaInfo, keyboardSession->GetKeyboardSyncTransactionStatus()); + keyboardSession->NotifyOccupiedAreaChangeInfo(occupiedAreaInfo, + keyboardSession->GetRSTransaction()); } } sessionMapDirty_ |= sceneSession->UpdateUIParam(iter->second); @@ -12735,9 +12793,10 @@ void SceneSessionManager::ReportWindowProfileInfos() { enum class WindowVisibleState : int32_t { FOCUSBLE = 0, - VISIBLE, + FULLY_VISIBLE, MINIMIZED, - OCCLUSION + TOTALLY_OCCLUSION, + PARTLY_OCCLUSION }; std::map> sceneSessionMapCopy; { @@ -12751,6 +12810,11 @@ void SceneSessionManager::ReportWindowProfileInfos() continue; } WindowProfileInfo windowProfileInfo; + WSRect rect = currSession->GetSessionRect(); + std::stringstream rectStr; + rectStr << "[" << rect.posX_ << " " << rect.posY_ << " " << rect.width_ << " " << rect.height_ << "]"; + windowProfileInfo.rect = rectStr.str(); + windowProfileInfo.zorder = static_cast(currSession->GetZOrder()); windowProfileInfo.bundleName = currSession->GetSessionInfo().bundleName_; windowProfileInfo.windowLocatedScreen = static_cast( currSession->GetSessionProperty()->GetDisplayId()); @@ -12759,16 +12823,20 @@ void SceneSessionManager::ReportWindowProfileInfos() windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::FOCUSBLE); } else if (currSession->GetSessionState() == SessionState::STATE_BACKGROUND) { windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::MINIMIZED); - } else if (!currSession->GetRSVisible()) { - windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::OCCLUSION); + } else if (currSession->GetVisibilityState() == WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { + windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::TOTALLY_OCCLUSION); + } else if (currSession->GetVisibilityState() == WINDOW_VISIBILITY_STATE_NO_OCCLUSION) { + windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::FULLY_VISIBLE); } else { - windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::VISIBLE); + windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::PARTLY_OCCLUSION); } WindowInfoReporter::GetInstance().ReportWindowProfileInfo(windowProfileInfo); - TLOGD(WmsLogTag::DEFAULT, "bundleName:%{public}s, windowVisibleState:%{public}d, " - "windowLocatedScreen:%{public}d, windowSceneMode:%{public}d", - windowProfileInfo.bundleName.c_str(), windowProfileInfo.windowVisibleState, - windowProfileInfo.windowLocatedScreen, windowProfileInfo.windowSceneMode); + TLOGD(WmsLogTag::DEFAULT, + "bundleName:%{public}s, windowVisibleState:%{public}d, windowLocatedScreen:%{public}d, " + "windowSceneMode:%{public}d, windowZorder:%{public}d, windowRect:%{public}s", + windowProfileInfo.bundleName.c_str(), windowProfileInfo.windowVisibleState, + windowProfileInfo.windowLocatedScreen, windowProfileInfo.windowSceneMode, + windowProfileInfo.zorder, windowProfileInfo.rect.c_str()); } } diff --git a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp index 7c172fdab5..eaeeedef7c 100644 --- a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp +++ b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp @@ -781,13 +781,39 @@ HWTEST_F(MultiScreenManagerTest, MultiScreenModeChange02, TestSize.Level1) MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "extend"); ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); - firstSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); - MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "mirror"); - ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_MIRROR); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: MultiScreenModeChange + * @tc.desc: firstSession == nullptr,secondarySession == nullptr + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, MultiScreenModeChange03, TestSize.Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + + testClient_ = new ScreenSessionManagerClientTest(); + ScreenSessionManager::GetInstance().SetClient(testClient_); + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); firstSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); - MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "extend"); - ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); + secondarySession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "mirror"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_MIRROR); ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); diff --git a/window_scene/test/dms_unittest/multi_screen_power_change_manager_test.cpp b/window_scene/test/dms_unittest/multi_screen_power_change_manager_test.cpp index 895609d1f0..10f4b51215 100644 --- a/window_scene/test/dms_unittest/multi_screen_power_change_manager_test.cpp +++ b/window_scene/test/dms_unittest/multi_screen_power_change_manager_test.cpp @@ -20,6 +20,7 @@ #include "display_manager_agent_default.h" #include "zidl/screen_session_manager_client_interface.h" #include "common_test_utils.h" +#include "test_client.h" using namespace testing; using namespace testing::ext; @@ -111,6 +112,15 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, OnMultiScreenPowerChangeRequest, Tes externalScreen = ssm_.GetScreenSession(screenId); ret = multiSPCM_.OnMultiScreenPowerChangeRequest(innerScreen, externalScreen, switchStatus); + ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + + switchStatus = MultiScreenPowerSwitchType::SCREEN_SWITCH_OFF; + ret = multiSPCM_.OnMultiScreenPowerChangeRequest(innerScreen, externalScreen, switchStatus); + ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + + switchStatus = MultiScreenPowerSwitchType::SCREEN_SWITCH_EXTERNAL; + ret = multiSPCM_.OnMultiScreenPowerChangeRequest(innerScreen, externalScreen, switchStatus); + ASSERT_NE(ret, DMError::DM_ERROR_INVALID_CALLING); ssm_.DestroyVirtualScreen(screenId); } @@ -135,13 +145,14 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleScreenOnChange, TestSize.Level ret = multiSPCM_.HandleScreenOnChange(innerScreen, externalScreen); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); - innerScreen = ssm_.GetDefaultScreenSession(); + innerScreen = ssm_.GetOrCreateScreenSession(0); externalScreen = nullptr; ret = multiSPCM_.HandleScreenOnChange(innerScreen, externalScreen); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); externalScreen = ssm_.GetScreenSession(screenId); ret = multiSPCM_.HandleScreenOnChange(innerScreen, externalScreen); + ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); ssm_.DestroyVirtualScreen(screenId); } @@ -166,13 +177,14 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleScreenOffChange, TestSize.Leve ret = multiSPCM_.HandleScreenOffChange(innerScreen, externalScreen); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); - innerScreen = ssm_.GetDefaultScreenSession(); + innerScreen = ssm_.GetOrCreateScreenSession(0); externalScreen = nullptr; ret = multiSPCM_.HandleScreenOffChange(innerScreen, externalScreen); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); externalScreen = ssm_.GetScreenSession(screenId); ret = multiSPCM_.HandleScreenOffChange(innerScreen, externalScreen); + ASSERT_NE(ret, DMError::DM_ERROR_NULLPTR); ssm_.DestroyVirtualScreen(screenId); } @@ -222,15 +234,29 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleScreenOnlyExternalModeChange, ret = multiSPCM_.HandleScreenOnlyExternalModeChange(innerScreen, externalScreen); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); - innerScreen = ssm_.GetDefaultScreenSession(); + innerScreen = ssm_.GetOrCreateScreenSession(0); externalScreen = nullptr; ret = multiSPCM_.HandleScreenOnlyExternalModeChange(innerScreen, externalScreen); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + externalScreen = ssm_.GetScreenSession(screenId); ret = multiSPCM_.HandleScreenOnlyExternalModeChange(innerScreen, externalScreen); + ASSERT_NE(ret, DMError::DM_ERROR_NULLPTR); ssm_.DestroyVirtualScreen(screenId); } +/** + * @tc.name: ScreenDisplayNodeRemove + * @tc.desc: ScreenDisplayNodeRemove func + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenPowerChangeManagerTest, ScreenDisplayNodeRemove, TestSize.Level1) +{ + sptr screenScreen = new ScreenSession(); + ASSERT_NE(nullptr, screenScreen); + multiSPCM_.ScreenDisplayNodeRemove(screenScreen); +} + /** * @tc.name: HandleInnerMirrorExternalMainChange * @tc.desc: HandleInnerMirrorExternalMainChange func @@ -242,6 +268,28 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerMirrorExternalMainChange, sptr externalScreen = nullptr; auto ret = multiSPCM_.HandleInnerMirrorExternalMainChange(innerScreen, externalScreen); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + + sptr displayManagerAgent = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + ScreenId screenId = ssm_.CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + innerScreen = ssm_.GetScreenSession(screenId); + + sptr displayManagerAgent1 = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + ScreenId screenId1 = ssm_.CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + externalScreen = ssm_.GetScreenSession(screenId1); + innerScreen->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + externalScreen->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + sptr ssmClient = new ScreenSessionManagerClientTest(); + ssm_.SetClient(ssmClient); + ret = multiSPCM_.HandleInnerMirrorExternalMainChange(innerScreen, externalScreen); + ASSERT_EQ(DMError::DM_OK, ret); + ssm_.DestroyVirtualScreen(screenId); + ssm_.DestroyVirtualScreen(screenId1); } /** @@ -251,10 +299,28 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerMirrorExternalMainChange, */ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerMainExternalExtendChange, TestSize.Level1) { - sptr innerScreen = nullptr; - sptr externalScreen = nullptr; + sptr displayManagerAgent = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + ScreenId screenId = ssm_.CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + sptr innerScreen = ssm_.GetScreenSession(screenId); + + sptr displayManagerAgent1 = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + ScreenId screenId1 = ssm_.CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + sptr externalScreen = ssm_.GetScreenSession(screenId1); + + innerScreen->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + externalScreen->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + sptr ssmClient = new ScreenSessionManagerClientTest(); + ssm_.SetClient(ssmClient); auto ret = multiSPCM_.HandleInnerMainExternalExtendChange(innerScreen, externalScreen); - ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + ASSERT_EQ(DMError::DM_OK, ret); + ssm_.DestroyVirtualScreen(screenId); + ssm_.DestroyVirtualScreen(screenId1); } /** @@ -264,10 +330,27 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerMainExternalExtendChange, */ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerMainExternalMirrorChange, TestSize.Level1) { - sptr innerScreen = nullptr; - sptr externalScreen = nullptr; + sptr displayManagerAgent = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + ScreenId screenId = ssm_.CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + sptr innerScreen = ssm_.GetScreenSession(screenId); + + sptr displayManagerAgent1 = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + ScreenId screenId1 = ssm_.CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + sptr externalScreen = ssm_.GetScreenSession(screenId1); + innerScreen->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + externalScreen->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + sptr ssmClient = new ScreenSessionManagerClientTest(); + ssm_.SetClient(ssmClient); auto ret = multiSPCM_.HandleInnerMainExternalMirrorChange(innerScreen, externalScreen); - ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + ASSERT_EQ(DMError::DM_OK, ret); + ssm_.DestroyVirtualScreen(screenId); + ssm_.DestroyVirtualScreen(screenId1); } /** @@ -277,10 +360,27 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerMainExternalMirrorChange, */ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerExtendExternalMainChange, TestSize.Level1) { - sptr innerScreen = nullptr; - sptr externalScreen = nullptr; + sptr displayManagerAgent = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + ScreenId screenId = ssm_.CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + sptr innerScreen = ssm_.GetScreenSession(screenId); + + sptr displayManagerAgent1 = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + ScreenId screenId1 = ssm_.CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + sptr externalScreen = ssm_.GetScreenSession(screenId1); + innerScreen->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + externalScreen->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + sptr ssmClient = new ScreenSessionManagerClientTest(); + ssm_.SetClient(ssmClient); auto ret = multiSPCM_.HandleInnerExtendExternalMainChange(innerScreen, externalScreen); - ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + ASSERT_EQ(DMError::DM_OK, ret); + ssm_.DestroyVirtualScreen(screenId); + ssm_.DestroyVirtualScreen(screenId1); } /** @@ -290,10 +390,27 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleInnerExtendExternalMainChange, */ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleRecoveryInnerMainExternalExtendChange, TestSize.Level1) { - sptr innerScreen = nullptr; - sptr externalScreen = nullptr; + sptr displayManagerAgent = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + ScreenId screenId = ssm_.CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + sptr innerScreen = ssm_.GetScreenSession(screenId); + + sptr displayManagerAgent1 = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + ScreenId screenId1 = ssm_.CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + sptr externalScreen = ssm_.GetScreenSession(screenId1); + innerScreen->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + externalScreen->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + sptr ssmClient = new ScreenSessionManagerClientTest(); + ssm_.SetClient(ssmClient); auto ret = multiSPCM_.HandleRecoveryInnerMainExternalExtendChange(innerScreen, externalScreen); - ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + ASSERT_EQ(DMError::DM_OK, ret); + ssm_.DestroyVirtualScreen(screenId); + ssm_.DestroyVirtualScreen(screenId1); } /** @@ -306,7 +423,7 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleRecoveryInnerMainExternalMirro sptr innerScreen = new ScreenSession(); sptr externalScreen = new ScreenSession(); auto ret = multiSPCM_.HandleRecoveryInnerMainExternalMirrorChange(innerScreen, externalScreen); - ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + ASSERT_NE(ret, DMError::DM_ERROR_NULLPTR); } /** @@ -316,10 +433,27 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleRecoveryInnerMainExternalMirro */ HWTEST_F(MultiScreenPowerChangeManagerTest, HandleRecoveryInnerExtendExternalMainChange, TestSize.Level1) { - sptr innerScreen = nullptr; - sptr externalScreen = nullptr; + sptr displayManagerAgent = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + ScreenId screenId = ssm_.CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + sptr innerScreen = ssm_.GetScreenSession(screenId); + + sptr displayManagerAgent1 = new DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + ScreenId screenId1 = ssm_.CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + sptr externalScreen = ssm_.GetScreenSession(screenId1); + innerScreen->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + externalScreen->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + sptr ssmClient = new ScreenSessionManagerClientTest(); + ssm_.SetClient(ssmClient); auto ret = multiSPCM_.HandleRecoveryInnerExtendExternalMainChange(innerScreen, externalScreen); - ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); + ASSERT_EQ(DMError::DM_OK, ret); + ssm_.DestroyVirtualScreen(screenId); + ssm_.DestroyVirtualScreen(screenId1); } /** @@ -340,8 +474,7 @@ HWTEST_F(MultiScreenPowerChangeManagerTest, ScreenToExtendChange, TestSize.Level virtualOption, displayManagerAgent->AsObject()); screenSession = ssm_.GetScreenSession(screenId); multiSPCM_.ScreenToExtendChange(ssmClient, screenSession); - /* ssmClient is null */ - ASSERT_EQ(ssmClient, nullptr); + ASSERT_NE(ssmClient, nullptr); } /** diff --git a/window_scene/test/dms_unittest/screen_scene_config_test.cpp b/window_scene/test/dms_unittest/screen_scene_config_test.cpp index fa53f13b5f..f21cde4d87 100644 --- a/window_scene/test/dms_unittest/screen_scene_config_test.cpp +++ b/window_scene/test/dms_unittest/screen_scene_config_test.cpp @@ -467,16 +467,107 @@ HWTEST_F(ScreenSceneConfigTest, GetCurvedCompressionAreaInLandscape, TestSize.Le } /** - * @tc.name: Split - * @tc.desc: Split func + * @tc.name: Split01 + * @tc.desc: Split01 func * @tc.type: FUNC */ -HWTEST_F(ScreenSceneConfigTest, Split, TestSize.Level1) +HWTEST_F(ScreenSceneConfigTest, Split01, TestSize.Level1) { auto result = ScreenSceneConfig::Split("oo", "+9"); ASSERT_NE(0, result.size()); } +/** + * @tc.name: Split02 + * @tc.desc: Test Split function when no pattern is found in the string + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, Split02, TestSize.Level1) +{ + std::string str = "HelloWorld"; + std::string pattern = "::"; + std::vector result = ScreenSceneConfig::Split(str, pattern); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(result[0], str); +} + +/** + * @tc.name: Split03 + * @tc.desc: Test Split function when one pattern is found in the string + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, Split03, TestSize.Level1) +{ + std::string str = "Hello::World"; + std::string pattern = "::"; + std::vector result = ScreenSceneConfig::Split(str, pattern); + EXPECT_EQ(result.size(), 2); + EXPECT_EQ(result[0], "Hello"); + EXPECT_EQ(result[1], "World"); +} + +/** + * @tc.name: Split04 + * @tc.desc: Test Split function when multiple patterns are found in the string + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, Split04, TestSize.Level1) +{ + std::string str = "Hello::World::This::Is::A::Test"; + std::string pattern = "::"; + std::vector result = ScreenSceneConfig::Split(str, pattern); + EXPECT_EQ(result.size(), 6); + EXPECT_EQ(result[0], "Hello"); + EXPECT_EQ(result[1], "World"); + EXPECT_EQ(result[2], "This"); + EXPECT_EQ(result[3], "Is"); + EXPECT_EQ(result[4], "A"); + EXPECT_EQ(result[5], "Test"); +} + +/** + * @tc.name: Split05 + * @tc.desc: Test Split function when the string ends with the pattern. + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, Split05, TestSize.Level1) +{ + std::string str = "Hello::World::"; + std::string pattern = "::"; + std::vector result = ScreenSceneConfig::Split(str, pattern); + EXPECT_EQ(result.size(), 3); + EXPECT_EQ(result[0], "Hello"); + EXPECT_EQ(result[1], "World"); + EXPECT_EQ(result[2], ""); +} + +/** + * @tc.name: Split06 + * @tc.desc: Test Split function when the input string is the same as the pattern. + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, Split06, TestSize.Level1) +{ + std::string str = "::"; + std::string pattern = "::"; + std::vector result = ScreenSceneConfig::Split(str, pattern); + EXPECT_EQ(result.size(), 2); + EXPECT_EQ(result[0], ""); + EXPECT_EQ(result[1], ""); +} + +/** + * @tc.name: GetAllDisplayPhysicalConfig01 + * @tc.desc: GetAllDisplayPhysicalConfig01 func + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, GetAllDisplayPhysicalConfig01, TestSize.Level1) +{ + ScreenSceneConfig::displayPhysicalResolution_.clear(); + std::vector actual = ScreenSceneConfig::GetAllDisplayPhysicalConfig(); + EXPECT_TRUE(actual.empty()); +} + /** * @tc.name: CalcCutoutBoundaryRect * @tc.desc: CalcCutoutBoundaryRect func diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp index 15ec86013a..2da664638e 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp @@ -482,6 +482,27 @@ HWTEST_F(ScreenSessionManagerClientStubTest, OnRemoteRequest19, TestSize.Level1) EXPECT_EQ(res, 0); } +/** + * @tc.name: OnRemoteRequest20 + * @tc.desc: TRANS_ID_ON_SCREEN_MODE_CHANGED + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientStubTest, OnRemoteRequest20, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerClientStub::GetDescriptor()); + ScreenModeChangeEvent screenModeChangeEvent = ScreenModeChangeEvent::UNKNOWN; + data.WriteInt32(static_cast(screenModeChangeEvent)); + + uint32_t code = static_cast( + IScreenSessionManagerClient::ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_MODE_CHANGED); + int res = screenSessionManagerClientStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + /** * @tc.name: HandleOnScreenConnectionChanged * @tc.desc: HandleOnScreenConnectionChanged test @@ -928,5 +949,24 @@ HWTEST_F(ScreenSessionManagerClientStubTest, HandleSyncScreenCombination, TestSi auto ret = screenSessionManagerClientStub_->HandleSyncScreenCombination(data, reply); EXPECT_EQ(ret, 0); } + +/** + * @tc.name: HandleOnScreenModeChanged + * @tc.desc: HandleOnScreenModeChanged test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientStubTest, HandleOnScreenModeChanged, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + + data.WriteInterfaceToken(ScreenSessionManagerClientStub::GetDescriptor()); + + ScreenModeChangeEvent screenModeChangeEvent = ScreenModeChangeEvent::UNKNOWN; + data.WriteUint32(static_cast(screenModeChangeEvent)); + ASSERT_TRUE(screenSessionManagerClientStub_ != nullptr); + auto ret = screenSessionManagerClientStub_->HandleOnScreenModeChanged(data, reply); + EXPECT_EQ(ret, 0); +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_lite_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_lite_test.cpp index d4ccfa152d..4ea5c80801 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_lite_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_lite_test.cpp @@ -205,7 +205,7 @@ HWTEST_F(ScreenSessionManagerLiteTest, GetInstance_ShouldReturnExistingInstance_ ScreenSessionManagerLite& instance2 = ScreenSessionManagerLite::GetInstance(); - EXPECT_NE(&instance1, &instance2); + EXPECT_EQ(&instance1, &instance2); } } } // namespace Rosen diff --git a/window_scene/test/dms_unittest/screen_session_manager_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_test.cpp index ad38416e56..20a5cbe417 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -24,6 +24,7 @@ #include "scene_board_judgement.h" #include "fold_screen_state_internel.h" #include "common_test_utils.h" +#include "iremote_object_mocker.h" using namespace testing; using namespace testing::ext; @@ -2279,7 +2280,7 @@ HWTEST_F(ScreenSessionManagerTest, HasPrivateWindow, TestSize.Level1) * @tc.desc: GetAvailableArea test * @tc.type: FUNC */ -HWTEST_F(ScreenSessionManagerTest, GetAvailableArea, TestSize.Level1) +HWTEST_F(ScreenSessionManagerTest, GetAvailableArea01, TestSize.Level1) { DMRect area; EXPECT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->GetAvailableArea(SCREEN_ID_INVALID, area)); @@ -2290,6 +2291,42 @@ HWTEST_F(ScreenSessionManagerTest, GetAvailableArea, TestSize.Level1) EXPECT_EQ(DMError::DM_OK, ssm_->GetAvailableArea(id, area)); } +/** + * @tc.name: GetAvailableArea + * @tc.desc: GetAvailableArea test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetAvailableArea02, TestSize.Level1) +{ + DMRect area; + DisplayId id = 999; + sptr screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0); + ssm_->screenSessionMap_.clear(); + ssm_->screenSessionMap_[id] = screenSession; + ASSERT_NE(nullptr, screenSession); + EXPECT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->GetAvailableArea(id, area)); + ssm_->screenSessionMap_.clear(); +} + + +/** + * @tc.name: GetExpandAvailableArea + * @tc.desc: GetExpandAvailableArea test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetExpandAvailableArea02, TestSize.Level1) +{ + DMRect area; + DisplayId id = 0; + EXPECT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->GetExpandAvailableArea(id, area)); + sptr screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0); + ssm_->screenSessionMap_.clear(); + ssm_->screenSessionMap_[id] = screenSession; + ASSERT_NE(nullptr, screenSession); + EXPECT_EQ(DMError::DM_OK, ssm_->GetExpandAvailableArea(id, area)); + ssm_->screenSessionMap_.clear(); +} + /** * @tc.name: ResetAllFreezeStatus * @tc.desc: ResetAllFreezeStatus test @@ -2550,7 +2587,7 @@ HWTEST_F(ScreenSessionManagerTest, SetVirtualDisplayMuteFlag02, Function | Small * @tc.desc: GetAllDisplayPhysicalResolution test * @tc.type: FUNC */ -HWTEST_F(ScreenSessionManagerTest, GetAllDisplayPhysicalResolution, TestSize.Level1) +HWTEST_F(ScreenSessionManagerTest, GetAllDisplayPhysicalResolution01, TestSize.Level1) { std::vector allSize {}; if (ssm_ != nullptr) { @@ -2561,6 +2598,54 @@ HWTEST_F(ScreenSessionManagerTest, GetAllDisplayPhysicalResolution, TestSize.Lev } } +/** + * @tc.name: GetAllDisplayPhysicalResolution + * @tc.desc: GetAllDisplayPhysicalResolution test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetAllDisplayPhysicalResolution02, TestSize.Level1) +{ + ssm_->allDisplayPhysicalResolution_.clear(); + ssm_->allDisplayPhysicalResolution_.emplace_back(DisplayPhysicalResolution()); + std::vector result = ssm_->GetAllDisplayPhysicalResolution(); + EXPECT_TRUE(!result.empty()); + ssm_->allDisplayPhysicalResolution_.clear(); +} + +/** + * @tc.name: GetAllDisplayPhysicalResolution + * @tc.desc: GetAllDisplayPhysicalResolution test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetAllDisplayPhysicalResolution03, TestSize.Level1) +{ + DisplayPhysicalResolution resolution; + resolution.physicalWidth_ = 1920; + resolution.physicalHeight_ = 1080; + ssm_->allDisplayPhysicalResolution_.clear(); + ssm_->allDisplayPhysicalResolution_.push_back(resolution); + std::vector result = ssm_->GetAllDisplayPhysicalResolution(); + EXPECT_EQ(result.size(), 1); + EXPECT_EQ(result[0].physicalWidth_, 1920); + EXPECT_EQ(result[0].physicalHeight_, 1080); + ssm_->allDisplayPhysicalResolution_.clear(); +} + +/** + * @tc.name: GetAllDisplayPhysicalResolution + * @tc.desc: GetAllDisplayPhysicalResolution test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetAllDisplayPhysicalResolution04, TestSize.Level1) +{ + ssm_->allDisplayPhysicalResolution_.clear(); + ssm_->allDisplayPhysicalResolution_.emplace_back(DisplayPhysicalResolution()); + ssm_->allDisplayPhysicalResolution_.back().foldDisplayMode_ = FoldDisplayMode::GLOBAL_FULL; + std::vector resolutions = ssm_->GetAllDisplayPhysicalResolution(); + EXPECT_EQ(resolutions.back().foldDisplayMode_, FoldDisplayMode::FULL); + ssm_->allDisplayPhysicalResolution_.clear(); +} + /** * @tc.name: SetDisplayScale * @tc.desc: SetDisplayScale test @@ -5637,7 +5722,7 @@ HWTEST_F(ScreenSessionManagerTest, SetSystemKeyboardStatus01, Function | SmallTe auto ret = ssm_->SetSystemKeyboardStatus(true); ASSERT_NE(ret, DMError::DM_ERROR_UNKNOWN); } - + /** * @tc.name: SetSystemKeyboardStatus * @tc.desc: SetSystemKeyboardStatus with false as parameter @@ -6004,7 +6089,7 @@ HWTEST_F(ScreenSessionManagerTest, CheckMultiScreenInfoMap, Function | SmallTest HWTEST_F(ScreenSessionManagerTest, SetMultiScreenFrameControl, Function | SmallTest | Level3) { ASSERT_NE(ssm_, nullptr); - + sptr screenSession1 = new ScreenSession(50, ScreenProperty(), 0); ASSERT_NE(nullptr, screenSession1); screenSession1->SetScreenType(ScreenType::REAL); @@ -6045,7 +6130,7 @@ HWTEST_F(ScreenSessionManagerTest, GetInternalScreenSession, Function | SmallTes sptr screenSession1 = nullptr; ASSERT_EQ(nullptr, screenSession1); ssm_->screenSessionMap_[50] = screenSession1; - + sptr screenSession2 = new ScreenSession(51, ScreenProperty(), 0); ASSERT_NE(nullptr, screenSession2); screenSession2->SetScreenType(ScreenType::REAL); @@ -6091,7 +6176,7 @@ HWTEST_F(ScreenSessionManagerTest, GetInternalAndExternalSession, Function | Sma sptr screenSession1 = nullptr; ASSERT_EQ(nullptr, screenSession1); ssm_->screenSessionMap_[50] = screenSession1; - + sptr screenSession2 = new ScreenSession(51, ScreenProperty(), 0); ASSERT_NE(nullptr, screenSession2); screenSession2->SetIsCurrentInUse(false); @@ -6350,6 +6435,194 @@ HWTEST_F(ScreenSessionManagerTest, SetRSScreenPowerStatus, TestSize.Level1) state = ssm_->GetScreenPower(0); EXPECT_EQ(state, ScreenPowerState::POWER_OFF); } + +/** + * @tc.name: GetScreenCombination01 + * @tc.desc: GetScreenCombination01 + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetScreenCombination01, TestSize.Level1) +{ + ScreenId screenId = 1051; + auto ret = ssm_->GetScreenCombination(screenId); + EXPECT_EQ(ret, ScreenCombination::SCREEN_ALONE); +} + +/** + * @tc.name: GetScreenCombination02 + * @tc.desc: !screenSession = false + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetScreenCombination02, TestSize.Level1) +{ + ScreenId screenId = 1050; + sptr screenSession = new (std::nothrow) ScreenSession(screenId, ScreenProperty(), 0); + EXPECT_NE(screenSession, nullptr); + ssm_->screenSessionMap_[screenId] = screenSession; + auto ret = ssm_->GetScreenCombination(screenId); + EXPECT_EQ(ret, ScreenCombination::SCREEN_ALONE); +} + +/** + * @tc.name: OnRemoteDied01 + * @tc.desc: OnRemoteDied_ShouldReturnFalse_WhenAgentIsNUllptr + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, OnRemoteDied01, TestSize.Level1) +{ + EXPECT_FALSE(ssm_->OnRemoteDied(nullptr)); +} + +/** + * @tc.name: OnRemoteDied02 + * @tc.desc: OnRemoteDied_ShouldReturnTrue_WhenAgentNotFound + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, OnRemoteDied02, TestSize.Level1) +{ + sptr agent = sptr::MakeSptr(); + EXPECT_TRUE(ssm_->OnRemoteDied(agent)); +} + +/** + * @tc.name: OnRemoteDied03 + * @tc.desc: OnRemoteDied_ShouldRemoveAgent_WhenAgentFoundAndNoScreens + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, OnRemoteDied03, TestSize.Level1) +{ + sptr agent = sptr::MakeSptr(); + ssm_->screenAgentMap_[agent] = {}; + + EXPECT_TRUE(ssm_->OnRemoteDied(agent)); + EXPECT_TRUE(ssm_->screenAgentMap_.find(agent) == ssm_->screenAgentMap_.end()); +} + +/** + * @tc.name: GetExpandAvailableArea + * @tc.desc: GetExpandAvailableArea test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetExpandAvailableArea, TestSize.Level1) +{ + DMRect area; + EXPECT_EQ(DMError::DM_ERROR_NULLPTR, ssm_->GetExpandAvailableArea(SCREEN_ID_INVALID, area)); + DisplayId id = 0; + sptr screenSession = new (std::nothrow) ScreenSession(id, ScreenProperty(), 0); + ssm_->screenSessionMap_[id] = screenSession; + ASSERT_NE(nullptr, screenSession); + EXPECT_EQ(DMError::DM_OK, ssm_->GetExpandAvailableArea(id, area)); +} + +/** + * @tc.name: GetFakePhysicalScreenSession001 + * @tc.desc: Test that the function returns nullptr when g_isPcDevice is false + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetFakePhysicalScreenSession001, TestSize.Level1) +{ + ScreenId screenId = 1; + ScreenId defScreenId = 2; + ScreenProperty property; + + auto screenSession = ScreenSessionManager::GetInstance().GetFakePhysicalScreenSession(screenId, defScreenId, + property); + EXPECT_EQ(screenSession, nullptr); +} + +/** + * @tc.name: CreateFakePhysicalMirrorSessionInner + * @tc.desc: CreateFakePhysicalMirrorSessionInner + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, CreateFakePhysicalMirrorSessionInner, TestSize.Level1) +{ + ScreenId screenId = 1; + ScreenId defScreenId = 2; + ScreenProperty property; + + auto screenSession = ScreenSessionManager::GetInstance().CreateFakePhysicalMirrorSessionInner(screenId, defScreenId, + property); + EXPECT_EQ(screenSession, nullptr); +} + +/** + * @tc.name: GetPhysicalScreenSessionInner + * @tc.desc: GetPhysicalScreenSessionInner + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetPhysicalScreenSessionInner, TestSize.Level1) +{ + ScreenId screenId = 1; + ScreenProperty property; + + auto screenSession = ScreenSessionManager::GetInstance().GetPhysicalScreenSessionInner(screenId, property); + EXPECT_EQ(screenSession, nullptr); +} + +/** + * @tc.name: GetOrCreatePhysicalScreenSession + * @tc.desc: Test scenario where no existing physical screen session exists and new session creation fails + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetOrCreatePhysicalScreenSession, TestSize.Level1) +{ + ScreenId screenId = 1; + sptr result = ScreenSessionManager::GetInstance().GetOrCreatePhysicalScreenSession(screenId); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.name: GetScreenSessionByRsId + * @tc.desc: GetScreenSessionByRsId + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetScreenSessionByRsId, TestSize.Level1) +{ + ScreenId rsScreenId = 123; + ssm_->screenSessionMap_[rsScreenId] = nullptr; + sptr newSession = new ScreenSession(); + + sptr result = ScreenSessionManager::GetInstance().GetScreenSessionByRsId(rsScreenId); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.name: GetPhysicalScreenSession001 + * @tc.desc: Test GetPhysicalScreenSession function when screenId is not found in the map + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetPhysicalScreenSession001, TestSize.Level1) +{ + ScreenId screenId = 123; + EXPECT_EQ(ssm_->GetPhysicalScreenSession(screenId), nullptr); +} + +/** + * @tc.name: GetPhysicalScreenSession002 + * @tc.desc: Test GetPhysicalScreenSession function when screenSessionMap is empty + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetPhysicalScreenSession002, TestSize.Level1) +{ + ssm_->screenAgentMap_.clear(); + ScreenId screenId = 123; + EXPECT_EQ(ssm_->GetPhysicalScreenSession(screenId), nullptr); +} + +/** + * @tc.name: OnScreenModeChange + * @tc.desc: OnScreenModeChange + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, OnScreenModeChange, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ASSERT_EQ(ssm_->clientProxy_, nullptr); + + ScreenModeChangeEvent screenModeChangeEvent = ScreenModeChangeEvent::UNKNOWN; + ssm_->OnScreenModeChange(screenModeChangeEvent); +} } } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 15710819b3..c7b627fbc6 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -18,12 +18,21 @@ #include "screen_session_manager/include/screen_session_manager.h" #include "scene_board_judgement.h" #include "fold_screen_state_internel.h" +#include "window_manager_hilog.h" // using namespace FRAME_TRACE; using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class MockScreenChangeListener : public IScreenChangeListener { public: void OnConnect(ScreenId screenId) override {} @@ -44,6 +53,7 @@ public: void OnExtendScreenConnectStatusChange(ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus) override {} void OnBeforeScreenPropertyChange(FoldStatus foldStatus) override {} + void OnScreenModeChange(ScreenModeChangeEvent screenModeChangeEvent) override {} }; class ScreenSessionTest : public testing::Test { public: @@ -457,42 +467,6 @@ HWTEST_F(ScreenSessionTest, UpdateToInputManager, TestSize.Level1) GTEST_LOG_(INFO) << "UpdateToInputManager end"; } -/** - * @tc.name: OptimizeSecondaryDisplayMode - * @tc.desc: normal function - * @tc.type: FUNC - */ -HWTEST_F(ScreenSessionTest, OptimizeSecondaryDisplayMode01, TestSize.Level1) -{ - if (!FoldScreenStateInternel::IsSecondaryDisplayFoldDevice()) { - GTEST_SKIP(); - } - GTEST_LOG_(INFO) << "OptimizeSecondaryDisplayMode start"; - ScreenSessionConfig config = { - .screenId = 100, - .rsId = 101, - .name = "OpenHarmony", - }; - sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); - ASSERT_NE(screenSession, nullptr); - FoldDisplayMode foldDisplayMode = FoldDisplayMode::UNKNOWN; - RRect bounds; - bounds.rect_.width_ = 1008; - bounds.rect_.height_ = 2232; - screenSession->OptimizeSecondaryDisplayMode(bounds, foldDisplayMode); - EXPECT_EQ(foldDisplayMode, FoldDisplayMode::MAIN); - - bounds.rect_.width_ = 2048; - screenSession->OptimizeSecondaryDisplayMode(bounds, foldDisplayMode); - EXPECT_EQ(foldDisplayMode, FoldDisplayMode::FULL); - - bounds.rect_.width_ = 3184; - screenSession->OptimizeSecondaryDisplayMode(bounds, foldDisplayMode); - EXPECT_EQ(foldDisplayMode, FoldDisplayMode::GLOBAL_FULL); - - GTEST_LOG_(INFO) << "OptimizeSecondaryDisplayMode end"; -} - /** * @tc.name: UpdatePropertyAfterRotation * @tc.desc: normal function @@ -771,6 +745,12 @@ HWTEST_F(ScreenSessionTest, GetSourceMode, TestSize.Level0) screenSession->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE); mode = screenSession->GetSourceMode(); ASSERT_EQ(mode, ScreenSourceMode::SCREEN_UNIQUE); + screenSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + mode = screenSession->GetSourceMode(); + ASSERT_EQ(mode, ScreenSourceMode::SCREEN_EXTEND); + screenSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + mode = screenSession->GetSourceMode(); + ASSERT_EQ(mode, ScreenSourceMode::SCREEN_MAIN); GTEST_LOG_(INFO) << "ScreenSessionTest: GetSourceMode end"; } @@ -1308,8 +1288,14 @@ HWTEST_F(ScreenSessionTest, GetScreenSupportedColorGamuts, TestSize.Level1) { GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenSupportedColorGamuts start"; std::vector colorGamuts; - sptr session = new(std::nothrow) ScreenSession(); - DMError ret = session->GetScreenSupportedColorGamuts(colorGamuts); + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + ASSERT_NE(screenSession, nullptr); + DMError ret = screenSession->GetScreenSupportedColorGamuts(colorGamuts); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_OK); } else { @@ -1369,11 +1355,15 @@ HWTEST_F(ScreenSessionTest, GetScreenColorGamut, TestSize.Level1) { #ifdef WM_SCREEN_COLOR_GAMUT_ENABLE GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenColorGamut start"; - sptr session = new(std::nothrow) ScreenSession(); - ASSERT_NE(session, nullptr); - + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + ASSERT_NE(screenSession, nullptr); ScreenColorGamut colorGamut; - DMError res = session->GetScreenColorGamut(colorGamut); + DMError res = screenSession->GetScreenColorGamut(colorGamut); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(res, DMError::DM_OK); } else { @@ -1416,7 +1406,7 @@ HWTEST_F(ScreenSessionTest, SetScreenColorGamut02, TestSize.Level1) int32_t colorGamut = -1; DMError res = session->SetScreenColorGamut(colorGamut); - ASSERT_EQ(res, DMError::DM_ERROR_INVALID_PARAM); + EXPECT_NE(res, DMError::DM_OK); GTEST_LOG_(INFO) << "ScreenSessionTest: SetScreenColorGamut end"; #endif } @@ -1960,6 +1950,8 @@ HWTEST_F(ScreenSessionTest, screen_session_test005, TestSize.Level1) ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::CHANGE_MODE; int res = 0; session->PropertyChange(newProperty, reason); + reason = ScreenPropertyChangeReason::VIRTUAL_PIXEL_RATIO_CHANGE; + session->PropertyChange(newProperty, reason); ASSERT_EQ(res, 0); GTEST_LOG_(INFO) << "ScreenSessionTest: screen_session_test005 end"; } @@ -2879,6 +2871,351 @@ HWTEST_F(ScreenSessionTest, UpdateDisplayNodeRotation, Function | SmallTest | Le ASSERT_EQ(screenSession->isExtended_, false); GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateDisplayNodeRotation end"; } + +/** + * @tc.name: UpdateExpandAvailableArea01 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, UpdateExpandAvailableArea01, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "UpdateExpandAvailableArea start"; + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + DMRect area = screenSession->GetAvailableArea(); + auto res = screenSession->UpdateExpandAvailableArea(area); + ASSERT_EQ(res, false); + area = {2, 2, 2, 2}; + res = screenSession->UpdateExpandAvailableArea(area); + ASSERT_EQ(res, true); + GTEST_LOG_(INFO) << "UpdateExpandAvailableArea end"; +} + +/** + * @tc.name: ScreenExtendChange01 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, ScreenExtendChange01, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenExtendChange start"; + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + ScreenId mainScreenId = 0; + ScreenId extendScreenId = 1; + screenSession->ScreenExtendChange(mainScreenId, extendScreenId); + GTEST_LOG_(INFO) << "UpdateExpandAvailableArea end"; +} + +/** + * @tc.name: ScreenExtendChange02 + * @tc.desc: run in for + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, ScreenExtendChange02, TestSize.Level1) +{ + LOG_SetCallback(MyLogCallback); + IScreenChangeListener* screenChangeListener = new MockScreenChangeListener(); + sptr session = new(std::nothrow) ScreenSession(); + EXPECT_NE(nullptr, session); + session->RegisterScreenChangeListener(screenChangeListener); + ScreenId mainScreenId = 0; + ScreenId extendScreenId = 1; + session->ScreenExtendChange(mainScreenId, extendScreenId); + EXPECT_FALSE(g_errLog.find("screenChangeListener is null.") != std::string::npos); +} + +/** + * @tc.name: SuperFoldStatusChange01 + * @tc.desc: run in for + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SuperFoldStatusChange01, TestSize.Level1) +{ + LOG_SetCallback(MyLogCallback); + sptr session = new(std::nothrow) ScreenSession(); + EXPECT_NE(nullptr, session); + ScreenId mainScreenId = 0; + SuperFoldStatus superFoldStatus = SuperFoldStatus::UNKNOWN; + session->SuperFoldStatusChange(mainScreenId, superFoldStatus); + EXPECT_EQ(true, session->screenChangeListenerList_.empty()); + EXPECT_TRUE(g_errLog.find("screenChangeListenerList is empty.") != std::string::npos); +} + +/** + * @tc.name: ExtendScreenConnectStatusChange + * @tc.desc: run in for + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, ExtendScreenConnectStatusChange, TestSize.Level1) +{ + LOG_SetCallback(MyLogCallback); + sptr session = new(std::nothrow) ScreenSession(); + EXPECT_NE(nullptr, session); + ScreenId mainScreenId = 0; + ExtendScreenConnectStatus extendScreenConnectStatus = ExtendScreenConnectStatus::UNKNOWN; + session->ExtendScreenConnectStatusChange(mainScreenId, extendScreenConnectStatus); + EXPECT_EQ(true, session->screenChangeListenerList_.empty()); + EXPECT_TRUE(g_errLog.find("screenChangeListenerList is empty.") != std::string::npos); +} + +/** + * @tc.name: SecondaryReflexionChange + * @tc.desc: run in for + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SecondaryReflexionChange, TestSize.Level1) +{ + LOG_SetCallback(MyLogCallback); + sptr session = new(std::nothrow) ScreenSession(); + EXPECT_NE(nullptr, session); + ScreenId mainScreenId = 0; + bool isSecondaryReflexion = true; + session->SecondaryReflexionChange(mainScreenId, isSecondaryReflexion); + EXPECT_EQ(true, session->screenChangeListenerList_.empty()); + EXPECT_TRUE(g_errLog.find("screenChangeListenerList is empty.") != std::string::npos); +} + +/** + * @tc.name: SetFrameGravity + * @tc.desc: run in for + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetFrameGravity, TestSize.Level1) +{ + LOG_SetCallback(MyLogCallback); + sptr session = new(std::nothrow) ScreenSession(); + EXPECT_NE(nullptr, session); + session->displayNode_ = nullptr; + Gravity gravity = Rosen::Gravity::RESIZE; + session->SetFrameGravity(gravity); + EXPECT_TRUE(g_errLog.find("displayNode_ is null, setFrameGravity failed") != std::string::npos); +} + +/** + * @tc.name: UpdatePropertyOnly + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, UpdatePropertyOnly, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "UpdatePropertyOnly start"; + LOG_SetCallback(MyLogCallback); + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + RRect bounds; + bounds.rect_.width_ = 1344; + bounds.rect_.height_ = 2772; + int rotation = 90; + FoldDisplayMode foldDisplayMode = FoldDisplayMode::MAIN; + screenSession->UpdatePropertyOnly(bounds, rotation, foldDisplayMode); + EXPECT_FALSE(g_errLog.find("bounds:[%{public}f %{public}f %{public}f %{public}f],\ + rotation:%{public}d, displayOrientation:%{public}u") != std::string::npos); + GTEST_LOG_(INFO) << "UpdatePropertyOnly end"; +} + +/** + * @tc.name: ReuseDisplayNode + * @tc.desc: ReuseDisplayNode test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, ReuseDisplayNode, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: ReuseDisplayNode start"; + Rosen::RSDisplayNodeConfig rsConfig; + rsConfig.isMirrored = true; + rsConfig.screenId = 101; + sptr screenSession = new ScreenSession(); + screenSession->displayNode_ = nullptr; + screenSession->ReuseDisplayNode(rsConfig); + GTEST_LOG_(INFO) << "ScreenSessionTest: ReuseDisplayNode end"; +} + +/** + * @tc.name: ConvertToRealDisplayInfo + * @tc.desc: ConvertToRealDisplayInfo test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, ConvertToRealDisplayInfo, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToRealDisplayInfo start"; + sptr displayInfo = new(std::nothrow) DisplayInfo(); + ASSERT_NE(displayInfo, nullptr); + sptr screenSession = new ScreenSession(); + ASSERT_NE(screenSession->ConvertToRealDisplayInfo(), nullptr); + GTEST_LOG_(INFO) << "ScreenSessionTest: ConvertToRealDisplayInfo end"; +} + +/** + * @tc.name: UpdateVirtualPixelRatio + * @tc.desc: UpdateVirtualPixelRatio test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, UpdateVirtualPixelRatio, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateVirtualPixelRatio start"; + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + EXPECT_NE(nullptr, screenSession); + RRect bounds; + bounds.rect_.width_ = 1344; + bounds.rect_.height_ = 2772; + screenSession->UpdateVirtualPixelRatio(bounds); + float curVirtualPixelRatio = screenSession->property_.GetVirtualPixelRatio(); + ASSERT_EQ(curVirtualPixelRatio, 3.5f); + GTEST_LOG_(INFO) << "ScreenSessionTest: UpdateVirtualPixelRatio end"; +} + +/** + * @tc.name: SetInnerName + * @tc.desc: SetInnerName test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetInnerName, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: SetInnerName start"; + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + EXPECT_NE(nullptr, screenSession); + std::string innerName = "OpenHarmony"; + screenSession->SetInnerName(innerName); + EXPECT_EQ(innerName, screenSession->GetInnerName()); + GTEST_LOG_(INFO) << "ScreenSessionTest: SetInnerName end"; +} + +/** + * @tc.name: SetFakeScreenSession + * @tc.desc: SetFakeScreenSession test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetFakeScreenSession, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: SetFakeScreenSession start"; + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + ScreenSessionConfig fakeConfig = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr fakeScreenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + screenSession->SetFakeScreenSession(fakeScreenSession); + ASSERT_EQ(screenSession->GetFakeScreenSession(), fakeScreenSession); + GTEST_LOG_(INFO) << "ScreenSessionTest: SetFakeScreenSession end"; +} + +/** + * @tc.name: GetScreenShape + * @tc.desc: GetScreenShape test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, GetScreenShape, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenShape start"; + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + screenSession->property_.SetScreenShape(ScreenShape::RECTANGLE); + ASSERT_EQ(screenSession->GetScreenShape(), ScreenShape::RECTANGLE); + screenSession->property_.SetScreenShape(ScreenShape::ROUND); + ASSERT_EQ(screenSession->GetScreenShape(), ScreenShape::ROUND); + GTEST_LOG_(INFO) << "ScreenSessionTest: GetScreenShape end"; +} + +/** + * @tc.name: SetSerialNumber + * @tc.desc: SetSerialNumber test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetSerialNumber, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: SetSerialNumber start"; + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + std::string serialNumber = "OpenHarmony"; + screenSession->SetSerialNumber(serialNumber); + ASSERT_EQ(screenSession->GetSerialNumber(), serialNumber); + GTEST_LOG_(INFO) << "ScreenSessionTest: SetSerialNumber end"; +} + +/** + * @tc.name: UpdatePropertyByFakeBounds + * @tc.desc: UpdatePropertyByFakeBounds test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, UpdatePropertyByFakeBounds, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByFakeBounds start"; + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + EXPECT_NE(nullptr, screenSession); + uint32_t width = 1000; + uint32_t height = 1500; + screenSession->UpdatePropertyByFakeBounds(width, height); + auto screenFakeBounds = screenSession->property_.GetFakeBounds(); + ASSERT_EQ(screenFakeBounds.rect_.width_, width); + ASSERT_EQ(screenFakeBounds.rect_.height_, height); + GTEST_LOG_(INFO) << "ScreenSessionTest: UpdatePropertyByFakeBounds end"; +} + +/** + * @tc.name: GetValidSensorRotation + * @tc.desc: GetValidSensorRotation test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, GetValidSensorRotation, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ScreenSessionTest: GetValidSensorRotation start"; + ScreenSessionConfig config = { + .screenId = 0, + .rsId = 0, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); + EXPECT_NE(nullptr, screenSession); + Rotation sensorRotation = Rotation::ROTATION_0; + screenSession->SensorRotationChange(sensorRotation); + ASSERT_EQ(0, screenSession->GetValidSensorRotation()); + GTEST_LOG_(INFO) << "ScreenSessionTest: GetValidSensorRotation end"; +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/test_client.h b/window_scene/test/dms_unittest/test_client.h index 3cd810fedc..320ca00ecf 100644 --- a/window_scene/test/dms_unittest/test_client.h +++ b/window_scene/test/dms_unittest/test_client.h @@ -59,6 +59,7 @@ public: void SetScreenCombination(ScreenId mainScreenId, ScreenId extendScreenId, ScreenCombination extendCombination) override {}; std::string OnDumperClientScreenSessions() override { return ""; }; + void OnScreenModeChanged(ScreenModeChangeEvent screenModeChangeEvent) override {}; sptr AsObject() override {return testPtr;}; sptr testPtr; }; diff --git a/window_scene/test/mock/mock_ibundle_mgr.h b/window_scene/test/mock/mock_ibundle_mgr.h index 2c27c891f7..7e39dd0873 100644 --- a/window_scene/test/mock/mock_ibundle_mgr.h +++ b/window_scene/test/mock/mock_ibundle_mgr.h @@ -21,6 +21,7 @@ namespace OHOS::AppExecFwk { class IBundleMgr; +struct AbilityInfo; struct ApplicationInfo; enum ApplicationFlag; struct BundleInfo; @@ -39,6 +40,8 @@ public: const int32_t userId, AppExecFwk::ApplicationInfo& appInfo)); MOCK_METHOD4(GetBundleInfoV9, ErrCode(const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId)); + MOCK_METHOD3(QueryLauncherAbilityInfos, ErrCode(const AAFwk::Want &want, int32_t userId, + std::vector& abilityInfos)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index 78e5c771a3..176af016da 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -28,7 +28,8 @@ public: MOCK_METHOD1(SetActive, WSError(bool active)); MOCK_METHOD4(UpdateRect, WSError(const WSRect& rect, SizeChangeReason reason, - const SceneAnimationConfig& config, const std::map& avoidAreas)); + const SceneAnimationConfig& config, const std::map& avoidAreas, + const sptr& info)); MOCK_METHOD0(UpdateDensity, void(void)); MOCK_METHOD0(UpdateOrientation, WSError(void)); MOCK_METHOD1(UpdateSessionViewportConfig, WSError(const SessionViewportConfig& config)); @@ -39,8 +40,8 @@ public: MOCK_METHOD2(NotifyTransferComponentDataSync, WSErrorCode(const AAFwk::WantParams& wantParams, AAFwk::WantParams& reWantParams)); MOCK_METHOD1(MarkProcessed, WSError(int32_t eventId)); - MOCK_METHOD2(NotifyOccupiedAreaChangeInfo, void(sptr info, - const std::shared_ptr& rsTransaction)); + // MOCK_METHOD2(NotifyOccupiedAreaChangeInfo, void(sptr info, + // const std::shared_ptr& rsTransaction)); MOCK_METHOD2(UpdateAvoidArea, WSError(const sptr& avoidArea, AvoidAreaType type)); MOCK_METHOD1(DumpSessionElementInfo, void(const std::vector& params)); MOCK_METHOD0(NotifyScreenshot, void(void)); diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 75d0555bad..c514815bc0 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -19,6 +19,7 @@ group("unittest") { testonly = true deps = [ + ":ws_ability_info_manager_test", ":ws_anomaly_detection_test", ":ws_dfx_hisysevent_test", ":ws_distributed_client_test", @@ -132,6 +133,23 @@ group("unittest") { } } +ohos_unittest("ws_ability_info_manager_test") { + module_out_path = module_out_path + + sources = [ "ability_info_manager_test.cpp" ] + + deps = [ ":ws_unittest_common" ] + + external_deps = [ + "ability_base:configuration", + "ability_base:session_info", + "ability_runtime:ability_context_native", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "hilog:libhilog", + ] +} + ohos_unittest("ws_anomaly_detection_test") { module_out_path = module_out_path diff --git a/window_scene/test/unittest/ability_info_manager_test.cpp b/window_scene/test/unittest/ability_info_manager_test.cpp new file mode 100644 index 0000000000..a0d91e1891 --- /dev/null +++ b/window_scene/test/unittest/ability_info_manager_test.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include "session/host/include/ability_info_manager.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class AbilityInfoManagerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void AbilityInfoManagerTest::SetUpTestCase() +{ +} + +void AbilityInfoManagerTest::TearDownTestCase() +{ +} + +void AbilityInfoManagerTest::SetUp() +{ +} + +void AbilityInfoManagerTest::TearDown() +{ +} + +namespace { +/** + * @tc.name: FindAbilityInfo01 + * @tc.desc: FindAbilityInfo01 + * @tc.type: FUNC + */ +HWTEST_F(AbilityInfoManagerTest, FindAbilityInfo01, TestSize.Level1) +{ + std::string moduleName = "testModuleName"; + std::string abilityName = "testAbilityName"; + AppExecFwk::BundleInfo bundleInfo; + AppExecFwk::AbilityInfo targetAbilityInfo; + auto ret = AbilityInfoManager::FindAbilityInfo(bundleInfo, moduleName, abilityName, targetAbilityInfo); + EXPECT_FALSE(ret); +} + +/** + * @tc.name: FindAbilityInfo02 + * @tc.desc: FindAbilityInfo02 + * @tc.type: FUNC + */ +HWTEST_F(AbilityInfoManagerTest, FindAbilityInfo02, TestSize.Level1) +{ + std::string moduleName = "testModuleName"; + std::string abilityName = "testAbilityName"; + AppExecFwk::BundleInfo bundleInfo; + AppExecFwk::AbilityInfo targetAbilityInfo; + AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.moduleName = moduleName; + abilityInfo.name = abilityName; + AppExecFwk::HapModuleInfo hapModuleInfo; + hapModuleInfo.abilityInfos.emplace_back(abilityInfo); + bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); + auto ret = AbilityInfoManager::FindAbilityInfo(bundleInfo, moduleName, abilityName, targetAbilityInfo); + EXPECT_TRUE(ret); + EXPECT_EQ(targetAbilityInfo.moduleName, moduleName); + EXPECT_EQ(targetAbilityInfo.name, abilityName); +} +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/animation/scene_session_animation_test.cpp b/window_scene/test/unittest/animation/scene_session_animation_test.cpp index 4c2684c3ab..8554ba96ea 100644 --- a/window_scene/test/unittest/animation/scene_session_animation_test.cpp +++ b/window_scene/test/unittest/animation/scene_session_animation_test.cpp @@ -46,21 +46,13 @@ public: void TearDown() override; }; -void SceneSessionAnimationTest::SetUpTestCase() -{ -} +void SceneSessionAnimationTest::SetUpTestCase() {} -void SceneSessionAnimationTest::TearDownTestCase() -{ -} +void SceneSessionAnimationTest::TearDownTestCase() {} -void SceneSessionAnimationTest::SetUp() -{ -} +void SceneSessionAnimationTest::SetUp() {} -void SceneSessionAnimationTest::TearDown() -{ -} +void SceneSessionAnimationTest::TearDown() {} namespace { /** @@ -75,9 +67,7 @@ HWTEST_F(SceneSessionAnimationTest, SetWindowCornerRadiusCallback, TestSize.Leve info.bundleName_ = "SetWindowCornerRadiusCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - NotifySetWindowCornerRadiusFunc func1 = [](float cornerRadius) { - return; - }; + NotifySetWindowCornerRadiusFunc func1 = [](float cornerRadius) { return; }; sceneSession->SetWindowCornerRadiusCallback(std::move(func1)); ASSERT_NE(nullptr, sceneSession->onSetWindowCornerRadiusFunc_); } @@ -96,9 +86,7 @@ HWTEST_F(SceneSessionAnimationTest, SetWindowCornerRadius, TestSize.Level1) EXPECT_NE(session, nullptr); EXPECT_EQ(WSError::WS_OK, session->SetWindowCornerRadius(1.0f)); - NotifySetWindowCornerRadiusFunc func = [](float cornerRadius) { - return; - }; + NotifySetWindowCornerRadiusFunc func = [](float cornerRadius) { return; }; session->onSetWindowCornerRadiusFunc_ = func; EXPECT_EQ(WSError::WS_OK, session->SetWindowCornerRadius(1.0f)); } @@ -115,7 +103,7 @@ HWTEST_F(SceneSessionAnimationTest, AddSidebarBlur01, TestSize.Level1) info.bundleName_ = "AddSidebarBlur01"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); @@ -125,14 +113,12 @@ HWTEST_F(SceneSessionAnimationTest, AddSidebarBlur01, TestSize.Level1) EXPECT_EQ(nullptr, session->blurSaturationValue_); EXPECT_EQ(nullptr, session->blurBrightnessValue_); EXPECT_EQ(nullptr, session->blurMaskColorValue_); - + session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); appContext->contextImpl_ = std::make_shared(); @@ -141,7 +127,7 @@ HWTEST_F(SceneSessionAnimationTest, AddSidebarBlur01, TestSize.Level1) EXPECT_NE(nullptr, appContextConfig); appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); + AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); session->AddSidebarBlur(); EXPECT_NE(nullptr, session->blurRadiusValue_); @@ -162,34 +148,32 @@ HWTEST_F(SceneSessionAnimationTest, AddSidebarBlur02, TestSize.Level1) info.bundleName_ = "AddSidebarBlur02"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); - + session->AddSidebarBlur(); EXPECT_EQ(nullptr, session->blurRadiusValue_); EXPECT_EQ(nullptr, session->blurSaturationValue_); EXPECT_EQ(nullptr, session->blurBrightnessValue_); EXPECT_EQ(nullptr, session->blurMaskColorValue_); - + session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); - + AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); + session->AddSidebarBlur(); EXPECT_NE(nullptr, session->blurRadiusValue_); EXPECT_NE(nullptr, session->blurSaturationValue_); @@ -209,27 +193,25 @@ HWTEST_F(SceneSessionAnimationTest, AddSidebarBlur03, TestSize.Level1) info.bundleName_ = "AddSidebarBlur03"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); - + AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); + session->AddSidebarBlur(); float radiusOpenDark = session->blurRadiusValue_->Get(); float saturationOpenDark = session->blurSaturationValue_->Get(); @@ -253,17 +235,15 @@ HWTEST_F(SceneSessionAnimationTest, AddSidebarBlur04, TestSize.Level1) info.bundleName_ = "AddSidebarBlur04"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); appContext->contextImpl_ = std::make_shared(); @@ -272,7 +252,7 @@ HWTEST_F(SceneSessionAnimationTest, AddSidebarBlur04, TestSize.Level1) EXPECT_NE(nullptr, appContextConfig); appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); + AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); session->AddSidebarBlur(); float radiusOpenLight = session->blurRadiusValue_->Get(); @@ -297,7 +277,7 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur01, TestSize.Level1) info.bundleName_ = "SetSidebarBlur01"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); @@ -307,23 +287,21 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur01, TestSize.Level1) EXPECT_EQ(nullptr, session->blurSaturationValue_); EXPECT_EQ(nullptr, session->blurBrightnessValue_); EXPECT_EQ(nullptr, session->blurMaskColorValue_); - + session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); + AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); session->AddSidebarBlur(); EXPECT_NE(nullptr, session->blurRadiusValue_); @@ -344,7 +322,7 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur02, TestSize.Level1) info.bundleName_ = "SetSidebarBlur02"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); @@ -354,23 +332,21 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur02, TestSize.Level1) EXPECT_EQ(nullptr, session->blurSaturationValue_); EXPECT_EQ(nullptr, session->blurBrightnessValue_); EXPECT_EQ(nullptr, session->blurMaskColorValue_); - + session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); + AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); session->AddSidebarBlur(); EXPECT_NE(nullptr, session->blurRadiusValue_); @@ -391,26 +367,24 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur03, TestSize.Level1) info.bundleName_ = "SetSidebarBlur03"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); + AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); session->AddSidebarBlur(); session->SetSidebarBlur(false, false); @@ -422,7 +396,7 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur03, TestSize.Level1) EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, saturationCloseDark); EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, brightnessCloseDark); EXPECT_EQ(SIDEBAR_SNAPSHOT_MASKCOLOR_DARK, colorCloseDark.AsArgbInt()); - + session->SetSidebarBlur(true, true); float radiusOpenDark = session->blurRadiusValue_->Get(); float saturationOpenDark = session->blurSaturationValue_->Get(); @@ -446,26 +420,24 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur04, TestSize.Level1) info.bundleName_ = "SetSidebarBlur04"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); + AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); session->AddSidebarBlur(); session->SetSidebarBlur(false, false); @@ -477,7 +449,7 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlur04, TestSize.Level1) EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, saturationCloseLight); EXPECT_EQ(SIDEBAR_BLUR_NUMBER_ZERO, brightnessCloseLight); EXPECT_EQ(SIDEBAR_SNAPSHOT_MASKCOLOR_LIGHT, colorCloseLight.AsArgbInt()); - + session->SetSidebarBlur(true, true); float radiusOpenLight = session->blurRadiusValue_->Get(); float saturationOpenLight = session->blurSaturationValue_->Get(); @@ -501,26 +473,24 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlurMaximize01, TestSize.Level1) info.bundleName_ = "SetSidebarBlurMaximize01"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); + AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); session->AddSidebarBlur(); session->SetSidebarBlurMaximize(false); @@ -532,7 +502,7 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlurMaximize01, TestSize.Level1) EXPECT_EQ(SIDEBAR_DEFAULT_SATURATION_DARK, saturationRecoverDark); EXPECT_EQ(SIDEBAR_DEFAULT_BRIGHTNESS_DARK, brightnessRecoverDark); EXPECT_EQ(SIDEBAR_DEFAULT_MASKCOLOR_DARK, colorRecoverDark.AsArgbInt()); - + session->SetSidebarBlurMaximize(true); float radiusMaximizeDark = session->blurRadiusValue_->Get(); float saturationMaximizeDark = session->blurSaturationValue_->Get(); @@ -556,26 +526,24 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlurMaximize02, TestSize.Level1) info.bundleName_ = "SetSidebarBlurMaximize02"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - + struct RSSurfaceNodeConfig surfaceNodeConfig; std::shared_ptr surfaceNode = RSSurfaceNode::Create(surfaceNodeConfig); EXPECT_EQ(nullptr, session->GetSurfaceNode()); session->surfaceNode_ = surfaceNode; EXPECT_NE(nullptr, session->GetSurfaceNode()); - AbilityRuntime::Context::applicationContext_ = std::make_shared< - AbilityRuntime::ApplicationContext>(); - std::shared_ptr appContext = - AbilityRuntime::Context::GetApplicationContext(); + AbilityRuntime::Context::applicationContext_ = std::make_shared(); + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); EXPECT_NE(nullptr, appContext); - + appContext->contextImpl_ = std::make_shared(); appContext->contextImpl_->config_ = std::make_shared(); std::shared_ptr appContextConfig = appContext->GetConfiguration(); EXPECT_NE(nullptr, appContextConfig); - + appContextConfig->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, - AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); + AppExecFwk::ConfigurationInner::COLOR_MODE_LIGHT); session->AddSidebarBlur(); session->SetSidebarBlurMaximize(false); @@ -587,7 +555,7 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlurMaximize02, TestSize.Level1) EXPECT_EQ(SIDEBAR_DEFAULT_SATURATION_LIGHT, saturationRecoverLight); EXPECT_EQ(SIDEBAR_DEFAULT_BRIGHTNESS_LIGHT, brightnessRecoverLight); EXPECT_EQ(SIDEBAR_DEFAULT_MASKCOLOR_LIGHT, colorRecoverLight.AsArgbInt()); - + session->SetSidebarBlurMaximize(true); float radiusMaximizeLight = session->blurRadiusValue_->Get(); float saturationMaximizeLight = session->blurSaturationValue_->Get(); @@ -598,6 +566,6 @@ HWTEST_F(SceneSessionAnimationTest, SetSidebarBlurMaximize02, TestSize.Level1) EXPECT_EQ(SIDEBAR_MAXIMIZE_BRIGHTNESS_LIGHT, brightnessMaximizeLight); EXPECT_EQ(SIDEBAR_MAXIMIZE_MASKCOLOR_LIGHT, colorMaximizeLight.AsArgbInt()); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/animation/session_proxy_animation_test.cpp b/window_scene/test/unittest/animation/session_proxy_animation_test.cpp index 2d72d8e26e..2691b75e7f 100644 --- a/window_scene/test/unittest/animation/session_proxy_animation_test.cpp +++ b/window_scene/test/unittest/animation/session_proxy_animation_test.cpp @@ -28,7 +28,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { class SessionProxyAnimationTest : public testing::Test { - public: +public: SessionProxyAnimationTest() {} ~SessionProxyAnimationTest() {} }; diff --git a/window_scene/test/unittest/animation/window_session_property_animation_test.cpp b/window_scene/test/unittest/animation/window_session_property_animation_test.cpp index ee9f179140..1057681cfd 100644 --- a/window_scene/test/unittest/animation/window_session_property_animation_test.cpp +++ b/window_scene/test/unittest/animation/window_session_property_animation_test.cpp @@ -28,13 +28,9 @@ public: static void TearDownTestCase(); }; -void WindowSessionPropertyAnimationTest::SetUpTestCase() -{ -} +void WindowSessionPropertyAnimationTest::SetUpTestCase() {} -void WindowSessionPropertyAnimationTest::TearDownTestCase() -{ -} +void WindowSessionPropertyAnimationTest::TearDownTestCase() {} namespace { /** diff --git a/window_scene/test/unittest/dfx_hisysevent_test.cpp b/window_scene/test/unittest/dfx_hisysevent_test.cpp index 3245a50589..fd4f501a76 100644 --- a/window_scene/test/unittest/dfx_hisysevent_test.cpp +++ b/window_scene/test/unittest/dfx_hisysevent_test.cpp @@ -32,21 +32,13 @@ public: void TearDown() override; }; -void DfxHisyseventTest::SetUpTestCase() -{ -} +void DfxHisyseventTest::SetUpTestCase() {} -void DfxHisyseventTest::TearDownTestCase() -{ -} +void DfxHisyseventTest::TearDownTestCase() {} -void DfxHisyseventTest::SetUp() -{ -} +void DfxHisyseventTest::SetUp() {} -void DfxHisyseventTest::TearDown() -{ -} +void DfxHisyseventTest::TearDown() {} namespace { /** @@ -142,5 +134,5 @@ TEST_F(DfxHisyseventTest, ApplicationBlockInput_Fail3) } } // namespace -} // namespace OHOS } // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/distributed_client_test.cpp b/window_scene/test/unittest/distributed_client_test.cpp index 0a142947f5..d585888a75 100644 --- a/window_scene/test/unittest/distributed_client_test.cpp +++ b/window_scene/test/unittest/distributed_client_test.cpp @@ -43,17 +43,14 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::shared_ptr distributedClient_; }; -void DistributedClientTest::SetUpTestCase() -{ -} +void DistributedClientTest::SetUpTestCase() {} -void DistributedClientTest::TearDownTestCase() -{ -} +void DistributedClientTest::TearDownTestCase() {} void DistributedClientTest::SetUp() { @@ -119,7 +116,7 @@ HWTEST_F(DistributedClientTest, GetMissionInfos03, TestSize.Level1) MockMessageParcel::ClearAllErrorFlag(); GTEST_LOG_(INFO) << "DistributedClientTest GetMissionInfos03 end."; } -} +} // namespace /** * @tc.name: GetRemoteMissionSnapshotInfo @@ -237,5 +234,5 @@ HWTEST_F(DistributedClientTest, SetMissionContinueState03, TestSize.Level1) MockMessageParcel::ClearAllErrorFlag(); GTEST_LOG_(INFO) << "DistributedClientTest SetMissionContinueState03 end."; } -} -} +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/event_distribution/intention_event_manager_test.cpp b/window_scene/test/unittest/event_distribution/intention_event_manager_test.cpp index f89295f4cb..63b2eeffb7 100644 --- a/window_scene/test/unittest/event_distribution/intention_event_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/intention_event_manager_test.cpp @@ -38,13 +38,9 @@ public: static constexpr uint32_t WAIT_SYNC_IN_NS = 500000; }; -void IntentionEventManagerTest::SetUpTestCase() -{ -} +void IntentionEventManagerTest::SetUpTestCase() {} -void IntentionEventManagerTest::TearDownTestCase() -{ -} +void IntentionEventManagerTest::TearDownTestCase() {} void IntentionEventManagerTest::SetUp() { @@ -53,8 +49,7 @@ void IntentionEventManagerTest::SetUp() runner_ = AppExecFwk::EventRunner::Create("TestRunner"); eventHandler_ = std::make_shared(runner_); EXPECT_NE(nullptr, eventHandler_); - inputEventListener_ = - std::make_shared(uIContent_.get(), eventHandler_); + inputEventListener_ = std::make_shared(uIContent_.get(), eventHandler_); EXPECT_NE(nullptr, inputEventListener_); SceneSessionManager::GetInstance().sceneSessionMap_.clear(); } @@ -76,14 +71,13 @@ namespace { */ HWTEST_F(IntentionEventManagerTest, EnableInputEventListener, TestSize.Level0) { - bool enable = DelayedSingleton::GetInstance()-> - EnableInputEventListener(nullptr, nullptr); + bool enable = DelayedSingleton::GetInstance()->EnableInputEventListener(nullptr, nullptr); EXPECT_EQ(false, enable); - enable = DelayedSingleton::GetInstance()-> - EnableInputEventListener(uIContent_.get(), nullptr); + enable = + DelayedSingleton::GetInstance()->EnableInputEventListener(uIContent_.get(), nullptr); EXPECT_EQ(false, enable); - enable = DelayedSingleton::GetInstance()-> - EnableInputEventListener(uIContent_.get(), eventHandler_); + enable = DelayedSingleton::GetInstance()->EnableInputEventListener(uIContent_.get(), + eventHandler_); EXPECT_EQ(true, enable); } @@ -103,8 +97,7 @@ HWTEST_F(IntentionEventManagerTest, DispatchKeyEventCallback, TestSize.Level0) SessionInfo info; info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); EXPECT_NE(nullptr, callback); sptr sceneSession = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession); @@ -150,8 +143,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEventPointer1, TestSize.Level0) info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; info.isSystem_ = true; - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); EXPECT_NE(nullptr, callback); sptr sceneSession0 = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession0); @@ -245,8 +237,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent0, TestSize.Level1) info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; info.isSystem_ = true; - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); EXPECT_NE(nullptr, callback); sptr sceneSession0 = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession0); @@ -306,8 +297,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent1, TestSize.Level0) info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; info.isSystem_ = true; - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); EXPECT_NE(nullptr, callback); sptr sceneSession0 = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession0); @@ -341,14 +331,11 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent2, TestSize.Level1) info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; info.isSystem_ = true; - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); EXPECT_NE(nullptr, callback); sptr sceneSession = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession); - auto func = [](std::shared_ptr keyEvent, bool isPreImeEvent) { - return true; - }; + auto func = [](std::shared_ptr keyEvent, bool isPreImeEvent) { return true; }; sceneSession->SetNotifySystemSessionKeyEventFunc(func); SceneSessionManager::GetInstance().sceneSessionMap_.emplace(std::make_pair(1, sceneSession)); EXPECT_EQ(1, SceneSessionManager::GetInstance().sceneSessionMap_.size()); @@ -379,8 +366,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent3, TestSize.Level1) info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; info.isSystem_ = true; - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); EXPECT_NE(nullptr, callback); sptr sceneSession = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession); @@ -462,6 +448,6 @@ HWTEST_F(IntentionEventManagerTest, ProcessInjectionEvent, TestSize.Level1) inputEventListener_->ProcessInjectionEvent(pointerEvent); EXPECT_EQ(oriPointerId + TRANSPARENT_FINGER_ID, pointerEvent->GetPointerId()); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp index 0c29772e9f..5f7e9becfe 100644 --- a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp @@ -33,6 +33,7 @@ public: void SetUp() override; void TearDown() override; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 500000; }; @@ -49,9 +50,7 @@ void SceneInputManagerTest::TearDownTestCase() ssm_ = nullptr; } -void SceneInputManagerTest::SetUp() -{ -} +void SceneInputManagerTest::SetUp() {} void SceneInputManagerTest::TearDown() { @@ -89,7 +88,6 @@ void CheckNeedUpdateTest() } } - void WindowInfoListZeroTest(sptr ssm_) { std::vector windowInfoList; @@ -208,9 +206,7 @@ HWTEST_F(SceneInputManagerTest, UpdateFocusedSessionId, TestSize.Level1) EXPECT_EQ(sceneInputManager->focusedSessionId_, -1); sceneInputManager->UpdateFocusedSessionId(sceneSession->GetPersistentId()); EXPECT_EQ(sceneInputManager->focusedSessionId_, -1); - ExtensionWindowEventInfo extensionInfo { - .persistentId = 12345 - }; + ExtensionWindowEventInfo extensionInfo{ .persistentId = 12345 }; sceneSession->AddNormalModalUIExtension(extensionInfo); sceneInputManager->UpdateFocusedSessionId(sceneSession->GetPersistentId()); EXPECT_EQ(sceneInputManager->focusedSessionId_, extensionInfo.persistentId); @@ -483,22 +479,20 @@ HWTEST_F(SceneInputManagerTest, NotifyWindowInfoChange, TestSize.Level0) info.abilityName_ = "NotifyWindowInfoChange"; info.bundleName_ = "NotifyWindowInfoChange"; info.appIndex_ = 10; - sptr specificCallback_ - = sptr::MakeSptr(); + sptr specificCallback_ = + sptr::MakeSptr(); EXPECT_NE(specificCallback_, nullptr); sptr sceneSession = sptr::MakeSptr(info, specificCallback_); // sceneSessionDirty_ = nullptr auto oldDirty = SceneInputManager::GetInstance().sceneSessionDirty_; SceneInputManager::GetInstance().sceneSessionDirty_ = nullptr; - SceneInputManager::GetInstance() - .NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_ADDED); + SceneInputManager::GetInstance().NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_ADDED); SceneInputManager::GetInstance().sceneSessionDirty_ = oldDirty; std::vector windowInfoList; std::vector> pixelMapList; - SceneInputManager::GetInstance() - .NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_ADDED); + SceneInputManager::GetInstance().NotifyWindowInfoChange(sceneSession, WindowUpdateType::WINDOW_UPDATE_ADDED); SceneInputManager::GetInstance().FlushDisplayInfoToMMI(std::move(windowInfoList), std::move(pixelMapList)); GTEST_LOG_(INFO) << "SceneInputManagerTest: NotifyWindowInfoChange end"; } @@ -515,8 +509,8 @@ HWTEST_F(SceneInputManagerTest, NotifyWindowInfoChangeFromSession, TestSize.Leve info.abilityName_ = "NotifyWindowInfoChangeFromSession"; info.bundleName_ = "NotifyWindowInfoChangeFromSession"; info.appIndex_ = 100; - sptr specificCallback_ - = sptr::MakeSptr(); + sptr specificCallback_ = + sptr::MakeSptr(); EXPECT_NE(specificCallback_, nullptr); sptr sceneSession = sptr::MakeSptr(info, specificCallback_); @@ -545,8 +539,8 @@ HWTEST_F(SceneInputManagerTest, NotifyMMIWindowPidChange, TestSize.Level1) info.abilityName_ = "NotifyMMIWindowPidChange"; info.bundleName_ = "NotifyMMIWindowPidChange"; info.appIndex_ = 1000; - sptr specificCallback_ - = sptr::MakeSptr(); + sptr specificCallback_ = + sptr::MakeSptr(); EXPECT_NE(specificCallback_, nullptr); sptr sceneSession = sptr::MakeSptr(info, specificCallback_); @@ -810,6 +804,6 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate4, TestSize.Level1) windowInfoList[0].pointerChangeAreas.clear(); SceneInputManager::GetInstance().lastWindowInfoList_[0].pointerChangeAreas.clear(); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp index 604a13d274..fd8b5f9231 100644 --- a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test.cpp @@ -25,7 +25,6 @@ #include "session_manager/include/scene_session_manager.h" #include "transaction/rs_uiextension_data.h" - using namespace testing; using namespace testing::ext; @@ -43,8 +42,8 @@ public: void TearDown() override; static constexpr uint32_t WAIT_SYNC_IN_NS = 500000; }; -SceneSessionDirtyManager *manager_; -SceneSessionManager *ssm_; +SceneSessionDirtyManager* manager_; +SceneSessionManager* ssm_; void SceneSessionDirtyManagerTest::SetUpTestCase() { ssm_ = &SceneSessionManager::GetInstance(); @@ -107,10 +106,10 @@ HWTEST_F(SceneSessionDirtyManagerTest, GetFullWindowInfoList, TestSize.Level0) sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->UpdateVisibilityInner(true); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); } { - ssm_->sceneSessionMap_.insert({111, nullptr}); + ssm_->sceneSessionMap_.insert({ 111, nullptr }); } { sptr sceneSessionDialog1 = sptr::MakeSptr(info, nullptr); @@ -118,7 +117,7 @@ HWTEST_F(SceneSessionDirtyManagerTest, GetFullWindowInfoList, TestSize.Level0) sceneSessionDialog1->UpdateVisibilityInner(true); sptr propertyDialog1 = sceneSessionDialog1->GetSessionProperty(); propertyDialog1->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); - ssm_->sceneSessionMap_.insert({sceneSessionDialog1->GetPersistentId(), sceneSessionDialog1}); + ssm_->sceneSessionMap_.insert({ sceneSessionDialog1->GetPersistentId(), sceneSessionDialog1 }); } { sptr sceneSessionModal1 = sptr::MakeSptr(info, nullptr); @@ -126,7 +125,7 @@ HWTEST_F(SceneSessionDirtyManagerTest, GetFullWindowInfoList, TestSize.Level0) sceneSessionModal1->UpdateVisibilityInner(true); sptr propertyModal1 = sceneSessionModal1->GetSessionProperty(); propertyModal1->SetWindowFlags(static_cast(WindowFlag::WINDOW_FLAG_IS_MODAL)); - ssm_->sceneSessionMap_.insert({sceneSessionModal1->GetPersistentId(), sceneSessionModal1}); + ssm_->sceneSessionMap_.insert({ sceneSessionModal1->GetPersistentId(), sceneSessionModal1 }); } auto [windowInfoList1, pixelMapList1] = manager_->GetFullWindowInfoList(); ASSERT_EQ(windowInfoList.size() + 3, windowInfoList1.size()); @@ -359,19 +358,16 @@ HWTEST_F(SceneSessionDirtyManagerTest, AddModalExtensionWindowInfo, TestSize.Lev std::vector windowInfoList; MMI::WindowInfo windowInfo; windowInfoList.emplace_back(windowInfo); - ExtensionWindowEventInfo extensionInfo = { - .persistentId = 12345, - .pid = 1234 - }; + ExtensionWindowEventInfo extensionInfo = { .persistentId = 12345, .pid = 1234 }; manager_->AddModalExtensionWindowInfo(windowInfoList, windowInfo, nullptr, extensionInfo); EXPECT_EQ(windowInfoList.size(), 1); - + sceneSession->AddNormalModalUIExtension(extensionInfo); manager_->AddModalExtensionWindowInfo(windowInfoList, windowInfo, sceneSession, extensionInfo); ASSERT_EQ(windowInfoList.size(), 2); EXPECT_TRUE(windowInfoList[1].defaultHotAreas.empty()); - Rect windowRect {1, 1, 7, 8}; + Rect windowRect{ 1, 1, 7, 8 }; extensionInfo.windowRect = windowRect; sceneSession->UpdateNormalModalUIExtension(extensionInfo); manager_->AddModalExtensionWindowInfo(windowInfoList, windowInfo, sceneSession, extensionInfo); @@ -636,13 +632,8 @@ HWTEST_F(SceneSessionDirtyManagerTest, ResetFlushWindowInfoTask1, TestSize.Level HWTEST_F(SceneSessionDirtyManagerTest, DumpRect, TestSize.Level1) { std::vector rects(0); - for (int i = 0; i < 2 ; i++) { - MMI::Rect rect = { - .x = i * 10, - .y = i * 10, - .width = i * 10, - .height = i * 10 - }; + for (int i = 0; i < 2; i++) { + MMI::Rect rect = { .x = i * 10, .y = i * 10, .width = i * 10, .height = i * 10 }; rects.emplace_back(rect); } std::string ret = DumpRect(rects); @@ -692,9 +683,10 @@ HWTEST_F(SceneSessionDirtyManagerTest, CheckDragActivatedInUpdatePointerAreas, T limits.minWidth_ = 0; sceneSession->property_->SetWindowLimits(limits); manager_->UpdatePointerAreas(sceneSession, pointerChangeAreas); - std::vector compare = {POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx, - POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, - pointerAreaFivePx, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT}; + std::vector compare = { POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx, + POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, + POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx, + POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT }; ASSERT_EQ(compare, pointerChangeAreas); } @@ -955,7 +947,7 @@ HWTEST_F(SceneSessionDirtyManagerTest, UpdateHotAreas, TestSize.Level0) std::vector touchHotAreasInSceneSession(0); sceneSession->GetSessionProperty()->SetTouchHotAreas(touchHotAreasInSceneSession); sceneSession->persistentId_ = 1; - for (int i = 0; i < 2 ; i++) { + for (int i = 0; i < 2; i++) { OHOS::Rosen::Rect area; area.posX_ = i * 10; area.posY_ = i * 10; @@ -968,7 +960,7 @@ HWTEST_F(SceneSessionDirtyManagerTest, UpdateHotAreas, TestSize.Level0) pointerHotAreas.clear(); manager_->UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas); ASSERT_EQ(touchHotAreas.size(), 2); - for (int i = 2; i < 10 ; i++) { + for (int i = 2; i < 10; i++) { OHOS::Rosen::Rect area; area.posX_ = i * 10; area.posY_ = i * 10; @@ -1028,7 +1020,7 @@ HWTEST_F(SceneSessionDirtyManagerTest, UpdateDefaultHotAreas, TestSize.Level1) if (sceneSession == nullptr) { return; } - WSRect rect = {0, 0, 320, 240}; + WSRect rect = { 0, 0, 320, 240 }; sceneSession->SetSessionRect(rect); manager_->UpdateDefaultHotAreas(sceneSession, empty, empty); ASSERT_NE(empty.size(), 0); diff --git a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp index 8d746db356..27c4083a58 100644 --- a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp +++ b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp @@ -72,21 +72,9 @@ namespace { void InitSessionInfo(MMI::DisplayInfo& displayedInfo, MMI::WindowInfo& windowInfo) { - displayedInfo = { - .id = 42, - .x = 0, - .y = 0, - .width = 1270, - .height = 2240 - }; + displayedInfo = { .id = 42, .x = 0, .y = 0, .width = 1270, .height = 2240 }; - windowInfo = { - .id = 43, - .pid = 433, - .displayId = 42, - .zOrder = 30.0, - .area = {0, 0, 1000, 1200} - }; + windowInfo = { .id = 43, .pid = 433, .displayId = 42, .zOrder = 30.0, .area = { 0, 0, 1000, 1200 } }; } /** @@ -94,7 +82,7 @@ void InitSessionInfo(MMI::DisplayInfo& displayedInfo, MMI::WindowInfo& windowInf * @tc.desc: Init sceneSession * @tc.type: FUNC */ -void InitSceneSession(sptr &sceneSession, int32_t pid, int windowId, WindowType propertyType) +void InitSceneSession(sptr& sceneSession, int32_t pid, int windowId, WindowType propertyType) { sptr windowSessionProperty = sptr::MakeSptr(); ASSERT_NE(windowSessionProperty, nullptr); @@ -107,11 +95,9 @@ void InitSceneSession(sptr &sceneSession, int32_t pid, int windowI windowSessionProperty->SetPersistentId(windowId); sceneSession->SetSessionProperty(windowSessionProperty); - WSRect windowRect = {0, 0, 1270, 2700}; + WSRect windowRect = { 0, 0, 1270, 2700 }; sceneSession->SetSessionRect(windowRect); - sceneSession->SetVisibilityChangedDetectFunc([](int32_t pid, bool isVisible, bool newIsVisible) { - return; - }); + sceneSession->SetVisibilityChangedDetectFunc([](int32_t pid, bool isVisible, bool newIsVisible) { return; }); sceneSession->SetCallingPid(pid); int32_t uid = 1315; sceneSession->SetCallingUid(uid); @@ -438,7 +424,7 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithAreaDiff, TestSize.Leve MMI::WindowInfo currWindowInfo; InitSessionInfo(currDisplayedInfo, currWindowInfo); // set different area number - currWindowInfo.area = {0, 0, 500, 600}; + currWindowInfo.area = { 0, 0, 500, 600 }; std::vector currDisplayInfos; std::vector currWindowInfoList; currDisplayInfos.emplace_back(currDisplayedInfo); @@ -502,15 +488,15 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithoutHotArea, TestSize.Le ASSERT_NE(windowSessionProperty, nullptr); windowSessionProperty->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); sceneSession->InitSessionPropertyWhenConnect(windowSessionProperty); - WSRect windowRect = {0, 0, 1270, 2700}; + WSRect windowRect = { 0, 0, 1270, 2700 }; sceneSession->SetSessionRect(windowRect); sceneSession->globalRect_ = windowRect; // set hotArea without info std::vector touchHotAreas; std::vector pointerHotAreas; manager_->UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas); - bool touchHotResult = touchHotAreas[0].x == 0 && touchHotAreas[0].y == 0 && - touchHotAreas[0].width == 1270 && touchHotAreas[0].height == 2700; + bool touchHotResult = touchHotAreas[0].x == 0 && touchHotAreas[0].y == 0 && touchHotAreas[0].width == 1270 && + touchHotAreas[0].height == 2700; ASSERT_EQ(touchHotResult, true); bool pointerHotResult = pointerHotAreas[0].x == 0 && pointerHotAreas[0].y == 0 && pointerHotAreas[0].width == 1270 && pointerHotAreas[0].height == 2700; @@ -532,22 +518,22 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithHotArea, TestSize.Level sptr windowSessionProperty = sptr::MakeSptr(); ASSERT_NE(windowSessionProperty, nullptr); windowSessionProperty->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); - Rect rect = {0, 0, 300, 500}; + Rect rect = { 0, 0, 300, 500 }; std::vector rects; rects.emplace_back(rect); // set touchHotArea and pointerHotArea info windowSessionProperty->SetTouchHotAreas(rects); sceneSession->InitSessionPropertyWhenConnect(windowSessionProperty); - WSRect windowRect = {0, 0, 1270, 2700}; + WSRect windowRect = { 0, 0, 1270, 2700 }; sceneSession->SetSessionRect(windowRect); std::vector touchHotAreas; std::vector pointerHotAreas; manager_->UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas); - bool touchHotResult = touchHotAreas[0].x == 0 && touchHotAreas[0].y == 0 && - touchHotAreas[0].width == 300 && touchHotAreas[0].height == 500; + bool touchHotResult = touchHotAreas[0].x == 0 && touchHotAreas[0].y == 0 && touchHotAreas[0].width == 300 && + touchHotAreas[0].height == 500; ASSERT_EQ(touchHotResult, true); - bool pointerHotResult = pointerHotAreas[0].x == 0 && pointerHotAreas[0].y == 0 && - pointerHotAreas[0].width == 300 && pointerHotAreas[0].height == 500; + bool pointerHotResult = pointerHotAreas[0].x == 0 && pointerHotAreas[0].y == 0 && pointerHotAreas[0].width == 300 && + pointerHotAreas[0].height == 500; ASSERT_EQ(pointerHotResult, true); } diff --git a/window_scene/test/unittest/hidumper_controller_test.cpp b/window_scene/test/unittest/hidumper_controller_test.cpp index bbd4078f4d..45141cb64d 100644 --- a/window_scene/test/unittest/hidumper_controller_test.cpp +++ b/window_scene/test/unittest/hidumper_controller_test.cpp @@ -34,21 +34,13 @@ public: sptr GetSceneSession(std::string name); }; -void HidumpControllerTest::SetUpTestCase() -{ -} +void HidumpControllerTest::SetUpTestCase() {} -void HidumpControllerTest::TearDownTestCase() -{ -} +void HidumpControllerTest::TearDownTestCase() {} -void HidumpControllerTest::SetUp() -{ -} +void HidumpControllerTest::SetUp() {} -void HidumpControllerTest::TearDown() -{ -} +void HidumpControllerTest::TearDown() {} sptr HidumpControllerTest::GetSceneSession(std::string name) { diff --git a/window_scene/test/unittest/keyboard_session_layout_test.cpp b/window_scene/test/unittest/keyboard_session_layout_test.cpp index 97c7b31e56..df80fbf485 100644 --- a/window_scene/test/unittest/keyboard_session_layout_test.cpp +++ b/window_scene/test/unittest/keyboard_session_layout_test.cpp @@ -41,24 +41,16 @@ private: sptr GetSceneSession(const std::string& abilityName, const std::string& bundleName); }; -void KeyboardSessionLayoutTest::SetUpTestCase() -{ -} +void KeyboardSessionLayoutTest::SetUpTestCase() {} -void KeyboardSessionLayoutTest::TearDownTestCase() -{ -} +void KeyboardSessionLayoutTest::TearDownTestCase() {} -void KeyboardSessionLayoutTest::SetUp() -{ -} +void KeyboardSessionLayoutTest::SetUp() {} -void KeyboardSessionLayoutTest::TearDown() -{ -} +void KeyboardSessionLayoutTest::TearDown() {} sptr KeyboardSessionLayoutTest::GetSceneSession(const std::string& abilityName, - const std::string& bundleName) + const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; @@ -141,6 +133,6 @@ HWTEST_F(KeyboardSessionLayoutTest, NotifyClientToUpdateRect03, TestSize.Level1) ret = keyboardSession->NotifyClientToUpdateRect("KeyboardSessionLayoutTest", nullptr); ASSERT_EQ(ret, WSError::WS_OK); } -} // namespace -} // namespace Rosen -} // namespace OHOS +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/keyboard_session_test.cpp b/window_scene/test/unittest/keyboard_session_test.cpp index c76ea243fe..53c4556d81 100644 --- a/window_scene/test/unittest/keyboard_session_test.cpp +++ b/window_scene/test/unittest/keyboard_session_test.cpp @@ -31,7 +31,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "KeyboardSessionTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "KeyboardSessionTest" }; } class KeyboardSessionTest : public testing::Test { @@ -46,30 +46,20 @@ private: static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; }; -void KeyboardSessionTest::SetUpTestCase() -{ -} +void KeyboardSessionTest::SetUpTestCase() {} -void KeyboardSessionTest::TearDownTestCase() -{ -} +void KeyboardSessionTest::TearDownTestCase() {} -void KeyboardSessionTest::SetUp() -{ -} +void KeyboardSessionTest::SetUp() {} -void KeyboardSessionTest::TearDown() -{ -} +void KeyboardSessionTest::TearDown() {} -sptr KeyboardSessionTest::GetSceneSession(const std::string& abilityName, - const std::string& bundleName) +sptr KeyboardSessionTest::GetSceneSession(const std::string& abilityName, const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; info.bundleName_ = bundleName; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr sceneSession = sptr::MakeSptr(info, specificCb); @@ -87,8 +77,7 @@ HWTEST_F(KeyboardSessionTest, GetKeyboardGravity, TestSize.Level1) SessionInfo info; info.abilityName_ = "GetKeyboardGravity"; info.bundleName_ = "GetKeyboardGravity"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); sptr keyboardSession = sptr::MakeSptr(info, specificCb, nullptr); sptr windowSessionProperty = sptr::MakeSptr(); keyboardSession->property_ = windowSessionProperty; @@ -134,8 +123,7 @@ HWTEST_F(KeyboardSessionTest, Show02, TestSize.Level0) SessionInfo info; info.abilityName_ = "Show02"; info.bundleName_ = "Show02"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -179,8 +167,7 @@ HWTEST_F(KeyboardSessionTest, Hide, TestSize.Level0) SessionInfo info; info.abilityName_ = "Hide"; info.bundleName_ = "Hide"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -250,8 +237,7 @@ HWTEST_F(KeyboardSessionTest, GetSceneSession01, TestSize.Level0) SessionInfo info; info.abilityName_ = "GetSceneSession01"; info.bundleName_ = "GetSceneSession01"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -265,9 +251,7 @@ HWTEST_F(KeyboardSessionTest, GetSceneSession01, TestSize.Level0) EXPECT_NE(id, 0); auto ret = keyboardSession->GetSceneSession(id); - keyboardCb->onGetSceneSession = [](uint32_t) { - return nullptr; - }; + keyboardCb->onGetSceneSession = [](uint32_t) { return nullptr; }; EXPECT_NE(keyboardCb->onGetSceneSession, nullptr); ret = keyboardSession->GetSceneSession(id); } @@ -277,73 +261,71 @@ HWTEST_F(KeyboardSessionTest, GetSceneSession01, TestSize.Level0) * @tc.desc: NotifyOccupiedAreaChangeInfo * @tc.type: FUNC */ -HWTEST_F(KeyboardSessionTest, NotifyOccupiedAreaChangeInfo, TestSize.Level0) -{ - SessionInfo info; - info.abilityName_ = "NotifyOccupiedAreaChangeInfo"; - info.bundleName_ = "NotifyOccupiedAreaChangeInfo"; - sptr specificCb = - sptr::MakeSptr(); - EXPECT_NE(specificCb, nullptr); - sptr keyboardCb = - sptr::MakeSptr(); - EXPECT_NE(keyboardCb, nullptr); - sptr keyboardSession = sptr::MakeSptr(info, specificCb, keyboardCb); - EXPECT_NE(keyboardSession, nullptr); - sptr callingSession = sptr::MakeSptr(info, nullptr); - WSRect rect = { 0, 0, 1260, 2720 }; - WSRect occupiedArea = { 0, 1700, 1260, 1020 }; - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); - - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); - - callingSession->lastSafeRect = { 0, 0, 0, 0 }; - callingSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); -} +// HWTEST_F(KeyboardSessionTest, NotifyOccupiedAreaChangeInfo, TestSize.Level0) +// { +// SessionInfo info; +// info.abilityName_ = "NotifyOccupiedAreaChangeInfo"; +// info.bundleName_ = "NotifyOccupiedAreaChangeInfo"; +// sptr specificCb = sptr::MakeSptr(); +// EXPECT_NE(specificCb, nullptr); +// sptr keyboardCb = +// sptr::MakeSptr(); +// EXPECT_NE(keyboardCb, nullptr); +// sptr keyboardSession = sptr::MakeSptr(info, specificCb, keyboardCb); +// EXPECT_NE(keyboardSession, nullptr); +// sptr callingSession = sptr::MakeSptr(info, nullptr); +// WSRect rect = { 0, 0, 1260, 2720 }; +// WSRect occupiedArea = { 0, 1700, 1260, 1020 }; +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); + +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); + +// callingSession->lastSafeRect = { 0, 0, 0, 0 }; +// callingSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); +// } /** * @tc.name: NotifyOccupiedAreaChangeInfo02 * @tc.desc: NotifyOccupiedAreaChangeInfo * @tc.type: FUNC */ -HWTEST_F(KeyboardSessionTest, NotifyOccupiedAreaChangeInfo02, TestSize.Level1) -{ - SessionInfo info; - info.abilityName_ = "NotifyOccupiedAreaChangeInfo02"; - info.bundleName_ = "NotifyOccupiedAreaChangeInfo02"; - sptr specificCb = - sptr::MakeSptr(); - EXPECT_NE(specificCb, nullptr); - sptr keyboardCb = - sptr::MakeSptr(); - EXPECT_NE(keyboardCb, nullptr); - sptr keyboardSession = sptr::MakeSptr(info, specificCb, keyboardCb); - EXPECT_NE(keyboardSession, nullptr); - sptr callingSession = sptr::MakeSptr(info, nullptr); - WSRect rect = { 0, 0, 1260, 2720 }; - WSRect occupiedArea = { 0, 1700, 1260, 1020 }; - - // test CalculateSafeRectForMidScene - WSRect zeroRect = { 0, 0, 0, 0 }; - callingSession->SetIsMidScene(true); - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); - EXPECT_NE(callingSession->GetLastSafeRect(), zeroRect); - callingSession->SetScale(0, 0, 0, 0); - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); - EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); - callingSession->SetScale(0, 1, 0, 0); - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); - EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); - callingSession->SetScale(1, 0, 0, 0); - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); - EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); - - callingSession->SetScale(1, 1, 0, 0); - rect = { 0, 0, 1260, 0 }; - keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); - EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); -} +// HWTEST_F(KeyboardSessionTest, NotifyOccupiedAreaChangeInfo02, TestSize.Level1) +// { +// SessionInfo info; +// info.abilityName_ = "NotifyOccupiedAreaChangeInfo02"; +// info.bundleName_ = "NotifyOccupiedAreaChangeInfo02"; +// sptr specificCb = sptr::MakeSptr(); +// EXPECT_NE(specificCb, nullptr); +// sptr keyboardCb = +// sptr::MakeSptr(); +// EXPECT_NE(keyboardCb, nullptr); +// sptr keyboardSession = sptr::MakeSptr(info, specificCb, keyboardCb); +// EXPECT_NE(keyboardSession, nullptr); +// sptr callingSession = sptr::MakeSptr(info, nullptr); +// WSRect rect = { 0, 0, 1260, 2720 }; +// WSRect occupiedArea = { 0, 1700, 1260, 1020 }; + +// // test CalculateSafeRectForMidScene +// WSRect zeroRect = { 0, 0, 0, 0 }; +// callingSession->SetIsMidScene(true); +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); +// EXPECT_NE(callingSession->GetLastSafeRect(), zeroRect); +// callingSession->SetScale(0, 0, 0, 0); +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); +// EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); +// callingSession->SetScale(0, 1, 0, 0); +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); +// EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); +// callingSession->SetScale(1, 0, 0, 0); +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); +// EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); + +// callingSession->SetScale(1, 1, 0, 0); +// rect = { 0, 0, 1260, 0 }; +// keyboardSession->NotifyOccupiedAreaChangeInfo(callingSession, rect, occupiedArea); +// EXPECT_EQ(callingSession->GetLastSafeRect(), zeroRect); +// } /** * @tc.name: NotifyRootSceneOccupiedAreaChange @@ -355,8 +337,7 @@ HWTEST_F(KeyboardSessionTest, NotifyRootSceneOccupiedAreaChange, TestSize.Level1 SessionInfo info; info.abilityName_ = "NotifyRootSceneOccupiedAreaChange"; info.bundleName_ = "NotifyRootSceneOccupiedAreaChange"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -385,8 +366,7 @@ HWTEST_F(KeyboardSessionTest, NotifyRootSceneOccupiedAreaChange02, TestSize.Leve SessionInfo info; info.abilityName_ = "NotifyRootSceneOccupiedAreaChange02"; info.bundleName_ = "NotifyRootSceneOccupiedAreaChange02"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); ASSERT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -397,9 +377,7 @@ HWTEST_F(KeyboardSessionTest, NotifyRootSceneOccupiedAreaChange02, TestSize.Leve ASSERT_NE(occupiedInfo, nullptr); auto ret = 1; keyboardSession->keyboardCallback_->onNotifyOccupiedAreaChange = - [&ret](const sptr& info)->void { - ret = 2; - }; + [&ret](const sptr& info) -> void { ret = 2; }; keyboardSession->GetSessionProperty()->SetDisplayId(ScreenSessionManagerClient::GetInstance().GetDefaultScreenId()); keyboardSession->NotifyRootSceneOccupiedAreaChange(occupiedInfo); EXPECT_EQ(ret, 2); @@ -415,8 +393,7 @@ HWTEST_F(KeyboardSessionTest, RestoreCallingSession, TestSize.Level0) SessionInfo info; info.abilityName_ = "RestoreCallingSession"; info.bundleName_ = "RestoreCallingSession"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -433,9 +410,7 @@ HWTEST_F(KeyboardSessionTest, RestoreCallingSession, TestSize.Level0) EXPECT_NE(callingSession, nullptr); ASSERT_NE(keyboardSession->keyboardCallback_, nullptr); keyboardSession->keyboardCallback_->onGetSceneSession = - [callingSession](int32_t persistentId) -> sptr { - return callingSession; - }; + [callingSession](int32_t persistentId) -> sptr { return callingSession; }; ASSERT_NE(callingSession->property_, nullptr); uint32_t callingId = callingSession->property_->GetPersistentId(); keyboardSession->RestoreCallingSession(callingId, nullptr); @@ -464,9 +439,7 @@ HWTEST_F(KeyboardSessionTest, RestoreCallingSession02, TestSize.Level0) sptr callingSession = sptr::MakeSptr(info, specificCb); ASSERT_NE(keyboardSession->keyboardCallback_, nullptr); keyboardSession->keyboardCallback_->onGetSceneSession = - [callingSession](int32_t persistentId) -> sptr { - return callingSession; - }; + [callingSession](int32_t persistentId) -> sptr { return callingSession; }; ASSERT_NE(callingSession->property_, nullptr); uint32_t callingId = callingSession->property_->GetPersistentId(); keyboardSession->keyboardAvoidAreaActive_ = false; @@ -484,8 +457,7 @@ HWTEST_F(KeyboardSessionTest, UseFocusIdIfCallingSessionIdInvalid, TestSize.Leve SessionInfo info; info.abilityName_ = "UseFocusIdIfCallingSessionIdInvalid"; info.bundleName_ = "UseFocusIdIfCallingSessionIdInvalid"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -516,9 +488,7 @@ HWTEST_F(KeyboardSessionTest, GetFocusedSessionId, TestSize.Level1) sptr keyboardCb = sptr::MakeSptr(); EXPECT_NE(keyboardCb, nullptr); - keyboardCb->onGetFocusedSessionId = []() { - return 0; - }; + keyboardCb->onGetFocusedSessionId = []() { return 0; }; EXPECT_NE(keyboardCb->onGetFocusedSessionId, nullptr); sptr keyboardSession = sptr::MakeSptr(info, nullptr, keyboardCb); ASSERT_EQ(INVALID_WINDOW_ID, keyboardSession->GetFocusedSessionId()); @@ -540,8 +510,7 @@ HWTEST_F(KeyboardSessionTest, OnKeyboardPanelUpdated, TestSize.Level1) SessionInfo info; info.abilityName_ = "OnKeyboardPanelUpdated"; info.bundleName_ = "OnKeyboardPanelUpdated"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -558,7 +527,7 @@ HWTEST_F(KeyboardSessionTest, OnKeyboardPanelUpdated, TestSize.Level1) keyboardSession->specificCallback_ = specificCb; auto onUpdateAvoidArea = specificCb->onUpdateAvoidArea_; if (onUpdateAvoidArea == nullptr) { - onUpdateAvoidArea = [](const int32_t& id){}; + onUpdateAvoidArea = [](const int32_t& id) {}; } specificCb->onUpdateAvoidArea_ = nullptr; keyboardSession->OnKeyboardPanelUpdated(); @@ -581,8 +550,7 @@ HWTEST_F(KeyboardSessionTest, SetCallingSessionId, TestSize.Level0) SessionInfo info; info.abilityName_ = "SetCallingSessionId"; info.bundleName_ = "SetCallingSessionId"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -600,13 +568,13 @@ HWTEST_F(KeyboardSessionTest, SetCallingSessionId, TestSize.Level0) EXPECT_NE(callingSession, nullptr); ASSERT_NE(keyboardSession->keyboardCallback_, nullptr); keyboardSession->keyboardCallback_->onGetSceneSession = - [callingSession](int32_t persistenId)->sptr { + [callingSession](int32_t persistenId) -> sptr { if (persistenId != 100) { // callingSession's persistentId is 100 return nullptr; } return callingSession; }; - keyboardSession->keyboardCallback_->onGetFocusedSessionId = []()->int32_t { + keyboardSession->keyboardCallback_->onGetFocusedSessionId = []() -> int32_t { return 100; // focusSession's persistentId is 100 }; keyboardSession->SetCallingSessionId(0); @@ -630,8 +598,7 @@ HWTEST_F(KeyboardSessionTest, SetCallingSessionId02, TestSize.Level0) SessionInfo info; info.abilityName_ = "SetCallingSessionId02"; info.bundleName_ = "SetCallingSessionId02"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -645,13 +612,13 @@ HWTEST_F(KeyboardSessionTest, SetCallingSessionId02, TestSize.Level0) EXPECT_NE(callingSession, nullptr); ASSERT_NE(keyboardSession->keyboardCallback_, nullptr); keyboardSession->keyboardCallback_->onGetSceneSession = - [callingSession](int32_t persistenId)->sptr { + [callingSession](int32_t persistenId) -> sptr { if (persistenId != 100) { // callingSession's persistentId is 100 return nullptr; } return callingSession; }; - keyboardSession->keyboardCallback_->onGetFocusedSessionId = []()->int32_t { + keyboardSession->keyboardCallback_->onGetFocusedSessionId = []() -> int32_t { return 100; // focusSession's persistentId is 100 }; keyboardSession->state_ = SessionState::STATE_FOREGROUND; @@ -725,8 +692,8 @@ HWTEST_F(KeyboardSessionTest, NotifySystemKeyboardAvoidChange, TestSize.Level1) ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_); ASSERT_NE(nullptr, keyboardSession->keyboardCallback_); - keyboardSession->keyboardCallback_->onSystemKeyboardAvoidChange = - [](DisplayId displayId, SystemKeyboardAvoidChangeReason reason) {}; + keyboardSession->keyboardCallback_->onSystemKeyboardAvoidChange = [](DisplayId displayId, + SystemKeyboardAvoidChangeReason reason) {}; keyboardSession->NotifySystemKeyboardAvoidChange(SystemKeyboardAvoidChangeReason::KEYBOARD_CREATED); ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_); } @@ -744,15 +711,13 @@ HWTEST_F(KeyboardSessionTest, ChangeKeyboardViewMode, TestSize.Level1) sptr keyboardSession = sptr::MakeSptr(info, nullptr, nullptr); auto result = KeyboardViewMode::NON_IMMERSIVE_MODE; - keyboardSession->changeKeyboardViewModeFunc_ = [&result](KeyboardViewMode mode) { - result = mode; - }; + keyboardSession->changeKeyboardViewModeFunc_ = [&result](KeyboardViewMode mode) { result = mode; }; keyboardSession->ChangeKeyboardViewMode(KeyboardViewMode::DARK_IMMERSIVE_MODE); sleep(SPLIT_TEST_SLEEP_S); ASSERT_EQ(result, KeyboardViewMode::DARK_IMMERSIVE_MODE); auto mode = keyboardSession->property_->GetKeyboardViewMode(); ASSERT_EQ(mode, KeyboardViewMode::DARK_IMMERSIVE_MODE); } -} // namespace -} // namespace Rosen -} // namespace OHOS +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/keyboard_session_test2.cpp b/window_scene/test/unittest/keyboard_session_test2.cpp index bcae0f1b22..b02a30b2e2 100644 --- a/window_scene/test/unittest/keyboard_session_test2.cpp +++ b/window_scene/test/unittest/keyboard_session_test2.cpp @@ -30,7 +30,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "KeyboardSessionTest2"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "KeyboardSessionTest2" }; } constexpr int WAIT_ASYNC_US = 1000000; @@ -47,30 +47,21 @@ private: sptr GetSceneSessionMocker(const std::string& abilityName, const std::string& bundleName); }; -void KeyboardSessionTest2::SetUpTestCase() -{ -} +void KeyboardSessionTest2::SetUpTestCase() {} -void KeyboardSessionTest2::TearDownTestCase() -{ -} +void KeyboardSessionTest2::TearDownTestCase() {} -void KeyboardSessionTest2::SetUp() -{ -} +void KeyboardSessionTest2::SetUp() {} -void KeyboardSessionTest2::TearDown() -{ -} +void KeyboardSessionTest2::TearDown() {} sptr KeyboardSessionTest2::GetKeyboardSession(const std::string& abilityName, - const std::string& bundleName) + const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; info.bundleName_ = bundleName; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -86,14 +77,12 @@ sptr KeyboardSessionTest2::GetKeyboardSession(const std::string return keyboardSession; } -sptr KeyboardSessionTest2::GetSceneSession(const std::string& abilityName, - const std::string& bundleName) +sptr KeyboardSessionTest2::GetSceneSession(const std::string& abilityName, const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; info.bundleName_ = bundleName; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr sceneSession = sptr::MakeSptr(info, specificCb); @@ -101,13 +90,12 @@ sptr KeyboardSessionTest2::GetSceneSession(const std::string& abil } sptr KeyboardSessionTest2::GetSceneSessionMocker(const std::string& abilityName, - const std::string& bundleName) + const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; info.bundleName_ = bundleName; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr mockSession = sptr::MakeSptr(info, nullptr); @@ -125,8 +113,7 @@ HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout01, TestSize.Level1) SessionInfo info; info.abilityName_ = "AdjustKeyboardLayout01"; info.bundleName_ = "AdjustKeyboardLayout01"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -143,7 +130,7 @@ HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout01, TestSize.Level1) keyboardSession->adjustKeyboardLayoutFunc_ = nullptr; ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK); - keyboardSession->adjustKeyboardLayoutFunc_ = [](const KeyboardLayoutParams& params){}; + keyboardSession->adjustKeyboardLayoutFunc_ = [](const KeyboardLayoutParams& params) {}; ASSERT_EQ(keyboardSession->AdjustKeyboardLayout(params), WSError::WS_OK); } @@ -157,8 +144,7 @@ HWTEST_F(KeyboardSessionTest2, AdjustKeyboardLayout02, TestSize.Level1) SessionInfo info; info.abilityName_ = "AdjustKeyboardLayout02"; info.bundleName_ = "AdjustKeyboardLayout02"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -188,8 +174,7 @@ HWTEST_F(KeyboardSessionTest2, CheckIfNeedRaiseCallingSession, TestSize.Level1) SessionInfo info; info.abilityName_ = "CheckIfNeedRaiseCallingSession"; info.bundleName_ = "CheckIfNeedRaiseCallingSession"; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -296,7 +281,7 @@ HWTEST_F(KeyboardSessionTest2, GetKeyboardGravity01, TestSize.Level0) */ HWTEST_F(KeyboardSessionTest2, NotifyKeyboardPanelInfoChange, TestSize.Level1) { - WSRect rect = {800, 800, 1200, 1200}; + WSRect rect = { 800, 800, 1200, 1200 }; SessionInfo info; info.abilityName_ = "NotifyKeyboardPanelInfoChange"; info.bundleName_ = "NotifyKeyboardPanelInfoChange"; @@ -455,9 +440,7 @@ HWTEST_F(KeyboardSessionTest2, RaiseCallingSession01, TestSize.Level0) // for cover GetSceneSession keyboardSession->keyboardCallback_->onGetSceneSession = - [callingSession](int32_t persistentId)->sptr { - return callingSession; - }; + [callingSession](int32_t persistentId) -> sptr { return callingSession; }; keyboardSession->RaiseCallingSession(callingId, keyboardPanelRect, true, rsTransaction); // for cover CheckIfNeedRaiseCallingSession keyboardSession->property_->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM; @@ -663,6 +646,6 @@ HWTEST_F(KeyboardSessionTest2, CloseKeyboardSyncTransaction4, TestSize.Level1) auto callingSessionId = keyboardSession->property_->GetCallingSessionId(); ASSERT_EQ(callingSessionId, INVALID_WINDOW_ID); } -} // namespace -} // namespace Rosen -} // namespace OHOS +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/keyboard_session_test3.cpp b/window_scene/test/unittest/keyboard_session_test3.cpp index ad41eb8f18..fa819a9df2 100644 --- a/window_scene/test/unittest/keyboard_session_test3.cpp +++ b/window_scene/test/unittest/keyboard_session_test3.cpp @@ -38,35 +38,27 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: sptr GetKeyboardSession(const std::string& abilityName, const std::string& bundleName); sptr GetSceneSession(const std::string& abilityName, const std::string& bundleName); }; -void KeyboardSessionTest3::SetUpTestCase() -{ -} +void KeyboardSessionTest3::SetUpTestCase() {} -void KeyboardSessionTest3::TearDownTestCase() -{ -} +void KeyboardSessionTest3::TearDownTestCase() {} -void KeyboardSessionTest3::SetUp() -{ -} +void KeyboardSessionTest3::SetUp() {} -void KeyboardSessionTest3::TearDown() -{ -} +void KeyboardSessionTest3::TearDown() {} sptr KeyboardSessionTest3::GetKeyboardSession(const std::string& abilityName, - const std::string& bundleName) + const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; info.bundleName_ = bundleName; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr keyboardCb = sptr::MakeSptr(); @@ -82,14 +74,12 @@ sptr KeyboardSessionTest3::GetKeyboardSession(const std::string return keyboardSession; } -sptr KeyboardSessionTest3::GetSceneSession(const std::string& abilityName, - const std::string& bundleName) +sptr KeyboardSessionTest3::GetSceneSession(const std::string& abilityName, const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; info.bundleName_ = bundleName; - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); EXPECT_NE(specificCb, nullptr); sptr sceneSession = sptr::MakeSptr(info, specificCb); @@ -146,8 +136,8 @@ HWTEST_F(KeyboardSessionTest3, GetSessionScreenName01, TestSize.Level1) */ HWTEST_F(KeyboardSessionTest3, UseFocusIdIfCallingSessionIdInvalid01, TestSize.Level1) { - auto keyboardSession = GetKeyboardSession("UseFocusIdIfCallingSessionIdInvalid01", - "UseFocusIdIfCallingSessionIdInvalid01"); + auto keyboardSession = + GetKeyboardSession("UseFocusIdIfCallingSessionIdInvalid01", "UseFocusIdIfCallingSessionIdInvalid01"); ASSERT_NE(keyboardSession, nullptr); sptr keyboardCallback = sptr::MakeSptr(); @@ -157,12 +147,12 @@ HWTEST_F(KeyboardSessionTest3, UseFocusIdIfCallingSessionIdInvalid01, TestSize.L ASSERT_NE(sceneSession, nullptr); sceneSession->persistentId_ = 100; keyboardSession->keyboardCallback_->onGetSceneSession = - [sceneSession](uint32_t callingSessionId)->sptr { - if (sceneSession->persistentId_ != callingSessionId) { - return nullptr; - } - return sceneSession; - }; + [sceneSession](uint32_t callingSessionId) -> sptr { + if (sceneSession->persistentId_ != callingSessionId) { + return nullptr; + } + return sceneSession; + }; keyboardSession->GetSessionProperty()->SetCallingSessionId(100); keyboardSession->UseFocusIdIfCallingSessionIdInvalid(); @@ -170,9 +160,7 @@ HWTEST_F(KeyboardSessionTest3, UseFocusIdIfCallingSessionIdInvalid01, TestSize.L ASSERT_EQ(resultId, 100); keyboardSession->GetSessionProperty()->SetCallingSessionId(101); - keyboardSession->keyboardCallback_->onGetFocusedSessionId = []()->int32_t { - return 100; - }; + keyboardSession->keyboardCallback_->onGetFocusedSessionId = []() -> int32_t { return 100; }; keyboardSession->UseFocusIdIfCallingSessionIdInvalid(); resultId = keyboardSession->GetCallingSessionId(); ASSERT_EQ(resultId, 100); @@ -331,9 +319,9 @@ HWTEST_F(KeyboardSessionTest3, NotifySessionRectChange01, TestSize.Level1) keyboardSession->NotifySessionRectChange(rect, SizeChangeReason::DRAG_END, -1); keyboardSession->NotifySessionRectChange(rect, SizeChangeReason::DRAG_END, 11); keyboardSession->sessionRectChangeFunc_ = [](const WSRect& rect, - SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) { - return; - }; + SizeChangeReason reason, + DisplayId displayId, + const RectAnimationConfig& rectAnimationConfig) { return; }; keyboardSession->NotifySessionRectChange(rect, SizeChangeReason::DRAG_END, -1); keyboardSession->NotifySessionRectChange(rect, SizeChangeReason::DRAG_END, 11); } @@ -378,8 +366,7 @@ HWTEST_F(KeyboardSessionTest3, OnCallingSessionUpdated01, TestSize.Level1) ASSERT_EQ(keyboardSession->state_, SessionState::STATE_FOREGROUND); // callingsession is not nullptr - sptr specificCb = - sptr::MakeSptr(); + sptr specificCb = sptr::MakeSptr(); ASSERT_NE(specificCb, nullptr); SessionInfo info; info.abilityName_ = "OnCallingSessionUpdated01"; @@ -389,9 +376,7 @@ HWTEST_F(KeyboardSessionTest3, OnCallingSessionUpdated01, TestSize.Level1) EXPECT_NE(callingSession, nullptr); ASSERT_NE(keyboardSession->keyboardCallback_, nullptr); keyboardSession->keyboardCallback_->onGetSceneSession = - [callingSession](int32_t persistentId)->sptr { - return callingSession; - }; + [callingSession](int32_t persistentId) -> sptr { return callingSession; }; // callingSession is fullScreen and isCallingSessionFloating is false // keyboardSession's gravity is SessionGravity::SESSION_GRAVITY_DEFAULT keyboardSession->OnCallingSessionUpdated(); @@ -432,7 +417,7 @@ HWTEST_F(KeyboardSessionTest3, OnCallingSessionUpdated02, TestSize.Level1) HWTEST_F(KeyboardSessionTest3, RecalculatePanelRectForAvoidArea, TestSize.Level1) { auto keyboardSession = GetKeyboardSession("RecalculatePanelRectForAvoidArea", "RecalculatePanelRectForAvoidArea"); - + // if landscapeAvoidHeight_ or portraitAvoidHeight_ < 0 WSRect panelRect = { 0, 0, 0, 0 }; KeyboardLayoutParams params; @@ -464,8 +449,8 @@ HWTEST_F(KeyboardSessionTest3, RecalculatePanelRectForAvoidArea, TestSize.Level1 */ HWTEST_F(KeyboardSessionTest3, RecalculatePanelRectForAvoidArea02, TestSize.Level1) { - auto keyboardSession = GetKeyboardSession("RecalculatePanelRectForAvoidArea02", - "RecalculatePanelRectForAvoidArea02"); + auto keyboardSession = + GetKeyboardSession("RecalculatePanelRectForAvoidArea02", "RecalculatePanelRectForAvoidArea02"); // if the landscape width is not same to the portrait KeyboardLayoutParams params; @@ -474,7 +459,7 @@ HWTEST_F(KeyboardSessionTest3, RecalculatePanelRectForAvoidArea02, TestSize.Leve params.LandscapePanelRect_.width_ = 1; params.PortraitPanelRect_.width_ = 2; keyboardSession->GetSessionProperty()->SetKeyboardLayoutParams(params); - + WSRect panelRect = { 0, 0, 0, 0 }; panelRect.width_ = 1; keyboardSession->RecalculatePanelRectForAvoidArea(panelRect); @@ -496,12 +481,10 @@ HWTEST_F(KeyboardSessionTest3, RecalculatePanelRectForAvoidArea02, TestSize.Leve */ HWTEST_F(KeyboardSessionTest3, SetSkipSelfWhenShowOnVirtualScreen, TestSize.Level1) { - auto keyboardSession = GetKeyboardSession("SetSkipSelfWhenShowOnVirtualScreen", - "SetSkipSelfWhenShowOnVirtualScreen"); + auto keyboardSession = + GetKeyboardSession("SetSkipSelfWhenShowOnVirtualScreen", "SetSkipSelfWhenShowOnVirtualScreen"); bool skipResult = false; - auto callFunc = [&skipResult](uint64_t surfaceNodeId, bool isSkip) { - skipResult = isSkip; - }; + auto callFunc = [&skipResult](uint64_t surfaceNodeId, bool isSkip) { skipResult = isSkip; }; keyboardSession->SetSkipSelfWhenShowOnVirtualScreen(true); usleep(SLEEP_TIME_US); ASSERT_EQ(skipResult, false); @@ -545,8 +528,7 @@ HWTEST_F(KeyboardSessionTest3, SetSkipEventOnCastPlus01, Function | SmallTest | */ HWTEST_F(KeyboardSessionTest3, IsNeedRaiseSubWindow01, Function | SmallTest | Level0) { - auto keyboardSession = GetKeyboardSession("IsNeedRaiseSubWindow", - "IsNeedRaiseSubWindow"); + auto keyboardSession = GetKeyboardSession("IsNeedRaiseSubWindow", "IsNeedRaiseSubWindow"); SessionInfo info; info.abilityName_ = "CallingSession"; info.bundleName_ = "CallingSession"; @@ -567,8 +549,7 @@ HWTEST_F(KeyboardSessionTest3, IsNeedRaiseSubWindow01, Function | SmallTest | Le */ HWTEST_F(KeyboardSessionTest3, IsNeedRaiseSubWindow02, Function | SmallTest | Level0) { - auto keyboardSession = GetKeyboardSession("IsNeedRaiseSubWindow", - "IsNeedRaiseSubWindow"); + auto keyboardSession = GetKeyboardSession("IsNeedRaiseSubWindow", "IsNeedRaiseSubWindow"); SessionInfo info; info.abilityName_ = "CallingSession"; info.bundleName_ = "CallingSession"; @@ -584,7 +565,7 @@ HWTEST_F(KeyboardSessionTest3, IsNeedRaiseSubWindow02, Function | SmallTest | Le auto ret = keyboardSession->IsNeedRaiseSubWindow(callingSession, sessionRect); ASSERT_EQ(true, ret); - + mainSession->GetSessionProperty()->windowMode_ = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; ret = keyboardSession->IsNeedRaiseSubWindow(callingSession, sessionRect); ASSERT_EQ(false, ret); @@ -594,6 +575,6 @@ HWTEST_F(KeyboardSessionTest3, IsNeedRaiseSubWindow02, Function | SmallTest | Le ret = keyboardSession->IsNeedRaiseSubWindow(callingSession, sessionRect); ASSERT_EQ(true, ret); } -} // namespace -} // namespace Rosen -} // namespace OHOS +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/layout/keyboard_session_layout_test.cpp b/window_scene/test/unittest/layout/keyboard_session_layout_test.cpp index 97c7b31e56..df80fbf485 100644 --- a/window_scene/test/unittest/layout/keyboard_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/keyboard_session_layout_test.cpp @@ -41,24 +41,16 @@ private: sptr GetSceneSession(const std::string& abilityName, const std::string& bundleName); }; -void KeyboardSessionLayoutTest::SetUpTestCase() -{ -} +void KeyboardSessionLayoutTest::SetUpTestCase() {} -void KeyboardSessionLayoutTest::TearDownTestCase() -{ -} +void KeyboardSessionLayoutTest::TearDownTestCase() {} -void KeyboardSessionLayoutTest::SetUp() -{ -} +void KeyboardSessionLayoutTest::SetUp() {} -void KeyboardSessionLayoutTest::TearDown() -{ -} +void KeyboardSessionLayoutTest::TearDown() {} sptr KeyboardSessionLayoutTest::GetSceneSession(const std::string& abilityName, - const std::string& bundleName) + const std::string& bundleName) { SessionInfo info; info.abilityName_ = abilityName; @@ -141,6 +133,6 @@ HWTEST_F(KeyboardSessionLayoutTest, NotifyClientToUpdateRect03, TestSize.Level1) ret = keyboardSession->NotifyClientToUpdateRect("KeyboardSessionLayoutTest", nullptr); ASSERT_EQ(ret, WSError::WS_OK); } -} // namespace -} // namespace Rosen -} // namespace OHOS +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/layout/scb_system_session_layout_test.cpp b/window_scene/test/unittest/layout/scb_system_session_layout_test.cpp index 6a09ea07c6..942056c464 100644 --- a/window_scene/test/unittest/layout/scb_system_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/scb_system_session_layout_test.cpp @@ -38,13 +38,9 @@ public: sptr scbSystemSession_; }; -void SCBSystemSessionLayoutTest::SetUpTestCase() -{ -} +void SCBSystemSessionLayoutTest::SetUpTestCase() {} -void SCBSystemSessionLayoutTest::TearDownTestCase() -{ -} +void SCBSystemSessionLayoutTest::TearDownTestCase() {} void SCBSystemSessionLayoutTest::SetUp() { @@ -71,7 +67,7 @@ HWTEST_F(SCBSystemSessionLayoutTest, UpdateWindowMode, TestSize.Level1) scbSystemSession_->PresentFocusIfPointDown(); scbSystemSession_->PresentFoucusIfNeed(2); ASSERT_EQ(WSError::WS_OK, scbSystemSession_->SetSystemSceneBlockingFocus(true)); - WSRect rect = {0, 0, 0, 0}; + WSRect rect = { 0, 0, 0, 0 }; scbSystemSession_->UpdatePointerArea(rect); auto ret = scbSystemSession_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, ret); @@ -182,6 +178,6 @@ HWTEST_F(SCBSystemSessionLayoutTest, NotifyClientToUpdateRect04, TestSize.Level1 auto ret = scbSystemSession_->NotifyClientToUpdateRect("SCBSystemSessionLayoutTest", nullptr); ASSERT_EQ(WSError::WS_OK, ret); } -} //namespace -} //namespace Rosen -} //namespace OHOS \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/layout/scene_session_layout_test.cpp b/window_scene/test/unittest/layout/scene_session_layout_test.cpp index d7b7a02b06..611cf26b79 100644 --- a/window_scene/test/unittest/layout/scene_session_layout_test.cpp +++ b/window_scene/test/unittest/layout/scene_session_layout_test.cpp @@ -44,22 +44,16 @@ private: sptr mockSessionStage_ = nullptr; }; -void SceneSessionLayoutTest::SetUpTestCase() -{ -} +void SceneSessionLayoutTest::SetUpTestCase() {} -void SceneSessionLayoutTest::TearDownTestCase() -{ -} +void SceneSessionLayoutTest::TearDownTestCase() {} void SceneSessionLayoutTest::SetUp() { mockSessionStage_ = sptr::MakeSptr(); } -void SceneSessionLayoutTest::TearDown() -{ -} +void SceneSessionLayoutTest::TearDown() {} namespace { /** @@ -79,13 +73,12 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRect01, TestSize.Level1) property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::UNDEFINED; WSError result = sceneSession->UpdateRect(rect, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); } - /** * @tc.name: UpdateRect02 * @tc.desc: normal function @@ -103,7 +96,7 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRect02, TestSize.Level0) property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::UNDEFINED; WSError result = sceneSession->UpdateRect(rect, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); @@ -116,7 +109,7 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRect02, TestSize.Level0) result = sceneSession->UpdateRect(rect, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); - WSRect rect2({0, 0, 0, 0}); + WSRect rect2({ 0, 0, 0, 0 }); result = sceneSession->UpdateRect(rect2, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); } @@ -184,9 +177,9 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRectInner01, TestSize.Level0) sceneSession->SetForegroundInteractiveStatus(true); uiParam.needSync_ = true; - uiParam.rect_ = {0, 0, 1, 1}; + uiParam.rect_ = { 0, 0, 1, 1 }; - sceneSession->winRect_ = {1, 1, 1, 1}; + sceneSession->winRect_ = { 1, 1, 1, 1 }; sceneSession->isVisible_ = true; ASSERT_EQ(false, sceneSession->UpdateRectInner(uiParam, reason)); } @@ -211,9 +204,7 @@ HWTEST_F(SceneSessionLayoutTest, NotifyClientToUpdateRect, TestSize.Level1) session->reason_ = SizeChangeReason::DRAG; EXPECT_EQ(WSError::WS_OK, session->NotifyClientToUpdateRect("SceneSessionLayoutTest", nullptr)); - UpdateAvoidAreaCallback func = [](const int32_t& persistentId) { - return; - }; + UpdateAvoidAreaCallback func = [](const int32_t& persistentId) { return; }; auto specificCallback = sptr::MakeSptr(); specificCallback->onUpdateAvoidArea_ = func; session->specificCallback_ = specificCallback; @@ -265,7 +256,7 @@ HWTEST_F(SceneSessionLayoutTest, CheckAspectRatioValid, TestSize.Level0) EXPECT_EQ(WSError::WS_OK, session->SetAspectRatio(0.0f)); sptr property = sptr::MakeSptr(); - WindowLimits limits = {8, 1, 6, 1, 1, 1.0f, 1.0f}; + WindowLimits limits = { 8, 1, 6, 1, 1, 1.0f, 1.0f }; property->SetWindowLimits(limits); session->SetSessionProperty(property); EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, session->SetAspectRatio(0.1f)); @@ -330,20 +321,20 @@ HWTEST_F(SceneSessionLayoutTest, NotifyClientToUpdateRectTask, TestSize.Level0) session->Session::UpdateSizeChangeReason(SizeChangeReason::UNDEFINED); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::MOVE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::DRAG_MOVE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::RESIZE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::RECOVER); EXPECT_EQ(session->reason_, SizeChangeReason::RECOVER); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); session->moveDragController_->isStartDrag_ = true; @@ -352,23 +343,23 @@ HWTEST_F(SceneSessionLayoutTest, NotifyClientToUpdateRectTask, TestSize.Level0) session->isKeyboardPanelEnabled_ = true; info.windowType_ = static_cast(WindowType::ABOVE_APP_SYSTEM_WINDOW_BASE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); info.windowType_ = static_cast(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::UNDEFINED); EXPECT_EQ(WSError::WS_ERROR_REPEAT_OPERATION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::MOVE); info.windowType_ = static_cast(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::DRAG_MOVE); info.windowType_ = static_cast(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); } /** @@ -948,5 +939,5 @@ HWTEST_F(SceneSessionLayoutTest, HandleSubSessionCrossNode, TestSize.Level1) ASSERT_EQ(sceneSession->IsDragStart(), true); } } // namespace -} // Rosen -} // OHOS \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/layout/scene_session_manager_layout_test.cpp b/window_scene/test/unittest/layout/scene_session_manager_layout_test.cpp index 97bd25b903..e85a9058e3 100644 --- a/window_scene/test/unittest/layout/scene_session_manager_layout_test.cpp +++ b/window_scene/test/unittest/layout/scene_session_manager_layout_test.cpp @@ -33,7 +33,7 @@ namespace { const std::string EMPTY_DEVICE_ID = ""; constexpr float SINGLE_HAND_SCALE = 0.75f; constexpr float SINGLE_HAND_DEFAULT_SCALE = 1.0f; -} +} // namespace class SceneSessionManagerLayoutTest : public testing::Test { public: static void SetUpTestCase(); @@ -41,6 +41,7 @@ public: void SetUp() override; void TearDown() override; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; @@ -95,8 +96,8 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestUIType, T WSRect originRect, singleHandRect; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); sptr screenSession = sptr::MakeSptr(); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); @@ -128,14 +129,14 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestWindowNam sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->property_->SetWindowName("OneHandModeBackground_testWindow"); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); sptr screenSession = sptr::MakeSptr(); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); SingleHandScreenInfo singleHandScreenInfo; WSRect originRect, singleHandRect; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; @@ -155,8 +156,8 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestDisplayId ssm_->singleHandTransform_ = singleHandTransform; SingleHandScreenInfo singleHandScreenInfo; WSRect originRect, singleHandRect; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; @@ -170,7 +171,7 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestDisplayId EXPECT_NE(sceneSession, nullptr); sceneSession->GetSessionProperty()->SetDisplayId(2025); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); usleep(WAIT_SYNC_IN_NS); EXPECT_NE(singleHandScreenInfo.scaleRatio, sceneSession->singleHandTransform_.scaleX); @@ -198,8 +199,8 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestMode, Tes SingleHandScreenInfo singleHandScreenInfo; WSRect originRect, singleHandRect; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); @@ -209,7 +210,7 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestMode, Tes ssm_->singleHandTransform_ = singleHandTransform; singleHandScreenInfo.mode = SingleHandMode::RIGHT; - singleHandRect = {50, 100, 200, 300}; + singleHandRect = { 50, 100, 200, 300 }; ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); usleep(WAIT_SYNC_IN_NS); EXPECT_EQ(100, ssm_->singleHandTransform_.posY); @@ -218,7 +219,7 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestMode, Tes singleHandScreenInfo.scaleRatio = SINGLE_HAND_DEFAULT_SCALE; singleHandScreenInfo.mode = SingleHandMode::MIDDLE; - singleHandRect = {0, 0, 200, 300}; + singleHandRect = { 0, 0, 200, 300 }; ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); usleep(WAIT_SYNC_IN_NS); EXPECT_EQ(0, ssm_->singleHandTransform_.posY); @@ -241,6 +242,6 @@ HWTEST_F(SceneSessionManagerLayoutTest, GetDisplaySizeById_TestDisplayId, TestSi displayId = 0; EXPECT_EQ(true, ssm_->GetDisplaySizeById(displayId, displayWidth, displayHeight)); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/layout/session_layout_test.cpp b/window_scene/test/unittest/layout/session_layout_test.cpp index 29bc6b598b..8651289e86 100644 --- a/window_scene/test/unittest/layout/session_layout_test.cpp +++ b/window_scene/test/unittest/layout/session_layout_test.cpp @@ -65,7 +65,9 @@ private: void OnExtensionDied() override {} void OnExtensionTimeout(int32_t errorCode) override {} void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, - int64_t uiExtensionIdLevel) override {} + int64_t uiExtensionIdLevel) override + { + } void OnDrawingCompleted() override {} void OnAppRemoveStartingWindow() override {} }; @@ -75,13 +77,9 @@ private: sptr mockEventChannel_ = nullptr; }; -void SessionLayoutTest::SetUpTestCase() -{ -} +void SessionLayoutTest::SetUpTestCase() {} -void SessionLayoutTest::TearDownTestCase() -{ -} +void SessionLayoutTest::TearDownTestCase() {} void SessionLayoutTest::SetUp() { @@ -93,9 +91,7 @@ void SessionLayoutTest::SetUp() session_->surfaceNode_ = CreateRSSurfaceNode(); ssm_ = sptr::MakeSptr(); session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_); - auto isScreenLockedCallback = [this]() { - return ssm_->IsScreenLocked(); - }; + auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); mockSessionStage_ = sptr::MakeSptr(); mockEventChannel_ = sptr::MakeSptr(mockSessionStage_); @@ -146,26 +142,25 @@ HWTEST_F(SessionLayoutTest, UpdateRect01, TestSize.Level1) session_->sessionStage_ = mockSessionStage; EXPECT_CALL(*(mockSessionStage), UpdateRect(_, _, _, _)).Times(AtLeast(1)).WillOnce(Return(WSError::WS_OK)); - WSRect rect = {0, 0, 0, 0}; - ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->UpdateRect(rect, - SizeChangeReason::UNDEFINED, "SessionLayoutTest")); + WSRect rect = { 0, 0, 0, 0 }; + ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, + session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); sptr mockEventChannel = sptr::MakeSptr(mockSessionStage); SystemSessionConfig sessionConfig; sptr property = sptr::MakeSptr(); - ASSERT_EQ(WSError::WS_OK, session_->Connect(mockSessionStage, - mockEventChannel, nullptr, sessionConfig, property)); + ASSERT_EQ(WSError::WS_OK, session_->Connect(mockSessionStage, mockEventChannel, nullptr, sessionConfig, property)); - rect = {0, 0, 100, 100}; - ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->UpdateRect(rect, - SizeChangeReason::UNDEFINED, "SessionLayoutTest")); + rect = { 0, 0, 100, 100 }; + ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, + session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); ASSERT_EQ(rect, session_->winRect_); - rect = {0, 0, 200, 200}; + rect = { 0, 0, 200, 200 }; session_->UpdateSessionState(SessionState::STATE_ACTIVE); ASSERT_EQ(WSError::WS_OK, session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); ASSERT_EQ(rect, session_->winRect_); - rect = {0, 0, 300, 300}; + rect = { 0, 0, 300, 300 }; session_->sessionStage_ = nullptr; ASSERT_EQ(WSError::WS_OK, session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); ASSERT_EQ(rect, session_->winRect_); @@ -204,7 +199,7 @@ HWTEST_F(SessionLayoutTest, UpdateSessionRect01, TestSize.Level1) info.abilityName_ = "testSession1"; info.bundleName_ = "testSession3"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - WSRect rect = {0, 0, 320, 240}; // width: 320, height: 240 + WSRect rect = { 0, 0, 320, 240 }; // width: 320, height: 240 auto result = sceneSession->UpdateSessionRect(rect, SizeChangeReason::RESIZE); ASSERT_EQ(result, WSError::WS_OK); @@ -276,6 +271,6 @@ HWTEST_F(SessionLayoutTest, SetOriginDisplayId, TestSize.Level1) session->SetOriginDisplayId(999); ASSERT_EQ(999, session->GetOriginDisplayId()); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/layout/session_stage_proxy_layout_test.cpp b/window_scene/test/unittest/layout/session_stage_proxy_layout_test.cpp index 6e588d9e60..f5bbdac153 100644 --- a/window_scene/test/unittest/layout/session_stage_proxy_layout_test.cpp +++ b/window_scene/test/unittest/layout/session_stage_proxy_layout_test.cpp @@ -58,6 +58,6 @@ HWTEST_F(SessionStageProxyLayoutTest, NotifySingleHandTransformChange, TestSize. ASSERT_TRUE((sessionStage_ != nullptr)); GTEST_LOG_(INFO) << "SessionStageProxyLayoutTest: NotifySingleHandTransformChange end"; } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/layout/session_stub_layout_test.cpp b/window_scene/test/unittest/layout/session_stub_layout_test.cpp index be34c24936..675acf37eb 100644 --- a/window_scene/test/unittest/layout/session_stub_layout_test.cpp +++ b/window_scene/test/unittest/layout/session_stub_layout_test.cpp @@ -49,13 +49,9 @@ private: sptr session_ = nullptr; }; -void SessionStubLayoutTest::SetUpTestCase() -{ -} +void SessionStubLayoutTest::SetUpTestCase() {} -void SessionStubLayoutTest::TearDownTestCase() -{ -} +void SessionStubLayoutTest::TearDownTestCase() {} void SessionStubLayoutTest::SetUp() { @@ -140,6 +136,6 @@ HWTEST_F(SessionStubLayoutTest, HandleSetSystemEnableDrag_TestReadBool, TestSize res = session_->HandleSetSystemEnableDrag(data, reply); ASSERT_EQ(ERR_NONE, res); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/main_session_lifecycle_test.cpp b/window_scene/test/unittest/main_session_lifecycle_test.cpp index 72f73c602c..12f2332b9d 100644 --- a/window_scene/test/unittest/main_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/main_session_lifecycle_test.cpp @@ -30,19 +30,16 @@ public: void SetUp() override; void TearDown() override; SessionInfo info; - sptr specificCallback = nullptr; - sptr mainSession_; + sptr specificCallback = nullptr; + sptr mainSession_; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); }; -void MainSessionLifecycleTest::SetUpTestCase() -{ -} +void MainSessionLifecycleTest::SetUpTestCase() {} -void MainSessionLifecycleTest::TearDownTestCase() -{ -} +void MainSessionLifecycleTest::TearDownTestCase() {} void MainSessionLifecycleTest::SetUp() { @@ -170,6 +167,6 @@ HWTEST_F(MainSessionLifecycleTest, NotifyForegroundInteractiveStatus02, TestSize mainSession_->NotifyForegroundInteractiveStatus(true); ASSERT_EQ(WSError::WS_OK, mainSession_->SetFocusable(false)); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/main_session_test.cpp b/window_scene/test/unittest/main_session_test.cpp index a54ca3e88a..9744e95add 100644 --- a/window_scene/test/unittest/main_session_test.cpp +++ b/window_scene/test/unittest/main_session_test.cpp @@ -41,17 +41,14 @@ public: SessionInfo info; sptr specificCallback = nullptr; sptr mainSession_; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); }; -void MainSessionTest::SetUpTestCase() -{ -} +void MainSessionTest::SetUpTestCase() {} -void MainSessionTest::TearDownTestCase() -{ -} +void MainSessionTest::TearDownTestCase() {} void MainSessionTest::SetUp() { @@ -104,7 +101,7 @@ HWTEST_F(MainSessionTest, MainSession01, TestSize.Level1) info.abilityName_ = "MainSession01"; info.moduleName_ = "MainSession02"; info.bundleName_ = "MainSession03"; - pSpecificCallback = new(std::nothrow) MainSession::SpecificSessionCallback; + pSpecificCallback = new (std::nothrow) MainSession::SpecificSessionCallback; pMainSession = sptr::MakeSptr(info, pSpecificCallback); EXPECT_NE(nullptr, pMainSession); @@ -213,7 +210,7 @@ HWTEST_F(MainSessionTest, SetTopmost02, TestSize.Level1) */ HWTEST_F(MainSessionTest, UpdatePointerArea, TestSize.Level1) { - WSRect Rect={0, 0, 50, 50}; + WSRect Rect = { 0, 0, 50, 50 }; mainSession_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); mainSession_->UpdatePointerArea(Rect); mainSession_->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -363,9 +360,7 @@ HWTEST_F(MainSessionTest, OnTitleAndDockHoverShowChange, TestSize.Level1) info.abilityName_ = "OnTitleAndDockHoverShowChange"; info.bundleName_ = "OnTitleAndDockHoverShowChange"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->SetTitleAndDockHoverShowChangeCallback([](bool isTitleHoverShown, bool isDockHoverShown) { - return; - }); + sceneSession->SetTitleAndDockHoverShowChangeCallback([](bool isTitleHoverShown, bool isDockHoverShown) { return; }); EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr); EXPECT_EQ(sceneSession->OnTitleAndDockHoverShowChange(true, true), WSError::WS_OK); } @@ -384,7 +379,7 @@ HWTEST_F(MainSessionTest, OnTitleAndDockHoverShowChange02, TestSize.Level1) ASSERT_NE(testSession, nullptr); auto callbackFlag = 1; - testSession->onTitleAndDockHoverShowChangeFunc_ = [&callbackFlag] (bool isTitleHoverShown, bool isDockHoverShown) { + testSession->onTitleAndDockHoverShowChangeFunc_ = [&callbackFlag](bool isTitleHoverShown, bool isDockHoverShown) { callbackFlag += 1; }; testSession->OnTitleAndDockHoverShowChange(true, true); @@ -408,9 +403,7 @@ HWTEST_F(MainSessionTest, OnRestoreMainWindow, TestSize.Level1) session->onRestoreMainWindowFunc_ = nullptr; EXPECT_EQ(WSError::WS_OK, session->OnRestoreMainWindow()); - NotifyRestoreMainWindowFunc func = [] { - return; - }; + NotifyRestoreMainWindowFunc func = [] { return; }; session->onRestoreMainWindowFunc_ = func; EXPECT_EQ(WSError::WS_OK, session->OnRestoreMainWindow()); } @@ -430,11 +423,9 @@ HWTEST_F(MainSessionTest, OnRestoreMainWindow02, TestSize.Level1) testSession->onRestoreMainWindowFunc_ = nullptr; EXPECT_EQ(testSession->OnRestoreMainWindow(), WSError::WS_OK); - + auto callbackFlag = 1; - testSession->onRestoreMainWindowFunc_ = [&callbackFlag] () { - callbackFlag += 1; - }; + testSession->onRestoreMainWindowFunc_ = [&callbackFlag]() { callbackFlag += 1; }; testSession->OnRestoreMainWindow(); EXPECT_EQ(callbackFlag, 2); } @@ -454,9 +445,7 @@ HWTEST_F(MainSessionTest, OnSetWindowRectAutoSave, TestSize.Level1) session->onSetWindowRectAutoSaveFunc_ = nullptr; EXPECT_EQ(nullptr, session->onSetWindowRectAutoSaveFunc_); - NotifySetWindowRectAutoSaveFunc func = [](bool enabled, bool isSaveBySpecifiedFlag) { - return; - }; + NotifySetWindowRectAutoSaveFunc func = [](bool enabled, bool isSaveBySpecifiedFlag) { return; }; session->onSetWindowRectAutoSaveFunc_ = func; EXPECT_NE(nullptr, session->onSetWindowRectAutoSaveFunc_); } @@ -478,7 +467,7 @@ HWTEST_F(MainSessionTest, OnSetWindowRectAutoSave02, TestSize.Level1) EXPECT_EQ(testSession->OnSetWindowRectAutoSave(true, true), WSError::WS_OK); auto callbackFlag = 1; - testSession->onSetWindowRectAutoSaveFunc_ = [&callbackFlag] (bool enabled, bool isSaveBySpecifiedFlag) { + testSession->onSetWindowRectAutoSaveFunc_ = [&callbackFlag](bool enabled, bool isSaveBySpecifiedFlag) { callbackFlag += 1; }; testSession->OnSetWindowRectAutoSave(true, true); @@ -497,9 +486,7 @@ HWTEST_F(MainSessionTest, NotifyMainModalTypeChange, TestSize.Level1) info.bundleName_ = "NotifyMainModalTypeChange"; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - sceneSession->RegisterMainModalTypeChangeCallback([](bool isModal) { - return; - }); + sceneSession->RegisterMainModalTypeChangeCallback([](bool isModal) { return; }); EXPECT_NE(sceneSession->onMainModalTypeChange_, nullptr); EXPECT_EQ(WSError::WS_OK, sceneSession->NotifyMainModalTypeChange(true)); } @@ -521,9 +508,7 @@ HWTEST_F(MainSessionTest, NotifyMainModalTypeChange02, TestSize.Level1) EXPECT_EQ(testSession->NotifyMainModalTypeChange(true), WSError::WS_OK); auto callbackFlag = 1; - testSession->onMainModalTypeChange_ = [&callbackFlag] (bool isModal) { - callbackFlag += 1; - }; + testSession->onMainModalTypeChange_ = [&callbackFlag](bool isModal) { callbackFlag += 1; }; testSession->NotifyMainModalTypeChange(true); EXPECT_EQ(callbackFlag, 2); } @@ -580,19 +565,16 @@ HWTEST_F(MainSessionTest, NotifySupportWindowModesChange, TestSize.Level1) info.bundleName_ = "NotifySupportWindowModesChange"; sptr session = sptr::MakeSptr(info, nullptr); - std::vector supportedWindowModes = { - AppExecFwk::SupportWindowMode::FULLSCREEN, - AppExecFwk::SupportWindowMode::SPLIT, - AppExecFwk::SupportWindowMode::FLOATING - }; + std::vector supportedWindowModes = { AppExecFwk::SupportWindowMode::FULLSCREEN, + AppExecFwk::SupportWindowMode::SPLIT, + AppExecFwk::SupportWindowMode::FLOATING }; EXPECT_EQ(WSError::WS_OK, session->NotifySupportWindowModesChange(supportedWindowModes)); session->onSetSupportedWindowModesFunc_ = nullptr; EXPECT_EQ(WSError::WS_OK, session->NotifySupportWindowModesChange(supportedWindowModes)); - session->onSetSupportedWindowModesFunc_ = []( - std::vector&& supportedWindowModes) { + session->onSetSupportedWindowModesFunc_ = [](std::vector&& supportedWindowModes) { return; }; @@ -611,20 +593,16 @@ HWTEST_F(MainSessionTest, NotifySupportWindowModesChange02, TestSize.Level1) info.bundleName_ = "NotifySupportWindowModesChange02"; sptr testSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(testSession, nullptr); - std::vector supportedWindowModes = { - AppExecFwk::SupportWindowMode::FULLSCREEN, - AppExecFwk::SupportWindowMode::SPLIT, - AppExecFwk::SupportWindowMode::FLOATING - }; + std::vector supportedWindowModes = { AppExecFwk::SupportWindowMode::FULLSCREEN, + AppExecFwk::SupportWindowMode::SPLIT, + AppExecFwk::SupportWindowMode::FLOATING }; testSession->onSetSupportedWindowModesFunc_ = nullptr; EXPECT_EQ(testSession->NotifySupportWindowModesChange(supportedWindowModes), WSError::WS_OK); auto callbackFlag = 1; - testSession->onSetSupportedWindowModesFunc_ = [&callbackFlag] ( - std::vector&& supportedWindowModes) { - callbackFlag += 1; - }; + testSession->onSetSupportedWindowModesFunc_ = + [&callbackFlag](std::vector&& supportedWindowModes) { callbackFlag += 1; }; testSession->NotifySupportWindowModesChange(supportedWindowModes); EXPECT_EQ(callbackFlag, 2); } @@ -663,9 +641,7 @@ HWTEST_F(MainSessionTest, UpdateFlag, TestSize.Level1) session->onUpdateFlagFunc_ = nullptr; EXPECT_EQ(nullptr, session->onUpdateFlagFunc_); - NotifyUpdateFlagFunc func = [](const std::string& flag) { - return; - }; + NotifyUpdateFlagFunc func = [](const std::string& flag) { return; }; session->onUpdateFlagFunc_ = func; EXPECT_NE(nullptr, session->onUpdateFlagFunc_); } @@ -680,11 +656,9 @@ HWTEST_F(MainSessionTest, NotifySubAndDialogFollowRectChange01, TestSize.Level1) SessionInfo info; sptr subSession = sptr::MakeSptr(info, nullptr); sptr mainSession = sptr::MakeSptr(info, nullptr); - + bool isCall = false; - auto task = [&isCall](const WSRect& rect, bool isGlobal, bool needFlush) { - isCall = true; - }; + auto task = [&isCall](const WSRect& rect, bool isGlobal, bool needFlush) { isCall = true; }; mainSession->RegisterNotifySurfaceBoundsChangeFunc(subSession->GetPersistentId(), std::move(task)); ASSERT_NE(nullptr, mainSession->notifySurfaceBoundsChangeFuncMap_[subSession->GetPersistentId()]); @@ -696,13 +670,11 @@ HWTEST_F(MainSessionTest, NotifySubAndDialogFollowRectChange01, TestSize.Level1) subSession->isFollowParentLayout_ = true; sptr callBack = sptr::MakeSptr(); mainSession->specificCallback_ = callBack; - auto getSessionCallBack = [&subSession](int32_t persistentId) { - return subSession; - }; + auto getSessionCallBack = [&subSession](int32_t persistentId) { return subSession; }; callBack->onGetSceneSessionByIdCallback_ = getSessionCallBack; mainSession->NotifySubAndDialogFollowRectChange(rect, false, false); ASSERT_EQ(true, isCall); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/mock_session_manager_service_test.cpp b/window_scene/test/unittest/mock_session_manager_service_test.cpp index b2809d986a..cd37f04309 100644 --- a/window_scene/test/unittest/mock_session_manager_service_test.cpp +++ b/window_scene/test/unittest/mock_session_manager_service_test.cpp @@ -31,8 +31,10 @@ namespace Rosen { class MockMockSessionManagerService : public MockSessionManagerService { public: MOCK_METHOD(sptr, GetSceneSessionManagerByUserId, (int32_t), (override)); - MOCK_METHOD(int32_t, NotifySCBSnapshotSkipByUserIdAndBundleNames, - (int32_t, const std::vector&, const sptr&), (override)); + MOCK_METHOD(int32_t, + NotifySCBSnapshotSkipByUserIdAndBundleNames, + (int32_t, const std::vector&, const sptr&), + (override)); }; namespace { @@ -54,13 +56,13 @@ HWTEST(MockSessionManagerServiceTest, SetSnapshotSkipByUserIdAndBundleNamesInner .WillOnce(Return(ERR_TRANSACTION_FAILED)) .WillRepeatedly(Return(ERR_NONE)); - int32_t ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, {"notepad"}); + int32_t ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, { "notepad" }); EXPECT_EQ(ERR_NONE, ret); - ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, {"notepad"}); + ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, { "notepad" }); EXPECT_EQ(ERR_TRANSACTION_FAILED, ret); - ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, {"notepad"}); + ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, { "notepad" }); EXPECT_EQ(ERR_NONE, ret); } @@ -82,13 +84,13 @@ HWTEST(MockSessionManagerServiceTest, SetSnapshotSkipByIdNamesMapInner, TestSize .WillOnce(Return(ERR_TRANSACTION_FAILED)) .WillRepeatedly(Return(ERR_NONE)); - int32_t ret = mockMockSms.SetSnapshotSkipByIdNamesMapInner({{100, {"notepad"}}}); + int32_t ret = mockMockSms.SetSnapshotSkipByIdNamesMapInner({ { 100, { "notepad" } } }); EXPECT_EQ(ERR_NONE, ret); - ret = mockMockSms.SetSnapshotSkipByIdNamesMapInner({{100, {"notepad"}}}); + ret = mockMockSms.SetSnapshotSkipByIdNamesMapInner({ { 100, { "notepad" } } }); EXPECT_EQ(ERR_TRANSACTION_FAILED, ret); - ret = mockMockSms.SetSnapshotSkipByIdNamesMapInner({{100, {"notepad"}}}); + ret = mockMockSms.SetSnapshotSkipByIdNamesMapInner({ { 100, { "notepad" } } }); EXPECT_EQ(ERR_NONE, ret); } @@ -112,7 +114,7 @@ HWTEST(MockSessionManagerServiceTest, RecoverSCBSnapshotSkipByUserId, TestSize.L .WillOnce(Return(ERR_TRANSACTION_FAILED)) .WillOnce(Return(ERR_NONE)); - int32_t ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, {"notepad"}); + int32_t ret = mockMockSms.SetSnapshotSkipByUserIdAndBundleNamesInner(100, { "notepad" }); EXPECT_EQ(ERR_NONE, ret); ret = mockMockSms.RecoverSCBSnapshotSkipByUserId(-1); @@ -127,6 +129,6 @@ HWTEST(MockSessionManagerServiceTest, RecoverSCBSnapshotSkipByUserId, TestSize.L ret = mockMockSms.RecoverSCBSnapshotSkipByUserId(100); EXPECT_EQ(ERR_NONE, ret); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/move_drag_controller_test.cpp b/window_scene/test/unittest/move_drag_controller_test.cpp index 2b447e3f7d..2c0c8fc6fe 100644 --- a/window_scene/test/unittest/move_drag_controller_test.cpp +++ b/window_scene/test/unittest/move_drag_controller_test.cpp @@ -42,13 +42,9 @@ public: sptr session_; }; -void MoveDragControllerTest::SetUpTestCase() -{ -} +void MoveDragControllerTest::SetUpTestCase() {} -void MoveDragControllerTest::TearDownTestCase() -{ -} +void MoveDragControllerTest::TearDownTestCase() {} void MoveDragControllerTest::SetUp() { @@ -210,8 +206,9 @@ HWTEST_F(MoveDragControllerTest, InitCrossDisplayProperty, TestSize.Level0) moveDragController->InitCrossDisplayProperty(1, 2); ASSERT_EQ(1, moveDragController->GetMoveDragStartDisplayId()); ASSERT_EQ(2, moveDragController->GetInitParentNodeId()); - ASSERT_EQ(true, moveDragController->GetDisplayIdsDuringMoveDrag().find(1) != - moveDragController->GetDisplayIdsDuringMoveDrag().end()); + ASSERT_EQ(true, + moveDragController->GetDisplayIdsDuringMoveDrag().find(1) != + moveDragController->GetDisplayIdsDuringMoveDrag().end()); ScreenId screenId = 1; ScreenSessionConfig config; sptr screenSession = @@ -220,8 +217,9 @@ HWTEST_F(MoveDragControllerTest, InitCrossDisplayProperty, TestSize.Level0) moveDragController->InitCrossDisplayProperty(1, 2); ASSERT_EQ(1, moveDragController->GetMoveDragStartDisplayId()); ASSERT_EQ(2, moveDragController->GetInitParentNodeId()); - ASSERT_EQ(true, moveDragController->GetDisplayIdsDuringMoveDrag().find(1) != - moveDragController->GetDisplayIdsDuringMoveDrag().end()); + ASSERT_EQ(true, + moveDragController->GetDisplayIdsDuringMoveDrag().find(1) != + moveDragController->GetDisplayIdsDuringMoveDrag().end()); } /** @@ -340,9 +338,9 @@ HWTEST_F(MoveDragControllerTest, CalcMoveTargetRect, TestSize.Level1) HWTEST_F(MoveDragControllerTest, CalcMoveInputBarRect, TestSize.Level1) { moveDragController->InitMoveDragProperty(); - moveDragController->SetMoveAvailableArea({0, 75, 3120, 1980}); + moveDragController->SetMoveAvailableArea({ 0, 75, 3120, 1980 }); moveDragController->SetMoveInputBarStartDisplayId(1); - WSRect originalRect = {10, 20, 336, 146}; + WSRect originalRect = { 10, 20, 336, 146 }; std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); pointerEvent->SetTargetDisplayId(1); @@ -358,10 +356,14 @@ HWTEST_F(MoveDragControllerTest, CalcMoveInputBarRect, TestSize.Level1) int32_t pointerWindowX = 10; int32_t pointerWindowY = 10; moveDragController->SetOriginalMoveDragPos(pointerEvent->GetPointerId(), - pointerEvent->GetSourceType(), pointerPosX, pointerPosY, pointerWindowX, - pointerWindowY, originalRect); + pointerEvent->GetSourceType(), + pointerPosX, + pointerPosY, + pointerWindowX, + pointerWindowY, + originalRect); moveDragController->CalcMoveInputBarRect(pointerEvent, originalRect); - + ASSERT_EQ(90, moveDragController->moveDragProperty_.targetRect_.posX_); ASSERT_EQ(190, moveDragController->moveDragProperty_.targetRect_.posY_); } @@ -373,8 +375,8 @@ HWTEST_F(MoveDragControllerTest, CalcMoveInputBarRect, TestSize.Level1) */ HWTEST_F(MoveDragControllerTest, AdjustTargetPositionByAvailableArea, TestSize.Level1) { - DMRect moveAvailableArea = {0, 75, 3120, 1980}; - WSRect originalRect = {10, 20, 336, 146}; + DMRect moveAvailableArea = { 0, 75, 3120, 1980 }; + WSRect originalRect = { 10, 20, 336, 146 }; moveDragController->moveAvailableArea_ = moveAvailableArea; moveDragController->moveDragProperty_.originalRect_ = originalRect; @@ -746,9 +748,7 @@ HWTEST_F(MoveDragControllerTest, ProcessWindowDragHotAreaFunc, TestSize.Level1) SizeChangeReason reason = SizeChangeReason::UNDEFINED; moveDragController->ProcessWindowDragHotAreaFunc(isSendHotAreaMessage, reason); ASSERT_EQ(true, isSendHotAreaMessage); - auto dragHotAreaFunc = [](DisplayId displayId, int32_t type, SizeChangeReason reason) { - type = 0; - }; + auto dragHotAreaFunc = [](DisplayId displayId, int32_t type, SizeChangeReason reason) { type = 0; }; auto preFunc = moveDragController->windowDragHotAreaFunc_; moveDragController->windowDragHotAreaFunc_ = dragHotAreaFunc; moveDragController->ProcessWindowDragHotAreaFunc(isSendHotAreaMessage, reason); @@ -1008,8 +1008,8 @@ HWTEST_F(MoveDragControllerTest, CalcFirstMoveTargetRect001, TestSize.Level1) moveDragController->InitMoveDragProperty(); moveDragController->SetStartMoveFlag(true); moveDragController->CalcFirstMoveTargetRect(windowRect, true); - WSRect targetRect = moveDragController->GetTargetRect( - MoveDragController::TargetRectCoordinate::RELATED_TO_START_DISPLAY); + WSRect targetRect = + moveDragController->GetTargetRect(MoveDragController::TargetRectCoordinate::RELATED_TO_START_DISPLAY); ASSERT_EQ(targetRect.posX_, 0); } @@ -1033,7 +1033,7 @@ HWTEST_F(MoveDragControllerTest, GetFullScreenToFloatingRect, TestSize.Level1) ASSERT_EQ(windowRect.posX_, rect.posX_); originalRect = { 1, 2, 3, 4 }; rect = moveDragController->GetFullScreenToFloatingRect(originalRect, windowRect); - WSRect targetRect = { 1, 2, 7, 8}; + WSRect targetRect = { 1, 2, 7, 8 }; ASSERT_EQ(targetRect.posX_, rect.posX_); moveDragController->moveTempProperty_ = preMoveTempProperty; } @@ -1214,9 +1214,7 @@ HWTEST_F(MoveDragControllerTest, ProcessSessionRectChange, TestSize.Level1) int32_t res = 0; auto preCallback = moveDragController->moveDragCallback_; SizeChangeReason reason = SizeChangeReason::UNDEFINED; - MoveDragCallback callBack = [](SizeChangeReason reason) { - return; - }; + MoveDragCallback callBack = [](SizeChangeReason reason) { return; }; moveDragController->moveDragCallback_ = callBack; moveDragController->ProcessSessionRectChange(reason); moveDragController->moveDragCallback_ = nullptr; @@ -1503,8 +1501,7 @@ HWTEST_F(MoveDragControllerTest, UpdateSubWindowGravityWhenFollow01, TestSize.Le sptr followController = sptr::MakeSptr(session_->GetPersistentId(), session_->GetWindowType()); struct RSSurfaceNodeConfig rsSurfaceNodeConfig; - std::shared_ptr surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig, - RSSurfaceNodeType::DEFAULT); + std::shared_ptr surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig, RSSurfaceNodeType::DEFAULT); followController->type_ = AreaType::UNDEFINED; moveDragController->UpdateSubWindowGravityWhenFollow(nullptr, nullptr); @@ -1524,6 +1521,6 @@ HWTEST_F(MoveDragControllerTest, UpdateSubWindowGravityWhenFollow01, TestSize.Le gravityIter = surfaceNode->propertyModifiers_.find(RSModifierType::FRAME_GRAVITY); ASSERT_NE(gravityIter, surfaceNode->propertyModifiers_.end()); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/multi_instance_manager_test.cpp b/window_scene/test/unittest/multi_instance_manager_test.cpp index ce98da4228..d4be60e432 100644 --- a/window_scene/test/unittest/multi_instance_manager_test.cpp +++ b/window_scene/test/unittest/multi_instance_manager_test.cpp @@ -26,33 +26,28 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { - const std::string BUNDLE_NAME = "bundleName"; - const int32_t USER_ID { 100 }; - const int32_t SLEEP_TIME { 10000 }; -} +const std::string BUNDLE_NAME = "bundleName"; +const int32_t USER_ID{ 100 }; +const int32_t SLEEP_TIME{ 10000 }; +} // namespace class MultiInstanceManagerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: sptr GetSceneSession(const std::string& instanceKey = ""); void Init(AppExecFwk::MultiAppModeType modeType, uint32_t maxCount); std::shared_ptr GetTaskScheduler(); }; -void MultiInstanceManagerTest::SetUpTestCase() -{ -} +void MultiInstanceManagerTest::SetUpTestCase() {} -void MultiInstanceManagerTest::TearDownTestCase() -{ -} +void MultiInstanceManagerTest::TearDownTestCase() {} -void MultiInstanceManagerTest::SetUp() -{ -} +void MultiInstanceManagerTest::SetUp() {} void MultiInstanceManagerTest::TearDown() { @@ -76,16 +71,17 @@ sptr MultiInstanceManagerTest::GetSceneSession(const std::string& void MultiInstanceManagerTest::Init(AppExecFwk::MultiAppModeType modeType, uint32_t maxCount) { sptr bundleMgrMocker = sptr::MakeSptr(); - EXPECT_CALL(*bundleMgrMocker, GetApplicationInfos(_, _, _)).WillOnce([modeType, maxCount]( - const AppExecFwk::ApplicationFlag flag, const int32_t userId, - std::vector& appInfos) { - AppExecFwk::ApplicationInfo appInfo; - appInfo.bundleName = BUNDLE_NAME; - appInfo.multiAppMode.multiAppModeType = modeType; - appInfo.multiAppMode.maxCount = maxCount; - appInfos.push_back(appInfo); - return true; - }); + EXPECT_CALL(*bundleMgrMocker, GetApplicationInfos(_, _, _)) + .WillOnce([modeType, maxCount](const AppExecFwk::ApplicationFlag flag, + const int32_t userId, + std::vector& appInfos) { + AppExecFwk::ApplicationInfo appInfo; + appInfo.bundleName = BUNDLE_NAME; + appInfo.multiAppMode.multiAppModeType = modeType; + appInfo.multiAppMode.maxCount = maxCount; + appInfos.push_back(appInfo); + return true; + }); MultiInstanceManager::GetInstance().Init(bundleMgrMocker, GetTaskScheduler()); MultiInstanceManager::GetInstance().SetCurrentUserId(USER_ID); usleep(SLEEP_TIME); @@ -374,6 +370,6 @@ HWTEST_F(MultiInstanceManagerTest, IsInstanceKeyExist, TestSize.Level1) MultiInstanceManager::GetInstance().DecreaseInstanceKeyRefCount(sceneSession); MultiInstanceManager::GetInstance().DecreaseInstanceKeyRefCount(sceneSession3); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/multi_user/session_manager_lite_test.cpp b/window_scene/test/unittest/multi_user/session_manager_lite_test.cpp index a929555017..14290f56d2 100644 --- a/window_scene/test/unittest/multi_user/session_manager_lite_test.cpp +++ b/window_scene/test/unittest/multi_user/session_manager_lite_test.cpp @@ -26,6 +26,7 @@ class SessionManagerLiteTest : public Test { public: void SetUp() override; void TearDown() override; + private: std::shared_ptr sml_; }; diff --git a/window_scene/test/unittest/multi_user/session_manager_test.cpp b/window_scene/test/unittest/multi_user/session_manager_test.cpp index dd1d259f83..96ae71623f 100644 --- a/window_scene/test/unittest/multi_user/session_manager_test.cpp +++ b/window_scene/test/unittest/multi_user/session_manager_test.cpp @@ -27,6 +27,7 @@ class SessionManagerTest : public Test { public: void SetUp() override; void TearDown() override; + private: std::shared_ptr sm_; }; @@ -151,7 +152,6 @@ HWTEST_F(SessionManagerTest, RegisterUserSwitchListener, Function | SmallTest | ASSERT_NE(sm_->userSwitchCallbackFunc_, nullptr); } - /** * @tc.name: OnUserSwitch * @tc.desc: normal function diff --git a/window_scene/test/unittest/pc_fold_screen_controller_test.cpp b/window_scene/test/unittest/pc_fold_screen_controller_test.cpp index 5ac1476f59..9ccb6fb778 100644 --- a/window_scene/test/unittest/pc_fold_screen_controller_test.cpp +++ b/window_scene/test/unittest/pc_fold_screen_controller_test.cpp @@ -30,12 +30,15 @@ namespace OHOS { namespace Rosen { namespace { - std::string g_errLog; - void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, - const char *msg) - { - g_errLog = msg; - } +std::string g_errLog; +void MyLogCallback(const LogType type, + const LogLevel level, + const unsigned int domain, + const char* tag, + const char* msg) +{ + g_errLog = msg; +} // screen const constexpr int32_t SCREEN_WIDTH = 2472; constexpr int32_t SCREEN_HEIGHT = 3296; @@ -50,9 +53,13 @@ const WSRect DEFAULT_DISPLAY_RECT = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT_HALF }; const WSRect VIRTUAL_DISPLAY_RECT = { 0, SCREEN_HEIGHT_HALF, SCREEN_WIDTH, SCREEN_HEIGHT_HALF }; const WSRect FOLD_CREASE_RECT = { 0, SCREEN_HEIGHT_HALF - CREASE_HEIGHT / 2, SCREEN_WIDTH, CREASE_HEIGHT }; const WSRect ZERO_RECT = { 0, 0, 0, 0 }; -const WSRect DEFAULT_FULLSCREEN_RECT = { 0, TOP_AVOID_HEIGHT, SCREEN_WIDTH, - SCREEN_HEIGHT_HALF - CREASE_HEIGHT / 2 - TOP_AVOID_HEIGHT}; -const WSRect VIRTUAL_FULLSCREEN_RECT = { 0, SCREEN_HEIGHT_HALF + CREASE_HEIGHT / 2, SCREEN_WIDTH, +const WSRect DEFAULT_FULLSCREEN_RECT = { 0, + TOP_AVOID_HEIGHT, + SCREEN_WIDTH, + SCREEN_HEIGHT_HALF - CREASE_HEIGHT / 2 - TOP_AVOID_HEIGHT }; +const WSRect VIRTUAL_FULLSCREEN_RECT = { 0, + SCREEN_HEIGHT_HALF + CREASE_HEIGHT / 2, + SCREEN_WIDTH, SCREEN_HEIGHT_HALF - CREASE_HEIGHT / 2 - BOT_AVOID_HEIGHT }; // test rects @@ -64,8 +71,8 @@ const WSRect C_ACROSS_RECT = { 400, SCREEN_HEIGHT_HALF - 100, 400, 400 }; const WSRect C_BOT_RECT = { 400, SCREEN_HEIGHT - 100, 400, 400 }; // arrange rule -constexpr int32_t RULE_TRANS_X = 48; // dp -constexpr int32_t MIN_DECOR_HEIGHT = 37; // dp +constexpr int32_t RULE_TRANS_X = 48; // dp +constexpr int32_t MIN_DECOR_HEIGHT = 37; // dp constexpr int32_t MAX_DECOR_HEIGHT = 112; // dp // velocity test @@ -94,33 +101,26 @@ public: PcFoldScreenManager& PcFoldScreenManagerTest::manager_ = PcFoldScreenManager::GetInstance(); -void PcFoldScreenManagerTest::SetUpTestCase() -{ -} +void PcFoldScreenManagerTest::SetUpTestCase() {} -void PcFoldScreenManagerTest::TearDownTestCase() -{ -} +void PcFoldScreenManagerTest::TearDownTestCase() {} void PcFoldScreenManagerTest::SetUp() { SetExpanded(); } -void PcFoldScreenManagerTest::TearDown() -{ -} +void PcFoldScreenManagerTest::TearDown() {} void PcFoldScreenManagerTest::SetHalfFolded() { - manager_.UpdateFoldScreenStatus(DEFAULT_SCREEN_ID, SuperFoldStatus::HALF_FOLDED, - DEFAULT_DISPLAY_RECT, VIRTUAL_DISPLAY_RECT, FOLD_CREASE_RECT); + manager_.UpdateFoldScreenStatus( + DEFAULT_SCREEN_ID, SuperFoldStatus::HALF_FOLDED, DEFAULT_DISPLAY_RECT, VIRTUAL_DISPLAY_RECT, FOLD_CREASE_RECT); } void PcFoldScreenManagerTest::SetExpanded() { - manager_.UpdateFoldScreenStatus(DEFAULT_SCREEN_ID, SuperFoldStatus::EXPANDED, - DISPLAY_RECT, ZERO_RECT, ZERO_RECT); + manager_.UpdateFoldScreenStatus(DEFAULT_SCREEN_ID, SuperFoldStatus::EXPANDED, DISPLAY_RECT, ZERO_RECT, ZERO_RECT); } class PcFoldScreenControllerTest : public testing::Test { @@ -140,13 +140,9 @@ public: PcFoldScreenManager& PcFoldScreenControllerTest::manager_ = PcFoldScreenManager::GetInstance(); -void PcFoldScreenControllerTest::SetUpTestCase() -{ -} +void PcFoldScreenControllerTest::SetUpTestCase() {} -void PcFoldScreenControllerTest::TearDownTestCase() -{ -} +void PcFoldScreenControllerTest::TearDownTestCase() {} void PcFoldScreenControllerTest::SetUp() { @@ -172,14 +168,13 @@ void PcFoldScreenControllerTest::TearDown() void PcFoldScreenControllerTest::SetHalfFolded() { - manager_.UpdateFoldScreenStatus(DEFAULT_SCREEN_ID, SuperFoldStatus::HALF_FOLDED, - DEFAULT_DISPLAY_RECT, VIRTUAL_DISPLAY_RECT, FOLD_CREASE_RECT); + manager_.UpdateFoldScreenStatus( + DEFAULT_SCREEN_ID, SuperFoldStatus::HALF_FOLDED, DEFAULT_DISPLAY_RECT, VIRTUAL_DISPLAY_RECT, FOLD_CREASE_RECT); } void PcFoldScreenControllerTest::SetExpanded() { - manager_.UpdateFoldScreenStatus(DEFAULT_SCREEN_ID, SuperFoldStatus::EXPANDED, - DISPLAY_RECT, ZERO_RECT, ZERO_RECT); + manager_.UpdateFoldScreenStatus(DEFAULT_SCREEN_ID, SuperFoldStatus::EXPANDED, DISPLAY_RECT, ZERO_RECT, ZERO_RECT); } /** @@ -362,21 +357,21 @@ HWTEST_F(PcFoldScreenManagerTest, NeedDoEasyThrowSlip, TestSize.Level1) SetHalfFolded(); // side B cross axis WSRect startRectB = { 100, 100, 100, 20 }; - WSRect rectB = { 100, SCREEN_HEIGHT_HALF + 90, 100, 20}; + WSRect rectB = { 100, SCREEN_HEIGHT_HALF + 90, 100, 20 }; ScreenSide throwSide = ScreenSide::FOLD_C; EXPECT_TRUE(manager_.NeedDoEasyThrowSlip(rectB, startRectB, B_VELOCITY, throwSide)); EXPECT_EQ(ScreenSide::FOLD_B, throwSide); - rectB = { 100, SCREEN_HEIGHT - 110, 100, 20}; + rectB = { 100, SCREEN_HEIGHT - 110, 100, 20 }; throwSide = ScreenSide::FOLD_C; EXPECT_FALSE(manager_.NeedDoEasyThrowSlip(rectB, startRectB, B_VELOCITY, throwSide)); EXPECT_EQ(ScreenSide::FOLD_C, throwSide); // side C cross axis WSRect startRectC = { 100, SCREEN_HEIGHT - 100, 100, 20 }; - WSRect rectC = { 100, SCREEN_HEIGHT_HALF - 110, 100, 20}; + WSRect rectC = { 100, SCREEN_HEIGHT_HALF - 110, 100, 20 }; throwSide = ScreenSide::FOLD_B; EXPECT_TRUE(manager_.NeedDoEasyThrowSlip(rectC, startRectC, C_VELOCITY, throwSide)); EXPECT_EQ(ScreenSide::FOLD_C, throwSide); - rectC = { 100, 90, 100, 20}; + rectC = { 100, 90, 100, 20 }; throwSide = ScreenSide::FOLD_B; EXPECT_FALSE(manager_.NeedDoEasyThrowSlip(rectC, startRectC, C_VELOCITY, throwSide)); EXPECT_EQ(ScreenSide::FOLD_B, throwSide); @@ -411,16 +406,16 @@ HWTEST_F(PcFoldScreenManagerTest, CalculateThrowBacktracingRect, TestSize.Level1 { SetHalfFolded(); // side B - WSRect rectB = { 100, SCREEN_HEIGHT_HALF + 90, 100, 20}; + WSRect rectB = { 100, SCREEN_HEIGHT_HALF + 90, 100, 20 }; EXPECT_EQ(ScreenSide::FOLD_B, - manager_.CalculateScreenSide(manager_.CalculateThrowBacktracingRect(rectB, B_VELOCITY))); - rectB = { 100, SCREEN_HEIGHT - 110, 100, 20}; + manager_.CalculateScreenSide(manager_.CalculateThrowBacktracingRect(rectB, B_VELOCITY))); + rectB = { 100, SCREEN_HEIGHT - 110, 100, 20 }; EXPECT_EQ(rectB, manager_.CalculateThrowBacktracingRect(rectB, B_VELOCITY)); // side C - WSRect rectC = { 100, SCREEN_HEIGHT_HALF - 110, 100, 20}; + WSRect rectC = { 100, SCREEN_HEIGHT_HALF - 110, 100, 20 }; EXPECT_EQ(ScreenSide::FOLD_C, - manager_.CalculateScreenSide(manager_.CalculateThrowBacktracingRect(rectC, C_VELOCITY))); - rectC = { 100, 90, 100, 20}; + manager_.CalculateScreenSide(manager_.CalculateThrowBacktracingRect(rectC, C_VELOCITY))); + rectC = { 100, 90, 100, 20 }; EXPECT_EQ(rectC, manager_.CalculateThrowBacktracingRect(rectC, C_VELOCITY)); } @@ -519,24 +514,23 @@ HWTEST_F(PcFoldScreenManagerTest, MappingRectInScreenSideWithArrangeRule1, TestS // init arrange rule manager_.defaultArrangedRect_ = ZERO_RECT; rect = B_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); const int32_t centerBX = (DEFAULT_DISPLAY_RECT.width_ - B_RECT.width_) / 2; const int32_t centerBY = TOP_AVOID_HEIGHT + (FOLD_CREASE_RECT.posY_ - TOP_AVOID_HEIGHT - B_RECT.height_) / 2; - EXPECT_EQ(rect, (WSRect { centerBX, centerBY, B_RECT.width_, B_RECT.height_ })); - EXPECT_EQ(manager_.defaultArrangedRect_, - (WSRect { centerBX, centerBY, RULE_TRANS_X * vpr, decorHeight * vpr })); + EXPECT_EQ(rect, (WSRect{ centerBX, centerBY, B_RECT.width_, B_RECT.height_ })); + EXPECT_EQ(manager_.defaultArrangedRect_, (WSRect{ centerBX, centerBY, RULE_TRANS_X * vpr, decorHeight * vpr })); manager_.virtualArrangedRect_ = ZERO_RECT; rect = C_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); const int32_t centerCX = (VIRTUAL_DISPLAY_RECT.width_ - C_RECT.width_) / 2; - const int32_t centerCY = FOLD_CREASE_RECT.posY_ + FOLD_CREASE_RECT.height_ + + const int32_t centerCY = + FOLD_CREASE_RECT.posY_ + FOLD_CREASE_RECT.height_ + (SCREEN_HEIGHT - FOLD_CREASE_RECT.posY_ - FOLD_CREASE_RECT.height_ - BOT_AVOID_HEIGHT - C_RECT.height_) / 2; - EXPECT_EQ(rect, (WSRect { centerCX, centerCY, C_RECT.width_, C_RECT.height_ })); - EXPECT_EQ(manager_.virtualArrangedRect_, - (WSRect { centerCX, centerCY, RULE_TRANS_X * vpr, decorHeight * vpr })); + EXPECT_EQ(rect, (WSRect{ centerCX, centerCY, C_RECT.width_, C_RECT.height_ })); + EXPECT_EQ(manager_.virtualArrangedRect_, (WSRect{ centerCX, centerCY, RULE_TRANS_X * vpr, decorHeight * vpr })); } /** @@ -553,23 +547,25 @@ HWTEST_F(PcFoldScreenManagerTest, MappingRectInScreenSideWithArrangeRule2, TestS WSRect rect = B_RECT; // normal arrange rule - manager_.defaultArrangedRect_ = WSRect { 100, 100, RULE_TRANS_X * vpr, 100 * vpr }; + manager_.defaultArrangedRect_ = WSRect{ 100, 100, RULE_TRANS_X * vpr, 100 * vpr }; rect = B_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); - EXPECT_EQ(rect, (WSRect { 100 + RULE_TRANS_X * vpr, 100 + 100 * vpr, B_RECT.width_, B_RECT.height_ })); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); + EXPECT_EQ(rect, (WSRect{ 100 + RULE_TRANS_X * vpr, 100 + 100 * vpr, B_RECT.width_, B_RECT.height_ })); EXPECT_EQ(manager_.defaultArrangedRect_, - (WSRect { 100 + RULE_TRANS_X * vpr, 100 + 100 * vpr, RULE_TRANS_X * vpr, decorHeight * vpr })); + (WSRect{ 100 + RULE_TRANS_X * vpr, 100 + 100 * vpr, RULE_TRANS_X * vpr, decorHeight * vpr })); - manager_.virtualArrangedRect_ = WSRect { 100, SCREEN_HEIGHT_HALF + 100, RULE_TRANS_X * vpr, 100 * vpr }; + manager_.virtualArrangedRect_ = WSRect{ 100, SCREEN_HEIGHT_HALF + 100, RULE_TRANS_X * vpr, 100 * vpr }; rect = C_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); - EXPECT_EQ(rect, - (WSRect { 100 + RULE_TRANS_X * vpr, SCREEN_HEIGHT_HALF + 100 + 100 * vpr, C_RECT.width_, C_RECT.height_ })); - EXPECT_EQ(manager_.virtualArrangedRect_, - (WSRect { 100 + RULE_TRANS_X * vpr, SCREEN_HEIGHT_HALF + 100 + 100 * vpr, - RULE_TRANS_X * vpr, decorHeight * vpr })); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); + EXPECT_EQ( + rect, + (WSRect{ 100 + RULE_TRANS_X * vpr, SCREEN_HEIGHT_HALF + 100 + 100 * vpr, C_RECT.width_, C_RECT.height_ })); + EXPECT_EQ( + manager_.virtualArrangedRect_, + (WSRect{ + 100 + RULE_TRANS_X * vpr, SCREEN_HEIGHT_HALF + 100 + 100 * vpr, RULE_TRANS_X * vpr, decorHeight * vpr })); } /** @@ -587,39 +583,36 @@ HWTEST_F(PcFoldScreenManagerTest, MappingRectInScreenSideWithArrangeRule3, TestS int32_t virtualPosY = FOLD_CREASE_RECT.posY_ + FOLD_CREASE_RECT.height_; // new column rule - manager_.defaultArrangedRect_ = WSRect { 100, SCREEN_HEIGHT_HALF - 200, RULE_TRANS_X * vpr, 100 * vpr }; + manager_.defaultArrangedRect_ = WSRect{ 100, SCREEN_HEIGHT_HALF - 200, RULE_TRANS_X * vpr, 100 * vpr }; rect = B_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); - EXPECT_EQ(rect, (WSRect { 100 + RULE_TRANS_X * vpr, TOP_AVOID_HEIGHT, B_RECT.width_, B_RECT.height_ })); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); + EXPECT_EQ(rect, (WSRect{ 100 + RULE_TRANS_X * vpr, TOP_AVOID_HEIGHT, B_RECT.width_, B_RECT.height_ })); EXPECT_EQ(manager_.defaultArrangedRect_, - (WSRect { 100 + RULE_TRANS_X * vpr, TOP_AVOID_HEIGHT, RULE_TRANS_X * vpr, decorHeight * vpr })); + (WSRect{ 100 + RULE_TRANS_X * vpr, TOP_AVOID_HEIGHT, RULE_TRANS_X * vpr, decorHeight * vpr })); - manager_.virtualArrangedRect_ = WSRect { 100, SCREEN_HEIGHT - 200, RULE_TRANS_X * vpr, 100 * vpr }; + manager_.virtualArrangedRect_ = WSRect{ 100, SCREEN_HEIGHT - 200, RULE_TRANS_X * vpr, 100 * vpr }; rect = C_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); - EXPECT_EQ(rect, - (WSRect { 100 + RULE_TRANS_X * vpr, virtualPosY, C_RECT.width_, C_RECT.height_ })); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); + EXPECT_EQ(rect, (WSRect{ 100 + RULE_TRANS_X * vpr, virtualPosY, C_RECT.width_, C_RECT.height_ })); EXPECT_EQ(manager_.virtualArrangedRect_, - (WSRect { 100 + RULE_TRANS_X * vpr, virtualPosY, RULE_TRANS_X * vpr, decorHeight * vpr })); + (WSRect{ 100 + RULE_TRANS_X * vpr, virtualPosY, RULE_TRANS_X * vpr, decorHeight * vpr })); // reset rule - manager_.defaultArrangedRect_ = WSRect { SCREEN_WIDTH - 200, 100, RULE_TRANS_X * vpr, 100 * vpr }; + manager_.defaultArrangedRect_ = WSRect{ SCREEN_WIDTH - 200, 100, RULE_TRANS_X * vpr, 100 * vpr }; rect = B_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); - EXPECT_EQ(rect, (WSRect { 0, TOP_AVOID_HEIGHT, B_RECT.width_, B_RECT.height_ })); - EXPECT_EQ(manager_.defaultArrangedRect_, - (WSRect { 0, TOP_AVOID_HEIGHT, RULE_TRANS_X * vpr, decorHeight * vpr })); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_B, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); + EXPECT_EQ(rect, (WSRect{ 0, TOP_AVOID_HEIGHT, B_RECT.width_, B_RECT.height_ })); + EXPECT_EQ(manager_.defaultArrangedRect_, (WSRect{ 0, TOP_AVOID_HEIGHT, RULE_TRANS_X * vpr, decorHeight * vpr })); - manager_.virtualArrangedRect_ = WSRect { SCREEN_WIDTH - 200, 100, RULE_TRANS_X * vpr, 100 * vpr }; + manager_.virtualArrangedRect_ = WSRect{ SCREEN_WIDTH - 200, 100, RULE_TRANS_X * vpr, 100 * vpr }; rect = C_RECT; - manager_.MappingRectInScreenSideWithArrangeRule(ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, - decorHeight); - EXPECT_EQ(rect, (WSRect { 0, virtualPosY, C_RECT.width_, C_RECT.height_ })); - EXPECT_EQ(manager_.virtualArrangedRect_, - (WSRect { 0, virtualPosY, RULE_TRANS_X * vpr, decorHeight * vpr })); + manager_.MappingRectInScreenSideWithArrangeRule( + ScreenSide::FOLD_C, rect, TOP_AVOID_HEIGHT, BOT_AVOID_HEIGHT, decorHeight); + EXPECT_EQ(rect, (WSRect{ 0, virtualPosY, C_RECT.width_, C_RECT.height_ })); + EXPECT_EQ(manager_.virtualArrangedRect_, (WSRect{ 0, virtualPosY, RULE_TRANS_X * vpr, decorHeight * vpr })); } /** @@ -634,8 +627,7 @@ HWTEST_F(PcFoldScreenManagerTest, RegisterFoldScreenStatusChangeCallback, TestSi EXPECT_EQ(callbacks.size(), 0); int32_t persistentId = 100; auto func = std::make_shared( - [](DisplayId displayId, SuperFoldStatus status, SuperFoldStatus prevStatus) {} - ); + [](DisplayId displayId, SuperFoldStatus status, SuperFoldStatus prevStatus) {}); manager_.RegisterFoldScreenStatusChangeCallback(persistentId, std::weak_ptr(func)); EXPECT_NE(callbacks.find(persistentId), callbacks.end()); manager_.UnregisterFoldScreenStatusChangeCallback(persistentId); @@ -657,13 +649,12 @@ HWTEST_F(PcFoldScreenManagerTest, ExecuteFoldScreenStatusChangeCallbacks, TestSi SuperFoldStatus testStatus = SuperFoldStatus::UNKNOWN; SuperFoldStatus testPrevStatus = SuperFoldStatus::UNKNOWN; auto func = std::make_shared( - [&testDisplayId, &testStatus, &testPrevStatus](DisplayId displayId, - SuperFoldStatus status, SuperFoldStatus prevStatus) { + [&testDisplayId, &testStatus, &testPrevStatus]( + DisplayId displayId, SuperFoldStatus status, SuperFoldStatus prevStatus) { testDisplayId = displayId; testStatus = status; testPrevStatus = prevStatus; - } - ); + }); manager_.RegisterFoldScreenStatusChangeCallback(persistentId, std::weak_ptr(func)); EXPECT_NE(callbacks.find(persistentId), callbacks.end()); manager_.ExecuteFoldScreenStatusChangeCallbacks(100, SuperFoldStatus::EXPANDED, SuperFoldStatus::HALF_FOLDED); @@ -683,11 +674,10 @@ HWTEST_F(PcFoldScreenManagerTest, RegisterSystemKeyboardStatusChangeCallback, Te callbacks.clear(); EXPECT_EQ(callbacks.size(), 0); int32_t persistentId = 100; - auto func = std::make_shared( - [](DisplayId displayId, bool hasSystemKeyboard) {} - ); + auto func = + std::make_shared([](DisplayId displayId, bool hasSystemKeyboard) {}); manager_.RegisterSystemKeyboardStatusChangeCallback(persistentId, - std::weak_ptr(func)); + std::weak_ptr(func)); EXPECT_NE(callbacks.find(persistentId), callbacks.end()); manager_.UnregisterSystemKeyboardStatusChangeCallback(persistentId); EXPECT_EQ(callbacks.find(persistentId), callbacks.end()); @@ -710,10 +700,9 @@ HWTEST_F(PcFoldScreenManagerTest, ExecuteSystemKeyboardStatusChangeCallbacks, Te [&testDisplayId, &testStatus](DisplayId displayId, bool hasSystemKeyboard) { testDisplayId = displayId; testStatus = hasSystemKeyboard; - } - ); + }); manager_.RegisterSystemKeyboardStatusChangeCallback(persistentId, - std::weak_ptr(func)); + std::weak_ptr(func)); EXPECT_NE(callbacks.find(persistentId), callbacks.end()); manager_.ExecuteSystemKeyboardStatusChangeCallbacks(100, true); EXPECT_EQ(testDisplayId, 100); @@ -731,6 +720,18 @@ HWTEST_F(PcFoldScreenManagerTest, GetVpr, TestSize.Level1) EXPECT_TRUE(MathHelper::NearZero(manager_.GetVpr() - 1.0)); } +/** + * @tc.name: GetVirtualDisplayPosY + * @tc.desc: test function : GetVirtualDisplayPosY + * @tc.type: FUNC + */ +HWTEST_F(PcFoldScreenManagerTest, GetVirtualDisplayPosY, Function | SmallTest | Level2) +{ + manager_.SetDisplayRects(DISPLAY_RECT, ZERO_RECT, ZERO_RECT); + const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = manager_.GetDisplayRects(); + EXPECT_EQ(defaultDisplayRect.posY_ + foldCreaseRect.posY_, manager_.GetVirtualDisplayPosY()); +} + /** * @tc.name: IsAllowThrowSlip * @tc.desc: test function : IsAllowThrowSlip, IsStartFullScreen @@ -995,9 +996,7 @@ HWTEST_F(PcFoldScreenControllerTest, RegisterFullScreenWaterfallModeChangeCallba // register and execute controller_->isFullScreenWaterfallMode_ = true; bool testWaterfallMode = false; - auto func2 = [&testWaterfallMode](bool isWaterfallMode) { - testWaterfallMode = isWaterfallMode; - }; + auto func2 = [&testWaterfallMode](bool isWaterfallMode) { testWaterfallMode = isWaterfallMode; }; controller_->RegisterFullScreenWaterfallModeChangeCallback(std::move(func2)); ASSERT_NE(controller_->fullScreenWaterfallModeChangeCallback_, nullptr); EXPECT_TRUE(testWaterfallMode); @@ -1133,6 +1132,6 @@ HWTEST_F(PcFoldScreenControllerTest, IsSupportEnterWaterfallMode, TestSize.Level EXPECT_FALSE(controller_->IsSupportEnterWaterfallMode(SuperFoldStatus::HALF_FOLDED, true)); EXPECT_FALSE(controller_->IsSupportEnterWaterfallMode(SuperFoldStatus::EXPANDED, false)); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/root_scene_session_test.cpp b/window_scene/test/unittest/root_scene_session_test.cpp index 0b7ec0b453..3ca9e474f5 100644 --- a/window_scene/test/unittest/root_scene_session_test.cpp +++ b/window_scene/test/unittest/root_scene_session_test.cpp @@ -34,9 +34,7 @@ public: sptr RootSceneSessionTest::ssm_ = nullptr; -void LoadContentFuncTest(const std::string&, napi_env, napi_value, AbilityRuntime::Context*) -{ -} +void LoadContentFuncTest(const std::string&, napi_env, napi_value, AbilityRuntime::Context*) {} void RootSceneSessionTest::SetUpTestCase() { @@ -48,13 +46,9 @@ void RootSceneSessionTest::TearDownTestCase() ssm_ = nullptr; } -void RootSceneSessionTest::SetUp() -{ -} +void RootSceneSessionTest::SetUp() {} -void RootSceneSessionTest::TearDown() -{ -} +void RootSceneSessionTest::TearDown() {} namespace { /** @@ -204,8 +198,8 @@ HWTEST_F(RootSceneSessionTest, GetAvoidAreaByType, TestSize.Level1) EXPECT_TRUE(avoidArea.isEmptyAvoidArea()); avoidArea = ssm_->rootSceneSession_->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD, { 0, 0, 0, 0 }, 1); EXPECT_TRUE(avoidArea.isEmptyAvoidArea()); - avoidArea = ssm_->rootSceneSession_->GetAvoidAreaByType( - AvoidAreaType::TYPE_NAVIGATION_INDICATOR, { 0, 0, 0, 0 }, 1); + avoidArea = + ssm_->rootSceneSession_->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR, { 0, 0, 0, 0 }, 1); EXPECT_TRUE(avoidArea.isEmptyAvoidArea()); avoidArea = ssm_->rootSceneSession_->GetAvoidAreaByType(AvoidAreaType::TYPE_END, { 0, 0, 0, 0 }, 1); EXPECT_TRUE(avoidArea.isEmptyAvoidArea()); @@ -273,7 +267,7 @@ HWTEST_F(RootSceneSessionTest, GetKeyboardAvoidAreaForRoot_01, TestSize.Level1) keyboardSession->winRect_ = { 0, 1700, 1260, 1020 }; keyboardSession->property_->SetPersistentId(2); keyboardSession->isVisible_ = true; - ssm_->sceneSessionMap_.insert({keyboardSession->GetPersistentId(), keyboardSession}); + ssm_->sceneSessionMap_.insert({ keyboardSession->GetPersistentId(), keyboardSession }); AvoidArea avoidArea; ssm_->rootSceneSession_->GetKeyboardAvoidAreaForRoot(ssm_->rootSceneSession_->winRect_, avoidArea); Rect rect = { 0, 1700, 1260, 1020 }; @@ -313,9 +307,7 @@ HWTEST_F(RootSceneSessionTest, GetAINavigationBarAreaForRoot_01, TestSize.Level1 { ASSERT_NE(nullptr, ssm_); auto specificCb = sptr::MakeSptr(); - specificCb->onGetAINavigationBarArea_ = [](uint64_t displayId) { - return ssm_->GetAINavigationBarArea(displayId); - }; + specificCb->onGetAINavigationBarArea_ = [](uint64_t displayId) { return ssm_->GetAINavigationBarArea(displayId); }; ssm_->rootSceneSession_ = sptr::MakeSptr(specificCb); ssm_->rootSceneSession_->winRect_ = { 0, 0, 1260, 2720 }; AvoidArea avoidArea; @@ -361,6 +353,6 @@ HWTEST_F(RootSceneSessionTest, UpdateAvoidArea_01, TestSize.Level1) auto ret = ssm_->rootSceneSession_->UpdateAvoidArea(new AvoidArea(avoidArea), AvoidAreaType::TYPE_SYSTEM); ASSERT_EQ(ret, WSError::WS_OK); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/rotation/scene_session_manager_rotation_test.cpp b/window_scene/test/unittest/rotation/scene_session_manager_rotation_test.cpp index 34e44ab326..4a0bac01ab 100644 --- a/window_scene/test/unittest/rotation/scene_session_manager_rotation_test.cpp +++ b/window_scene/test/unittest/rotation/scene_session_manager_rotation_test.cpp @@ -39,32 +39,25 @@ public: void InitTestSceneSessionForListWindowInfo(); static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; sptr SceneSessionManagerAnimationTest::ssm_ = nullptr; -void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) -{ -} +void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) {} bool TraverseFuncTest(const sptr& session) { return true; } -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} -void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) -{ -} +void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) {} void SceneSessionManagerAnimationTest::SetUpTestCase() { @@ -76,9 +69,7 @@ void SceneSessionManagerAnimationTest::TearDownTestCase() ssm_ = nullptr; } -void SceneSessionManagerAnimationTest::SetUp() -{ -} +void SceneSessionManagerAnimationTest::SetUp() {} void SceneSessionManagerAnimationTest::TearDown() { @@ -86,7 +77,10 @@ void SceneSessionManagerAnimationTest::TearDown() } void SceneSessionManagerAnimationTest::InitTestSceneSession(DisplayId displayId, - int32_t windowId, int32_t zOrder, bool visible, WSRect rect) + int32_t windowId, + int32_t zOrder, + bool visible, + WSRect rect) { SessionInfo info; info.bundleName_ = "root"; @@ -97,7 +91,7 @@ void SceneSessionManagerAnimationTest::InitTestSceneSession(DisplayId displayId, sceneSession->SetRSVisible(visible); sceneSession->SetSessionRect(rect); sceneSession->property_->SetDisplayId(displayId); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); EXPECT_EQ(windowId, sceneSession->GetPersistentId()); } @@ -177,6 +171,6 @@ HWTEST_F(SceneSessionManagerAnimationTest, TestUpdateRotateAnimationConfig_02, T usleep(WAIT_SYNC_IN_NS); ASSERT_EQ(ssm_->rotateAnimationConfig_.duration_, 600); } -} // namespace -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/rotation/scene_session_rotation_test.cpp b/window_scene/test/unittest/rotation/scene_session_rotation_test.cpp index 02e00e8f7f..5be2067669 100644 --- a/window_scene/test/unittest/rotation/scene_session_rotation_test.cpp +++ b/window_scene/test/unittest/rotation/scene_session_rotation_test.cpp @@ -46,21 +46,13 @@ public: void TearDown() override; }; -void SceneSessionRotationTest::SetUpTestCase() -{ -} +void SceneSessionRotationTest::SetUpTestCase() {} -void SceneSessionRotationTest::TearDownTestCase() -{ -} +void SceneSessionRotationTest::TearDownTestCase() {} -void SceneSessionRotationTest::SetUp() -{ -} +void SceneSessionRotationTest::SetUp() {} -void SceneSessionRotationTest::TearDown() -{ -} +void SceneSessionRotationTest::TearDown() {} namespace { /** @@ -105,6 +97,6 @@ HWTEST_F(SceneSessionRotationTest, SetDefaultRequestedOrientation, TestSize.Leve ret = sceneSession->GetRequestedOrientation(); ASSERT_EQ(orientation, ret); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/rotation/session_stage_proxy_rotation_test.cpp b/window_scene/test/unittest/rotation/session_stage_proxy_rotation_test.cpp index b8e58c5021..fc25b2262d 100644 --- a/window_scene/test/unittest/rotation/session_stage_proxy_rotation_test.cpp +++ b/window_scene/test/unittest/rotation/session_stage_proxy_rotation_test.cpp @@ -40,21 +40,13 @@ public: sptr sessionStage_ = sptr::MakeSptr(iRemoteObjectMocker); }; -void SessionStageProxyRotationTest::SetUpTestCase() -{ -} +void SessionStageProxyRotationTest::SetUpTestCase() {} -void SessionStageProxyRotationTest::TearDownTestCase() -{ -} +void SessionStageProxyRotationTest::TearDownTestCase() {} -void SessionStageProxyRotationTest::SetUp() -{ -} +void SessionStageProxyRotationTest::SetUp() {} -void SessionStageProxyRotationTest::TearDown() -{ -} +void SessionStageProxyRotationTest::TearDown() {} namespace { /** @@ -62,13 +54,13 @@ namespace { * @tc.desc: test function : SetCurrentRotation * @tc.type: FUNC */ - HWTEST_F(SessionStageProxyRotationTest, SetCurrentRotation, TestSize.Level1) +HWTEST_F(SessionStageProxyRotationTest, SetCurrentRotation, TestSize.Level1) { int32_t currentRotation = 90; ASSERT_TRUE(sessionStage_ != nullptr); WSError res = sessionStage_->SetCurrentRotation(currentRotation); ASSERT_EQ(WSError::WS_OK, res); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/rotation/session_stage_stub_rotation_test.cpp b/window_scene/test/unittest/rotation/session_stage_stub_rotation_test.cpp index 88a54d82f2..c1127adbb9 100644 --- a/window_scene/test/unittest/rotation/session_stage_stub_rotation_test.cpp +++ b/window_scene/test/unittest/rotation/session_stage_stub_rotation_test.cpp @@ -43,21 +43,13 @@ public: sptr sessionStageStub_ = sptr::MakeSptr(); }; -void SessionStageStubRotationTest::SetUpTestCase() -{ -} +void SessionStageStubRotationTest::SetUpTestCase() {} -void SessionStageStubRotationTest::TearDownTestCase() -{ -} +void SessionStageStubRotationTest::TearDownTestCase() {} -void SessionStageStubRotationTest::SetUp() -{ -} +void SessionStageStubRotationTest::SetUp() {} -void SessionStageStubRotationTest::TearDown() -{ -} +void SessionStageStubRotationTest::TearDown() {} namespace { /** @@ -81,6 +73,6 @@ HWTEST_F(SessionStageStubRotationTest, HandleSetCurrentRotation, TestSize.Level1 data.WriteInt32(ONE_FOURTH_FULL_CIRCLE_DEGREE); EXPECT_EQ(ERR_NONE, sessionStageStub_->HandleSetCurrentRotation(data, reply)); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/rotation/window_session_property_rotation_test.cpp b/window_scene/test/unittest/rotation/window_session_property_rotation_test.cpp index e576188f24..d13920b080 100644 --- a/window_scene/test/unittest/rotation/window_session_property_rotation_test.cpp +++ b/window_scene/test/unittest/rotation/window_session_property_rotation_test.cpp @@ -28,13 +28,9 @@ public: static void TearDownTestCase(); }; -void WindowSessionPropertyRotationTest::SetUpTestCase() -{ -} +void WindowSessionPropertyRotationTest::SetUpTestCase() {} -void WindowSessionPropertyRotationTest::TearDownTestCase() -{ -} +void WindowSessionPropertyRotationTest::TearDownTestCase() {} namespace { /** diff --git a/window_scene/test/unittest/scb_system_session_layout_test.cpp b/window_scene/test/unittest/scb_system_session_layout_test.cpp index 6a09ea07c6..942056c464 100644 --- a/window_scene/test/unittest/scb_system_session_layout_test.cpp +++ b/window_scene/test/unittest/scb_system_session_layout_test.cpp @@ -38,13 +38,9 @@ public: sptr scbSystemSession_; }; -void SCBSystemSessionLayoutTest::SetUpTestCase() -{ -} +void SCBSystemSessionLayoutTest::SetUpTestCase() {} -void SCBSystemSessionLayoutTest::TearDownTestCase() -{ -} +void SCBSystemSessionLayoutTest::TearDownTestCase() {} void SCBSystemSessionLayoutTest::SetUp() { @@ -71,7 +67,7 @@ HWTEST_F(SCBSystemSessionLayoutTest, UpdateWindowMode, TestSize.Level1) scbSystemSession_->PresentFocusIfPointDown(); scbSystemSession_->PresentFoucusIfNeed(2); ASSERT_EQ(WSError::WS_OK, scbSystemSession_->SetSystemSceneBlockingFocus(true)); - WSRect rect = {0, 0, 0, 0}; + WSRect rect = { 0, 0, 0, 0 }; scbSystemSession_->UpdatePointerArea(rect); auto ret = scbSystemSession_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, ret); @@ -182,6 +178,6 @@ HWTEST_F(SCBSystemSessionLayoutTest, NotifyClientToUpdateRect04, TestSize.Level1 auto ret = scbSystemSession_->NotifyClientToUpdateRect("SCBSystemSessionLayoutTest", nullptr); ASSERT_EQ(WSError::WS_OK, ret); } -} //namespace -} //namespace Rosen -} //namespace OHOS \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scb_system_session_test.cpp b/window_scene/test/unittest/scb_system_session_test.cpp index d40621420d..1380b53c6b 100644 --- a/window_scene/test/unittest/scb_system_session_test.cpp +++ b/window_scene/test/unittest/scb_system_session_test.cpp @@ -38,13 +38,9 @@ public: sptr scbSystemSession_; }; -void SCBSystemSessionTest::SetUpTestCase() -{ -} +void SCBSystemSessionTest::SetUpTestCase() {} -void SCBSystemSessionTest::TearDownTestCase() -{ -} +void SCBSystemSessionTest::TearDownTestCase() {} void SCBSystemSessionTest::SetUp() { @@ -140,8 +136,7 @@ HWTEST_F(SCBSystemSessionTest, BindKeyboardSession02, TestSize.Level1) info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; info.isSystem_ = true; - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); sptr session = sptr::MakeSptr(info, callback); scbSystemSession_->BindKeyboardSession(session); } @@ -248,6 +243,6 @@ HWTEST_F(SCBSystemSessionTest, SetSkipEventOnCastPlus01, TestSize.Level1) scbSystemSession_->SetSkipEventOnCastPlus(false); ASSERT_EQ(false, scbSystemSession_->GetSessionProperty()->GetSkipEventOnCastPlus()); } -} //namespace -} //namespace Rosen -} //namespace OHOS \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_board_judgement_test.cpp b/window_scene/test/unittest/scene_board_judgement_test.cpp index 98945a5c94..e2f03d6172 100644 --- a/window_scene/test/unittest/scene_board_judgement_test.cpp +++ b/window_scene/test/unittest/scene_board_judgement_test.cpp @@ -67,5 +67,5 @@ HWTEST_F(SceneBoardJudgementTest, SafeGetLine_WhenLineIsEmpty, TestSize.Level1) EXPECT_EQ(line, ""); } -} // Rosen -} // OHOS \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_persistence_test.cpp b/window_scene/test/unittest/scene_persistence_test.cpp index 4995dedec9..9bdaa52f34 100644 --- a/window_scene/test/unittest/scene_persistence_test.cpp +++ b/window_scene/test/unittest/scene_persistence_test.cpp @@ -31,6 +31,7 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::shared_ptr mPixelMap = std::make_shared(); }; @@ -40,21 +41,13 @@ constexpr const char* IMAGE_SUFFIX = ".jpg"; static sptr scenePersistence = sptr::MakeSptr("testBundleName", 1423); -void ScenePersistenceTest::SetUpTestCase() -{ -} +void ScenePersistenceTest::SetUpTestCase() {} -void ScenePersistenceTest::TearDownTestCase() -{ -} +void ScenePersistenceTest::TearDownTestCase() {} -void ScenePersistenceTest::SetUp() -{ -} +void ScenePersistenceTest::SetUp() {} -void ScenePersistenceTest::TearDown() -{ -} +void ScenePersistenceTest::TearDown() {} namespace { /** @@ -109,8 +102,8 @@ HWTEST_F(ScenePersistenceTest, SaveSnapshot, TestSize.Level1) scenePersistence->SaveSnapshot(mPixelMap); uint32_t fileID = static_cast(persistentId) & 0x3fffffff; - std::string test = ScenePersistence::snapshotDirectory_ + - bundleName + UNDERLINE_SEPARATOR + std::to_string(fileID) + IMAGE_SUFFIX; + std::string test = + ScenePersistence::snapshotDirectory_ + bundleName + UNDERLINE_SEPARATOR + std::to_string(fileID) + IMAGE_SUFFIX; std::pair sizeResult = scenePersistence->GetSnapshotSize(); EXPECT_EQ(sizeResult.first, 0); EXPECT_EQ(sizeResult.second, 0); @@ -166,8 +159,7 @@ HWTEST_F(ScenePersistenceTest, GetLocalSnapshotPixelMap, TestSize.Level1) auto abilityInfo = session->GetSessionInfo(); auto persistentId = abilityInfo.persistentId_; ScenePersistence::CreateSnapshotDir("storage"); - sptr scenePersistence = - sptr::MakeSptr(abilityInfo.bundleName_, persistentId); + sptr scenePersistence = sptr::MakeSptr(abilityInfo.bundleName_, persistentId); ASSERT_NE(nullptr, scenePersistence); auto result = scenePersistence->GetLocalSnapshotPixelMap(0.5, 0.5); EXPECT_EQ(result, nullptr); @@ -263,6 +255,6 @@ HWTEST_F(ScenePersistenceTest, ResetSnapshotCache, TestSize.Level1) scenePersistence->ResetSnapshotCache(); ASSERT_EQ(scenePersistence->isSavingSnapshot_, false); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_persistent_storage_test.cpp b/window_scene/test/unittest/scene_persistent_storage_test.cpp index 8eccaa4012..657d5d2944 100644 --- a/window_scene/test/unittest/scene_persistent_storage_test.cpp +++ b/window_scene/test/unittest/scene_persistent_storage_test.cpp @@ -29,21 +29,13 @@ public: void TearDown() override; }; -void ScenePersistentStorageTest::SetUpTestCase() -{ -} +void ScenePersistentStorageTest::SetUpTestCase() {} -void ScenePersistentStorageTest::TearDownTestCase() -{ -} +void ScenePersistentStorageTest::TearDownTestCase() {} -void ScenePersistentStorageTest::SetUp() -{ -} +void ScenePersistentStorageTest::SetUp() {} -void ScenePersistentStorageTest::TearDown() -{ -} +void ScenePersistentStorageTest::TearDown() {} namespace { /** @@ -91,6 +83,6 @@ HWTEST_F(ScenePersistentStorageTest, InitDir, TestSize.Level1) scenePersistentStorage_.InitDir(dir_); ASSERT_FALSE(scenePersistentStorage_.HasKey("maximize_state", ScenePersistentStorageType::MAXIMIZE_STATE)); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_converter_test.cpp b/window_scene/test/unittest/scene_session_converter_test.cpp index 26a713969f..9db5564091 100644 --- a/window_scene/test/unittest/scene_session_converter_test.cpp +++ b/window_scene/test/unittest/scene_session_converter_test.cpp @@ -36,21 +36,13 @@ public: void TearDown() override; }; -void SceneSessionConverterTest::SetUpTestCase() -{ -} +void SceneSessionConverterTest::SetUpTestCase() {} -void SceneSessionConverterTest::TearDownTestCase() -{ -} +void SceneSessionConverterTest::TearDownTestCase() {} -void SceneSessionConverterTest::SetUp() -{ -} +void SceneSessionConverterTest::SetUp() {} -void SceneSessionConverterTest::TearDown() -{ -} +void SceneSessionConverterTest::TearDown() {} namespace { @@ -111,6 +103,6 @@ HWTEST_F(SceneSessionConverterTest, ConvertToMissionInfo, TestSize.Level1) EXPECT_EQ(WSError::WS_OK, result3); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_layout_test.cpp b/window_scene/test/unittest/scene_session_layout_test.cpp index d7b7a02b06..611cf26b79 100644 --- a/window_scene/test/unittest/scene_session_layout_test.cpp +++ b/window_scene/test/unittest/scene_session_layout_test.cpp @@ -44,22 +44,16 @@ private: sptr mockSessionStage_ = nullptr; }; -void SceneSessionLayoutTest::SetUpTestCase() -{ -} +void SceneSessionLayoutTest::SetUpTestCase() {} -void SceneSessionLayoutTest::TearDownTestCase() -{ -} +void SceneSessionLayoutTest::TearDownTestCase() {} void SceneSessionLayoutTest::SetUp() { mockSessionStage_ = sptr::MakeSptr(); } -void SceneSessionLayoutTest::TearDown() -{ -} +void SceneSessionLayoutTest::TearDown() {} namespace { /** @@ -79,13 +73,12 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRect01, TestSize.Level1) property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::UNDEFINED; WSError result = sceneSession->UpdateRect(rect, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); } - /** * @tc.name: UpdateRect02 * @tc.desc: normal function @@ -103,7 +96,7 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRect02, TestSize.Level0) property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::UNDEFINED; WSError result = sceneSession->UpdateRect(rect, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); @@ -116,7 +109,7 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRect02, TestSize.Level0) result = sceneSession->UpdateRect(rect, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); - WSRect rect2({0, 0, 0, 0}); + WSRect rect2({ 0, 0, 0, 0 }); result = sceneSession->UpdateRect(rect2, reason, "SceneSessionLayoutTest"); ASSERT_EQ(result, WSError::WS_OK); } @@ -184,9 +177,9 @@ HWTEST_F(SceneSessionLayoutTest, UpdateRectInner01, TestSize.Level0) sceneSession->SetForegroundInteractiveStatus(true); uiParam.needSync_ = true; - uiParam.rect_ = {0, 0, 1, 1}; + uiParam.rect_ = { 0, 0, 1, 1 }; - sceneSession->winRect_ = {1, 1, 1, 1}; + sceneSession->winRect_ = { 1, 1, 1, 1 }; sceneSession->isVisible_ = true; ASSERT_EQ(false, sceneSession->UpdateRectInner(uiParam, reason)); } @@ -211,9 +204,7 @@ HWTEST_F(SceneSessionLayoutTest, NotifyClientToUpdateRect, TestSize.Level1) session->reason_ = SizeChangeReason::DRAG; EXPECT_EQ(WSError::WS_OK, session->NotifyClientToUpdateRect("SceneSessionLayoutTest", nullptr)); - UpdateAvoidAreaCallback func = [](const int32_t& persistentId) { - return; - }; + UpdateAvoidAreaCallback func = [](const int32_t& persistentId) { return; }; auto specificCallback = sptr::MakeSptr(); specificCallback->onUpdateAvoidArea_ = func; session->specificCallback_ = specificCallback; @@ -265,7 +256,7 @@ HWTEST_F(SceneSessionLayoutTest, CheckAspectRatioValid, TestSize.Level0) EXPECT_EQ(WSError::WS_OK, session->SetAspectRatio(0.0f)); sptr property = sptr::MakeSptr(); - WindowLimits limits = {8, 1, 6, 1, 1, 1.0f, 1.0f}; + WindowLimits limits = { 8, 1, 6, 1, 1, 1.0f, 1.0f }; property->SetWindowLimits(limits); session->SetSessionProperty(property); EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, session->SetAspectRatio(0.1f)); @@ -330,20 +321,20 @@ HWTEST_F(SceneSessionLayoutTest, NotifyClientToUpdateRectTask, TestSize.Level0) session->Session::UpdateSizeChangeReason(SizeChangeReason::UNDEFINED); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::MOVE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::DRAG_MOVE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::RESIZE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::RECOVER); EXPECT_EQ(session->reason_, SizeChangeReason::RECOVER); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); session->moveDragController_->isStartDrag_ = true; @@ -352,23 +343,23 @@ HWTEST_F(SceneSessionLayoutTest, NotifyClientToUpdateRectTask, TestSize.Level0) session->isKeyboardPanelEnabled_ = true; info.windowType_ = static_cast(WindowType::ABOVE_APP_SYSTEM_WINDOW_BASE); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); info.windowType_ = static_cast(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::UNDEFINED); EXPECT_EQ(WSError::WS_ERROR_REPEAT_OPERATION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::MOVE); info.windowType_ = static_cast(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); session->Session::UpdateSizeChangeReason(SizeChangeReason::DRAG_MOVE); info.windowType_ = static_cast(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); + session->NotifyClientToUpdateRectTask("SceneSessionLayoutTest", nullptr)); } /** @@ -948,5 +939,5 @@ HWTEST_F(SceneSessionLayoutTest, HandleSubSessionCrossNode, TestSize.Level1) ASSERT_EQ(sceneSession->IsDragStart(), true); } } // namespace -} // Rosen -} // OHOS \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 8c3305bb81..d416b3e397 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -41,26 +41,20 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; - sptr sceneSession; + sptr sceneSession; SessionInfo info; }; -void SceneSessionLifecycleTest::SetUpTestCase() -{ -} +void SceneSessionLifecycleTest::SetUpTestCase() {} -void SceneSessionLifecycleTest::TearDownTestCase() -{ -} +void SceneSessionLifecycleTest::TearDownTestCase() {} void SceneSessionLifecycleTest::SetUp() { sceneSession = sptr::MakeSptr(info, nullptr); } -void SceneSessionLifecycleTest::TearDown() -{ -} +void SceneSessionLifecycleTest::TearDown() {} namespace { @@ -76,7 +70,7 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground01, TestSize.Level0) info.bundleName_ = "Foreground01"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); int resultValue = 0; sptr sceneSession; @@ -89,9 +83,9 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground01, TestSize.Level0) auto result = sceneSession->Foreground(property); ASSERT_EQ(result, WSError::WS_OK); - specificCallback->onCreate_ = [&resultValue, specificCallback](const SessionInfo& info, - sptr property) -> sptr - { + specificCallback->onCreate_ = [&resultValue, + specificCallback](const SessionInfo& info, + sptr property) -> sptr { sptr sceneSessionReturn = sptr::MakeSptr(info, specificCallback); EXPECT_NE(sceneSessionReturn, nullptr); resultValue = 1; @@ -117,7 +111,7 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground02, TestSize.Level1) info.bundleName_ = "Foreground02"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession; @@ -141,7 +135,7 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground03, TestSize.Level1) info.bundleName_ = "Foreground03"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession; @@ -195,7 +189,7 @@ HWTEST_F(SceneSessionLifecycleTest, Foreground05, TestSize.Level1) EXPECT_EQ(WSError::WS_OK, session->Foreground(property, false)); sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); session->specificCallback_ = specificCallback; EXPECT_EQ(WSError::WS_OK, session->Foreground(property, false)); @@ -257,7 +251,7 @@ HWTEST_F(SceneSessionLifecycleTest, Background01, TestSize.Level0) info.bundleName_ = "Background01"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); int resultValue = 0; sptr sceneSession; @@ -267,9 +261,9 @@ HWTEST_F(SceneSessionLifecycleTest, Background01, TestSize.Level0) sceneSession->isActive_ = true; auto result = sceneSession->Background(); ASSERT_EQ(result, WSError::WS_OK); - specificCallback->onCreate_ = [&resultValue, specificCallback](const SessionInfo& info, - sptr property) -> sptr - { + specificCallback->onCreate_ = [&resultValue, + specificCallback](const SessionInfo& info, + sptr property) -> sptr { sptr sceneSessionReturn = sptr::MakeSptr(info, specificCallback); EXPECT_NE(sceneSessionReturn, nullptr); resultValue = 1; @@ -295,7 +289,7 @@ HWTEST_F(SceneSessionLifecycleTest, Background02, TestSize.Level1) info.bundleName_ = "Background02"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -346,7 +340,7 @@ HWTEST_F(SceneSessionLifecycleTest, BackgroundTask01, TestSize.Level0) info.abilityName_ = "BackgroundTask01"; info.bundleName_ = "BackgroundTask01"; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); int resultValue = 0; sptr sceneSession; @@ -358,10 +352,9 @@ HWTEST_F(SceneSessionLifecycleTest, BackgroundTask01, TestSize.Level0) sceneSession->isActive_ = true; result = sceneSession->BackgroundTask(false); ASSERT_EQ(result, WSError::WS_OK); - specificCallback->onCreate_ = - [&resultValue, specificCallback](const SessionInfo& info, - sptr property) -> sptr - { + specificCallback->onCreate_ = [&resultValue, + specificCallback](const SessionInfo& info, + sptr property) -> sptr { sptr sceneSessionReturn = sptr::MakeSptr(info, specificCallback); EXPECT_NE(sceneSessionReturn, nullptr); resultValue = 1; @@ -390,7 +383,7 @@ HWTEST_F(SceneSessionLifecycleTest, BackgroundTask02, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -432,7 +425,7 @@ HWTEST_F(SceneSessionLifecycleTest, BackgroundTask03, TestSize.Level0) info.windowType_ = static_cast(WindowType::APP_MAIN_WINDOW_BASE); sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); session->specificCallback_ = specificCallback; EXPECT_EQ(WSError::WS_OK, session->BackgroundTask(false)); @@ -464,7 +457,7 @@ HWTEST_F(SceneSessionLifecycleTest, DisconnectTask01, TestSize.Level0) info.abilityName_ = "DisconnectTask01"; info.bundleName_ = "DisconnectTask01"; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); int resultValue = 0; @@ -478,9 +471,9 @@ HWTEST_F(SceneSessionLifecycleTest, DisconnectTask01, TestSize.Level0) result = sceneSession->DisconnectTask(false, true); sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_EQ(result, WSError::WS_OK); - specificCallback->onCreate_ = - [&resultValue, specificCallback](const SessionInfo& info, - sptr property) -> sptr { + specificCallback->onCreate_ = [&resultValue, + specificCallback](const SessionInfo& info, + sptr property) -> sptr { sptr sceneSessionReturn = sptr::MakeSptr(info, specificCallback); EXPECT_NE(sceneSessionReturn, nullptr); resultValue = 1; @@ -511,7 +504,7 @@ HWTEST_F(SceneSessionLifecycleTest, DisconnectTask02, TestSize.Level0) info.abilityName_ = "DisconnectTask02"; info.bundleName_ = "DisconnectTask02"; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -540,7 +533,7 @@ HWTEST_F(SceneSessionLifecycleTest, Disconnect, TestSize.Level0) info.bundleName_ = "Disconnect"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -565,7 +558,7 @@ HWTEST_F(SceneSessionLifecycleTest, Disconnect2, TestSize.Level1) info.bundleName_ = "Disconnect2"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -592,7 +585,7 @@ HWTEST_F(SceneSessionLifecycleTest, Disconnect3, TestSize.Level0) info.bundleName_ = "Disconnect3"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -631,7 +624,7 @@ HWTEST_F(SceneSessionLifecycleTest, UpdateActiveStatus01, TestSize.Level0) info.bundleName_ = "UpdateActiveStatus01"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -659,7 +652,7 @@ HWTEST_F(SceneSessionLifecycleTest, UpdateActiveStatus02, TestSize.Level1) info.bundleName_ = "UpdateActiveStatus02"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -684,7 +677,7 @@ HWTEST_F(SceneSessionLifecycleTest, UpdateActiveStatus03, TestSize.Level0) info.bundleName_ = "UpdateActiveStatus03"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -765,8 +758,7 @@ HWTEST_F(SceneSessionLifecycleTest, Connect, TestSize.Level0) SystemSessionConfig systemConfig; sptr property = sptr::MakeSptr(); sptr token; - WSError res = sceneSession->Connect(sessionStage, eventChannel, - surfaceNode, systemConfig, property, token); + WSError res = sceneSession->Connect(sessionStage, eventChannel, surfaceNode, systemConfig, property, token); ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR); } @@ -790,16 +782,15 @@ HWTEST_F(SceneSessionLifecycleTest, ConnectInner01, TestSize.Level0) ASSERT_NE(property, nullptr); sceneSession->clientIdentityToken_ = "session1"; - auto result = sceneSession->ConnectInner(mockSessionStage, nullptr, nullptr, systemConfig, - property, nullptr, -1, -1, "session2"); + auto result = sceneSession->ConnectInner( + mockSessionStage, nullptr, nullptr, systemConfig, property, nullptr, -1, -1, "session2"); ASSERT_EQ(result, WSError::WS_OK); - result = sceneSession->ConnectInner(mockSessionStage, nullptr, nullptr, systemConfig, - property, nullptr, -1, -1, "session1"); + result = sceneSession->ConnectInner( + mockSessionStage, nullptr, nullptr, systemConfig, property, nullptr, -1, -1, "session1"); ASSERT_EQ(result, WSError::WS_OK); - result = sceneSession->ConnectInner(mockSessionStage, nullptr, nullptr, systemConfig, - property, nullptr, -1, -1); + result = sceneSession->ConnectInner(mockSessionStage, nullptr, nullptr, systemConfig, property, nullptr, -1, -1); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } @@ -823,15 +814,13 @@ HWTEST_F(SceneSessionLifecycleTest, ConnectInner02, TestSize.Level0) ASSERT_NE(property, nullptr); sceneSession->SetSessionState(SessionState::STATE_CONNECT); sceneSession->Session::isTerminating_ = false; - auto result = sceneSession->ConnectInner(mockSessionStage, nullptr, nullptr, systemConfig, - property, nullptr); + auto result = sceneSession->ConnectInner(mockSessionStage, nullptr, nullptr, systemConfig, property, nullptr); ASSERT_EQ(result, WSError::WS_ERROR_INVALID_SESSION); sptr eventChannel = sptr::MakeSptr(mockSessionStage); ASSERT_NE(eventChannel, nullptr); sceneSession->SetSessionState(SessionState::STATE_DISCONNECT); - result = sceneSession->ConnectInner(mockSessionStage, eventChannel, nullptr, systemConfig, - property, nullptr); + result = sceneSession->ConnectInner(mockSessionStage, eventChannel, nullptr, systemConfig, property, nullptr); ASSERT_EQ(result, WSError::WS_OK); } @@ -856,8 +845,7 @@ HWTEST_F(SceneSessionLifecycleTest, Reconnect, TestSize.Level0) sptr token; int32_t pid = -1; int32_t uid = -1; - WSError res = - sceneSession->Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid); + WSError res = sceneSession->Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid); ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR); property->windowState_ = WindowState::STATE_SHOWN; @@ -924,7 +912,7 @@ HWTEST_F(SceneSessionLifecycleTest, PendingSessionActivation, TestSize.Level0) info.bundleName_ = "PendingSessionActivation"; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -991,8 +979,7 @@ HWTEST_F(SceneSessionLifecycleTest, TerminateSession, TestSize.Level0) ASSERT_EQ(WSError::WS_OK, sceneSession->TerminateSession(abilitySessionInfo)); - NotifyTerminateSessionFuncNew callback = - [](const SessionInfo& info, bool needStartCaller, bool isFromBroker){}; + NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {}; session.isTerminating_ = false; ASSERT_EQ(WSError::WS_OK, sceneSession->TerminateSession(abilitySessionInfo)); @@ -1033,7 +1020,7 @@ HWTEST_F(SceneSessionLifecycleTest, NotifySessionForeground, TestSize.Level0) info.windowType_ = 1; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession; sceneSession = sptr::MakeSptr(info, nullptr); @@ -1061,7 +1048,7 @@ HWTEST_F(SceneSessionLifecycleTest, NotifySessionFullScreen, TestSize.Level0) info.bundleName_ = "IsFloatingWindowAppType"; info.windowType_ = 1; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); @@ -1089,7 +1076,7 @@ HWTEST_F(SceneSessionLifecycleTest, NotifySessionBackground, TestSize.Level0) info.windowType_ = 1; sptr session_; sptr specificCallback = - sptr::MakeSptr(); + sptr::MakeSptr(); EXPECT_NE(specificCallback, nullptr); sptr sceneSession; sceneSession = sptr::MakeSptr(info, nullptr); @@ -1105,6 +1092,6 @@ HWTEST_F(SceneSessionLifecycleTest, NotifySessionBackground, TestSize.Level0) sceneSession->NotifySessionBackground(reason, withAnimation, isFromInnerkits); ASSERT_EQ(ret, 1); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_layout_test.cpp b/window_scene/test/unittest/scene_session_manager_layout_test.cpp index 97bd25b903..e85a9058e3 100644 --- a/window_scene/test/unittest/scene_session_manager_layout_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_layout_test.cpp @@ -33,7 +33,7 @@ namespace { const std::string EMPTY_DEVICE_ID = ""; constexpr float SINGLE_HAND_SCALE = 0.75f; constexpr float SINGLE_HAND_DEFAULT_SCALE = 1.0f; -} +} // namespace class SceneSessionManagerLayoutTest : public testing::Test { public: static void SetUpTestCase(); @@ -41,6 +41,7 @@ public: void SetUp() override; void TearDown() override; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; @@ -95,8 +96,8 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestUIType, T WSRect originRect, singleHandRect; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); sptr screenSession = sptr::MakeSptr(); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); @@ -128,14 +129,14 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestWindowNam sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->property_->SetWindowName("OneHandModeBackground_testWindow"); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); sptr screenSession = sptr::MakeSptr(); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); SingleHandScreenInfo singleHandScreenInfo; WSRect originRect, singleHandRect; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; @@ -155,8 +156,8 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestDisplayId ssm_->singleHandTransform_ = singleHandTransform; SingleHandScreenInfo singleHandScreenInfo; WSRect originRect, singleHandRect; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; @@ -170,7 +171,7 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestDisplayId EXPECT_NE(sceneSession, nullptr); sceneSession->GetSessionProperty()->SetDisplayId(2025); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); usleep(WAIT_SYNC_IN_NS); EXPECT_NE(singleHandScreenInfo.scaleRatio, sceneSession->singleHandTransform_.scaleX); @@ -198,8 +199,8 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestMode, Tes SingleHandScreenInfo singleHandScreenInfo; WSRect originRect, singleHandRect; - originRect = {0, 0, 400, 600}; - singleHandRect = {0, 100, 200, 300}; + originRect = { 0, 0, 400, 600 }; + singleHandRect = { 0, 100, 200, 300 }; singleHandScreenInfo.scaleRatio = SINGLE_HAND_SCALE; singleHandScreenInfo.mode = SingleHandMode::LEFT; ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); @@ -209,7 +210,7 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestMode, Tes ssm_->singleHandTransform_ = singleHandTransform; singleHandScreenInfo.mode = SingleHandMode::RIGHT; - singleHandRect = {50, 100, 200, 300}; + singleHandRect = { 50, 100, 200, 300 }; ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); usleep(WAIT_SYNC_IN_NS); EXPECT_EQ(100, ssm_->singleHandTransform_.posY); @@ -218,7 +219,7 @@ HWTEST_F(SceneSessionManagerLayoutTest, NotifySingleHandInfoChange_TestMode, Tes singleHandScreenInfo.scaleRatio = SINGLE_HAND_DEFAULT_SCALE; singleHandScreenInfo.mode = SingleHandMode::MIDDLE; - singleHandRect = {0, 0, 200, 300}; + singleHandRect = { 0, 0, 200, 300 }; ssm_->NotifySingleHandInfoChange(singleHandScreenInfo, originRect, singleHandRect); usleep(WAIT_SYNC_IN_NS); EXPECT_EQ(0, ssm_->singleHandTransform_.posY); @@ -241,6 +242,6 @@ HWTEST_F(SceneSessionManagerLayoutTest, GetDisplaySizeById_TestDisplayId, TestSi displayId = 0; EXPECT_EQ(true, ssm_->GetDisplaySizeById(displayId, displayWidth, displayHeight)); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp index 9244e6d1a3..a11e737d5c 100644 --- a/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp @@ -55,23 +55,18 @@ public: static void SetVisibleForAccessibility(sptr& sceneSession); int32_t GetTaskCount(sptr& session); static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; sptr SceneSessionManagerLifecycleTest::ssm_ = nullptr; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} -void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) -{ -} +void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) {} void SceneSessionManagerLifecycleTest::SetUpTestCase() { @@ -166,7 +161,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, NotifySessionMovedToFront, TestSize.L info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->NotifySessionMovedToFront(100); } @@ -185,7 +180,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, PendingSessionToBackgroundForDelegato info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ret = ssm_->PendingSessionToBackgroundForDelegator(nullptr, true); ASSERT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); } @@ -204,7 +199,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, OnSessionStateChange, TestSize.Level1 info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->OnSessionStateChange(100, SessionState::STATE_END); ssm_->OnSessionStateChange(100, SessionState::STATE_FOREGROUND); ssm_->OnSessionStateChange(0, SessionState::STATE_FOREGROUND); @@ -255,7 +250,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RecoverAndReconnectSceneSession02, Te sptr session; sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); - std::vector recoveredPersistentIds = {0, 1, 2}; + std::vector recoveredPersistentIds = { 0, 1, 2 }; ssm_->SetAlivePersistentIds(recoveredPersistentIds); property->SetPersistentId(1); ProcessShiftFocusFunc shiftFocusFunc_; @@ -309,7 +304,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, CreateSceneSession, TestSize.Level1) ssm_->UpdateSceneSessionWant(info); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->UpdateSceneSessionWant(info); std::shared_ptr want = std::make_shared(); ASSERT_NE(nullptr, want); @@ -364,7 +359,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionBackground, TestSi ssm_->SetAbilitySessionInfo(sceneSession); ssm_->RequestSceneSessionActivation(sceneSession, true); ssm_->RequestInputMethodCloseKeyboard(1); - ssm_->sceneSessionMap_.insert({1, nullptr}); + ssm_->sceneSessionMap_.insert({ 1, nullptr }); ssm_->RequestInputMethodCloseKeyboard(1); ssm_->RequestSceneSessionActivation(sceneSession, true); ssm_->RequestSceneSessionActivation(sceneSession, false); @@ -398,7 +393,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionDestruction, TestS ssm_->AddClientDeathRecipient(sessionStage, sceneSession); ssm_->RequestSceneSessionDestruction(sceneSession, true); ssm_->RequestSceneSessionDestruction(sceneSession, false); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ssm_->RequestSceneSessionDestruction(sceneSession, true); ssm_->RequestSceneSessionDestruction(sceneSession, false); ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); @@ -406,8 +401,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionDestruction, TestS ASSERT_NE(nullptr, sceneSessionInfo); ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, true); ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, false); - std::shared_ptr listenerController = - std::make_shared(); + std::shared_ptr listenerController = std::make_shared(); ASSERT_NE(nullptr, listenerController); ssm_->listenerController_ = listenerController; ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, true); @@ -493,8 +487,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, NotifySessionCreate, TestSize.Level1) EXPECT_NE(info.want, nullptr); AppExecFwk::AbilityInfo aInfo; sptr abilitySessionInfo = sptr::MakeSptr(); - std::shared_ptr abilityInfo = - std::make_shared(aInfo); + std::shared_ptr abilityInfo = std::make_shared(aInfo); ASSERT_NE(nullptr, abilityInfo); int32_t collaboratorType = CollaboratorType::RESERVE_TYPE; ssm_->NotifyLoadAbility(collaboratorType, abilitySessionInfo, abilityInfo); @@ -518,7 +511,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, UpdateRecoveredSessionInfo02, TestSiz sptr specificCallback; sptr sceneSession = sptr::MakeSptr(info, specificCallback); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds); constexpr uint32_t WAIT_SYNC_IN_NS = 50000; usleep(WAIT_SYNC_IN_NS); @@ -560,7 +553,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSession02, TestSize.Level info2.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info1, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr getSceneSession = ssm_->RequestSceneSession(info2, windowSessionProperty); ASSERT_NE(getSceneSession->GetSessionInfo().bundleName_, info2.bundleName_); } @@ -580,7 +573,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSession03, TestSize.Level auto windowSessionProperty = sptr::MakeSptr(); auto sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr getSceneSession = ssm_->RequestSceneSession(info, windowSessionProperty); ASSERT_EQ(getSceneSession, nullptr); @@ -620,8 +613,8 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionBackground01, Test info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ASSERT_EQ(ssm_->RequestSceneSessionBackground( - sceneSession, isDelegator, isToDesktop, isSaveSnapshot), WSError::WS_OK); + ASSERT_EQ(ssm_->RequestSceneSessionBackground(sceneSession, isDelegator, isToDesktop, isSaveSnapshot), + WSError::WS_OK); } /** @@ -640,9 +633,9 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionBackground02, Test info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); - ASSERT_EQ(ssm_->RequestSceneSessionBackground( - sceneSession, isDelegator, isToDesktop, isSaveSnapshot), WSError::WS_OK); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); + ASSERT_EQ(ssm_->RequestSceneSessionBackground(sceneSession, isDelegator, isToDesktop, isSaveSnapshot), + WSError::WS_OK); } /** @@ -661,10 +654,10 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionBackground03, Test info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->SetBrightness(sceneSession, 0.5); - ASSERT_EQ(ssm_->RequestSceneSessionBackground( - sceneSession, isDelegator, isToDesktop, isSaveSnapshot), WSError::WS_OK); + ASSERT_EQ(ssm_->RequestSceneSessionBackground(sceneSession, isDelegator, isToDesktop, isSaveSnapshot), + WSError::WS_OK); } /** @@ -683,9 +676,9 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionBackground04, Test info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); - ASSERT_EQ(ssm_->RequestSceneSessionBackground( - sceneSession, isDelegator, isToDesktop, isSaveSnapshot), WSError::WS_OK); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); + ASSERT_EQ(ssm_->RequestSceneSessionBackground(sceneSession, isDelegator, isToDesktop, isSaveSnapshot), + WSError::WS_OK); } /** @@ -701,8 +694,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionDestruction01, Tes info.bundleName_ = "RequestSceneSessionDestruction"; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ASSERT_EQ(ssm_->RequestSceneSessionDestruction( - sceneSession, needRemoveSession), WSError::WS_OK); + ASSERT_EQ(ssm_->RequestSceneSessionDestruction(sceneSession, needRemoveSession), WSError::WS_OK); } /** @@ -719,9 +711,8 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionDestruction02, Tes info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); - ASSERT_EQ(ssm_->RequestSceneSessionDestruction( - sceneSession, needRemoveSession), WSError::WS_OK); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); + ASSERT_EQ(ssm_->RequestSceneSessionDestruction(sceneSession, needRemoveSession), WSError::WS_OK); } /** @@ -789,7 +780,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionByCall01, TestSize info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ASSERT_EQ(ssm_->RequestSceneSessionByCall(sceneSession), WSError::WS_OK); } @@ -807,7 +798,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionByCall02, TestSize info.callState_ = static_cast(AAFwk::CallToState::BACKGROUND); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ASSERT_EQ(ssm_->RequestSceneSessionByCall(sceneSession), WSError::WS_OK); } @@ -825,7 +816,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionByCall03, TestSize info.callState_ = static_cast(AAFwk::CallToState::FOREGROUND); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ASSERT_EQ(ssm_->RequestSceneSessionByCall(sceneSession), WSError::WS_OK); } @@ -879,12 +870,12 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RecoveryVisibilityPidCount, TestSize. info.abilityName_ = "VisibilityChanged"; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sceneSession->SetCallingPid(pid); sptr sceneSession2 = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession2, nullptr); - ssm_->sceneSessionMap_.insert({2, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 2, sceneSession2 }); sceneSession2->SetCallingPid(pid); sceneSession2->isVisible_ = true; @@ -946,10 +937,12 @@ HWTEST_F(SceneSessionManagerLifecycleTest, StartUIAbilityBySCBTimeoutCheck, Test sptr abilitySessionInfo = ssm_->SetAbilitySessionInfo(sceneSession); ASSERT_NE(abilitySessionInfo, nullptr); bool isColdStart = true; - ASSERT_EQ(ssm_->StartUIAbilityBySCBTimeoutCheck(abilitySessionInfo, - static_cast(WindowStateChangeReason::ABILITY_CALL), isColdStart), 2097202); - ASSERT_EQ(ssm_->StartUIAbilityBySCBTimeoutCheck(abilitySessionInfo, - static_cast(WindowStateChangeReason::USER_SWITCH), isColdStart), 2097202); + ASSERT_EQ(ssm_->StartUIAbilityBySCBTimeoutCheck( + abilitySessionInfo, static_cast(WindowStateChangeReason::ABILITY_CALL), isColdStart), + 2097202); + ASSERT_EQ(ssm_->StartUIAbilityBySCBTimeoutCheck( + abilitySessionInfo, static_cast(WindowStateChangeReason::USER_SWITCH), isColdStart), + 2097202); } /** @@ -973,6 +966,6 @@ HWTEST_F(SceneSessionManagerLifecycleTest, SubmitTaskAndWait, TestSize.Level1) }; ASSERT_EQ(ffrtQueueHelper->SubmitTaskAndWait(std::move(task), timeout), false); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp b/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp index a36b2c87b2..0791e8aad7 100644 --- a/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp @@ -53,23 +53,18 @@ public: static void SetVisibleForAccessibility(sptr& sceneSession); int32_t GetTaskCount(sptr& session); static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; sptr SceneSessionManagerLifecycleTest2::ssm_ = nullptr; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} -void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) -{ -} +void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) {} void SceneSessionManagerLifecycleTest2::SetUpTestCase() { @@ -249,14 +244,14 @@ HWTEST_F(SceneSessionManagerLifecycleTest2, NotifyWindowStateErrorFromMMI, TestS sceneSession2->property_ = property2; sceneSession2->SetCallingPid(100); - ssm_->sceneSessionMap_.insert({10086, sceneSession}); - ssm_->sceneSessionMap_.insert({10087, sceneSession1}); - ssm_->sceneSessionMap_.insert({10088, sceneSession2}); - ssm_->sceneSessionMap_.insert({10089, nullptr}); + ssm_->sceneSessionMap_.insert({ 10086, sceneSession }); + ssm_->sceneSessionMap_.insert({ 10087, sceneSession1 }); + ssm_->sceneSessionMap_.insert({ 10088, sceneSession2 }); + ssm_->sceneSessionMap_.insert({ 10089, nullptr }); ssm_->NotifyWindowStateErrorFromMMI(-1, 10086); ssm_->NotifyWindowStateErrorFromMMI(100, 10086); ASSERT_EQ(ret, 0); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp index cdb81d58e8..943957c488 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp @@ -61,7 +61,8 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { return WSError::WS_OK; } WSError GetSessionInfos(const std::string& deviceId, - int32_t numMax, std::vector& sessionInfos) override + int32_t numMax, + std::vector& sessionInfos) override { return WSError::WS_OK; } @@ -74,7 +75,7 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { return WSError::WS_OK; } WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId, - SessionInfoBean& sessionInfo) override + SessionInfoBean& sessionInfo) override { return WSError::WS_OK; } @@ -82,13 +83,16 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { { return WSError::WS_OK; } - WSError TerminateSessionNew( - const sptr info, bool needStartCaller, bool isFromBroker = false) override + WSError TerminateSessionNew(const sptr info, + bool needStartCaller, + bool isFromBroker = false) override { return WSError::WS_OK; } - WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId, - SessionSnapshot& snapshot, bool isLowResolution) override + WSError GetSessionSnapshot(const std::string& deviceId, + int32_t persistentId, + SessionSnapshot& snapshot, + bool isLowResolution) override { return WSError::WS_OK; } @@ -113,28 +117,25 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { return WSError::WS_OK; } WSError MoveSessionsToBackground(const std::vector& sessionIds, - std::vector& result) override + std::vector& result) override { return WSError::WS_OK; } WMError RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override + const sptr& windowManagerAgent) override { return WMError::WM_OK; } WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override + const sptr& windowManagerAgent) override { return WMError::WM_OK; } - WMError ListWindowInfo(const WindowInfoOption& windowInfoOption, - std::vector>& infos) override + WMError ListWindowInfo(const WindowInfoOption& windowInfoOption, std::vector>& infos) override { return WMError::WM_OK; } - void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) override - { - } + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) override {} WMError CheckWindowId(int32_t windowId, int32_t& pid) override { return WMError::WM_OK; @@ -155,8 +156,7 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { { return WMError::WM_OK; } - WMError ClearMainSessions(const std::vector& persistentIds, - std::vector& clearFailedIds) override + WMError ClearMainSessions(const std::vector& persistentIds, std::vector& clearFailedIds) override { clearFailedIds.push_back(1); return WMError::WM_OK; @@ -166,7 +166,7 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { return WSError::WS_OK; } WSError RegisterIAbilityManagerCollaborator(int32_t type, - const sptr& impl) override + const sptr& impl) override { return WSError::WS_OK; } @@ -207,25 +207,46 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { { return nullptr; } - WMError CheckUIExtensionCreation(int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName& element, - AppExecFwk::ExtensionAbilityType extensionAbilityType, int32_t& pid) override + WMError CheckUIExtensionCreation(int32_t windowId, + uint32_t tokenId, + const AppExecFwk::ElementName& element, + AppExecFwk::ExtensionAbilityType extensionAbilityType, + int32_t& pid) override + { + return WMError::WM_OK; + } + WSError NotifyAppUseControlList(ControlAppType type, + int32_t userId, + const std::vector& controlList) override + { + return WSError::WS_OK; + } + WMError MinimizeMainSession(const std::string& bundleName, int32_t appIndex, int32_t userId) override + { + return WMError::WM_OK; + } + WMError HasFloatingWindowForeground(const sptr& abilityToken, bool& hasFloatingShowing) override + { + return WMError::WM_OK; + } + WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, bool isLock) override { return WMError::WM_OK; } - WSError NotifyAppUseControlList(ControlAppType type, int32_t userId, - const std::vector& controlList) override { return WSError::WS_OK; } - WMError MinimizeMainSession(const std::string& bundleName, - int32_t appIndex, int32_t userId) override { return WMError::WM_OK; } - WMError HasFloatingWindowForeground(const sptr& abilityToken, - bool& hasFloatingShowing) override { return WMError::WM_OK; } - WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, - bool isLock) override { return WMError::WM_OK; } WMError RegisterSessionLifecycleListenerByIds(const sptr& listener, - const std::vector& persistentIdList) override { return WMError::WM_OK; } + const std::vector& persistentIdList) override + { + return WMError::WM_OK; + } WMError RegisterSessionLifecycleListenerByBundles(const sptr& listener, - const std::vector& bundleNameList) override { return WMError::WM_OK; } - WMError UnregisterSessionLifecycleListener(const sptr& listener) - override { return WMError::WM_OK; } + const std::vector& bundleNameList) override + { + return WMError::WM_OK; + } + WMError UnregisterSessionLifecycleListener(const sptr& listener) override + { + return WMError::WM_OK; + } }; class SceneSessionManagerLiteStubTest : public testing::Test { @@ -237,13 +258,9 @@ public: sptr sceneSessionManagerLiteStub_ = nullptr; }; -void SceneSessionManagerLiteStubTest::SetUpTestCase() -{ -} +void SceneSessionManagerLiteStubTest::SetUpTestCase() {} -void SceneSessionManagerLiteStubTest::TearDownTestCase() -{ -} +void SceneSessionManagerLiteStubTest::TearDownTestCase() {} void SceneSessionManagerLiteStubTest::SetUp() { @@ -264,25 +281,22 @@ namespace { */ HWTEST_F(SceneSessionManagerLiteStubTest, OnRemoteRequest, TestSize.Level1) { - uint32_t code = static_cast(SceneSessionManagerLiteStub:: - SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL); + uint32_t code = + static_cast(SceneSessionManagerLiteStub::SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL); MessageParcel data; MessageParcel reply; MessageOption option; data.WriteInterfaceToken(u"OpenHarmeny"); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::OnRemoteRequest(code, data, reply, option); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::OnRemoteRequest(code, data, reply, option); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); data.WriteInterfaceToken(SceneSessionManagerLiteStub::GetDescriptor()); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::OnRemoteRequest(1000, data, reply, option); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::OnRemoteRequest(1000, data, reply, option); EXPECT_EQ(IPC_STUB_UNKNOW_TRANS_ERR, res); data.WriteInterfaceToken(SceneSessionManagerLiteStub::GetDescriptor()); sptr token = nullptr; data.WriteRemoteObject(token); data.WriteString("OnRemoteRequest UT Testing."); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::OnRemoteRequest(code, data, reply, option); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::OnRemoteRequest(code, data, reply, option); EXPECT_EQ(ERR_NONE, res); } @@ -295,8 +309,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleSetSessionIcon, TestSize.Level1) { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleSetSessionIcon(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleSetSessionIcon(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); } @@ -309,8 +322,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleIsValidSessionIds, TestSize.Leve { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleIsValidSessionIds(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleIsValidSessionIds(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -323,8 +335,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandlePendingSessionToForeground, Test { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandlePendingSessionToForeground(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandlePendingSessionToForeground(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); } @@ -337,8 +348,8 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandlePendingSessionToBackgroundForDel { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator( + data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); } @@ -351,8 +362,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleRegisterSessionListener, TestSiz { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterSessionListener(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterSessionListener(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -365,8 +375,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleUnRegisterSessionListener, TestS { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -379,8 +388,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetSessionInfos, TestSize.Level1 { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -393,8 +401,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetMainWindowStatesByPid, TestSi { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetMainWindowStatesByPid(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetMainWindowStatesByPid(data, reply); EXPECT_EQ(res, ERR_INVALID_DATA); } @@ -408,21 +415,18 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetSessionInfo, TestSize.Level1) MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetSessionInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetSessionInfo(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); std::u16string deviceIdU16 = u"testDeviceId"; data.WriteString16(deviceIdU16); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetSessionInfo(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetSessionInfo(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); int32_t persistentId = 0; data.WriteString16(deviceIdU16); data.WriteInt32(persistentId); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetSessionInfo(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetSessionInfo(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -436,14 +440,14 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetSessionInfoByContinueSessionI MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetSessionInfoByContinueSessionId(data, reply); + auto res = + sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetSessionInfoByContinueSessionId(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); std::string continueSessionId = "testSessionId"; data.WriteString(continueSessionId); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetSessionInfoByContinueSessionId(data, reply); + res = + sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetSessionInfoByContinueSessionId(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -456,8 +460,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleTerminateSessionNew, TestSize.Le { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleTerminateSessionNew(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleTerminateSessionNew(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); } @@ -471,8 +474,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetFocusSessionToken, TestSize.L MessageParcel data; MessageParcel reply; data.WriteUint64(0); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetFocusSessionToken(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetFocusSessionToken(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -485,8 +487,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetFocusSessionToken1, TestSize. { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetFocusSessionToken(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetFocusSessionToken(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); } @@ -500,8 +501,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetFocusSessionElement, TestSize MessageParcel data; MessageParcel reply; data.WriteUint64(0); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetFocusSessionElement(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetFocusSessionElement(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -514,8 +514,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetFocusSessionElement1, TestSiz { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetFocusSessionElement(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetFocusSessionElement(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); } @@ -529,24 +528,21 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleSetSessionContinueState, TestSiz MessageParcel data; MessageParcel reply; - sptr token = nullptr; + sptr token = nullptr; data.WriteRemoteObject(token); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); int32_t continueStateValue = -3; data.WriteRemoteObject(token); data.WriteInt32(continueStateValue); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); continueStateValue = 1; data.WriteRemoteObject(token); data.WriteInt32(continueStateValue); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -561,8 +557,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleSetSessionContinueState1, TestSi MessageParcel reply; data.WriteRemoteObject(nullptr); data.WriteInt32(-2); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); EXPECT_EQ(res, ERR_INVALID_DATA); } @@ -578,8 +573,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleSetSessionContinueState2, TestSi sptr token = nullptr; data.WriteRemoteObject(token); data.WriteInt32(static_cast(ContinueState::CONTINUESTATE_MAX)); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleSetSessionContinueState(data, reply); EXPECT_EQ(res, ERR_NONE); uint32_t writtenError; EXPECT_TRUE(reply.ReadUint32(writtenError)); @@ -601,8 +595,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetSessionSnapshot, TestSize.Lev data.WriteInt32(persistentId); const bool isLowResolution = true; data.WriteBool(isLowResolution); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetSessionSnapshot(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetSessionSnapshot(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -616,14 +609,12 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleClearSession, TestSize.Level1) MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleClearSession(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleClearSession(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); int32_t persistentId = 0; data.WriteInt32(persistentId); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleClearSession(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleClearSession(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -636,8 +627,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleClearAllSessions, TestSize.Level { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleClearAllSessions(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleClearAllSessions(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -651,14 +641,12 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleLockSession, TestSize.Level1) MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleLockSession(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleLockSession(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); int32_t persistentId = 0; data.WriteInt32(persistentId); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleLockSession(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleLockSession(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -672,14 +660,12 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleUnlockSession, TestSize.Level1) MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleUnlockSession(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleUnlockSession(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); int32_t sessionId = 0; data.WriteInt32(sessionId); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleUnlockSession(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleUnlockSession(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -693,22 +679,19 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleMoveSessionsToForeground, TestSi MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); std::vector sessionIds; sessionIds.push_back(0); data.WriteInt32Vector(sessionIds); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(data, reply); EXPECT_EQ(ERR_TRANSACTION_FAILED, res); int32_t topSessionId = 0; data.WriteInt32Vector(sessionIds); data.WriteInt32(topSessionId); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -721,8 +704,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleMoveSessionsToBackground, TestSi { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -736,8 +718,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetFocusSessionInfo, TestSize.Le MessageParcel data; MessageParcel reply; data.WriteUint64(0); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -750,8 +731,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetFocusSessionInfo1, TestSize.L { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); } @@ -766,8 +746,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleCheckWindowId, TestSize.Level1) MessageParcel reply; int32_t numMax = 100; data.WriteInt32(numMax); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleCheckWindowId(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleCheckWindowId(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -781,23 +760,19 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleRegisterWindowManagerAgent, Test MessageParcel data; MessageParcel reply; data.WriteUint32(static_cast(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS)); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_NONE, res); data.WriteUint32(-100); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); data.WriteUint32(100); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); data.WriteUint32(5); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -811,23 +786,19 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleUnregisterWindowManagerAgent, Te MessageParcel data; MessageParcel reply; data.WriteUint32(static_cast(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS)); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_NONE, res); data.WriteUint32(-100); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); data.WriteUint32(100); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); data.WriteUint32(5); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -846,8 +817,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleListWindowInfo, TestSize.Level1) data.WriteUint8(static_cast(WindowInfoTypeOption::ALL)); data.WriteUint64(displayId); data.WriteInt32(windowId); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleListWindowInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleListWindowInfo(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -860,8 +830,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetVisibilityWindowInfo, TestSiz { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -876,8 +845,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetMainWinodowInfo, TestSize.Lev MessageParcel reply; int32_t numMax = 100; data.WriteInt32(numMax); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetMainWinodowInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetMainWinodowInfo(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -890,8 +858,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetAllMainWindowInfos, TestSize. { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -904,10 +871,9 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleClearMainSessions, TestSize.Leve { MessageParcel data; MessageParcel reply; - std::vector persistentIds = {1, 2, 3}; + std::vector persistentIds = { 1, 2, 3 }; data.WriteInt32Vector(persistentIds); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleClearMainSessions(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleClearMainSessions(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -922,8 +888,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleRaiseWindowToTop, TestSize.Level MessageParcel reply; int32_t persistentId = 65535; data.WriteInt32(persistentId); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleRaiseWindowToTop(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleRaiseWindowToTop(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -937,14 +902,13 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleTerminateSessionByPersistentId, MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(data, reply); + auto res = + sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(data, reply); EXPECT_EQ(ERR_INVALID_DATA, res); int32_t persistentId = 1; data.WriteInt32(persistentId); - res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(data, reply); + res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleTerminateSessionByPersistentId(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -957,8 +921,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetWindowStyleType, TestSize.Lev { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetWindowStyleType(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetWindowStyleType(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -972,8 +935,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleCloseTargetFloatWindow, TestSize MessageParcel data; MessageParcel reply; data.WriteString("test"); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleCloseTargetFloatWindow(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleCloseTargetFloatWindow(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -986,8 +948,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleCloseTargetPiPWindow, TestSize.L { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleCloseTargetPiPWindow(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleCloseTargetPiPWindow(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -1000,8 +961,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetCurrentPiPWindowInfo, TestSiz { MessageParcel data; MessageParcel reply; - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetCurrentPiPWindowInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetCurrentPiPWindowInfo(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -1016,8 +976,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleGetRootMainWindowId, TestSize.Le MessageParcel reply; int32_t persistentId = 1; data.WriteInt32(persistentId); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleGetRootMainWindowId(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleGetRootMainWindowId(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -1044,8 +1003,7 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleNotifyAppUseControlList, TestSiz data.WriteInt32(appIndex); data.WriteBool(isControl); - auto res = sceneSessionManagerLiteStub_-> - SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleNotifyAppUseControlList(data, reply); EXPECT_EQ(ERR_NONE, res); } @@ -1091,10 +1049,9 @@ HWTEST_F(SceneSessionManagerLiteStubTest, HandleLockSessionByAbilityInfo, TestSi data.WriteInt32(appIndex); data.WriteBool(isLock); - auto res = - sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleLockSessionByAbilityInfo(data, reply); + auto res = sceneSessionManagerLiteStub_->SceneSessionManagerLiteStub::HandleLockSessionByAbilityInfo(data, reply); EXPECT_EQ(ERR_NONE, res); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_lite_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_test.cpp index 3758121e15..ac27bd3d9d 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_test.cpp @@ -31,21 +31,13 @@ public: void TearDown() override; }; -void SceneSessionManagerLiteTest::SetUpTestCase() -{ -} +void SceneSessionManagerLiteTest::SetUpTestCase() {} -void SceneSessionManagerLiteTest::TearDownTestCase() -{ -} +void SceneSessionManagerLiteTest::TearDownTestCase() {} -void SceneSessionManagerLiteTest::SetUp() -{ -} +void SceneSessionManagerLiteTest::SetUp() {} -void SceneSessionManagerLiteTest::TearDown() -{ -} +void SceneSessionManagerLiteTest::TearDown() {} namespace { /** @@ -60,6 +52,6 @@ HWTEST_F(SceneSessionManagerLiteTest, GetInstance, TestSize.Level1) SceneSessionManagerLite& instance2 = SceneSessionManagerLite::GetInstance(); EXPECT_EQ(&instance1, &instance2); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_proxy_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_manager_proxy_lifecycle_test.cpp index 3198768fe8..ed7da8606a 100644 --- a/window_scene/test/unittest/scene_session_manager_proxy_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_proxy_lifecycle_test.cpp @@ -37,21 +37,13 @@ public: sptr iRemoteObjectMocker; }; -void sceneSessionManagerProxyLifecycleTest::SetUpTestCase() -{ -} +void sceneSessionManagerProxyLifecycleTest::SetUpTestCase() {} -void sceneSessionManagerProxyLifecycleTest::TearDownTestCase() -{ -} +void sceneSessionManagerProxyLifecycleTest::TearDownTestCase() {} -void sceneSessionManagerProxyLifecycleTest::SetUp() -{ -} +void sceneSessionManagerProxyLifecycleTest::SetUp() {} -void sceneSessionManagerProxyLifecycleTest::TearDown() -{ -} +void sceneSessionManagerProxyLifecycleTest::TearDown() {} namespace { /** @@ -68,8 +60,8 @@ HWTEST_F(sceneSessionManagerProxyLifecycleTest, UpdateSessionWindowVisibilityLis sptr::MakeSptr(iRemoteObjectMocker); EXPECT_NE(sceneSessionManagerProxy, nullptr); - ASSERT_EQ(WSError::WS_OK, sceneSessionManagerProxy->UpdateSessionWindowVisibilityListener(persistentId, - haveListener)); + ASSERT_EQ(WSError::WS_OK, + sceneSessionManagerProxy->UpdateSessionWindowVisibilityListener(persistentId, haveListener)); } /** @@ -102,7 +94,7 @@ HWTEST_F(sceneSessionManagerProxyLifecycleTest, PendingSessionToBackgroundForDel EXPECT_NE(sceneSessionManagerProxy, nullptr); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, - sceneSessionManagerProxy->PendingSessionToBackgroundForDelegator(token, true)); + sceneSessionManagerProxy->PendingSessionToBackgroundForDelegator(token, true)); } /** @@ -120,6 +112,6 @@ HWTEST_F(sceneSessionManagerProxyLifecycleTest, GetVisibilityWindowInfo, TestSiz std::vector> infos; ASSERT_EQ(WMError::WM_OK, sceneSessionManagerProxy->GetVisibilityWindowInfo(infos)); } -} // namespace -} -} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_proxy_test.cpp b/window_scene/test/unittest/scene_session_manager_proxy_test.cpp index 5dbb38a096..a9b2f6ea9f 100644 --- a/window_scene/test/unittest/scene_session_manager_proxy_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_proxy_test.cpp @@ -37,21 +37,13 @@ public: sptr iRemoteObjectMocker; }; -void sceneSessionManagerProxyTest::SetUpTestCase() -{ -} +void sceneSessionManagerProxyTest::SetUpTestCase() {} -void sceneSessionManagerProxyTest::TearDownTestCase() -{ -} +void sceneSessionManagerProxyTest::TearDownTestCase() {} -void sceneSessionManagerProxyTest::SetUp() -{ -} +void sceneSessionManagerProxyTest::SetUp() {} -void sceneSessionManagerProxyTest::TearDown() -{ -} +void sceneSessionManagerProxyTest::TearDown() {} namespace { /** @@ -77,8 +69,8 @@ HWTEST_F(sceneSessionManagerProxyTest, CreateAndConnectSpecificSession, TestSize SystemSessionConfig systemConfig; sptr token = sptr::MakeSptr(); - sceneSessionManagerProxy->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, - persistentId, session, systemConfig, token); + sceneSessionManagerProxy->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, persistentId, session, systemConfig, token); EXPECT_NE(sceneSessionManagerProxy, nullptr); } @@ -104,8 +96,8 @@ HWTEST_F(sceneSessionManagerProxyTest, CreateAndConnectSpecificSession2, TestSiz SystemSessionConfig systemConfig; sptr token = sptr::MakeSptr(); - sceneSessionManagerProxy->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, - persistentId, session, systemConfig, token); + sceneSessionManagerProxy->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, persistentId, session, systemConfig, token); EXPECT_NE(sceneSessionManagerProxy, nullptr); } @@ -132,8 +124,8 @@ HWTEST_F(sceneSessionManagerProxyTest, CreateAndConnectSpecificSession3, TestSiz SystemSessionConfig systemConfig; sptr token = sptr::MakeSptr(); - sceneSessionManagerProxy->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, - persistentId, session, systemConfig, token); + sceneSessionManagerProxy->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, persistentId, session, systemConfig, token); EXPECT_NE(sceneSessionManagerProxy, nullptr); } @@ -160,8 +152,8 @@ HWTEST_F(sceneSessionManagerProxyTest, CreateAndConnectSpecificSession4, TestSiz SystemSessionConfig systemConfig; sptr token = nullptr; - sceneSessionManagerProxy->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, - persistentId, session, systemConfig, token); + sceneSessionManagerProxy->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, persistentId, session, systemConfig, token); EXPECT_NE(sceneSessionManagerProxy, nullptr); } @@ -184,8 +176,8 @@ HWTEST_F(sceneSessionManagerProxyTest, RecoverAndConnectSpecificSession, TestSiz sptr session = sptr::MakeSptr(info); sptr token = sptr::MakeSptr(); - auto ret = sceneSessionManagerProxy->RecoverAndConnectSpecificSession(sessionStage, eventChannel, node, property, - session, token); + auto ret = sceneSessionManagerProxy->RecoverAndConnectSpecificSession( + sessionStage, eventChannel, node, property, session, token); EXPECT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); } @@ -208,8 +200,8 @@ HWTEST_F(sceneSessionManagerProxyTest, RecoverAndConnectSpecificSession2, TestSi sptr session = sptr::MakeSptr(info); sptr token = sptr::MakeSptr(); - auto ret = sceneSessionManagerProxy->RecoverAndConnectSpecificSession(sessionStage, eventChannel, node, property, - session, token); + auto ret = sceneSessionManagerProxy->RecoverAndConnectSpecificSession( + sessionStage, eventChannel, node, property, session, token); EXPECT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); } @@ -232,8 +224,8 @@ HWTEST_F(sceneSessionManagerProxyTest, RecoverAndConnectSpecificSession3, TestSi sptr session = sptr::MakeSptr(info); sptr token = nullptr; - auto ret = sceneSessionManagerProxy->RecoverAndConnectSpecificSession(sessionStage, eventChannel, node, property, - session, token); + auto ret = sceneSessionManagerProxy->RecoverAndConnectSpecificSession( + sessionStage, eventChannel, node, property, session, token); EXPECT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); } @@ -256,8 +248,8 @@ HWTEST_F(sceneSessionManagerProxyTest, RecoverAndReconnectSceneSession, TestSize sptr session = sptr::MakeSptr(info); sptr token = sptr::MakeSptr(); - auto ret = sceneSessionManagerProxy->RecoverAndReconnectSceneSession(sessionStage, eventChannel, node, session, - property, token); + auto ret = sceneSessionManagerProxy->RecoverAndReconnectSceneSession( + sessionStage, eventChannel, node, session, property, token); EXPECT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); } @@ -280,8 +272,8 @@ HWTEST_F(sceneSessionManagerProxyTest, RecoverAndReconnectSceneSession2, TestSiz sptr session = sptr::MakeSptr(info); sptr token = sptr::MakeSptr(); - auto ret = sceneSessionManagerProxy->RecoverAndReconnectSceneSession(sessionStage, eventChannel, node, session, - property, token); + auto ret = sceneSessionManagerProxy->RecoverAndReconnectSceneSession( + sessionStage, eventChannel, node, session, property, token); EXPECT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); } @@ -304,8 +296,8 @@ HWTEST_F(sceneSessionManagerProxyTest, RecoverAndReconnectSceneSession3, TestSiz sptr session = sptr::MakeSptr(info); sptr token = nullptr; - auto ret = sceneSessionManagerProxy->RecoverAndReconnectSceneSession(sessionStage, eventChannel, node, session, - property, token); + auto ret = sceneSessionManagerProxy->RecoverAndReconnectSceneSession( + sessionStage, eventChannel, node, session, property, token); EXPECT_EQ(ret, WSError::WS_ERROR_IPC_FAILED); } @@ -330,11 +322,7 @@ HWTEST_F(sceneSessionManagerProxyTest, DestroyAndDisconnectSpecificSession, Test * @tc.desc: normal function * @tc.type: FUNC */ -HWTEST_F( - sceneSessionManagerProxyTest, - DestroyAndDisconnectSpecificSessionWithDetachCallback, - TestSize.Level1 -) +HWTEST_F(sceneSessionManagerProxyTest, DestroyAndDisconnectSpecificSessionWithDetachCallback, TestSize.Level1) { sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sceneSessionManagerProxy = @@ -533,7 +521,7 @@ HWTEST_F(sceneSessionManagerProxyTest, UpdateModalExtensionRect, TestSize.Level1 sptr token = sptr::MakeSptr(); ASSERT_NE(token, nullptr); - Rect rect { 1, 2, 3, 4 }; + Rect rect{ 1, 2, 3, 4 }; sceneSessionManagerProxy->UpdateModalExtensionRect(token, rect); sceneSessionManagerProxy->UpdateModalExtensionRect(nullptr, rect); } @@ -639,7 +627,7 @@ HWTEST_F(sceneSessionManagerProxyTest, GetSessionInfoByContinueSessionId, TestSi std::string continueSessionId = "test_01"; SessionInfoBean missionInfo; ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, - sceneSessionManagerProxy->GetSessionInfoByContinueSessionId(continueSessionId, missionInfo)); + sceneSessionManagerProxy->GetSessionInfoByContinueSessionId(continueSessionId, missionInfo)); } /** @@ -736,8 +724,7 @@ HWTEST_F(sceneSessionManagerProxyTest, UpdateSessionAvoidAreaListener, TestSize. sptr iRemoteObjectMocker = sptr::MakeSptr(); auto sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); - ASSERT_EQ(WSError::WS_OK, sceneSessionManagerProxy->UpdateSessionAvoidAreaListener(persistendId, - haveListener)); + ASSERT_EQ(WSError::WS_OK, sceneSessionManagerProxy->UpdateSessionAvoidAreaListener(persistendId, haveListener)); } /** @@ -982,10 +969,10 @@ HWTEST_F(sceneSessionManagerProxyTest, GetProcessSurfaceNodeIdByPersistentId, Te auto sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); int32_t pid = 123; - std::vector persistentIds = {1, 2, 3}; + std::vector persistentIds = { 1, 2, 3 }; std::vector surfaceNodeIds; - ASSERT_EQ(WMError::WM_OK, sceneSessionManagerProxy->GetProcessSurfaceNodeIdByPersistentId( - pid, persistentIds, surfaceNodeIds)); + ASSERT_EQ(WMError::WM_OK, + sceneSessionManagerProxy->GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds)); } /** @@ -999,9 +986,8 @@ HWTEST_F(sceneSessionManagerProxyTest, SkipSnapshotByUserIdAndBundleNames, TestS auto sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); int32_t userId = 1; - std::vector bundleNameList = {"a", "b", "c"}; - ASSERT_EQ(WMError::WM_OK, sceneSessionManagerProxy->SkipSnapshotByUserIdAndBundleNames( - userId, bundleNameList)); + std::vector bundleNameList = { "a", "b", "c" }; + ASSERT_EQ(WMError::WM_OK, sceneSessionManagerProxy->SkipSnapshotByUserIdAndBundleNames(userId, bundleNameList)); } /** @@ -1029,7 +1015,7 @@ HWTEST_F(sceneSessionManagerProxyTest, AddSkipSelfWhenShowOnVirtualScreenList, F sptr sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); EXPECT_NE(sceneSessionManagerProxy, nullptr); - std::vector persistentIds {0, 1, 2}; + std::vector persistentIds{ 0, 1, 2 }; ASSERT_EQ(sceneSessionManagerProxy->AddSkipSelfWhenShowOnVirtualScreenList(persistentIds), WMError::WM_OK); } @@ -1044,7 +1030,7 @@ HWTEST_F(sceneSessionManagerProxyTest, RemoveSkipSelfWhenShowOnVirtualScreenList sptr sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); EXPECT_NE(sceneSessionManagerProxy, nullptr); - std::vector persistentIds {0, 1, 2}; + std::vector persistentIds{ 0, 1, 2 }; ASSERT_EQ(sceneSessionManagerProxy->RemoveSkipSelfWhenShowOnVirtualScreenList(persistentIds), WMError::WM_OK); } @@ -1058,8 +1044,7 @@ HWTEST_F(sceneSessionManagerProxyTest, IsPcWindow, TestSize.Level1) sptr iRemoteObjectMocker = sptr::MakeSptr(); auto sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isPcWindow = false; - ASSERT_EQ(sceneSessionManagerProxy->IsPcWindow(isPcWindow), - WMError::WM_ERROR_IPC_FAILED); + ASSERT_EQ(sceneSessionManagerProxy->IsPcWindow(isPcWindow), WMError::WM_ERROR_IPC_FAILED); ASSERT_EQ(isPcWindow, false); } @@ -1074,7 +1059,7 @@ HWTEST_F(sceneSessionManagerProxyTest, IsPcOrPadFreeMultiWindowMode, TestSize.Le auto sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); bool isPcOrPadFreeMultiWindowMode = false; ASSERT_EQ(sceneSessionManagerProxy->IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode), - WMError::WM_ERROR_IPC_FAILED); + WMError::WM_ERROR_IPC_FAILED); ASSERT_EQ(isPcOrPadFreeMultiWindowMode, false); } @@ -1105,7 +1090,7 @@ HWTEST_F(sceneSessionManagerProxyTest, GetDisplayIdByWindowId, TestSize.Level1) sptr sceneSessionManagerProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_TRUE(sceneSessionManagerProxy != nullptr); - const std::vector windowIds = {1, 2}; + const std::vector windowIds = { 1, 2 }; std::unordered_map windowDisplayIdMap; sceneSessionManagerProxy->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap); } @@ -1510,6 +1495,6 @@ HWTEST_F(sceneSessionManagerProxyTest, SetForegroundWindowNum, TestSize.Level1) res = sceneSessionManagerProxy->SetForegroundWindowNum(windowNum); ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, res); } -} // namespace -} -} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp index 611b3878b2..3d3dd0ee3c 100644 --- a/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_stub_lifecycle_test.cpp @@ -38,17 +38,14 @@ public: void SetUp() override; void TearDown() override; sptr stub_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void SceneSessionManagerStubLifecycleTest::SetUpTestCase() -{ -} +void SceneSessionManagerStubLifecycleTest::SetUpTestCase() {} -void SceneSessionManagerStubLifecycleTest::TearDownTestCase() -{ -} +void SceneSessionManagerStubLifecycleTest::TearDownTestCase() {} void SceneSessionManagerStubLifecycleTest::SetUp() { @@ -129,11 +126,7 @@ HWTEST_F(SceneSessionManagerStubLifecycleTest, HandlePendingSessionToForeground, * @tc.desc: test HandlePendingSessionToBackgroundForDelegator * @tc.type: FUNC */ -HWTEST_F( - SceneSessionManagerStubLifecycleTest, - HandlePendingSessionToBackgroundForDelegator, - TestSize.Level1 -) +HWTEST_F(SceneSessionManagerStubLifecycleTest, HandlePendingSessionToBackgroundForDelegator, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -283,7 +276,7 @@ HWTEST_F(SceneSessionManagerStubLifecycleTest, HandleMoveSessionsToForeground, T auto res = stub_->HandleMoveSessionsToForeground(data, reply); EXPECT_EQ(res, ERR_INVALID_DATA); - std::vector sessionIds = {1, 2, 3, 15, 1423}; + std::vector sessionIds = { 1, 2, 3, 15, 1423 }; data.WriteInt32Vector(sessionIds); int32_t topSessionId = 1; data.WriteInt32(topSessionId); @@ -305,9 +298,9 @@ HWTEST_F(SceneSessionManagerStubLifecycleTest, HandleMoveSessionsToBackground, T MessageParcel data; MessageParcel reply; - std::vector sessionIds = {1, 2, 3, 15, 1423}; + std::vector sessionIds = { 1, 2, 3, 15, 1423 }; data.WriteInt32Vector(sessionIds); - std::vector result = {1, 2, 3, 15, 1423}; + std::vector result = { 1, 2, 3, 15, 1423 }; data.WriteInt32Vector(result); int res = stub_->HandleMoveSessionsToBackground(data, reply); @@ -319,11 +312,7 @@ HWTEST_F(SceneSessionManagerStubLifecycleTest, HandleMoveSessionsToBackground, T * @tc.desc: test HandleUpdateSessionWindowVisibilityListener * @tc.type: FUNC */ -HWTEST_F( - SceneSessionManagerStubLifecycleTest, - HandleUpdateSessionWindowVisibilityListener, - TestSize.Level1 -) +HWTEST_F(SceneSessionManagerStubLifecycleTest, HandleUpdateSessionWindowVisibilityListener, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -352,6 +341,6 @@ HWTEST_F(SceneSessionManagerStubLifecycleTest, HandleGetVisibilityWindowInfo, Te int res = stub_->HandleGetVisibilityWindowInfo(data, reply); EXPECT_EQ(res, ERR_NONE); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_stub_test.cpp index b8762df7a2..f614e788bc 100644 --- a/window_scene/test/unittest/scene_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_stub_test.cpp @@ -38,17 +38,14 @@ public: void SetUp() override; void TearDown() override; sptr stub_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void SceneSessionManagerStubTest::SetUpTestCase() -{ -} +void SceneSessionManagerStubTest::SetUpTestCase() {} -void SceneSessionManagerStubTest::TearDownTestCase() -{ -} +void SceneSessionManagerStubTest::TearDownTestCase() {} void SceneSessionManagerStubTest::SetUp() { @@ -223,8 +220,7 @@ HWTEST_F(SceneSessionManagerStubTest, TransIdDestroyAndDisconnectSpecificSession * @tc.desc: test TransIdDestroyAndDisconnectSpecificSessionWithDetachCallback * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerStubTest, TransIdDestroyAndDisconnectSpecificSessionWithDetachCallback, - TestSize.Level1) +HWTEST_F(SceneSessionManagerStubTest, TransIdDestroyAndDisconnectSpecificSessionWithDetachCallback, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -363,7 +359,7 @@ HWTEST_F(SceneSessionManagerStubTest, TransIdIsValidSessionIds, TestSize.Level1) MessageOption option; data.WriteInterfaceToken(SceneSessionManagerStub::GetDescriptor()); - std::vector points{0, 0}; + std::vector points{ 0, 0 }; data.WriteInt32Vector(points); uint32_t code = @@ -802,7 +798,7 @@ HWTEST_F(SceneSessionManagerStubTest, TransIdGetSessionDump, TestSize.Level1) MessageOption option; data.WriteInterfaceToken(SceneSessionManagerStub::GetDescriptor()); - std::vector params = {"-a"}; + std::vector params = { "-a" }; data.WriteStringVector(params); stub_->HandleGetSessionDump(data, reply); @@ -1062,8 +1058,8 @@ HWTEST_F(SceneSessionManagerStubTest, OnRemoteRequest01, TestSize.Level1) sptr windowManagerAgent = sptr::MakeSptr(); data.WriteRemoteObject(windowManagerAgent->AsObject()); - uint32_t code = static_cast( - ISceneSessionManager::SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT); + uint32_t code = + static_cast(ISceneSessionManager::SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); @@ -1202,8 +1198,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleDestroyAndDisconnectSpcificSession, * @tc.desc: test HandleDestroyAndDisconnectSpcificSessionWithDetachCallback * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerStubTest, HandleDestroyAndDisconnectSpcificSessionWithDetachCallback, - TestSize.Level1) +HWTEST_F(SceneSessionManagerStubTest, HandleDestroyAndDisconnectSpcificSessionWithDetachCallback, TestSize.Level1) { MessageParcel data; MessageParcel reply; @@ -1421,7 +1416,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleIsValidSessionIds, TestSize.Level1) MessageParcel data; MessageParcel reply; - std::vector points {0, 0}; + std::vector points{ 0, 0 }; data.WriteInt32Vector(points); int res = stub_->HandleIsValidSessionIds(data, reply); EXPECT_EQ(res, ERR_NONE); @@ -1655,7 +1650,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleGetSessionDump, TestSize.Level1) MessageParcel data; MessageParcel reply; - std::vector params = {"-a"}; + std::vector params = { "-a" }; data.WriteStringVector(params); stub_->HandleGetSessionDump(data, reply); @@ -1778,7 +1773,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleNotifyDumpInfoResult, TestSize.Level data.WriteUint32(vectorSize); stub_->HandleNotifyDumpInfoResult(data, reply); - std::vector info = {"-a", "-b123", "-c3456789", ""}; + std::vector info = { "-a", "-b123", "-c3456789", "" }; vectorSize = static_cast(info.size()); data.WriteUint32(vectorSize); uint32_t curSize; @@ -2034,7 +2029,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleUpdateModalExtensionRect, TestSize.L sptr token = nullptr; data.WriteRemoteObject(token); - Rect rect { 1, 2, 3, 4 }; + Rect rect{ 1, 2, 3, 4 }; data.WriteInt32(rect.posX_); data.WriteInt32(rect.posY_); data.WriteInt32(rect.width_); @@ -2248,7 +2243,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleGetProcessSurfaceNodeIdByPersistentI MessageParcel data; MessageParcel reply; int32_t pid = 123; - std::vector persistentIds = {1, 2, 3}; + std::vector persistentIds = { 1, 2, 3 }; std::vector surfaceNodeIds; data.WriteInterfaceToken(SceneSessionManagerStub::GetDescriptor()); data.WriteInt32(pid); @@ -2268,7 +2263,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleSkipSnapshotByUserIdAndBundleNames, MessageParcel data; MessageParcel reply; int32_t userId = 100; - std::vector bundleNameList = {"a", "b", "c"}; + std::vector bundleNameList = { "a", "b", "c" }; data.WriteInterfaceToken(SceneSessionManagerStub::GetDescriptor()); data.WriteInt32(userId); data.WriteStringVector(bundleNameList); @@ -2373,7 +2368,7 @@ HWTEST_F(SceneSessionManagerStubTest, HandleGetDisplayIdByWindowId, TestSize.Lev { MessageParcel data; MessageParcel reply; - const std::vector windowIds = {1, 2}; + const std::vector windowIds = { 1, 2 }; data.WriteUInt64Vector(windowIds); int res = stub_->HandleGetDisplayIdByWindowId(data, reply); @@ -2522,6 +2517,6 @@ HWTEST_F(SceneSessionManagerStubTest, HandleSetForegroundWindowNum, TestSize.Lev int res = stub_->HandleSetForegroundWindowNum(data, reply); EXPECT_EQ(res, ERR_NONE); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp index 2e8a008576..964cd0c355 100644 --- a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp @@ -133,7 +133,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithNullSceneSession { ssm_->systemConfig_.freeMultiWindowSupport_ = true; sptr sceneSession; - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); auto res = ssm_->SwitchFreeMultiWindow(false); ASSERT_EQ(res, WSError::WS_OK); @@ -153,7 +153,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithSceneSession, Te sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName"; sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName"; sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); auto res = ssm_->SwitchFreeMultiWindow(false); ASSERT_EQ(res, WSError::WS_OK); @@ -173,7 +173,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithProperty, TestSi sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName"; sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName"; sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr property = sptr::MakeSptr(); ASSERT_NE(property, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW); @@ -197,7 +197,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestSwitchWindowWithPropertyInputTru sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName"; sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName"; sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr property = sptr::MakeSptr(); ASSERT_NE(property, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW); @@ -228,8 +228,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestSetEnableInputEventWithInputTrue * @tc.desc: SceneSessionManagerSupplementTest RequestSceneSessionActivationInner * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInner, - TestSize.Level1) +HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInner, TestSize.Level1) { SessionInfo sessionInfo; sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName"; @@ -251,8 +250,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInner, * @tc.desc: SceneSessionManagerSupplementTest RequestSceneSessionActivationInner * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInnerTest_01, - TestSize.Level1) +HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInnerTest_01, TestSize.Level1) { SessionInfo sessionInfo; sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName"; @@ -275,8 +273,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, RequestSceneSessionActivationInnerTe * @tc.desc: SceneSessionManagerSupplementTest NotifyCollaboratorAfterStart * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerSupplementTest, NotifyCollaboratorAfterStart, - TestSize.Level1) +HWTEST_F(SceneSessionManagerSupplementTest, NotifyCollaboratorAfterStart, TestSize.Level1) { sptr sceneSession; sptr sceneSessionInfo; @@ -302,7 +299,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, NotifyCollaboratorAfterStart, ret = ssm_->RequestSceneSessionBackground(sceneSession, false, false); ASSERT_EQ(ret, WSError::WS_OK); ssm_->brightnessSessionId_ = 0; - ssm_->systemConfig_.backgroundswitch = true; + ssm_->systemConfig_.backgroundswitch = true; ret = ssm_->RequestSceneSessionBackground(sceneSession, true, true); ASSERT_EQ(ret, WSError::WS_OK); ret = ssm_->RequestSceneSessionBackground(sceneSession, true, false); @@ -317,7 +314,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, NotifyCollaboratorAfterStart, ASSERT_EQ(ret, WSError::WS_OK); ssm_->NotifyForegroundInteractiveStatus(sceneSession, true); ssm_->NotifyForegroundInteractiveStatus(sceneSession, false); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ssm_->NotifyForegroundInteractiveStatus(sceneSession, true); } @@ -434,7 +431,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyDialogWithMainWindow_05, ssm_->DestroySubSession(sceneSession); ssm_->RequestSceneSessionDestruction(sceneSession, true); ssm_->RequestSceneSessionDestruction(sceneSession, false); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); auto res = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(res, WSError::WS_OK); } @@ -515,7 +512,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, DestroyDialogWithTrueType_01, TestSi sceneSession->subSession_.push_back(sceneSession2); sceneSession2 = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession2, nullptr); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); auto res = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(res, WSError::WS_OK); } @@ -536,8 +533,8 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_01, Test sptr token; int32_t id = 0; - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR); } @@ -559,8 +556,8 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_02, Test int32_t id = 0; property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(res, WSError::WS_ERROR_NOT_SYSTEM_APP); } @@ -582,8 +579,8 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_03, Test int32_t id = 0; property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR); } @@ -606,8 +603,8 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_04, Test property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); property->SetFloatingWindowAppType(true); - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(res, WSError::WS_ERROR_NOT_SYSTEM_APP); } @@ -631,8 +628,8 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_05, Test property->SetFloatingWindowAppType(true); property->SetIsUIExtFirstSubWindow(true); - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR); } @@ -656,8 +653,8 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_06, Test property->SetFloatingWindowAppType(true); property->SetIsUIExtFirstSubWindow(true); - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(res, WSError::WS_ERROR_INVALID_WINDOW); } @@ -681,8 +678,8 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCreateAndConnectSession_07, Test property->SetFloatingWindowAppType(true); property->SetIsUIExtFirstSubWindow(true); - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(res, WSError::WS_DO_NOTHING); } @@ -708,7 +705,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, ClosePipWindowIfExist, TestSize.Leve pipInfo.priority = 0; auto res = ssm_->CheckPiPPriority(pipInfo); ASSERT_EQ(res, true); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ssm_->ClosePipWindowIfExist(WindowType::WINDOW_TYPE_PIP); res = ssm_->CheckPiPPriority(pipInfo); ASSERT_EQ(res, true); @@ -874,7 +871,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, SetAlivePersistentIdsWithNoId, TestS */ HWTEST_F(SceneSessionManagerSupplementTest, SetAlivePersistentIdsWithIds, TestSize.Level1) { - std::vector alivePersistentIds = {0, 1, 2}; + std::vector alivePersistentIds = { 0, 1, 2 }; ASSERT_NE(ssm_, nullptr); ssm_->SetAlivePersistentIds(alivePersistentIds); ASSERT_EQ(ssm_->alivePersistentIds_, alivePersistentIds); @@ -1021,7 +1018,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecoverin property->SetParentPersistentId(1); NotifyCreateSubSessionFunc func; ssm_->createSubSessionFuncMap_.clear(); - ssm_->createSubSessionFuncMap_.insert({1, func}); + ssm_->createSubSessionFuncMap_.insert({ 1, func }); ssm_->CacheSpecificSessionForRecovering(sceneSession, property); ASSERT_EQ(ssm_->recoverSubSessionCacheMap_.size(), 0); ssm_->createSubSessionFuncMap_.clear(); @@ -1045,7 +1042,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestCacheSpecificSessionForRecoverin property->SetParentPersistentId(1); NotifyCreateSubSessionFunc func; ssm_->bindDialogTargetFuncMap_.clear(); - ssm_->bindDialogTargetFuncMap_.insert({1, func}); + ssm_->bindDialogTargetFuncMap_.insert({ 1, func }); ssm_->CacheSpecificSessionForRecovering(sceneSession, property); ASSERT_EQ(ssm_->recoverDialogSessionCacheMap_.size(), 0); } @@ -1186,7 +1183,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, NotifyCreateSpecificSession, TestSiz info1.bundleName_ = "test3"; info1.abilityName_ = "test3"; sptr sceneSession2 = sptr::MakeSptr(info1, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession2 }); ASSERT_TRUE(ssm_->sceneSessionMap_.find(1) != ssm_->sceneSessionMap_.end()); ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_FLOAT); ssm_->NotifyCreateSpecificSession(sceneSession, property, WindowType::WINDOW_TYPE_DIALOG); @@ -1217,7 +1214,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, NotifyCreateSubSession, TestSize.Lev sptr sceneSession1 = sptr::MakeSptr(info1, nullptr); ASSERT_NE(sceneSession1, nullptr); NotifyCreateSubSessionFunc func; - ssm_->createSubSessionFuncMap_.insert({1, func}); + ssm_->createSubSessionFuncMap_.insert({ 1, func }); ssm_->NotifyCreateSubSession(1, sceneSession); ssm_->UnregisterSpecificSessionCreateListener(1); ssm_->createSubSessionFuncMap_.clear(); @@ -1226,7 +1223,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, NotifyCreateSubSession, TestSize.Lev ASSERT_NE(property, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); sceneSession->SetSessionProperty(property); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ASSERT_TRUE(ssm_->sceneSessionMap_.find(1) != ssm_->sceneSessionMap_.end()); ssm_->NotifySessionTouchOutside(1); sceneSession->state_ = SessionState::STATE_FOREGROUND; @@ -1266,7 +1263,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyAndDisconSpecSessionInner sptr sceneSession = sptr::MakeSptr(info, nullptr); uint32_t uid = 0; ssm_->GetTopWindowId(1, uid); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->GetTopWindowId(1, uid); auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1); ASSERT_EQ(ret, WSError::WS_OK); @@ -1286,7 +1283,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyAndDisconSpecSessionInner sptr sceneSession = sptr::MakeSptr(info, nullptr); uint32_t uid = 0; ssm_->GetTopWindowId(1, uid); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->GetTopWindowId(1, uid); sptr property = sptr::MakeSptr(); property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); @@ -1311,7 +1308,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestDestroyAndDisconSpecSessionInner sptr sceneSession = sptr::MakeSptr(info, nullptr); uint32_t uid = 0; ssm_->GetTopWindowId(1, uid); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->GetTopWindowId(1, uid); sptr property = sptr::MakeSptr(); property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); @@ -1357,7 +1354,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, GetFocusWindowInfo, TestSize.Level1) ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ret = ssm_->UpdateBrightness(1); ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); property->SetBrightness(-1.f); property->SetWindowType(WindowType::APP_WINDOW_BASE); sceneSession->SetSessionProperty(property); @@ -1442,7 +1439,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_04, TestSize.Le SessionInfo info1; info1.bundleName_ = "test3"; sptr sceneSession1 = sptr::MakeSptr(info1, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession1}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession1 }); property->SetParentPersistentId(100); sceneSession->SetSessionProperty(property); sceneSession->SetParentSession(sceneSession1); @@ -1470,7 +1467,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_05, TestSize.Le SessionInfo info1; info1.bundleName_ = "test3"; sptr sceneSession1 = sptr::MakeSptr(info1, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession1}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession1 }); property->SetParentPersistentId(1); sceneSession->SetSessionProperty(property); sceneSession->SetParentSession(sceneSession1); @@ -1500,7 +1497,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_06, TestSize.Le SessionInfo info1; info1.bundleName_ = "test3"; sptr sceneSession1 = sptr::MakeSptr(info1, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession1}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession1 }); property->SetParentPersistentId(1); sceneSession->SetSessionProperty(property); sceneSession->SetParentSession(sceneSession1); @@ -1530,7 +1527,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, TestIsSessionVisible_07, TestSize.Le SessionInfo info1; info1.bundleName_ = "test3"; sptr sceneSession1 = sptr::MakeSptr(info1, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession1}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession1 }); property->SetParentPersistentId(1); sceneSession->SetSessionProperty(property); sceneSession->SetParentSession(sceneSession1); @@ -1615,6 +1612,6 @@ HWTEST_F(SceneSessionManagerSupplementTest, RegisterBindDialogTargetListener, Te ssm_->bindDialogTargetFuncMap_.clear(); ASSERT_EQ(ssm_->bindDialogTargetFuncMap_.find(persistentId), ssm_->bindDialogTargetFuncMap_.end()); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index efa6a58444..6d1ad6ba25 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -52,6 +52,7 @@ public: static bool gestureNavigationEnabled_; static ProcessGestureNavigationEnabledChangeFunc callbackFunc_; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; static constexpr uint32_t WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS = 500000; @@ -61,22 +62,14 @@ private: sptr SceneSessionManagerTest::ssm_ = nullptr; bool SceneSessionManagerTest::gestureNavigationEnabled_ = true; -ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest::callbackFunc_ = [](bool enable, - const std::string& bundleName, GestureBackType type) { - gestureNavigationEnabled_ = enable; -}; +ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest::callbackFunc_ = + [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} -void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) -{ -} +void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) {} void SceneSessionManagerTest::SetUpTestCase() { @@ -153,14 +146,14 @@ HWTEST_F(SceneSessionManagerTest, GerPrivacyBundleListTwoWindow, TestSize.Level1 sessionInfoFirst.abilityName_ = "privacyAbilityName"; sptr sceneSessionFirst = ssm_->CreateSceneSession(sessionInfoFirst, nullptr); ASSERT_NE(sceneSessionFirst, nullptr); - ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst}); + ssm_->sceneSessionMap_.insert({ sceneSessionFirst->GetPersistentId(), sceneSessionFirst }); SessionInfo sessionInfoSecond; sessionInfoSecond.bundleName_ = "privacy.test.second"; sessionInfoSecond.abilityName_ = "privacyAbilityName"; sptr sceneSessionSecond = ssm_->CreateSceneSession(sessionInfoSecond, nullptr); ASSERT_NE(sceneSessionSecond, nullptr); - ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond}); + ssm_->sceneSessionMap_.insert({ sceneSessionSecond->GetPersistentId(), sceneSessionSecond }); sceneSessionFirst->GetSessionProperty()->displayId_ = 0; sceneSessionFirst->GetSessionProperty()->isPrivacyMode_ = true; @@ -260,7 +253,7 @@ HWTEST_F(SceneSessionManagerTest, NotifyWaterMarkFlagChangedResult, TestSize.Lev */ HWTEST_F(SceneSessionManagerTest, IsValidSessionIds, TestSize.Level1) { - std::vector sessionIds = {0, 1, 2, 3, 4, 5, 24, 10086}; + std::vector sessionIds = { 0, 1, 2, 3, 4, 5, 24, 10086 }; std::vector results = {}; WSError result = ssm_->IsValidSessionIds(sessionIds, results); EXPECT_EQ(result, WSError::WS_OK); @@ -292,7 +285,7 @@ HWTEST_F(SceneSessionManagerTest, GetSessionInfos01, TestSize.Level1) infoFrist.label = "fristBundleName"; AAFwk::MissionInfo infoSecond; infoSecond.label = "secondBundleName"; - std::vector sessionInfos = {infoFrist, infoSecond}; + std::vector sessionInfos = { infoFrist, infoSecond }; WSError result = ssm_->GetSessionInfos(deviceId, numMax, sessionInfos); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); } @@ -309,7 +302,7 @@ HWTEST_F(SceneSessionManagerTest, GetSessionInfos02, TestSize.Level1) infoFrist.label = "fristBundleName"; AAFwk::MissionInfo infoSecond; infoSecond.label = "secondBundleName"; - std::vector sessionInfos = {infoFrist, infoSecond}; + std::vector sessionInfos = { infoFrist, infoSecond }; int32_t persistentId = 24; SessionInfoBean sessionInfo; int result01 = ssm_->GetRemoteSessionInfo(deviceId, persistentId, sessionInfo); @@ -320,7 +313,7 @@ HWTEST_F(SceneSessionManagerTest, GetSessionInfos02, TestSize.Level1) * @tc.name: GetUnreliableWindowInfo * @tc.desc: SceneSesionManager get unreliable window info * @tc.type: FUNC -*/ + */ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo, TestSize.Level1) { int32_t windowId = 0; @@ -575,7 +568,7 @@ HWTEST_F(SceneSessionManagerTest, FindMainWindowWithToken03, TestSize.Level1) info.moduleName_ = "test3"; info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); persistentId = 1; WSError result02 = ssm_->BindDialogSessionTarget(persistentId, targetToken); EXPECT_EQ(result02, WSError::WS_OK); @@ -636,8 +629,8 @@ HWTEST_F(SceneSessionManagerTest, MoveSessionsToBackground01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest, MoveSessionsToBackground02, TestSize.Level1) { - std::vector sessionIds = {1, 2, 3, 15, 1423}; - std::vector res = {1, 2, 3, 15, 1423}; + std::vector sessionIds = { 1, 2, 3, 15, 1423 }; + std::vector res = { 1, 2, 3, 15, 1423 }; WSError result03 = ssm_->MoveSessionsToBackground(sessionIds, res); ASSERT_EQ(result03, WSError::WS_ERROR_INVALID_PERMISSION); } @@ -663,7 +656,7 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions, TestSize.Level1) ssm_->sceneSessionMap_.erase(info.persistentId_); }); usleep(WAIT_SYNC_IN_NS); - ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); + ssm_->sceneSessionMap_.insert({ persistentId, sceneSession }); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], sceneSession); } @@ -689,7 +682,7 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions02, TestSize.Level ssm_->sceneSessionMap_.erase(info.persistentId_); }); usleep(WAIT_SYNC_IN_NS); - ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); + ssm_->sceneSessionMap_.insert({ persistentId, sceneSession }); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr); } @@ -715,7 +708,7 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions03, TestSize.Level ssm_->sceneSessionMap_.erase(info.persistentId_); }); usleep(WAIT_SYNC_IN_NS); - ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); + ssm_->sceneSessionMap_.insert({ persistentId, sceneSession }); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr); } @@ -727,7 +720,7 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions03, TestSize.Level */ HWTEST_F(SceneSessionManagerTest, MoveSessionsToForeground, TestSize.Level1) { - std::vector sessionIds = {1, 2, 3, 15, 1423}; + std::vector sessionIds = { 1, 2, 3, 15, 1423 }; int32_t topSessionId = 1; WSError result = ssm_->MoveSessionsToForeground(sessionIds, topSessionId); ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); @@ -767,7 +760,7 @@ HWTEST_F(SceneSessionManagerTest, GetImmersiveState, TestSize.Level1) HWTEST_F(SceneSessionManagerTest, NotifyAINavigationBarShowStatus, TestSize.Level1) { bool isVisible = false; - WSRect barArea = { 0, 0, 320, 240}; // width: 320, height: 240 + WSRect barArea = { 0, 0, 320, 240 }; // width: 320, height: 240 uint64_t displayId = 0; ssm_->rootSceneSession_ = sptr::MakeSptr(); WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea, displayId); @@ -889,7 +882,7 @@ HWTEST_F(SceneSessionManagerTest, GetUIContentRemoteObj, TestSize.Level1) info.bundleName_ = "GetUIContentRemoteObj"; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({65535, sceneSession}); + ssm_->sceneSessionMap_.insert({ 65535, sceneSession }); EXPECT_EQ(ssm_->GetUIContentRemoteObj(65535, remoteObj), WSError::WS_ERROR_INVALID_PERMISSION); } @@ -1078,7 +1071,7 @@ HWTEST_F(SceneSessionManagerTest, UpdateModalExtensionRect, TestSize.Level1) info.bundleName_ = "UpdateModalExtensionRect"; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - Rect rect { 1, 2, 3, 4 }; + Rect rect{ 1, 2, 3, 4 }; ssm_->UpdateModalExtensionRect(nullptr, rect); EXPECT_FALSE(sceneSession->GetLastModalUIExtensionEventInfo()); } @@ -1168,7 +1161,7 @@ HWTEST_F(SceneSessionManagerTest, SetScreenLocked001, TestSize.Level1) detectTaskInfo.taskWindowMode = WindowMode::WINDOW_MODE_UNDEFINED; sceneSession->SetDetectTaskInfo(detectTaskInfo); std::string taskName = "wms:WindowStateDetect" + std::to_string(sceneSession->persistentId_); - auto task = [](){}; + auto task = []() {}; int64_t delayTime = 3000; sceneSession->handler_->PostTask(task, taskName, delayTime); int32_t beforeTaskNum = GetTaskCount(sceneSession); @@ -1207,7 +1200,7 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneSceneSessionListToNotifyLi sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; ssm_->GetAllSceneSessionForAccessibility(sceneSessionList); @@ -1237,8 +1230,8 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoSceneSessionListToNotifyLi ASSERT_NE(sceneSessionSecond, nullptr); SetVisibleForAccessibility(sceneSessionSecond); - ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst}); - ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond}); + ssm_->sceneSessionMap_.insert({ sceneSessionFirst->GetPersistentId(), sceneSessionFirst }); + ssm_->sceneSessionMap_.insert({ sceneSessionSecond->GetPersistentId(), sceneSessionSecond }); std::vector> sceneSessionList; ssm_->GetAllSceneSessionForAccessibility(sceneSessionList); @@ -1262,7 +1255,7 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyBundleName, TestSize.Lev sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; ssm_->GetAllSceneSessionForAccessibility(sceneSessionList); @@ -1291,7 +1284,7 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillBundleName, TestSize.Level1) sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; ssm_->GetAllSceneSessionForAccessibility(sceneSessionList); @@ -1320,7 +1313,7 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillFilterBundleName, TestSize.Le sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; ssm_->GetAllSceneSessionForAccessibility(sceneSessionList); @@ -1345,7 +1338,7 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillEmptyHotAreas, TestSize.Level sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; std::vector> accessibilityInfo; @@ -1369,14 +1362,14 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillOneHotAreas, TestSize.Level1) sessionInfo.bundleName_ = "accessibilityNotifyTesterBundleName"; sessionInfo.abilityName_ = "accessibilityNotifyTesterAbilityName"; - Rect rect = {100, 200, 100, 200}; + Rect rect = { 100, 200, 100, 200 }; std::vector hotAreas; hotAreas.push_back(rect); sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetTouchHotAreas(hotAreas); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; std::vector> accessibilityInfo; @@ -1412,15 +1405,15 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFillTwoHotAreas, TestSize.Level1) sptr property = sptr::MakeSptr(); std::vector hotAreas; - Rect rectFitst = {100, 200, 100, 200}; - Rect rectSecond = {50, 50, 20, 30}; + Rect rectFitst = { 100, 200, 100, 200 }; + Rect rectSecond = { 50, 50, 20, 30 }; hotAreas.push_back(rectFitst); hotAreas.push_back(rectSecond); sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetTouchHotAreas(hotAreas); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; std::vector> accessibilityInfo; @@ -1469,9 +1462,9 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFilterOneWindow, TestSize.Level1) sptr sceneSession = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); - sceneSession->SetSessionRect({100, 100, 200, 200}); + sceneSession->SetSessionRect({ 100, 100, 200, 200 }); SetVisibleForAccessibility(sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> sceneSessionList; std::vector> accessibilityInfo; @@ -1494,15 +1487,15 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowNotCovered, TestSi sptr sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSessionFirst, nullptr); - sceneSessionFirst->SetSessionRect({0, 0, 200, 200}); + sceneSessionFirst->SetSessionRect({ 0, 0, 200, 200 }); SetVisibleForAccessibility(sceneSessionFirst); - ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst}); + ssm_->sceneSessionMap_.insert({ sceneSessionFirst->GetPersistentId(), sceneSessionFirst }); sptr sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSessionSecond, nullptr); - sceneSessionSecond->SetSessionRect({300, 300, 200, 200}); + sceneSessionSecond->SetSessionRect({ 300, 300, 200, 200 }); SetVisibleForAccessibility(sceneSessionSecond); - ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond}); + ssm_->sceneSessionMap_.insert({ sceneSessionSecond->GetPersistentId(), sceneSessionSecond }); std::vector> sceneSessionList; std::vector> accessibilityInfo; @@ -1525,17 +1518,17 @@ HWTEST_F(SceneSessionManagerTest, AccessibilityFilterTwoWindowCovered, TestSize. sptr sceneSessionFirst = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSessionFirst, nullptr); - sceneSessionFirst->SetSessionRect({0, 0, 200, 200}); + sceneSessionFirst->SetSessionRect({ 0, 0, 200, 200 }); SetVisibleForAccessibility(sceneSessionFirst); sceneSessionFirst->SetZOrder(20); - ssm_->sceneSessionMap_.insert({sceneSessionFirst->GetPersistentId(), sceneSessionFirst}); + ssm_->sceneSessionMap_.insert({ sceneSessionFirst->GetPersistentId(), sceneSessionFirst }); sptr sceneSessionSecond = ssm_->CreateSceneSession(sessionInfo, nullptr); ASSERT_NE(sceneSessionSecond, nullptr); - sceneSessionSecond->SetSessionRect({50, 50, 50, 50}); + sceneSessionSecond->SetSessionRect({ 50, 50, 50, 50 }); SetVisibleForAccessibility(sceneSessionSecond); sceneSessionSecond->SetZOrder(10); - ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond}); + ssm_->sceneSessionMap_.insert({ sceneSessionSecond->GetPersistentId(), sceneSessionSecond }); std::vector> sceneSessionList; std::vector> accessibilityInfo; @@ -1578,7 +1571,7 @@ HWTEST_F(SceneSessionManagerTest, GetAllWindowVisibilityInfos, TestSize.Level1) SessionInfo info; sptr sceneSession = ssm_->CreateSceneSession(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> windowVisibilityInfos; ssm_->GetAllWindowVisibilityInfos(windowVisibilityInfos); EXPECT_NE(windowVisibilityInfos.size(), 0); @@ -1632,7 +1625,7 @@ HWTEST_F(SceneSessionManagerTest, TestIsEnablePiPCreate, TestSize.Level1) property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sceneSession->pipTemplateInfo_ = {}; sceneSession->pipTemplateInfo_.priority = 100; - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property)); ssm_->sceneSessionMap_.clear(); ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property)); @@ -1640,12 +1633,12 @@ HWTEST_F(SceneSessionManagerTest, TestIsEnablePiPCreate, TestSize.Level1) property->SetParentPersistentId(100); ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property)); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ASSERT_TRUE(!ssm_->IsEnablePiPCreate(property)); ssm_->sceneSessionMap_.clear(); sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ASSERT_TRUE(ssm_->IsEnablePiPCreate(property)); } @@ -1671,7 +1664,7 @@ HWTEST_F(SceneSessionManagerTest, TestIsPiPForbidden, TestSize.Level1) ASSERT_NE(nullptr, sceneSession); property->SetDisplayId(-1ULL); sceneSession->SetSessionProperty(property); - ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); + ssm_->sceneSessionMap_.insert({ persistentId, sceneSession }); ASSERT_TRUE(!ssm_->IsPiPForbidden(property, WindowType::WINDOW_TYPE_PIP)); uint64_t displayId = 1001; @@ -1680,7 +1673,7 @@ HWTEST_F(SceneSessionManagerTest, TestIsPiPForbidden, TestSize.Level1) ssm_->sceneSessionMap_[persistentId] = sceneSession; sptr screenSession = new ScreenSession(); screenSession->SetName("HiCar"); - ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert({displayId, screenSession}); + ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert({ displayId, screenSession }); ASSERT_TRUE(ssm_->IsPiPForbidden(property, WindowType::WINDOW_TYPE_PIP)); ASSERT_TRUE(!ssm_->IsPiPForbidden(property, WindowType::WINDOW_TYPE_FLOAT)); } @@ -1698,7 +1691,7 @@ HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos, TestSize.Level1) info.windowType_ = static_cast(WindowType::APP_SUB_WINDOW_BASE); info.persistentId_ = 100; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector infos; WMError result = ssm_->GetAllMainWindowInfos(infos); ASSERT_EQ(result, WMError::WM_OK); @@ -1726,7 +1719,7 @@ HWTEST_F(SceneSessionManagerTest, GetAllMainWindowInfos001, TestSize.Level1) if (sceneSession == nullptr) { return; } - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector infos; WMError result = ssm_->GetAllMainWindowInfos(infos); EXPECT_EQ(result, WMError::WM_OK); @@ -1760,7 +1753,7 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo01, TestSize.Level1) SessionInfo info; sptr sceneSession = ssm_->CreateSceneSession(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); int32_t windowId = sceneSession->GetPersistentId(); std::vector> infos; @@ -1785,7 +1778,7 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo02, TestSize.Level1) sptr sceneSession = ssm_->CreateSceneSession(info, property); ASSERT_NE(nullptr, sceneSession); sceneSession->SetRSVisible(true); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); int32_t windowId = 0; std::vector> infos; @@ -1809,7 +1802,7 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo03, TestSize.Level1) property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); sptr sceneSession = ssm_->CreateSceneSession(info, property); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); SessionInfo info2; info2.windowType_ = 1001; @@ -1820,7 +1813,7 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo03, TestSize.Level1) sptr sceneSession2 = ssm_->CreateSceneSession(info2, property2); ASSERT_NE(nullptr, sceneSession2); sceneSession2->SetRSVisible(true); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); int32_t windowId = 0; std::vector> infos; @@ -1845,7 +1838,7 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo04, TestSize.Level1) sptr sceneSession = ssm_->CreateSceneSession(info, property); ASSERT_NE(nullptr, sceneSession); sceneSession->SetRSVisible(true); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); int32_t windowId = 0; std::vector> infos; @@ -1870,8 +1863,8 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo05, TestSize.Level1) sptr sceneSession = ssm_->CreateSceneSession(info, property); ASSERT_NE(nullptr, sceneSession); sceneSession->SetRSVisible(true); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); - ssm_->sceneSessionMap_.insert({0, nullptr}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); + ssm_->sceneSessionMap_.insert({ 0, nullptr }); int32_t windowId = 0; std::vector> infos; @@ -1895,19 +1888,19 @@ HWTEST_F(SceneSessionManagerTest, GetUnreliableWindowInfo06, TestSize.Level1) info1.bundleName_ = "SCBGestureBack"; sptr sceneSession1 = ssm_->CreateSceneSession(info1, nullptr); ASSERT_NE(nullptr, sceneSession1); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); SessionInfo info2; info2.bundleName_ = "SCBGestureNavBar"; sptr sceneSession2 = ssm_->CreateSceneSession(info2, nullptr); ASSERT_NE(nullptr, sceneSession2); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); SessionInfo info3; info3.bundleName_ = "SCBGestureTopBar"; sptr sceneSession3 = ssm_->CreateSceneSession(info3, nullptr); ASSERT_NE(nullptr, sceneSession3); - ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3}); + ssm_->sceneSessionMap_.insert({ sceneSession3->GetPersistentId(), sceneSession3 }); std::vector> infos; ssm_->GetUnreliableWindowInfo(sceneSession1->GetPersistentId(), infos); @@ -1943,9 +1936,9 @@ HWTEST_F(SceneSessionManagerTest, SkipSnapshotForAppProcess, TestSize.Level1) ASSERT_NE(nullptr, sceneSession2); sceneSession1->SetCallingPid(1000); sceneSession2->SetCallingPid(1001); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); - ssm_->sceneSessionMap_.insert({-1, nullptr}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); + ssm_->sceneSessionMap_.insert({ -1, nullptr }); skip = true; result = ssm_->SkipSnapshotForAppProcess(pid, skip); usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS); @@ -2002,23 +1995,23 @@ HWTEST_F(SceneSessionManagerTest, TestReportCorrectScreenFoldStatusChangeEvent, { GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportCorrectScreenFoldStatusChangeEvent start"; ScreenFoldData screenFoldData1; - screenFoldData1.currentScreenFoldStatus_ = 1; // 1: current screen fold status - screenFoldData1.nextScreenFoldStatus_ = 3; // 3: next screen fold status + screenFoldData1.currentScreenFoldStatus_ = 1; // 1: current screen fold status + screenFoldData1.nextScreenFoldStatus_ = 3; // 3: next screen fold status screenFoldData1.currentScreenFoldStatusDuration_ = 18; // 18: current duration - screenFoldData1.postureAngle_ = 47.1f; // 47.1: posture angle (type: float) - screenFoldData1.screenRotation_ = 1; // 1: screen rotation - screenFoldData1.typeCThermal_ = 3000; // 3000: typec port thermal + screenFoldData1.postureAngle_ = 47.1f; // 47.1: posture angle (type: float) + screenFoldData1.screenRotation_ = 1; // 1: screen rotation + screenFoldData1.typeCThermal_ = 3000; // 3000: typec port thermal screenFoldData1.focusedPackageName_ = "Developer Test: (1, 3, 18, 47.1, 1, 3000)"; WMError result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData1); ASSERT_EQ(result, WMError::WM_DO_NOTHING); // not report half-fold event until next change ScreenFoldData screenFoldData2; - screenFoldData2.currentScreenFoldStatus_ = 3; // 3: current screen fold status - screenFoldData2.nextScreenFoldStatus_ = 2; // 2: next screen fold status + screenFoldData2.currentScreenFoldStatus_ = 3; // 3: current screen fold status + screenFoldData2.nextScreenFoldStatus_ = 2; // 2: next screen fold status screenFoldData2.currentScreenFoldStatusDuration_ = 20; // 20: current duration - screenFoldData2.postureAngle_ = 143.7f; // 143.7: posture angle (type: float) - screenFoldData2.screenRotation_ = 2; // 2: screen rotation - screenFoldData2.typeCThermal_ = 3005; // 3005: typec port thermal + screenFoldData2.postureAngle_ = 143.7f; // 143.7: posture angle (type: float) + screenFoldData2.screenRotation_ = 2; // 2: screen rotation + screenFoldData2.typeCThermal_ = 3005; // 3005: typec port thermal screenFoldData2.focusedPackageName_ = "Developer Test: (3, 2, 20, 143.7, 2, 3005)"; result = ssm_->CheckAndReportScreenFoldStatus(screenFoldData2); ASSERT_EQ(result, WMError::WM_OK); @@ -2033,7 +2026,7 @@ HWTEST_F(SceneSessionManagerTest, TestReportIncompleteScreenFoldStatusChangeEven { GTEST_LOG_(INFO) << "SceneSessionManagerTest: TestReportIncompleteScreenFoldStatusChangeEvent start"; // screen fold status changes from -1: invalid to 3: half_fold, duration = 0, angle = 67.0, rotation = 0 - std::vector screenFoldInfo {"-1", "3", "0", "67.0", "0"}; + std::vector screenFoldInfo{ "-1", "3", "0", "67.0", "0" }; WMError result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo); ASSERT_EQ(result, WMError::WM_DO_NOTHING); @@ -2042,12 +2035,12 @@ HWTEST_F(SceneSessionManagerTest, TestReportIncompleteScreenFoldStatusChangeEven ASSERT_EQ(result, WMError::WM_DO_NOTHING); // screen fold status changes from 2: folded to 3: half_fold, duration = 0, angle = 67.0, rotation = 0 - screenFoldInfo = {"2", "3", "0", "67.0", "0"}; + screenFoldInfo = { "2", "3", "0", "67.0", "0" }; result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo); ASSERT_EQ(result, WMError::WM_DO_NOTHING); // screen fold status changes from 3: half_fold to 1: expand, duration = 18, angle = 147.3, rotation = 2 - screenFoldInfo = {"3", "1", "18", "147.3", "2"}; + screenFoldInfo = { "3", "1", "18", "147.3", "2" }; result = ssm_->ReportScreenFoldStatusChange(screenFoldInfo); ASSERT_EQ(result, WMError::WM_DO_NOTHING); } @@ -2085,7 +2078,7 @@ HWTEST_F(SceneSessionManagerTest, GetAppForceLandscapeConfig, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest, RemoveProcessWatermarkPid, TestSize.Level1) { - ssm_->processWatermarkPidMap_.insert({1, "test"}); + ssm_->processWatermarkPidMap_.insert({ 1, "test" }); ssm_->RemoveProcessWatermarkPid(1); ASSERT_EQ(ssm_->processWatermarkPidMap_.find(1), ssm_->processWatermarkPidMap_.end()); } @@ -2101,7 +2094,7 @@ HWTEST_F(SceneSessionManagerTest, SetSessionWatermarkForAppProcess, TestSize.Lev sptr sceneSession = ssm_->CreateSceneSession(info, nullptr); sceneSession->SetCallingPid(1); ASSERT_FALSE(ssm_->SetSessionWatermarkForAppProcess(sceneSession)); - ssm_->processWatermarkPidMap_.insert({1, "test"}); + ssm_->processWatermarkPidMap_.insert({ 1, "test" }); ASSERT_TRUE(ssm_->SetSessionWatermarkForAppProcess(sceneSession)); ssm_->processWatermarkPidMap_.erase(1); } @@ -2163,8 +2156,8 @@ HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo02, TestSize.Level1) sptr sceneSession2 = sptr::MakeSptr(info2, nullptr); ASSERT_NE(nullptr, sceneSession2); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); std::string bundleName; auto result = ssm_->GetCurrentPiPWindowInfo(bundleName); ASSERT_EQ(result, WMError::WM_OK); @@ -2179,7 +2172,7 @@ HWTEST_F(SceneSessionManagerTest, GetCurrentPiPWindowInfo02, TestSize.Level1) HWTEST_F(SceneSessionManagerTest, SkipSnapshotByUserIdAndBundleNames, TestSize.Level1) { ASSERT_NE(nullptr, ssm_); - auto result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {"TestName"}); + auto result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, { "TestName" }); ASSERT_EQ(result, WMError::WM_OK); usleep(WAIT_SYNC_FOR_SNAPSHOT_SKIP_IN_NS); ASSERT_NE(ssm_->snapshotSkipBundleNameSet_.find("TestName"), ssm_->snapshotSkipBundleNameSet_.end()); @@ -2199,10 +2192,10 @@ HWTEST_F(SceneSessionManagerTest, SkipSnapshotByUserIdAndBundleNames, TestSize.L ASSERT_NE(nullptr, sceneSession2); sceneSession1->SetCallingPid(1000); sceneSession2->SetCallingPid(1001); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); - ssm_->sceneSessionMap_.insert({-1, nullptr}); - result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, {"TestName1"}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); + ssm_->sceneSessionMap_.insert({ -1, nullptr }); + result = ssm_->SkipSnapshotByUserIdAndBundleNames(100, { "TestName1" }); ASSERT_EQ(result, WMError::WM_OK); ssm_->sceneSessionMap_.erase(sceneSession1->GetPersistentId()); ssm_->sceneSessionMap_.erase(sceneSession2->GetPersistentId()); @@ -2253,8 +2246,8 @@ HWTEST_F(SceneSessionManagerTest, GetRootMainWindowId, TestSize.Level1) ASSERT_NE(nullptr, sceneSession2); sceneSession2->SetParentSession(sceneSession1); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); int32_t hostWindowId = -1; auto result = ssm_->GetRootMainWindowId(sceneSession2->GetPersistentId(), hostWindowId); ASSERT_EQ(result, WMError::WM_OK); @@ -2414,15 +2407,17 @@ HWTEST_F(SceneSessionManagerTest, GetDisplayIdByWindowId01, TestSize.Level1) info.bundleName_ = "test"; sptr sceneSession1 = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession1); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); sptr sceneSession2 = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession2); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); DisplayId displayId = 0; sceneSession1->property_->SetDisplayId(displayId); - const std::vector windowIds = {1001, sceneSession1->GetPersistentId(), sceneSession2->GetPersistentId()}; + const std::vector windowIds = { 1001, + sceneSession1->GetPersistentId(), + sceneSession2->GetPersistentId() }; std::unordered_map windowDisplayIdMap; ASSERT_EQ(ssm_->GetDisplayIdByWindowId(windowIds, windowDisplayIdMap), WMError::WM_OK); } @@ -2434,8 +2429,8 @@ HWTEST_F(SceneSessionManagerTest, GetDisplayIdByWindowId01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest, GetDisplayIdByWindowId02, TestSize.Level1) { - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); SessionInfo sessionInfo; sessionInfo.isSystem_ = false; @@ -2474,7 +2469,7 @@ HWTEST_F(SceneSessionManagerTest, SetGlobalDragResizeType01, TestSize.Level1) info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ASSERT_EQ(ssm_->SetGlobalDragResizeType(DragResizeType::RESIZE_TYPE_UNDEFINED), WMError::WM_OK); ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK); @@ -2495,12 +2490,12 @@ HWTEST_F(SceneSessionManagerTest, SetGlobalDragResizeType02, TestSize.Level1) info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK); - ssm_->sceneSessionMap_.insert({0, nullptr}); + ssm_->sceneSessionMap_.insert({ 0, nullptr }); ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK); ssm_->sceneSessionMap_.clear(); - ssm_->sceneSessionMap_.insert({0, nullptr}); + ssm_->sceneSessionMap_.insert({ 0, nullptr }); ASSERT_EQ(ssm_->SetGlobalDragResizeType(dragResizeType), WMError::WM_OK); } @@ -2528,7 +2523,7 @@ HWTEST_F(SceneSessionManagerTest, SetAppDragResizeType, TestSize.Level1) info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); DragResizeType dragResizeType = DragResizeType::RESIZE_EACH_FRAME; ASSERT_EQ(ssm_->SetAppDragResizeType("", dragResizeType), WMError::WM_ERROR_INVALID_PARAM); ASSERT_EQ(ssm_->SetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK); @@ -2547,7 +2542,7 @@ HWTEST_F(SceneSessionManagerTest, GetAppDragResizeType, TestSize.Level1) info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED; ASSERT_EQ(ssm_->GetAppDragResizeType(info.bundleName_, dragResizeType), WMError::WM_OK); } @@ -2575,12 +2570,12 @@ HWTEST_F(SceneSessionManagerTest, SetAppKeyFramePolicy, TestSize.Level1) getKeyFramePolicy = ssm_->GetAppKeyFramePolicy(info.bundleName_); ASSERT_EQ(getKeyFramePolicy.dragResizeType_, keyFramePolicy.dragResizeType_); // valid - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK); getKeyFramePolicy = ssm_->GetAppKeyFramePolicy(info.bundleName_); ASSERT_EQ(getKeyFramePolicy.dragResizeType_, keyFramePolicy.dragResizeType_); // nullptr - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), nullptr}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), nullptr }); ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK); getKeyFramePolicy = ssm_->GetAppKeyFramePolicy(info.bundleName_); ASSERT_EQ(getKeyFramePolicy.dragResizeType_, keyFramePolicy.dragResizeType_); @@ -2590,7 +2585,7 @@ HWTEST_F(SceneSessionManagerTest, SetAppKeyFramePolicy, TestSize.Level1) info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); sptr sceneSession2 = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession2); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession2 }); ASSERT_EQ(ssm_->SetAppKeyFramePolicy(info.bundleName_, keyFramePolicy), WMError::WM_OK); } @@ -2655,6 +2650,6 @@ HWTEST_F(SceneSessionManagerTest, CloneWindow, TestSize.Level1) WSError res = ssm_->CloneWindow(fromPersistentId, toPersistentId, needOffScreen); EXPECT_EQ(WSError::WS_ERROR_NULLPTR, res); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index c2fbc836df..cb03882de4 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -39,28 +39,23 @@ public: void InitTestSceneSessionForListWindowInfo(); static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; sptr SceneSessionManagerTest10::ssm_ = nullptr; -void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) -{ -} +void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) {} bool TraverseFuncTest(const sptr& session) { return true; } -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} bool GetCutoutInfoByRotation(Rotation rotation, Rect& rect) { @@ -75,12 +70,7 @@ bool GetCutoutInfoByRotation(Rotation rotation, Rect& rect) return false; } for (auto& cutoutArea : cutoutAreas) { - rect = { - cutoutArea.posX_, - cutoutArea.posY_, - cutoutArea.width_, - cutoutArea.height_ - }; + rect = { cutoutArea.posX_, cutoutArea.posY_, cutoutArea.width_, cutoutArea.height_ }; } return true; } @@ -95,9 +85,7 @@ void SceneSessionManagerTest10::TearDownTestCase() ssm_ = nullptr; } -void SceneSessionManagerTest10::SetUp() -{ -} +void SceneSessionManagerTest10::SetUp() {} void SceneSessionManagerTest10::TearDown() { @@ -105,7 +93,10 @@ void SceneSessionManagerTest10::TearDown() } void SceneSessionManagerTest10::InitTestSceneSession(DisplayId displayId, - int32_t windowId, int32_t zOrder, bool visible, WSRect rect) + int32_t windowId, + int32_t zOrder, + bool visible, + WSRect rect) { SessionInfo info; info.bundleName_ = "root"; @@ -116,7 +107,7 @@ void SceneSessionManagerTest10::InitTestSceneSession(DisplayId displayId, sceneSession->SetRSVisible(visible); sceneSession->SetSessionRect(rect); sceneSession->property_->SetDisplayId(displayId); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); EXPECT_EQ(windowId, sceneSession->GetPersistentId()); } @@ -209,8 +200,8 @@ HWTEST_F(SceneSessionManagerTest10, RequestSceneSessionDestructionInner, TestSiz SessionInfo sessionInfo; sessionInfo.collaboratorType_ = CollaboratorType::RESERVE_TYPE; - auto res = ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, - needRemoveSession, isForceClean); + auto res = + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, needRemoveSession, isForceClean); ASSERT_EQ(res, WSError::WS_OK); } @@ -234,8 +225,8 @@ HWTEST_F(SceneSessionManagerTest10, TestRequestSceneSessionDestructionInner_01, sessionInfo.collaboratorType_ = CollaboratorType::DEFAULT_TYPE; sessionInfo.want = std::make_shared(); ssm_->listenerController_ = std::make_shared(); - auto res = ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, - needRemoveSession, isForceClean); + auto res = + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, needRemoveSession, isForceClean); ASSERT_EQ(res, WSError::WS_OK); } @@ -389,7 +380,7 @@ HWTEST_F(SceneSessionManagerTest10, RegisterAcquireRotateAnimationConfigFunc, Te ASSERT_NE(sceneSession->scenePersistence_, nullptr); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->RegisterAcquireRotateAnimationConfigFunc(sceneSession); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::ROTATION; WSError result = sceneSession->UpdateRect(rect, reason, "SceneSessionManagerTest10"); ASSERT_EQ(result, WSError::WS_OK); @@ -474,19 +465,19 @@ HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate01, TestSize.Level1) HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate02, TestSize.Level1) { ssm_->sceneSessionMap_.clear(); - InitTestSceneSession(1, 101, 11, true, {100, 100, 200, 200}); - ssm_->sceneSessionMap_.insert({102, nullptr}); - InitTestSceneSession(1, 103, 14, true, {120, 120, 220, 220}); - InitTestSceneSession(1, 105, 12, true, {100, 100, 200, 200}); + InitTestSceneSession(1, 101, 11, true, { 100, 100, 200, 200 }); + ssm_->sceneSessionMap_.insert({ 102, nullptr }); + InitTestSceneSession(1, 103, 14, true, { 120, 120, 220, 220 }); + InitTestSceneSession(1, 105, 12, true, { 100, 100, 200, 200 }); auto it1 = ssm_->sceneSessionMap_.find(105); if (it1 != ssm_->sceneSessionMap_.end()) { it1->second->sessionInfo_.bundleName_ = "other"; } - InitTestSceneSession(1, 106, 15, true, {140, 140, 240, 240}); - InitTestSceneSession(2, 107, 15, true, {150, 150, 250, 250}); - InitTestSceneSession(1, 108, 13, false, {150, 150, 250, 250}); - InitTestSceneSession(1, 109, 13, true, {160, 160, 260, 260}); - InitTestSceneSession(1, 110, 12, true, {500, 500, 600, 600}); + InitTestSceneSession(1, 106, 15, true, { 140, 140, 240, 240 }); + InitTestSceneSession(2, 107, 15, true, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 108, 13, false, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 109, 13, true, { 160, 160, 260, 260 }); + InitTestSceneSession(1, 110, 12, true, { 500, 500, 600, 600 }); std::vector windowIds; WMError result = ssm_->GetWindowIdsByCoordinate(1, 0, -1, -1, windowIds); @@ -508,21 +499,21 @@ HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate02, TestSize.Level1) HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate03, TestSize.Level1) { ssm_->sceneSessionMap_.clear(); - InitTestSceneSession(1, 111, 11, true, {100, 100, 200, 200}); - ssm_->sceneSessionMap_.insert({102, nullptr}); - InitTestSceneSession(1, 113, 14, true, {120, 120, 220, 220}); - InitTestSceneSession(1, 114, 12, true, {100, 100, 200, 200}); + InitTestSceneSession(1, 111, 11, true, { 100, 100, 200, 200 }); + ssm_->sceneSessionMap_.insert({ 102, nullptr }); + InitTestSceneSession(1, 113, 14, true, { 120, 120, 220, 220 }); + InitTestSceneSession(1, 114, 12, true, { 100, 100, 200, 200 }); ASSERT_TRUE(ssm_->sceneSessionMap_.find(114) != ssm_->sceneSessionMap_.end()); - InitTestSceneSession(1, 115, 12, true, {100, 100, 200, 200}); + InitTestSceneSession(1, 115, 12, true, { 100, 100, 200, 200 }); auto it1 = ssm_->sceneSessionMap_.find(115); if (it1 != ssm_->sceneSessionMap_.end()) { it1->second->sessionInfo_.bundleName_ = "other"; } - InitTestSceneSession(1, 116, 15, true, {140, 140, 240, 240}); - InitTestSceneSession(2, 117, 15, true, {150, 150, 250, 250}); - InitTestSceneSession(1, 118, 13, false, {150, 150, 250, 250}); - InitTestSceneSession(1, 119, 13, true, {160, 160, 260, 260}); - InitTestSceneSession(1, 120, 12, true, {500, 500, 600, 600}); + InitTestSceneSession(1, 116, 15, true, { 140, 140, 240, 240 }); + InitTestSceneSession(2, 117, 15, true, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 118, 13, false, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 119, 13, true, { 160, 160, 260, 260 }); + InitTestSceneSession(1, 120, 12, true, { 500, 500, 600, 600 }); std::vector windowIds; WMError result = ssm_->GetWindowIdsByCoordinate(1, 3, -1, -1, windowIds); @@ -542,19 +533,19 @@ HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate03, TestSize.Level1) HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate04, TestSize.Level1) { ssm_->sceneSessionMap_.clear(); - InitTestSceneSession(1, 121, 11, true, {100, 100, 200, 200}); - ssm_->sceneSessionMap_.insert({102, nullptr}); - InitTestSceneSession(1, 123, 14, true, {120, 120, 220, 220}); - InitTestSceneSession(1, 125, 12, true, {100, 100, 200, 200}); + InitTestSceneSession(1, 121, 11, true, { 100, 100, 200, 200 }); + ssm_->sceneSessionMap_.insert({ 102, nullptr }); + InitTestSceneSession(1, 123, 14, true, { 120, 120, 220, 220 }); + InitTestSceneSession(1, 125, 12, true, { 100, 100, 200, 200 }); auto it1 = ssm_->sceneSessionMap_.find(125); if (it1 != ssm_->sceneSessionMap_.end()) { it1->second->sessionInfo_.bundleName_ = "other"; } - InitTestSceneSession(1, 126, 15, true, {140, 140, 240, 240}); - InitTestSceneSession(2, 127, 15, true, {150, 150, 250, 250}); - InitTestSceneSession(1, 128, 13, false, {150, 150, 250, 250}); - InitTestSceneSession(1, 129, 13, true, {160, 160, 260, 260}); - InitTestSceneSession(1, 130, 12, true, {500, 500, 600, 600}); + InitTestSceneSession(1, 126, 15, true, { 140, 140, 240, 240 }); + InitTestSceneSession(2, 127, 15, true, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 128, 13, false, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 129, 13, true, { 160, 160, 260, 260 }); + InitTestSceneSession(1, 130, 12, true, { 500, 500, 600, 600 }); std::vector windowIds; WMError result = ssm_->GetWindowIdsByCoordinate(1, 0, 180, 180, windowIds); @@ -575,21 +566,21 @@ HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate04, TestSize.Level1) HWTEST_F(SceneSessionManagerTest10, GetWindowIdsByCoordinate05, TestSize.Level1) { ssm_->sceneSessionMap_.clear(); - InitTestSceneSession(1, 131, 11, true, {100, 100, 200, 200}); - ssm_->sceneSessionMap_.insert({102, nullptr}); - InitTestSceneSession(1, 133, 14, true, {120, 120, 220, 220}); - InitTestSceneSession(1, 134, 12, true, {100, 100, 200, 200}); + InitTestSceneSession(1, 131, 11, true, { 100, 100, 200, 200 }); + ssm_->sceneSessionMap_.insert({ 102, nullptr }); + InitTestSceneSession(1, 133, 14, true, { 120, 120, 220, 220 }); + InitTestSceneSession(1, 134, 12, true, { 100, 100, 200, 200 }); ASSERT_TRUE(ssm_->sceneSessionMap_.find(134) != ssm_->sceneSessionMap_.end()); - InitTestSceneSession(1, 135, 12, true, {100, 100, 200, 200}); + InitTestSceneSession(1, 135, 12, true, { 100, 100, 200, 200 }); auto it1 = ssm_->sceneSessionMap_.find(135); if (it1 != ssm_->sceneSessionMap_.end()) { it1->second->sessionInfo_.bundleName_ = "other"; } - InitTestSceneSession(1, 136, 15, true, {140, 140, 240, 240}); - InitTestSceneSession(2, 137, 15, true, {150, 150, 250, 250}); - InitTestSceneSession(1, 138, 13, false, {150, 150, 250, 250}); - InitTestSceneSession(1, 139, 13, true, {160, 160, 260, 260}); - InitTestSceneSession(1, 140, 12, true, {500, 500, 600, 600}); + InitTestSceneSession(1, 136, 15, true, { 140, 140, 240, 240 }); + InitTestSceneSession(2, 137, 15, true, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 138, 13, false, { 150, 150, 250, 250 }); + InitTestSceneSession(1, 139, 13, true, { 160, 160, 260, 260 }); + InitTestSceneSession(1, 140, 12, true, { 500, 500, 600, 600 }); std::vector windowIds; WMError result = ssm_->GetWindowIdsByCoordinate(1, 3, 180, 180, windowIds); @@ -730,7 +721,7 @@ HWTEST_F(SceneSessionManagerTest10, TestGetMainParentSceneSession_03, TestSize.L sptr sceneSession = sptr::MakeSptr(info, nullptr); sptr sceneSessionParent = sptr::MakeSptr(info, nullptr); sceneSessionParent->property_->SetPersistentId(100); - ssm_->sceneSessionMap_.insert({100, sceneSessionParent}); + ssm_->sceneSessionMap_.insert({ 100, sceneSessionParent }); sceneSession->SetParentSession(sceneSessionParent); ssm_->sceneSessionMap_[999] = sceneSession; @@ -823,7 +814,7 @@ HWTEST_F(SceneSessionManagerTest10, NotifyVisibleChange, TestSize.Level1) ASSERT_NE(nullptr, sceneSession); ASSERT_FALSE(ssm_->NotifyVisibleChange(sceneSession->GetPersistentId())); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ASSERT_TRUE(ssm_->NotifyVisibleChange(sceneSession->GetPersistentId())); ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); @@ -896,7 +887,7 @@ HWTEST_F(SceneSessionManagerTest10, TestEraseSceneSessionAndMarkDirtyLocked_01, sptr sceneSession = sptr::MakeSptr(info, nullptr); const int32_t validId = 100; const int32_t invalidId = 101; - ssm_->sceneSessionMap_.insert({validId, sceneSession}); + ssm_->sceneSessionMap_.insert({ validId, sceneSession }); // erase id not exist ssm_->EraseSceneSessionAndMarkDirtyLocked(invalidId); ASSERT_EQ(ssm_->sessionMapDirty_, 0); @@ -919,7 +910,7 @@ HWTEST_F(SceneSessionManagerTest10, TestEraseSceneSessionAndMarkDirtyLocked_02, info.bundleName_ = "TestEraseSceneSessionAndMarkDirtyLocked_02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); const int32_t validId = 100; - ssm_->sceneSessionMap_.insert({validId, sceneSession}); + ssm_->sceneSessionMap_.insert({ validId, sceneSession }); // erase invisible session sceneSession->isVisible_ = false; @@ -946,7 +937,7 @@ HWTEST_F(SceneSessionManagerTest10, TestEraseSceneSessionAndMarkDirtyLocked_03, const int32_t validId = 100; // erase visible session - ssm_->sceneSessionMap_.insert({validId, sceneSession}); + ssm_->sceneSessionMap_.insert({ validId, sceneSession }); sceneSession->isVisible_ = true; ssm_->EraseSceneSessionAndMarkDirtyLocked(validId); ASSERT_EQ(ssm_->sessionMapDirty_, static_cast(SessionUIDirtyFlag::VISIBLE)); @@ -1070,7 +1061,7 @@ HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, TestSize.Level0) sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); sceneSession->isStatusBarVisible_ = true; EXPECT_EQ(WSError::WS_OK, ssm_->NotifyStatusBarShowStatus(sceneSession->GetPersistentId(), false)); ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); @@ -1089,7 +1080,7 @@ HWTEST_F(SceneSessionManagerTest10, GetStatusBarConstantlyShow, TestSize.Level0) sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); bool isVisible; ssm_->NotifyStatusBarConstantlyShow(sceneSession->GetSessionProperty()->GetDisplayId(), false); ssm_->GetStatusBarConstantlyShow(sceneSession->GetSessionProperty()->GetDisplayId(), isVisible); @@ -1108,14 +1099,14 @@ HWTEST_F(SceneSessionManagerTest10, NotifyAppUseControlList, TestSize.Level1) std::vector controlList; controlList.emplace_back(); EXPECT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, - ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList)); + ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList)); AppUseControlInfo appUseControlInfo; appUseControlInfo.bundleName_ = "bundleName"; appUseControlInfo.appIndex_ = 1; appUseControlInfo.isNeedControl_ = true; EXPECT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, - ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList)); + ssm_->NotifyAppUseControlList(ControlAppType::APP_LOCK, -1, controlList)); } /** @@ -1285,8 +1276,8 @@ HWTEST_F(SceneSessionManagerTest10, FilterForListWindowInfo06, TestSize.Level1) ssm_->sceneSessionMap_.clear(); InitTestSceneSessionForListWindowInfo(); WindowInfoOption windowInfoOption; - windowInfoOption.windowInfoFilterOption = WindowInfoFilterOption::EXCLUDE_SYSTEM | - WindowInfoFilterOption::FOREGROUND; + windowInfoOption.windowInfoFilterOption = + WindowInfoFilterOption::EXCLUDE_SYSTEM | WindowInfoFilterOption::FOREGROUND; windowInfoOption.windowInfoTypeOption = WindowInfoTypeOption::ALL; windowInfoOption.displayId = DISPLAY_ID_INVALID; windowInfoOption.windowId = 0; @@ -1384,10 +1375,10 @@ HWTEST_F(SceneSessionManagerTest10, NotifyNextAvoidRectInfo_01, TestSize.Level0) info.bundleName_ = "NotifyNextAvoidRectInfo"; info.screenId_ = 0; auto specificCb = sptr::MakeSptr(); - specificCb->onGetNextAvoidAreaRectInfo_ = []( - DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { - return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); - }; + specificCb->onGetNextAvoidAreaRectInfo_ = + [](DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { + return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); + }; sptr sceneSession = sptr::MakeSptr(info, specificCb); sceneSession->property_->SetPersistentId(1); sceneSession->winRect_ = { 0, 0, 1260, 2720 }; @@ -1418,10 +1409,10 @@ HWTEST_F(SceneSessionManagerTest10, NotifyNextAvoidRectInfo_statusBar, TestSize. info.bundleName_ = "NotifyNextAvoidRectInfo_statusBar"; info.screenId_ = 0; auto specificCb = sptr::MakeSptr(); - specificCb->onGetNextAvoidAreaRectInfo_ = []( - DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { - return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); - }; + specificCb->onGetNextAvoidAreaRectInfo_ = + [](DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { + return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); + }; sptr sceneSession = sptr::MakeSptr(info, specificCb); sceneSession->property_->SetPersistentId(1); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); @@ -1460,10 +1451,10 @@ HWTEST_F(SceneSessionManagerTest10, NotifyNextAvoidRectInfo_statusBar_01, TestSi info.bundleName_ = "NotifyNextAvoidRectInfo_statusBar_01"; info.screenId_ = 0; auto specificCb = sptr::MakeSptr(); - specificCb->onGetNextAvoidAreaRectInfo_ = []( - DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { - return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); - }; + specificCb->onGetNextAvoidAreaRectInfo_ = + [](DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { + return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); + }; sptr sceneSession = sptr::MakeSptr(info, specificCb); sceneSession->property_->SetPersistentId(1); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); @@ -1497,10 +1488,10 @@ HWTEST_F(SceneSessionManagerTest10, NotifyNextAvoidRectInfo_keyboard, TestSize.L info.bundleName_ = "NotifyNextAvoidRectInfo_keyboard"; info.screenId_ = 0; auto specificCb = sptr::MakeSptr(); - specificCb->onKeyboardRotationChange_ = [](int32_t persistentId, Rotation rotation, - std::vector>& avoidAreas) { - ssm_->GetKeyboardOccupiedAreaWithRotation(persistentId, rotation, avoidAreas); - }; + specificCb->onKeyboardRotationChange_ = + [](int32_t persistentId, Rotation rotation, std::vector>& avoidAreas) { + ssm_->GetKeyboardOccupiedAreaWithRotation(persistentId, rotation, avoidAreas); + }; sptr sceneSession = sptr::MakeSptr(info, specificCb); sceneSession->property_->SetPersistentId(1); ssm_->sceneSessionMap_.insert({ 1, sceneSession }); @@ -1523,10 +1514,10 @@ HWTEST_F(SceneSessionManagerTest10, NotifyNextAvoidRectInfo_keyboard_01, TestSiz info.bundleName_ = "NotifyNextAvoidRectInfo_keyboard_01"; info.screenId_ = 0; auto specificCb = sptr::MakeSptr(); - specificCb->onKeyboardRotationChange_ = [](int32_t persistentId, Rotation rotation, - std::vector>& avoidAreas) { - ssm_->GetKeyboardOccupiedAreaWithRotation(persistentId, rotation, avoidAreas); - }; + specificCb->onKeyboardRotationChange_ = + [](int32_t persistentId, Rotation rotation, std::vector>& avoidAreas) { + ssm_->GetKeyboardOccupiedAreaWithRotation(persistentId, rotation, avoidAreas); + }; sptr sceneSession = sptr::MakeSptr(info, specificCb); sceneSession->property_->SetPersistentId(1); SessionInfo keyboardSessionInfo; @@ -1615,10 +1606,10 @@ HWTEST_F(SceneSessionManagerTest10, NotifyNextAvoidRectInfo_AIBar, TestSize.Leve info.bundleName_ = "NotifyNextAvoidRectInfo_AIBar"; info.screenId_ = 0; auto specificCb = sptr::MakeSptr(); - specificCb->onGetNextAvoidAreaRectInfo_ = []( - DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { - return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); - }; + specificCb->onGetNextAvoidAreaRectInfo_ = + [](DisplayId displayId, AvoidAreaType type, std::pair& nextSystemBarAvoidAreaRectInfo) { + return ssm_->GetNextAvoidRectInfo(displayId, type, nextSystemBarAvoidAreaRectInfo); + }; sptr sceneSession = sptr::MakeSptr(info, specificCb); sceneSession->property_->SetPersistentId(1); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); @@ -1648,6 +1639,6 @@ HWTEST_F(SceneSessionManagerTest10, NotifyNextAvoidRectInfo_AIBar, TestSize.Leve ASSERT_EQ(avoidAreas[AvoidAreaType::TYPE_NAVIGATION_INDICATOR].topRect_, rect); ssm_->sceneSessionMap_.clear(); } -} // namespace -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test11.cpp b/window_scene/test/unittest/scene_session_manager_test11.cpp index e3eb5444b5..4581ef22f7 100755 --- a/window_scene/test/unittest/scene_session_manager_test11.cpp +++ b/window_scene/test/unittest/scene_session_manager_test11.cpp @@ -35,10 +35,10 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { - const std::string BUNDLE_NAME = "bundleName"; - const int32_t USER_ID { 100 }; - const int32_t SLEEP_TIME { 10000 }; -} +const std::string BUNDLE_NAME = "bundleName"; +const int32_t USER_ID{ 100 }; +const int32_t SLEEP_TIME{ 10000 }; +} // namespace class SceneSessionManagerTest11 : public testing::Test { public: static void SetUpTestCase(); @@ -47,6 +47,7 @@ public: void TearDown() override; static sptr ssm_; + private: sptr GetSceneSession(const std::string& instanceKey = ""); void Init(AppExecFwk::MultiAppModeType modeType, uint32_t maxCount); @@ -66,9 +67,7 @@ void SceneSessionManagerTest11::TearDownTestCase() ssm_ = nullptr; } -void SceneSessionManagerTest11::SetUp() -{ -} +void SceneSessionManagerTest11::SetUp() {} void SceneSessionManagerTest11::TearDown() { @@ -93,16 +92,17 @@ sptr SceneSessionManagerTest11::GetSceneSession(const std::string& void SceneSessionManagerTest11::Init(AppExecFwk::MultiAppModeType modeType, uint32_t maxCount) { sptr bundleMgrMocker = sptr::MakeSptr(); - EXPECT_CALL(*bundleMgrMocker, GetApplicationInfos(_, _, _)).WillOnce([modeType, maxCount]( - const AppExecFwk::ApplicationFlag flag, const int32_t userId, - std::vector& appInfos) { - AppExecFwk::ApplicationInfo appInfo; - appInfo.bundleName = BUNDLE_NAME; - appInfo.multiAppMode.multiAppModeType = modeType; - appInfo.multiAppMode.maxCount = maxCount; - appInfos.push_back(appInfo); - return true; - }); + EXPECT_CALL(*bundleMgrMocker, GetApplicationInfos(_, _, _)) + .WillOnce([modeType, maxCount](const AppExecFwk::ApplicationFlag flag, + const int32_t userId, + std::vector& appInfos) { + AppExecFwk::ApplicationInfo appInfo; + appInfo.bundleName = BUNDLE_NAME; + appInfo.multiAppMode.multiAppModeType = modeType; + appInfo.multiAppMode.maxCount = maxCount; + appInfos.push_back(appInfo); + return true; + }); MultiInstanceManager::GetInstance().Init(bundleMgrMocker, GetTaskScheduler()); MultiInstanceManager::GetInstance().SetCurrentUserId(USER_ID); usleep(SLEEP_TIME); @@ -243,7 +243,7 @@ HWTEST_F(SceneSessionManagerTest11, UpdateOccupiedAreaIfNeed, TestSize.Level1) info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->UpdateOccupiedAreaIfNeed(persistentId); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); @@ -300,11 +300,11 @@ HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo02, TestSize.Level1) HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo03, TestSize.Level1) { sptr bundleMgrMocker = sptr::MakeSptr(); - EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( - const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { - bundleInfo.hapModuleInfos = {}; - return 0; - }); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)) + .WillOnce([](const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + bundleInfo.hapModuleInfos = {}; + return 0; + }); ssm_->bundleMgr_ = bundleMgrMocker; std::string bundleName = "bundleName"; std::string moduleName = "moduleName"; @@ -323,17 +323,17 @@ HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo03, TestSize.Level1) HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo04, TestSize.Level1) { sptr bundleMgrMocker = sptr::MakeSptr(); - EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( - const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { - AppExecFwk::AbilityInfo abilityInfo; - abilityInfo.moduleName = "moduleName"; - abilityInfo.name = "abilityName"; - AppExecFwk::HapModuleInfo hapModuleInfo; - hapModuleInfo.abilityInfos = { abilityInfo }; - bundleInfo.hapModuleInfos = { hapModuleInfo }; - bundleInfo.applicationInfo.codePath = "testCodePath"; - return 0; - }); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)) + .WillOnce([](const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.moduleName = "moduleName"; + abilityInfo.name = "abilityName"; + AppExecFwk::HapModuleInfo hapModuleInfo; + hapModuleInfo.abilityInfos = { abilityInfo }; + bundleInfo.hapModuleInfos = { hapModuleInfo }; + bundleInfo.applicationInfo.codePath = "testCodePath"; + return 0; + }); ssm_->bundleMgr_ = bundleMgrMocker; std::string bundleName = "bundleName"; std::string moduleName = "moduleName"; @@ -353,16 +353,16 @@ HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo04, TestSize.Level1) HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo05, TestSize.Level1) { sptr bundleMgrMocker = sptr::MakeSptr(); - EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( - const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { - AppExecFwk::AbilityInfo abilityInfo; - abilityInfo.moduleName = "moduleName2"; - abilityInfo.name = "abilityName2"; - AppExecFwk::HapModuleInfo hapModuleInfo; - hapModuleInfo.abilityInfos = { abilityInfo }; - bundleInfo.hapModuleInfos = { hapModuleInfo }; - return 0; - }); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)) + .WillOnce([](const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.moduleName = "moduleName2"; + abilityInfo.name = "abilityName2"; + AppExecFwk::HapModuleInfo hapModuleInfo; + hapModuleInfo.abilityInfos = { abilityInfo }; + bundleInfo.hapModuleInfos = { hapModuleInfo }; + return 0; + }); ssm_->bundleMgr_ = bundleMgrMocker; std::string bundleName = "bundleName"; std::string moduleName = "moduleName"; @@ -574,7 +574,7 @@ HWTEST_F(SceneSessionManagerTest11, GetMainSessionByBundleNameAndAppIndex, TestS ssm_->GetMainSessionByBundleNameAndAppIndex(bundleName, appIndex, mainSessions); sptr sceneSession = GetSceneSession(bundleName); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->GetMainSessionByBundleNameAndAppIndex(bundleName, appIndex, mainSessions); ssm_->GetMainSessionByBundleNameAndAppIndex(BUNDLE_NAME, appIndex, mainSessions); @@ -601,7 +601,7 @@ HWTEST_F(SceneSessionManagerTest11, GetMainSessionByAbilityInfo, TestSize.Level1 std::vector> mainSessions; std::string bundleName = "bundleName_test"; sptr sceneSession = GetSceneSession(bundleName); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->GetMainSessionByAbilityInfo(abilityInfo, mainSessions); abilityInfo.bundleName = BUNDLE_NAME; @@ -639,7 +639,7 @@ HWTEST_F(SceneSessionManagerTest11, GetKeyboardSession, TestSize.Level1) info.screenId_ = 5; sptr specificCb = sptr::MakeSptr(); sptr sceneSession = sptr::MakeSptr(info, specificCb); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->GetKeyboardSession(displayId, isSystemKeyboard); displayId = 5; @@ -690,8 +690,8 @@ HWTEST_F(SceneSessionManagerTest11, CreateAndConnectSpecificSession01, TestSize. sptr iRemoteObjectMocker = sptr::MakeSptr(); property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); - auto result = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, - persistentId, session, systemConfig, iRemoteObjectMocker); + auto result = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, persistentId, session, systemConfig, iRemoteObjectMocker); ASSERT_EQ(result, WSError::WS_ERROR_NOT_SYSTEM_APP); property->SetTopmost(false); @@ -699,10 +699,10 @@ HWTEST_F(SceneSessionManagerTest11, CreateAndConnectSpecificSession01, TestSize. std::string bundleName = "bundleName_test"; sptr parentSession = GetSceneSession(bundleName); parentSession->GetSessionProperty()->SetSubWindowLevel(10); - ssm_->sceneSessionMap_.insert({1, parentSession}); + ssm_->sceneSessionMap_.insert({ 1, parentSession }); property->SetParentPersistentId(1); - result = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, - persistentId, session, systemConfig, iRemoteObjectMocker); + result = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, persistentId, session, systemConfig, iRemoteObjectMocker); ASSERT_EQ(result, WSError::WS_ERROR_INVALID_WINDOW); } @@ -753,7 +753,7 @@ HWTEST_F(SceneSessionManagerTest11, GetStartingWindowInfoFromCache, TestSize.Lev bool res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); ASSERT_EQ(res, false); - std::map startingWindowInfoMap{{ BUNDLE_NAME, startingWindowInfo }}; + std::map startingWindowInfoMap{ { BUNDLE_NAME, startingWindowInfo } }; ssm_->startingWindowMap_.insert({ BUNDLE_NAME, startingWindowInfoMap }); res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); ASSERT_EQ(res, false); @@ -777,7 +777,7 @@ HWTEST_F(SceneSessionManagerTest11, GetStartingWindowInfoFromCache02, TestSize.L bool res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); ASSERT_EQ(res, false); - std::map startingWindowInfoMap{{ "test", startingWindowInfo }}; + std::map startingWindowInfoMap{ { "test", startingWindowInfo } }; ssm_->startingWindowMap_.insert({ "test", startingWindowInfoMap }); res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); @@ -934,6 +934,6 @@ HWTEST_F(SceneSessionManagerTest11, GetTopNearestBlockingFocusSession_branch05, ASSERT_EQ(nullptr, ssm_->GetTopNearestBlockingFocusSession(displayId, zOrder, includingAppSession)); ssm_->sceneSessionMap_.clear(); } -} // namespace -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 4513bc6b97..05a531c71a 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -51,10 +51,14 @@ public: // keyboard void ConstructKeyboardCallingWindowTestData(const KeyboardTestData& keyboardTestData); bool CheckKeyboardOccupiedAreaInfo(const Rect& desiredRect, const WSRect& actualRect); - void GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType windowType, DisplayId cDisplayId, - DisplayId kDisplayId, SessionState keyboardState, WindowGravity gravity); + void GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType windowType, + DisplayId cDisplayId, + DisplayId kDisplayId, + SessionState keyboardState, + WindowGravity gravity); static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; @@ -71,27 +75,28 @@ void SceneSessionManagerTest12::TearDownTestCase() ssm_ = nullptr; } -void SceneSessionManagerTest12::SetUp() -{ -} +void SceneSessionManagerTest12::SetUp() {} void SceneSessionManagerTest12::TearDown() { usleep(WAIT_SYNC_IN_NS); } -const Rect landscapePanelRect_ = {0, 538, 2720, 722}; -const Rect portraitPanelRect_ = {0, 1700, 1260, 1020}; +const Rect landscapePanelRect_ = { 0, 538, 2720, 722 }; +const Rect portraitPanelRect_ = { 0, 1700, 1260, 1020 }; std::vector> avoidAreas_ = {}; bool SceneSessionManagerTest12::CheckKeyboardOccupiedAreaInfo(const Rect& desiredRect, const WSRect& actualRect) { return desiredRect.posX_ == actualRect.posX_ && desiredRect.posY_ == actualRect.posY_ && - static_cast(desiredRect.width_) == actualRect.width_ && - static_cast(desiredRect.height_) == actualRect.height_; + static_cast(desiredRect.width_) == actualRect.width_ && + static_cast(desiredRect.height_) == actualRect.height_; } void SceneSessionManagerTest12::GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType windowType, - DisplayId cDisplayId, DisplayId kDisplayId, SessionState keyboardState, WindowGravity gravity) + DisplayId cDisplayId, + DisplayId kDisplayId, + SessionState keyboardState, + WindowGravity gravity) { ssm_->sceneSessionMap_.clear(); avoidAreas_.clear(); @@ -120,15 +125,24 @@ void SceneSessionManagerTest12::GetKeyboardOccupiedAreaWithRotationTestData(Wind keyboardSession->SetSessionState(keyboardState); keyboardSession->SetSessionProperty(keyboardProperties); - ssm_->sceneSessionMap_.insert({1, callingSession}); - ssm_->sceneSessionMap_.insert({2, keyboardSession}); + ssm_->sceneSessionMap_.insert({ 1, callingSession }); + ssm_->sceneSessionMap_.insert({ 2, keyboardSession }); } class KeyboardTestData { public: - KeyboardTestData(uint64_t cScreenId, int32_t cPid, int32_t kScreenId, WindowType keyboardWindowType, - bool isSysKeyboard) : cScreenId_(cScreenId), cPid_(cPid), kScreenId_(kScreenId), - keyboardWindowType_(keyboardWindowType), isSysKeyboard_(isSysKeyboard) {} + KeyboardTestData(uint64_t cScreenId, + int32_t cPid, + int32_t kScreenId, + WindowType keyboardWindowType, + bool isSysKeyboard) + : cScreenId_(cScreenId), + cPid_(cPid), + kScreenId_(kScreenId), + keyboardWindowType_(keyboardWindowType), + isSysKeyboard_(isSysKeyboard) + { + } void SetCallingSessionId(uint32_t callingSessionId) { @@ -137,8 +151,8 @@ public: private: uint64_t cScreenId_; // screenId of callingWindow - int32_t cPid_; // callingPid of callingWindow - int32_t kScreenId_; // screenId of keyboard + int32_t cPid_; // callingPid of callingWindow + int32_t kScreenId_; // screenId of keyboard WindowType keyboardWindowType_; bool isSysKeyboard_; uint32_t callingSessionId_; @@ -169,8 +183,8 @@ void SceneSessionManagerTest12::ConstructKeyboardCallingWindowTestData(const Key keyboardProperties->SetCallingSessionId(keyboardTestData.callingSessionId_); keyboardSession->SetSessionProperty(keyboardProperties); - ssm_->sceneSessionMap_.insert({keyboardTestData.callingSessionId_, callingSession}); - ssm_->sceneSessionMap_.insert({2, keyboardSession}); + ssm_->sceneSessionMap_.insert({ keyboardTestData.callingSessionId_, callingSession }); + ssm_->sceneSessionMap_.insert({ 2, keyboardSession }); } namespace { @@ -485,34 +499,34 @@ HWTEST_F(SceneSessionManagerTest12, CreateAndConnectSpecificSession03, TestSize. ASSERT_NE(ssm_, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); - auto res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + auto res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res); property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); property->SetTopmost(true); uint32_t flags = property->GetWindowFlags() & (~(static_cast(WindowFlag::WINDOW_FLAG_IS_MODAL))); property->SetWindowFlags(flags); - res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res); property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); property->SetFloatingWindowAppType(true); ssm_->shouldHideNonSecureFloatingWindows_.store(true); - res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res); property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW); - res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_ERROR_INVALID_WINDOW, res); property->SetWindowType(WindowType::WINDOW_TYPE_PIP); ssm_->isScreenLocked_ = true; - res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_DO_NOTHING, res); } @@ -547,7 +561,7 @@ HWTEST_F(SceneSessionManagerTest12, DestroyAndDisconnectSpecificSessionInner02, info.bundleName_ = "test2"; sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); - std::vector recoveredPersistentIds = {0, 1, 2}; + std::vector recoveredPersistentIds = { 0, 1, 2 }; ssm_->SetAlivePersistentIds(recoveredPersistentIds); property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); auto ret = ssm_->DestroyAndDisconnectSpecificSessionInner(1); @@ -651,7 +665,7 @@ HWTEST_F(SceneSessionManagerTest12, DestroyAndDisconnectSpecificSessionInner, Te sptr session; sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); - std::vector recoveredPersistentIds = {0, 1, 2}; + std::vector recoveredPersistentIds = { 0, 1, 2 }; ssm_->SetAlivePersistentIds(recoveredPersistentIds); ProcessShiftFocusFunc shiftFocusFunc_; property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); @@ -700,7 +714,7 @@ HWTEST_F(SceneSessionManagerTest12, IsKeyboardForeground, TestSize.Level1) info.bundleName_ = "test2"; sptr sceneSession = sptr::MakeSptr(info, nullptr); sceneSession->property_ = sptr::MakeSptr(); - sceneSessionManager->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + sceneSessionManager->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); sceneSession->state_ = SessionState::STATE_FOREGROUND; @@ -778,12 +792,12 @@ HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_01, TestSize.Leve SessionInfo sourceInfo; sourceInfo.windowType_ = 1; sptr sourceSceneSession = sptr::MakeSptr(sourceInfo, nullptr); - ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession}); + ssm_->sceneSessionMap_.insert({ sourceSceneSession->GetPersistentId(), sourceSceneSession }); SessionInfo targetInfo; targetInfo.windowType_ = 1; sptr targetSceneSession = sptr::MakeSptr(targetInfo, nullptr); - ssm_->sceneSessionMap_.insert({targetSceneSession->GetPersistentId(), targetSceneSession}); + ssm_->sceneSessionMap_.insert({ targetSceneSession->GetPersistentId(), targetSceneSession }); ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; WMError result = ssm_->ShiftAppWindowPointerEvent(INVALID_SESSION_ID, targetSceneSession->GetPersistentId()); @@ -804,12 +818,12 @@ HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_02, TestSize.Leve SessionInfo systemWindowInfo; systemWindowInfo.windowType_ = 2000; sptr systemWindowSession = sptr::MakeSptr(systemWindowInfo, nullptr); - ssm_->sceneSessionMap_.insert({systemWindowSession->GetPersistentId(), systemWindowSession}); + ssm_->sceneSessionMap_.insert({ systemWindowSession->GetPersistentId(), systemWindowSession }); SessionInfo mainWindowInfo; mainWindowInfo.windowType_ = 1; sptr mainWindowSession = sptr::MakeSptr(mainWindowInfo, nullptr); - ssm_->sceneSessionMap_.insert({mainWindowSession->GetPersistentId(), mainWindowSession}); + ssm_->sceneSessionMap_.insert({ mainWindowSession->GetPersistentId(), mainWindowSession }); int mainWindowPersistentId = mainWindowSession->GetPersistentId(); int systemWindowPersistentId = systemWindowSession->GetPersistentId(); @@ -832,7 +846,7 @@ HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_03, TestSize.Leve SessionInfo sourceInfo; sourceInfo.windowType_ = 1; sptr sourceSceneSession = sptr::MakeSptr(sourceInfo, nullptr); - ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession}); + ssm_->sceneSessionMap_.insert({ sourceSceneSession->GetPersistentId(), sourceSceneSession }); int32_t sourcePersistentId = sourceSceneSession->GetPersistentId(); ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; @@ -855,19 +869,19 @@ HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEvent_04, TestSize.Leve SessionInfo sourceInfo; sourceInfo.windowType_ = 1; sptr sourceSceneSession = sptr::MakeSptr(sourceInfo, nullptr); - ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession}); + ssm_->sceneSessionMap_.insert({ sourceSceneSession->GetPersistentId(), sourceSceneSession }); SessionInfo otherSourceInfo; otherSourceInfo.bundleName_ = "other"; otherSourceInfo.windowType_ = 1; sptr otherSourceSession = sptr::MakeSptr(otherSourceInfo, nullptr); - ssm_->sceneSessionMap_.insert({otherSourceSession->GetPersistentId(), otherSourceSession}); + ssm_->sceneSessionMap_.insert({ otherSourceSession->GetPersistentId(), otherSourceSession }); SessionInfo otherTargetInfo; otherTargetInfo.bundleName_ = "other"; otherTargetInfo.windowType_ = 1; sptr otherTargetSession = sptr::MakeSptr(otherTargetInfo, nullptr); - ssm_->sceneSessionMap_.insert({otherTargetSession->GetPersistentId(), otherTargetSession}); + ssm_->sceneSessionMap_.insert({ otherTargetSession->GetPersistentId(), otherTargetSession }); int32_t sourcePersistentId = sourceSceneSession->GetPersistentId(); int32_t otherSourcePersistentId = otherSourceSession->GetPersistentId(); @@ -892,12 +906,12 @@ HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEventInner01, TestSize. SessionInfo sourceInfo; sourceInfo.windowType_ = 1; sptr sourceSceneSession = sptr::MakeSptr(sourceInfo, nullptr); - ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession}); + ssm_->sceneSessionMap_.insert({ sourceSceneSession->GetPersistentId(), sourceSceneSession }); SessionInfo targetInfo; targetInfo.windowType_ = 1; sptr targetSceneSession = sptr::MakeSptr(targetInfo, nullptr); - ssm_->sceneSessionMap_.insert({targetSceneSession->GetPersistentId(), targetSceneSession}); + ssm_->sceneSessionMap_.insert({ targetSceneSession->GetPersistentId(), targetSceneSession }); ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; WMError result = ssm_->ShiftAppWindowPointerEventInner( @@ -917,12 +931,12 @@ HWTEST_F(SceneSessionManagerTest12, ShiftAppWindowPointerEventInner02, TestSize. SessionInfo sourceInfo; sourceInfo.windowType_ = 1; sptr sourceSceneSession = sptr::MakeSptr(sourceInfo, nullptr); - ssm_->sceneSessionMap_.insert({sourceSceneSession->GetPersistentId(), sourceSceneSession}); + ssm_->sceneSessionMap_.insert({ sourceSceneSession->GetPersistentId(), sourceSceneSession }); SessionInfo targetInfo; targetInfo.windowType_ = 1; sptr targetSceneSession = sptr::MakeSptr(targetInfo, nullptr); - ssm_->sceneSessionMap_.insert({targetSceneSession->GetPersistentId(), targetSceneSession}); + ssm_->sceneSessionMap_.insert({ targetSceneSession->GetPersistentId(), targetSceneSession }); ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; WMError result = ssm_->ShiftAppWindowPointerEventInner( @@ -944,7 +958,7 @@ HWTEST_F(SceneSessionManagerTest12, GetKeyboardSession, TestSize.Level1) info.abilityName_ = "GetKeyboardSession"; info.bundleName_ = "GetKeyboardSession"; info.windowType_ = 2105; // 2105 is WINDOW_TYPE_INPUT_METHOD_FLOAT - info.screenId_ = 1; // 1 is screenId + info.screenId_ = 1; // 1 is screenId sptr keyboardSession = sptr::MakeSptr(info, nullptr, nullptr); ASSERT_EQ(false, keyboardSession->IsSystemKeyboard()); ssm->sceneSessionMap_.insert({ keyboardSession->GetPersistentId(), keyboardSession }); @@ -970,7 +984,7 @@ HWTEST_F(SceneSessionManagerTest12, UpdateKeyboardAvoidAreaActive, TestSize.Leve info.abilityName_ = "UpdateKeyboardAvoidAreaActive"; info.bundleName_ = "UpdateKeyboardAvoidAreaActive"; info.windowType_ = 2105; // 2105 is WINDOW_TYPE_INPUT_METHOD_FLOAT - info.screenId_ = 1; // 1 is screenId + info.screenId_ = 1; // 1 is screenId sptr keyboardSession = sptr::MakeSptr(info, nullptr, nullptr); ASSERT_NE(nullptr, keyboardSession->GetSessionProperty()); keyboardSession->GetSessionProperty()->SetDisplayId(info.screenId_); @@ -1003,7 +1017,7 @@ HWTEST_F(SceneSessionManagerTest12, HandleKeyboardAvoidChange, TestSize.Level1) info.abilityName_ = "HandleKeyboardAvoidChange"; info.bundleName_ = "HandleKeyboardAvoidChange"; info.windowType_ = 2105; // 2105 is WINDOW_TYPE_INPUT_METHOD_FLOAT - info.screenId_ = 1; // 1 is screenId + info.screenId_ = 1; // 1 is screenId sptr keyboardSession = sptr::MakeSptr(info, nullptr, nullptr); ASSERT_NE(nullptr, keyboardSession->GetSessionProperty()); keyboardSession->GetSessionProperty()->SetDisplayId(info.screenId_); @@ -1017,36 +1031,39 @@ HWTEST_F(SceneSessionManagerTest12, HandleKeyboardAvoidChange, TestSize.Level1) ssm->sceneSessionMap_.insert({ systemKeyboardSession->GetPersistentId(), systemKeyboardSession }); ssm->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; - ssm->HandleKeyboardAvoidChange(keyboardSession, keyboardSession->GetScreenId(), - SystemKeyboardAvoidChangeReason::KEYBOARD_CREATED); + ssm->HandleKeyboardAvoidChange( + keyboardSession, keyboardSession->GetScreenId(), SystemKeyboardAvoidChangeReason::KEYBOARD_CREATED); ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_); ssm->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; - ssm->HandleKeyboardAvoidChange(keyboardSession, keyboardSession->GetScreenId(), - SystemKeyboardAvoidChangeReason::KEYBOARD_CREATED); + ssm->HandleKeyboardAvoidChange( + keyboardSession, keyboardSession->GetScreenId(), SystemKeyboardAvoidChangeReason::KEYBOARD_CREATED); ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_); - ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(), - SystemKeyboardAvoidChangeReason::KEYBOARD_SHOW); + ssm->HandleKeyboardAvoidChange( + systemKeyboardSession, systemKeyboardSession->GetScreenId(), SystemKeyboardAvoidChangeReason::KEYBOARD_SHOW); ASSERT_EQ(false, keyboardSession->keyboardAvoidAreaActive_); ASSERT_EQ(true, systemKeyboardSession->keyboardAvoidAreaActive_); - ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(), + ssm->HandleKeyboardAvoidChange(systemKeyboardSession, + systemKeyboardSession->GetScreenId(), SystemKeyboardAvoidChangeReason::KEYBOARD_GRAVITY_BOTTOM); ASSERT_EQ(false, keyboardSession->keyboardAvoidAreaActive_); ASSERT_EQ(true, systemKeyboardSession->keyboardAvoidAreaActive_); - ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(), - SystemKeyboardAvoidChangeReason::KEYBOARD_HIDE); + ssm->HandleKeyboardAvoidChange( + systemKeyboardSession, systemKeyboardSession->GetScreenId(), SystemKeyboardAvoidChangeReason::KEYBOARD_HIDE); ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_); ASSERT_EQ(false, systemKeyboardSession->keyboardAvoidAreaActive_); - ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(), + ssm->HandleKeyboardAvoidChange(systemKeyboardSession, + systemKeyboardSession->GetScreenId(), SystemKeyboardAvoidChangeReason::KEYBOARD_DISCONNECT); ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_); ASSERT_EQ(false, systemKeyboardSession->keyboardAvoidAreaActive_); - ssm->HandleKeyboardAvoidChange(systemKeyboardSession, systemKeyboardSession->GetScreenId(), + ssm->HandleKeyboardAvoidChange(systemKeyboardSession, + systemKeyboardSession->GetScreenId(), SystemKeyboardAvoidChangeReason::KEYBOARD_GRAVITY_FLOAT); ASSERT_EQ(true, keyboardSession->keyboardAvoidAreaActive_); ASSERT_EQ(false, systemKeyboardSession->keyboardAvoidAreaActive_); @@ -1059,8 +1076,8 @@ HWTEST_F(SceneSessionManagerTest12, HandleKeyboardAvoidChange, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest12, GetAllWindowLayoutInfo01, TestSize.Level0) { - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); SessionInfo sessionInfo; sessionInfo.isSystem_ = false; @@ -1133,7 +1150,7 @@ HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo02, TestSize. sceneSession1->SetSessionGlobalRect(rect); int32_t zOrder = 100; sceneSession1->SetZOrder(zOrder); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); sessionInfo.isSystem_ = true; sessionInfo.abilityName_ = "SCBSmartDock"; @@ -1213,8 +1230,8 @@ HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo03, TestSize. */ HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo04, TestSize.Level0) { - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); SessionInfo sessionInfo; sessionInfo.isSystem_ = false; @@ -1278,8 +1295,8 @@ HWTEST_F(SceneSessionManagerTest12, FilterForGetAllWindowLayoutInfo05, TestSize. */ HWTEST_F(SceneSessionManagerTest12, GetFoldLowerScreenPosY01, TestSize.Level0) { - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); ASSERT_EQ(2472, ssm_->GetFoldLowerScreenPosY()); } @@ -1674,7 +1691,7 @@ HWTEST_F(SceneSessionManagerTest12, UpdateSessionWithFoldStateChange, TestSize.L info.bundleName_ = "test1"; info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); EXPECT_CALL(*sceneSession, UpdateCrossAxis()).Times(1); ssm_->UpdateSessionWithFoldStateChange(10, SuperFoldStatus::EXPANDED, SuperFoldStatus::FOLDED); } @@ -1729,22 +1746,22 @@ HWTEST_F(SceneSessionManagerTest12, SetStatusBarAvoidHeight, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation1, TestSize.Level1) { - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PHONE_WINDOW, 0, 0, - SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PHONE_WINDOW, 0, 0, SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_0, avoidAreas_); ASSERT_EQ(1, static_cast(avoidAreas_.size())); ASSERT_EQ(true, avoidAreas_[0].first); ASSERT_EQ(true, CheckKeyboardOccupiedAreaInfo(portraitPanelRect_, avoidAreas_[0].second)); - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PAD_WINDOW, 0, 0, - SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PAD_WINDOW, 0, 0, SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_90, avoidAreas_); ASSERT_EQ(1, static_cast(avoidAreas_.size())); ASSERT_EQ(true, avoidAreas_[0].first); ASSERT_EQ(true, CheckKeyboardOccupiedAreaInfo(landscapePanelRect_, avoidAreas_[0].second)); - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PC_WINDOW, 0, 0, - SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PC_WINDOW, 0, 0, SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_0, avoidAreas_); ASSERT_EQ(0, static_cast(avoidAreas_.size())); } @@ -1756,8 +1773,8 @@ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation1, TestSi */ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation2, TestSize.Level1) { - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PHONE_WINDOW, 0, 0, - SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PHONE_WINDOW, 0, 0, SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(-1, Rotation::ROTATION_0, avoidAreas_); ASSERT_EQ(0, static_cast(avoidAreas_.size())); @@ -1765,8 +1782,8 @@ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation2, TestSi ssm_->GetKeyboardOccupiedAreaWithRotation(0, Rotation::ROTATION_0, avoidAreas_); ASSERT_EQ(0, static_cast(avoidAreas_.size())); - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PHONE_WINDOW, 12, 0, - SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PHONE_WINDOW, 12, 0, SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_0, avoidAreas_); ASSERT_EQ(0, static_cast(avoidAreas_.size())); } @@ -1778,8 +1795,8 @@ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation2, TestSi */ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation4, TestSize.Level1) { - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PHONE_WINDOW, 0, 0, - SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_FLOAT); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PHONE_WINDOW, 0, 0, SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_FLOAT); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_0, avoidAreas_); ASSERT_EQ(1, static_cast(avoidAreas_.size())); @@ -1794,8 +1811,8 @@ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation4, TestSi */ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation5, TestSize.Level1) { - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PHONE_WINDOW, 0, 0, - SessionState::STATE_BACKGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PHONE_WINDOW, 0, 0, SessionState::STATE_BACKGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_90, avoidAreas_); ASSERT_EQ(1, static_cast(avoidAreas_.size())); @@ -1810,8 +1827,8 @@ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation5, TestSi */ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation6, TestSize.Level1) { - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PHONE_WINDOW, 0, 0, - SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PHONE_WINDOW, 0, 0, SessionState::STATE_FOREGROUND, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_180, avoidAreas_); ASSERT_EQ(1, static_cast(avoidAreas_.size())); @@ -1831,8 +1848,8 @@ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation6, TestSi */ HWTEST_F(SceneSessionManagerTest12, GetKeyboardOccupiedAreaWithRotation7, TestSize.Level1) { - GetKeyboardOccupiedAreaWithRotationTestData(WindowUIType::PHONE_WINDOW, 0, 0, - SessionState::STATE_ACTIVE, WindowGravity::WINDOW_GRAVITY_BOTTOM); + GetKeyboardOccupiedAreaWithRotationTestData( + WindowUIType::PHONE_WINDOW, 0, 0, SessionState::STATE_ACTIVE, WindowGravity::WINDOW_GRAVITY_BOTTOM); ssm_->GetKeyboardOccupiedAreaWithRotation(1, Rotation::ROTATION_270, avoidAreas_); ASSERT_EQ(1, static_cast(avoidAreas_.size())); @@ -1896,8 +1913,8 @@ HWTEST_F(SceneSessionManagerTest12, QueryAbilityInfoFromBMSTest, TestSize.Level1 sessionInfo_.moduleName_ = "ModuleName"; ssm_->bundleMgr_ = nullptr; - auto res = ssm_->QueryAbilityInfoFromBMS(uId, - sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); + auto res = ssm_->QueryAbilityInfoFromBMS( + uId, sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); EXPECT_EQ(res, nullptr); } @@ -1919,8 +1936,8 @@ HWTEST_F(SceneSessionManagerTest12, QueryAbilityInfoFromBMSTest001, TestSize.Lev }; ssm_->abilityInfoMap_[listKey] = std::make_shared(); - auto res = ssm_->QueryAbilityInfoFromBMS(uId, - sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); + auto res = ssm_->QueryAbilityInfoFromBMS( + uId, sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); EXPECT_NE(res, nullptr); } @@ -2023,14 +2040,13 @@ HWTEST_F(SceneSessionManagerTest12, AddSkipSelfWhenShowOnVirtualScreenList, Func info.bundleName_ = "AddSkipSelfWhenShowOnVirtualScreenList"; info.abilityName_ = "AddSkipSelfWhenShowOnVirtualScreenList"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); - std::vector persistentIds {sceneSession->GetPersistentId()}; + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); + std::vector persistentIds{ sceneSession->GetPersistentId() }; auto ret = ssm_->AddSkipSelfWhenShowOnVirtualScreenList(persistentIds); usleep(WAIT_SYNC_IN_NS); EXPECT_EQ(ret, WMError::WM_OK); } - /** * @tc.name: RemoveSkipSelfWhenShowOnVirtualScreenList * @tc.desc: test function : RemoveSkipSelfWhenShowOnVirtualScreenList @@ -2042,8 +2058,8 @@ HWTEST_F(SceneSessionManagerTest12, RemoveSkipSelfWhenShowOnVirtualScreenList, F info.bundleName_ = "RemoveSkipSelfWhenShowOnVirtualScreenList"; info.abilityName_ = "RemoveSkipSelfWhenShowOnVirtualScreenList"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); - std::vector persistentIds {sceneSession->GetPersistentId()}; + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); + std::vector persistentIds{ sceneSession->GetPersistentId() }; auto ret = ssm_->RemoveSkipSelfWhenShowOnVirtualScreenList(persistentIds); usleep(WAIT_SYNC_IN_NS); EXPECT_EQ(ret, WMError::WM_OK); @@ -2116,7 +2132,7 @@ HWTEST_F(SceneSessionManagerTest12, UpdateSessionDisplayId1, TestSize.Level0) EXPECT_CALL(*wmAgentLiteMocker, NotifyCallingWindowDisplayChanged(_)).Times(0); ssm_->UpdateSessionDisplayId(86, 12); - keyboardTestData = {0, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, true}; + keyboardTestData = { 0, 57256, 0, WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, true }; keyboardTestData.SetCallingSessionId(86); ConstructKeyboardCallingWindowTestData(keyboardTestData); EXPECT_CALL(*wmAgentLiteMocker, NotifyCallingWindowDisplayChanged(_)).Times(0); @@ -2146,7 +2162,7 @@ HWTEST_F(SceneSessionManagerTest12, UpdateSessionDisplayId2, TestSize.Level0) sceneSessionProperties->SetDisplayId(0); sceneSession->SetSessionProperty(sceneSessionProperties); // Add non-callingWindow - ssm_->sceneSessionMap_.insert({90, sceneSession}); + ssm_->sceneSessionMap_.insert({ 90, sceneSession }); // Change display id of non-callingWindow EXPECT_CALL(*wmAgentLiteMocker, NotifyCallingWindowDisplayChanged(_)).Times(0); ssm_->UpdateSessionDisplayId(90, 12); @@ -2182,7 +2198,7 @@ HWTEST_F(SceneSessionManagerTest12, GetActiveSceneSessionCopy, Function | SmallT info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr sceneSession = sptr::MakeSptr(info, nullptr); sceneSession->state_ = SessionState::STATE_FOREGROUND; - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::vector> activeSession = ssm_->GetActiveSceneSessionCopy(); EXPECT_EQ(activeSession.empty(), false); } @@ -2205,7 +2221,7 @@ HWTEST_F(SceneSessionManagerTest12, GetHookedSessionByModuleName, Function | Sma auto res = ssm_->GetHookedSessionByModuleName(info); ASSERT_EQ(res, nullptr); - ssm_->sceneSessionMap_.insert({101, sceneSession}); + ssm_->sceneSessionMap_.insert({ 101, sceneSession }); res = ssm_->GetHookedSessionByModuleName(info); ASSERT_EQ(res, sceneSession); @@ -2250,6 +2266,6 @@ HWTEST_F(SceneSessionManagerTest12, RequestSceneSession, Function | SmallTest | ASSERT_NE(result, nullptr); ASSERT_EQ(result->GetSessionInfo().moduleName_, info.moduleName_); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test2.cpp b/window_scene/test/unittest/scene_session_manager_test2.cpp index 3afb3b4190..52d6f1e431 100644 --- a/window_scene/test/unittest/scene_session_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_test2.cpp @@ -62,7 +62,7 @@ ConfigItem ReadConfig(const std::string& xmlStr) xmlFreeDoc(docPtr); return config; } -} +} // namespace class SceneSessionManagerTest2 : public testing::Test { public: static void SetUpTestCase(); @@ -81,18 +81,12 @@ private: sptr SceneSessionManagerTest2::ssm_ = nullptr; bool SceneSessionManagerTest2::gestureNavigationEnabled_ = true; -ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest2::callbackFunc_ = [](bool enable, - const std::string& bundleName, GestureBackType type) { - gestureNavigationEnabled_ = enable; -}; +ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest2::callbackFunc_ = + [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} void SceneSessionManagerTest2::SetUpTestCase() { @@ -155,8 +149,7 @@ HWTEST_F(SceneSessionManagerTest2, RegisterWindowManagerAgent, TestSize.Level1) WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm_->RegisterWindowManagerAgent(type, windowManagerAgent)); - ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm_->UnregisterWindowManagerAgent( - type, windowManagerAgent)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ssm_->UnregisterWindowManagerAgent(type, windowManagerAgent)); } /** @@ -166,7 +159,8 @@ HWTEST_F(SceneSessionManagerTest2, RegisterWindowManagerAgent, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSizeLimits01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "10" @@ -192,37 +186,38 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSizeLimits01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "off" - "off" - "off" - "" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "" - "" - "0" - "#111111" - "2" - "2" - "1" - "1" - "" - "" - "" - "" + "" + "" + "" + "off" + "off" + "off" + "" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" + "0" + "#111111" + "2" + "2" + "1" + "1" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -244,25 +239,26 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "off" - "off" - "" - "" - "" - "0" - "0" - "" - "" - "0" - "" - "" - "" - "" + "" + "" + "" + "off" + "off" + "" + "" + "" + "0" + "0" + "" + "" + "0" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -276,32 +272,33 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect02, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "" - "" - "0" - "#111111" - "2" - "2" - "1" - "1" - "" - "" - "" - "" + "" + "" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" + "0" + "#111111" + "2" + "2" + "1" + "1" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -323,35 +320,36 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect03, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "off" - "off" - "off" - "" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "" - "" + "" + "" + "" + "off" + "off" + "off" + "" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -372,27 +370,28 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect04, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect05, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "" - "0" - "1" - "2" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "" - "" + "" + "" + "" + "" + "0" + "1" + "2" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -409,27 +408,28 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect05, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect06, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "" - "0" - "1" - "2" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "" - "" + "" + "" + "" + "" + "0" + "1" + "2" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -446,27 +446,28 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect06, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect07, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "" - "0" - "1" - "2" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "" - "" + "" + "" + "" + "" + "0" + "1" + "2" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -483,27 +484,28 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect07, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect08, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "" - "0" - "1" - "2" - "" - "" - "0" - "#000000" - "1" - "1" - "0" - "0.5" - "" - "" - "" - "" + "" + "" + "" + "" + "0" + "1" + "2" + "" + "" + "0" + "#000000" + "1" + "1" + "0" + "0.5" + "" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -520,7 +522,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowEffect08, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, TestSize.Level1) { - std::string xmlStr1 = "" + std::string xmlStr1 = + "" "" "" "fullscreen" @@ -529,7 +532,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, TestSize.Level1) WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "fullscreen" @@ -538,7 +542,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, TestSize.Level1) WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, - static_cast(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN)); + static_cast(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN)); } /** @@ -548,15 +552,15 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, - WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); } /** @@ -566,7 +570,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor02, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "floating" @@ -574,8 +579,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor03, TestSize.Level1) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, - WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); } /** @@ -585,7 +589,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor03, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "pip" @@ -593,8 +598,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor04, TestSize.Level1) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, - WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); } /** @@ -604,7 +608,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor04, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor05, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "split" @@ -613,8 +618,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor05, TestSize.Level1) WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); } /** @@ -624,7 +629,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor05, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigDecor06, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "111" @@ -632,8 +638,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor06, TestSize.Level1) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, - WINDOW_MODE_SUPPORT_ALL); + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WINDOW_MODE_SUPPORT_ALL); } /** @@ -643,21 +648,22 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor06, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "10" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - std::string xmlStr1 = "" + std::string xmlStr1 = + "" "" "102" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_, - static_cast(static_cast(102))); + ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_, static_cast(static_cast(102))); } /** @@ -667,7 +673,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "1 1" "phone" @@ -678,14 +685,14 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml02, TestSize.Level1) WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - std::string xmlStr1 = "" + std::string xmlStr1 = + "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_, - static_cast(static_cast(1))); + ASSERT_EQ(ssm_->systemConfig_.defaultWindowMode_, static_cast(static_cast(1))); } /** @@ -695,21 +702,22 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml02, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "1 1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - std::string xmlStr1 = "" + std::string xmlStr1 = + "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(SceneSession::maximizeMode_, - static_cast(static_cast(1))); + ASSERT_EQ(SceneSession::maximizeMode_, static_cast(static_cast(1))); } /** @@ -719,21 +727,22 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml03, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "111" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - std::string xmlStr1 = "" + std::string xmlStr1 = + "" "" "0" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(SceneSession::maximizeMode_, - static_cast(static_cast(0))); + ASSERT_EQ(SceneSession::maximizeMode_, static_cast(static_cast(0))); } /** @@ -743,21 +752,22 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml04, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml05, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - std::string xmlStr1 = "" + std::string xmlStr1 = + "" "" "1" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.maxFloatingWindowSize_, - static_cast(1)); + ASSERT_EQ(ssm_->systemConfig_.maxFloatingWindowSize_, static_cast(1)); } /** @@ -767,7 +777,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml05, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml07, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" ""; @@ -783,7 +794,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml07, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml08, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "rotation" ""; @@ -799,18 +811,19 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml08, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "350" - "" - "" - "0.7 0.7" - "0 0 1 0" - "0 0" - "0" - "" + "" + "" + "350" + "" + "" + "0.7 0.7" + "0 0 1 0" + "0 0" + "0" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -833,14 +846,15 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "350" - "" - "" - "" + "" + "" + "350" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -854,16 +868,17 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation02, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "0.7 0.7" - "0 0 1 0" - "0 0" - "0" - "" + "" + "" + "" + "0.7 0.7" + "0 0 1 0" + "0 0" + "0" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -885,18 +900,19 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation03, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "aaa" - "" - "" - "0.7 0.7" - "0 0 1 0" - "0 0" - "0" - "" + "" + "" + "aaa" + "" + "" + "0.7 0.7" + "0 0 1 0" + "0 0" + "0" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -918,18 +934,19 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation04, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation05, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "350 350" - "" - "" - "0.7 0.7" - "0 0 1 0" - "0 0" - "0" - "" + "" + "" + "350 350" + "" + "" + "0.7 0.7" + "0 0 1 0" + "0 0" + "0" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -951,18 +968,19 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation05, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation06, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "350" - "" - "" - "a a" - "a a a a" - "a a" - "a" - "" + "" + "" + "350" + "" + "" + "a a" + "a a a a" + "a a" + "a" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -976,18 +994,19 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation06, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation07, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "350" - "" - "" - "0.7 0.7 0.7" - "0 0 1 0 1" - "0 0 1" - "0 1" - "" + "" + "" + "350" + "" + "" + "0.7 0.7 0.7" + "0 0 1 0 1" + "0 0 1" + "0 1" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -1001,16 +1020,17 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowAnimation07, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "200" - "" - "" - "1" - "0" - "" + "" + "" + "200" + "" + "" + "1" + "0" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -1027,16 +1047,17 @@ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation01, TestSize.Lev */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "200" - "" - "" - "1" - "0" - "" + "" + "" + "200" + "" + "" + "1" + "0" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -1052,16 +1073,17 @@ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation02, TestSize.Lev */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "aaa" - "" - "" - "aaa" - "aaa" - "" + "" + "" + "aaa" + "" + "" + "aaa" + "aaa" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -1075,16 +1097,17 @@ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation03, TestSize.Lev */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "200 200" - "" - "" - "1 1" - "0 1" - "" + "" + "" + "200 200" + "" + "" + "1 1" + "0 1" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -1098,16 +1121,17 @@ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation04, TestSize.Lev */ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation05, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "aaa aaa" - "" - "" - "a a" - "a a" - "" + "" + "" + "aaa aaa" + "" + "" + "a a" + "a a" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -1121,7 +1145,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigStartingWindowAnimation05, TestSize.Lev */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "0.7" ""; @@ -1137,7 +1162,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale01, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "0.7 0.7" ""; @@ -1153,7 +1179,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale02, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "aaa" ""; @@ -1169,7 +1196,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale03, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "-0.1" ""; @@ -1185,7 +1213,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale04, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale05, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "1.5" ""; @@ -1201,22 +1230,24 @@ HWTEST_F(SceneSessionManagerTest2, ConfigSnapshotScale05, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigSystemUIStatusBar01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "1" - "#4c000000" - "#ffffee" - "" + "" + "1" + "#4c000000" + "#ffffee" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); sptr sceneSessionManager = sptr::MakeSptr(); sceneSessionManager->ConfigWindowSceneXml(); ASSERT_EQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_, 1); ASSERT_STREQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_.c_str(), - "#4c000000"); - ASSERT_STREQ(sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_. - immersiveStatusBarContentColor_.c_str(), "#ffffee"); + "#4c000000"); + ASSERT_STREQ( + sceneSessionManager->appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarContentColor_.c_str(), + "#ffffee"); } /** @@ -1265,7 +1296,7 @@ HWTEST_F(SceneSessionManagerTest2, UpdateRecoveredSessionInfo, TestSize.Level1) info.bundleName_ = "test2"; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds); ssm_->sceneSessionMap_.erase(0); } @@ -1288,7 +1319,7 @@ HWTEST_F(SceneSessionManagerTest2, UpdateRecoveredSessionInfo02, TestSize.Level1 sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); ssm_->failRecoveredPersistentIdSet_.insert(0); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds); ssm_->failRecoveredPersistentIdSet_.erase(0); ssm_->sceneSessionMap_.erase(1); @@ -1310,7 +1341,7 @@ HWTEST_F(SceneSessionManagerTest2, NotifyCreateSubSession, TestSize.Level1) sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); NotifyCreateSubSessionFunc func; - ssm_->createSubSessionFuncMap_.insert({1, func}); + ssm_->createSubSessionFuncMap_.insert({ 1, func }); ssm_->NotifyCreateSubSession(1, sceneSession, 256); ssm_->createSubSessionFuncMap_.erase(1); ASSERT_EQ(ret, 0); @@ -1335,8 +1366,8 @@ HWTEST_F(SceneSessionManagerTest2, ConfigWindowSceneXml, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState, TestSize.Level1) { - MessageParcel *data = new MessageParcel(); - sptr token = data->ReadRemoteObject(); + MessageParcel* data = new MessageParcel(); + sptr token = data->ReadRemoteObject(); auto continueState = static_cast(data->ReadInt32()); WSError result02 = ssm_->SetSessionContinueState(nullptr, continueState); WSError result01 = ssm_->SetSessionContinueState(token, continueState); @@ -1352,7 +1383,7 @@ HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState002, TestSize.Level1) { - MessageParcel *data = new MessageParcel(); + MessageParcel* data = new MessageParcel(); sptr token = data->ReadRemoteObject(); auto continueState = static_cast(0); SessionInfo info; @@ -1363,7 +1394,7 @@ HWTEST_F(SceneSessionManagerTest2, SetSessionContinueState002, TestSize.Level1) delete data; return; } - ssm_->sceneSessionMap_.insert({1000, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1000, sceneSession }); ssm_->SetSessionContinueState(token, continueState); ASSERT_NE(sceneSession, nullptr); delete data; @@ -1411,7 +1442,7 @@ HWTEST_F(SceneSessionManagerTest2, GetFocusWindowInfo2, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ssm_->GetFocusWindowInfo(fcinfo); } @@ -1429,7 +1460,7 @@ HWTEST_F(SceneSessionManagerTest2, SetSessionLabel, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->SetSessionLabel(nullptr, "test"); } @@ -1447,7 +1478,7 @@ HWTEST_F(SceneSessionManagerTest2, SetSessionIcon, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->SetSessionIcon(nullptr, nullptr); } @@ -1476,7 +1507,7 @@ HWTEST_F(SceneSessionManagerTest2, PendingSessionToForeground, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->PendingSessionToForeground(nullptr); } @@ -1496,7 +1527,7 @@ HWTEST_F(SceneSessionManagerTest2, GetFocusSessionToken, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ret = ssm_->GetFocusSessionToken(token); ASSERT_EQ(WSError::WS_ERROR_INVALID_PERMISSION, ret); } @@ -1516,7 +1547,7 @@ HWTEST_F(SceneSessionManagerTest2, GetFocusSessionElement, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->GetFocusSessionElement(element); } @@ -1573,7 +1604,7 @@ HWTEST_F(SceneSessionManagerTest2, GetIsLayoutFullScreen, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); isLayoutFullScreen = true; ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen); ASSERT_EQ(WSError::WS_OK, ret); @@ -1602,7 +1633,7 @@ HWTEST_F(SceneSessionManagerTest2, UpdateSessionAvoidAreaListener, TestSize.Leve info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->UpdateSessionAvoidAreaListener(persistentId, true); ssm_->UpdateSessionAvoidAreaListener(persistentId, false); } @@ -1626,7 +1657,7 @@ HWTEST_F(SceneSessionManagerTest2, UpdateSessionTouchOutsideListener, TestSize.L info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->UpdateSessionTouchOutsideListener(persistentId, true); ssm_->UpdateSessionTouchOutsideListener(persistentId, false); @@ -1689,7 +1720,7 @@ HWTEST_F(SceneSessionManagerTest2, GetTopWindowId, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ret = ssm_->GetTopWindowId(persistentId, topWinId); ASSERT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, ret); } @@ -1729,7 +1760,7 @@ HWTEST_F(SceneSessionManagerTest2, GetAccessibilityWindowInfo, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ret = ssm_->GetAccessibilityWindowInfo(infos); ASSERT_EQ(WMError::WM_OK, ret); } @@ -1753,7 +1784,7 @@ HWTEST_F(SceneSessionManagerTest2, OnScreenshot, TestSize.Level1) info.abilityName_ = "BackgroundTask02"; info.bundleName_ = "BackgroundTask02"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->OnScreenshot(displayId); sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); @@ -1811,8 +1842,8 @@ HWTEST_F(SceneSessionManagerTest2, ProcessSubSessionForeground, TestSize.Level1) sceneSession->subSession_ = subs; ssm_->ProcessSubSessionForeground(sceneSession); - ssm_->sceneSessionMap_.insert({0, sceneSession}); - ssm_->sceneSessionMap_.insert({100, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); + ssm_->sceneSessionMap_.insert({ 100, sceneSession }); ssm_->ProcessSubSessionForeground(sceneSession); ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; ssm_->ProcessSubSessionForeground(sceneSession); @@ -1826,10 +1857,11 @@ HWTEST_F(SceneSessionManagerTest2, ProcessSubSessionForeground, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest2, ConfigSystemUIStatusBar02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); sptr sceneSessionManager = sptr::MakeSptr(); @@ -1849,7 +1881,7 @@ HWTEST_F(SceneSessionManagerTest2, ClosePipWindowIfExist, TestSize.Level1) ssm_->ClosePipWindowIfExist(WindowType::WINDOW_TYPE_PIP); SessionInfo info; - info.sessionState_ = {1}; + info.sessionState_ = { 1 }; Rect reqRect = { 0, 0, 10, 10 }; property->SetRequestRect(reqRect); property->SetWindowMode(WindowMode::WINDOW_MODE_PIP); @@ -1871,8 +1903,8 @@ HWTEST_F(SceneSessionManagerTest2, RecoverAndConnectSpecificSession, TestSize.Le std::shared_ptr surfaceNode; sptr session; sptr token; - auto result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, - surfaceNode, property, session, token); + auto result = + ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } @@ -1898,8 +1930,8 @@ HWTEST_F(SceneSessionManagerTest2, RecoverAndConnectSpecificSession02, TestSize. sptr session; sptr token; ASSERT_NE(ssm_, nullptr); - auto result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, - surfaceNode, property, session, token); + auto result = + ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } @@ -1911,7 +1943,7 @@ HWTEST_F(SceneSessionManagerTest2, RecoverAndConnectSpecificSession02, TestSize. HWTEST_F(SceneSessionManagerTest2, SetAlivePersistentIds, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); - std::vector recoveredPersistentIds = {0, 1, 2}; + std::vector recoveredPersistentIds = { 0, 1, 2 }; ssm_->SetAlivePersistentIds(recoveredPersistentIds); ASSERT_EQ(ssm_->alivePersistentIds_, recoveredPersistentIds); } @@ -2008,11 +2040,11 @@ HWTEST_F(SceneSessionManagerTest2, ParseWindowModeFromMetaData, Function | Small sptr sceneSession = ssm_->CreateSceneSession(info, property); ASSERT_NE(sceneSession, nullptr); - std::vector updateWindowModes = - {AppExecFwk::SupportWindowMode::FULLSCREEN, AppExecFwk::SupportWindowMode::SPLIT, - AppExecFwk::SupportWindowMode::FLOATING}; + std::vector updateWindowModes = { AppExecFwk::SupportWindowMode::FULLSCREEN, + AppExecFwk::SupportWindowMode::SPLIT, + AppExecFwk::SupportWindowMode::FLOATING }; ASSERT_EQ(updateWindowModes, ssm_->ParseWindowModeFromMetaData("fullscreen,split,floating")); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test3.cpp b/window_scene/test/unittest/scene_session_manager_test3.cpp index 932e2f13cb..f8b0e5a38f 100644 --- a/window_scene/test/unittest/scene_session_manager_test3.cpp +++ b/window_scene/test/unittest/scene_session_manager_test3.cpp @@ -37,30 +37,30 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { - const std::string EMPTY_DEVICE_ID = ""; - using ConfigItem = WindowSceneConfig::ConfigItem; - ConfigItem ReadConfig(const std::string& xmlStr) - { - ConfigItem config; - xmlDocPtr docPtr = xmlParseMemory(xmlStr.c_str(), xmlStr.length() + 1); - if (docPtr == nullptr) { - return config; - } - - xmlNodePtr rootPtr = xmlDocGetRootElement(docPtr); - if (rootPtr == nullptr || rootPtr->name == nullptr || - xmlStrcmp(rootPtr->name, reinterpret_cast("Configs"))) { - xmlFreeDoc(docPtr); - return config; - } - - std::map configMap; - config.SetValue(configMap); - WindowSceneConfig::ReadConfig(rootPtr, *config.mapValue_); +const std::string EMPTY_DEVICE_ID = ""; +using ConfigItem = WindowSceneConfig::ConfigItem; +ConfigItem ReadConfig(const std::string& xmlStr) +{ + ConfigItem config; + xmlDocPtr docPtr = xmlParseMemory(xmlStr.c_str(), xmlStr.length() + 1); + if (docPtr == nullptr) { + return config; + } + + xmlNodePtr rootPtr = xmlDocGetRootElement(docPtr); + if (rootPtr == nullptr || rootPtr->name == nullptr || + xmlStrcmp(rootPtr->name, reinterpret_cast("Configs"))) { xmlFreeDoc(docPtr); return config; } + + std::map configMap; + config.SetValue(configMap); + WindowSceneConfig::ReadConfig(rootPtr, *config.mapValue_); + xmlFreeDoc(docPtr); + return config; } +} // namespace class SceneSessionManagerTest3 : public testing::Test { public: static void SetUpTestCase(); @@ -71,6 +71,7 @@ public: static bool gestureNavigationEnabled_; static ProcessGestureNavigationEnabledChangeFunc callbackFunc_; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 50000; }; @@ -78,18 +79,12 @@ private: sptr SceneSessionManagerTest3::ssm_ = nullptr; bool SceneSessionManagerTest3::gestureNavigationEnabled_ = true; -ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest3::callbackFunc_ = [](bool enable, - const std::string& bundleName, GestureBackType type) { - gestureNavigationEnabled_ = enable; -}; +ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest3::callbackFunc_ = + [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable, const std::string& bundleName) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable, const std::string& bundleName) {} void SceneSessionManagerTest3::SetUpTestCase() { @@ -175,26 +170,26 @@ HWTEST_F(SceneSessionManagerTest3, ConfigAppWindowShadow, TestSize.Level1) WindowSceneConfig::ConfigItem item; WindowSceneConfig::ConfigItem shadowConfig; WindowShadowConfig outShadow; - std::vector floatTest = {0.0f, 0.1f, 0.2f, 0.3f}; + std::vector floatTest = { 0.0f, 0.1f, 0.2f, 0.3f }; bool result01 = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result01, true); item.SetValue(floatTest); - shadowConfig.SetValue({{"radius", item}}); + shadowConfig.SetValue({ { "radius", item } }); bool result02 = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result02, false); - shadowConfig.SetValue({{"alpha", item}}); + shadowConfig.SetValue({ { "alpha", item } }); bool result03 = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result03, false); - shadowConfig.SetValue({{"sffsetY", item}}); + shadowConfig.SetValue({ { "sffsetY", item } }); bool result04 = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result04, true); - shadowConfig.SetValue({{"sffsetX", item}}); + shadowConfig.SetValue({ { "sffsetX", item } }); bool result05 = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result05, true); item.SetValue(new std::string("color")); - shadowConfig.SetValue({{"color", item}}); + shadowConfig.SetValue({ { "color", item } }); bool result06 = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result06, true); } @@ -210,13 +205,14 @@ HWTEST_F(SceneSessionManagerTest3, ConfigStatusBar, TestSize.Level1) WindowSceneConfig::ConfigItem enable; enable.SetValue(true); WindowSceneConfig::ConfigItem showHide; - showHide.SetProperty({{"enable", enable}}); + showHide.SetProperty({ { "enable", enable } }); WindowSceneConfig::ConfigItem item01; WindowSceneConfig::ConfigItem contentColor; contentColor.SetValue(std::string("#12345678")); WindowSceneConfig::ConfigItem backgroundColor; backgroundColor.SetValue(std::string("#12345678")); - item01.SetValue({{"showHide", showHide}, {"contentColor", contentColor}, {"backgroundColor", backgroundColor}}); + item01.SetValue( + { { "showHide", showHide }, { "contentColor", contentColor }, { "backgroundColor", backgroundColor } }); bool result01 = ssm_->ConfigStatusBar(item01, out); ASSERT_EQ(result01, true); ASSERT_EQ(out.showHide_, true); @@ -231,27 +227,28 @@ HWTEST_F(SceneSessionManagerTest3, ConfigStatusBar, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest3, ConfigWindowImmersive, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "#12341234" - "#12341234" - "" - "" - "" - "" - "#12341234" - "#12341234" - "" - "" - "" - "#12341234" - "#12341234" - "" - "" - "" + "" + "" + "" + "#12341234" + "#12341234" + "" + "" + "" + "" + "#12341234" + "#12341234" + "" + "" + "" + "#12341234" + "#12341234" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -275,42 +272,42 @@ HWTEST_F(SceneSessionManagerTest3, ConfigWindowAnimation, TestSize.Level1) { WindowSceneConfig::ConfigItem windowAnimationConfig; WindowSceneConfig::ConfigItem item; - std::vector opacity = {0.1f}; - std::vector translate = {0.1f, 0.2f}; - std::vector rotation = {0.1f, 0.2f, 0.3f, 0.4f}; - std::vector scale = {0.1f, 0.2f}; - std::vector duration = {39}; + std::vector opacity = { 0.1f }; + std::vector translate = { 0.1f, 0.2f }; + std::vector rotation = { 0.1f, 0.2f, 0.3f, 0.4f }; + std::vector scale = { 0.1f, 0.2f }; + std::vector duration = { 39 }; item.SetValue(opacity); - windowAnimationConfig.SetValue({{"opacity", item}}); + windowAnimationConfig.SetValue({ { "opacity", item } }); int ret = 0; ssm_->ConfigWindowAnimation(windowAnimationConfig); ASSERT_EQ(ret, 0); item.SetValue(rotation); - windowAnimationConfig.SetValue({{"rotation", item}}); + windowAnimationConfig.SetValue({ { "rotation", item } }); ssm_->ConfigWindowAnimation(windowAnimationConfig); ASSERT_EQ(ret, 0); item.SetValue(translate); - windowAnimationConfig.SetValue({{"translate", item}}); + windowAnimationConfig.SetValue({ { "translate", item } }); ssm_->ConfigWindowAnimation(windowAnimationConfig); ASSERT_EQ(ret, 0); item.SetValue(scale); - windowAnimationConfig.SetValue({{"scale", item}}); + windowAnimationConfig.SetValue({ { "scale", item } }); ssm_->ConfigWindowAnimation(windowAnimationConfig); ASSERT_EQ(ret, 0); item.SetValue(duration); - item.SetValue({{"duration", item}}); - windowAnimationConfig.SetValue({{"timing", item}}); + item.SetValue({ { "duration", item } }); + windowAnimationConfig.SetValue({ { "timing", item } }); ssm_->ConfigWindowAnimation(windowAnimationConfig); ASSERT_EQ(ret, 0); item.SetValue(duration); - item.SetValue({{"curve", item}}); - windowAnimationConfig.SetValue({{"timing", item}}); + item.SetValue({ { "curve", item } }); + windowAnimationConfig.SetValue({ { "timing", item } }); ssm_->ConfigWindowAnimation(windowAnimationConfig); ASSERT_EQ(ret, 0); } @@ -342,22 +339,24 @@ HWTEST_F(SceneSessionManagerTest3, RecoverAndReconnectSceneSession, TestSize.Lev */ HWTEST_F(SceneSessionManagerTest3, ConfigStartingWindowAnimation, TestSize.Level1) { - std::vector midFloat = {0.1f}; - std::vector midInt = {1}; + std::vector midFloat = { 0.1f }; + std::vector midInt = { 1 }; WindowSceneConfig::ConfigItem middleFloat; middleFloat.SetValue(midFloat); WindowSceneConfig::ConfigItem middleInt; middleInt.SetValue(midInt); WindowSceneConfig::ConfigItem curve; curve.SetValue(midFloat); - curve.SetValue({{"curve", curve}}); + curve.SetValue({ { "curve", curve } }); WindowSceneConfig::ConfigItem enableConfigItem; enableConfigItem.SetValue(false); - std::map midMap = {{"duration", middleInt}, {"curve", curve}}; + std::map midMap = { { "duration", middleInt }, { "curve", curve } }; WindowSceneConfig::ConfigItem timing; timing.SetValue(midMap); - std::map middleMap = {{"enable", enableConfigItem}, - {"timing", timing}, {"opacityStart", middleFloat}, {"opacityEnd", middleFloat}}; + std::map middleMap = { { "enable", enableConfigItem }, + { "timing", timing }, + { "opacityStart", middleFloat }, + { "opacityEnd", middleFloat } }; WindowSceneConfig::ConfigItem configItem; configItem.SetValue(middleMap); int ret = 0; @@ -380,19 +379,19 @@ HWTEST_F(SceneSessionManagerTest3, CreateCurve, TestSize.Level1) std::string value02 = "userName"; curveConfig.SetValue(value02); - curveConfig.SetValue({{"name", curveConfig}}); + curveConfig.SetValue({ { "name", curveConfig } }); std::string result02 = std::get(ssm_->CreateCurve(curveConfig)); ASSERT_EQ(result02, "easeOut"); std::string value03 = "interactiveSpring"; curveConfig.SetValue(value03); - curveConfig.SetValue({{"name", curveConfig}}); + curveConfig.SetValue({ { "name", curveConfig } }); std::string result03 = std::get(ssm_->CreateCurve(curveConfig)); ASSERT_EQ(result03, "easeOut"); std::string value04 = "cubic"; curveConfig.SetValue(value04); - curveConfig.SetValue({{"name", curveConfig}}); + curveConfig.SetValue({ { "name", curveConfig } }); std::string result04 = std::get(ssm_->CreateCurve(curveConfig)); ASSERT_EQ(result04, "easeOut"); } @@ -448,7 +447,7 @@ HWTEST_F(SceneSessionManagerTest3, GetSceneSession002, TestSize.Level1) if (sceneSession == nullptr) { return; } - ssm_->sceneSessionMap_.insert({65535, sceneSession}); + ssm_->sceneSessionMap_.insert({ 65535, sceneSession }); int32_t persistentId = 65535; ASSERT_NE(ssm_->GetSceneSession(persistentId), nullptr); } @@ -475,7 +474,7 @@ HWTEST_F(SceneSessionManagerTest3, GetSceneSessionByIdentityInfo, TestSize.Level int32_t appIndex1 = 10; SessionIdentityInfo identityInfo = { bundleName1, moduleName1, abilityName1, appIndex1 }; ASSERT_EQ(ssm_->GetSceneSessionByIdentityInfo(identityInfo), nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); std::string bundleName2 = "test11"; std::string moduleName2 = "test22"; std::string abilityName2 = "test33"; @@ -513,7 +512,7 @@ HWTEST_F(SceneSessionManagerTest3, GetSceneSessionVectorByTypeAndDisplayId, Test if (sceneSession == nullptr) { return; } - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->GetSceneSessionVectorByTypeAndDisplayId(WindowType::APP_MAIN_WINDOW_BASE, displayId); sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); ssm_->GetSceneSessionVectorByTypeAndDisplayId(WindowType::APP_MAIN_WINDOW_BASE, displayId); @@ -543,9 +542,9 @@ HWTEST_F(SceneSessionManagerTest3, GetWindowLimits, TestSize.Level1) limits.maxWidth_ = 1000; limits.minWidth_ = 500; sceneSession->property_->SetWindowLimits(limits); - + int32_t windowId = 1; - ssm_->sceneSessionMap_.insert({windowId, sceneSession}); + ssm_->sceneSessionMap_.insert({ windowId, sceneSession }); auto defaultUIType = ssm_->systemConfig_.windowUIType_; ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; auto ret = ssm_->GetWindowLimits(windowId); @@ -568,14 +567,14 @@ HWTEST_F(SceneSessionManagerTest3, CheckWindowId, TestSize.Level1) int32_t windowId = 1; int32_t pid = 2; ssm_->CheckWindowId(windowId, pid); - ssm_->sceneSessionMap_.insert({windowId, nullptr}); + ssm_->sceneSessionMap_.insert({ windowId, nullptr }); ssm_->CheckWindowId(windowId, pid); SessionInfo info; info.abilityName_ = "test1"; info.bundleName_ = "test2"; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({windowId, sceneSession}); + ssm_->sceneSessionMap_.insert({ windowId, sceneSession }); ssm_->CheckWindowId(windowId, pid); ssm_->PerformRegisterInRequestSceneSession(sceneSession); ssm_->sceneSessionMap_.erase(windowId); @@ -613,9 +612,9 @@ HWTEST_F(SceneSessionManagerTest3, CheckAppIsInDisplay, TestSize.Level1) ssm_->isPrepareTerminateEnable_ = false; ssm_->PrepareTerminate(1, res); ssm_->StartUIAbilityBySCB(sceneSession); - ssm_->sceneSessionMap_.insert({1, nullptr}); + ssm_->sceneSessionMap_.insert({ 1, nullptr }); ssm_->IsKeyboardForeground(); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->NotifyForegroundInteractiveStatus(sceneSession, true); ssm_->NotifyForegroundInteractiveStatus(sceneSession, false); property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); @@ -806,9 +805,7 @@ HWTEST_F(SceneSessionManagerTest3, NotifySessionTouchOutside, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest3, SetOutsideDownEventListener, TestSize.Level1) { - ProcessOutsideDownEventFunc func = [](int32_t x, int32_t y) { - ssm_->OnOutsideDownEvent(x, y); - }; + ProcessOutsideDownEventFunc func = [](int32_t x, int32_t y) { ssm_->OnOutsideDownEvent(x, y); }; int ret = 0; ssm_->SetOutsideDownEventListener(func); ASSERT_EQ(ret, 0); @@ -889,7 +886,7 @@ HWTEST_F(SceneSessionManagerTest3, GetSessionInfoByContinueSessionId, TestSize.L std::string continueSessionId = ""; SessionInfoBean missionInfo; EXPECT_EQ(ssm_->GetSessionInfoByContinueSessionId(continueSessionId, missionInfo), - WSError::WS_ERROR_INVALID_PERMISSION); + WSError::WS_ERROR_INVALID_PERMISSION); } /** @@ -991,12 +988,10 @@ HWTEST_F(SceneSessionManagerTest3, QueryAbilityInfoFromBMS, TestSize.Level1) sessionInfo_.moduleName_ = "ModuleName"; AppExecFwk::AbilityInfo abilityInfo; int32_t collaboratorType = CollaboratorType::RESERVE_TYPE; - ssm_->QueryAbilityInfoFromBMS(uId, - sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); + ssm_->QueryAbilityInfoFromBMS(uId, sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); EXPECT_EQ(sessionInfo_.want, nullptr); ssm_->Init(); - ssm_->QueryAbilityInfoFromBMS(uId, - sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); + ssm_->QueryAbilityInfoFromBMS(uId, sessionInfo_.bundleName_, sessionInfo_.abilityName_, sessionInfo_.moduleName_); ssm_->NotifyStartAbility(collaboratorType, sessionInfo_); sessionInfo_.want = std::make_shared(); collaboratorType = CollaboratorType::OTHERS_TYPE; @@ -1015,8 +1010,7 @@ HWTEST_F(SceneSessionManagerTest3, NotifyStartAbility, TestSize.Level1) sessionInfo.moduleName_ = "SceneSessionManagerTest"; sessionInfo.bundleName_ = "SceneSessionManagerTest3"; sessionInfo.abilityName_ = "NotifyStartAbility"; - sptr collaborator = - iface_cast(nullptr); + sptr collaborator = iface_cast(nullptr); ssm_->collaboratorMap_.clear(); ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); int32_t collaboratorType = 1; @@ -1237,8 +1231,7 @@ HWTEST_F(SceneSessionManagerTest3, RequestFocusStatusBySA, TestSize.Level1) bool isFocused = true; bool byForeground = true; FocusChangeReason reason = FocusChangeReason::CLICK; - auto result = ssm_->SceneSessionManager::RequestFocusStatusBySA( - persistentId, isFocused, byForeground, reason); + auto result = ssm_->SceneSessionManager::RequestFocusStatusBySA(persistentId, isFocused, byForeground, reason); ASSERT_EQ(result, WMError::WM_ERROR_INVALID_PERMISSION); } @@ -1455,7 +1448,7 @@ HWTEST_F(SceneSessionManagerTest3, GerPrivacyBundleListOneWindow, TestSize.Level sceneSession->GetSessionProperty()->displayId_ = 0; sceneSession->GetSessionProperty()->isPrivacyMode_ = true; sceneSession->state_ = SessionState::STATE_FOREGROUND; - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); std::unordered_set privacyBundleList; sceneSession->GetSessionProperty()->isPrivacyMode_ = false; @@ -1494,7 +1487,7 @@ HWTEST_F(SceneSessionManagerTest3, GetTopWindowId, TestSize.Level1) auto sceneSession1 = sptr::MakeSptr(sessionInfo1, nullptr); ASSERT_NE(sceneSession1, nullptr); sceneSession1->SetCallingPid(65534); - ssm_->sceneSessionMap_.insert({100, sceneSession1}); + ssm_->sceneSessionMap_.insert({ 100, sceneSession1 }); SessionInfo sessionInfo2; sessionInfo2.bundleName_ = "subWin1"; @@ -1503,7 +1496,7 @@ HWTEST_F(SceneSessionManagerTest3, GetTopWindowId, TestSize.Level1) auto sceneSession2 = sptr::MakeSptr(sessionInfo2, nullptr); ASSERT_NE(sceneSession2, nullptr); sceneSession2->SetCallingPid(65535); - ssm_->sceneSessionMap_.insert({101, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 101, sceneSession2 }); SessionInfo sessionInfo3; sessionInfo3.bundleName_ = "subWin2"; @@ -1512,13 +1505,13 @@ HWTEST_F(SceneSessionManagerTest3, GetTopWindowId, TestSize.Level1) auto sceneSession3 = sptr::MakeSptr(sessionInfo3, nullptr); ASSERT_NE(sceneSession3, nullptr); sceneSession3->SetCallingPid(65534); - ssm_->sceneSessionMap_.insert({102, sceneSession3}); + ssm_->sceneSessionMap_.insert({ 102, sceneSession3 }); sceneSession1->AddSubSession(sceneSession2); sceneSession1->AddSubSession(sceneSession3); uint32_t topWinId; ASSERT_NE(ssm_->GetTopWindowId(static_cast(sceneSession1->GetPersistentId()), topWinId), - WMError::WM_ERROR_INVALID_WINDOW); + WMError::WM_ERROR_INVALID_WINDOW); } /** @@ -1568,12 +1561,12 @@ HWTEST_F(SceneSessionManagerTest3, ConfigAppWindowShadow02, TestSize.Level1) ASSERT_EQ(result, true); item.SetValue(floatTest); - shadowConfig.SetValue({{"radius", item}}); + shadowConfig.SetValue({ { "radius", item } }); result = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result, false); item.SetValue(new std::string("")); - shadowConfig.SetValue({{"", item}}); + shadowConfig.SetValue({ { "", item } }); result = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result, true); } @@ -1587,12 +1580,12 @@ HWTEST_F(SceneSessionManagerTest3, ConfigWindowAnimation02, TestSize.Level1) { WindowSceneConfig::ConfigItem windowAnimationConfig; WindowSceneConfig::ConfigItem item; - std::vector rotation = {0.1f, 0.2f, 0.3f, 0.4f}; + std::vector rotation = { 0.1f, 0.2f, 0.3f, 0.4f }; ASSERT_NE(ssm_, nullptr); item.SetValue(rotation); - item.SetValue({{"curve", item}}); - windowAnimationConfig.SetValue({{"timing", item}}); + item.SetValue({ { "curve", item } }); + windowAnimationConfig.SetValue({ { "timing", item } }); ssm_->ConfigWindowAnimation(windowAnimationConfig); } @@ -1603,8 +1596,8 @@ HWTEST_F(SceneSessionManagerTest3, ConfigWindowAnimation02, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest3, ConfigStartingWindowAnimation02, TestSize.Level1) { - std::vector midFloat = {0.1f}; - std::vector midInt = {1}; + std::vector midFloat = { 0.1f }; + std::vector midInt = { 1 }; ASSERT_NE(ssm_, nullptr); WindowSceneConfig::ConfigItem middleFloat; middleFloat.SetValue(midFloat); @@ -1615,7 +1608,7 @@ HWTEST_F(SceneSessionManagerTest3, ConfigStartingWindowAnimation02, TestSize.Lev WindowSceneConfig::ConfigItem curve; curve.SetValue(midFloat); - curve.SetValue({{"curve", curve}}); + curve.SetValue({ { "curve", curve } }); ssm_->ConfigStartingWindowAnimation(curve); } @@ -1627,28 +1620,28 @@ HWTEST_F(SceneSessionManagerTest3, ConfigStartingWindowAnimation02, TestSize.Lev HWTEST_F(SceneSessionManagerTest3, ConfigMainWindowSizeLimits02, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); - std::vector maInt = {1, 2, 3, 4}; + std::vector maInt = { 1, 2, 3, 4 }; WindowSceneConfig::ConfigItem mainleInt; mainleInt.SetValue(maInt); - mainleInt.SetValue({{"miniWidth", mainleInt}}); + mainleInt.SetValue({ { "miniWidth", mainleInt } }); ssm_->ConfigMainWindowSizeLimits(mainleInt); mainleInt.ClearValue(); - std::vector maFloat = {0.1f}; + std::vector maFloat = { 0.1f }; WindowSceneConfig::ConfigItem mainFloat; mainFloat.SetValue(maFloat); - mainFloat.SetValue({{"miniWidth", mainFloat}}); + mainFloat.SetValue({ { "miniWidth", mainFloat } }); ssm_->ConfigMainWindowSizeLimits(mainFloat); mainFloat.ClearValue(); WindowSceneConfig::ConfigItem mainleInt02; mainleInt02.SetValue(maInt); - mainleInt02.SetValue({{"miniHeight", mainleInt02}}); + mainleInt02.SetValue({ { "miniHeight", mainleInt02 } }); ssm_->ConfigMainWindowSizeLimits(mainleInt02); WindowSceneConfig::ConfigItem mainFloat02; mainFloat02.SetValue(maFloat); - mainFloat02.SetValue({{"miniHeight", mainFloat02}}); + mainFloat02.SetValue({ { "miniHeight", mainFloat02 } }); ssm_->ConfigMainWindowSizeLimits(mainFloat02); } @@ -1660,28 +1653,28 @@ HWTEST_F(SceneSessionManagerTest3, ConfigMainWindowSizeLimits02, TestSize.Level1 HWTEST_F(SceneSessionManagerTest3, ConfigSubWindowSizeLimits02, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); - std::vector subInt = {1, 2, 3, 4}; + std::vector subInt = { 1, 2, 3, 4 }; WindowSceneConfig::ConfigItem subleInt; subleInt.SetValue(subInt); - subleInt.SetValue({{"miniWidth", subleInt}}); + subleInt.SetValue({ { "miniWidth", subleInt } }); ssm_->ConfigSubWindowSizeLimits(subleInt); subleInt.ClearValue(); - std::vector subFloat = {0.1f}; + std::vector subFloat = { 0.1f }; WindowSceneConfig::ConfigItem mainFloat; mainFloat.SetValue(subFloat); - mainFloat.SetValue({{"miniWidth", mainFloat}}); + mainFloat.SetValue({ { "miniWidth", mainFloat } }); ssm_->ConfigSubWindowSizeLimits(mainFloat); mainFloat.ClearValue(); WindowSceneConfig::ConfigItem subleInt02; subleInt02.SetValue(subInt); - subleInt02.SetValue({{"miniHeight", subleInt02}}); + subleInt02.SetValue({ { "miniHeight", subleInt02 } }); ssm_->ConfigSubWindowSizeLimits(subleInt02); WindowSceneConfig::ConfigItem mainFloat02; mainFloat02.SetValue(subFloat); - mainFloat02.SetValue({{"miniHeight", mainFloat02}}); + mainFloat02.SetValue({ { "miniHeight", mainFloat02 } }); ssm_->ConfigSubWindowSizeLimits(mainFloat02); } @@ -1693,30 +1686,30 @@ HWTEST_F(SceneSessionManagerTest3, ConfigSubWindowSizeLimits02, TestSize.Level1) HWTEST_F(SceneSessionManagerTest3, ConfigDialogWindowSizeLimits01, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); - std::vector subInt = {1, 2, 3, 4}; + std::vector subInt = { 1, 2, 3, 4 }; WindowSceneConfig::ConfigItem subleInt; subleInt.SetValue(subInt); - subleInt.SetValue({{"miniWidth", subleInt}}); + subleInt.SetValue({ { "miniWidth", subleInt } }); ssm_->ConfigDialogWindowSizeLimits(subleInt); subleInt.ClearValue(); - std::vector subFloat = {0.1f}; + std::vector subFloat = { 0.1f }; WindowSceneConfig::ConfigItem mainFloat; mainFloat.SetValue(subFloat); - mainFloat.SetValue({{"miniWidth", mainFloat}}); + mainFloat.SetValue({ { "miniWidth", mainFloat } }); ssm_->ConfigDialogWindowSizeLimits(mainFloat); mainFloat.ClearValue(); WindowSceneConfig::ConfigItem subleInt02; subleInt02.SetValue(subInt); - subleInt02.SetValue({{"miniHeight", subleInt02}}); + subleInt02.SetValue({ { "miniHeight", subleInt02 } }); ssm_->ConfigDialogWindowSizeLimits(subleInt02); WindowSceneConfig::ConfigItem mainFloat02; mainFloat02.SetValue(subFloat); - mainFloat02.SetValue({{"miniHeight", mainFloat02}}); + mainFloat02.SetValue({ { "miniHeight", mainFloat02 } }); ssm_->ConfigDialogWindowSizeLimits(mainFloat02); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index be7fee9473..58c61340e4 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -60,19 +60,12 @@ private: sptr SceneSessionManagerTest4::ssm_ = nullptr; bool SceneSessionManagerTest4::gestureNavigationEnabled_ = true; -ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest4::callbackFunc_ = [](bool enable, - const std::string& bundleName, GestureBackType type) { - gestureNavigationEnabled_ = enable; -}; +ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest4::callbackFunc_ = + [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} - -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} void SceneSessionManagerTest4::SetUpTestCase() { @@ -95,7 +88,6 @@ void SceneSessionManagerTest4::TearDown() usleep(WAIT_SYNC_IN_NS); } - namespace { /** * @tc.name: UpdateSceneSessionWant01 @@ -134,7 +126,7 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant03, TestSize.Level1) info.persistentId_ = 1; auto sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->UpdateSceneSessionWant(info); ASSERT_NE(ssm_, nullptr); } @@ -152,7 +144,7 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant04, TestSize.Level1) info.want = want; auto sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->UpdateSceneSessionWant(info); ASSERT_NE(ssm_, nullptr); } @@ -172,7 +164,7 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant05, TestSize.Level1) ASSERT_NE(sceneSession, nullptr); int32_t collaboratorType = CollaboratorType::RESERVE_TYPE; sceneSession->SetCollaboratorType(collaboratorType); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->UpdateSceneSessionWant(info); ASSERT_NE(ssm_, nullptr); } @@ -192,7 +184,7 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSceneSessionWant06, TestSize.Level1) ASSERT_NE(sceneSession, nullptr); int32_t collaboratorType = -1; sceneSession->SetCollaboratorType(collaboratorType); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ssm_->UpdateSceneSessionWant(info); ASSERT_NE(ssm_, nullptr); } @@ -216,7 +208,7 @@ HWTEST_F(SceneSessionManagerTest4, GetSceneSessionByIdentityInfo01, TestSize.Lev info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); SessionIdentityInfo identityInfo = { bundleName, moduleName, abilityName, appIndex }; ASSERT_NE(ssm_->GetSceneSessionByIdentityInfo(identityInfo), nullptr); } @@ -234,7 +226,7 @@ HWTEST_F(SceneSessionManagerTest4, DestroyAndDisconnectSpecificSession01, TestSi info.persistentId_ = 1; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); ASSERT_NE(ssm_->DestroyAndDisconnectSpecificSession(1), WSError::WS_ERROR_NULLPTR); } @@ -343,8 +335,7 @@ HWTEST_F(SceneSessionManagerTest4, UpdateDisplayRegion, TestSize.Level1) displayInfo->SetHeight(height); PcFoldScreenManager::GetInstance().SetDisplayInfo(displayId, SuperFoldStatus::HALF_FOLDED); - PcFoldScreenManager::GetInstance().SetDisplayRects( - WSRect::EMPTY_RECT, { 0, 0, width, height }, WSRect::EMPTY_RECT); + PcFoldScreenManager::GetInstance().SetDisplayRects(WSRect::EMPTY_RECT, { 0, 0, width, height }, WSRect::EMPTY_RECT); ssm_->UpdateDisplayRegion(displayInfo); ASSERT_NE(ssm_->displayRegionMap_.count(displayId), 0); auto region = ssm_->displayRegionMap_[displayId]; @@ -372,7 +363,7 @@ HWTEST_F(SceneSessionManagerTest4, GetDisplayRegion, TestSize.Level1) constexpr int32_t top = 0; constexpr int32_t right = 100; constexpr int32_t bottom = 200; - SkIRect rect { .fLeft = left, .fTop = top, .fRight = right, .fBottom = bottom }; + SkIRect rect{ .fLeft = left, .fTop = top, .fRight = right, .fBottom = bottom }; ssm_->displayRegionMap_[displayId] = std::make_shared(rect); auto region1 = ssm_->GetDisplayRegion(displayId); ASSERT_NE(region1, nullptr); @@ -725,8 +716,7 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSessionWindowVisibilityListener02, Test HWTEST_F(SceneSessionManagerTest4, UpdateDarkColorModeToRS, TestSize.Level1) { ASSERT_NE(nullptr, ssm_); - AbilityRuntime::ApplicationContext::applicationContext_ = - std::make_shared(); + AbilityRuntime::ApplicationContext::applicationContext_ = std::make_shared(); ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_); AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_ = std::make_shared(); @@ -1104,19 +1094,19 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSubWindowVisibility, TestSize.Level1) std::vector> windowVisibilityInfos; std::string visibilityInfo = ""; std::vector> currVisibleData; - ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo, - windowVisibilityInfos, visibilityInfo, currVisibleData); + ssm_->UpdateSubWindowVisibility( + sceneSession, visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData); ASSERT_NE(sceneSession->property_, nullptr); sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END); - ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo, - windowVisibilityInfos, visibilityInfo, currVisibleData); + ssm_->UpdateSubWindowVisibility( + sceneSession, visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData); sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); visibleState = WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION; ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr)); - ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo, - windowVisibilityInfos, visibilityInfo, currVisibleData); + ssm_->UpdateSubWindowVisibility( + sceneSession, visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData); sptr sceneSession01 = sptr::MakeSptr(info, nullptr); sptr sceneSession02 = sptr::MakeSptr(info, nullptr); @@ -1135,8 +1125,8 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSubWindowVisibility, TestSize.Level1) ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01)); ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession02)); ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03)); - ssm_->UpdateSubWindowVisibility(sceneSession, visibleState, visibilityChangeInfo, - windowVisibilityInfos, visibilityInfo, currVisibleData); + ssm_->UpdateSubWindowVisibility( + sceneSession, visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr)); } @@ -1506,8 +1496,7 @@ HWTEST_F(SceneSessionManagerTest4, RegisterSessionExceptionFunc, TestSize.Level1 sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(sceneSession, nullptr); ssm_->sceneSessionMap_.insert(std::make_pair(sessionInfo.persistentId_, sceneSession)); - std::shared_ptr listenerController = - std::make_shared(); + std::shared_ptr listenerController = std::make_shared(); ssm_->listenerController_ = listenerController; ASSERT_NE(ssm_->listenerController_, nullptr); ExceptionInfo exceptionInfo; @@ -1897,7 +1886,6 @@ HWTEST_F(SceneSessionManagerTest4, ProcessModalExtensionPointDown, TestSize.Leve EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(result)); usleep(WAIT_SYNC_IN_NS); } -} +} // namespace } // namespace Rosen } // namespace OHOS - diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 10ded4f859..bde6a7d911 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -34,7 +34,6 @@ #include "mock/mock_window_event_channel.h" #include "context.h" - using namespace testing; using namespace testing::ext; @@ -63,19 +62,12 @@ private: sptr SceneSessionManagerTest5::ssm_ = nullptr; bool SceneSessionManagerTest5::gestureNavigationEnabled_ = true; -ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest5::callbackFunc_ = [](bool enable, - const std::string& bundleName, GestureBackType type) { - gestureNavigationEnabled_ = enable; -}; - +ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest5::callbackFunc_ = + [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} void SceneSessionManagerTest5::SetUpTestCase() { @@ -138,8 +130,8 @@ HWTEST_F(SceneSessionManagerTest5, OnBundleUpdated, TestSize.Level1) sessionInfo.bundleName_ = "bundleName"; auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_; StartingWindowInfo startingWindowInfo; - std::map startingWindowInfoMap{{ key, startingWindowInfo }}; - ssm_->startingWindowMap_.insert({sessionInfo.bundleName_, startingWindowInfoMap}); + std::map startingWindowInfoMap{ { key, startingWindowInfo } }; + ssm_->startingWindowMap_.insert({ sessionInfo.bundleName_, startingWindowInfoMap }); ASSERT_NE(ssm_->startingWindowMap_.size(), 0); /** @@ -168,8 +160,8 @@ HWTEST_F(SceneSessionManagerTest5, OnConfigurationUpdated, TestSize.Level1) sessionInfo.bundleName_ = "bundleName"; auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_; StartingWindowInfo startingWindowInfo; - std::map startingWindowInfoMap{{ key, startingWindowInfo }}; - ssm_->startingWindowMap_.insert({sessionInfo.bundleName_, startingWindowInfoMap}); + std::map startingWindowInfoMap{ { key, startingWindowInfo } }; + ssm_->startingWindowMap_.insert({ sessionInfo.bundleName_, startingWindowInfoMap }); ASSERT_NE(ssm_->startingWindowMap_.size(), 0); /** @@ -394,7 +386,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, TestSize.Level0) sceneSession1->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); focusGroup->SetFocusedSessionId(2); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); ret = ssm_->RequestSessionFocus(1, true, reason); ASSERT_EQ(ret, WSError::WS_OK); ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); @@ -439,8 +431,8 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusClient, TestSize.Level0) sceneSession2->isVisible_ = true; sceneSession2->state_ = SessionState::STATE_ACTIVE; sceneSession2->SetZOrder(2); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); FocusChangeReason reason = FocusChangeReason::CLIENT_REQUEST; auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); @@ -510,9 +502,9 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusClient01, TestSize.Level1) sceneSession3->state_ = SessionState::STATE_ACTIVE; sceneSession3->SetZOrder(3); sceneSession3->blockingFocus_ = true; - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); - ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); + ssm_->sceneSessionMap_.insert({ sceneSession3->GetPersistentId(), sceneSession3 }); FocusChangeReason reason = FocusChangeReason::CLIENT_REQUEST; ssm_->RequestSessionFocus(1, false, reason); @@ -578,8 +570,8 @@ HWTEST_F(SceneSessionManagerTest5, ShiftFocus, TestSize.Level1) sceneSession->persistentId_ = 2; focusedSession->GetSessionProperty()->SetDisplayId(0); sceneSession->GetSessionProperty()->SetDisplayId(12); - ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession}); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ focusedSession->GetPersistentId(), focusedSession }); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ssm_->ShiftFocus(DEFAULT_DISPLAY_ID, sceneSession, false, FocusChangeReason::DEFAULT); } @@ -666,8 +658,8 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, TestSize.Level0) focusedSession->persistentId_ = 2; focusedSession->property_->parentPersistentId_ = 1; ssm_->windowFocusController_->UpdateFocusedSessionId(DEFAULT_DISPLAY_ID, 1); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); - ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); + ssm_->sceneSessionMap_.insert({ focusedSession->GetPersistentId(), focusedSession }); ret = ssm_->RequestSessionUnfocus(1, reason); ASSERT_EQ(ret, WSError::WS_OK); auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); @@ -853,8 +845,8 @@ HWTEST_F(SceneSessionManagerTest5, CheckFocusIsDownThroughBlockingType01, TestSi focusedSession->blockingFocus_ = true; focusedSession->state_ = SessionState::STATE_FOREGROUND; focusedSession->isVisible_ = true; - ssm_->sceneSessionMap_.insert({0, requestSceneSession}); - ssm_->sceneSessionMap_.insert({1, focusedSession}); + ssm_->sceneSessionMap_.insert({ 0, requestSceneSession }); + ssm_->sceneSessionMap_.insert({ 1, focusedSession }); ret = ssm_->CheckFocusIsDownThroughBlockingType(requestSceneSession, focusedSession, includingAppSession); ASSERT_EQ(ret, true); } @@ -981,7 +973,7 @@ HWTEST_F(SceneSessionManagerTest5, PreloadInLakeApp, TestSize.Level1) ssm_->UpdateSessionAvoidAreaListener(persistentId, true); sceneSession = ssm_->CreateSceneSession(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ssm_->UpdateSessionAvoidAreaListener(persistentId, true); } @@ -1000,7 +992,7 @@ HWTEST_F(SceneSessionManagerTest5, NotifyMMIWindowPidChange, TestSize.Level1) ssm_->NotifyMMIWindowPidChange(0, true); sceneSession = ssm_->CreateSceneSession(info, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); } /** @@ -1039,7 +1031,7 @@ HWTEST_F(SceneSessionManagerTest5, PutSnapshotToCache, TestSize.Level1) int32_t persistentId = 30; sceneSession->scenePersistence_ = sptr::MakeSptr(bundleName, persistentId); sceneSession->snapshot_ = std::make_shared(); - ssm_->sceneSessionMap_.insert({30, sceneSession}); + ssm_->sceneSessionMap_.insert({ 30, sceneSession }); for (int32_t id = 30; id <= 30 + ssm_->snapshotCapacity_; ++id) { ssm_->PutSnapshotToCache(id); } @@ -1063,7 +1055,7 @@ HWTEST_F(SceneSessionManagerTest5, VisitSnapshotFromCache, TestSize.Level1) std::string bundleName = "testBundleName"; int32_t persistentId = 30; sceneSession->scenePersistence_ = sptr::MakeSptr(bundleName, persistentId); - ssm_->sceneSessionMap_.insert({30, sceneSession}); + ssm_->sceneSessionMap_.insert({ 30, sceneSession }); sceneSession->snapshot_ = std::make_shared(); for (int32_t id = 30; id < 30 + ssm_->snapshotCapacity_; ++id) { ssm_->PutSnapshotToCache(id); @@ -1090,7 +1082,7 @@ HWTEST_F(SceneSessionManagerTest5, RemoveSnapshotFromCache, TestSize.Level1) std::string bundleName = "testBundleName"; int32_t persistentId = 30; sceneSession->scenePersistence_ = sptr::MakeSptr(bundleName, persistentId); - ssm_->sceneSessionMap_.insert({30, sceneSession}); + ssm_->sceneSessionMap_.insert({ 30, sceneSession }); sceneSession->snapshot_ = std::make_shared(); for (int32_t id = 30; id < 30 + ssm_->snapshotCapacity_; ++id) { ssm_->PutSnapshotToCache(id); @@ -1161,19 +1153,19 @@ HWTEST_F(SceneSessionManagerTest5, ConfigAppWindowShadow03, TestSize.Level1) WindowSceneConfig::ConfigItem item; WindowSceneConfig::ConfigItem shadowConfig; WindowShadowConfig outShadow; - std::vector floatTest = {0.0f, 0.1f, 0.2f, 0.3f}; + std::vector floatTest = { 0.0f, 0.1f, 0.2f, 0.3f }; bool result = ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); ASSERT_EQ(result, true); item.SetValue(floatTest); - shadowConfig.SetValue({{"offsetX", item}}); + shadowConfig.SetValue({ { "offsetX", item } }); ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); - shadowConfig.SetValue({{"offsetY", item}}); + shadowConfig.SetValue({ { "offsetY", item } }); ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); item.SetValue(new std::string("")); - shadowConfig.SetValue({{"color", item}}); + shadowConfig.SetValue({ { "color", item } }); ssm_->ConfigAppWindowShadow(shadowConfig, outShadow); } @@ -1198,32 +1190,32 @@ HWTEST_F(SceneSessionManagerTest5, CreateAndConnectSpecificSession02, TestSize.L ASSERT_NE(property, nullptr); property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); property->SetWindowFlags(123); - WSError res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + WSError res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_ERROR_NULLPTR, res); // create main window, property must be nullptr sessionStage = sptr::MakeSptr(); property = sptr::MakeSptr(); property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); property->SetWindowFlags(123); - res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_OK, res); sessionStage = sptr::MakeSptr(); property = sptr::MakeSptr(); property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); property->SetWindowFlags(123); - res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res); property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); property->SetFloatingWindowAppType(true); ssm_->shouldHideNonSecureFloatingWindows_.store(true); ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; - res = ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, - systemConfig, token); + res = ssm_->CreateAndConnectSpecificSession( + sessionStage, eventChannel, node, property, id, session, systemConfig, token); ASSERT_EQ(WSError::WS_ERROR_NOT_SYSTEM_APP, res); ssm_->shouldHideNonSecureFloatingWindows_.store(false); ssm_->systemConfig_.windowUIType_ = WindowUIType::INVALID_WINDOW; @@ -1245,13 +1237,12 @@ HWTEST_F(SceneSessionManagerTest5, CheckUIExtensionAndSetDisplayId01, TestSize.L sptr property = sptr::MakeSptr(); sptr sessionStage = sptr::MakeSptr(); EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), - WSError::WS_ERROR_NULLPTR); + WSError::WS_ERROR_NULLPTR); property->SetParentPersistentId(parentSession->GetPersistentId()); property->SetIsUIExtFirstSubWindow(true); constexpr DisplayId displayId = 0; parentSession->GetSessionProperty()->SetDisplayId(displayId); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), - WSError::WS_OK); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), WSError::WS_OK); EXPECT_EQ(property->GetDisplayId(), displayId); } @@ -1271,14 +1262,13 @@ HWTEST_F(SceneSessionManagerTest5, CheckUIExtensionAndSetDisplayId02, TestSize.L sptr property = sptr::MakeSptr(); sptr sessionStage = sptr::MakeSptr(); EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), - WSError::WS_ERROR_NULLPTR); + WSError::WS_ERROR_NULLPTR); property->SetParentPersistentId(parentSession->GetPersistentId()); property->SetIsUIExtFirstSubWindow(true); constexpr DisplayId displayId = 0; parentSession->GetSessionProperty()->SetDisplayId(displayId); parentSession->SetClientDisplayId(999); - EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), - WSError::WS_OK); + EXPECT_EQ(ssm_->CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage), WSError::WS_OK); EXPECT_EQ(property->GetDisplayId(), displayId); } @@ -1442,7 +1432,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestSceneSessionBackground03, TestSize.Lev ssm_->RequestSceneSessionBackground(sceneSession, false, false, true); ssm_->sceneSessionMap_.clear(); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ssm_->RequestSceneSessionBackground(sceneSession, false, false, true); ssm_->sceneSessionMap_.clear(); } @@ -1559,7 +1549,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusStatusBySCB, TestSize.Level1) sceneSession->persistentId_ = 1; sceneSession->isVisible_ = true; sceneSession->state_ = SessionState::STATE_ACTIVE; - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); FocusChangeReason reason = FocusChangeReason::FOREGROUND; auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); @@ -1592,7 +1582,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusStatusBySCB01, TestSize.Level1) sceneSession->persistentId_ = 1; sceneSession->isVisible_ = true; sceneSession->state_ = SessionState::STATE_ACTIVE; - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); sptr sceneSession1 = sptr::MakeSptr(info, nullptr); sceneSession1->property_->SetFocusable(true); @@ -1600,7 +1590,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusStatusBySCB01, TestSize.Level1) sceneSession1->persistentId_ = 2; sceneSession1->isVisible_ = true; sceneSession1->state_ = SessionState::STATE_ACTIVE; - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); FocusChangeReason reason = FocusChangeReason::FOREGROUND; auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); ssm_->RequestFocusStatusBySCB(2, true, false, reason); @@ -1648,8 +1638,8 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus01, TestSize.Level1) sceneSession1->zOrder_ = 2; sceneSession1->property_->SetDisplayId(DEFAULT_DISPLAY_ID); sceneSession1->isVisible_ = true; - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); ssm_->SetFocusedSessionId(2, DEFAULT_DISPLAY_ID); ssm_->RequestSessionUnfocus(2, FocusChangeReason::DEFAULT); auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); @@ -1682,8 +1672,8 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus02, TestSize.Level1) sceneSession1->zOrder_ = 2; sceneSession1->property_->SetDisplayId(DEFAULT_DISPLAY_ID); sceneSession1->isVisible_ = true; - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); ssm_->SetFocusedSessionId(2, DEFAULT_DISPLAY_ID); ssm_->RequestSessionUnfocus(2, FocusChangeReason::DEFAULT); auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); @@ -1757,6 +1747,6 @@ HWTEST_F(SceneSessionManagerTest5, SetDelayRemoveSnapshot, TestSize.Level1) auto res = ssm_->GetDelayRemoveSnapshot(); ASSERT_EQ(true, res); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index f7585c0731..b2a5178613 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -21,6 +21,7 @@ #include "interfaces/include/ws_common.h" #include "mock/mock_session_stage.h" #include "mock/mock_window_event_channel.h" +#include "mock/mock_ibundle_mgr.h" #include "session/host/include/scene_session.h" #include "session/host/include/main_session.h" #include "session_info.h" @@ -38,7 +39,7 @@ namespace Rosen { namespace { const std::string EMPTY_DEVICE_ID = ""; using ConfigItem = WindowSceneConfig::ConfigItem; -} +} // namespace class SceneSessionManagerTest6 : public testing::Test { public: static void SetUpTestCase(); @@ -49,6 +50,7 @@ public: static bool gestureNavigationEnabled_; static ProcessGestureNavigationEnabledChangeFunc callbackFunc_; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; @@ -56,18 +58,12 @@ private: sptr SceneSessionManagerTest6::ssm_ = nullptr; bool SceneSessionManagerTest6::gestureNavigationEnabled_ = true; -ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest6::callbackFunc_ = [](bool enable, - const std::string& bundleName, GestureBackType type) { - gestureNavigationEnabled_ = enable; -}; +ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest6::callbackFunc_ = + [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} void SceneSessionManagerTest6::SetUpTestCase() { @@ -114,7 +110,7 @@ HWTEST_F(SceneSessionManagerTest6, MissionChanged, TestSize.Level1) SessionInfo sessionInfoSecond; sessionInfoSecond.bundleName_ = "privacy.test.second"; sessionInfoSecond.abilityName_ = "privacyAbilityName"; - currSession= sptr::MakeSptr(sessionInfoSecond, nullptr); + currSession = sptr::MakeSptr(sessionInfoSecond, nullptr); ASSERT_NE(nullptr, currSession); prevSession->persistentId_ = 0; currSession->persistentId_ = 0; @@ -232,8 +228,7 @@ HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo03, TestSize.Lev currVisibleData.clear(); ssm_->lastVisibleData_.clear(); currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION)); - ssm_->lastVisibleData_.push_back( - std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION)); + ssm_->lastVisibleData_.push_back(std::make_pair(2, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION)); visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData); ASSERT_EQ(visibilityChangeInfos.size(), 1); ASSERT_EQ(visibilityChangeInfos[0].first, 2); @@ -625,7 +620,7 @@ HWTEST_F(SceneSessionManagerTest6, GetSceneSessionPrivacyModeBundles01, TestSize sessionInfoSecond.abilityName_ = "privacyAbilityName"; sptr sceneSessionSecond = sptr::MakeSptr(sessionInfoSecond, nullptr); ASSERT_NE(nullptr, sceneSessionSecond); - ssm_->sceneSessionMap_.insert({sceneSessionSecond->GetPersistentId(), sceneSessionSecond}); + ssm_->sceneSessionMap_.insert({ sceneSessionSecond->GetPersistentId(), sceneSessionSecond }); ASSERT_NE(nullptr, sceneSessionSecond->property_); sceneSessionSecond->property_->displayId_ = 1; sceneSessionSecond->state_ = SessionState::STATE_ACTIVE; @@ -849,6 +844,96 @@ HWTEST_F(SceneSessionManagerTest6, GetAbilityInfosFromBundleInfo, TestSize.Level EXPECT_EQ(WSError::WS_OK, ret); } +/** + * @tc.name: GetCollaboratorAbilityInfos01 + * @tc.desc: GetCollaboratorAbilityInfos01 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, GetCollaboratorAbilityInfos01, TestSize.Level1) +{ + ASSERT_NE(nullptr, ssm_); + std::vector bundleInfos; + std::vector scbAbilityInfos; + int32_t userId = 0; + ssm_->GetCollaboratorAbilityInfos(bundleInfos, scbAbilityInfos, userId); + EXPECT_EQ(scbAbilityInfos.size(), 0); +} + +/** + * @tc.name: GetCollaboratorAbilityInfos02 + * @tc.desc: GetCollaboratorAbilityInfos02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, GetCollaboratorAbilityInfos02, TestSize.Level1) +{ + ASSERT_NE(nullptr, ssm_); + std::string launcherBundleName = "launcherBundleName"; + std::string launcherModuleName = "launcherModuleName"; + std::string launcherAbilityName = "launcherAbilityName"; + AppExecFwk::AbilityInfo launcherAbility; + launcherAbility.bundleName = launcherBundleName; + launcherAbility.moduleName = launcherModuleName; + launcherAbility.name = launcherAbilityName; + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, QueryLauncherAbilityInfos(_, _, _)) + .WillOnce([launcherAbility](const AAFwk::Want &want, int32_t userId, + std::vector& abilityInfos) { + abilityInfos.emplace_back(launcherAbility); + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::vector bundleInfos; + AppExecFwk::BundleInfo bundleInfo; + bundleInfo.name = launcherBundleName; + AppExecFwk::HapModuleInfo hapModuleInfo; + AppExecFwk::AbilityInfo abilityInfo; + hapModuleInfo.abilityInfos.emplace_back(abilityInfo); + hapModuleInfo.abilityInfos.emplace_back(launcherAbility); + bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); + bundleInfos.emplace_back(bundleInfo); + std::vector scbAbilityInfos; + int32_t userId = 0; + ssm_->GetCollaboratorAbilityInfos(bundleInfos, scbAbilityInfos, userId); + EXPECT_EQ(scbAbilityInfos.size(), 1); + EXPECT_EQ(scbAbilityInfos[0].abilityInfo_.moduleName, launcherModuleName); + EXPECT_EQ(scbAbilityInfos[0].abilityInfo_.name, launcherAbilityName); +} + +/** + * @tc.name: GetCollaboratorAbilityInfos03 + * @tc.desc: GetCollaboratorAbilityInfos03 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, GetCollaboratorAbilityInfos03, TestSize.Level1) +{ + ASSERT_NE(nullptr, ssm_); + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, QueryLauncherAbilityInfos(_, _, _)) + .WillOnce([](const AAFwk::Want &want, int32_t userId, + std::vector &abilityInfos) { + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::vector bundleInfos; + AppExecFwk::BundleInfo bundleInfo; + AppExecFwk::HapModuleInfo hapModuleInfo; + std::string abilityName1 = "testAbilityName1"; + AppExecFwk::AbilityInfo abilityInfo1; + abilityInfo1.name = abilityName1; + hapModuleInfo.abilityInfos.emplace_back(abilityInfo1); + std::string abilityName2 = "testAbilityName2"; + AppExecFwk::AbilityInfo abilityInfo2; + abilityInfo2.name = abilityName2; + hapModuleInfo.abilityInfos.emplace_back(abilityInfo2); + bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); + bundleInfos.emplace_back(bundleInfo); + std::vector scbAbilityInfos; + int32_t userId = 0; + ssm_->GetCollaboratorAbilityInfos(bundleInfos, scbAbilityInfos, userId); + EXPECT_EQ(scbAbilityInfos.size(), 1); + EXPECT_EQ(scbAbilityInfos[0].abilityInfo_.name, abilityName1); +} + /** * @tc.name: GetOrientationFromResourceManager * @tc.desc: GetOrientationFromResourceManager @@ -1135,8 +1220,8 @@ HWTEST_F(SceneSessionManagerTest6, FillWindowInfo05, TestSize.Level1) sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); sceneSession->GetSessionProperty()->SetIsSystemKeyboard(true); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); WSRect area = { 0, 1690, 2472, 1648 }; sceneSession->SetSessionGlobalRect(area); auto ret = ssm_->FillWindowInfo(infos, sceneSession); @@ -1226,7 +1311,7 @@ HWTEST_F(SceneSessionManagerTest6, JudgeNeedNotifyPrivacyInfo, TestSize.Level1) std::unordered_set privacyBundles1; privacyBundles1.insert("bundle2"); ASSERT_NE(nullptr, ssm_); - ssm_->privacyBundleMap_.insert({displayId, privacyBundles1}); + ssm_->privacyBundleMap_.insert({ displayId, privacyBundles1 }); ret = ssm_->JudgeNeedNotifyPrivacyInfo(displayId, privacyBundles); EXPECT_EQ(true, ret); privacyBundles.insert("bundle2"); @@ -1444,7 +1529,7 @@ HWTEST_F(SceneSessionManagerTest6, ProcessDialogRequestFocusImmdediately, TestSi */ HWTEST_F(SceneSessionManagerTest6, IsValidSessionIds, TestSize.Level1) { - std::vector sessionIds = {1, 2, 3, 4}; + std::vector sessionIds = { 1, 2, 3, 4 }; std::vector results; results.clear(); SessionInfo sessionInfo; @@ -1580,7 +1665,7 @@ HWTEST_F(SceneSessionManagerTest6, RequestInputMethodCloseKeyboard, TestSize.Lev SessionInfo info; sptr specificCallback = nullptr; sptr sceneSession = sptr::MakeSptr(info, specificCallback); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); int32_t persistentId = 10; ssm_->RequestInputMethodCloseKeyboard(persistentId); @@ -1613,12 +1698,12 @@ HWTEST_F(SceneSessionManagerTest6, RequestSceneSession, TestSize.Level0) sptr sceneSession = sptr::MakeSptr(info1, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr getSceneSession1 = ssm_->RequestSceneSession(info1, windowSessionProperty); ASSERT_EQ(info1.bundleName_, getSceneSession1->GetSessionInfo().bundleName_); sptr sceneSession2 = sptr::MakeSptr(info2, nullptr); - ssm_->sceneSessionMap_.insert({2, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 2, sceneSession2 }); sptr getSceneSession2 = ssm_->RequestSceneSession(info2, windowSessionProperty); ASSERT_NE(info2.bundleName_, getSceneSession2->GetSessionInfo().bundleName_); } @@ -1649,7 +1734,7 @@ HWTEST_F(SceneSessionManagerTest6, GetSceneSessionBySessionInfo, TestSize.Level1 info2.abilityInfo->launchMode = AppExecFwk::LaunchMode::SINGLETON; sptr sceneSession = sptr::MakeSptr(info2, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr getSceneSession = ssm_->GetSceneSessionBySessionInfo(info2); ASSERT_EQ(sceneSession, getSceneSession); @@ -1664,7 +1749,7 @@ HWTEST_F(SceneSessionManagerTest6, GetSceneSessionBySessionInfo, TestSize.Level1 info3.abilityInfo->launchMode = AppExecFwk::LaunchMode::SPECIFIED; sptr sceneSession2 = sptr::MakeSptr(info3, nullptr); ASSERT_NE(sceneSession2, nullptr); - ssm_->sceneSessionMap_.insert({2, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 2, sceneSession2 }); info3.persistentId_ = 1000; ASSERT_EQ(ssm_->GetSceneSessionBySessionInfo(info3), nullptr); @@ -1691,8 +1776,8 @@ HWTEST_F(SceneSessionManagerTest6, RequestSceneSessionDestruction, TestSize.Leve bool needRemoveSession = true; bool isSaveSnapshot = true; bool isForceClean = true; - ASSERT_EQ(WSError::WS_OK, ssm_->RequestSceneSessionDestruction( - sceneSession, needRemoveSession, isSaveSnapshot, isForceClean)); + ASSERT_EQ(WSError::WS_OK, + ssm_->RequestSceneSessionDestruction(sceneSession, needRemoveSession, isSaveSnapshot, isForceClean)); SessionInfo info; sptr specificCallback = nullptr; @@ -1700,8 +1785,8 @@ HWTEST_F(SceneSessionManagerTest6, RequestSceneSessionDestruction, TestSize.Leve sptr property = sptr::MakeSptr(); ASSERT_NE(property, nullptr); property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - ASSERT_EQ(WSError::WS_OK, ssm_->RequestSceneSessionDestruction( - sceneSession, needRemoveSession, isSaveSnapshot, isForceClean)); + ASSERT_EQ(WSError::WS_OK, + ssm_->RequestSceneSessionDestruction(sceneSession, needRemoveSession, isSaveSnapshot, isForceClean)); } /** @@ -1716,7 +1801,7 @@ HWTEST_F(SceneSessionManagerTest6, NotifySessionAINavigationBarChange, TestSize. SessionInfo info; sptr specificCallback = nullptr; sptr sceneSession = sptr::MakeSptr(info, specificCallback); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ssm_->NotifySessionAINavigationBarChange(persistentId); persistentId = 0; @@ -1749,9 +1834,9 @@ HWTEST_F(SceneSessionManagerTest6, GetProcessSurfaceNodeIdByPersistentId, TestSi persistentIds.push_back(sceneSession1->GetPersistentId()); persistentIds.push_back(sceneSession2->GetPersistentId()); persistentIds.push_back(sceneSession3->GetPersistentId()); - ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); - ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); - ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3}); + ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); + ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); + ssm_->sceneSessionMap_.insert({ sceneSession3->GetPersistentId(), sceneSession3 }); ASSERT_EQ(WMError::WM_OK, ssm_->GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds)); ASSERT_EQ(0, surfaceNodeIds.size()); @@ -1859,10 +1944,10 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession02, TestSize.Level1) sessionInfo.abilityName_ = "CheckIfReuseSession02"; sessionInfo.want = std::make_shared(); - SceneSessionManager::SessionInfoList list = { - .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", - .abilityName_ = "CheckIfReuseSession02", .moduleName_ = "SceneSessionManager" - }; + SceneSessionManager::SessionInfoList list = { .uid_ = 123, + .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession02", + .moduleName_ = "SceneSessionManager" }; std::shared_ptr abilityInfo = std::make_shared(); ASSERT_NE(abilityInfo, nullptr); @@ -1889,10 +1974,10 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession03, TestSize.Level1) sessionInfo.abilityName_ = "CheckIfReuseSession03"; sessionInfo.want = std::make_shared(); - SceneSessionManager::SessionInfoList list = { - .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", - .abilityName_ = "CheckIfReuseSession03", .moduleName_ = "SceneSessionManager" - }; + SceneSessionManager::SessionInfoList list = { .uid_ = 123, + .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession03", + .moduleName_ = "SceneSessionManager" }; std::shared_ptr abilityInfo = std::make_shared(); ASSERT_NE(abilityInfo, nullptr); @@ -1920,18 +2005,17 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession04, TestSize.Level1) sessionInfo.abilityName_ = "CheckIfReuseSession04"; sessionInfo.want = std::make_shared(); - SceneSessionManager::SessionInfoList list = { - .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", - .abilityName_ = "CheckIfReuseSession04", .moduleName_ = "SceneSessionManager" - }; + SceneSessionManager::SessionInfoList list = { .uid_ = 123, + .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession04", + .moduleName_ = "SceneSessionManager" }; std::shared_ptr abilityInfo = std::make_shared(); ASSERT_NE(abilityInfo, nullptr); abilityInfo->applicationInfo.codePath = std::to_string(CollaboratorType::RESERVE_TYPE); ssm_->abilityInfoMap_[list] = abilityInfo; - sptr collaborator = - iface_cast(nullptr); + sptr collaborator = iface_cast(nullptr); ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); auto ret3 = ssm_->CheckIfReuseSession(sessionInfo); ASSERT_EQ(ret3, BrokerStates::BROKER_UNKOWN); @@ -1956,18 +2040,17 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession05, TestSize.Level1) sessionInfo.abilityName_ = "CheckIfReuseSession05"; sessionInfo.want = std::make_shared(); - SceneSessionManager::SessionInfoList list = { - .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", - .abilityName_ = "CheckIfReuseSession05", .moduleName_ = "SceneSessionManager" - }; + SceneSessionManager::SessionInfoList list = { .uid_ = 123, + .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession05", + .moduleName_ = "SceneSessionManager" }; std::shared_ptr abilityInfo = std::make_shared(); ASSERT_NE(abilityInfo, nullptr); abilityInfo->applicationInfo.codePath = std::to_string(CollaboratorType::OTHERS_TYPE); ssm_->abilityInfoMap_[list] = abilityInfo; - sptr collaborator = - iface_cast(nullptr); + sptr collaborator = iface_cast(nullptr); ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); auto ret4 = ssm_->CheckIfReuseSession(sessionInfo); ASSERT_EQ(ret4, BrokerStates::BROKER_UNKOWN); @@ -2050,6 +2133,6 @@ HWTEST_F(SceneSessionManagerTest6, WindowDestroyNotifyVisibility, TestSize.Level ssm_->WindowDestroyNotifyVisibility(sceneSession); ASSERT_FALSE(sceneSession->GetRSVisible()); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test7.cpp b/window_scene/test/unittest/scene_session_manager_test7.cpp index 85cb3f74e4..3000b4a168 100644 --- a/window_scene/test/unittest/scene_session_manager_test7.cpp +++ b/window_scene/test/unittest/scene_session_manager_test7.cpp @@ -30,7 +30,7 @@ namespace Rosen { namespace { const std::string EMPTY_DEVICE_ID = ""; using ConfigItem = WindowSceneConfig::ConfigItem; -} +} // namespace class SceneSessionManagerTest7 : public testing::Test { public: static void SetUpTestCase(); @@ -41,6 +41,7 @@ public: static bool gestureNavigationEnabled_; static ProcessGestureNavigationEnabledChangeFunc callbackFunc_; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; @@ -48,18 +49,12 @@ private: sptr SceneSessionManagerTest7::ssm_ = nullptr; bool SceneSessionManagerTest7::gestureNavigationEnabled_ = true; -ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest7::callbackFunc_ = [](bool enable, - const std::string& bundleName, GestureBackType type) { - gestureNavigationEnabled_ = enable; -}; +ProcessGestureNavigationEnabledChangeFunc SceneSessionManagerTest7::callbackFunc_ = + [](bool enable, const std::string& bundleName, GestureBackType type) { gestureNavigationEnabled_ = enable; }; -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} void SceneSessionManagerTest7::SetUpTestCase() { @@ -328,7 +323,7 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent, TestSize.Level1) ssm_->rootSceneProcessBackEventFunc_ = nullptr; ret = ssm_->ProcessBackEvent(); EXPECT_EQ(ret, WSError::WS_OK); - RootSceneProcessBackEventFunc func = [](){}; + RootSceneProcessBackEventFunc func = []() {}; ssm_->rootSceneProcessBackEventFunc_ = func; ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_); ret = ssm_->ProcessBackEvent(); @@ -370,8 +365,7 @@ HWTEST_F(SceneSessionManagerTest7, DestroySpecificSession, TestSize.Level1) * @tc.desc: DestroyAndDisconnectSpecificSessionWithDetachCallback * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionWithDetachCallback, - TestSize.Level0) +HWTEST_F(SceneSessionManagerTest7, DestroyAndDisconnectSpecificSessionWithDetachCallback, TestSize.Level0) { int32_t persistentId = 1; sptr callback = sptr::MakeSptr(); @@ -983,7 +977,7 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent03, TestSize.Level1) focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; - RootSceneProcessBackEventFunc func = [](){}; + RootSceneProcessBackEventFunc func = []() {}; ssm_->rootSceneProcessBackEventFunc_ = func; ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_); auto ret = ssm_->ProcessBackEvent(); @@ -1031,7 +1025,7 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent05, TestSize.Level1) focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; - RootSceneProcessBackEventFunc func = [](){}; + RootSceneProcessBackEventFunc func = []() {}; ssm_->rootSceneProcessBackEventFunc_ = func; ASSERT_NE(nullptr, ssm_->rootSceneProcessBackEventFunc_); auto ret = ssm_->ProcessBackEvent(); @@ -1251,6 +1245,6 @@ HWTEST_F(SceneSessionManagerTest7, UpdateNormalSessionAvoidArea02, TestSize.Leve ssm_->avoidAreaListenerSessionSet_.insert(persistentId); ssm_->UpdateNormalSessionAvoidArea(persistentId, sceneSession, needUpdate); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test8.cpp b/window_scene/test/unittest/scene_session_manager_test8.cpp index f5b27f7603..6c9bb1c5f4 100644 --- a/window_scene/test/unittest/scene_session_manager_test8.cpp +++ b/window_scene/test/unittest/scene_session_manager_test8.cpp @@ -35,18 +35,15 @@ public: static void TearDownTestCase(); void SetUp(); void TearDown(); + private: sptr ssm_; static constexpr uint32_t WAIT_SYNC_IN_NS = 500000; }; -void SceneSessionManagerTest8::SetUpTestCase() -{ -} +void SceneSessionManagerTest8::SetUpTestCase() {} -void SceneSessionManagerTest8::TearDownTestCase() -{ -} +void SceneSessionManagerTest8::TearDownTestCase() {} void SceneSessionManagerTest8::SetUp() { @@ -159,7 +156,7 @@ HWTEST_F(SceneSessionManagerTest8, PostProcessFocus01, TestSize.Level1) sceneSession->state_ = SessionState::STATE_FOREGROUND; sceneSession->isVisible_ = true; - PostProcessFocusState state = {true, true, true, FocusChangeReason::FOREGROUND}; + PostProcessFocusState state = { true, true, true, FocusChangeReason::FOREGROUND }; sceneSession->SetPostProcessFocusState(state); sceneSession->SetFocusableOnShow(false); ssm_->sceneSessionMap_.emplace(1, sceneSession); @@ -184,7 +181,7 @@ HWTEST_F(SceneSessionManagerTest8, PostProcessFocus03, TestSize.Level1) sceneSession->persistentId_ = 1; sceneSession->SetFocusedOnShow(false); - PostProcessFocusState state = {true, true, true, FocusChangeReason::FOREGROUND}; + PostProcessFocusState state = { true, true, true, FocusChangeReason::FOREGROUND }; sceneSession->SetPostProcessFocusState(state); ssm_->sceneSessionMap_.emplace(1, sceneSession); ssm_->PostProcessFocus(); @@ -192,7 +189,7 @@ HWTEST_F(SceneSessionManagerTest8, PostProcessFocus03, TestSize.Level1) sceneSession->state_ = SessionState::STATE_FOREGROUND; sceneSession->isVisible_ = true; - state = {true, true, true, FocusChangeReason::FOREGROUND}; + state = { true, true, true, FocusChangeReason::FOREGROUND }; sceneSession->SetPostProcessFocusState(state); ssm_->sceneSessionMap_.emplace(1, sceneSession); ssm_->PostProcessFocus(); @@ -330,7 +327,7 @@ HWTEST_F(SceneSessionManagerTest8, FilterSceneSessionCovered, TestSize.Level1) */ HWTEST_F(SceneSessionManagerTest8, SubtractIntersectArea, TestSize.Level1) { - SkIRect rect {.fLeft = 0, .fTop = 0, .fRight = 2880, .fBottom = 1920}; + SkIRect rect{ .fLeft = 0, .fTop = 0, .fRight = 2880, .fBottom = 1920 }; auto unaccountedSpace = std::make_shared(rect); EXPECT_NE(unaccountedSpace, nullptr); @@ -340,7 +337,7 @@ HWTEST_F(SceneSessionManagerTest8, SubtractIntersectArea, TestSize.Level1) SessionInfo sessionInfo; sceneSession = sptr::MakeSptr(sessionInfo, nullptr); EXPECT_NE(sceneSession, nullptr); - WSRect wsRect {.posX_ = 0, .posY_ = 0, .width_ = 100, .height_ = 100}; + WSRect wsRect{ .posX_ = 0, .posY_ = 0, .width_ = 100, .height_ = 100 }; sceneSession->winRect_ = wsRect; EXPECT_EQ(ssm_->SubtractIntersectArea(unaccountedSpace, sceneSession), true); } @@ -390,8 +387,8 @@ HWTEST_F(SceneSessionManagerTest8, UpdateSubWindowVisibility, TestSize.Level1) sceneSession2->SetParentSession(sceneSession2); EXPECT_EQ(1998, sceneSession2->GetParentSession()->GetWindowId()); ssm_->sceneSessionMap_.emplace(0, sceneSession2); - ssm_->UpdateSubWindowVisibility(sceneSession, - visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData); + ssm_->UpdateSubWindowVisibility( + sceneSession, visibleState, visibilityChangeInfo, windowVisibilityInfos, visibilityInfo, currVisibleData); } /** @@ -413,13 +410,13 @@ HWTEST_F(SceneSessionManagerTest8, RegisterSessionChangeByActionNotifyManagerFun sptr property = nullptr; sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); property = sptr::MakeSptr(); EXPECT_NE(nullptr, property); sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); } /** @@ -442,31 +439,27 @@ HWTEST_F(SceneSessionManagerTest8, RegisterSessionChangeByActionNotifyManagerFun EXPECT_NE(nullptr, property); sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); - sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS); + sceneSession->NotifySessionChangeByActionNotifyManager( + property, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS); sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS); + WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS); sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE); + WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE); - sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_FLAGS); + sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_FLAGS); - sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_MODE); + sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_MODE); - sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); + sceneSession->NotifySessionChangeByActionNotifyManager( + property, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); - sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK); + sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK); - sceneSession->NotifySessionChangeByActionNotifyManager(property, - WSPropertyChangeAction::ACTION_UPDATE_TOPMOST); + sceneSession->NotifySessionChangeByActionNotifyManager(property, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST); } /** @@ -613,14 +606,10 @@ HWTEST_F(SceneSessionManagerTest8, IsLastFrameLayoutFinished, TestSize.Level1) { ssm_->closeTargetFloatWindowFunc_ = nullptr; std::string bundleName = "SetCloseTargetFloatWindowFunc"; - ProcessCloseTargetFloatWindowFunc func = [](const std::string& bundleName1) { - return ; - }; + ProcessCloseTargetFloatWindowFunc func = [](const std::string& bundleName1) { return; }; ssm_->SetCloseTargetFloatWindowFunc(func); - IsRootSceneLastFrameLayoutFinishedFunc func1 = []() { - return true; - }; + IsRootSceneLastFrameLayoutFinishedFunc func1 = []() { return true; }; ssm_->isRootSceneLastFrameLayoutFinishedFunc_ = func1; ASSERT_NE(ssm_->isRootSceneLastFrameLayoutFinishedFunc_, nullptr); bool isLayoutFinished = false; @@ -712,49 +701,49 @@ HWTEST_F(SceneSessionManagerTest8, GetHostWindowRect, TestSize.Level1) sceneSession->sessionInfo_.screenId_ = 0; EXPECT_EQ(sceneSession->GetScreenId(), 0); ssm_->sceneSessionMap_.insert(std::make_pair(hostWindowId, sceneSession)); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::EXPANDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::EXPANDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); auto ret = ssm_->GetHostWindowRect(hostWindowId, rect); EXPECT_EQ(WSError::WS_OK, ret); EXPECT_EQ(rect.posY_, 0); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::KEYBOARD, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - sceneSession->winRect_ = {0, 100, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::KEYBOARD, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + sceneSession->winRect_ = { 0, 100, 0, 0 }; ret = ssm_->GetHostWindowRect(hostWindowId, rect); EXPECT_EQ(WSError::WS_OK, ret); EXPECT_EQ(rect.posY_, 100); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); - sceneSession->winRect_ = {0, 1000, 100, 100}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); + sceneSession->winRect_ = { 0, 1000, 100, 100 }; ret = ssm_->GetHostWindowRect(hostWindowId, rect); EXPECT_EQ(WSError::WS_OK, ret); EXPECT_EQ(rect.posY_, 1000); - sceneSession->winRect_ = {0, 2000, 100, 100}; + sceneSession->winRect_ = { 0, 2000, 100, 100 }; ret = ssm_->GetHostWindowRect(hostWindowId, rect); - WSRect hostRect = {0, 2000, 100, 100}; + WSRect hostRect = { 0, 2000, 100, 100 }; sceneSession->TransformGlobalRectToRelativeRect(hostRect); EXPECT_EQ(WSError::WS_OK, ret); EXPECT_EQ(rect.posY_, hostRect.posY_); sceneSession->GetSessionProperty()->SetIsSystemKeyboard(false); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::UNKNOWN, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - sceneSession->winRect_ = {0, 0, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::UNKNOWN, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + sceneSession->winRect_ = { 0, 0, 0, 0 }; ret = ssm_->GetHostWindowRect(hostWindowId, rect); EXPECT_EQ(WSError::WS_OK, ret); EXPECT_EQ(rect.posY_, 0); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - sceneSession->winRect_ = {0, 100, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + sceneSession->winRect_ = { 0, 100, 0, 0 }; ret = ssm_->GetHostWindowRect(hostWindowId, rect); EXPECT_EQ(WSError::WS_OK, ret); EXPECT_EQ(rect.posY_, 100); sceneSession->GetSessionProperty()->SetIsSystemKeyboard(true); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); - sceneSession->winRect_ = {0, 1000, 100, 100}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); + sceneSession->winRect_ = { 0, 1000, 100, 100 }; ret = ssm_->GetHostWindowRect(hostWindowId, rect); EXPECT_EQ(WSError::WS_OK, ret); EXPECT_EQ(rect.posY_, 1000); @@ -953,7 +942,7 @@ HWTEST_F(SceneSessionManagerTest8, UnregisterSpecificSessionCreateListener, Test ssm_->HandleHideNonSystemFloatingWindows(property, sceneSession); NotifyCreateKeyboardSessionFunc func = [](const sptr& keyboardSession, - const sptr& panelSession) {}; + const sptr& panelSession) {}; ssm_->SetCreateKeyboardSessionListener(func); ProcessOutsideDownEventFunc func1 = [](int32_t x, int32_t y) {}; @@ -1004,6 +993,6 @@ HWTEST_F(SceneSessionManagerTest8, GetIsLayoutFullScreen, TestSize.Level1) ret = ssm_->GetIsLayoutFullScreen(isLayoutFullScreen); EXPECT_EQ(WSError::WS_OK, ret); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 8f7db806da..d83839bdf8 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -37,15 +37,14 @@ public: void TearDown() override; static sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; sptr SceneSessionManagerTest9::ssm_ = nullptr; -void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) -{ -} +void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) {} bool getStateFalse(const ManagerState key) { @@ -62,13 +61,9 @@ bool TraverseFuncTest(const sptr& session) return true; } -void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) -{ -} +void WindowChangedFuncTest(int32_t persistentId, WindowUpdateType type) {} -void ProcessStatusBarEnabledChangeFuncTest(bool enable) -{ -} +void ProcessStatusBarEnabledChangeFuncTest(bool enable) {} void SceneSessionManagerTest9::SetUpTestCase() { @@ -80,9 +75,7 @@ void SceneSessionManagerTest9::TearDownTestCase() ssm_ = nullptr; } -void SceneSessionManagerTest9::SetUp() -{ -} +void SceneSessionManagerTest9::SetUp() {} void SceneSessionManagerTest9::TearDown() { @@ -972,7 +965,8 @@ HWTEST_F(SceneSessionManagerTest9, RecoverAndReconnectSceneSession02, TestSize.L * @tc.desc: RefreshPcZorder * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, TestSize.Level0) { +HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, TestSize.Level0) +{ std::vector persistentIds; SessionInfo info1; info1.abilityName_ = "RefreshPcZorder1"; @@ -980,21 +974,21 @@ HWTEST_F(SceneSessionManagerTest9, RefreshPcZorder, TestSize.Level0) { sptr session1 = sptr::MakeSptr(info1, nullptr); ASSERT_NE(session1, nullptr); persistentIds.push_back(session1->GetPersistentId()); - ssm_->sceneSessionMap_.insert({session1->GetPersistentId(), session1}); + ssm_->sceneSessionMap_.insert({ session1->GetPersistentId(), session1 }); SessionInfo info2; info2.abilityName_ = "RefreshPcZorder2"; info2.bundleName_ = "RefreshPcZorder2"; sptr session2 = sptr::MakeSptr(info2, nullptr); ASSERT_NE(session2, nullptr); persistentIds.push_back(session2->GetPersistentId()); - ssm_->sceneSessionMap_.insert({session2->GetPersistentId(), session2}); + ssm_->sceneSessionMap_.insert({ session2->GetPersistentId(), session2 }); SessionInfo info3; info3.abilityName_ = "RefreshPcZorder3"; info3.bundleName_ = "RefreshPcZorder3"; sptr session3 = sptr::MakeSptr(info3, nullptr); ASSERT_NE(session3, nullptr); session3->SetZOrder(404); - ssm_->sceneSessionMap_.insert({session3->GetPersistentId(), session3}); + ssm_->sceneSessionMap_.insert({ session3->GetPersistentId(), session3 }); persistentIds.push_back(999); uint32_t startZOrder = 100; std::vector newPersistentIds = persistentIds; @@ -1092,8 +1086,8 @@ HWTEST_F(SceneSessionManagerTest9, ShiftFocus, TestSize.Level1) ASSERT_NE(nextSession, nullptr); focusedSession->persistentId_ = 1; nextSession->persistentId_ = 4; - ssm_->sceneSessionMap_.insert({1, focusedSession}); - ssm_->sceneSessionMap_.insert({4, nextSession}); + ssm_->sceneSessionMap_.insert({ 1, focusedSession }); + ssm_->sceneSessionMap_.insert({ 4, nextSession }); auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); focusGroup->SetFocusedSessionId(1); WSError ret = ssm_->ShiftFocus(DEFAULT_DISPLAY_ID, nextSession, false, FocusChangeReason::DEFAULT); @@ -1264,7 +1258,7 @@ HWTEST_F(SceneSessionManagerTest9, UpdateSpecificSessionClientDisplayId01, TestS sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); sceneSession->persistentId_ = 1; - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); property->SetParentPersistentId(1); @@ -1294,7 +1288,7 @@ HWTEST_F(SceneSessionManagerTest9, UpdateSpecificSessionClientDisplayId02, TestS ASSERT_NE(nullptr, sceneSession); sceneSession->persistentId_ = 1; sceneSession->SetClientDisplayId(999); - ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession }); sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); property->SetParentPersistentId(1); @@ -1346,12 +1340,12 @@ HWTEST_F(SceneSessionManagerTest9, SetSkipEventOnCastPlusInner01, TestSize.Level sessionInfo.abilityName_ = "SetSkipEventOnCastPlusInner"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); - ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); ssm_->SetSkipEventOnCastPlusInner(sceneSession->GetPersistentId(), true); EXPECT_EQ(true, sceneSession->GetSessionProperty()->GetSkipEventOnCastPlus()); ssm_->SetSkipEventOnCastPlusInner(sceneSession->GetPersistentId(), false); EXPECT_EQ(false, sceneSession->GetSessionProperty()->GetSkipEventOnCastPlus()); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 448dc2d485..1805e6924e 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -35,12 +35,15 @@ namespace OHOS { namespace Rosen { namespace { std::string logMsg; -void SceneSessionLogCallback( - const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *msg) +void SceneSessionLogCallback(const LogType type, + const LogLevel level, + const unsigned int domain, + const char* tag, + const char* msg) { logMsg = msg; } -} +} // namespace constexpr int WAIT_ASYNC_US = 1000000; class SceneSessionTest : public testing::Test { public: @@ -50,21 +53,13 @@ public: void TearDown() override; }; -void SceneSessionTest::SetUpTestCase() -{ -} +void SceneSessionTest::SetUpTestCase() {} -void SceneSessionTest::TearDownTestCase() -{ -} +void SceneSessionTest::TearDownTestCase() {} -void SceneSessionTest::SetUp() -{ -} +void SceneSessionTest::SetUp() {} -void SceneSessionTest::TearDown() -{ -} +void SceneSessionTest::TearDown() {} namespace { @@ -162,13 +157,12 @@ HWTEST_F(SceneSessionTest, SetAndGetPipTemplateInfo, TestSize.Level1) PiPTemplateInfo pipTemplateInfo; pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); sceneSession->SetPiPTemplateInfo(pipTemplateInfo); - ASSERT_EQ(sceneSession->GetPiPTemplateInfo().pipTemplateType, - static_cast(PiPTemplateType::VIDEO_CALL)); + ASSERT_EQ(sceneSession->GetPiPTemplateInfo().pipTemplateType, static_cast(PiPTemplateType::VIDEO_CALL)); pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_MEETING); sceneSession->SetPiPTemplateInfo(pipTemplateInfo); ASSERT_EQ(sceneSession->GetPiPTemplateInfo().pipTemplateType, - static_cast(PiPTemplateType::VIDEO_MEETING)); + static_cast(PiPTemplateType::VIDEO_MEETING)); } /** @@ -228,13 +222,13 @@ HWTEST_F(SceneSessionTest, GetTouchHotAreas01, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - Rect windowRect = {1, 1, 1, 1}; + Rect windowRect = { 1, 1, 1, 1 }; std::vector rects; uint32_t hotAreasNum = 10; uint32_t hotAreaWidth = windowRect.width_ / hotAreasNum; uint32_t hotAreaHeight = windowRect.height_ / hotAreasNum; for (uint32_t i = 0; i < hotAreasNum; ++i) { - rects.emplace_back(Rect{hotAreaWidth * i, hotAreaHeight * i, hotAreaWidth, hotAreaHeight}); + rects.emplace_back(Rect{ hotAreaWidth * i, hotAreaHeight * i, hotAreaWidth, hotAreaHeight }); } sptr property = sptr::MakeSptr(); @@ -695,9 +689,9 @@ HWTEST_F(SceneSessionTest, NotifySessionRectChange, TestSize.Level1) sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1); sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11); sceneSession->sessionRectChangeFunc_ = [](const WSRect& rect, - SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) { - return; - }; + SizeChangeReason reason, + DisplayId displayId, + const RectAnimationConfig& rectAnimationConfig) { return; }; sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1); sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11); } @@ -725,7 +719,7 @@ HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); - WSRect overlapRect = {0, 0, 0, 0}; + WSRect overlapRect = { 0, 0, 0, 0 }; AvoidArea avoidArea; sceneSession->GetKeyboardAvoidArea(overlapRect, avoidArea); ASSERT_EQ(true, overlapRect.IsEmpty()); @@ -879,21 +873,20 @@ HWTEST_F(SceneSessionTest, GetAvoidAreaByType, TestSize.Level1) sptr specificCallback_ = sptr::MakeSptr(); EXPECT_NE(specificCallback_, nullptr); - specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [](WindowType type, - uint64_t displayId)-> std::vector> - { + specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = + [](WindowType type, uint64_t displayId) -> std::vector> { SessionInfo info_; info_.abilityName_ = "Background01"; info_.bundleName_ = "IsFloatingWindowAppType"; std::vector> backgroundSession; - sptr session2= sptr::MakeSptr(info_, nullptr); + sptr session2 = sptr::MakeSptr(info_, nullptr); backgroundSession.push_back(session2); return backgroundSession; }; sptr sceneSession; sceneSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); - WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240 + WSRect rect = { 0, 0, 320, 240 }; // width: 320, height: 240 sceneSession->SetSessionRect(rect); sptr property = sptr::MakeSptr(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -947,11 +940,10 @@ HWTEST_F(SceneSessionTest, TransferPointerEventDecorDialog, TestSize.Level1) sptr session_; sptr specificCallback_ = sptr::MakeSptr(); - sptr sceneSession = - sptr::MakeSptr(info, specificCallback_); + sptr sceneSession = sptr::MakeSptr(info, specificCallback_); sceneSession->moveDragController_ = sptr::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT); sceneSession->SetSessionState(SessionState::STATE_ACTIVE); - std::shared_ptr pointerEvent_ = MMI::PointerEvent::Create(); + std::shared_ptr pointerEvent_ = MMI::PointerEvent::Create(); sptr property = sptr::MakeSptr(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL); @@ -1315,25 +1307,25 @@ HWTEST_F(SceneSessionTest, UpdateSessionRectPosYFromClient01, TestSize.Level1) ASSERT_NE(sceneSession, nullptr); sceneSession->sessionInfo_.screenId_ = 0; EXPECT_EQ(sceneSession->GetScreenId(), 0); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::EXPANDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - WSRect rect = {0, 0, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::EXPANDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + WSRect rect = { 0, 0, 0, 0 }; sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect); EXPECT_EQ(rect.posY_, 0); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::KEYBOARD, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - rect = {0, 100, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::KEYBOARD, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + rect = { 0, 100, 0, 0 }; sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect); EXPECT_EQ(rect.posY_, 100); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); sceneSession->clientDisplayId_ = 0; - rect = {0, 100, 100, 100}; + rect = { 0, 100, 100, 100 }; sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect); EXPECT_EQ(rect.posY_, 100); sceneSession->clientDisplayId_ = 999; - rect = {0, 100, 100, 100}; + rect = { 0, 100, 100, 100 }; auto rect2 = rect; sceneSession->UpdateSessionRectPosYFromClient(SizeChangeReason::UNDEFINED, displayId, rect); EXPECT_EQ(rect.posY_, rect2.posY_); @@ -1362,7 +1354,7 @@ HWTEST_F(SceneSessionTest, UpdateSessionRect, TestSize.Level1) property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM; sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::MOVE; WSError result = sceneSession->UpdateSessionRect(rect, reason); ASSERT_EQ(result, WSError::WS_OK); @@ -1391,7 +1383,7 @@ HWTEST_F(SceneSessionTest, UpdateSessionRect1, TestSize.Level1) property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM; sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::RESIZE; WSError result = sceneSession->UpdateSessionRect(rect, reason); ASSERT_EQ(result, WSError::WS_OK); @@ -1420,7 +1412,7 @@ HWTEST_F(SceneSessionTest, UpdateSessionRect2, TestSize.Level1) property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM; sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); SizeChangeReason reason = SizeChangeReason::UNDEFINED; WSError result = sceneSession->UpdateSessionRect(rect, reason); ASSERT_EQ(result, WSError::WS_OK); @@ -1445,8 +1437,8 @@ HWTEST_F(SceneSessionTest, UpdateSessionRect3, TestSize.Level1) sceneSession->SetSessionProperty(property); SizeChangeReason reason = SizeChangeReason::UNDEFINED; - WSRect oldRect({1, 1, 1, 1}); - WSRect parentRect({10, 10, 1, 1}); + WSRect oldRect({ 1, 1, 1, 1 }); + WSRect parentRect({ 10, 10, 1, 1 }); sptr parentSession = sptr::MakeSptr(info, nullptr); sceneSession->SetParentSession(parentSession); @@ -1479,8 +1471,7 @@ HWTEST_F(SceneSessionTest, GetStatusBarHeight, TestSize.Level1) ASSERT_EQ(height, 0); SystemBarProperty propertyHide; propertyHide.enable_ = false; - ASSERT_EQ(WSError::WS_OK, sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, - propertyHide)); + ASSERT_EQ(WSError::WS_OK, sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, propertyHide)); ASSERT_EQ(height, 0); sptr specificCallback_ = sptr::MakeSptr(); @@ -1488,11 +1479,10 @@ HWTEST_F(SceneSessionTest, GetStatusBarHeight, TestSize.Level1) sceneSession = sptr::MakeSptr(info, specificCallback_); height = sceneSession->GetStatusBarHeight(); ASSERT_EQ(height, 0); - WSRect rect({0, 0, 0, 1}); + WSRect rect({ 0, 0, 0, 1 }); sceneSession->winRect_ = rect; - specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [&](WindowType type, - uint64_t displayId)->std::vector> - { + specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = + [&](WindowType type, uint64_t displayId) -> std::vector> { std::vector> vec; vec.push_back(sceneSession); return vec; @@ -1502,8 +1492,7 @@ HWTEST_F(SceneSessionTest, GetStatusBarHeight, TestSize.Level1) sceneSession->property_ = property; height = sceneSession->GetStatusBarHeight(); ASSERT_EQ(height, 1); - ASSERT_EQ(WSError::WS_OK, sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, - propertyHide)); + ASSERT_EQ(WSError::WS_OK, sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, propertyHide)); ASSERT_EQ(height, 1); } @@ -1525,11 +1514,10 @@ HWTEST_F(SceneSessionTest, GetDockHeight, TestSize.Level1) EXPECT_NE(specificCallback_, nullptr); sceneSession = sptr::MakeSptr(info, specificCallback_); ASSERT_EQ(sceneSession->GetDockHeight(), 0); - WSRect rect({0, 0, 0, 112}); + WSRect rect({ 0, 0, 0, 112 }); sceneSession->winRect_ = rect; - specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = [&](WindowType type, - uint64_t displayId)->std::vector> - { + specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ = + [&](WindowType type, uint64_t displayId) -> std::vector> { std::vector> vec; vec.push_back(sceneSession); return vec; @@ -1578,12 +1566,12 @@ HWTEST_F(SceneSessionTest, HandleCompatibleModeMoveDrag, TestSize.Level1) EXPECT_NE(sceneSession, nullptr); sceneSession->moveDragController_ = sptr::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT); - WSRect rect = {1, 1, 1, 1}; - WSRect rect2 = {2, 2, 2, 1}; + WSRect rect = { 1, 1, 1, 1 }; + WSRect rect2 = { 2, 2, 2, 1 }; sceneSession->winRect_ = rect2; sceneSession->moveDragController_->moveDragProperty_.originalRect_ = rect; sceneSession->HandleCompatibleModeMoveDrag(rect2, SizeChangeReason::HIDE); - WSRect rect3 = {1, 1, 2, 1}; + WSRect rect3 = { 1, 1, 2, 1 }; ASSERT_NE(rect2, rect3); ASSERT_EQ(rect2.posX_, 2); ASSERT_EQ(rect2.posY_, 2); @@ -1608,23 +1596,23 @@ HWTEST_F(SceneSessionTest, HandleCompatibleModeDrag, TestSize.Level1) EXPECT_NE(sceneSession, nullptr); sceneSession->moveDragController_ = sptr::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT); - WSRect rect = {1, 1, 1, 1}; - WSRect rect2 = {2, 1, 1, 1}; + WSRect rect = { 1, 1, 1, 1 }; + WSRect rect2 = { 2, 1, 1, 1 }; sceneSession->winRect_ = rect2; sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false); ASSERT_EQ(sceneSession->winRect_, rect2); - rect2 = {1, 2, 1, 1}; + rect2 = { 1, 2, 1, 1 }; sceneSession->winRect_ = rect2; sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false); ASSERT_EQ(sceneSession->winRect_, rect2); - rect2 = {1, 1, 2, 1}; + rect2 = { 1, 1, 2, 1 }; sceneSession->winRect_ = rect2; sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false); ASSERT_EQ(sceneSession->winRect_, rect2); - rect2 = {1, 1, 1, 2}; + rect2 = { 1, 1, 1, 2 }; sceneSession->winRect_ = rect2; sceneSession->HandleCompatibleModeDrag(rect, SizeChangeReason::DRAG_MOVE, false); ASSERT_EQ(sceneSession->winRect_, rect2); @@ -1736,9 +1724,7 @@ HWTEST_F(SceneSessionTest, SetIsStatusBarVisibleInner01, TestSize.Level0) EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(true), WSError::WS_OK); EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(false), WSError::WS_ERROR_NULLPTR); - sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) { - return WSError::WS_ERROR_NULLPTR; - }; + sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) { return WSError::WS_ERROR_NULLPTR; }; EXPECT_EQ(sceneSession->SetIsStatusBarVisibleInner(true), WSError::WS_ERROR_NULLPTR); sceneSession->isLastFrameLayoutFinishedFunc_ = [](bool& isLayoutFinished) { @@ -1861,5 +1847,5 @@ HWTEST_F(SceneSessionTest, CloneWindow, TestSize.Level1) EXPECT_TRUE(logMsg.find("cloned") != std::string::npos); } } // namespace -} // Rosen -} // OHOS \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 43eb9b4bdf..6808eeac8c 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -42,21 +42,13 @@ public: void TearDown() override; }; -void SceneSessionTest2::SetUpTestCase() -{ -} +void SceneSessionTest2::SetUpTestCase() {} -void SceneSessionTest2::TearDownTestCase() -{ -} +void SceneSessionTest2::TearDownTestCase() {} -void SceneSessionTest2::SetUp() -{ -} +void SceneSessionTest2::SetUp() {} -void SceneSessionTest2::TearDown() -{ -} +void SceneSessionTest2::TearDown() {} namespace { /** @@ -152,7 +144,7 @@ HWTEST_F(SceneSessionTest2, GetSystemAvoidArea, TestSize.Level1) property->SetWindowFlags(static_cast(WindowFlag::WINDOW_FLAG_NEED_AVOID)); sceneSession->SetSessionProperty(property); - WSRect rect({1, 1, 1, 1}); + WSRect rect({ 1, 1, 1, 1 }); AvoidArea avoidArea; sceneSession->GetSystemAvoidArea(rect, avoidArea); ASSERT_EQ(p, 10); @@ -390,7 +382,7 @@ HWTEST_F(SceneSessionTest2, UpdatePiPRect, TestSize.Level1) property->SetWindowType(WindowType::WINDOW_TYPE_PIP); sceneSession->SetSessionProperty(property); - Rect rect = {0, 0, 800, 600}; + Rect rect = { 0, 0, 800, 600 }; SizeChangeReason reason = SizeChangeReason::PIP_START; WSError result = sceneSession->UpdatePiPRect(rect, reason); ASSERT_EQ(result, WSError::WS_OK); @@ -705,9 +697,7 @@ HWTEST_F(SceneSessionTest2, NotifyTouchOutside, TestSize.Level1) EXPECT_NE(nullptr, sceneSession->sessionStage_); sceneSession->NotifyTouchOutside(); - auto func = [sceneSession]() { - sceneSession->SaveUpdatedIcon(nullptr); - }; + auto func = [sceneSession]() { sceneSession->SaveUpdatedIcon(nullptr); }; sceneSession->onTouchOutside_ = func; EXPECT_NE(nullptr, &func); sceneSession->sessionStage_ = nullptr; @@ -730,9 +720,7 @@ HWTEST_F(SceneSessionTest2, CheckTouchOutsideCallbackRegistered, TestSize.Level1 info.bundleName_ = "CheckTouchOutsideCallbackRegistered"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - auto func = [sceneSession]() { - sceneSession->NotifyWindowVisibility(); - }; + auto func = [sceneSession]() { sceneSession->NotifyWindowVisibility(); }; sceneSession->onTouchOutside_ = func; bool result = sceneSession->CheckTouchOutsideCallbackRegistered(); EXPECT_EQ(true, result); @@ -802,9 +790,7 @@ HWTEST_F(SceneSessionTest2, NotifyForceHideChange, TestSize.Level1) sceneSession->NotifyForceHideChange(true); sptr session = sptr::MakeSptr(info); - auto func = [sceneSession](bool hide) { - sceneSession->SetPrivacyMode(hide); - }; + auto func = [sceneSession](bool hide) { sceneSession->SetPrivacyMode(hide); }; sceneSession->onForceHideChangeFunc_ = func; EXPECT_NE(nullptr, &func); sceneSession->NotifyForceHideChange(true); @@ -826,8 +812,7 @@ HWTEST_F(SceneSessionTest2, SendPointerEventToUI, TestSize.Level1) sceneSession->NotifyOutsideDownEvent(pointerEvent); }; sceneSession->systemSessionPointerEventFunc_ = pointerEventFunc; - std::shared_ptr pointerEvent = - MMI::PointerEvent::Create(); + std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); sceneSession->SendPointerEventToUI(pointerEvent); EXPECT_NE(nullptr, pointerEvent); } @@ -961,7 +946,7 @@ HWTEST_F(SceneSessionTest2, SetLastSafeRect, TestSize.Level1) sptr specificSession = sptr::MakeSptr(); sceneSession = sptr::MakeSptr(info, specificSession); - WSRect rect = {3, 4, 5, 6}; + WSRect rect = { 3, 4, 5, 6 }; sceneSession->SetLastSafeRect(rect); WSRect result = sceneSession->GetLastSafeRect(); EXPECT_EQ(3, result.posX_); @@ -998,7 +983,7 @@ HWTEST_F(SceneSessionTest2, GetSessionTargetRectByDisplayId, TestSize.Level1) return; }; sceneSession->SetWindowDragHotAreaListener(dragHotAreaFunc); - EXPECT_NE(nullptr, sceneSession->moveDragController_); + EXPECT_NE(nullptr, sceneSession->moveDragController_); sceneSession->moveDragController_ = nullptr; rectResult = sceneSession->GetSessionTargetRectByDisplayId(0); sceneSession->SetWindowDragHotAreaListener(dragHotAreaFunc); @@ -1209,8 +1194,7 @@ HWTEST_F(SceneSessionTest2, GetCutoutAvoidArea01, TestSize.Level1) AvoidArea avoidArea; DisplayManager displayManager; Session ssession(info); - auto display = DisplayManager::GetInstance().GetDisplayById( - ssession.GetSessionProperty()->GetDisplayId()); + auto display = DisplayManager::GetInstance().GetDisplayById(ssession.GetSessionProperty()->GetDisplayId()); sceneSession->GetCutoutAvoidArea(rect, avoidArea); } @@ -1247,7 +1231,7 @@ HWTEST_F(SceneSessionTest2, GetAINavigationBarArea, TestSize.Level1) sceneSession->specificCallback_ = sptr::MakeSptr(); ASSERT_NE(nullptr, sceneSession->specificCallback_); sceneSession->specificCallback_->onGetAINavigationBarArea_ = [](uint64_t displayId) { - WSRect rect = {1, 1, 1, 1}; + WSRect rect = { 1, 1, 1, 1 }; return rect; }; sceneSession->GetAINavigationBarArea(rect, avoidArea); @@ -1370,11 +1354,9 @@ HWTEST_F(SceneSessionTest2, OnMoveDragCallback02, TestSize.Level1) Session session(info); sptr abilitySessionInfo = nullptr; ExceptionInfo exceptionInfo; - NotifySessionExceptionFunc func = [](const SessionInfo& info, - const ExceptionInfo& exceInfo, bool startFail) {}; + NotifySessionExceptionFunc func = [](const SessionInfo& info, const ExceptionInfo& exceInfo, bool startFail) {}; session.sessionExceptionFunc_ = func; - NotifySessionExceptionFunc func1 = [](const SessionInfo& info, - const ExceptionInfo& exceInfo, bool startFail) {}; + NotifySessionExceptionFunc func1 = [](const SessionInfo& info, const ExceptionInfo& exceInfo, bool startFail) {}; session.jsSceneSessionExceptionFunc_ = func1; sceneSession->NotifySessionException(abilitySessionInfo, exceptionInfo); @@ -1517,7 +1499,7 @@ HWTEST_F(SceneSessionTest2, GetWindowDragHotAreaType, TestSize.Level1) info.bundleName_ = "HotAreaType"; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - WSRect rect = {0, 0, 10, 10}; + WSRect rect = { 0, 0, 10, 10 }; sceneSession->AddOrUpdateWindowDragHotArea(0, 1, rect); sceneSession->AddOrUpdateWindowDragHotArea(0, 1, rect); auto type = sceneSession->GetWindowDragHotAreaType(0, 1, 2, 2); @@ -1536,9 +1518,7 @@ HWTEST_F(SceneSessionTest2, RegisterSubModalTypeChangeCallback, TestSize.Level1) info.bundleName_ = "RegisterSubModalTypeChangeCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) { - return; - }); + sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) { return; }); EXPECT_NE(sceneSession->onSubModalTypeChange_, nullptr); } @@ -1554,9 +1534,7 @@ HWTEST_F(SceneSessionTest2, NotifySubModalTypeChange, TestSize.Level1) info.bundleName_ = "NotifySubModalTypeChange"; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) { - return; - }); + sceneSession->RegisterSubModalTypeChangeCallback([](SubWindowModalType subWindowModalType) { return; }); EXPECT_NE(sceneSession->onSubModalTypeChange_, nullptr); EXPECT_EQ(sceneSession->NotifySubModalTypeChange(SubWindowModalType::TYPE_WINDOW_MODALITY), WSError::WS_OK); } @@ -1573,9 +1551,7 @@ HWTEST_F(SceneSessionTest2, RegisterMainModalTypeChangeCallback, TestSize.Level1 info.bundleName_ = "RegisterMainModalTypeChangeCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - sceneSession->RegisterMainModalTypeChangeCallback([](bool isModal) { - return; - }); + sceneSession->RegisterMainModalTypeChangeCallback([](bool isModal) { return; }); EXPECT_NE(sceneSession->onMainModalTypeChange_, nullptr); } @@ -1669,11 +1645,9 @@ HWTEST_F(SceneSessionTest2, SetTitleAndDockHoverShowChangeCallback, TestSize.Lev info.abilityName_ = "SetTitleAndDockHoverShowChangeCallback"; info.bundleName_ = "SetTitleAndDockHoverShowChangeCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->SetTitleAndDockHoverShowChangeCallback([](bool isTitleHoverShown, bool isDockHoverShown) { - return; - }); + sceneSession->SetTitleAndDockHoverShowChangeCallback([](bool isTitleHoverShown, bool isDockHoverShown) { return; }); EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index d51f2ab877..8d3c398fc0 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -35,13 +35,12 @@ #include "window_helper.h" #include "wm_common.h" - using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { - constexpr uint32_t SLEEP_TIME_US = 100000; // 100ms +constexpr uint32_t SLEEP_TIME_US = 100000; // 100ms } class SceneSessionTest3 : public testing::Test { public: @@ -51,21 +50,13 @@ public: void TearDown() override; }; -void SceneSessionTest3::SetUpTestCase() -{ -} +void SceneSessionTest3::SetUpTestCase() {} -void SceneSessionTest3::TearDownTestCase() -{ -} +void SceneSessionTest3::TearDownTestCase() {} -void SceneSessionTest3::SetUp() -{ -} +void SceneSessionTest3::SetUp() {} -void SceneSessionTest3::TearDown() -{ -} +void SceneSessionTest3::TearDown() {} namespace { /** @@ -96,8 +87,7 @@ HWTEST_F(SceneSessionTest3, NotifyClientToUpdateRectTask, TestSize.Level1) sceneSession->isKeyboardPanelEnabled_ = true; sceneSession->state_ = SessionState::STATE_FOREGROUND; sceneSession->isScbCoreEnabled_ = false; - ASSERT_EQ(WSError::WS_OK, - sceneSession->NotifyClientToUpdateRectTask("SceneSessionTest3", nullptr)); + ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask("SceneSessionTest3", nullptr)); property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); sceneSession->SetSessionProperty(property); @@ -285,8 +275,7 @@ HWTEST_F(SceneSessionTest3, NotifyClientToUpdateAvoidArea, TestSize.Level1) sceneSession->NotifyClientToUpdateAvoidArea(); EXPECT_EQ(nullptr, sceneSession->specificCallback_); - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); sceneSession = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession); sceneSession->persistentId_ = 6; @@ -299,14 +288,14 @@ HWTEST_F(SceneSessionTest3, NotifyClientToUpdateAvoidArea, TestSize.Level1) }; callback->onUpdateAvoidArea_ = callbackFun; - callback->onUpdateOccupiedAreaIfNeed_ = nullptr; - UpdateOccupiedAreaIfNeedCallback updateCallbackFun = [&sceneSession](int32_t persistentId) { - sceneSession->RemoveToastSession(persistentId); - return; - }; - callback->onUpdateOccupiedAreaIfNeed_ = updateCallbackFun; - sceneSession->NotifyClientToUpdateAvoidArea(); - EXPECT_EQ(6, sceneSession->GetPersistentId()); + // callback->onUpdateOccupiedAreaIfNeed_ = nullptr; + // UpdateOccupiedAreaIfNeedCallback updateCallbackFun = [&sceneSession](int32_t persistentId) { + // sceneSession->RemoveToastSession(persistentId); + // return; + // }; + // callback->onUpdateOccupiedAreaIfNeed_ = updateCallbackFun; + // sceneSession->NotifyClientToUpdateAvoidArea(); + // EXPECT_EQ(6, sceneSession->GetPersistentId()); } /** @@ -434,14 +423,10 @@ HWTEST_F(SceneSessionTest3, RegisterDefaultAnimationFlagChangeCallback, TestSize info.abilityName_ = "RegisterDefaultAnimationFlagChangeCallback"; info.bundleName_ = "RegisterDefaultAnimationFlagChangeCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->RegisterDefaultAnimationFlagChangeCallback([sceneSession](const bool flag) { - return; - }); + sceneSession->RegisterDefaultAnimationFlagChangeCallback([sceneSession](const bool flag) { return; }); ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateWindowAnimationFlag(true)); - sceneSession->RegisterDefaultAnimationFlagChangeCallback([sceneSession](const bool flag) { - return; - }); + sceneSession->RegisterDefaultAnimationFlagChangeCallback([sceneSession](const bool flag) { return; }); ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateWindowAnimationFlag(true)); } @@ -460,9 +445,7 @@ HWTEST_F(SceneSessionTest3, SetMainWindowTopmostChangeCallback, TestSize.Level1) NotifyMainWindowTopmostChangeFunc func; sceneSession->SetMainWindowTopmostChangeCallback(std::move(func)); - NotifyMainWindowTopmostChangeFunc func1 = [sceneSession](bool isTopmost) { - return; - }; + NotifyMainWindowTopmostChangeFunc func1 = [sceneSession](bool isTopmost) { return; }; sceneSession->SetMainWindowTopmostChangeCallback(std::move(func1)); ASSERT_NE(nullptr, sceneSession->mainWindowTopmostChangeFunc_); } @@ -479,9 +462,7 @@ HWTEST_F(SceneSessionTest3, SetRestoreMainWindowCallback, TestSize.Level1) info.bundleName_ = "SetRestoreMainWindowCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->SetRestoreMainWindowCallback([] { - return; - }); + sceneSession->SetRestoreMainWindowCallback([] { return; }); ASSERT_NE(nullptr, sceneSession->onRestoreMainWindowFunc_); } @@ -502,9 +483,7 @@ HWTEST_F(SceneSessionTest3, SetAdjustKeyboardLayoutCallback, TestSize.Level1) NotifyKeyboardLayoutAdjustFunc func; sceneSession->SetAdjustKeyboardLayoutCallback(func); - NotifyKeyboardLayoutAdjustFunc func1 = [sceneSession](const KeyboardLayoutParams& params) { - return; - }; + NotifyKeyboardLayoutAdjustFunc func1 = [sceneSession](const KeyboardLayoutParams& params) { return; }; sceneSession->SetAdjustKeyboardLayoutCallback(func1); ASSERT_NE(nullptr, sceneSession->adjustKeyboardLayoutFunc_); } @@ -547,7 +526,8 @@ HWTEST_F(SceneSessionTest3, SetCompatibleWindowSizeInPc, TestSize.Level1) sptr windowSessionProperty = sptr::MakeSptr(); sceneSession->property_ = windowSessionProperty; - ASSERT_EQ(WSError::WS_OK, + ASSERT_EQ( + WSError::WS_OK, sceneSession->SetCompatibleWindowSizeInPc(portraitWidth, portraitHeight, landscapeWidth, landscapeHeight)); } @@ -663,9 +643,7 @@ HWTEST_F(SceneSessionTest3, SetWindowRectAutoSaveCallback, TestSize.Level1) sptr windowSessionProperty = sptr::MakeSptr(); sceneSession->property_ = windowSessionProperty; - NotifySetWindowRectAutoSaveFunc func1 = [](bool enabled, bool isSaveBySpecifiedFlag) { - return; - }; + NotifySetWindowRectAutoSaveFunc func1 = [](bool enabled, bool isSaveBySpecifiedFlag) { return; }; sceneSession->SetWindowRectAutoSaveCallback(std::move(func1)); ASSERT_NE(nullptr, sceneSession->onSetWindowRectAutoSaveFunc_); } @@ -682,10 +660,8 @@ HWTEST_F(SceneSessionTest3, RegisterSupportWindowModesCallback, TestSize.Level1) info.bundleName_ = "RegisterSupportWindowModesCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - NotifySetSupportedWindowModesFunc func1 = [sceneSession]( - std::vector&& supportedWindowModes) { - return; - }; + NotifySetSupportedWindowModesFunc func1 = + [sceneSession](std::vector&& supportedWindowModes) { return; }; sceneSession->RegisterSupportWindowModesCallback(std::move(func1)); ASSERT_NE(nullptr, sceneSession->onSetSupportedWindowModesFunc_); @@ -880,9 +856,7 @@ HWTEST_F(SceneSessionTest3, RegisterFullScreenWaterfallModeChangeCallback, TestS info.bundleName_ = "RegisterFullScreenWaterfallModeChangeCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - std::function func = [](bool isWaterfallMode) { - return; - }; + std::function func = [](bool isWaterfallMode) { return; }; sceneSession->RegisterFullScreenWaterfallModeChangeCallback(std::move(func)); EXPECT_NE(sceneSession, nullptr); } @@ -899,9 +873,7 @@ HWTEST_F(SceneSessionTest3, RegisterThrowSlipAnimationStateChangeCallback, TestS info.bundleName_ = "RegisterThrowSlipAnimationStateChangeCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - std::function func = [](bool isAnimating) { - return; - }; + std::function func = [](bool isAnimating) { return; }; sceneSession->RegisterThrowSlipAnimationStateChangeCallback(std::move(func)); EXPECT_NE(sceneSession, nullptr); } @@ -1013,9 +985,7 @@ HWTEST_F(SceneSessionTest3, RegisterSetLandscapeMultiWindowFunc, TestSize.Level1 info.bundleName_ = "RegisterSetLandscapeMultiWindowFunc"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - std::function func = [](bool isLandscapeMultiWindow) { - return; - }; + std::function func = [](bool isLandscapeMultiWindow) { return; }; sceneSession->RegisterSetLandscapeMultiWindowFunc(std::move(func)); EXPECT_NE(sceneSession, nullptr); } @@ -1034,8 +1004,9 @@ HWTEST_F(SceneSessionTest3, IsDirtyDragWindow, TestSize.Level1) sceneSession->dirtyFlags_ = 0; auto res = sceneSession->IsDirtyDragWindow(); - EXPECT_EQ(res, sceneSession->dirtyFlags_ - & static_cast(SessionUIDirtyFlag::DRAG_RECT) || sceneSession->isDragging_); + EXPECT_EQ(res, + sceneSession->dirtyFlags_ & static_cast(SessionUIDirtyFlag::DRAG_RECT) || + sceneSession->isDragging_); } /** @@ -1211,9 +1182,7 @@ HWTEST_F(SceneSessionTest3, NotifyUpdateFlagCallback, TestSize.Level1) info.bundleName_ = "NotifyUpdateFlagCallback"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - NotifyUpdateFlagFunc func1 = [](const std::string& flag) { - return; - }; + NotifyUpdateFlagFunc func1 = [](const std::string& flag) { return; }; sceneSession->NotifyUpdateFlagCallback(std::move(func1)); ASSERT_NE(nullptr, sceneSession->onUpdateFlagFunc_); } @@ -1233,7 +1202,7 @@ HWTEST_F(SceneSessionTest3, GetKeyboardOccupiedAreaWithRotation1, TestSize.Level int32_t persistentId = 1; std::vector> avoidAreas; - std::pair keyboardOccupiedArea = {false, {0, 0, 0, 0}}; + std::pair keyboardOccupiedArea = { false, { 0, 0, 0, 0 } }; avoidAreas.emplace_back(keyboardOccupiedArea); sceneSession->GetKeyboardOccupiedAreaWithRotation(persistentId, Rotation::ROTATION_90, avoidAreas); uint32_t areaSize = static_cast(avoidAreas.size()); @@ -1259,7 +1228,7 @@ HWTEST_F(SceneSessionTest3, GetKeyboardOccupiedAreaWithRotation2, TestSize.Level int32_t persistentId = 1; std::vector> avoidAreas; - std::pair keyboardOccupiedArea = {true, {0, 0, 0, 0}}; + std::pair keyboardOccupiedArea = { true, { 0, 0, 0, 0 } }; avoidAreas.emplace_back(keyboardOccupiedArea); sceneSession->GetKeyboardOccupiedAreaWithRotation(persistentId, Rotation::ROTATION_90, avoidAreas); uint32_t areaSize = static_cast(avoidAreas.size()); @@ -1283,6 +1252,6 @@ HWTEST_F(SceneSessionTest3, SetSkipEventOnCastPlus01, TestSize.Level1) sceneSession->SetSkipEventOnCastPlus(false); ASSERT_EQ(false, sceneSession->GetSessionProperty()->GetSkipEventOnCastPlus()); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 27547acd19..512851cf9d 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -64,21 +64,13 @@ public: void TearDown() override; }; -void SceneSessionTest5::SetUpTestCase() -{ -} +void SceneSessionTest5::SetUpTestCase() {} -void SceneSessionTest5::TearDownTestCase() -{ -} +void SceneSessionTest5::TearDownTestCase() {} -void SceneSessionTest5::SetUp() -{ -} +void SceneSessionTest5::SetUp() {} -void SceneSessionTest5::TearDown() -{ -} +void SceneSessionTest5::TearDown() {} namespace { @@ -147,11 +139,11 @@ HWTEST_F(SceneSessionTest5, HookAvoidAreaInCompatibleMode, TestSize.Level1) sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - WSRect rect = {800, 100, 1000, 1000}; + WSRect rect = { 800, 100, 1000, 1000 }; AvoidArea avoidArea; - avoidArea.topRect_ = {-1, -1, -1, -1}; - avoidArea.bottomRect_ = {-1, -1, -1, -1}; - Rect invalidRect = {-1, -1, -1, -1}; + avoidArea.topRect_ = { -1, -1, -1, -1 }; + avoidArea.bottomRect_ = { -1, -1, -1, -1 }; + Rect invalidRect = { -1, -1, -1, -1 }; // hook Func only support compatibleMode session->SetCompatibleModeInPc(false, true); session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -167,12 +159,12 @@ HWTEST_F(SceneSessionTest5, HookAvoidAreaInCompatibleMode, TestSize.Level1) session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); session->HookAvoidAreaInCompatibleMode(rect, AvoidAreaType::TYPE_SYSTEM, avoidArea); auto vpr = 3.5f; - Rect targetRect = {0, 0, rect.width_, 40 * vpr}; + Rect targetRect = { 0, 0, rect.width_, 40 * vpr }; EXPECT_TRUE(avoidArea.topRect_ == targetRect); // test buttom aiBar avoidArea session->HookAvoidAreaInCompatibleMode(rect, AvoidAreaType::TYPE_NAVIGATION_INDICATOR, avoidArea); - targetRect = {0, rect.height_ - 28 * vpr, rect.width_, 28 * vpr}; + targetRect = { 0, rect.height_ - 28 * vpr, rect.width_, 28 * vpr }; EXPECT_TRUE(avoidArea.bottomRect_ == targetRect); } @@ -226,7 +218,7 @@ HWTEST_F(SceneSessionTest5, GetSystemAvoidArea01, TestSize.Level1) session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); session->GetSystemAvoidArea(rect, avoidArea); rect.height_ = 3; - rect.width_ =4; + rect.width_ = 4; session->GetSystemAvoidArea(rect, avoidArea); session->isVisible_ = true; @@ -263,9 +255,7 @@ HWTEST_F(SceneSessionTest5, NotifyOutsideDownEvent, TestSize.Level1) session->specificCallback_ = specificCallback; session->specificCallback_->onOutsideDownEvent_ = nullptr; session->NotifyOutsideDownEvent(pointerEvent); - OnOutsideDownEvent func = [](int32_t x, int32_t y) { - return; - }; + OnOutsideDownEvent func = [](int32_t x, int32_t y) { return; }; session->specificCallback_->onOutsideDownEvent_ = func; session->NotifyOutsideDownEvent(pointerEvent); auto res = pointerEvent->GetPointerItem(2024, pointerItem); @@ -304,9 +294,7 @@ HWTEST_F(SceneSessionTest5, TransferPointerEventInner, TestSize.Level1) session->specificCallback_->onSessionTouchOutside_ = nullptr; EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEventInner(pointerEvent, false)); - NotifySessionTouchOutsideCallback func = [](int32_t persistentId) { - return; - }; + NotifySessionTouchOutsideCallback func = [](int32_t persistentId) { return; }; session->specificCallback_->onSessionTouchOutside_ = func; EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEventInner(pointerEvent, false)); pointerEvent->SetPointerAction(2); @@ -462,10 +450,10 @@ HWTEST_F(SceneSessionTest5, UpdateSessionPropertyByAction, TestSize.Level1) sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); sptr property = sptr::MakeSptr(); - EXPECT_EQ(WMError::WM_ERROR_NULLPTR, session->UpdateSessionPropertyByAction - (nullptr, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE)); - EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, session->UpdateSessionPropertyByAction - (property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE)); + EXPECT_EQ(WMError::WM_ERROR_NULLPTR, + session->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE)); + EXPECT_EQ(WMError::WM_ERROR_INVALID_PERMISSION, + session->UpdateSessionPropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE)); } /** @@ -481,10 +469,10 @@ HWTEST_F(SceneSessionTest5, SetSessionRectChangeCallback, TestSize.Level1) sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); WSRect rec = { 1, 1, 1, 1 }; - NotifySessionRectChangeFunc func = [](const WSRect& rect, SizeChangeReason reason, - DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) { - return; - }; + NotifySessionRectChangeFunc func = [](const WSRect& rect, + SizeChangeReason reason, + DisplayId displayId, + const RectAnimationConfig& rectAnimationConfig) { return; }; session->SetSessionRectChangeCallback(nullptr); info.windowType_ = static_cast(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); session->SetSessionRectChangeCallback(func); @@ -510,10 +498,10 @@ HWTEST_F(SceneSessionTest5, SetSessionRectChangeCallback02, TestSize.Level1) sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); WSRect rec = { 1, 1, 1, 1 }; - NotifySessionRectChangeFunc func = [](const WSRect& rect, SizeChangeReason reason, - DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) { - return; - }; + NotifySessionRectChangeFunc func = [](const WSRect& rect, + SizeChangeReason reason, + DisplayId displayId, + const RectAnimationConfig& rectAnimationConfig) { return; }; session->SetSessionRectChangeCallback(nullptr); sptr property = sptr::MakeSptr(); @@ -552,10 +540,10 @@ HWTEST_F(SceneSessionTest5, SetSessionRectChangeCallback03, TestSize.Level1) sptr session = sptr::MakeSptr(info, nullptr); session->SetSessionProperty(property); WSRect rec = { 1, 1, 1, 1 }; - NotifySessionRectChangeFunc func = [](const WSRect& rect, const SizeChangeReason reason, - DisplayId displayId, const RectAnimationConfig& rectAnimationConfig) { - return; - }; + NotifySessionRectChangeFunc func = [](const WSRect& rect, + const SizeChangeReason reason, + DisplayId displayId, + const RectAnimationConfig& rectAnimationConfig) { return; }; session->SetSessionRequestRect(rec); session->SetSessionRectChangeCallback(nullptr); @@ -608,7 +596,7 @@ HWTEST_F(SceneSessionTest5, GetSystemAvoidArea02, TestSize.Level1) session->GetSystemAvoidArea(rect, avoidArea); session->GetSessionProperty()->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); rect.height_ = 2; - rect.width_ =1 ; + rect.width_ = 1; session->GetSystemAvoidArea(rect, avoidArea); rect.height_ = 1; session->GetSystemAvoidArea(rect, avoidArea); @@ -828,7 +816,7 @@ HWTEST_F(SceneSessionTest5, UpdateKeyFrameState, Function | SmallTest | Level2) EXPECT_NE(nullptr, rsTransaction); session->moveDragController_ = nullptr; - session->sessionStage_= nullptr; + session->sessionStage_ = nullptr; SizeChangeReason reason = { SizeChangeReason::DRAG_START }; WSRect rect; KeyFramePolicy keyFramePolicy; @@ -838,7 +826,7 @@ HWTEST_F(SceneSessionTest5, UpdateKeyFrameState, Function | SmallTest | Level2) session->moveDragController_ = moveDragController; session->UpdateKeyFrameState(reason, rect); EXPECT_EQ(session->keyFramePolicy_.running_, false); - session->sessionStage_= sessionStage; + session->sessionStage_ = sessionStage; session->UpdateKeyFrameState(reason, rect); EXPECT_EQ(session->keyFramePolicy_.running_, false); session->moveDragController_->isStartDrag_ = true; @@ -875,7 +863,7 @@ HWTEST_F(SceneSessionTest5, RequestKeyFrameNextVsync, Function | SmallTest | Lev EXPECT_NE(session, nullptr); uint64_t requestStamp = 0; uint64_t count = 0; - + session->RequestKeyFrameNextVsync(requestStamp, count); session->keyFramePolicy_.running_ = true; session->RequestKeyFrameNextVsync(requestStamp, count); @@ -917,8 +905,9 @@ HWTEST_F(SceneSessionTest5, OnKeyFrameNextVsync, Function | SmallTest | Level2) EXPECT_EQ(session->keyFrameDragPauseNoticed_, true); session->keyFrameDragPauseNoticed_ = false; session->keyFrameAnimating_ = false; - uint64_t nowTimeStamp = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count(); + uint64_t nowTimeStamp = + std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()) + .count(); session->lastKeyFrameDragStamp_ = nowTimeStamp; session->OnKeyFrameNextVsync(count); EXPECT_EQ(session->keyFrameDragPauseNoticed_, false); @@ -951,8 +940,9 @@ HWTEST_F(SceneSessionTest5, KeyFrameNotifyFilter, Function | SmallTest | Level2) EXPECT_EQ(session->KeyFrameNotifyFilter(rect, reason), false); EXPECT_EQ(session->KeyFrameNotifyFilter(rect, reason), true); session->lastKeyFrameRect_ = rect; - WSRect moveToRect = { 0, 0, static_cast(session->keyFramePolicy_.distance_), - static_cast(session->keyFramePolicy_.distance_) }; + WSRect moveToRect = { + 0, 0, static_cast(session->keyFramePolicy_.distance_), static_cast(session->keyFramePolicy_.distance_) + }; session->keyFrameAnimating_ = false; EXPECT_EQ(session->KeyFrameNotifyFilter(moveToRect, reason), false); session->keyFramePolicy_.distance_ = 0; @@ -995,9 +985,8 @@ HWTEST_F(SceneSessionTest5, UpdateWinRectForSystemBar, TestSize.Level1) session->specificCallback_ = specificCallback; WSRect rect = { 1, 10, 3, 4 }; session->UpdateWinRectForSystemBar(rect); - GetSceneSessionVectorByTypeAndDisplayIdCallback func = [session](WindowType type, uint64_t displayId)-> - std::vector> - { + GetSceneSessionVectorByTypeAndDisplayIdCallback func = + [session](WindowType type, uint64_t displayId) -> std::vector> { std::vector> vSession; vSession.push_back(session); return vSession; @@ -1033,12 +1022,8 @@ HWTEST_F(SceneSessionTest5, UpdateNativeVisibility, TestSize.Level1) EXPECT_NE(session, nullptr); sptr specificCallback = sptr::MakeSptr(); - NotifyWindowInfoUpdateCallback dateFunc = [](int32_t persistentId, WindowUpdateType type) { - return; - }; - UpdateAvoidAreaCallback areaFunc = [](const int32_t persistentId) { - return; - }; + NotifyWindowInfoUpdateCallback dateFunc = [](int32_t persistentId, WindowUpdateType type) { return; }; + UpdateAvoidAreaCallback areaFunc = [](const int32_t persistentId) { return; }; specificCallback->onWindowInfoUpdate_ = dateFunc; specificCallback->onUpdateAvoidArea_ = areaFunc; session->specificCallback_ = specificCallback; @@ -1237,9 +1222,7 @@ HWTEST_F(SceneSessionTest5, UpdateWindowAnimationFlag, TestSize.Level1) session->onWindowAnimationFlagChange_ = nullptr; EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); - NotifyWindowAnimationFlagChangeFunc func = [](const bool flag) { - return; - }; + NotifyWindowAnimationFlagChangeFunc func = [](const bool flag) { return; }; session->onWindowAnimationFlagChange_ = func; EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); } @@ -1453,8 +1436,8 @@ HWTEST_F(SceneSessionTest5, HandleActionUpdateWindowModeSupportType, TestSize.Le property->isSystemCalling_ = false; session->SetSessionProperty(property); - ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, session->HandleActionUpdateWindowModeSupportType(property, - WSPropertyChangeAction::ACTION_UPDATE_RECT)); + ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, + session->HandleActionUpdateWindowModeSupportType(property, WSPropertyChangeAction::ACTION_UPDATE_RECT)); } /** @@ -1557,14 +1540,12 @@ HWTEST_F(SceneSessionTest5, ProcessUpdatePropertyByAction, TestSize.Level1) session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE); - session->ProcessUpdatePropertyByAction( - property, WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE); + session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS); - session->ProcessUpdatePropertyByAction( - property, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS); + session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_FLAGS); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_MODE); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG); @@ -1573,10 +1554,9 @@ HWTEST_F(SceneSessionTest5, ProcessUpdatePropertyByAction, TestSize.Level1) session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED); - session->ProcessUpdatePropertyByAction( - property, WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); - session->ProcessUpdatePropertyByAction( - property, WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO); + session->ProcessUpdatePropertyByAction(property, + WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); + session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_TOPMOST); session->ProcessUpdatePropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); @@ -1598,13 +1578,11 @@ HWTEST_F(SceneSessionTest5, HandleActionUpdateTurnScreenOn, TestSize.Level0) sptr property = sptr::MakeSptr(); EXPECT_NE(property, nullptr); - auto res = session->HandleActionUpdateTurnScreenOn( - property, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); + auto res = session->HandleActionUpdateTurnScreenOn(property, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); EXPECT_EQ(res, WMError::WM_OK); property->SetTurnScreenOn(true); - res = session->HandleActionUpdateTurnScreenOn( - property, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); + res = session->HandleActionUpdateTurnScreenOn(property, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); EXPECT_EQ(res, WMError::WM_OK); } @@ -1628,8 +1606,7 @@ HWTEST_F(SceneSessionTest5, HandleActionUpdatePrivacyMode1, TestSize.Level0) session->property_->SetPrivacyMode(false); sptr property = sptr::MakeSptr(); property->SetPrivacyMode(true); - auto res = - session->HandleActionUpdatePrivacyMode(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE); + auto res = session->HandleActionUpdatePrivacyMode(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE); EXPECT_EQ(WMError::WM_OK, res); EXPECT_EQ(true, session->property_->GetPrivacyMode()); } @@ -1654,8 +1631,7 @@ HWTEST_F(SceneSessionTest5, HandleActionUpdatePrivacyMode2, TestSize.Level1) session->property_->SetPrivacyMode(true); sptr property = sptr::MakeSptr(); property->SetPrivacyMode(false); - auto res = - session->HandleActionUpdatePrivacyMode(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE); + auto res = session->HandleActionUpdatePrivacyMode(property, WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE); EXPECT_EQ(WMError::WM_OK, res); EXPECT_EQ(false, session->property_->GetPrivacyMode()); } @@ -1832,8 +1808,8 @@ HWTEST_F(SceneSessionTest5, MoveUnderInteriaAndNotifyRectChange, TestSize.Level1 auto controller = mainSession->pcFoldScreenController_; WSRect rect = { 0, 0, 100, 100 }; EXPECT_FALSE(mainSession->MoveUnderInteriaAndNotifyRectChange(rect, SizeChangeReason::DRAG_END)); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); PcFoldScreenManager::GetInstance().vpr_ = 1.7f; WSRect rect0 = { 100, 100, 400, 400 }; @@ -1857,6 +1833,160 @@ HWTEST_F(SceneSessionTest5, MoveUnderInteriaAndNotifyRectChange, TestSize.Level1 EXPECT_TRUE(mainSession->MoveUnderInteriaAndNotifyRectChange(rect, SizeChangeReason::DRAG_END)); } +/** + * @tc.name: WindowScaleTransfer01 + * @tc.desc: WindowScaleTransfer01 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, WindowScaleTransfer01, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "WindowScaleTransfer01"; + info.bundleName_ = "WindowScaleTransfer01"; + info.screenId_ = 0; + sptr mainSession = sptr::MakeSptr(info, nullptr); + WSRect rect = { 100, 100, 400, 400 }; + WSRect resultRect = { 200, 200, 200, 200 }; + float scaleX = 0.5f; + float scaleY = 0.5f; + mainSession->winRect_ = rect; + mainSession->SetScale(scaleX, scaleY, 0.5f, 0.5f); + mainSession->WindowScaleTransfer(mainSession->winRect_, scaleX, scaleY); + EXPECT_EQ(mainSession->winRect_, resultRect); +} + +/** + * @tc.name: WindowScaleTransfer02 + * @tc.desc: WindowScaleTransfer02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, WindowScaleTransfer02, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "WindowScaleTransfer02"; + info.bundleName_ = "WindowScaleTransfer02"; + info.screenId_ = 0; + sptr mainSession = sptr::MakeSptr(info, nullptr); + WSRect rect = { 200, 200, 200, 200 }; + WSRect resultRect = { 100, 100, 400, 400 }; + float scaleX = 2.0f; + float scaleY = 2.0f; + mainSession->winRect_ = rect; + mainSession->SetScale(scaleX, scaleY, 0.5f, 0.5f); + mainSession->WindowScaleTransfer(mainSession->winRect_, scaleX, scaleY); + EXPECT_EQ(mainSession->winRect_, resultRect); +} + +/** + * @tc.name: IsCompatibilityModeScale01 + * @tc.desc: IsCompatibilityModeScale01 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, IsCompatibilityModeScale01, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "IsCompatibilityModeScale01"; + info.bundleName_ = "IsCompatibilityModeScale01"; + info.screenId_ = 0; + sptr mainSession = sptr::MakeSptr(info, nullptr); + auto property = mainSession->GetSessionProperty(); + float scaleX = 2.0f; + float scaleY = 2.0f; + property->SetCompatibleModeInPc(true); + ASSERT_EQ(property->GetCompatibleModeInPc(), true); + bool res = mainSession->IsCompatibilityModeScale(scaleX, scaleY); + EXPECT_EQ(res, true); + property->SetCompatibleModeInPc(false); + ASSERT_EQ(property->GetCompatibleModeInPc(), false); + res = mainSession->IsCompatibilityModeScale(scaleX, scaleY); + EXPECT_EQ(res, false); +} + +/** + * @tc.name: IsCompatibilityModeScale02 + * @tc.desc: IsCompatibilityModeScale02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, IsCompatibilityModeScale02, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "IsCompatibilityModeScale02"; + info.bundleName_ = "IsCompatibilityModeScale02"; + info.screenId_ = 0; + sptr mainSession = sptr::MakeSptr(info, nullptr); + auto property = mainSession->GetSessionProperty(); + float scaleX = 1.0f; + float scaleY = 1.0f; + property->SetCompatibleModeInPc(true); + ASSERT_EQ(property->GetCompatibleModeInPc(), true); + bool res = mainSession->IsCompatibilityModeScale(scaleX, scaleY); + EXPECT_EQ(res, false); + property->SetCompatibleModeInPc(false); + ASSERT_EQ(property->GetCompatibleModeInPc(), false); + res = mainSession->IsCompatibilityModeScale(scaleX, scaleY); + EXPECT_EQ(res, false); +} + +/** + * @tc.name: HookStartMoveRect + * @tc.desc: HookStartMoveRect + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, HookStartMoveRect, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "HookStartMoveRect"; + info.bundleName_ = "HookStartMoveRect"; + info.screenId_ = 0; + sptr mainSession = sptr::MakeSptr(info, nullptr); + WSRect preRect = { 100, 100, 400, 400 }; + WSRect resultRect = { 200, 200, 200, 200 }; + float scaleX = 0.5f; + float scaleY = 0.5f; + mainSession->SetScale(scaleX, scaleY, 0.5f, 0.5f); + mainSession->SetSessionRect(preRect); + EXPECT_EQ(preRect, mainSession->GetSessionRect()); + auto property = mainSession->GetSessionProperty(); + property->SetCompatibleModeInPc(false); + WSRect currRect; + mainSession->HookStartMoveRect(currRect, mainSession->GetSessionRect()); + EXPECT_EQ(preRect, currRect); + property->SetCompatibleModeInPc(true); + mainSession->HookStartMoveRect(currRect, mainSession->GetSessionRect()); + EXPECT_EQ(resultRect, currRect); +} + +/** + * @tc.name: CompatibilityModeWindowScaleTransfer + * @tc.desc: CompatibilityModeWindowScaleTransfer + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, CompatibilityModeWindowScaleTransfer, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "CompatibilityModeWindowScaleTransfer"; + info.bundleName_ = "CompatibilityModeWindowScaleTransfer"; + info.screenId_ = 0; + sptr mainSession = sptr::MakeSptr(info, nullptr); + WSRect preRect = { 100, 100, 400, 400 }; + WSRect noChangeRect = { 100, 100, 400, 400 }; + WSRect resultRect = { 200, 200, 200, 200 }; + float scaleX = 0.5f; + float scaleY = 0.5f; + bool isScale = true; + mainSession->SetScale(scaleX, scaleY, 0.5f, 0.5f); + auto property = mainSession->GetSessionProperty(); + property->SetCompatibleModeInPc(false); + mainSession->CompatibilityModeWindowScaleTransfer(preRect, isScale); + EXPECT_EQ(noChangeRect, preRect); + property->SetCompatibleModeInPc(true); + mainSession->CompatibilityModeWindowScaleTransfer(preRect, isScale); + EXPECT_EQ(resultRect, preRect); + isScale = false; + mainSession->CompatibilityModeWindowScaleTransfer(preRect, isScale); + EXPECT_EQ(noChangeRect, preRect); +} + /** * @tc.name: ThrowSlipDirectly * @tc.desc: ThrowSlipDirectly @@ -1871,7 +2001,7 @@ HWTEST_F(SceneSessionTest5, ThrowSlipDirectly, TestSize.Level1) sptr mainSession = sptr::MakeSptr(info, nullptr); WSRect rect = { 100, 100, 400, 400 }; mainSession->winRect_ = rect; - mainSession->ThrowSlipDirectly(ThrowSlipMode::THREE_FINGERS_SWIPE, WSRectF { 0.0f, 0.0f, 0.0f, 0.0f }); + mainSession->ThrowSlipDirectly(ThrowSlipMode::THREE_FINGERS_SWIPE, WSRectF{ 0.0f, 0.0f, 0.0f, 0.0f }); EXPECT_EQ(mainSession->winRect_, rect); } @@ -1934,9 +2064,7 @@ HWTEST_F(SceneSessionTest5, SetSessionDisplayIdChangeCallback, TestSize.Level1) { const SessionInfo info; sptr sceneSession = sptr::MakeSptr(info, nullptr); - sceneSession->SetSessionDisplayIdChangeCallback([] (uint64_t displayId) { - return; - }); + sceneSession->SetSessionDisplayIdChangeCallback([](uint64_t displayId) { return; }); ASSERT_NE(sceneSession->sessionDisplayIdChangeFunc_, nullptr); } @@ -1951,9 +2079,7 @@ HWTEST_F(SceneSessionTest5, NotifySessionDisplayIdChange, TestSize.Level1) sptr sceneSession = sptr::MakeSptr(info, nullptr); uint64_t checkDisplayId = 345; uint64_t moveDisplayId = 456; - sceneSession->sessionDisplayIdChangeFunc_ = [&checkDisplayId] (uint64_t displayId) { - checkDisplayId = displayId; - }; + sceneSession->sessionDisplayIdChangeFunc_ = [&checkDisplayId](uint64_t displayId) { checkDisplayId = displayId; }; sceneSession->NotifySessionDisplayIdChange(moveDisplayId); ASSERT_EQ(moveDisplayId, checkDisplayId); } @@ -1979,7 +2105,7 @@ HWTEST_F(SceneSessionTest5, CheckAndMoveDisplayIdRecursively, TestSize.Level1) GTEST_LOG_(INFO) << "SceneSessionMocker:NULL"; return; } - }); + }); sceneSession->property_->SetDisplayId(displayId); sceneSession->shouldFollowParentWhenShow_ = true; EXPECT_CALL(*sceneSession, SetScreenId(displayId)).Times(0); @@ -2304,7 +2430,7 @@ HWTEST_F(SceneSessionTest5, UpdateDensity, TestSize.Level1) }; sptr screenSession = sptr::MakeSptr(); ASSERT_NE(nullptr, screenSession); - + session->UpdateDensity(); WSRect resultRect = { 10, 10, 800, 600 }; EXPECT_EQ(session->winRect_, resultRect); @@ -2328,7 +2454,7 @@ HWTEST_F(SceneSessionTest5, NotifyRotationChange, Function | SmallTest | Level2) session->isRotationChangeCallbackRegistered = true; res = session->NotifyRotationChange(rotationInfo); EXPECT_EQ(res.windowRect_.width_, 0); - + sptr sessionStageMocker = sptr::MakeSptr(); ASSERT_NE(sessionStageMocker, nullptr); session->sessionStage_ = sessionStageMocker; @@ -2350,9 +2476,7 @@ HWTEST_F(SceneSessionTest5, SetSessionGetTargetOrientationConfigInfoCallback, Fu sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - sceneSession->SetSessionGetTargetOrientationConfigInfoCallback([](uint32_t targetOrientation) { - return; - }); + sceneSession->SetSessionGetTargetOrientationConfigInfoCallback([](uint32_t targetOrientation) { return; }); EXPECT_NE(sceneSession->sessionGetTargetOrientationConfigInfoFunc_, nullptr); } @@ -2420,6 +2544,6 @@ HWTEST_F(SceneSessionTest5, GetSystemBarPropertyForRotation, Function | SmallTes sceneSession->SetSystemBarPropertyForRotation(properties); EXPECT_EQ(sceneSession->GetSystemBarPropertyForRotation(), properties); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_test6.cpp b/window_scene/test/unittest/scene_session_test6.cpp index f8648e5794..d38a9ac937 100644 --- a/window_scene/test/unittest/scene_session_test6.cpp +++ b/window_scene/test/unittest/scene_session_test6.cpp @@ -35,13 +35,16 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { - std::string g_errlog; - void ScreenSessionLogCallback( - const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *msg) - { +std::string g_errlog; +void ScreenSessionLogCallback(const LogType type, + const LogLevel level, + const unsigned int domain, + const char* tag, + const char* msg) +{ g_errlog = msg; - } -} // namespace name +} +} // namespace class SceneSessionTest6 : public testing::Test { public: @@ -51,21 +54,13 @@ public: void TearDown() override; }; -void SceneSessionTest6::SetUpTestCase() -{ -} +void SceneSessionTest6::SetUpTestCase() {} -void SceneSessionTest6::TearDownTestCase() -{ -} +void SceneSessionTest6::TearDownTestCase() {} -void SceneSessionTest6::SetUp() -{ -} +void SceneSessionTest6::SetUp() {} -void SceneSessionTest6::TearDown() -{ -} +void SceneSessionTest6::TearDown() {} namespace { @@ -100,7 +95,7 @@ HWTEST_F(SceneSessionTest6, NotifyUpdateGravity01, TestSize.Level1) SessionInfo info; sptr subSession = sptr::MakeSptr(info, nullptr); int32_t subSessionId = subSession->GetPersistentId(); - + sptr mainSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(nullptr, mainSession); @@ -160,9 +155,7 @@ HWTEST_F(SceneSessionTest6, GetSceneSessionById01, TestSize.Level1) ret = sceneSession->GetSceneSessionById(findSession->GetPersistentId()); ASSERT_EQ(nullptr, ret); - auto task = [&findSession](int32_t persistentId) { - return findSession; - }; + auto task = [&findSession](int32_t persistentId) { return findSession; }; callBack->onGetSceneSessionByIdCallback_ = task; ret = sceneSession->GetSceneSessionById(findSession->GetPersistentId()); ASSERT_EQ(findSession->GetPersistentId(), ret->GetPersistentId()); @@ -177,7 +170,7 @@ HWTEST_F(SceneSessionTest6, SetFollowParentRectFunc01, TestSize.Level1) { SessionInfo info; sptr sceneSession = sptr::MakeSptr(info, nullptr); - + sceneSession->SetFollowParentRectFunc(nullptr); ASSERT_EQ(nullptr, sceneSession->followParentRectFunc_); @@ -210,7 +203,7 @@ HWTEST_F(SceneSessionTest6, SetFollowParentWindowLayoutEnabled01, TestSize.Level property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); ret = sceneSession->SetFollowParentWindowLayoutEnabled(true); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_OPERATION); - + property->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); ret = sceneSession->SetFollowParentWindowLayoutEnabled(true); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_OPERATION); @@ -238,11 +231,9 @@ HWTEST_F(SceneSessionTest6, SetFollowParentWindowLayoutEnabled02, TestSize.Level sceneSession->isFollowParentLayout_ = false; sceneSession->SetFollowParentWindowLayoutEnabled(true); ASSERT_TRUE(sceneSession->isFollowParentLayout_); - //test after set flag, call func + // test after set flag, call func bool isCall = false; - NotifyFollowParentRectFunc func = [&isCall](bool isFollow) { - isCall = true; - }; + NotifyFollowParentRectFunc func = [&isCall](bool isFollow) { isCall = true; }; sceneSession->SetFollowParentRectFunc(std::move(func)); ASSERT_NE(nullptr, sceneSession->followParentRectFunc_); sceneSession->SetFollowParentWindowLayoutEnabled(true); @@ -290,8 +281,8 @@ HWTEST_F(SceneSessionTest6, NotifyKeyboardAnimationCompleted, Function | SmallTe sceneSession->property_ = property; sceneSession->sessionStage_ = nullptr; bool isShowAnimation = true; - WSRect beginRect = {0, 2720, 1260, 1020}; - WSRect endRect = {0, 1700, 1260, 1020}; + WSRect beginRect = { 0, 2720, 1260, 1020 }; + WSRect endRect = { 0, 1700, 1260, 1020 }; sceneSession->NotifyKeyboardAnimationCompleted(isShowAnimation, beginRect, endRect); sceneSession->sessionStage_ = sptr::MakeSptr(); EXPECT_NE(nullptr, sceneSession->sessionStage_); @@ -300,14 +291,13 @@ HWTEST_F(SceneSessionTest6, NotifyKeyboardAnimationCompleted, Function | SmallTe sceneSession->NotifyKeyboardAnimationCompleted(isShowAnimation, beginRect, endRect); isShowAnimation = false; - beginRect = {0, 1700, 1260, 1020}; - endRect = {0, 2720, 1260, 1020}; + beginRect = { 0, 1700, 1260, 1020 }; + endRect = { 0, 2720, 1260, 1020 }; sceneSession->NotifyKeyboardAnimationCompleted(isShowAnimation, beginRect, endRect); sceneSession->NotifyKeyboardDidHideRegistered(true); sceneSession->NotifyKeyboardAnimationCompleted(isShowAnimation, beginRect, endRect); } - /** * @tc.name: UpdateNewSizeForPCWindow * @tc.desc: UpdateNewSizeForPCWindow @@ -395,6 +385,54 @@ HWTEST_F(SceneSessionTest6, NotifyWindowAttachStateListenerRegistered_session, F sceneSession->NotifyWindowAttachStateListenerRegistered(false); EXPECT_EQ(sceneSession->needNotifyAttachState_, false); } + +/** + * @tc.name: UpdateFollowScreenChange + * @tc.desc: UpdateFollowScreenChange + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest6, UpdateFollowScreenChange, Function | SmallTest | Level1) +{ + SessionInfo info; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(nullptr, sceneSession); + bool isFollowScreenChange = true; + sceneSession->specificCallback_ = nullptr; + WSError ret = sceneSession->UpdateFollowScreenChange(isFollowScreenChange); + EXPECT_EQ(WSError::WS_OK, ret); + + sptr callback = sptr::MakeSptr(); + ASSERT_NE(nullptr, callback); + sceneSession->specificCallback_ = callback; + ret = sceneSession->UpdateFollowScreenChange(isFollowScreenChange); + EXPECT_EQ(WSError::WS_OK, ret); + + auto task = [] (bool isFollowScreenChange) {}; + callback->onUpdateFollowScreenChange_ = task; + ret = sceneSession->UpdateFollowScreenChange(isFollowScreenChange); + EXPECT_EQ(WSError::WS_OK, ret); +} + +/** + * @tc.name: RegisterFollowScreenChangeCallback + * @tc.desc: RegisterFollowScreenChangeCallback + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest6, RegisterFollowScreenChangeCallback, Function | SmallTest | Level1) +{ + SessionInfo info; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(nullptr, sceneSession); + sceneSession->specificCallback_ = nullptr; + sptr callback = sptr::MakeSptr(); + ASSERT_NE(nullptr, callback); + sceneSession->specificCallback_ = callback; + EXPECT_EQ(nullptr, callback->onUpdateFollowScreenChange_); + + auto task = [] (bool isFollowScreenChange) {}; + callback->onUpdateFollowScreenChange_ = task; + EXPECT_NE(nullptr, callback->onUpdateFollowScreenChange_); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/scene_system_ability_listener_test.cpp b/window_scene/test/unittest/scene_system_ability_listener_test.cpp index 48b728cab2..621e833639 100644 --- a/window_scene/test/unittest/scene_system_ability_listener_test.cpp +++ b/window_scene/test/unittest/scene_system_ability_listener_test.cpp @@ -33,21 +33,13 @@ public: void TearDown() override; }; -void SceneSystemAbilityListenerTest::SetUpTestCase() -{ -} +void SceneSystemAbilityListenerTest::SetUpTestCase() {} -void SceneSystemAbilityListenerTest::TearDownTestCase() -{ -} +void SceneSystemAbilityListenerTest::TearDownTestCase() {} -void SceneSystemAbilityListenerTest::SetUp() -{ -} +void SceneSystemAbilityListenerTest::SetUp() {} -void SceneSystemAbilityListenerTest::TearDown() -{ -} +void SceneSystemAbilityListenerTest::TearDown() {} HWTEST_F(SceneSystemAbilityListenerTest, OnAddSystemAbilityTest, TestSize.Level1) { @@ -57,8 +49,12 @@ HWTEST_F(SceneSystemAbilityListenerTest, OnAddSystemAbilityTest, TestSize.Level1 std::string ssmTid = std::to_string(78); std::string scbBundleName = "scb"; std::string ssmThreadName = "ssm"; - SCBThreadInfo threadInfo = {.scbUid_ = scbUid, .scbPid_ = scbPid, .scbTid_ = scbTid, - .ssmTid_ = ssmTid, .scbBundleName_ = scbBundleName, .ssmThreadName_ = ssmThreadName}; + SCBThreadInfo threadInfo = { .scbUid_ = scbUid, + .scbPid_ = scbPid, + .scbTid_ = scbTid, + .ssmTid_ = ssmTid, + .scbBundleName_ = scbBundleName, + .ssmThreadName_ = ssmThreadName }; SceneSystemAbilityListener listener(threadInfo); #ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE ResourceSchedule::ResSchedClient::GetInstance().rss_ = nullptr; @@ -70,5 +66,5 @@ HWTEST_F(SceneSystemAbilityListenerTest, OnAddSystemAbilityTest, TestSize.Level1 EXPECT_EQ(listener.info_, threadInfo); #endif } -} -} \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_layout_test.cpp b/window_scene/test/unittest/session_layout_test.cpp index 29bc6b598b..8651289e86 100644 --- a/window_scene/test/unittest/session_layout_test.cpp +++ b/window_scene/test/unittest/session_layout_test.cpp @@ -65,7 +65,9 @@ private: void OnExtensionDied() override {} void OnExtensionTimeout(int32_t errorCode) override {} void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, - int64_t uiExtensionIdLevel) override {} + int64_t uiExtensionIdLevel) override + { + } void OnDrawingCompleted() override {} void OnAppRemoveStartingWindow() override {} }; @@ -75,13 +77,9 @@ private: sptr mockEventChannel_ = nullptr; }; -void SessionLayoutTest::SetUpTestCase() -{ -} +void SessionLayoutTest::SetUpTestCase() {} -void SessionLayoutTest::TearDownTestCase() -{ -} +void SessionLayoutTest::TearDownTestCase() {} void SessionLayoutTest::SetUp() { @@ -93,9 +91,7 @@ void SessionLayoutTest::SetUp() session_->surfaceNode_ = CreateRSSurfaceNode(); ssm_ = sptr::MakeSptr(); session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_); - auto isScreenLockedCallback = [this]() { - return ssm_->IsScreenLocked(); - }; + auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); mockSessionStage_ = sptr::MakeSptr(); mockEventChannel_ = sptr::MakeSptr(mockSessionStage_); @@ -146,26 +142,25 @@ HWTEST_F(SessionLayoutTest, UpdateRect01, TestSize.Level1) session_->sessionStage_ = mockSessionStage; EXPECT_CALL(*(mockSessionStage), UpdateRect(_, _, _, _)).Times(AtLeast(1)).WillOnce(Return(WSError::WS_OK)); - WSRect rect = {0, 0, 0, 0}; - ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->UpdateRect(rect, - SizeChangeReason::UNDEFINED, "SessionLayoutTest")); + WSRect rect = { 0, 0, 0, 0 }; + ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, + session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); sptr mockEventChannel = sptr::MakeSptr(mockSessionStage); SystemSessionConfig sessionConfig; sptr property = sptr::MakeSptr(); - ASSERT_EQ(WSError::WS_OK, session_->Connect(mockSessionStage, - mockEventChannel, nullptr, sessionConfig, property)); + ASSERT_EQ(WSError::WS_OK, session_->Connect(mockSessionStage, mockEventChannel, nullptr, sessionConfig, property)); - rect = {0, 0, 100, 100}; - ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->UpdateRect(rect, - SizeChangeReason::UNDEFINED, "SessionLayoutTest")); + rect = { 0, 0, 100, 100 }; + ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, + session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); ASSERT_EQ(rect, session_->winRect_); - rect = {0, 0, 200, 200}; + rect = { 0, 0, 200, 200 }; session_->UpdateSessionState(SessionState::STATE_ACTIVE); ASSERT_EQ(WSError::WS_OK, session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); ASSERT_EQ(rect, session_->winRect_); - rect = {0, 0, 300, 300}; + rect = { 0, 0, 300, 300 }; session_->sessionStage_ = nullptr; ASSERT_EQ(WSError::WS_OK, session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "SessionLayoutTest")); ASSERT_EQ(rect, session_->winRect_); @@ -204,7 +199,7 @@ HWTEST_F(SessionLayoutTest, UpdateSessionRect01, TestSize.Level1) info.abilityName_ = "testSession1"; info.bundleName_ = "testSession3"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - WSRect rect = {0, 0, 320, 240}; // width: 320, height: 240 + WSRect rect = { 0, 0, 320, 240 }; // width: 320, height: 240 auto result = sceneSession->UpdateSessionRect(rect, SizeChangeReason::RESIZE); ASSERT_EQ(result, WSError::WS_OK); @@ -276,6 +271,6 @@ HWTEST_F(SessionLayoutTest, SetOriginDisplayId, TestSize.Level1) session->SetOriginDisplayId(999); ASSERT_EQ(999, session->GetOriginDisplayId()); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_lifecycle_test.cpp b/window_scene/test/unittest/session_lifecycle_test.cpp index 293fa2281c..17c115a30b 100644 --- a/window_scene/test/unittest/session_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_lifecycle_test.cpp @@ -38,7 +38,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { - const std::string UNDEFINED = "undefined"; +const std::string UNDEFINED = "undefined"; } class WindowSessionLifecycleTest : public testing::Test { @@ -48,14 +48,13 @@ public: void SetUp() override; void TearDown() override; int32_t GetTaskCount(); - sptr ssm_; + sptr ssm_; private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); - sptr session_ = nullptr; - static constexpr uint32_t - WAIT_SYNC_IN_NS = 500000; + sptr session_ = nullptr; + static constexpr uint32_t WAIT_SYNC_IN_NS = 500000; class TLifecycleListener : public ILifecycleListener { public: @@ -68,20 +67,18 @@ private: void OnExtensionDied() override {} void OnExtensionTimeout(int32_t errorCode) override {} void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, - int64_t uiExtensionIdLevel) override {} + int64_t uiExtensionIdLevel) override + { + } void OnDrawingCompleted() override {} void OnAppRemoveStartingWindow() override {} }; std::shared_ptr lifecycleListener_ = std::make_shared(); }; -void WindowSessionLifecycleTest::SetUpTestCase() -{ -} +void WindowSessionLifecycleTest::SetUpTestCase() {} -void WindowSessionLifecycleTest::TearDownTestCase() -{ -} +void WindowSessionLifecycleTest::TearDownTestCase() {} void WindowSessionLifecycleTest::SetUp() { @@ -94,9 +91,7 @@ void WindowSessionLifecycleTest::SetUp() EXPECT_NE(nullptr, session_); ssm_ = sptr::MakeSptr(); session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_); - auto isScreenLockedCallback = [this]() { - return ssm_->IsScreenLocked(); - }; + auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); } @@ -339,10 +334,7 @@ HWTEST_F(WindowSessionLifecycleTest, Disconnect01, TestSize.Level1) */ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionNew01, TestSize.Level1) { - NotifyTerminateSessionFuncNew callback = - [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) - { - }; + NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {}; bool needStartCaller = false; bool isFromBroker = false; @@ -350,8 +342,7 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionNew01, TestSize.Level1) session_->terminateSessionFuncNew_ = nullptr; session_->TerminateSessionNew(info, needStartCaller, isFromBroker); - ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session_->TerminateSessionNew(nullptr, needStartCaller, isFromBroker)); + ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->TerminateSessionNew(nullptr, needStartCaller, isFromBroker)); } /** @@ -539,7 +530,7 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionTotal01, TestSize.Level1) { ASSERT_NE(session_, nullptr); ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, - session_->TerminateSessionTotal(nullptr, TerminateType::CLOSE_AND_KEEP_MULTITASK)); + session_->TerminateSessionTotal(nullptr, TerminateType::CLOSE_AND_KEEP_MULTITASK)); } /** @@ -553,7 +544,7 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionTotal02, TestSize.Level1) sptr abilitySessionInfo = sptr::MakeSptr(); session_->isTerminating_ = true; ASSERT_EQ(WSError::WS_ERROR_INVALID_OPERATION, - session_->TerminateSessionTotal(abilitySessionInfo, TerminateType::CLOSE_AND_KEEP_MULTITASK)); + session_->TerminateSessionTotal(abilitySessionInfo, TerminateType::CLOSE_AND_KEEP_MULTITASK)); } /** @@ -568,7 +559,7 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionTotal03, TestSize.Level1) session_->isTerminating_ = false; session_->SetTerminateSessionListenerTotal(nullptr); ASSERT_EQ(WSError::WS_OK, - session_->TerminateSessionTotal(abilitySessionInfo, TerminateType::CLOSE_AND_KEEP_MULTITASK)); + session_->TerminateSessionTotal(abilitySessionInfo, TerminateType::CLOSE_AND_KEEP_MULTITASK)); } /** @@ -709,6 +700,6 @@ HWTEST_F(WindowSessionLifecycleTest, IsTerminated49, TestSize.Level1) res = session_->IsTerminated(); ASSERT_EQ(false, res); } -} -} -} +} // namespace +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/session_listener_controller_test.cpp b/window_scene/test/unittest/session_listener_controller_test.cpp index 37400f5d57..13f54daa8e 100644 --- a/window_scene/test/unittest/session_listener_controller_test.cpp +++ b/window_scene/test/unittest/session_listener_controller_test.cpp @@ -141,17 +141,14 @@ public: { event_ = event; } + private: ISessionLifecycleListener::SessionLifecycleEvent event_; }; -void SessionListenerControllerTest::SetUpTestCase() -{ -} +void SessionListenerControllerTest::SetUpTestCase() {} -void SessionListenerControllerTest::TearDownTestCase() -{ -} +void SessionListenerControllerTest::TearDownTestCase() {} void SessionListenerControllerTest::SetUp() { @@ -451,7 +448,7 @@ HWTEST_F(SessionListenerControllerTest, ListenerDeathRecipient, TestSize.Level1) */ HWTEST_F(SessionListenerControllerTest, RegisterSessionLifecycleListenerByBundles, TestSize.Level1) { - std::vector bundleNameList1 = {"bundle1", "bundle2"}; + std::vector bundleNameList1 = { "bundle1", "bundle2" }; WMError res = slController->RegisterSessionLifecycleListener(nullptr, bundleNameList1); ASSERT_EQ(res, WMError::WM_ERROR_INVALID_PARAM); @@ -472,7 +469,7 @@ HWTEST_F(SessionListenerControllerTest, RegisterSessionLifecycleListenerByBundle */ HWTEST_F(SessionListenerControllerTest, RegisterSessionLifecycleListenerByIds, TestSize.Level1) { - std::vector persistentIdList1 = {1, 2}; + std::vector persistentIdList1 = { 1, 2 }; WMError res = slController->RegisterSessionLifecycleListener(nullptr, persistentIdList1); ASSERT_EQ(res, WMError::WM_ERROR_INVALID_PARAM); @@ -544,8 +541,8 @@ HWTEST_F(SessionListenerControllerTest, NotifySessionLifecycleEvent02, Function sptr myListener = new MySessionLifecycleListener(); sptr listener = iface_cast(myListener->AsObject()); ASSERT_NE(listener, nullptr); - std::vector persistentIdList = {102}; - + std::vector persistentIdList = { 102 }; + SessionInfo info; info.bundleName_ = "com.example.myapp"; info.abilityName_ = "MainAbility"; @@ -555,8 +552,8 @@ HWTEST_F(SessionListenerControllerTest, NotifySessionLifecycleEvent02, Function sptr ssm = sptr::MakeSptr(); sptr sceneSession = sptr::MakeSptr(info, nullptr); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - ssm->sceneSessionMap_.insert({102, sceneSession}); - + ssm->sceneSessionMap_.insert({ 102, sceneSession }); + slController->RegisterSessionLifecycleListener(listener, persistentIdList); slController->NotifySessionLifecycleEvent(ISessionLifecycleListener::SessionLifecycleEvent::CREATED, info); ASSERT_EQ(myListener->event_, ISessionLifecycleListener::SessionLifecycleEvent::CREATED); diff --git a/window_scene/test/unittest/session_manager_agent_controller_test.cpp b/window_scene/test/unittest/session_manager_agent_controller_test.cpp index aa0ac25365..efdee09f8a 100644 --- a/window_scene/test/unittest/session_manager_agent_controller_test.cpp +++ b/window_scene/test/unittest/session_manager_agent_controller_test.cpp @@ -34,21 +34,13 @@ public: void TearDown() override; }; -void SessionManagerAgentControllerTest::SetUpTestCase() -{ -} +void SessionManagerAgentControllerTest::SetUpTestCase() {} -void SessionManagerAgentControllerTest::TearDownTestCase() -{ -} +void SessionManagerAgentControllerTest::TearDownTestCase() {} -void SessionManagerAgentControllerTest::SetUp() -{ -} +void SessionManagerAgentControllerTest::SetUp() {} -void SessionManagerAgentControllerTest::TearDown() -{ -} +void SessionManagerAgentControllerTest::TearDown() {} /** * @tc.name: RegisterWindowManagerAgent @@ -60,10 +52,10 @@ HWTEST_F(SessionManagerAgentControllerTest, RegisterWindowManagerAgent, TestSize sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; int32_t pid = 65535; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -76,11 +68,11 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateCameraFloatWindowStatus, TestS sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; int32_t pid = 65535; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); SessionManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(0, false); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -93,12 +85,12 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateFocusChangeInfo, TestSize.Leve sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; int32_t pid = 65535; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); sptr focusChangeInfo = sptr::MakeSptr(); SessionManagerAgentController::GetInstance().UpdateFocusChangeInfo(focusChangeInfo, false); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -111,11 +103,11 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateWindowModeTypeInfo, TestSize.L int32_t pid = 65535; sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); SessionManagerAgentController::GetInstance().UpdateWindowModeTypeInfo(WindowModeType::WINDOW_MODE_SPLIT); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -128,13 +120,13 @@ HWTEST_F(SessionManagerAgentControllerTest, NotifyAccessibilityWindowInfo, TestS sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; int32_t pid = 65535; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); std::vector> infos; SessionManagerAgentController::GetInstance().NotifyAccessibilityWindowInfo(infos, - WindowUpdateType::WINDOW_UPDATE_ACTIVE); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + WindowUpdateType::WINDOW_UPDATE_ACTIVE); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -147,11 +139,11 @@ HWTEST_F(SessionManagerAgentControllerTest, NotifyWaterMarkFlagChangedResult, Te sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; int32_t pid = 65535; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); SessionManagerAgentController::GetInstance().NotifyWaterMarkFlagChangedResult(false); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -164,12 +156,12 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateWindowVisibilityInfo, TestSize sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; int32_t pid = 65535; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); std::vector> windowVisibilityInfos; SessionManagerAgentController::GetInstance().UpdateWindowVisibilityInfo(windowVisibilityInfos); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -184,8 +176,8 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateVisibleWindowNum, TestSize.Lev int32_t pid = 65535; sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_VISIBLE_WINDOW_NUM; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -200,8 +192,8 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateWindowDrawingContentInfo, Test int32_t pid = 65535; sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); } /** @@ -214,11 +206,11 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateCameraWindowStatus, TestSize.L sptr windowMangerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_WINDOW; int32_t pid = 65535; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowMangerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowMangerAgent, type, pid)); SessionManagerAgentController::GetInstance().UpdateCameraWindowStatus(0, false); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowMangerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowMangerAgent, type, pid)); } /** @@ -231,13 +223,12 @@ HWTEST_F(SessionManagerAgentControllerTest, NotifyWindowStyleChange, TestSize.Le int32_t pid = 65535; sptr windowManagerAgent = sptr::MakeSptr(); WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_STYLE; - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent(windowManagerAgent, type, pid)); SessionManagerAgentController::GetInstance().NotifyWindowStyleChange(Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT); - ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent( - windowManagerAgent, type, pid)); + ASSERT_EQ(WMError::WM_OK, + SessionManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type, pid)); } } // namespace Rosen } // namespace OHOS - diff --git a/window_scene/test/unittest/session_manager_lite_test.cpp b/window_scene/test/unittest/session_manager_lite_test.cpp index 28affdec60..59d29b6003 100644 --- a/window_scene/test/unittest/session_manager_lite_test.cpp +++ b/window_scene/test/unittest/session_manager_lite_test.cpp @@ -35,17 +35,14 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::shared_ptr sml_; }; -void SessionManagerLiteTest::SetUpTestCase() -{ -} +void SessionManagerLiteTest::SetUpTestCase() {} -void SessionManagerLiteTest::TearDownTestCase() -{ -} +void SessionManagerLiteTest::TearDownTestCase() {} void SessionManagerLiteTest::SetUp() { @@ -183,6 +180,6 @@ HWTEST_F(SessionManagerLiteTest, InitMockSMSProxy, TestSize.Level1) sml_->InitMockSMSProxy(); ASSERT_NE(sml_->foundationDeath_, nullptr); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_manager_lite_ut_test.cpp b/window_scene/test/unittest/session_manager_lite_ut_test.cpp index 08494c4025..59e91505ff 100644 --- a/window_scene/test/unittest/session_manager_lite_ut_test.cpp +++ b/window_scene/test/unittest/session_manager_lite_ut_test.cpp @@ -35,17 +35,14 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::shared_ptr sml_; }; -void SessionManagerLiteUTTest::SetUpTestCase() -{ -} +void SessionManagerLiteUTTest::SetUpTestCase() {} -void SessionManagerLiteUTTest::TearDownTestCase() -{ -} +void SessionManagerLiteUTTest::TearDownTestCase() {} void SessionManagerLiteUTTest::SetUp() { @@ -361,6 +358,6 @@ HWTEST_F(SessionManagerLiteUTTest, InitMockSMSProxy, TestSize.Level1) sml_->InitMockSMSProxy(); ASSERT_NE(sml_->foundationDeath_, nullptr); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_manager_service_recover_proxy_test.cpp b/window_scene/test/unittest/session_manager_service_recover_proxy_test.cpp index 8f1445e4d9..b71664ec3b 100644 --- a/window_scene/test/unittest/session_manager_service_recover_proxy_test.cpp +++ b/window_scene/test/unittest/session_manager_service_recover_proxy_test.cpp @@ -18,11 +18,9 @@ #include "mock_message_parcel.h" #include "session_manager_service_recover_proxy.h" - using namespace testing; using namespace testing::ext; - namespace OHOS { namespace Rosen { class SessionManagerServiceRecoverProxyTest : public testing::Test { @@ -226,6 +224,6 @@ HWTEST_F(SessionManagerServiceRecoverProxyTest, OnWMSConnectionChanged07, TestSi ASSERT_NE(sessionManagerService, nullptr); sessionManagerServiceRecoverProxy_->OnWMSConnectionChanged(1, 1, true, sessionManagerService); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_manager_test.cpp b/window_scene/test/unittest/session_manager_test.cpp index 5eade5aee1..8bb1884138 100644 --- a/window_scene/test/unittest/session_manager_test.cpp +++ b/window_scene/test/unittest/session_manager_test.cpp @@ -37,17 +37,14 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::shared_ptr sm_; }; -void SessionManagerTest::SetUpTestCase() -{ -} +void SessionManagerTest::SetUpTestCase() {} -void SessionManagerTest::TearDownTestCase() -{ -} +void SessionManagerTest::TearDownTestCase() {} void SessionManagerTest::SetUp() { @@ -73,13 +70,14 @@ HWTEST_F(SessionManagerTest, OnRemoteRequest, TestSize.Level1) OHOS::MessageOption option; IPCObjectStub iPCObjectStub; - uint32_t code = static_cast(OHOS::Rosen::ISessionManagerServiceRecoverListener:: - SessionManagerServiceRecoverMessage::TRANS_ID_ON_SESSION_MANAGER_SERVICE_RECOVER); + uint32_t code = + static_cast(OHOS::Rosen::ISessionManagerServiceRecoverListener::SessionManagerServiceRecoverMessage:: + TRANS_ID_ON_SESSION_MANAGER_SERVICE_RECOVER); auto ret = iPCObjectStub.OnRemoteRequest(code, data, reply, option); ASSERT_NE(ret, 0); code = static_cast(OHOS::Rosen::ISessionManagerServiceRecoverListener:: - SessionManagerServiceRecoverMessage::TRANS_ID_ON_WMS_CONNECTION_CHANGED); + SessionManagerServiceRecoverMessage::TRANS_ID_ON_WMS_CONNECTION_CHANGED); ret = iPCObjectStub.OnRemoteRequest(code, data, reply, option); ASSERT_NE(ret, 0); @@ -162,6 +160,6 @@ HWTEST_F(SessionManagerTest, RegisterWindowManagerRecoverCallbackFunc, TestSize. sm_->RegisterWindowManagerRecoverCallbackFunc(testFunc); ASSERT_NE(sm_->windowManagerRecoverFunc_, nullptr); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_manager_ut_test.cpp b/window_scene/test/unittest/session_manager_ut_test.cpp index 28f64c02b2..f6b7c123db 100644 --- a/window_scene/test/unittest/session_manager_ut_test.cpp +++ b/window_scene/test/unittest/session_manager_ut_test.cpp @@ -37,17 +37,14 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::shared_ptr sm_; }; -void SessionManagerUTTest::SetUpTestCase() -{ -} +void SessionManagerUTTest::SetUpTestCase() {} -void SessionManagerUTTest::TearDownTestCase() -{ -} +void SessionManagerUTTest::TearDownTestCase() {} void SessionManagerUTTest::SetUp() { @@ -73,13 +70,14 @@ HWTEST_F(SessionManagerUTTest, OnRemoteRequest, TestSize.Level1) OHOS::MessageOption option; IPCObjectStub iPCObjectStub; - uint32_t code = static_cast(OHOS::Rosen::ISessionManagerServiceRecoverListener:: - SessionManagerServiceRecoverMessage::TRANS_ID_ON_SESSION_MANAGER_SERVICE_RECOVER); + uint32_t code = + static_cast(OHOS::Rosen::ISessionManagerServiceRecoverListener::SessionManagerServiceRecoverMessage:: + TRANS_ID_ON_SESSION_MANAGER_SERVICE_RECOVER); auto ret = iPCObjectStub.OnRemoteRequest(code, data, reply, option); ASSERT_NE(ret, 0); code = static_cast(OHOS::Rosen::ISessionManagerServiceRecoverListener:: - SessionManagerServiceRecoverMessage::TRANS_ID_ON_WMS_CONNECTION_CHANGED); + SessionManagerServiceRecoverMessage::TRANS_ID_ON_WMS_CONNECTION_CHANGED); ret = iPCObjectStub.OnRemoteRequest(code, data, reply, option); ASSERT_NE(ret, 0); @@ -365,6 +363,6 @@ HWTEST_F(SessionManagerUTTest, RegisterWindowManagerRecoverCallbackFunc, TestSiz sm_->RegisterWindowManagerRecoverCallbackFunc(testFunc); ASSERT_NE(sm_->windowManagerRecoverFunc_, nullptr); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_permission_test.cpp b/window_scene/test/unittest/session_permission_test.cpp index 80161ad696..0c8f1fdb9f 100644 --- a/window_scene/test/unittest/session_permission_test.cpp +++ b/window_scene/test/unittest/session_permission_test.cpp @@ -33,21 +33,13 @@ public: void TearDown() override; }; -void SessionPermissionTest::SetUpTestCase() -{ -} +void SessionPermissionTest::SetUpTestCase() {} -void SessionPermissionTest::TearDownTestCase() -{ -} +void SessionPermissionTest::TearDownTestCase() {} -void SessionPermissionTest::SetUp() -{ -} +void SessionPermissionTest::SetUp() {} -void SessionPermissionTest::TearDown() -{ -} +void SessionPermissionTest::TearDown() {} namespace { /** @@ -80,7 +72,7 @@ HWTEST_F(SessionPermissionTest, IsSACalling, TestSize.Level1) */ HWTEST_F(SessionPermissionTest, VerifyCallingPermission, TestSize.Level1) { - const std::string *permissionNode = new string; + const std::string* permissionNode = new string; bool result = SessionPermission::VerifyCallingPermission(*permissionNode); ASSERT_EQ(false, result); } @@ -93,7 +85,7 @@ HWTEST_F(SessionPermissionTest, VerifyCallingPermission, TestSize.Level1) HWTEST_F(SessionPermissionTest, VerifyPermissionByCallerToken, TestSize.Level1) { const uint32_t callerToken = 1000; - const std::string *permissionNode = new string; + const std::string* permissionNode = new string; bool result = SessionPermission::VerifyPermissionByCallerToken(callerToken, *permissionNode); ASSERT_EQ(false, result); } @@ -105,11 +97,11 @@ HWTEST_F(SessionPermissionTest, VerifyPermissionByCallerToken, TestSize.Level1) */ HWTEST_F(SessionPermissionTest, IsSameBundleNameAsCalling, TestSize.Level1) { - const std::string *bundleName = new string; + const std::string* bundleName = new string; bool result = SessionPermission::IsSameBundleNameAsCalling(*bundleName); ASSERT_EQ(false, result); - const std::string *bundleName2 = new string("test"); + const std::string* bundleName2 = new string("test"); bool result2 = SessionPermission::IsSameBundleNameAsCalling(*bundleName2); ASSERT_EQ(false, result2); } @@ -208,6 +200,6 @@ HWTEST_F(SessionPermissionTest, IsFoundationCall, TestSize.Level1) ASSERT_EQ(false, result); } -} // namespacecd +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_proxy_immersive_test.cpp b/window_scene/test/unittest/session_proxy_immersive_test.cpp index e4e16b0b21..ab489add87 100644 --- a/window_scene/test/unittest/session_proxy_immersive_test.cpp +++ b/window_scene/test/unittest/session_proxy_immersive_test.cpp @@ -29,7 +29,7 @@ public: SessionProxyImmersiveTest() {} ~SessionProxyImmersiveTest() {} }; - + namespace { /** * @tc.name: GetAllAvoidAreasOnlyOne @@ -40,17 +40,16 @@ HWTEST_F(SessionProxyImmersiveTest, GetAllAvoidAreasOnlyOne, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyImmersiveTest::GetAllAvoidAreasOnlyOne start"; auto remoteObj = sptr::MakeSptr(); - EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)).WillOnce(Invoke( - [](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)) + .WillOnce(Invoke([](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { reply.WriteUint32(static_cast(1)); // avoidArea num reply.WriteUint32(static_cast(AvoidAreaType::TYPE_SYSTEM)); AvoidArea tmpArea; - tmpArea.topRect_ = {0, 0, 1200, 127}; + tmpArea.topRect_ = { 0, 0, 1200, 127 }; reply.WriteParcelable(&tmpArea); reply.WriteUint32(0); // error code return 0; - } - )); + })); auto sProxy = sptr::MakeSptr(remoteObj); std::map avoidAreas; @@ -96,13 +95,12 @@ HWTEST_F(SessionProxyImmersiveTest, GetAllAvoidAreasEmpty, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionProxyImmersiveTest::GetAllAvoidAreasEmpty start"; auto remoteObj = sptr::MakeSptr(); - EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)).WillOnce(Invoke( - [](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)) + .WillOnce(Invoke([](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { reply.WriteUint32(0); // avoidArea num reply.WriteUint32(0); // error code return 0; - } - )); + })); auto sProxy = sptr::MakeSptr(remoteObj); std::map avoidAreas; @@ -122,17 +120,16 @@ HWTEST_F(SessionProxyImmersiveTest, GetAllAvoidAreasWithInvalidAreaType, TestSiz { GTEST_LOG_(INFO) << "SessionProxyImmersiveTest::GetAllAvoidAreasWithInvalidAreaType start"; auto remoteObj = sptr::MakeSptr(); - EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)).WillOnce(Invoke( - [](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { - reply.WriteUint32(1); // avoidArea num + EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)) + .WillOnce(Invoke([](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + reply.WriteUint32(1); // avoidArea num reply.WriteUint32(1111); // invalid areaType AvoidArea tmpArea; - tmpArea.topRect_ = {0, 0, 1200, 127}; + tmpArea.topRect_ = { 0, 0, 1200, 127 }; reply.WriteParcelable(&tmpArea); reply.WriteUint32(0); // error code return 0; - } - )); + })); auto sProxy = sptr::MakeSptr(remoteObj); std::map avoidAreas; @@ -151,15 +148,14 @@ HWTEST_F(SessionProxyImmersiveTest, GetAllAvoidAreasWithInvalidArea, TestSize.Le { GTEST_LOG_(INFO) << "SessionProxyImmersiveTest::GetAllAvoidAreasWithInvalidArea start"; auto remoteObj = sptr::MakeSptr(); - EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)).WillOnce(Invoke( - [](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)) + .WillOnce(Invoke([](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { reply.WriteUint32(1); // avoidArea num reply.WriteUint32(static_cast(AvoidAreaType::TYPE_SYSTEM)); reply.WriteUint32(2234); // invalid area - reply.WriteUint32(0); // error code + reply.WriteUint32(0); // error code return 0; - } - )); + })); auto sProxy = sptr::MakeSptr(remoteObj); std::map avoidAreas; @@ -209,12 +205,11 @@ HWTEST_F(SessionProxyImmersiveTest, GetAvoidAreaByTypeWithAreaInvalid, TestSize. { GTEST_LOG_(INFO) << "SessionProxyImmersiveTest::GetAvoidAreaByTypeWithAreaInvalid start"; auto remoteObj = sptr::MakeSptr(); - EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)).WillOnce(Invoke( - [](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)) + .WillOnce(Invoke([](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { reply.WriteUint32(2234); // invalid area return 0; - } - )); + })); auto sProxy = sptr::MakeSptr(remoteObj); AvoidArea ret = sProxy->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM); @@ -231,14 +226,13 @@ HWTEST_F(SessionProxyImmersiveTest, GetAvoidAreaByTypeWithAreaNormal, TestSize.L { GTEST_LOG_(INFO) << "SessionProxyImmersiveTest::GetAvoidAreaByTypeWithAreaNormal start"; auto remoteObj = sptr::MakeSptr(); - EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)).WillOnce(Invoke( - [](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + EXPECT_CALL(*remoteObj, SendRequest(_, _, _, _)) + .WillOnce(Invoke([](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { AvoidArea tmpArea; - tmpArea.topRect_ = {0, 0, 1200, 127}; + tmpArea.topRect_ = { 0, 0, 1200, 127 }; reply.WriteParcelable(&tmpArea); return 0; - } - )); + })); auto sProxy = sptr::MakeSptr(remoteObj); AvoidArea ret = sProxy->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM); diff --git a/window_scene/test/unittest/session_proxy_lifecycle_test.cpp b/window_scene/test/unittest/session_proxy_lifecycle_test.cpp index 70bfd1d405..c8a05f9ac5 100644 --- a/window_scene/test/unittest/session_proxy_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_proxy_lifecycle_test.cpp @@ -191,6 +191,6 @@ HWTEST_F(SessionProxyLifecycleTest, NotifySessionException, TestSize.Level1) ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyLifecycleTest: NotifySessionException end"; } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_proxy_mock_test.cpp b/window_scene/test/unittest/session_proxy_mock_test.cpp index 396882878d..5683ba4098 100644 --- a/window_scene/test/unittest/session_proxy_mock_test.cpp +++ b/window_scene/test/unittest/session_proxy_mock_test.cpp @@ -25,10 +25,10 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionProxyMockTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionProxyMockTest" }; } class SessionProxyMockTest : public testing::Test { - public: +public: SessionProxyMockTest() {} ~SessionProxyMockTest() {} }; @@ -107,29 +107,34 @@ HWTEST_F(SessionProxyMockTest, UpdateSessionPropertyByAction, TestSize.Level1) sptr iRemoteObjectMocker = sptr::MakeSptr(); SessionProxy* sessionProxy = sptr::MakeSptr(iRemoteObjectMocker); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); - ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_ERROR_IPC_FAILED, + sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); sptr property = sptr::MakeSptr(); MockMessageParcel::SetWriteBoolErrorFlag(true); - ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_ERROR_IPC_FAILED, + sessionProxy->UpdateSessionPropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(false); - ASSERT_EQ(WMError::WM_OK, sessionProxy->UpdateSessionPropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_OK, + sessionProxy->UpdateSessionPropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(true); - ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_ERROR_IPC_FAILED, + sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(false); - ASSERT_EQ(WMError::WM_OK, sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_OK, + sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); } } // namespace diff --git a/window_scene/test/unittest/session_proxy_property_test.cpp b/window_scene/test/unittest/session_proxy_property_test.cpp index ca513cf7ff..5a82399a2f 100644 --- a/window_scene/test/unittest/session_proxy_property_test.cpp +++ b/window_scene/test/unittest/session_proxy_property_test.cpp @@ -45,8 +45,7 @@ HWTEST_F(SessionProxyPropertyTest, UpdateSessionPropertyByAction01, TestSize.Lev ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); - WMError res = sProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); + WMError res = sProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON); ASSERT_EQ(res, WMError::WM_OK); GTEST_LOG_(INFO) << "SessionProxyPropertyTest: UpdateSessionPropertyByAction01 end"; } @@ -63,8 +62,7 @@ HWTEST_F(SessionProxyPropertyTest, UpdateSessionPropertyByAction02, TestSize.Lev ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sProxy, nullptr); - WMError res = sProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); + WMError res = sProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON); ASSERT_EQ(res, WMError::WM_OK); GTEST_LOG_(INFO) << "SessionProxyPropertyTest: UpdateSessionPropertyByAction02 end"; } @@ -81,37 +79,43 @@ HWTEST_F(SessionProxyPropertyTest, UpdateSessionPropertyByAction, TestSize.Level auto sessionProxy = sptr::MakeSptr(iRemoteObjectMocker); ASSERT_NE(sessionProxy, nullptr); MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); - ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_ERROR_IPC_FAILED, + sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteUint32ErrorFlag(true); - ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_ERROR_IPC_FAILED, + sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); sptr property = sptr::MakeSptr(); ASSERT_NE(property, nullptr); MockMessageParcel::SetWriteBoolErrorFlag(true); - ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_ERROR_IPC_FAILED, + sessionProxy->UpdateSessionPropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(false); - ASSERT_EQ(WMError::WM_OK, sessionProxy->UpdateSessionPropertyByAction(property, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_OK, + sessionProxy->UpdateSessionPropertyByAction(property, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(true); - ASSERT_EQ(WMError::WM_ERROR_IPC_FAILED, sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_ERROR_IPC_FAILED, + sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); MockMessageParcel::SetWriteBoolErrorFlag(false); - ASSERT_EQ(WMError::WM_OK, sessionProxy->UpdateSessionPropertyByAction(nullptr, - WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); + ASSERT_EQ( + WMError::WM_OK, + sessionProxy->UpdateSessionPropertyByAction(nullptr, WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON)); MockMessageParcel::ClearAllErrorFlag(); } -} +} // namespace } // namespace Rosen -} // OHOS +} // namespace OHOS diff --git a/window_scene/test/unittest/session_proxy_test.cpp b/window_scene/test/unittest/session_proxy_test.cpp index b61907d517..c60fd9ccb1 100755 --- a/window_scene/test/unittest/session_proxy_test.cpp +++ b/window_scene/test/unittest/session_proxy_test.cpp @@ -28,7 +28,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { class SessionProxyTest : public testing::Test { - public: +public: SessionProxyTest() {} ~SessionProxyTest() {} }; @@ -60,7 +60,7 @@ HWTEST_F(SessionProxyTest, UpdateSessionRect, TestSize.Level1) GTEST_LOG_(INFO) << "SessionProxyTest: UpdateSessionRect start"; sptr iRemoteObjectMocker = sptr::MakeSptr(); sptr sProxy = sptr::MakeSptr(iRemoteObjectMocker); - WSRect rect{.posX_ = 1, .posY_ = 1, .width_ = 100, .height_ = 100}; + WSRect rect{ .posX_ = 1, .posY_ = 1, .width_ = 100, .height_ = 100 }; SizeChangeReason reason = SizeChangeReason::RECOVER; WSError res = sProxy->UpdateSessionRect(rect, reason); ASSERT_EQ(res, WSError::WS_OK); @@ -850,11 +850,9 @@ HWTEST_F(SessionProxyTest, NotifySupportWindowModesChange, TestSize.Level1) ASSERT_NE(iRemoteObjectMocker, nullptr); auto sProxy = sptr::MakeSptr(iRemoteObjectMocker); - std::vector supportedWindowModes = { - AppExecFwk::SupportWindowMode::FULLSCREEN, - AppExecFwk::SupportWindowMode::SPLIT, - AppExecFwk::SupportWindowMode::FLOATING - }; + std::vector supportedWindowModes = { AppExecFwk::SupportWindowMode::FULLSCREEN, + AppExecFwk::SupportWindowMode::SPLIT, + AppExecFwk::SupportWindowMode::FLOATING }; WSError res = sProxy->NotifySupportWindowModesChange(supportedWindowModes); ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "SessionProxyTest: NotifySupportWindowModesChange end"; diff --git a/window_scene/test/unittest/session_specific_window_test.cpp b/window_scene/test/unittest/session_specific_window_test.cpp index 1164e87ea9..384d765343 100644 --- a/window_scene/test/unittest/session_specific_window_test.cpp +++ b/window_scene/test/unittest/session_specific_window_test.cpp @@ -49,13 +49,9 @@ private: sptr mockEventChannel_ = nullptr; }; -void SessionSpecificWindowTest::SetUpTestCase() -{ -} +void SessionSpecificWindowTest::SetUpTestCase() {} -void SessionSpecificWindowTest::TearDownTestCase() -{ -} +void SessionSpecificWindowTest::TearDownTestCase() {} void SessionSpecificWindowTest::SetUp() { @@ -110,7 +106,6 @@ HWTEST_F(SessionSpecificWindowTest, BindDialogSessionTarget, TestSize.Level1) ASSERT_EQ(result, WSError::WS_OK); } - /** * @tc.name: AddSubSession * @tc.desc: AddSubSession Test @@ -170,9 +165,7 @@ HWTEST_F(SessionSpecificWindowTest, ClearSpecificSessionCbMap, TestSize.Level1) info.bundleName_ = "ClearSpecificSessionCbMap"; sptr sceneSession = sptr::MakeSptr(info, nullptr); auto result = false; - sceneSession->clearCallbackMapFunc_ = [&result](bool needRemove) { - result = needRemove; - }; + sceneSession->clearCallbackMapFunc_ = [&result](bool needRemove) { result = needRemove; }; sceneSession->ClearSpecificSessionCbMap(); usleep(WAIT_SYNC_IN_NS); ASSERT_EQ(result, true); @@ -675,6 +668,6 @@ HWTEST_F(SessionSpecificWindowTest, HandleSubWindowClick05, Function | SmallTest result = session->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_DOWN, true); EXPECT_EQ(result, WSError::WS_OK); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_stage_proxy_layout_test.cpp b/window_scene/test/unittest/session_stage_proxy_layout_test.cpp index 6e588d9e60..f5bbdac153 100644 --- a/window_scene/test/unittest/session_stage_proxy_layout_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_layout_test.cpp @@ -58,6 +58,6 @@ HWTEST_F(SessionStageProxyLayoutTest, NotifySingleHandTransformChange, TestSize. ASSERT_TRUE((sessionStage_ != nullptr)); GTEST_LOG_(INFO) << "SessionStageProxyLayoutTest: NotifySingleHandTransformChange end"; } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_proxy_lifecycle_test.cpp b/window_scene/test/unittest/session_stage_proxy_lifecycle_test.cpp index b792828c79..d9f44187ac 100644 --- a/window_scene/test/unittest/session_stage_proxy_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_lifecycle_test.cpp @@ -23,7 +23,6 @@ #include "window_manager_hilog.h" #include "wm_common.h" - using namespace testing; using namespace testing::ext; @@ -39,21 +38,13 @@ public: sptr sessionStage_ = sptr::MakeSptr(iRemoteObjectMocker); }; -void SessionStageProxyLifecycleTest::SetUpTestCase() -{ -} +void SessionStageProxyLifecycleTest::SetUpTestCase() {} -void SessionStageProxyLifecycleTest::TearDownTestCase() -{ -} +void SessionStageProxyLifecycleTest::TearDownTestCase() {} -void SessionStageProxyLifecycleTest::SetUp() -{ -} +void SessionStageProxyLifecycleTest::SetUp() {} -void SessionStageProxyLifecycleTest::TearDown() -{ -} +void SessionStageProxyLifecycleTest::TearDown() {} namespace { /** @@ -134,6 +125,6 @@ HWTEST_F(SessionStageProxyLifecycleTest, NotifyWindowVisibility, TestSize.Level1 ASSERT_TRUE((sessionStage_ != nullptr)); sessionStage_->NotifyWindowVisibility(true); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_proxy_test.cpp b/window_scene/test/unittest/session_stage_proxy_test.cpp index 9aac765013..28a396b943 100755 --- a/window_scene/test/unittest/session_stage_proxy_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_test.cpp @@ -24,7 +24,6 @@ #include "wm_common.h" #include "mock_message_parcel.h" - using namespace testing; using namespace testing::ext; @@ -40,21 +39,13 @@ public: sptr sessionStage_ = sptr::MakeSptr(iRemoteObjectMocker); }; -void SessionStageProxyTest::SetUpTestCase() -{ -} +void SessionStageProxyTest::SetUpTestCase() {} -void SessionStageProxyTest::TearDownTestCase() -{ -} +void SessionStageProxyTest::TearDownTestCase() {} -void SessionStageProxyTest::SetUp() -{ -} +void SessionStageProxyTest::SetUp() {} -void SessionStageProxyTest::TearDown() -{ -} +void SessionStageProxyTest::TearDown() {} namespace { /** @@ -103,7 +94,7 @@ HWTEST_F(SessionStageProxyTest, UpdateRect, TestSize.Level1) WSError res = sessionStage_->UpdateRect(rect, reason); ASSERT_EQ(WSError::WS_OK, res); std::shared_ptr rsTransaction = std::make_shared(); - SceneAnimationConfig config { .rsTransaction_ = rsTransaction }; + SceneAnimationConfig config{ .rsTransaction_ = rsTransaction }; res = sessionStage_->UpdateRect(rect, reason, config); ASSERT_EQ(WSError::WS_OK, res); } @@ -782,6 +773,6 @@ HWTEST_F(SessionStageProxyTest, NotifyWindowCrossAxisChange, Function | SmallTes sessionStage_->NotifyWindowCrossAxisChange(state); ASSERT_NE(nullptr, sessionStage_); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_stub_lifecycle_test.cpp b/window_scene/test/unittest/session_stage_stub_lifecycle_test.cpp index 00954f8943..475cb620d4 100644 --- a/window_scene/test/unittest/session_stage_stub_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_stage_stub_lifecycle_test.cpp @@ -32,7 +32,6 @@ #include "zidl/window_manager_agent_interface.h" #include "window_manager_hilog.h" - using namespace testing; using namespace testing::ext; @@ -47,21 +46,13 @@ public: sptr sessionStageStub_ = sptr::MakeSptr(); }; -void SessionStageStubLifecycleTest::SetUpTestCase() -{ -} +void SessionStageStubLifecycleTest::SetUpTestCase() {} -void SessionStageStubLifecycleTest::TearDownTestCase() -{ -} +void SessionStageStubLifecycleTest::TearDownTestCase() {} -void SessionStageStubLifecycleTest::SetUp() -{ -} +void SessionStageStubLifecycleTest::SetUp() {} -void SessionStageStubLifecycleTest::TearDown() -{ -} +void SessionStageStubLifecycleTest::TearDown() {} namespace { /** @@ -125,6 +116,6 @@ HWTEST_F(SessionStageStubLifecycleTest, HandleNotifySessionBackground, TestSize. ASSERT_TRUE((sessionStageStub_ != nullptr)); ASSERT_EQ(0, sessionStageStub_->HandleNotifySessionBackground(data, reply)); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_stub_test.cpp b/window_scene/test/unittest/session_stage_stub_test.cpp index def3c303c3..e44e1013ec 100644 --- a/window_scene/test/unittest/session_stage_stub_test.cpp +++ b/window_scene/test/unittest/session_stage_stub_test.cpp @@ -29,7 +29,6 @@ #include "ws_common.h" #include "zidl/window_manager_agent_interface.h" - using namespace testing; using namespace testing::ext; @@ -44,21 +43,13 @@ public: sptr sessionStageStub_ = sptr::MakeSptr(); }; -void SessionStageStubTest::SetUpTestCase() -{ -} +void SessionStageStubTest::SetUpTestCase() {} -void SessionStageStubTest::TearDownTestCase() -{ -} +void SessionStageStubTest::TearDownTestCase() {} -void SessionStageStubTest::SetUp() -{ -} +void SessionStageStubTest::SetUp() {} -void SessionStageStubTest::TearDown() -{ -} +void SessionStageStubTest::TearDown() {} namespace { /** @@ -275,7 +266,7 @@ HWTEST_F(SessionStageStubTest, HandleNotifyTransferComponentDataSync, TestSize.L uint32_t code = static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA_SYNC); ASSERT_TRUE((sessionStageStub_ != nullptr)); ASSERT_EQ(static_cast(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED), - sessionStageStub_->OnRemoteRequest(code, data, reply, option)); + sessionStageStub_->OnRemoteRequest(code, data, reply, option)); } /** @@ -935,7 +926,7 @@ HWTEST_F(SessionStageStubTest, HandleNotifyHighlightChange, TestSize.Level1) { MessageParcel data; MessageParcel reply; - + data.WriteBool(false); ASSERT_TRUE(sessionStageStub_ != nullptr); ASSERT_EQ(0, sessionStageStub_->HandleNotifyHighlightChange(data, reply)); @@ -952,7 +943,7 @@ HWTEST_F(SessionStageStubTest, HandleNotifyWindowCrossAxisChange, TestSize.Level MessageParcel data; MessageParcel reply; MessageOption option; - CrossAxisState state = CrossAxisState::STATE_CROSS; + CrossAxisState state = CrossAxisState::STATE_CROSS; uint32_t code = static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CROSS_AXIS); data.WriteInterfaceToken(SessionStageStub::GetDescriptor()); data.WriteUint32(static_cast(state)); @@ -1012,6 +1003,6 @@ HWTEST_F(SessionStageStubTest, HandleNotifyRotationProperty, Function | SmallTes EXPECT_TRUE(sessionStageStub_ != nullptr); EXPECT_EQ(0, sessionStageStub_->OnRemoteRequest(code, data, reply, option)); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stub_immersive_test.cpp b/window_scene/test/unittest/session_stub_immersive_test.cpp index 0b325f1d97..59daf4d262 100644 --- a/window_scene/test/unittest/session_stub_immersive_test.cpp +++ b/window_scene/test/unittest/session_stub_immersive_test.cpp @@ -43,11 +43,10 @@ void SessionStubImmersiveTest::SetUp() session_ = sptr::MakeSptr(); EXPECT_NE(nullptr, session_); - EXPECT_CALL(*session_, OnRemoteRequest(_, _, _, _)).WillOnce(Invoke( - [&](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + EXPECT_CALL(*session_, OnRemoteRequest(_, _, _, _)) + .WillOnce(Invoke([&](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { return session_->SessionStub::OnRemoteRequest(code, data, reply, option); - } - )); + })); } void SessionStubImmersiveTest::TearDown() @@ -67,7 +66,7 @@ HWTEST_F(SessionStubImmersiveTest, HandleGetAvoidAreaByTypeWithInvalidType, Test GTEST_LOG_(INFO) << "SessionStubImmersiveTest::HandleGetAvoidAreaByTypeWithInvalidType start"; MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteInterfaceToken(u"OHOS.ISession"); data.WriteUint32(1111); // invalid type uint32_t code = static_cast(SessionInterfaceCode::TRANS_ID_GET_AVOID_AREA); @@ -91,10 +90,10 @@ HWTEST_F(SessionStubImmersiveTest, HandleGetAvoidAreaByTypeWithSystemType, TestS MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteInterfaceToken(u"OHOS.ISession"); data.WriteUint32(static_cast(AvoidAreaType::TYPE_SYSTEM)); - WSRect rect = {0, 0, 1200, 127}; + WSRect rect = { 0, 0, 1200, 127 }; data.WriteInt32(rect.posX_); data.WriteInt32(rect.posY_); data.WriteInt32(rect.width_); @@ -118,8 +117,8 @@ HWTEST_F(SessionStubImmersiveTest, HandleGetAvoidAreaByTypeWithSystemType, TestS HWTEST_F(SessionStubImmersiveTest, HandleGetAllAvoidAreasNormal, TestSize.Level1) { GTEST_LOG_(INFO) << "SessionStubImmersiveTest::HandleGetAllAvoidAreasNormal start"; - EXPECT_CALL(*session_, GetAllAvoidAreas(_)).WillOnce(Invoke( - [](std::map& avoidAreas) -> WSError { + EXPECT_CALL(*session_, GetAllAvoidAreas(_)) + .WillOnce(Invoke([](std::map& avoidAreas) -> WSError { AvoidArea mockArea; mockArea.topRect_.width_ = 1200; mockArea.topRect_.height_ = 127; @@ -130,12 +129,11 @@ HWTEST_F(SessionStubImmersiveTest, HandleGetAllAvoidAreasNormal, TestSize.Level1 indArea.bottomRect_.height_ = 10; avoidAreas[AvoidAreaType::TYPE_NAVIGATION_INDICATOR] = indArea; return WSError::WS_OK; - } - )); + })); MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteInterfaceToken(u"OHOS.ISession"); data.WriteUint32(static_cast(AvoidAreaType::TYPE_SYSTEM)); uint32_t code = static_cast(SessionInterfaceCode::TRANS_ID_GET_ALL_AVOID_AREAS); @@ -148,8 +146,8 @@ HWTEST_F(SessionStubImmersiveTest, HandleGetAllAvoidAreasNormal, TestSize.Level1 for (uint32_t i = 0; i < 2; i++) { uint32_t type = reply.ReadUint32(); ASSERT_TRUE((static_cast(type) == AvoidAreaType::TYPE_SYSTEM) || - (static_cast(type) == AvoidAreaType::TYPE_NAVIGATION_INDICATOR)); - + (static_cast(type) == AvoidAreaType::TYPE_NAVIGATION_INDICATOR)); + sptr area = reply.ReadParcelable(); ASSERT_TRUE(area != nullptr); } @@ -170,7 +168,7 @@ HWTEST_F(SessionStubImmersiveTest, HandleGetAllAvoidAreasEmpty, TestSize.Level1) MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteInterfaceToken(u"OHOS.ISession"); data.WriteUint32(static_cast(AvoidAreaType::TYPE_SYSTEM)); uint32_t code = static_cast(SessionInterfaceCode::TRANS_ID_GET_ALL_AVOID_AREAS); @@ -184,6 +182,6 @@ HWTEST_F(SessionStubImmersiveTest, HandleGetAllAvoidAreasEmpty, TestSize.Level1) ASSERT_EQ(errCode, 0); GTEST_LOG_(INFO) << "SessionStubImmersiveTest::HandleGetAllAvoidAreasEmpty end"; } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_stub_layout_test.cpp b/window_scene/test/unittest/session_stub_layout_test.cpp index be34c24936..675acf37eb 100644 --- a/window_scene/test/unittest/session_stub_layout_test.cpp +++ b/window_scene/test/unittest/session_stub_layout_test.cpp @@ -49,13 +49,9 @@ private: sptr session_ = nullptr; }; -void SessionStubLayoutTest::SetUpTestCase() -{ -} +void SessionStubLayoutTest::SetUpTestCase() {} -void SessionStubLayoutTest::TearDownTestCase() -{ -} +void SessionStubLayoutTest::TearDownTestCase() {} void SessionStubLayoutTest::SetUp() { @@ -140,6 +136,6 @@ HWTEST_F(SessionStubLayoutTest, HandleSetSystemEnableDrag_TestReadBool, TestSize res = session_->HandleSetSystemEnableDrag(data, reply); ASSERT_EQ(ERR_NONE, res); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stub_lifecycle_test.cpp b/window_scene/test/unittest/session_stub_lifecycle_test.cpp index e514fe2e0f..9eec5564e4 100644 --- a/window_scene/test/unittest/session_stub_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_stub_lifecycle_test.cpp @@ -38,16 +38,12 @@ public: void TearDown() override; private: - sptr session_ = nullptr; + sptr session_ = nullptr; }; -void SessionStubLifecycleTest::SetUpTestCase() -{ -} +void SessionStubLifecycleTest::SetUpTestCase() {} -void SessionStubLifecycleTest::TearDownTestCase() -{ -} +void SessionStubLifecycleTest::TearDownTestCase() {} void SessionStubLifecycleTest::SetUp() { @@ -125,6 +121,6 @@ HWTEST_F(SessionStubLifecycleTest, HandlePendingSessionActivation011, TestSize.L auto res = session_->HandlePendingSessionActivation(data, reply); ASSERT_EQ(5, res); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stub_mock_test.cpp b/window_scene/test/unittest/session_stub_mock_test.cpp index 509ba6b0d6..d8387823bd 100644 --- a/window_scene/test/unittest/session_stub_mock_test.cpp +++ b/window_scene/test/unittest/session_stub_mock_test.cpp @@ -26,7 +26,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStubMockTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStubMockTest" }; } namespace OHOS::Accessibility { @@ -43,13 +43,9 @@ private: sptr session_ = nullptr; }; -void SessionStubMockTest::SetUpTestCase() -{ -} +void SessionStubMockTest::SetUpTestCase() {} -void SessionStubMockTest::TearDownTestCase() -{ -} +void SessionStubMockTest::TearDownTestCase() {} void SessionStubMockTest::SetUp() { @@ -108,6 +104,6 @@ HWTEST_F(SessionStubMockTest, HandleTransferAccessibilityEvent01, TestSize.Level ASSERT_EQ(ERR_INVALID_DATA, session_->HandleTransferAccessibilityEvent(data, reply)); WLOGI("HandleTransferAccessibilityEvent01 end"); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stub_property_test.cpp b/window_scene/test/unittest/session_stub_property_test.cpp index 45aef891dd..4ac666ff71 100644 --- a/window_scene/test/unittest/session_stub_property_test.cpp +++ b/window_scene/test/unittest/session_stub_property_test.cpp @@ -42,11 +42,10 @@ void SessionStubPropertyTest::SetUp() session_ = sptr::MakeSptr(); EXPECT_NE(nullptr, session_); - EXPECT_CALL(*session_, OnRemoteRequest(_, _, _, _)).WillOnce(Invoke( - [&](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { + EXPECT_CALL(*session_, OnRemoteRequest(_, _, _, _)) + .WillOnce(Invoke([&](uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) -> int { return session_->SessionStub::OnRemoteRequest(code, data, reply, option); - } - )); + })); } void SessionStubPropertyTest::TearDown() @@ -68,7 +67,7 @@ HWTEST_F(SessionStubPropertyTest, HandleUpdatePropertyByAction01, TestSize.Level MessageParcel data; MessageParcel reply; - MessageOption option{MessageOption::TF_SYNC}; + MessageOption option{ MessageOption::TF_SYNC }; data.WriteInterfaceToken(u"OHOS.ISession"); data.WriteUint64(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST)); uint32_t code = static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_PROPERTY); @@ -89,7 +88,7 @@ HWTEST_F(SessionStubPropertyTest, HandleUpdatePropertyByAction02, TestSize.Level MessageParcel data; MessageParcel reply; - MessageOption option{MessageOption::TF_SYNC}; + MessageOption option{ MessageOption::TF_SYNC }; data.WriteInterfaceToken(u"OHOS.ISession"); const uint32_t invalidData = 0; data.WriteUint32(invalidData); @@ -111,13 +110,13 @@ HWTEST_F(SessionStubPropertyTest, HandleUpdatePropertyByAction03, TestSize.Level MessageParcel data; MessageParcel reply; - MessageOption option{MessageOption::TF_SYNC}; + MessageOption option{ MessageOption::TF_SYNC }; data.WriteInterfaceToken(u"OHOS.ISession"); uint32_t code = static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_PROPERTY); int ret = session_->OnRemoteRequest(code, data, reply, option); ASSERT_EQ(ERR_INVALID_DATA, ret); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 54d7ae2f41..0d58b4720d 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -50,13 +50,9 @@ private: sptr session_ = nullptr; }; -void SessionStubTest::SetUpTestCase() -{ -} +void SessionStubTest::SetUpTestCase() {} -void SessionStubTest::TearDownTestCase() -{ -} +void SessionStubTest::TearDownTestCase() {} void SessionStubTest::SetUp() { @@ -81,7 +77,7 @@ HWTEST_F(SessionStubTest, OnRemoteRequest01, TestSize.Level1) uint32_t code = 1; MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; auto res = session_->OnRemoteRequest(code, data, reply, option); ASSERT_EQ(ERR_NONE, res); data.WriteInterfaceToken(u"OHOS.ISession"); @@ -99,7 +95,7 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest01, TestSize.Level1) { MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteBool(true); auto res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG), data, reply, option); @@ -158,7 +154,7 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest02, TestSize.Level1) { MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteBool(true); auto res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG), data, reply, option); @@ -213,7 +209,7 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest03, TestSize.Level1) { MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteBool(true); sptr iRemoteObjectMocker = sptr::MakeSptr(); EXPECT_NE(data.WriteRemoteObject(iRemoteObjectMocker), false); @@ -222,11 +218,11 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest03, TestSize.Level1) EXPECT_NE(data.WriteString("HandleSessionException"), false); EXPECT_NE(data.WriteParcelable(&options), false); ASSERT_EQ(data.WriteUint64(2), true); - auto res = session_->ProcessRemoteRequest( - static_cast(SessionInterfaceCode::TRANS_ID_SHOW), data, reply, option); + auto res = + session_->ProcessRemoteRequest(static_cast(SessionInterfaceCode::TRANS_ID_SHOW), data, reply, option); ASSERT_EQ(ERR_INVALID_DATA, res); - res = session_->ProcessRemoteRequest( - static_cast(SessionInterfaceCode::TRANS_ID_HIDE), data, reply, option); + res = + session_->ProcessRemoteRequest(static_cast(SessionInterfaceCode::TRANS_ID_HIDE), data, reply, option); ASSERT_EQ(ERR_NONE, res); res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_DRAWING_COMPLETED), data, reply, option); @@ -263,7 +259,7 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest04, TestSize.Level1) { MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; ASSERT_EQ(data.WriteInt32(1), true); ASSERT_EQ(data.WriteInt32(2), true); auto res = session_->ProcessRemoteRequest( @@ -302,7 +298,7 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest05, TestSize.Level1) { MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; data.WriteBool(true); sptr iRemoteObjectMocker = sptr::MakeSptr(); EXPECT_NE(data.WriteRemoteObject(iRemoteObjectMocker), false); @@ -338,7 +334,7 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest06, TestSize.Level1) { MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; AAFwk::Want want; data.WriteParcelable(&want); data.WriteBool(true); @@ -374,7 +370,7 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest07, TestSize.Level1) { MessageParcel data; MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; + MessageOption option = { MessageOption::TF_SYNC }; ASSERT_EQ(data.WriteInt32(1), true); ASSERT_EQ(data.WriteInt32(1), true); ASSERT_EQ(data.WriteUint32(1), true); @@ -413,7 +409,9 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest07, TestSize.Level1) ASSERT_EQ(data.WriteBool(true), true); res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_SET_FOLLOW_PARENT_MULTI_SCREEN_POLICY), - data, reply, option); + data, + reply, + option); ASSERT_EQ(ERR_NONE, res); } @@ -973,7 +971,7 @@ HWTEST_F(SessionStubTest, HandleSetSessionLabelAndIcon03, TestSize.Level1) MessageParcel reply; std::string label = "demo label"; data.WriteString(label); - const uint32_t color[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}; + const uint32_t color[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; uint32_t len = sizeof(color) / sizeof(color[0]); Media::InitializationOptions opts; opts.size.width = 2; @@ -997,8 +995,8 @@ HWTEST_F(SessionStubTest, HandleGetCrossAxisState, TestSize.Level1) MessageParcel data; MessageParcel reply; sptr session = sptr::MakeSptr(); - EXPECT_CALL(*session, GetCrossAxisState(_)). - WillOnce(DoAll(SetArgReferee<0>(CrossAxisState::STATE_CROSS), Return(WSError::WS_OK))); + EXPECT_CALL(*session, GetCrossAxisState(_)) + .WillOnce(DoAll(SetArgReferee<0>(CrossAxisState::STATE_CROSS), Return(WSError::WS_OK))); session->HandleGetCrossAxisState(data, reply); uint32_t state = 0; reply.ReadUint32(state); @@ -1300,11 +1298,9 @@ HWTEST_F(SessionStubTest, HandleSetSupportedWindowModes, Function | SmallTest | { MessageParcel data; MessageParcel reply; - std::vector supportedWindowModes = { - AppExecFwk::SupportWindowMode::FULLSCREEN, - AppExecFwk::SupportWindowMode::SPLIT, - AppExecFwk::SupportWindowMode::FLOATING - }; + std::vector supportedWindowModes = { AppExecFwk::SupportWindowMode::FULLSCREEN, + AppExecFwk::SupportWindowMode::SPLIT, + AppExecFwk::SupportWindowMode::FLOATING }; auto result = session_->HandleSetSupportedWindowModes(data, reply); ASSERT_EQ(result, ERR_INVALID_DATA); data.WriteUint32(supportedWindowModes.size()); @@ -1366,6 +1362,6 @@ HWTEST_F(SessionStubTest, HandleTransferAccessibilityEvent, Function | SmallTest result = session_->HandleTransferAccessibilityEvent(data, reply); ASSERT_EQ(result, ERR_NONE); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 9f5766f7d7..d2d771c144 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -67,7 +67,9 @@ private: void OnExtensionDied() override {} void OnExtensionTimeout(int32_t errorCode) override {} void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, - int64_t uiExtensionIdLevel) override {} + int64_t uiExtensionIdLevel) override + { + } void OnDrawingCompleted() override {} void OnAppRemoveStartingWindow() override {} }; @@ -77,13 +79,9 @@ private: sptr mockEventChannel_ = nullptr; }; -void WindowSessionTest::SetUpTestCase() -{ -} +void WindowSessionTest::SetUpTestCase() {} -void WindowSessionTest::TearDownTestCase() -{ -} +void WindowSessionTest::TearDownTestCase() {} void WindowSessionTest::SetUp() { @@ -96,9 +94,7 @@ void WindowSessionTest::SetUp() EXPECT_NE(nullptr, session_); ssm_ = sptr::MakeSptr(); session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_); - auto isScreenLockedCallback = [this]() { - return ssm_->IsScreenLocked(); - }; + auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); mockSessionStage_ = sptr::MakeSptr(); @@ -174,8 +170,8 @@ HWTEST_F(WindowSessionTest, SetActive01, TestSize.Level1) SystemSessionConfig sessionConfig; sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); - ASSERT_EQ(WSError::WS_OK, session_->Connect(mockSessionStage, - mockEventChannel, surfaceNode, sessionConfig, property)); + ASSERT_EQ(WSError::WS_OK, + session_->Connect(mockSessionStage, mockEventChannel, surfaceNode, sessionConfig, property)); ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->SetActive(true)); ASSERT_EQ(false, session_->isActive_); @@ -246,25 +242,25 @@ HWTEST_F(WindowSessionTest, UpdateClientRectPosYAndDisplayId01, TestSize.Level1) session_->sessionInfo_.screenId_ = 0; EXPECT_EQ(session_->GetScreenId(), 0); session_->GetSessionProperty()->SetIsSystemKeyboard(false); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::EXPANDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - WSRect rect = {0, 0, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::EXPANDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + WSRect rect = { 0, 0, 0, 0 }; session_->UpdateClientRectPosYAndDisplayId(rect); EXPECT_EQ(rect.posY_, 0); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::KEYBOARD, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - rect = {0, 100, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::KEYBOARD, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + rect = { 0, 100, 0, 0 }; session_->UpdateClientRectPosYAndDisplayId(rect); EXPECT_EQ(rect.posY_, 100); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); const auto& [defaultDisplayRect, virtualDisplayRect, foldCreaseRect] = PcFoldScreenManager::GetInstance().GetDisplayRects(); - rect = {0, 1000, 100, 100}; + rect = { 0, 1000, 100, 100 }; session_->UpdateClientRectPosYAndDisplayId(rect); EXPECT_EQ(rect.posY_, 1000); - rect = {0, 2000, 100, 100}; + rect = { 0, 2000, 100, 100 }; auto rect2 = rect; session_->UpdateClientRectPosYAndDisplayId(rect); EXPECT_EQ(rect.posY_, rect2.posY_ - defaultDisplayRect.height_ - foldCreaseRect.height_); @@ -299,21 +295,21 @@ HWTEST_F(WindowSessionTest, ConnectInner, TestSize.Level1) property->SetIsNeedUpdateWindowMode(true); session_->SetScreenId(233); session_->SetSessionProperty(property); - auto res = session_->ConnectInner(mockSessionStage_, mockEventChannel_, - nullptr, sessionConfig, property, nullptr, 1, 1, ""); + auto res = session_->ConnectInner( + mockSessionStage_, mockEventChannel_, nullptr, sessionConfig, property, nullptr, 1, 1, ""); ASSERT_EQ(res, WSError::WS_ERROR_INVALID_SESSION); session_->isTerminating_ = true; - auto res2 = session_->ConnectInner(mockSessionStage_, mockEventChannel_, - nullptr, sessionConfig, property, nullptr, 1, 1, ""); + auto res2 = session_->ConnectInner( + mockSessionStage_, mockEventChannel_, nullptr, sessionConfig, property, nullptr, 1, 1, ""); ASSERT_EQ(res2, WSError::WS_OK); property->SetWindowType(WindowType::APP_MAIN_WINDOW_END); property->SetIsNeedUpdateWindowMode(true); session_->SetScreenId(SCREEN_ID_INVALID); session_->SetSessionProperty(property); - auto res3 = session_->ConnectInner(mockSessionStage_, mockEventChannel_, - nullptr, sessionConfig, property, nullptr, 1, 1, ""); + auto res3 = session_->ConnectInner( + mockSessionStage_, mockEventChannel_, nullptr, sessionConfig, property, nullptr, 1, 1, ""); ASSERT_EQ(res3, WSError::WS_OK); ASSERT_EQ(false, session_->GetSessionProperty()->GetIsNeedUpdateWindowMode()); } @@ -333,7 +329,7 @@ HWTEST_F(WindowSessionTest, LifeCycleTask, TestSize.Level1) session_->PostLifeCycleTask(task2, "task2", LifeCycleTaskType::START); ASSERT_EQ(session_->lifeCycleTaskQueue_.size(), 2); - LifeCycleTaskType taskType = LifeCycleTaskType{0}; + LifeCycleTaskType taskType = LifeCycleTaskType{ 0 }; session_->RemoveLifeCycleTask(taskType); ASSERT_EQ(session_->lifeCycleTaskQueue_.size(), 1); @@ -365,7 +361,7 @@ HWTEST_F(WindowSessionTest, SetSessionProperty01, TestSize.Level1) HWTEST_F(WindowSessionTest, SetSessionRect, TestSize.Level1) { ASSERT_NE(session_, nullptr); - WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240 + WSRect rect = { 0, 0, 320, 240 }; // width: 320, height: 240 session_->SetSessionRect(rect); ASSERT_EQ(rect, session_->winRect_); } @@ -378,7 +374,7 @@ HWTEST_F(WindowSessionTest, SetSessionRect, TestSize.Level1) HWTEST_F(WindowSessionTest, GetSessionRect, TestSize.Level1) { ASSERT_NE(session_, nullptr); - WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240 + WSRect rect = { 0, 0, 320, 240 }; // width: 320, height: 240 session_->SetSessionRect(rect); ASSERT_EQ(rect, session_->GetSessionRect()); } @@ -408,7 +404,7 @@ HWTEST_F(WindowSessionTest, GetGlobalScaledRect, TestSize.Level1) SessionInfo info; sptr sceneSession = sptr::MakeSptr(info, nullptr); Rect globalScaledRect; - sceneSession->globalRect_ = {100, 100, 50, 40}; + sceneSession->globalRect_ = { 100, 100, 50, 40 }; sceneSession->isScbCoreEnabled_ = true; sceneSession->scaleX_ = 0.5f; sceneSession->scaleY_ = 0.5f; @@ -473,8 +469,9 @@ HWTEST_F(WindowSessionTest, OnSessionEvent01, TestSize.Level1) ASSERT_EQ(result, WSError::WS_OK); int resultValue = 0; - NotifySessionEventFunc onSessionEvent_ = [&resultValue](int32_t eventId, SessionEventParam param) - { resultValue = 1; }; + NotifySessionEventFunc onSessionEvent_ = [&resultValue](int32_t eventId, SessionEventParam param) { + resultValue = 1; + }; sceneSession->onSessionEvent_ = onSessionEvent_; result = sceneSession->OnSessionEvent(SessionEvent::EVENT_MINIMIZE); ASSERT_EQ(result, WSError::WS_OK); @@ -609,8 +606,8 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent01, TestSize.Level1) std::shared_ptr pointerEvent = nullptr; sptr property = nullptr; - auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, - sessionConfig); + auto result = + sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig); ASSERT_EQ(result, false); pointerEvent = MMI::PointerEvent::Create(); @@ -670,8 +667,8 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent02, TestSize.Level1) pointerItem.SetDisplayY(100); pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); - auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, - sessionConfig); + auto result = + sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig); ASSERT_EQ(result, true); sceneSession->moveDragController_->aspectRatio_ = 0.0f; @@ -733,8 +730,8 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent03, TestSize.Level1) // LEFT_TOP pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); - auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, - sessionConfig); + auto result = + sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig); ASSERT_EQ(result, true); // RIGHT_TOP @@ -794,8 +791,8 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent04, TestSize.Level1) // LEFT pointerItem.SetWindowX(0); pointerItem.SetWindowY(500); - auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, - sessionConfig); + auto result = + sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig); ASSERT_EQ(result, true); // TOP @@ -1326,7 +1323,7 @@ HWTEST_F(WindowSessionTest, CreateDetectStateTask002, TestSize.Level1) { session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_); - auto task = [](){}; + auto task = []() {}; int64_t delayTime = 3000; session_->handler_->PostTask(task, taskName, delayTime); int32_t beforeTaskNum = GetTaskCount(); @@ -1582,7 +1579,7 @@ HWTEST_F(WindowSessionTest, ProcessBackEvent, TestSize.Level1) */ HWTEST_F(WindowSessionTest, GetAndSetSessionRequestRect, TestSize.Level1) { - WSRect rect = {0, 0, 0, 0}; + WSRect rect = { 0, 0, 0, 0 }; session_->SetSessionRequestRect(rect); ASSERT_EQ(session_->GetSessionRequestRect(), rect); } @@ -1610,14 +1607,14 @@ HWTEST_F(WindowSessionTest, UpdateClientRectPosYAndDisplayId02, TestSize.Level1) session_->sessionInfo_.screenId_ = 0; EXPECT_EQ(session_->GetScreenId(), 0); session_->GetSessionProperty()->SetIsSystemKeyboard(false); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::UNKNOWN, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - WSRect rect = {0, 0, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::UNKNOWN, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + WSRect rect = { 0, 0, 0, 0 }; session_->UpdateClientRectPosYAndDisplayId(rect); EXPECT_EQ(rect.posY_, 0); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - rect = {0, 100, 0, 0}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + rect = { 0, 100, 0, 0 }; session_->UpdateClientRectPosYAndDisplayId(rect); EXPECT_EQ(rect.posY_, 100); } @@ -1633,9 +1630,9 @@ HWTEST_F(WindowSessionTest, UpdateClientRectPosYAndDisplayId03, TestSize.Level1) session_->sessionInfo_.screenId_ = 0; EXPECT_EQ(session_->GetScreenId(), 0); session_->GetSessionProperty()->SetIsSystemKeyboard(true); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); - WSRect rect = {0, 1000, 100, 100}; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1649, 2472, 40 }); + WSRect rect = { 0, 1000, 100, 100 }; session_->UpdateClientRectPosYAndDisplayId(rect); EXPECT_EQ(rect.posY_, 1000); } @@ -1655,7 +1652,7 @@ HWTEST_F(WindowSessionTest, SetExclusivelyHighlighted, TestSize.Level1) isExclusivelyHighlighted = session_->GetSessionProperty()->GetExclusivelyHighlighted(); ASSERT_EQ(isExclusivelyHighlighted, true); } - + /** * @tc.name: UpdateHighlightStatus * @tc.desc: UpdateHighlightStatus Test @@ -1665,12 +1662,12 @@ HWTEST_F(WindowSessionTest, UpdateHighlightStatus, TestSize.Level1) { ASSERT_NE(session_, nullptr); EXPECT_EQ(session_->UpdateHighlightStatus(false, false), WSError::WS_DO_NOTHING); - + EXPECT_EQ(session_->UpdateHighlightStatus(true, false), WSError::WS_OK); session_->isHighlighted_ = false; EXPECT_EQ(session_->UpdateHighlightStatus(true, true), WSError::WS_OK); } - + /** * @tc.name: NotifyHighlightChange * @tc.desc: NotifyHighlightChange Test @@ -1702,9 +1699,9 @@ HWTEST_F(WindowSessionTest, TransformRelativeRectToGlobalRect, TestSize.Level1) sessionInfo.bundleName_ = "bundleName"; sessionInfo.abilityName_ = "abilityName"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus(0, SuperFoldStatus::HALF_FOLDED, - { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); - WSRect rect { 0, 100, 100, 100 }; + PcFoldScreenManager::GetInstance().UpdateFoldScreenStatus( + 0, SuperFoldStatus::HALF_FOLDED, { 0, 0, 2472, 1648 }, { 0, 1648, 2472, 1648 }, { 0, 1624, 2472, 1648 }); + WSRect rect{ 0, 100, 100, 100 }; sceneSession->globalRect_ = { 0, 0, 2472, 1648 }; sceneSession->winRect_ = { 0, 0, 2472, 1648 }; sceneSession->TransformRelativeRectToGlobalRect(rect); @@ -1714,6 +1711,6 @@ HWTEST_F(WindowSessionTest, TransformRelativeRectToGlobalRect, TestSize.Level1) sceneSession->TransformRelativeRectToGlobalRect(rect); EXPECT_NE(rect.posY_, 100); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index 40edb0853a..1581f8b7b2 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -67,7 +67,9 @@ private: void OnExtensionDied() override {} void OnExtensionTimeout(int32_t errorCode) override {} void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, - int64_t uiExtensionIdLevel) override {} + int64_t uiExtensionIdLevel) override + { + } void OnDrawingCompleted() override {} void OnAppRemoveStartingWindow() override {} }; @@ -77,13 +79,9 @@ private: sptr mockEventChannel_ = nullptr; }; -void WindowSessionTest2::SetUpTestCase() -{ -} +void WindowSessionTest2::SetUpTestCase() {} -void WindowSessionTest2::TearDownTestCase() -{ -} +void WindowSessionTest2::TearDownTestCase() {} void WindowSessionTest2::SetUp() { @@ -96,9 +94,7 @@ void WindowSessionTest2::SetUp() EXPECT_NE(nullptr, session_); ssm_ = sptr::MakeSptr(); session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_); - auto isScreenLockedCallback = [this]() { - return ssm_->IsScreenLocked(); - }; + auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); mockSessionStage_ = sptr::MakeSptr(); @@ -561,9 +557,7 @@ HWTEST_F(WindowSessionTest2, SetSessionFocusableChangeListener, TestSize.Level1) { ASSERT_NE(session_, nullptr); - NotifySessionFocusableChangeFunc func = [](const bool isFocusable) - { - }; + NotifySessionFocusableChangeFunc func = [](const bool isFocusable) {}; session_->SetSessionFocusableChangeListener(func); session_->state_ = SessionState::STATE_DISCONNECT; @@ -579,9 +573,7 @@ HWTEST_F(WindowSessionTest2, SetSessionTouchableChangeListener, TestSize.Level1) { ASSERT_NE(session_, nullptr); - NotifySessionTouchableChangeFunc func = [](const bool touchable) - { - }; + NotifySessionTouchableChangeFunc func = [](const bool touchable) {}; session_->SetSessionTouchableChangeListener(func); session_->state_ = SessionState::STATE_DISCONNECT; @@ -597,9 +589,7 @@ HWTEST_F(WindowSessionTest2, SetSessionInfoLockedStateChangeListener, TestSize.L { ASSERT_NE(session_, nullptr); - NotifySessionTouchableChangeFunc func = [](const bool lockedState) - { - }; + NotifySessionTouchableChangeFunc func = [](const bool lockedState) {}; session_->SetSessionInfoLockedStateChangeListener(func); session_->SetSessionInfoLockedState(true); @@ -1163,10 +1153,8 @@ HWTEST_F(WindowSessionTest2, SetSessionState02, TestSize.Level1) HWTEST_F(WindowSessionTest2, SetChangeSessionVisibilityWithStatusBarEventListener, TestSize.Level1) { int resultValue = 0; - session_->SetChangeSessionVisibilityWithStatusBarEventListener([&resultValue]( - const SessionInfo& info, const bool visible) { - resultValue = 1; - }); + session_->SetChangeSessionVisibilityWithStatusBarEventListener( + [&resultValue](const SessionInfo& info, const bool visible) { resultValue = 1; }); usleep(WAIT_SYNC_IN_NS); ASSERT_NE(session_->changeSessionVisibilityWithStatusBarFunc_, nullptr); @@ -1174,10 +1162,8 @@ HWTEST_F(WindowSessionTest2, SetChangeSessionVisibilityWithStatusBarEventListene session_->changeSessionVisibilityWithStatusBarFunc_(info, true); ASSERT_EQ(resultValue, 1); - session_->SetChangeSessionVisibilityWithStatusBarEventListener([&resultValue]( - const SessionInfo& info, const bool visible) { - resultValue = 2; - }); + session_->SetChangeSessionVisibilityWithStatusBarEventListener( + [&resultValue](const SessionInfo& info, const bool visible) { resultValue = 2; }); usleep(WAIT_SYNC_IN_NS); ASSERT_NE(session_->changeSessionVisibilityWithStatusBarFunc_, nullptr); session_->changeSessionVisibilityWithStatusBarFunc_(info, true); @@ -1267,7 +1253,7 @@ HWTEST_F(WindowSessionTest2, GetRSVisible02, TestSize.Level1) HWTEST_F(WindowSessionTest2, SetVisibilityState, TestSize.Level1) { ASSERT_NE(session_, nullptr); - WindowVisibilityState state { WINDOW_VISIBILITY_STATE_NO_OCCLUSION}; + WindowVisibilityState state{ WINDOW_VISIBILITY_STATE_NO_OCCLUSION }; ASSERT_EQ(WSError::WS_OK, session_->SetVisibilityState(state)); ASSERT_EQ(state, session_->visibilityState_); } @@ -1280,7 +1266,7 @@ HWTEST_F(WindowSessionTest2, SetVisibilityState, TestSize.Level1) HWTEST_F(WindowSessionTest2, GetVisibilityState, TestSize.Level1) { ASSERT_NE(session_, nullptr); - WindowVisibilityState state { WINDOW_LAYER_STATE_MAX}; + WindowVisibilityState state{ WINDOW_LAYER_STATE_MAX }; ASSERT_EQ(state, session_->GetVisibilityState()); } @@ -1528,7 +1514,7 @@ HWTEST_F(WindowSessionTest2, SetContextTransparentFunc, TestSize.Level1) ASSERT_NE(session_, nullptr); session_->SetContextTransparentFunc(nullptr); ASSERT_EQ(session_->contextTransparentFunc_, nullptr); - NotifyContextTransparentFunc func = [](){}; + NotifyContextTransparentFunc func = []() {}; session_->SetContextTransparentFunc(func); ASSERT_NE(session_->contextTransparentFunc_, nullptr); } @@ -1543,7 +1529,7 @@ HWTEST_F(WindowSessionTest2, NeedCheckContextTransparent, TestSize.Level1) ASSERT_NE(session_, nullptr); session_->SetContextTransparentFunc(nullptr); ASSERT_EQ(session_->NeedCheckContextTransparent(), false); - NotifyContextTransparentFunc func = [](){}; + NotifyContextTransparentFunc func = []() {}; session_->SetContextTransparentFunc(func); ASSERT_EQ(session_->NeedCheckContextTransparent(), true); } @@ -1572,6 +1558,6 @@ HWTEST_F(WindowSessionTest2, SetBorderUnoccupied, TestSize.Level1) bool res = session_->GetBorderUnoccupied(); ASSERT_EQ(res, true); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 5fd7d1e668..ae5f6933e9 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -58,13 +58,9 @@ private: static constexpr uint32_t WAIT_SYNC_IN_NS = 500000; }; -void WindowSessionTest3::SetUpTestCase() -{ -} +void WindowSessionTest3::SetUpTestCase() {} -void WindowSessionTest3::TearDownTestCase() -{ -} +void WindowSessionTest3::TearDownTestCase() {} void WindowSessionTest3::SetUp() { @@ -77,9 +73,7 @@ void WindowSessionTest3::SetUp() session_->surfaceNode_ = CreateRSSurfaceNode(); ssm_ = sptr::MakeSptr(); session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_); - auto isScreenLockedCallback = [this]() { - return ssm_->IsScreenLocked(); - }; + auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); } @@ -536,9 +530,7 @@ HWTEST_F(WindowSessionTest3, SetBufferAvailableChangeListener, TestSize.Level1) session_->SetBufferAvailableChangeListener(nullptr); int resultValue = 0; - NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) { - resultValue += 1; - }; + NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) { resultValue += 1; }; session_->SetBufferAvailableChangeListener(func); ASSERT_EQ(resultValue, 1); } @@ -551,9 +543,7 @@ HWTEST_F(WindowSessionTest3, SetBufferAvailableChangeListener, TestSize.Level1) HWTEST_F(WindowSessionTest3, NotifySessionFocusableChange, TestSize.Level1) { int resultValue = 0; - NotifySessionFocusableChangeFunc func = [&resultValue](const bool isFocusable) { - resultValue += 1; - }; + NotifySessionFocusableChangeFunc func = [&resultValue](const bool isFocusable) { resultValue += 1; }; session_->SetSessionFocusableChangeListener(func); session_->NotifySessionFocusableChange(true); ASSERT_EQ(resultValue, 2); @@ -566,10 +556,8 @@ HWTEST_F(WindowSessionTest3, NotifySessionFocusableChange, TestSize.Level1) */ HWTEST_F(WindowSessionTest3, GetStateFromManager, TestSize.Level1) { - ManagerState key = ManagerState{0}; - GetStateFromManagerFunc func = [](const ManagerState key) { - return true; - }; + ManagerState key = ManagerState{ 0 }; + GetStateFromManagerFunc func = [](const ManagerState key) { return true; }; session_->getStateFromManagerFunc_ = func; session_->GetStateFromManager(key); @@ -577,7 +565,7 @@ HWTEST_F(WindowSessionTest3, GetStateFromManager, TestSize.Level1) ASSERT_EQ(false, session_->GetStateFromManager(key)); // 覆盖default分支 - key = ManagerState{-1}; + key = ManagerState{ -1 }; ASSERT_EQ(false, session_->GetStateFromManager(key)); } @@ -619,9 +607,7 @@ HWTEST_F(WindowSessionTest3, SetCompatibleModeInPc, TestSize.Level1) HWTEST_F(WindowSessionTest3, NotifySessionTouchableChange, TestSize.Level1) { int resultValue = 0; - NotifySessionTouchableChangeFunc func = [&resultValue](const bool touchable) { - resultValue += 1; - }; + NotifySessionTouchableChangeFunc func = [&resultValue](const bool touchable) { resultValue += 1; }; session_->SetSessionTouchableChangeListener(func); session_->NotifySessionTouchableChange(true); ASSERT_EQ(resultValue, 2); @@ -658,10 +644,10 @@ HWTEST_F(WindowSessionTest3, NotifyClick, TestSize.Level1) HWTEST_F(WindowSessionTest3, NotifyRequestFocusStatusNotifyManager, TestSize.Level1) { int resultValue = 0; - NotifyRequestFocusStatusNotifyManagerFunc func = [&resultValue](int32_t persistentId, - const bool isFocused, const bool byForeground, FocusChangeReason reason) { - resultValue += 1; - }; + NotifyRequestFocusStatusNotifyManagerFunc func = + [&resultValue](int32_t persistentId, const bool isFocused, const bool byForeground, FocusChangeReason reason) { + resultValue += 1; + }; session_->SetRequestFocusStatusNotifyManagerListener(func); FocusChangeReason reason = FocusChangeReason::SCB_SESSION_REQUEST; session_->NotifyRequestFocusStatusNotifyManager(true, false, reason); @@ -833,7 +819,7 @@ HWTEST_F(WindowSessionTest3, RectCheckProcess01, TestSize.Level1) ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(0, screenSession)); session_->RectCheckProcess(); - WSRect rect = {0, 0, 0, 0}; + WSRect rect = { 0, 0, 0, 0 }; session_->winRect_ = rect; session_->RectCheckProcess(); @@ -868,9 +854,7 @@ HWTEST_F(WindowSessionTest3, SetAcquireRotateAnimationConfigFunc, TestSize.Level int32_t duration = session_->GetRotateAnimationDuration(); ASSERT_EQ(duration, ROTATE_ANIMATION_DURATION); - AcquireRotateAnimationConfigFunc func = [](RotateAnimationConfig& config) { - config.duration_ = 800; - }; + AcquireRotateAnimationConfigFunc func = [](RotateAnimationConfig& config) { config.duration_ = 800; }; session_->SetAcquireRotateAnimationConfigFunc(func); ASSERT_NE(session_->acquireRotateAnimationConfigFunc_, nullptr); duration = session_->GetRotateAnimationDuration(); @@ -898,9 +882,7 @@ HWTEST_F(WindowSessionTest3, SetIsPcAppInPad, TestSize.Level1) HWTEST_F(WindowSessionTest3, SetBufferAvailable, TestSize.Level1) { int resultValue = 0; - NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) { - resultValue = 1; - }; + NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) { resultValue = 1; }; session_->SetBufferAvailableChangeListener(func); session_->SetBufferAvailable(true); ASSERT_EQ(session_->bufferAvailable_, true); @@ -914,9 +896,7 @@ HWTEST_F(WindowSessionTest3, SetBufferAvailable, TestSize.Level1) HWTEST_F(WindowSessionTest3, NotifySessionInfoChange, TestSize.Level1) { int resultValue = 0; - NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) { - resultValue = 1; - }; + NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) { resultValue = 1; }; session_->SetSessionInfoChangeNotifyManagerListener(func); session_->NotifySessionInfoChange(); ASSERT_EQ(resultValue, 1); @@ -1174,6 +1154,6 @@ HWTEST_F(WindowSessionTest3, GetIsHighlighted, Function | SmallTest | Level2) ASSERT_EQ(session_->GetIsHighlighted(isHighlighted), WSError::WS_OK); ASSERT_EQ(isHighlighted, false); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index f90a33fed9..bd5b3a649c 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -38,16 +38,19 @@ namespace OHOS { namespace Rosen { namespace { const std::string UNDEFINED = "undefined"; -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest4"}; -} +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest4" }; +} // namespace namespace { std::string g_logMsg; -void SessionTest4LogCallBack( - const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *msg) +void SessionTest4LogCallBack(const LogType type, + const LogLevel level, + const unsigned int domain, + const char* tag, + const char* msg) { g_logMsg = msg; } -} +} // namespace class WindowSessionTest4 : public testing::Test { public: static void SetUpTestCase(); @@ -63,13 +66,9 @@ private: static constexpr uint32_t waitSyncInNs_ = 500000; }; -void WindowSessionTest4::SetUpTestCase() -{ -} +void WindowSessionTest4::SetUpTestCase() {} -void WindowSessionTest4::TearDownTestCase() -{ -} +void WindowSessionTest4::TearDownTestCase() {} void WindowSessionTest4::SetUp() { @@ -82,9 +81,7 @@ void WindowSessionTest4::SetUp() EXPECT_NE(nullptr, session_); ssm_ = sptr::MakeSptr(); session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_); - auto isScreenLockedCallback = [this]() { - return ssm_->IsScreenLocked(); - }; + auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); } @@ -127,7 +124,7 @@ namespace { HWTEST_F(WindowSessionTest4, SetShowRecent001, TestSize.Level1) { std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_); - auto task = [](){}; + auto task = []() {}; int64_t delayTime = 3000; session_->handler_->PostTask(task, taskName, delayTime); int32_t beforeTaskNum = GetTaskCount(); @@ -145,7 +142,7 @@ HWTEST_F(WindowSessionTest4, SetShowRecent001, TestSize.Level1) HWTEST_F(WindowSessionTest4, SetShowRecent002, TestSize.Level1) { std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_); - auto task = [](){}; + auto task = []() {}; int64_t delayTime = 3000; session_->handler_->PostTask(task, taskName, delayTime); session_->showRecent_ = false; @@ -164,7 +161,7 @@ HWTEST_F(WindowSessionTest4, SetShowRecent002, TestSize.Level1) HWTEST_F(WindowSessionTest4, SetShowRecent003, TestSize.Level1) { std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_); - auto task = [](){}; + auto task = []() {}; int64_t delayTime = 3000; session_->handler_->PostTask(task, taskName, delayTime); session_->showRecent_ = true; @@ -228,7 +225,7 @@ HWTEST_F(WindowSessionTest4, CreateDetectStateTask002, TestSize.Level1) { session_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; std::string taskName = "wms:WindowStateDetect" + std::to_string(session_->persistentId_); - auto task = [](){}; + auto task = []() {}; int64_t delayTime = 3000; session_->handler_->PostTask(task, taskName, delayTime); int32_t beforeTaskNum = GetTaskCount(); @@ -341,7 +338,7 @@ HWTEST_F(WindowSessionTest4, PostExportTask02, TestSize.Level1) { ASSERT_NE(session_, nullptr); std::string name = "sessionExportTask"; - auto task = [](){}; + auto task = []() {}; int64_t delayTime = 0; session_->PostExportTask(task, name, delayTime); @@ -350,7 +347,7 @@ HWTEST_F(WindowSessionTest4, PostExportTask02, TestSize.Level1) sptr sceneSessionManager = sptr::MakeSptr(); session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(), - sceneSessionManager->eventHandler_); + sceneSessionManager->eventHandler_); session_->PostExportTask(task, name, delayTime); auto result2 = session_->GetBufferAvailable(); ASSERT_EQ(result2, false); @@ -507,7 +504,7 @@ HWTEST_F(WindowSessionTest4, UpdateDensity, TestSize.Level1) */ HWTEST_F(WindowSessionTest4, UpdateSizeChangeReason, TestSize.Level1) { - SizeChangeReason reason = SizeChangeReason{1}; + SizeChangeReason reason = SizeChangeReason{ 1 }; ASSERT_EQ(session_->UpdateSizeChangeReason(reason), WSError::WS_OK); } @@ -519,15 +516,11 @@ HWTEST_F(WindowSessionTest4, UpdateSizeChangeReason, TestSize.Level1) HWTEST_F(WindowSessionTest4, SetPendingSessionActivationEventListener, TestSize.Level1) { int resultValue = 0; - session_->SetPendingSessionActivationEventListener([&resultValue](const SessionInfo& info) { - resultValue = 1; - }); + session_->SetPendingSessionActivationEventListener([&resultValue](const SessionInfo& info) { resultValue = 1; }); usleep(waitSyncInNs_); - session_->SetTerminateSessionListener([&resultValue](const SessionInfo& info) { - resultValue = 2; - }); + session_->SetTerminateSessionListener([&resultValue](const SessionInfo& info) { resultValue = 2; }); usleep(waitSyncInNs_); - LifeCycleTaskType taskType = LifeCycleTaskType{0}; + LifeCycleTaskType taskType = LifeCycleTaskType{ 0 }; session_->RemoveLifeCycleTask(taskType); ASSERT_EQ(resultValue, 0); } @@ -568,8 +561,8 @@ HWTEST_F(WindowSessionTest4, SetSessionIcon, TestSize.Level1) HWTEST_F(WindowSessionTest4, SetSessionExceptionListener, TestSize.Level1) { session_->SetSessionExceptionListener(nullptr, true); - session_->SetSessionExceptionListener([](const SessionInfo& info, - const ExceptionInfo& exceptionInfo, bool startFail) {}, true); + session_->SetSessionExceptionListener( + [](const SessionInfo& info, const ExceptionInfo& exceptionInfo, bool startFail) {}, true); usleep(waitSyncInNs_); ASSERT_NE(nullptr, session_->jsSceneSessionExceptionFunc_); } @@ -615,7 +608,7 @@ HWTEST_F(WindowSessionTest4, NotifyCloseExistPipWindow, TestSize.Level1) { sptr mockSessionStage = sptr::MakeSptr(); ASSERT_NE(mockSessionStage, nullptr); - ManagerState key = ManagerState{0}; + ManagerState key = ManagerState{ 0 }; session_->GetStateFromManager(key); session_->NotifyUILostFocus(); @@ -636,7 +629,7 @@ HWTEST_F(WindowSessionTest4, NotifyCloseExistPipWindow, TestSize.Level1) * @tc.desc: SetUseStartingWindowAboveLocked Test * @tc.type: FUNC */ - HWTEST_F(WindowSessionTest4, SetUseStartingWindowAboveLocked, TestSize.Level1) +HWTEST_F(WindowSessionTest4, SetUseStartingWindowAboveLocked, TestSize.Level1) { ASSERT_NE(session_, nullptr); session_->useStartingWindowAboveLocked_ = false; @@ -710,9 +703,7 @@ HWTEST_F(WindowSessionTest4, SetBackPressedListenser, TestSize.Level1) { ASSERT_NE(session_, nullptr); int32_t result = 0; - session_->SetBackPressedListenser([&result](const bool needMoveToBackground) { - result = 1; - }); + session_->SetBackPressedListenser([&result](const bool needMoveToBackground) { result = 1; }); usleep(waitSyncInNs_); session_->backPressedFunc_(true); ASSERT_EQ(result, 1); @@ -745,7 +736,7 @@ HWTEST_F(WindowSessionTest4, NotifyContextTransparent, TestSize.Level1) NotifyContextTransparentFunc contextTransparentFunc = session_->contextTransparentFunc_; if (contextTransparentFunc == nullptr) { - contextTransparentFunc = [](){}; + contextTransparentFunc = []() {}; } session_->contextTransparentFunc_ = nullptr; session_->NotifyContextTransparent(); @@ -1100,30 +1091,30 @@ HWTEST_F(WindowSessionTest4, GetWindowMetaInfoForWindowInfo01, TestSize.Level1) } /** - * @tc.name: SafelyGetWant01 - * @tc.desc: SafelyGetWant Test + * @tc.name: GetWantSafely01 + * @tc.desc: GetWantSafely Test * @tc.type: FUNC */ -HWTEST_F(WindowSessionTest4, SafelyGetWant01, TestSize.Level1) +HWTEST_F(WindowSessionTest4, GetWantSafely01, TestSize.Level1) { SessionInfo sessionInfo; ASSERT_EQ(nullptr, sessionInfo.want); - EXPECT_EQ(sessionInfo.SafelyGetWant().GetBundle(), ""); + EXPECT_EQ(sessionInfo.GetWantSafely().GetBundle(), ""); } /** - * @tc.name: SafelySetWant01 - * @tc.desc: SafelySetWant Test + * @tc.name: SetWantSafely01 + * @tc.desc: SetWantSafely Test * @tc.type: FUNC */ -HWTEST_F(WindowSessionTest4, SafelySetWant01, TestSize.Level1) +HWTEST_F(WindowSessionTest4, SetWantSafely01, TestSize.Level1) { SessionInfo sessionInfo; AAFwk::Want wantObj; - wantObj.SetBundle("SafelySetWantTest"); - sessionInfo.SafelySetWant(wantObj); + wantObj.SetBundle("SetWantSafelyTest"); + sessionInfo.SetWantSafely(wantObj); ASSERT_NE(nullptr, sessionInfo.want); - EXPECT_EQ(sessionInfo.SafelyGetWant().GetBundle(), "SafelySetWantTest"); + EXPECT_EQ(sessionInfo.GetWantSafely().GetBundle(), "SetWantSafelyTest"); } /** @@ -1249,7 +1240,7 @@ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_Handler_NOT_NULL, TestSize.Leve sptr sceneSessionManager = sptr::MakeSptr(); session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(), - sceneSessionManager->eventHandler_); + sceneSessionManager->eventHandler_); EXPECT_TRUE(g_logMsg.find("not specific window") == std::string::npos); EXPECT_TRUE(g_logMsg.find("handler is null") == std::string::npos); } @@ -1277,7 +1268,7 @@ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_WindowAnimationDuration, TestSi session->PostSpecificSessionLifeCycleTimeoutTask(ATTACH_EVENT_NAME); sptr sceneSessionManager = sptr::MakeSptr(); session_->SetEventHandler(sceneSessionManager->taskScheduler_->GetEventHandler(), - sceneSessionManager->eventHandler_); + sceneSessionManager->eventHandler_); EXPECT_TRUE(g_logMsg.find("handler is null") == std::string::npos); session->SetWindowAnimationDuration(true); @@ -1286,6 +1277,6 @@ HWTEST_F(WindowSessionTest4, ReportWindowTimeout_WindowAnimationDuration, TestSi session->SetWindowAnimationDuration(false); EXPECT_TRUE(g_logMsg.find("window configured animation") == std::string::npos); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/ssmgr_specific_window_test.cpp b/window_scene/test/unittest/ssmgr_specific_window_test.cpp index bd52bf1363..cd4ccb6108 100644 --- a/window_scene/test/unittest/ssmgr_specific_window_test.cpp +++ b/window_scene/test/unittest/ssmgr_specific_window_test.cpp @@ -62,7 +62,7 @@ ConfigItem ReadConfig(const std::string& xmlStr) xmlFreeDoc(docPtr); return config; } -} +} // namespace class SSMgrSpecificWindowTest : public testing::Test { public: @@ -75,6 +75,7 @@ public: void TearDown() override; static sptr ssm_; + private: }; @@ -90,9 +91,7 @@ void SSMgrSpecificWindowTest::TearDownTestCase() ssm_ = nullptr; } -void SSMgrSpecificWindowTest::SetUp() -{ -} +void SSMgrSpecificWindowTest::SetUp() {} void SSMgrSpecificWindowTest::TearDown() { @@ -107,42 +106,44 @@ namespace { */ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "abv" - "0.2 0.0 0.2 1.0" - "" - "" - "" - "" - "abv" - "0.2 0.0 0.2 1.0" - "" - "" - "" + "" + "" + "" + "abv" + "0.2 0.0 0.2 1.0" + "" + "" + "" + "" + "abv" + "0.2 0.0 0.2 1.0" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - std::string xmlStr1 = "" + std::string xmlStr1 = + "" "" - "" - "" - "" - "500" - "0.2 0.0 0.2 1.0" - "" - "" - "" - "" - "300" - "0.2 0.0 0.2 1.0" - "" - "" - "" + "" + "" + "" + "500" + "0.2 0.0 0.2 1.0" + "" + "" + "" + "" + "300" + "0.2 0.0 0.2 1.0" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr1); ssm_->ConfigWindowSceneXml(); @@ -157,21 +158,22 @@ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation01, TestSize.Level1) */ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "500" - "600" - "" - "" - "" - "" - "300" - "" - "" - "" + "" + "" + "" + "500" + "600" + "" + "" + "" + "" + "300" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -185,21 +187,22 @@ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation02, TestSize.Level1) */ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "500" - "" - "" - "" - "" - "300" - "400" - "" - "" - "" + "" + "" + "" + "500" + "" + "" + "" + "" + "300" + "400" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -213,15 +216,16 @@ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation03, TestSize.Level1) */ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" - "" - "" - "" - "500" - "" - "" - "" + "" + "" + "" + "500" + "" + "" + "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); @@ -246,7 +250,7 @@ HWTEST_F(SSMgrSpecificWindowTest, IsKeyboardForeground, TestSize.Level1) auto result = ssm_->IsKeyboardForeground(); ASSERT_EQ(result, false); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); session->property_ = sptr::MakeSptr(); ASSERT_NE(session->property_, nullptr); @@ -391,7 +395,7 @@ HWTEST_F(SSMgrSpecificWindowTest, DestroyDialogWithMainWindow, TestSize.Level1) result = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(result, WSError::WS_OK); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); ssm_->GetSceneSession(1); result = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(result, WSError::WS_OK); @@ -420,8 +424,8 @@ HWTEST_F(SSMgrSpecificWindowTest, DestroyDialogWithMainWindow02, TestSize.Level1 ASSERT_NE(ssm_, nullptr); ssm_->sceneSessionMap_.clear(); - ssm_->sceneSessionMap_.insert({0, nullptr}); - ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->sceneSessionMap_.insert({ 0, nullptr }); + ssm_->sceneSessionMap_.insert({ 0, sceneSession }); auto ret = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); @@ -442,21 +446,21 @@ HWTEST_F(SSMgrSpecificWindowTest, ConfigKeyboardAnimation, TestSize.Level1) WindowSceneConfig::ConfigItem nameProp; std::string name = "cubic"; nameProp.SetValue(name); - itemCurve.SetProperty({{ "name", nameProp}}); + itemCurve.SetProperty({ { "name", nameProp } }); // prepare duration - std::vector durationVec = {39}; + std::vector durationVec = { 39 }; itemDuration.SetValue(durationVec); // prepare timing WindowSceneConfig::ConfigItem timing; WindowSceneConfig::ConfigItem timingObj; - timingObj.SetValue({{ "curve", itemCurve }, { "duration", itemDuration}}); - timing.SetValue({{ "timing", timingObj }}); + timingObj.SetValue({ { "curve", itemCurve }, { "duration", itemDuration } }); + timing.SetValue({ { "timing", timingObj } }); WindowSceneConfig::ConfigItem timing2(timing); // prepare animationConfig - animationConfig.SetValue({{ "animationIn", timing }, { "animationOut", timing2 }}); + animationConfig.SetValue({ { "animationIn", timing }, { "animationOut", timing2 } }); ssm_->ConfigKeyboardAnimation(animationConfig); ASSERT_EQ(ssm_->systemConfig_.animationIn_.curveType_, "cubic"); @@ -503,7 +507,7 @@ HWTEST_F(SSMgrSpecificWindowTest, UpdateParentSessionForDialog, TestSize.Level1) info1.bundleName_ = "test3"; sptr sceneSession2 = sptr::MakeSptr(info1, nullptr); ASSERT_NE(nullptr, sceneSession2); - ssm_->sceneSessionMap_.insert({2, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 2, sceneSession2 }); property->SetParentPersistentId(2); result = ssm_->UpdateParentSessionForDialog(sceneSession, property); EXPECT_EQ(result, WSError::WS_OK); @@ -526,14 +530,12 @@ HWTEST_F(SSMgrSpecificWindowTest, DestroyAndDisconnectSpecificSession, TestSize. * @tc.desc: SceneSesionManager destroy and disconnect specific session with detach callback * @tc.type: FUNC */ -HWTEST_F(SSMgrSpecificWindowTest, - DestroyAndDisconnectSpecificSessionWithDetachCallback, - TestSize.Level1) +HWTEST_F(SSMgrSpecificWindowTest, DestroyAndDisconnectSpecificSessionWithDetachCallback, TestSize.Level1) { int32_t persistentId = 0; WSError result = ssm_->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, nullptr); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } -} +} // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/sub_session_lifecycle_test.cpp b/window_scene/test/unittest/sub_session_lifecycle_test.cpp index bc22477c02..b5f4bd19b7 100644 --- a/window_scene/test/unittest/sub_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/sub_session_lifecycle_test.cpp @@ -41,20 +41,17 @@ public: void SetUp() override; void TearDown() override; SessionInfo info; - sptr specificCallback = nullptr; + sptr specificCallback = nullptr; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); - sptr subSession_; + sptr subSession_; SystemSessionConfig systemConfig_; }; -void SessionStubLifecycleTest::SetUpTestCase() -{ -} +void SessionStubLifecycleTest::SetUpTestCase() {} -void SessionStubLifecycleTest::TearDownTestCase() -{ -} +void SessionStubLifecycleTest::TearDownTestCase() {} void SessionStubLifecycleTest::SetUp() { @@ -141,7 +138,7 @@ HWTEST_F(SessionStubLifecycleTest, Hide01, TestSize.Level1) { subSession_->Hide(); subSession_->GetMissionId(); - + subSession_->isActive_ = true; ASSERT_EQ(WSError::WS_OK, subSession_->Hide()); subSession_->isActive_ = false; @@ -154,7 +151,7 @@ HWTEST_F(SessionStubLifecycleTest, Hide01, TestSize.Level1) subSession_->sessionStage_ = nullptr; ASSERT_EQ(WSError::WS_OK, subSession_->Hide()); subSession_->sessionStage_ = tempStage_; - + WSRect rect; subSession_->UpdatePointerArea(rect); subSession_->RectCheck(50, 100); @@ -303,6 +300,6 @@ HWTEST_F(SessionStubLifecycleTest, ProcessPointDownSession02, TestSize.Level1) ASSERT_FALSE(subSession_->GetSessionProperty()->GetRaiseEnabled()); ASSERT_EQ(subSession_->ProcessPointDownSession(50, 100), WSError::WS_OK); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/sub_session_test.cpp b/window_scene/test/unittest/sub_session_test.cpp index 913b3cc083..45a5258a6f 100644 --- a/window_scene/test/unittest/sub_session_test.cpp +++ b/window_scene/test/unittest/sub_session_test.cpp @@ -43,19 +43,16 @@ public: void TearDown() override; SessionInfo info; sptr specificCallback = nullptr; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); sptr subSession_; SystemSessionConfig systemConfig_; }; -void SubSessionTest::SetUpTestCase() -{ -} +void SubSessionTest::SetUpTestCase() {} -void SubSessionTest::TearDownTestCase() -{ -} +void SubSessionTest::TearDownTestCase() {} void SubSessionTest::SetUp() { @@ -433,9 +430,7 @@ HWTEST_F(SubSessionTest, SetParentSessionCallback, TestSize.Level1) subSession->SetParentSessionCallback(nullptr); EXPECT_EQ(subSession->setParentSessionFunc_, nullptr); - NotifySetParentSessionFunc func = [](int32_t oldParentWindowId, int32_t newParentWindowId) { - return; - }; + NotifySetParentSessionFunc func = [](int32_t oldParentWindowId, int32_t newParentWindowId) { return; }; subSession->SetParentSessionCallback(std::move(func)); EXPECT_NE(subSession->setParentSessionFunc_, nullptr); } @@ -456,9 +451,7 @@ HWTEST_F(SubSessionTest, NotifySetParentSession, TestSize.Level1) auto res = subSession->NotifySetParentSession(oldParentWindowId, newParentWindowId); EXPECT_EQ(res, WMError::WM_OK); - NotifySetParentSessionFunc func = [](int32_t oldParentWindowId, int32_t newParentWindowId) { - return; - }; + NotifySetParentSessionFunc func = [](int32_t oldParentWindowId, int32_t newParentWindowId) { return; }; subSession->SetParentSessionCallback(std::move(func)); res = subSession->NotifySetParentSession(oldParentWindowId, newParentWindowId); EXPECT_EQ(res, WMError::WM_OK); @@ -640,9 +633,7 @@ HWTEST_F(SubSessionTest, SetSubWindowZLevel, TestSize.Level1) info.bundleName_ = "SetSubWindowZLevel"; sptr subSession = sptr::MakeSptr(info, nullptr); int32_t testZLevel = 0; - subSession->onSubSessionZLevelChange_ = [&testZLevel](int32_t zLevel) { - testZLevel = zLevel; - }; + subSession->onSubSessionZLevelChange_ = [&testZLevel](int32_t zLevel) { testZLevel = zLevel; }; subSession->property_->zLevel_ = 0; WSError ret = subSession->SetSubWindowZLevel(1); EXPECT_EQ(1, subSession->property_->zLevel_); @@ -664,6 +655,6 @@ HWTEST_F(SubSessionTest, GetSubWindowZLevel, TestSize.Level1) subSession->property_->zLevel_ = 1; EXPECT_EQ(1, subSession->GetSubWindowZLevel()); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/system_session_lifecycle_test.cpp b/window_scene/test/unittest/system_session_lifecycle_test.cpp index 227e35c136..b01abc3cba 100644 --- a/window_scene/test/unittest/system_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/system_session_lifecycle_test.cpp @@ -38,19 +38,16 @@ public: void SetUp() override; void TearDown() override; SessionInfo info; - sptr specificCallback = nullptr; - sptr systemSession_; + sptr specificCallback = nullptr; + sptr systemSession_; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); }; -void SystemSessionLifecycleTest::SetUpTestCase() -{ -} +void SystemSessionLifecycleTest::SetUpTestCase() {} -void SystemSessionLifecycleTest::TearDownTestCase() -{ -} +void SystemSessionLifecycleTest::TearDownTestCase() {} void SystemSessionLifecycleTest::SetUp() { @@ -209,8 +206,7 @@ HWTEST_F(SystemSessionLifecycleTest, Disconnect02, TestSize.Level1) sptr specificCallback = sptr::MakeSptr(); ASSERT_NE(specificCallback, nullptr); - sptr sysSession = - sptr::MakeSptr(info, specificCallback); + sptr sysSession = sptr::MakeSptr(info, specificCallback); ASSERT_NE(sysSession, nullptr); bool isFromClient = true; @@ -232,8 +228,7 @@ HWTEST_F(SystemSessionLifecycleTest, Disconnect03, TestSize.Level1) sptr specificCallback = sptr::MakeSptr(); ASSERT_NE(specificCallback, nullptr); - sptr sysSession = - sptr::MakeSptr(info, specificCallback); + sptr sysSession = sptr::MakeSptr(info, specificCallback); ASSERT_NE(sysSession, nullptr); sptr property = sptr::MakeSptr(); @@ -245,6 +240,6 @@ HWTEST_F(SystemSessionLifecycleTest, Disconnect03, TestSize.Level1) auto ret = sysSession->Disconnect(isFromClient); ASSERT_EQ(WSError::WS_OK, ret); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/system_session_test.cpp b/window_scene/test/unittest/system_session_test.cpp index 8fc786023b..4fbb38544a 100644 --- a/window_scene/test/unittest/system_session_test.cpp +++ b/window_scene/test/unittest/system_session_test.cpp @@ -42,19 +42,16 @@ public: SessionInfo info; sptr specificCallback = nullptr; sptr systemSession_; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); sptr GetSystemSession(const std::string& name); sptr GetSceneSession(const std::string& name); }; -void SystemSessionTest::SetUpTestCase() -{ -} +void SystemSessionTest::SetUpTestCase() {} -void SystemSessionTest::TearDownTestCase() -{ -} +void SystemSessionTest::TearDownTestCase() {} void SystemSessionTest::SetUp() { @@ -166,8 +163,7 @@ HWTEST_F(SystemSessionTest, CheckPointerEventDispatch, TestSize.Level1) info.windowType_ = 2122; sptr specificCallback_ = sptr::MakeSptr(); - sptr sysSession = - sptr::MakeSptr(info, specificCallback_); + sptr sysSession = sptr::MakeSptr(info, specificCallback_); sysSession->SetSessionState(SessionState::STATE_FOREGROUND); bool ret1 = sysSession->CheckPointerEventDispatch(pointerEvent_); ASSERT_EQ(true, ret1); @@ -187,8 +183,7 @@ HWTEST_F(SystemSessionTest, UpdatePointerArea, TestSize.Level1) info.windowType_ = 2122; sptr specificCallback_ = sptr::MakeSptr(); - sptr sysSession = - sptr::MakeSptr(info, specificCallback_); + sptr sysSession = sptr::MakeSptr(info, specificCallback_); sysSession->UpdatePointerArea(rect); ASSERT_NE(sysSession->preRect_, rect); @@ -332,10 +327,9 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus01, TestSize.Level1) systemSession_->UpdateCameraWindowStatus(true); ASSERT_EQ(result, false); - systemSession_->specificCallback_->onCameraFloatSessionChange_ = - [&result] (uint32_t accessTokenId, bool isShowing) { - result = isShowing; - }; + systemSession_->specificCallback_->onCameraFloatSessionChange_ = [&result](uint32_t accessTokenId, bool isShowing) { + result = isShowing; + }; systemSession_->UpdateCameraWindowStatus(true); ASSERT_EQ(result, true); } @@ -354,32 +348,28 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus02, TestSize.Level1) ASSERT_NE(specificCallback, nullptr); bool result = false; sysSession->specificCallback_ = specificCallback; - + sysSession->property_->SetWindowType(WindowType::WINDOW_TYPE_PIP); sysSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sysSession->UpdateCameraWindowStatus(true); ASSERT_EQ(result, false); - sysSession->specificCallback_->onCameraSessionChange_ = - [&result](uint32_t accessTokenId, bool isShowing) { - result = isShowing; - }; + sysSession->specificCallback_->onCameraSessionChange_ = [&result](uint32_t accessTokenId, bool isShowing) { + result = isShowing; + }; result = false; - sysSession->pipTemplateInfo_.pipTemplateType = - static_cast(PiPTemplateType::VIDEO_CALL); + sysSession->pipTemplateInfo_.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); sysSession->UpdateCameraWindowStatus(true); ASSERT_EQ(result, true); result = false; - sysSession->pipTemplateInfo_.pipTemplateType = - static_cast(PiPTemplateType::VIDEO_MEETING); + sysSession->pipTemplateInfo_.pipTemplateType = static_cast(PiPTemplateType::VIDEO_MEETING); sysSession->UpdateCameraWindowStatus(true); ASSERT_EQ(result, true); result = false; - sysSession->pipTemplateInfo_.pipTemplateType = - static_cast(PiPTemplateType::VIDEO_LIVE); + sysSession->pipTemplateInfo_.pipTemplateType = static_cast(PiPTemplateType::VIDEO_LIVE); sysSession->UpdateCameraWindowStatus(true); ASSERT_EQ(result, false); } @@ -684,7 +674,7 @@ HWTEST_F(SystemSessionTest, NotifyClientToUpdateRect02, TestSize.Level1) sysSession->property_->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL); sysSession->state_ = SessionState::STATE_ACTIVE; - //for NotifyClientToUpdateRectTask + // for NotifyClientToUpdateRectTask sysSession->isKeyboardPanelEnabled_ = true; sysSession->dirtyFlags_ = 0; @@ -779,22 +769,17 @@ HWTEST_F(SystemSessionTest, UpdatePiPWindowStateChanged, TestSize.Level1) sessionInfo.moduleName_ = "UpdatePiPWindowStateChanged"; sessionInfo.bundleName_ = "UpdatePiPWindowStateChanged"; sessionInfo.windowType_ = static_cast(WindowType::APP_MAIN_WINDOW_BASE); - sptr callback = - sptr::MakeSptr(); + sptr callback = sptr::MakeSptr(); EXPECT_NE(nullptr, callback); - sptr systemSession = - sptr::MakeSptr(sessionInfo, callback); + sptr systemSession = sptr::MakeSptr(sessionInfo, callback); EXPECT_NE(nullptr, systemSession); - PiPStateChangeCallback callbackFun = [](const std::string& bundleName, bool isForeground) { - return; - }; + PiPStateChangeCallback callbackFun = [](const std::string& bundleName, bool isForeground) { return; }; callback->onPiPStateChange_ = callbackFun; EXPECT_EQ(WindowType::APP_MAIN_WINDOW_BASE, systemSession->GetWindowType()); systemSession->UpdatePiPWindowStateChanged(true); sessionInfo.windowType_ = static_cast(WindowType::WINDOW_TYPE_PIP); - sptr system = - sptr::MakeSptr(sessionInfo, callback); + sptr system = sptr::MakeSptr(sessionInfo, callback); EXPECT_NE(nullptr, system); EXPECT_EQ(WindowType::WINDOW_TYPE_PIP, system->GetWindowType()); system->UpdatePiPWindowStateChanged(true); diff --git a/window_scene/test/unittest/task_scheduler_test.cpp b/window_scene/test/unittest/task_scheduler_test.cpp index dcdad1d975..70e84bd580 100644 --- a/window_scene/test/unittest/task_scheduler_test.cpp +++ b/window_scene/test/unittest/task_scheduler_test.cpp @@ -21,7 +21,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { class TaskSchedulerTest : public testing::Test { - public: +public: TaskSchedulerTest() {} ~TaskSchedulerTest() {} }; @@ -37,7 +37,7 @@ HWTEST_F(TaskSchedulerTest, task_scheduler_test001, TestSize.Level1) GTEST_LOG_(INFO) << "TaskSchedulerTest: task_scheduler_test001 start"; std::string threadName = "threadName"; std::string name = "name"; - TaskScheduler* taskScheduler = new(std::nothrow) TaskScheduler(threadName); + TaskScheduler* taskScheduler = new (std::nothrow) TaskScheduler(threadName); int res = 0; taskScheduler->RemoveTask(name); ASSERT_EQ(res, 0); @@ -99,7 +99,6 @@ HWTEST_F(TaskSchedulerTest, AddExportTask1, TestSize.Level1) ASSERT_EQ(taskScheduler->exportFuncMap_.size(), 0); } - HWTEST_F(TaskSchedulerTest, AddExportTask2, TestSize.Level1) { std::string threadName = "threadName"; diff --git a/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_mock.h b/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_mock.h index c73ea9d925..126ce72b99 100644 --- a/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_mock.h +++ b/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_mock.h @@ -26,12 +26,14 @@ public: MockDataHandler() = default; ~MockDataHandler() override = default; - MOCK_METHOD(DataHandlerErr, SendData, - (const AAFwk::Want& data, AAFwk::Want& reply, const DataTransferConfig& config), (override)); - MOCK_METHOD(bool, WriteInterfaceToken, (MessageParcel& data), (override)); + MOCK_METHOD(DataHandlerErr, + SendData, + (const AAFwk::Want& data, AAFwk::Want& reply, const DataTransferConfig& config), + (override)); + MOCK_METHOD(bool, WriteInterfaceToken, (MessageParcel & data), (override)); // Helper methods to expose protected methods for testing using DataHandler::NotifyDataConsumer; }; -} // namespace OHOS::Rosen::Extension -#endif // OHOS_ROSEN_EXTENSION_DATA_HANDLE_MOCK_H +} // namespace OHOS::Rosen::Extension +#endif // OHOS_ROSEN_EXTENSION_DATA_HANDLE_MOCK_H diff --git a/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_test.cpp b/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_test.cpp index 909bc4acd9..fd603365b1 100644 --- a/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_test.cpp +++ b/window_scene/test/unittest/ui_extension/data_handler/extension_data_handler_test.cpp @@ -97,8 +97,8 @@ HWTEST_F(ExtensionDataHandlerTest, DataTransferConfigUnmarshalling02, TestSize.L HWTEST_F(ExtensionDataHandlerTest, RegisterDataConsumer01, TestSize.Level1) { MockDataHandler handler; - auto callback = [](SubSystemId id, uint32_t customId, AAFwk::Want&& data, - std::optional& reply) -> int32_t { + auto callback = + [](SubSystemId id, uint32_t customId, AAFwk::Want&& data, std::optional& reply) -> int32_t { return 0; }; @@ -114,8 +114,8 @@ HWTEST_F(ExtensionDataHandlerTest, RegisterDataConsumer01, TestSize.Level1) HWTEST_F(ExtensionDataHandlerTest, RegisterDataConsumer02, TestSize.Level1) { MockDataHandler handler; - auto callback = [](SubSystemId id, uint32_t customId, AAFwk::Want&& data, - std::optional& reply) -> int32_t { + auto callback = + [](SubSystemId id, uint32_t customId, AAFwk::Want&& data, std::optional& reply) -> int32_t { return 0; }; auto callback1 = callback; @@ -134,8 +134,8 @@ HWTEST_F(ExtensionDataHandlerTest, RegisterDataConsumer02, TestSize.Level1) HWTEST_F(ExtensionDataHandlerTest, UnregisterDataConsumer01, TestSize.Level1) { MockDataHandler handler; - auto callback = [](SubSystemId id, uint32_t customId, AAFwk::Want&& data, - std::optional& reply) -> int32_t { + auto callback = + [](SubSystemId id, uint32_t customId, AAFwk::Want&& data, std::optional& reply) -> int32_t { return 0; }; auto callback1 = callback; @@ -175,7 +175,9 @@ HWTEST_F(ExtensionDataHandlerTest, NotifyDataConsumer01, TestSize.Level1) MockDataHandler handler; bool callbackCalled = false; - auto callback = [&callbackCalled](SubSystemId id, uint32_t customId, AAFwk::Want&& data, + auto callback = [&callbackCalled](SubSystemId id, + uint32_t customId, + AAFwk::Want&& data, std::optional& reply) -> int32_t { callbackCalled = true; EXPECT_EQ(SubSystemId::WM_UIEXT, id); @@ -217,7 +219,9 @@ HWTEST_F(ExtensionDataHandlerTest, NotifyDataConsumer02, TestSize.Level1) MockDataHandler handler; bool callbackCalled = false; - auto callback = [&callbackCalled](SubSystemId id, uint32_t customId, AAFwk::Want&& data, + auto callback = [&callbackCalled](SubSystemId id, + uint32_t customId, + AAFwk::Want&& data, std::optional& reply) -> int32_t { callbackCalled = true; EXPECT_EQ(SubSystemId::WM_UIEXT, id); @@ -259,4 +263,4 @@ HWTEST_F(ExtensionDataHandlerTest, NotifyDataConsumer03, TestSize.Level1) auto ret = handler.NotifyDataConsumer(std::move(data), reply, config); ASSERT_EQ(DataHandlerErr::NO_CONSUME_CALLBACK, ret); } -} // namespace OHOS::Rosen::Extension +} // namespace OHOS::Rosen::Extension diff --git a/window_scene/test/unittest/ui_extension/extension_session_manager_test.cpp b/window_scene/test/unittest/ui_extension/extension_session_manager_test.cpp index d95ccef46e..260dd1f520 100644 --- a/window_scene/test/unittest/ui_extension/extension_session_manager_test.cpp +++ b/window_scene/test/unittest/ui_extension/extension_session_manager_test.cpp @@ -29,25 +29,18 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void ExtensionSessionManagerTest::SetUpTestCase() -{ -} +void ExtensionSessionManagerTest::SetUpTestCase() {} -void ExtensionSessionManagerTest::TearDownTestCase() -{ -} +void ExtensionSessionManagerTest::TearDownTestCase() {} -void ExtensionSessionManagerTest::SetUp() -{ -} +void ExtensionSessionManagerTest::SetUp() {} -void ExtensionSessionManagerTest::TearDown() -{ -} +void ExtensionSessionManagerTest::TearDown() {} namespace { /** @@ -72,11 +65,10 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionActivation01, TestS SessionInfo info; sptr extensionSession = sptr::MakeSptr(info); ASSERT_EQ(WSError::WS_OK, - ExtensionSessionManager::GetInstance().RequestExtensionSessionBackground(extensionSession, nullptr)); + ExtensionSessionManager::GetInstance().RequestExtensionSessionBackground(extensionSession, nullptr)); } -void func(WSError we) -{} +void func(WSError we) {} /** * @tc.name: RequestExtensionSessionActivation02 @@ -87,7 +79,7 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionActivation02, TestS { SessionInfo info; sptr extensionSession = sptr::MakeSptr(info); - ExtensionSessionManager *instance = &ExtensionSessionManager::GetInstance(); + ExtensionSessionManager* instance = &ExtensionSessionManager::GetInstance(); ASSERT_EQ(WSError::WS_OK, instance->RequestExtensionSessionActivation(extensionSession, 1, nullptr)); usleep(WAIT_SYNC_IN_NS); @@ -109,7 +101,7 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionBackground01, TestS SessionInfo info; sptr extensionSession = sptr::MakeSptr(info); ASSERT_EQ(WSError::WS_OK, - ExtensionSessionManager::GetInstance().RequestExtensionSessionBackground(extensionSession, nullptr)); + ExtensionSessionManager::GetInstance().RequestExtensionSessionBackground(extensionSession, nullptr)); } /** @@ -121,7 +113,7 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionBackground02, TestS { SessionInfo info; sptr extensionSession = sptr::MakeSptr(info); - ExtensionSessionManager *instance = &ExtensionSessionManager::GetInstance(); + ExtensionSessionManager* instance = &ExtensionSessionManager::GetInstance(); ASSERT_EQ(WSError::WS_OK, instance->RequestExtensionSessionBackground(extensionSession, nullptr)); usleep(WAIT_SYNC_IN_NS); @@ -143,7 +135,7 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionDestruction01, Test SessionInfo info; sptr extensionSession = sptr::MakeSptr(info); ASSERT_EQ(WSError::WS_OK, - ExtensionSessionManager::GetInstance().RequestExtensionSessionDestruction(extensionSession, nullptr)); + ExtensionSessionManager::GetInstance().RequestExtensionSessionDestruction(extensionSession, nullptr)); } /** @@ -168,7 +160,7 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionDestruction03, Test { SessionInfo info; sptr extensionSession = sptr::MakeSptr(info); - ExtensionSessionManager *instance = &ExtensionSessionManager::GetInstance(); + ExtensionSessionManager* instance = &ExtensionSessionManager::GetInstance(); ASSERT_EQ(WSError::WS_OK, instance->RequestExtensionSessionDestruction(extensionSession, nullptr)); usleep(WAIT_SYNC_IN_NS); @@ -205,7 +197,7 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionDestructionDone03, */ HWTEST_F(ExtensionSessionManagerTest, GetInstance, TestSize.Level1) { - ExtensionSessionManager *instance = &ExtensionSessionManager::GetInstance(); + ExtensionSessionManager* instance = &ExtensionSessionManager::GetInstance(); ASSERT_NE(nullptr, instance); } @@ -220,7 +212,7 @@ HWTEST_F(ExtensionSessionManagerTest, SetAbilitySessionInfo, TestSize.Level1) SessionInfo infoInput; infoInput.want = std::make_shared(want); sptr extSession = new ExtensionSession(infoInput); - ExtensionSessionManager *instance = &ExtensionSessionManager::GetInstance(); + ExtensionSessionManager* instance = &ExtensionSessionManager::GetInstance(); sptr result = instance->SetAbilitySessionInfo(extSession); int32_t persistentId = extSession->GetPersistentId(); ASSERT_EQ(result->persistentId, persistentId); @@ -241,7 +233,7 @@ HWTEST_F(ExtensionSessionManagerTest, RequestExtensionSessionDestruction02, Test SessionInfo infoInput; infoInput.want = std::make_shared(want); sptr extSession = nullptr; - ExtensionSessionManager *instance = &ExtensionSessionManager::GetInstance(); + ExtensionSessionManager* instance = &ExtensionSessionManager::GetInstance(); WSError result01 = instance->RequestExtensionSessionDestruction(extSession, nullptr); EXPECT_EQ(result01, WSError::WS_OK); } diff --git a/window_scene/test/unittest/ui_extension/extension_session_test.cpp b/window_scene/test/unittest/ui_extension/extension_session_test.cpp index 383d6893ba..1f00143565 100644 --- a/window_scene/test/unittest/ui_extension/extension_session_test.cpp +++ b/window_scene/test/unittest/ui_extension/extension_session_test.cpp @@ -40,13 +40,9 @@ public: sptr extSessionEventCallback_ = nullptr; }; -void ExtensionSessionTest::SetUpTestCase() -{ -} +void ExtensionSessionTest::SetUpTestCase() {} -void ExtensionSessionTest::TearDownTestCase() -{ -} +void ExtensionSessionTest::TearDownTestCase() {} void ExtensionSessionTest::SetUp() { @@ -84,8 +80,8 @@ HWTEST_F(ExtensionSessionTest, Connect, TestSize.Level0) { SystemSessionConfig sessionConfig; extensionSession_->state_ = SessionState::STATE_DISCONNECT; - auto res = extensionSession_->Connect(mockSessionStage_, mockEventChannel_, nullptr, sessionConfig, nullptr, - nullptr, ""); + auto res = + extensionSession_->Connect(mockSessionStage_, mockEventChannel_, nullptr, sessionConfig, nullptr, nullptr, ""); ASSERT_EQ(res, WSError::WS_OK); extensionSession_->state_ = SessionState::STATE_DISCONNECT; @@ -408,8 +404,7 @@ HWTEST_F(ExtensionSessionTest, TransferAccessibilityHoverEvent01, TestSize.Level int32_t sourceType = 0; int32_t eventType = 0; int64_t timeMs = 0; - WSError result = extensionSession_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError result = extensionSession_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(result, WSError::WS_OK); } @@ -426,8 +421,7 @@ HWTEST_F(ExtensionSessionTest, TransferAccessibilityHoverEvent02, TestSize.Level int32_t sourceType = 0; int32_t eventType = 0; int64_t timeMs = 0; - WSError result = extensionSession_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError result = extensionSession_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } @@ -656,7 +650,7 @@ HWTEST_F(ExtensionSessionTest, WindowEventChannelListenerOnRemoteRequest01, Test data.WriteBool(true); data.WriteInt32(0); uint32_t code = static_cast(IWindowEventChannelListener::WindowEventChannelListenerMessage:: - TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC); + TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC); WindowEventChannelListener listener; ASSERT_EQ(listener.OnRemoteRequest(code, data, reply, option), 0); } @@ -782,7 +776,7 @@ HWTEST_F(ExtensionSessionTest, GetAvoidAreaByType, TestSize.Level0) AvoidAreaType typeKeyboard = AvoidAreaType::TYPE_KEYBOARD; AvoidAreaType typeNavigationIndicator = AvoidAreaType::TYPE_NAVIGATION_INDICATOR; AvoidArea expectedAvoidArea; - expectedAvoidArea.topRect_ = {10, 20, 30, 40}; + expectedAvoidArea.topRect_ = { 10, 20, 30, 40 }; EXPECT_CALL(mockNotifyGetAvoidAreaByTypeFunc, Call(_, _)).Times(5).WillRepeatedly(Return(expectedAvoidArea)); auto res = extensionSession_->GetAvoidAreaByType(typeSystem); ASSERT_EQ(res, expectedAvoidArea); @@ -946,6 +940,6 @@ HWTEST_F(ExtensionSessionTest, TryUpdateExtensionPersistentId, TestSize.Level1) sptr extensionSessionC = sptr::MakeSptr(info); ASSERT_EQ(info.persistentId_, extensionSessionC->GetPersistentId()); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_event_channel_base.h b/window_scene/test/unittest/window_event_channel_base.h index dcb9c12afb..dd6214c7e3 100644 --- a/window_scene/test/unittest/window_event_channel_base.h +++ b/window_scene/test/unittest/window_event_channel_base.h @@ -31,19 +31,23 @@ public: WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, - bool isPreImeEvent = false) override; - WSError TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, bool isPreImeEvent, - const sptr& listener) override; + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, + bool& isConsumed, + bool isPreImeEvent = false) override; + WSError TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, + bool isPreImeEvent, + const sptr& listener) override; WSError TransferFocusState(bool focusState) override; WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; - WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, - int64_t timeMs) override; - WSError TransferAccessibilityChildTreeRegister( - uint32_t windowId, int32_t treeId, int64_t accessibilityId) override; + WSError TransferAccessibilityHoverEvent(float pointX, + float pointY, + int32_t sourceType, + int32_t eventType, + int64_t timeMs) override; + WSError TransferAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId) override; WSError TransferAccessibilityChildTreeUnregister() override; - WSError TransferAccessibilityDumpChildInfo( - const std::vector& params, std::vector& info) override; + WSError TransferAccessibilityDumpChildInfo(const std::vector& params, + std::vector& info) override; sptr AsObject() override { @@ -66,14 +70,16 @@ WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive) return WSError::WS_OK; } -WSError TestWindowEventChannel::TransferKeyEventForConsumed( - const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent) +WSError TestWindowEventChannel::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, + bool& isConsumed, + bool isPreImeEvent) { return WSError::WS_OK; } WSError TestWindowEventChannel::TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, - bool isPreImeEvent, const sptr& listener) + bool isPreImeEvent, + const sptr& listener) { return WSError::WS_OK; } @@ -88,8 +94,9 @@ WSError TestWindowEventChannel::TransferBackpressedEventForConsumed(bool& isCons return WSError::WS_OK; } -WSError TestWindowEventChannel::TransferAccessibilityChildTreeRegister( - uint32_t windowId, int32_t treeId, int64_t accessibilityId) +WSError TestWindowEventChannel::TransferAccessibilityChildTreeRegister(uint32_t windowId, + int32_t treeId, + int64_t accessibilityId) { return WSError::WS_OK; } @@ -99,14 +106,17 @@ WSError TestWindowEventChannel::TransferAccessibilityChildTreeUnregister() return WSError::WS_OK; } -WSError TestWindowEventChannel::TransferAccessibilityDumpChildInfo( - const std::vector& params, std::vector& info) +WSError TestWindowEventChannel::TransferAccessibilityDumpChildInfo(const std::vector& params, + std::vector& info) { return WSError::WS_OK; } -WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, - int32_t eventType, int64_t timeMs) +WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, + float pointY, + int32_t sourceType, + int32_t eventType, + int64_t timeMs) { return WSError::WS_OK; } diff --git a/window_scene/test/unittest/window_event_channel_proxy_mock_test.cpp b/window_scene/test/unittest/window_event_channel_proxy_mock_test.cpp index 8ba4c1ee2d..a418981a79 100644 --- a/window_scene/test/unittest/window_event_channel_proxy_mock_test.cpp +++ b/window_scene/test/unittest/window_event_channel_proxy_mock_test.cpp @@ -30,7 +30,7 @@ class AccessibilityElementInfo; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannelProxyMockTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannelProxyMockTest" }; } class WindowEventChannelProxyMockTest : public testing::Test { public: @@ -43,21 +43,13 @@ public: sptr::MakeSptr(iRemoteObjectMocker); }; -void WindowEventChannelProxyMockTest::SetUpTestCase() -{ -} +void WindowEventChannelProxyMockTest::SetUpTestCase() {} -void WindowEventChannelProxyMockTest::TearDownTestCase() -{ -} +void WindowEventChannelProxyMockTest::TearDownTestCase() {} -void WindowEventChannelProxyMockTest::SetUp() -{ -} +void WindowEventChannelProxyMockTest::SetUp() {} -void WindowEventChannelProxyMockTest::TearDown() -{ -} +void WindowEventChannelProxyMockTest::TearDown() {} namespace { /** @@ -74,8 +66,8 @@ HWTEST_F(WindowEventChannelProxyMockTest, TransferAccessibilityHoverEvent, TestS int32_t sourceType = 0; int32_t eventType = 0; int64_t timeMs = 0; - WSError res = windowEventChannelProxy_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError res = + windowEventChannelProxy_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, res); MockMessageParcel::ClearAllErrorFlag(); WLOGI("TransferAccessibilityHoverEvent end"); @@ -94,8 +86,8 @@ HWTEST_F(WindowEventChannelProxyMockTest, TransferAccessibilityHoverEvent1, Test int32_t sourceType = 0; int32_t eventType = 0; int64_t timeMs = 0; - WSError res = windowEventChannelProxy_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError res = + windowEventChannelProxy_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, res); MockMessageParcel::ClearAllErrorFlag(); WLOGI("TransferAccessibilityHoverEvent1 end"); @@ -114,8 +106,8 @@ HWTEST_F(WindowEventChannelProxyMockTest, TransferAccessibilityHoverEvent2, Test int32_t sourceType = 0; int32_t eventType = 0; int64_t timeMs = 0; - WSError res = windowEventChannelProxy_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError res = + windowEventChannelProxy_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, res); MockMessageParcel::ClearAllErrorFlag(); WLOGI("TransferAccessibilityHoverEvent2 end"); @@ -134,8 +126,8 @@ HWTEST_F(WindowEventChannelProxyMockTest, TransferAccessibilityHoverEvent3, Test int32_t sourceType = -1; int32_t eventType = 0; int64_t timeMs = 0; - WSError res = windowEventChannelProxy_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError res = + windowEventChannelProxy_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, res); MockMessageParcel::ClearAllErrorFlag(); WLOGI("TransferAccessibilityHoverEvent3 end"); @@ -154,8 +146,8 @@ HWTEST_F(WindowEventChannelProxyMockTest, TransferAccessibilityHoverEvent4, Test int32_t sourceType = 0; int32_t eventType = -1; int64_t timeMs = 0; - WSError res = windowEventChannelProxy_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError res = + windowEventChannelProxy_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, res); MockMessageParcel::ClearAllErrorFlag(); WLOGI("TransferAccessibilityHoverEvent4 end"); @@ -174,8 +166,8 @@ HWTEST_F(WindowEventChannelProxyMockTest, TransferAccessibilityHoverEvent5, Test int32_t sourceType = 0; int32_t eventType = 0; int64_t timeMs = -1; - WSError res = windowEventChannelProxy_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError res = + windowEventChannelProxy_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, res); MockMessageParcel::ClearAllErrorFlag(); WLOGI("TransferAccessibilityHoverEvent5 end"); @@ -324,6 +316,6 @@ HWTEST_F(WindowEventChannelProxyMockTest, TransferAccessibilityDumpChildInfo2, T ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, res); WLOGI("TransferAccessibilityDumpChildInfo2 end"); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_event_channel_proxy_test.cpp b/window_scene/test/unittest/window_event_channel_proxy_test.cpp index d7c796c615..a1529e64cf 100644 --- a/window_scene/test/unittest/window_event_channel_proxy_test.cpp +++ b/window_scene/test/unittest/window_event_channel_proxy_test.cpp @@ -44,21 +44,13 @@ public: sptr::MakeSptr(iRemoteObjectMocker); }; -void WindowEventChannelProxyTest::SetUpTestCase() -{ -} +void WindowEventChannelProxyTest::SetUpTestCase() {} -void WindowEventChannelProxyTest::TearDownTestCase() -{ -} +void WindowEventChannelProxyTest::TearDownTestCase() {} -void WindowEventChannelProxyTest::SetUp() -{ -} +void WindowEventChannelProxyTest::SetUp() {} -void WindowEventChannelProxyTest::TearDown() -{ -} +void WindowEventChannelProxyTest::TearDown() {} namespace { /** @@ -122,8 +114,8 @@ HWTEST_F(WindowEventChannelProxyTest, TransferKeyEventForConsumedAsync, TestSize ASSERT_NE(keyEvent, nullptr); bool isPreImeEvent = false; sptr iRemoteObjectMocker = sptr::MakeSptr(); - WSError res = windowEventChannelProxy_->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, - iRemoteObjectMocker); + WSError res = + windowEventChannelProxy_->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, iRemoteObjectMocker); ASSERT_EQ(WSError::WS_OK, res); } @@ -169,8 +161,8 @@ HWTEST_F(WindowEventChannelProxyTest, TransferAccessibilityHoverEvent, TestSize. int32_t sourceType = 0; int32_t eventType = 0; int64_t timeMs = 0; - WSError res = windowEventChannelProxy_->TransferAccessibilityHoverEvent( - pointX, pointY, sourceType, eventType, timeMs); + WSError res = + windowEventChannelProxy_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); ASSERT_EQ(WSError::WS_OK, res); } @@ -213,6 +205,6 @@ HWTEST_F(WindowEventChannelProxyTest, TransferAccessibilityDumpChildInfo, TestSi WSError res = windowEventChannelProxy_->TransferAccessibilityDumpChildInfo(params, info); ASSERT_EQ(WSError::WS_OK, res); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_event_channel_stub_mock_test.cpp b/window_scene/test/unittest/window_event_channel_stub_mock_test.cpp index b152f7aaae..3a91690a4b 100644 --- a/window_scene/test/unittest/window_event_channel_stub_mock_test.cpp +++ b/window_scene/test/unittest/window_event_channel_stub_mock_test.cpp @@ -32,7 +32,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannelProxyMockTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannelProxyMockTest" }; } class WindowEventChannelMockStubTest : public testing::Test { public: @@ -45,21 +45,13 @@ public: sptr windowEventChannelStub_ = sptr::MakeSptr(sessionStage); }; -void WindowEventChannelMockStubTest::SetUpTestCase() -{ -} +void WindowEventChannelMockStubTest::SetUpTestCase() {} -void WindowEventChannelMockStubTest::TearDownTestCase() -{ -} +void WindowEventChannelMockStubTest::TearDownTestCase() {} -void WindowEventChannelMockStubTest::SetUp() -{ -} +void WindowEventChannelMockStubTest::SetUp() {} -void WindowEventChannelMockStubTest::TearDown() -{ -} +void WindowEventChannelMockStubTest::TearDown() {} /** * @tc.name: HandleTransferAccessibilityChildTreeRegister01 @@ -72,11 +64,11 @@ HWTEST_F(WindowEventChannelMockStubTest, HandleTransferAccessibilityChildTreeReg MockMessageParcel::ClearAllErrorFlag(); MessageParcel data; MessageParcel reply; - + data.WriteUint32(0); data.WriteInt32(0); data.WriteInt64(0); - + MockMessageParcel::SetWriteInt32ErrorFlag(true); ASSERT_TRUE((windowEventChannelStub_ != nullptr)); ASSERT_EQ(ERR_INVALID_DATA, windowEventChannelStub_->HandleTransferAccessibilityChildTreeRegister(data, reply)); @@ -140,5 +132,5 @@ HWTEST_F(WindowEventChannelMockStubTest, HandleTransferAccessibilityDumpChildInf ASSERT_EQ(ERR_NONE, windowEventChannelStub_->HandleTransferAccessibilityDumpChildInfo(data, reply)); WLOGI("HandleTransferAccessibilityDumpChildInfo end"); } -} -} \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_event_channel_stub_test.cpp b/window_scene/test/unittest/window_event_channel_stub_test.cpp index e9b67ead01..877b2aef3b 100644 --- a/window_scene/test/unittest/window_event_channel_stub_test.cpp +++ b/window_scene/test/unittest/window_event_channel_stub_test.cpp @@ -38,7 +38,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannelStubTest"}; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannelStubTest" }; } class WindowEventChannelStubTest : public testing::Test { public: @@ -51,21 +51,13 @@ public: sptr windowEventChannelStub_ = sptr::MakeSptr(sessionStage); }; -void WindowEventChannelStubTest::SetUpTestCase() -{ -} +void WindowEventChannelStubTest::SetUpTestCase() {} -void WindowEventChannelStubTest::TearDownTestCase() -{ -} +void WindowEventChannelStubTest::TearDownTestCase() {} -void WindowEventChannelStubTest::SetUp() -{ -} +void WindowEventChannelStubTest::SetUp() {} -void WindowEventChannelStubTest::TearDown() -{ -} +void WindowEventChannelStubTest::TearDown() {} namespace { /** @@ -333,7 +325,7 @@ HWTEST_F(WindowEventChannelStubTest, HandleTransferAccessibilityChildTreeRegiste WLOGI("HandleTransferAccessibilityChildTreeRegister02 begin"); MessageParcel data; MessageParcel reply; - + ASSERT_TRUE(windowEventChannelStub_ != nullptr); ASSERT_EQ(ERR_INVALID_DATA, windowEventChannelStub_->HandleTransferAccessibilityChildTreeRegister(data, reply)); WLOGI("HandleTransferAccessibilityChildTreeRegister02 end"); @@ -406,6 +398,6 @@ HWTEST_F(WindowEventChannelStubTest, HandleTransferAccessibilityDumpChildInfo01, ASSERT_EQ(0, windowEventChannelStub_->HandleTransferAccessibilityDumpChildInfo(data, reply)); WLOGI("HandleTransferAccessibilityDumpChildInfo01 end"); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_event_channel_test.cpp b/window_scene/test/unittest/window_event_channel_test.cpp index 2c109f605c..ac49dac11d 100644 --- a/window_scene/test/unittest/window_event_channel_test.cpp +++ b/window_scene/test/unittest/window_event_channel_test.cpp @@ -48,21 +48,13 @@ public: sptr windowEventChannel_ = sptr::MakeSptr(sessionStage); }; -void WindowEventChannelTest::SetUpTestCase() -{ -} +void WindowEventChannelTest::SetUpTestCase() {} -void WindowEventChannelTest::TearDownTestCase() -{ -} +void WindowEventChannelTest::TearDownTestCase() {} -void WindowEventChannelTest::SetUp() -{ -} +void WindowEventChannelTest::SetUp() {} -void WindowEventChannelTest::TearDown() -{ -} +void WindowEventChannelTest::TearDown() {} WSError WindowEventChannelTest::TransferAccessibilityHoverEvent(bool isChannelNull) { @@ -539,5 +531,5 @@ HWTEST_F(WindowEventChannelTest, PrintInfoPointerEvent, TestSize.Level1) windowEventChannel_->PrintPointerEvent(pointerEvent); } -} -} +} // namespace +} // namespace OHOS::Rosen diff --git a/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp b/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp index adcb601f22..22ef170514 100644 --- a/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp +++ b/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp @@ -29,21 +29,13 @@ public: void TearDown() override; }; -void WindowFocusSceneSessionTest::SetUpTestCase() -{ -} +void WindowFocusSceneSessionTest::SetUpTestCase() {} -void WindowFocusSceneSessionTest::TearDownTestCase() -{ -} +void WindowFocusSceneSessionTest::TearDownTestCase() {} -void WindowFocusSceneSessionTest::SetUp() -{ -} +void WindowFocusSceneSessionTest::SetUp() {} -void WindowFocusSceneSessionTest::TearDown() -{ -} +void WindowFocusSceneSessionTest::TearDown() {} namespace { @@ -217,5 +209,5 @@ HWTEST_F(WindowFocusSceneSessionTest, IsSystemSessionAboveApp02, TestSize.Level1 ASSERT_EQ(false, sceneSession->IsSystemSessionAboveApp()); } } // namespace -} // Rosen -} // OHOS \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_manager_lru_test.cpp b/window_scene/test/unittest/window_manager_lru_test.cpp index e556beb2ed..0dfdf81f08 100644 --- a/window_scene/test/unittest/window_manager_lru_test.cpp +++ b/window_scene/test/unittest/window_manager_lru_test.cpp @@ -29,25 +29,18 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + private: std::unique_ptr testLruCache_; }; -void LruCacheTest::SetUpTestCase() -{ -} +void LruCacheTest::SetUpTestCase() {} -void LruCacheTest::TearDownTestCase() -{ -} +void LruCacheTest::TearDownTestCase() {} -void LruCacheTest::SetUp() -{ -} +void LruCacheTest::SetUp() {} -void LruCacheTest::TearDown() -{ -} +void LruCacheTest::TearDown() {} /** * @tc.name: Visit @@ -99,5 +92,5 @@ HWTEST_F(LruCacheTest, Remove, TestSize.Level1) res = testLruCache_->Put(33); ASSERT_EQ(res, -1); } -} -} \ No newline at end of file +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_manager_service_dump_test.cpp b/window_scene/test/unittest/window_manager_service_dump_test.cpp index 2c73cbc6c0..134f37dee4 100644 --- a/window_scene/test/unittest/window_manager_service_dump_test.cpp +++ b/window_scene/test/unittest/window_manager_service_dump_test.cpp @@ -35,21 +35,16 @@ public: void SetUp() override; void TearDown() override; sptr ssm_; + private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) -{ -} +void DumpRootSceneElementInfoFuncTest(const std::vector& params, std::vector& infos) {} -void WindowManagerServiceDumpTest::SetUpTestCase() -{ -} +void WindowManagerServiceDumpTest::SetUpTestCase() {} -void WindowManagerServiceDumpTest::TearDownTestCase() -{ -} +void WindowManagerServiceDumpTest::TearDownTestCase() {} void WindowManagerServiceDumpTest::SetUp() { @@ -73,7 +68,7 @@ HWTEST_F(WindowManagerServiceDumpTest, GetSessionDumpInfo01, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); std::string dumpInfo = "testDumpInfo"; - std::vector params = {"testDumpInfo"}; + std::vector params = { "testDumpInfo" }; WSError result = ssm_->GetSessionDumpInfo(params, dumpInfo); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION); @@ -227,9 +222,9 @@ HWTEST_F(WindowManagerServiceDumpTest, DumpSessionElementInfo, TestSize.Level1) */ HWTEST_F(WindowManagerServiceDumpTest, NotifyDumpInfoResult, TestSize.Level1) { - std::vector info = {"std::", "vector", ""}; + std::vector info = { "std::", "vector", "" }; ssm_->NotifyDumpInfoResult(info); - std::vector params = {"-a"}; + std::vector params = { "-a" }; std::string dumpInfo = ""; WSError result01 = ssm_->GetSessionDumpInfo(params, dumpInfo); EXPECT_EQ(result01, WSError::WS_OK); @@ -266,8 +261,8 @@ HWTEST_F(WindowManagerServiceDumpTest, GetAllSessionDumpInfo01, TestSize.Level1) ASSERT_NE(sceneSession2, nullptr); sceneSession2->UpdateNativeVisibility(false); - ssm_->sceneSessionMap_.insert({1, sceneSession1}); - ssm_->sceneSessionMap_.insert({2, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 1, sceneSession1 }); + ssm_->sceneSessionMap_.insert({ 2, sceneSession2 }); std::string dumpInfo; ASSERT_EQ(ssm_->GetAllSessionDumpInfo(dumpInfo), WSError::WS_OK); } @@ -352,9 +347,9 @@ HWTEST_F(WindowManagerServiceDumpTest, GetAllSessionDumpDetailInfo, TestSize.Lev ASSERT_NE(sceneSession2, nullptr); sceneSession2->UpdateNativeVisibility(false); - ssm_->sceneSessionMap_.insert({0, nullptr}); - ssm_->sceneSessionMap_.insert({1, sceneSession1}); - ssm_->sceneSessionMap_.insert({2, sceneSession2}); + ssm_->sceneSessionMap_.insert({ 0, nullptr }); + ssm_->sceneSessionMap_.insert({ 1, sceneSession1 }); + ssm_->sceneSessionMap_.insert({ 2, sceneSession2 }); std::string dumpInfo; ASSERT_EQ(ssm_->GetAllSessionDumpDetailInfo(dumpInfo), WSError::WS_OK); } @@ -372,7 +367,7 @@ HWTEST_F(WindowManagerServiceDumpTest, GetSpecifiedSessionDumpInfo, TestSize.Lev info.persistentId_ = 1234; sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->sceneSessionMap_.insert({1234, sceneSession}); + ssm_->sceneSessionMap_.insert({ 1234, sceneSession }); std::string dumpInfo; std::string strId = "1234"; std::vector params_(5, ""); @@ -388,9 +383,7 @@ HWTEST_F(WindowManagerServiceDumpTest, GetTotalUITreeInfo, TestSize.Level1) std::string dumpInfo = "dumpInfo"; ssm_->SetDumpUITreeFunc(nullptr); EXPECT_EQ(WSError::WS_OK, ssm_->GetTotalUITreeInfo(dumpInfo)); - DumpUITreeFunc func = [](std::string& dumpInfo) { - return; - }; + DumpUITreeFunc func = [](std::string& dumpInfo) { return; }; ssm_->SetDumpUITreeFunc(func); EXPECT_EQ(WSError::WS_OK, ssm_->GetTotalUITreeInfo(dumpInfo)); } @@ -441,6 +434,6 @@ HWTEST_F(WindowManagerServiceDumpTest, SceneSessionDumpSessionElementInfo, TestS ASSERT_EQ(ret, 1); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp b/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp index e5024d9ff7..f92575ade3 100644 --- a/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp +++ b/window_scene/test/unittest/window_pattern/window_pattern_snapshot_test.cpp @@ -49,13 +49,13 @@ public: void SetUp() override; void TearDown() override; static sptr ssm_; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); sptr session_ = nullptr; std::shared_ptr mPixelMap = std::make_shared(); }; - constexpr const char* UNDERLINE_SEPARATOR = "_"; constexpr const char* IMAGE_SUFFIX = ".jpg"; @@ -155,8 +155,8 @@ HWTEST_F(WindowPatternSnapshotTest, SaveSnapshot01, TestSize.Level1) scenePersistence->SaveSnapshot(mPixelMap); uint32_t fileID = static_cast(persistentId) & 0x3fffffff; - std::string test = ScenePersistence::snapshotDirectory_ + - bundleName + UNDERLINE_SEPARATOR + std::to_string(fileID) + IMAGE_SUFFIX; + std::string test = + ScenePersistence::snapshotDirectory_ + bundleName + UNDERLINE_SEPARATOR + std::to_string(fileID) + IMAGE_SUFFIX; std::pair sizeResult = scenePersistence->GetSnapshotSize(); EXPECT_EQ(sizeResult.first, 0); EXPECT_EQ(sizeResult.second, 0); @@ -212,8 +212,7 @@ HWTEST_F(WindowPatternSnapshotTest, GetLocalSnapshotPixelMap, TestSize.Level1) auto abilityInfo = session->GetSessionInfo(); auto persistentId = abilityInfo.persistentId_; ScenePersistence::CreateSnapshotDir("storage"); - sptr scenePersistence = - sptr::MakeSptr(abilityInfo.bundleName_, persistentId); + sptr scenePersistence = sptr::MakeSptr(abilityInfo.bundleName_, persistentId); ASSERT_NE(nullptr, scenePersistence); auto result = scenePersistence->GetLocalSnapshotPixelMap(0.5, 0.5); ASSERT_EQ(result, nullptr); @@ -469,7 +468,6 @@ HWTEST_F(WindowPatternSnapshotTest, NotifyRemoveSnapshot, TestSize.Level1) ASSERT_EQ(session_->GetScenePersistence()->HasSnapshot(), false); } - /** * @tc.name: Snapshot01 * @tc.desc: ret is false @@ -567,6 +565,31 @@ HWTEST_F(WindowPatternSnapshotTest, GetSnapshotPixelMap, TestSize.Level1) session_->snapshot_ = nullptr; ASSERT_EQ(nullptr, session_->GetSnapshotPixelMap(6.6f, 8.8f)); } + +/** + * @tc.name: GetEnableAddSnapshot + * @tc.desc: GetEnableAddSnapshot Test + * @tc.type: FUNC + */ +HWTEST_F(WindowPatternSnapshotTest, GetEnableAddSnapshot, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + bool res = session_->GetEnableAddSnapshot(); + EXPECT_EQ(res, true); } + +/** + * @tc.name: SetEnableAddSnapshot + * @tc.desc: SetEnableAddSnapshot Test + * @tc.type: FUNC + */ +HWTEST_F(WindowPatternSnapshotTest, SetEnableAddSnapshot, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + session_->SetEnableAddSnapshot(false); + bool res = session_->GetEnableAddSnapshot(); + EXPECT_EQ(res, false); } -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_rdb_test.cpp b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_rdb_test.cpp index e65a62ee3a..674e715647 100644 --- a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_rdb_test.cpp +++ b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_rdb_test.cpp @@ -41,13 +41,9 @@ public: std::shared_ptr WindowPatternStartingWindowRdbTest::startingWindowRdbMgr_ = nullptr; -void WindowPatternStartingWindowRdbTest::SetUpTestCase() -{ -} +void WindowPatternStartingWindowRdbTest::SetUpTestCase() {} -void WindowPatternStartingWindowRdbTest::TearDownTestCase() -{ -} +void WindowPatternStartingWindowRdbTest::TearDownTestCase() {} void WindowPatternStartingWindowRdbTest::SetUp() { @@ -131,7 +127,7 @@ HWTEST_F(WindowPatternStartingWindowRdbTest, BatchInsert, TestSize.Level1) StartingWindowInfo firstStartingWindowInfo, secondStartingWindowInfo; firstItemKey.bundleName = "first"; secondItemKey.bundleName = "second"; - std::vector> inputValues { + std::vector> inputValues{ std::make_pair(firstItemKey, firstStartingWindowInfo), std::make_pair(secondItemKey, secondStartingWindowInfo), }; @@ -180,6 +176,6 @@ HWTEST_F(WindowPatternStartingWindowRdbTest, QueryData, TestSize.Level1) ASSERT_EQ(res, true); ASSERT_EQ(inputInfo.backgroundColor_, resInfo.backgroundColor_); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp index 8cd22d6aeb..c57c3139de 100644 --- a/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp +++ b/window_scene/test/unittest/window_pattern/window_pattern_starting_window_test.cpp @@ -61,13 +61,9 @@ void WindowPatternStartingWindowTest::TearDownTestCase() NativeRdb::RdbHelper::DeleteRdbStore(TEST_RDB_PATH + TEST_RDB_NAME); } -void WindowPatternStartingWindowTest::SetUp() -{ -} +void WindowPatternStartingWindowTest::SetUp() {} -void WindowPatternStartingWindowTest::TearDown() -{ -} +void WindowPatternStartingWindowTest::TearDown() {} void WindowPatternStartingWindowTest::InitTestStartingWindowRdb() { @@ -122,7 +118,7 @@ HWTEST_F(WindowPatternStartingWindowTest, GetStartupPage02, TestSize.Level1) cachedInfo.iconPathEarlyVersion_ = "pathFromCache"; ssm_->startingWindowMap_.clear(); auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_; - std::map startingWindowInfoMap { { key, cachedInfo } }; + std::map startingWindowInfoMap{ { key, cachedInfo } }; ssm_->startingWindowMap_.insert({ sessionInfo.bundleName_, startingWindowInfoMap }); StartingWindowInfo outInfo; outInfo.iconPathEarlyVersion_ = "default"; @@ -174,7 +170,7 @@ HWTEST_F(WindowPatternStartingWindowTest, GetStartingWindowInfoFromCache, TestSi auto res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); ASSERT_EQ(res, false); auto key = sessionInfo.moduleName_ + sessionInfo.abilityName_; - std::map startingWindowInfoMap { {key, startingWindowInfo } }; + std::map startingWindowInfoMap{ { key, startingWindowInfo } }; ssm_->startingWindowMap_.insert({ sessionInfo.bundleName_, startingWindowInfoMap }); res = ssm_->GetStartingWindowInfoFromCache(sessionInfo, startingWindowInfo); ASSERT_EQ(res, true); @@ -275,8 +271,7 @@ HWTEST_F(WindowPatternStartingWindowTest, CacheStartingWindowInfo01, TestSize.Le /** * @tc.steps: step2. Cache info and check result. */ - ssm_->CacheStartingWindowInfo( - abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name, startingWindowInfo); + ssm_->CacheStartingWindowInfo(abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name, startingWindowInfo); auto iter = ssm_->startingWindowMap_.find(abilityInfo.bundleName); ASSERT_NE(iter, ssm_->startingWindowMap_.end()); auto& infoMap = iter->second; @@ -314,14 +309,13 @@ HWTEST_F(WindowPatternStartingWindowTest, CacheStartingWindowInfo02, TestSize.Le .backgroundColorEarlyVersion_ = 0x00000000, .iconPathEarlyVersion_ = "path", }; - std::map startingWindowInfoMap{{ key, anotherStartingWindowInfo }}; - ssm_->startingWindowMap_.insert({abilityInfo.bundleName, startingWindowInfoMap}); + std::map startingWindowInfoMap{ { key, anotherStartingWindowInfo } }; + ssm_->startingWindowMap_.insert({ abilityInfo.bundleName, startingWindowInfoMap }); /** * @tc.steps: step3. Execute and check result. */ - ssm_->CacheStartingWindowInfo( - abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name, startingWindowInfo); + ssm_->CacheStartingWindowInfo(abilityInfo.bundleName, abilityInfo.moduleName, abilityInfo.name, startingWindowInfo); auto iter = ssm_->startingWindowMap_.find(abilityInfo.bundleName); ASSERT_NE(iter, ssm_->startingWindowMap_.end()); auto& infoMap = iter->second; @@ -358,6 +352,6 @@ HWTEST_F(WindowPatternStartingWindowTest, GetBundleStartingWindowInfos, TestSize ssm_->GetBundleStartingWindowInfos(bundleInfo, outValues); ASSERT_EQ(outValues.size(), 0); } -} +} // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_recover/BUILD.gn b/window_scene/test/unittest/window_recover/BUILD.gn index e68e187061..56fbdf29de 100644 --- a/window_scene/test/unittest/window_recover/BUILD.gn +++ b/window_scene/test/unittest/window_recover/BUILD.gn @@ -14,8 +14,7 @@ import("//build/test.gni") import("../../../../windowmanager_aafwk.gni") -module_out_path = - "window_manager/window_manager/window_scene/test/unittest/window_recover" +module_out_path = "window_manager/window_manager/window_scene/window_recover" ws_unittest_common = "../:ws_unittest_common" ohos_unittest("ws_window_recover_session_test") { diff --git a/window_scene/test/unittest/window_recover/window_recover_session_test.cpp b/window_scene/test/unittest/window_recover/window_recover_session_test.cpp index 52eb20d3bd..46d6fe1072 100644 --- a/window_scene/test/unittest/window_recover/window_recover_session_test.cpp +++ b/window_scene/test/unittest/window_recover/window_recover_session_test.cpp @@ -40,24 +40,21 @@ public: void SetUp() override; void TearDown() override; SessionInfo mainSessionInfo; - sptr specificCallback = nullptr; - sptr mainSession_; + sptr specificCallback = nullptr; + sptr mainSession_; SessionInfo sceneSessionInfo; - sptr sceneSession_; + sptr sceneSession_; sptr ssm_; std::shared_ptr sm_; + private: RSSurfaceNode::SharedPtr CreateRSSurfaceNode(); static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void WindowRecoverSessionTest::SetUpTestCase() -{ -} +void WindowRecoverSessionTest::SetUpTestCase() {} -void WindowRecoverSessionTest::TearDownTestCase() -{ -} +void WindowRecoverSessionTest::TearDownTestCase() {} void WindowRecoverSessionTest::SetUp() { @@ -99,9 +96,7 @@ RSSurfaceNode::SharedPtr WindowRecoverSessionTest::CreateRSSurfaceNode() return surfaceNode; } -void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) -{ -} +void NotifyRecoverSceneSessionFuncTest(const sptr& session, const SessionInfo& sessionInfo) {} namespace { @@ -239,7 +234,7 @@ HWTEST_F(WindowRecoverSessionTest, CheckSessionPropertyOnRecovery, TestSize.Leve sptr property = nullptr; WSError result = ssm_->CheckSessionPropertyOnRecovery(property, false); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); - + property = sptr::MakeSptr(); property->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); property->SetWindowFlags(123); @@ -253,7 +248,7 @@ HWTEST_F(WindowRecoverSessionTest, CheckSessionPropertyOnRecovery, TestSize.Leve ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM); // 主窗,需要恢复 - ssm_->SetAlivePersistentIds({100}); + ssm_->SetAlivePersistentIds({ 100 }); result = ssm_->CheckSessionPropertyOnRecovery(property, false); ASSERT_EQ(result, WSError::WS_OK); @@ -264,7 +259,7 @@ HWTEST_F(WindowRecoverSessionTest, CheckSessionPropertyOnRecovery, TestSize.Leve ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PARAM); // 特殊窗,需要恢复 - ssm_->SetAlivePersistentIds({111}); + ssm_->SetAlivePersistentIds({ 111 }); result = ssm_->CheckSessionPropertyOnRecovery(property, true); ASSERT_EQ(result, WSError::WS_OK); } @@ -284,18 +279,17 @@ HWTEST_F(WindowRecoverSessionTest, RecoverAndReconnectSceneSession, TestSize.Lev sptr session = nullptr; sptr token = nullptr; // 0.property 为空 - auto result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, - surfaceNode, session, property, token); + auto result = + ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, surfaceNode, session, property, token); EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR); property = sptr::MakeSptr(); property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); property->SetPersistentId(100); - ssm_->SetAlivePersistentIds({15, 16, 100}); + ssm_->SetAlivePersistentIds({ 15, 16, 100 }); // 1.已经恢复结束 ssm_->recoveringFinished_ = true; - result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, - surfaceNode, session, property, token); + result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, surfaceNode, session, property, token); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION); ssm_->recoveringFinished_ = false; @@ -306,15 +300,13 @@ HWTEST_F(WindowRecoverSessionTest, RecoverAndReconnectSceneSession, TestSize.Lev property->SetSessionInfo(sessionInfo); // 2.recoverSceneSessionFunc_ 为空 - result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, - surfaceNode, session, property, token); + result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, surfaceNode, session, property, token); EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR); - + // 3. sessionStage为空 property->SetPersistentId(15); ssm_->recoverSceneSessionFunc_ = NotifyRecoverSceneSessionFuncTest; - result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, - surfaceNode, session, property, token); + result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, surfaceNode, session, property, token); EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR); // 4.重连 @@ -325,8 +317,7 @@ HWTEST_F(WindowRecoverSessionTest, RecoverAndReconnectSceneSession, TestSize.Lev surfaceNode = CreateRSSurfaceNode(); property->SetPersistentId(16); property->SetWindowState(WindowState::STATE_SHOWN); - result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, - surfaceNode, session, property, token); + result = ssm_->RecoverAndReconnectSceneSession(sessionStage, eventChannel, surfaceNode, session, property, token); EXPECT_EQ(result, WSError::WS_OK); } @@ -345,18 +336,17 @@ HWTEST_F(WindowRecoverSessionTest, RecoverAndConnectSpecificSession, TestSize.Le sptr session = nullptr; sptr token = nullptr; // 0. property 为空 - auto result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, - surfaceNode, property, session, token); + auto result = + ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR); property = sptr::MakeSptr(); property->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); property->SetParentPersistentId(111); - ssm_->SetAlivePersistentIds({111}); + ssm_->SetAlivePersistentIds({ 111 }); // 1.已经恢复结束 ssm_->recoveringFinished_ = true; - result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, - surfaceNode, property, session, token); + result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION); ssm_->recoveringFinished_ = false; @@ -367,14 +357,12 @@ HWTEST_F(WindowRecoverSessionTest, RecoverAndConnectSpecificSession, TestSize.Le property->SetSessionInfo(sessionInfo); // 2.info persistentId 无效 - result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, - surfaceNode, property, session, token); + result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION); // 3. sessionStage 为空 property->SetPersistentId(20); - result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, - surfaceNode, property, session, token); + result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR); // 4.重连 窗口id:21,在前台 @@ -385,8 +373,7 @@ HWTEST_F(WindowRecoverSessionTest, RecoverAndConnectSpecificSession, TestSize.Le surfaceNode = CreateRSSurfaceNode(); property->SetPersistentId(21); property->SetWindowState(WindowState::STATE_SHOWN); - result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, - surfaceNode, property, session, token); + result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, surfaceNode, property, session, token); EXPECT_EQ(result, WSError::WS_OK); } @@ -465,7 +452,7 @@ HWTEST_F(WindowRecoverSessionTest, GetBatchAbilityInfos04, TestSize.Level1) */ HWTEST_F(WindowRecoverSessionTest, IsWindowSupportCacheForRecovering, TestSize.Level1) { - std::vector recoveredPersistentIds = {1}; + std::vector recoveredPersistentIds = { 1 }; ssm_->alivePersistentIds_.clear(); ssm_->alivePersistentIds_.push_back(1); ssm_->alivePersistentIds_.push_back(2); @@ -499,7 +486,7 @@ HWTEST_F(WindowRecoverSessionTest, IsWindowSupportCacheForRecovering, TestSize.L */ HWTEST_F(WindowRecoverSessionTest, IsWindowSupportCacheForRecovering01, TestSize.Level1) { - std::vector windowIds = {0, 1}; + std::vector windowIds = { 0, 1 }; sptr sceneSession = nullptr; ssm_->sceneSessionMap_.clear(); ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession)); @@ -699,8 +686,9 @@ HWTEST_F(WindowRecoverSessionTest, RecoverSessionInfo, TestSize.Level1) HWTEST_F(WindowRecoverSessionTest, UpdateRecoverPropertyForSuperFold, TestSize.Level1) { sptr property = sptr::MakeSptr(); - Rect rect = {static_cast(10), static_cast(10), - static_cast(100), static_cast(100)}; + Rect rect = { + static_cast(10), static_cast(10), static_cast(100), static_cast(100) + }; property->SetWindowRect(rect); property->SetRequestRect(rect); property->SetDisplayId(0); @@ -758,6 +746,6 @@ HWTEST_F(WindowRecoverSessionTest, RegisterSMSRecoverListener2, TestSize.Level1) ASSERT_EQ(sm_->isRecoverListenerRegistered_, true); } -} -} -} \ No newline at end of file +} // namespace +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/window_scene_config_test.cpp b/window_scene/test/unittest/window_scene_config_test.cpp index b3a8a47e65..3b20e4db5a 100755 --- a/window_scene/test/unittest/window_scene_config_test.cpp +++ b/window_scene/test/unittest/window_scene_config_test.cpp @@ -137,21 +137,13 @@ public: ConfigItem ReadConfig(const std::string& xmlStr); }; -void WindowSceneConfigTest::SetUpTestCase() -{ -} +void WindowSceneConfigTest::SetUpTestCase() {} -void WindowSceneConfigTest::TearDownTestCase() -{ -} +void WindowSceneConfigTest::TearDownTestCase() {} -void WindowSceneConfigTest::SetUp() -{ -} +void WindowSceneConfigTest::SetUp() {} -void WindowSceneConfigTest::TearDown() -{ -} +void WindowSceneConfigTest::TearDown() {} ConfigItem WindowSceneConfigTest::ReadConfig(const std::string& xmlStr) { @@ -221,7 +213,8 @@ HWTEST_F(WindowSceneConfigTest, AnimationConfig, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, MaxAppWindowNumber, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "0" ""; @@ -235,7 +228,8 @@ HWTEST_F(WindowSceneConfigTest, MaxAppWindowNumber, TestSize.Level1) ASSERT_EQ(true, value.size() >= 1); ASSERT_EQ(0, value[0]); - xmlStr = "" + xmlStr = + "" "" "-2" ""; @@ -245,7 +239,8 @@ HWTEST_F(WindowSceneConfigTest, MaxAppWindowNumber, TestSize.Level1) ASSERT_EQ(true, item.IsInts()); ASSERT_EQ(true, item.intsValue_->size() == 0); - xmlStr = "" + xmlStr = + "" "" "4" ""; @@ -257,7 +252,8 @@ HWTEST_F(WindowSceneConfigTest, MaxAppWindowNumber, TestSize.Level1) value = *item.intsValue_; ASSERT_EQ(4, value[0]); - xmlStr = "" + xmlStr = + "" "" "1000" ""; @@ -278,14 +274,16 @@ HWTEST_F(WindowSceneConfigTest, MaxAppWindowNumber, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, DecorConfig01, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ASSERT_EQ(true, WindowSceneConfig::config_["decor"].GetProp("enable").boolValue_); - xmlStr = "" + xmlStr = + "" "" "" ""; @@ -301,7 +299,8 @@ HWTEST_F(WindowSceneConfigTest, DecorConfig01, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, DecorConfig02, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "fullscreen" @@ -326,7 +325,8 @@ HWTEST_F(WindowSceneConfigTest, DecorConfig02, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, DecorConfig03, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "floating" @@ -351,7 +351,8 @@ HWTEST_F(WindowSceneConfigTest, DecorConfig03, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, DecorConfig04, TestSize.Level1) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "" "fullscreen floating" @@ -387,7 +388,7 @@ HWTEST_F(WindowSceneConfigTest, LoadConfigXml, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, ReadFloatNumbersConfigInfo, TestSize.Level1) { - xmlNodePtr currNode = xmlNewNode(NULL, BAD_CAST"nodeName"); + xmlNodePtr currNode = xmlNewNode(NULL, BAD_CAST "nodeName"); auto result = WindowSceneConfig::ReadFloatNumbersConfigInfo(currNode, false); ASSERT_EQ(0, result.size()); } @@ -399,7 +400,7 @@ HWTEST_F(WindowSceneConfigTest, ReadFloatNumbersConfigInfo, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, ReadStringConfigInfo, TestSize.Level1) { - xmlNodePtr currNode = xmlNewNode(NULL, BAD_CAST"nodeName"); + xmlNodePtr currNode = xmlNewNode(NULL, BAD_CAST "nodeName"); auto result = WindowSceneConfig::ReadStringConfigInfo(currNode); ASSERT_EQ(0, result.size()); } @@ -412,7 +413,8 @@ HWTEST_F(WindowSceneConfigTest, ReadStringConfigInfo, TestSize.Level1) */ HWTEST_F(WindowSceneConfigTest, MaxMidSceneNumConfig01, Function | SmallTest | Level2) { - std::string xmlStr = "" + std::string xmlStr = + "" "" "3" ""; diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 646b9244e4..41994c886d 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -28,13 +28,9 @@ public: static void TearDownTestCase(); }; -void WindowSessionPropertyTest::SetUpTestCase() -{ -} +void WindowSessionPropertyTest::SetUpTestCase() {} -void WindowSessionPropertyTest::TearDownTestCase() -{ -} +void WindowSessionPropertyTest::TearDownTestCase() {} namespace { /** @@ -208,8 +204,7 @@ HWTEST_F(WindowSessionPropertyTest, SetAndGetPipTemplateInfo, TestSize.Level1) PiPTemplateInfo pipTemplateInfo; pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); property->SetPiPTemplateInfo(pipTemplateInfo); - ASSERT_EQ(property->GetPiPTemplateInfo().pipTemplateType, - static_cast(PiPTemplateType::VIDEO_CALL)); + ASSERT_EQ(property->GetPiPTemplateInfo().pipTemplateType, static_cast(PiPTemplateType::VIDEO_CALL)); } /** @@ -421,8 +416,8 @@ HWTEST_F(WindowSessionPropertyTest, IsFloatingWindowAppType, TestSize.Level1) HWTEST_F(WindowSessionPropertyTest, SetTouchHotAreas, TestSize.Level0) { sptr property = sptr::MakeSptr(); - Rect rect { 4, 4, 4, 4 }; - std::vector vRect { rect }; + Rect rect{ 4, 4, 4, 4 }; + std::vector vRect{ rect }; property->SetPersistentId(0); property->SetSessionPropertyChangeCallback(nullptr); EXPECT_EQ(nullptr, property->touchHotAreasChangeCallback_); @@ -434,7 +429,7 @@ HWTEST_F(WindowSessionPropertyTest, SetTouchHotAreas, TestSize.Level0) property->SetTouchHotAreas(vRect); EXPECT_NE(nullptr, property->touchHotAreasChangeCallback_); - Rect rect1 { 5, 5, 5, 5 }; + Rect rect1{ 5, 5, 5, 5 }; vRect.emplace_back(rect1); property->SetTouchHotAreas(vRect); } @@ -448,7 +443,7 @@ HWTEST_F(WindowSessionPropertyTest, SetKeyboardTouchHotAreas, TestSize.Level1) { sptr property = sptr::MakeSptr(); KeyboardTouchHotAreas hotAreas; - Rect rect { 4, 4, 4, 4 }; + Rect rect{ 4, 4, 4, 4 }; hotAreas.landscapeKeyboardHotAreas_.push_back(rect); hotAreas.landscapePanelHotAreas_.push_back(rect); hotAreas.portraitKeyboardHotAreas_.push_back(rect); @@ -464,7 +459,7 @@ HWTEST_F(WindowSessionPropertyTest, SetKeyboardTouchHotAreas, TestSize.Level1) property->SetKeyboardTouchHotAreas(hotAreas); EXPECT_NE(nullptr, property->touchHotAreasChangeCallback_); - Rect rect1 { 5, 5, 5, 5 }; + Rect rect1{ 5, 5, 5, 5 }; hotAreas.landscapeKeyboardHotAreas_.push_back(rect1); hotAreas.landscapePanelHotAreas_.push_back(rect1); hotAreas.portraitKeyboardHotAreas_.push_back(rect1); @@ -510,8 +505,8 @@ HWTEST_F(WindowSessionPropertyTest, UnmarshallingTouchHotAreas, TestSize.Level1) { Parcel parcel; sptr property = sptr::MakeSptr(); - Rect rect { 4, 4, 4, 4 }; - std::vector vRect { rect }; + Rect rect{ 4, 4, 4, 4 }; + std::vector vRect{ rect }; WindowSessionProperty windowSessionProperty; windowSessionProperty.SetTouchHotAreas(vRect); windowSessionProperty.MarshallingTouchHotAreas(parcel); @@ -529,7 +524,7 @@ HWTEST_F(WindowSessionPropertyTest, UnmarshallingKeyboardTouchHotAreas, TestSize Parcel parcel; sptr property = sptr::MakeSptr(); KeyboardTouchHotAreas hotAreas; - Rect rect { 4, 4, 4, 4 }; + Rect rect{ 4, 4, 4, 4 }; hotAreas.landscapeKeyboardHotAreas_.push_back(rect); hotAreas.landscapePanelHotAreas_.push_back(rect); hotAreas.portraitKeyboardHotAreas_.push_back(rect); @@ -966,7 +961,7 @@ HWTEST_F(WindowSessionPropertyTest, GetWindowRect, TestSize.Level1) { sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); - Rect rect = {0, 0, 0, 0}; + Rect rect = { 0, 0, 0, 0 }; property->SetWindowRect(rect); auto result = property->GetWindowRect(); ASSERT_EQ(result, rect); @@ -995,7 +990,7 @@ HWTEST_F(WindowSessionPropertyTest, GetRequestRect, TestSize.Level1) { sptr property = sptr::MakeSptr(); ASSERT_NE(nullptr, property); - Rect requestRect = {0, 0, 0, 0}; + Rect requestRect = { 0, 0, 0, 0 }; property->SetRequestRect(requestRect); auto result = property->GetRequestRect(); ASSERT_EQ(result, requestRect); @@ -1212,7 +1207,7 @@ HWTEST_F(WindowSessionPropertyTest, MarshallingTouchHotAreas, TestSize.Level1) sptr property = sptr::MakeSptr(); std::vector rects; for (int i = 0; i < 55; i++) { - Rect rect { i, i, i, i }; + Rect rect{ i, i, i, i }; rects.push_back(rect); } property->SetTouchHotAreas(rects); @@ -1231,7 +1226,7 @@ HWTEST_F(WindowSessionPropertyTest, MarshallingKeyboardTouchHotAreas, TestSize.L sptr property = sptr::MakeSptr(); KeyboardTouchHotAreas hotAreas; for (int i = 0; i < 55; i++) { - Rect rect { i, i, i, i }; + Rect rect{ i, i, i, i }; hotAreas.landscapeKeyboardHotAreas_.push_back(rect); hotAreas.landscapePanelHotAreas_.push_back(rect); hotAreas.portraitKeyboardHotAreas_.push_back(rect); diff --git a/window_scene/test/unittest/ws_ffrt_helper_test.cpp b/window_scene/test/unittest/ws_ffrt_helper_test.cpp index 9a00fc9000..d819608ec6 100644 --- a/window_scene/test/unittest/ws_ffrt_helper_test.cpp +++ b/window_scene/test/unittest/ws_ffrt_helper_test.cpp @@ -40,13 +40,9 @@ private: WSFFRTHelper* wsFfrtHelper_; }; -void WSFFRTHelperTest::SetUpTestCase() -{ -} +void WSFFRTHelperTest::SetUpTestCase() {} -void WSFFRTHelperTest::TearDownTestCase() -{ -} +void WSFFRTHelperTest::TearDownTestCase() {} void WSFFRTHelperTest::SetUp() { @@ -68,7 +64,7 @@ HWTEST_F(WSFFRTHelperTest, SubmitTask001, TestSize.Level1) { ASSERT_NE(wsFfrtHelper_, nullptr); - auto mockTask = []{}; + auto mockTask = [] {}; std::string taskName = "testTask"; uint64_t delayTime = 0; TaskQos qos = TaskQos::USER_INTERACTIVE; @@ -93,7 +89,7 @@ HWTEST_F(WSFFRTHelperTest, SubmitTask002, TestSize.Level1) SET_THREAD_NUM(threadNum); auto submitTask = [] { for (size_t i = 0; i < TASK_NUM; ++i) { - auto mockTask = []{}; + auto mockTask = [] {}; int id = g_taskId.fetch_add(1); std::string taskName = "testTask" + std::to_string(id); uint64_t delayTime = 0; @@ -117,7 +113,7 @@ HWTEST_F(WSFFRTHelperTest, CancelTask001, TestSize.Level1) { ASSERT_NE(wsFfrtHelper_, nullptr); - auto mockTask = []{}; + auto mockTask = [] {}; std::string taskName = "testTask"; uint64_t delayTime = 0; TaskQos qos = TaskQos::USER_INTERACTIVE; @@ -139,7 +135,7 @@ HWTEST_F(WSFFRTHelperTest, CancelTask002, TestSize.Level1) ASSERT_NE(g_wsFfrtHelper, nullptr); constexpr int totalTaskNum = 50000; - auto mockTask = []{}; + auto mockTask = [] {}; for (size_t i = 0; i < totalTaskNum; ++i) { wsFfrtHelper_->SubmitTask(mockTask, "testTask" + std::to_string(i), 0, TaskQos::USER_INTERACTIVE); } @@ -161,4 +157,4 @@ HWTEST_F(WSFFRTHelperTest, CancelTask002, TestSize.Level1) g_wsFfrtHelper = nullptr; } -} \ No newline at end of file +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index d9c4d9328d..2cf0ed85a0 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -174,6 +174,8 @@ public: WMError SetWindowRectAutoSave(bool enabled, bool isSaveBySpecifiedFlag = false) override; WMError IsWindowRectAutoSave(bool& enabled) override; WMError MaximizeFloating() override; + WMError MaximizeForCompatibleMode(); + WMError RecoverForCompatibleMode(); WMError Maximize() override; WMError Maximize(MaximizePresentation presentation) override; WMError Recover() override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 6160e0a12e..e49038745a 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -252,6 +252,8 @@ public: void NotifyBackgroundFailed(WMError ret); WSError MarkProcessed(int32_t eventId) override; void UpdateTitleButtonVisibility(); + void HideTitleButton(bool& hideSplitButton, bool& hideMaximizeButton, bool& hideMinimizeButton, + bool& hideCloseButton); WSError NotifyDestroy() override; WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override; WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, @@ -435,6 +437,7 @@ public: void SetDisplayOrientationForRotation(DisplayOrientation displayOrientaion); DisplayOrientation GetDisplayOrientationForRotation() const; void SetPreferredRequestedOrientation(Orientation orientation) override; + WMError SetFollowScreenChange(bool isFollowScreenChange) override; protected: WMError Connect(); diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 38e771efa0..22a4ac787f 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -391,7 +391,6 @@ void WindowAdapter::WindowManagerAndSessionRecover() if (ret != WMError::WM_OK) { TLOGE(WmsLogTag::WMS_RECOVER, "Session recover callback, persistentId=%{public}" PRId32 " is error", it.first); - return; } } } diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 6d8d7f695a..f5f9c37937 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -106,6 +106,8 @@ constexpr int32_t DISPLAY_ID_C = 999; constexpr int32_t MAX_POINTERS = 16; constexpr int32_t TOUCH_SLOP_RATIO = 25; const std::string BACK_WINDOW_EVENT = "scb_back_window_event"; +const std::string COMPATIBLE_MAX_WINDOW_EVENT = "win_compatible_max_event"; +const std::string COMPATIBLE_RECOVER_WINDOW_EVENT = "win_compatible_recover_event"; const std::unordered_set INVALID_SYSTEM_WINDOW_TYPE = { WindowType::WINDOW_TYPE_NEGATIVE_SCREEN, WindowType::WINDOW_TYPE_THEME_EDITOR, @@ -2984,6 +2986,40 @@ WMError WindowSceneSessionImpl::Minimize() return WMError::WM_OK; } +WMError WindowSceneSessionImpl::MaximizeForCompatibleMode() +{ + TLOGI(WmsLogTag::WMS_LAYOUT_PC, "id: %{public}d", GetPersistentId()); + if (IsWindowSessionInvalid()) { + TLOGE(WmsLogTag::WMS_LAYOUT_PC, "session is invalid"); + return WMError::WM_ERROR_INVALID_WINDOW; + } + if (!WindowHelper::IsMainWindow(GetType())) { + TLOGE(WmsLogTag::WMS_LAYOUT_PC, "maximize fail, not main"); + return WMError::WM_ERROR_INVALID_CALLING; + } + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); + hostSession->OnSessionEvent(SessionEvent::EVENT_COMPATIBLE_TO_MAXIMIZE); + return WMError::WM_OK; +} + +WMError WindowSceneSessionImpl::RecoverForCompatibleMode() +{ + TLOGI(WmsLogTag::WMS_LAYOUT_PC, "id: %{public}d", GetPersistentId()); + if (IsWindowSessionInvalid()) { + TLOGE(WmsLogTag::WMS_LAYOUT_PC, "session is invalid"); + return WMError::WM_ERROR_INVALID_WINDOW; + } + if (!WindowHelper::IsMainWindow(GetType())) { + TLOGE(WmsLogTag::WMS_LAYOUT_PC, "recover fail, not main"); + return WMError::WM_ERROR_INVALID_CALLING; + } + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); + hostSession->OnSessionEvent(SessionEvent::EVENT_COMPATIBLE_TO_RECOVER); + return WMError::WM_OK; +} + WMError WindowSceneSessionImpl::Maximize() { TLOGI(WmsLogTag::WMS_LAYOUT_PC, "id: %{public}d", GetPersistentId()); @@ -5870,6 +5906,12 @@ WMError WindowSceneSessionImpl::OnContainerModalEvent(const std::string& eventNa } else if (eventName == BACK_WINDOW_EVENT) { HandleBackEvent(); return WMError::WM_OK; + } else if (eventName == COMPATIBLE_MAX_WINDOW_EVENT) { + MaximizeForCompatibleMode(); + return WMError::WM_OK; + } else if (eventName == COMPATIBLE_RECOVER_WINDOW_EVENT) { + RecoverForCompatibleMode(); + return WMError::WM_OK; } return WMError::WM_DO_NOTHING; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 6cb6df2b1d..e7fd395246 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -81,6 +81,7 @@ const std::string DECOR_BUTTON_STYLE_CHANGE = "decor_button_style_change"; constexpr int64_t SET_UIEXTENSION_DESTROY_TIMEOUT_TIME_MS = 4000; const std::string SCB_BACK_VISIBILITY = "scb_back_visibility"; +const std::string SCB_COMPATIBLE_MAXIMIZE_VISIBILITY = "scb_compatible_maximize_visibility"; Ace::ContentInfoType GetAceContentInfoType(BackupAndRestoreType type) { @@ -1559,16 +1560,7 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() "[%{public}d, %{public}d, %{public}d, %{public}d]", hideSplitButton, hideMaximizeButton, hideMinimizeButton, hideCloseButton); bool isSuperFoldDisplayDevice = FoldScreenStateInternel::IsSuperFoldDisplayDevice(); - if (property_->GetCompatibleModeInPc() && !property_->GetIsAtomicService()) { - bool isLayoutFullScreen = property_->IsLayoutFullScreen(); - uiContent->HideWindowTitleButton(true, !isLayoutFullScreen, hideMinimizeButton, hideCloseButton); - if (!property_->GetCompatibleModeInPcTitleVisible()) { - uiContent->OnContainerModalEvent(SCB_BACK_VISIBILITY, isLayoutFullScreen ? "false" : "true"); - } - } else { - uiContent->HideWindowTitleButton(hideSplitButton, hideMaximizeButton, hideMinimizeButton, hideCloseButton); - uiContent->OnContainerModalEvent(SCB_BACK_VISIBILITY, "false"); - } + HideTitleButton(hideSplitButton, hideMaximizeButton, hideMinimizeButton, hideCloseButton); if (isSuperFoldDisplayDevice) { handler_->PostTask([weakThis = wptr(this), where = __func__] { auto window = weakThis.promote(); @@ -1587,6 +1579,27 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() } } +void WindowSessionImpl::HideTitleButton(bool& hideSplitButton, bool& hideMaximizeButton, + bool& hideMinimizeButton, bool& hideCloseButton) +{ + std::shared_ptr uiContent = GetUIContentSharedPtr(); + if (uiContent == nullptr || !IsDecorEnable()) { + return; + } + if (property_->GetCompatibleModeInPc() && !property_->GetIsAtomicService()) { + bool isLayoutFullScreen = property_->IsLayoutFullScreen(); + uiContent->HideWindowTitleButton(true, !isLayoutFullScreen, hideMinimizeButton, hideCloseButton); + if (!property_->GetCompatibleModeInPcTitleVisible()) { + uiContent->OnContainerModalEvent(SCB_BACK_VISIBILITY, isLayoutFullScreen ? "false" : "true"); + uiContent->OnContainerModalEvent(SCB_COMPATIBLE_MAXIMIZE_VISIBILITY, isLayoutFullScreen ? "false" : "true"); + } + } else { + uiContent->HideWindowTitleButton(hideSplitButton, hideMaximizeButton, hideMinimizeButton, hideCloseButton); + uiContent->OnContainerModalEvent(SCB_BACK_VISIBILITY, "false"); + uiContent->OnContainerModalEvent(SCB_COMPATIBLE_MAXIMIZE_VISIBILITY, "false"); + } +} + WMError WindowSessionImpl::NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) { @@ -2583,14 +2596,14 @@ WMError WindowSessionImpl::UnregisterWindowChangeListener(const sptr& listener) { WLOGFD("in"); - std::lock_guard lockListener(windowChangeListenerMutex_); + std::lock_guard lockListener(windowCrossAxisListenerMutex_); return RegisterListener(windowCrossAxisListeners_[GetPersistentId()], listener); } WMError WindowSessionImpl::UnregisterWindowCrossAxisListener(const sptr& listener) { WLOGFD("in"); - std::lock_guard lockListener(windowChangeListenerMutex_); + std::lock_guard lockListener(windowCrossAxisListenerMutex_); return UnregisterListener(windowCrossAxisListeners_[GetPersistentId()], listener); } @@ -3328,7 +3341,7 @@ void WindowSessionImpl::NotifyWindowCrossAxisChange(CrossAxisState state) uiContent->SendUIExtProprty(static_cast(Extension::Businesscode::SYNC_CROSS_AXIS_STATE), want, static_cast(SubSystemId::WM_UIEXT)); } - std::lock_guard lockListener(windowTitleButtonRectChangeListenerMutex_); + std::lock_guard lockListener(windowCrossAxisListenerMutex_); auto windowCrossAxisListeners = GetListeners(); for (const auto& listener : windowCrossAxisListeners) { if (listener != nullptr) { @@ -3661,6 +3674,22 @@ WSError WindowSessionImpl::SetSplitButtonVisible(bool isVisible) return WSError::WS_OK; } +WMError WindowSessionImpl::SetFollowScreenChange(bool isFollowScreenChange) +{ + TLOGI(WmsLogTag::DEFAULT, "window %{public}u set follow screen change: %{public}d", + GetWindowId(), isFollowScreenChange); + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + + if (!WindowHelper::IsSystemWindow(property_->GetWindowType())) { + TLOGE(WmsLogTag::DEFAULT, "window %{public}u type not support", GetWindowId()); + return WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE; + } + property_->SetFollowScreenChange(isFollowScreenChange); + return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE); +} + WMError WindowSessionImpl::GetIsMidScene(bool& isMidScene) { if (IsWindowSessionInvalid()) { diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index b18e273160..9f42946327 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1085,6 +1085,48 @@ HWTEST_F(WindowSceneSessionImplTest, Maximize01, TestSize.Level1) ASSERT_EQ(WMError::WM_OK, windowSceneSession->Maximize()); } +/** + * @tc.name: MaximizeForCompatibleMode + * @tc.desc: MaximizeForCompatibleMode + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, MaximizeForCompatibleMode, Function | SmallTest | Level2) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("MaximizeForCompatibleMode"); + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sptr windowSceneSession = sptr::MakeSptr(option); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->MaximizeForCompatibleMode()); + + windowSceneSession->property_->SetPersistentId(1); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + + windowSceneSession->hostSession_ = session; + ASSERT_EQ(WMError::WM_OK, windowSceneSession->MaximizeForCompatibleMode()); +} + +/** + * @tc.name: RecoverForCompatibleMode + * @tc.desc: RecoverForCompatibleMode + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, RecoverForCompatibleMode, Function | SmallTest | Level2) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("RecoverForCompatibleMode"); + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sptr windowSceneSession = sptr::MakeSptr(option); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, windowSceneSession->RecoverForCompatibleMode()); + + windowSceneSession->property_->SetPersistentId(1); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = sptr::MakeSptr(sessionInfo); + + windowSceneSession->hostSession_ = session; + ASSERT_EQ(WMError::WM_OK, windowSceneSession->RecoverForCompatibleMode()); +} + /** * @tc.name: Hide01 * @tc.desc: Hide session diff --git a/wm/test/unittest/window_scene_test.cpp b/wm/test/unittest/window_scene_test.cpp index 9a9ae5bc3d..90630725f3 100644 --- a/wm/test/unittest/window_scene_test.cpp +++ b/wm/test/unittest/window_scene_test.cpp @@ -585,6 +585,42 @@ HWTEST_F(WindowSceneTest, NotifyMemoryLevel03, TestSize.Level1) ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->NotifyMemoryLevel(0)); // ui content is null } +/** + * @tc.name: GoDestroyHookWindow + * @tc.desc: Destroy hook window + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneTest, GoDestroyHookWindow, TestSize.Level1) +{ + DisplayId displayId = 0; + std::unique_ptr m = std::make_unique(); + sptr listener = nullptr; + sptr scene = sptr::MakeSptr(); + sptr option = sptr::MakeSptr(); + EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowSceneSessionImpl(option))); + ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, scene->GoDestroyHookWindow()); +} + +/** + * @tc.name: SetHookedWindowElementInfo + * @tc.desc: SetHookedWindowElementInfo + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneTest, SetHookedWindowElementInfo, TestSize.Level1) +{ + DisplayId displayId = 0; + AppExecFwk::ElementName elementName; + sptr scene = sptr::MakeSptr(); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->SetHookedWindowElementInfo(elementName)); + + std::unique_ptr m = std::make_unique(); + sptr listener = nullptr; + sptr option = sptr::MakeSptr(); + EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowSceneSessionImpl(option))); + ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener)); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->SetHookedWindowElementInfo(elementName)); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wm/test/unittest/window_session_impl_test5.cpp b/wm/test/unittest/window_session_impl_test5.cpp index 1f54a09a54..fca8ffe060 100644 --- a/wm/test/unittest/window_session_impl_test5.cpp +++ b/wm/test/unittest/window_session_impl_test5.cpp @@ -619,6 +619,35 @@ HWTEST_F(WindowSessionImplTest5, GetRequestedOrientation, Function | SmallTest | EXPECT_EQ(window->GetRequestedOrientation(), Orientation::FOLLOW_DESKTOP); GTEST_LOG_(INFO) << "WindowSessionImplTest5: GetRequestedOrientation end"; } + +/** + * @tc.name: SetFollowScreenChange + * @tc.desc: SetFollowScreenChange + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, SetFollowScreenChange, Function | SmallTest | Level2) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("SetFollowScreenChange"); + + sptr window = sptr::MakeSptr(option); + window->property_->SetPersistentId(0); + WMError ret = window->SetFollowScreenChange(true); + EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret); + + window->property_->SetPersistentId(1); + window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_END); + ret = window->SetFollowScreenChange(true); + EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, ret); + + window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); + ret = window->SetFollowScreenChange(true); + EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, ret); + + window->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); + ret = window->SetFollowScreenChange(true); + EXPECT_EQ(WMError::WM_OK, ret); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 148fb6a90f..4e9c3c054c 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -1606,6 +1606,10 @@ WMError WindowController::UpdateProperty(sptr& property, Propert node->GetWindowProperty()->SetTextFieldHeight(property->GetTextFieldHeight()); break; } + case PropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE: { + node->GetWindowProperty()->SetFollowScreenChange(property->GetFollowScreenChange()); + break; + } default: break; } -- Gitee