Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 | |
Ady Abraham | 29d16cb | 2021-03-08 13:19:21 -0800 | [diff] [blame^] | 21 | #include <sys/epoll.h> |
| 22 | |
| 23 | #include <gui/DisplayEventReceiver.h> |
| 24 | |
Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 25 | #include "LayerTransactionTest.h" |
| 26 | #include "utils/CallbackUtils.h" |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | using android::hardware::graphics::common::V1_1::BufferUsage; |
| 31 | |
| 32 | ::testing::Environment* const binderEnv = |
| 33 | ::testing::AddGlobalTestEnvironment(new BinderEnvironment()); |
| 34 | |
| 35 | class LayerCallbackTest : public LayerTransactionTest { |
| 36 | public: |
Ady Abraham | 29d16cb | 2021-03-08 13:19:21 -0800 | [diff] [blame^] | 37 | void SetUp() override { |
| 38 | LayerTransactionTest::SetUp(); |
| 39 | |
| 40 | EXPECT_EQ(NO_ERROR, mDisplayEventReceiver.initCheck()); |
| 41 | |
| 42 | mEpollFd = epoll_create1(EPOLL_CLOEXEC); |
| 43 | EXPECT_GT(mEpollFd, 1); |
| 44 | |
| 45 | epoll_event event; |
| 46 | event.events = EPOLLIN; |
| 47 | EXPECT_EQ(0, epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mDisplayEventReceiver.getFd(), &event)); |
| 48 | } |
| 49 | |
| 50 | void TearDown() override { |
| 51 | close(mEpollFd); |
| 52 | LayerTransactionTest::TearDown(); |
| 53 | } |
| 54 | |
Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 55 | virtual sp<SurfaceControl> createBufferStateLayer() { |
| 56 | return createLayer(mClient, "test", 0, 0, ISurfaceComposerClient::eFXSurfaceBufferState); |
| 57 | } |
| 58 | |
| 59 | static int fillTransaction(Transaction& transaction, CallbackHelper* callbackHelper, |
| 60 | const sp<SurfaceControl>& layer = nullptr, bool setBuffer = true, |
| 61 | bool setBackgroundColor = false) { |
| 62 | if (layer) { |
| 63 | sp<GraphicBuffer> buffer; |
| 64 | sp<Fence> fence; |
| 65 | if (setBuffer) { |
| 66 | int err = getBuffer(&buffer, &fence); |
| 67 | if (err != NO_ERROR) { |
| 68 | return err; |
| 69 | } |
| 70 | |
| 71 | transaction.setBuffer(layer, buffer); |
| 72 | transaction.setAcquireFence(layer, fence); |
| 73 | } |
| 74 | |
| 75 | if (setBackgroundColor) { |
| 76 | transaction.setBackgroundColor(layer, /*color*/ half3(1.0f, 0, 0), /*alpha*/ 1.0f, |
| 77 | ui::Dataspace::UNKNOWN); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | transaction.addTransactionCompletedCallback(callbackHelper->function, |
| 82 | callbackHelper->getContext()); |
| 83 | return NO_ERROR; |
| 84 | } |
| 85 | |
| 86 | static void waitForCallback(CallbackHelper& helper, const ExpectedResult& expectedResult, |
| 87 | bool finalState = false) { |
| 88 | CallbackData callbackData; |
| 89 | ASSERT_NO_FATAL_FAILURE(helper.getCallbackData(&callbackData)); |
| 90 | EXPECT_NO_FATAL_FAILURE(expectedResult.verifyCallbackData(callbackData)); |
| 91 | |
| 92 | if (finalState) { |
| 93 | ASSERT_NO_FATAL_FAILURE(helper.verifyFinalState()); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | static void waitForCallbacks(CallbackHelper& helper, |
| 98 | const std::vector<ExpectedResult>& expectedResults, |
| 99 | bool finalState = false) { |
| 100 | for (const auto& expectedResult : expectedResults) { |
| 101 | waitForCallback(helper, expectedResult); |
| 102 | } |
| 103 | if (finalState) { |
| 104 | ASSERT_NO_FATAL_FAILURE(helper.verifyFinalState()); |
| 105 | } |
| 106 | } |
Ady Abraham | 29d16cb | 2021-03-08 13:19:21 -0800 | [diff] [blame^] | 107 | |
| 108 | DisplayEventReceiver mDisplayEventReceiver; |
| 109 | int mEpollFd; |
| 110 | |
| 111 | struct Vsync { |
| 112 | int64_t vsyncId = FrameTimelineInfo::INVALID_VSYNC_ID; |
| 113 | nsecs_t expectedPresentTime = std::numeric_limits<nsecs_t>::max(); |
| 114 | }; |
| 115 | |
| 116 | Vsync waitForNextVsync() { |
| 117 | mDisplayEventReceiver.requestNextVsync(); |
| 118 | epoll_event epollEvent; |
| 119 | Vsync vsync; |
| 120 | EXPECT_EQ(1, epoll_wait(mEpollFd, &epollEvent, 1, 1000)) |
| 121 | << "Timeout waiting for vsync event"; |
| 122 | DisplayEventReceiver::Event event; |
| 123 | while (mDisplayEventReceiver.getEvents(&event, 1) > 0) { |
| 124 | if (event.header.type != DisplayEventReceiver::DISPLAY_EVENT_VSYNC) { |
| 125 | continue; |
| 126 | } |
| 127 | |
| 128 | vsync = {event.vsync.vsyncId, event.vsync.expectedVSyncTimestamp}; |
| 129 | } |
| 130 | |
| 131 | EXPECT_GE(vsync.vsyncId, 1); |
| 132 | EXPECT_GT(event.vsync.expectedVSyncTimestamp, systemTime()); |
| 133 | |
| 134 | return vsync; |
| 135 | } |
Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | TEST_F(LayerCallbackTest, BufferColor) { |
| 139 | sp<SurfaceControl> layer; |
| 140 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 141 | |
| 142 | Transaction transaction; |
| 143 | CallbackHelper callback; |
| 144 | int err = fillTransaction(transaction, &callback, layer, true, true); |
| 145 | if (err) { |
| 146 | GTEST_SUCCEED() << "test not supported"; |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | transaction.apply(); |
| 151 | |
| 152 | ExpectedResult expected; |
| 153 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 154 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 155 | } |
| 156 | |
| 157 | TEST_F(LayerCallbackTest, NoBufferNoColor) { |
| 158 | sp<SurfaceControl> layer; |
| 159 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 160 | |
| 161 | Transaction transaction; |
| 162 | CallbackHelper callback; |
| 163 | int err = fillTransaction(transaction, &callback, layer, false, false); |
| 164 | if (err) { |
| 165 | GTEST_SUCCEED() << "test not supported"; |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | transaction.setFrame(layer, Rect(0, 0, 32, 32)).apply(); |
| 170 | |
| 171 | ExpectedResult expected; |
| 172 | expected.addSurface(ExpectedResult::Transaction::NOT_PRESENTED, layer, |
| 173 | ExpectedResult::Buffer::NOT_ACQUIRED); |
| 174 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 175 | } |
| 176 | |
| 177 | TEST_F(LayerCallbackTest, BufferNoColor) { |
| 178 | sp<SurfaceControl> layer; |
| 179 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 180 | |
| 181 | Transaction transaction; |
| 182 | CallbackHelper callback; |
| 183 | int err = fillTransaction(transaction, &callback, layer, true, false); |
| 184 | if (err) { |
| 185 | GTEST_SUCCEED() << "test not supported"; |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | transaction.setFrame(layer, Rect(0, 0, 32, 32)).apply(); |
| 190 | |
| 191 | ExpectedResult expected; |
| 192 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 193 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 194 | } |
| 195 | |
| 196 | TEST_F(LayerCallbackTest, NoBufferColor) { |
| 197 | sp<SurfaceControl> layer; |
| 198 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 199 | |
| 200 | Transaction transaction; |
| 201 | CallbackHelper callback; |
| 202 | int err = fillTransaction(transaction, &callback, layer, false, true); |
| 203 | if (err) { |
| 204 | GTEST_SUCCEED() << "test not supported"; |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | transaction.setFrame(layer, Rect(0, 0, 32, 32)).apply(); |
| 209 | |
| 210 | ExpectedResult expected; |
| 211 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer, |
| 212 | ExpectedResult::Buffer::NOT_ACQUIRED); |
| 213 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 214 | } |
| 215 | |
| 216 | TEST_F(LayerCallbackTest, NoStateChange) { |
| 217 | Transaction transaction; |
| 218 | CallbackHelper callback; |
| 219 | int err = fillTransaction(transaction, &callback); |
| 220 | if (err) { |
| 221 | GTEST_SUCCEED() << "test not supported"; |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | transaction.apply(); |
| 226 | |
| 227 | ExpectedResult expected; |
| 228 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 229 | } |
| 230 | |
| 231 | TEST_F(LayerCallbackTest, OffScreen) { |
| 232 | sp<SurfaceControl> layer; |
| 233 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 234 | |
| 235 | Transaction transaction; |
| 236 | CallbackHelper callback; |
| 237 | int err = fillTransaction(transaction, &callback, layer); |
| 238 | if (err) { |
| 239 | GTEST_SUCCEED() << "test not supported"; |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | transaction.setFrame(layer, Rect(-100, -100, 100, 100)).apply(); |
| 244 | |
| 245 | ExpectedResult expected; |
| 246 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 247 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 248 | } |
| 249 | |
| 250 | TEST_F(LayerCallbackTest, MergeBufferNoColor) { |
| 251 | sp<SurfaceControl> layer1, layer2; |
| 252 | ASSERT_NO_FATAL_FAILURE(layer1 = createBufferStateLayer()); |
| 253 | ASSERT_NO_FATAL_FAILURE(layer2 = createBufferStateLayer()); |
| 254 | |
| 255 | Transaction transaction1, transaction2; |
| 256 | CallbackHelper callback1, callback2; |
| 257 | int err = fillTransaction(transaction1, &callback1, layer1); |
| 258 | if (err) { |
| 259 | GTEST_SUCCEED() << "test not supported"; |
| 260 | return; |
| 261 | } |
| 262 | err = fillTransaction(transaction2, &callback2, layer2); |
| 263 | if (err) { |
| 264 | GTEST_SUCCEED() << "test not supported"; |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 269 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 270 | |
| 271 | ExpectedResult expected; |
| 272 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}); |
| 273 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 274 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 275 | } |
| 276 | |
| 277 | TEST_F(LayerCallbackTest, MergeNoBufferColor) { |
| 278 | sp<SurfaceControl> layer1, layer2; |
| 279 | ASSERT_NO_FATAL_FAILURE(layer1 = createBufferStateLayer()); |
| 280 | ASSERT_NO_FATAL_FAILURE(layer2 = createBufferStateLayer()); |
| 281 | |
| 282 | Transaction transaction1, transaction2; |
| 283 | CallbackHelper callback1, callback2; |
| 284 | int err = fillTransaction(transaction1, &callback1, layer1, false, true); |
| 285 | if (err) { |
| 286 | GTEST_SUCCEED() << "test not supported"; |
| 287 | return; |
| 288 | } |
| 289 | err = fillTransaction(transaction2, &callback2, layer2, false, true); |
| 290 | if (err) { |
| 291 | GTEST_SUCCEED() << "test not supported"; |
| 292 | return; |
| 293 | } |
| 294 | |
| 295 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 296 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 297 | |
| 298 | ExpectedResult expected; |
| 299 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}, |
| 300 | ExpectedResult::Buffer::NOT_ACQUIRED); |
| 301 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 302 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 303 | } |
| 304 | |
| 305 | TEST_F(LayerCallbackTest, MergeOneBufferOneColor) { |
| 306 | sp<SurfaceControl> layer1, layer2; |
| 307 | ASSERT_NO_FATAL_FAILURE(layer1 = createBufferStateLayer()); |
| 308 | ASSERT_NO_FATAL_FAILURE(layer2 = createBufferStateLayer()); |
| 309 | |
| 310 | Transaction transaction1, transaction2; |
| 311 | CallbackHelper callback1, callback2; |
| 312 | int err = fillTransaction(transaction1, &callback1, layer1); |
| 313 | if (err) { |
| 314 | GTEST_SUCCEED() << "test not supported"; |
| 315 | return; |
| 316 | } |
| 317 | err = fillTransaction(transaction2, &callback2, layer2, false, true); |
| 318 | if (err) { |
| 319 | GTEST_SUCCEED() << "test not supported"; |
| 320 | return; |
| 321 | } |
| 322 | |
| 323 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 324 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 325 | |
| 326 | ExpectedResult expected; |
| 327 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer1); |
| 328 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer2, |
| 329 | ExpectedResult::Buffer::NOT_ACQUIRED); |
| 330 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 331 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 332 | } |
| 333 | TEST_F(LayerCallbackTest, Merge_SameCallback) { |
| 334 | sp<SurfaceControl> layer1, layer2; |
| 335 | ASSERT_NO_FATAL_FAILURE(layer1 = createBufferStateLayer()); |
| 336 | ASSERT_NO_FATAL_FAILURE(layer2 = createBufferStateLayer()); |
| 337 | |
| 338 | Transaction transaction1, transaction2; |
| 339 | CallbackHelper callback; |
| 340 | int err = fillTransaction(transaction1, &callback, layer1); |
| 341 | if (err) { |
| 342 | GTEST_SUCCEED() << "test not supported"; |
| 343 | return; |
| 344 | } |
| 345 | err = fillTransaction(transaction2, &callback, layer2); |
| 346 | if (err) { |
| 347 | GTEST_SUCCEED() << "test not supported"; |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | transaction2.merge(std::move(transaction1)).apply(); |
| 352 | |
| 353 | ExpectedResult expected; |
| 354 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}); |
| 355 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected)); |
| 356 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 357 | } |
| 358 | |
| 359 | TEST_F(LayerCallbackTest, Merge_SameLayer) { |
| 360 | sp<SurfaceControl> layer; |
| 361 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 362 | |
| 363 | Transaction transaction1, transaction2; |
| 364 | CallbackHelper callback1, callback2; |
| 365 | int err = fillTransaction(transaction1, &callback1, layer); |
| 366 | if (err) { |
| 367 | GTEST_SUCCEED() << "test not supported"; |
| 368 | return; |
| 369 | } |
| 370 | err = fillTransaction(transaction2, &callback2, layer); |
| 371 | if (err) { |
| 372 | GTEST_SUCCEED() << "test not supported"; |
| 373 | return; |
| 374 | } |
| 375 | |
| 376 | transaction2.merge(std::move(transaction1)).apply(); |
| 377 | |
| 378 | ExpectedResult expected; |
| 379 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 380 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 381 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 382 | } |
| 383 | |
| 384 | TEST_F(LayerCallbackTest, Merge_DifferentClients) { |
| 385 | sp<SurfaceComposerClient> client1(new SurfaceComposerClient), |
| 386 | client2(new SurfaceComposerClient); |
| 387 | |
| 388 | ASSERT_EQ(NO_ERROR, client1->initCheck()) << "failed to create SurfaceComposerClient"; |
| 389 | ASSERT_EQ(NO_ERROR, client2->initCheck()) << "failed to create SurfaceComposerClient"; |
| 390 | |
| 391 | sp<SurfaceControl> layer1, layer2; |
| 392 | ASSERT_NO_FATAL_FAILURE(layer1 = createLayer(client1, "test", 0, 0, |
| 393 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 394 | ASSERT_NO_FATAL_FAILURE(layer2 = createLayer(client2, "test", 0, 0, |
| 395 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 396 | |
| 397 | Transaction transaction1, transaction2; |
| 398 | CallbackHelper callback1, callback2; |
| 399 | int err = fillTransaction(transaction1, &callback1, layer1); |
| 400 | if (err) { |
| 401 | GTEST_SUCCEED() << "test not supported"; |
| 402 | return; |
| 403 | } |
| 404 | err = fillTransaction(transaction2, &callback2, layer2); |
| 405 | if (err) { |
| 406 | GTEST_SUCCEED() << "test not supported"; |
| 407 | return; |
| 408 | } |
| 409 | |
| 410 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 411 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 412 | |
| 413 | ExpectedResult expected; |
| 414 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}); |
| 415 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 416 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 417 | } |
| 418 | |
| 419 | TEST_F(LayerCallbackTest, MultipleTransactions) { |
| 420 | sp<SurfaceControl> layer; |
| 421 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 422 | |
| 423 | Transaction transaction; |
| 424 | CallbackHelper callback; |
| 425 | for (size_t i = 0; i < 10; i++) { |
| 426 | int err = fillTransaction(transaction, &callback, layer); |
| 427 | if (err) { |
| 428 | GTEST_SUCCEED() << "test not supported"; |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | transaction.apply(); |
| 433 | |
| 434 | ExpectedResult expected; |
| 435 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer, |
| 436 | ExpectedResult::Buffer::ACQUIRED, |
| 437 | (i == 0) ? ExpectedResult::PreviousBuffer::NOT_RELEASED |
| 438 | : ExpectedResult::PreviousBuffer::RELEASED); |
| 439 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected)); |
| 440 | } |
| 441 | ASSERT_NO_FATAL_FAILURE(callback.verifyFinalState()); |
| 442 | } |
| 443 | |
| 444 | TEST_F(LayerCallbackTest, MultipleTransactions_NoStateChange) { |
| 445 | sp<SurfaceControl> layer; |
| 446 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 447 | |
| 448 | Transaction transaction; |
| 449 | CallbackHelper callback; |
| 450 | for (size_t i = 0; i < 10; i++) { |
| 451 | ExpectedResult expected; |
| 452 | |
| 453 | if (i == 0) { |
| 454 | int err = fillTransaction(transaction, &callback, layer); |
| 455 | if (err) { |
| 456 | GTEST_SUCCEED() << "test not supported"; |
| 457 | return; |
| 458 | } |
| 459 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 460 | } else { |
| 461 | int err = fillTransaction(transaction, &callback); |
| 462 | if (err) { |
| 463 | GTEST_SUCCEED() << "test not supported"; |
| 464 | return; |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | transaction.apply(); |
| 469 | |
| 470 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected)); |
| 471 | } |
| 472 | ASSERT_NO_FATAL_FAILURE(callback.verifyFinalState()); |
| 473 | } |
| 474 | |
| 475 | TEST_F(LayerCallbackTest, MultipleTransactions_SameStateChange) { |
| 476 | sp<SurfaceControl> layer; |
| 477 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 478 | |
| 479 | Transaction transaction; |
| 480 | CallbackHelper callback; |
| 481 | for (size_t i = 0; i < 10; i++) { |
| 482 | if (i == 0) { |
| 483 | int err = fillTransaction(transaction, &callback, layer); |
| 484 | if (err) { |
| 485 | GTEST_SUCCEED() << "test not supported"; |
| 486 | return; |
| 487 | } |
| 488 | } else { |
| 489 | int err = fillTransaction(transaction, &callback); |
| 490 | if (err) { |
| 491 | GTEST_SUCCEED() << "test not supported"; |
| 492 | return; |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | transaction.setFrame(layer, Rect(0, 0, 32, 32)).apply(); |
| 497 | |
| 498 | ExpectedResult expected; |
| 499 | expected.addSurface((i == 0) ? ExpectedResult::Transaction::PRESENTED |
| 500 | : ExpectedResult::Transaction::NOT_PRESENTED, |
| 501 | layer, |
| 502 | (i == 0) ? ExpectedResult::Buffer::ACQUIRED |
| 503 | : ExpectedResult::Buffer::NOT_ACQUIRED); |
| 504 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, i == 0)); |
| 505 | } |
| 506 | ASSERT_NO_FATAL_FAILURE(callback.verifyFinalState()); |
| 507 | } |
| 508 | |
| 509 | TEST_F(LayerCallbackTest, MultipleTransactions_Merge) { |
| 510 | sp<SurfaceControl> layer1, layer2; |
| 511 | ASSERT_NO_FATAL_FAILURE(layer1 = createBufferStateLayer()); |
| 512 | ASSERT_NO_FATAL_FAILURE(layer2 = createBufferStateLayer()); |
| 513 | |
| 514 | Transaction transaction1, transaction2; |
| 515 | CallbackHelper callback1, callback2; |
| 516 | for (size_t i = 0; i < 10; i++) { |
| 517 | int err = fillTransaction(transaction1, &callback1, layer1); |
| 518 | if (err) { |
| 519 | GTEST_SUCCEED() << "test not supported"; |
| 520 | return; |
| 521 | } |
| 522 | err = fillTransaction(transaction2, &callback2, layer2); |
| 523 | if (err) { |
| 524 | GTEST_SUCCEED() << "test not supported"; |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 529 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 530 | |
| 531 | ExpectedResult expected; |
| 532 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}, |
| 533 | ExpectedResult::Buffer::ACQUIRED, |
| 534 | (i == 0) ? ExpectedResult::PreviousBuffer::NOT_RELEASED |
| 535 | : ExpectedResult::PreviousBuffer::RELEASED); |
| 536 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected)); |
| 537 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected)); |
| 538 | } |
| 539 | ASSERT_NO_FATAL_FAILURE(callback1.verifyFinalState()); |
| 540 | ASSERT_NO_FATAL_FAILURE(callback2.verifyFinalState()); |
| 541 | } |
| 542 | |
| 543 | TEST_F(LayerCallbackTest, MultipleTransactions_Merge_DifferentClients) { |
| 544 | sp<SurfaceComposerClient> client1(new SurfaceComposerClient), |
| 545 | client2(new SurfaceComposerClient); |
| 546 | ASSERT_EQ(NO_ERROR, client1->initCheck()) << "failed to create SurfaceComposerClient"; |
| 547 | ASSERT_EQ(NO_ERROR, client2->initCheck()) << "failed to create SurfaceComposerClient"; |
| 548 | |
| 549 | sp<SurfaceControl> layer1, layer2; |
| 550 | ASSERT_NO_FATAL_FAILURE(layer1 = createLayer(client1, "test", 0, 0, |
| 551 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 552 | ASSERT_NO_FATAL_FAILURE(layer2 = createLayer(client2, "test", 0, 0, |
| 553 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 554 | |
| 555 | Transaction transaction1, transaction2; |
| 556 | CallbackHelper callback1, callback2; |
| 557 | for (size_t i = 0; i < 10; i++) { |
| 558 | int err = fillTransaction(transaction1, &callback1, layer1); |
| 559 | if (err) { |
| 560 | GTEST_SUCCEED() << "test not supported"; |
| 561 | return; |
| 562 | } |
| 563 | err = fillTransaction(transaction2, &callback2, layer2); |
| 564 | if (err) { |
| 565 | GTEST_SUCCEED() << "test not supported"; |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 570 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 571 | |
| 572 | ExpectedResult expected; |
| 573 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}, |
| 574 | ExpectedResult::Buffer::ACQUIRED, |
| 575 | (i == 0) ? ExpectedResult::PreviousBuffer::NOT_RELEASED |
| 576 | : ExpectedResult::PreviousBuffer::RELEASED); |
| 577 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected)); |
| 578 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected)); |
| 579 | } |
| 580 | ASSERT_NO_FATAL_FAILURE(callback1.verifyFinalState()); |
| 581 | ASSERT_NO_FATAL_FAILURE(callback2.verifyFinalState()); |
| 582 | } |
| 583 | |
| 584 | TEST_F(LayerCallbackTest, MultipleTransactions_Merge_DifferentClients_NoStateChange) { |
| 585 | sp<SurfaceComposerClient> client1(new SurfaceComposerClient), |
| 586 | client2(new SurfaceComposerClient); |
| 587 | ASSERT_EQ(NO_ERROR, client1->initCheck()) << "failed to create SurfaceComposerClient"; |
| 588 | ASSERT_EQ(NO_ERROR, client2->initCheck()) << "failed to create SurfaceComposerClient"; |
| 589 | |
| 590 | sp<SurfaceControl> layer1, layer2; |
| 591 | ASSERT_NO_FATAL_FAILURE(layer1 = createLayer(client1, "test", 0, 0, |
| 592 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 593 | ASSERT_NO_FATAL_FAILURE(layer2 = createLayer(client2, "test", 0, 0, |
| 594 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 595 | |
| 596 | Transaction transaction1, transaction2; |
| 597 | CallbackHelper callback1, callback2; |
| 598 | |
| 599 | // Normal call to set up test |
| 600 | int err = fillTransaction(transaction1, &callback1, layer1); |
| 601 | if (err) { |
| 602 | GTEST_SUCCEED() << "test not supported"; |
| 603 | return; |
| 604 | } |
| 605 | err = fillTransaction(transaction2, &callback2, layer2); |
| 606 | if (err) { |
| 607 | GTEST_SUCCEED() << "test not supported"; |
| 608 | return; |
| 609 | } |
| 610 | |
| 611 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 612 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 613 | |
| 614 | ExpectedResult expected; |
| 615 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}); |
| 616 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 617 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 618 | expected.reset(); |
| 619 | |
| 620 | // Test |
| 621 | err = fillTransaction(transaction1, &callback1); |
| 622 | if (err) { |
| 623 | GTEST_SUCCEED() << "test not supported"; |
| 624 | return; |
| 625 | } |
| 626 | err = fillTransaction(transaction2, &callback2); |
| 627 | if (err) { |
| 628 | GTEST_SUCCEED() << "test not supported"; |
| 629 | return; |
| 630 | } |
| 631 | |
| 632 | transaction2.merge(std::move(transaction1)).apply(); |
| 633 | |
| 634 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 635 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 636 | } |
| 637 | |
| 638 | TEST_F(LayerCallbackTest, MultipleTransactions_Merge_DifferentClients_SameStateChange) { |
| 639 | sp<SurfaceComposerClient> client1(new SurfaceComposerClient), |
| 640 | client2(new SurfaceComposerClient); |
| 641 | |
| 642 | ASSERT_EQ(NO_ERROR, client1->initCheck()) << "failed to create SurfaceComposerClient"; |
| 643 | ASSERT_EQ(NO_ERROR, client2->initCheck()) << "failed to create SurfaceComposerClient"; |
| 644 | |
| 645 | sp<SurfaceControl> layer1, layer2; |
| 646 | ASSERT_NO_FATAL_FAILURE(layer1 = createLayer(client1, "test", 0, 0, |
| 647 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 648 | ASSERT_NO_FATAL_FAILURE(layer2 = createLayer(client2, "test", 0, 0, |
| 649 | ISurfaceComposerClient::eFXSurfaceBufferState)); |
| 650 | |
| 651 | Transaction transaction1, transaction2; |
| 652 | CallbackHelper callback1, callback2; |
| 653 | |
| 654 | // Normal call to set up test |
| 655 | int err = fillTransaction(transaction1, &callback1, layer1); |
| 656 | if (err) { |
| 657 | GTEST_SUCCEED() << "test not supported"; |
| 658 | return; |
| 659 | } |
| 660 | err = fillTransaction(transaction2, &callback2, layer2); |
| 661 | if (err) { |
| 662 | GTEST_SUCCEED() << "test not supported"; |
| 663 | return; |
| 664 | } |
| 665 | |
| 666 | transaction1.setFrame(layer1, Rect(0, 0, 32, 32)); |
| 667 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 668 | |
| 669 | ExpectedResult expected; |
| 670 | expected.addSurfaces(ExpectedResult::Transaction::PRESENTED, {layer1, layer2}); |
| 671 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 672 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 673 | expected.reset(); |
| 674 | |
| 675 | // Test |
| 676 | err = fillTransaction(transaction1, &callback1); |
| 677 | if (err) { |
| 678 | GTEST_SUCCEED() << "test not supported"; |
| 679 | return; |
| 680 | } |
| 681 | err = fillTransaction(transaction2, &callback2); |
| 682 | if (err) { |
| 683 | GTEST_SUCCEED() << "test not supported"; |
| 684 | return; |
| 685 | } |
| 686 | |
| 687 | transaction2.setFrame(layer2, Rect(32, 32, 64, 64)).merge(std::move(transaction1)).apply(); |
| 688 | |
| 689 | expected.addSurface(ExpectedResult::Transaction::NOT_PRESENTED, layer2, |
| 690 | ExpectedResult::Buffer::NOT_ACQUIRED); |
| 691 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected, true)); |
| 692 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected, true)); |
| 693 | } |
| 694 | |
| 695 | TEST_F(LayerCallbackTest, MultipleTransactions_SingleFrame) { |
| 696 | sp<SurfaceControl> layer; |
| 697 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 698 | |
| 699 | Transaction transaction; |
| 700 | CallbackHelper callback; |
| 701 | std::vector<ExpectedResult> expectedResults(50); |
| 702 | for (auto& expected : expectedResults) { |
| 703 | expected.reset(); |
| 704 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer, |
| 705 | ExpectedResult::Buffer::ACQUIRED, |
| 706 | ExpectedResult::PreviousBuffer::UNKNOWN); |
| 707 | |
| 708 | int err = fillTransaction(transaction, &callback, layer); |
| 709 | if (err) { |
| 710 | GTEST_SUCCEED() << "test not supported"; |
| 711 | return; |
| 712 | } |
| 713 | |
| 714 | transaction.apply(); |
| 715 | } |
| 716 | EXPECT_NO_FATAL_FAILURE(waitForCallbacks(callback, expectedResults, true)); |
| 717 | } |
| 718 | |
| 719 | TEST_F(LayerCallbackTest, MultipleTransactions_SingleFrame_NoStateChange) { |
| 720 | sp<SurfaceControl> layer; |
| 721 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 722 | |
| 723 | // Normal call to set up test |
| 724 | Transaction transaction; |
| 725 | CallbackHelper callback; |
| 726 | int err = fillTransaction(transaction, &callback, layer); |
| 727 | if (err) { |
| 728 | GTEST_SUCCEED() << "test not supported"; |
| 729 | return; |
| 730 | } |
| 731 | |
| 732 | transaction.apply(); |
| 733 | |
| 734 | ExpectedResult expected; |
| 735 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 736 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 737 | |
| 738 | // Test |
| 739 | std::vector<ExpectedResult> expectedResults(50); |
| 740 | for (auto& expected : expectedResults) { |
| 741 | expected.reset(); |
| 742 | |
| 743 | err = fillTransaction(transaction, &callback); |
| 744 | if (err) { |
| 745 | GTEST_SUCCEED() << "test not supported"; |
| 746 | return; |
| 747 | } |
| 748 | |
| 749 | transaction.apply(); |
| 750 | } |
| 751 | EXPECT_NO_FATAL_FAILURE(waitForCallbacks(callback, expectedResults, true)); |
| 752 | } |
| 753 | |
| 754 | TEST_F(LayerCallbackTest, MultipleTransactions_SingleFrame_SameStateChange) { |
| 755 | sp<SurfaceControl> layer; |
| 756 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 757 | |
| 758 | // Normal call to set up test |
| 759 | Transaction transaction; |
| 760 | CallbackHelper callback; |
| 761 | int err = fillTransaction(transaction, &callback, layer); |
| 762 | if (err) { |
| 763 | GTEST_SUCCEED() << "test not supported"; |
| 764 | return; |
| 765 | } |
| 766 | |
| 767 | transaction.setFrame(layer, Rect(0, 0, 32, 32)).apply(); |
| 768 | |
| 769 | ExpectedResult expectedResult; |
| 770 | expectedResult.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 771 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expectedResult, true)); |
| 772 | |
| 773 | // Test |
| 774 | std::vector<ExpectedResult> expectedResults(50); |
| 775 | for (auto& expected : expectedResults) { |
| 776 | expected.reset(); |
| 777 | expected.addSurface(ExpectedResult::Transaction::NOT_PRESENTED, layer, |
| 778 | ExpectedResult::Buffer::NOT_ACQUIRED); |
| 779 | |
| 780 | err = fillTransaction(transaction, &callback); |
| 781 | if (err) { |
| 782 | GTEST_SUCCEED() << "test not supported"; |
| 783 | return; |
| 784 | } |
| 785 | |
| 786 | transaction.setFrame(layer, Rect(0, 0, 32, 32)).apply(); |
| 787 | } |
| 788 | EXPECT_NO_FATAL_FAILURE(waitForCallbacks(callback, expectedResults, true)); |
| 789 | } |
| 790 | |
| 791 | TEST_F(LayerCallbackTest, DesiredPresentTime) { |
| 792 | sp<SurfaceControl> layer; |
| 793 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 794 | |
| 795 | Transaction transaction; |
| 796 | CallbackHelper callback; |
| 797 | int err = fillTransaction(transaction, &callback, layer); |
| 798 | if (err) { |
| 799 | GTEST_SUCCEED() << "test not supported"; |
| 800 | return; |
| 801 | } |
| 802 | |
| 803 | // Try to present 100ms in the future |
| 804 | nsecs_t time = systemTime() + (100 * 1e6); |
| 805 | |
| 806 | transaction.setDesiredPresentTime(time); |
| 807 | transaction.apply(); |
| 808 | |
| 809 | ExpectedResult expected; |
| 810 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 811 | expected.addExpectedPresentTime(time); |
| 812 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 813 | } |
| 814 | |
| 815 | TEST_F(LayerCallbackTest, DesiredPresentTime_Multiple) { |
| 816 | sp<SurfaceControl> layer; |
| 817 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 818 | |
| 819 | Transaction transaction; |
| 820 | CallbackHelper callback1; |
| 821 | int err = fillTransaction(transaction, &callback1, layer); |
| 822 | if (err) { |
| 823 | GTEST_SUCCEED() << "test not supported"; |
| 824 | return; |
| 825 | } |
| 826 | |
| 827 | // Try to present 100ms in the future |
| 828 | nsecs_t time = systemTime() + (100 * 1e6); |
| 829 | |
| 830 | transaction.setDesiredPresentTime(time); |
| 831 | transaction.apply(); |
| 832 | |
| 833 | ExpectedResult expected1; |
| 834 | expected1.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 835 | expected1.addExpectedPresentTime(time); |
| 836 | |
| 837 | CallbackHelper callback2; |
| 838 | err = fillTransaction(transaction, &callback2, layer); |
| 839 | if (err) { |
| 840 | GTEST_SUCCEED() << "test not supported"; |
| 841 | return; |
| 842 | } |
| 843 | |
| 844 | // Try to present 33ms after the first frame |
| 845 | time += (33.3 * 1e6); |
| 846 | |
| 847 | transaction.setDesiredPresentTime(time); |
| 848 | transaction.apply(); |
| 849 | |
| 850 | ExpectedResult expected2; |
| 851 | expected2.addSurface(ExpectedResult::Transaction::PRESENTED, layer, |
| 852 | ExpectedResult::Buffer::ACQUIRED, |
| 853 | ExpectedResult::PreviousBuffer::RELEASED); |
| 854 | expected2.addExpectedPresentTime(time); |
| 855 | |
| 856 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected1, true)); |
| 857 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected2, true)); |
| 858 | } |
| 859 | |
| 860 | TEST_F(LayerCallbackTest, DesiredPresentTime_OutOfOrder) { |
| 861 | sp<SurfaceControl> layer; |
| 862 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 863 | |
| 864 | Transaction transaction; |
| 865 | CallbackHelper callback1; |
| 866 | int err = fillTransaction(transaction, &callback1, layer); |
| 867 | if (err) { |
| 868 | GTEST_SUCCEED() << "test not supported"; |
| 869 | return; |
| 870 | } |
| 871 | |
| 872 | // Try to present 100ms in the future |
| 873 | nsecs_t time = systemTime() + (100 * 1e6); |
| 874 | |
| 875 | transaction.setDesiredPresentTime(time); |
| 876 | transaction.apply(); |
| 877 | |
| 878 | ExpectedResult expected1; |
| 879 | expected1.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 880 | expected1.addExpectedPresentTime(time); |
| 881 | |
| 882 | CallbackHelper callback2; |
| 883 | err = fillTransaction(transaction, &callback2, layer); |
| 884 | if (err) { |
| 885 | GTEST_SUCCEED() << "test not supported"; |
| 886 | return; |
| 887 | } |
| 888 | |
| 889 | // Try to present 33ms before the previous frame |
| 890 | time -= (33.3 * 1e6); |
| 891 | |
| 892 | transaction.setDesiredPresentTime(time); |
| 893 | transaction.apply(); |
| 894 | |
| 895 | ExpectedResult expected2; |
| 896 | expected2.addSurface(ExpectedResult::Transaction::PRESENTED, layer, |
| 897 | ExpectedResult::Buffer::ACQUIRED, |
| 898 | ExpectedResult::PreviousBuffer::RELEASED); |
| 899 | |
| 900 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback1, expected1, true)); |
| 901 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback2, expected2, true)); |
| 902 | } |
| 903 | |
| 904 | TEST_F(LayerCallbackTest, DesiredPresentTime_Past) { |
| 905 | sp<SurfaceControl> layer; |
| 906 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 907 | |
| 908 | Transaction transaction; |
| 909 | CallbackHelper callback; |
| 910 | int err = fillTransaction(transaction, &callback, layer); |
| 911 | if (err) { |
| 912 | GTEST_SUCCEED() << "test not supported"; |
| 913 | return; |
| 914 | } |
| 915 | |
| 916 | // Try to present 100ms in the past |
| 917 | nsecs_t time = systemTime() - (100 * 1e6); |
| 918 | |
| 919 | transaction.setDesiredPresentTime(time); |
| 920 | transaction.apply(); |
| 921 | |
| 922 | ExpectedResult expected; |
| 923 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 924 | expected.addExpectedPresentTime(systemTime()); |
| 925 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 926 | } |
Ady Abraham | 29d16cb | 2021-03-08 13:19:21 -0800 | [diff] [blame^] | 927 | |
| 928 | TEST_F(LayerCallbackTest, ExpectedPresentTime) { |
| 929 | sp<SurfaceControl> layer; |
| 930 | ASSERT_NO_FATAL_FAILURE(layer = createBufferStateLayer()); |
| 931 | |
| 932 | Transaction transaction; |
| 933 | CallbackHelper callback; |
| 934 | int err = fillTransaction(transaction, &callback, layer); |
| 935 | if (err) { |
| 936 | GTEST_SUCCEED() << "test not supported"; |
| 937 | return; |
| 938 | } |
| 939 | |
| 940 | const Vsync vsync = waitForNextVsync(); |
| 941 | transaction.setFrameTimelineInfo({vsync.vsyncId, 0}); |
| 942 | transaction.apply(); |
| 943 | |
| 944 | ExpectedResult expected; |
| 945 | expected.addSurface(ExpectedResult::Transaction::PRESENTED, layer); |
| 946 | expected.addExpectedPresentTimeForVsyncId(vsync.expectedPresentTime); |
| 947 | EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); |
| 948 | } |
| 949 | |
Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 950 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 951 | |
| 952 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 953 | #pragma clang diagnostic pop // ignored "-Wconversion" |