Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 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 | |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 19 | #include <compositionengine/Output.h> |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 20 | #include <gmock/gmock.h> |
| 21 | |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 22 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 23 | #pragma clang diagnostic push |
| 24 | #pragma clang diagnostic ignored "-Wconversion" |
Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 25 | #pragma clang diagnostic ignored "-Wextra" |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 26 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 27 | #include "DisplayHardware/HWComposer.h" |
| 28 | |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 29 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 30 | #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 31 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 32 | namespace android { |
| 33 | namespace mock { |
| 34 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 35 | namespace hal = android::hardware::graphics::composer::hal; |
| 36 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 37 | class HWComposer : public android::HWComposer { |
| 38 | public: |
| 39 | HWComposer(); |
| 40 | ~HWComposer() override; |
| 41 | |
Yichi Chen | 1a417af | 2022-01-21 15:29:52 +0800 | [diff] [blame] | 42 | MOCK_METHOD1(setCallback, void(HWC2::ComposerCallback&)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 43 | MOCK_CONST_METHOD3(getDisplayIdentificationData, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 44 | bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*)); |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 45 | MOCK_CONST_METHOD1(hasCapability, |
| 46 | bool(aidl::android::hardware::graphics::composer3::Capability)); |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 47 | MOCK_CONST_METHOD2(hasDisplayCapability, |
| 48 | bool(HalDisplayId, |
| 49 | aidl::android::hardware::graphics::composer3::DisplayCapability)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 50 | |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 51 | MOCK_CONST_METHOD0(getMaxVirtualDisplayCount, size_t()); |
| 52 | MOCK_CONST_METHOD0(getMaxVirtualDisplayDimension, size_t()); |
Dominik Laskowski | 263eec4 | 2021-07-21 23:13:24 -0700 | [diff] [blame] | 53 | MOCK_METHOD3(allocateVirtualDisplay, bool(HalVirtualDisplayId, ui::Size, ui::PixelFormat*)); |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 54 | MOCK_METHOD2(allocatePhysicalDisplay, void(hal::HWDisplayId, PhysicalDisplayId)); |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 55 | |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 56 | MOCK_METHOD1(createLayer, std::shared_ptr<HWC2::Layer>(HalDisplayId)); |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 57 | MOCK_METHOD6(getDeviceCompositionChanges, |
Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 58 | status_t(HalDisplayId, bool, std::chrono::steady_clock::time_point, |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 59 | const std::shared_ptr<FenceTime>&, nsecs_t, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 60 | std::optional<android::HWComposer::DeviceRequestedChanges>*)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 61 | MOCK_METHOD5(setClientTarget, |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 62 | status_t(HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&, |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 63 | ui::Dataspace)); |
Ady Abraham | ec7aa8a | 2021-06-28 12:37:09 -0700 | [diff] [blame] | 64 | MOCK_METHOD3(presentAndGetReleaseFences, |
| 65 | status_t(HalDisplayId, std::chrono::steady_clock::time_point, |
| 66 | const std::shared_ptr<FenceTime>&)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 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)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 71 | MOCK_CONST_METHOD1(hasDeviceComposition, bool(const std::optional<DisplayId>&)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 72 | MOCK_CONST_METHOD1(getPresentFence, sp<Fence>(HalDisplayId)); |
Dominik Laskowski | dc2bb80 | 2022-09-28 16:02:59 -0400 | [diff] [blame] | 73 | MOCK_METHOD(nsecs_t, getPresentTimestamp, (PhysicalDisplayId), (const, override)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 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)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 83 | MOCK_METHOD4(getDisplayedContentSamplingAttributes, |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 84 | status_t(HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*)); |
| 85 | MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(HalDisplayId, bool, uint8_t, uint64_t)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 86 | MOCK_METHOD4(getDisplayedContentSample, |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 87 | status_t(HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*)); |
Dominik Laskowski | b17c621 | 2022-05-09 09:36:19 -0700 | [diff] [blame] | 88 | MOCK_METHOD(ftl::Future<status_t>, setDisplayBrightness, |
| 89 | (PhysicalDisplayId, float, float, const Hwc2::Composer::DisplayBrightnessOptions&), |
| 90 | (override)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 91 | MOCK_METHOD2(getDisplayBrightnessSupport, status_t(PhysicalDisplayId, bool*)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 92 | |
| 93 | MOCK_METHOD2(onHotplug, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 94 | std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection)); |
Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 95 | MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool()); |
Leon Scroggins III | db16a2b | 2023-02-06 17:50:05 -0500 | [diff] [blame^] | 96 | MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 97 | MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 98 | MOCK_CONST_METHOD1(isConnected, bool(PhysicalDisplayId)); |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 99 | MOCK_CONST_METHOD1(getModes, std::vector<HWComposer::HWCDisplayMode>(PhysicalDisplayId)); |
| 100 | MOCK_CONST_METHOD1(getActiveMode, std::optional<hal::HWConfigId>(PhysicalDisplayId)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 101 | MOCK_CONST_METHOD1(getColorModes, std::vector<ui::ColorMode>(PhysicalDisplayId)); |
| 102 | MOCK_METHOD3(setActiveColorMode, status_t(PhysicalDisplayId, ui::ColorMode, ui::RenderIntent)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 103 | MOCK_CONST_METHOD0(isUsingVrComposer, bool()); |
Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 104 | MOCK_CONST_METHOD1(getDisplayConnectionType, ui::DisplayConnectionType(PhysicalDisplayId)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 105 | MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId)); |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 106 | MOCK_CONST_METHOD2(getDisplayVsyncPeriod, status_t(PhysicalDisplayId, nsecs_t*)); |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 107 | MOCK_METHOD4(setActiveModeWithConstraints, |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 108 | status_t(PhysicalDisplayId, hal::HWConfigId, |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 109 | const hal::VsyncPeriodChangeConstraints&, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 110 | hal::VsyncPeriodChangeTimeline*)); |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 111 | MOCK_METHOD2(setBootDisplayMode, status_t(PhysicalDisplayId, hal::HWConfigId)); |
| 112 | MOCK_METHOD1(clearBootDisplayMode, status_t(PhysicalDisplayId)); |
Kriti Dang | 16ca297 | 2022-02-01 20:07:03 +0100 | [diff] [blame] | 113 | MOCK_METHOD1(getPreferredBootDisplayMode, std::optional<hal::HWConfigId>(PhysicalDisplayId)); |
Kriti Dang | 646f8ec | 2022-01-18 14:35:02 +0100 | [diff] [blame] | 114 | MOCK_METHOD0(getBootDisplayModeSupport, bool()); |
Kriti Dang | 674b937 | 2022-11-18 10:58:44 +0100 | [diff] [blame] | 115 | MOCK_CONST_METHOD0( |
| 116 | getHdrConversionCapabilities, |
| 117 | std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>()); |
| 118 | MOCK_METHOD1(setHdrConversionStrategy, |
| 119 | status_t(aidl::android::hardware::graphics::common::HdrConversionStrategy)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 120 | MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool)); |
Dominik Laskowski | 6c7b36e | 2022-03-03 08:27:58 -0800 | [diff] [blame] | 121 | MOCK_METHOD(status_t, getSupportedContentTypes, |
| 122 | (PhysicalDisplayId, std::vector<hal::ContentType>*), (const, override)); |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 123 | MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType)); |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 124 | MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata, |
| 125 | const std::unordered_map<std::string, bool>&()); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 126 | |
| 127 | MOCK_CONST_METHOD1(dump, void(std::string&)); |
| 128 | MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*()); |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 129 | |
| 130 | MOCK_METHOD(hal::HWDisplayId, getPrimaryHwcDisplayId, (), (const, override)); |
| 131 | MOCK_METHOD(PhysicalDisplayId, getPrimaryDisplayId, (), (const, override)); |
| 132 | MOCK_METHOD(bool, isHeadless, (), (const, override)); |
| 133 | |
| 134 | MOCK_METHOD(std::optional<PhysicalDisplayId>, toPhysicalDisplayId, (hal::HWDisplayId), |
| 135 | (const, override)); |
| 136 | MOCK_METHOD(std::optional<hal::HWDisplayId>, fromPhysicalDisplayId, (PhysicalDisplayId), |
| 137 | (const, override)); |
Leon Scroggins III | e7c51c6 | 2022-02-01 15:53:54 -0500 | [diff] [blame] | 138 | MOCK_METHOD2(getDisplayDecorationSupport, |
| 139 | status_t(PhysicalDisplayId, |
| 140 | std::optional<aidl::android::hardware::graphics::common:: |
| 141 | DisplayDecorationSupport>* support)); |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 142 | MOCK_METHOD2(setIdleTimerEnabled, status_t(PhysicalDisplayId, std::chrono::milliseconds)); |
ramindani | 06e518e | 2022-03-14 18:47:53 +0000 | [diff] [blame] | 143 | MOCK_METHOD(bool, hasDisplayIdleTimerCapability, (PhysicalDisplayId), (const, override)); |
| 144 | MOCK_METHOD(Hwc2::AidlTransform, getPhysicalDisplayOrientation, (PhysicalDisplayId), |
| 145 | (const, override)); |
Matt Buckley | 50c4406 | 2022-01-17 20:48:10 +0000 | [diff] [blame] | 146 | MOCK_METHOD(bool, getValidateSkipped, (HalDisplayId), (const, override)); |
Sally Qi | bb866c1 | 2022-10-17 11:31:20 -0700 | [diff] [blame] | 147 | MOCK_METHOD(const aidl::android::hardware::graphics::composer3::OverlayProperties&, |
| 148 | getOverlaySupport, (), (const, override)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | } // namespace mock |
| 152 | } // namespace android |