1 /* 2 * Copyright 2019 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 21 #include "DisplayHardware/HWC2.h" 22 23 using android::HWC2::Layer; 24 25 namespace android { 26 namespace Hwc2 { 27 namespace mock { 28 29 namespace hal = android::hardware::graphics::composer::hal; 30 31 class Display : public HWC2::Display { 32 public: 33 using Layer = ::Layer; 34 35 Display(); 36 ~Display(); 37 38 MOCK_CONST_METHOD0(getId, hal::HWDisplayId()); 39 MOCK_CONST_METHOD0(isConnected, bool()); 40 MOCK_METHOD1(setConnected, void(bool)); 41 MOCK_CONST_METHOD0(getCapabilities, const std::unordered_set<hal::DisplayCapability>&()); 42 43 MOCK_METHOD0(acceptChanges, hal::Error()); 44 MOCK_METHOD1(createLayer, hal::Error(Layer**)); 45 MOCK_METHOD1(destroyLayer, hal::Error(Layer*)); 46 MOCK_CONST_METHOD1(getActiveConfig, hal::Error(std::shared_ptr<const Config>*)); 47 MOCK_CONST_METHOD1(getActiveConfigIndex, hal::Error(int* outIndex)); 48 MOCK_METHOD1(getChangedCompositionTypes, 49 hal::Error(std::unordered_map<Layer*, hal::Composition>*)); 50 MOCK_CONST_METHOD1(getColorModes, hal::Error(std::vector<hal::ColorMode>*)); 51 52 MOCK_CONST_METHOD0(getSupportedPerFrameMetadata, int32_t()); 53 MOCK_CONST_METHOD2(getRenderIntents, 54 hal::Error(hal::ColorMode, std::vector<hal::RenderIntent>*)); 55 MOCK_METHOD2(getDataspaceSaturationMatrix, hal::Error(hal::Dataspace, android::mat4*)); 56 MOCK_CONST_METHOD0(getConfigs, std::vector<std::shared_ptr<const Config>>()); 57 58 MOCK_CONST_METHOD1(getName, hal::Error(std::string*)); 59 MOCK_METHOD2(getRequests, 60 hal::Error(hal::DisplayRequest*, std::unordered_map<Layer*, hal::LayerRequest>*)); 61 MOCK_CONST_METHOD1(getType, hal::Error(hal::DisplayType*)); 62 MOCK_CONST_METHOD1(supportsDoze, hal::Error(bool*)); 63 MOCK_CONST_METHOD1(getHdrCapabilities, hal::Error(android::HdrCapabilities*)); 64 MOCK_CONST_METHOD3(getDisplayedContentSamplingAttributes, 65 hal::Error(hal::PixelFormat*, hal::Dataspace*, uint8_t*)); 66 MOCK_CONST_METHOD3(setDisplayContentSamplingEnabled, hal::Error(bool, uint8_t, uint64_t)); 67 MOCK_CONST_METHOD3(getDisplayedContentSample, 68 hal::Error(uint64_t, uint64_t, android::DisplayedFrameStats*)); 69 MOCK_CONST_METHOD1( 70 getReleaseFences, 71 hal::Error(std::unordered_map<Layer*, android::sp<android::Fence>>* outFences)); 72 MOCK_METHOD1(present, hal::Error(android::sp<android::Fence>*)); 73 MOCK_METHOD1(setActiveConfig, hal::Error(const std::shared_ptr<const HWC2::Display::Config>&)); 74 MOCK_METHOD4(setClientTarget, 75 hal::Error(uint32_t, const android::sp<android::GraphicBuffer>&, 76 const android::sp<android::Fence>&, hal::Dataspace)); 77 MOCK_METHOD2(setColorMode, hal::Error(hal::ColorMode, hal::RenderIntent)); 78 MOCK_METHOD2(setColorTransform, hal::Error(const android::mat4&, hal::ColorTransform)); 79 MOCK_METHOD2(setOutputBuffer, 80 hal::Error(const android::sp<android::GraphicBuffer>&, 81 const android::sp<android::Fence>&)); 82 MOCK_METHOD1(setPowerMode, hal::Error(hal::PowerMode)); 83 MOCK_METHOD1(setVsyncEnabled, hal::Error(hal::Vsync)); 84 MOCK_METHOD2(validate, hal::Error(uint32_t*, uint32_t*)); 85 MOCK_METHOD4(presentOrValidate, 86 hal::Error(uint32_t*, uint32_t*, android::sp<android::Fence>*, uint32_t*)); 87 MOCK_METHOD1(setDisplayBrightness, std::future<hal::Error>(float)); 88 MOCK_CONST_METHOD1(getDisplayVsyncPeriod, hal::Error(nsecs_t*)); 89 MOCK_METHOD3(setActiveConfigWithConstraints, 90 hal::Error(const std::shared_ptr<const HWC2::Display::Config>&, 91 const hal::VsyncPeriodChangeConstraints&, 92 hal::VsyncPeriodChangeTimeline*)); 93 MOCK_METHOD1(setAutoLowLatencyMode, hal::Error(bool on)); 94 MOCK_CONST_METHOD1(getSupportedContentTypes, hal::Error(std::vector<hal::ContentType>*)); 95 MOCK_METHOD1(setContentType, hal::Error(hal::ContentType)); 96 MOCK_METHOD1(getClientTargetProperty, hal::Error(hal::ClientTargetProperty*)); 97 MOCK_CONST_METHOD1(getConnectionType, hal::Error(android::DisplayConnectionType*)); 98 MOCK_CONST_METHOD0(isVsyncPeriodSwitchSupported, bool()); 99 }; 100 101 } // namespace mock 102 } // namespace Hwc2 103 } // namespace android 104