OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/scheduler/scheduler_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
6 | 6 |
7 #include "cc/scheduler/scheduler.h" | 7 #include "cc/scheduler/scheduler.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 #define EXPECT_ACTION_UPDATE_STATE(action) \ | 10 #define EXPECT_ACTION_UPDATE_STATE(action) \ |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 EXPECT_ACTION_UPDATE_STATE( | 232 EXPECT_ACTION_UPDATE_STATE( |
233 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); | 233 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); |
234 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 234 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
235 EXPECT_EQ(state.CommitState(), | 235 EXPECT_EQ(state.CommitState(), |
236 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW); | 236 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW); |
237 | 237 |
238 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 238 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
239 state.OnBeginImplFrameDeadline(); | 239 state.OnBeginImplFrameDeadline(); |
240 EXPECT_ACTION_UPDATE_STATE( | 240 EXPECT_ACTION_UPDATE_STATE( |
241 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 241 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 242 state.DidSwapBuffers(); |
| 243 state.DidSwapBuffersComplete(); |
242 EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE); | 244 EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE); |
243 EXPECT_ACTION_UPDATE_STATE( | 245 EXPECT_ACTION_UPDATE_STATE( |
244 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 246 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
245 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 247 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
246 EXPECT_EQ(state.CommitState(), | 248 EXPECT_EQ(state.CommitState(), |
247 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); | 249 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); |
248 | 250 |
249 state.NotifyBeginMainFrameStarted(); | 251 state.NotifyBeginMainFrameStarted(); |
250 state.NotifyReadyToCommit(); | 252 state.NotifyReadyToCommit(); |
251 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 253 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // commit in that order. | 305 // commit in that order. |
304 state.NotifyReadyToActivate(); | 306 state.NotifyReadyToActivate(); |
305 EXPECT_ACTION_UPDATE_STATE( | 307 EXPECT_ACTION_UPDATE_STATE( |
306 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); | 308 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); |
307 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 309 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
308 | 310 |
309 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 311 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
310 state.OnBeginImplFrameDeadline(); | 312 state.OnBeginImplFrameDeadline(); |
311 EXPECT_ACTION_UPDATE_STATE( | 313 EXPECT_ACTION_UPDATE_STATE( |
312 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 314 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 315 state.DidSwapBuffers(); |
| 316 state.DidSwapBuffersComplete(); |
313 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 317 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
314 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 318 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
315 EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE); | 319 EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE); |
316 } | 320 } |
317 | 321 |
318 TEST(SchedulerStateMachineTest, | 322 TEST(SchedulerStateMachineTest, |
319 TestFailedDrawForAnimationCheckerboardSetsNeedsCommitAndDoesNotDrawAgain) { | 323 TestFailedDrawForAnimationCheckerboardSetsNeedsCommitAndDoesNotDrawAgain) { |
320 SchedulerSettings default_scheduler_settings; | 324 SchedulerSettings default_scheduler_settings; |
321 StateMachine state(default_scheduler_settings); | 325 StateMachine state(default_scheduler_settings); |
322 state.SetCanStart(); | 326 state.SetCanStart(); |
323 state.UpdateState(state.NextAction()); | 327 state.UpdateState(state.NextAction()); |
324 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 328 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
325 state.SetVisible(true); | 329 state.SetVisible(true); |
326 state.SetCanDraw(true); | 330 state.SetCanDraw(true); |
327 state.SetNeedsRedraw(true); | 331 state.SetNeedsRedraw(true); |
328 EXPECT_TRUE(state.RedrawPending()); | 332 EXPECT_TRUE(state.RedrawPending()); |
329 EXPECT_TRUE(state.BeginFrameNeeded()); | 333 EXPECT_TRUE(state.BeginFrameNeeded()); |
330 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 334 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
331 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 335 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
332 state.OnBeginImplFrameDeadline(); | 336 state.OnBeginImplFrameDeadline(); |
333 | 337 |
334 // We're drawing now. | 338 // We're drawing now. |
335 EXPECT_ACTION_UPDATE_STATE( | 339 EXPECT_ACTION_UPDATE_STATE( |
336 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 340 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 341 state.DidSwapBuffers(); |
| 342 state.DidSwapBuffersComplete(); |
337 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 343 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
338 | 344 |
339 EXPECT_FALSE(state.RedrawPending()); | 345 EXPECT_FALSE(state.RedrawPending()); |
340 EXPECT_FALSE(state.CommitPending()); | 346 EXPECT_FALSE(state.CommitPending()); |
341 | 347 |
342 // Failing the draw makes us require a commit. | 348 // Failing the draw makes us require a commit. |
343 state.DidDrawIfPossibleCompleted( | 349 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
344 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); | |
345 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 350 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
346 EXPECT_ACTION_UPDATE_STATE( | 351 EXPECT_ACTION_UPDATE_STATE( |
347 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 352 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
348 EXPECT_TRUE(state.RedrawPending()); | 353 EXPECT_TRUE(state.RedrawPending()); |
349 EXPECT_TRUE(state.CommitPending()); | 354 EXPECT_TRUE(state.CommitPending()); |
350 } | 355 } |
351 | 356 |
352 TEST(SchedulerStateMachineTest, TestFailedDrawForMissingHighResNeedsCommit) { | 357 TEST(SchedulerStateMachineTest, TestFailedDrawForMissingHighResNeedsCommit) { |
353 SchedulerSettings default_scheduler_settings; | 358 SchedulerSettings default_scheduler_settings; |
354 StateMachine state(default_scheduler_settings); | 359 StateMachine state(default_scheduler_settings); |
355 state.SetCanStart(); | 360 state.SetCanStart(); |
356 state.UpdateState(state.NextAction()); | 361 state.UpdateState(state.NextAction()); |
357 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 362 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
358 state.SetVisible(true); | 363 state.SetVisible(true); |
359 state.SetCanDraw(true); | 364 state.SetCanDraw(true); |
360 state.SetNeedsRedraw(true); | 365 state.SetNeedsRedraw(true); |
361 EXPECT_TRUE(state.RedrawPending()); | 366 EXPECT_TRUE(state.RedrawPending()); |
362 EXPECT_TRUE(state.BeginFrameNeeded()); | 367 EXPECT_TRUE(state.BeginFrameNeeded()); |
363 | 368 |
364 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 369 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
365 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 370 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
366 state.OnBeginImplFrameDeadline(); | 371 state.OnBeginImplFrameDeadline(); |
367 EXPECT_ACTION_UPDATE_STATE( | 372 EXPECT_ACTION_UPDATE_STATE( |
368 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 373 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 374 state.DidSwapBuffers(); |
| 375 state.DidSwapBuffersComplete(); |
369 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 376 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
370 EXPECT_FALSE(state.RedrawPending()); | 377 EXPECT_FALSE(state.RedrawPending()); |
371 EXPECT_FALSE(state.CommitPending()); | 378 EXPECT_FALSE(state.CommitPending()); |
372 | 379 |
373 // Missing high res content requires a commit (but not a redraw) | 380 // Missing high res content requires a commit (but not a redraw) |
374 state.DidDrawIfPossibleCompleted( | 381 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); |
375 DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); | |
376 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 382 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
377 EXPECT_ACTION_UPDATE_STATE( | 383 EXPECT_ACTION_UPDATE_STATE( |
378 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 384 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
379 EXPECT_FALSE(state.RedrawPending()); | 385 EXPECT_FALSE(state.RedrawPending()); |
380 EXPECT_TRUE(state.CommitPending()); | 386 EXPECT_TRUE(state.CommitPending()); |
381 } | 387 } |
382 | 388 |
383 TEST(SchedulerStateMachineTest, | 389 TEST(SchedulerStateMachineTest, |
384 TestsetNeedsRedrawDuringFailedDrawDoesNotRemoveNeedsRedraw) { | 390 TestsetNeedsRedrawDuringFailedDrawDoesNotRemoveNeedsRedraw) { |
385 SchedulerSettings default_scheduler_settings; | 391 SchedulerSettings default_scheduler_settings; |
386 StateMachine state(default_scheduler_settings); | 392 StateMachine state(default_scheduler_settings); |
387 state.SetCanStart(); | 393 state.SetCanStart(); |
388 state.UpdateState(state.NextAction()); | 394 state.UpdateState(state.NextAction()); |
389 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 395 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
390 | 396 |
391 state.SetVisible(true); | 397 state.SetVisible(true); |
392 state.SetCanDraw(true); | 398 state.SetCanDraw(true); |
393 state.SetNeedsRedraw(true); | 399 state.SetNeedsRedraw(true); |
394 EXPECT_TRUE(state.RedrawPending()); | 400 EXPECT_TRUE(state.RedrawPending()); |
395 EXPECT_TRUE(state.BeginFrameNeeded()); | 401 EXPECT_TRUE(state.BeginFrameNeeded()); |
396 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 402 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
397 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 403 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
398 state.OnBeginImplFrameDeadline(); | 404 state.OnBeginImplFrameDeadline(); |
399 | 405 |
400 // We're drawing now. | 406 // We're drawing now. |
401 EXPECT_ACTION_UPDATE_STATE( | 407 EXPECT_ACTION_UPDATE_STATE( |
402 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 408 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 409 state.DidSwapBuffers(); |
| 410 state.DidSwapBuffersComplete(); |
403 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 411 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
404 EXPECT_FALSE(state.RedrawPending()); | 412 EXPECT_FALSE(state.RedrawPending()); |
405 EXPECT_FALSE(state.CommitPending()); | 413 EXPECT_FALSE(state.CommitPending()); |
406 | 414 |
407 // While still in the same BeginMainFrame callback on the main thread, | 415 // While still in the same BeginMainFrame callback on the main thread, |
408 // set needs redraw again. This should not redraw. | 416 // set needs redraw again. This should not redraw. |
409 state.SetNeedsRedraw(true); | 417 state.SetNeedsRedraw(true); |
410 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 418 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
411 | 419 |
412 // Failing the draw for animation checkerboards makes us require a commit. | 420 // Failing the draw for animation checkerboards makes us require a commit. |
413 state.DidDrawIfPossibleCompleted( | 421 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
414 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); | |
415 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 422 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
416 EXPECT_ACTION_UPDATE_STATE( | 423 EXPECT_ACTION_UPDATE_STATE( |
417 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 424 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
418 EXPECT_TRUE(state.RedrawPending()); | 425 EXPECT_TRUE(state.RedrawPending()); |
419 } | 426 } |
420 | 427 |
421 void TestFailedDrawsEventuallyForceDrawAfterNextCommit( | 428 void TestFailedDrawsEventuallyForceDrawAfterNextCommit( |
422 bool main_frame_before_draw_enabled) { | 429 bool main_frame_before_draw_enabled) { |
423 SchedulerSettings scheduler_settings; | 430 SchedulerSettings scheduler_settings; |
424 scheduler_settings.main_frame_before_draw_enabled = | 431 scheduler_settings.main_frame_before_draw_enabled = |
(...skipping 15 matching lines...) Expand all Loading... |
440 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 447 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
441 EXPECT_TRUE(state.CommitPending()); | 448 EXPECT_TRUE(state.CommitPending()); |
442 | 449 |
443 // Then initiate a draw. | 450 // Then initiate a draw. |
444 state.SetNeedsRedraw(true); | 451 state.SetNeedsRedraw(true); |
445 state.OnBeginImplFrameDeadline(); | 452 state.OnBeginImplFrameDeadline(); |
446 EXPECT_ACTION_UPDATE_STATE( | 453 EXPECT_ACTION_UPDATE_STATE( |
447 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 454 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
448 | 455 |
449 // Fail the draw. | 456 // Fail the draw. |
450 state.DidDrawIfPossibleCompleted( | 457 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
451 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); | |
452 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 458 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
453 EXPECT_TRUE(state.BeginFrameNeeded()); | 459 EXPECT_TRUE(state.BeginFrameNeeded()); |
454 EXPECT_TRUE(state.RedrawPending()); | 460 EXPECT_TRUE(state.RedrawPending()); |
455 // But the commit is ongoing. | 461 // But the commit is ongoing. |
456 EXPECT_TRUE(state.CommitPending()); | 462 EXPECT_TRUE(state.CommitPending()); |
457 | 463 |
458 // Finish the commit. Note, we should not yet be forcing a draw, but should | 464 // Finish the commit. Note, we should not yet be forcing a draw, but should |
459 // continue the commit as usual. | 465 // continue the commit as usual. |
460 state.NotifyBeginMainFrameStarted(); | 466 state.NotifyBeginMainFrameStarted(); |
461 state.NotifyReadyToCommit(); | 467 state.NotifyReadyToCommit(); |
462 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 468 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
463 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 469 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
464 EXPECT_TRUE(state.RedrawPending()); | 470 EXPECT_TRUE(state.RedrawPending()); |
465 | 471 |
466 // The redraw should be forced at the end of the next BeginImplFrame. | 472 // The redraw should be forced at the end of the next BeginImplFrame. |
467 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 473 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
468 if (main_frame_before_draw_enabled) { | 474 if (main_frame_before_draw_enabled) { |
469 EXPECT_ACTION_UPDATE_STATE( | 475 EXPECT_ACTION_UPDATE_STATE( |
470 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 476 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
471 } | 477 } |
472 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 478 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
473 state.OnBeginImplFrameDeadline(); | 479 state.OnBeginImplFrameDeadline(); |
474 EXPECT_ACTION_UPDATE_STATE( | 480 EXPECT_ACTION_UPDATE_STATE( |
475 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED); | 481 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED); |
| 482 state.DidSwapBuffers(); |
| 483 state.DidSwapBuffersComplete(); |
476 } | 484 } |
477 | 485 |
478 TEST(SchedulerStateMachineTest, | 486 TEST(SchedulerStateMachineTest, |
479 TestFailedDrawsEventuallyForceDrawAfterNextCommit) { | 487 TestFailedDrawsEventuallyForceDrawAfterNextCommit) { |
480 bool main_frame_before_draw_enabled = false; | 488 bool main_frame_before_draw_enabled = false; |
481 TestFailedDrawsEventuallyForceDrawAfterNextCommit( | 489 TestFailedDrawsEventuallyForceDrawAfterNextCommit( |
482 main_frame_before_draw_enabled); | 490 main_frame_before_draw_enabled); |
483 } | 491 } |
484 | 492 |
485 TEST(SchedulerStateMachineTest, | 493 TEST(SchedulerStateMachineTest, |
(...skipping 26 matching lines...) Expand all Loading... |
512 EXPECT_TRUE(state.CommitPending()); | 520 EXPECT_TRUE(state.CommitPending()); |
513 | 521 |
514 // Then initiate a draw. | 522 // Then initiate a draw. |
515 state.SetNeedsRedraw(true); | 523 state.SetNeedsRedraw(true); |
516 state.OnBeginImplFrameDeadline(); | 524 state.OnBeginImplFrameDeadline(); |
517 EXPECT_ACTION_UPDATE_STATE( | 525 EXPECT_ACTION_UPDATE_STATE( |
518 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 526 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
519 | 527 |
520 // Fail the draw enough times to force a redraw, | 528 // Fail the draw enough times to force a redraw, |
521 // then once more for good measure. | 529 // then once more for good measure. |
522 for (int i = 0; i < draw_limit + 1; ++i) { | 530 for (int i = 0; i < draw_limit + 1; ++i) |
523 state.DidDrawIfPossibleCompleted( | 531 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
524 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); | |
525 } | |
526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 532 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
527 EXPECT_TRUE(state.BeginFrameNeeded()); | 533 EXPECT_TRUE(state.BeginFrameNeeded()); |
528 EXPECT_TRUE(state.RedrawPending()); | 534 EXPECT_TRUE(state.RedrawPending()); |
529 // But the commit is ongoing. | 535 // But the commit is ongoing. |
530 EXPECT_TRUE(state.CommitPending()); | 536 EXPECT_TRUE(state.CommitPending()); |
531 EXPECT_TRUE(state.ForcedRedrawState() == | 537 EXPECT_TRUE(state.ForcedRedrawState() == |
532 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_COMMIT); | 538 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_COMMIT); |
533 | 539 |
534 state.NotifyBeginMainFrameStarted(); | 540 state.NotifyBeginMainFrameStarted(); |
535 state.NotifyReadyToCommit(); | 541 state.NotifyReadyToCommit(); |
536 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 542 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
537 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 543 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
538 EXPECT_TRUE(state.RedrawPending()); | 544 EXPECT_TRUE(state.RedrawPending()); |
539 EXPECT_FALSE(state.CommitPending()); | 545 EXPECT_FALSE(state.CommitPending()); |
540 | 546 |
541 // Now force redraw should be in waiting for activation | 547 // Now force redraw should be in waiting for activation |
542 EXPECT_TRUE(state.ForcedRedrawState() == | 548 EXPECT_TRUE(state.ForcedRedrawState() == |
543 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); | 549 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); |
544 | 550 |
545 // After failing additional draws, we should still be in a forced | 551 // After failing additional draws, we should still be in a forced |
546 // redraw, but not back in WAITING_FOR_COMMIT. | 552 // redraw, but not back in WAITING_FOR_COMMIT. |
547 for (int i = 0; i < draw_limit + 1; ++i) { | 553 for (int i = 0; i < draw_limit + 1; ++i) |
548 state.DidDrawIfPossibleCompleted( | 554 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
549 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); | |
550 } | |
551 EXPECT_TRUE(state.RedrawPending()); | 555 EXPECT_TRUE(state.RedrawPending()); |
552 EXPECT_TRUE(state.ForcedRedrawState() == | 556 EXPECT_TRUE(state.ForcedRedrawState() == |
553 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); | 557 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); |
554 } | 558 } |
555 | 559 |
556 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { | 560 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { |
557 SchedulerSettings default_scheduler_settings; | 561 SchedulerSettings default_scheduler_settings; |
558 StateMachine state(default_scheduler_settings); | 562 StateMachine state(default_scheduler_settings); |
559 state.SetCanStart(); | 563 state.SetCanStart(); |
560 state.UpdateState(state.NextAction()); | 564 state.UpdateState(state.NextAction()); |
561 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 565 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
562 state.SetVisible(true); | 566 state.SetVisible(true); |
563 state.SetCanDraw(true); | 567 state.SetCanDraw(true); |
564 | 568 |
565 // Start a draw. | 569 // Start a draw. |
566 state.SetNeedsRedraw(true); | 570 state.SetNeedsRedraw(true); |
567 EXPECT_TRUE(state.BeginFrameNeeded()); | 571 EXPECT_TRUE(state.BeginFrameNeeded()); |
568 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 572 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
569 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 573 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
570 state.OnBeginImplFrameDeadline(); | 574 state.OnBeginImplFrameDeadline(); |
571 EXPECT_TRUE(state.RedrawPending()); | 575 EXPECT_TRUE(state.RedrawPending()); |
572 EXPECT_ACTION_UPDATE_STATE( | 576 EXPECT_ACTION_UPDATE_STATE( |
573 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 577 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
574 | 578 |
575 // Failing the draw for animation checkerboards makes us require a commit. | 579 // Failing the draw for animation checkerboards makes us require a commit. |
576 state.DidDrawIfPossibleCompleted( | 580 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
577 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); | |
578 EXPECT_ACTION_UPDATE_STATE( | 581 EXPECT_ACTION_UPDATE_STATE( |
579 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 582 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
580 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 583 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
581 EXPECT_TRUE(state.RedrawPending()); | 584 EXPECT_TRUE(state.RedrawPending()); |
582 | 585 |
583 // We should not be trying to draw again now, but we have a commit pending. | 586 // We should not be trying to draw again now, but we have a commit pending. |
584 EXPECT_TRUE(state.BeginFrameNeeded()); | 587 EXPECT_TRUE(state.BeginFrameNeeded()); |
585 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 588 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
586 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 589 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
587 | 590 |
588 // We should try to draw again at the end of the next BeginImplFrame on | 591 // We should try to draw again at the end of the next BeginImplFrame on |
589 // the impl thread. | 592 // the impl thread. |
590 state.OnBeginImplFrameDeadline(); | 593 state.OnBeginImplFrameDeadline(); |
591 EXPECT_ACTION_UPDATE_STATE( | 594 EXPECT_ACTION_UPDATE_STATE( |
592 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 595 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 596 state.DidSwapBuffers(); |
| 597 state.DidSwapBuffersComplete(); |
593 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 598 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
594 } | 599 } |
595 | 600 |
596 TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { | 601 TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { |
597 SchedulerSettings default_scheduler_settings; | 602 SchedulerSettings default_scheduler_settings; |
598 StateMachine state(default_scheduler_settings); | 603 StateMachine state(default_scheduler_settings); |
599 state.SetCanStart(); | 604 state.SetCanStart(); |
600 state.UpdateState(state.NextAction()); | 605 state.UpdateState(state.NextAction()); |
601 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 606 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
602 state.SetVisible(true); | 607 state.SetVisible(true); |
603 state.SetCanDraw(true); | 608 state.SetCanDraw(true); |
604 state.SetNeedsRedraw(true); | 609 state.SetNeedsRedraw(true); |
605 | 610 |
606 // Draw the first frame. | 611 // Draw the first frame. |
607 EXPECT_TRUE(state.BeginFrameNeeded()); | 612 EXPECT_TRUE(state.BeginFrameNeeded()); |
608 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 613 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
609 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 614 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
610 | 615 |
611 state.OnBeginImplFrameDeadline(); | 616 state.OnBeginImplFrameDeadline(); |
612 EXPECT_ACTION_UPDATE_STATE( | 617 EXPECT_ACTION_UPDATE_STATE( |
613 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 618 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
614 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 619 state.DidSwapBuffers(); |
| 620 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 621 state.DidSwapBuffersComplete(); |
615 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 622 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
616 | 623 |
617 // Before the next BeginImplFrame, set needs redraw again. | 624 // Before the next BeginImplFrame, set needs redraw again. |
618 // This should not redraw until the next BeginImplFrame. | 625 // This should not redraw until the next BeginImplFrame. |
619 state.SetNeedsRedraw(true); | 626 state.SetNeedsRedraw(true); |
620 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 627 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
621 | 628 |
622 // Move to another frame. This should now draw. | 629 // Move to another frame. This should now draw. |
623 EXPECT_TRUE(state.BeginFrameNeeded()); | 630 EXPECT_TRUE(state.BeginFrameNeeded()); |
624 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 631 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
625 | 632 |
626 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 633 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
627 | 634 |
628 state.OnBeginImplFrameDeadline(); | 635 state.OnBeginImplFrameDeadline(); |
629 EXPECT_ACTION_UPDATE_STATE( | 636 EXPECT_ACTION_UPDATE_STATE( |
630 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 637 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
631 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 638 state.DidSwapBuffers(); |
| 639 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 640 state.DidSwapBuffersComplete(); |
632 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 641 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
633 | 642 |
634 // We just swapped, so we should proactively request another BeginImplFrame. | 643 // We just swapped, so we should proactively request another BeginImplFrame. |
635 EXPECT_TRUE(state.BeginFrameNeeded()); | 644 EXPECT_TRUE(state.BeginFrameNeeded()); |
636 } | 645 } |
637 | 646 |
638 TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { | 647 TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { |
639 SchedulerSettings default_scheduler_settings; | 648 SchedulerSettings default_scheduler_settings; |
640 | 649 |
641 // When not in BeginImplFrame deadline, or in BeginImplFrame deadline | 650 // When not in BeginImplFrame deadline, or in BeginImplFrame deadline |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 EXPECT_ACTION_UPDATE_STATE( | 872 EXPECT_ACTION_UPDATE_STATE( |
864 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 873 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
865 } | 874 } |
866 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 875 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
867 | 876 |
868 state.OnBeginImplFrameDeadline(); | 877 state.OnBeginImplFrameDeadline(); |
869 | 878 |
870 EXPECT_TRUE(state.active_tree_needs_first_draw()); | 879 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
871 EXPECT_ACTION_UPDATE_STATE( | 880 EXPECT_ACTION_UPDATE_STATE( |
872 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 881 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
873 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 882 state.DidSwapBuffers(); |
| 883 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 884 state.DidSwapBuffersComplete(); |
874 if (!main_frame_before_draw_enabled) { | 885 if (!main_frame_before_draw_enabled) { |
875 EXPECT_ACTION_UPDATE_STATE( | 886 EXPECT_ACTION_UPDATE_STATE( |
876 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 887 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
877 } | 888 } |
878 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 889 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
879 } | 890 } |
880 | 891 |
881 TEST(SchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) { | 892 TEST(SchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) { |
882 bool main_frame_before_draw_enabled = false; | 893 bool main_frame_before_draw_enabled = false; |
883 TestSetNeedsCommitIsNotLost(main_frame_before_draw_enabled); | 894 TestSetNeedsCommitIsNotLost(main_frame_before_draw_enabled); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 EXPECT_TRUE(state.active_tree_needs_first_draw()); | 931 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
921 EXPECT_TRUE(state.needs_redraw()); | 932 EXPECT_TRUE(state.needs_redraw()); |
922 | 933 |
923 // Expect to do nothing until BeginImplFrame deadline | 934 // Expect to do nothing until BeginImplFrame deadline |
924 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 935 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
925 | 936 |
926 // At BeginImplFrame deadline, draw. | 937 // At BeginImplFrame deadline, draw. |
927 state.OnBeginImplFrameDeadline(); | 938 state.OnBeginImplFrameDeadline(); |
928 EXPECT_ACTION_UPDATE_STATE( | 939 EXPECT_ACTION_UPDATE_STATE( |
929 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 940 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
930 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 941 state.DidSwapBuffers(); |
| 942 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 943 state.DidSwapBuffersComplete(); |
931 | 944 |
932 // Should be synchronized, no draw needed, no action needed. | 945 // Should be synchronized, no draw needed, no action needed. |
933 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 946 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
934 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 947 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
935 EXPECT_FALSE(state.needs_redraw()); | 948 EXPECT_FALSE(state.needs_redraw()); |
936 } | 949 } |
937 | 950 |
938 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) { | 951 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) { |
939 SchedulerSettings default_scheduler_settings; | 952 SchedulerSettings default_scheduler_settings; |
940 StateMachine state(default_scheduler_settings); | 953 StateMachine state(default_scheduler_settings); |
(...skipping 30 matching lines...) Expand all Loading... |
971 EXPECT_TRUE(state.active_tree_needs_first_draw()); | 984 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
972 EXPECT_TRUE(state.needs_redraw()); | 985 EXPECT_TRUE(state.needs_redraw()); |
973 | 986 |
974 // Expect to do nothing until BeginImplFrame deadline. | 987 // Expect to do nothing until BeginImplFrame deadline. |
975 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 988 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
976 | 989 |
977 // At BeginImplFrame deadline, draw. | 990 // At BeginImplFrame deadline, draw. |
978 state.OnBeginImplFrameDeadline(); | 991 state.OnBeginImplFrameDeadline(); |
979 EXPECT_ACTION_UPDATE_STATE( | 992 EXPECT_ACTION_UPDATE_STATE( |
980 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 993 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
981 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 994 state.DidSwapBuffers(); |
| 995 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 996 state.DidSwapBuffersComplete(); |
982 | 997 |
983 // Should be synchronized, no draw needed, no action needed. | 998 // Should be synchronized, no draw needed, no action needed. |
984 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 999 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
985 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 1000 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
986 EXPECT_FALSE(state.needs_redraw()); | 1001 EXPECT_FALSE(state.needs_redraw()); |
987 | 1002 |
988 // Next BeginImplFrame should initiate second commit. | 1003 // Next BeginImplFrame should initiate second commit. |
989 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 1004 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
990 EXPECT_ACTION_UPDATE_STATE( | 1005 EXPECT_ACTION_UPDATE_STATE( |
991 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1006 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 1096 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
1082 EXPECT_FALSE(state.NeedsCommit()); | 1097 EXPECT_FALSE(state.NeedsCommit()); |
1083 | 1098 |
1084 // Start a new frame; draw because this is the first frame since output | 1099 // Start a new frame; draw because this is the first frame since output |
1085 // surface init'd. | 1100 // surface init'd. |
1086 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 1101 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
1087 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1102 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1088 state.OnBeginImplFrameDeadline(); | 1103 state.OnBeginImplFrameDeadline(); |
1089 EXPECT_ACTION_UPDATE_STATE( | 1104 EXPECT_ACTION_UPDATE_STATE( |
1090 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1105 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1106 state.DidSwapBuffers(); |
| 1107 state.DidSwapBuffersComplete(); |
1091 | 1108 |
1092 // Verify another commit doesn't start on another frame either. | 1109 // Verify another commit doesn't start on another frame either. |
1093 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 1110 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
1094 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 1111 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
1095 EXPECT_FALSE(state.NeedsCommit()); | 1112 EXPECT_FALSE(state.NeedsCommit()); |
1096 | 1113 |
1097 // Verify another commit can start if requested, though. | 1114 // Verify another commit can start if requested, though. |
1098 state.SetNeedsCommit(); | 1115 state.SetNeedsCommit(); |
1099 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 1116 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
1100 EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME, | 1117 EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 | 1252 |
1236 // Set damage and expect a draw. | 1253 // Set damage and expect a draw. |
1237 state.SetNeedsRedraw(true); | 1254 state.SetNeedsRedraw(true); |
1238 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 1255 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
1239 EXPECT_ACTION_UPDATE_STATE( | 1256 EXPECT_ACTION_UPDATE_STATE( |
1240 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1257 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1241 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1258 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1242 state.OnBeginImplFrameDeadline(); | 1259 state.OnBeginImplFrameDeadline(); |
1243 EXPECT_ACTION_UPDATE_STATE( | 1260 EXPECT_ACTION_UPDATE_STATE( |
1244 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1261 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1262 state.DidSwapBuffers(); |
| 1263 state.DidSwapBuffersComplete(); |
1245 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1264 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1246 | 1265 |
1247 // Cause a lost context while the BeginMainFrame is in flight. | 1266 // Cause a lost context while the BeginMainFrame is in flight. |
1248 state.DidLoseOutputSurface(); | 1267 state.DidLoseOutputSurface(); |
1249 | 1268 |
1250 // Ask for another draw. Expect nothing happens. | 1269 // Ask for another draw. Expect nothing happens. |
1251 state.SetNeedsRedraw(true); | 1270 state.SetNeedsRedraw(true); |
1252 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 1271 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
1253 | 1272 |
1254 // Finish the frame, and commit. | 1273 // Finish the frame, and commit. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 | 1318 |
1300 // Set damage and expect a draw. | 1319 // Set damage and expect a draw. |
1301 state.SetNeedsRedraw(true); | 1320 state.SetNeedsRedraw(true); |
1302 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 1321 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
1303 EXPECT_ACTION_UPDATE_STATE( | 1322 EXPECT_ACTION_UPDATE_STATE( |
1304 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1323 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1305 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1324 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1306 state.OnBeginImplFrameDeadline(); | 1325 state.OnBeginImplFrameDeadline(); |
1307 EXPECT_ACTION_UPDATE_STATE( | 1326 EXPECT_ACTION_UPDATE_STATE( |
1308 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1327 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1328 state.DidSwapBuffers(); |
| 1329 state.DidSwapBuffersComplete(); |
1309 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1330 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1310 | 1331 |
1311 // Cause a lost context while the BeginMainFrame is in flight. | 1332 // Cause a lost context while the BeginMainFrame is in flight. |
1312 state.DidLoseOutputSurface(); | 1333 state.DidLoseOutputSurface(); |
1313 | 1334 |
1314 // Ask for another draw and also set needs commit. Expect nothing happens. | 1335 // Ask for another draw and also set needs commit. Expect nothing happens. |
1315 state.SetNeedsRedraw(true); | 1336 state.SetNeedsRedraw(true); |
1316 state.SetNeedsCommit(); | 1337 state.SetNeedsCommit(); |
1317 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1338 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1318 | 1339 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 EXPECT_ACTION_UPDATE_STATE( | 1377 EXPECT_ACTION_UPDATE_STATE( |
1357 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1378 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1358 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1379 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1359 state.NotifyBeginMainFrameStarted(); | 1380 state.NotifyBeginMainFrameStarted(); |
1360 state.NotifyReadyToCommit(); | 1381 state.NotifyReadyToCommit(); |
1361 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1382 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1362 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1383 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1363 state.OnBeginImplFrameDeadline(); | 1384 state.OnBeginImplFrameDeadline(); |
1364 EXPECT_ACTION_UPDATE_STATE( | 1385 EXPECT_ACTION_UPDATE_STATE( |
1365 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1386 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1387 state.DidSwapBuffers(); |
| 1388 state.DidSwapBuffersComplete(); |
1366 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1389 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1367 } | 1390 } |
1368 | 1391 |
1369 TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) { | 1392 TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) { |
1370 SchedulerSettings default_scheduler_settings; | 1393 SchedulerSettings default_scheduler_settings; |
1371 StateMachine state(default_scheduler_settings); | 1394 StateMachine state(default_scheduler_settings); |
1372 state.SetCanStart(); | 1395 state.SetCanStart(); |
1373 state.UpdateState(state.NextAction()); | 1396 state.UpdateState(state.NextAction()); |
1374 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1397 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1375 state.SetVisible(true); | 1398 state.SetVisible(true); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 state.readback_state()); | 1649 state.readback_state()); |
1627 } | 1650 } |
1628 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1651 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1629 | 1652 |
1630 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 1653 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
1631 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1654 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1632 // Perform the draw & swap of replacement commit. | 1655 // Perform the draw & swap of replacement commit. |
1633 state.OnBeginImplFrameDeadline(); | 1656 state.OnBeginImplFrameDeadline(); |
1634 EXPECT_ACTION_UPDATE_STATE( | 1657 EXPECT_ACTION_UPDATE_STATE( |
1635 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1658 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1659 state.DidSwapBuffers(); |
| 1660 state.DidSwapBuffersComplete(); |
1636 if (!settings.main_frame_before_draw_enabled) { | 1661 if (!settings.main_frame_before_draw_enabled) { |
1637 // New replacement commit is scheduled. | 1662 // New replacement commit is scheduled. |
1638 EXPECT_ACTION_UPDATE_STATE( | 1663 EXPECT_ACTION_UPDATE_STATE( |
1639 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 1664 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
1640 // Forced commit is started. | 1665 // Forced commit is started. |
1641 EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_WAITING_FOR_COMMIT, | 1666 EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_WAITING_FOR_COMMIT, |
1642 state.readback_state()); | 1667 state.readback_state()); |
1643 } | 1668 } |
1644 EXPECT_ACTION_UPDATE_STATE( | 1669 EXPECT_ACTION_UPDATE_STATE( |
1645 SchedulerStateMachine::ACTION_NONE); | 1670 SchedulerStateMachine::ACTION_NONE); |
(...skipping 18 matching lines...) Expand all Loading... |
1664 state.NotifyReadyToCommit(); | 1689 state.NotifyReadyToCommit(); |
1665 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1690 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1666 state.NotifyReadyToActivate(); | 1691 state.NotifyReadyToActivate(); |
1667 EXPECT_ACTION_UPDATE_STATE( | 1692 EXPECT_ACTION_UPDATE_STATE( |
1668 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); | 1693 SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE); |
1669 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 1694 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
1670 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1695 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1671 state.OnBeginImplFrameDeadline(); | 1696 state.OnBeginImplFrameDeadline(); |
1672 EXPECT_ACTION_UPDATE_STATE( | 1697 EXPECT_ACTION_UPDATE_STATE( |
1673 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1698 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1699 state.DidSwapBuffers(); |
| 1700 state.DidSwapBuffersComplete(); |
1674 EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_IDLE, state.readback_state()); | 1701 EXPECT_EQ(SchedulerStateMachine::READBACK_STATE_IDLE, state.readback_state()); |
1675 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1702 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1676 } | 1703 } |
1677 | 1704 |
1678 // Explicitly test when main_frame_before_draw_enabled = true. | 1705 // Explicitly test when main_frame_before_draw_enabled = true. |
1679 TEST(SchedulerStateMachineTest, | 1706 TEST(SchedulerStateMachineTest, |
1680 ForceCommitWhenReplacementActivationInProgressAndMainFrameEnabled) { | 1707 ForceCommitWhenReplacementActivationInProgressAndMainFrameEnabled) { |
1681 bool main_frame_before_draw_enabled = true; | 1708 bool main_frame_before_draw_enabled = true; |
1682 TestForceCommitWhenReplacementActivationInProgress( | 1709 TestForceCommitWhenReplacementActivationInProgress( |
1683 main_frame_before_draw_enabled); | 1710 main_frame_before_draw_enabled); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 state.readback_state()); | 1762 state.readback_state()); |
1736 EXPECT_FALSE(state.NeedsCommit()); | 1763 EXPECT_FALSE(state.NeedsCommit()); |
1737 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1764 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1738 | 1765 |
1739 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 1766 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
1740 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1767 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1741 // Perform the draw & swap of replacement commit. | 1768 // Perform the draw & swap of replacement commit. |
1742 state.OnBeginImplFrameDeadline(); | 1769 state.OnBeginImplFrameDeadline(); |
1743 EXPECT_ACTION_UPDATE_STATE( | 1770 EXPECT_ACTION_UPDATE_STATE( |
1744 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 1771 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
| 1772 state.DidSwapBuffers(); |
| 1773 state.DidSwapBuffersComplete(); |
1745 EXPECT_ACTION_UPDATE_STATE( | 1774 EXPECT_ACTION_UPDATE_STATE( |
1746 SchedulerStateMachine::ACTION_NONE); | 1775 SchedulerStateMachine::ACTION_NONE); |
1747 | 1776 |
1748 // forced commit is started. | 1777 // forced commit is started. |
1749 state.NotifyBeginMainFrameStarted(); | 1778 state.NotifyBeginMainFrameStarted(); |
1750 state.NotifyReadyToCommit(); | 1779 state.NotifyReadyToCommit(); |
1751 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1780 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1752 } | 1781 } |
1753 | 1782 |
1754 TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) { | 1783 TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 state.NotifyBeginMainFrameStarted(); | 1833 state.NotifyBeginMainFrameStarted(); |
1805 state.NotifyReadyToCommit(); | 1834 state.NotifyReadyToCommit(); |
1806 | 1835 |
1807 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1836 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1808 state.CommitState()); | 1837 state.CommitState()); |
1809 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1838 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1810 | 1839 |
1811 EXPECT_TRUE(state.active_tree_needs_first_draw()); | 1840 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
1812 | 1841 |
1813 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1842 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1814 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 1843 state.DidSwapBuffers(); |
| 1844 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 1845 state.DidSwapBuffersComplete(); |
1815 | 1846 |
1816 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1847 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1817 | 1848 |
1818 // Should be waiting for the normal BeginMainFrame. | 1849 // Should be waiting for the normal BeginMainFrame. |
1819 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, | 1850 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, |
1820 state.CommitState()); | 1851 state.CommitState()); |
1821 } | 1852 } |
1822 | 1853 |
1823 TEST(SchedulerStateMachineTest, TestImmediateFinishCommitDuringCommit) { | 1854 TEST(SchedulerStateMachineTest, TestImmediateFinishCommitDuringCommit) { |
1824 SchedulerSettings scheduler_settings; | 1855 SchedulerSettings scheduler_settings; |
(...skipping 15 matching lines...) Expand all Loading... |
1840 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1871 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1841 state.NotifyBeginMainFrameStarted(); | 1872 state.NotifyBeginMainFrameStarted(); |
1842 state.NotifyReadyToCommit(); | 1873 state.NotifyReadyToCommit(); |
1843 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1874 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1844 state.CommitState()); | 1875 state.CommitState()); |
1845 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1876 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1846 | 1877 |
1847 EXPECT_TRUE(state.active_tree_needs_first_draw()); | 1878 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
1848 | 1879 |
1849 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1880 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1850 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 1881 state.DidSwapBuffers(); |
| 1882 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 1883 state.DidSwapBuffersComplete(); |
1851 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1884 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1852 | 1885 |
1853 // Should be waiting for the normal BeginMainFrame. | 1886 // Should be waiting for the normal BeginMainFrame. |
1854 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, | 1887 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, |
1855 state.CommitState()) | 1888 state.CommitState()) |
1856 << *state.AsValue(); | 1889 << *state.AsValue(); |
1857 } | 1890 } |
1858 | 1891 |
1859 TEST(SchedulerStateMachineTest, ImmediateBeginMainFrameAbortedWhileInvisible) { | 1892 TEST(SchedulerStateMachineTest, ImmediateBeginMainFrameAbortedWhileInvisible) { |
1860 SchedulerSettings scheduler_settings; | 1893 SchedulerSettings scheduler_settings; |
(...skipping 13 matching lines...) Expand all Loading... |
1874 state.NotifyBeginMainFrameStarted(); | 1907 state.NotifyBeginMainFrameStarted(); |
1875 state.NotifyReadyToCommit(); | 1908 state.NotifyReadyToCommit(); |
1876 | 1909 |
1877 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1910 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1878 state.CommitState()); | 1911 state.CommitState()); |
1879 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1912 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1880 | 1913 |
1881 EXPECT_TRUE(state.active_tree_needs_first_draw()); | 1914 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
1882 | 1915 |
1883 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1916 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1884 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 1917 state.DidSwapBuffers(); |
| 1918 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 1919 state.DidSwapBuffersComplete(); |
1885 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1920 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1886 | 1921 |
1887 // Should be waiting for BeginMainFrame. | 1922 // Should be waiting for BeginMainFrame. |
1888 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, | 1923 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, |
1889 state.CommitState()) | 1924 state.CommitState()) |
1890 << *state.AsValue(); | 1925 << *state.AsValue(); |
1891 | 1926 |
1892 // Become invisible and abort BeginMainFrame. | 1927 // Become invisible and abort BeginMainFrame. |
1893 state.SetVisible(false); | 1928 state.SetVisible(false); |
1894 state.BeginMainFrameAborted(false); | 1929 state.BeginMainFrameAborted(false); |
(...skipping 20 matching lines...) Expand all Loading... |
1915 state.NotifyBeginMainFrameStarted(); | 1950 state.NotifyBeginMainFrameStarted(); |
1916 state.NotifyReadyToCommit(); | 1951 state.NotifyReadyToCommit(); |
1917 | 1952 |
1918 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1953 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1919 state.CommitState()); | 1954 state.CommitState()); |
1920 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1955 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1921 | 1956 |
1922 EXPECT_TRUE(state.active_tree_needs_first_draw()); | 1957 EXPECT_TRUE(state.active_tree_needs_first_draw()); |
1923 | 1958 |
1924 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1959 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1925 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); | 1960 state.DidSwapBuffers(); |
| 1961 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); |
| 1962 state.DidSwapBuffersComplete(); |
1926 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1963 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1927 } | 1964 } |
1928 | 1965 |
1929 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { | 1966 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { |
1930 SchedulerSettings default_scheduler_settings; | 1967 SchedulerSettings default_scheduler_settings; |
1931 StateMachine state(default_scheduler_settings); | 1968 StateMachine state(default_scheduler_settings); |
1932 state.SetCanStart(); | 1969 state.SetCanStart(); |
1933 state.UpdateState(state.NextAction()); | 1970 state.UpdateState(state.NextAction()); |
1934 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1971 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1935 | 1972 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 2044 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
2008 | 2045 |
2009 // The deadline is not triggered early until we enter prefer smoothness mode. | 2046 // The deadline is not triggered early until we enter prefer smoothness mode. |
2010 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 2047 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
2011 state.SetSmoothnessTakesPriority(true); | 2048 state.SetSmoothnessTakesPriority(true); |
2012 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 2049 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
2013 } | 2050 } |
2014 | 2051 |
2015 } // namespace | 2052 } // namespace |
2016 } // namespace cc | 2053 } // namespace cc |
OLD | NEW |