blob: 82dd3c7bd805ca6d563a4cb0bc0865f0b9c6a35e [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
37#include "TestableSurfaceFlinger.h"
38#include "mock/DisplayHardware/MockComposer.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070039#include "mock/MockDispSync.h"
40#include "mock/MockEventControlThread.h"
41#include "mock/MockEventThread.h"
42#include "mock/MockMessageQueue.h"
Alec Mouriba013fa2018-10-16 12:43:11 -070043#include "mock/system/window/MockNativeWindow.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070044
45namespace android {
46namespace {
47
48using testing::_;
David Sodman15094112018-10-11 09:39:37 -070049using testing::AtLeast;
Alec Mourie7d1d4a2019-02-05 01:13:46 +000050using testing::Between;
Lloyd Piqued6b579f2018-04-06 15:29:10 -070051using testing::ByMove;
52using testing::DoAll;
Alec Mourie7d1d4a2019-02-05 01:13:46 +000053using testing::Field;
Alec Mouri0a9c7b82018-11-16 13:05:25 -080054using testing::Invoke;
Lloyd Piqued6b579f2018-04-06 15:29:10 -070055using testing::IsNull;
56using testing::Mock;
57using testing::NotNull;
58using testing::Ref;
59using testing::Return;
60using testing::ReturnRef;
61using testing::SetArgPointee;
62
63using android::Hwc2::Error;
64using android::Hwc2::IComposer;
65using android::Hwc2::IComposerClient;
66using android::Hwc2::Transform;
67
68using FakeHwcDisplayInjector = TestableSurfaceFlinger::FakeHwcDisplayInjector;
69using FakeDisplayDeviceInjector = TestableSurfaceFlinger::FakeDisplayDeviceInjector;
70
71constexpr hwc2_display_t HWC_DISPLAY = FakeHwcDisplayInjector::DEFAULT_HWC_DISPLAY_ID;
72constexpr hwc2_layer_t HWC_LAYER = 5000;
73constexpr Transform DEFAULT_TRANSFORM = static_cast<Transform>(0);
74
Dominik Laskowski34157762018-10-31 13:07:19 -070075constexpr DisplayId DEFAULT_DISPLAY_ID = DisplayId{42};
Lloyd Piqued6b579f2018-04-06 15:29:10 -070076constexpr int DEFAULT_DISPLAY_WIDTH = 1920;
77constexpr int DEFAULT_DISPLAY_HEIGHT = 1024;
78
79constexpr int DEFAULT_CONFIG_ID = 0;
80constexpr int DEFAULT_TEXTURE_ID = 6000;
81constexpr int DEFAULT_LAYER_STACK = 7000;
82
83constexpr int DEFAULT_DISPLAY_MAX_LUMINANCE = 500;
84
85constexpr int DEFAULT_SIDEBAND_STREAM = 51;
86
87class CompositionTest : public testing::Test {
88public:
89 CompositionTest() {
90 const ::testing::TestInfo* const test_info =
91 ::testing::UnitTest::GetInstance()->current_test_info();
92 ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
93
Lloyd Piqued6b579f2018-04-06 15:29:10 -070094 mFlinger.mutableEventQueue().reset(mMessageQueue);
Ana Krulecafb45842019-02-13 13:33:03 -080095 setupScheduler();
Lloyd Piqued6b579f2018-04-06 15:29:10 -070096
Alec Mourif6fd29e2018-11-17 04:56:41 +000097 EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
98 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0)));
99 EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
100 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0)));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700101
102 mFlinger.setupRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine));
103 setupComposer(0);
104 }
105
106 ~CompositionTest() {
107 const ::testing::TestInfo* const test_info =
108 ::testing::UnitTest::GetInstance()->current_test_info();
109 ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name());
110 }
111
112 void setupComposer(int virtualDisplayCount) {
113 mComposer = new Hwc2::mock::Composer();
114 EXPECT_CALL(*mComposer, getCapabilities())
115 .WillOnce(Return(std::vector<IComposer::Capability>()));
116 EXPECT_CALL(*mComposer, getMaxVirtualDisplayCount()).WillOnce(Return(virtualDisplayCount));
117 mFlinger.setupComposer(std::unique_ptr<Hwc2::Composer>(mComposer));
118
119 Mock::VerifyAndClear(mComposer);
120 }
121
Ana Krulecafb45842019-02-13 13:33:03 -0800122 void setupScheduler() {
Dominik Laskowski7c9dbf92019-08-01 17:57:31 -0700123 auto eventThread = std::make_unique<mock::EventThread>();
124 auto sfEventThread = std::make_unique<mock::EventThread>();
Ana Krulecafb45842019-02-13 13:33:03 -0800125
Dominik Laskowski7c9dbf92019-08-01 17:57:31 -0700126 EXPECT_CALL(*eventThread, registerDisplayEventConnection(_));
127 EXPECT_CALL(*sfEventThread, registerDisplayEventConnection(_));
128
129 auto primaryDispSync = std::make_unique<mock::DispSync>();
130
131 EXPECT_CALL(*primaryDispSync, computeNextRefresh(0)).WillRepeatedly(Return(0));
132 EXPECT_CALL(*primaryDispSync, getPeriod())
133 .WillRepeatedly(Return(FakeHwcDisplayInjector::DEFAULT_REFRESH_RATE));
134 EXPECT_CALL(*primaryDispSync, expectedPresentTime()).WillRepeatedly(Return(0));
135
136 mFlinger.setupScheduler(std::move(primaryDispSync),
137 std::make_unique<mock::EventControlThread>(),
138 std::move(eventThread), std::move(sfEventThread));
Ana Krulecafb45842019-02-13 13:33:03 -0800139 }
140
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700141 void setupForceGeometryDirty() {
142 // TODO: This requires the visible region and other related
143 // state to be set, and is problematic for BufferLayers since they are
144 // not visible without a buffer (and setting up a buffer looks like a
145 // pain)
146 // mFlinger.mutableVisibleRegionsDirty() = true;
147
148 mFlinger.mutableGeometryInvalid() = true;
149 }
150
151 template <typename Case>
152 void displayRefreshCompositionDirtyGeometry();
153
154 template <typename Case>
155 void displayRefreshCompositionDirtyFrame();
156
157 template <typename Case>
158 void captureScreenComposition();
159
160 std::unordered_set<HWC2::Capability> mDefaultCapabilities = {HWC2::Capability::SidebandStream};
161
162 TestableSurfaceFlinger mFlinger;
163 sp<DisplayDevice> mDisplay;
164 sp<DisplayDevice> mExternalDisplay;
Lloyd Pique542307f2018-10-19 13:24:08 -0700165 sp<compositionengine::mock::DisplaySurface> mDisplaySurface =
166 new compositionengine::mock::DisplaySurface();
Alec Mouriba013fa2018-10-16 12:43:11 -0700167 mock::NativeWindow* mNativeWindow = new mock::NativeWindow();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700168
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800169 sp<GraphicBuffer> mBuffer = new GraphicBuffer();
170 ANativeWindowBuffer* mNativeWindowBuffer = mBuffer->getNativeBuffer();
171
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700172 Hwc2::mock::Composer* mComposer = nullptr;
173 renderengine::mock::RenderEngine* mRenderEngine = new renderengine::mock::RenderEngine();
174 mock::MessageQueue* mMessageQueue = new mock::MessageQueue();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700175
176 sp<Fence> mClientTargetAcquireFence = Fence::NO_FENCE;
177
178 sp<GraphicBuffer> mCaptureScreenBuffer;
179};
180
181template <typename LayerCase>
182void CompositionTest::displayRefreshCompositionDirtyGeometry() {
183 setupForceGeometryDirty();
184 LayerCase::setupForDirtyGeometry(this);
185
186 // --------------------------------------------------------------------
187 // Invocation
188
189 mFlinger.onMessageReceived(MessageQueue::INVALIDATE);
190 mFlinger.onMessageReceived(MessageQueue::REFRESH);
191
192 LayerCase::cleanup(this);
193}
194
195template <typename LayerCase>
196void CompositionTest::displayRefreshCompositionDirtyFrame() {
197 LayerCase::setupForDirtyFrame(this);
198
199 // --------------------------------------------------------------------
200 // Invocation
201
202 mFlinger.onMessageReceived(MessageQueue::INVALIDATE);
203 mFlinger.onMessageReceived(MessageQueue::REFRESH);
204
205 LayerCase::cleanup(this);
206}
207
208template <typename LayerCase>
209void CompositionTest::captureScreenComposition() {
210 LayerCase::setupForScreenCapture(this);
211
212 const Rect sourceCrop(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700213 constexpr bool useIdentityTransform = true;
214 constexpr bool forSystem = true;
215
216 DisplayRenderArea renderArea(mDisplay, sourceCrop, DEFAULT_DISPLAY_WIDTH,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700217 DEFAULT_DISPLAY_HEIGHT, ui::Dataspace::V0_SRGB,
218 ui::Transform::ROT_0);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700219
220 auto traverseLayers = [this](const LayerVector::Visitor& visitor) {
chaviw0e3479f2018-09-10 16:49:30 -0700221 return mFlinger.traverseLayersInDisplay(mDisplay, visitor);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700222 };
223
224 // TODO: Eliminate expensive/real allocation if possible.
225 const uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
226 GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
227 mCaptureScreenBuffer = new GraphicBuffer(renderArea.getReqWidth(), renderArea.getReqHeight(),
228 HAL_PIXEL_FORMAT_RGBA_8888, 1, usage, "screenshot");
229
230 int fd = -1;
231 status_t result =
232 mFlinger.captureScreenImplLocked(renderArea, traverseLayers, mCaptureScreenBuffer.get(),
233 useIdentityTransform, forSystem, &fd);
234 if (fd >= 0) {
235 close(fd);
236 }
237
238 EXPECT_EQ(NO_ERROR, result);
239
240 LayerCase::cleanup(this);
241}
242
243/* ------------------------------------------------------------------------
244 * Variants for each display configuration which can be tested
245 */
246
247template <typename Derived>
248struct BaseDisplayVariant {
249 static constexpr bool IS_SECURE = true;
250 static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_NORMAL;
251
252 static void setupPreconditions(CompositionTest* test) {
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700253 EXPECT_CALL(*test->mComposer,
254 setPowerMode(HWC_DISPLAY,
255 static_cast<Hwc2::IComposerClient::PowerMode>(
256 Derived::INIT_POWER_MODE)))
257 .WillOnce(Return(Error::NONE));
Alec Mouriba013fa2018-10-16 12:43:11 -0700258
Dominik Laskowski075d3172018-05-24 15:50:06 -0700259 FakeHwcDisplayInjector(DEFAULT_DISPLAY_ID, HWC2::DisplayType::Physical,
260 true /* isPrimary */)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700261 .setCapabilities(&test->mDefaultCapabilities)
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700262 .setPowerMode(Derived::INIT_POWER_MODE)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700263 .inject(&test->mFlinger, test->mComposer);
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800264 Mock::VerifyAndClear(test->mComposer);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700265
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800266 EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
267 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0)));
268 EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
269 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0)));
270 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_BUFFERS_FORMAT)).Times(1);
271 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_API_CONNECT)).Times(1);
272 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_USAGE64)).Times(1);
Dominik Laskowski075d3172018-05-24 15:50:06 -0700273 test->mDisplay = FakeDisplayDeviceInjector(test->mFlinger, DEFAULT_DISPLAY_ID,
274 false /* isVirtual */, true /* isPrimary */)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700275 .setDisplaySurface(test->mDisplaySurface)
Alec Mouriba013fa2018-10-16 12:43:11 -0700276 .setNativeWindow(test->mNativeWindow)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700277 .setSecure(Derived::IS_SECURE)
278 .setPowerMode(Derived::INIT_POWER_MODE)
279 .inject();
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800280 Mock::VerifyAndClear(test->mNativeWindow);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700281 test->mDisplay->setLayerStack(DEFAULT_LAYER_STACK);
282 }
283
284 template <typename Case>
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700285 static void setupPreconditionCallExpectations(CompositionTest* test) {
286 EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _))
287 .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::DisplayCapability>({})),
288 Return(Error::NONE)));
289 }
290
291 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700292 static void setupCommonCompositionCallExpectations(CompositionTest* test) {
293 EXPECT_CALL(*test->mComposer,
294 setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
295 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700296 EXPECT_CALL(*test->mComposer, getDisplayRequests(HWC_DISPLAY, _, _, _)).Times(1);
297 EXPECT_CALL(*test->mComposer, acceptDisplayChanges(HWC_DISPLAY)).Times(1);
298 EXPECT_CALL(*test->mComposer, presentDisplay(HWC_DISPLAY, _)).Times(1);
299 EXPECT_CALL(*test->mComposer, getReleaseFences(HWC_DISPLAY, _, _)).Times(1);
300
301 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700302
303 EXPECT_CALL(*test->mDisplaySurface, onFrameCommitted()).Times(1);
304 EXPECT_CALL(*test->mDisplaySurface, advanceFrame()).Times(1);
305
306 Case::CompositionType::setupHwcSetCallExpectations(test);
307 Case::CompositionType::setupHwcGetCallExpectations(test);
308 }
309
310 template <typename Case>
311 static void setupCommonScreensCaptureCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000312 EXPECT_CALL(*test->mRenderEngine, drawLayers)
313 .WillRepeatedly(
314 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700315 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
316 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000317 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
318 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
319 displaySettings.physicalDisplay);
320 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
321 displaySettings.clip);
322 return NO_ERROR;
323 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700324 }
325
326 static void setupNonEmptyFrameCompositionCallExpectations(CompositionTest* test) {
327 EXPECT_CALL(*test->mDisplaySurface, beginFrame(true)).Times(1);
328 }
329
330 static void setupEmptyFrameCompositionCallExpectations(CompositionTest* test) {
331 EXPECT_CALL(*test->mDisplaySurface, beginFrame(false)).Times(1);
332 }
333
334 static void setupHwcCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique66d68602019-02-13 14:23:31 -0800335 EXPECT_CALL(*test->mComposer, presentOrValidateDisplay(HWC_DISPLAY, _, _, _, _)).Times(1);
336
Lloyd Pique542307f2018-10-19 13:24:08 -0700337 EXPECT_CALL(*test->mDisplaySurface,
338 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_HWC))
339 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700340 }
341
Lloyd Pique66d68602019-02-13 14:23:31 -0800342 static void setupHwcClientCompositionCallExpectations(CompositionTest* test) {
343 EXPECT_CALL(*test->mComposer, presentOrValidateDisplay(HWC_DISPLAY, _, _, _, _)).Times(1);
344 }
345
346 static void setupHwcForcedClientCompositionCallExpectations(CompositionTest* test) {
347 EXPECT_CALL(*test->mComposer, validateDisplay(HWC_DISPLAY, _, _)).Times(1);
348 }
349
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700350 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique542307f2018-10-19 13:24:08 -0700351 EXPECT_CALL(*test->mDisplaySurface,
352 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_GLES))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700353 .Times(1);
354 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
355 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
356
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800357 EXPECT_CALL(*test->mNativeWindow, queueBuffer(_, _)).WillOnce(Return(0));
358 EXPECT_CALL(*test->mNativeWindow, dequeueBuffer(_, _))
359 .WillOnce(DoAll(SetArgPointee<0>(test->mNativeWindowBuffer), SetArgPointee<1>(-1),
360 Return(0)));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000361 EXPECT_CALL(*test->mRenderEngine, drawLayers)
362 .WillRepeatedly(
363 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700364 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
365 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000366 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
367 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
368 displaySettings.physicalDisplay);
369 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
370 displaySettings.clip);
371 EXPECT_EQ(ui::Dataspace::UNKNOWN, displaySettings.outputDataspace);
372 return NO_ERROR;
373 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700374 }
375
376 template <typename Case>
377 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
378 Case::Layer::setupRECompositionCallExpectations(test);
379 }
380
381 template <typename Case>
382 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
383 Case::Layer::setupREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700384 }
385};
386
387struct DefaultDisplaySetupVariant : public BaseDisplayVariant<DefaultDisplaySetupVariant> {};
388
389struct InsecureDisplaySetupVariant : public BaseDisplayVariant<InsecureDisplaySetupVariant> {
390 static constexpr bool IS_SECURE = false;
391
392 template <typename Case>
393 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
394 Case::Layer::setupInsecureRECompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700395 }
396
397 template <typename Case>
398 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
399 Case::Layer::setupInsecureREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700400 }
401};
402
403struct PoweredOffDisplaySetupVariant : public BaseDisplayVariant<PoweredOffDisplaySetupVariant> {
404 static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_OFF;
405
406 template <typename Case>
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700407 static void setupPreconditionCallExpectations(CompositionTest*) {}
408
409 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700410 static void setupCommonCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800411 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
412
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700413 // TODO: This seems like an unnecessary call if display is powered off.
414 EXPECT_CALL(*test->mComposer,
415 setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
416 .Times(1);
417
418 // TODO: This seems like an unnecessary call if display is powered off.
419 Case::CompositionType::setupHwcSetCallExpectations(test);
420 }
421
422 static void setupHwcCompositionCallExpectations(CompositionTest*) {}
Lloyd Pique66d68602019-02-13 14:23:31 -0800423 static void setupHwcClientCompositionCallExpectations(CompositionTest*) {}
424 static void setupHwcForcedClientCompositionCallExpectations(CompositionTest*) {}
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700425
426 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800427 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
428
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700429 // TODO: This seems like an unnecessary call if display is powered off.
430 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
431 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
432 }
433
434 template <typename Case>
435 static void setupRELayerCompositionCallExpectations(CompositionTest*) {}
436};
437
438/* ------------------------------------------------------------------------
439 * Variants for each layer configuration which can be tested
440 */
441
442template <typename LayerProperties>
443struct BaseLayerProperties {
444 static constexpr uint32_t WIDTH = 100;
445 static constexpr uint32_t HEIGHT = 100;
446 static constexpr PixelFormat FORMAT = PIXEL_FORMAT_RGBA_8888;
447 static constexpr uint64_t USAGE =
448 GraphicBuffer::USAGE_SW_READ_NEVER | GraphicBuffer::USAGE_SW_WRITE_NEVER;
449 static constexpr android_dataspace DATASPACE = HAL_DATASPACE_UNKNOWN;
450 static constexpr uint32_t SCALING_MODE = 0;
451 static constexpr uint32_t TRANSFORM = 0;
452 static constexpr uint32_t LAYER_FLAGS = 0;
453 static constexpr float COLOR[] = {1.f, 1.f, 1.f, 1.f};
454 static constexpr IComposerClient::BlendMode BLENDMODE =
455 IComposerClient::BlendMode::PREMULTIPLIED;
456
457 static void enqueueBuffer(CompositionTest*, sp<BufferQueueLayer> layer) {
458 auto producer = layer->getProducer();
459
460 IGraphicBufferProducer::QueueBufferOutput qbo;
461 status_t result = producer->connect(nullptr, NATIVE_WINDOW_API_EGL, false, &qbo);
462 if (result != NO_ERROR) {
463 ALOGE("Failed to connect() (%d)", result);
464 return;
465 }
466
467 int slot;
468 sp<Fence> fence;
469 result = producer->dequeueBuffer(&slot, &fence, LayerProperties::WIDTH,
470 LayerProperties::HEIGHT, LayerProperties::FORMAT,
471 LayerProperties::USAGE, nullptr, nullptr);
472 if (result != IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
473 ALOGE("Failed to dequeueBuffer() (%d)", result);
474 return;
475 }
476
477 sp<GraphicBuffer> buffer;
478 result = producer->requestBuffer(slot, &buffer);
479 if (result != NO_ERROR) {
480 ALOGE("Failed to requestBuffer() (%d)", result);
481 return;
482 }
483
484 IGraphicBufferProducer::QueueBufferInput qbi(systemTime(), false /* isAutoTimestamp */,
485 LayerProperties::DATASPACE,
486 Rect(LayerProperties::WIDTH,
487 LayerProperties::HEIGHT),
488 LayerProperties::SCALING_MODE,
489 LayerProperties::TRANSFORM, Fence::NO_FENCE);
490 result = producer->queueBuffer(slot, qbi, &qbo);
491 if (result != NO_ERROR) {
492 ALOGE("Failed to queueBuffer (%d)", result);
493 return;
494 }
495 }
496
497 static void setupLatchedBuffer(CompositionTest* test, sp<BufferQueueLayer> layer) {
498 // TODO: Eliminate the complexity of actually creating a buffer
499 EXPECT_CALL(*test->mRenderEngine, getMaxTextureSize()).WillOnce(Return(16384));
500 EXPECT_CALL(*test->mRenderEngine, getMaxViewportDims()).WillOnce(Return(16384));
501 status_t err =
502 layer->setDefaultBufferProperties(LayerProperties::WIDTH, LayerProperties::HEIGHT,
503 LayerProperties::FORMAT);
504 ASSERT_EQ(NO_ERROR, err);
505 Mock::VerifyAndClear(test->mRenderEngine);
506
507 EXPECT_CALL(*test->mMessageQueue, invalidate()).Times(1);
508 enqueueBuffer(test, layer);
509 Mock::VerifyAndClear(test->mMessageQueue);
510
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700511 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700512 bool ignoredRecomputeVisibleRegions;
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700513 layer->latchBuffer(ignoredRecomputeVisibleRegions, 0, 0);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700514 Mock::VerifyAndClear(test->mRenderEngine);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700515 }
516
517 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
518 setupLatchedBuffer(test, layer);
519 }
520
521 static void setupBufferLayerPostFrameCallExpectations(CompositionTest* test) {
522 // BufferLayer::onPostComposition(), when there is no present fence
523 EXPECT_CALL(*test->mComposer, getActiveConfig(HWC_DISPLAY, _))
524 .WillOnce(DoAll(SetArgPointee<1>(DEFAULT_CONFIG_ID), Return(Error::NONE)));
525 }
526
527 static void setupHwcSetGeometryCallExpectations(CompositionTest* test) {
528 // TODO: Coverage of other values
529 EXPECT_CALL(*test->mComposer,
530 setLayerBlendMode(HWC_DISPLAY, HWC_LAYER, LayerProperties::BLENDMODE))
531 .Times(1);
532 // TODO: Coverage of other values for origin
533 EXPECT_CALL(*test->mComposer,
534 setLayerDisplayFrame(HWC_DISPLAY, HWC_LAYER,
535 IComposerClient::Rect({0, 0, LayerProperties::WIDTH,
536 LayerProperties::HEIGHT})))
537 .Times(1);
538 EXPECT_CALL(*test->mComposer,
539 setLayerPlaneAlpha(HWC_DISPLAY, HWC_LAYER, LayerProperties::COLOR[3]))
540 .Times(1);
541 // TODO: Coverage of other values
542 EXPECT_CALL(*test->mComposer, setLayerZOrder(HWC_DISPLAY, HWC_LAYER, 0u)).Times(1);
543 // TODO: Coverage of other values
544 EXPECT_CALL(*test->mComposer, setLayerInfo(HWC_DISPLAY, HWC_LAYER, 0u, 0u)).Times(1);
545
546 // These expectations retire on saturation as the code path these
547 // expectations are for appears to make an extra call to them.
548 // TODO: Investigate this extra call
549 EXPECT_CALL(*test->mComposer, setLayerTransform(HWC_DISPLAY, HWC_LAYER, DEFAULT_TRANSFORM))
David Sodman15094112018-10-11 09:39:37 -0700550 .Times(AtLeast(1))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700551 .RetiresOnSaturation();
552 }
553
554 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
555 EXPECT_CALL(*test->mComposer,
556 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
557 IComposerClient::FRect({0.f, 0.f, LayerProperties::WIDTH,
558 LayerProperties::HEIGHT})))
559 .Times(1);
560 }
561
562 static void setupHwcSetSourceCropColorCallExpectations(CompositionTest* test) {
563 EXPECT_CALL(*test->mComposer,
564 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
565 IComposerClient::FRect({0.f, 0.f, 0.f, 0.f})))
566 .Times(1);
567 }
568
569 static void setupHwcSetPerFrameCallExpectations(CompositionTest* test) {
570 EXPECT_CALL(*test->mComposer,
571 setLayerVisibleRegion(HWC_DISPLAY, HWC_LAYER,
572 std::vector<IComposerClient::Rect>({IComposerClient::Rect(
573 {0, 0, LayerProperties::WIDTH,
574 LayerProperties::HEIGHT})})))
575 .Times(1);
576 }
577
578 static void setupHwcSetPerFrameColorCallExpectations(CompositionTest* test) {
579 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
580
581 // TODO: use COLOR
582 EXPECT_CALL(*test->mComposer,
583 setLayerColor(HWC_DISPLAY, HWC_LAYER,
584 IComposerClient::Color({0xff, 0xff, 0xff, 0xff})))
585 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700586 }
587
588 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
589 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
590 EXPECT_CALL(*test->mComposer, setLayerBuffer(HWC_DISPLAY, HWC_LAYER, _, _, _)).Times(1);
591
592 setupBufferLayerPostFrameCallExpectations(test);
593 }
594
595 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000596 EXPECT_CALL(*test->mRenderEngine, drawLayers)
597 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
598 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700599 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800600 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000601 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
602 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
603 displaySettings.physicalDisplay);
604 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
605 displaySettings.clip);
606 // screen capture adds an additional color layer as an alpha
607 // prefill, so gtet the back layer.
608 renderengine::LayerSettings layer = layerSettings.back();
609 EXPECT_THAT(layer.source.buffer.buffer, Not(IsNull()));
610 EXPECT_THAT(layer.source.buffer.fence, Not(IsNull()));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000611 EXPECT_EQ(DEFAULT_TEXTURE_ID, layer.source.buffer.textureName);
612 EXPECT_EQ(false, layer.source.buffer.isY410BT2020);
613 EXPECT_EQ(true, layer.source.buffer.usePremultipliedAlpha);
614 EXPECT_EQ(false, layer.source.buffer.isOpaque);
615 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
616 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
617 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
618 return NO_ERROR;
619 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700620 }
621
622 static void setupREBufferCompositionCallExpectations(CompositionTest* test) {
623 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700624 }
625
626 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
627 setupREBufferCompositionCallExpectations(test);
628 }
629
630 static void setupREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
631 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
632 }
633
634 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
635 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
636 }
637
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700638 static void setupREColorCompositionCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000639 EXPECT_CALL(*test->mRenderEngine, drawLayers)
640 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
641 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700642 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800643 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000644 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
645 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
646 displaySettings.physicalDisplay);
647 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
648 displaySettings.clip);
649 // screen capture adds an additional color layer as an alpha
650 // prefill, so get the back layer.
651 renderengine::LayerSettings layer = layerSettings.back();
652 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
653 EXPECT_EQ(half3(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
654 LayerProperties::COLOR[2]),
655 layer.source.solidColor);
656 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
657 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
658 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
659 return NO_ERROR;
660 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700661 }
662
663 static void setupREColorScreenshotCompositionCallExpectations(CompositionTest* test) {
664 setupREColorCompositionCallExpectations(test);
665 }
666};
667
668struct DefaultLayerProperties : public BaseLayerProperties<DefaultLayerProperties> {};
669
670struct ColorLayerProperties : public BaseLayerProperties<ColorLayerProperties> {};
671
672struct SidebandLayerProperties : public BaseLayerProperties<SidebandLayerProperties> {
673 using Base = BaseLayerProperties<SidebandLayerProperties>;
674 static constexpr IComposerClient::BlendMode BLENDMODE = IComposerClient::BlendMode::NONE;
675
676 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
677 sp<NativeHandle> stream =
678 NativeHandle::create(reinterpret_cast<native_handle_t*>(DEFAULT_SIDEBAND_STREAM),
679 false);
680 test->mFlinger.setLayerSidebandStream(layer, stream);
681 }
682
683 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
684 EXPECT_CALL(*test->mComposer,
685 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
686 IComposerClient::FRect({0.f, 0.f, -1.f, -1.f})))
687 .Times(1);
688 }
689
690 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
691 EXPECT_CALL(*test->mComposer,
692 setLayerSidebandStream(HWC_DISPLAY, HWC_LAYER,
693 reinterpret_cast<native_handle_t*>(
694 DEFAULT_SIDEBAND_STREAM)))
695 .WillOnce(Return(Error::NONE));
696
697 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
698 }
699
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000700 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* /*test*/) {}
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700701};
702
703struct SecureLayerProperties : public BaseLayerProperties<SecureLayerProperties> {
704 using Base = BaseLayerProperties<SecureLayerProperties>;
705
706 static constexpr uint32_t LAYER_FLAGS = ISurfaceComposerClient::eSecure;
707
708 static void setupInsecureREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000709 EXPECT_CALL(*test->mRenderEngine, drawLayers)
710 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
711 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700712 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800713 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000714 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
715 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
716 displaySettings.physicalDisplay);
717 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
718 displaySettings.clip);
719 // screen capture adds an additional color layer as an alpha
720 // prefill, so get the back layer.
721 renderengine::LayerSettings layer = layerSettings.back();
722 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
723 EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), layer.source.solidColor);
724 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
725 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
726 EXPECT_EQ(1.0f, layer.alpha);
727 return NO_ERROR;
728 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700729 }
730
731 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
732 setupInsecureREBufferCompositionCommonCallExpectations(test);
733 Base::setupBufferLayerPostFrameCallExpectations(test);
734 }
735
736 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
737 setupInsecureREBufferCompositionCommonCallExpectations(test);
738 }
739};
740
741struct CursorLayerProperties : public BaseLayerProperties<CursorLayerProperties> {
742 using Base = BaseLayerProperties<CursorLayerProperties>;
743
744 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
745 Base::setupLayerState(test, layer);
746 test->mFlinger.setLayerPotentialCursor(layer, true);
747 }
748};
749
750struct NoLayerVariant {
751 using FlingerLayerType = sp<BufferQueueLayer>;
752
753 static FlingerLayerType createLayer(CompositionTest*) { return FlingerLayerType(); }
754 static void injectLayer(CompositionTest*, FlingerLayerType) {}
755 static void cleanupInjectedLayers(CompositionTest*) {}
756
757 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
758 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
759};
760
761template <typename LayerProperties>
762struct BaseLayerVariant {
763 template <typename L, typename F>
764 static sp<L> createLayerWithFactory(CompositionTest* test, F factory) {
765 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(0);
766
767 sp<L> layer = factory();
768
769 Mock::VerifyAndClear(test->mComposer);
770 Mock::VerifyAndClear(test->mRenderEngine);
771 Mock::VerifyAndClear(test->mMessageQueue);
772
773 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
774 layerDrawingState.layerStack = DEFAULT_LAYER_STACK;
775 layerDrawingState.active.w = 100;
776 layerDrawingState.active.h = 100;
777 layerDrawingState.color = half4(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
778 LayerProperties::COLOR[2], LayerProperties::COLOR[3]);
Vishnu Nair4351ad52019-02-11 14:13:02 -0800779 layer->computeBounds(FloatRect(0, 0, 100, 100), ui::Transform());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700780 layer->setVisibleRegion(Region(Rect(0, 0, 100, 100)));
781
782 return layer;
783 }
784
785 static void injectLayer(CompositionTest* test, sp<Layer> layer) {
786 EXPECT_CALL(*test->mComposer, createLayer(HWC_DISPLAY, _))
787 .WillOnce(DoAll(SetArgPointee<1>(HWC_LAYER), Return(Error::NONE)));
788
Lloyd Pique07e33212018-12-18 16:33:37 -0800789 std::vector<std::unique_ptr<compositionengine::OutputLayer>> outputLayers;
790 outputLayers.emplace_back(test->mDisplay->getCompositionDisplay()
791 ->getOrCreateOutputLayer(DEFAULT_DISPLAY_ID,
792 layer->getCompositionLayer(),
793 layer));
794
795 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(std::move(outputLayers));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700796
797 Mock::VerifyAndClear(test->mComposer);
798
799 Vector<sp<Layer>> layers;
800 layers.add(layer);
801 test->mDisplay->setVisibleLayersSortedByZ(layers);
802 test->mFlinger.mutableDrawingState().layersSortedByZ.add(layer);
803 }
804
805 static void cleanupInjectedLayers(CompositionTest* test) {
806 EXPECT_CALL(*test->mComposer, destroyLayer(HWC_DISPLAY, HWC_LAYER))
807 .WillOnce(Return(Error::NONE));
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800808
809 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(
810 std::vector<std::unique_ptr<compositionengine::OutputLayer>>());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700811 test->mFlinger.mutableDrawingState().layersSortedByZ.clear();
812 }
813};
814
815template <typename LayerProperties>
816struct ColorLayerVariant : public BaseLayerVariant<LayerProperties> {
817 using Base = BaseLayerVariant<LayerProperties>;
818 using FlingerLayerType = sp<ColorLayer>;
819
820 static FlingerLayerType createLayer(CompositionTest* test) {
821 FlingerLayerType layer = Base::template createLayerWithFactory<ColorLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700822 return new ColorLayer(LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
823 String8("test-layer"), LayerProperties::WIDTH,
824 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800825 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700826 });
Vishnu Nair60356342018-11-13 13:00:45 -0800827
828 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
829 layerDrawingState.crop_legacy = Rect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700830 return layer;
831 }
832
833 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700834 LayerProperties::setupREColorCompositionCallExpectations(test);
835 }
836
837 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
838 LayerProperties::setupREColorScreenshotCompositionCallExpectations(test);
839 }
840
841 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
842 LayerProperties::setupHwcSetGeometryCallExpectations(test);
843 LayerProperties::setupHwcSetSourceCropColorCallExpectations(test);
844 }
845
846 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
847 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
848 LayerProperties::setupHwcSetPerFrameColorCallExpectations(test);
849 }
850};
851
852template <typename LayerProperties>
853struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> {
854 using Base = BaseLayerVariant<LayerProperties>;
855 using FlingerLayerType = sp<BufferQueueLayer>;
856
857 static FlingerLayerType createLayer(CompositionTest* test) {
858 test->mFlinger.mutableTexturePool().push_back(DEFAULT_TEXTURE_ID);
859
860 FlingerLayerType layer =
861 Base::template createLayerWithFactory<BufferQueueLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700862 return new BufferQueueLayer(
863 LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
864 String8("test-layer"), LayerProperties::WIDTH,
865 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800866 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700867 });
868
869 LayerProperties::setupLayerState(test, layer);
870
871 return layer;
872 }
873
874 static void cleanupInjectedLayers(CompositionTest* test) {
Dan Stoza67765d82019-05-07 14:58:27 -0700875 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700876 Base::cleanupInjectedLayers(test);
877 }
878
879 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
880 LayerProperties::setupHwcSetGeometryCallExpectations(test);
881 LayerProperties::setupHwcSetSourceCropBufferCallExpectations(test);
882 }
883
884 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
885 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
886 LayerProperties::setupHwcSetPerFrameBufferCallExpectations(test);
887 }
888
889 static void setupRECompositionCallExpectations(CompositionTest* test) {
890 LayerProperties::setupREBufferCompositionCallExpectations(test);
891 }
892
893 static void setupInsecureRECompositionCallExpectations(CompositionTest* test) {
894 LayerProperties::setupInsecureREBufferCompositionCallExpectations(test);
895 }
896
897 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
898 LayerProperties::setupREBufferScreenshotCompositionCallExpectations(test);
899 }
900
901 static void setupInsecureREScreenshotCompositionCallExpectations(CompositionTest* test) {
902 LayerProperties::setupInsecureREBufferScreenshotCompositionCallExpectations(test);
903 }
904};
905
906/* ------------------------------------------------------------------------
907 * Variants to control how the composition type is changed
908 */
909
910struct NoCompositionTypeVariant {
911 static void setupHwcSetCallExpectations(CompositionTest*) {}
912
913 static void setupHwcGetCallExpectations(CompositionTest* test) {
914 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
915 }
916};
917
918template <IComposerClient::Composition CompositionType>
919struct KeepCompositionTypeVariant {
920 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(CompositionType);
921
922 static void setupHwcSetCallExpectations(CompositionTest* test) {
923 EXPECT_CALL(*test->mComposer,
924 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, CompositionType))
925 .Times(1);
926 }
927
928 static void setupHwcGetCallExpectations(CompositionTest* test) {
929 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
930 }
931};
932
933template <IComposerClient::Composition InitialCompositionType,
934 IComposerClient::Composition FinalCompositionType>
935struct ChangeCompositionTypeVariant {
936 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(FinalCompositionType);
937
938 static void setupHwcSetCallExpectations(CompositionTest* test) {
939 EXPECT_CALL(*test->mComposer,
940 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, InitialCompositionType))
941 .Times(1);
942 }
943
944 static void setupHwcGetCallExpectations(CompositionTest* test) {
945 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _))
946 .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::Layer>{
947 static_cast<Hwc2::Layer>(HWC_LAYER)}),
948 SetArgPointee<2>(std::vector<IComposerClient::Composition>{
949 FinalCompositionType}),
950 Return(Error::NONE)));
951 }
952};
953
954/* ------------------------------------------------------------------------
955 * Variants to select how the composition is expected to be handled
956 */
957
958struct CompositionResultBaseVariant {
959 static void setupLayerState(CompositionTest*, sp<Layer>) {}
960
961 template <typename Case>
962 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
963 Case::Layer::setupCallExpectationsForDirtyGeometry(test);
964 }
965
966 template <typename Case>
967 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
968 Case::Layer::setupCallExpectationsForDirtyFrame(test);
969 }
970};
971
972struct NoCompositionResultVariant : public CompositionResultBaseVariant {
973 template <typename Case>
974 static void setupCallExpectations(CompositionTest* test) {
975 Case::Display::setupEmptyFrameCompositionCallExpectations(test);
976 Case::Display::setupHwcCompositionCallExpectations(test);
977 }
978};
979
980struct HwcCompositionResultVariant : public CompositionResultBaseVariant {
981 template <typename Case>
982 static void setupCallExpectations(CompositionTest* test) {
983 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
984 Case::Display::setupHwcCompositionCallExpectations(test);
985 }
986};
987
988struct RECompositionResultVariant : public CompositionResultBaseVariant {
989 template <typename Case>
990 static void setupCallExpectations(CompositionTest* test) {
991 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
Lloyd Pique66d68602019-02-13 14:23:31 -0800992 Case::Display::setupHwcClientCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700993 Case::Display::setupRECompositionCallExpectations(test);
994 Case::Display::template setupRELayerCompositionCallExpectations<Case>(test);
995 }
996};
997
Lloyd Pique66d68602019-02-13 14:23:31 -0800998struct ForcedClientCompositionResultVariant : public CompositionResultBaseVariant {
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800999 static void setupLayerState(CompositionTest* test, sp<Layer> layer) {
Lloyd Piquef5275482019-01-29 18:42:42 -08001000 const auto outputLayer = layer->findOutputLayerForDisplay(test->mDisplay);
1001 LOG_FATAL_IF(!outputLayer);
1002 outputLayer->editState().forceClientComposition = true;
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001003 }
1004
1005 template <typename Case>
Lloyd Pique66d68602019-02-13 14:23:31 -08001006 static void setupCallExpectations(CompositionTest* test) {
1007 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
1008 Case::Display::setupHwcForcedClientCompositionCallExpectations(test);
1009 Case::Display::setupRECompositionCallExpectations(test);
1010 Case::Display::template setupRELayerCompositionCallExpectations<Case>(test);
1011 }
1012
1013 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001014 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
1015
1016 template <typename Case>
1017 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
1018};
1019
1020struct EmptyScreenshotResultVariant {
1021 static void setupLayerState(CompositionTest*, sp<Layer>) {}
1022
1023 template <typename Case>
1024 static void setupCallExpectations(CompositionTest*) {}
1025};
1026
1027struct REScreenshotResultVariant : public EmptyScreenshotResultVariant {
1028 using Base = EmptyScreenshotResultVariant;
1029
1030 template <typename Case>
1031 static void setupCallExpectations(CompositionTest* test) {
1032 Base::template setupCallExpectations<Case>(test);
1033 Case::Display::template setupRELayerScreenshotCompositionCallExpectations<Case>(test);
1034 }
1035};
1036
1037/* ------------------------------------------------------------------------
1038 * Composition test case, containing all the variants being tested
1039 */
1040
1041template <typename DisplayCase, typename LayerCase, typename CompositionTypeCase,
1042 typename CompositionResultCase>
1043struct CompositionCase {
1044 using ThisCase =
1045 CompositionCase<DisplayCase, LayerCase, CompositionTypeCase, CompositionResultCase>;
1046 using Display = DisplayCase;
1047 using Layer = LayerCase;
1048 using CompositionType = CompositionTypeCase;
1049 using CompositionResult = CompositionResultCase;
1050
1051 static void setupCommon(CompositionTest* test) {
Peiyong Lin1336e6e2019-05-28 09:23:50 -07001052 Display::template setupPreconditionCallExpectations<ThisCase>(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001053 Display::setupPreconditions(test);
1054
1055 auto layer = Layer::createLayer(test);
1056 Layer::injectLayer(test, layer);
1057 CompositionResult::setupLayerState(test, layer);
1058 }
1059
1060 static void setupForDirtyGeometry(CompositionTest* test) {
1061 setupCommon(test);
1062
1063 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1064 CompositionResult::template setupCallExpectationsForDirtyGeometry<ThisCase>(test);
1065 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1066 CompositionResult::template setupCallExpectations<ThisCase>(test);
1067 }
1068
1069 static void setupForDirtyFrame(CompositionTest* test) {
1070 setupCommon(test);
1071
1072 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1073 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1074 CompositionResult::template setupCallExpectations<ThisCase>(test);
1075 }
1076
1077 static void setupForScreenCapture(CompositionTest* test) {
1078 setupCommon(test);
1079
1080 Display::template setupCommonScreensCaptureCallExpectations<ThisCase>(test);
1081 CompositionResult::template setupCallExpectations<ThisCase>(test);
1082 }
1083
1084 static void cleanup(CompositionTest* test) {
1085 Layer::cleanupInjectedLayers(test);
1086
1087 for (auto& hwcDisplay : test->mFlinger.mFakeHwcDisplays) {
1088 hwcDisplay->mutableLayers().clear();
1089 }
1090
1091 test->mDisplay->setVisibleLayersSortedByZ(Vector<sp<android::Layer>>());
1092 }
1093};
1094
1095/* ------------------------------------------------------------------------
1096 * Composition cases to test
1097 */
1098
1099TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyGeometry) {
1100 displayRefreshCompositionDirtyGeometry<
1101 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1102 NoCompositionResultVariant>>();
1103}
1104
1105TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyFrame) {
1106 displayRefreshCompositionDirtyFrame<
1107 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1108 NoCompositionResultVariant>>();
1109}
1110
1111TEST_F(CompositionTest, noLayersDoesMinimalWorkToCaptureScreen) {
1112 captureScreenComposition<
1113 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1114 EmptyScreenshotResultVariant>>();
1115}
1116
1117/* ------------------------------------------------------------------------
1118 * Simple buffer layers
1119 */
1120
1121TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyGeometry) {
1122 displayRefreshCompositionDirtyGeometry<
1123 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1124 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1125 HwcCompositionResultVariant>>();
1126}
1127
1128TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyFrame) {
1129 displayRefreshCompositionDirtyFrame<
1130 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1131 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1132 HwcCompositionResultVariant>>();
1133}
1134
1135TEST_F(CompositionTest, REComposedNormalBufferLayer) {
1136 displayRefreshCompositionDirtyFrame<
1137 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1138 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1139 IComposerClient::Composition::CLIENT>,
1140 RECompositionResultVariant>>();
1141}
1142
1143TEST_F(CompositionTest, captureScreenNormalBufferLayer) {
1144 captureScreenComposition<
1145 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1146 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1147}
1148
1149/* ------------------------------------------------------------------------
1150 * Single-color layers
1151 */
1152
1153TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyGeometry) {
1154 displayRefreshCompositionDirtyGeometry<
1155 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1156 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1157 HwcCompositionResultVariant>>();
1158}
1159
1160TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyFrame) {
1161 displayRefreshCompositionDirtyFrame<
1162 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1163 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1164 HwcCompositionResultVariant>>();
1165}
1166
1167TEST_F(CompositionTest, REComposedColorLayer) {
1168 displayRefreshCompositionDirtyFrame<
1169 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1170 ChangeCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR,
1171 IComposerClient::Composition::CLIENT>,
1172 RECompositionResultVariant>>();
1173}
1174
1175TEST_F(CompositionTest, captureScreenColorLayer) {
1176 captureScreenComposition<
1177 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1178 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1179}
1180
1181/* ------------------------------------------------------------------------
1182 * Layers with sideband buffers
1183 */
1184
1185TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyGeometry) {
1186 displayRefreshCompositionDirtyGeometry<
1187 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1188 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1189 HwcCompositionResultVariant>>();
1190}
1191
1192TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyFrame) {
1193 displayRefreshCompositionDirtyFrame<
1194 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1195 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1196 HwcCompositionResultVariant>>();
1197}
1198
1199TEST_F(CompositionTest, REComposedSidebandBufferLayer) {
1200 displayRefreshCompositionDirtyFrame<
1201 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1202 ChangeCompositionTypeVariant<IComposerClient::Composition::SIDEBAND,
1203 IComposerClient::Composition::CLIENT>,
1204 RECompositionResultVariant>>();
1205}
1206
1207TEST_F(CompositionTest, captureScreenSidebandBufferLayer) {
1208 captureScreenComposition<
1209 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1210 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1211}
1212
1213/* ------------------------------------------------------------------------
1214 * Layers with ISurfaceComposerClient::eSecure, on a secure display
1215 */
1216
1217TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyGeometry) {
1218 displayRefreshCompositionDirtyGeometry<
1219 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1220 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1221 HwcCompositionResultVariant>>();
1222}
1223
1224TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyFrame) {
1225 displayRefreshCompositionDirtyFrame<
1226 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1227 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1228 HwcCompositionResultVariant>>();
1229}
1230
1231TEST_F(CompositionTest, REComposedSecureBufferLayer) {
1232 displayRefreshCompositionDirtyFrame<
1233 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1234 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1235 IComposerClient::Composition::CLIENT>,
1236 RECompositionResultVariant>>();
1237}
1238
1239TEST_F(CompositionTest, captureScreenSecureBufferLayerOnSecureDisplay) {
1240 captureScreenComposition<
1241 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1242 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1243}
1244
1245/* ------------------------------------------------------------------------
1246 * Layers with ISurfaceComposerClient::eSecure, on a non-secure display
1247 */
1248
1249TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyGeometry) {
1250 displayRefreshCompositionDirtyGeometry<
1251 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1252 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1253 ForcedClientCompositionResultVariant>>();
1254}
1255
1256TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyFrame) {
1257 displayRefreshCompositionDirtyFrame<
1258 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1259 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1260 ForcedClientCompositionResultVariant>>();
1261}
1262
1263TEST_F(CompositionTest, captureScreenSecureBufferLayerOnInsecureDisplay) {
1264 captureScreenComposition<
1265 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1266 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1267}
1268
1269/* ------------------------------------------------------------------------
1270 * Cursor layers
1271 */
1272
1273TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyGeometry) {
1274 displayRefreshCompositionDirtyGeometry<
1275 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1276 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1277 HwcCompositionResultVariant>>();
1278}
1279
1280TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyFrame) {
1281 displayRefreshCompositionDirtyFrame<
1282 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1283 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1284 HwcCompositionResultVariant>>();
1285}
1286
1287TEST_F(CompositionTest, REComposedCursorLayer) {
1288 displayRefreshCompositionDirtyFrame<
1289 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1290 ChangeCompositionTypeVariant<IComposerClient::Composition::CURSOR,
1291 IComposerClient::Composition::CLIENT>,
1292 RECompositionResultVariant>>();
1293}
1294
1295TEST_F(CompositionTest, captureScreenCursorLayer) {
1296 captureScreenComposition<
1297 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1298 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1299}
1300
1301/* ------------------------------------------------------------------------
1302 * Simple buffer layer on a display which is powered off.
1303 */
1304
1305TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyGeometry) {
1306 displayRefreshCompositionDirtyGeometry<CompositionCase<
1307 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1308 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1309 HwcCompositionResultVariant>>();
1310}
1311
1312TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyFrame) {
1313 displayRefreshCompositionDirtyFrame<CompositionCase<
1314 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1315 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1316 HwcCompositionResultVariant>>();
1317}
1318
1319TEST_F(CompositionTest, displayOffREComposedNormalBufferLayer) {
1320 displayRefreshCompositionDirtyFrame<CompositionCase<
1321 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1322 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1323 IComposerClient::Composition::CLIENT>,
1324 RECompositionResultVariant>>();
1325}
1326
1327TEST_F(CompositionTest, captureScreenNormalBufferLayerOnPoweredOffDisplay) {
1328 captureScreenComposition<CompositionCase<
1329 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1330 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1331}
1332
1333} // namespace
1334} // namespace android