1 /*
2  * Copyright (c) 2021-2022 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 #include "display_manager_adapter.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 class MockDisplayManagerAdapter : public DisplayManagerAdapter {
25 public:
26     MOCK_METHOD0(Clear, void());
27     MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
28         DisplayManagerAgentType type));
29     MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
30         DisplayManagerAgentType type));
31     MOCK_METHOD0(GetDefaultDisplayInfo, sptr<DisplayInfo>());
32     MOCK_METHOD1(GetDisplayInfoByScreenId, sptr<DisplayInfo>(ScreenId screenId));
33     MOCK_METHOD3(GetDisplaySnapshot, std::shared_ptr<Media::PixelMap>(DisplayId displayId, DmErrorCode* errorCode,
34         bool isUseDma));
35 
36     MOCK_METHOD1(WakeUpBegin, bool(PowerStateChangeReason reason));
37     MOCK_METHOD0(WakeUpEnd, bool());
38     MOCK_METHOD1(SuspendBegin, bool(PowerStateChangeReason reason));
39     MOCK_METHOD0(SuspendEnd, bool());
40     MOCK_METHOD1(SetDisplayState, bool(DisplayState state));
41     MOCK_METHOD1(GetDisplayState, DisplayState(DisplayId displayId));
42     MOCK_METHOD1(NotifyDisplayEvent, void(DisplayEvent event));
43     MOCK_METHOD1(GetDisplayInfo, sptr<DisplayInfo>(DisplayId displayId));
44     MOCK_METHOD1(GetCutoutInfo, sptr<CutoutInfo>(DisplayId displayId));
45     MOCK_METHOD2(GetAvailableArea, DMError(DisplayId displayId, DMRect& area));
46     MOCK_METHOD1(HasImmersiveWindow, DMError(bool& immersive));
47 };
48 
49 class MockScreenManagerAdapter : public ScreenManagerAdapter {
50 public:
51     MOCK_METHOD0(Clear, void());
52     MOCK_METHOD2(RegisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
53         DisplayManagerAgentType type));
54     MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr<IDisplayManagerAgent>& displayManagerAgent,
55         DisplayManagerAgentType type));
56     MOCK_METHOD2(RequestRotation, bool(ScreenId screenId, Rotation rotation));
57     MOCK_METHOD2(CreateVirtualScreen, ScreenId(VirtualScreenOption option,
58         const sptr<IDisplayManagerAgent>& displayManagerAgent));
59     MOCK_METHOD1(DestroyVirtualScreen, DMError(ScreenId screenId));
60     MOCK_METHOD2(SetVirtualScreenSurface, DMError(ScreenId screenId, sptr<Surface> surface));
61     MOCK_METHOD1(GetScreenGroupInfoById, sptr<ScreenGroupInfo>(ScreenId screenId));
62     MOCK_METHOD1(GetAllScreenInfos, DMError(std::vector<sptr<ScreenInfo>>& screenInfos));
63     MOCK_METHOD3(MakeMirror, DMError(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenId,
64         ScreenId& screenGroupId));
65     MOCK_METHOD3(MakeExpand, DMError(std::vector<ScreenId> screenId, std::vector<Point> startPoint,
66         ScreenId& screenGroupId));
67     MOCK_METHOD2(SetScreenActiveMode, DMError(ScreenId screenId, uint32_t modeId));
68     MOCK_METHOD1(GetScreenInfo, sptr<ScreenInfo>(ScreenId screenId));
69     MOCK_METHOD2(SetScreenPowerForAll, bool(ScreenPowerState state, PowerStateChangeReason reason));
70     MOCK_METHOD1(GetScreenPower, ScreenPowerState(ScreenId dmsScreenId));
71 
72     MOCK_METHOD2(GetScreenSupportedColorGamuts, DMError(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts));
73     MOCK_METHOD2(GetScreenColorGamut, DMError(ScreenId screenId, ScreenColorGamut& colorGamut));
74     MOCK_METHOD2(SetScreenColorGamut, DMError(ScreenId screenId, int32_t colorGamutIdx));
75     MOCK_METHOD2(GetScreenGamutMap, DMError(ScreenId screenId, ScreenGamutMap& gamutMap));
76     MOCK_METHOD2(SetScreenGamutMap, DMError(ScreenId screenId, ScreenGamutMap gamutMap));
77     MOCK_METHOD1(SetScreenColorTransform, DMError(ScreenId screenId));
78 
79     MOCK_METHOD1(RemoveVirtualScreenFromGroup, void(std::vector<ScreenId> screens));
80     MOCK_METHOD1(SetScreenRotationLocked, DMError(bool isLocked));
81     MOCK_METHOD1(IsScreenRotationLocked, DMError(bool& isLocked));
82     MOCK_METHOD4(SetResolution, DMError(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio));
83     MOCK_METHOD2(GetPixelFormat, DMError(ScreenId screenId, GraphicPixelFormat& pixelFormat));
84     MOCK_METHOD2(SetPixelFormat, DMError(ScreenId screenId, GraphicPixelFormat pixelFormat));
85     MOCK_METHOD2(GetDensityInCurResolution, DMError(ScreenId screenId, float& virtualPixelRatio));
86     MOCK_METHOD2(GetSupportedHDRFormats, DMError(ScreenId screenId, std::vector<ScreenHDRFormat>&  hdrFormats));
87     MOCK_METHOD2(GetSupportedColorSpaces, DMError(ScreenId screenId,
88         std::vector<GraphicCM_ColorSpaceType>& colorSpaces));
89     MOCK_METHOD2(SetOrientation, DMError(ScreenId screenId, Orientation orientation));
90     MOCK_METHOD2(GetScreenHDRFormat, DMError(ScreenId screenId, ScreenHDRFormat& hdrFormat));
91     MOCK_METHOD2(SetScreenHDRFormat, DMError(ScreenId screenId, int32_t modeIdx));
92     MOCK_METHOD2(GetScreenColorSpace, DMError(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace));
93     MOCK_METHOD2(SetScreenColorSpace, DMError(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace));
94 };
95 }
96 } // namespace OHOS
97 
98 #endif // FRAMEWORKS_WM_TEST_UT_MOCK_DISPLAY_MANAGER_ADAPTER_H