blob: 224dad1647b9da0e45b2b355fa67c2bfb5d74228 [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
Dominik Laskowski0deb06e2021-04-16 23:18:31 -070042 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*));
45 MOCK_CONST_METHOD1(hasCapability, bool(hal::Capability));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020046 MOCK_CONST_METHOD2(hasDisplayCapability, bool(HalDisplayId, hal::DisplayCapability));
Lloyd Pique441d5042018-10-18 16:49:51 -070047
Dominik Laskowski3dce4f42021-03-08 20:48:28 -080048 MOCK_CONST_METHOD0(getMaxVirtualDisplayCount, size_t());
49 MOCK_CONST_METHOD0(getMaxVirtualDisplayDimension, size_t());
Dominik Laskowski263eec42021-07-21 23:13:24 -070050 MOCK_METHOD3(allocateVirtualDisplay, bool(HalVirtualDisplayId, ui::Size, ui::PixelFormat*));
Marin Shalamanova524a092020-07-27 21:39:55 +020051 MOCK_METHOD2(allocatePhysicalDisplay, void(hal::HWDisplayId, PhysicalDisplayId));
Dominik Laskowski3dce4f42021-03-08 20:48:28 -080052
Lloyd Piquea516c002021-05-07 14:36:58 -070053 MOCK_METHOD1(createLayer, std::shared_ptr<HWC2::Layer>(HalDisplayId));
Ady Abrahamec7aa8a2021-06-28 12:37:09 -070054 MOCK_METHOD5(getDeviceCompositionChanges,
Ady Abrahamb42cdc12021-05-11 14:31:26 -070055 status_t(HalDisplayId, bool, std::chrono::steady_clock::time_point,
Ady Abrahamec7aa8a2021-06-28 12:37:09 -070056 const std::shared_ptr<FenceTime>&,
Lloyd Pique66d68602019-02-13 14:23:31 -080057 std::optional<android::HWComposer::DeviceRequestedChanges>*));
Lloyd Pique441d5042018-10-18 16:49:51 -070058 MOCK_METHOD5(setClientTarget,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020059 status_t(HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&,
Lloyd Pique441d5042018-10-18 16:49:51 -070060 ui::Dataspace));
Ady Abrahamec7aa8a2021-06-28 12:37:09 -070061 MOCK_METHOD3(presentAndGetReleaseFences,
62 status_t(HalDisplayId, std::chrono::steady_clock::time_point,
63 const std::shared_ptr<FenceTime>&));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020064 MOCK_METHOD2(setPowerMode, status_t(PhysicalDisplayId, hal::PowerMode));
65 MOCK_METHOD2(setActiveConfig, status_t(HalDisplayId, size_t));
66 MOCK_METHOD2(setColorTransform, status_t(HalDisplayId, const mat4&));
67 MOCK_METHOD1(disconnectDisplay, void(HalDisplayId));
Lloyd Pique441d5042018-10-18 16:49:51 -070068 MOCK_CONST_METHOD1(hasDeviceComposition, bool(const std::optional<DisplayId>&));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020069 MOCK_CONST_METHOD1(getPresentFence, sp<Fence>(HalDisplayId));
70 MOCK_CONST_METHOD2(getLayerReleaseFence, sp<Fence>(HalDisplayId, HWC2::Layer*));
71 MOCK_METHOD3(setOutputBuffer,
72 status_t(HalVirtualDisplayId, const sp<Fence>&, const sp<GraphicBuffer>&));
73 MOCK_METHOD1(clearReleaseFences, void(HalDisplayId));
74 MOCK_METHOD2(getHdrCapabilities, status_t(HalDisplayId, HdrCapabilities*));
75 MOCK_CONST_METHOD1(getSupportedPerFrameMetadata, int32_t(HalDisplayId));
76 MOCK_CONST_METHOD2(getRenderIntents,
77 std::vector<ui::RenderIntent>(HalDisplayId, ui::ColorMode));
78 MOCK_METHOD2(getDataspaceSaturationMatrix, mat4(HalDisplayId, ui::Dataspace));
Lloyd Pique441d5042018-10-18 16:49:51 -070079 MOCK_METHOD4(getDisplayedContentSamplingAttributes,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020080 status_t(HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*));
81 MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(HalDisplayId, bool, uint8_t, uint64_t));
Lloyd Pique441d5042018-10-18 16:49:51 -070082 MOCK_METHOD4(getDisplayedContentSample,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020083 status_t(HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*));
84 MOCK_METHOD2(setDisplayBrightness, std::future<status_t>(PhysicalDisplayId, float));
85 MOCK_METHOD2(getDisplayBrightnessSupport, status_t(PhysicalDisplayId, bool*));
Lloyd Pique441d5042018-10-18 16:49:51 -070086
87 MOCK_METHOD2(onHotplug,
Peiyong Line9d809e2020-04-14 13:10:48 -070088 std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection));
Marin Shalamanovf8c63722020-10-06 13:11:21 +020089 MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool());
Peiyong Line9d809e2020-04-14 13:10:48 -070090 MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020091 MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020092 MOCK_CONST_METHOD1(isConnected, bool(PhysicalDisplayId));
Marin Shalamanov045b7002021-01-07 16:56:24 +010093 MOCK_CONST_METHOD1(getModes, std::vector<HWComposer::HWCDisplayMode>(PhysicalDisplayId));
94 MOCK_CONST_METHOD1(getActiveMode, std::optional<hal::HWConfigId>(PhysicalDisplayId));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020095 MOCK_CONST_METHOD1(getColorModes, std::vector<ui::ColorMode>(PhysicalDisplayId));
96 MOCK_METHOD3(setActiveColorMode, status_t(PhysicalDisplayId, ui::ColorMode, ui::RenderIntent));
Lloyd Pique441d5042018-10-18 16:49:51 -070097 MOCK_CONST_METHOD0(isUsingVrComposer, bool());
Marin Shalamanov228f46b2021-01-28 21:11:45 +010098 MOCK_CONST_METHOD1(getDisplayConnectionType, ui::DisplayConnectionType(PhysicalDisplayId));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020099 MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId));
Marin Shalamanov045b7002021-01-07 16:56:24 +0100100 MOCK_CONST_METHOD2(getDisplayVsyncPeriod, status_t(PhysicalDisplayId, nsecs_t*));
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100101 MOCK_METHOD4(setActiveModeWithConstraints,
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100102 status_t(PhysicalDisplayId, hal::HWConfigId,
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100103 const hal::VsyncPeriodChangeConstraints&,
Peiyong Line9d809e2020-04-14 13:10:48 -0700104 hal::VsyncPeriodChangeTimeline*));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200105 MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
106 MOCK_METHOD2(getSupportedContentTypes,
107 status_t(PhysicalDisplayId, std::vector<hal::ContentType>*));
108 MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType));
Lloyd Pique4603f3c2020-02-11 12:06:56 -0800109 MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata,
110 const std::unordered_map<std::string, bool>&());
Lloyd Pique441d5042018-10-18 16:49:51 -0700111
112 MOCK_CONST_METHOD1(dump, void(std::string&));
113 MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*());
Dominik Laskowskif8db0f02021-04-19 11:05:25 -0700114
115 MOCK_METHOD(hal::HWDisplayId, getPrimaryHwcDisplayId, (), (const, override));
116 MOCK_METHOD(PhysicalDisplayId, getPrimaryDisplayId, (), (const, override));
117 MOCK_METHOD(bool, isHeadless, (), (const, override));
118
119 MOCK_METHOD(std::optional<PhysicalDisplayId>, toPhysicalDisplayId, (hal::HWDisplayId),
120 (const, override));
121 MOCK_METHOD(std::optional<hal::HWDisplayId>, fromPhysicalDisplayId, (PhysicalDisplayId),
122 (const, override));
Lloyd Pique441d5042018-10-18 16:49:51 -0700123};
124
125} // namespace mock
126} // namespace android