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(_, _)) |
Ady Abraham | 62f216c | 2020-10-13 19:07:23 -0700 | [diff] [blame^] | 68 | .WillOnce(Return(new EventThreadConnection(eventThread.get(), /*callingUid=*/0, |
| 69 | ResyncCallback()))); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 70 | |
| 71 | EXPECT_CALL(*sfEventThread, registerDisplayEventConnection(_)); |
| 72 | EXPECT_CALL(*sfEventThread, createEventConnection(_, _)) |
Ady Abraham | 62f216c | 2020-10-13 19:07:23 -0700 | [diff] [blame^] | 73 | .WillOnce(Return(new EventThreadConnection(sfEventThread.get(), /*callingUid=*/0, |
| 74 | ResyncCallback()))); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 75 | |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 76 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)).WillRepeatedly(Return(0)); |
| 77 | EXPECT_CALL(*mVSyncTracker, currentPeriod()) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 78 | .WillRepeatedly(Return(FakeHwcDisplayInjector::DEFAULT_REFRESH_RATE)); |
| 79 | |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 80 | mFlinger.setupScheduler(std::unique_ptr<mock::VsyncController>(mVsyncController), |
| 81 | std::unique_ptr<mock::VSyncTracker>(mVSyncTracker), |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 82 | std::move(eventThread), std::move(sfEventThread)); |
| 83 | } |
| 84 | |
| 85 | TestableScheduler* mScheduler; |
| 86 | TestableSurfaceFlinger mFlinger; |
| 87 | |
| 88 | std::unique_ptr<mock::EventThread> mEventThread = std::make_unique<mock::EventThread>(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 89 | |
| 90 | mock::MessageQueue* mMessageQueue = new mock::MessageQueue(); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 91 | mock::VsyncController* mVsyncController = new mock::VsyncController(); |
| 92 | mock::VSyncTracker* mVSyncTracker = new mock::VSyncTracker(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 93 | |
| 94 | struct TransactionInfo { |
| 95 | Vector<ComposerState> states; |
| 96 | Vector<DisplayState> displays; |
| 97 | uint32_t flags = 0; |
| 98 | sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); |
| 99 | InputWindowCommands inputWindowCommands; |
| 100 | int64_t desiredPresentTime = -1; |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 101 | int64_t frameTimelineVsyncId = ISurfaceComposer::INVALID_VSYNC_ID; |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 102 | client_cache_t uncacheBuffer; |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 103 | int64_t id = -1; |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | void checkEqual(TransactionInfo info, SurfaceFlinger::TransactionState state) { |
| 107 | EXPECT_EQ(0, info.states.size()); |
| 108 | EXPECT_EQ(0, state.states.size()); |
| 109 | |
| 110 | EXPECT_EQ(0, info.displays.size()); |
| 111 | EXPECT_EQ(0, state.displays.size()); |
| 112 | EXPECT_EQ(info.flags, state.flags); |
| 113 | EXPECT_EQ(info.desiredPresentTime, state.desiredPresentTime); |
| 114 | } |
| 115 | |
| 116 | void setupSingle(TransactionInfo& transaction, uint32_t flags, bool syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 117 | int64_t desiredPresentTime, int64_t frameTimelineVsyncId) { |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 118 | mTransactionNumber++; |
| 119 | transaction.flags |= flags; // ISurfaceComposer::eSynchronous; |
| 120 | transaction.inputWindowCommands.syncInputWindows = syncInputWindows; |
| 121 | transaction.desiredPresentTime = desiredPresentTime; |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 122 | transaction.frameTimelineVsyncId = frameTimelineVsyncId; |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | void NotPlacedOnTransactionQueue(uint32_t flags, bool syncInputWindows) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 126 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 127 | // called in SurfaceFlinger::signalTransaction |
| 128 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 129 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)).WillOnce(Return(systemTime())); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 130 | TransactionInfo transaction; |
| 131 | setupSingle(transaction, flags, syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 132 | /*desiredPresentTime*/ -1, ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 133 | nsecs_t applicationTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 134 | mFlinger.setTransactionState(transaction.frameTimelineVsyncId, transaction.states, |
| 135 | transaction.displays, transaction.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 136 | transaction.applyToken, transaction.inputWindowCommands, |
| 137 | transaction.desiredPresentTime, transaction.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 138 | mHasListenerCallbacks, mCallbacks, transaction.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 139 | |
| 140 | // This transaction should not have been placed on the transaction queue. |
| 141 | // If transaction is synchronous or syncs input windows, SF |
| 142 | // applyTransactionState should time out (5s) wating for SF to commit |
| 143 | // the transaction or to receive a signal that syncInputWindows has |
| 144 | // completed. If this is animation, it should not time out waiting. |
| 145 | nsecs_t returnedTime = systemTime(); |
| 146 | if (flags & ISurfaceComposer::eSynchronous || syncInputWindows) { |
| 147 | EXPECT_GE(returnedTime, applicationTime + s2ns(5)); |
| 148 | } else { |
| 149 | EXPECT_LE(returnedTime, applicationTime + s2ns(5)); |
| 150 | } |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 151 | auto transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 152 | EXPECT_EQ(0, transactionQueue.size()); |
| 153 | } |
| 154 | |
| 155 | void PlaceOnTransactionQueue(uint32_t flags, bool syncInputWindows) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 156 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 157 | // called in SurfaceFlinger::signalTransaction |
| 158 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
| 159 | |
| 160 | // first check will see desired present time has not passed, |
| 161 | // but afterwards it will look like the desired present time has passed |
| 162 | nsecs_t time = systemTime(); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 163 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 164 | .WillOnce(Return(time + nsecs_t(5 * 1e8))); |
| 165 | TransactionInfo transaction; |
| 166 | setupSingle(transaction, flags, syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 167 | /*desiredPresentTime*/ time + s2ns(1), ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 168 | nsecs_t applicationSentTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 169 | mFlinger.setTransactionState(transaction.frameTimelineVsyncId, transaction.states, |
| 170 | transaction.displays, transaction.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 171 | transaction.applyToken, transaction.inputWindowCommands, |
| 172 | transaction.desiredPresentTime, transaction.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 173 | mHasListenerCallbacks, mCallbacks, transaction.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 174 | |
| 175 | nsecs_t returnedTime = systemTime(); |
| 176 | EXPECT_LE(returnedTime, applicationSentTime + s2ns(5)); |
| 177 | // This transaction should have been placed on the transaction queue |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 178 | auto transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 179 | EXPECT_EQ(1, transactionQueue.size()); |
| 180 | } |
| 181 | |
| 182 | void BlockedByPriorTransaction(uint32_t flags, bool syncInputWindows) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 183 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 184 | // called in SurfaceFlinger::signalTransaction |
| 185 | nsecs_t time = systemTime(); |
| 186 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 187 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 188 | .WillOnce(Return(time + nsecs_t(5 * 1e8))); |
| 189 | // transaction that should go on the pending thread |
| 190 | TransactionInfo transactionA; |
| 191 | setupSingle(transactionA, /*flags*/ 0, /*syncInputWindows*/ false, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 192 | /*desiredPresentTime*/ time + s2ns(1), ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 193 | |
| 194 | // transaction that would not have gone on the pending thread if not |
| 195 | // blocked |
| 196 | TransactionInfo transactionB; |
| 197 | setupSingle(transactionB, flags, syncInputWindows, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 198 | /*desiredPresentTime*/ -1, ISurfaceComposer::INVALID_VSYNC_ID); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 199 | |
| 200 | nsecs_t applicationSentTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 201 | mFlinger.setTransactionState(transactionA.frameTimelineVsyncId, transactionA.states, |
| 202 | transactionA.displays, transactionA.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 203 | transactionA.applyToken, transactionA.inputWindowCommands, |
| 204 | transactionA.desiredPresentTime, transactionA.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 205 | mHasListenerCallbacks, mCallbacks, transactionA.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 206 | |
| 207 | // This thread should not have been blocked by the above transaction |
| 208 | // (5s is the timeout period that applyTransactionState waits for SF to |
| 209 | // commit the transaction) |
| 210 | EXPECT_LE(systemTime(), applicationSentTime + s2ns(5)); |
| 211 | |
| 212 | applicationSentTime = systemTime(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 213 | mFlinger.setTransactionState(transactionB.frameTimelineVsyncId, transactionB.states, |
| 214 | transactionB.displays, transactionB.flags, |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 215 | transactionB.applyToken, transactionB.inputWindowCommands, |
| 216 | transactionB.desiredPresentTime, transactionB.uncacheBuffer, |
Pablo Gamito | 7eb7ee7 | 2020-08-05 10:57:05 +0000 | [diff] [blame] | 217 | mHasListenerCallbacks, mCallbacks, transactionB.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 218 | |
| 219 | // this thread should have been blocked by the above transaction |
| 220 | // if this is an animation, this thread should be blocked for 5s |
| 221 | // in setTransactionState waiting for transactionA to flush. Otherwise, |
| 222 | // the transaction should be placed on the pending queue |
| 223 | if (flags & ISurfaceComposer::eAnimation) { |
| 224 | EXPECT_GE(systemTime(), applicationSentTime + s2ns(5)); |
| 225 | } else { |
| 226 | EXPECT_LE(systemTime(), applicationSentTime + s2ns(5)); |
| 227 | } |
| 228 | |
| 229 | // check that there is one binder on the pending queue. |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 230 | auto transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 231 | EXPECT_EQ(1, transactionQueue.size()); |
| 232 | |
| 233 | auto& [applyToken, transactionStates] = *(transactionQueue.begin()); |
| 234 | EXPECT_EQ(2, transactionStates.size()); |
| 235 | |
| 236 | auto& transactionStateA = transactionStates.front(); |
| 237 | transactionStates.pop(); |
| 238 | checkEqual(transactionA, transactionStateA); |
| 239 | auto& transactionStateB = transactionStates.front(); |
| 240 | checkEqual(transactionB, transactionStateB); |
| 241 | } |
| 242 | |
| 243 | bool mHasListenerCallbacks = false; |
| 244 | std::vector<ListenerCallbacks> mCallbacks; |
| 245 | int mTransactionNumber = 0; |
| 246 | }; |
| 247 | |
| 248 | TEST_F(TransactionApplicationTest, Flush_RemovesFromQueue) { |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 249 | ASSERT_EQ(0, mFlinger.getTransactionQueue().size()); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 250 | // called in SurfaceFlinger::signalTransaction |
| 251 | EXPECT_CALL(*mMessageQueue, invalidate()).Times(1); |
| 252 | |
| 253 | // nsecs_t time = systemTime(); |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 254 | EXPECT_CALL(*mVSyncTracker, nextAnticipatedVSyncTimeFrom(_)) |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 255 | .WillOnce(Return(nsecs_t(5 * 1e8))) |
| 256 | .WillOnce(Return(s2ns(2))); |
| 257 | TransactionInfo transactionA; // transaction to go on pending queue |
| 258 | setupSingle(transactionA, /*flags*/ 0, /*syncInputWindows*/ false, |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 259 | /*desiredPresentTime*/ s2ns(1), ISurfaceComposer::INVALID_VSYNC_ID); |
| 260 | mFlinger.setTransactionState(transactionA.frameTimelineVsyncId, transactionA.states, |
| 261 | transactionA.displays, transactionA.flags, transactionA.applyToken, |
| 262 | transactionA.inputWindowCommands, transactionA.desiredPresentTime, |
| 263 | transactionA.uncacheBuffer, mHasListenerCallbacks, mCallbacks, |
| 264 | transactionA.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 265 | |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 266 | auto& transactionQueue = mFlinger.getTransactionQueue(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 267 | ASSERT_EQ(1, transactionQueue.size()); |
| 268 | |
| 269 | auto& [applyToken, transactionStates] = *(transactionQueue.begin()); |
| 270 | ASSERT_EQ(1, transactionStates.size()); |
| 271 | |
| 272 | auto& transactionState = transactionStates.front(); |
| 273 | checkEqual(transactionA, transactionState); |
| 274 | |
| 275 | // because flushing uses the cached expected present time, we send an empty |
| 276 | // transaction here (sending a null applyToken to fake it as from a |
| 277 | // different process) to re-query and reset the cached expected present time |
| 278 | TransactionInfo empty; |
| 279 | empty.applyToken = sp<IBinder>(); |
Ady Abraham | 22c7b5c | 2020-09-22 19:33:40 -0700 | [diff] [blame] | 280 | mFlinger.setTransactionState(empty.frameTimelineVsyncId, empty.states, empty.displays, |
| 281 | empty.flags, empty.applyToken, empty.inputWindowCommands, |
| 282 | empty.desiredPresentTime, empty.uncacheBuffer, |
| 283 | mHasListenerCallbacks, mCallbacks, empty.id); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 284 | |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 285 | // flush transaction queue should flush as desiredPresentTime has |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 286 | // passed |
Arthur Hung | 1bedccb | 2020-09-24 10:09:25 +0000 | [diff] [blame] | 287 | mFlinger.flushTransactionQueues(); |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 288 | |
| 289 | EXPECT_EQ(0, transactionQueue.size()); |
| 290 | } |
| 291 | |
| 292 | TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_Synchronous) { |
| 293 | NotPlacedOnTransactionQueue(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 294 | } |
| 295 | |
| 296 | TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_Animation) { |
| 297 | NotPlacedOnTransactionQueue(ISurfaceComposer::eAnimation, /*syncInputWindows*/ false); |
| 298 | } |
| 299 | |
| 300 | TEST_F(TransactionApplicationTest, NotPlacedOnTransactionQueue_SyncInputWindows) { |
| 301 | NotPlacedOnTransactionQueue(/*flags*/ 0, /*syncInputWindows*/ true); |
| 302 | } |
| 303 | |
| 304 | TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_Synchronous) { |
| 305 | PlaceOnTransactionQueue(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 306 | } |
| 307 | |
| 308 | TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_Animation) { |
| 309 | PlaceOnTransactionQueue(ISurfaceComposer::eAnimation, /*syncInputWindows*/ false); |
| 310 | } |
| 311 | |
| 312 | TEST_F(TransactionApplicationTest, PlaceOnTransactionQueue_SyncInputWindows) { |
| 313 | PlaceOnTransactionQueue(/*flags*/ 0, /*syncInputWindows*/ true); |
| 314 | } |
| 315 | |
| 316 | TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_Synchronous) { |
| 317 | BlockedByPriorTransaction(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 318 | } |
| 319 | |
| 320 | TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_Animation) { |
| 321 | BlockedByPriorTransaction(ISurfaceComposer::eSynchronous, /*syncInputWindows*/ false); |
| 322 | } |
| 323 | |
| 324 | TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_SyncInputWindows) { |
| 325 | BlockedByPriorTransaction(/*flags*/ 0, /*syncInputWindows*/ true); |
| 326 | } |
| 327 | |
Valerie Hau | 09e6005 | 2019-12-15 14:51:15 -0800 | [diff] [blame] | 328 | TEST_F(TransactionApplicationTest, FromHandle) { |
| 329 | sp<IBinder> badHandle; |
| 330 | auto ret = mFlinger.fromHandle(badHandle); |
Alec Mouri | 9a02eda | 2020-04-21 17:39:34 -0700 | [diff] [blame] | 331 | EXPECT_EQ(nullptr, ret.promote().get()); |
Valerie Hau | 09e6005 | 2019-12-15 14:51:15 -0800 | [diff] [blame] | 332 | } |
Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 333 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 334 | |
| 335 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 336 | #pragma clang diagnostic pop // ignored "-Wconversion" |