Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1367)

Side by Side Diff: cc/scheduler/scheduler_state_machine_unittest.cc

Issue 2753843003: Create a new action triggered when a BeginMainFrame is not expected before vsync (Closed)
Patch Set: Respond to Sami's comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/output/begin_frame_args.h" 10 #include "cc/output/begin_frame_args.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 return; 197 return;
198 198
199 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: 199 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE:
200 sm->WillActivate(); 200 sm->WillActivate();
201 return; 201 return;
202 202
203 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: 203 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME:
204 sm->WillSendBeginMainFrame(); 204 sm->WillSendBeginMainFrame();
205 return; 205 return;
206 206
207 case SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK:
208 sm->WillDoShortIdleWork();
209 return;
210
207 case SchedulerStateMachine::ACTION_COMMIT: { 211 case SchedulerStateMachine::ACTION_COMMIT: {
208 bool commit_has_no_updates = false; 212 bool commit_has_no_updates = false;
209 sm->WillCommit(commit_has_no_updates); 213 sm->WillCommit(commit_has_no_updates);
210 return; 214 return;
211 } 215 }
212 216
213 case SchedulerStateMachine::ACTION_DRAW_FORCED: 217 case SchedulerStateMachine::ACTION_DRAW_FORCED:
214 case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: { 218 case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: {
215 sm->WillDraw(); 219 sm->WillDraw();
216 sm->DidDraw(sm->draw_result_for_test()); 220 sm->DidDraw(sm->draw_result_for_test());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // Don't request BeginFrames when commit is pending if 287 // Don't request BeginFrames when commit is pending if
284 // we are currently deferring commits. 288 // we are currently deferring commits.
285 state.SetVisible(true); 289 state.SetVisible(true);
286 state.SetNeedsRedraw(false); 290 state.SetNeedsRedraw(false);
287 state.SetNeedsOneBeginImplFrame(false); 291 state.SetNeedsOneBeginImplFrame(false);
288 state.SetNeedsBeginMainFrameForTest(true); 292 state.SetNeedsBeginMainFrameForTest(true);
289 state.SetDeferCommits(true); 293 state.SetDeferCommits(true);
290 EXPECT_FALSE(state.BeginFrameNeeded()); 294 EXPECT_FALSE(state.BeginFrameNeeded());
291 } 295 }
292 296
297 TEST(SchedulerStateMachineTest, TestNextActionDoShortIdleWork) {
298 SchedulerSettings default_scheduler_settings;
299 StateMachine state(default_scheduler_settings);
300 state.SetVisible(true);
301 EXPECT_ACTION_UPDATE_STATE(
302 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
303 state.IssueNextBeginImplFrame();
304 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
305 // A main frame was not requested so short idle work is scheduled instead.
306 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
307 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
308
309 state.SetNeedsRedraw(true);
310 state.SetNeedsBeginMainFrame();
311 // Now a main frame is requested no short idle work is scheduled.
312 EXPECT_ACTION_UPDATE_STATE(
313 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
314 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
315 }
316
293 TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { 317 TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) {
294 SchedulerSettings default_scheduler_settings; 318 SchedulerSettings default_scheduler_settings;
295 319
296 // If no commit needed, do nothing. 320 // If no commit needed, do nothing.
297 { 321 {
298 StateMachine state(default_scheduler_settings); 322 StateMachine state(default_scheduler_settings);
299 state.SetVisible(true); 323 state.SetVisible(true);
300 EXPECT_ACTION_UPDATE_STATE( 324 EXPECT_ACTION_UPDATE_STATE(
301 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 325 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
302 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 326 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
303 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit(); 327 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
304 state.SetBeginMainFrameState( 328 state.SetBeginMainFrameState(
305 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 329 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
306 state.SetNeedsRedraw(false); 330 state.SetNeedsRedraw(false);
307 331
308 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 332 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
309 EXPECT_FALSE(state.NeedsCommit()); 333 EXPECT_FALSE(state.NeedsCommit());
310 334
311 state.IssueNextBeginImplFrame(); 335 state.IssueNextBeginImplFrame();
336 EXPECT_ACTION_UPDATE_STATE(
337 SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
312 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 338 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
313 339
314 state.OnBeginImplFrameDeadline(); 340 state.OnBeginImplFrameDeadline();
315 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 341 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
316 EXPECT_FALSE(state.NeedsCommit()); 342 EXPECT_FALSE(state.NeedsCommit());
317 } 343 }
318 344
319 // If commit requested but not visible yet, do nothing. 345 // If commit requested but not visible yet, do nothing.
320 { 346 {
321 StateMachine state(default_scheduler_settings); 347 StateMachine state(default_scheduler_settings);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 FailedDrawForAnimationCheckerboardSetsNeedsCommitAndRetriesDraw) { 477 FailedDrawForAnimationCheckerboardSetsNeedsCommitAndRetriesDraw) {
452 SchedulerSettings default_scheduler_settings; 478 SchedulerSettings default_scheduler_settings;
453 StateMachine state(default_scheduler_settings); 479 StateMachine state(default_scheduler_settings);
454 SET_UP_STATE(state) 480 SET_UP_STATE(state)
455 state.SetNeedsRedraw(true); 481 state.SetNeedsRedraw(true);
456 EXPECT_TRUE(state.RedrawPending()); 482 EXPECT_TRUE(state.RedrawPending());
457 EXPECT_TRUE(state.BeginFrameNeeded()); 483 EXPECT_TRUE(state.BeginFrameNeeded());
458 484
459 // Start a frame. 485 // Start a frame.
460 state.IssueNextBeginImplFrame(); 486 state.IssueNextBeginImplFrame();
487 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
461 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 488 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
462 EXPECT_FALSE(state.CommitPending()); 489 EXPECT_FALSE(state.CommitPending());
463 490
464 // Failing a draw triggers request for a new BeginMainFrame. 491 // Failing a draw triggers request for a new BeginMainFrame.
465 state.OnBeginImplFrameDeadline(); 492 state.OnBeginImplFrameDeadline();
466 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); 493 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS);
467 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 494 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
468 EXPECT_ACTION_UPDATE_STATE( 495 EXPECT_ACTION_UPDATE_STATE(
469 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 496 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
470 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 497 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 17 matching lines...) Expand all
488 TEST(SchedulerStateMachineTest, FailedDrawForMissingHighResNeedsCommit) { 515 TEST(SchedulerStateMachineTest, FailedDrawForMissingHighResNeedsCommit) {
489 SchedulerSettings default_scheduler_settings; 516 SchedulerSettings default_scheduler_settings;
490 StateMachine state(default_scheduler_settings); 517 StateMachine state(default_scheduler_settings);
491 SET_UP_STATE(state) 518 SET_UP_STATE(state)
492 state.SetNeedsRedraw(true); 519 state.SetNeedsRedraw(true);
493 EXPECT_TRUE(state.RedrawPending()); 520 EXPECT_TRUE(state.RedrawPending());
494 EXPECT_TRUE(state.BeginFrameNeeded()); 521 EXPECT_TRUE(state.BeginFrameNeeded());
495 522
496 // Start a frame. 523 // Start a frame.
497 state.IssueNextBeginImplFrame(); 524 state.IssueNextBeginImplFrame();
525 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
498 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
499 EXPECT_FALSE(state.CommitPending()); 527 EXPECT_FALSE(state.CommitPending());
500 528
501 // Failing a draw triggers because of high res tiles missing 529 // Failing a draw triggers because of high res tiles missing
502 // request for a new BeginMainFrame. 530 // request for a new BeginMainFrame.
503 state.OnBeginImplFrameDeadline(); 531 state.OnBeginImplFrameDeadline();
504 state.SetDrawResultForTest(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); 532 state.SetDrawResultForTest(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT);
505 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 533 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
506 EXPECT_ACTION_UPDATE_STATE( 534 EXPECT_ACTION_UPDATE_STATE(
507 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 535 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
508 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 536 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
509 state.OnBeginImplFrameIdle(); 537 state.OnBeginImplFrameIdle();
510 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 538 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
511 539
512 // It doesn't request a draw until we get a new commit though. 540 // It doesn't request a draw until we get a new commit though.
513 EXPECT_TRUE(state.CommitPending()); 541 EXPECT_TRUE(state.CommitPending());
514 EXPECT_FALSE(state.RedrawPending()); 542 EXPECT_FALSE(state.RedrawPending());
515 state.IssueNextBeginImplFrame(); 543 state.IssueNextBeginImplFrame();
516 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 544 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
517 state.OnBeginImplFrameDeadline(); 545 state.OnBeginImplFrameDeadline();
518 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 546 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
519 state.OnBeginImplFrameIdle(); 547 state.OnBeginImplFrameIdle();
520 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 548 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
521 549
522 // Finish the commit and activation. 550 // Finish the commit and activation.
523 state.NotifyBeginMainFrameStarted(); 551 state.NotifyBeginMainFrameStarted();
524 state.NotifyReadyToCommit(); 552 state.NotifyReadyToCommit();
525 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 553 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
554 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 555 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
527 state.NotifyReadyToActivate(); 556 state.NotifyReadyToActivate();
528 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 557 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
529 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 558 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
530 EXPECT_TRUE(state.RedrawPending()); 559 EXPECT_TRUE(state.RedrawPending());
531 560
532 // Verify we draw with the new frame. 561 // Verify we draw with the new frame.
533 state.IssueNextBeginImplFrame(); 562 state.IssueNextBeginImplFrame();
563 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
534 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 564 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
535 state.OnBeginImplFrameDeadline(); 565 state.OnBeginImplFrameDeadline();
536 state.SetDrawResultForTest(DRAW_SUCCESS); 566 state.SetDrawResultForTest(DRAW_SUCCESS);
537 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 567 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
538 state.DidSubmitCompositorFrame(); 568 state.DidSubmitCompositorFrame();
539 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 569 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
540 state.OnBeginImplFrameIdle(); 570 state.OnBeginImplFrameIdle();
541 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 571 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
542 } 572 }
543 573
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 687
658 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { 688 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) {
659 SchedulerSettings default_scheduler_settings; 689 SchedulerSettings default_scheduler_settings;
660 StateMachine state(default_scheduler_settings); 690 StateMachine state(default_scheduler_settings);
661 SET_UP_STATE(state) 691 SET_UP_STATE(state)
662 692
663 // Start a draw. 693 // Start a draw.
664 state.SetNeedsRedraw(true); 694 state.SetNeedsRedraw(true);
665 EXPECT_TRUE(state.BeginFrameNeeded()); 695 EXPECT_TRUE(state.BeginFrameNeeded());
666 state.IssueNextBeginImplFrame(); 696 state.IssueNextBeginImplFrame();
697 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
667 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 698 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
668 state.OnBeginImplFrameDeadline(); 699 state.OnBeginImplFrameDeadline();
669 EXPECT_TRUE(state.RedrawPending()); 700 EXPECT_TRUE(state.RedrawPending());
670 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); 701 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS);
671 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 702 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
672 703
673 // Failing the draw for animation checkerboards makes us require a commit. 704 // Failing the draw for animation checkerboards makes us require a commit.
674 EXPECT_ACTION_UPDATE_STATE( 705 EXPECT_ACTION_UPDATE_STATE(
675 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 706 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
676 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 707 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 16 matching lines...) Expand all
693 724
694 TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { 725 TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) {
695 SchedulerSettings default_scheduler_settings; 726 SchedulerSettings default_scheduler_settings;
696 StateMachine state(default_scheduler_settings); 727 StateMachine state(default_scheduler_settings);
697 SET_UP_STATE(state) 728 SET_UP_STATE(state)
698 state.SetNeedsRedraw(true); 729 state.SetNeedsRedraw(true);
699 730
700 // Draw the first frame. 731 // Draw the first frame.
701 EXPECT_TRUE(state.BeginFrameNeeded()); 732 EXPECT_TRUE(state.BeginFrameNeeded());
702 state.IssueNextBeginImplFrame(); 733 state.IssueNextBeginImplFrame();
734 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
703 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 735 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
704 736
705 state.OnBeginImplFrameDeadline(); 737 state.OnBeginImplFrameDeadline();
706 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 738 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
707 state.DidSubmitCompositorFrame(); 739 state.DidSubmitCompositorFrame();
708 state.DidReceiveCompositorFrameAck(); 740 state.DidReceiveCompositorFrameAck();
709 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 741 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
710 742
711 // Before the next BeginImplFrame, set needs redraw again. 743 // Before the next BeginImplFrame, set needs redraw again.
712 // This should not redraw until the next BeginImplFrame. 744 // This should not redraw until the next BeginImplFrame.
713 state.SetNeedsRedraw(true); 745 state.SetNeedsRedraw(true);
714 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 746 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
715 747
716 // Move to another frame. This should now draw. 748 // Move to another frame. This should now draw.
717 EXPECT_TRUE(state.BeginFrameNeeded()); 749 EXPECT_TRUE(state.BeginFrameNeeded());
718 state.IssueNextBeginImplFrame(); 750 state.IssueNextBeginImplFrame();
751 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
719 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 752 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
720 state.OnBeginImplFrameDeadline(); 753 state.OnBeginImplFrameDeadline();
721 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 754 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
722 state.DidSubmitCompositorFrame(); 755 state.DidSubmitCompositorFrame();
723 state.DidReceiveCompositorFrameAck(); 756 state.DidReceiveCompositorFrameAck();
724 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 757 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
725 758
726 // We just submitted, so we should proactively request another BeginImplFrame. 759 // We just submitted, so we should proactively request another BeginImplFrame.
727 EXPECT_TRUE(state.BeginFrameNeeded()); 760 EXPECT_TRUE(state.BeginFrameNeeded());
728 } 761 }
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 // Since the commit was aborted, we don't need to try and draw. 1426 // Since the commit was aborted, we don't need to try and draw.
1394 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1427 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1395 state.OnBeginImplFrameDeadline(); 1428 state.OnBeginImplFrameDeadline();
1396 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1429 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1397 1430
1398 // Verify another commit doesn't start on another frame either. 1431 // Verify another commit doesn't start on another frame either.
1399 EXPECT_FALSE(state.NeedsCommit()); 1432 EXPECT_FALSE(state.NeedsCommit());
1400 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 1433 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
1401 1434
1402 state.IssueNextBeginImplFrame(); 1435 state.IssueNextBeginImplFrame();
1436 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1403 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1437 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1404 state.OnBeginImplFrameDeadline(); 1438 state.OnBeginImplFrameDeadline();
1405 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1439 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1406 1440
1407 // Verify another commit can start if requested, though. 1441 // Verify another commit can start if requested, though.
1408 state.SetNeedsBeginMainFrame(); 1442 state.SetNeedsBeginMainFrame();
1409 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 1443 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
1410 state.IssueNextBeginImplFrame(); 1444 state.IssueNextBeginImplFrame();
1411 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1445 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1412 } 1446 }
1413 1447
1414 TEST(SchedulerStateMachineTest, TestFirstContextCreation) { 1448 TEST(SchedulerStateMachineTest, TestFirstContextCreation) {
1415 SchedulerSettings default_scheduler_settings; 1449 SchedulerSettings default_scheduler_settings;
1416 StateMachine state(default_scheduler_settings); 1450 StateMachine state(default_scheduler_settings);
1417 state.SetVisible(true); 1451 state.SetVisible(true);
1418 state.SetCanDraw(true); 1452 state.SetCanDraw(true);
1419 1453
1420 EXPECT_ACTION_UPDATE_STATE( 1454 EXPECT_ACTION_UPDATE_STATE(
1421 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 1455 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1422 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit(); 1456 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1423 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1457 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1424 1458
1425 // Check that the first init does not SetNeedsBeginMainFrame. 1459 // Check that the first init does not SetNeedsBeginMainFrame.
1426 state.IssueNextBeginImplFrame(); 1460 state.IssueNextBeginImplFrame();
1461 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1427 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1462 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1428 state.OnBeginImplFrameDeadline(); 1463 state.OnBeginImplFrameDeadline();
1429 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1464 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1430 1465
1431 // Check that a needs commit initiates a BeginMainFrame. 1466 // Check that a needs commit initiates a BeginMainFrame.
1432 state.SetNeedsBeginMainFrame(); 1467 state.SetNeedsBeginMainFrame();
1433 state.IssueNextBeginImplFrame(); 1468 state.IssueNextBeginImplFrame();
1434 EXPECT_ACTION_UPDATE_STATE( 1469 EXPECT_ACTION_UPDATE_STATE(
1435 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1470 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1436 } 1471 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 state.DidLoseCompositorFrameSink(); 1506 state.DidLoseCompositorFrameSink();
1472 EXPECT_EQ(state.compositor_frame_sink_state(), 1507 EXPECT_EQ(state.compositor_frame_sink_state(),
1473 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_NONE); 1508 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_NONE);
1474 1509
1475 EXPECT_ACTION_UPDATE_STATE( 1510 EXPECT_ACTION_UPDATE_STATE(
1476 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 1511 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1477 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1512 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1478 1513
1479 // Once context recreation begins, nothing should happen. 1514 // Once context recreation begins, nothing should happen.
1480 state.IssueNextBeginImplFrame(); 1515 state.IssueNextBeginImplFrame();
1516 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1481 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1517 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1482 state.OnBeginImplFrameDeadline(); 1518 state.OnBeginImplFrameDeadline();
1483 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1519 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1484 1520
1485 // While context is recreating, commits shouldn't begin. 1521 // While context is recreating, commits shouldn't begin.
1486 state.SetNeedsBeginMainFrame(); 1522 state.SetNeedsBeginMainFrame();
1487 state.IssueNextBeginImplFrame(); 1523 state.IssueNextBeginImplFrame();
1488 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1524 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1489 state.OnBeginImplFrameDeadline(); 1525 state.OnBeginImplFrameDeadline();
1490 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 30 matching lines...) Expand all
1521 state.NotifyReadyToActivate(); 1557 state.NotifyReadyToActivate();
1522 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1558 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1523 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1559 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1524 EXPECT_EQ(state.compositor_frame_sink_state(), 1560 EXPECT_EQ(state.compositor_frame_sink_state(),
1525 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_ACTIVE); 1561 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_ACTIVE);
1526 1562
1527 // Finishing the first commit after initializing an CompositorFrameSink should 1563 // Finishing the first commit after initializing an CompositorFrameSink should
1528 // automatically cause a redraw. 1564 // automatically cause a redraw.
1529 EXPECT_TRUE(state.RedrawPending()); 1565 EXPECT_TRUE(state.RedrawPending());
1530 state.IssueNextBeginImplFrame(); 1566 state.IssueNextBeginImplFrame();
1567 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1531 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1568 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1532 state.OnBeginImplFrameDeadline(); 1569 state.OnBeginImplFrameDeadline();
1533 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 1570 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
1534 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1571 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1535 EXPECT_FALSE(state.RedrawPending()); 1572 EXPECT_FALSE(state.RedrawPending());
1536 1573
1537 // Next frame as no work to do. 1574 // Next frame as no work to do.
1538 state.IssueNextBeginImplFrame(); 1575 state.IssueNextBeginImplFrame();
1576 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1539 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1577 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1540 state.OnBeginImplFrameDeadline(); 1578 state.OnBeginImplFrameDeadline();
1541 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1579 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1542 1580
1543 // Once the context is recreated, whether we draw should be based on 1581 // Once the context is recreated, whether we draw should be based on
1544 // SetCanDraw if waiting on first draw after activate. 1582 // SetCanDraw if waiting on first draw after activate.
1545 state.SetNeedsRedraw(true); 1583 state.SetNeedsRedraw(true);
1546 state.IssueNextBeginImplFrame(); 1584 state.IssueNextBeginImplFrame();
1585 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1547 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1586 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1548 state.OnBeginImplFrameDeadline(); 1587 state.OnBeginImplFrameDeadline();
1549 EXPECT_ACTION(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 1588 EXPECT_ACTION(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
1550 state.SetCanDraw(false); 1589 state.SetCanDraw(false);
1551 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1590 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1552 state.SetCanDraw(true); 1591 state.SetCanDraw(true);
1553 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 1592 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
1554 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1593 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1555 1594
1556 // Once the context is recreated, whether we draw should be based on 1595 // Once the context is recreated, whether we draw should be based on
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 BeginFrameArgs::kInvalidFrameNumber); 1668 BeginFrameArgs::kInvalidFrameNumber);
1630 1669
1631 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE 1670 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE
1632 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 1671 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
1633 EXPECT_ACTION( 1672 EXPECT_ACTION(
1634 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 1673 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1635 1674
1636 state.OnBeginImplFrame(0, 11); 1675 state.OnBeginImplFrame(0, 11);
1637 EXPECT_IMPL_FRAME_STATE( 1676 EXPECT_IMPL_FRAME_STATE(
1638 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME); 1677 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME);
1678 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1639 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1679 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1640 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 10u, 1680 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 10u,
1641 BeginFrameArgs::kInvalidFrameNumber); 1681 BeginFrameArgs::kInvalidFrameNumber);
1642 1682
1643 state.OnBeginImplFrameDeadline(); 1683 state.OnBeginImplFrameDeadline();
1644 EXPECT_IMPL_FRAME_STATE( 1684 EXPECT_IMPL_FRAME_STATE(
1645 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 1685 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
1646 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1686 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1647 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 11u, 11u); 1687 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 11u, 11u);
1648 } 1688 }
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 // commit. 2026 // commit.
1987 state.NotifyBeginMainFrameStarted(); 2027 state.NotifyBeginMainFrameStarted();
1988 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); 2028 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
1989 2029
1990 // Since the commit was aborted, we should draw right away instead of waiting 2030 // Since the commit was aborted, we should draw right away instead of waiting
1991 // for the deadline. 2031 // for the deadline.
1992 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2032 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
1993 } 2033 }
1994 2034
1995 void FinishPreviousCommitAndDrawWithoutExitingDeadline( 2035 void FinishPreviousCommitAndDrawWithoutExitingDeadline(
1996 StateMachine* state_ptr) { 2036 StateMachine* state_ptr,
2037 bool expect_idle_work_before_impl_frame_deadline) {
1997 // Gross, but allows us to use macros below. 2038 // Gross, but allows us to use macros below.
1998 StateMachine& state = *state_ptr; 2039 StateMachine& state = *state_ptr;
1999 2040
2000 state.NotifyBeginMainFrameStarted(); 2041 state.NotifyBeginMainFrameStarted();
2001 state.NotifyReadyToCommit(); 2042 state.NotifyReadyToCommit();
2002 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 2043 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
2003 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2044 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2004 state.NotifyReadyToActivate(); 2045 state.NotifyReadyToActivate();
2005 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 2046 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
2006 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2047 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2007 2048
2008 state.IssueNextBeginImplFrame(); 2049 state.IssueNextBeginImplFrame();
2050 if (expect_idle_work_before_impl_frame_deadline) {
2051 EXPECT_ACTION_UPDATE_STATE(
2052 SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2053 }
2009 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2054 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2010 2055
2011 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2056 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
2012 state.OnBeginImplFrameDeadline(); 2057 state.OnBeginImplFrameDeadline();
2013 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 2058 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
2014 state.DidSubmitCompositorFrame(); 2059 state.DidSubmitCompositorFrame();
2015 } 2060 }
2016 2061
2017 TEST(SchedulerStateMachineTest, TestImplLatencyTakesPriority) { 2062 TEST(SchedulerStateMachineTest, TestImplLatencyTakesPriority) {
2018 SchedulerSettings default_scheduler_settings; 2063 SchedulerSettings default_scheduler_settings;
(...skipping 19 matching lines...) Expand all
2038 2083
2039 // Trigger the deadline. 2084 // Trigger the deadline.
2040 state.OnBeginImplFrameDeadline(); 2085 state.OnBeginImplFrameDeadline();
2041 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 2086 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
2042 state.DidSubmitCompositorFrame(); 2087 state.DidSubmitCompositorFrame();
2043 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2088 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2044 state.DidReceiveCompositorFrameAck(); 2089 state.DidReceiveCompositorFrameAck();
2045 2090
2046 // Request a new commit and finish the previous one. 2091 // Request a new commit and finish the previous one.
2047 state.SetNeedsBeginMainFrame(); 2092 state.SetNeedsBeginMainFrame();
2048 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state); 2093 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state, false);
2049 EXPECT_ACTION_UPDATE_STATE( 2094 EXPECT_ACTION_UPDATE_STATE(
2050 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2095 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2051 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2096 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2052 state.DidReceiveCompositorFrameAck(); 2097 state.DidReceiveCompositorFrameAck();
2053 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2098 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2054 2099
2055 // Finish the previous commit and draw it. 2100 // Finish the previous commit and draw it.
2056 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state); 2101 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state, true);
2057 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2102 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2058 2103
2059 // Verify we do not send another BeginMainFrame if was are submit-frame 2104 // Verify we do not send another BeginMainFrame if was are submit-frame
2060 // throttled and did not just submit one. 2105 // throttled and did not just submit one.
2061 state.SetNeedsBeginMainFrame(); 2106 state.SetNeedsBeginMainFrame();
2062 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2107 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2063 state.IssueNextBeginImplFrame(); 2108 state.IssueNextBeginImplFrame();
2064 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2109 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2065 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2110 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
2066 state.OnBeginImplFrameDeadline(); 2111 state.OnBeginImplFrameDeadline();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2272 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2228 } 2273 }
2229 2274
2230 TEST(SchedulerStateMachineTest, ImplSideInvalidationOnlyInsideDeadline) { 2275 TEST(SchedulerStateMachineTest, ImplSideInvalidationOnlyInsideDeadline) {
2231 SchedulerSettings settings; 2276 SchedulerSettings settings;
2232 StateMachine state(settings); 2277 StateMachine state(settings);
2233 SET_UP_STATE(state); 2278 SET_UP_STATE(state);
2234 2279
2235 state.SetNeedsImplSideInvalidation(); 2280 state.SetNeedsImplSideInvalidation();
2236 state.IssueNextBeginImplFrame(); 2281 state.IssueNextBeginImplFrame();
2282 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2237 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2283 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2238 state.OnBeginImplFrameDeadline(); 2284 state.OnBeginImplFrameDeadline();
2239 EXPECT_ACTION_UPDATE_STATE( 2285 EXPECT_ACTION_UPDATE_STATE(
2240 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2286 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2241 } 2287 }
2242 2288
2243 TEST(SchedulerStateMachineTest, 2289 TEST(SchedulerStateMachineTest,
2244 NoImplSideInvalidationWithoutCompositorFrameSink) { 2290 NoImplSideInvalidationWithoutCompositorFrameSink) {
2245 SchedulerSettings settings; 2291 SchedulerSettings settings;
2246 StateMachine state(settings); 2292 StateMachine state(settings);
2247 SET_UP_STATE(state); 2293 SET_UP_STATE(state);
2248 2294
2249 // Impl-side invalidations should not be triggered till the frame sink is 2295 // Impl-side invalidations should not be triggered till the frame sink is
2250 // initialized. 2296 // initialized.
2251 state.DidLoseCompositorFrameSink(); 2297 state.DidLoseCompositorFrameSink();
2252 EXPECT_ACTION_UPDATE_STATE( 2298 EXPECT_ACTION_UPDATE_STATE(
2253 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 2299 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
2254 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2300 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2255 2301
2256 // No impl-side invalidations should be performed during frame sink creation. 2302 // No impl-side invalidations should be performed during frame sink creation.
2257 state.SetNeedsImplSideInvalidation(); 2303 state.SetNeedsImplSideInvalidation();
2258 state.IssueNextBeginImplFrame(); 2304 state.IssueNextBeginImplFrame();
2259 state.OnBeginImplFrameDeadline(); 2305 state.OnBeginImplFrameDeadline();
2306 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2260 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2307 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2261 2308
2262 // Initializing the CompositorFrameSink puts us in a state waiting for the 2309 // Initializing the CompositorFrameSink puts us in a state waiting for the
2263 // first commit. 2310 // first commit.
2264 state.DidCreateAndInitializeCompositorFrameSink(); 2311 state.DidCreateAndInitializeCompositorFrameSink();
2265 state.IssueNextBeginImplFrame(); 2312 state.IssueNextBeginImplFrame();
2266 EXPECT_ACTION_UPDATE_STATE( 2313 EXPECT_ACTION_UPDATE_STATE(
2267 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2314 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2268 state.NotifyBeginMainFrameStarted(); 2315 state.NotifyBeginMainFrameStarted();
2269 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); 2316 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 SchedulerSettings settings; 2391 SchedulerSettings settings;
2345 StateMachine state(settings); 2392 StateMachine state(settings);
2346 SET_UP_STATE(state); 2393 SET_UP_STATE(state);
2347 2394
2348 // Set up a request for impl-side invalidation. 2395 // Set up a request for impl-side invalidation.
2349 state.SetNeedsImplSideInvalidation(); 2396 state.SetNeedsImplSideInvalidation();
2350 state.IssueNextBeginImplFrame(); 2397 state.IssueNextBeginImplFrame();
2351 state.OnBeginImplFrameDeadline(); 2398 state.OnBeginImplFrameDeadline();
2352 EXPECT_ACTION_UPDATE_STATE( 2399 EXPECT_ACTION_UPDATE_STATE(
2353 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2400 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2401 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2354 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2402 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2355 2403
2356 // Request another invalidation, which should wait until the pending tree is 2404 // Request another invalidation, which should wait until the pending tree is
2357 // activated *and* we start the next BeginFrame. 2405 // activated *and* we start the next BeginFrame.
2358 state.SetNeedsImplSideInvalidation(); 2406 state.SetNeedsImplSideInvalidation();
2359 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2407 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2360 state.NotifyReadyToActivate(); 2408 state.NotifyReadyToActivate();
2361 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 2409 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
2362 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2410 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2363 2411
(...skipping 28 matching lines...) Expand all
2392 state.OnBeginImplFrameDeadline(); 2440 state.OnBeginImplFrameDeadline();
2393 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 2441 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
2394 state.DidSubmitCompositorFrame(); 2442 state.DidSubmitCompositorFrame();
2395 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2443 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2396 2444
2397 // Request impl-side invalidation and start a new frame, which should be 2445 // Request impl-side invalidation and start a new frame, which should be
2398 // blocked on the ack for the previous frame. 2446 // blocked on the ack for the previous frame.
2399 state.SetNeedsImplSideInvalidation(); 2447 state.SetNeedsImplSideInvalidation();
2400 state.IssueNextBeginImplFrame(); 2448 state.IssueNextBeginImplFrame();
2401 state.OnBeginImplFrameDeadline(); 2449 state.OnBeginImplFrameDeadline();
2450 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2402 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2451 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2403 2452
2404 // Ack the previous frame and begin impl frame, which should perform the 2453 // Ack the previous frame and begin impl frame, which should perform the
2405 // invalidation now. 2454 // invalidation now.
2406 state.DidReceiveCompositorFrameAck(); 2455 state.DidReceiveCompositorFrameAck();
2407 state.IssueNextBeginImplFrame(); 2456 state.IssueNextBeginImplFrame();
2408 state.OnBeginImplFrameDeadline(); 2457 state.OnBeginImplFrameDeadline();
2409 EXPECT_ACTION_UPDATE_STATE( 2458 EXPECT_ACTION_UPDATE_STATE(
2410 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2459 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2411 } 2460 }
(...skipping 28 matching lines...) Expand all
2440 2489
2441 // Request a PrepareTiles and impl-side invalidation. The impl-side 2490 // Request a PrepareTiles and impl-side invalidation. The impl-side
2442 // invalidation should run first, since it will perform PrepareTiles as well. 2491 // invalidation should run first, since it will perform PrepareTiles as well.
2443 state.SetNeedsImplSideInvalidation(); 2492 state.SetNeedsImplSideInvalidation();
2444 state.SetNeedsPrepareTiles(); 2493 state.SetNeedsPrepareTiles();
2445 state.IssueNextBeginImplFrame(); 2494 state.IssueNextBeginImplFrame();
2446 state.OnBeginImplFrameDeadline(); 2495 state.OnBeginImplFrameDeadline();
2447 EXPECT_ACTION_UPDATE_STATE( 2496 EXPECT_ACTION_UPDATE_STATE(
2448 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2497 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2449 state.DidPrepareTiles(); 2498 state.DidPrepareTiles();
2499 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2450 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2500 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2451 } 2501 }
2452 2502
2453 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessInitialState) { 2503 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessInitialState) {
2454 SchedulerSettings default_scheduler_settings; 2504 SchedulerSettings default_scheduler_settings;
2455 StateMachine state(default_scheduler_settings); 2505 StateMachine state(default_scheduler_settings);
2456 SET_UP_STATE(state) 2506 SET_UP_STATE(state)
2457 2507
2458 // Initially, we report invalid frame numbers. 2508 // Initially, we report invalid frame numbers.
2459 EXPECT_SEQUENCE_NUMBERS( 2509 EXPECT_SEQUENCE_NUMBERS(
2460 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber, 2510 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber,
2461 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber, 2511 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber,
2462 BeginFrameArgs::kInvalidFrameNumber); 2512 BeginFrameArgs::kInvalidFrameNumber);
2463 } 2513 }
2464 2514
2465 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithoutUpdates) { 2515 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithoutUpdates) {
2466 // Setup without any requested updates. 2516 // Setup without any requested updates.
2467 SchedulerSettings default_scheduler_settings; 2517 SchedulerSettings default_scheduler_settings;
2468 StateMachine state(default_scheduler_settings); 2518 StateMachine state(default_scheduler_settings);
2469 SET_UP_STATE(state) 2519 SET_UP_STATE(state)
2470 state.SetNeedsRedraw(false); 2520 state.SetNeedsRedraw(false);
2471 EXPECT_FALSE(state.RedrawPending()); 2521 EXPECT_FALSE(state.RedrawPending());
2472 EXPECT_FALSE(state.NeedsCommit()); 2522 EXPECT_FALSE(state.NeedsCommit());
2473 2523
2474 // OnBeginImplFrame() updates the sequence number. 2524 // OnBeginImplFrame() updates the sequence number.
2475 state.OnBeginImplFrame(0, 10); 2525 state.OnBeginImplFrame(0, 10);
2526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2476 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2527 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2477 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2528 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber,
2478 BeginFrameArgs::kInvalidFrameNumber, 2529 BeginFrameArgs::kInvalidFrameNumber,
2479 BeginFrameArgs::kInvalidFrameNumber, 2530 BeginFrameArgs::kInvalidFrameNumber,
2480 BeginFrameArgs::kInvalidFrameNumber); 2531 BeginFrameArgs::kInvalidFrameNumber);
2481 2532
2482 // When no updates are required, OnBeginImplFrameDeadline() updates active 2533 // When no updates are required, OnBeginImplFrameDeadline() updates active
2483 // tree and compositor frame freshness. 2534 // tree and compositor frame freshness.
2484 state.OnBeginImplFrameDeadline(); 2535 state.OnBeginImplFrameDeadline();
2485 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2536 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2486 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2537 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber,
2487 BeginFrameArgs::kInvalidFrameNumber, 10u, 10u); 2538 BeginFrameArgs::kInvalidFrameNumber, 10u, 10u);
2488 state.OnBeginImplFrameIdle(); 2539 state.OnBeginImplFrameIdle();
2489 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2540 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2490 } 2541 }
2491 2542
2492 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithImplFrameUpdates) { 2543 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithImplFrameUpdates) {
2493 // Setup with an impl-thread draw requested. 2544 // Setup with an impl-thread draw requested.
2494 SchedulerSettings default_scheduler_settings; 2545 SchedulerSettings default_scheduler_settings;
2495 StateMachine state(default_scheduler_settings); 2546 StateMachine state(default_scheduler_settings);
2496 SET_UP_STATE(state) 2547 SET_UP_STATE(state)
2497 state.SetNeedsRedraw(true); 2548 state.SetNeedsRedraw(true);
2498 EXPECT_TRUE(state.RedrawPending()); 2549 EXPECT_TRUE(state.RedrawPending());
2499 EXPECT_FALSE(state.NeedsCommit()); 2550 EXPECT_FALSE(state.NeedsCommit());
2500 2551
2501 // OnBeginImplFrame() updates the sequence number. 2552 // OnBeginImplFrame() updates the sequence number.
2502 state.OnBeginImplFrame(0, 10); 2553 state.OnBeginImplFrame(0, 10);
2554 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2503 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2555 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2504 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2556 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber,
2505 BeginFrameArgs::kInvalidFrameNumber, 2557 BeginFrameArgs::kInvalidFrameNumber,
2506 BeginFrameArgs::kInvalidFrameNumber, 2558 BeginFrameArgs::kInvalidFrameNumber,
2507 BeginFrameArgs::kInvalidFrameNumber); 2559 BeginFrameArgs::kInvalidFrameNumber);
2508 2560
2509 // With only an impl-thread draw requested, OnBeginImplFrameDeadline() 2561 // With only an impl-thread draw requested, OnBeginImplFrameDeadline()
2510 // updates the active tree freshness. 2562 // updates the active tree freshness.
2511 state.OnBeginImplFrameDeadline(); 2563 state.OnBeginImplFrameDeadline();
2512 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2564 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2619 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2568 EXPECT_SEQUENCE_NUMBERS(11u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2620 EXPECT_SEQUENCE_NUMBERS(11u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2569 BeginFrameArgs::kInvalidFrameNumber, 2621 BeginFrameArgs::kInvalidFrameNumber,
2570 BeginFrameArgs::kInvalidFrameNumber); 2622 BeginFrameArgs::kInvalidFrameNumber);
2571 state.OnBeginImplFrameIdle(); 2623 state.OnBeginImplFrameIdle();
2572 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2624 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2573 2625
2574 // Pending tree freshness is updated when the new pending tree is committed. 2626 // Pending tree freshness is updated when the new pending tree is committed.
2575 state.NotifyReadyToCommit(); 2627 state.NotifyReadyToCommit();
2576 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 2628 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
2629 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2577 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2630 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2578 EXPECT_FALSE(state.CommitPending()); 2631 EXPECT_FALSE(state.CommitPending());
2579 EXPECT_TRUE(state.has_pending_tree()); 2632 EXPECT_TRUE(state.has_pending_tree());
2580 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2633 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2581 BeginFrameArgs::kInvalidFrameNumber); 2634 BeginFrameArgs::kInvalidFrameNumber);
2582 2635
2583 // If no further BeginMainFrame is needed, OnBeginFrameImplDeadline() 2636 // If no further BeginMainFrame is needed, OnBeginFrameImplDeadline()
2584 // updates the pending tree's frame number. 2637 // updates the pending tree's frame number.
2585 state.OnBeginImplFrame(0, 12); 2638 state.OnBeginImplFrame(0, 12);
2639 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2586 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2640 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2587 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2641 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2588 BeginFrameArgs::kInvalidFrameNumber); 2642 BeginFrameArgs::kInvalidFrameNumber);
2589 state.OnBeginImplFrameDeadline(); 2643 state.OnBeginImplFrameDeadline();
2590 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2644 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2591 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 12u, BeginFrameArgs::kInvalidFrameNumber, 2645 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 12u, BeginFrameArgs::kInvalidFrameNumber,
2592 BeginFrameArgs::kInvalidFrameNumber); 2646 BeginFrameArgs::kInvalidFrameNumber);
2593 state.OnBeginImplFrameIdle(); 2647 state.OnBeginImplFrameIdle();
2594 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2648 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2595 2649
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 state.DidSubmitCompositorFrame(); 2691 state.DidSubmitCompositorFrame();
2638 state.DidReceiveCompositorFrameAck(); 2692 state.DidReceiveCompositorFrameAck();
2639 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2693 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2640 EXPECT_SEQUENCE_NUMBERS(14u, 14u, 12u, 14u, 14u); 2694 EXPECT_SEQUENCE_NUMBERS(14u, 14u, 12u, 14u, 14u);
2641 state.OnBeginImplFrameIdle(); 2695 state.OnBeginImplFrameIdle();
2642 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2696 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2643 2697
2644 // When no updates are required, OnBeginImplFrameDeadline() updates active 2698 // When no updates are required, OnBeginImplFrameDeadline() updates active
2645 // tree and compositor frame freshness. 2699 // tree and compositor frame freshness.
2646 state.OnBeginImplFrame(0, 15); 2700 state.OnBeginImplFrame(0, 15);
2701 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2647 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2702 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2648 state.OnBeginImplFrameDeadline(); 2703 state.OnBeginImplFrameDeadline();
2649 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2704 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2650 EXPECT_SEQUENCE_NUMBERS(15u, 14u, 12u, 15u, 15u); 2705 EXPECT_SEQUENCE_NUMBERS(15u, 14u, 12u, 15u, 15u);
2651 state.OnBeginImplFrameIdle(); 2706 state.OnBeginImplFrameIdle();
2652 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2707 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2653 2708
2654 // Active tree and compositor frame freshness are updated when commit doesn't 2709 // Active tree and compositor frame freshness are updated when commit doesn't
2655 // have updates and compositor frame was fresh before. 2710 // have updates and compositor frame was fresh before.
2656 state.SetNeedsBeginMainFrameForTest(true); 2711 state.SetNeedsBeginMainFrameForTest(true);
2657 EXPECT_TRUE(state.NeedsCommit()); 2712 EXPECT_TRUE(state.NeedsCommit());
2658 state.OnBeginImplFrame(0, 16); 2713 state.OnBeginImplFrame(0, 16);
2659 EXPECT_ACTION_UPDATE_STATE( 2714 EXPECT_ACTION_UPDATE_STATE(
2660 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2715 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2661 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2716 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2662 EXPECT_FALSE(state.NeedsCommit()); 2717 EXPECT_FALSE(state.NeedsCommit());
2663 EXPECT_TRUE(state.CommitPending()); 2718 EXPECT_TRUE(state.CommitPending());
2664 state.NotifyBeginMainFrameStarted(); 2719 state.NotifyBeginMainFrameStarted();
2665 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); 2720 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
2666 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u); 2721 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u);
2667 state.OnBeginImplFrameDeadline(); 2722 state.OnBeginImplFrameDeadline();
2668 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2723 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2669 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u); 2724 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u);
2670 state.OnBeginImplFrameIdle(); 2725 state.OnBeginImplFrameIdle();
2671 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2726 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2672 2727
2673 // When the source changes, the current frame number is updated and frame 2728 // When the source changes, the current frame number is updated and frame
2674 // numbers for freshness are reset to invalid numbers. 2729 // numbers for freshness are reset to invalid numbers.
2675 state.OnBeginImplFrame(1, 5); 2730 state.OnBeginImplFrame(1, 5);
2731 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2676 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2732 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2677 EXPECT_SEQUENCE_NUMBERS(5u, BeginFrameArgs::kInvalidFrameNumber, 2733 EXPECT_SEQUENCE_NUMBERS(5u, BeginFrameArgs::kInvalidFrameNumber,
2678 BeginFrameArgs::kInvalidFrameNumber, 2734 BeginFrameArgs::kInvalidFrameNumber,
2679 BeginFrameArgs::kInvalidFrameNumber, 2735 BeginFrameArgs::kInvalidFrameNumber,
2680 BeginFrameArgs::kInvalidFrameNumber); 2736 BeginFrameArgs::kInvalidFrameNumber);
2681 2737
2682 // When no updates are required, OnBeginImplFrameDeadline() updates active 2738 // When no updates are required, OnBeginImplFrameDeadline() updates active
2683 // tree and compositor frame freshness. 2739 // tree and compositor frame freshness.
2684 state.OnBeginImplFrameDeadline(); 2740 state.OnBeginImplFrameDeadline();
2685 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2741 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 state.OnBeginImplFrameDeadline(); 2783 state.OnBeginImplFrameDeadline();
2728 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2784 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2729 EXPECT_SEQUENCE_NUMBERS(10u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2785 EXPECT_SEQUENCE_NUMBERS(10u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2730 BeginFrameArgs::kInvalidFrameNumber); 2786 BeginFrameArgs::kInvalidFrameNumber);
2731 state.OnBeginImplFrameIdle(); 2787 state.OnBeginImplFrameIdle();
2732 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2788 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2733 } 2789 }
2734 2790
2735 } // namespace 2791 } // namespace
2736 } // namespace cc 2792 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698