1 /* 2 * Copyright 2021 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 19 #include <gmock/gmock.h> 20 #include <cstdint> 21 22 #include "DisplayHardware/HWC2.h" 23 24 namespace android::HWC2::mock { 25 26 class Display : public HWC2::Display { 27 public: 28 Display(); 29 ~Display() override; 30 31 MOCK_METHOD(hal::HWDisplayId, getId, (), (const, override)); 32 MOCK_METHOD(bool, isConnected, (), (const, override)); 33 MOCK_METHOD(void, setConnected, (bool), (override)); 34 MOCK_METHOD(bool, hasCapability, 35 (aidl::android::hardware::graphics::composer3::DisplayCapability), 36 (const, override)); 37 MOCK_METHOD(bool, isVsyncPeriodSwitchSupported, (), (const, override)); 38 MOCK_METHOD(void, onLayerDestroyed, (hal::HWLayerId), (override)); 39 MOCK_METHOD(std::optional<ui::Size>, getPhysicalSizeInMm, (), (const override)); 40 41 MOCK_METHOD(hal::Error, acceptChanges, (), (override)); 42 MOCK_METHOD((base::expected<std::shared_ptr<HWC2::Layer>, hal::Error>), createLayer, (), 43 (override)); 44 MOCK_METHOD(hal::Error, getChangedCompositionTypes, 45 ((std::unordered_map<Layer *, 46 aidl::android::hardware::graphics::composer3::Composition> *)), 47 (override)); 48 MOCK_METHOD(hal::Error, getColorModes, (std::vector<hal::ColorMode> *), (const, override)); 49 MOCK_METHOD(int32_t, getSupportedPerFrameMetadata, (), (const, override)); 50 MOCK_METHOD(hal::Error, getRenderIntents, (hal::ColorMode, std::vector<hal::RenderIntent> *), 51 (const, override)); 52 MOCK_METHOD(hal::Error, getDataspaceSaturationMatrix, (hal::Dataspace, android::mat4 *), 53 (override)); 54 MOCK_METHOD(hal::Error, getName, (std::string *), (const, override)); 55 MOCK_METHOD(hal::Error, getRequests, 56 (hal::DisplayRequest*, (std::unordered_map<Layer*, hal::LayerRequest>*)), 57 (override)); 58 MOCK_METHOD((ftl::Expected<ui::DisplayConnectionType, hal::Error>), getConnectionType, (), 59 (const, override)); 60 MOCK_METHOD(hal::Error, supportsDoze, (bool *), (const, override)); 61 MOCK_METHOD(hal::Error, getHdrCapabilities, (android::HdrCapabilities *), (const, override)); 62 MOCK_METHOD(hal::Error, getDisplayedContentSamplingAttributes, 63 (hal::PixelFormat *, hal::Dataspace *, uint8_t *), (const, override)); 64 MOCK_METHOD(hal::Error, setDisplayContentSamplingEnabled, (bool, uint8_t, uint64_t), 65 (const, override)); 66 MOCK_METHOD(hal::Error, getDisplayedContentSample, 67 (uint64_t, uint64_t, android::DisplayedFrameStats *), (const, override)); 68 MOCK_METHOD(hal::Error, getReleaseFences, 69 ((std::unordered_map<Layer *, android::sp<android::Fence>> *)), (const, override)); 70 MOCK_METHOD(hal::Error, present, (android::sp<android::Fence> *), (override)); 71 MOCK_METHOD(hal::Error, setClientTarget, 72 (uint32_t, const android::sp<android::GraphicBuffer>&, 73 const android::sp<android::Fence>&, hal::Dataspace, float), 74 (override)); 75 MOCK_METHOD(hal::Error, setColorMode, (hal::ColorMode, hal::RenderIntent), (override)); 76 MOCK_METHOD(hal::Error, setColorTransform, (const android::mat4 &), (override)); 77 MOCK_METHOD(hal::Error, setOutputBuffer, 78 (const android::sp<android::GraphicBuffer> &, const android::sp<android::Fence> &), 79 (override)); 80 MOCK_METHOD(hal::Error, setPowerMode, (hal::PowerMode), (override)); 81 MOCK_METHOD(hal::Error, setVsyncEnabled, (hal::Vsync), (override)); 82 MOCK_METHOD(hal::Error, validate, (nsecs_t, int32_t, uint32_t*, uint32_t*), (override)); 83 MOCK_METHOD(hal::Error, presentOrValidate, 84 (nsecs_t, int32_t, uint32_t*, uint32_t*, android::sp<android::Fence>*, uint32_t*), 85 (override)); 86 MOCK_METHOD(ftl::Future<hal::Error>, setDisplayBrightness, 87 (float, float, const Hwc2::Composer::DisplayBrightnessOptions &), (override)); 88 MOCK_METHOD(hal::Error, setActiveConfigWithConstraints, 89 (hal::HWConfigId, const hal::VsyncPeriodChangeConstraints&, 90 hal::VsyncPeriodChangeTimeline*), 91 (override)); 92 MOCK_METHOD(hal::Error, setBootDisplayConfig, (hal::HWConfigId), (override)); 93 MOCK_METHOD(hal::Error, clearBootDisplayConfig, (), (override)); 94 MOCK_METHOD(hal::Error, getPreferredBootDisplayConfig, (hal::HWConfigId *), (const, override)); 95 MOCK_METHOD(hal::Error, setAutoLowLatencyMode, (bool), (override)); 96 MOCK_METHOD(hal::Error, getSupportedContentTypes, (std::vector<hal::ContentType> *), 97 (const, override)); 98 MOCK_METHOD(hal::Error, setContentType, (hal::ContentType), (override)); 99 MOCK_METHOD( 100 hal::Error, getClientTargetProperty, 101 (aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness *), 102 (override)); 103 MOCK_METHOD( 104 hal::Error, getDisplayDecorationSupport, 105 (std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport> *), 106 (override)); 107 MOCK_METHOD(hal::Error, setIdleTimerEnabled, (std::chrono::milliseconds), (override)); 108 MOCK_METHOD(bool, hasDisplayIdleTimerCapability, (), (const override)); 109 MOCK_METHOD(hal::Error, getPhysicalDisplayOrientation, (Hwc2::AidlTransform *), 110 (const override)); 111 MOCK_METHOD(hal::Error, getOverlaySupport, 112 (aidl::android::hardware::graphics::composer3::OverlayProperties *), 113 (const override)); 114 MOCK_METHOD(hal::Error, getRequestedLuts, 115 (HWC2::Display::LayerLuts*, HWC2::Display::LutFileDescriptorMapper&), (override)); 116 MOCK_METHOD(hal::Error, getMaxLayerPictureProfiles, (int32_t*), (override)); 117 MOCK_METHOD(hal::Error, setPictureProfileHandle, (const android::PictureProfileHandle&), 118 (override)); 119 }; 120 121 class Layer : public HWC2::Layer { 122 public: 123 Layer(); 124 ~Layer() override; 125 126 MOCK_METHOD(hal::HWLayerId, getId, (), (const, override)); 127 MOCK_METHOD(hal::Error, setCursorPosition, (int32_t, int32_t), (override)); 128 MOCK_METHOD(hal::Error, setBuffer, 129 (uint32_t, const android::sp<android::GraphicBuffer> &, 130 const android::sp<android::Fence> &), 131 (override)); 132 MOCK_METHOD(hal::Error, setBufferSlotsToClear, 133 (const std::vector<uint32_t>& slotsToClear, uint32_t activeBufferSlot), (override)); 134 MOCK_METHOD(hal::Error, setSurfaceDamage, (const android::Region &), (override)); 135 MOCK_METHOD(hal::Error, setBlendMode, (hal::BlendMode), (override)); 136 MOCK_METHOD(hal::Error, setColor, (aidl::android::hardware::graphics::composer3::Color), 137 (override)); 138 MOCK_METHOD(hal::Error, setCompositionType, 139 (aidl::android::hardware::graphics::composer3::Composition), (override)); 140 MOCK_METHOD(hal::Error, setDataspace, (android::ui::Dataspace), (override)); 141 MOCK_METHOD(hal::Error, setPerFrameMetadata, (const int32_t, const android::HdrMetadata &), 142 (override)); 143 MOCK_METHOD(hal::Error, setDisplayFrame, (const android::Rect &), (override)); 144 MOCK_METHOD(hal::Error, setPlaneAlpha, (float), (override)); 145 MOCK_METHOD(hal::Error, setSidebandStream, (const native_handle_t *), (override)); 146 MOCK_METHOD(hal::Error, setSourceCrop, (const android::FloatRect &), (override)); 147 MOCK_METHOD(hal::Error, setTransform, (hal::Transform), (override)); 148 MOCK_METHOD(hal::Error, setVisibleRegion, (const android::Region &), (override)); 149 MOCK_METHOD(hal::Error, setZOrder, (uint32_t), (override)); 150 MOCK_METHOD(hal::Error, setColorTransform, (const android::mat4 &), (override)); 151 MOCK_METHOD(hal::Error, setLayerGenericMetadata, 152 (const std::string &, bool, const std::vector<uint8_t> &), (override)); 153 MOCK_METHOD(hal::Error, setBrightness, (float), (override)); 154 MOCK_METHOD(hal::Error, setBlockingRegion, (const android::Region &), (override)); 155 MOCK_METHOD(hal::Error, setLuts, (aidl::android::hardware::graphics::composer3::Luts&), 156 (override)); 157 MOCK_METHOD(hal::Error, setPictureProfileHandle, (const android::PictureProfileHandle&), 158 (override)); 159 }; 160 161 } // namespace android::HWC2::mock 162