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

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

Issue 421183003: Revert of Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | cc/scheduler/scheduler_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/scheduler_state_machine.h" 5 #include "cc/scheduler/scheduler_state_machine.h"
6 6
7 #include "base/debug/trace_event.h"
8 #include "cc/scheduler/scheduler.h" 7 #include "cc/scheduler/scheduler.h"
9 #include "cc/test/begin_frame_args_test.h" 8 #include "cc/test/begin_frame_args_test.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 #define EXPECT_ACTION_UPDATE_STATE(action) \ 11 #define EXPECT_ACTION_UPDATE_STATE(action) \
13 EXPECT_EQ(action, state.NextAction()) << state.AsValue()->ToString(); \ 12 EXPECT_EQ(action, state.NextAction()) << *state.AsValue(); \
14 if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \ 13 if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \
15 action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \ 14 action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \
16 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, \ 15 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, \
17 state.begin_impl_frame_state()) \ 16 state.begin_impl_frame_state()) \
18 << state.AsValue()->ToString(); \ 17 << *state.AsValue(); \
19 } \ 18 } \
20 state.UpdateState(action); \ 19 state.UpdateState(action); \
21 if (action == SchedulerStateMachine::ACTION_NONE) { \ 20 if (action == SchedulerStateMachine::ACTION_NONE) { \
22 if (state.begin_impl_frame_state() == \ 21 if (state.begin_impl_frame_state() == \
23 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) \ 22 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) \
24 state.OnBeginImplFrameDeadlinePending(); \ 23 state.OnBeginImplFrameDeadlinePending(); \
25 if (state.begin_impl_frame_state() == \ 24 if (state.begin_impl_frame_state() == \
26 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \ 25 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \
27 state.OnBeginImplFrameIdle(); \ 26 state.OnBeginImplFrameIdle(); \
28 } 27 }
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 state.SetVisible(visible); 683 state.SetVisible(visible);
685 684
686 // Case 1: needs_commit=false 685 // Case 1: needs_commit=false
687 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 686 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
688 state.NextAction()); 687 state.NextAction());
689 688
690 // Case 2: needs_commit=true 689 // Case 2: needs_commit=true
691 state.SetNeedsCommit(); 690 state.SetNeedsCommit();
692 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 691 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
693 state.NextAction()) 692 state.NextAction())
694 << state.AsValue()->ToString(); 693 << *state.AsValue();
695 } 694 }
696 } 695 }
697 696
698 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw 697 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw
699 // except if we're ready to commit, in which case we expect a commit first. 698 // except if we're ready to commit, in which case we expect a commit first.
700 for (size_t i = 0; i < num_commit_states; ++i) { 699 for (size_t i = 0; i < num_commit_states; ++i) {
701 StateMachine state(default_scheduler_settings); 700 StateMachine state(default_scheduler_settings);
702 state.SetCanStart(); 701 state.SetCanStart();
703 state.UpdateState(state.NextAction()); 702 state.UpdateState(state.NextAction());
704 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 703 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
705 state.SetCanDraw(true); 704 state.SetCanDraw(true);
706 state.SetCommitState(all_commit_states[i]); 705 state.SetCommitState(all_commit_states[i]);
707 state.SetBeginImplFrameState( 706 state.SetBeginImplFrameState(
708 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 707 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
709 708
710 state.SetNeedsRedraw(true); 709 state.SetNeedsRedraw(true);
711 state.SetVisible(true); 710 state.SetVisible(true);
712 711
713 SchedulerStateMachine::Action expected_action; 712 SchedulerStateMachine::Action expected_action;
714 if (all_commit_states[i] == 713 if (all_commit_states[i] ==
715 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) { 714 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT) {
716 expected_action = SchedulerStateMachine::ACTION_COMMIT; 715 expected_action = SchedulerStateMachine::ACTION_COMMIT;
717 } else { 716 } else {
718 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE; 717 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE;
719 EXPECT_EQ(state.NextAction(), SchedulerStateMachine::ACTION_ANIMATE) 718 EXPECT_EQ(state.NextAction(), SchedulerStateMachine::ACTION_ANIMATE)
720 << state.AsValue()->ToString(); 719 << *state.AsValue();
721 state.UpdateState(state.NextAction()); 720 state.UpdateState(state.NextAction());
722 } 721 }
723 722
724 // Case 1: needs_commit=false. 723 // Case 1: needs_commit=false.
725 EXPECT_EQ(state.NextAction(), expected_action) 724 EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
726 << state.AsValue()->ToString();
727 725
728 // Case 2: needs_commit=true. 726 // Case 2: needs_commit=true.
729 state.SetNeedsCommit(); 727 state.SetNeedsCommit();
730 EXPECT_EQ(state.NextAction(), expected_action) 728 EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue();
731 << state.AsValue()->ToString();
732 } 729 }
733 } 730 }
734 731
735 TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) { 732 TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) {
736 SchedulerSettings default_scheduler_settings; 733 SchedulerSettings default_scheduler_settings;
737 734
738 size_t num_commit_states = 735 size_t num_commit_states =
739 sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState); 736 sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState);
740 for (size_t i = 0; i < num_commit_states; ++i) { 737 for (size_t i = 0; i < num_commit_states; ++i) {
741 // There shouldn't be any drawing regardless of BeginImplFrame. 738 // There shouldn't be any drawing regardless of BeginImplFrame.
(...skipping 11 matching lines...) Expand all
753 } 750 }
754 751
755 // Case 1: needs_commit=false. 752 // Case 1: needs_commit=false.
756 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 753 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
757 state.NextAction()); 754 state.NextAction());
758 755
759 // Case 2: needs_commit=true. 756 // Case 2: needs_commit=true.
760 state.SetNeedsCommit(); 757 state.SetNeedsCommit();
761 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 758 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
762 state.NextAction()) 759 state.NextAction())
763 << state.AsValue()->ToString(); 760 << *state.AsValue();
764 } 761 }
765 } 762 }
766 } 763 }
767 764
768 TEST(SchedulerStateMachineTest, TestCanRedraw_StopsDraw) { 765 TEST(SchedulerStateMachineTest, TestCanRedraw_StopsDraw) {
769 SchedulerSettings default_scheduler_settings; 766 SchedulerSettings default_scheduler_settings;
770 767
771 size_t num_commit_states = 768 size_t num_commit_states =
772 sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState); 769 sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState);
773 for (size_t i = 0; i < num_commit_states; ++i) { 770 for (size_t i = 0; i < num_commit_states; ++i) {
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 1648
1652 state.DidCreateAndInitializeOutputSurface(); 1649 state.DidCreateAndInitializeOutputSurface();
1653 EXPECT_EQ(state.output_surface_state(), 1650 EXPECT_EQ(state.output_surface_state(),
1654 SchedulerStateMachine::OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT); 1651 SchedulerStateMachine::OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT);
1655 1652
1656 // We should not send a BeginMainFrame when we are invisible, even if we've 1653 // We should not send a BeginMainFrame when we are invisible, even if we've
1657 // lost the output surface and are trying to get the first commit, since the 1654 // lost the output surface and are trying to get the first commit, since the
1658 // main thread will just abort anyway. 1655 // main thread will just abort anyway.
1659 state.SetVisible(false); 1656 state.SetVisible(false);
1660 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()) 1657 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction())
1661 << state.AsValue()->ToString(); 1658 << *state.AsValue();
1662 } 1659 }
1663 1660
1664 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { 1661 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) {
1665 SchedulerSettings default_scheduler_settings; 1662 SchedulerSettings default_scheduler_settings;
1666 StateMachine state(default_scheduler_settings); 1663 StateMachine state(default_scheduler_settings);
1667 state.SetCanStart(); 1664 state.SetCanStart();
1668 state.UpdateState(state.NextAction()); 1665 state.UpdateState(state.NextAction());
1669 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1666 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1670 1667
1671 state.SetCanDraw(true); 1668 state.SetCanDraw(true);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 state.SetNeedsAnimate(); 1899 state.SetNeedsAnimate();
1903 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1900 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1904 1901
1905 state.OnBeginImplFrameDeadline(); 1902 state.OnBeginImplFrameDeadline();
1906 EXPECT_ACTION_UPDATE_STATE( 1903 EXPECT_ACTION_UPDATE_STATE(
1907 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 1904 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1908 } 1905 }
1909 1906
1910 } // namespace 1907 } // namespace
1911 } // namespace cc 1908 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698