/* * 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 #include "display_manager_adapter.h" #include "display_manager.h" #include "screen_manager.h" #include "display_manager_proxy.h" #include "window_scene.h" #include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { class DisplayManagerAdapterTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; }; void DisplayManagerAdapterTest::SetUpTestCase() { } void DisplayManagerAdapterTest::TearDownTestCase() { } void DisplayManagerAdapterTest::SetUp() { } void DisplayManagerAdapterTest::TearDown() { } namespace { /** * @tc.name: GetDisplayInfo * @tc.desc: test nullptr * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetDisplayInfo, Function | SmallTest | Level2) { sptr info = SingletonContainer::Get().GetDisplayInfo(DISPLAY_ID_INVALID); ASSERT_EQ(info, nullptr); } /** * @tc.name: GetCutoutInfo * @tc.desc: test nullptr * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetCutoutInfo, Function | SmallTest | Level2) { sptr info = SingletonContainer::Get().GetCutoutInfo(DISPLAY_ID_INVALID); ASSERT_EQ(info, nullptr); } /** * @tc.name: GetScreenSupportedColorGamuts * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level2) { std::vector colorGamuts; DMError err = SingletonContainer::Get().GetScreenSupportedColorGamuts(0, colorGamuts); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetScreenColorGamut * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorGamut, Function | SmallTest | Level2) { std::vector colorGamuts; DMError err = SingletonContainer::Get().SetScreenColorGamut(0, -1); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } else { ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } } /** * @tc.name: GetScreenColorGamut * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenColorGamut, Function | SmallTest | Level2) { ScreenColorGamut colorGamut; DMError err = SingletonContainer::Get().GetScreenColorGamut(0, colorGamut); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetScreenGamutMap * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenGamutMap, Function | SmallTest | Level2) { ScreenGamutMap gamutMap; DMError err = SingletonContainer::Get().GetScreenGamutMap(0, gamutMap); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } else { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } } /** * @tc.name: SetScreenGamutMap * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenGamutMap, Function | SmallTest | Level2) { DMError err = SingletonContainer::Get().SetScreenGamutMap(0, GAMUT_MAP_CONSTANT); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } else { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } } /** * @tc.name: SetScreenColorTransform * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorTransform, Function | SmallTest | Level2) { DMError err = SingletonContainer::Get().SetScreenColorTransform(0); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_OK); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetFreeze * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetFreeze, Function | SmallTest | Level2) { std::vector displayIds; bool ret = SingletonContainer::Get().SetFreeze(displayIds, false); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } else { ASSERT_FALSE(ret); } } /** * @tc.name: GetScreenGroupInfoById * @tc.desc: test nullptr * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenGroupInfoById, Function | SmallTest | Level2) { auto info = SingletonContainer::Get().GetScreenGroupInfoById(SCREEN_ID_INVALID); ASSERT_EQ(info, nullptr); } /** * @tc.name: GetScreenInfo * @tc.desc: test nullptr * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenInfo, Function | SmallTest | Level2) { sptr info = SingletonContainer::Get().GetScreenInfo(SCREEN_ID_INVALID); ASSERT_EQ(info, nullptr); } /** * @tc.name: OnRemoteDied * @tc.desc: test nullptr * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied, Function | SmallTest | Level2) { sptr dmsDeath_ = nullptr; dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get()); dmsDeath_->OnRemoteDied(nullptr); EXPECT_NE(nullptr, dmsDeath_); } /** * @tc.name: OnRemoteDied01 * @tc.desc: test nullptr * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied01, Function | SmallTest | Level2) { sptr dmsDeath_ = nullptr; dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get()); SingletonContainer::Get().InitDMSProxy(); sptr obj = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); wptr wptrDeath = obj; dmsDeath_->OnRemoteDied(wptrDeath); EXPECT_NE(nullptr, dmsDeath_); } /** * @tc.name: Clear * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, Clear, Function | SmallTest | Level2) { SingletonContainer::Get().InitDMSProxy(); SingletonContainer::Get().Clear(); ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); } /** * @tc.name: Clear01 * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, Clear01, Function | SmallTest | Level2) { SingletonContainer::Get().InitDMSProxy(); SingletonContainer::Get().displayManagerServiceProxy_ = nullptr; SingletonContainer::Get().Clear(); ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); } /** * @tc.name: DisableMirror * @tc.desc: DisableMirror test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, DisableMirror, Function | SmallTest | Level2) { DMError ret = SingletonContainer::Get().DisableMirror(false); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(DMError::DM_OK, ret); } else { ASSERT_NE(DMError::DM_OK, ret); } } /** * @tc.name: HasImmersiveWindow * @tc.desc: test HasImmersiveWindow * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, HasImmersiveWindow, Function | SmallTest | Level2) { bool immersive = false; DMError ret = SingletonContainer::Get().HasImmersiveWindow(immersive); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(ret, DMError::DM_OK); } } /** * @tc.name: GetPixelFormat * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetPixelFormat, Function | SmallTest | Level2) { GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8}; DMError err = SingletonContainer::Get().GetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetPixelFormat * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetPixelFormat, Function | SmallTest | Level2) { GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8}; DMError err = SingletonContainer::Get().SetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetSupportedHDRFormats * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetSupportedHDRFormats, Function | SmallTest | Level2) { std::vector hdrFormats; DMError err = SingletonContainer::Get().GetSupportedHDRFormats(0, hdrFormats); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetScreenHDRFormat * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenHDRFormat, Function | SmallTest | Level2) { ScreenHDRFormat hdrFormat = ScreenHDRFormat{NOT_SUPPORT_HDR}; DMError err = SingletonContainer::Get().GetScreenHDRFormat(0, hdrFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetScreenHDRFormat * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenHDRFormat, Function | SmallTest | Level2) { DMError err = SingletonContainer::Get().SetScreenHDRFormat(0, 0); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetSupportedColorSpaces * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetSupportedColorSpaces, Function | SmallTest | Level2) { std::vector colorSpaces; DMError err = SingletonContainer::Get().GetSupportedColorSpaces(0, colorSpaces); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetScreenColorSpace * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenColorSpace, Function | SmallTest | Level2) { GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE}; DMError err = SingletonContainer::Get().GetScreenColorSpace(0, colorSpace); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetScreenColorSpace * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorSpace, Function | SmallTest | Level2) { GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE}; DMError err = SingletonContainer::Get().SetScreenColorSpace(0, colorSpace); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } } /** * @tc.name: DestroyVirtualScreen * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, DestroyVirtualScreen, Function | SmallTest | Level2) { VirtualScreenOption defaultOption = {"virtualScreen01", 480, 320, 2.0, nullptr, 0}; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().DestroyVirtualScreen(id); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_OK); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetVirtualMirrorScreenCanvasRotation * @tc.desc: test SetVirtualMirrorScreenCanvasRotation * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetVirtualMirrorScreenCanvasRotation, Function | SmallTest | Level2) { bool canvasRotation = false; DMError ret = SingletonContainer::Get(). SetVirtualMirrorScreenCanvasRotation(0, canvasRotation); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_OK); } else { ASSERT_EQ(ret, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } } /** * @tc.name: SetScreenRotationLocked * @tc.desc: test SetScreenRotationLocked * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenRotationLocked, Function | SmallTest | Level2) { bool isLocked = false; DMError ret = SingletonContainer::Get().SetScreenRotationLocked(isLocked); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_OK); } else { ASSERT_EQ(ret, DMError::DM_OK); } } /** * @tc.name: IsScreenRotationLocked * @tc.desc: test IsScreenRotationLocked * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, IsScreenRotationLocked, Function | SmallTest | Level2) { bool isLocked = false; DMError ret = SingletonContainer::Get().IsScreenRotationLocked(isLocked); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_OK); } else { ASSERT_EQ(ret, DMError::DM_OK); } } /** * @tc.name: SetSpecifiedScreenPower * @tc.desc: test SetSpecifiedScreenPower * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetSpecifiedScreenPower, Function | SmallTest | Level2) { ScreenPowerState state = ScreenPowerState{0}; PowerStateChangeReason reason = PowerStateChangeReason{0}; bool ret = SingletonContainer::Get().SetSpecifiedScreenPower(0, state, reason); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } else { ASSERT_FALSE(ret); } } /** * @tc.name: SetOrientation * @tc.desc: SetOrientation success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetOrientation, Function | SmallTest | Level2) { Orientation orientation = Orientation{0}; DMError err = SingletonContainer::Get().SetOrientation(0, orientation); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_OK); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: WakeUpBegin * @tc.desc: test WakeUpBegin * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, WakeUpBegin, Function | SmallTest | Level2) { PowerStateChangeReason reason = PowerStateChangeReason{0}; bool ret = SingletonContainer::Get().WakeUpBegin(reason); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } else { ASSERT_TRUE(ret); } } /** * @tc.name: WakeUpEnd * @tc.desc: test WakeUpEnd * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, WakeUpEnd, Function | SmallTest | Level2) { bool ret = SingletonContainer::Get().WakeUpEnd(); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } else { ASSERT_TRUE(ret); } } /** * @tc.name: SuspendBegin * @tc.desc: test SuspendBegin * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SuspendBegin, Function | SmallTest | Level2) { PowerStateChangeReason reason = PowerStateChangeReason{0}; bool ret = SingletonContainer::Get().SuspendBegin(reason); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } else { ASSERT_TRUE(ret); } } /** * @tc.name: SuspendEnd * @tc.desc: test SuspendEnd * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SuspendEnd, Function | SmallTest | Level2) { bool ret = SingletonContainer::Get().SuspendEnd(); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } else { ASSERT_TRUE(ret); } } /** * @tc.name: SetDisplayState * @tc.desc: test SetDisplayState * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, Function | SmallTest | Level2) { DisplayState state = DisplayState{1}; bool ret = SingletonContainer::Get().SetDisplayState(state); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } else { ASSERT_FALSE(ret); } } /** * @tc.name: MakeMirror * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, MakeMirror, Function | SmallTest | Level2) { std::vector mirrorScreenId; ScreenId screenGroupId; DMError err = SingletonContainer::Get().MakeMirror(0, mirrorScreenId, screenGroupId); ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } /** * @tc.name: StopMirror * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, StopMirror, Function | SmallTest | Level2) { std::vector mirrorScreenIds; DMError err = SingletonContainer::Get().StopMirror(mirrorScreenIds); ASSERT_EQ(err, DMError::DM_OK); } /** * @tc.name: HasPrivateWindow * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, HasPrivateWindow, Function | SmallTest | Level2) { bool hasPrivateWindow = false; DMError err = SingletonContainer::Get().HasPrivateWindow(0, hasPrivateWindow); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(DMError::DM_OK, err); } else { ASSERT_EQ(DMError::DM_OK, err); } } /** * @tc.name: AddSurfaceNodeToDisplay * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, Function | SmallTest | Level2) { std::shared_ptr surfaceNode; DMError err = SingletonContainer::Get().AddSurfaceNodeToDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err); } else { ASSERT_EQ(DMError::DM_OK, err); } } /** * @tc.name: RemoveSurfaceNodeFromDisplay * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, RemoveSurfaceNodeFromDisplay, Function | SmallTest | Level2) { std::shared_ptr surfaceNode; DMError err = SingletonContainer::Get().RemoveSurfaceNodeFromDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err); } else { ASSERT_EQ(DMError::DM_OK, err); } } /** * @tc.name: MakeExpand * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, MakeExpand, Function | SmallTest | Level2) { std::vector screenId; std::vector startPoint; ScreenId screenGroupId; DMError err = SingletonContainer::Get().MakeExpand(screenId, startPoint, screenGroupId); ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } /** * @tc.name: StopExpand * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, StopExpand, Function | SmallTest | Level2) { std::vector expandScreenIds; DMError err = SingletonContainer::Get().StopExpand(expandScreenIds); ASSERT_EQ(err, DMError::DM_OK); } /** * @tc.name: RemoveVirtualScreenFromGroup * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, RemoveVirtualScreenFromGroup, Function | SmallTest | Level2) { std::vector screens; int resultValue = 0; std::function func = [&]() { SingletonContainer::Get().RemoveVirtualScreenFromGroup(screens); resultValue = 1; }; func(); ASSERT_EQ(resultValue, 1); } /** * @tc.name: SetScreenActiveMode * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenActiveMode, Function | SmallTest | Level2) { VirtualScreenOption defaultOption = {"virtualScreen02", 480, 320, 2.0, nullptr, 0}; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().SetScreenActiveMode(id, 100); ASSERT_EQ(err, DMError::DM_OK); SingletonContainer::Get().DestroyVirtualScreen(id); } /** * @tc.name: SetVirtualPixelRatio * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetVirtualPixelRatio, Function | SmallTest | Level2) { VirtualScreenOption defaultOption = {"virtualScreen03", 480, 320, 2.0, nullptr, 0}; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().SetVirtualPixelRatio(id, 0); ASSERT_EQ(err, DMError::DM_OK); SingletonContainer::Get().DestroyVirtualScreen(id); } /** * @tc.name: SetResolution * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetResolution, Function | SmallTest | Level2) { VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0}; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().SetResolution(id, 70, 100, 1); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); } else { ASSERT_EQ(err, DMError::DM_OK); } SingletonContainer::Get().DestroyVirtualScreen(id); } /** * @tc.name: ResizeVirtualScreen * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, ResizeVirtualScreen, Function | SmallTest | Level2) { DMError err = SingletonContainer::Get().ResizeVirtualScreen(0, 70, 100); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_OK); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: MakeUniqueScreen * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, Function | SmallTest | Level2) { std::vector screenIds; DMError err = SingletonContainer::Get().MakeUniqueScreen(screenIds); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_OK); } else { ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } } /** * @tc.name: GetAvailableArea * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetAvailableArea, Function | SmallTest | Level2) { DMRect area; DMError err = SingletonContainer::Get().GetAvailableArea(0, area); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetAllDisplayPhysicalResolution * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetAllDisplayPhysicalResolution, Function | SmallTest | Level2) { std::vector allSize = SingletonContainer::Get().GetAllDisplayPhysicalResolution(); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(!allSize.empty()); } else { ASSERT_TRUE(!allSize.empty()); } } /** * @tc.name: SetDisplayScale * @tc.desc: SetDisplayScale test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, Function | SmallTest | Level2) { DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get(); const float scaleX = 1.0f; const float scaleY = 1.0f; const float pivotX = 0.5f; const float pivotY = 0.5f; sptr displayInfo = displayManagerAdapter.GetDefaultDisplayInfo(); ASSERT_NE(displayInfo, nullptr); ScreenId screenId = displayInfo->GetScreenId(); displayManagerAdapter.SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY); } /** * @tc.name: GetPrimaryDisplayInfo * @tc.desc: GetPrimaryDisplayInfo test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetPrimaryDisplayInfo, Function | SmallTest | Level2) { DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get(); sptr displayInfo = displayManagerAdapter.GetPrimaryDisplayInfo(); ASSERT_NE(displayInfo, nullptr); } } } }