blob: ed23176718c9b90ea871c4e3ce6ac0f9efcfe7bb [file] [log] [blame]
Valerie Haud251afb2019-03-29 14:19:02 -07001/*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080017
Valerie Haud251afb2019-03-29 14:19:02 -070018#undef LOG_TAG
19#define LOG_TAG "CompositionTest"
20
21#include <compositionengine/Display.h>
22#include <compositionengine/mock/DisplaySurface.h>
23#include <gmock/gmock.h>
24#include <gtest/gtest.h>
25#include <gui/SurfaceComposerClient.h>
26#include <log/log.h>
ramindani4d48f902021-09-20 21:07:45 +000027#include <ui/MockFence.h>
Valerie Haud251afb2019-03-29 14:19:02 -070028#include <utils/String8.h>
Dominik Laskowski068173d2021-08-11 17:22:59 -070029
Valerie Haud251afb2019-03-29 14:19:02 -070030#include "TestableSurfaceFlinger.h"
Valerie Haud251afb2019-03-29 14:19:02 -070031#include "mock/MockEventThread.h"
Ady Abraham8cb21882020-08-26 18:22:05 -070032#include "mock/MockVsyncController.h"
Valerie Haud251afb2019-03-29 14:19:02 -070033
34namespace android {
35
36using testing::_;
37using testing::Return;
38
39using FakeHwcDisplayInjector = TestableSurfaceFlinger::FakeHwcDisplayInjector;
40
41class TransactionApplicationTest : public testing::Test {
42public:
43 TransactionApplicationTest() {
44 const ::testing::TestInfo* const test_info =
45 ::testing::UnitTest::GetInstance()->current_test_info();
46 ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
47
Valerie Haud251afb2019-03-29 14:19:02 -070048 setupScheduler();
49 }
50
51 ~TransactionApplicationTest() {
52 const ::testing::TestInfo* const test_info =
53 ::testing::UnitTest::GetInstance()->current_test_info();
54 ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name());
55 }
56
57 void setupScheduler() {
58 auto eventThread = std::make_unique<mock::EventThread>();
59 auto sfEventThread = std::make_unique<mock::EventThread>();
60
61 EXPECT_CALL(*eventThread, registerDisplayEventConnection(_));
62 EXPECT_CALL(*eventThread, createEventConnection(_, _))
Ady Abraham62f216c2020-10-13 19:07:23 -070063 .WillOnce(Return(new EventThreadConnection(eventThread.get(), /*callingUid=*/0,
64 ResyncCallback())));
Valerie Haud251afb2019-03-29 14:19:02 -070065
66 EXPECT_CALL(*sfEventThread, registerDisplayEventConnection(_));
67 EXPECT_CALL(*sfEventThread, createEventConnection(_, _))
Ady Abraham62f216c2020-10-13 19:07:23 -070068 .WillOnce(Return(new EventThreadConnection(sfEventThread.get(), /*callingUid=*/0,
69 ResyncCallback())));
Valerie Haud251afb2019-03-29 14:19:02 -070070
Ady Abraham8cb21882020-08-26 18:22:05 -070071 EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)).WillRepeatedly(Return(0));
72 EXPECT_CALL(*mVSyncTracker, currentPeriod())
Marin Shalamanov045b7002021-01-07 16:56:24 +010073 .WillRepeatedly(Return(FakeHwcDisplayInjector::DEFAULT_VSYNC_PERIOD));
Valerie Haud251afb2019-03-29 14:19:02 -070074
ramindani4d48f902021-09-20 21:07:45 +000075 EXPECT_CALL(*mFenceUnsignaled, getStatus())
76 .WillRepeatedly(Return(Fence::Status::Unsignaled));
77 EXPECT_CALL(*mFenceUnsignaled2, getStatus())
78 .WillRepeatedly(Return(Fence::Status::Unsignaled));
79 EXPECT_CALL(*mFenceSignaled, getStatus()).WillRepeatedly(Return(Fence::Status::Signaled));
80 EXPECT_CALL(*mFenceSignaled2, getStatus()).WillRepeatedly(Return(Fence::Status::Signaled));
81
Ady Abraham3efa3942021-06-24 19:01:25 -070082 mFlinger.setupComposer(std::make_unique<Hwc2::mock::Composer>());
Ady Abraham8cb21882020-08-26 18:22:05 -070083 mFlinger.setupScheduler(std::unique_ptr<mock::VsyncController>(mVsyncController),
84 std::unique_ptr<mock::VSyncTracker>(mVSyncTracker),
Valerie Haud251afb2019-03-29 14:19:02 -070085 std::move(eventThread), std::move(sfEventThread));
86 }
87
Valerie Haud251afb2019-03-29 14:19:02 -070088 TestableSurfaceFlinger mFlinger;
89
Ady Abraham8cb21882020-08-26 18:22:05 -070090 mock::VsyncController* mVsyncController = new mock::VsyncController();
91 mock::VSyncTracker* mVSyncTracker = new mock::VSyncTracker();
Ady Abraham853c6df2022-02-03 12:04:23 -080092 sp<mock::MockFence> mFenceUnsignaled = sp<mock::MockFence>::make();
93 sp<mock::MockFence> mFenceSignaled = sp<mock::MockFence>::make();
94 sp<mock::MockFence> mFenceUnsignaled2 = sp<mock::MockFence>::make();
95 sp<mock::MockFence> mFenceSignaled2 = sp<mock::MockFence>::make();
Valerie Haud251afb2019-03-29 14:19:02 -070096
97 struct TransactionInfo {
98 Vector<ComposerState> states;
99 Vector<DisplayState> displays;
100 uint32_t flags = 0;
101 sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
102 InputWindowCommands inputWindowCommands;
Ady Abrahamf0c56492020-12-17 18:04:15 -0800103 int64_t desiredPresentTime = 0;
104 bool isAutoTimestamp = true;
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000105 FrameTimelineInfo frameTimelineInfo;
Valerie Haud251afb2019-03-29 14:19:02 -0700106 client_cache_t uncacheBuffer;
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000107 uint64_t id = static_cast<uint64_t>(-1);
108 static_assert(0xffffffffffffffff == static_cast<uint64_t>(-1));
Valerie Haud251afb2019-03-29 14:19:02 -0700109 };
110
Vishnu Nair6b591152021-10-08 11:45:14 -0700111 void checkEqual(TransactionInfo info, TransactionState state) {
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000112 EXPECT_EQ(0u, info.states.size());
113 EXPECT_EQ(0u, state.states.size());
Valerie Haud251afb2019-03-29 14:19:02 -0700114
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000115 EXPECT_EQ(0u, info.displays.size());
116 EXPECT_EQ(0u, state.displays.size());
Valerie Haud251afb2019-03-29 14:19:02 -0700117 EXPECT_EQ(info.flags, state.flags);
118 EXPECT_EQ(info.desiredPresentTime, state.desiredPresentTime);
119 }
120
121 void setupSingle(TransactionInfo& transaction, uint32_t flags, bool syncInputWindows,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800122 int64_t desiredPresentTime, bool isAutoTimestamp,
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000123 const FrameTimelineInfo& frameTimelineInfo) {
Valerie Haud251afb2019-03-29 14:19:02 -0700124 mTransactionNumber++;
125 transaction.flags |= flags; // ISurfaceComposer::eSynchronous;
126 transaction.inputWindowCommands.syncInputWindows = syncInputWindows;
127 transaction.desiredPresentTime = desiredPresentTime;
Ady Abrahamf0c56492020-12-17 18:04:15 -0800128 transaction.isAutoTimestamp = isAutoTimestamp;
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000129 transaction.frameTimelineInfo = frameTimelineInfo;
Valerie Haud251afb2019-03-29 14:19:02 -0700130 }
131
ramindani4d48f902021-09-20 21:07:45 +0000132 void setupSingleWithComposer(TransactionInfo& transaction, uint32_t flags,
133 bool syncInputWindows, int64_t desiredPresentTime,
134 bool isAutoTimestamp, const FrameTimelineInfo& frameTimelineInfo,
135 const Vector<ComposerState>* states) {
136 setupSingle(transaction, flags, syncInputWindows, desiredPresentTime, isAutoTimestamp,
137 frameTimelineInfo);
138 transaction.states = *states;
139 }
140
Valerie Haud251afb2019-03-29 14:19:02 -0700141 void NotPlacedOnTransactionQueue(uint32_t flags, bool syncInputWindows) {
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000142 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
Dominik Laskowski46f3e3b2021-08-10 11:44:24 -0700143 EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(1);
Valerie Haud251afb2019-03-29 14:19:02 -0700144 TransactionInfo transaction;
145 setupSingle(transaction, flags, syncInputWindows,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800146 /*desiredPresentTime*/ systemTime(), /*isAutoTimestamp*/ true,
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000147 FrameTimelineInfo{});
Valerie Haud251afb2019-03-29 14:19:02 -0700148 nsecs_t applicationTime = systemTime();
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000149 mFlinger.setTransactionState(transaction.frameTimelineInfo, transaction.states,
Ady Abraham22c7b5c2020-09-22 19:33:40 -0700150 transaction.displays, transaction.flags,
Valerie Haud251afb2019-03-29 14:19:02 -0700151 transaction.applyToken, transaction.inputWindowCommands,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800152 transaction.desiredPresentTime, transaction.isAutoTimestamp,
153 transaction.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
154 transaction.id);
Valerie Haud251afb2019-03-29 14:19:02 -0700155
Valerie Haud251afb2019-03-29 14:19:02 -0700156 // If transaction is synchronous or syncs input windows, SF
157 // applyTransactionState should time out (5s) wating for SF to commit
158 // the transaction or to receive a signal that syncInputWindows has
159 // completed. If this is animation, it should not time out waiting.
160 nsecs_t returnedTime = systemTime();
161 if (flags & ISurfaceComposer::eSynchronous || syncInputWindows) {
Ady Abrahame9ebce02022-02-03 12:05:06 -0800162 EXPECT_GE(returnedTime, applicationTime + mFlinger.getAnimationTransactionTimeout());
Valerie Haud251afb2019-03-29 14:19:02 -0700163 } else {
Ady Abrahame9ebce02022-02-03 12:05:06 -0800164 EXPECT_LE(returnedTime, applicationTime + mFlinger.getAnimationTransactionTimeout());
Valerie Haud251afb2019-03-29 14:19:02 -0700165 }
Arthur Hung58144272021-01-16 03:43:53 +0000166 // Each transaction should have been placed on the transaction queue
Zhuoyao Zhang3d3540d2021-01-14 05:14:54 +0000167 auto transactionQueue = mFlinger.getTransactionQueue();
Arthur Hung58144272021-01-16 03:43:53 +0000168 EXPECT_EQ(1u, transactionQueue.size());
Valerie Haud251afb2019-03-29 14:19:02 -0700169 }
170
171 void PlaceOnTransactionQueue(uint32_t flags, bool syncInputWindows) {
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000172 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
Dominik Laskowski46f3e3b2021-08-10 11:44:24 -0700173 EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(1);
Valerie Haud251afb2019-03-29 14:19:02 -0700174
175 // first check will see desired present time has not passed,
176 // but afterwards it will look like the desired present time has passed
177 nsecs_t time = systemTime();
Valerie Haud251afb2019-03-29 14:19:02 -0700178 TransactionInfo transaction;
179 setupSingle(transaction, flags, syncInputWindows,
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000180 /*desiredPresentTime*/ time + s2ns(1), false, FrameTimelineInfo{});
Valerie Haud251afb2019-03-29 14:19:02 -0700181 nsecs_t applicationSentTime = systemTime();
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000182 mFlinger.setTransactionState(transaction.frameTimelineInfo, transaction.states,
Ady Abraham22c7b5c2020-09-22 19:33:40 -0700183 transaction.displays, transaction.flags,
Valerie Haud251afb2019-03-29 14:19:02 -0700184 transaction.applyToken, transaction.inputWindowCommands,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800185 transaction.desiredPresentTime, transaction.isAutoTimestamp,
186 transaction.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
187 transaction.id);
Valerie Haud251afb2019-03-29 14:19:02 -0700188
189 nsecs_t returnedTime = systemTime();
Ady Abrahame46243a2021-02-23 19:33:49 -0800190 if ((flags & ISurfaceComposer::eSynchronous) || syncInputWindows) {
Ady Abrahame9ebce02022-02-03 12:05:06 -0800191 EXPECT_GE(systemTime(),
192 applicationSentTime + mFlinger.getAnimationTransactionTimeout());
Ady Abrahame46243a2021-02-23 19:33:49 -0800193 } else {
Ady Abrahame9ebce02022-02-03 12:05:06 -0800194 EXPECT_LE(returnedTime,
195 applicationSentTime + mFlinger.getAnimationTransactionTimeout());
Ady Abrahame46243a2021-02-23 19:33:49 -0800196 }
Valerie Haud251afb2019-03-29 14:19:02 -0700197 // This transaction should have been placed on the transaction queue
Zhuoyao Zhang3d3540d2021-01-14 05:14:54 +0000198 auto transactionQueue = mFlinger.getTransactionQueue();
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000199 EXPECT_EQ(1u, transactionQueue.size());
Valerie Haud251afb2019-03-29 14:19:02 -0700200 }
201
202 void BlockedByPriorTransaction(uint32_t flags, bool syncInputWindows) {
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000203 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
Valerie Haud251afb2019-03-29 14:19:02 -0700204 nsecs_t time = systemTime();
Ady Abrahame46243a2021-02-23 19:33:49 -0800205 if (!syncInputWindows) {
Dominik Laskowski46f3e3b2021-08-10 11:44:24 -0700206 EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(2);
Ady Abrahame46243a2021-02-23 19:33:49 -0800207 } else {
Dominik Laskowski46f3e3b2021-08-10 11:44:24 -0700208 EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(1);
Ady Abrahame46243a2021-02-23 19:33:49 -0800209 }
Valerie Haud251afb2019-03-29 14:19:02 -0700210 // transaction that should go on the pending thread
211 TransactionInfo transactionA;
212 setupSingle(transactionA, /*flags*/ 0, /*syncInputWindows*/ false,
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000213 /*desiredPresentTime*/ time + s2ns(1), false, FrameTimelineInfo{});
Valerie Haud251afb2019-03-29 14:19:02 -0700214
215 // transaction that would not have gone on the pending thread if not
216 // blocked
217 TransactionInfo transactionB;
218 setupSingle(transactionB, flags, syncInputWindows,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800219 /*desiredPresentTime*/ systemTime(), /*isAutoTimestamp*/ true,
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000220 FrameTimelineInfo{});
Valerie Haud251afb2019-03-29 14:19:02 -0700221
222 nsecs_t applicationSentTime = systemTime();
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000223 mFlinger.setTransactionState(transactionA.frameTimelineInfo, transactionA.states,
Ady Abraham22c7b5c2020-09-22 19:33:40 -0700224 transactionA.displays, transactionA.flags,
Valerie Haud251afb2019-03-29 14:19:02 -0700225 transactionA.applyToken, transactionA.inputWindowCommands,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800226 transactionA.desiredPresentTime, transactionA.isAutoTimestamp,
227 transactionA.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
228 transactionA.id);
Valerie Haud251afb2019-03-29 14:19:02 -0700229
230 // This thread should not have been blocked by the above transaction
231 // (5s is the timeout period that applyTransactionState waits for SF to
232 // commit the transaction)
Ady Abrahame9ebce02022-02-03 12:05:06 -0800233 EXPECT_LE(systemTime(), applicationSentTime + mFlinger.getAnimationTransactionTimeout());
Arthur Hung58144272021-01-16 03:43:53 +0000234 // transaction that would goes to pending transaciton queue.
235 mFlinger.flushTransactionQueues();
Valerie Haud251afb2019-03-29 14:19:02 -0700236
237 applicationSentTime = systemTime();
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000238 mFlinger.setTransactionState(transactionB.frameTimelineInfo, transactionB.states,
Ady Abraham22c7b5c2020-09-22 19:33:40 -0700239 transactionB.displays, transactionB.flags,
Valerie Haud251afb2019-03-29 14:19:02 -0700240 transactionB.applyToken, transactionB.inputWindowCommands,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800241 transactionB.desiredPresentTime, transactionB.isAutoTimestamp,
242 transactionB.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
243 transactionB.id);
Valerie Haud251afb2019-03-29 14:19:02 -0700244
245 // this thread should have been blocked by the above transaction
246 // if this is an animation, this thread should be blocked for 5s
247 // in setTransactionState waiting for transactionA to flush. Otherwise,
248 // the transaction should be placed on the pending queue
Ady Abrahame46243a2021-02-23 19:33:49 -0800249 if (flags & (ISurfaceComposer::eAnimation | ISurfaceComposer::eSynchronous) ||
250 syncInputWindows) {
Ady Abrahame9ebce02022-02-03 12:05:06 -0800251 EXPECT_GE(systemTime(),
252 applicationSentTime + mFlinger.getAnimationTransactionTimeout());
Valerie Haud251afb2019-03-29 14:19:02 -0700253 } else {
Ady Abrahame9ebce02022-02-03 12:05:06 -0800254 EXPECT_LE(systemTime(),
255 applicationSentTime + mFlinger.getAnimationTransactionTimeout());
Valerie Haud251afb2019-03-29 14:19:02 -0700256 }
257
Arthur Hung58144272021-01-16 03:43:53 +0000258 // transaction that would goes to pending transaciton queue.
259 mFlinger.flushTransactionQueues();
260
Ady Abrahame46243a2021-02-23 19:33:49 -0800261 // check that the transaction was applied.
Arthur Hung58144272021-01-16 03:43:53 +0000262 auto transactionQueue = mFlinger.getPendingTransactionQueue();
Ady Abrahame46243a2021-02-23 19:33:49 -0800263 EXPECT_EQ(0u, transactionQueue.size());
Valerie Haud251afb2019-03-29 14:19:02 -0700264 }
265
ramindani4d48f902021-09-20 21:07:45 +0000266 void Flush_removesUnsignaledFromTheQueue(Vector<ComposerState> state1,
267 Vector<ComposerState> state2,
268 bool updateApplyToken = true) {
269 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
270
271 TransactionInfo transactionA;
272 setupSingleWithComposer(transactionA, ISurfaceComposer::eSynchronous,
273 /*syncInputWindows*/ false,
274 /*desiredPresentTime*/ systemTime(), /*isAutoTimestamp*/ true,
275 FrameTimelineInfo{}, &state1);
276
277 mFlinger.setTransactionState(transactionA.frameTimelineInfo, transactionA.states,
278 transactionA.displays, transactionA.flags,
279 transactionA.applyToken, transactionA.inputWindowCommands,
280 transactionA.desiredPresentTime, transactionA.isAutoTimestamp,
281 transactionA.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
282 transactionA.id);
283
284 TransactionInfo transactionB;
285 if (updateApplyToken) {
286 transactionB.applyToken = sp<IBinder>();
287 }
288 setupSingleWithComposer(transactionB, ISurfaceComposer::eSynchronous,
289 /*syncInputWindows*/ false,
290 /*desiredPresentTime*/ systemTime(), /*isAutoTimestamp*/ true,
291 FrameTimelineInfo{}, &state2);
292 mFlinger.setTransactionState(transactionB.frameTimelineInfo, transactionB.states,
293 transactionB.displays, transactionB.flags,
294 transactionB.applyToken, transactionB.inputWindowCommands,
295 transactionB.desiredPresentTime, transactionB.isAutoTimestamp,
296 transactionB.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
297 transactionB.id);
298
299 mFlinger.flushTransactionQueues();
300 EXPECT_EQ(0u, mFlinger.getPendingTransactionQueue().size());
301 EXPECT_EQ(0u, mFlinger.getTransactionQueue().size());
302 EXPECT_EQ(2ul, mFlinger.getTransactionCommittedSignals().size());
303 }
304
305 void Flush_removesFromTheQueue(const Vector<ComposerState>& state) {
306 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
307 EXPECT_EQ(0u, mFlinger.getPendingTransactionQueue().size());
308
309 TransactionInfo transaction;
310 setupSingleWithComposer(transaction, ISurfaceComposer::eSynchronous,
311 /*syncInputWindows*/ false,
312 /*desiredPresentTime*/ systemTime(), /*isAutoTimestamp*/ true,
313 FrameTimelineInfo{}, &state);
314
315 mFlinger.setTransactionState(transaction.frameTimelineInfo, transaction.states,
316 transaction.displays, transaction.flags,
317 transaction.applyToken, transaction.inputWindowCommands,
318 transaction.desiredPresentTime, transaction.isAutoTimestamp,
319 transaction.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
320 transaction.id);
321
322 mFlinger.flushTransactionQueues();
323 EXPECT_EQ(0u, mFlinger.getPendingTransactionQueue().size());
324 EXPECT_EQ(0u, mFlinger.getTransactionQueue().size());
325 EXPECT_EQ(1u, mFlinger.getTransactionCommittedSignals().size());
326 }
327
328 void Flush_keepsInTheQueue(const Vector<ComposerState>& state) {
329 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
330 EXPECT_EQ(0u, mFlinger.getPendingTransactionQueue().size());
331
332 TransactionInfo transaction;
333 setupSingleWithComposer(transaction, ISurfaceComposer::eSynchronous,
334 /*syncInputWindows*/ false,
335 /*desiredPresentTime*/ systemTime(), /*isAutoTimestamp*/ true,
336 FrameTimelineInfo{}, &state);
337
338 mFlinger.setTransactionState(transaction.frameTimelineInfo, transaction.states,
339 transaction.displays, transaction.flags,
340 transaction.applyToken, transaction.inputWindowCommands,
341 transaction.desiredPresentTime, transaction.isAutoTimestamp,
342 transaction.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
343 transaction.id);
344
345 mFlinger.flushTransactionQueues();
346 EXPECT_EQ(1u, mFlinger.getPendingTransactionQueue().size());
347 EXPECT_EQ(0u, mFlinger.getTransactionQueue().size());
348 EXPECT_EQ(0ul, mFlinger.getTransactionCommittedSignals().size());
349 }
350
351 void Flush_KeepsUnsignaledInTheQueue(const Vector<ComposerState>& state1,
352 const Vector<ComposerState>& state2,
353 bool updateApplyToken = true,
354 uint32_t pendingTransactionQueueSize = 1u) {
355 EXPECT_EQ(0u, mFlinger.getPendingTransactionQueue().size());
356 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
357 auto time = systemTime();
358 TransactionInfo transactionA;
359 TransactionInfo transactionB;
360 setupSingleWithComposer(transactionA, ISurfaceComposer::eSynchronous,
361 /*syncInputWindows*/ false,
362 /*desiredPresentTime*/ time, /*isAutoTimestamp*/ true,
363 FrameTimelineInfo{}, &state1);
364 setupSingleWithComposer(transactionB, ISurfaceComposer::eSynchronous,
365 /*syncInputWindows*/ false,
366 /*desiredPresentTime*/ time, /*isAutoTimestamp*/ true,
367 FrameTimelineInfo{}, &state2);
368 mFlinger.setTransactionState(transactionA.frameTimelineInfo, transactionA.states,
369 transactionA.displays, transactionA.flags,
370 transactionA.applyToken, transactionA.inputWindowCommands,
371 transactionA.desiredPresentTime, transactionA.isAutoTimestamp,
372 transactionA.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
373 transactionA.id);
374 if (updateApplyToken) {
375 transactionB.applyToken = sp<IBinder>();
376 }
377 mFlinger.setTransactionState(transactionB.frameTimelineInfo, transactionB.states,
378 transactionB.displays, transactionB.flags,
379 transactionB.applyToken, transactionB.inputWindowCommands,
380 transactionB.desiredPresentTime, transactionB.isAutoTimestamp,
381 transactionB.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
382 transactionB.id);
383
384 mFlinger.flushTransactionQueues();
385 EXPECT_EQ(pendingTransactionQueueSize, mFlinger.getPendingTransactionQueue().size());
386 EXPECT_EQ(0u, mFlinger.getTransactionQueue().size());
387 }
388
389 void Flush_removesSignaledFromTheQueue(const Vector<ComposerState>& state1,
390 const Vector<ComposerState>& state2) {
391 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
392 EXPECT_EQ(0u, mFlinger.getPendingTransactionQueue().size());
393
394 auto time = systemTime();
395 TransactionInfo transactionA;
396 TransactionInfo transactionB;
397 setupSingleWithComposer(transactionA, ISurfaceComposer::eSynchronous,
398 /*syncInputWindows*/ false,
399 /*desiredPresentTime*/ time, /*isAutoTimestamp*/ true,
400 FrameTimelineInfo{}, &state1);
401 setupSingleWithComposer(transactionB, ISurfaceComposer::eSynchronous,
402 /*syncInputWindows*/ false,
403 /*desiredPresentTime*/ time, /*isAutoTimestamp*/ true,
404 FrameTimelineInfo{}, &state2);
405 mFlinger.setTransactionState(transactionA.frameTimelineInfo, transactionA.states,
406 transactionA.displays, transactionA.flags,
407 transactionA.applyToken, transactionA.inputWindowCommands,
408 transactionA.desiredPresentTime, transactionA.isAutoTimestamp,
409 transactionA.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
410 transactionA.id);
411 mFlinger.setTransactionState(transactionB.frameTimelineInfo, transactionB.states,
412 transactionB.displays, transactionB.flags,
413 transactionB.applyToken, transactionB.inputWindowCommands,
414 transactionB.desiredPresentTime, transactionB.isAutoTimestamp,
415 transactionB.uncacheBuffer, mHasListenerCallbacks, mCallbacks,
416 transactionB.id);
417
418 mFlinger.flushTransactionQueues();
419 EXPECT_EQ(0u, mFlinger.getPendingTransactionQueue().size());
420 EXPECT_EQ(0u, mFlinger.getTransactionQueue().size());
421 EXPECT_EQ(2ul, mFlinger.getTransactionCommittedSignals().size());
422 }
423
424 static Vector<ComposerState> createComposerStateVector(const ComposerState& state1,
425 const ComposerState& state2) {
426 Vector<ComposerState> states;
427 states.push_back(state1);
428 states.push_back(state2);
429 return states;
430 }
431
432 static Vector<ComposerState> createComposerStateVector(const ComposerState& state) {
433 Vector<ComposerState> states;
434 states.push_back(state);
435 return states;
436 }
437
438 static ComposerState createComposerState(int layerId, sp<Fence> fence,
439 uint32_t stateFlags = layer_state_t::eBufferChanged) {
440 ComposerState composer_state;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800441 composer_state.state.bufferData = std::make_shared<BufferData>();
442 composer_state.state.bufferData->acquireFence = std::move(fence);
ramindani4d48f902021-09-20 21:07:45 +0000443 composer_state.state.layerId = layerId;
Vishnu Nair9f0835e2022-01-07 09:33:19 -0800444 composer_state.state.bufferData->flags = BufferData::BufferDataChange::fenceChanged;
ramindani4d48f902021-09-20 21:07:45 +0000445 composer_state.state.flags = stateFlags;
446 return composer_state;
447 }
448
Valerie Haud251afb2019-03-29 14:19:02 -0700449 bool mHasListenerCallbacks = false;
450 std::vector<ListenerCallbacks> mCallbacks;
451 int mTransactionNumber = 0;
452};
453
454TEST_F(TransactionApplicationTest, Flush_RemovesFromQueue) {
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000455 ASSERT_EQ(0u, mFlinger.getTransactionQueue().size());
Dominik Laskowski46f3e3b2021-08-10 11:44:24 -0700456 EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame()).Times(1);
Valerie Haud251afb2019-03-29 14:19:02 -0700457
Valerie Haud251afb2019-03-29 14:19:02 -0700458 TransactionInfo transactionA; // transaction to go on pending queue
459 setupSingle(transactionA, /*flags*/ 0, /*syncInputWindows*/ false,
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000460 /*desiredPresentTime*/ s2ns(1), false, FrameTimelineInfo{});
461 mFlinger.setTransactionState(transactionA.frameTimelineInfo, transactionA.states,
Ady Abraham22c7b5c2020-09-22 19:33:40 -0700462 transactionA.displays, transactionA.flags, transactionA.applyToken,
463 transactionA.inputWindowCommands, transactionA.desiredPresentTime,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800464 transactionA.isAutoTimestamp, transactionA.uncacheBuffer,
465 mHasListenerCallbacks, mCallbacks, transactionA.id);
Valerie Haud251afb2019-03-29 14:19:02 -0700466
Zhuoyao Zhang3d3540d2021-01-14 05:14:54 +0000467 auto& transactionQueue = mFlinger.getTransactionQueue();
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000468 ASSERT_EQ(1u, transactionQueue.size());
Valerie Haud251afb2019-03-29 14:19:02 -0700469
Arthur Hung58144272021-01-16 03:43:53 +0000470 auto& transactionState = transactionQueue.front();
Valerie Haud251afb2019-03-29 14:19:02 -0700471 checkEqual(transactionA, transactionState);
472
473 // because flushing uses the cached expected present time, we send an empty
474 // transaction here (sending a null applyToken to fake it as from a
475 // different process) to re-query and reset the cached expected present time
476 TransactionInfo empty;
477 empty.applyToken = sp<IBinder>();
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000478 mFlinger.setTransactionState(empty.frameTimelineInfo, empty.states, empty.displays, empty.flags,
479 empty.applyToken, empty.inputWindowCommands,
Ady Abrahamf0c56492020-12-17 18:04:15 -0800480 empty.desiredPresentTime, empty.isAutoTimestamp,
481 empty.uncacheBuffer, mHasListenerCallbacks, mCallbacks, empty.id);
Valerie Haud251afb2019-03-29 14:19:02 -0700482
Zhuoyao Zhang3d3540d2021-01-14 05:14:54 +0000483 // flush transaction queue should flush as desiredPresentTime has
Valerie Haud251afb2019-03-29 14:19:02 -0700484 // passed
Zhuoyao Zhang3d3540d2021-01-14 05:14:54 +0000485 mFlinger.flushTransactionQueues();
Valerie Haud251afb2019-03-29 14:19:02 -0700486
Siarhei Vishniakoufc434ac2021-01-13 10:28:00 -1000487 EXPECT_EQ(0u, transactionQueue.size());
Valerie Haud251afb2019-03-29 14:19:02 -0700488}
489
490TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_Synchronous) {
491 NotPlacedOnTransactionQueue(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false);
492}
493
494TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_Animation) {
495 NotPlacedOnTransactionQueue(ISurfaceComposer::eAnimation, /*syncInputWindows*/ false);
496}
497
498TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_SyncInputWindows) {
499 NotPlacedOnTransactionQueue(/*flags*/ 0, /*syncInputWindows*/ true);
500}
501
502TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_Synchronous) {
503 PlaceOnTransactionQueue(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false);
504}
505
506TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_Animation) {
507 PlaceOnTransactionQueue(ISurfaceComposer::eAnimation, /*syncInputWindows*/ false);
508}
509
510TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_SyncInputWindows) {
511 PlaceOnTransactionQueue(/*flags*/ 0, /*syncInputWindows*/ true);
512}
513
514TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_Synchronous) {
515 BlockedByPriorTransaction(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false);
516}
517
518TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_Animation) {
519 BlockedByPriorTransaction(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false);
520}
521
522TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_SyncInputWindows) {
523 BlockedByPriorTransaction(/*flags*/ 0, /*syncInputWindows*/ true);
524}
525
Valerie Hau09e60052019-12-15 14:51:15 -0800526TEST_F(TransactionApplicationTest, FromHandle) {
527 sp<IBinder> badHandle;
528 auto ret = mFlinger.fromHandle(badHandle);
Alec Mouri9a02eda2020-04-21 17:39:34 -0700529 EXPECT_EQ(nullptr, ret.promote().get());
Valerie Hau09e60052019-12-15 14:51:15 -0800530}
ramindani4d48f902021-09-20 21:07:45 +0000531
532TEST_F(TransactionApplicationTest, Flush_RemovesSingleSignaledFromTheQueue_LatchUnsignaled_Auto) {
533 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
534 Flush_removesFromTheQueue(
535 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceSignaled)));
536}
537
538TEST_F(TransactionApplicationTest, Flush_RemovesSingleUnSignaledFromTheQueue_LatchUnsignaled_Auto) {
539 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
540 Flush_removesFromTheQueue(
541 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled)));
542}
543
544TEST_F(TransactionApplicationTest,
545 Flush_KeepsUnSignaledInTheQueue_NonBufferCropChange_LatchUnsignaled_Auto) {
546 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
547 Flush_keepsInTheQueue(createComposerStateVector(
548 createComposerState(/*layerId*/ 1, mFenceUnsignaled, layer_state_t::eCropChanged)));
549}
550
551TEST_F(TransactionApplicationTest,
552 Flush_KeepsUnSignaledInTheQueue_NonBufferChangeClubed_LatchUnsignaled_Auto) {
553 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
554 Flush_keepsInTheQueue(createComposerStateVector(
555 createComposerState(/*layerId*/ 1, mFenceUnsignaled,
556 layer_state_t::eCropChanged | layer_state_t::eBufferChanged)));
557}
558
559TEST_F(TransactionApplicationTest,
560 Flush_KeepsInTheQueueSameApplyTokenMultiState_LatchUnsignaled_Auto) {
561 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
562 Flush_keepsInTheQueue(
563 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled),
564 createComposerState(/*layerId*/ 1, mFenceSignaled)));
565}
566
567TEST_F(TransactionApplicationTest, Flush_KeepsInTheQueue_MultipleStateTransaction_Auto) {
568 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
569 Flush_keepsInTheQueue(
570 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled),
571 createComposerState(/*layerId*/ 2, mFenceSignaled)));
572}
573
574TEST_F(TransactionApplicationTest, Flush_RemovesSignaledFromTheQueue_LatchUnsignaled_Auto) {
575 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
576 Flush_removesSignaledFromTheQueue(createComposerStateVector(
577 createComposerState(/*layerId*/ 1, mFenceSignaled)),
578 createComposerStateVector(
579 createComposerState(/*layerId*/ 2, mFenceSignaled2)));
580}
581
582TEST_F(TransactionApplicationTest, Flush_RemoveSignaledWithUnsignaledIntact_LatchUnsignaled_Auto) {
583 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
584 Flush_KeepsUnsignaledInTheQueue(createComposerStateVector(
585 createComposerState(/*layerId*/ 1, mFenceSignaled)),
586 createComposerStateVector(
587 createComposerState(/*layerId*/ 2, mFenceUnsignaled)));
588 EXPECT_EQ(1ul, mFlinger.getTransactionCommittedSignals().size());
589}
590
591TEST_F(TransactionApplicationTest,
592 Flush_KeepsTransactionInTheQueueSameApplyToken_LatchUnsignaled_Auto) {
593 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
594 Flush_KeepsUnsignaledInTheQueue(createComposerStateVector(
595 createComposerState(/*layerId*/ 1, mFenceUnsignaled)),
596 createComposerStateVector(
597 createComposerState(/*layerId*/ 2, mFenceSignaled)),
598 /*updateApplyToken*/ false);
599 EXPECT_EQ(1ul, mFlinger.getTransactionCommittedSignals().size());
600}
601
602TEST_F(TransactionApplicationTest, Flush_KeepsTransactionInTheQueue_LatchUnsignaled_Auto) {
603 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Auto;
604 Flush_KeepsUnsignaledInTheQueue(createComposerStateVector(
605 createComposerState(/*layerId*/ 1, mFenceUnsignaled)),
606 createComposerStateVector(
607 createComposerState(/*layerId*/ 2, mFenceUnsignaled)),
608 /*updateApplyToken*/ true,
609 /*pendingTransactionQueueSize*/ 2u);
610 EXPECT_EQ(0ul, mFlinger.getTransactionCommittedSignals().size());
611}
612
613TEST_F(TransactionApplicationTest, Flush_RemovesSignaledFromTheQueue_LatchUnsignaled_Disabled) {
614 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
615 Flush_removesFromTheQueue(
616 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceSignaled)));
617}
618
619TEST_F(TransactionApplicationTest, Flush_KeepsInTheQueue_LatchUnsignaled_Disabled) {
620 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
621 Flush_keepsInTheQueue(
622 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled)));
623}
624
625TEST_F(TransactionApplicationTest, Flush_KeepsInTheQueueSameLayerId_LatchUnsignaled_Disabled) {
626 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
627 Flush_keepsInTheQueue(
628 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled),
629 createComposerState(/*layerId*/ 1, mFenceUnsignaled)));
630}
631
632TEST_F(TransactionApplicationTest, Flush_KeepsInTheQueueDifferentLayerId_LatchUnsignaled_Disabled) {
633 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
634 Flush_keepsInTheQueue(
635 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled),
636 createComposerState(/*layerId*/ 2, mFenceUnsignaled)));
637}
638
639TEST_F(TransactionApplicationTest, Flush_RemovesSignaledFromTheQueue_LatchUnSignaled_Disabled) {
640 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
641 Flush_removesSignaledFromTheQueue(createComposerStateVector(
642 createComposerState(/*layerId*/ 1, mFenceSignaled)),
643 createComposerStateVector(
644 createComposerState(/*layerId*/ 2, mFenceSignaled2)));
645}
646
647TEST_F(TransactionApplicationTest,
648 Flush_KeepInTheQueueDifferentApplyToken_LatchUnsignaled_Disabled) {
649 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
650 Flush_KeepsUnsignaledInTheQueue(createComposerStateVector(
651 createComposerState(/*layerId*/ 1, mFenceUnsignaled)),
652 createComposerStateVector(
653 createComposerState(/*layerId*/ 2, mFenceSignaled)));
654 EXPECT_EQ(1ul, mFlinger.getTransactionCommittedSignals().size());
655}
656
657TEST_F(TransactionApplicationTest, Flush_KeepInTheQueueSameApplyToken_LatchUnsignaled_Disabled) {
658 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
659 Flush_KeepsUnsignaledInTheQueue(createComposerStateVector(
660 createComposerState(/*layerId*/ 1, mFenceSignaled)),
661 createComposerStateVector(
662 createComposerState(/*layerId*/ 2, mFenceUnsignaled)),
663 /*updateApplyToken*/ false);
664 EXPECT_EQ(1ul, mFlinger.getTransactionCommittedSignals().size());
665}
666
667TEST_F(TransactionApplicationTest, Flush_KeepInTheUnsignaledTheQueue_LatchUnsignaled_Disabled) {
668 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Disabled;
669 Flush_KeepsUnsignaledInTheQueue(createComposerStateVector(
670 createComposerState(/*layerId*/ 1, mFenceUnsignaled)),
671 createComposerStateVector(
672 createComposerState(/*layerId*/ 2, mFenceUnsignaled)),
673 /*updateApplyToken*/ false);
674 EXPECT_EQ(0ul, mFlinger.getTransactionCommittedSignals().size());
675}
676
677TEST_F(TransactionApplicationTest, Flush_RemovesSignaledFromTheQueue_LatchUnsignaled_Always) {
678 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
679 Flush_removesFromTheQueue(
680 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceSignaled)));
681}
682
683TEST_F(TransactionApplicationTest, Flush_RemovesFromTheQueue_LatchUnsignaled_Always) {
684 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
685 Flush_removesFromTheQueue(
686 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled)));
687}
688
689TEST_F(TransactionApplicationTest, Flush_RemovesFromTheQueueSameLayerId_LatchUnsignaled_Always) {
690 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
691 Flush_removesFromTheQueue(
692 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled),
693 createComposerState(/*layerId*/ 1, mFenceSignaled)));
694}
695
696TEST_F(TransactionApplicationTest,
697 Flush_RemovesFromTheQueueDifferentLayerId_LatchUnsignaled_Always) {
698 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
699 Flush_removesFromTheQueue(
700 createComposerStateVector(createComposerState(/*layerId*/ 1, mFenceUnsignaled),
701 createComposerState(/*layerId*/ 2, mFenceSignaled)));
702}
703
704TEST_F(TransactionApplicationTest, Flush_RemovesSignaledFromTheQueue_LatchUnSignaled_Always) {
705 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
706 Flush_removesSignaledFromTheQueue(createComposerStateVector(
707 createComposerState(/*layerId*/ 1, mFenceSignaled)),
708 createComposerStateVector(
709 createComposerState(/*layerId*/ 2, mFenceSignaled2)));
710}
711
712TEST_F(TransactionApplicationTest,
713 Flush_RemovesFromTheQueueDifferentApplyToken_LatchUnsignaled_Always) {
714 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
715 Flush_removesUnsignaledFromTheQueue(createComposerStateVector(
716 createComposerState(/*layerId*/ 1, mFenceSignaled)),
717 createComposerStateVector(
718 createComposerState(/*layerId*/ 2,
719 mFenceUnsignaled)));
720}
721
722TEST_F(TransactionApplicationTest,
723 Flush_RemovesUnsignaledFromTheQueueSameApplyToken_LatchUnsignaled_Always) {
724 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
725 Flush_removesUnsignaledFromTheQueue(createComposerStateVector(
726 createComposerState(/*layerId*/ 1,
727 mFenceUnsignaled)),
728 createComposerStateVector(
729 createComposerState(/*layerId*/ 2, mFenceSignaled)),
730 /*updateApplyToken*/ false);
731}
732
733TEST_F(TransactionApplicationTest, Flush_RemovesUnsignaledFromTheQueue_LatchUnsignaled_Always) {
734 SurfaceFlinger::enableLatchUnsignaledConfig = LatchUnsignaledConfig::Always;
735 Flush_removesUnsignaledFromTheQueue(createComposerStateVector(
736 createComposerState(/*layerId*/ 1,
737 mFenceUnsignaled)),
738 createComposerStateVector(
739 createComposerState(/*layerId*/ 2,
740 mFenceUnsignaled)));
741}
742
Valerie Haud251afb2019-03-29 14:19:02 -0700743} // namespace android