blob: e910c72e2e3bfeb9305fcb6a2ae59b0b20d7bf5d [file] [log] [blame]
Lloyd Pique441d5042018-10-18 16:49:51 -07001/*
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 Pique37c2c9b2018-12-04 17:25:10 -080019#include <compositionengine/Output.h>
Lloyd Pique441d5042018-10-18 16:49:51 -070020#include <gmock/gmock.h>
21
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080022// TODO(b/129481165): remove the #pragma below and fix conversion issues
23#pragma clang diagnostic push
24#pragma clang diagnostic ignored "-Wconversion"
Marin Shalamanovbed7fd32020-12-21 20:02:20 +010025#pragma clang diagnostic ignored "-Wextra"
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080026
Lloyd Pique441d5042018-10-18 16:49:51 -070027#include "DisplayHardware/HWComposer.h"
28
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080029// TODO(b/129481165): remove the #pragma below and fix conversion issues
Marin Shalamanovbed7fd32020-12-21 20:02:20 +010030#pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080031
Lloyd Pique441d5042018-10-18 16:49:51 -070032namespace android {
33namespace mock {
34
Peiyong Line9d809e2020-04-14 13:10:48 -070035namespace hal = android::hardware::graphics::composer::hal;
36
Lloyd Pique441d5042018-10-18 16:49:51 -070037class HWComposer : public android::HWComposer {
38public:
39 HWComposer();
40 ~HWComposer() override;
41
Yichi Chen1a417af2022-01-21 15:29:52 +080042 MOCK_METHOD1(setCallback, void(HWC2::ComposerCallback&));
Lloyd Pique441d5042018-10-18 16:49:51 -070043 MOCK_CONST_METHOD3(getDisplayIdentificationData,
Peiyong Line9d809e2020-04-14 13:10:48 -070044 bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*));
Ady Abrahamde549d42022-01-26 19:19:17 -080045 MOCK_CONST_METHOD1(hasCapability,
46 bool(aidl::android::hardware::graphics::composer3::Capability));
Leon Scroggins III5967aec2021-12-29 11:14:22 -050047 MOCK_CONST_METHOD2(hasDisplayCapability,
48 bool(HalDisplayId,
49 aidl::android::hardware::graphics::composer3::DisplayCapability));
Lloyd Pique441d5042018-10-18 16:49:51 -070050
Dominik Laskowski3dce4f42021-03-08 20:48:28 -080051 MOCK_CONST_METHOD0(getMaxVirtualDisplayCount, size_t());
52 MOCK_CONST_METHOD0(getMaxVirtualDisplayDimension, size_t());
Dominik Laskowski263eec42021-07-21 23:13:24 -070053 MOCK_METHOD3(allocateVirtualDisplay, bool(HalVirtualDisplayId, ui::Size, ui::PixelFormat*));
Lucas Berthou8d0a0c42024-08-27 14:32:31 +000054 MOCK_METHOD3(allocatePhysicalDisplay,
55 void(hal::HWDisplayId, PhysicalDisplayId, std::optional<ui::Size>));
Dominik Laskowski3dce4f42021-03-08 20:48:28 -080056
Lloyd Piquea516c002021-05-07 14:36:58 -070057 MOCK_METHOD1(createLayer, std::shared_ptr<HWC2::Layer>(HalDisplayId));
ramindani4aac32c2023-10-30 14:13:30 -070058 MOCK_METHOD(status_t, getDeviceCompositionChanges,
59 (HalDisplayId, bool, std::optional<std::chrono::steady_clock::time_point>, nsecs_t,
60 Fps, std::optional<android::HWComposer::DeviceRequestedChanges>*));
Alec Mourif97df4d2023-09-06 02:10:05 +000061 MOCK_METHOD(status_t, setClientTarget,
62 (HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&, ui::Dataspace,
63 float),
64 (override));
Ady Abrahamf1db8032023-03-24 17:52:34 -070065 MOCK_METHOD2(presentAndGetReleaseFences,
66 status_t(HalDisplayId, std::optional<std::chrono::steady_clock::time_point>));
Leon Scroggins IIIa3ba7fa2024-05-22 16:34:52 -040067 MOCK_METHOD(status_t, executeCommands, (HalDisplayId));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020068 MOCK_METHOD2(setPowerMode, status_t(PhysicalDisplayId, hal::PowerMode));
69 MOCK_METHOD2(setActiveConfig, status_t(HalDisplayId, size_t));
70 MOCK_METHOD2(setColorTransform, status_t(HalDisplayId, const mat4&));
71 MOCK_METHOD1(disconnectDisplay, void(HalDisplayId));
Lloyd Pique441d5042018-10-18 16:49:51 -070072 MOCK_CONST_METHOD1(hasDeviceComposition, bool(const std::optional<DisplayId>&));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020073 MOCK_CONST_METHOD1(getPresentFence, sp<Fence>(HalDisplayId));
Dominik Laskowskidc2bb802022-09-28 16:02:59 -040074 MOCK_METHOD(nsecs_t, getPresentTimestamp, (PhysicalDisplayId), (const, override));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020075 MOCK_CONST_METHOD2(getLayerReleaseFence, sp<Fence>(HalDisplayId, HWC2::Layer*));
76 MOCK_METHOD3(setOutputBuffer,
77 status_t(HalVirtualDisplayId, const sp<Fence>&, const sp<GraphicBuffer>&));
78 MOCK_METHOD1(clearReleaseFences, void(HalDisplayId));
79 MOCK_METHOD2(getHdrCapabilities, status_t(HalDisplayId, HdrCapabilities*));
80 MOCK_CONST_METHOD1(getSupportedPerFrameMetadata, int32_t(HalDisplayId));
81 MOCK_CONST_METHOD2(getRenderIntents,
82 std::vector<ui::RenderIntent>(HalDisplayId, ui::ColorMode));
83 MOCK_METHOD2(getDataspaceSaturationMatrix, mat4(HalDisplayId, ui::Dataspace));
Lloyd Pique441d5042018-10-18 16:49:51 -070084 MOCK_METHOD4(getDisplayedContentSamplingAttributes,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020085 status_t(HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*));
86 MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(HalDisplayId, bool, uint8_t, uint64_t));
Lloyd Pique441d5042018-10-18 16:49:51 -070087 MOCK_METHOD4(getDisplayedContentSample,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020088 status_t(HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*));
Dominik Laskowskib17c6212022-05-09 09:36:19 -070089 MOCK_METHOD(ftl::Future<status_t>, setDisplayBrightness,
90 (PhysicalDisplayId, float, float, const Hwc2::Composer::DisplayBrightnessOptions&),
91 (override));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020092 MOCK_METHOD2(getDisplayBrightnessSupport, status_t(PhysicalDisplayId, bool*));
Lloyd Pique441d5042018-10-18 16:49:51 -070093
94 MOCK_METHOD2(onHotplug,
Peiyong Line9d809e2020-04-14 13:10:48 -070095 std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection));
Marin Shalamanovf8c63722020-10-06 13:11:21 +020096 MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool());
Leon Scroggins III959a7ff2023-02-07 11:24:25 -050097 MOCK_METHOD(std::optional<PhysicalDisplayId>, onVsync, (hal::HWDisplayId, int64_t));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020098 MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020099 MOCK_CONST_METHOD1(isConnected, bool(PhysicalDisplayId));
ramindani263a3f12023-07-18 20:44:49 -0700100 MOCK_CONST_METHOD2(getModes,
101 std::vector<HWComposer::HWCDisplayMode>(PhysicalDisplayId, int32_t));
Dominik Laskowskid940a012024-01-28 13:25:44 -0500102 MOCK_CONST_METHOD1(getActiveMode, ftl::Expected<hal::HWConfigId, status_t>(PhysicalDisplayId));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200103 MOCK_CONST_METHOD1(getColorModes, std::vector<ui::ColorMode>(PhysicalDisplayId));
104 MOCK_METHOD3(setActiveColorMode, status_t(PhysicalDisplayId, ui::ColorMode, ui::RenderIntent));
Lloyd Pique441d5042018-10-18 16:49:51 -0700105 MOCK_CONST_METHOD0(isUsingVrComposer, bool());
Marin Shalamanov228f46b2021-01-28 21:11:45 +0100106 MOCK_CONST_METHOD1(getDisplayConnectionType, ui::DisplayConnectionType(PhysicalDisplayId));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200107 MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId));
Dominik Laskowskia109bb22024-01-28 13:33:51 -0500108 MOCK_CONST_METHOD1(getDisplayVsyncPeriod, ftl::Expected<nsecs_t, status_t>(PhysicalDisplayId));
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100109 MOCK_METHOD4(setActiveModeWithConstraints,
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100110 status_t(PhysicalDisplayId, hal::HWConfigId,
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100111 const hal::VsyncPeriodChangeConstraints&,
Peiyong Line9d809e2020-04-14 13:10:48 -0700112 hal::VsyncPeriodChangeTimeline*));
Kriti Dang7defaf32021-11-15 11:55:43 +0100113 MOCK_METHOD2(setBootDisplayMode, status_t(PhysicalDisplayId, hal::HWConfigId));
114 MOCK_METHOD1(clearBootDisplayMode, status_t(PhysicalDisplayId));
Kriti Dang16ca2972022-02-01 20:07:03 +0100115 MOCK_METHOD1(getPreferredBootDisplayMode, std::optional<hal::HWConfigId>(PhysicalDisplayId));
Kriti Dang646f8ec2022-01-18 14:35:02 +0100116 MOCK_METHOD0(getBootDisplayModeSupport, bool());
Kriti Dang674b9372022-11-18 10:58:44 +0100117 MOCK_CONST_METHOD0(
118 getHdrConversionCapabilities,
119 std::vector<aidl::android::hardware::graphics::common::HdrConversionCapability>());
Kriti Dangd432bb52023-02-09 18:21:04 +0100120 MOCK_METHOD2(setHdrConversionStrategy,
121 status_t(aidl::android::hardware::graphics::common::HdrConversionStrategy,
122 aidl::android::hardware::graphics::common::Hdr*));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200123 MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
Dominik Laskowski6c7b36e2022-03-03 08:27:58 -0800124 MOCK_METHOD(status_t, getSupportedContentTypes,
125 (PhysicalDisplayId, std::vector<hal::ContentType>*), (const, override));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200126 MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType));
Lloyd Pique4603f3c2020-02-11 12:06:56 -0800127 MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata,
128 const std::unordered_map<std::string, bool>&());
Lloyd Pique441d5042018-10-18 16:49:51 -0700129
130 MOCK_CONST_METHOD1(dump, void(std::string&));
Sally Qi254ef492024-04-08 15:01:28 -0700131 MOCK_CONST_METHOD1(dumpOverlayProperties, void(std::string&));
Lloyd Pique441d5042018-10-18 16:49:51 -0700132 MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*());
Dominik Laskowskif8db0f02021-04-19 11:05:25 -0700133
134 MOCK_METHOD(hal::HWDisplayId, getPrimaryHwcDisplayId, (), (const, override));
135 MOCK_METHOD(PhysicalDisplayId, getPrimaryDisplayId, (), (const, override));
136 MOCK_METHOD(bool, isHeadless, (), (const, override));
137
138 MOCK_METHOD(std::optional<PhysicalDisplayId>, toPhysicalDisplayId, (hal::HWDisplayId),
139 (const, override));
140 MOCK_METHOD(std::optional<hal::HWDisplayId>, fromPhysicalDisplayId, (PhysicalDisplayId),
141 (const, override));
Leon Scroggins IIIe7c51c62022-02-01 15:53:54 -0500142 MOCK_METHOD2(getDisplayDecorationSupport,
143 status_t(PhysicalDisplayId,
144 std::optional<aidl::android::hardware::graphics::common::
145 DisplayDecorationSupport>* support));
ramindani32cf0602022-03-02 02:30:29 +0000146 MOCK_METHOD2(setIdleTimerEnabled, status_t(PhysicalDisplayId, std::chrono::milliseconds));
ramindani06e518e2022-03-14 18:47:53 +0000147 MOCK_METHOD(bool, hasDisplayIdleTimerCapability, (PhysicalDisplayId), (const, override));
148 MOCK_METHOD(Hwc2::AidlTransform, getPhysicalDisplayOrientation, (PhysicalDisplayId),
149 (const, override));
Matt Buckley50c44062022-01-17 20:48:10 +0000150 MOCK_METHOD(bool, getValidateSkipped, (HalDisplayId), (const, override));
Sally Qibb866c12022-10-17 11:31:20 -0700151 MOCK_METHOD(const aidl::android::hardware::graphics::composer3::OverlayProperties&,
152 getOverlaySupport, (), (const, override));
ramindanib2158ee2023-02-13 20:29:59 -0800153 MOCK_METHOD(status_t, setRefreshRateChangedCallbackDebugEnabled, (PhysicalDisplayId, bool));
ramindanic67d22c2023-11-28 14:58:47 -0800154 MOCK_METHOD(status_t, notifyExpectedPresent, (PhysicalDisplayId, TimePoint, Fps));
Sally Qi11dcd582024-08-16 18:11:27 -0700155 MOCK_METHOD(status_t, getRequestedLuts,
156 (PhysicalDisplayId,
157 std::vector<aidl::android::hardware::graphics::composer3::DisplayLuts::LayerLut>*),
158 (override));
Lloyd Pique441d5042018-10-18 16:49:51 -0700159};
160
161} // namespace mock
162} // namespace android