blob: 4f8ed1ae1c75800151a63188731e0919c460de15 [file] [log] [blame]
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001/*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#undef LOG_TAG
18#define LOG_TAG "CompositionTest"
19
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080020#include <compositionengine/Display.h>
Lloyd Pique542307f2018-10-19 13:24:08 -070021#include <compositionengine/mock/DisplaySurface.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070022#include <gmock/gmock.h>
23#include <gtest/gtest.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070024#include <gui/IProducerListener.h>
Evan Roskya1f1e152019-01-24 16:17:46 -080025#include <gui/LayerMetadata.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070026#include <log/log.h>
Lloyd Pique3823e7b2018-10-18 16:58:10 -070027#include <renderengine/mock/Framebuffer.h>
28#include <renderengine/mock/Image.h>
29#include <renderengine/mock/RenderEngine.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070030#include <system/window.h>
31#include <utils/String8.h>
32
33#include "BufferQueueLayer.h"
34#include "ColorLayer.h"
35#include "Layer.h"
36
Ana Krulecafb45842019-02-13 13:33:03 -080037#include "TestableScheduler.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070038#include "TestableSurfaceFlinger.h"
39#include "mock/DisplayHardware/MockComposer.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070040#include "mock/MockDispSync.h"
41#include "mock/MockEventControlThread.h"
42#include "mock/MockEventThread.h"
43#include "mock/MockMessageQueue.h"
Alec Mouriba013fa2018-10-16 12:43:11 -070044#include "mock/system/window/MockNativeWindow.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070045
46namespace android {
47namespace {
48
49using testing::_;
David Sodman15094112018-10-11 09:39:37 -070050using testing::AtLeast;
Alec Mourie7d1d4a2019-02-05 01:13:46 +000051using testing::Between;
Lloyd Piqued6b579f2018-04-06 15:29:10 -070052using testing::ByMove;
53using testing::DoAll;
Alec Mourie7d1d4a2019-02-05 01:13:46 +000054using testing::Field;
Alec Mouri0a9c7b82018-11-16 13:05:25 -080055using testing::Invoke;
Lloyd Piqued6b579f2018-04-06 15:29:10 -070056using testing::IsNull;
57using testing::Mock;
58using testing::NotNull;
59using testing::Ref;
60using testing::Return;
61using testing::ReturnRef;
62using testing::SetArgPointee;
63
64using android::Hwc2::Error;
65using android::Hwc2::IComposer;
66using android::Hwc2::IComposerClient;
67using android::Hwc2::Transform;
68
69using FakeHwcDisplayInjector = TestableSurfaceFlinger::FakeHwcDisplayInjector;
70using FakeDisplayDeviceInjector = TestableSurfaceFlinger::FakeDisplayDeviceInjector;
71
72constexpr hwc2_display_t HWC_DISPLAY = FakeHwcDisplayInjector::DEFAULT_HWC_DISPLAY_ID;
73constexpr hwc2_layer_t HWC_LAYER = 5000;
74constexpr Transform DEFAULT_TRANSFORM = static_cast<Transform>(0);
75
Dominik Laskowski34157762018-10-31 13:07:19 -070076constexpr DisplayId DEFAULT_DISPLAY_ID = DisplayId{42};
Lloyd Piqued6b579f2018-04-06 15:29:10 -070077constexpr int DEFAULT_DISPLAY_WIDTH = 1920;
78constexpr int DEFAULT_DISPLAY_HEIGHT = 1024;
79
80constexpr int DEFAULT_CONFIG_ID = 0;
81constexpr int DEFAULT_TEXTURE_ID = 6000;
82constexpr int DEFAULT_LAYER_STACK = 7000;
83
84constexpr int DEFAULT_DISPLAY_MAX_LUMINANCE = 500;
85
86constexpr int DEFAULT_SIDEBAND_STREAM = 51;
87
88class CompositionTest : public testing::Test {
89public:
90 CompositionTest() {
91 const ::testing::TestInfo* const test_info =
92 ::testing::UnitTest::GetInstance()->current_test_info();
93 ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
94
Lloyd Piqued6b579f2018-04-06 15:29:10 -070095 mFlinger.mutableEventQueue().reset(mMessageQueue);
Ana Krulecafb45842019-02-13 13:33:03 -080096 setupScheduler();
Lloyd Piqued6b579f2018-04-06 15:29:10 -070097
Lloyd Piqued6b579f2018-04-06 15:29:10 -070098 EXPECT_CALL(*mPrimaryDispSync, computeNextRefresh(0)).WillRepeatedly(Return(0));
99 EXPECT_CALL(*mPrimaryDispSync, getPeriod())
100 .WillRepeatedly(Return(FakeHwcDisplayInjector::DEFAULT_REFRESH_RATE));
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800101 EXPECT_CALL(*mPrimaryDispSync, expectedPresentTime()).WillRepeatedly(Return(0));
Alec Mourif6fd29e2018-11-17 04:56:41 +0000102 EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
103 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0)));
104 EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
105 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0)));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700106
107 mFlinger.setupRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine));
108 setupComposer(0);
109 }
110
111 ~CompositionTest() {
112 const ::testing::TestInfo* const test_info =
113 ::testing::UnitTest::GetInstance()->current_test_info();
114 ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name());
115 }
116
117 void setupComposer(int virtualDisplayCount) {
118 mComposer = new Hwc2::mock::Composer();
119 EXPECT_CALL(*mComposer, getCapabilities())
120 .WillOnce(Return(std::vector<IComposer::Capability>()));
121 EXPECT_CALL(*mComposer, getMaxVirtualDisplayCount()).WillOnce(Return(virtualDisplayCount));
122 mFlinger.setupComposer(std::unique_ptr<Hwc2::Composer>(mComposer));
123
124 Mock::VerifyAndClear(mComposer);
125 }
126
Ana Krulecafb45842019-02-13 13:33:03 -0800127 void setupScheduler() {
Ady Abraham09bd3922019-04-08 10:44:56 -0700128 mScheduler = new TestableScheduler(mFlinger.mutableRefreshRateConfigs());
Ana Krulecafb45842019-02-13 13:33:03 -0800129 mScheduler->mutableEventControlThread().reset(mEventControlThread);
130 mScheduler->mutablePrimaryDispSync().reset(mPrimaryDispSync);
131 EXPECT_CALL(*mEventThread.get(), registerDisplayEventConnection(_));
132 sp<Scheduler::ConnectionHandle> connectionHandle =
133 mScheduler->addConnection(std::move(mEventThread));
134 mFlinger.mutableSfConnectionHandle() = std::move(connectionHandle);
135
136 mFlinger.mutableScheduler().reset(mScheduler);
137 }
138
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700139 void setupForceGeometryDirty() {
140 // TODO: This requires the visible region and other related
141 // state to be set, and is problematic for BufferLayers since they are
142 // not visible without a buffer (and setting up a buffer looks like a
143 // pain)
144 // mFlinger.mutableVisibleRegionsDirty() = true;
145
146 mFlinger.mutableGeometryInvalid() = true;
147 }
148
149 template <typename Case>
150 void displayRefreshCompositionDirtyGeometry();
151
152 template <typename Case>
153 void displayRefreshCompositionDirtyFrame();
154
155 template <typename Case>
156 void captureScreenComposition();
157
158 std::unordered_set<HWC2::Capability> mDefaultCapabilities = {HWC2::Capability::SidebandStream};
159
Ana Krulecafb45842019-02-13 13:33:03 -0800160 TestableScheduler* mScheduler;
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700161 TestableSurfaceFlinger mFlinger;
162 sp<DisplayDevice> mDisplay;
163 sp<DisplayDevice> mExternalDisplay;
Lloyd Pique542307f2018-10-19 13:24:08 -0700164 sp<compositionengine::mock::DisplaySurface> mDisplaySurface =
165 new compositionengine::mock::DisplaySurface();
Alec Mouriba013fa2018-10-16 12:43:11 -0700166 mock::NativeWindow* mNativeWindow = new mock::NativeWindow();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700167
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800168 sp<GraphicBuffer> mBuffer = new GraphicBuffer();
169 ANativeWindowBuffer* mNativeWindowBuffer = mBuffer->getNativeBuffer();
170
Ana Krulecafb45842019-02-13 13:33:03 -0800171 std::unique_ptr<mock::EventThread> mEventThread = std::make_unique<mock::EventThread>();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700172 mock::EventControlThread* mEventControlThread = new mock::EventControlThread();
173
174 Hwc2::mock::Composer* mComposer = nullptr;
175 renderengine::mock::RenderEngine* mRenderEngine = new renderengine::mock::RenderEngine();
176 mock::MessageQueue* mMessageQueue = new mock::MessageQueue();
177 mock::DispSync* mPrimaryDispSync = new mock::DispSync();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700178
179 sp<Fence> mClientTargetAcquireFence = Fence::NO_FENCE;
180
181 sp<GraphicBuffer> mCaptureScreenBuffer;
182};
183
184template <typename LayerCase>
185void CompositionTest::displayRefreshCompositionDirtyGeometry() {
186 setupForceGeometryDirty();
187 LayerCase::setupForDirtyGeometry(this);
188
189 // --------------------------------------------------------------------
190 // Invocation
191
192 mFlinger.onMessageReceived(MessageQueue::INVALIDATE);
193 mFlinger.onMessageReceived(MessageQueue::REFRESH);
194
195 LayerCase::cleanup(this);
196}
197
198template <typename LayerCase>
199void CompositionTest::displayRefreshCompositionDirtyFrame() {
200 LayerCase::setupForDirtyFrame(this);
201
202 // --------------------------------------------------------------------
203 // Invocation
204
205 mFlinger.onMessageReceived(MessageQueue::INVALIDATE);
206 mFlinger.onMessageReceived(MessageQueue::REFRESH);
207
208 LayerCase::cleanup(this);
209}
210
211template <typename LayerCase>
212void CompositionTest::captureScreenComposition() {
213 LayerCase::setupForScreenCapture(this);
214
215 const Rect sourceCrop(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700216 constexpr bool useIdentityTransform = true;
217 constexpr bool forSystem = true;
218
219 DisplayRenderArea renderArea(mDisplay, sourceCrop, DEFAULT_DISPLAY_WIDTH,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700220 DEFAULT_DISPLAY_HEIGHT, ui::Dataspace::V0_SRGB,
221 ui::Transform::ROT_0);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700222
223 auto traverseLayers = [this](const LayerVector::Visitor& visitor) {
chaviw0e3479f2018-09-10 16:49:30 -0700224 return mFlinger.traverseLayersInDisplay(mDisplay, visitor);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700225 };
226
227 // TODO: Eliminate expensive/real allocation if possible.
228 const uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
229 GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
230 mCaptureScreenBuffer = new GraphicBuffer(renderArea.getReqWidth(), renderArea.getReqHeight(),
231 HAL_PIXEL_FORMAT_RGBA_8888, 1, usage, "screenshot");
232
233 int fd = -1;
234 status_t result =
235 mFlinger.captureScreenImplLocked(renderArea, traverseLayers, mCaptureScreenBuffer.get(),
236 useIdentityTransform, forSystem, &fd);
237 if (fd >= 0) {
238 close(fd);
239 }
240
241 EXPECT_EQ(NO_ERROR, result);
242
243 LayerCase::cleanup(this);
244}
245
246/* ------------------------------------------------------------------------
247 * Variants for each display configuration which can be tested
248 */
249
250template <typename Derived>
251struct BaseDisplayVariant {
252 static constexpr bool IS_SECURE = true;
253 static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_NORMAL;
254
255 static void setupPreconditions(CompositionTest* test) {
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700256 EXPECT_CALL(*test->mComposer,
257 setPowerMode(HWC_DISPLAY,
258 static_cast<Hwc2::IComposerClient::PowerMode>(
259 Derived::INIT_POWER_MODE)))
260 .WillOnce(Return(Error::NONE));
Alec Mouriba013fa2018-10-16 12:43:11 -0700261
Dominik Laskowski075d3172018-05-24 15:50:06 -0700262 FakeHwcDisplayInjector(DEFAULT_DISPLAY_ID, HWC2::DisplayType::Physical,
263 true /* isPrimary */)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700264 .setCapabilities(&test->mDefaultCapabilities)
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700265 .setPowerMode(Derived::INIT_POWER_MODE)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700266 .inject(&test->mFlinger, test->mComposer);
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800267 Mock::VerifyAndClear(test->mComposer);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700268
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800269 EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
270 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0)));
271 EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
272 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0)));
273 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_BUFFERS_FORMAT)).Times(1);
274 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_API_CONNECT)).Times(1);
275 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_USAGE64)).Times(1);
Dominik Laskowski075d3172018-05-24 15:50:06 -0700276 test->mDisplay = FakeDisplayDeviceInjector(test->mFlinger, DEFAULT_DISPLAY_ID,
277 false /* isVirtual */, true /* isPrimary */)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700278 .setDisplaySurface(test->mDisplaySurface)
Alec Mouriba013fa2018-10-16 12:43:11 -0700279 .setNativeWindow(test->mNativeWindow)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700280 .setSecure(Derived::IS_SECURE)
281 .setPowerMode(Derived::INIT_POWER_MODE)
282 .inject();
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800283 Mock::VerifyAndClear(test->mNativeWindow);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700284 test->mDisplay->setLayerStack(DEFAULT_LAYER_STACK);
285 }
286
287 template <typename Case>
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700288 static void setupPreconditionCallExpectations(CompositionTest* test) {
289 EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _))
290 .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::DisplayCapability>({})),
291 Return(Error::NONE)));
292 }
293
294 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700295 static void setupCommonCompositionCallExpectations(CompositionTest* test) {
296 EXPECT_CALL(*test->mComposer,
297 setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
298 .Times(1);
299 EXPECT_CALL(*test->mComposer, presentOrValidateDisplay(HWC_DISPLAY, _, _, _, _)).Times(1);
300 EXPECT_CALL(*test->mComposer, getDisplayRequests(HWC_DISPLAY, _, _, _)).Times(1);
301 EXPECT_CALL(*test->mComposer, acceptDisplayChanges(HWC_DISPLAY)).Times(1);
302 EXPECT_CALL(*test->mComposer, presentDisplay(HWC_DISPLAY, _)).Times(1);
303 EXPECT_CALL(*test->mComposer, getReleaseFences(HWC_DISPLAY, _, _)).Times(1);
304
305 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000306 // TODO: remove once we verify that we can just grab the fence from the
307 // FramebufferSurface.
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800308 EXPECT_CALL(*test->mRenderEngine, flush()).WillRepeatedly(Invoke([]() {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000309 return base::unique_fd();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800310 }));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700311
312 EXPECT_CALL(*test->mDisplaySurface, onFrameCommitted()).Times(1);
313 EXPECT_CALL(*test->mDisplaySurface, advanceFrame()).Times(1);
314
315 Case::CompositionType::setupHwcSetCallExpectations(test);
316 Case::CompositionType::setupHwcGetCallExpectations(test);
317 }
318
319 template <typename Case>
320 static void setupCommonScreensCaptureCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000321 EXPECT_CALL(*test->mRenderEngine, drawLayers)
322 .WillRepeatedly(
323 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700324 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
325 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000326 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
327 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
328 displaySettings.physicalDisplay);
329 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
330 displaySettings.clip);
331 return NO_ERROR;
332 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700333 }
334
335 static void setupNonEmptyFrameCompositionCallExpectations(CompositionTest* test) {
336 EXPECT_CALL(*test->mDisplaySurface, beginFrame(true)).Times(1);
337 }
338
339 static void setupEmptyFrameCompositionCallExpectations(CompositionTest* test) {
340 EXPECT_CALL(*test->mDisplaySurface, beginFrame(false)).Times(1);
341 }
342
343 static void setupHwcCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique542307f2018-10-19 13:24:08 -0700344 EXPECT_CALL(*test->mDisplaySurface,
345 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_HWC))
346 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700347 }
348
349 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique542307f2018-10-19 13:24:08 -0700350 EXPECT_CALL(*test->mDisplaySurface,
351 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_GLES))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700352 .Times(1);
353 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
354 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
355
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800356 EXPECT_CALL(*test->mNativeWindow, queueBuffer(_, _)).WillOnce(Return(0));
357 EXPECT_CALL(*test->mNativeWindow, dequeueBuffer(_, _))
358 .WillOnce(DoAll(SetArgPointee<0>(test->mNativeWindowBuffer), SetArgPointee<1>(-1),
359 Return(0)));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000360 EXPECT_CALL(*test->mRenderEngine, drawLayers)
361 .WillRepeatedly(
362 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700363 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
364 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000365 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
366 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
367 displaySettings.physicalDisplay);
368 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
369 displaySettings.clip);
370 EXPECT_EQ(ui::Dataspace::UNKNOWN, displaySettings.outputDataspace);
371 return NO_ERROR;
372 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700373 }
374
375 template <typename Case>
376 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
377 Case::Layer::setupRECompositionCallExpectations(test);
378 }
379
380 template <typename Case>
381 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
382 Case::Layer::setupREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700383 }
384};
385
386struct DefaultDisplaySetupVariant : public BaseDisplayVariant<DefaultDisplaySetupVariant> {};
387
388struct InsecureDisplaySetupVariant : public BaseDisplayVariant<InsecureDisplaySetupVariant> {
389 static constexpr bool IS_SECURE = false;
390
391 template <typename Case>
392 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
393 Case::Layer::setupInsecureRECompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700394 }
395
396 template <typename Case>
397 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
398 Case::Layer::setupInsecureREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700399 }
400};
401
402struct PoweredOffDisplaySetupVariant : public BaseDisplayVariant<PoweredOffDisplaySetupVariant> {
403 static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_OFF;
404
405 template <typename Case>
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700406 static void setupPreconditionCallExpectations(CompositionTest*) {}
407
408 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700409 static void setupCommonCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800410 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
411
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700412 // TODO: This seems like an unnecessary call if display is powered off.
413 EXPECT_CALL(*test->mComposer,
414 setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
415 .Times(1);
416
417 // TODO: This seems like an unnecessary call if display is powered off.
418 Case::CompositionType::setupHwcSetCallExpectations(test);
419 }
420
421 static void setupHwcCompositionCallExpectations(CompositionTest*) {}
422
423 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800424 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
425
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700426 // TODO: This seems like an unnecessary call if display is powered off.
427 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
428 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
429 }
430
431 template <typename Case>
432 static void setupRELayerCompositionCallExpectations(CompositionTest*) {}
433};
434
435/* ------------------------------------------------------------------------
436 * Variants for each layer configuration which can be tested
437 */
438
439template <typename LayerProperties>
440struct BaseLayerProperties {
441 static constexpr uint32_t WIDTH = 100;
442 static constexpr uint32_t HEIGHT = 100;
443 static constexpr PixelFormat FORMAT = PIXEL_FORMAT_RGBA_8888;
444 static constexpr uint64_t USAGE =
445 GraphicBuffer::USAGE_SW_READ_NEVER | GraphicBuffer::USAGE_SW_WRITE_NEVER;
446 static constexpr android_dataspace DATASPACE = HAL_DATASPACE_UNKNOWN;
447 static constexpr uint32_t SCALING_MODE = 0;
448 static constexpr uint32_t TRANSFORM = 0;
449 static constexpr uint32_t LAYER_FLAGS = 0;
450 static constexpr float COLOR[] = {1.f, 1.f, 1.f, 1.f};
451 static constexpr IComposerClient::BlendMode BLENDMODE =
452 IComposerClient::BlendMode::PREMULTIPLIED;
453
454 static void enqueueBuffer(CompositionTest*, sp<BufferQueueLayer> layer) {
455 auto producer = layer->getProducer();
456
457 IGraphicBufferProducer::QueueBufferOutput qbo;
458 status_t result = producer->connect(nullptr, NATIVE_WINDOW_API_EGL, false, &qbo);
459 if (result != NO_ERROR) {
460 ALOGE("Failed to connect() (%d)", result);
461 return;
462 }
463
464 int slot;
465 sp<Fence> fence;
466 result = producer->dequeueBuffer(&slot, &fence, LayerProperties::WIDTH,
467 LayerProperties::HEIGHT, LayerProperties::FORMAT,
468 LayerProperties::USAGE, nullptr, nullptr);
469 if (result != IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
470 ALOGE("Failed to dequeueBuffer() (%d)", result);
471 return;
472 }
473
474 sp<GraphicBuffer> buffer;
475 result = producer->requestBuffer(slot, &buffer);
476 if (result != NO_ERROR) {
477 ALOGE("Failed to requestBuffer() (%d)", result);
478 return;
479 }
480
481 IGraphicBufferProducer::QueueBufferInput qbi(systemTime(), false /* isAutoTimestamp */,
482 LayerProperties::DATASPACE,
483 Rect(LayerProperties::WIDTH,
484 LayerProperties::HEIGHT),
485 LayerProperties::SCALING_MODE,
486 LayerProperties::TRANSFORM, Fence::NO_FENCE);
487 result = producer->queueBuffer(slot, qbi, &qbo);
488 if (result != NO_ERROR) {
489 ALOGE("Failed to queueBuffer (%d)", result);
490 return;
491 }
492 }
493
494 static void setupLatchedBuffer(CompositionTest* test, sp<BufferQueueLayer> layer) {
495 // TODO: Eliminate the complexity of actually creating a buffer
496 EXPECT_CALL(*test->mRenderEngine, getMaxTextureSize()).WillOnce(Return(16384));
497 EXPECT_CALL(*test->mRenderEngine, getMaxViewportDims()).WillOnce(Return(16384));
498 status_t err =
499 layer->setDefaultBufferProperties(LayerProperties::WIDTH, LayerProperties::HEIGHT,
500 LayerProperties::FORMAT);
501 ASSERT_EQ(NO_ERROR, err);
502 Mock::VerifyAndClear(test->mRenderEngine);
503
504 EXPECT_CALL(*test->mMessageQueue, invalidate()).Times(1);
505 enqueueBuffer(test, layer);
506 Mock::VerifyAndClear(test->mMessageQueue);
507
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700508 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700509 bool ignoredRecomputeVisibleRegions;
Alec Mouri56e538f2019-01-14 15:22:01 -0800510 layer->latchBuffer(ignoredRecomputeVisibleRegions, 0);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700511 Mock::VerifyAndClear(test->mRenderEngine);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700512 }
513
514 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
515 setupLatchedBuffer(test, layer);
516 }
517
518 static void setupBufferLayerPostFrameCallExpectations(CompositionTest* test) {
519 // BufferLayer::onPostComposition(), when there is no present fence
520 EXPECT_CALL(*test->mComposer, getActiveConfig(HWC_DISPLAY, _))
521 .WillOnce(DoAll(SetArgPointee<1>(DEFAULT_CONFIG_ID), Return(Error::NONE)));
522 }
523
524 static void setupHwcSetGeometryCallExpectations(CompositionTest* test) {
525 // TODO: Coverage of other values
526 EXPECT_CALL(*test->mComposer,
527 setLayerBlendMode(HWC_DISPLAY, HWC_LAYER, LayerProperties::BLENDMODE))
528 .Times(1);
529 // TODO: Coverage of other values for origin
530 EXPECT_CALL(*test->mComposer,
531 setLayerDisplayFrame(HWC_DISPLAY, HWC_LAYER,
532 IComposerClient::Rect({0, 0, LayerProperties::WIDTH,
533 LayerProperties::HEIGHT})))
534 .Times(1);
535 EXPECT_CALL(*test->mComposer,
536 setLayerPlaneAlpha(HWC_DISPLAY, HWC_LAYER, LayerProperties::COLOR[3]))
537 .Times(1);
538 // TODO: Coverage of other values
539 EXPECT_CALL(*test->mComposer, setLayerZOrder(HWC_DISPLAY, HWC_LAYER, 0u)).Times(1);
540 // TODO: Coverage of other values
541 EXPECT_CALL(*test->mComposer, setLayerInfo(HWC_DISPLAY, HWC_LAYER, 0u, 0u)).Times(1);
542
543 // These expectations retire on saturation as the code path these
544 // expectations are for appears to make an extra call to them.
545 // TODO: Investigate this extra call
546 EXPECT_CALL(*test->mComposer, setLayerTransform(HWC_DISPLAY, HWC_LAYER, DEFAULT_TRANSFORM))
David Sodman15094112018-10-11 09:39:37 -0700547 .Times(AtLeast(1))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700548 .RetiresOnSaturation();
549 }
550
551 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
552 EXPECT_CALL(*test->mComposer,
553 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
554 IComposerClient::FRect({0.f, 0.f, LayerProperties::WIDTH,
555 LayerProperties::HEIGHT})))
556 .Times(1);
557 }
558
559 static void setupHwcSetSourceCropColorCallExpectations(CompositionTest* test) {
560 EXPECT_CALL(*test->mComposer,
561 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
562 IComposerClient::FRect({0.f, 0.f, 0.f, 0.f})))
563 .Times(1);
564 }
565
566 static void setupHwcSetPerFrameCallExpectations(CompositionTest* test) {
567 EXPECT_CALL(*test->mComposer,
568 setLayerVisibleRegion(HWC_DISPLAY, HWC_LAYER,
569 std::vector<IComposerClient::Rect>({IComposerClient::Rect(
570 {0, 0, LayerProperties::WIDTH,
571 LayerProperties::HEIGHT})})))
572 .Times(1);
573 }
574
575 static void setupHwcSetPerFrameColorCallExpectations(CompositionTest* test) {
576 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
577
578 // TODO: use COLOR
579 EXPECT_CALL(*test->mComposer,
580 setLayerColor(HWC_DISPLAY, HWC_LAYER,
581 IComposerClient::Color({0xff, 0xff, 0xff, 0xff})))
582 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700583 }
584
585 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
586 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
587 EXPECT_CALL(*test->mComposer, setLayerBuffer(HWC_DISPLAY, HWC_LAYER, _, _, _)).Times(1);
588
589 setupBufferLayerPostFrameCallExpectations(test);
590 }
591
592 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000593 EXPECT_CALL(*test->mRenderEngine, drawLayers)
594 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
595 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700596 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800597 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000598 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
599 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
600 displaySettings.physicalDisplay);
601 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
602 displaySettings.clip);
603 // screen capture adds an additional color layer as an alpha
604 // prefill, so gtet the back layer.
605 renderengine::LayerSettings layer = layerSettings.back();
606 EXPECT_THAT(layer.source.buffer.buffer, Not(IsNull()));
607 EXPECT_THAT(layer.source.buffer.fence, Not(IsNull()));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000608 EXPECT_EQ(DEFAULT_TEXTURE_ID, layer.source.buffer.textureName);
609 EXPECT_EQ(false, layer.source.buffer.isY410BT2020);
610 EXPECT_EQ(true, layer.source.buffer.usePremultipliedAlpha);
611 EXPECT_EQ(false, layer.source.buffer.isOpaque);
612 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
613 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
614 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
615 return NO_ERROR;
616 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700617 }
618
619 static void setupREBufferCompositionCallExpectations(CompositionTest* test) {
620 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700621 }
622
623 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
624 setupREBufferCompositionCallExpectations(test);
625 }
626
627 static void setupREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
628 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
629 }
630
631 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
632 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
633 }
634
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700635 static void setupREColorCompositionCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000636 EXPECT_CALL(*test->mRenderEngine, drawLayers)
637 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
638 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700639 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800640 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000641 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
642 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
643 displaySettings.physicalDisplay);
644 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
645 displaySettings.clip);
646 // screen capture adds an additional color layer as an alpha
647 // prefill, so get the back layer.
648 renderengine::LayerSettings layer = layerSettings.back();
649 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
650 EXPECT_EQ(half3(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
651 LayerProperties::COLOR[2]),
652 layer.source.solidColor);
653 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
654 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
655 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
656 return NO_ERROR;
657 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700658 }
659
660 static void setupREColorScreenshotCompositionCallExpectations(CompositionTest* test) {
661 setupREColorCompositionCallExpectations(test);
662 }
663};
664
665struct DefaultLayerProperties : public BaseLayerProperties<DefaultLayerProperties> {};
666
667struct ColorLayerProperties : public BaseLayerProperties<ColorLayerProperties> {};
668
669struct SidebandLayerProperties : public BaseLayerProperties<SidebandLayerProperties> {
670 using Base = BaseLayerProperties<SidebandLayerProperties>;
671 static constexpr IComposerClient::BlendMode BLENDMODE = IComposerClient::BlendMode::NONE;
672
673 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
674 sp<NativeHandle> stream =
675 NativeHandle::create(reinterpret_cast<native_handle_t*>(DEFAULT_SIDEBAND_STREAM),
676 false);
677 test->mFlinger.setLayerSidebandStream(layer, stream);
678 }
679
680 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
681 EXPECT_CALL(*test->mComposer,
682 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
683 IComposerClient::FRect({0.f, 0.f, -1.f, -1.f})))
684 .Times(1);
685 }
686
687 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
688 EXPECT_CALL(*test->mComposer,
689 setLayerSidebandStream(HWC_DISPLAY, HWC_LAYER,
690 reinterpret_cast<native_handle_t*>(
691 DEFAULT_SIDEBAND_STREAM)))
692 .WillOnce(Return(Error::NONE));
693
694 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
695 }
696
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000697 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* /*test*/) {}
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700698};
699
700struct SecureLayerProperties : public BaseLayerProperties<SecureLayerProperties> {
701 using Base = BaseLayerProperties<SecureLayerProperties>;
702
703 static constexpr uint32_t LAYER_FLAGS = ISurfaceComposerClient::eSecure;
704
705 static void setupInsecureREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000706 EXPECT_CALL(*test->mRenderEngine, drawLayers)
707 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
708 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700709 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800710 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000711 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
712 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
713 displaySettings.physicalDisplay);
714 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
715 displaySettings.clip);
716 // screen capture adds an additional color layer as an alpha
717 // prefill, so get the back layer.
718 renderengine::LayerSettings layer = layerSettings.back();
719 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
720 EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), layer.source.solidColor);
721 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
722 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
723 EXPECT_EQ(1.0f, layer.alpha);
724 return NO_ERROR;
725 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700726 }
727
728 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
729 setupInsecureREBufferCompositionCommonCallExpectations(test);
730 Base::setupBufferLayerPostFrameCallExpectations(test);
731 }
732
733 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
734 setupInsecureREBufferCompositionCommonCallExpectations(test);
735 }
736};
737
738struct CursorLayerProperties : public BaseLayerProperties<CursorLayerProperties> {
739 using Base = BaseLayerProperties<CursorLayerProperties>;
740
741 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
742 Base::setupLayerState(test, layer);
743 test->mFlinger.setLayerPotentialCursor(layer, true);
744 }
745};
746
747struct NoLayerVariant {
748 using FlingerLayerType = sp<BufferQueueLayer>;
749
750 static FlingerLayerType createLayer(CompositionTest*) { return FlingerLayerType(); }
751 static void injectLayer(CompositionTest*, FlingerLayerType) {}
752 static void cleanupInjectedLayers(CompositionTest*) {}
753
754 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
755 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
756};
757
758template <typename LayerProperties>
759struct BaseLayerVariant {
760 template <typename L, typename F>
761 static sp<L> createLayerWithFactory(CompositionTest* test, F factory) {
762 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(0);
763
764 sp<L> layer = factory();
765
766 Mock::VerifyAndClear(test->mComposer);
767 Mock::VerifyAndClear(test->mRenderEngine);
768 Mock::VerifyAndClear(test->mMessageQueue);
769
770 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
771 layerDrawingState.layerStack = DEFAULT_LAYER_STACK;
772 layerDrawingState.active.w = 100;
773 layerDrawingState.active.h = 100;
774 layerDrawingState.color = half4(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
775 LayerProperties::COLOR[2], LayerProperties::COLOR[3]);
Vishnu Nair4351ad52019-02-11 14:13:02 -0800776 layer->computeBounds(FloatRect(0, 0, 100, 100), ui::Transform());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700777 layer->setVisibleRegion(Region(Rect(0, 0, 100, 100)));
778
779 return layer;
780 }
781
782 static void injectLayer(CompositionTest* test, sp<Layer> layer) {
783 EXPECT_CALL(*test->mComposer, createLayer(HWC_DISPLAY, _))
784 .WillOnce(DoAll(SetArgPointee<1>(HWC_LAYER), Return(Error::NONE)));
785
Lloyd Pique07e33212018-12-18 16:33:37 -0800786 std::vector<std::unique_ptr<compositionengine::OutputLayer>> outputLayers;
787 outputLayers.emplace_back(test->mDisplay->getCompositionDisplay()
788 ->getOrCreateOutputLayer(DEFAULT_DISPLAY_ID,
789 layer->getCompositionLayer(),
790 layer));
791
792 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(std::move(outputLayers));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700793
794 Mock::VerifyAndClear(test->mComposer);
795
796 Vector<sp<Layer>> layers;
797 layers.add(layer);
798 test->mDisplay->setVisibleLayersSortedByZ(layers);
799 test->mFlinger.mutableDrawingState().layersSortedByZ.add(layer);
800 }
801
802 static void cleanupInjectedLayers(CompositionTest* test) {
803 EXPECT_CALL(*test->mComposer, destroyLayer(HWC_DISPLAY, HWC_LAYER))
804 .WillOnce(Return(Error::NONE));
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800805
806 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(
807 std::vector<std::unique_ptr<compositionengine::OutputLayer>>());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700808 test->mFlinger.mutableDrawingState().layersSortedByZ.clear();
809 }
810};
811
812template <typename LayerProperties>
813struct ColorLayerVariant : public BaseLayerVariant<LayerProperties> {
814 using Base = BaseLayerVariant<LayerProperties>;
815 using FlingerLayerType = sp<ColorLayer>;
816
817 static FlingerLayerType createLayer(CompositionTest* test) {
818 FlingerLayerType layer = Base::template createLayerWithFactory<ColorLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700819 return new ColorLayer(LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
820 String8("test-layer"), LayerProperties::WIDTH,
821 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800822 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700823 });
Vishnu Nair60356342018-11-13 13:00:45 -0800824
825 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
826 layerDrawingState.crop_legacy = Rect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700827 return layer;
828 }
829
830 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700831 LayerProperties::setupREColorCompositionCallExpectations(test);
832 }
833
834 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
835 LayerProperties::setupREColorScreenshotCompositionCallExpectations(test);
836 }
837
838 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
839 LayerProperties::setupHwcSetGeometryCallExpectations(test);
840 LayerProperties::setupHwcSetSourceCropColorCallExpectations(test);
841 }
842
843 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
844 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
845 LayerProperties::setupHwcSetPerFrameColorCallExpectations(test);
846 }
847};
848
849template <typename LayerProperties>
850struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> {
851 using Base = BaseLayerVariant<LayerProperties>;
852 using FlingerLayerType = sp<BufferQueueLayer>;
853
854 static FlingerLayerType createLayer(CompositionTest* test) {
855 test->mFlinger.mutableTexturePool().push_back(DEFAULT_TEXTURE_ID);
856
857 FlingerLayerType layer =
858 Base::template createLayerWithFactory<BufferQueueLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700859 return new BufferQueueLayer(
860 LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
861 String8("test-layer"), LayerProperties::WIDTH,
862 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800863 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700864 });
865
866 LayerProperties::setupLayerState(test, layer);
867
868 return layer;
869 }
870
871 static void cleanupInjectedLayers(CompositionTest* test) {
Dan Stoza67765d82019-05-07 14:58:27 -0700872 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700873 Base::cleanupInjectedLayers(test);
874 }
875
876 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
877 LayerProperties::setupHwcSetGeometryCallExpectations(test);
878 LayerProperties::setupHwcSetSourceCropBufferCallExpectations(test);
879 }
880
881 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
882 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
883 LayerProperties::setupHwcSetPerFrameBufferCallExpectations(test);
884 }
885
886 static void setupRECompositionCallExpectations(CompositionTest* test) {
887 LayerProperties::setupREBufferCompositionCallExpectations(test);
888 }
889
890 static void setupInsecureRECompositionCallExpectations(CompositionTest* test) {
891 LayerProperties::setupInsecureREBufferCompositionCallExpectations(test);
892 }
893
894 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
895 LayerProperties::setupREBufferScreenshotCompositionCallExpectations(test);
896 }
897
898 static void setupInsecureREScreenshotCompositionCallExpectations(CompositionTest* test) {
899 LayerProperties::setupInsecureREBufferScreenshotCompositionCallExpectations(test);
900 }
901};
902
903/* ------------------------------------------------------------------------
904 * Variants to control how the composition type is changed
905 */
906
907struct NoCompositionTypeVariant {
908 static void setupHwcSetCallExpectations(CompositionTest*) {}
909
910 static void setupHwcGetCallExpectations(CompositionTest* test) {
911 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
912 }
913};
914
915template <IComposerClient::Composition CompositionType>
916struct KeepCompositionTypeVariant {
917 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(CompositionType);
918
919 static void setupHwcSetCallExpectations(CompositionTest* test) {
920 EXPECT_CALL(*test->mComposer,
921 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, CompositionType))
922 .Times(1);
923 }
924
925 static void setupHwcGetCallExpectations(CompositionTest* test) {
926 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
927 }
928};
929
930template <IComposerClient::Composition InitialCompositionType,
931 IComposerClient::Composition FinalCompositionType>
932struct ChangeCompositionTypeVariant {
933 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(FinalCompositionType);
934
935 static void setupHwcSetCallExpectations(CompositionTest* test) {
936 EXPECT_CALL(*test->mComposer,
937 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, InitialCompositionType))
938 .Times(1);
939 }
940
941 static void setupHwcGetCallExpectations(CompositionTest* test) {
942 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _))
943 .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::Layer>{
944 static_cast<Hwc2::Layer>(HWC_LAYER)}),
945 SetArgPointee<2>(std::vector<IComposerClient::Composition>{
946 FinalCompositionType}),
947 Return(Error::NONE)));
948 }
949};
950
951/* ------------------------------------------------------------------------
952 * Variants to select how the composition is expected to be handled
953 */
954
955struct CompositionResultBaseVariant {
956 static void setupLayerState(CompositionTest*, sp<Layer>) {}
957
958 template <typename Case>
959 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
960 Case::Layer::setupCallExpectationsForDirtyGeometry(test);
961 }
962
963 template <typename Case>
964 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
965 Case::Layer::setupCallExpectationsForDirtyFrame(test);
966 }
967};
968
969struct NoCompositionResultVariant : public CompositionResultBaseVariant {
970 template <typename Case>
971 static void setupCallExpectations(CompositionTest* test) {
972 Case::Display::setupEmptyFrameCompositionCallExpectations(test);
973 Case::Display::setupHwcCompositionCallExpectations(test);
974 }
975};
976
977struct HwcCompositionResultVariant : public CompositionResultBaseVariant {
978 template <typename Case>
979 static void setupCallExpectations(CompositionTest* test) {
980 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
981 Case::Display::setupHwcCompositionCallExpectations(test);
982 }
983};
984
985struct RECompositionResultVariant : public CompositionResultBaseVariant {
986 template <typename Case>
987 static void setupCallExpectations(CompositionTest* test) {
988 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
989 Case::Display::setupRECompositionCallExpectations(test);
990 Case::Display::template setupRELayerCompositionCallExpectations<Case>(test);
991 }
992};
993
994struct ForcedClientCompositionResultVariant : public RECompositionResultVariant {
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800995 static void setupLayerState(CompositionTest* test, sp<Layer> layer) {
996 layer->forceClientComposition(test->mDisplay);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700997 }
998
999 template <typename Case>
1000 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
1001
1002 template <typename Case>
1003 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
1004};
1005
1006struct EmptyScreenshotResultVariant {
1007 static void setupLayerState(CompositionTest*, sp<Layer>) {}
1008
1009 template <typename Case>
1010 static void setupCallExpectations(CompositionTest*) {}
1011};
1012
1013struct REScreenshotResultVariant : public EmptyScreenshotResultVariant {
1014 using Base = EmptyScreenshotResultVariant;
1015
1016 template <typename Case>
1017 static void setupCallExpectations(CompositionTest* test) {
1018 Base::template setupCallExpectations<Case>(test);
1019 Case::Display::template setupRELayerScreenshotCompositionCallExpectations<Case>(test);
1020 }
1021};
1022
1023/* ------------------------------------------------------------------------
1024 * Composition test case, containing all the variants being tested
1025 */
1026
1027template <typename DisplayCase, typename LayerCase, typename CompositionTypeCase,
1028 typename CompositionResultCase>
1029struct CompositionCase {
1030 using ThisCase =
1031 CompositionCase<DisplayCase, LayerCase, CompositionTypeCase, CompositionResultCase>;
1032 using Display = DisplayCase;
1033 using Layer = LayerCase;
1034 using CompositionType = CompositionTypeCase;
1035 using CompositionResult = CompositionResultCase;
1036
1037 static void setupCommon(CompositionTest* test) {
Peiyong Lin1336e6e2019-05-28 09:23:50 -07001038 Display::template setupPreconditionCallExpectations<ThisCase>(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001039 Display::setupPreconditions(test);
1040
1041 auto layer = Layer::createLayer(test);
1042 Layer::injectLayer(test, layer);
1043 CompositionResult::setupLayerState(test, layer);
1044 }
1045
1046 static void setupForDirtyGeometry(CompositionTest* test) {
1047 setupCommon(test);
1048
1049 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1050 CompositionResult::template setupCallExpectationsForDirtyGeometry<ThisCase>(test);
1051 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1052 CompositionResult::template setupCallExpectations<ThisCase>(test);
1053 }
1054
1055 static void setupForDirtyFrame(CompositionTest* test) {
1056 setupCommon(test);
1057
1058 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1059 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1060 CompositionResult::template setupCallExpectations<ThisCase>(test);
1061 }
1062
1063 static void setupForScreenCapture(CompositionTest* test) {
1064 setupCommon(test);
1065
1066 Display::template setupCommonScreensCaptureCallExpectations<ThisCase>(test);
1067 CompositionResult::template setupCallExpectations<ThisCase>(test);
1068 }
1069
1070 static void cleanup(CompositionTest* test) {
1071 Layer::cleanupInjectedLayers(test);
1072
1073 for (auto& hwcDisplay : test->mFlinger.mFakeHwcDisplays) {
1074 hwcDisplay->mutableLayers().clear();
1075 }
1076
1077 test->mDisplay->setVisibleLayersSortedByZ(Vector<sp<android::Layer>>());
1078 }
1079};
1080
1081/* ------------------------------------------------------------------------
1082 * Composition cases to test
1083 */
1084
1085TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyGeometry) {
1086 displayRefreshCompositionDirtyGeometry<
1087 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1088 NoCompositionResultVariant>>();
1089}
1090
1091TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyFrame) {
1092 displayRefreshCompositionDirtyFrame<
1093 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1094 NoCompositionResultVariant>>();
1095}
1096
1097TEST_F(CompositionTest, noLayersDoesMinimalWorkToCaptureScreen) {
1098 captureScreenComposition<
1099 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1100 EmptyScreenshotResultVariant>>();
1101}
1102
1103/* ------------------------------------------------------------------------
1104 * Simple buffer layers
1105 */
1106
1107TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyGeometry) {
1108 displayRefreshCompositionDirtyGeometry<
1109 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1110 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1111 HwcCompositionResultVariant>>();
1112}
1113
1114TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyFrame) {
1115 displayRefreshCompositionDirtyFrame<
1116 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1117 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1118 HwcCompositionResultVariant>>();
1119}
1120
1121TEST_F(CompositionTest, REComposedNormalBufferLayer) {
1122 displayRefreshCompositionDirtyFrame<
1123 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1124 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1125 IComposerClient::Composition::CLIENT>,
1126 RECompositionResultVariant>>();
1127}
1128
1129TEST_F(CompositionTest, captureScreenNormalBufferLayer) {
1130 captureScreenComposition<
1131 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1132 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1133}
1134
1135/* ------------------------------------------------------------------------
1136 * Single-color layers
1137 */
1138
1139TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyGeometry) {
1140 displayRefreshCompositionDirtyGeometry<
1141 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1142 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1143 HwcCompositionResultVariant>>();
1144}
1145
1146TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyFrame) {
1147 displayRefreshCompositionDirtyFrame<
1148 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1149 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1150 HwcCompositionResultVariant>>();
1151}
1152
1153TEST_F(CompositionTest, REComposedColorLayer) {
1154 displayRefreshCompositionDirtyFrame<
1155 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1156 ChangeCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR,
1157 IComposerClient::Composition::CLIENT>,
1158 RECompositionResultVariant>>();
1159}
1160
1161TEST_F(CompositionTest, captureScreenColorLayer) {
1162 captureScreenComposition<
1163 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1164 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1165}
1166
1167/* ------------------------------------------------------------------------
1168 * Layers with sideband buffers
1169 */
1170
1171TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyGeometry) {
1172 displayRefreshCompositionDirtyGeometry<
1173 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1174 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1175 HwcCompositionResultVariant>>();
1176}
1177
1178TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyFrame) {
1179 displayRefreshCompositionDirtyFrame<
1180 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1181 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1182 HwcCompositionResultVariant>>();
1183}
1184
1185TEST_F(CompositionTest, REComposedSidebandBufferLayer) {
1186 displayRefreshCompositionDirtyFrame<
1187 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1188 ChangeCompositionTypeVariant<IComposerClient::Composition::SIDEBAND,
1189 IComposerClient::Composition::CLIENT>,
1190 RECompositionResultVariant>>();
1191}
1192
1193TEST_F(CompositionTest, captureScreenSidebandBufferLayer) {
1194 captureScreenComposition<
1195 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1196 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1197}
1198
1199/* ------------------------------------------------------------------------
1200 * Layers with ISurfaceComposerClient::eSecure, on a secure display
1201 */
1202
1203TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyGeometry) {
1204 displayRefreshCompositionDirtyGeometry<
1205 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1206 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1207 HwcCompositionResultVariant>>();
1208}
1209
1210TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyFrame) {
1211 displayRefreshCompositionDirtyFrame<
1212 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1213 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1214 HwcCompositionResultVariant>>();
1215}
1216
1217TEST_F(CompositionTest, REComposedSecureBufferLayer) {
1218 displayRefreshCompositionDirtyFrame<
1219 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1220 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1221 IComposerClient::Composition::CLIENT>,
1222 RECompositionResultVariant>>();
1223}
1224
1225TEST_F(CompositionTest, captureScreenSecureBufferLayerOnSecureDisplay) {
1226 captureScreenComposition<
1227 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1228 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1229}
1230
1231/* ------------------------------------------------------------------------
1232 * Layers with ISurfaceComposerClient::eSecure, on a non-secure display
1233 */
1234
1235TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyGeometry) {
1236 displayRefreshCompositionDirtyGeometry<
1237 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1238 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1239 ForcedClientCompositionResultVariant>>();
1240}
1241
1242TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyFrame) {
1243 displayRefreshCompositionDirtyFrame<
1244 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1245 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1246 ForcedClientCompositionResultVariant>>();
1247}
1248
1249TEST_F(CompositionTest, captureScreenSecureBufferLayerOnInsecureDisplay) {
1250 captureScreenComposition<
1251 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1252 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1253}
1254
1255/* ------------------------------------------------------------------------
1256 * Cursor layers
1257 */
1258
1259TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyGeometry) {
1260 displayRefreshCompositionDirtyGeometry<
1261 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1262 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1263 HwcCompositionResultVariant>>();
1264}
1265
1266TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyFrame) {
1267 displayRefreshCompositionDirtyFrame<
1268 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1269 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1270 HwcCompositionResultVariant>>();
1271}
1272
1273TEST_F(CompositionTest, REComposedCursorLayer) {
1274 displayRefreshCompositionDirtyFrame<
1275 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1276 ChangeCompositionTypeVariant<IComposerClient::Composition::CURSOR,
1277 IComposerClient::Composition::CLIENT>,
1278 RECompositionResultVariant>>();
1279}
1280
1281TEST_F(CompositionTest, captureScreenCursorLayer) {
1282 captureScreenComposition<
1283 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1284 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1285}
1286
1287/* ------------------------------------------------------------------------
1288 * Simple buffer layer on a display which is powered off.
1289 */
1290
1291TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyGeometry) {
1292 displayRefreshCompositionDirtyGeometry<CompositionCase<
1293 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1294 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1295 HwcCompositionResultVariant>>();
1296}
1297
1298TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyFrame) {
1299 displayRefreshCompositionDirtyFrame<CompositionCase<
1300 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1301 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1302 HwcCompositionResultVariant>>();
1303}
1304
1305TEST_F(CompositionTest, displayOffREComposedNormalBufferLayer) {
1306 displayRefreshCompositionDirtyFrame<CompositionCase<
1307 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1308 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1309 IComposerClient::Composition::CLIENT>,
1310 RECompositionResultVariant>>();
1311}
1312
1313TEST_F(CompositionTest, captureScreenNormalBufferLayerOnPoweredOffDisplay) {
1314 captureScreenComposition<CompositionCase<
1315 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1316 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1317}
1318
1319} // namespace
1320} // namespace android