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_METHOD(status_t, getDeviceCompositionChanges, 58 (HalDisplayId, bool, std::optional<std::chrono::steady_clock::time_point>, nsecs_t, 59 Fps, std::optional<android::HWComposer::DeviceRequestedChanges>*)); 60 MOCK_METHOD(status_t, setClientTarget, 61 (HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&, ui::Dataspace, 62 float), 63 (override)); 64 MOCK_METHOD2(presentAndGetReleaseFences, 65 status_t(HalDisplayId, std::optional<std::chrono::steady_clock::time_point>)); 66 MOCK_METHOD(status_t, executeCommands, (HalDisplayId)); 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_METHOD(nsecs_t, getPresentTimestamp, (PhysicalDisplayId), (const, override)); 74 MOCK_CONST_METHOD2(getLayerReleaseFence, sp<Fence>(HalDisplayId, HWC2::Layer*)); 75 MOCK_METHOD3(setOutputBuffer, 76 status_t(HalVirtualDisplayId, const sp<Fence>&, const sp<GraphicBuffer>&)); 77 MOCK_METHOD1(clearReleaseFences, void(HalDisplayId)); 78 MOCK_METHOD2(getHdrCapabilities, status_t(HalDisplayId, HdrCapabilities*)); 79 MOCK_CONST_METHOD1(getSupportedPerFrameMetadata, int32_t(HalDisplayId)); 80 MOCK_CONST_METHOD2(getRenderIntents, 81 std::vector<ui::RenderIntent>(HalDisplayId, ui::ColorMode)); 82 MOCK_METHOD2(getDataspaceSaturationMatrix, mat4(HalDisplayId, ui::Dataspace)); 83 MOCK_METHOD4(getDisplayedContentSamplingAttributes, 84 status_t(HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*)); 85 MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(HalDisplayId, bool, uint8_t, uint64_t)); 86 MOCK_METHOD4(getDisplayedContentSample, 87 status_t(HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*)); 88 MOCK_METHOD(ftl::Future<status_t>, setDisplayBrightness, 89 (PhysicalDisplayId, float, float, const Hwc2::Composer::DisplayBrightnessOptions&), 90 (override)); 91 MOCK_METHOD2(getDisplayBrightnessSupport, status_t(PhysicalDisplayId, bool*)); 92 93 MOCK_METHOD2(onHotplug, 94 std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection)); 95 MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool()); 96 MOCK_METHOD(std::optional<PhysicalDisplayId>, onVsync, (hal::HWDisplayId, int64_t)); 97 MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync)); 98 MOCK_CONST_METHOD1(isConnected, bool(PhysicalDisplayId)); 99 MOCK_CONST_METHOD2(getModes, 100 std::vector<HWComposer::HWCDisplayMode>(PhysicalDisplayId, int32_t)); 101 MOCK_CONST_METHOD1(getActiveMode, ftl::Expected<hal::HWConfigId, status_t>(PhysicalDisplayId)); 102 MOCK_CONST_METHOD1(getColorModes, std::vector<ui::ColorMode>(PhysicalDisplayId)); 103 MOCK_METHOD3(setActiveColorMode, status_t(PhysicalDisplayId, ui::ColorMode, ui::RenderIntent)); 104 MOCK_CONST_METHOD0(isUsingVrComposer, bool()); 105 MOCK_CONST_METHOD1(getDisplayConnectionType, ui::DisplayConnectionType(PhysicalDisplayId)); 106 MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId)); 107 MOCK_CONST_METHOD1(getDisplayVsyncPeriod, ftl::Expected<nsecs_t, status_t>(PhysicalDisplayId)); 108 MOCK_METHOD4(setActiveModeWithConstraints, 109 status_t(PhysicalDisplayId, hal::HWConfigId, 110 const hal::VsyncPeriodChangeConstraints&, 111 hal::VsyncPeriodChangeTimeline*)); 112 MOCK_METHOD2(setBootDisplayMode, status_t(PhysicalDisplayId, hal::HWConfigId)); 113 MOCK_METHOD1(clearBootDisplayMode, status_t(PhysicalDisplayId)); 114 MOCK_METHOD1(getPreferredBootDisplayMode, std::optional<hal::HWConfigId>(PhysicalDisplayId)); 115 MOCK_METHOD0(getBootDisplayModeSupport, bool()); 116 MOCK_CONST_METHOD0( 117 getHdrConversionCapabilities, 118 std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>()); 119 MOCK_METHOD2(setHdrConversionStrategy, 120 status_t(aidl::android::hardware::graphics::common::HdrConversionStrategy, 121 aidl::android::hardware::graphics::common::Hdr*)); 122 MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool)); 123 MOCK_METHOD(status_t, getSupportedContentTypes, 124 (PhysicalDisplayId, std::vector<hal::ContentType>*), (const, override)); 125 MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType)); 126 MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata, 127 const std::unordered_map<std::string, bool>&()); 128 129 MOCK_CONST_METHOD1(dump, void(std::string&)); 130 MOCK_CONST_METHOD1(dumpOverlayProperties, void(std::string&)); 131 MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*()); 132 133 MOCK_METHOD(hal::HWDisplayId, getPrimaryHwcDisplayId, (), (const, override)); 134 MOCK_METHOD(PhysicalDisplayId, getPrimaryDisplayId, (), (const, override)); 135 MOCK_METHOD(bool, isHeadless, (), (const, override)); 136 137 MOCK_METHOD(std::optional<PhysicalDisplayId>, toPhysicalDisplayId, (hal::HWDisplayId), 138 (const, override)); 139 MOCK_METHOD(std::optional<hal::HWDisplayId>, fromPhysicalDisplayId, (PhysicalDisplayId), 140 (const, override)); 141 MOCK_METHOD2(getDisplayDecorationSupport, 142 status_t(PhysicalDisplayId, 143 std::optional<aidl::android::hardware::graphics::common:: 144 DisplayDecorationSupport>* support)); 145 MOCK_METHOD2(setIdleTimerEnabled, status_t(PhysicalDisplayId, std::chrono::milliseconds)); 146 MOCK_METHOD(bool, hasDisplayIdleTimerCapability, (PhysicalDisplayId), (const, override)); 147 MOCK_METHOD(Hwc2::AidlTransform, getPhysicalDisplayOrientation, (PhysicalDisplayId), 148 (const, override)); 149 MOCK_METHOD(bool, getValidateSkipped, (HalDisplayId), (const, override)); 150 MOCK_METHOD(const aidl::android::hardware::graphics::composer3::OverlayProperties&, 151 getOverlaySupport, (), (const, override)); 152 MOCK_METHOD(status_t, setRefreshRateChangedCallbackDebugEnabled, (PhysicalDisplayId, bool)); 153 MOCK_METHOD(status_t, notifyExpectedPresent, (PhysicalDisplayId, TimePoint, Fps)); 154 }; 155 156 } // namespace mock 157 } // namespace android 158