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

Unified Diff: cc/scheduler_state_machine_unittest.cc

Issue 11571049: cc: Make the scheduler compositeAndReadback flow not race with WAITING_FOR_FIRST_DRAW (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indents 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler_state_machine_unittest.cc
diff --git a/cc/scheduler_state_machine_unittest.cc b/cc/scheduler_state_machine_unittest.cc
index bb3c21e44579d50879e62aa5340c6ef2cdbc2765..67fc684aa93b8765b80075ad93826dbc38e45184 100644
--- a/cc/scheduler_state_machine_unittest.cc
+++ b/cc/scheduler_state_machine_unittest.cc
@@ -834,7 +834,6 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress)
state.setVisible(false);
state.setCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS);
state.setNeedsCommit();
- state.setNeedsForcedCommit();
state.beginFrameComplete();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
@@ -842,7 +841,26 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress)
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, state.commitState());
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
+}
+
+TEST(SchedulerStateMachineTest, TestBeginFrameWhenForcedCommitInProgress)
+{
+ StateMachine state;
+ state.setCanBeginFrame(true);
+ state.setVisible(false);
+ state.setCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS);
+ state.setNeedsCommit();
+ state.setNeedsForcedCommit();
+
+ state.beginFrameComplete();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
+ state.updateState(state.nextAction());
+
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, state.commitState());
+
+ // If we are waiting for forced draw then we know a begin frame is already in flight.
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
}
TEST(SchedulerStateMachineTest, TestBeginFrameWhenContextLost)
@@ -873,82 +891,124 @@ TEST(SchedulerStateMachineTest, TestImmediateBeginFrame)
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState());
state.updateState(state.nextAction());
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, state.commitState());
+
state.didEnterVSync();
- EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
+ state.setNeedsForcedRedraw(true);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
state.updateState(state.nextAction());
state.didDrawIfPossibleCompleted(true);
- state.didLeaveVSync();
+ state.didLeaveVSync();
- // Should be waiting for the normal begin frame
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState());
+ // Should be waiting for the normal begin frame
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState());
}
TEST(SchedulerStateMachineTest, TestImmediateBeginFrameDuringCommit)
{
- StateMachine state;
- state.setCanBeginFrame(true);
- state.setVisible(true);
- state.setCanDraw(true);
+ StateMachine state;
+ state.setCanBeginFrame(true);
+ state.setVisible(true);
+ state.setCanDraw(true);
- // Start a normal commit.
- state.setNeedsCommit();
- state.updateState(state.nextAction());
+ // Start a normal commit.
+ state.setNeedsCommit();
+ state.updateState(state.nextAction());
- // Schedule a forced frame, commit it, draw it.
- state.setNeedsCommit();
- state.setNeedsForcedCommit();
- state.updateState(state.nextAction());
- state.beginFrameComplete();
- EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState());
- state.updateState(state.nextAction());
+ // Schedule a forced frame, commit it, draw it.
+ state.setNeedsCommit();
+ state.setNeedsForcedCommit();
+ state.updateState(state.nextAction());
+ state.beginFrameComplete();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState());
+ state.updateState(state.nextAction());
+
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, state.commitState());
- state.didEnterVSync();
- EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction());
- state.updateState(state.nextAction());
- state.didDrawIfPossibleCompleted(true);
- state.didLeaveVSync();
+ state.didEnterVSync();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
+ state.setNeedsForcedRedraw(true);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
+ state.updateState(state.nextAction());
+ state.didDrawIfPossibleCompleted(true);
+ state.didLeaveVSync();
- // Should be waiting for the normal begin frame
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()) << state.toString();
+ // Should be waiting for the normal begin frame
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()) << state.toString();
}
TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileInvisible)
{
- StateMachine state;
- state.setCanBeginFrame(true);
- state.setVisible(true);
- state.setCanDraw(true);
+ StateMachine state;
+ state.setCanBeginFrame(true);
+ state.setVisible(true);
+ state.setCanDraw(true);
+
+ state.setNeedsCommit();
+ state.updateState(state.nextAction());
+
+ state.setNeedsCommit();
+ state.setNeedsForcedCommit();
+ state.updateState(state.nextAction());
+ state.beginFrameComplete();
+
+ EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState());
+ state.updateState(state.nextAction());
- state.setNeedsCommit();
- state.updateState(state.nextAction());
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, state.commitState());
+
+ state.didEnterVSync();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
+ state.setNeedsForcedRedraw(true);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
+ state.updateState(state.nextAction());
+ state.didDrawIfPossibleCompleted(true);
+ state.didLeaveVSync();
+
+ // Should be waiting for the normal begin frame
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()) << state.toString();
+
+
+ // Become invisible and abort the "normal" begin frame.
+ state.setVisible(false);
+ state.beginFrameAborted();
- state.setNeedsCommit();
- state.setNeedsForcedCommit();
- state.updateState(state.nextAction());
- state.beginFrameComplete();
+ // Should be back in the idle state, but needing a commit.
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState());
+ EXPECT_TRUE(state.needsCommit());
+}
- EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState());
- state.updateState(state.nextAction());
+TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileCantDraw)
+{
+ StateMachine state;
+ state.setCanBeginFrame(true);
+ state.setVisible(true);
+ state.setCanDraw(false);
- state.didEnterVSync();
- EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction());
- state.updateState(state.nextAction());
- state.didDrawIfPossibleCompleted(true);
- state.didLeaveVSync();
+ state.setNeedsCommit();
+ state.updateState(state.nextAction());
- // Should be waiting for the normal begin frame
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState()) << state.toString();
+ state.setNeedsCommit();
+ state.setNeedsForcedCommit();
+ state.updateState(state.nextAction());
+ state.beginFrameComplete();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, state.commitState());
+ state.updateState(state.nextAction());
- // Become invisible and abort the "normal" begin frame.
- state.setVisible(false);
- state.beginFrameAborted();
+ EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, state.commitState());
- // Should be back in the idle state, but needing a commit.
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState());
- EXPECT_TRUE(state.needsCommit());
+ state.didEnterVSync();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
+ state.setNeedsForcedRedraw(true);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
+ state.updateState(state.nextAction());
+ state.didDrawIfPossibleCompleted(true);
+ state.didLeaveVSync();
}
} // namespace
« no previous file with comments | « cc/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698