blob: 0f21ad86d80d4eecb4d12cc05b244f8b9f4ffddf [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));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700306
307 EXPECT_CALL(*test->mDisplaySurface, onFrameCommitted()).Times(1);
308 EXPECT_CALL(*test->mDisplaySurface, advanceFrame()).Times(1);
309
310 Case::CompositionType::setupHwcSetCallExpectations(test);
311 Case::CompositionType::setupHwcGetCallExpectations(test);
312 }
313
314 template <typename Case>
315 static void setupCommonScreensCaptureCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000316 EXPECT_CALL(*test->mRenderEngine, drawLayers)
317 .WillRepeatedly(
318 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700319 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
320 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000321 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
322 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
323 displaySettings.physicalDisplay);
324 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
325 displaySettings.clip);
326 return NO_ERROR;
327 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700328 }
329
330 static void setupNonEmptyFrameCompositionCallExpectations(CompositionTest* test) {
331 EXPECT_CALL(*test->mDisplaySurface, beginFrame(true)).Times(1);
332 }
333
334 static void setupEmptyFrameCompositionCallExpectations(CompositionTest* test) {
335 EXPECT_CALL(*test->mDisplaySurface, beginFrame(false)).Times(1);
336 }
337
338 static void setupHwcCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique542307f2018-10-19 13:24:08 -0700339 EXPECT_CALL(*test->mDisplaySurface,
340 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_HWC))
341 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700342 }
343
344 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique542307f2018-10-19 13:24:08 -0700345 EXPECT_CALL(*test->mDisplaySurface,
346 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_GLES))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700347 .Times(1);
348 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
349 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
350
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800351 EXPECT_CALL(*test->mNativeWindow, queueBuffer(_, _)).WillOnce(Return(0));
352 EXPECT_CALL(*test->mNativeWindow, dequeueBuffer(_, _))
353 .WillOnce(DoAll(SetArgPointee<0>(test->mNativeWindowBuffer), SetArgPointee<1>(-1),
354 Return(0)));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000355 EXPECT_CALL(*test->mRenderEngine, drawLayers)
356 .WillRepeatedly(
357 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700358 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
359 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000360 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
361 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
362 displaySettings.physicalDisplay);
363 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
364 displaySettings.clip);
365 EXPECT_EQ(ui::Dataspace::UNKNOWN, displaySettings.outputDataspace);
366 return NO_ERROR;
367 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700368 }
369
370 template <typename Case>
371 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
372 Case::Layer::setupRECompositionCallExpectations(test);
373 }
374
375 template <typename Case>
376 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
377 Case::Layer::setupREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700378 }
379};
380
381struct DefaultDisplaySetupVariant : public BaseDisplayVariant<DefaultDisplaySetupVariant> {};
382
383struct InsecureDisplaySetupVariant : public BaseDisplayVariant<InsecureDisplaySetupVariant> {
384 static constexpr bool IS_SECURE = false;
385
386 template <typename Case>
387 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
388 Case::Layer::setupInsecureRECompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700389 }
390
391 template <typename Case>
392 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
393 Case::Layer::setupInsecureREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700394 }
395};
396
397struct PoweredOffDisplaySetupVariant : public BaseDisplayVariant<PoweredOffDisplaySetupVariant> {
398 static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_OFF;
399
400 template <typename Case>
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700401 static void setupPreconditionCallExpectations(CompositionTest*) {}
402
403 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700404 static void setupCommonCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800405 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
406
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700407 // TODO: This seems like an unnecessary call if display is powered off.
408 EXPECT_CALL(*test->mComposer,
409 setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
410 .Times(1);
411
412 // TODO: This seems like an unnecessary call if display is powered off.
413 Case::CompositionType::setupHwcSetCallExpectations(test);
414 }
415
416 static void setupHwcCompositionCallExpectations(CompositionTest*) {}
417
418 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800419 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
420
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700421 // TODO: This seems like an unnecessary call if display is powered off.
422 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
423 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
424 }
425
426 template <typename Case>
427 static void setupRELayerCompositionCallExpectations(CompositionTest*) {}
428};
429
430/* ------------------------------------------------------------------------
431 * Variants for each layer configuration which can be tested
432 */
433
434template <typename LayerProperties>
435struct BaseLayerProperties {
436 static constexpr uint32_t WIDTH = 100;
437 static constexpr uint32_t HEIGHT = 100;
438 static constexpr PixelFormat FORMAT = PIXEL_FORMAT_RGBA_8888;
439 static constexpr uint64_t USAGE =
440 GraphicBuffer::USAGE_SW_READ_NEVER | GraphicBuffer::USAGE_SW_WRITE_NEVER;
441 static constexpr android_dataspace DATASPACE = HAL_DATASPACE_UNKNOWN;
442 static constexpr uint32_t SCALING_MODE = 0;
443 static constexpr uint32_t TRANSFORM = 0;
444 static constexpr uint32_t LAYER_FLAGS = 0;
445 static constexpr float COLOR[] = {1.f, 1.f, 1.f, 1.f};
446 static constexpr IComposerClient::BlendMode BLENDMODE =
447 IComposerClient::BlendMode::PREMULTIPLIED;
448
449 static void enqueueBuffer(CompositionTest*, sp<BufferQueueLayer> layer) {
450 auto producer = layer->getProducer();
451
452 IGraphicBufferProducer::QueueBufferOutput qbo;
453 status_t result = producer->connect(nullptr, NATIVE_WINDOW_API_EGL, false, &qbo);
454 if (result != NO_ERROR) {
455 ALOGE("Failed to connect() (%d)", result);
456 return;
457 }
458
459 int slot;
460 sp<Fence> fence;
461 result = producer->dequeueBuffer(&slot, &fence, LayerProperties::WIDTH,
462 LayerProperties::HEIGHT, LayerProperties::FORMAT,
463 LayerProperties::USAGE, nullptr, nullptr);
464 if (result != IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
465 ALOGE("Failed to dequeueBuffer() (%d)", result);
466 return;
467 }
468
469 sp<GraphicBuffer> buffer;
470 result = producer->requestBuffer(slot, &buffer);
471 if (result != NO_ERROR) {
472 ALOGE("Failed to requestBuffer() (%d)", result);
473 return;
474 }
475
476 IGraphicBufferProducer::QueueBufferInput qbi(systemTime(), false /* isAutoTimestamp */,
477 LayerProperties::DATASPACE,
478 Rect(LayerProperties::WIDTH,
479 LayerProperties::HEIGHT),
480 LayerProperties::SCALING_MODE,
481 LayerProperties::TRANSFORM, Fence::NO_FENCE);
482 result = producer->queueBuffer(slot, qbi, &qbo);
483 if (result != NO_ERROR) {
484 ALOGE("Failed to queueBuffer (%d)", result);
485 return;
486 }
487 }
488
489 static void setupLatchedBuffer(CompositionTest* test, sp<BufferQueueLayer> layer) {
490 // TODO: Eliminate the complexity of actually creating a buffer
491 EXPECT_CALL(*test->mRenderEngine, getMaxTextureSize()).WillOnce(Return(16384));
492 EXPECT_CALL(*test->mRenderEngine, getMaxViewportDims()).WillOnce(Return(16384));
493 status_t err =
494 layer->setDefaultBufferProperties(LayerProperties::WIDTH, LayerProperties::HEIGHT,
495 LayerProperties::FORMAT);
496 ASSERT_EQ(NO_ERROR, err);
497 Mock::VerifyAndClear(test->mRenderEngine);
498
499 EXPECT_CALL(*test->mMessageQueue, invalidate()).Times(1);
500 enqueueBuffer(test, layer);
501 Mock::VerifyAndClear(test->mMessageQueue);
502
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700503 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700504 bool ignoredRecomputeVisibleRegions;
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700505 layer->latchBuffer(ignoredRecomputeVisibleRegions, 0, 0);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700506 Mock::VerifyAndClear(test->mRenderEngine);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700507 }
508
509 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
510 setupLatchedBuffer(test, layer);
511 }
512
513 static void setupBufferLayerPostFrameCallExpectations(CompositionTest* test) {
514 // BufferLayer::onPostComposition(), when there is no present fence
515 EXPECT_CALL(*test->mComposer, getActiveConfig(HWC_DISPLAY, _))
516 .WillOnce(DoAll(SetArgPointee<1>(DEFAULT_CONFIG_ID), Return(Error::NONE)));
517 }
518
519 static void setupHwcSetGeometryCallExpectations(CompositionTest* test) {
520 // TODO: Coverage of other values
521 EXPECT_CALL(*test->mComposer,
522 setLayerBlendMode(HWC_DISPLAY, HWC_LAYER, LayerProperties::BLENDMODE))
523 .Times(1);
524 // TODO: Coverage of other values for origin
525 EXPECT_CALL(*test->mComposer,
526 setLayerDisplayFrame(HWC_DISPLAY, HWC_LAYER,
527 IComposerClient::Rect({0, 0, LayerProperties::WIDTH,
528 LayerProperties::HEIGHT})))
529 .Times(1);
530 EXPECT_CALL(*test->mComposer,
531 setLayerPlaneAlpha(HWC_DISPLAY, HWC_LAYER, LayerProperties::COLOR[3]))
532 .Times(1);
533 // TODO: Coverage of other values
534 EXPECT_CALL(*test->mComposer, setLayerZOrder(HWC_DISPLAY, HWC_LAYER, 0u)).Times(1);
535 // TODO: Coverage of other values
536 EXPECT_CALL(*test->mComposer, setLayerInfo(HWC_DISPLAY, HWC_LAYER, 0u, 0u)).Times(1);
537
538 // These expectations retire on saturation as the code path these
539 // expectations are for appears to make an extra call to them.
540 // TODO: Investigate this extra call
541 EXPECT_CALL(*test->mComposer, setLayerTransform(HWC_DISPLAY, HWC_LAYER, DEFAULT_TRANSFORM))
David Sodman15094112018-10-11 09:39:37 -0700542 .Times(AtLeast(1))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700543 .RetiresOnSaturation();
544 }
545
546 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
547 EXPECT_CALL(*test->mComposer,
548 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
549 IComposerClient::FRect({0.f, 0.f, LayerProperties::WIDTH,
550 LayerProperties::HEIGHT})))
551 .Times(1);
552 }
553
554 static void setupHwcSetSourceCropColorCallExpectations(CompositionTest* test) {
555 EXPECT_CALL(*test->mComposer,
556 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
557 IComposerClient::FRect({0.f, 0.f, 0.f, 0.f})))
558 .Times(1);
559 }
560
561 static void setupHwcSetPerFrameCallExpectations(CompositionTest* test) {
562 EXPECT_CALL(*test->mComposer,
563 setLayerVisibleRegion(HWC_DISPLAY, HWC_LAYER,
564 std::vector<IComposerClient::Rect>({IComposerClient::Rect(
565 {0, 0, LayerProperties::WIDTH,
566 LayerProperties::HEIGHT})})))
567 .Times(1);
568 }
569
570 static void setupHwcSetPerFrameColorCallExpectations(CompositionTest* test) {
571 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
572
573 // TODO: use COLOR
574 EXPECT_CALL(*test->mComposer,
575 setLayerColor(HWC_DISPLAY, HWC_LAYER,
576 IComposerClient::Color({0xff, 0xff, 0xff, 0xff})))
577 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700578 }
579
580 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
581 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
582 EXPECT_CALL(*test->mComposer, setLayerBuffer(HWC_DISPLAY, HWC_LAYER, _, _, _)).Times(1);
583
584 setupBufferLayerPostFrameCallExpectations(test);
585 }
586
587 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000588 EXPECT_CALL(*test->mRenderEngine, drawLayers)
589 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
590 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700591 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800592 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000593 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
594 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
595 displaySettings.physicalDisplay);
596 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
597 displaySettings.clip);
598 // screen capture adds an additional color layer as an alpha
599 // prefill, so gtet the back layer.
600 renderengine::LayerSettings layer = layerSettings.back();
601 EXPECT_THAT(layer.source.buffer.buffer, Not(IsNull()));
602 EXPECT_THAT(layer.source.buffer.fence, Not(IsNull()));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000603 EXPECT_EQ(DEFAULT_TEXTURE_ID, layer.source.buffer.textureName);
604 EXPECT_EQ(false, layer.source.buffer.isY410BT2020);
605 EXPECT_EQ(true, layer.source.buffer.usePremultipliedAlpha);
606 EXPECT_EQ(false, layer.source.buffer.isOpaque);
607 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
608 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
609 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
610 return NO_ERROR;
611 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700612 }
613
614 static void setupREBufferCompositionCallExpectations(CompositionTest* test) {
615 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700616 }
617
618 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
619 setupREBufferCompositionCallExpectations(test);
620 }
621
622 static void setupREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
623 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
624 }
625
626 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
627 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
628 }
629
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700630 static void setupREColorCompositionCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000631 EXPECT_CALL(*test->mRenderEngine, drawLayers)
632 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
633 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700634 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800635 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000636 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
637 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
638 displaySettings.physicalDisplay);
639 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
640 displaySettings.clip);
641 // screen capture adds an additional color layer as an alpha
642 // prefill, so get the back layer.
643 renderengine::LayerSettings layer = layerSettings.back();
644 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
645 EXPECT_EQ(half3(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
646 LayerProperties::COLOR[2]),
647 layer.source.solidColor);
648 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
649 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
650 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
651 return NO_ERROR;
652 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700653 }
654
655 static void setupREColorScreenshotCompositionCallExpectations(CompositionTest* test) {
656 setupREColorCompositionCallExpectations(test);
657 }
658};
659
660struct DefaultLayerProperties : public BaseLayerProperties<DefaultLayerProperties> {};
661
662struct ColorLayerProperties : public BaseLayerProperties<ColorLayerProperties> {};
663
664struct SidebandLayerProperties : public BaseLayerProperties<SidebandLayerProperties> {
665 using Base = BaseLayerProperties<SidebandLayerProperties>;
666 static constexpr IComposerClient::BlendMode BLENDMODE = IComposerClient::BlendMode::NONE;
667
668 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
669 sp<NativeHandle> stream =
670 NativeHandle::create(reinterpret_cast<native_handle_t*>(DEFAULT_SIDEBAND_STREAM),
671 false);
672 test->mFlinger.setLayerSidebandStream(layer, stream);
673 }
674
675 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
676 EXPECT_CALL(*test->mComposer,
677 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
678 IComposerClient::FRect({0.f, 0.f, -1.f, -1.f})))
679 .Times(1);
680 }
681
682 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
683 EXPECT_CALL(*test->mComposer,
684 setLayerSidebandStream(HWC_DISPLAY, HWC_LAYER,
685 reinterpret_cast<native_handle_t*>(
686 DEFAULT_SIDEBAND_STREAM)))
687 .WillOnce(Return(Error::NONE));
688
689 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
690 }
691
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000692 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* /*test*/) {}
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700693};
694
695struct SecureLayerProperties : public BaseLayerProperties<SecureLayerProperties> {
696 using Base = BaseLayerProperties<SecureLayerProperties>;
697
698 static constexpr uint32_t LAYER_FLAGS = ISurfaceComposerClient::eSecure;
699
700 static void setupInsecureREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000701 EXPECT_CALL(*test->mRenderEngine, drawLayers)
702 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
703 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700704 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800705 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000706 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
707 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
708 displaySettings.physicalDisplay);
709 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
710 displaySettings.clip);
711 // screen capture adds an additional color layer as an alpha
712 // prefill, so get the back layer.
713 renderengine::LayerSettings layer = layerSettings.back();
714 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
715 EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), layer.source.solidColor);
716 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
717 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
718 EXPECT_EQ(1.0f, layer.alpha);
719 return NO_ERROR;
720 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700721 }
722
723 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
724 setupInsecureREBufferCompositionCommonCallExpectations(test);
725 Base::setupBufferLayerPostFrameCallExpectations(test);
726 }
727
728 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
729 setupInsecureREBufferCompositionCommonCallExpectations(test);
730 }
731};
732
733struct CursorLayerProperties : public BaseLayerProperties<CursorLayerProperties> {
734 using Base = BaseLayerProperties<CursorLayerProperties>;
735
736 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
737 Base::setupLayerState(test, layer);
738 test->mFlinger.setLayerPotentialCursor(layer, true);
739 }
740};
741
742struct NoLayerVariant {
743 using FlingerLayerType = sp<BufferQueueLayer>;
744
745 static FlingerLayerType createLayer(CompositionTest*) { return FlingerLayerType(); }
746 static void injectLayer(CompositionTest*, FlingerLayerType) {}
747 static void cleanupInjectedLayers(CompositionTest*) {}
748
749 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
750 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
751};
752
753template <typename LayerProperties>
754struct BaseLayerVariant {
755 template <typename L, typename F>
756 static sp<L> createLayerWithFactory(CompositionTest* test, F factory) {
757 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(0);
758
759 sp<L> layer = factory();
760
761 Mock::VerifyAndClear(test->mComposer);
762 Mock::VerifyAndClear(test->mRenderEngine);
763 Mock::VerifyAndClear(test->mMessageQueue);
764
765 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
766 layerDrawingState.layerStack = DEFAULT_LAYER_STACK;
767 layerDrawingState.active.w = 100;
768 layerDrawingState.active.h = 100;
769 layerDrawingState.color = half4(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
770 LayerProperties::COLOR[2], LayerProperties::COLOR[3]);
Vishnu Nair4351ad52019-02-11 14:13:02 -0800771 layer->computeBounds(FloatRect(0, 0, 100, 100), ui::Transform());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700772 layer->setVisibleRegion(Region(Rect(0, 0, 100, 100)));
773
774 return layer;
775 }
776
777 static void injectLayer(CompositionTest* test, sp<Layer> layer) {
778 EXPECT_CALL(*test->mComposer, createLayer(HWC_DISPLAY, _))
779 .WillOnce(DoAll(SetArgPointee<1>(HWC_LAYER), Return(Error::NONE)));
780
Lloyd Pique07e33212018-12-18 16:33:37 -0800781 std::vector<std::unique_ptr<compositionengine::OutputLayer>> outputLayers;
782 outputLayers.emplace_back(test->mDisplay->getCompositionDisplay()
783 ->getOrCreateOutputLayer(DEFAULT_DISPLAY_ID,
784 layer->getCompositionLayer(),
785 layer));
786
787 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(std::move(outputLayers));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700788
789 Mock::VerifyAndClear(test->mComposer);
790
791 Vector<sp<Layer>> layers;
792 layers.add(layer);
793 test->mDisplay->setVisibleLayersSortedByZ(layers);
794 test->mFlinger.mutableDrawingState().layersSortedByZ.add(layer);
795 }
796
797 static void cleanupInjectedLayers(CompositionTest* test) {
798 EXPECT_CALL(*test->mComposer, destroyLayer(HWC_DISPLAY, HWC_LAYER))
799 .WillOnce(Return(Error::NONE));
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800800
801 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(
802 std::vector<std::unique_ptr<compositionengine::OutputLayer>>());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700803 test->mFlinger.mutableDrawingState().layersSortedByZ.clear();
804 }
805};
806
807template <typename LayerProperties>
808struct ColorLayerVariant : public BaseLayerVariant<LayerProperties> {
809 using Base = BaseLayerVariant<LayerProperties>;
810 using FlingerLayerType = sp<ColorLayer>;
811
812 static FlingerLayerType createLayer(CompositionTest* test) {
813 FlingerLayerType layer = Base::template createLayerWithFactory<ColorLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700814 return new ColorLayer(LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
815 String8("test-layer"), LayerProperties::WIDTH,
816 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800817 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700818 });
Vishnu Nair60356342018-11-13 13:00:45 -0800819
820 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
821 layerDrawingState.crop_legacy = Rect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700822 return layer;
823 }
824
825 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700826 LayerProperties::setupREColorCompositionCallExpectations(test);
827 }
828
829 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
830 LayerProperties::setupREColorScreenshotCompositionCallExpectations(test);
831 }
832
833 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
834 LayerProperties::setupHwcSetGeometryCallExpectations(test);
835 LayerProperties::setupHwcSetSourceCropColorCallExpectations(test);
836 }
837
838 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
839 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
840 LayerProperties::setupHwcSetPerFrameColorCallExpectations(test);
841 }
842};
843
844template <typename LayerProperties>
845struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> {
846 using Base = BaseLayerVariant<LayerProperties>;
847 using FlingerLayerType = sp<BufferQueueLayer>;
848
849 static FlingerLayerType createLayer(CompositionTest* test) {
850 test->mFlinger.mutableTexturePool().push_back(DEFAULT_TEXTURE_ID);
851
852 FlingerLayerType layer =
853 Base::template createLayerWithFactory<BufferQueueLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700854 return new BufferQueueLayer(
855 LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
856 String8("test-layer"), LayerProperties::WIDTH,
857 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800858 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700859 });
860
861 LayerProperties::setupLayerState(test, layer);
862
863 return layer;
864 }
865
866 static void cleanupInjectedLayers(CompositionTest* test) {
Dan Stoza67765d82019-05-07 14:58:27 -0700867 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700868 Base::cleanupInjectedLayers(test);
869 }
870
871 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
872 LayerProperties::setupHwcSetGeometryCallExpectations(test);
873 LayerProperties::setupHwcSetSourceCropBufferCallExpectations(test);
874 }
875
876 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
877 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
878 LayerProperties::setupHwcSetPerFrameBufferCallExpectations(test);
879 }
880
881 static void setupRECompositionCallExpectations(CompositionTest* test) {
882 LayerProperties::setupREBufferCompositionCallExpectations(test);
883 }
884
885 static void setupInsecureRECompositionCallExpectations(CompositionTest* test) {
886 LayerProperties::setupInsecureREBufferCompositionCallExpectations(test);
887 }
888
889 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
890 LayerProperties::setupREBufferScreenshotCompositionCallExpectations(test);
891 }
892
893 static void setupInsecureREScreenshotCompositionCallExpectations(CompositionTest* test) {
894 LayerProperties::setupInsecureREBufferScreenshotCompositionCallExpectations(test);
895 }
896};
897
898/* ------------------------------------------------------------------------
899 * Variants to control how the composition type is changed
900 */
901
902struct NoCompositionTypeVariant {
903 static void setupHwcSetCallExpectations(CompositionTest*) {}
904
905 static void setupHwcGetCallExpectations(CompositionTest* test) {
906 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
907 }
908};
909
910template <IComposerClient::Composition CompositionType>
911struct KeepCompositionTypeVariant {
912 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(CompositionType);
913
914 static void setupHwcSetCallExpectations(CompositionTest* test) {
915 EXPECT_CALL(*test->mComposer,
916 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, CompositionType))
917 .Times(1);
918 }
919
920 static void setupHwcGetCallExpectations(CompositionTest* test) {
921 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
922 }
923};
924
925template <IComposerClient::Composition InitialCompositionType,
926 IComposerClient::Composition FinalCompositionType>
927struct ChangeCompositionTypeVariant {
928 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(FinalCompositionType);
929
930 static void setupHwcSetCallExpectations(CompositionTest* test) {
931 EXPECT_CALL(*test->mComposer,
932 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, InitialCompositionType))
933 .Times(1);
934 }
935
936 static void setupHwcGetCallExpectations(CompositionTest* test) {
937 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _))
938 .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::Layer>{
939 static_cast<Hwc2::Layer>(HWC_LAYER)}),
940 SetArgPointee<2>(std::vector<IComposerClient::Composition>{
941 FinalCompositionType}),
942 Return(Error::NONE)));
943 }
944};
945
946/* ------------------------------------------------------------------------
947 * Variants to select how the composition is expected to be handled
948 */
949
950struct CompositionResultBaseVariant {
951 static void setupLayerState(CompositionTest*, sp<Layer>) {}
952
953 template <typename Case>
954 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
955 Case::Layer::setupCallExpectationsForDirtyGeometry(test);
956 }
957
958 template <typename Case>
959 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
960 Case::Layer::setupCallExpectationsForDirtyFrame(test);
961 }
962};
963
964struct NoCompositionResultVariant : public CompositionResultBaseVariant {
965 template <typename Case>
966 static void setupCallExpectations(CompositionTest* test) {
967 Case::Display::setupEmptyFrameCompositionCallExpectations(test);
968 Case::Display::setupHwcCompositionCallExpectations(test);
969 }
970};
971
972struct HwcCompositionResultVariant : public CompositionResultBaseVariant {
973 template <typename Case>
974 static void setupCallExpectations(CompositionTest* test) {
975 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
976 Case::Display::setupHwcCompositionCallExpectations(test);
977 }
978};
979
980struct RECompositionResultVariant : public CompositionResultBaseVariant {
981 template <typename Case>
982 static void setupCallExpectations(CompositionTest* test) {
983 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
984 Case::Display::setupRECompositionCallExpectations(test);
985 Case::Display::template setupRELayerCompositionCallExpectations<Case>(test);
986 }
987};
988
989struct ForcedClientCompositionResultVariant : public RECompositionResultVariant {
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800990 static void setupLayerState(CompositionTest* test, sp<Layer> layer) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800991 const auto outputLayer = layer->findOutputLayerForDisplay(test->mDisplay);
992 LOG_FATAL_IF(!outputLayer);
993 outputLayer->editState().forceClientComposition = true;
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700994 }
995
996 template <typename Case>
997 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
998
999 template <typename Case>
1000 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
1001};
1002
1003struct EmptyScreenshotResultVariant {
1004 static void setupLayerState(CompositionTest*, sp<Layer>) {}
1005
1006 template <typename Case>
1007 static void setupCallExpectations(CompositionTest*) {}
1008};
1009
1010struct REScreenshotResultVariant : public EmptyScreenshotResultVariant {
1011 using Base = EmptyScreenshotResultVariant;
1012
1013 template <typename Case>
1014 static void setupCallExpectations(CompositionTest* test) {
1015 Base::template setupCallExpectations<Case>(test);
1016 Case::Display::template setupRELayerScreenshotCompositionCallExpectations<Case>(test);
1017 }
1018};
1019
1020/* ------------------------------------------------------------------------
1021 * Composition test case, containing all the variants being tested
1022 */
1023
1024template <typename DisplayCase, typename LayerCase, typename CompositionTypeCase,
1025 typename CompositionResultCase>
1026struct CompositionCase {
1027 using ThisCase =
1028 CompositionCase<DisplayCase, LayerCase, CompositionTypeCase, CompositionResultCase>;
1029 using Display = DisplayCase;
1030 using Layer = LayerCase;
1031 using CompositionType = CompositionTypeCase;
1032 using CompositionResult = CompositionResultCase;
1033
1034 static void setupCommon(CompositionTest* test) {
Peiyong Lin1336e6e2019-05-28 09:23:50 -07001035 Display::template setupPreconditionCallExpectations<ThisCase>(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001036 Display::setupPreconditions(test);
1037
1038 auto layer = Layer::createLayer(test);
1039 Layer::injectLayer(test, layer);
1040 CompositionResult::setupLayerState(test, layer);
1041 }
1042
1043 static void setupForDirtyGeometry(CompositionTest* test) {
1044 setupCommon(test);
1045
1046 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1047 CompositionResult::template setupCallExpectationsForDirtyGeometry<ThisCase>(test);
1048 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1049 CompositionResult::template setupCallExpectations<ThisCase>(test);
1050 }
1051
1052 static void setupForDirtyFrame(CompositionTest* test) {
1053 setupCommon(test);
1054
1055 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1056 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1057 CompositionResult::template setupCallExpectations<ThisCase>(test);
1058 }
1059
1060 static void setupForScreenCapture(CompositionTest* test) {
1061 setupCommon(test);
1062
1063 Display::template setupCommonScreensCaptureCallExpectations<ThisCase>(test);
1064 CompositionResult::template setupCallExpectations<ThisCase>(test);
1065 }
1066
1067 static void cleanup(CompositionTest* test) {
1068 Layer::cleanupInjectedLayers(test);
1069
1070 for (auto& hwcDisplay : test->mFlinger.mFakeHwcDisplays) {
1071 hwcDisplay->mutableLayers().clear();
1072 }
1073
1074 test->mDisplay->setVisibleLayersSortedByZ(Vector<sp<android::Layer>>());
1075 }
1076};
1077
1078/* ------------------------------------------------------------------------
1079 * Composition cases to test
1080 */
1081
1082TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyGeometry) {
1083 displayRefreshCompositionDirtyGeometry<
1084 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1085 NoCompositionResultVariant>>();
1086}
1087
1088TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyFrame) {
1089 displayRefreshCompositionDirtyFrame<
1090 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1091 NoCompositionResultVariant>>();
1092}
1093
1094TEST_F(CompositionTest, noLayersDoesMinimalWorkToCaptureScreen) {
1095 captureScreenComposition<
1096 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1097 EmptyScreenshotResultVariant>>();
1098}
1099
1100/* ------------------------------------------------------------------------
1101 * Simple buffer layers
1102 */
1103
1104TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyGeometry) {
1105 displayRefreshCompositionDirtyGeometry<
1106 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1107 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1108 HwcCompositionResultVariant>>();
1109}
1110
1111TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyFrame) {
1112 displayRefreshCompositionDirtyFrame<
1113 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1114 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1115 HwcCompositionResultVariant>>();
1116}
1117
1118TEST_F(CompositionTest, REComposedNormalBufferLayer) {
1119 displayRefreshCompositionDirtyFrame<
1120 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1121 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1122 IComposerClient::Composition::CLIENT>,
1123 RECompositionResultVariant>>();
1124}
1125
1126TEST_F(CompositionTest, captureScreenNormalBufferLayer) {
1127 captureScreenComposition<
1128 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1129 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1130}
1131
1132/* ------------------------------------------------------------------------
1133 * Single-color layers
1134 */
1135
1136TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyGeometry) {
1137 displayRefreshCompositionDirtyGeometry<
1138 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1139 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1140 HwcCompositionResultVariant>>();
1141}
1142
1143TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyFrame) {
1144 displayRefreshCompositionDirtyFrame<
1145 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1146 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1147 HwcCompositionResultVariant>>();
1148}
1149
1150TEST_F(CompositionTest, REComposedColorLayer) {
1151 displayRefreshCompositionDirtyFrame<
1152 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1153 ChangeCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR,
1154 IComposerClient::Composition::CLIENT>,
1155 RECompositionResultVariant>>();
1156}
1157
1158TEST_F(CompositionTest, captureScreenColorLayer) {
1159 captureScreenComposition<
1160 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1161 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1162}
1163
1164/* ------------------------------------------------------------------------
1165 * Layers with sideband buffers
1166 */
1167
1168TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyGeometry) {
1169 displayRefreshCompositionDirtyGeometry<
1170 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1171 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1172 HwcCompositionResultVariant>>();
1173}
1174
1175TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyFrame) {
1176 displayRefreshCompositionDirtyFrame<
1177 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1178 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1179 HwcCompositionResultVariant>>();
1180}
1181
1182TEST_F(CompositionTest, REComposedSidebandBufferLayer) {
1183 displayRefreshCompositionDirtyFrame<
1184 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1185 ChangeCompositionTypeVariant<IComposerClient::Composition::SIDEBAND,
1186 IComposerClient::Composition::CLIENT>,
1187 RECompositionResultVariant>>();
1188}
1189
1190TEST_F(CompositionTest, captureScreenSidebandBufferLayer) {
1191 captureScreenComposition<
1192 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1193 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1194}
1195
1196/* ------------------------------------------------------------------------
1197 * Layers with ISurfaceComposerClient::eSecure, on a secure display
1198 */
1199
1200TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyGeometry) {
1201 displayRefreshCompositionDirtyGeometry<
1202 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1203 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1204 HwcCompositionResultVariant>>();
1205}
1206
1207TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyFrame) {
1208 displayRefreshCompositionDirtyFrame<
1209 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1210 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1211 HwcCompositionResultVariant>>();
1212}
1213
1214TEST_F(CompositionTest, REComposedSecureBufferLayer) {
1215 displayRefreshCompositionDirtyFrame<
1216 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1217 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1218 IComposerClient::Composition::CLIENT>,
1219 RECompositionResultVariant>>();
1220}
1221
1222TEST_F(CompositionTest, captureScreenSecureBufferLayerOnSecureDisplay) {
1223 captureScreenComposition<
1224 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1225 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1226}
1227
1228/* ------------------------------------------------------------------------
1229 * Layers with ISurfaceComposerClient::eSecure, on a non-secure display
1230 */
1231
1232TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyGeometry) {
1233 displayRefreshCompositionDirtyGeometry<
1234 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1235 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1236 ForcedClientCompositionResultVariant>>();
1237}
1238
1239TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyFrame) {
1240 displayRefreshCompositionDirtyFrame<
1241 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1242 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1243 ForcedClientCompositionResultVariant>>();
1244}
1245
1246TEST_F(CompositionTest, captureScreenSecureBufferLayerOnInsecureDisplay) {
1247 captureScreenComposition<
1248 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1249 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1250}
1251
1252/* ------------------------------------------------------------------------
1253 * Cursor layers
1254 */
1255
1256TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyGeometry) {
1257 displayRefreshCompositionDirtyGeometry<
1258 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1259 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1260 HwcCompositionResultVariant>>();
1261}
1262
1263TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyFrame) {
1264 displayRefreshCompositionDirtyFrame<
1265 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1266 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1267 HwcCompositionResultVariant>>();
1268}
1269
1270TEST_F(CompositionTest, REComposedCursorLayer) {
1271 displayRefreshCompositionDirtyFrame<
1272 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1273 ChangeCompositionTypeVariant<IComposerClient::Composition::CURSOR,
1274 IComposerClient::Composition::CLIENT>,
1275 RECompositionResultVariant>>();
1276}
1277
1278TEST_F(CompositionTest, captureScreenCursorLayer) {
1279 captureScreenComposition<
1280 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1281 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1282}
1283
1284/* ------------------------------------------------------------------------
1285 * Simple buffer layer on a display which is powered off.
1286 */
1287
1288TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyGeometry) {
1289 displayRefreshCompositionDirtyGeometry<CompositionCase<
1290 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1291 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1292 HwcCompositionResultVariant>>();
1293}
1294
1295TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyFrame) {
1296 displayRefreshCompositionDirtyFrame<CompositionCase<
1297 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1298 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1299 HwcCompositionResultVariant>>();
1300}
1301
1302TEST_F(CompositionTest, displayOffREComposedNormalBufferLayer) {
1303 displayRefreshCompositionDirtyFrame<CompositionCase<
1304 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1305 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1306 IComposerClient::Composition::CLIENT>,
1307 RECompositionResultVariant>>();
1308}
1309
1310TEST_F(CompositionTest, captureScreenNormalBufferLayerOnPoweredOffDisplay) {
1311 captureScreenComposition<CompositionCase<
1312 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1313 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1314}
1315
1316} // namespace
1317} // namespace android