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