Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 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 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 17 | #include <cmath> |
| 18 | |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 19 | #include <compositionengine/DisplayColorProfileCreationArgs.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 20 | #include <compositionengine/DisplayCreationArgs.h> |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 21 | #include <compositionengine/DisplaySurface.h> |
| 22 | #include <compositionengine/RenderSurfaceCreationArgs.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 23 | #include <compositionengine/impl/Display.h> |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 24 | #include <compositionengine/impl/RenderSurface.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 25 | #include <compositionengine/mock/CompositionEngine.h> |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 26 | #include <compositionengine/mock/DisplayColorProfile.h> |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 27 | #include <compositionengine/mock/DisplaySurface.h> |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 28 | #include <compositionengine/mock/LayerFE.h> |
chaviw | 8beb414 | 2019-04-11 13:09:05 -0700 | [diff] [blame] | 29 | #include <compositionengine/mock/NativeWindow.h> |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 30 | #include <compositionengine/mock/OutputLayer.h> |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 31 | #include <compositionengine/mock/RenderSurface.h> |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 32 | #include <gtest/gtest.h> |
Lloyd Pique | e9eff97 | 2020-05-05 12:36:44 -0700 | [diff] [blame] | 33 | #include <renderengine/mock/RenderEngine.h> |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 34 | #include <ui/DisplayInfo.h> |
| 35 | #include <ui/Rect.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 36 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 37 | #include "MockHWC2.h" |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 38 | #include "MockHWComposer.h" |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 39 | #include "MockPowerAdvisor.h" |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 40 | |
| 41 | namespace android::compositionengine { |
| 42 | namespace { |
| 43 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 44 | namespace hal = android::hardware::graphics::composer::hal; |
| 45 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 46 | using testing::_; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 47 | using testing::DoAll; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 48 | using testing::Eq; |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 49 | using testing::InSequence; |
| 50 | using testing::NiceMock; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 51 | using testing::Pointee; |
| 52 | using testing::Ref; |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 53 | using testing::Return; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 54 | using testing::ReturnRef; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 55 | using testing::Sequence; |
| 56 | using testing::SetArgPointee; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 57 | using testing::StrictMock; |
| 58 | |
| 59 | constexpr DisplayId DEFAULT_DISPLAY_ID = DisplayId{42}; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 60 | constexpr DisplayId VIRTUAL_DISPLAY_ID = DisplayId{43}; |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 61 | constexpr int32_t DEFAULT_DISPLAY_WIDTH = 1920; |
| 62 | constexpr int32_t DEFAULT_DISPLAY_HEIGHT = 1080; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 63 | constexpr int32_t DEFAULT_LAYER_STACK = 123; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 64 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 65 | struct Layer { |
| 66 | Layer() { |
| 67 | EXPECT_CALL(*outputLayer, getLayerFE()).WillRepeatedly(ReturnRef(*layerFE)); |
| 68 | EXPECT_CALL(*outputLayer, getHwcLayer()).WillRepeatedly(Return(&hwc2Layer)); |
| 69 | } |
| 70 | |
| 71 | sp<mock::LayerFE> layerFE = new StrictMock<mock::LayerFE>(); |
| 72 | StrictMock<mock::OutputLayer>* outputLayer = new StrictMock<mock::OutputLayer>(); |
| 73 | StrictMock<HWC2::mock::Layer> hwc2Layer; |
| 74 | }; |
| 75 | |
| 76 | struct LayerNoHWC2Layer { |
| 77 | LayerNoHWC2Layer() { |
| 78 | EXPECT_CALL(*outputLayer, getLayerFE()).WillRepeatedly(ReturnRef(*layerFE)); |
| 79 | EXPECT_CALL(*outputLayer, getHwcLayer()).WillRepeatedly(Return(nullptr)); |
| 80 | } |
| 81 | |
| 82 | sp<mock::LayerFE> layerFE = new StrictMock<mock::LayerFE>(); |
| 83 | StrictMock<mock::OutputLayer>* outputLayer = new StrictMock<mock::OutputLayer>(); |
| 84 | }; |
| 85 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 86 | struct DisplayTestCommon : public testing::Test { |
| 87 | // Uses the full implementation of a display |
| 88 | class FullImplDisplay : public impl::Display { |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 89 | public: |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 90 | using impl::Display::injectOutputLayerForTest; |
| 91 | virtual void injectOutputLayerForTest(std::unique_ptr<compositionengine::OutputLayer>) = 0; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 92 | |
| 93 | using impl::Display::maybeAllocateDisplayIdForVirtualDisplay; |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 96 | // Uses a special implementation with key internal member functions set up |
| 97 | // as mock implementations, to allow for easier testing. |
| 98 | struct PartialMockDisplay : public impl::Display { |
| 99 | PartialMockDisplay(const compositionengine::CompositionEngine& compositionEngine) |
| 100 | : mCompositionEngine(compositionEngine) {} |
| 101 | |
| 102 | // compositionengine::Output overrides |
| 103 | const OutputCompositionState& getState() const override { return mState; } |
| 104 | OutputCompositionState& editState() override { return mState; } |
| 105 | |
| 106 | // compositionengine::impl::Output overrides |
| 107 | const CompositionEngine& getCompositionEngine() const override { |
| 108 | return mCompositionEngine; |
| 109 | }; |
| 110 | |
| 111 | // Mock implementation overrides |
| 112 | MOCK_CONST_METHOD0(getOutputLayerCount, size_t()); |
| 113 | MOCK_CONST_METHOD1(getOutputLayerOrderedByZByIndex, |
| 114 | compositionengine::OutputLayer*(size_t)); |
| 115 | MOCK_METHOD2(ensureOutputLayer, |
| 116 | compositionengine::OutputLayer*(std::optional<size_t>, const sp<LayerFE>&)); |
| 117 | MOCK_METHOD0(finalizePendingOutputLayers, void()); |
| 118 | MOCK_METHOD0(clearOutputLayers, void()); |
| 119 | MOCK_CONST_METHOD1(dumpState, void(std::string&)); |
| 120 | MOCK_METHOD1(injectOutputLayerForTest, compositionengine::OutputLayer*(const sp<LayerFE>&)); |
| 121 | MOCK_METHOD1(injectOutputLayerForTest, void(std::unique_ptr<OutputLayer>)); |
| 122 | MOCK_CONST_METHOD0(anyLayersRequireClientComposition, bool()); |
| 123 | MOCK_CONST_METHOD0(allLayersRequireClientComposition, bool()); |
| 124 | MOCK_METHOD1(applyChangedTypesToLayers, void(const impl::Display::ChangedTypes&)); |
| 125 | MOCK_METHOD1(applyDisplayRequests, void(const impl::Display::DisplayRequests&)); |
| 126 | MOCK_METHOD1(applyLayerRequestsToLayers, void(const impl::Display::LayerRequests&)); |
| 127 | |
| 128 | const compositionengine::CompositionEngine& mCompositionEngine; |
| 129 | impl::OutputCompositionState mState; |
| 130 | }; |
| 131 | |
| 132 | static std::string getDisplayNameFromCurrentTest() { |
| 133 | const ::testing::TestInfo* const test_info = |
| 134 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 135 | return std::string("display for ") + test_info->test_case_name() + "." + test_info->name(); |
| 136 | } |
| 137 | |
| 138 | template <typename Display> |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 139 | static std::shared_ptr<Display> createDisplay( |
| 140 | const compositionengine::CompositionEngine& compositionEngine, |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 141 | compositionengine::DisplayCreationArgs args) { |
| 142 | args.name = getDisplayNameFromCurrentTest(); |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 143 | return impl::createDisplayTemplated<Display>(compositionEngine, args); |
| 144 | } |
| 145 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 146 | template <typename Display> |
| 147 | static std::shared_ptr<StrictMock<Display>> createPartialMockDisplay( |
| 148 | const compositionengine::CompositionEngine& compositionEngine, |
| 149 | compositionengine::DisplayCreationArgs args) { |
| 150 | args.name = getDisplayNameFromCurrentTest(); |
| 151 | auto display = std::make_shared<StrictMock<Display>>(compositionEngine); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 152 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 153 | display->setConfiguration(args); |
| 154 | |
| 155 | return display; |
| 156 | } |
| 157 | |
| 158 | DisplayTestCommon() { |
| 159 | EXPECT_CALL(mCompositionEngine, getHwComposer()).WillRepeatedly(ReturnRef(mHwComposer)); |
Lloyd Pique | e9eff97 | 2020-05-05 12:36:44 -0700 | [diff] [blame] | 160 | EXPECT_CALL(mCompositionEngine, getRenderEngine()).WillRepeatedly(ReturnRef(mRenderEngine)); |
| 161 | EXPECT_CALL(mRenderEngine, supportsProtectedContent()).WillRepeatedly(Return(false)); |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | DisplayCreationArgs getDisplayCreationArgsForPhysicalHWCDisplay() { |
| 165 | return DisplayCreationArgsBuilder() |
| 166 | .setPhysical({DEFAULT_DISPLAY_ID, DisplayConnectionType::Internal}) |
| 167 | .setPixels({DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT}) |
| 168 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 169 | .setIsSecure(true) |
| 170 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 171 | .setPowerAdvisor(&mPowerAdvisor) |
| 172 | .build(); |
| 173 | } |
| 174 | |
| 175 | DisplayCreationArgs getDisplayCreationArgsForNonHWCVirtualDisplay() { |
| 176 | return DisplayCreationArgsBuilder() |
| 177 | .setUseHwcVirtualDisplays(false) |
| 178 | .setPixels({DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT}) |
| 179 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 180 | .setIsSecure(false) |
| 181 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 182 | .setPowerAdvisor(&mPowerAdvisor) |
| 183 | .build(); |
| 184 | } |
| 185 | |
| 186 | StrictMock<android::mock::HWComposer> mHwComposer; |
| 187 | StrictMock<Hwc2::mock::PowerAdvisor> mPowerAdvisor; |
Lloyd Pique | e9eff97 | 2020-05-05 12:36:44 -0700 | [diff] [blame] | 188 | StrictMock<renderengine::mock::RenderEngine> mRenderEngine; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 189 | StrictMock<mock::CompositionEngine> mCompositionEngine; |
| 190 | sp<mock::NativeWindow> mNativeWindow = new StrictMock<mock::NativeWindow>(); |
| 191 | }; |
| 192 | |
| 193 | struct PartialMockDisplayTestCommon : public DisplayTestCommon { |
| 194 | using Display = DisplayTestCommon::PartialMockDisplay; |
| 195 | std::shared_ptr<Display> mDisplay = |
| 196 | createPartialMockDisplay<Display>(mCompositionEngine, |
| 197 | getDisplayCreationArgsForPhysicalHWCDisplay()); |
| 198 | }; |
| 199 | |
| 200 | struct FullDisplayImplTestCommon : public DisplayTestCommon { |
| 201 | using Display = DisplayTestCommon::FullImplDisplay; |
| 202 | std::shared_ptr<Display> mDisplay = |
| 203 | createDisplay<Display>(mCompositionEngine, |
| 204 | getDisplayCreationArgsForPhysicalHWCDisplay()); |
| 205 | }; |
| 206 | |
| 207 | struct DisplayWithLayersTestCommon : public FullDisplayImplTestCommon { |
| 208 | DisplayWithLayersTestCommon() { |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 209 | mDisplay->injectOutputLayerForTest( |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 210 | std::unique_ptr<compositionengine::OutputLayer>(mLayer1.outputLayer)); |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 211 | mDisplay->injectOutputLayerForTest( |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 212 | std::unique_ptr<compositionengine::OutputLayer>(mLayer2.outputLayer)); |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 213 | mDisplay->injectOutputLayerForTest( |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 214 | std::unique_ptr<compositionengine::OutputLayer>(mLayer3.outputLayer)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 215 | } |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 216 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 217 | Layer mLayer1; |
| 218 | Layer mLayer2; |
| 219 | LayerNoHWC2Layer mLayer3; |
| 220 | StrictMock<HWC2::mock::Layer> hwc2LayerUnknown; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 221 | std::shared_ptr<Display> mDisplay = |
| 222 | createDisplay<Display>(mCompositionEngine, |
| 223 | getDisplayCreationArgsForPhysicalHWCDisplay()); |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 224 | }; |
| 225 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 226 | /* |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 227 | * Basic construction |
| 228 | */ |
| 229 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 230 | struct DisplayCreationTest : public DisplayTestCommon { |
| 231 | using Display = DisplayTestCommon::FullImplDisplay; |
| 232 | }; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 233 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 234 | TEST_F(DisplayCreationTest, createPhysicalInternalDisplay) { |
| 235 | auto display = |
| 236 | impl::createDisplay(mCompositionEngine, getDisplayCreationArgsForPhysicalHWCDisplay()); |
| 237 | EXPECT_TRUE(display->isSecure()); |
| 238 | EXPECT_FALSE(display->isVirtual()); |
| 239 | EXPECT_EQ(DEFAULT_DISPLAY_ID, display->getId()); |
| 240 | } |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 241 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 242 | TEST_F(DisplayCreationTest, createNonHwcVirtualDisplay) { |
| 243 | auto display = impl::createDisplay(mCompositionEngine, |
| 244 | getDisplayCreationArgsForNonHWCVirtualDisplay()); |
| 245 | EXPECT_FALSE(display->isSecure()); |
| 246 | EXPECT_TRUE(display->isVirtual()); |
| 247 | EXPECT_EQ(std::nullopt, display->getId()); |
| 248 | } |
| 249 | |
| 250 | /* |
| 251 | * Display::setConfiguration() |
| 252 | */ |
| 253 | |
| 254 | using DisplaySetConfigurationTest = PartialMockDisplayTestCommon; |
| 255 | |
| 256 | TEST_F(DisplaySetConfigurationTest, configuresInternalSecurePhysicalDisplay) { |
| 257 | mDisplay->setConfiguration( |
| 258 | DisplayCreationArgsBuilder() |
| 259 | .setUseHwcVirtualDisplays(true) |
| 260 | .setPhysical({DEFAULT_DISPLAY_ID, DisplayConnectionType::Internal}) |
| 261 | .setPixels(ui::Size(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH)) |
| 262 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 263 | .setIsSecure(true) |
| 264 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 265 | .setPowerAdvisor(&mPowerAdvisor) |
| 266 | .setName(getDisplayNameFromCurrentTest()) |
| 267 | .build()); |
| 268 | |
| 269 | EXPECT_EQ(DEFAULT_DISPLAY_ID, mDisplay->getId()); |
| 270 | EXPECT_TRUE(mDisplay->isSecure()); |
| 271 | EXPECT_FALSE(mDisplay->isVirtual()); |
| 272 | EXPECT_EQ(DEFAULT_LAYER_STACK, mDisplay->getState().layerStackId); |
| 273 | EXPECT_TRUE(mDisplay->getState().layerStackInternal); |
| 274 | EXPECT_FALSE(mDisplay->isValid()); |
| 275 | } |
| 276 | |
| 277 | TEST_F(DisplaySetConfigurationTest, configuresExternalInsecurePhysicalDisplay) { |
| 278 | mDisplay->setConfiguration( |
| 279 | DisplayCreationArgsBuilder() |
| 280 | .setUseHwcVirtualDisplays(true) |
| 281 | .setPhysical({DEFAULT_DISPLAY_ID, DisplayConnectionType::External}) |
| 282 | .setPixels(ui::Size(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH)) |
| 283 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 284 | .setIsSecure(false) |
| 285 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 286 | .setPowerAdvisor(&mPowerAdvisor) |
| 287 | .setName(getDisplayNameFromCurrentTest()) |
| 288 | .build()); |
| 289 | |
| 290 | EXPECT_EQ(DEFAULT_DISPLAY_ID, mDisplay->getId()); |
| 291 | EXPECT_FALSE(mDisplay->isSecure()); |
| 292 | EXPECT_FALSE(mDisplay->isVirtual()); |
| 293 | EXPECT_EQ(DEFAULT_LAYER_STACK, mDisplay->getState().layerStackId); |
| 294 | EXPECT_FALSE(mDisplay->getState().layerStackInternal); |
| 295 | EXPECT_FALSE(mDisplay->isValid()); |
| 296 | } |
| 297 | |
| 298 | TEST_F(DisplaySetConfigurationTest, configuresHwcBackedVirtualDisplay) { |
| 299 | EXPECT_CALL(mHwComposer, |
| 300 | allocateVirtualDisplay(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH, |
| 301 | Pointee(Eq(static_cast<ui::PixelFormat>( |
| 302 | PIXEL_FORMAT_RGBA_8888))))) |
| 303 | .WillOnce(Return(VIRTUAL_DISPLAY_ID)); |
| 304 | |
| 305 | mDisplay->setConfiguration( |
| 306 | DisplayCreationArgsBuilder() |
| 307 | .setUseHwcVirtualDisplays(true) |
| 308 | .setPixels(ui::Size(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH)) |
| 309 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 310 | .setIsSecure(false) |
| 311 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 312 | .setPowerAdvisor(&mPowerAdvisor) |
| 313 | .setName(getDisplayNameFromCurrentTest()) |
| 314 | .build()); |
| 315 | |
| 316 | EXPECT_EQ(VIRTUAL_DISPLAY_ID, mDisplay->getId()); |
| 317 | EXPECT_FALSE(mDisplay->isSecure()); |
| 318 | EXPECT_TRUE(mDisplay->isVirtual()); |
| 319 | EXPECT_EQ(DEFAULT_LAYER_STACK, mDisplay->getState().layerStackId); |
| 320 | EXPECT_FALSE(mDisplay->getState().layerStackInternal); |
| 321 | EXPECT_FALSE(mDisplay->isValid()); |
| 322 | } |
| 323 | |
| 324 | TEST_F(DisplaySetConfigurationTest, configuresNonHwcBackedVirtualDisplayIfHwcAllocationFails) { |
| 325 | EXPECT_CALL(mHwComposer, |
| 326 | allocateVirtualDisplay(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH, |
| 327 | Pointee(Eq(static_cast<ui::PixelFormat>( |
| 328 | PIXEL_FORMAT_RGBA_8888))))) |
| 329 | .WillOnce(Return(std::nullopt)); |
| 330 | |
| 331 | mDisplay->setConfiguration( |
| 332 | DisplayCreationArgsBuilder() |
| 333 | .setUseHwcVirtualDisplays(true) |
| 334 | .setPixels(ui::Size(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH)) |
| 335 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 336 | .setIsSecure(false) |
| 337 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 338 | .setPowerAdvisor(&mPowerAdvisor) |
| 339 | .setName(getDisplayNameFromCurrentTest()) |
| 340 | .build()); |
| 341 | |
| 342 | EXPECT_EQ(std::nullopt, mDisplay->getId()); |
| 343 | EXPECT_FALSE(mDisplay->isSecure()); |
| 344 | EXPECT_TRUE(mDisplay->isVirtual()); |
| 345 | EXPECT_EQ(DEFAULT_LAYER_STACK, mDisplay->getState().layerStackId); |
| 346 | EXPECT_FALSE(mDisplay->getState().layerStackInternal); |
| 347 | EXPECT_FALSE(mDisplay->isValid()); |
| 348 | } |
| 349 | |
| 350 | TEST_F(DisplaySetConfigurationTest, configuresNonHwcBackedVirtualDisplayIfShouldNotUseHwc) { |
| 351 | mDisplay->setConfiguration( |
| 352 | DisplayCreationArgsBuilder() |
| 353 | .setUseHwcVirtualDisplays(false) |
| 354 | .setPixels(ui::Size(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH)) |
| 355 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 356 | .setIsSecure(false) |
| 357 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 358 | .setPowerAdvisor(&mPowerAdvisor) |
| 359 | .setName(getDisplayNameFromCurrentTest()) |
| 360 | .build()); |
| 361 | |
| 362 | EXPECT_EQ(std::nullopt, mDisplay->getId()); |
| 363 | EXPECT_FALSE(mDisplay->isSecure()); |
| 364 | EXPECT_TRUE(mDisplay->isVirtual()); |
| 365 | EXPECT_EQ(DEFAULT_LAYER_STACK, mDisplay->getState().layerStackId); |
| 366 | EXPECT_FALSE(mDisplay->getState().layerStackInternal); |
| 367 | EXPECT_FALSE(mDisplay->isValid()); |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 370 | /* |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 371 | * Display::disconnect() |
| 372 | */ |
| 373 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 374 | using DisplayDisconnectTest = PartialMockDisplayTestCommon; |
| 375 | |
| 376 | TEST_F(DisplayDisconnectTest, disconnectsDisplay) { |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 377 | // The first call to disconnect will disconnect the display with the HWC and |
| 378 | // set mHwcId to -1. |
| 379 | EXPECT_CALL(mHwComposer, disconnectDisplay(DEFAULT_DISPLAY_ID)).Times(1); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 380 | mDisplay->disconnect(); |
| 381 | EXPECT_FALSE(mDisplay->getId()); |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 382 | |
| 383 | // Subsequent calls will do nothing, |
| 384 | EXPECT_CALL(mHwComposer, disconnectDisplay(DEFAULT_DISPLAY_ID)).Times(0); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 385 | mDisplay->disconnect(); |
| 386 | EXPECT_FALSE(mDisplay->getId()); |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 387 | } |
| 388 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 389 | /* |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 390 | * Display::setColorTransform() |
| 391 | */ |
| 392 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 393 | using DisplaySetColorTransformTest = PartialMockDisplayTestCommon; |
| 394 | |
| 395 | TEST_F(DisplaySetColorTransformTest, setsTransform) { |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 396 | // No change does nothing |
| 397 | CompositionRefreshArgs refreshArgs; |
| 398 | refreshArgs.colorTransformMatrix = std::nullopt; |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 399 | mDisplay->setColorTransform(refreshArgs); |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 400 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 401 | // Identity matrix sets an identity state value |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 402 | const mat4 kIdentity; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 403 | |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 404 | EXPECT_CALL(mHwComposer, setColorTransform(DEFAULT_DISPLAY_ID, kIdentity)).Times(1); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 405 | |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 406 | refreshArgs.colorTransformMatrix = kIdentity; |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 407 | mDisplay->setColorTransform(refreshArgs); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 408 | |
| 409 | // Non-identity matrix sets a non-identity state value |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 410 | const mat4 kNonIdentity = mat4() * 2; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 411 | |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 412 | EXPECT_CALL(mHwComposer, setColorTransform(DEFAULT_DISPLAY_ID, kNonIdentity)).Times(1); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 413 | |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 414 | refreshArgs.colorTransformMatrix = kNonIdentity; |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 415 | mDisplay->setColorTransform(refreshArgs); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 418 | /* |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 419 | * Display::setColorMode() |
| 420 | */ |
| 421 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 422 | using DisplaySetColorModeTest = PartialMockDisplayTestCommon; |
| 423 | |
| 424 | TEST_F(DisplaySetColorModeTest, setsModeUnlessNoChange) { |
Lloyd Pique | 6a3b446 | 2019-03-07 20:58:12 -0800 | [diff] [blame] | 425 | using ColorProfile = Output::ColorProfile; |
| 426 | |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 427 | mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>(); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 428 | mDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface)); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 429 | mock::DisplayColorProfile* colorProfile = new StrictMock<mock::DisplayColorProfile>(); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 430 | mDisplay->setDisplayColorProfileForTest(std::unique_ptr<DisplayColorProfile>(colorProfile)); |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 431 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 432 | EXPECT_CALL(*colorProfile, getTargetDataspace(_, _, _)) |
| 433 | .WillRepeatedly(Return(ui::Dataspace::UNKNOWN)); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 434 | |
| 435 | // These values are expected to be the initial state. |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 436 | ASSERT_EQ(ui::ColorMode::NATIVE, mDisplay->getState().colorMode); |
| 437 | ASSERT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().dataspace); |
| 438 | ASSERT_EQ(ui::RenderIntent::COLORIMETRIC, mDisplay->getState().renderIntent); |
| 439 | ASSERT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().targetDataspace); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 440 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 441 | // Otherwise if the values are unchanged, nothing happens |
| 442 | mDisplay->setColorProfile(ColorProfile{ui::ColorMode::NATIVE, ui::Dataspace::UNKNOWN, |
| 443 | ui::RenderIntent::COLORIMETRIC, ui::Dataspace::UNKNOWN}); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 444 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 445 | EXPECT_EQ(ui::ColorMode::NATIVE, mDisplay->getState().colorMode); |
| 446 | EXPECT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().dataspace); |
| 447 | EXPECT_EQ(ui::RenderIntent::COLORIMETRIC, mDisplay->getState().renderIntent); |
| 448 | EXPECT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().targetDataspace); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 449 | |
| 450 | // Otherwise if the values are different, updates happen |
Lloyd Pique | ef95812 | 2019-02-05 18:00:12 -0800 | [diff] [blame] | 451 | EXPECT_CALL(*renderSurface, setBufferDataspace(ui::Dataspace::DISPLAY_P3)).Times(1); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 452 | EXPECT_CALL(mHwComposer, |
Lloyd Pique | ef95812 | 2019-02-05 18:00:12 -0800 | [diff] [blame] | 453 | setActiveColorMode(DEFAULT_DISPLAY_ID, ui::ColorMode::DISPLAY_P3, |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 454 | ui::RenderIntent::TONE_MAP_COLORIMETRIC)) |
| 455 | .Times(1); |
| 456 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 457 | mDisplay->setColorProfile(ColorProfile{ui::ColorMode::DISPLAY_P3, ui::Dataspace::DISPLAY_P3, |
| 458 | ui::RenderIntent::TONE_MAP_COLORIMETRIC, |
| 459 | ui::Dataspace::UNKNOWN}); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 460 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 461 | EXPECT_EQ(ui::ColorMode::DISPLAY_P3, mDisplay->getState().colorMode); |
| 462 | EXPECT_EQ(ui::Dataspace::DISPLAY_P3, mDisplay->getState().dataspace); |
| 463 | EXPECT_EQ(ui::RenderIntent::TONE_MAP_COLORIMETRIC, mDisplay->getState().renderIntent); |
| 464 | EXPECT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().targetDataspace); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 465 | } |
| 466 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 467 | TEST_F(DisplaySetColorModeTest, doesNothingForVirtualDisplay) { |
Lloyd Pique | 6a3b446 | 2019-03-07 20:58:12 -0800 | [diff] [blame] | 468 | using ColorProfile = Output::ColorProfile; |
| 469 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 470 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 471 | std::shared_ptr<impl::Display> virtualDisplay = impl::createDisplay(mCompositionEngine, args); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 472 | |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 473 | mock::DisplayColorProfile* colorProfile = new StrictMock<mock::DisplayColorProfile>(); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 474 | virtualDisplay->setDisplayColorProfileForTest( |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 475 | std::unique_ptr<DisplayColorProfile>(colorProfile)); |
| 476 | |
| 477 | EXPECT_CALL(*colorProfile, |
| 478 | getTargetDataspace(ui::ColorMode::DISPLAY_P3, ui::Dataspace::DISPLAY_P3, |
| 479 | ui::Dataspace::UNKNOWN)) |
| 480 | .WillOnce(Return(ui::Dataspace::UNKNOWN)); |
| 481 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 482 | virtualDisplay->setColorProfile( |
Lloyd Pique | 6a3b446 | 2019-03-07 20:58:12 -0800 | [diff] [blame] | 483 | ColorProfile{ui::ColorMode::DISPLAY_P3, ui::Dataspace::DISPLAY_P3, |
| 484 | ui::RenderIntent::TONE_MAP_COLORIMETRIC, ui::Dataspace::UNKNOWN}); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 485 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 486 | EXPECT_EQ(ui::ColorMode::NATIVE, virtualDisplay->getState().colorMode); |
| 487 | EXPECT_EQ(ui::Dataspace::UNKNOWN, virtualDisplay->getState().dataspace); |
| 488 | EXPECT_EQ(ui::RenderIntent::COLORIMETRIC, virtualDisplay->getState().renderIntent); |
| 489 | EXPECT_EQ(ui::Dataspace::UNKNOWN, virtualDisplay->getState().targetDataspace); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 490 | } |
| 491 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 492 | /* |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 493 | * Display::createDisplayColorProfile() |
| 494 | */ |
| 495 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 496 | using DisplayCreateColorProfileTest = PartialMockDisplayTestCommon; |
| 497 | |
| 498 | TEST_F(DisplayCreateColorProfileTest, setsDisplayColorProfile) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 499 | EXPECT_TRUE(mDisplay->getDisplayColorProfile() == nullptr); |
| 500 | mDisplay->createDisplayColorProfile( |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 501 | DisplayColorProfileCreationArgs{false, HdrCapabilities(), 0, |
| 502 | DisplayColorProfileCreationArgs::HwcColorModes()}); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 503 | EXPECT_TRUE(mDisplay->getDisplayColorProfile() != nullptr); |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 504 | } |
| 505 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 506 | /* |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 507 | * Display::createRenderSurface() |
| 508 | */ |
| 509 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 510 | using DisplayCreateRenderSurfaceTest = PartialMockDisplayTestCommon; |
| 511 | |
| 512 | TEST_F(DisplayCreateRenderSurfaceTest, setsRenderSurface) { |
chaviw | 8beb414 | 2019-04-11 13:09:05 -0700 | [diff] [blame] | 513 | EXPECT_CALL(*mNativeWindow, disconnect(NATIVE_WINDOW_API_EGL)).WillRepeatedly(Return(NO_ERROR)); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 514 | EXPECT_TRUE(mDisplay->getRenderSurface() == nullptr); |
| 515 | mDisplay->createRenderSurface(RenderSurfaceCreationArgs{640, 480, mNativeWindow, nullptr}); |
| 516 | EXPECT_TRUE(mDisplay->getRenderSurface() != nullptr); |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 517 | } |
| 518 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 519 | /* |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 520 | * Display::createOutputLayer() |
| 521 | */ |
| 522 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 523 | using DisplayCreateOutputLayerTest = FullDisplayImplTestCommon; |
| 524 | |
| 525 | TEST_F(DisplayCreateOutputLayerTest, setsHwcLayer) { |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 526 | sp<mock::LayerFE> layerFE = new StrictMock<mock::LayerFE>(); |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 527 | StrictMock<HWC2::mock::Layer> hwcLayer; |
| 528 | |
| 529 | EXPECT_CALL(mHwComposer, createLayer(DEFAULT_DISPLAY_ID)).WillOnce(Return(&hwcLayer)); |
| 530 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 531 | auto outputLayer = mDisplay->createOutputLayer(layerFE); |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 532 | |
| 533 | EXPECT_EQ(&hwcLayer, outputLayer->getHwcLayer()); |
| 534 | |
| 535 | EXPECT_CALL(mHwComposer, destroyLayer(DEFAULT_DISPLAY_ID, &hwcLayer)); |
| 536 | outputLayer.reset(); |
| 537 | } |
| 538 | |
| 539 | /* |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 540 | * Display::setReleasedLayers() |
| 541 | */ |
| 542 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 543 | using DisplaySetReleasedLayersTest = DisplayWithLayersTestCommon; |
| 544 | |
| 545 | TEST_F(DisplaySetReleasedLayersTest, doesNothingIfNotHwcDisplay) { |
| 546 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 547 | std::shared_ptr<impl::Display> nonHwcDisplay = impl::createDisplay(mCompositionEngine, args); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 548 | |
| 549 | sp<mock::LayerFE> layerXLayerFE = new StrictMock<mock::LayerFE>(); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 550 | |
| 551 | { |
| 552 | Output::ReleasedLayers releasedLayers; |
| 553 | releasedLayers.emplace_back(layerXLayerFE); |
| 554 | nonHwcDisplay->setReleasedLayers(std::move(releasedLayers)); |
| 555 | } |
| 556 | |
| 557 | CompositionRefreshArgs refreshArgs; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 558 | refreshArgs.layersWithQueuedFrames.push_back(layerXLayerFE); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 559 | |
| 560 | nonHwcDisplay->setReleasedLayers(refreshArgs); |
| 561 | |
| 562 | const auto& releasedLayers = nonHwcDisplay->getReleasedLayersForTest(); |
| 563 | ASSERT_EQ(1, releasedLayers.size()); |
| 564 | } |
| 565 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 566 | TEST_F(DisplaySetReleasedLayersTest, doesNothingIfNoLayersWithQueuedFrames) { |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 567 | sp<mock::LayerFE> layerXLayerFE = new StrictMock<mock::LayerFE>(); |
| 568 | |
| 569 | { |
| 570 | Output::ReleasedLayers releasedLayers; |
| 571 | releasedLayers.emplace_back(layerXLayerFE); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 572 | mDisplay->setReleasedLayers(std::move(releasedLayers)); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | CompositionRefreshArgs refreshArgs; |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 576 | mDisplay->setReleasedLayers(refreshArgs); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 577 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 578 | const auto& releasedLayers = mDisplay->getReleasedLayersForTest(); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 579 | ASSERT_EQ(1, releasedLayers.size()); |
| 580 | } |
| 581 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 582 | TEST_F(DisplaySetReleasedLayersTest, setReleasedLayers) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 583 | sp<mock::LayerFE> unknownLayer = new StrictMock<mock::LayerFE>(); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 584 | |
| 585 | CompositionRefreshArgs refreshArgs; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 586 | refreshArgs.layersWithQueuedFrames.push_back(mLayer1.layerFE); |
| 587 | refreshArgs.layersWithQueuedFrames.push_back(mLayer2.layerFE); |
| 588 | refreshArgs.layersWithQueuedFrames.push_back(unknownLayer); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 589 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 590 | mDisplay->setReleasedLayers(refreshArgs); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 591 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 592 | const auto& releasedLayers = mDisplay->getReleasedLayersForTest(); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 593 | ASSERT_EQ(2, releasedLayers.size()); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 594 | ASSERT_EQ(mLayer1.layerFE.get(), releasedLayers[0].promote().get()); |
| 595 | ASSERT_EQ(mLayer2.layerFE.get(), releasedLayers[1].promote().get()); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | /* |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 599 | * Display::chooseCompositionStrategy() |
| 600 | */ |
| 601 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 602 | using DisplayChooseCompositionStrategyTest = PartialMockDisplayTestCommon; |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 603 | |
| 604 | TEST_F(DisplayChooseCompositionStrategyTest, takesEarlyOutIfNotAHwcDisplay) { |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 605 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 606 | std::shared_ptr<Display> nonHwcDisplay = |
| 607 | createPartialMockDisplay<Display>(mCompositionEngine, args); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 608 | EXPECT_FALSE(nonHwcDisplay->getId()); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 609 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 610 | nonHwcDisplay->chooseCompositionStrategy(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 611 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 612 | auto& state = nonHwcDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 613 | EXPECT_TRUE(state.usesClientComposition); |
| 614 | EXPECT_FALSE(state.usesDeviceComposition); |
| 615 | } |
| 616 | |
| 617 | TEST_F(DisplayChooseCompositionStrategyTest, takesEarlyOutOnHwcError) { |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 618 | EXPECT_CALL(*mDisplay, anyLayersRequireClientComposition()).WillOnce(Return(false)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 619 | EXPECT_CALL(mHwComposer, getDeviceCompositionChanges(DEFAULT_DISPLAY_ID, false, _)) |
| 620 | .WillOnce(Return(INVALID_OPERATION)); |
| 621 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 622 | mDisplay->chooseCompositionStrategy(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 623 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 624 | auto& state = mDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 625 | EXPECT_TRUE(state.usesClientComposition); |
| 626 | EXPECT_FALSE(state.usesDeviceComposition); |
| 627 | } |
| 628 | |
| 629 | TEST_F(DisplayChooseCompositionStrategyTest, normalOperation) { |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 630 | // Since two calls are made to anyLayersRequireClientComposition with different return |
| 631 | // values, use a Sequence to control the matching so the values are returned in a known |
| 632 | // order. |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 633 | Sequence s; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 634 | EXPECT_CALL(*mDisplay, anyLayersRequireClientComposition()) |
| 635 | .InSequence(s) |
| 636 | .WillOnce(Return(true)); |
| 637 | EXPECT_CALL(*mDisplay, anyLayersRequireClientComposition()) |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 638 | .InSequence(s) |
| 639 | .WillOnce(Return(false)); |
| 640 | |
| 641 | EXPECT_CALL(mHwComposer, getDeviceCompositionChanges(DEFAULT_DISPLAY_ID, true, _)) |
| 642 | .WillOnce(Return(NO_ERROR)); |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 643 | EXPECT_CALL(*mDisplay, allLayersRequireClientComposition()).WillOnce(Return(false)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 644 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 645 | mDisplay->chooseCompositionStrategy(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 646 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 647 | auto& state = mDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 648 | EXPECT_FALSE(state.usesClientComposition); |
| 649 | EXPECT_TRUE(state.usesDeviceComposition); |
| 650 | } |
| 651 | |
| 652 | TEST_F(DisplayChooseCompositionStrategyTest, normalOperationWithChanges) { |
| 653 | android::HWComposer::DeviceRequestedChanges changes{ |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 654 | {{nullptr, hal::Composition::CLIENT}}, |
| 655 | hal::DisplayRequest::FLIP_CLIENT_TARGET, |
| 656 | {{nullptr, hal::LayerRequest::CLEAR_CLIENT_TARGET}}, |
Peiyong Lin | dfc3f7c | 2020-05-07 20:15:50 -0700 | [diff] [blame] | 657 | {hal::PixelFormat::RGBA_8888, hal::Dataspace::UNKNOWN}, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 658 | }; |
| 659 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 660 | // Since two calls are made to anyLayersRequireClientComposition with different return |
| 661 | // values, use a Sequence to control the matching so the values are returned in a known |
| 662 | // order. |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 663 | Sequence s; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 664 | EXPECT_CALL(*mDisplay, anyLayersRequireClientComposition()) |
| 665 | .InSequence(s) |
| 666 | .WillOnce(Return(true)); |
| 667 | EXPECT_CALL(*mDisplay, anyLayersRequireClientComposition()) |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 668 | .InSequence(s) |
| 669 | .WillOnce(Return(false)); |
| 670 | |
| 671 | EXPECT_CALL(mHwComposer, getDeviceCompositionChanges(DEFAULT_DISPLAY_ID, true, _)) |
| 672 | .WillOnce(DoAll(SetArgPointee<2>(changes), Return(NO_ERROR))); |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 673 | EXPECT_CALL(*mDisplay, applyChangedTypesToLayers(changes.changedTypes)).Times(1); |
| 674 | EXPECT_CALL(*mDisplay, applyDisplayRequests(changes.displayRequests)).Times(1); |
| 675 | EXPECT_CALL(*mDisplay, applyLayerRequestsToLayers(changes.layerRequests)).Times(1); |
| 676 | EXPECT_CALL(*mDisplay, allLayersRequireClientComposition()).WillOnce(Return(false)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 677 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 678 | mDisplay->chooseCompositionStrategy(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 679 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 680 | auto& state = mDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 681 | EXPECT_FALSE(state.usesClientComposition); |
| 682 | EXPECT_TRUE(state.usesDeviceComposition); |
| 683 | } |
| 684 | |
| 685 | /* |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 686 | * Display::getSkipColorTransform() |
| 687 | */ |
| 688 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 689 | using DisplayGetSkipColorTransformTest = DisplayWithLayersTestCommon; |
| 690 | |
Dominik Laskowski | 1162e47 | 2020-04-02 19:02:47 -0700 | [diff] [blame] | 691 | TEST_F(DisplayGetSkipColorTransformTest, checksCapabilityIfNonHwcDisplay) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 692 | EXPECT_CALL(mHwComposer, hasCapability(hal::Capability::SKIP_CLIENT_COLOR_TRANSFORM)) |
Dominik Laskowski | 1162e47 | 2020-04-02 19:02:47 -0700 | [diff] [blame] | 693 | .WillOnce(Return(true)); |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 694 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 695 | auto nonHwcDisplay{impl::createDisplay(mCompositionEngine, args)}; |
Dominik Laskowski | 1162e47 | 2020-04-02 19:02:47 -0700 | [diff] [blame] | 696 | EXPECT_TRUE(nonHwcDisplay->getSkipColorTransform()); |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 697 | } |
| 698 | |
Dominik Laskowski | 1162e47 | 2020-04-02 19:02:47 -0700 | [diff] [blame] | 699 | TEST_F(DisplayGetSkipColorTransformTest, checksDisplayCapability) { |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 700 | EXPECT_CALL(mHwComposer, |
Dominik Laskowski | 1162e47 | 2020-04-02 19:02:47 -0700 | [diff] [blame] | 701 | hasDisplayCapability(DEFAULT_DISPLAY_ID, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 702 | hal::DisplayCapability::SKIP_CLIENT_COLOR_TRANSFORM)) |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 703 | .WillOnce(Return(true)); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 704 | EXPECT_TRUE(mDisplay->getSkipColorTransform()); |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | /* |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 708 | * Display::anyLayersRequireClientComposition() |
| 709 | */ |
| 710 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 711 | using DisplayAnyLayersRequireClientCompositionTest = DisplayWithLayersTestCommon; |
| 712 | |
| 713 | TEST_F(DisplayAnyLayersRequireClientCompositionTest, returnsFalse) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 714 | EXPECT_CALL(*mLayer1.outputLayer, requiresClientComposition()).WillOnce(Return(false)); |
| 715 | EXPECT_CALL(*mLayer2.outputLayer, requiresClientComposition()).WillOnce(Return(false)); |
| 716 | EXPECT_CALL(*mLayer3.outputLayer, requiresClientComposition()).WillOnce(Return(false)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 717 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 718 | EXPECT_FALSE(mDisplay->anyLayersRequireClientComposition()); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 719 | } |
| 720 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 721 | TEST_F(DisplayAnyLayersRequireClientCompositionTest, returnsTrue) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 722 | EXPECT_CALL(*mLayer1.outputLayer, requiresClientComposition()).WillOnce(Return(false)); |
| 723 | EXPECT_CALL(*mLayer2.outputLayer, requiresClientComposition()).WillOnce(Return(true)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 724 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 725 | EXPECT_TRUE(mDisplay->anyLayersRequireClientComposition()); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | /* |
| 729 | * Display::allLayersRequireClientComposition() |
| 730 | */ |
| 731 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 732 | using DisplayAllLayersRequireClientCompositionTest = DisplayWithLayersTestCommon; |
| 733 | |
| 734 | TEST_F(DisplayAllLayersRequireClientCompositionTest, returnsTrue) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 735 | EXPECT_CALL(*mLayer1.outputLayer, requiresClientComposition()).WillOnce(Return(true)); |
| 736 | EXPECT_CALL(*mLayer2.outputLayer, requiresClientComposition()).WillOnce(Return(true)); |
| 737 | EXPECT_CALL(*mLayer3.outputLayer, requiresClientComposition()).WillOnce(Return(true)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 738 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 739 | EXPECT_TRUE(mDisplay->allLayersRequireClientComposition()); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 740 | } |
| 741 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 742 | TEST_F(DisplayAllLayersRequireClientCompositionTest, returnsFalse) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 743 | EXPECT_CALL(*mLayer1.outputLayer, requiresClientComposition()).WillOnce(Return(true)); |
| 744 | EXPECT_CALL(*mLayer2.outputLayer, requiresClientComposition()).WillOnce(Return(false)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 745 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 746 | EXPECT_FALSE(mDisplay->allLayersRequireClientComposition()); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | /* |
| 750 | * Display::applyChangedTypesToLayers() |
| 751 | */ |
| 752 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 753 | using DisplayApplyChangedTypesToLayersTest = DisplayWithLayersTestCommon; |
| 754 | |
| 755 | TEST_F(DisplayApplyChangedTypesToLayersTest, takesEarlyOutIfNoChangedLayers) { |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 756 | mDisplay->applyChangedTypesToLayers(impl::Display::ChangedTypes()); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 757 | } |
| 758 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 759 | TEST_F(DisplayApplyChangedTypesToLayersTest, appliesChanges) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 760 | EXPECT_CALL(*mLayer1.outputLayer, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 761 | applyDeviceCompositionTypeChange(Hwc2::IComposerClient::Composition::CLIENT)) |
| 762 | .Times(1); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 763 | EXPECT_CALL(*mLayer2.outputLayer, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 764 | applyDeviceCompositionTypeChange(Hwc2::IComposerClient::Composition::DEVICE)) |
| 765 | .Times(1); |
| 766 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 767 | mDisplay->applyChangedTypesToLayers(impl::Display::ChangedTypes{ |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 768 | {&mLayer1.hwc2Layer, hal::Composition::CLIENT}, |
| 769 | {&mLayer2.hwc2Layer, hal::Composition::DEVICE}, |
| 770 | {&hwc2LayerUnknown, hal::Composition::SOLID_COLOR}, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 771 | }); |
| 772 | } |
| 773 | |
| 774 | /* |
| 775 | * Display::applyDisplayRequests() |
| 776 | */ |
| 777 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 778 | using DisplayApplyDisplayRequestsTest = DisplayWithLayersTestCommon; |
| 779 | |
| 780 | TEST_F(DisplayApplyDisplayRequestsTest, handlesNoRequests) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 781 | mDisplay->applyDisplayRequests(static_cast<hal::DisplayRequest>(0)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 782 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 783 | auto& state = mDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 784 | EXPECT_FALSE(state.flipClientTarget); |
| 785 | } |
| 786 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 787 | TEST_F(DisplayApplyDisplayRequestsTest, handlesFlipClientTarget) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 788 | mDisplay->applyDisplayRequests(hal::DisplayRequest::FLIP_CLIENT_TARGET); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 789 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 790 | auto& state = mDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 791 | EXPECT_TRUE(state.flipClientTarget); |
| 792 | } |
| 793 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 794 | TEST_F(DisplayApplyDisplayRequestsTest, handlesWriteClientTargetToOutput) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 795 | mDisplay->applyDisplayRequests(hal::DisplayRequest::WRITE_CLIENT_TARGET_TO_OUTPUT); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 796 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 797 | auto& state = mDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 798 | EXPECT_FALSE(state.flipClientTarget); |
| 799 | } |
| 800 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 801 | TEST_F(DisplayApplyDisplayRequestsTest, handlesAllRequestFlagsSet) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 802 | mDisplay->applyDisplayRequests(static_cast<hal::DisplayRequest>(~0)); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 803 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 804 | auto& state = mDisplay->getState(); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 805 | EXPECT_TRUE(state.flipClientTarget); |
| 806 | } |
| 807 | |
| 808 | /* |
| 809 | * Display::applyLayerRequestsToLayers() |
| 810 | */ |
| 811 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 812 | using DisplayApplyLayerRequestsToLayersTest = DisplayWithLayersTestCommon; |
| 813 | |
| 814 | TEST_F(DisplayApplyLayerRequestsToLayersTest, preparesAllLayers) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 815 | EXPECT_CALL(*mLayer1.outputLayer, prepareForDeviceLayerRequests()).Times(1); |
| 816 | EXPECT_CALL(*mLayer2.outputLayer, prepareForDeviceLayerRequests()).Times(1); |
| 817 | EXPECT_CALL(*mLayer3.outputLayer, prepareForDeviceLayerRequests()).Times(1); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 818 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 819 | mDisplay->applyLayerRequestsToLayers(impl::Display::LayerRequests()); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 820 | } |
| 821 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 822 | TEST_F(DisplayApplyLayerRequestsToLayersTest, appliesDeviceLayerRequests) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 823 | EXPECT_CALL(*mLayer1.outputLayer, prepareForDeviceLayerRequests()).Times(1); |
| 824 | EXPECT_CALL(*mLayer2.outputLayer, prepareForDeviceLayerRequests()).Times(1); |
| 825 | EXPECT_CALL(*mLayer3.outputLayer, prepareForDeviceLayerRequests()).Times(1); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 826 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 827 | EXPECT_CALL(*mLayer1.outputLayer, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 828 | applyDeviceLayerRequest(Hwc2::IComposerClient::LayerRequest::CLEAR_CLIENT_TARGET)) |
| 829 | .Times(1); |
| 830 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 831 | mDisplay->applyLayerRequestsToLayers(impl::Display::LayerRequests{ |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 832 | {&mLayer1.hwc2Layer, hal::LayerRequest::CLEAR_CLIENT_TARGET}, |
| 833 | {&hwc2LayerUnknown, hal::LayerRequest::CLEAR_CLIENT_TARGET}, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 834 | }); |
| 835 | } |
| 836 | |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 837 | /* |
| 838 | * Display::presentAndGetFrameFences() |
| 839 | */ |
| 840 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 841 | using DisplayPresentAndGetFrameFencesTest = DisplayWithLayersTestCommon; |
| 842 | |
| 843 | TEST_F(DisplayPresentAndGetFrameFencesTest, returnsNoFencesOnNonHwcDisplay) { |
| 844 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 845 | auto nonHwcDisplay{impl::createDisplay(mCompositionEngine, args)}; |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 846 | |
| 847 | auto result = nonHwcDisplay->presentAndGetFrameFences(); |
| 848 | |
| 849 | ASSERT_TRUE(result.presentFence.get()); |
| 850 | EXPECT_FALSE(result.presentFence->isValid()); |
| 851 | EXPECT_EQ(0u, result.layerFences.size()); |
| 852 | } |
| 853 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 854 | TEST_F(DisplayPresentAndGetFrameFencesTest, returnsPresentAndLayerFences) { |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 855 | sp<Fence> presentFence = new Fence(); |
| 856 | sp<Fence> layer1Fence = new Fence(); |
| 857 | sp<Fence> layer2Fence = new Fence(); |
| 858 | |
| 859 | EXPECT_CALL(mHwComposer, presentAndGetReleaseFences(DEFAULT_DISPLAY_ID)).Times(1); |
| 860 | EXPECT_CALL(mHwComposer, getPresentFence(DEFAULT_DISPLAY_ID)).WillOnce(Return(presentFence)); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 861 | EXPECT_CALL(mHwComposer, getLayerReleaseFence(DEFAULT_DISPLAY_ID, &mLayer1.hwc2Layer)) |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 862 | .WillOnce(Return(layer1Fence)); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 863 | EXPECT_CALL(mHwComposer, getLayerReleaseFence(DEFAULT_DISPLAY_ID, &mLayer2.hwc2Layer)) |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 864 | .WillOnce(Return(layer2Fence)); |
| 865 | EXPECT_CALL(mHwComposer, clearReleaseFences(DEFAULT_DISPLAY_ID)).Times(1); |
| 866 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 867 | auto result = mDisplay->presentAndGetFrameFences(); |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 868 | |
| 869 | EXPECT_EQ(presentFence, result.presentFence); |
| 870 | |
| 871 | EXPECT_EQ(2u, result.layerFences.size()); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 872 | ASSERT_EQ(1, result.layerFences.count(&mLayer1.hwc2Layer)); |
| 873 | EXPECT_EQ(layer1Fence, result.layerFences[&mLayer1.hwc2Layer]); |
| 874 | ASSERT_EQ(1, result.layerFences.count(&mLayer2.hwc2Layer)); |
| 875 | EXPECT_EQ(layer2Fence, result.layerFences[&mLayer2.hwc2Layer]); |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 876 | } |
| 877 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 878 | /* |
| 879 | * Display::setExpensiveRenderingExpected() |
| 880 | */ |
| 881 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 882 | using DisplaySetExpensiveRenderingExpectedTest = DisplayWithLayersTestCommon; |
| 883 | |
| 884 | TEST_F(DisplaySetExpensiveRenderingExpectedTest, forwardsToPowerAdvisor) { |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 885 | EXPECT_CALL(mPowerAdvisor, setExpensiveRenderingExpected(DEFAULT_DISPLAY_ID, true)).Times(1); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 886 | mDisplay->setExpensiveRenderingExpected(true); |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 887 | |
| 888 | EXPECT_CALL(mPowerAdvisor, setExpensiveRenderingExpected(DEFAULT_DISPLAY_ID, false)).Times(1); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 889 | mDisplay->setExpensiveRenderingExpected(false); |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 890 | } |
| 891 | |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 892 | /* |
| 893 | * Display::finishFrame() |
| 894 | */ |
| 895 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 896 | using DisplayFinishFrameTest = DisplayWithLayersTestCommon; |
| 897 | |
| 898 | TEST_F(DisplayFinishFrameTest, doesNotSkipCompositionIfNotDirtyOnHwcDisplay) { |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 899 | mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>(); |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 900 | mDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface)); |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 901 | |
| 902 | // We expect no calls to queueBuffer if composition was skipped. |
| 903 | EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(1); |
| 904 | |
Lloyd Pique | a76ce46 | 2020-01-14 13:06:37 -0800 | [diff] [blame] | 905 | // Expect a call to signal no expensive rendering since there is no client composition. |
| 906 | EXPECT_CALL(mPowerAdvisor, setExpensiveRenderingExpected(DEFAULT_DISPLAY_ID, false)); |
| 907 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 908 | mDisplay->editState().isEnabled = true; |
| 909 | mDisplay->editState().usesClientComposition = false; |
| 910 | mDisplay->editState().viewport = Rect(0, 0, 1, 1); |
| 911 | mDisplay->editState().dirtyRegion = Region::INVALID_REGION; |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 912 | |
| 913 | CompositionRefreshArgs refreshArgs; |
| 914 | refreshArgs.repaintEverything = false; |
| 915 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 916 | mDisplay->finishFrame(refreshArgs); |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 917 | } |
| 918 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 919 | TEST_F(DisplayFinishFrameTest, skipsCompositionIfNotDirty) { |
| 920 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 921 | std::shared_ptr<impl::Display> nonHwcDisplay = impl::createDisplay(mCompositionEngine, args); |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 922 | |
| 923 | mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>(); |
| 924 | nonHwcDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface)); |
| 925 | |
| 926 | // We expect no calls to queueBuffer if composition was skipped. |
| 927 | EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(0); |
| 928 | |
| 929 | nonHwcDisplay->editState().isEnabled = true; |
| 930 | nonHwcDisplay->editState().usesClientComposition = false; |
| 931 | nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1); |
| 932 | nonHwcDisplay->editState().dirtyRegion = Region::INVALID_REGION; |
| 933 | |
| 934 | CompositionRefreshArgs refreshArgs; |
| 935 | refreshArgs.repaintEverything = false; |
| 936 | |
| 937 | nonHwcDisplay->finishFrame(refreshArgs); |
| 938 | } |
| 939 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 940 | TEST_F(DisplayFinishFrameTest, performsCompositionIfDirty) { |
| 941 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 942 | std::shared_ptr<impl::Display> nonHwcDisplay = impl::createDisplay(mCompositionEngine, args); |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 943 | |
| 944 | mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>(); |
| 945 | nonHwcDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface)); |
| 946 | |
| 947 | // We expect a single call to queueBuffer when composition is not skipped. |
| 948 | EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(1); |
| 949 | |
| 950 | nonHwcDisplay->editState().isEnabled = true; |
| 951 | nonHwcDisplay->editState().usesClientComposition = false; |
| 952 | nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1); |
| 953 | nonHwcDisplay->editState().dirtyRegion = Region(Rect(0, 0, 1, 1)); |
| 954 | |
| 955 | CompositionRefreshArgs refreshArgs; |
| 956 | refreshArgs.repaintEverything = false; |
| 957 | |
| 958 | nonHwcDisplay->finishFrame(refreshArgs); |
| 959 | } |
| 960 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 961 | TEST_F(DisplayFinishFrameTest, performsCompositionIfRepaintEverything) { |
| 962 | auto args = getDisplayCreationArgsForNonHWCVirtualDisplay(); |
| 963 | std::shared_ptr<impl::Display> nonHwcDisplay = impl::createDisplay(mCompositionEngine, args); |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 964 | |
| 965 | mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>(); |
| 966 | nonHwcDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface)); |
| 967 | |
| 968 | // We expect a single call to queueBuffer when composition is not skipped. |
| 969 | EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(1); |
| 970 | |
| 971 | nonHwcDisplay->editState().isEnabled = true; |
| 972 | nonHwcDisplay->editState().usesClientComposition = false; |
| 973 | nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1); |
| 974 | nonHwcDisplay->editState().dirtyRegion = Region::INVALID_REGION; |
| 975 | |
| 976 | CompositionRefreshArgs refreshArgs; |
| 977 | refreshArgs.repaintEverything = true; |
| 978 | |
| 979 | nonHwcDisplay->finishFrame(refreshArgs); |
| 980 | } |
| 981 | |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 982 | /* |
| 983 | * Display functional tests |
| 984 | */ |
| 985 | |
| 986 | struct DisplayFunctionalTest : public testing::Test { |
| 987 | class Display : public impl::Display { |
| 988 | public: |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 989 | using impl::Display::injectOutputLayerForTest; |
| 990 | virtual void injectOutputLayerForTest(std::unique_ptr<compositionengine::OutputLayer>) = 0; |
| 991 | }; |
| 992 | |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 993 | DisplayFunctionalTest() { |
| 994 | EXPECT_CALL(mCompositionEngine, getHwComposer()).WillRepeatedly(ReturnRef(mHwComposer)); |
| 995 | |
| 996 | mDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(mRenderSurface)); |
| 997 | } |
| 998 | |
| 999 | NiceMock<android::mock::HWComposer> mHwComposer; |
| 1000 | NiceMock<Hwc2::mock::PowerAdvisor> mPowerAdvisor; |
| 1001 | NiceMock<mock::CompositionEngine> mCompositionEngine; |
| 1002 | sp<mock::NativeWindow> mNativeWindow = new NiceMock<mock::NativeWindow>(); |
| 1003 | sp<mock::DisplaySurface> mDisplaySurface = new NiceMock<mock::DisplaySurface>(); |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 1004 | std::shared_ptr<Display> mDisplay = impl::createDisplayTemplated< |
| 1005 | Display>(mCompositionEngine, |
| 1006 | DisplayCreationArgsBuilder() |
| 1007 | .setPhysical({DEFAULT_DISPLAY_ID, DisplayConnectionType::Internal}) |
| 1008 | .setPixels({DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT}) |
| 1009 | .setPixelFormat(static_cast<ui::PixelFormat>(PIXEL_FORMAT_RGBA_8888)) |
| 1010 | .setIsSecure(true) |
| 1011 | .setLayerStackId(DEFAULT_LAYER_STACK) |
| 1012 | .setPowerAdvisor(&mPowerAdvisor) |
| 1013 | .build() |
| 1014 | |
| 1015 | ); |
Lloyd Pique | c660755 | 2019-12-02 17:57:39 -0800 | [diff] [blame] | 1016 | impl::RenderSurface* mRenderSurface = |
| 1017 | new impl::RenderSurface{mCompositionEngine, *mDisplay, |
| 1018 | RenderSurfaceCreationArgs{DEFAULT_DISPLAY_WIDTH, |
| 1019 | DEFAULT_DISPLAY_HEIGHT, mNativeWindow, |
| 1020 | mDisplaySurface}}; |
| 1021 | }; |
| 1022 | |
| 1023 | TEST_F(DisplayFunctionalTest, postFramebufferCriticalCallsAreOrdered) { |
| 1024 | InSequence seq; |
| 1025 | |
| 1026 | mDisplay->editState().isEnabled = true; |
| 1027 | |
| 1028 | EXPECT_CALL(mHwComposer, presentAndGetReleaseFences(_)); |
| 1029 | EXPECT_CALL(*mDisplaySurface, onFrameCommitted()); |
| 1030 | |
| 1031 | mDisplay->postFramebuffer(); |
| 1032 | } |
| 1033 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 1034 | } // namespace |
| 1035 | } // namespace android::compositionengine |