/* * Copyright (c) 2022-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 "display_manager.h" #include "display_manager_adapter.h" #include "display_manager_proxy.h" #include "scene_board_judgement.h" #include "screen_manager.h" #include "window_scene.h" using namespace testing; using namespace testing::ext; namespace OHOS::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 { static constexpr DisplayId DEFAULT_DISPLAY = 1ULL; static const int32_t PIXELMAP_SIZE = 2; static const int32_t SDR_PIXELMAP = 0; static const int32_t HDR_PIXELMAP = 1; /** * @tc.name: GetDisplayInfo * @tc.desc: test nullptr * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetDisplayInfo, TestSize.Level1) { 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, TestSize.Level1) { sptr info = SingletonContainer::Get().GetCutoutInfo(DISPLAY_ID_INVALID, 0, 0, Rotation::ROTATION_0); ASSERT_EQ(info, nullptr); } /** * @tc.name: GetScreenSupportedColorGamuts * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenSupportedColorGamuts, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { ScreenGamutMap gamutMap; DMError err = SingletonContainer::Get().GetScreenGamutMap(0, gamutMap); ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } /** * @tc.name: SetScreenGamutMap * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenGamutMap, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenGamutMap(0, GAMUT_MAP_CONSTANT); ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } /** * @tc.name: SetScreenColorTransform * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorTransform, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenColorTransform(0); ASSERT_EQ(err, DMError::DM_OK); } /** * @tc.name: SetFreeze * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetFreeze, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { sptr dmsDeath = new (std::nothrow) DMSDeathRecipient(SingletonContainer::Get()); SingletonContainer::Get().InitDMSProxy(); sptr remoteObject; if (SceneBoardJudgement::IsSceneBoardEnabled()) { remoteObject = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); } else { remoteObject = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); } wptr wptrDeath = remoteObject; dmsDeath->OnRemoteDied(wptrDeath); EXPECT_NE(nullptr, dmsDeath); } /** * @tc.name: Clear * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, Clear, TestSize.Level1) { if (SceneBoardJudgement::IsSceneBoardEnabled()) { SingletonContainer::Get().InitDMSProxy(); SingletonContainer::Get().Clear(); ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); } else { 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, TestSize.Level1) { if (SceneBoardJudgement::IsSceneBoardEnabled()) { SingletonContainer::Get().InitDMSProxy(); SingletonContainer::Get().screenSessionManagerServiceProxy_ = nullptr; SingletonContainer::Get().Clear(); ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); } else { 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, TestSize.Level1) { DMError ret = SingletonContainer::Get().DisableMirror(false); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_ERROR_INVALID_PERMISSION); } else { ASSERT_EQ(ret, DMError::DM_OK); } } /** * @tc.name: HasImmersiveWindow * @tc.desc: test HasImmersiveWindow * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, HasImmersiveWindow, TestSize.Level1) { bool immersive = false; DMError ret = SingletonContainer::Get().HasImmersiveWindow(0u, 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, TestSize.Level1) { GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_CLUT8; DMError err = SingletonContainer::Get().GetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetPixelFormat * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetPixelFormat, TestSize.Level1) { GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_CLUT8; DMError err = SingletonContainer::Get().SetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetSupportedHDRFormats * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetSupportedHDRFormats, TestSize.Level1) { std::vector hdrFormats; DMError err = SingletonContainer::Get().GetSupportedHDRFormats(0, hdrFormats); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetScreenHDRFormat * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenHDRFormat, TestSize.Level1) { ScreenHDRFormat hdrFormat = ScreenHDRFormat::NOT_SUPPORT_HDR; DMError err = SingletonContainer::Get().GetScreenHDRFormat(0, hdrFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetScreenHDRFormat * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenHDRFormat, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenHDRFormat(0, 0); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetSupportedColorSpaces * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetSupportedColorSpaces, TestSize.Level1) { std::vector colorSpaces; DMError err = SingletonContainer::Get().GetSupportedColorSpaces(0, colorSpaces); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetScreenColorSpace * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetScreenColorSpace, TestSize.Level1) { 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_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } } /** * @tc.name: SetScreenColorSpace * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorSpace, TestSize.Level1) { 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_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } } /** * @tc.name: DestroyVirtualScreen * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, DestroyVirtualScreen, TestSize.Level1) { VirtualScreenOption defaultOption = { "virtualScreen01", 480, 320, 2.0, nullptr, 0 }; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().DestroyVirtualScreen(id); ASSERT_EQ(err, DMError::DM_OK); } /** * @tc.name: SetVirtualMirrorScreenCanvasRotation * @tc.desc: test SetVirtualMirrorScreenCanvasRotation * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetVirtualMirrorScreenCanvasRotation, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { ScreenPowerState state = ScreenPowerState::POWER_ON; PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; 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, TestSize.Level1) { Orientation orientation = Orientation::BEGIN; DMError err = SingletonContainer::Get().SetOrientation(0, orientation); ASSERT_EQ(err, DMError::DM_OK); } /** * @tc.name: WakeUpBegin * @tc.desc: test WakeUpBegin * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, WakeUpBegin, TestSize.Level1) { PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().WakeUpBegin(reason); ASSERT_TRUE(ret); } /** * @tc.name: WakeUpEnd * @tc.desc: test WakeUpEnd * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, WakeUpEnd, TestSize.Level1) { bool ret = SingletonContainer::Get().WakeUpEnd(); ASSERT_TRUE(ret); } /** * @tc.name: SuspendBegin * @tc.desc: test SuspendBegin * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SuspendBegin, TestSize.Level1) { PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().SuspendBegin(reason); ASSERT_TRUE(ret); } /** * @tc.name: SuspendEnd * @tc.desc: test SuspendEnd * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SuspendEnd, TestSize.Level1) { bool ret = SingletonContainer::Get().SuspendEnd(); ASSERT_TRUE(ret); } /** * @tc.name: SetDisplayState * @tc.desc: test SetDisplayState * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, TestSize.Level1) { DisplayState state = DisplayState::OFF; bool ret = SingletonContainer::Get().SetDisplayState(state); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); } } /** * @tc.name: MakeMirror * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, MakeMirror, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { bool hasPrivateWindow = false; DMError err = SingletonContainer::Get().HasPrivateWindow(0, hasPrivateWindow); ASSERT_EQ(DMError::DM_OK, err); } /** * @tc.name: AddSurfaceNodeToDisplay * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, TestSize.Level1) { RSSurfaceNodeConfig rsSurfaceNodeConfig; std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); DMError err = SingletonContainer::Get().AddSurfaceNodeToDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(DMError::DM_ERROR_NULLPTR, err); } else { ASSERT_EQ(DMError::DM_OK, err); } } /** * @tc.name: RemoveSurfaceNodeFromDisplay * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, RemoveSurfaceNodeFromDisplay, TestSize.Level1) { RSSurfaceNodeConfig rsSurfaceNodeConfig; std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); DMError err = SingletonContainer::Get().RemoveSurfaceNodeFromDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(DMError::DM_ERROR_NULLPTR, err); } else { ASSERT_EQ(DMError::DM_OK, err); } } /** * @tc.name: MakeExpand * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, MakeExpand, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { 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, TestSize.Level1) { VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0}; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().SetResolution(id, 70, 100, 1); ASSERT_EQ(err, DMError::DM_OK); SingletonContainer::Get().DestroyVirtualScreen(id); } /** * @tc.name: ResizeVirtualScreen * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, ResizeVirtualScreen, TestSize.Level1) { DMError err = SingletonContainer::Get().ResizeVirtualScreen(0, 70, 100); ASSERT_EQ(err, DMError::DM_OK); } /** * @tc.name: MakeUniqueScreen * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, TestSize.Level1) { std::vector screenIds; std::vector displayIds; DMError err = SingletonContainer::Get().MakeUniqueScreen(screenIds, displayIds); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } } /** * @tc.name: GetAvailableArea * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetAvailableArea, TestSize.Level1) { 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, TestSize.Level1) { std::vector allSize = SingletonContainer::Get().GetAllDisplayPhysicalResolution(); ASSERT_FALSE(allSize.empty()); } /** * @tc.name: SetDisplayScale * @tc.desc: SetDisplayScale test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, TestSize.Level1) { auto& displayManagerAdapter = SingletonContainer::Get(); constexpr float scaleX = 1.0f; constexpr float scaleY = 1.0f; constexpr float pivotX = 0.5f; constexpr 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, TestSize.Level1) { sptr displayInfo = SingletonContainer::Get().GetPrimaryDisplayInfo(); ASSERT_NE(displayInfo, nullptr); } /** * @tc.name: SetScreenSkipProtectedWindow * @tc.desc: SetScreenSkipProtectedWindow test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenSkipProtectedWindow, TestSize.Level1) { const std::vector screenIds = {1001, 1002}; bool isEnable = true; auto result = SingletonContainer::Get().SetScreenSkipProtectedWindow(screenIds, isEnable); ASSERT_EQ(result, DMError::DM_OK); } /** * @tc.name: GetDisplayCapability * @tc.desc: GetDisplayCapability test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetDisplayCapability, TestSize.Level1) { std::string capabilitInfo; auto result = SingletonContainer::Get().GetDisplayCapability(capabilitInfo); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(result, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(result, DMError::DM_OK); } } /** * @tc.name: GetVisibleAreaDisplayInfoById * @tc.desc: Test GetVisibleAreaDisplayInfoById function with invalid displayId. * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetVisibleAreaDisplayInfoById, TestSize.Level1) { sptr info = SingletonContainer::Get().GetVisibleAreaDisplayInfoById(DISPLAY_ID_INVALID); EXPECT_EQ(info, nullptr); } /** * @tc.name: GetExpandAvailableArea * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetExpandAvailableArea, TestSize.Level1) { DMRect area; DMError err = SingletonContainer::Get().GetExpandAvailableArea(0, area); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { EXPECT_EQ(err, DMError::DM_OK); } } /** * @tc.name: GetDisplayHDRSnapshotWithOption001 * @tc.desc: GetDisplayHDRSnapshotWithOption test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetDisplayHDRSnapshotWithOption001, TestSize.Level1) { CaptureOption captureOption; DmErrorCode errorCode; sptr screenSessionManagerServiceProxyTmp = SingletonContainer::Get().screenSessionManagerServiceProxy_; SingletonContainer::Get().screenSessionManagerServiceProxy_ = nullptr; std::vector> result = SingletonContainer::Get().GetDisplayHDRSnapshotWithOption(captureOption, errorCode); SingletonContainer::Get().screenSessionManagerServiceProxy_ = screenSessionManagerServiceProxyTmp; EXPECT_EQ(result.size(), PIXELMAP_SIZE); EXPECT_EQ(result[SDR_PIXELMAP], nullptr); EXPECT_EQ(result[HDR_PIXELMAP], nullptr); } /** * @tc.name: GetDisplayHDRSnapshot001 * @tc.desc: GetDisplayHDRSnapshot test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, GetDisplayHDRSnapshot001, TestSize.Level1) { DisplayId validDisplayId = DEFAULT_DISPLAY; DmErrorCode errorCode; bool isUseDma = false; bool isCaptureFullOfScreen = false; std::vector> result = SingletonContainer::Get().GetDisplayHDRSnapshot( validDisplayId, errorCode, isUseDma, isCaptureFullOfScreen); EXPECT_EQ(result.size(), PIXELMAP_SIZE); EXPECT_EQ(result[SDR_PIXELMAP], nullptr); EXPECT_EQ(result[HDR_PIXELMAP], nullptr); } /** * @tc.name: SetVirtualScreenAutoRotation * @tc.desc: SetVirtualScreenAutoRotation test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetVirtualScreenAutoRotation, TestSize.Level1) { if (!SceneBoardJudgement::IsSceneBoardEnabled()) { return; } ScreenId screenId = 1111; bool enable = false; DMError err = SingletonContainer::Get().SetVirtualScreenAutoRotation(screenId, enable); EXPECT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } /** * @tc.name: SetScreenPrivacyWindowTagSwitch * @tc.desc: SetScreenPrivacyWindowTagSwitch test * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetScreenPrivacyWindowTagSwitch, TestSize.Level1) { if (!SceneBoardJudgement::IsSceneBoardEnabled()) { return; } ScreenId screenId = 0; std::vector privacyWindowTag{"test1", "test2"}; DMError res = SingletonContainer::Get().SetScreenPrivacyWindowTagSwitch(screenId, privacyWindowTag, true); EXPECT_EQ(res, DMError::DM_OK); sptr screenSessionManagerServiceProxyTmp = SingletonContainer::Get().screenSessionManagerServiceProxy_; SingletonContainer::Get().screenSessionManagerServiceProxy_ = nullptr; res = SingletonContainer::Get().SetScreenPrivacyWindowTagSwitch(screenId, privacyWindowTag, true); SingletonContainer::Get().screenSessionManagerServiceProxy_ = screenSessionManagerServiceProxyTmp; EXPECT_EQ(res, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } /** * @tc.name: SetVirtualScreenAsDefault * @tc.desc: test success * @tc.type: FUNC */ HWTEST_F(DisplayManagerAdapterTest, SetVirtualScreenAsDefault, TestSize.Level1) { ScreenId screenId = 0; bool res = SingletonContainer::Get().SetVirtualScreenAsDefault(screenId); EXPECT_FALSE(res); } } }