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, bool(hal::Capability)); 46 MOCK_CONST_METHOD2(hasDisplayCapability, bool(HalDisplayId, hal::DisplayCapability)); 47 48 MOCK_CONST_METHOD0(getMaxVirtualDisplayCount, size_t()); 49 MOCK_CONST_METHOD0(getMaxVirtualDisplayDimension, size_t()); 50 MOCK_METHOD4(allocateVirtualDisplay, 51 bool(HalVirtualDisplayId, ui::Size, ui::PixelFormat*, 52 std::optional<PhysicalDisplayId>)); 53 MOCK_METHOD2(allocatePhysicalDisplay, void(hal::HWDisplayId, PhysicalDisplayId)); 54 MOCK_METHOD1(createLayer, std::shared_ptr<HWC2::Layer>(HalDisplayId)); 55 MOCK_METHOD5(getDeviceCompositionChanges, 56 status_t(HalDisplayId, bool, std::chrono::steady_clock::time_point, 57 const std::shared_ptr<FenceTime>&, 58 std::optional<android::HWComposer::DeviceRequestedChanges>*)); 59 MOCK_METHOD5(setClientTarget, 60 status_t(HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&, 61 ui::Dataspace)); 62 MOCK_METHOD3(presentAndGetReleaseFences, 63 status_t(HalDisplayId, std::chrono::steady_clock::time_point, 64 const std::shared_ptr<FenceTime>&)); 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_CONST_METHOD2(getLayerReleaseFence, sp<Fence>(HalDisplayId, HWC2::Layer*)); 72 MOCK_METHOD3(setOutputBuffer, 73 status_t(HalVirtualDisplayId, const sp<Fence>&, const sp<GraphicBuffer>&)); 74 MOCK_METHOD1(clearReleaseFences, void(HalDisplayId)); 75 MOCK_METHOD2(getHdrCapabilities, status_t(HalDisplayId, HdrCapabilities*)); 76 MOCK_CONST_METHOD1(getSupportedPerFrameMetadata, int32_t(HalDisplayId)); 77 MOCK_CONST_METHOD2(getRenderIntents, 78 std::vector<ui::RenderIntent>(HalDisplayId, ui::ColorMode)); 79 MOCK_METHOD2(getDataspaceSaturationMatrix, mat4(HalDisplayId, ui::Dataspace)); 80 MOCK_METHOD4(getDisplayedContentSamplingAttributes, 81 status_t(HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*)); 82 MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(HalDisplayId, bool, uint8_t, uint64_t)); 83 MOCK_METHOD4(getDisplayedContentSample, 84 status_t(HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*)); 85 MOCK_METHOD2(setDisplayBrightness, std::future<status_t>(PhysicalDisplayId, float)); 86 MOCK_METHOD2(getDisplayBrightnessSupport, status_t(PhysicalDisplayId, bool*)); 87 88 MOCK_METHOD2(onHotplug, 89 std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection)); 90 MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool()); 91 MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t)); 92 MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync)); 93 MOCK_CONST_METHOD1(isConnected, bool(PhysicalDisplayId)); 94 MOCK_CONST_METHOD1(getModes, std::vector<HWComposer::HWCDisplayMode>(PhysicalDisplayId)); 95 MOCK_CONST_METHOD1(getActiveMode, std::optional<hal::HWConfigId>(PhysicalDisplayId)); 96 MOCK_CONST_METHOD1(getColorModes, std::vector<ui::ColorMode>(PhysicalDisplayId)); 97 MOCK_METHOD3(setActiveColorMode, status_t(PhysicalDisplayId, ui::ColorMode, ui::RenderIntent)); 98 MOCK_CONST_METHOD0(isUsingVrComposer, bool()); 99 MOCK_CONST_METHOD1(getDisplayConnectionType, ui::DisplayConnectionType(PhysicalDisplayId)); 100 MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId)); 101 MOCK_CONST_METHOD2(getDisplayVsyncPeriod, status_t(PhysicalDisplayId, nsecs_t*)); 102 MOCK_METHOD4(setActiveModeWithConstraints, 103 status_t(PhysicalDisplayId, hal::HWConfigId, 104 const hal::VsyncPeriodChangeConstraints&, 105 hal::VsyncPeriodChangeTimeline*)); 106 MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool)); 107 MOCK_METHOD2(getSupportedContentTypes, 108 status_t(PhysicalDisplayId, std::vector<hal::ContentType>*)); 109 MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType)); 110 MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata, 111 const std::unordered_map<std::string, bool>&()); 112 113 MOCK_CONST_METHOD1(dump, void(std::string&)); 114 MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*()); 115 MOCK_CONST_METHOD1(getHwcDisplayId, std::optional<hal::HWDisplayId>(int32_t)); 116 MOCK_CONST_METHOD0(getInternalHwcDisplayId, std::optional<hal::HWDisplayId>()); 117 MOCK_CONST_METHOD0(getExternalHwcDisplayId, std::optional<hal::HWDisplayId>()); 118 MOCK_CONST_METHOD1(toPhysicalDisplayId, std::optional<PhysicalDisplayId>(hal::HWDisplayId)); 119 MOCK_CONST_METHOD1(fromPhysicalDisplayId, std::optional<hal::HWDisplayId>(PhysicalDisplayId)); 120 }; 121 122 } // namespace mock 123 } // namespace android 124