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

Side by Side Diff: cc/scheduler_state_machine_unittest.cc

Issue 11439026: Revert 171403 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/scheduler_state_machine.cc ('k') | cc/scoped_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_state_machine.h" 5 #include "cc/scheduler_state_machine.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace cc { 9 namespace cc {
10 namespace { 10 namespace {
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commi tState()); 630 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commi tState());
631 } 631 }
632 632
633 TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) 633 TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle)
634 { 634 {
635 StateMachine state; 635 StateMachine state;
636 state.setCanBeginFrame(true); 636 state.setCanBeginFrame(true);
637 state.setVisible(true); 637 state.setVisible(true);
638 state.setCanDraw(true); 638 state.setCanDraw(true);
639 639
640 state.didLoseOutputSurface(); 640 state.didLoseContext();
641 641
642 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, sta te.nextAction()); 642 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.next Action());
643 state.updateState(state.nextAction()); 643 state.updateState(state.nextAction());
644 644
645 // Once context recreation begins, nothing should happen. 645 // Once context recreation begins, nothing should happen.
646 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); 646 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
647 647
648 // Recreate the context 648 // Recreate the context
649 state.didRecreateOutputSurface(); 649 state.didRecreateContext();
650 650
651 // When the context is recreated, we should begin a commit 651 // When the context is recreated, we should begin a commit
652 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 652 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
653 state.updateState(state.nextAction()); 653 state.updateState(state.nextAction());
654 } 654 }
655 655
656 TEST(SchedulerStateMachineTest, TestContextLostWhenIdleAndCommitRequestedWhileRe creating) 656 TEST(SchedulerStateMachineTest, TestContextLostWhenIdleAndCommitRequestedWhileRe creating)
657 { 657 {
658 StateMachine state; 658 StateMachine state;
659 state.setCanBeginFrame(true); 659 state.setCanBeginFrame(true);
660 state.setVisible(true); 660 state.setVisible(true);
661 state.setCanDraw(true); 661 state.setCanDraw(true);
662 662
663 state.didLoseOutputSurface(); 663 state.didLoseContext();
664 664
665 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, sta te.nextAction()); 665 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.next Action());
666 state.updateState(state.nextAction()); 666 state.updateState(state.nextAction());
667 667
668 // Once context recreation begins, nothing should happen. 668 // Once context recreation begins, nothing should happen.
669 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); 669 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
670 670
671 // While context is recreating, commits shouldn't begin. 671 // While context is recreating, commits shouldn't begin.
672 state.setNeedsCommit(); 672 state.setNeedsCommit();
673 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); 673 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
674 674
675 // Recreate the context 675 // Recreate the context
676 state.didRecreateOutputSurface(); 676 state.didRecreateContext();
677 677
678 // When the context is recreated, we should begin a commit 678 // When the context is recreated, we should begin a commit
679 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 679 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
680 state.updateState(state.nextAction()); 680 state.updateState(state.nextAction());
681 681
682 // Once the context is recreated, whether we draw should be based on 682 // Once the context is recreated, whether we draw should be based on
683 // setCanDraw. 683 // setCanDraw.
684 state.setNeedsRedraw(true); 684 state.setNeedsRedraw(true);
685 state.didEnterVSync(); 685 state.didEnterVSync();
686 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() ); 686 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() );
(...skipping 16 matching lines...) Expand all
703 state.updateState(state.nextAction()); 703 state.updateState(state.nextAction());
704 704
705 // Set damage and expect a draw. 705 // Set damage and expect a draw.
706 state.setNeedsRedraw(true); 706 state.setNeedsRedraw(true);
707 state.didEnterVSync(); 707 state.didEnterVSync();
708 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() ); 708 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() );
709 state.updateState(state.nextAction()); 709 state.updateState(state.nextAction());
710 state.didLeaveVSync(); 710 state.didLeaveVSync();
711 711
712 // Cause a lost context while the begin frame is in flight. 712 // Cause a lost context while the begin frame is in flight.
713 state.didLoseOutputSurface(); 713 state.didLoseContext();
714 714
715 // Ask for another draw. Expect nothing happens. 715 // Ask for another draw. Expect nothing happens.
716 state.setNeedsRedraw(true); 716 state.setNeedsRedraw(true);
717 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); 717 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
718 718
719 // Finish the frame, and commit. 719 // Finish the frame, and commit.
720 state.beginFrameComplete(); 720 state.beginFrameComplete();
721 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction()); 721 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
722 state.updateState(state.nextAction()); 722 state.updateState(state.nextAction());
723 723
724 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, state. commitState()); 724 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, state. commitState());
725 725
726 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() ); 726 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() );
727 state.updateState(state.nextAction()); 727 state.updateState(state.nextAction());
728 728
729 // Expect to be told to begin context recreation, independent of vsync state 729 // Expect to be told to begin context recreation, independent of vsync state
730 state.didEnterVSync(); 730 state.didEnterVSync();
731 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, sta te.nextAction()); 731 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.next Action());
732 state.didLeaveVSync(); 732 state.didLeaveVSync();
733 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, sta te.nextAction()); 733 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.next Action());
734 } 734 }
735 735
736 TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnotherCo mmitRequested) 736 TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnotherCo mmitRequested)
737 { 737 {
738 StateMachine state; 738 StateMachine state;
739 state.setCanBeginFrame(true); 739 state.setCanBeginFrame(true);
740 state.setVisible(true); 740 state.setVisible(true);
741 state.setCanDraw(true); 741 state.setCanDraw(true);
742 742
743 // Get a commit in flight. 743 // Get a commit in flight.
744 state.setNeedsCommit(); 744 state.setNeedsCommit();
745 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 745 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
746 state.updateState(state.nextAction()); 746 state.updateState(state.nextAction());
747 747
748 // Set damage and expect a draw. 748 // Set damage and expect a draw.
749 state.setNeedsRedraw(true); 749 state.setNeedsRedraw(true);
750 state.didEnterVSync(); 750 state.didEnterVSync();
751 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() ); 751 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() );
752 state.updateState(state.nextAction()); 752 state.updateState(state.nextAction());
753 state.didLeaveVSync(); 753 state.didLeaveVSync();
754 754
755 // Cause a lost context while the begin frame is in flight. 755 // Cause a lost context while the begin frame is in flight.
756 state.didLoseOutputSurface(); 756 state.didLoseContext();
757 757
758 // Ask for another draw and also set needs commit. Expect nothing happens. 758 // Ask for another draw and also set needs commit. Expect nothing happens.
759 state.setNeedsRedraw(true); 759 state.setNeedsRedraw(true);
760 state.setNeedsCommit(); 760 state.setNeedsCommit();
761 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); 761 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
762 762
763 // Finish the frame, and commit. 763 // Finish the frame, and commit.
764 state.beginFrameComplete(); 764 state.beginFrameComplete();
765 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction()); 765 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
766 state.updateState(state.nextAction()); 766 state.updateState(state.nextAction());
767 767
768 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, state. commitState()); 768 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, state. commitState());
769 769
770 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() ); 770 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction() );
771 state.updateState(state.nextAction()); 771 state.updateState(state.nextAction());
772 772
773 // Expect to be told to begin context recreation, independent of vsync state 773 // Expect to be told to begin context recreation, independent of vsync state
774 state.didEnterVSync(); 774 state.didEnterVSync();
775 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, sta te.nextAction()); 775 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.next Action());
776 state.didLeaveVSync(); 776 state.didLeaveVSync();
777 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, sta te.nextAction()); 777 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.next Action());
778 } 778 }
779 779
780 780
781 TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) 781 TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost)
782 { 782 {
783 StateMachine state; 783 StateMachine state;
784 state.setVisible(true); 784 state.setVisible(true);
785 state.setCanDraw(true); 785 state.setCanDraw(true);
786 786
787 // Cause a lost context lost. 787 // Cause a lost context lost.
788 state.didLoseOutputSurface(); 788 state.didLoseContext();
789 789
790 // Ask a forced redraw and verify it ocurrs. 790 // Ask a forced redraw and verify it ocurrs.
791 state.setNeedsForcedRedraw(true); 791 state.setNeedsForcedRedraw(true);
792 state.didEnterVSync(); 792 state.didEnterVSync();
793 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction()); 793 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
794 state.didLeaveVSync(); 794 state.didLeaveVSync();
795 795
796 // Clear the forced redraw bit. 796 // Clear the forced redraw bit.
797 state.setNeedsForcedRedraw(false); 797 state.setNeedsForcedRedraw(false);
798 798
799 // Expect to be told to begin context recreation, independent of vsync state 799 // Expect to be told to begin context recreation, independent of vsync state
800 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION, sta te.nextAction()); 800 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.next Action());
801 state.updateState(state.nextAction()); 801 state.updateState(state.nextAction());
802 802
803 // Ask a forced redraw and verify it ocurrs. 803 // Ask a forced redraw and verify it ocurrs.
804 state.setNeedsForcedRedraw(true); 804 state.setNeedsForcedRedraw(true);
805 state.didEnterVSync(); 805 state.didEnterVSync();
806 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction()); 806 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
807 state.didLeaveVSync(); 807 state.didLeaveVSync();
808 } 808 }
809 809
810 TEST(SchedulerStateMachineTest, TestBeginFrameWhenInvisibleAndForceCommit) 810 TEST(SchedulerStateMachineTest, TestBeginFrameWhenInvisibleAndForceCommit)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 846 }
847 847
848 TEST(SchedulerStateMachineTest, TestBeginFrameWhenContextLost) 848 TEST(SchedulerStateMachineTest, TestBeginFrameWhenContextLost)
849 { 849 {
850 StateMachine state; 850 StateMachine state;
851 state.setCanBeginFrame(true); 851 state.setCanBeginFrame(true);
852 state.setVisible(true); 852 state.setVisible(true);
853 state.setCanDraw(true); 853 state.setCanDraw(true);
854 state.setNeedsCommit(); 854 state.setNeedsCommit();
855 state.setNeedsForcedCommit(); 855 state.setNeedsForcedCommit();
856 state.didLoseOutputSurface(); 856 state.didLoseContext();
857 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 857 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
858 } 858 }
859 859
860 TEST(SchedulerStateMachineTest, TestImmediateBeginFrame) 860 TEST(SchedulerStateMachineTest, TestImmediateBeginFrame)
861 { 861 {
862 StateMachine state; 862 StateMachine state;
863 state.setCanBeginFrame(true); 863 state.setCanBeginFrame(true);
864 state.setVisible(true); 864 state.setVisible(true);
865 state.setCanDraw(true); 865 state.setCanDraw(true);
866 866
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 state.setVisible(false); 946 state.setVisible(false);
947 state.beginFrameAborted(); 947 state.beginFrameAborted();
948 948
949 // Should be back in the idle state, but needing a commit. 949 // Should be back in the idle state, but needing a commit.
950 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState()); 950 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState());
951 EXPECT_TRUE(state.needsCommit()); 951 EXPECT_TRUE(state.needsCommit());
952 } 952 }
953 953
954 } // namespace 954 } // namespace
955 } // namespace cc 955 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler_state_machine.cc ('k') | cc/scoped_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698