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

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: missed one Created 3 years, 9 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 306 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
303 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit(); 307 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
304 state.SetBeginMainFrameState( 308 state.SetBeginMainFrameState(
305 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 309 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
306 state.SetNeedsRedraw(false); 310 state.SetNeedsRedraw(false);
307 311
308 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 312 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
309 EXPECT_FALSE(state.NeedsCommit()); 313 EXPECT_FALSE(state.NeedsCommit());
310 314
311 state.IssueNextBeginImplFrame(); 315 state.IssueNextBeginImplFrame();
316 EXPECT_ACTION_UPDATE_STATE(
317 SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
312 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 318 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
313 319
314 state.OnBeginImplFrameDeadline(); 320 state.OnBeginImplFrameDeadline();
315 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 321 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
316 EXPECT_FALSE(state.NeedsCommit()); 322 EXPECT_FALSE(state.NeedsCommit());
317 } 323 }
318 324
319 // If commit requested but not visible yet, do nothing. 325 // If commit requested but not visible yet, do nothing.
320 { 326 {
321 StateMachine state(default_scheduler_settings); 327 StateMachine state(default_scheduler_settings);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 FailedDrawForAnimationCheckerboardSetsNeedsCommitAndRetriesDraw) { 457 FailedDrawForAnimationCheckerboardSetsNeedsCommitAndRetriesDraw) {
452 SchedulerSettings default_scheduler_settings; 458 SchedulerSettings default_scheduler_settings;
453 StateMachine state(default_scheduler_settings); 459 StateMachine state(default_scheduler_settings);
454 SET_UP_STATE(state) 460 SET_UP_STATE(state)
455 state.SetNeedsRedraw(true); 461 state.SetNeedsRedraw(true);
456 EXPECT_TRUE(state.RedrawPending()); 462 EXPECT_TRUE(state.RedrawPending());
457 EXPECT_TRUE(state.BeginFrameNeeded()); 463 EXPECT_TRUE(state.BeginFrameNeeded());
458 464
459 // Start a frame. 465 // Start a frame.
460 state.IssueNextBeginImplFrame(); 466 state.IssueNextBeginImplFrame();
467 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
Sami 2017/03/24 15:24:10 I was thinking we might wanna avoid idling here, b
Dan Elphick 2017/03/29 16:02:44 Acknowledged.
461 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 468 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
462 EXPECT_FALSE(state.CommitPending()); 469 EXPECT_FALSE(state.CommitPending());
463 470
464 // Failing a draw triggers request for a new BeginMainFrame. 471 // Failing a draw triggers request for a new BeginMainFrame.
465 state.OnBeginImplFrameDeadline(); 472 state.OnBeginImplFrameDeadline();
466 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); 473 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS);
467 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 474 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
468 EXPECT_ACTION_UPDATE_STATE( 475 EXPECT_ACTION_UPDATE_STATE(
469 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 476 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
470 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 477 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 17 matching lines...) Expand all
488 TEST(SchedulerStateMachineTest, FailedDrawForMissingHighResNeedsCommit) { 495 TEST(SchedulerStateMachineTest, FailedDrawForMissingHighResNeedsCommit) {
489 SchedulerSettings default_scheduler_settings; 496 SchedulerSettings default_scheduler_settings;
490 StateMachine state(default_scheduler_settings); 497 StateMachine state(default_scheduler_settings);
491 SET_UP_STATE(state) 498 SET_UP_STATE(state)
492 state.SetNeedsRedraw(true); 499 state.SetNeedsRedraw(true);
493 EXPECT_TRUE(state.RedrawPending()); 500 EXPECT_TRUE(state.RedrawPending());
494 EXPECT_TRUE(state.BeginFrameNeeded()); 501 EXPECT_TRUE(state.BeginFrameNeeded());
495 502
496 // Start a frame. 503 // Start a frame.
497 state.IssueNextBeginImplFrame(); 504 state.IssueNextBeginImplFrame();
505 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
498 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 506 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
499 EXPECT_FALSE(state.CommitPending()); 507 EXPECT_FALSE(state.CommitPending());
500 508
501 // Failing a draw triggers because of high res tiles missing 509 // Failing a draw triggers because of high res tiles missing
502 // request for a new BeginMainFrame. 510 // request for a new BeginMainFrame.
503 state.OnBeginImplFrameDeadline(); 511 state.OnBeginImplFrameDeadline();
504 state.SetDrawResultForTest(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); 512 state.SetDrawResultForTest(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT);
505 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 513 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
506 EXPECT_ACTION_UPDATE_STATE( 514 EXPECT_ACTION_UPDATE_STATE(
507 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 515 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
508 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 516 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
509 state.OnBeginImplFrameIdle(); 517 state.OnBeginImplFrameIdle();
510 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 518 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
511 519
512 // It doesn't request a draw until we get a new commit though. 520 // It doesn't request a draw until we get a new commit though.
513 EXPECT_TRUE(state.CommitPending()); 521 EXPECT_TRUE(state.CommitPending());
514 EXPECT_FALSE(state.RedrawPending()); 522 EXPECT_FALSE(state.RedrawPending());
515 state.IssueNextBeginImplFrame(); 523 state.IssueNextBeginImplFrame();
516 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 524 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
517 state.OnBeginImplFrameDeadline(); 525 state.OnBeginImplFrameDeadline();
518 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
519 state.OnBeginImplFrameIdle(); 527 state.OnBeginImplFrameIdle();
520 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 528 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
521 529
522 // Finish the commit and activation. 530 // Finish the commit and activation.
523 state.NotifyBeginMainFrameStarted(); 531 state.NotifyBeginMainFrameStarted();
524 state.NotifyReadyToCommit(); 532 state.NotifyReadyToCommit();
525 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 533 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
534 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
Sami 2017/03/24 15:24:11 Is this right? We just did a BeginMainFrame.
Dan Elphick 2017/03/29 16:02:44 It's right in that the tests don't pass without it
Dan Elphick 2017/04/06 16:10:16 This is now removed after tweaking the state machi
526 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 535 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
527 state.NotifyReadyToActivate(); 536 state.NotifyReadyToActivate();
528 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 537 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
529 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 538 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
530 EXPECT_TRUE(state.RedrawPending()); 539 EXPECT_TRUE(state.RedrawPending());
531 540
532 // Verify we draw with the new frame. 541 // Verify we draw with the new frame.
533 state.IssueNextBeginImplFrame(); 542 state.IssueNextBeginImplFrame();
543 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
534 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 544 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
535 state.OnBeginImplFrameDeadline(); 545 state.OnBeginImplFrameDeadline();
536 state.SetDrawResultForTest(DRAW_SUCCESS); 546 state.SetDrawResultForTest(DRAW_SUCCESS);
537 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 547 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
538 state.DidSubmitCompositorFrame(); 548 state.DidSubmitCompositorFrame();
539 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 549 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
540 state.OnBeginImplFrameIdle(); 550 state.OnBeginImplFrameIdle();
541 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 551 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
542 } 552 }
543 553
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 667
658 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) { 668 TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedInNextBeginImplFrame) {
659 SchedulerSettings default_scheduler_settings; 669 SchedulerSettings default_scheduler_settings;
660 StateMachine state(default_scheduler_settings); 670 StateMachine state(default_scheduler_settings);
661 SET_UP_STATE(state) 671 SET_UP_STATE(state)
662 672
663 // Start a draw. 673 // Start a draw.
664 state.SetNeedsRedraw(true); 674 state.SetNeedsRedraw(true);
665 EXPECT_TRUE(state.BeginFrameNeeded()); 675 EXPECT_TRUE(state.BeginFrameNeeded());
666 state.IssueNextBeginImplFrame(); 676 state.IssueNextBeginImplFrame();
677 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
667 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 678 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
668 state.OnBeginImplFrameDeadline(); 679 state.OnBeginImplFrameDeadline();
669 EXPECT_TRUE(state.RedrawPending()); 680 EXPECT_TRUE(state.RedrawPending());
670 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); 681 state.SetDrawResultForTest(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS);
671 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 682 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
672 683
673 // Failing the draw for animation checkerboards makes us require a commit. 684 // Failing the draw for animation checkerboards makes us require a commit.
674 EXPECT_ACTION_UPDATE_STATE( 685 EXPECT_ACTION_UPDATE_STATE(
675 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 686 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
676 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 687 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 16 matching lines...) Expand all
693 704
694 TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) { 705 TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) {
695 SchedulerSettings default_scheduler_settings; 706 SchedulerSettings default_scheduler_settings;
696 StateMachine state(default_scheduler_settings); 707 StateMachine state(default_scheduler_settings);
697 SET_UP_STATE(state) 708 SET_UP_STATE(state)
698 state.SetNeedsRedraw(true); 709 state.SetNeedsRedraw(true);
699 710
700 // Draw the first frame. 711 // Draw the first frame.
701 EXPECT_TRUE(state.BeginFrameNeeded()); 712 EXPECT_TRUE(state.BeginFrameNeeded());
702 state.IssueNextBeginImplFrame(); 713 state.IssueNextBeginImplFrame();
714 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
703 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 715 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
704 716
705 state.OnBeginImplFrameDeadline(); 717 state.OnBeginImplFrameDeadline();
706 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 718 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
707 state.DidSubmitCompositorFrame(); 719 state.DidSubmitCompositorFrame();
708 state.DidReceiveCompositorFrameAck(); 720 state.DidReceiveCompositorFrameAck();
709 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 721 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
710 722
711 // Before the next BeginImplFrame, set needs redraw again. 723 // Before the next BeginImplFrame, set needs redraw again.
712 // This should not redraw until the next BeginImplFrame. 724 // This should not redraw until the next BeginImplFrame.
713 state.SetNeedsRedraw(true); 725 state.SetNeedsRedraw(true);
714 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 726 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
715 727
716 // Move to another frame. This should now draw. 728 // Move to another frame. This should now draw.
717 EXPECT_TRUE(state.BeginFrameNeeded()); 729 EXPECT_TRUE(state.BeginFrameNeeded());
718 state.IssueNextBeginImplFrame(); 730 state.IssueNextBeginImplFrame();
731 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
719 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 732 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
720 state.OnBeginImplFrameDeadline(); 733 state.OnBeginImplFrameDeadline();
721 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 734 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
722 state.DidSubmitCompositorFrame(); 735 state.DidSubmitCompositorFrame();
723 state.DidReceiveCompositorFrameAck(); 736 state.DidReceiveCompositorFrameAck();
724 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 737 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
725 738
726 // We just submitted, so we should proactively request another BeginImplFrame. 739 // We just submitted, so we should proactively request another BeginImplFrame.
727 EXPECT_TRUE(state.BeginFrameNeeded()); 740 EXPECT_TRUE(state.BeginFrameNeeded());
728 } 741 }
(...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. 1406 // Since the commit was aborted, we don't need to try and draw.
1394 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1407 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1395 state.OnBeginImplFrameDeadline(); 1408 state.OnBeginImplFrameDeadline();
1396 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1409 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1397 1410
1398 // Verify another commit doesn't start on another frame either. 1411 // Verify another commit doesn't start on another frame either.
1399 EXPECT_FALSE(state.NeedsCommit()); 1412 EXPECT_FALSE(state.NeedsCommit());
1400 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 1413 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
1401 1414
1402 state.IssueNextBeginImplFrame(); 1415 state.IssueNextBeginImplFrame();
1416 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1403 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1417 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1404 state.OnBeginImplFrameDeadline(); 1418 state.OnBeginImplFrameDeadline();
1405 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1419 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1406 1420
1407 // Verify another commit can start if requested, though. 1421 // Verify another commit can start if requested, though.
1408 state.SetNeedsBeginMainFrame(); 1422 state.SetNeedsBeginMainFrame();
1409 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 1423 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
1410 state.IssueNextBeginImplFrame(); 1424 state.IssueNextBeginImplFrame();
1411 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1425 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1412 } 1426 }
1413 1427
1414 TEST(SchedulerStateMachineTest, TestFirstContextCreation) { 1428 TEST(SchedulerStateMachineTest, TestFirstContextCreation) {
1415 SchedulerSettings default_scheduler_settings; 1429 SchedulerSettings default_scheduler_settings;
1416 StateMachine state(default_scheduler_settings); 1430 StateMachine state(default_scheduler_settings);
1417 state.SetVisible(true); 1431 state.SetVisible(true);
1418 state.SetCanDraw(true); 1432 state.SetCanDraw(true);
1419 1433
1420 EXPECT_ACTION_UPDATE_STATE( 1434 EXPECT_ACTION_UPDATE_STATE(
1421 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 1435 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1422 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit(); 1436 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1423 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1437 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1424 1438
1425 // Check that the first init does not SetNeedsBeginMainFrame. 1439 // Check that the first init does not SetNeedsBeginMainFrame.
1426 state.IssueNextBeginImplFrame(); 1440 state.IssueNextBeginImplFrame();
1441 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1427 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1442 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1428 state.OnBeginImplFrameDeadline(); 1443 state.OnBeginImplFrameDeadline();
1429 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1444 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1430 1445
1431 // Check that a needs commit initiates a BeginMainFrame. 1446 // Check that a needs commit initiates a BeginMainFrame.
1432 state.SetNeedsBeginMainFrame(); 1447 state.SetNeedsBeginMainFrame();
1433 state.IssueNextBeginImplFrame(); 1448 state.IssueNextBeginImplFrame();
1434 EXPECT_ACTION_UPDATE_STATE( 1449 EXPECT_ACTION_UPDATE_STATE(
1435 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1450 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1436 } 1451 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 state.DidLoseCompositorFrameSink(); 1486 state.DidLoseCompositorFrameSink();
1472 EXPECT_EQ(state.compositor_frame_sink_state(), 1487 EXPECT_EQ(state.compositor_frame_sink_state(),
1473 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_NONE); 1488 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_NONE);
1474 1489
1475 EXPECT_ACTION_UPDATE_STATE( 1490 EXPECT_ACTION_UPDATE_STATE(
1476 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 1491 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1477 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1492 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1478 1493
1479 // Once context recreation begins, nothing should happen. 1494 // Once context recreation begins, nothing should happen.
1480 state.IssueNextBeginImplFrame(); 1495 state.IssueNextBeginImplFrame();
1496 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1481 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1497 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1482 state.OnBeginImplFrameDeadline(); 1498 state.OnBeginImplFrameDeadline();
1483 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1499 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1484 1500
1485 // While context is recreating, commits shouldn't begin. 1501 // While context is recreating, commits shouldn't begin.
1486 state.SetNeedsBeginMainFrame(); 1502 state.SetNeedsBeginMainFrame();
1487 state.IssueNextBeginImplFrame(); 1503 state.IssueNextBeginImplFrame();
1488 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1504 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1489 state.OnBeginImplFrameDeadline(); 1505 state.OnBeginImplFrameDeadline();
1490 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1506 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 30 matching lines...) Expand all
1521 state.NotifyReadyToActivate(); 1537 state.NotifyReadyToActivate();
1522 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1538 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1523 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1539 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1524 EXPECT_EQ(state.compositor_frame_sink_state(), 1540 EXPECT_EQ(state.compositor_frame_sink_state(),
1525 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_ACTIVE); 1541 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_ACTIVE);
1526 1542
1527 // Finishing the first commit after initializing an CompositorFrameSink should 1543 // Finishing the first commit after initializing an CompositorFrameSink should
1528 // automatically cause a redraw. 1544 // automatically cause a redraw.
1529 EXPECT_TRUE(state.RedrawPending()); 1545 EXPECT_TRUE(state.RedrawPending());
1530 state.IssueNextBeginImplFrame(); 1546 state.IssueNextBeginImplFrame();
1547 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1531 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1548 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1532 state.OnBeginImplFrameDeadline(); 1549 state.OnBeginImplFrameDeadline();
1533 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 1550 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
1534 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1551 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1535 EXPECT_FALSE(state.RedrawPending()); 1552 EXPECT_FALSE(state.RedrawPending());
1536 1553
1537 // Next frame as no work to do. 1554 // Next frame as no work to do.
1538 state.IssueNextBeginImplFrame(); 1555 state.IssueNextBeginImplFrame();
1556 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1539 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1557 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1540 state.OnBeginImplFrameDeadline(); 1558 state.OnBeginImplFrameDeadline();
1541 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1559 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1542 1560
1543 // Once the context is recreated, whether we draw should be based on 1561 // Once the context is recreated, whether we draw should be based on
1544 // SetCanDraw if waiting on first draw after activate. 1562 // SetCanDraw if waiting on first draw after activate.
1545 state.SetNeedsRedraw(true); 1563 state.SetNeedsRedraw(true);
1546 state.IssueNextBeginImplFrame(); 1564 state.IssueNextBeginImplFrame();
1565 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1547 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1566 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1548 state.OnBeginImplFrameDeadline(); 1567 state.OnBeginImplFrameDeadline();
1549 EXPECT_ACTION(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 1568 EXPECT_ACTION(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
1550 state.SetCanDraw(false); 1569 state.SetCanDraw(false);
1551 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1570 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1552 state.SetCanDraw(true); 1571 state.SetCanDraw(true);
1553 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 1572 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
1554 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1573 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1555 1574
1556 // Once the context is recreated, whether we draw should be based on 1575 // 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); 1648 BeginFrameArgs::kInvalidFrameNumber);
1630 1649
1631 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE 1650 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE
1632 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 1651 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
1633 EXPECT_ACTION( 1652 EXPECT_ACTION(
1634 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 1653 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1635 1654
1636 state.OnBeginImplFrame(0, 11); 1655 state.OnBeginImplFrame(0, 11);
1637 EXPECT_IMPL_FRAME_STATE( 1656 EXPECT_IMPL_FRAME_STATE(
1638 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME); 1657 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME);
1658 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
1639 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1659 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1640 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 10u, 1660 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 10u,
1641 BeginFrameArgs::kInvalidFrameNumber); 1661 BeginFrameArgs::kInvalidFrameNumber);
1642 1662
1643 state.OnBeginImplFrameDeadline(); 1663 state.OnBeginImplFrameDeadline();
1644 EXPECT_IMPL_FRAME_STATE( 1664 EXPECT_IMPL_FRAME_STATE(
1645 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 1665 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
1646 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1666 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1647 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 11u, 11u); 1667 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, 11u, 11u);
1648 } 1668 }
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 // commit. 2006 // commit.
1987 state.NotifyBeginMainFrameStarted(); 2007 state.NotifyBeginMainFrameStarted();
1988 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); 2008 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
1989 2009
1990 // Since the commit was aborted, we should draw right away instead of waiting 2010 // Since the commit was aborted, we should draw right away instead of waiting
1991 // for the deadline. 2011 // for the deadline.
1992 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2012 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
1993 } 2013 }
1994 2014
1995 void FinishPreviousCommitAndDrawWithoutExitingDeadline( 2015 void FinishPreviousCommitAndDrawWithoutExitingDeadline(
1996 StateMachine* state_ptr) { 2016 StateMachine* state_ptr,
2017 bool expectIdleWorkBeforeImplFrame) {
Sami 2017/03/24 15:24:11 nit: hacker_style Also expect_idle_work_before_im
Dan Elphick 2017/03/29 16:02:44 Done.
1997 // Gross, but allows us to use macros below. 2018 // Gross, but allows us to use macros below.
1998 StateMachine& state = *state_ptr; 2019 StateMachine& state = *state_ptr;
1999 2020
2000 state.NotifyBeginMainFrameStarted(); 2021 state.NotifyBeginMainFrameStarted();
2001 state.NotifyReadyToCommit(); 2022 state.NotifyReadyToCommit();
2002 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 2023 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
2003 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2024 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2004 state.NotifyReadyToActivate(); 2025 state.NotifyReadyToActivate();
2005 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 2026 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
2006 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2027 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2007 2028
2008 state.IssueNextBeginImplFrame(); 2029 state.IssueNextBeginImplFrame();
2030 if (expectIdleWorkBeforeImplFrame) {
2031 EXPECT_ACTION_UPDATE_STATE(
2032 SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2033 }
2009 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2034 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2010 2035
2011 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2036 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
2012 state.OnBeginImplFrameDeadline(); 2037 state.OnBeginImplFrameDeadline();
2013 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 2038 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
2014 state.DidSubmitCompositorFrame(); 2039 state.DidSubmitCompositorFrame();
2015 } 2040 }
2016 2041
2017 TEST(SchedulerStateMachineTest, TestImplLatencyTakesPriority) { 2042 TEST(SchedulerStateMachineTest, TestImplLatencyTakesPriority) {
2018 SchedulerSettings default_scheduler_settings; 2043 SchedulerSettings default_scheduler_settings;
(...skipping 19 matching lines...) Expand all
2038 2063
2039 // Trigger the deadline. 2064 // Trigger the deadline.
2040 state.OnBeginImplFrameDeadline(); 2065 state.OnBeginImplFrameDeadline();
2041 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 2066 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
2042 state.DidSubmitCompositorFrame(); 2067 state.DidSubmitCompositorFrame();
2043 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2068 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2044 state.DidReceiveCompositorFrameAck(); 2069 state.DidReceiveCompositorFrameAck();
2045 2070
2046 // Request a new commit and finish the previous one. 2071 // Request a new commit and finish the previous one.
2047 state.SetNeedsBeginMainFrame(); 2072 state.SetNeedsBeginMainFrame();
2048 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state); 2073 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state, false);
2049 EXPECT_ACTION_UPDATE_STATE( 2074 EXPECT_ACTION_UPDATE_STATE(
2050 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2075 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2051 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2076 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2052 state.DidReceiveCompositorFrameAck(); 2077 state.DidReceiveCompositorFrameAck();
2053 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2078 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2054 2079
2055 // Finish the previous commit and draw it. 2080 // Finish the previous commit and draw it.
2056 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state); 2081 FinishPreviousCommitAndDrawWithoutExitingDeadline(&state, true);
2057 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2082 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2058 2083
2059 // Verify we do not send another BeginMainFrame if was are submit-frame 2084 // Verify we do not send another BeginMainFrame if was are submit-frame
2060 // throttled and did not just submit one. 2085 // throttled and did not just submit one.
2061 state.SetNeedsBeginMainFrame(); 2086 state.SetNeedsBeginMainFrame();
2062 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2087 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2063 state.IssueNextBeginImplFrame(); 2088 state.IssueNextBeginImplFrame();
2064 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2089 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2065 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2090 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
2066 state.OnBeginImplFrameDeadline(); 2091 state.OnBeginImplFrameDeadline();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2252 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2228 } 2253 }
2229 2254
2230 TEST(SchedulerStateMachineTest, ImplSideInvalidationOnlyInsideDeadline) { 2255 TEST(SchedulerStateMachineTest, ImplSideInvalidationOnlyInsideDeadline) {
2231 SchedulerSettings settings; 2256 SchedulerSettings settings;
2232 StateMachine state(settings); 2257 StateMachine state(settings);
2233 SET_UP_STATE(state); 2258 SET_UP_STATE(state);
2234 2259
2235 state.SetNeedsImplSideInvalidation(); 2260 state.SetNeedsImplSideInvalidation();
2236 state.IssueNextBeginImplFrame(); 2261 state.IssueNextBeginImplFrame();
2262 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2237 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2263 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2238 state.OnBeginImplFrameDeadline(); 2264 state.OnBeginImplFrameDeadline();
2239 EXPECT_ACTION_UPDATE_STATE( 2265 EXPECT_ACTION_UPDATE_STATE(
2240 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2266 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2241 } 2267 }
2242 2268
2243 TEST(SchedulerStateMachineTest, 2269 TEST(SchedulerStateMachineTest,
2244 NoImplSideInvalidationWithoutCompositorFrameSink) { 2270 NoImplSideInvalidationWithoutCompositorFrameSink) {
2245 SchedulerSettings settings; 2271 SchedulerSettings settings;
2246 StateMachine state(settings); 2272 StateMachine state(settings);
2247 SET_UP_STATE(state); 2273 SET_UP_STATE(state);
2248 2274
2249 // Impl-side invalidations should not be triggered till the frame sink is 2275 // Impl-side invalidations should not be triggered till the frame sink is
2250 // initialized. 2276 // initialized.
2251 state.DidLoseCompositorFrameSink(); 2277 state.DidLoseCompositorFrameSink();
2252 EXPECT_ACTION_UPDATE_STATE( 2278 EXPECT_ACTION_UPDATE_STATE(
2253 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); 2279 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
2254 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2280 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2255 2281
2256 // No impl-side invalidations should be performed during frame sink creation. 2282 // No impl-side invalidations should be performed during frame sink creation.
2257 state.SetNeedsImplSideInvalidation(); 2283 state.SetNeedsImplSideInvalidation();
2258 state.IssueNextBeginImplFrame(); 2284 state.IssueNextBeginImplFrame();
2259 state.OnBeginImplFrameDeadline(); 2285 state.OnBeginImplFrameDeadline();
2286 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2260 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2287 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2261 2288
2262 // Initializing the CompositorFrameSink puts us in a state waiting for the 2289 // Initializing the CompositorFrameSink puts us in a state waiting for the
2263 // first commit. 2290 // first commit.
2264 state.DidCreateAndInitializeCompositorFrameSink(); 2291 state.DidCreateAndInitializeCompositorFrameSink();
2265 state.IssueNextBeginImplFrame(); 2292 state.IssueNextBeginImplFrame();
2266 EXPECT_ACTION_UPDATE_STATE( 2293 EXPECT_ACTION_UPDATE_STATE(
2267 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2294 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2268 state.NotifyBeginMainFrameStarted(); 2295 state.NotifyBeginMainFrameStarted();
2269 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); 2296 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 SchedulerSettings settings; 2371 SchedulerSettings settings;
2345 StateMachine state(settings); 2372 StateMachine state(settings);
2346 SET_UP_STATE(state); 2373 SET_UP_STATE(state);
2347 2374
2348 // Set up a request for impl-side invalidation. 2375 // Set up a request for impl-side invalidation.
2349 state.SetNeedsImplSideInvalidation(); 2376 state.SetNeedsImplSideInvalidation();
2350 state.IssueNextBeginImplFrame(); 2377 state.IssueNextBeginImplFrame();
2351 state.OnBeginImplFrameDeadline(); 2378 state.OnBeginImplFrameDeadline();
2352 EXPECT_ACTION_UPDATE_STATE( 2379 EXPECT_ACTION_UPDATE_STATE(
2353 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2380 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2381 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2354 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2382 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2355 2383
2356 // Request another invalidation, which should wait until the pending tree is 2384 // Request another invalidation, which should wait until the pending tree is
2357 // activated *and* we start the next BeginFrame. 2385 // activated *and* we start the next BeginFrame.
2358 state.SetNeedsImplSideInvalidation(); 2386 state.SetNeedsImplSideInvalidation();
2359 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2387 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2360 state.NotifyReadyToActivate(); 2388 state.NotifyReadyToActivate();
2361 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 2389 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
2362 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2390 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2363 2391
(...skipping 28 matching lines...) Expand all
2392 state.OnBeginImplFrameDeadline(); 2420 state.OnBeginImplFrameDeadline();
2393 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 2421 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
2394 state.DidSubmitCompositorFrame(); 2422 state.DidSubmitCompositorFrame();
2395 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2423 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2396 2424
2397 // Request impl-side invalidation and start a new frame, which should be 2425 // Request impl-side invalidation and start a new frame, which should be
2398 // blocked on the ack for the previous frame. 2426 // blocked on the ack for the previous frame.
2399 state.SetNeedsImplSideInvalidation(); 2427 state.SetNeedsImplSideInvalidation();
2400 state.IssueNextBeginImplFrame(); 2428 state.IssueNextBeginImplFrame();
2401 state.OnBeginImplFrameDeadline(); 2429 state.OnBeginImplFrameDeadline();
2430 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2402 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2431 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2403 2432
2404 // Ack the previous frame and begin impl frame, which should perform the 2433 // Ack the previous frame and begin impl frame, which should perform the
2405 // invalidation now. 2434 // invalidation now.
2406 state.DidReceiveCompositorFrameAck(); 2435 state.DidReceiveCompositorFrameAck();
2407 state.IssueNextBeginImplFrame(); 2436 state.IssueNextBeginImplFrame();
2408 state.OnBeginImplFrameDeadline(); 2437 state.OnBeginImplFrameDeadline();
2409 EXPECT_ACTION_UPDATE_STATE( 2438 EXPECT_ACTION_UPDATE_STATE(
2410 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2439 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2411 } 2440 }
(...skipping 28 matching lines...) Expand all
2440 2469
2441 // Request a PrepareTiles and impl-side invalidation. The impl-side 2470 // Request a PrepareTiles and impl-side invalidation. The impl-side
2442 // invalidation should run first, since it will perform PrepareTiles as well. 2471 // invalidation should run first, since it will perform PrepareTiles as well.
2443 state.SetNeedsImplSideInvalidation(); 2472 state.SetNeedsImplSideInvalidation();
2444 state.SetNeedsPrepareTiles(); 2473 state.SetNeedsPrepareTiles();
2445 state.IssueNextBeginImplFrame(); 2474 state.IssueNextBeginImplFrame();
2446 state.OnBeginImplFrameDeadline(); 2475 state.OnBeginImplFrameDeadline();
2447 EXPECT_ACTION_UPDATE_STATE( 2476 EXPECT_ACTION_UPDATE_STATE(
2448 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION); 2477 SchedulerStateMachine::ACTION_PERFORM_IMPL_SIDE_INVALIDATION);
2449 state.DidPrepareTiles(); 2478 state.DidPrepareTiles();
2479 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2450 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2480 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2451 } 2481 }
2452 2482
2453 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessInitialState) { 2483 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessInitialState) {
2454 SchedulerSettings default_scheduler_settings; 2484 SchedulerSettings default_scheduler_settings;
2455 StateMachine state(default_scheduler_settings); 2485 StateMachine state(default_scheduler_settings);
2456 SET_UP_STATE(state) 2486 SET_UP_STATE(state)
2457 2487
2458 // Initially, we report invalid frame numbers. 2488 // Initially, we report invalid frame numbers.
2459 EXPECT_SEQUENCE_NUMBERS( 2489 EXPECT_SEQUENCE_NUMBERS(
2460 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber, 2490 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber,
2461 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber, 2491 BeginFrameArgs::kInvalidFrameNumber, BeginFrameArgs::kInvalidFrameNumber,
2462 BeginFrameArgs::kInvalidFrameNumber); 2492 BeginFrameArgs::kInvalidFrameNumber);
2463 } 2493 }
2464 2494
2465 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithoutUpdates) { 2495 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithoutUpdates) {
2466 // Setup without any requested updates. 2496 // Setup without any requested updates.
2467 SchedulerSettings default_scheduler_settings; 2497 SchedulerSettings default_scheduler_settings;
2468 StateMachine state(default_scheduler_settings); 2498 StateMachine state(default_scheduler_settings);
2469 SET_UP_STATE(state) 2499 SET_UP_STATE(state)
2470 state.SetNeedsRedraw(false); 2500 state.SetNeedsRedraw(false);
2471 EXPECT_FALSE(state.RedrawPending()); 2501 EXPECT_FALSE(state.RedrawPending());
2472 EXPECT_FALSE(state.NeedsCommit()); 2502 EXPECT_FALSE(state.NeedsCommit());
2473 2503
2474 // OnBeginImplFrame() updates the sequence number. 2504 // OnBeginImplFrame() updates the sequence number.
2475 state.OnBeginImplFrame(0, 10); 2505 state.OnBeginImplFrame(0, 10);
2506 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2476 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2507 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2477 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2508 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber,
2478 BeginFrameArgs::kInvalidFrameNumber, 2509 BeginFrameArgs::kInvalidFrameNumber,
2479 BeginFrameArgs::kInvalidFrameNumber, 2510 BeginFrameArgs::kInvalidFrameNumber,
2480 BeginFrameArgs::kInvalidFrameNumber); 2511 BeginFrameArgs::kInvalidFrameNumber);
2481 2512
2482 // When no updates are required, OnBeginImplFrameDeadline() updates active 2513 // When no updates are required, OnBeginImplFrameDeadline() updates active
2483 // tree and compositor frame freshness. 2514 // tree and compositor frame freshness.
2484 state.OnBeginImplFrameDeadline(); 2515 state.OnBeginImplFrameDeadline();
2485 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2516 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2486 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2517 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber,
2487 BeginFrameArgs::kInvalidFrameNumber, 10u, 10u); 2518 BeginFrameArgs::kInvalidFrameNumber, 10u, 10u);
2488 state.OnBeginImplFrameIdle(); 2519 state.OnBeginImplFrameIdle();
2489 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2520 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2490 } 2521 }
2491 2522
2492 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithImplFrameUpdates) { 2523 TEST(SchedulerStateMachineTest, TestBeginFrameFreshnessWithImplFrameUpdates) {
2493 // Setup with an impl-thread draw requested. 2524 // Setup with an impl-thread draw requested.
2494 SchedulerSettings default_scheduler_settings; 2525 SchedulerSettings default_scheduler_settings;
2495 StateMachine state(default_scheduler_settings); 2526 StateMachine state(default_scheduler_settings);
2496 SET_UP_STATE(state) 2527 SET_UP_STATE(state)
2497 state.SetNeedsRedraw(true); 2528 state.SetNeedsRedraw(true);
2498 EXPECT_TRUE(state.RedrawPending()); 2529 EXPECT_TRUE(state.RedrawPending());
2499 EXPECT_FALSE(state.NeedsCommit()); 2530 EXPECT_FALSE(state.NeedsCommit());
2500 2531
2501 // OnBeginImplFrame() updates the sequence number. 2532 // OnBeginImplFrame() updates the sequence number.
2502 state.OnBeginImplFrame(0, 10); 2533 state.OnBeginImplFrame(0, 10);
2534 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2503 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2535 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2504 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2536 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber,
2505 BeginFrameArgs::kInvalidFrameNumber, 2537 BeginFrameArgs::kInvalidFrameNumber,
2506 BeginFrameArgs::kInvalidFrameNumber, 2538 BeginFrameArgs::kInvalidFrameNumber,
2507 BeginFrameArgs::kInvalidFrameNumber); 2539 BeginFrameArgs::kInvalidFrameNumber);
2508 2540
2509 // With only an impl-thread draw requested, OnBeginImplFrameDeadline() 2541 // With only an impl-thread draw requested, OnBeginImplFrameDeadline()
2510 // updates the active tree freshness. 2542 // updates the active tree freshness.
2511 state.OnBeginImplFrameDeadline(); 2543 state.OnBeginImplFrameDeadline();
2512 EXPECT_SEQUENCE_NUMBERS(10u, BeginFrameArgs::kInvalidFrameNumber, 2544 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); 2599 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2568 EXPECT_SEQUENCE_NUMBERS(11u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2600 EXPECT_SEQUENCE_NUMBERS(11u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2569 BeginFrameArgs::kInvalidFrameNumber, 2601 BeginFrameArgs::kInvalidFrameNumber,
2570 BeginFrameArgs::kInvalidFrameNumber); 2602 BeginFrameArgs::kInvalidFrameNumber);
2571 state.OnBeginImplFrameIdle(); 2603 state.OnBeginImplFrameIdle();
2572 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2604 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2573 2605
2574 // Pending tree freshness is updated when the new pending tree is committed. 2606 // Pending tree freshness is updated when the new pending tree is committed.
2575 state.NotifyReadyToCommit(); 2607 state.NotifyReadyToCommit();
2576 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 2608 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
2609 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
Sami 2017/03/24 15:24:10 Here a begin main frame seems to have recently com
Dan Elphick 2017/03/29 16:02:44 Seems like this is the same as the last one. What
Dan Elphick 2017/04/06 16:10:16 Done.
2577 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2610 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2578 EXPECT_FALSE(state.CommitPending()); 2611 EXPECT_FALSE(state.CommitPending());
2579 EXPECT_TRUE(state.has_pending_tree()); 2612 EXPECT_TRUE(state.has_pending_tree());
2580 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2613 EXPECT_SEQUENCE_NUMBERS(11u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2581 BeginFrameArgs::kInvalidFrameNumber); 2614 BeginFrameArgs::kInvalidFrameNumber);
2582 2615
2583 // If no further BeginMainFrame is needed, OnBeginFrameImplDeadline() 2616 // If no further BeginMainFrame is needed, OnBeginFrameImplDeadline()
2584 // updates the pending tree's frame number. 2617 // updates the pending tree's frame number.
2585 state.OnBeginImplFrame(0, 12); 2618 state.OnBeginImplFrame(0, 12);
2619 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2586 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2620 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2587 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2621 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2588 BeginFrameArgs::kInvalidFrameNumber); 2622 BeginFrameArgs::kInvalidFrameNumber);
2589 state.OnBeginImplFrameDeadline(); 2623 state.OnBeginImplFrameDeadline();
2590 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2624 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2591 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 12u, BeginFrameArgs::kInvalidFrameNumber, 2625 EXPECT_SEQUENCE_NUMBERS(12u, 10u, 12u, BeginFrameArgs::kInvalidFrameNumber,
2592 BeginFrameArgs::kInvalidFrameNumber); 2626 BeginFrameArgs::kInvalidFrameNumber);
2593 state.OnBeginImplFrameIdle(); 2627 state.OnBeginImplFrameIdle();
2594 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2628 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2595 2629
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 state.DidSubmitCompositorFrame(); 2671 state.DidSubmitCompositorFrame();
2638 state.DidReceiveCompositorFrameAck(); 2672 state.DidReceiveCompositorFrameAck();
2639 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2673 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2640 EXPECT_SEQUENCE_NUMBERS(14u, 14u, 12u, 14u, 14u); 2674 EXPECT_SEQUENCE_NUMBERS(14u, 14u, 12u, 14u, 14u);
2641 state.OnBeginImplFrameIdle(); 2675 state.OnBeginImplFrameIdle();
2642 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2676 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2643 2677
2644 // When no updates are required, OnBeginImplFrameDeadline() updates active 2678 // When no updates are required, OnBeginImplFrameDeadline() updates active
2645 // tree and compositor frame freshness. 2679 // tree and compositor frame freshness.
2646 state.OnBeginImplFrame(0, 15); 2680 state.OnBeginImplFrame(0, 15);
2681 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2647 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2682 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2648 state.OnBeginImplFrameDeadline(); 2683 state.OnBeginImplFrameDeadline();
2649 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2684 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2650 EXPECT_SEQUENCE_NUMBERS(15u, 14u, 12u, 15u, 15u); 2685 EXPECT_SEQUENCE_NUMBERS(15u, 14u, 12u, 15u, 15u);
2651 state.OnBeginImplFrameIdle(); 2686 state.OnBeginImplFrameIdle();
2652 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2687 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2653 2688
2654 // Active tree and compositor frame freshness are updated when commit doesn't 2689 // Active tree and compositor frame freshness are updated when commit doesn't
2655 // have updates and compositor frame was fresh before. 2690 // have updates and compositor frame was fresh before.
2656 state.SetNeedsBeginMainFrameForTest(true); 2691 state.SetNeedsBeginMainFrameForTest(true);
2657 EXPECT_TRUE(state.NeedsCommit()); 2692 EXPECT_TRUE(state.NeedsCommit());
2658 state.OnBeginImplFrame(0, 16); 2693 state.OnBeginImplFrame(0, 16);
2659 EXPECT_ACTION_UPDATE_STATE( 2694 EXPECT_ACTION_UPDATE_STATE(
2660 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2695 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2661 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2696 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2662 EXPECT_FALSE(state.NeedsCommit()); 2697 EXPECT_FALSE(state.NeedsCommit());
2663 EXPECT_TRUE(state.CommitPending()); 2698 EXPECT_TRUE(state.CommitPending());
2664 state.NotifyBeginMainFrameStarted(); 2699 state.NotifyBeginMainFrameStarted();
2665 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); 2700 state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
2666 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u); 2701 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u);
2667 state.OnBeginImplFrameDeadline(); 2702 state.OnBeginImplFrameDeadline();
2668 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2703 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2669 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u); 2704 EXPECT_SEQUENCE_NUMBERS(16u, 16u, 12u, 16u, 16u);
2670 state.OnBeginImplFrameIdle(); 2705 state.OnBeginImplFrameIdle();
2671 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2706 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2672 2707
2673 // When the source changes, the current frame number is updated and frame 2708 // When the source changes, the current frame number is updated and frame
2674 // numbers for freshness are reset to invalid numbers. 2709 // numbers for freshness are reset to invalid numbers.
2675 state.OnBeginImplFrame(1, 5); 2710 state.OnBeginImplFrame(1, 5);
2711 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DO_SHORT_IDLE_WORK);
2676 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2712 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2677 EXPECT_SEQUENCE_NUMBERS(5u, BeginFrameArgs::kInvalidFrameNumber, 2713 EXPECT_SEQUENCE_NUMBERS(5u, BeginFrameArgs::kInvalidFrameNumber,
2678 BeginFrameArgs::kInvalidFrameNumber, 2714 BeginFrameArgs::kInvalidFrameNumber,
2679 BeginFrameArgs::kInvalidFrameNumber, 2715 BeginFrameArgs::kInvalidFrameNumber,
2680 BeginFrameArgs::kInvalidFrameNumber); 2716 BeginFrameArgs::kInvalidFrameNumber);
2681 2717
2682 // When no updates are required, OnBeginImplFrameDeadline() updates active 2718 // When no updates are required, OnBeginImplFrameDeadline() updates active
2683 // tree and compositor frame freshness. 2719 // tree and compositor frame freshness.
2684 state.OnBeginImplFrameDeadline(); 2720 state.OnBeginImplFrameDeadline();
2685 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2721 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 state.OnBeginImplFrameDeadline(); 2763 state.OnBeginImplFrameDeadline();
2728 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2764 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2729 EXPECT_SEQUENCE_NUMBERS(10u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber, 2765 EXPECT_SEQUENCE_NUMBERS(10u, 10u, 10u, BeginFrameArgs::kInvalidFrameNumber,
2730 BeginFrameArgs::kInvalidFrameNumber); 2766 BeginFrameArgs::kInvalidFrameNumber);
2731 state.OnBeginImplFrameIdle(); 2767 state.OnBeginImplFrameIdle();
2732 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2768 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2733 } 2769 }
2734 2770
2735 } // namespace 2771 } // namespace
2736 } // namespace cc 2772 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698