Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 18 | #pragma clang diagnostic push |
| 19 | #pragma clang diagnostic ignored "-Wconversion" |
| 20 | |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 21 | #undef LOG_TAG |
| 22 | #define LOG_TAG "CompositionTest" |
| 23 | |
| 24 | #include <compositionengine/Display.h> |
| 25 | #include <compositionengine/mock/DisplaySurface.h> |
| 26 | #include <gmock/gmock.h> |
| 27 | #include <gtest/gtest.h> |
| 28 | #include <gui/SurfaceComposerClient.h> |
| 29 | #include <log/log.h> |
| 30 | #include <utils/String8.h> |
| 31 | |
| 32 | #include "TestableScheduler.h" |
| 33 | #include "TestableSurfaceFlinger.h" |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 34 | #include "mock/MockEventThread.h" |
| 35 | #include "mock/MockMessageQueue.h" |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 36 | #include "mock/MockVsyncController.h" |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 37 | |
| 38 | namespace android { |
| 39 | |
| 40 | using testing::_; |
| 41 | using testing::Return; |
| 42 | |
| 43 | using FakeHwcDisplayInjector = TestableSurfaceFlinger::FakeHwcDisplayInjector; |
| 44 | |
| 45 | class TransactionApplicationTest : public testing::Test { |
| 46 | public: |
| 47 | TransactionApplicationTest() { |
| 48 | const ::testing::TestInfo* const test_info = |
| 49 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 50 | ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name()); |
| 51 | |
| 52 | mFlinger.mutableEventQueue().reset(mMessageQueue); |
| 53 | setupScheduler(); |
| 54 | } |
| 55 | |
| 56 | ~TransactionApplicationTest() { |
| 57 | const ::testing::TestInfo* const test_info = |
| 58 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 59 | ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name()); |
| 60 | } |
| 61 | |
| 62 | void setupScheduler() { |
| 63 | auto eventThread = std::make_unique<mock::EventThread>(); |
| 64 | auto sfEventThread = std::make_unique<mock::EventThread>(); |
| 65 | |
| 66 | EXPECT_CALL(*eventThread, registerDisplayEventConnection(_)); |
| 67 | EXPECT_CALL(*eventThread, createEventConnection(_, _)) |
| 68 | .WillOnce(Return( |
Ady Abraham | 0bb6a47 | 2020-10-12 10:22:13 -0700 | [diff] [blame] | 69 | new EventThreadConnection(eventThread.get(), /*callingUid=*/0, |
| 70 | ResyncCallback(), |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 71 | ISurfaceComposer::eConfigChangedSuppress))); |
| 72 | |
| 73 | EXPECT_CALL(*sfEventThread, registerDisplayEventConnection(_)); |
| 74 | EXPECT_CALL(*sfEventThread, createEventConnection(_, _)) |
| 75 | .WillOnce(Return( |
Ady Abraham | 0bb6a47 | 2020-10-12 10:22:13 -0700 | [diff] [blame] | 76 | new EventThreadConnection(sfEventThread.get(), /*callingUid=*/0, |
| 77 | ResyncCallback(), |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 78 | ISurfaceComposer::eConfigChangedSuppress))); |
| 79 | |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 80 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)).WillRepeatedly(Return(0)); |
| 81 | EXPECT_CALL(*mVSyncTracker, currentPeriod()) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 82 | .WillRepeatedly(Return(FakeHwcDisplayInjector::DEFAULT_REFRESH_RATE)); |
| 83 | |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 84 | mFlinger.setupScheduler(std::unique_ptr<mock::VsyncController>(mVsyncController), |
| 85 | std::unique_ptr<mock::VSyncTracker>(mVSyncTracker), |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 86 | std::move(eventThread), std::move(sfEventThread)); |
| 87 | } |
| 88 | |
| 89 | TestableScheduler* mScheduler; |
| 90 | TestableSurfaceFlinger mFlinger; |
| 91 | |
| 92 | std::unique_ptr<mock::EventThread> mEventThread = std::make_unique<mock::EventThread>(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 93 | |
| 94 | mock::MessageQueue* mMessageQueue = new mock::MessageQueue(); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 95 | mock::VsyncController* mVsyncController = new mock::VsyncController(); |
| 96 | mock::VSyncTracker* mVSyncTracker = new mock::VSyncTracker(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 97 | |
| 98 | struct TransactionInfo { |
| 99 | Vector<ComposerState> states; |
| 100 | Vector<DisplayState> displays; |
| 101 | uint32_t flags = 0; |
| 102 | sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); |
| 103 | InputWindowCommands inputWindowCommands; |
| 104 | int64_t desiredPresentTime = -1; |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 105 | int64_t frameTimelineVsyncId = ISurfaceComposer::INVALID_VSYNC_ID; |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 106 | client_cache_t uncacheBuffer; |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 107 | int64_t id = -1; |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | void checkEqual(TransactionInfo info, SurfaceFlinger::TransactionState state) { |
| 111 | EXPECT_EQ(0, info.states.size()); |
| 112 | EXPECT_EQ(0, state.states.size()); |
| 113 | |
| 114 | EXPECT_EQ(0, info.displays.size()); |
| 115 | EXPECT_EQ(0, state.displays.size()); |
| 116 | EXPECT_EQ(info.flags, state.flags); |
| 117 | EXPECT_EQ(info.desiredPresentTime, state.desiredPresentTime); |
| 118 | } |
| 119 | |
| 120 | void setupSingle(TransactionInfo& transaction, uint32_t flags, bool syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 121 | int64_t desiredPresentTime, int64_t frameTimelineVsyncId) { |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 122 | mTransactionNumber++; |
| 123 | transaction.flags |= flags; // ISurfaceComposer::eSynchronous; |
| 124 | transaction.inputWindowCommands.syncInputWindows = syncInputWindows; |
| 125 | transaction.desiredPresentTime = desiredPresentTime; |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 126 | transaction.frameTimelineVsyncId = frameTimelineVsyncId; |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | void NotPlacedOnTransactionQueue(uint32_t flags, bool syncInputWindows) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 130 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 131 | // called in SurfaceFlinger::signalTransaction |
| 132 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 133 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)).WillOnce(Return(systemTime())); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 134 | TransactionInfo transaction; |
| 135 | setupSingle(transaction, flags, syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 136 | /*desiredPresentTime*/ -1, ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 137 | nsecs_t applicationTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 138 | mFlinger.setTransactionState(transaction.frameTimelineVsyncId, transaction.states, |
| 139 | transaction.displays, transaction.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 140 | transaction.applyToken, transaction.inputWindowCommands, |
| 141 | transaction.desiredPresentTime, transaction.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 142 | mHasListenerCallbacks, mCallbacks, transaction.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 143 | |
| 144 | // This transaction should not have been placed on the transaction queue. |
| 145 | // If transaction is synchronous or syncs input windows, SF |
| 146 | // applyTransactionState should time out (5s) wating for SF to commit |
| 147 | // the transaction or to receive a signal that syncInputWindows has |
| 148 | // completed. If this is animation, it should not time out waiting. |
| 149 | nsecs_t returnedTime = systemTime(); |
| 150 | if (flags & ISurfaceComposer::eSynchronous || syncInputWindows) { |
| 151 | EXPECT_GE(returnedTime, applicationTime + s2ns(5)); |
| 152 | } else { |
| 153 | EXPECT_LE(returnedTime, applicationTime + s2ns(5)); |
| 154 | } |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 155 | auto transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 156 | EXPECT_EQ(0, transactionQueue.size()); |
| 157 | } |
| 158 | |
| 159 | void PlaceOnTransactionQueue(uint32_t flags, bool syncInputWindows) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 160 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 161 | // called in SurfaceFlinger::signalTransaction |
| 162 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
| 163 | |
| 164 | // first check will see desired present time has not passed, |
| 165 | // but afterwards it will look like the desired present time has passed |
| 166 | nsecs_t time = systemTime(); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 167 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 168 | .WillOnce(Return(time + nsecs_t(5 * 1e8))); |
| 169 | TransactionInfo transaction; |
| 170 | setupSingle(transaction, flags, syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 171 | /*desiredPresentTime*/ time + s2ns(1), ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 172 | nsecs_t applicationSentTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 173 | mFlinger.setTransactionState(transaction.frameTimelineVsyncId, transaction.states, |
| 174 | transaction.displays, transaction.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 175 | transaction.applyToken, transaction.inputWindowCommands, |
| 176 | transaction.desiredPresentTime, transaction.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 177 | mHasListenerCallbacks, mCallbacks, transaction.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 178 | |
| 179 | nsecs_t returnedTime = systemTime(); |
| 180 | EXPECT_LE(returnedTime, applicationSentTime + s2ns(5)); |
| 181 | // This transaction should have been placed on the transaction queue |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 182 | auto transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 183 | EXPECT_EQ(1, transactionQueue.size()); |
| 184 | } |
| 185 | |
| 186 | void BlockedByPriorTransaction(uint32_t flags, bool syncInputWindows) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 187 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 188 | // called in SurfaceFlinger::signalTransaction |
| 189 | nsecs_t time = systemTime(); |
| 190 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 191 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 192 | .WillOnce(Return(time + nsecs_t(5 * 1e8))); |
| 193 | // transaction that should go on the pending thread |
| 194 | TransactionInfo transactionA; |
| 195 | setupSingle(transactionA, /*flags*/ 0, /*syncInputWindows*/ false, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 196 | /*desiredPresentTime*/ time + s2ns(1), ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 197 | |
| 198 | // transaction that would not have gone on the pending thread if not |
| 199 | // blocked |
| 200 | TransactionInfo transactionB; |
| 201 | setupSingle(transactionB, flags, syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 202 | /*desiredPresentTime*/ -1, ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 203 | |
| 204 | nsecs_t applicationSentTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 205 | mFlinger.setTransactionState(transactionA.frameTimelineVsyncId, transactionA.states, |
| 206 | transactionA.displays, transactionA.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 207 | transactionA.applyToken, transactionA.inputWindowCommands, |
| 208 | transactionA.desiredPresentTime, transactionA.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 209 | mHasListenerCallbacks, mCallbacks, transactionA.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 210 | |
| 211 | // This thread should not have been blocked by the above transaction |
| 212 | // (5s is the timeout period that applyTransactionState waits for SF to |
| 213 | // commit the transaction) |
| 214 | EXPECT_LE(systemTime(), applicationSentTime + s2ns(5)); |
| 215 | |
| 216 | applicationSentTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 217 | mFlinger.setTransactionState(transactionB.frameTimelineVsyncId, transactionB.states, |
| 218 | transactionB.displays, transactionB.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 219 | transactionB.applyToken, transactionB.inputWindowCommands, |
| 220 | transactionB.desiredPresentTime, transactionB.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 221 | mHasListenerCallbacks, mCallbacks, transactionB.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 222 | |
| 223 | // this thread should have been blocked by the above transaction |
| 224 | // if this is an animation, this thread should be blocked for 5s |
| 225 | // in setTransactionState waiting for transactionA to flush. Otherwise, |
| 226 | // the transaction should be placed on the pending queue |
| 227 | if (flags & ISurfaceComposer::eAnimation) { |
| 228 | EXPECT_GE(systemTime(), applicationSentTime + s2ns(5)); |
| 229 | } else { |
| 230 | EXPECT_LE(systemTime(), applicationSentTime + s2ns(5)); |
| 231 | } |
| 232 | |
| 233 | // check that there is one binder on the pending queue. |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 234 | auto transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 235 | EXPECT_EQ(1, transactionQueue.size()); |
| 236 | |
| 237 | auto& [applyToken, transactionStates] = *(transactionQueue.begin()); |
| 238 | EXPECT_EQ(2, transactionStates.size()); |
| 239 | |
| 240 | auto& transactionStateA = transactionStates.front(); |
| 241 | transactionStates.pop(); |
| 242 | checkEqual(transactionA, transactionStateA); |
| 243 | auto& transactionStateB = transactionStates.front(); |
| 244 | checkEqual(transactionB, transactionStateB); |
| 245 | } |
| 246 | |
| 247 | bool mHasListenerCallbacks = false; |
| 248 | std::vector<ListenerCallbacks> mCallbacks; |
| 249 | int mTransactionNumber = 0; |
| 250 | }; |
| 251 | |
| 252 | TEST_F(TransactionApplicationTest, Flush_RemovesFromQueue) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 253 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 254 | // called in SurfaceFlinger::signalTransaction |
| 255 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
| 256 | |
| 257 | // nsecs_t time = systemTime(); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 258 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 259 | .WillOnce(Return(nsecs_t(5 * 1e8))) |
| 260 | .WillOnce(Return(s2ns(2))); |
| 261 | TransactionInfo transactionA; // transaction to go on pending queue |
| 262 | setupSingle(transactionA, /*flags*/ 0, /*syncInputWindows*/ false, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 263 | /*desiredPresentTime*/ s2ns(1), ISurfaceComposer::INVALID_VSYNC_ID); |
| 264 | mFlinger.setTransactionState(transactionA.frameTimelineVsyncId, transactionA.states, |
| 265 | transactionA.displays, transactionA.flags, transactionA.applyToken, |
| 266 | transactionA.inputWindowCommands, transactionA.desiredPresentTime, |
| 267 | transactionA.uncacheBuffer, mHasListenerCallbacks, mCallbacks, |
| 268 | transactionA.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 269 | |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 270 | auto& transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 271 | ASSERT_EQ(1, transactionQueue.size()); |
| 272 | |
| 273 | auto& [applyToken, transactionStates] = *(transactionQueue.begin()); |
| 274 | ASSERT_EQ(1, transactionStates.size()); |
| 275 | |
| 276 | auto& transactionState = transactionStates.front(); |
| 277 | checkEqual(transactionA, transactionState); |
| 278 | |
| 279 | // because flushing uses the cached expected present time, we send an empty |
| 280 | // transaction here (sending a null applyToken to fake it as from a |
| 281 | // different process) to re-query and reset the cached expected present time |
| 282 | TransactionInfo empty; |
| 283 | empty.applyToken = sp<IBinder>(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 284 | mFlinger.setTransactionState(empty.frameTimelineVsyncId, empty.states, empty.displays, |
| 285 | empty.flags, empty.applyToken, empty.inputWindowCommands, |
| 286 | empty.desiredPresentTime, empty.uncacheBuffer, |
| 287 | mHasListenerCallbacks, mCallbacks, empty.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 288 | |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 289 | // flush transaction queue should flush as desiredPresentTime has |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 290 | // passed |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 291 | mFlinger.flushTransactionQueues(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 292 | |
| 293 | EXPECT_EQ(0, transactionQueue.size()); |
| 294 | } |
| 295 | |
| 296 | TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_Synchronous) { |
| 297 | NotPlacedOnTransactionQueue(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 298 | } |
| 299 | |
| 300 | TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_Animation) { |
| 301 | NotPlacedOnTransactionQueue(ISurfaceComposer::eAnimation, /*syncInputWindows*/ false); |
| 302 | } |
| 303 | |
| 304 | TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_SyncInputWindows) { |
| 305 | NotPlacedOnTransactionQueue(/*flags*/ 0, /*syncInputWindows*/ true); |
| 306 | } |
| 307 | |
| 308 | TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_Synchronous) { |
| 309 | PlaceOnTransactionQueue(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 310 | } |
| 311 | |
| 312 | TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_Animation) { |
| 313 | PlaceOnTransactionQueue(ISurfaceComposer::eAnimation, /*syncInputWindows*/ false); |
| 314 | } |
| 315 | |
| 316 | TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_SyncInputWindows) { |
| 317 | PlaceOnTransactionQueue(/*flags*/ 0, /*syncInputWindows*/ true); |
| 318 | } |
| 319 | |
| 320 | TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_Synchronous) { |
| 321 | BlockedByPriorTransaction(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 322 | } |
| 323 | |
| 324 | TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_Animation) { |
| 325 | BlockedByPriorTransaction(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 326 | } |
| 327 | |
| 328 | TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_SyncInputWindows) { |
| 329 | BlockedByPriorTransaction(/*flags*/ 0, /*syncInputWindows*/ true); |
| 330 | } |
| 331 | |
Valerie Hau | 09e6005 | 2019-12-15 14:51:15 -0800 | [diff] [blame] | 332 | TEST_F(TransactionApplicationTest, FromHandle) { |
| 333 | sp<IBinder> badHandle; |
| 334 | auto ret = mFlinger.fromHandle(badHandle); |
Alec Mouri | 9a02eda | 2020-04-21 17:39:34 -0700 | [diff] [blame] | 335 | EXPECT_EQ(nullptr, ret.promote().get()); |
Valerie Hau | 09e6005 | 2019-12-15 14:51:15 -0800 | [diff] [blame] | 336 | } |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 337 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 338 | |
| 339 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 340 | #pragma clang diagnostic pop // ignored "-Wconversion" |