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" |
| 25 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 26 | #include "DisplayHardware/HWComposer.h" |
| 27 | |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 28 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 29 | #pragma clang diagnostic pop // ignored "-Wconversion" |
| 30 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 31 | namespace android { |
| 32 | namespace mock { |
| 33 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 34 | namespace hal = android::hardware::graphics::composer::hal; |
| 35 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 36 | class HWComposer : public android::HWComposer { |
| 37 | public: |
| 38 | HWComposer(); |
| 39 | ~HWComposer() override; |
| 40 | |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 41 | MOCK_METHOD2(setConfiguration, void(HWC2::ComposerCallback*, int32_t)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 42 | MOCK_CONST_METHOD3(getDisplayIdentificationData, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 43 | bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*)); |
| 44 | MOCK_CONST_METHOD1(hasCapability, bool(hal::Capability)); |
| 45 | MOCK_CONST_METHOD2(hasDisplayCapability, bool(DisplayId, hal::DisplayCapability)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 46 | |
| 47 | MOCK_METHOD3(allocateVirtualDisplay, |
| 48 | std::optional<DisplayId>(uint32_t, uint32_t, ui::PixelFormat*)); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 49 | MOCK_METHOD2(allocatePhysicalDisplay, void(hal::HWDisplayId, DisplayId)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 50 | MOCK_METHOD1(createLayer, HWC2::Layer*(DisplayId)); |
| 51 | MOCK_METHOD2(destroyLayer, void(DisplayId, HWC2::Layer*)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 52 | MOCK_METHOD3(getDeviceCompositionChanges, |
| 53 | status_t(DisplayId, bool, |
| 54 | std::optional<android::HWComposer::DeviceRequestedChanges>*)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 55 | MOCK_METHOD5(setClientTarget, |
| 56 | status_t(DisplayId, uint32_t, const sp<Fence>&, const sp<GraphicBuffer>&, |
| 57 | ui::Dataspace)); |
| 58 | MOCK_METHOD1(presentAndGetReleaseFences, status_t(DisplayId)); |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 59 | MOCK_METHOD2(setPowerMode, status_t(DisplayId, hal::PowerMode)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 60 | MOCK_METHOD2(setActiveConfig, status_t(DisplayId, size_t)); |
| 61 | MOCK_METHOD2(setColorTransform, status_t(DisplayId, const mat4&)); |
| 62 | MOCK_METHOD1(disconnectDisplay, void(DisplayId)); |
| 63 | MOCK_CONST_METHOD1(hasDeviceComposition, bool(const std::optional<DisplayId>&)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 64 | MOCK_CONST_METHOD1(getPresentFence, sp<Fence>(DisplayId)); |
| 65 | MOCK_CONST_METHOD2(getLayerReleaseFence, sp<Fence>(DisplayId, HWC2::Layer*)); |
| 66 | MOCK_METHOD3(setOutputBuffer, status_t(DisplayId, const sp<Fence>&, const sp<GraphicBuffer>&)); |
| 67 | MOCK_METHOD1(clearReleaseFences, void(DisplayId)); |
| 68 | MOCK_METHOD2(getHdrCapabilities, status_t(DisplayId, HdrCapabilities*)); |
| 69 | MOCK_CONST_METHOD1(getSupportedPerFrameMetadata, int32_t(DisplayId)); |
| 70 | MOCK_CONST_METHOD2(getRenderIntents, std::vector<ui::RenderIntent>(DisplayId, ui::ColorMode)); |
| 71 | MOCK_METHOD2(getDataspaceSaturationMatrix, mat4(DisplayId, ui::Dataspace)); |
| 72 | MOCK_METHOD4(getDisplayedContentSamplingAttributes, |
| 73 | status_t(DisplayId, ui::PixelFormat*, ui::Dataspace*, uint8_t*)); |
| 74 | MOCK_METHOD4(setDisplayContentSamplingEnabled, status_t(DisplayId, bool, uint8_t, uint64_t)); |
| 75 | MOCK_METHOD4(getDisplayedContentSample, |
| 76 | status_t(DisplayId, uint64_t, uint64_t, DisplayedFrameStats*)); |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 77 | MOCK_METHOD2(setDisplayBrightness, status_t(DisplayId, float)); |
| 78 | MOCK_METHOD2(getDisplayBrightnessSupport, status_t(DisplayId, bool*)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 79 | |
| 80 | MOCK_METHOD2(onHotplug, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 81 | std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection)); |
| 82 | MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t)); |
| 83 | MOCK_METHOD2(setVsyncEnabled, void(DisplayId, hal::Vsync)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 84 | MOCK_CONST_METHOD1(getRefreshTimestamp, nsecs_t(DisplayId)); |
| 85 | MOCK_CONST_METHOD1(isConnected, bool(DisplayId)); |
| 86 | MOCK_CONST_METHOD1(getConfigs, |
| 87 | std::vector<std::shared_ptr<const HWC2::Display::Config>>(DisplayId)); |
| 88 | MOCK_CONST_METHOD1(getActiveConfig, std::shared_ptr<const HWC2::Display::Config>(DisplayId)); |
| 89 | MOCK_CONST_METHOD1(getActiveConfigIndex, int(DisplayId)); |
| 90 | MOCK_CONST_METHOD1(getColorModes, std::vector<ui::ColorMode>(DisplayId)); |
| 91 | MOCK_METHOD3(setActiveColorMode, status_t(DisplayId, ui::ColorMode, ui::RenderIntent)); |
| 92 | MOCK_CONST_METHOD0(isUsingVrComposer, bool()); |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 93 | MOCK_CONST_METHOD1(getDisplayConnectionType, DisplayConnectionType(DisplayId)); |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 94 | MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(DisplayId)); |
| 95 | MOCK_CONST_METHOD1(getDisplayVsyncPeriod, nsecs_t(DisplayId)); |
| 96 | MOCK_METHOD4(setActiveConfigWithConstraints, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 97 | status_t(DisplayId, size_t, const hal::VsyncPeriodChangeConstraints&, |
| 98 | hal::VsyncPeriodChangeTimeline*)); |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 99 | MOCK_METHOD2(setAutoLowLatencyMode, status_t(DisplayId, bool)); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 100 | MOCK_METHOD2(getSupportedContentTypes, status_t(DisplayId, std::vector<hal::ContentType>*)); |
| 101 | MOCK_METHOD2(setContentType, status_t(DisplayId, hal::ContentType)); |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 102 | MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata, |
| 103 | const std::unordered_map<std::string, bool>&()); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 104 | |
| 105 | MOCK_CONST_METHOD1(dump, void(std::string&)); |
| 106 | MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*()); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 107 | MOCK_CONST_METHOD1(getHwcDisplayId, std::optional<hal::HWDisplayId>(int32_t)); |
| 108 | MOCK_CONST_METHOD0(getInternalHwcDisplayId, std::optional<hal::HWDisplayId>()); |
| 109 | MOCK_CONST_METHOD0(getExternalHwcDisplayId, std::optional<hal::HWDisplayId>()); |
| 110 | MOCK_CONST_METHOD1(toPhysicalDisplayId, std::optional<DisplayId>(hal::HWDisplayId)); |
| 111 | MOCK_CONST_METHOD1(fromPhysicalDisplayId, std::optional<hal::HWDisplayId>(DisplayId)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | } // namespace mock |
| 115 | } // namespace android |