1 /* 2 * Copyright (c) 2021-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FRAMEWORKS_WM_TEST_UT_MOCK_DISPLAY_MANAGER_ADAPTER_H 17 #define FRAMEWORKS_WM_TEST_UT_MOCK_DISPLAY_MANAGER_ADAPTER_H 18 #include <gmock/gmock.h> 19 20 21 #include "display_manager.h" 22 #include "display_manager_adapter.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class MockDisplayManagerAdapter : public DisplayManagerAdapter { 27 public: 28 MOCK_METHOD0(Clear, void()); 29 MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent, 30 DisplayManagerAgentType type)); 31 MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent, 32 DisplayManagerAgentType type)); 33 MOCK_METHOD0(GetDefaultDisplayInfo, sptr<DisplayInfo>()); 34 MOCK_METHOD1(GetDisplayInfoByScreenId, sptr<DisplayInfo>(ScreenId screenId)); 35 MOCK_METHOD4(GetDisplaySnapshot, std::shared_ptr<Media::PixelMap>(DisplayId displayId, DmErrorCode* errorCode, 36 bool isUseDma, bool isCaptureFullOfScreen)); 37 38 MOCK_METHOD1(WakeUpBegin, bool(PowerStateChangeReason reason)); 39 MOCK_METHOD0(WakeUpEnd, bool()); 40 MOCK_METHOD1(SuspendBegin, bool(PowerStateChangeReason reason)); 41 MOCK_METHOD0(SuspendEnd, bool()); 42 MOCK_METHOD1(SetDisplayState, bool(DisplayState state)); 43 MOCK_METHOD1(GetDisplayState, DisplayState(DisplayId displayId)); 44 MOCK_METHOD1(NotifyDisplayEvent, void(DisplayEvent event)); 45 MOCK_METHOD1(GetDisplayInfo, sptr<DisplayInfo>(DisplayId displayId)); 46 MOCK_METHOD4(GetCutoutInfo, sptr<CutoutInfo>(DisplayId displayId, int32_t width, int32_t height, 47 Rotation rotation)); 48 MOCK_METHOD2(GetAvailableArea, DMError(ScreenId screenId, DMRect& area)); 49 MOCK_METHOD2(HasImmersiveWindow, DMError(ScreenId screenId, bool& immersive)); 50 MOCK_METHOD0(GetAllDisplayIds, std::vector<DisplayId>()); 51 MOCK_METHOD4(GetDisplayHDRSnapshot, std::vector<std::shared_ptr<Media::PixelMap>>(DisplayId displayId, 52 DmErrorCode& errorCode, bool isUseDma, bool isCaptureFullOfScreen)); 53 MOCK_METHOD2(GetDisplayHDRSnapshotWithOption, std::vector<std::shared_ptr<Media::PixelMap>>( 54 const CaptureOption& captureOption, DmErrorCode& errorCode)); 55 }; 56 57 class MockScreenManagerAdapter : public ScreenManagerAdapter { 58 public: 59 MOCK_METHOD0(Clear, void()); 60 MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent, 61 DisplayManagerAgentType type)); 62 MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent, 63 DisplayManagerAgentType type)); 64 MOCK_METHOD2(CreateVirtualScreen, ScreenId(VirtualScreenOption option, 65 const sptr<IDisplayManagerAgent>& displayManagerAgent)); 66 MOCK_METHOD1(DestroyVirtualScreen, DMError(ScreenId screenId)); 67 MOCK_METHOD2(SetVirtualScreenSurface, DMError(ScreenId screenId, sptr<Surface> surface)); 68 MOCK_METHOD1(GetScreenGroupInfoById, sptr<ScreenGroupInfo>(ScreenId screenId)); 69 MOCK_METHOD1(GetAllScreenInfos, DMError(std::vector<sptr<ScreenInfo>>& screenInfos)); 70 MOCK_METHOD3(MakeMirror, DMError(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId, 71 ScreenId& screenGroupId)); 72 MOCK_METHOD3(MakeExpand, DMError(std::vector<ScreenId> screenId, std::vector<Point> startPoint, 73 ScreenId& screenGroupId)); 74 MOCK_METHOD2(SetScreenActiveMode, DMError(ScreenId screenId, uint32_t modeId)); 75 MOCK_METHOD1(GetScreenInfo, sptr<ScreenInfo>(ScreenId screenId)); 76 MOCK_METHOD2(SetScreenPowerForAll, bool(ScreenPowerState state, PowerStateChangeReason reason)); 77 MOCK_METHOD1(GetScreenPower, ScreenPowerState(ScreenId dmsScreenId)); 78 79 MOCK_METHOD2(GetScreenSupportedColorGamuts, DMError(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts)); 80 MOCK_METHOD2(GetScreenColorGamut, DMError(ScreenId screenId, ScreenColorGamut& colorGamut)); 81 MOCK_METHOD2(SetScreenColorGamut, DMError(ScreenId screenId, int32_t colorGamutIdx)); 82 MOCK_METHOD2(GetScreenGamutMap, DMError(ScreenId screenId, ScreenGamutMap& gamutMap)); 83 MOCK_METHOD2(SetScreenGamutMap, DMError(ScreenId screenId, ScreenGamutMap gamutMap)); 84 MOCK_METHOD1(SetScreenColorTransform, DMError(ScreenId screenId)); 85 MOCK_METHOD2(SetOrientation, DMError(ScreenId screenId, Orientation orientation)); 86 MOCK_METHOD2(GetDensityInCurResolution, DMError(ScreenId screenId, float& virtualPixelRatio)); 87 MOCK_METHOD2(GetPixelFormat, DMError(ScreenId screenId, GraphicPixelFormat& pixelFormat)); 88 MOCK_METHOD2(SetPixelFormat, DMError(ScreenId screenId, GraphicPixelFormat pixelFormat)); 89 MOCK_METHOD2(GetSupportedHDRFormats, DMError(ScreenId screenId, std::vector<ScreenHDRFormat>& hdrFormats)); 90 MOCK_METHOD2(GetScreenHDRFormat, DMError(ScreenId screenId, ScreenHDRFormat& hdrFormat)); 91 MOCK_METHOD2(SetScreenHDRFormat, DMError(ScreenId screenId, int32_t modeIdx)); 92 MOCK_METHOD2(GetSupportedColorSpaces, DMError(ScreenId screenId, 93 std::vector<GraphicCM_ColorSpaceType>& colorSpaces)); 94 MOCK_METHOD2(GetScreenColorSpace, DMError(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace)); 95 MOCK_METHOD2(SetScreenColorSpace, DMError(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace)); 96 97 MOCK_METHOD1(RemoveVirtualScreenFromGroup, void(std::vector<ScreenId> screens)); 98 MOCK_METHOD1(SetScreenRotationLocked, DMError(bool isLocked)); 99 MOCK_METHOD1(IsScreenRotationLocked, DMError(bool& isLocked)); 100 MOCK_METHOD4(SetResolution, DMError(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio)); 101 }; 102 103 class MockDisplayManger : public DisplayManager { 104 public: 105 MOCK_METHOD4(GetScreenHDRshot, std::vector<std::shared_ptr<Media::PixelMap>>(DisplayId displayId, 106 DmErrorCode* errorCode, bool isUseDma, bool isCaptureFullOfScreen)); 107 MOCK_METHOD2(GetDisplayHDRSnapshotWithOption, std::vector<std::shared_ptr<Media::PixelMap>>( 108 const CaptureOption& captureOption, DmErrorCode* errorCode)); 109 }; 110 } // namespace Rosen 111 } // namespace OHOS 112 113 #endif // FRAMEWORKS_WM_TEST_UT_MOCK_DISPLAY_MANAGER_ADAPTER_H 114