blob: 84c027bfd3047f66246fe3865e58c7564c5ad896 [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"
25
Lloyd Pique441d5042018-10-18 16:49:51 -070026#include "DisplayHardware/HWComposer.h"
27
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080028// TODO(b/129481165): remove the #pragma below and fix conversion issues
29#pragma clang diagnostic pop // ignored "-Wconversion"
30
Lloyd Pique441d5042018-10-18 16:49:51 -070031namespace android {
32namespace mock {
33
Peiyong Line9d809e2020-04-14 13:10:48 -070034namespace hal = android::hardware::graphics::composer::hal;
35
Lloyd Pique441d5042018-10-18 16:49:51 -070036class HWComposer : public android::HWComposer {
37public:
38 HWComposer();
39 ~HWComposer() override;
40
Lloyd Pique4603f3c2020-02-11 12:06:56 -080041 MOCK_METHOD2(setConfiguration, void(HWC2::ComposerCallback*, int32_t));
Lloyd Pique441d5042018-10-18 16:49:51 -070042 MOCK_CONST_METHOD3(getDisplayIdentificationData,
Peiyong Line9d809e2020-04-14 13:10:48 -070043 bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*));
44 MOCK_CONST_METHOD1(hasCapability, bool(hal::Capability));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020045 MOCK_CONST_METHOD2(hasDisplayCapability, bool(HalDisplayId, hal::DisplayCapability));
Lloyd Pique441d5042018-10-18 16:49:51 -070046
47 MOCK_METHOD3(allocateVirtualDisplay,
48 std::optional<DisplayId>(uint32_t, uint32_t, ui::PixelFormat*));
Marin Shalamanova524a092020-07-27 21:39:55 +020049 MOCK_METHOD2(allocatePhysicalDisplay, void(hal::HWDisplayId, PhysicalDisplayId));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020050 MOCK_METHOD1(createLayer, HWC2::Layer*(HalDisplayId));
51 MOCK_METHOD2(destroyLayer, void(HalDisplayId, HWC2::Layer*));
Lloyd Pique66d68602019-02-13 14:23:31 -080052 MOCK_METHOD3(getDeviceCompositionChanges,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020053 status_t(HalDisplayId, bool,
Lloyd Pique66d68602019-02-13 14:23:31 -080054 std::optional<android::HWComposer::DeviceRequestedChanges>*));
Lloyd Pique441d5042018-10-18 16:49:51 -070055 MOCK_METHOD5(setClientTarget,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020056 status_t(HalDisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&,
Lloyd Pique441d5042018-10-18 16:49:51 -070057 ui::Dataspace));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020058 MOCK_METHOD1(presentAndGetReleaseFences, status_t(HalDisplayId));
59 MOCK_METHOD2(setPowerMode, status_t(PhysicalDisplayId, hal::PowerMode));
60 MOCK_METHOD2(setActiveConfig, status_t(HalDisplayId, size_t));
61 MOCK_METHOD2(setColorTransform, status_t(HalDisplayId, const mat4&));
62 MOCK_METHOD1(disconnectDisplay, void(HalDisplayId));
Lloyd Pique441d5042018-10-18 16:49:51 -070063 MOCK_CONST_METHOD1(hasDeviceComposition, bool(const std::optional<DisplayId>&));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020064 MOCK_CONST_METHOD1(getPresentFence, sp<Fence>(HalDisplayId));
65 MOCK_CONST_METHOD2(getLayerReleaseFence, sp<Fence>(HalDisplayId, HWC2::Layer*));
66 MOCK_METHOD3(setOutputBuffer,
67 status_t(HalVirtualDisplayId, const sp<Fence>&, const sp<GraphicBuffer>&));
68 MOCK_METHOD1(clearReleaseFences, void(HalDisplayId));
69 MOCK_METHOD2(getHdrCapabilities, status_t(HalDisplayId, HdrCapabilities*));
70 MOCK_CONST_METHOD1(getSupportedPerFrameMetadata, int32_t(HalDisplayId));
71 MOCK_CONST_METHOD2(getRenderIntents,
72 std::vector<ui::RenderIntent>(HalDisplayId, ui::ColorMode));
73 MOCK_METHOD2(getDataspaceSaturationMatrix, mat4(HalDisplayId, ui::Dataspace));
Lloyd Pique441d5042018-10-18 16:49:51 -070074 MOCK_METHOD4(getDisplayedContentSamplingAttributes,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020075 status_t(HalDisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*));
76 MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(HalDisplayId, bool, uint8_t, uint64_t));
Lloyd Pique441d5042018-10-18 16:49:51 -070077 MOCK_METHOD4(getDisplayedContentSample,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020078 status_t(HalDisplayId, uint64_t, uint64_t, DisplayedFrameStats*));
79 MOCK_METHOD2(setDisplayBrightness, std::future<status_t>(PhysicalDisplayId, float));
80 MOCK_METHOD2(getDisplayBrightnessSupport, status_t(PhysicalDisplayId, bool*));
Lloyd Pique441d5042018-10-18 16:49:51 -070081
82 MOCK_METHOD2(onHotplug,
Peiyong Line9d809e2020-04-14 13:10:48 -070083 std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection));
Marin Shalamanovf8c63722020-10-06 13:11:21 +020084 MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool());
Peiyong Line9d809e2020-04-14 13:10:48 -070085 MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020086 MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync));
87 MOCK_CONST_METHOD1(getRefreshTimestamp, nsecs_t(PhysicalDisplayId));
88 MOCK_CONST_METHOD1(isConnected, bool(PhysicalDisplayId));
89 MOCK_CONST_METHOD1(
90 getConfigs,
91 std::vector<std::shared_ptr<const HWC2::Display::Config>>(PhysicalDisplayId));
92 MOCK_CONST_METHOD1(getActiveConfig,
93 std::shared_ptr<const HWC2::Display::Config>(PhysicalDisplayId));
94 MOCK_CONST_METHOD1(getActiveConfigIndex, int(PhysicalDisplayId));
95 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 Shalamanov0f10d0d2020-08-06 20:04:06 +020098 MOCK_CONST_METHOD1(getDisplayConnectionType, DisplayConnectionType(PhysicalDisplayId));
99 MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId));
100 MOCK_CONST_METHOD1(getDisplayVsyncPeriod, nsecs_t(PhysicalDisplayId));
Ady Abraham7159f572019-10-11 11:10:18 -0700101 MOCK_METHOD4(setActiveConfigWithConstraints,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200102 status_t(PhysicalDisplayId, size_t, const hal::VsyncPeriodChangeConstraints&,
Peiyong Line9d809e2020-04-14 13:10:48 -0700103 hal::VsyncPeriodChangeTimeline*));
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200104 MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
105 MOCK_METHOD2(getSupportedContentTypes,
106 status_t(PhysicalDisplayId, std::vector<hal::ContentType>*));
107 MOCK_METHOD2(setContentType, status_t(PhysicalDisplayId, hal::ContentType));
Lloyd Pique4603f3c2020-02-11 12:06:56 -0800108 MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata,
109 const std::unordered_map<std::string, bool>&());
Lloyd Pique441d5042018-10-18 16:49:51 -0700110
111 MOCK_CONST_METHOD1(dump, void(std::string&));
112 MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*());
Peiyong Line9d809e2020-04-14 13:10:48 -0700113 MOCK_CONST_METHOD1(getHwcDisplayId, std::optional<hal::HWDisplayId>(int32_t));
114 MOCK_CONST_METHOD0(getInternalHwcDisplayId, std::optional<hal::HWDisplayId>());
115 MOCK_CONST_METHOD0(getExternalHwcDisplayId, std::optional<hal::HWDisplayId>());
Marin Shalamanova524a092020-07-27 21:39:55 +0200116 MOCK_CONST_METHOD1(toPhysicalDisplayId, std::optional<PhysicalDisplayId>(hal::HWDisplayId));
117 MOCK_CONST_METHOD1(fromPhysicalDisplayId, std::optional<hal::HWDisplayId>(PhysicalDisplayId));
Lloyd Pique441d5042018-10-18 16:49:51 -0700118};
119
120} // namespace mock
121} // namespace android