mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 15:00:12 +00:00
[UT]abstract_display,window_manager_service,display_manager_agent_controller
Signed-off-by: yangfei <yangfei110@huawei.com> Change-Id: I665e7a5aaac5f2916ed68e167b6962cd8a4ff59f
This commit is contained in:
parent
daca96de66
commit
ffe021e915
@ -19,14 +19,32 @@ group("unittest") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
":dmserver_abstract_display_test",
|
||||
":dmserver_display_cutout_controller_test",
|
||||
":dmserver_display_dumper_test",
|
||||
":dmserver_display_manager_agent_controller_test",
|
||||
":dmserver_display_manager_proxy_test",
|
||||
":dmserver_display_manager_service_test",
|
||||
":dmserver_screen_rotation_controller_test",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("dmserver_display_manager_agent_controller_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "display_manager_agent_controller_test.cpp" ]
|
||||
|
||||
deps = [ ":dmserver_unittest_common" ]
|
||||
}
|
||||
|
||||
ohos_unittest("dmserver_abstract_display_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "abstract_display_test.cpp" ]
|
||||
|
||||
deps = [ ":dmserver_unittest_common" ]
|
||||
}
|
||||
|
||||
ohos_unittest("dmserver_display_manager_service_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
|
97
dmserver/test/unittest/abstract_display_test.cpp
Normal file
97
dmserver/test/unittest/abstract_display_test.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "abstract_display.h"
|
||||
#include "abstract_screen_controller.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class AbstractDisplayTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
DisplayId id = 1;
|
||||
std::string name = "abstract_display_test";
|
||||
SupportedScreenModes modesInfo;
|
||||
std::recursive_mutex mutex;
|
||||
sptr<AbstractScreenController> absController;
|
||||
sptr<AbstractScreen> absScreen;
|
||||
sptr<AbstractDisplay> absDisplay;
|
||||
sptr<AbstractDisplay> absDisplay2;
|
||||
sptr<AbstractDisplay> absDisplay3;
|
||||
};
|
||||
|
||||
void AbstractDisplayTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void AbstractDisplayTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void AbstractDisplayTest::SetUp()
|
||||
{
|
||||
modesInfo.width_ = 2160;
|
||||
modesInfo.height_ = 1600;
|
||||
modesInfo.refreshRate_ = 60;
|
||||
sptr<SupportedScreenModes> info = new SupportedScreenModes(modesInfo);
|
||||
absController = nullptr;
|
||||
absScreen = new AbstractScreen(absController, name, 1, 1);
|
||||
absDisplay = new AbstractDisplay(id, name, info, absScreen);
|
||||
modesInfo.width_ = 800;
|
||||
modesInfo.height_ = 2560;
|
||||
absDisplay2 = new AbstractDisplay(id, name, info, absScreen);
|
||||
modesInfo.width_ = 2560;
|
||||
modesInfo.height_ = 2560;
|
||||
absDisplay3 = new AbstractDisplay(id, name, info, absScreen);
|
||||
}
|
||||
|
||||
void AbstractDisplayTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: BindAbstractScreen
|
||||
* @tc.desc: BindAbstractScreen test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AbstractDisplayTest, BindAbstractScreen01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<AbstractScreen> abstractScreen = nullptr;
|
||||
ASSERT_EQ(false, absDisplay->BindAbstractScreen(abstractScreen));
|
||||
}
|
||||
/**
|
||||
* @tc.name: BindAbstractScreen
|
||||
* @tc.desc: BindAbstractScreen test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AbstractDisplayTest, BindAbstractScreen02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<AbstractScreen> abstractScreen = absScreen;
|
||||
abstractScreen->activeIdx_ = -1;
|
||||
ASSERT_EQ(false, absDisplay->BindAbstractScreen(abstractScreen));
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
144
dmserver/test/unittest/display_manager_agent_controller_test.cpp
Normal file
144
dmserver/test/unittest/display_manager_agent_controller_test.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "display_manager_agent_controller.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class DisplayManagerAgentControllerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
void DisplayManagerAgentControllerTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void DisplayManagerAgentControllerTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void DisplayManagerAgentControllerTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void DisplayManagerAgentControllerTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: OnScreenConnect
|
||||
* @tc.desc: OnScreenConnect test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerAgentControllerTest, OnScreenConnect, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<ScreenInfo> screenInfo = nullptr;
|
||||
DisplayManagerAgentController::GetInstance().OnScreenConnect(screenInfo);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnScreenChange
|
||||
* @tc.desc: OnScreenChange test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerAgentControllerTest, OnScreenChange, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<ScreenInfo> screenInfo = nullptr;
|
||||
DisplayManagerAgentController::GetInstance().OnScreenChange(screenInfo, ScreenChangeEvent::UPDATE_ROTATION);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnScreenGroupChange
|
||||
* @tc.desc: OnScreenChange test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerAgentControllerTest, OnScreenGroupChange, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<ScreenInfo> screenInfo = nullptr;
|
||||
std::string trigger;
|
||||
DisplayManagerAgentController::GetInstance().OnScreenGroupChange(trigger, screenInfo, ScreenGroupChangeEvent::ADD_TO_GROUP);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
std::vector<sptr<ScreenInfo>> screenInfos;
|
||||
screenInfos.push_back(screenInfo);
|
||||
DisplayManagerAgentController::GetInstance().OnScreenGroupChange(trigger, screenInfos, ScreenGroupChangeEvent::ADD_TO_GROUP);
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnDisplayCreate
|
||||
* @tc.desc: OnDisplayCreate test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerAgentControllerTest, OnDisplayCreate, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<DisplayInfo> displayInfo;
|
||||
DisplayManagerAgentController::GetInstance().OnDisplayCreate(displayInfo);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnDisplayDestroy
|
||||
* @tc.desc: OnDisplayDestroy test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerAgentControllerTest, OnDisplayDestroy, Function | SmallTest | Level3)
|
||||
{
|
||||
DisplayId displayId = 0;
|
||||
DisplayManagerAgentController::GetInstance().OnDisplayDestroy(displayId);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnDisplayChange
|
||||
* @tc.desc: OnDisplayChange test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerAgentControllerTest, OnDisplayChange, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<DisplayInfo> displayInfo = nullptr;
|
||||
DisplayManagerAgentController::GetInstance().OnDisplayChange(displayInfo, DisplayChangeEvent::UNKNOWN);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
displayInfo = new DisplayInfo();
|
||||
DisplayManagerAgentController::GetInstance().OnDisplayChange(displayInfo, DisplayChangeEvent::UNKNOWN);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnScreenshot
|
||||
* @tc.desc: OnScreenshot test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerAgentControllerTest, OnScreenshot, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<ScreenshotInfo> info = nullptr;
|
||||
DisplayManagerAgentController::GetInstance().OnScreenshot(info);
|
||||
ASSERT_EQ(0, DisplayManagerAgentController::GetInstance().
|
||||
dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER).size());
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
53
test/common/mock/mock_RSIWindowAnimationController.h
Normal file
53
test/common/mock/mock_RSIWindowAnimationController.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <iremote_broker.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include "rs_iwindow_animation_controller.h"
|
||||
#include "iremote_object_mocker.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSIWindowAnimationControllerMocker : public RSIWindowAnimationController {
|
||||
public:
|
||||
RSIWindowAnimationControllerMocker() {};
|
||||
~RSIWindowAnimationControllerMocker() {};
|
||||
MOCK_METHOD3(OnStartApp, void(StartingAppType type, const sptr<RSWindowAnimationTarget>& startingWindowTarget,
|
||||
const sptr<RSIWindowAnimationFinishedCallback>& finishedCallback));
|
||||
MOCK_METHOD3(OnAppTransition, void(const sptr<RSWindowAnimationTarget>& from, const sptr<RSWindowAnimationTarget>& to,
|
||||
const sptr<RSIWindowAnimationFinishedCallback>& finishedCallback));
|
||||
MOCK_METHOD3(OnAppBackTransition, void(const sptr<RSWindowAnimationTarget>& from, const sptr<RSWindowAnimationTarget>& to,
|
||||
const sptr<RSIWindowAnimationFinishedCallback>& finishedCallback));
|
||||
MOCK_METHOD2(OnMinimizeWindow, void(const sptr<RSWindowAnimationTarget>& minimizingWindow,
|
||||
const sptr<RSIWindowAnimationFinishedCallback>& finishedCallback));
|
||||
MOCK_METHOD2(OnMinimizeAllWindow, void(std::vector<sptr<RSWindowAnimationTarget>> minimizingWindows,
|
||||
const sptr<RSIWindowAnimationFinishedCallback>& finishedCallback));
|
||||
MOCK_METHOD2(OnCloseWindow, void(const sptr<RSWindowAnimationTarget>& closingWindow,
|
||||
const sptr<RSIWindowAnimationFinishedCallback>& finishedCallback));
|
||||
MOCK_METHOD1(OnScreenUnlock, void(const sptr<RSIWindowAnimationFinishedCallback>& finishedCallback));
|
||||
MOCK_METHOD2(OnWindowAnimationTargetsUpdate, void(const sptr<RSWindowAnimationTarget>& fullScreenWindowTarget,
|
||||
const std::vector<sptr<RSWindowAnimationTarget>>& floatingWindowTargets));
|
||||
MOCK_METHOD1(OnWallpaperUpdate, void(const sptr<RSWindowAnimationTarget>& wallpaperTarget));
|
||||
sptr<IRemoteObject> AsObject() override
|
||||
{
|
||||
sptr<IRemoteObject> remote = new IRemoteObjectMocker();
|
||||
return remote;
|
||||
};
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -26,6 +26,7 @@ group("unittest") {
|
||||
":wmserver_window_layout_policy_test",
|
||||
":wmserver_window_manager_config_test",
|
||||
":wmserver_window_manager_proxy_test",
|
||||
":wmserver_window_manager_service_test",
|
||||
":wmserver_window_manager_stub_test",
|
||||
":wmserver_window_node_container_test",
|
||||
":wmserver_window_node_test",
|
||||
@ -164,6 +165,33 @@ ohos_unittest("wmserver_starting_window_test") {
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("wmserver_window_manager_service_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_manager_service_test.cpp" ]
|
||||
|
||||
deps = [ ":wmserver_unittest_common" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"config_policy:configpolicy_util",
|
||||
"display_manager:displaymgr",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_standard:window_animation",
|
||||
"hicollie_native:libhicollie",
|
||||
"hilog_native:libhilog",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_core",
|
||||
"power_manager:powermgr_client",
|
||||
"safwk:system_ability_fwk",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("wmserver_window_manager_proxy_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
|
317
wmserver/test/unittest/window_manager_service_test.cpp
Normal file
317
wmserver/test/unittest/window_manager_service_test.cpp
Normal file
@ -0,0 +1,317 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "common_test_utils.h"
|
||||
// mock class declare
|
||||
//#include "mock_IWindow.h"
|
||||
#include "iremote_object_mocker.h"
|
||||
#include "mock_RSIWindowAnimationController.h"
|
||||
#include "window_manager_service.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <ability_manager_client.h>
|
||||
#include <cinttypes>
|
||||
#include <chrono>
|
||||
#include <hisysevent.h>
|
||||
#include <hitrace_meter.h>
|
||||
#include <ipc_skeleton.h>
|
||||
#include <parameters.h>
|
||||
#include <rs_iwindow_animation_controller.h>
|
||||
#include <system_ability_definition.h>
|
||||
#include <sstream>
|
||||
#include "xcollie/watchdog.h"
|
||||
|
||||
#include "color_parser.h"
|
||||
#include "display_manager_service_inner.h"
|
||||
#include "dm_common.h"
|
||||
#include "drag_controller.h"
|
||||
#include "minimize_app.h"
|
||||
#include "permission.h"
|
||||
#include "remote_animation.h"
|
||||
#include "singleton_container.h"
|
||||
#include "ui/rs_ui_director.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_inner_manager.h"
|
||||
#include "window_manager_agent_controller.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common.h"
|
||||
#include "wm_math.h"
|
||||
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class WindowManagerServiceTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
void SetAceessTokenPermission(const std::string processName);
|
||||
sptr<WindowManagerService> wms = new WindowManagerService();
|
||||
};
|
||||
|
||||
void WindowManagerServiceTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowManagerServiceTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowManagerServiceTest::SetUp()
|
||||
{
|
||||
CommonTestUtils::SetAceessTokenPermission("WindowManagerServiceTest");
|
||||
wms->OnStart();
|
||||
}
|
||||
|
||||
void WindowManagerServiceTest::TearDown()
|
||||
{
|
||||
wms->OnStop();
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: OnAddSystemAbility
|
||||
* @tc.desc: OnAddSystemAbility test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, OnAddSystemAbility01, Function | SmallTest | Level2)
|
||||
{
|
||||
std::string str = "OnAddSystemAbility";
|
||||
wms->OnAddSystemAbility(0, str);
|
||||
ASSERT_EQ(nullptr, wms->windowCommonEvent_->subscriber_);
|
||||
}
|
||||
/**
|
||||
* @tc.name: WindowVisibilityChangeCallback
|
||||
* @tc.desc: WindowVisibilityChangeCallback test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, WindowVisibilityChangeCallback01, Function | SmallTest | Level2)
|
||||
{
|
||||
std::shared_ptr<RSOcclusionData> occlusionData = nullptr;
|
||||
wms->WindowVisibilityChangeCallback(occlusionData);
|
||||
ASSERT_EQ(nullptr, occlusionData);
|
||||
}
|
||||
/**
|
||||
* @tc.name: RegisterSnapshotHandler
|
||||
* @tc.desc: Register Snapshot Handler
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, RegisterSnapshotHandler01, Function | SmallTest | Level2)
|
||||
{
|
||||
wms->snapshotController_ = nullptr;
|
||||
wms->RegisterSnapshotHandler();
|
||||
ASSERT_NE(nullptr, wms->snapshotController_);
|
||||
}
|
||||
/**
|
||||
* @tc.name: RegisterWindowManagerServiceHandler
|
||||
* @tc.desc: Register Snapshot Handler
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, RegisterWindowManagerServiceHandler01, Function | SmallTest | Level2)
|
||||
{
|
||||
wms->wmsHandler_ = new WindowManagerServiceHandler;
|
||||
wms->RegisterWindowManagerServiceHandler();
|
||||
ASSERT_NE(nullptr, wms->wmsHandler_);
|
||||
}
|
||||
/**
|
||||
* @tc.name: Dump
|
||||
* @tc.desc: Dump info
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, Dump01, Function | SmallTest | Level2)
|
||||
{
|
||||
|
||||
wms->windowDumper_ = nullptr;
|
||||
std::vector<std::u16string> args;
|
||||
ASSERT_EQ(static_cast<int>(WMError::WM_ERROR_INVALID_PARAM), wms->Dump(-1, args));
|
||||
ASSERT_EQ(static_cast<int>(WMError::WM_OK), wms->Dump(0, args));
|
||||
}
|
||||
/**
|
||||
* @tc.name: NotifyWindowTransition
|
||||
* @tc.desc: NotifyWindowTransition test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, NotifyWindowTransition01, Function | SmallTest | Level2)
|
||||
{
|
||||
|
||||
sptr<WindowTransitionInfo> fromInfo = nullptr;
|
||||
sptr<WindowTransitionInfo> toInfo = nullptr;
|
||||
ASSERT_EQ(WMError::WM_OK, wms->NotifyWindowTransition(fromInfo, toInfo, false));
|
||||
ASSERT_EQ(WMError::WM_ERROR_NO_REMOTE_ANIMATION, wms->NotifyWindowTransition(fromInfo, toInfo, true));
|
||||
}
|
||||
/**
|
||||
* @tc.name: StartingWindow
|
||||
* @tc.desc: StartingWindow test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, StartingWindow01, Function | SmallTest | Level2)
|
||||
{
|
||||
|
||||
wms->startingOpen_ = false;
|
||||
wms->StartingWindow(nullptr, nullptr, false, 0);
|
||||
ASSERT_EQ(false, wms->startingOpen_);
|
||||
wms->CancelStartingWindow(nullptr);
|
||||
wms->startingOpen_ = true;
|
||||
wms->StartingWindow(nullptr, nullptr, false, 0);
|
||||
ASSERT_EQ(true, wms->startingOpen_);
|
||||
wms->CancelStartingWindow(nullptr);
|
||||
}
|
||||
/**
|
||||
* @tc.name: RemoveWindow
|
||||
* @tc.desc: RemoveWindow test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, RemoveWindow01, Function | SmallTest | Level2)
|
||||
{
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->RemoveWindow(0));
|
||||
}
|
||||
/**
|
||||
* @tc.name: CreateWindow
|
||||
* @tc.desc: CreateWindow test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, CreateWindow01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<IWindow> window = nullptr;
|
||||
uint32_t id = 2;
|
||||
std::shared_ptr<RSSurfaceNode> RS_node = nullptr;
|
||||
sptr<WindowProperty> property = new WindowProperty();
|
||||
property->SetWindowType(WindowType::WINDOW_TYPE_WALLPAPER);
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->CreateWindow(window, property, RS_node, id, nullptr));
|
||||
wms->DestroyWindow(id, true);
|
||||
}
|
||||
/**
|
||||
* @tc.name: AddWindow
|
||||
* @tc.desc: AddWindow test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, AddWindow01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowProperty> property = nullptr;
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->AddWindow(property));
|
||||
}
|
||||
/**
|
||||
* @tc.name: RegisterWindowManagerAgent
|
||||
* @tc.desc: RegisterWindowManagerAgent test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, RegisterWindowManagerAgent01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<IWindowManagerAgent> windowManagerAgent = nullptr;
|
||||
WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT;
|
||||
ASSERT_EQ(false, wms->RegisterWindowManagerAgent(type, windowManagerAgent));
|
||||
ASSERT_EQ(false, wms->UnregisterWindowManagerAgent(type, windowManagerAgent));
|
||||
}
|
||||
/**
|
||||
* @tc.name: SetWindowAnimationController
|
||||
* @tc.desc: SetWindowAnimationController test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, SetWindowAnimationController01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<RSIWindowAnimationController> controller = nullptr;
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->SetWindowAnimationController(controller));
|
||||
controller = new RSIWindowAnimationControllerMocker;
|
||||
ASSERT_EQ(WMError::WM_OK, wms->SetWindowAnimationController(controller));
|
||||
}
|
||||
/**
|
||||
* @tc.name: OnWindowEvent
|
||||
* @tc.desc: OnWindowEvent test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, OnWindowEvent01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<IRemoteObject> remoteObject = new IRemoteObjectMocker;
|
||||
wms->OnWindowEvent(static_cast<Event>(1), remoteObject);
|
||||
wms->OnWindowEvent(Event::REMOTE_DIED, remoteObject);
|
||||
ASSERT_EQ(INVALID_WINDOW_ID, wms->windowRoot_->GetWindowIdByObject(remoteObject));
|
||||
}
|
||||
/**
|
||||
* @tc.name: NotifyServerReadyToMoveOrDrag
|
||||
* @tc.desc: NotifyServerReadyToMoveOrDrag test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, NotifyServerReadyToMoveOrDrag01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowProperty> windowProperty = nullptr;
|
||||
sptr<MoveDragProperty> moveDragProperty = nullptr;
|
||||
wms->NotifyServerReadyToMoveOrDrag(0, windowProperty, moveDragProperty);
|
||||
windowProperty = new WindowProperty();
|
||||
wms->NotifyServerReadyToMoveOrDrag(0, windowProperty, moveDragProperty);
|
||||
ASSERT_EQ(nullptr, moveDragProperty);
|
||||
moveDragProperty = new MoveDragProperty();
|
||||
moveDragProperty->startDragFlag_ = false;
|
||||
moveDragProperty->startMoveFlag_ = true;
|
||||
wms->NotifyServerReadyToMoveOrDrag(0, windowProperty, moveDragProperty);
|
||||
ASSERT_EQ(true, WindowInnerManager::GetInstance().NotifyServerReadyToMoveOrDrag(0, windowProperty, moveDragProperty));
|
||||
}
|
||||
/**
|
||||
* @tc.name: UpdateProperty
|
||||
* @tc.desc: UpdateProperty test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, UpdateProperty01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowProperty> windowProperty = nullptr;
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->UpdateProperty(windowProperty, PropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG, true));
|
||||
}
|
||||
/**
|
||||
* @tc.name: GetModeChangeHotZones
|
||||
* @tc.desc: GetModeChangeHotZones test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, GetModeChangeHotZones01, Function | SmallTest | Level2)
|
||||
{
|
||||
ModeChangeHotZonesConfig config = {false, 0, 0, 0};
|
||||
DisplayId displayId = 0;
|
||||
ModeChangeHotZones hotZone;
|
||||
wms->hotZonesConfig_ = config;
|
||||
ASSERT_EQ(WMError::WM_DO_NOTHING, wms->GetModeChangeHotZones(displayId, hotZone));
|
||||
config.isModeChangeHotZoneConfigured_ = true;
|
||||
wms->hotZonesConfig_ = config;
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->GetModeChangeHotZones(displayId, hotZone));
|
||||
}
|
||||
/**
|
||||
* @tc.name: UpdateAvoidAreaListener
|
||||
* @tc.desc: UpdateAvoidAreaListener test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, UpdateAvoidAreaListener01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowProperty> property = new WindowProperty();
|
||||
sptr<WindowNode> node = new WindowNode(property);
|
||||
wms->windowRoot_->windowNodeMap_.insert(std::make_pair(0, node));
|
||||
ASSERT_EQ(WMError::WM_DO_NOTHING, wms->UpdateAvoidAreaListener(0, true));
|
||||
}
|
||||
/**
|
||||
* @tc.name: BindDialogTarget
|
||||
* @tc.desc: BindDialogTarget test
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowManagerServiceTest, BindDialogTarget01, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<IRemoteObject> targetToken = new IRemoteObjectMocker();
|
||||
uint32_t id = 0;
|
||||
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, wms->BindDialogTarget(id, targetToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user