• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <compositionengine/Output.h>
20 #include <gmock/gmock.h>
21 
22 // TODO(b/129481165): remove the #pragma below and fix conversion issues
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wconversion"
25 #pragma clang diagnostic ignored "-Wextra"
26 
27 #include "DisplayHardware/HWComposer.h"
28 
29 // TODO(b/129481165): remove the #pragma below and fix conversion issues
30 #pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
31 
32 namespace android {
33 namespace mock {
34 
35 namespace hal = android::hardware::graphics::composer::hal;
36 
37 class HWComposer : public android::HWComposer {
38 public:
39     HWComposer();
40     ~HWComposer() override;
41 
42     MOCK_METHOD1(setCallback, void(HWC2::ComposerCallback&));
43     MOCK_CONST_METHOD3(getDisplayIdentificationData,
44                        bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*));
45     MOCK_CONST_METHOD1(hasCapability,
46                        bool(aidl::android::hardware::graphics::composer3::Capability));
47     MOCK_CONST_METHOD2(hasDisplayCapability,
48                        bool(HalDisplayId,
49                             aidl::android::hardware::graphics::composer3::DisplayCapability));
50 
51     MOCK_CONST_METHOD0(getMaxVirtualDisplayCount, size_t());
52     MOCK_CONST_METHOD0(getMaxVirtualDisplayDimension, size_t());
53     MOCK_METHOD3(allocateVirtualDisplay, bool(HalVirtualDisplayId, ui::Size, ui::PixelFormat*));
54     MOCK_METHOD2(allocatePhysicalDisplay, void(hal::HWDisplayId, PhysicalDisplayId));
55 
56     MOCK_METHOD1(createLayer, std::shared_ptr<HWC2::Layer>(HalDisplayId));
57     MOCK_METHOD6(getDeviceCompositionChanges,
58                  status_t(HalDisplayId, bool, std::chrono::steady_clock::time_point,
59                           const std::shared_ptr<FenceTime>&, nsecs_t,
60                           std::optional<android::HWComposer::DeviceRequestedChanges>*));
61     MOCK_METHOD5(setClientTarget,
62                  status_t(HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&,
63                           ui::Dataspace));
64     MOCK_METHOD3(presentAndGetReleaseFences,
65                  status_t(HalDisplayId, std::chrono::steady_clock::time_point,
66                           const std::shared_ptr<FenceTime>&));
67     MOCK_METHOD2(setPowerMode, status_t(PhysicalDisplayId, hal::PowerMode));
68     MOCK_METHOD2(setActiveConfig, status_t(HalDisplayId, size_t));
69     MOCK_METHOD2(setColorTransform, status_t(HalDisplayId, const mat4&));
70     MOCK_METHOD1(disconnectDisplay, void(HalDisplayId));
71     MOCK_CONST_METHOD1(hasDeviceComposition, bool(const std::optional<DisplayId>&));
72     MOCK_CONST_METHOD1(getPresentFence, sp<Fence>(HalDisplayId));
73     MOCK_CONST_METHOD2(getLayerReleaseFence, sp<Fence>(HalDisplayId, HWC2::Layer*));
74     MOCK_METHOD3(setOutputBuffer,
75                  status_t(HalVirtualDisplayId, const sp<Fence>&, const sp<GraphicBuffer>&));
76     MOCK_METHOD1(clearReleaseFences, void(HalDisplayId));
77     MOCK_METHOD2(getHdrCapabilities, status_t(HalDisplayId, HdrCapabilities*));
78     MOCK_CONST_METHOD1(getSupportedPerFrameMetadata, int32_t(HalDisplayId));
79     MOCK_CONST_METHOD2(getRenderIntents,
80                        std::vector<ui::RenderIntent>(HalDisplayId, ui::ColorMode));
81     MOCK_METHOD2(getDataspaceSaturationMatrix, mat4(HalDisplayId, ui::Dataspace));
82     MOCK_METHOD4(getDisplayedContentSamplingAttributes,
83                  status_t(HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*));
84     MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(HalDisplayId, bool, uint8_t, uint64_t));
85     MOCK_METHOD4(getDisplayedContentSample,
86                  status_t(HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*));
87     MOCK_METHOD(ftl::Future<status_t>, setDisplayBrightness,
88                 (PhysicalDisplayId, float, float, const Hwc2::Composer::DisplayBrightnessOptions&),
89                 (override));
90     MOCK_METHOD2(getDisplayBrightnessSupport, status_t(PhysicalDisplayId, bool*));
91 
92     MOCK_METHOD2(onHotplug,
93                  std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection));
94     MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool());
95     MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t));
96     MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync));
97     MOCK_CONST_METHOD1(isConnected, bool(PhysicalDisplayId));
98     MOCK_CONST_METHOD1(getModes, std::vector<HWComposer::HWCDisplayMode>(PhysicalDisplayId));
99     MOCK_CONST_METHOD1(getActiveMode, std::optional<hal::HWConfigId>(PhysicalDisplayId));
100     MOCK_CONST_METHOD1(getColorModes, std::vector<ui::ColorMode>(PhysicalDisplayId));
101     MOCK_METHOD3(setActiveColorMode, status_t(PhysicalDisplayId, ui::ColorMode, ui::RenderIntent));
102     MOCK_CONST_METHOD0(isUsingVrComposer, bool());
103     MOCK_CONST_METHOD1(getDisplayConnectionType, ui::DisplayConnectionType(PhysicalDisplayId));
104     MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId));
105     MOCK_CONST_METHOD2(getDisplayVsyncPeriod, status_t(PhysicalDisplayId, nsecs_t*));
106     MOCK_METHOD4(setActiveModeWithConstraints,
107                  status_t(PhysicalDisplayId, hal::HWConfigId,
108                           const hal::VsyncPeriodChangeConstraints&,
109                           hal::VsyncPeriodChangeTimeline*));
110     MOCK_METHOD2(setBootDisplayMode, status_t(PhysicalDisplayId, hal::HWConfigId));
111     MOCK_METHOD1(clearBootDisplayMode, status_t(PhysicalDisplayId));
112     MOCK_METHOD1(getPreferredBootDisplayMode, std::optional<hal::HWConfigId>(PhysicalDisplayId));
113     MOCK_METHOD0(getBootDisplayModeSupport, bool());
114     MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
115     MOCK_METHOD(status_t, getSupportedContentTypes,
116                 (PhysicalDisplayId, std::vector<hal::ContentType>*), (const, override));
117     MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType));
118     MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata,
119                        const std::unordered_map<std::string, bool>&());
120 
121     MOCK_CONST_METHOD1(dump, void(std::string&));
122     MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*());
123 
124     MOCK_METHOD(hal::HWDisplayId, getPrimaryHwcDisplayId, (), (const, override));
125     MOCK_METHOD(PhysicalDisplayId, getPrimaryDisplayId, (), (const, override));
126     MOCK_METHOD(bool, isHeadless, (), (const, override));
127 
128     MOCK_METHOD(std::optional<PhysicalDisplayId>, toPhysicalDisplayId, (hal::HWDisplayId),
129                 (const, override));
130     MOCK_METHOD(std::optional<hal::HWDisplayId>, fromPhysicalDisplayId, (PhysicalDisplayId),
131                 (const, override));
132     MOCK_METHOD2(getDisplayDecorationSupport,
133                  status_t(PhysicalDisplayId,
134                           std::optional<aidl::android::hardware::graphics::common::
135                                                 DisplayDecorationSupport>* support));
136     MOCK_METHOD2(setIdleTimerEnabled, status_t(PhysicalDisplayId, std::chrono::milliseconds));
137     MOCK_METHOD(bool, hasDisplayIdleTimerCapability, (PhysicalDisplayId), (const, override));
138     MOCK_METHOD(Hwc2::AidlTransform, getPhysicalDisplayOrientation, (PhysicalDisplayId),
139                 (const, override));
140     MOCK_METHOD(bool, getValidateSkipped, (HalDisplayId), (const, override));
141 };
142 
143 } // namespace mock
144 } // namespace android
145