mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 00:51:35 +00:00
Add moveMissionsToForeground/moveMissionsToBackground
Signed-off-by: wangyong <wangyong5@huawei.com> Change-Id: I64c1b26d6b040b20dbfd7f821814938679502b16
This commit is contained in:
parent
fe9f42610e
commit
5567aae00f
@ -19,6 +19,7 @@ config("libwms_config") {
|
||||
"include",
|
||||
"include/utils",
|
||||
"include/window_snapshot",
|
||||
"include/window_group",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//foundation/window/window_manager/interfaces/innerkits/wm",
|
||||
"//foundation/window/window_manager/interfaces/innerkits/dm",
|
||||
@ -55,6 +56,7 @@ ohos_shared_library("libwms") {
|
||||
"src/window_common_event.cpp",
|
||||
"src/window_controller.cpp",
|
||||
"src/window_dumper.cpp",
|
||||
"src/window_group_mgr.cpp",
|
||||
"src/window_inner_manager.cpp",
|
||||
"src/window_layout_policy.cpp",
|
||||
"src/window_layout_policy_cascade.cpp",
|
||||
|
67
wmserver/include/window_group_mgr.h
Normal file
67
wmserver/include/window_group_mgr.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ROSEN_WINDOW_GROUP_MGR_H
|
||||
#define OHOS_ROSEN_WINDOW_GROUP_MGR_H
|
||||
|
||||
#include <refbase.h>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "window_root.h"
|
||||
#include "window_transition_info.h"
|
||||
#include "wm_common.h"
|
||||
#include "wm_occlusion_region.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class WindowGroupMgr : public RefBase {
|
||||
public:
|
||||
explicit WindowGroupMgr(sptr<WindowRoot>& root) : windowRoot_(root) {
|
||||
}
|
||||
|
||||
static constexpr int32_t DEFAULT_GROUP_ID = 0;
|
||||
static constexpr int32_t START_GROUP_ID = 1;
|
||||
static constexpr int32_t MAX_GROUP_NUM = 3;
|
||||
|
||||
static constexpr int32_t DEFAULT_MISSION_ID = -1;
|
||||
|
||||
WMError MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId);
|
||||
WMError MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result);
|
||||
|
||||
void OnWindowDestroyed(uint32_t windowId);
|
||||
void OnDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
|
||||
|
||||
private:
|
||||
WMError MoveMissionToForeground(int32_t missionId);
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
std::unordered_map<uint32_t, WindowMode> backupWindowModes_;
|
||||
std::map<DisplayId, Rect> backupDividerWindowRect_;
|
||||
|
||||
template<typename T> std::string DumpVector(std::vector<T> vec)
|
||||
{
|
||||
std::stringstream oss;
|
||||
oss << "[ ";
|
||||
for (T& v : vec) {
|
||||
oss << v << ", ";
|
||||
}
|
||||
oss << " ]";
|
||||
return oss.str();
|
||||
}
|
||||
};
|
||||
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
#endif // OHOS_ROSEN_WINDOW_GROUP_MGR_H
|
@ -16,32 +16,33 @@
|
||||
#ifndef OHOS_WINDOW_MANAGER_SERVICE_H
|
||||
#define OHOS_WINDOW_MANAGER_SERVICE_H
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "event_handler.h"
|
||||
|
||||
#include <input_window_monitor.h>
|
||||
#include <map>
|
||||
#include <nocopyable.h>
|
||||
#include <system_ability.h>
|
||||
#include <window_manager_service_handler_stub.h>
|
||||
#include <transaction/rs_interfaces.h>
|
||||
#include <vector>
|
||||
#include <window_manager_service_handler_stub.h>
|
||||
|
||||
#include "atomic_map.h"
|
||||
#include "display_change_listener.h"
|
||||
#include "drag_controller.h"
|
||||
#include "event_handler.h"
|
||||
#include "freeze_controller.h"
|
||||
#include "perform_reporter.h"
|
||||
#include "singleton_delegator.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "wm_single_instance.h"
|
||||
#include "snapshot_controller.h"
|
||||
#include "struct_multimodal.h"
|
||||
#include "window_common_event.h"
|
||||
#include "window_controller.h"
|
||||
#include "zidl/window_manager_stub.h"
|
||||
#include "window_dumper.h"
|
||||
#include "window_group_mgr.h"
|
||||
#include "window_manager_config.h"
|
||||
#include "window_root.h"
|
||||
#include "window_system_effect.h"
|
||||
#include "snapshot_controller.h"
|
||||
#include "perform_reporter.h"
|
||||
#include "struct_multimodal.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "wm_single_instance.h"
|
||||
#include "zidl/window_manager_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -68,6 +69,9 @@ public:
|
||||
sptr<AAFwk::AbilityTransitionInfo> info, std::shared_ptr<Media::PixelMap> pixelMap) override;
|
||||
virtual void CancelStartingWindow(sptr<IRemoteObject> abilityToken) override;
|
||||
virtual void NotifyAnimationAbilityDied(sptr<AAFwk::AbilityTransitionInfo> info) override;
|
||||
virtual int32_t MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override;
|
||||
virtual int32_t MoveMissionsToBackground(
|
||||
const std::vector<int32_t>& missionIds, std::vector<int32_t>& result) override;
|
||||
};
|
||||
|
||||
class RSUIDirector;
|
||||
@ -127,6 +131,9 @@ public:
|
||||
void StartingWindow(sptr<WindowTransitionInfo> info, std::shared_ptr<Media::PixelMap> pixelMap,
|
||||
bool isColdStart, uint32_t bkgColor = 0xffffffff);
|
||||
void CancelStartingWindow(sptr<IRemoteObject> abilityToken);
|
||||
WMError MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId);
|
||||
WMError MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result);
|
||||
void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
|
||||
sptr<RSIWindowAnimationFinishedCallback>& finishCallback) override;
|
||||
WMError UpdateRsTree(uint32_t windowId, bool isAdd) override;
|
||||
@ -189,6 +196,7 @@ private:
|
||||
sptr<DragController> dragController_;
|
||||
sptr<FreezeController> freezeDisplayController_;
|
||||
sptr<WindowDumper> windowDumper_;
|
||||
sptr<WindowGroupMgr> windowGroupMgr_;
|
||||
SystemConfig systemConfig_;
|
||||
ModeChangeHotZonesConfig hotZonesConfig_ { false, 0, 0, 0 };
|
||||
std::shared_ptr<WindowCommonEvent> windowCommonEvent_;
|
||||
|
181
wmserver/src/window_group_mgr.cpp
Normal file
181
wmserver/src/window_group_mgr.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 <ability_manager_client.h>
|
||||
#include <transaction/rs_transaction.h>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "display_manager_service_inner.h"
|
||||
#include "dm_common.h"
|
||||
#include "singleton_container.h"
|
||||
#include "window_adapter.h"
|
||||
#include "window_group_mgr.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "window_manager_service.h"
|
||||
#include "minimize_app.h"
|
||||
#include "wm_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowGroupMgr"};
|
||||
}
|
||||
|
||||
WMError WindowGroupMgr::MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
|
||||
{
|
||||
WLOGFD("%{public}s, topMissionId: %{public}d ", DumpVector(missionIds).c_str(), topMissionId);
|
||||
if (missionIds.empty()) {
|
||||
return WMError::WM_DO_NOTHING;
|
||||
}
|
||||
|
||||
WMError res = WMError::WM_OK;
|
||||
for (auto it = missionIds.rbegin(); it != missionIds.rend(); it++) {
|
||||
if (*it == topMissionId) {
|
||||
continue;
|
||||
}
|
||||
WMError tempRes = MoveMissionToForeground(*it);
|
||||
res = tempRes != WMError::WM_OK ? tempRes : res;
|
||||
}
|
||||
|
||||
if (topMissionId != DEFAULT_MISSION_ID) {
|
||||
WMError tempRes = MoveMissionToForeground(topMissionId);
|
||||
res = tempRes == WMError::WM_OK ? tempRes : res;
|
||||
WLOGFD("raise zOrder, missindId: %{public}d ", topMissionId);
|
||||
auto windowNode = windowRoot_->GetWindowNodeByMissionId(topMissionId);
|
||||
windowRoot_->RaiseZOrderForAppWindow(windowNode);
|
||||
OHOS::Rosen::RSTransaction::FlushImplicitTransaction();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
WMError WindowGroupMgr::MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result)
|
||||
{
|
||||
WLOGFD("%{public}s ", DumpVector(missionIds).c_str());
|
||||
if (missionIds.empty()) {
|
||||
return WMError::WM_DO_NOTHING;
|
||||
}
|
||||
|
||||
std::vector<sptr<WindowNode>> windowNodes;
|
||||
std::vector<uint32_t> hideWindowIds;
|
||||
for (auto missionId : missionIds) {
|
||||
sptr<WindowNode> windowNode = windowRoot_->GetWindowNodeByMissionId(missionId);
|
||||
if (!windowNode) {
|
||||
continue;
|
||||
}
|
||||
windowNodes.emplace_back(windowNode);
|
||||
}
|
||||
std::sort(windowNodes.begin(), windowNodes.end(), [](const sptr<WindowNode>& w1, const sptr<WindowNode>& w2) {
|
||||
return w1->zOrder_ > w2->zOrder_;
|
||||
});
|
||||
|
||||
std::unordered_set<DisplayId> displayIds;
|
||||
for (auto windowNode : windowNodes) {
|
||||
result.emplace_back(windowNode->abilityInfo_.missionId_);
|
||||
hideWindowIds.emplace_back(windowNode->GetWindowId());
|
||||
backupWindowModes_[windowNode->GetWindowId()] = windowNode->GetWindowMode();
|
||||
WLOGFD("windowId: %{public}d, missionId: %{public}d, node: %{public}s, zOrder: %{public}d, "
|
||||
"mode: %{public}d ", windowNode->GetWindowId(), windowNode->abilityInfo_.missionId_,
|
||||
(windowNode == nullptr ? "NUll" : windowNode->GetWindowName().c_str()),
|
||||
windowNode->zOrder_, windowNode->GetWindowMode());
|
||||
displayIds.insert(windowNode->GetDisplayId());
|
||||
}
|
||||
|
||||
for (auto displayId : displayIds) {
|
||||
auto container = windowRoot_->GetOrCreateWindowNodeContainer(displayId);
|
||||
if (container != nullptr) {
|
||||
auto windowPair = container->GetDisplayGroupController()->GetWindowPairByDisplayId(displayId);
|
||||
if (windowPair && windowPair->GetDividerWindow()) {
|
||||
backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WLOGFD("WindowGroupMgr::HideWindowGroup, hide WindowIds: %{public}s", DumpVector(hideWindowIds).c_str());
|
||||
windowRoot_->MinimizeTargetWindows(hideWindowIds);
|
||||
MinimizeApp::ExecuteMinimizeTargetReasons(MinimizeReason::GESTURE_ANIMATION);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowGroupMgr::MoveMissionToForeground(int32_t missionId)
|
||||
{
|
||||
auto windowNode = windowRoot_->GetWindowNodeByMissionId(missionId);
|
||||
if (windowNode == nullptr || windowNode->GetWindowToken() == nullptr) {
|
||||
WLOGFE("GetWindowToken failed, missionId: %{public}d", missionId);
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
auto property = windowNode->GetWindowToken()->GetWindowProperty();
|
||||
if (property == nullptr) {
|
||||
WLOGFE("Get property failed , skip, missionId: %{public}d ", missionId);
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
std::set<DisplayId> displayIds;
|
||||
if (backupWindowModes_.count(windowNode->GetWindowId()) > 0) {
|
||||
auto mode = backupWindowModes_.at(windowNode->GetWindowId());
|
||||
if (mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) {
|
||||
property->SetWindowMode(mode);
|
||||
windowNode->SetWindowMode(mode);
|
||||
// when change mode, need to reset shadow and radius
|
||||
WindowSystemEffect::SetWindowEffect(windowNode);
|
||||
displayIds.insert(windowNode->GetDisplayId());
|
||||
windowNode->GetWindowToken()->RestoreSplitWindowMode(static_cast<uint32_t>(mode));
|
||||
WLOGFD("Restore windowId: %{public}d, missionId: %{public}d, node: %{public}s, \
|
||||
zOrder: %{public}d, mode: %{public}d ",
|
||||
windowNode->GetWindowId(), windowNode->abilityInfo_.missionId_,
|
||||
(windowNode == nullptr ? "NUll" : windowNode->GetWindowName().c_str()),
|
||||
windowNode->zOrder_, windowNode->GetWindowMode());
|
||||
}
|
||||
}
|
||||
for (auto displayId : displayIds) {
|
||||
auto container = windowRoot_->GetOrCreateWindowNodeContainer(displayId);
|
||||
if (container != nullptr) {
|
||||
auto windowPair = container->GetDisplayGroupController()->GetWindowPairByDisplayId(displayId);
|
||||
if (windowPair != nullptr) {
|
||||
windowPair->SetAllSplitAppWindowsRestoring(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
windowNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_SHOWN);
|
||||
WindowManagerService::GetInstance().AddWindow(property);
|
||||
for (auto displayId : displayIds) {
|
||||
auto container = windowRoot_->GetOrCreateWindowNodeContainer(displayId);
|
||||
if (container != nullptr) {
|
||||
auto windowPair = container->GetDisplayGroupController()->GetWindowPairByDisplayId(displayId);
|
||||
if (windowPair != nullptr) {
|
||||
windowPair->SetAllSplitAppWindowsRestoring(false);
|
||||
container->GetLayoutPolicy()->SetSplitDividerWindowRects(backupDividerWindowRect_);
|
||||
}
|
||||
}
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowGroupMgr::OnWindowDestroyed(uint32_t windowId)
|
||||
{
|
||||
WLOGFD("OnWindowDestroyed WindowIds: %{public}d", windowId);
|
||||
backupWindowModes_.erase(windowId);
|
||||
}
|
||||
|
||||
void WindowGroupMgr::OnDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type)
|
||||
{
|
||||
WLOGFD("OnDisplayStateChange displayId: %{public}" PRIu64", type: %{public}d", defaultDisplayId, type);
|
||||
if (type == DisplayStateChangeType::DESTROY) {
|
||||
backupDividerWindowRect_.erase(defaultDisplayId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -73,6 +73,7 @@ WindowManagerService::WindowManagerService() : SystemAbility(WINDOW_MANAGER_SERV
|
||||
runner_ = AppExecFwk::EventRunner::Create(name_);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(runner_);
|
||||
snapshotController_ = new SnapshotController(windowRoot_, handler_);
|
||||
windowGroupMgr_ = new WindowGroupMgr(windowRoot_);
|
||||
int ret = HiviewDFX::Watchdog::GetInstance().AddThread(name_, handler_);
|
||||
if (ret != 0) {
|
||||
WLOGFE("Add watchdog thread failed");
|
||||
@ -249,6 +250,20 @@ void WindowManagerServiceHandler::CancelStartingWindow(sptr<IRemoteObject> abili
|
||||
WindowManagerService::GetInstance().CancelStartingWindow(abilityToken);
|
||||
}
|
||||
|
||||
int32_t WindowManagerServiceHandler::MoveMissionsToForeground(const std::vector<int32_t>& missionIds,
|
||||
int32_t topMissionId)
|
||||
{
|
||||
WLOGD("WindowManagerServiceHandler MoveMissionsToForeground!");
|
||||
return static_cast<int32_t>(WindowManagerService::GetInstance().MoveMissionsToForeground(missionIds, topMissionId));
|
||||
}
|
||||
|
||||
int32_t WindowManagerServiceHandler::MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result)
|
||||
{
|
||||
WLOGD("WindowManagerServiceHandler MoveMissionsToBackground!");
|
||||
return static_cast<int32_t>(WindowManagerService::GetInstance().MoveMissionsToBackground(missionIds, result));
|
||||
}
|
||||
|
||||
bool WindowManagerService::Init()
|
||||
{
|
||||
WLOGI("Init start");
|
||||
@ -730,6 +745,38 @@ void WindowManagerService::CancelStartingWindow(sptr<IRemoteObject> abilityToken
|
||||
});
|
||||
}
|
||||
|
||||
WMError WindowManagerService::MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
|
||||
{
|
||||
if (windowGroupMgr_) {
|
||||
return PostSyncTask([this, &missionIds, topMissionId]() {
|
||||
WMError res = windowGroupMgr_->MoveMissionsToForeground(missionIds, topMissionId);
|
||||
// no need to return inner error to caller
|
||||
if (res > WMError::WM_ERROR_NEED_REPORT_BASE) {
|
||||
return res;
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
});
|
||||
}
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
WMError WindowManagerService::MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result)
|
||||
{
|
||||
if (windowGroupMgr_) {
|
||||
return PostSyncTask([this, &missionIds, &result]() {
|
||||
WMError res = windowGroupMgr_->MoveMissionsToBackground(missionIds, result);
|
||||
// no need to return wms inner error to caller
|
||||
if (res > WMError::WM_ERROR_NEED_REPORT_BASE) {
|
||||
return res;
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
});
|
||||
}
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
|
||||
bool WindowManagerService::CheckAnimationPermission(const sptr<WindowProperty>& property) const
|
||||
{
|
||||
WindowType type = property->GetWindowType();
|
||||
@ -867,6 +914,7 @@ WMError WindowManagerService::DestroyWindow(uint32_t windowId, bool onlySelf)
|
||||
WLOGI("[WMS] Destroy: %{public}u", windowId);
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "wms:DestroyWindow(%u)", windowId);
|
||||
WindowInnerManager::GetInstance().NotifyWindowRemovedOrDestroyed(windowId);
|
||||
windowGroupMgr_->OnWindowDestroyed(windowId);
|
||||
auto node = windowRoot_->GetWindowNode(windowId);
|
||||
if (node == nullptr) {
|
||||
return WMError::WM_OK;
|
||||
@ -992,6 +1040,7 @@ void WindowManagerService::OnWindowEvent(Event event, const sptr<IRemoteObject>&
|
||||
dragController_->FinishDrag(windowId);
|
||||
}
|
||||
WindowInnerManager::GetInstance().NotifyWindowRemovedOrDestroyed(windowId);
|
||||
windowGroupMgr_->OnWindowDestroyed(windowId);
|
||||
windowController_->DestroyWindow(windowId, node->stateMachine_.GetDestroyTaskParam());
|
||||
};
|
||||
|
||||
@ -1027,6 +1076,7 @@ void WindowManagerService::NotifyDisplayStateChange(DisplayId defaultDisplayId,
|
||||
} else {
|
||||
PostAsyncTask([this, defaultDisplayId, displayInfo, displayInfoMap, type]() mutable {
|
||||
windowController_->NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
|
||||
windowGroupMgr_->OnDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ group("unittest") {
|
||||
":wmserver_window_display_zoom_controller_test",
|
||||
":wmserver_window_dumper_test",
|
||||
":wmserver_window_freeze_controller_test",
|
||||
":wmserver_window_group_mgr_test",
|
||||
":wmserver_window_inner_manager_test",
|
||||
":wmserver_window_inner_window_test",
|
||||
":wmserver_window_layout_policy_test",
|
||||
@ -397,3 +398,13 @@ ohos_unittest("wmserver_window_manager_service_utils_test") {
|
||||
external_deps += [ "init_lite:libbegetutil" ]
|
||||
}
|
||||
}
|
||||
|
||||
ohos_unittest("wmserver_window_group_mgr_test") {
|
||||
module_out_path = module_out_path
|
||||
configs = test_public_config
|
||||
sources = [ "window_group_mgr_test.cpp" ]
|
||||
|
||||
deps = test_inner_deps
|
||||
public_deps = test_public_deps
|
||||
external_deps = test_external_deps
|
||||
}
|
||||
|
152
wmserver/test/unittest/window_group_mgr_test.cpp
Normal file
152
wmserver/test/unittest/window_group_mgr_test.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 <cstdint>
|
||||
#include <gtest/gtest.h>
|
||||
#include "display_manager.h"
|
||||
#include "window_agent.h"
|
||||
#include "window_group_mgr.h"
|
||||
#include "window_impl.h"
|
||||
#include "window_property.h"
|
||||
#include "window_root.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, "WindowGroupMgrTest"};
|
||||
}
|
||||
|
||||
class WindowGroupMgrTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
static sptr<WindowGroupMgr> windowGroupMgr_;
|
||||
static sptr<WindowRoot> windowRoot_;
|
||||
static DisplayId defalutDisplayId_;
|
||||
static int missionCount_;
|
||||
};
|
||||
|
||||
|
||||
sptr<WindowGroupMgr> WindowGroupMgrTest::windowGroupMgr_ = nullptr;
|
||||
sptr<WindowRoot> WindowGroupMgrTest::windowRoot_;
|
||||
DisplayId WindowGroupMgrTest::defalutDisplayId_ = -1;
|
||||
int WindowGroupMgrTest::missionCount_ = 3;
|
||||
|
||||
void WindowGroupMgrTest::SetUpTestCase()
|
||||
{
|
||||
WLOGI("SetUpTestCase");
|
||||
windowRoot_ = new WindowRoot(nullptr);
|
||||
windowGroupMgr_ = new WindowGroupMgr(windowRoot_);
|
||||
|
||||
auto display = DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
sptr<DisplayInfo> displayInfo = display->GetDisplayInfo();
|
||||
ASSERT_TRUE((displayInfo != nullptr));
|
||||
auto container = windowRoot_->CreateWindowNodeContainer(0, displayInfo);
|
||||
defalutDisplayId_ = display->GetId();
|
||||
|
||||
for (int i = 0; i < missionCount_; i++) {
|
||||
int32_t missindId = i + 1;
|
||||
sptr<WindowProperty> property = new WindowProperty();
|
||||
AbilityInfo abilityInfo({"bundle_test" + std::to_string(missindId), "ability_test" + std::to_string(missindId),
|
||||
missindId});
|
||||
property->SetAbilityInfo(abilityInfo);
|
||||
property->SetWindowId(static_cast<uint32_t>(missindId));
|
||||
property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
property->SetDisplayId(defalutDisplayId_);
|
||||
sptr<WindowNode> node = new WindowNode(property);
|
||||
node->abilityInfo_ = abilityInfo;
|
||||
sptr<WindowOption> windowOption = new WindowOption();
|
||||
sptr<WindowImpl> windowImpl = new WindowImpl(windowOption);
|
||||
sptr<IWindow> window = new WindowAgent(windowImpl);
|
||||
node->SetWindowToken(window);
|
||||
WLOGFI("windowId: %{public}u, missionId: %{public}d", node->GetWindowId(), node->abilityInfo_.missionId_);
|
||||
windowRoot_->SaveWindow(node);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowGroupMgrTest::TearDownTestCase()
|
||||
{
|
||||
windowGroupMgr_ = nullptr;
|
||||
windowRoot_ = nullptr;
|
||||
defalutDisplayId_ = -1;
|
||||
}
|
||||
|
||||
void WindowGroupMgrTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowGroupMgrTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: MoveMissionsToForeground01
|
||||
* @tc.desc: move missions to foreground
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowGroupMgrTest, MoveMissionsToForeground01, Function | SmallTest | Level2)
|
||||
{
|
||||
WLOGI("MoveMissionsToForeground01");
|
||||
auto rs = windowGroupMgr_->MoveMissionsToForeground({1, 2, 3}, 2);
|
||||
ASSERT_EQ(WMError::WM_OK, rs);
|
||||
rs = windowGroupMgr_->MoveMissionsToForeground({1, 2, 3}, -1);
|
||||
ASSERT_EQ(WMError::WM_OK, rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MoveMissionsToBackground01
|
||||
* @tc.desc: move missions to background
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowGroupMgrTest, MoveMissionsToBackground01, Function | SmallTest | Level2)
|
||||
{
|
||||
std::vector<int32_t> moveRs;
|
||||
auto rs = windowGroupMgr_->MoveMissionsToBackground({1, 2, 3}, moveRs);
|
||||
ASSERT_EQ(WMError::WM_OK, rs);
|
||||
ASSERT_EQ(3, moveRs.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnWindowDestroyed01
|
||||
* @tc.desc: OnWindowDestroyed test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowGroupMgrTest, OnWindowDestroyed01, Function | SmallTest | Level2)
|
||||
{
|
||||
windowGroupMgr_->OnWindowDestroyed(1);
|
||||
ASSERT_EQ(0, windowGroupMgr_->backupWindowModes_.count(1));
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnDisplayStateChange01
|
||||
* @tc.desc: OnDisplayStateChange test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowGroupMgrTest, OnDisplayStateChange01, Function | SmallTest | Level2)
|
||||
{
|
||||
windowGroupMgr_->OnDisplayStateChange(defalutDisplayId_, nullptr, {}, DisplayStateChangeType::DESTROY);
|
||||
ASSERT_EQ(0, windowGroupMgr_->backupDividerWindowRect_.count(defalutDisplayId_));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -157,6 +157,32 @@ HWTEST_F(WindowManagerServiceTest, StartingWindow01, Function | SmallTest | Leve
|
||||
ASSERT_EQ(true, wms->startingOpen_);
|
||||
wms->CancelStartingWindow(nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MoveMissionsToForeground
|
||||
* @tc.desc: MoveMissionsToForont test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, MoveMissionsToForeground01, Function | SmallTest | Level2)
|
||||
{
|
||||
WMError rs = wms->MoveMissionsToForeground({1, 2, 3}, 1);
|
||||
ASSERT_EQ(WMError::WM_OK, rs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.name: MoveMissionsToBackground
|
||||
* @tc.desc: MoveMissionsToBackground test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, MoveMissionsToBackground01, Function | SmallTest | Level2)
|
||||
{
|
||||
std::vector<int32_t> moveRs;
|
||||
WMError rs = wms->MoveMissionsToBackground({1, 2, 3}, moveRs);
|
||||
ASSERT_EQ(WMError::WM_OK, rs);
|
||||
ASSERT_EQ(3, moveRs.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: CreateWindow
|
||||
* @tc.desc: CreateWindow test
|
||||
|
Loading…
Reference in New Issue
Block a user