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