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

Unified Diff: cc/scheduler_state_machine_unittest.cc

Issue 11362054: Use message passing for BeginFrameAndCommitState and clean up forced commit logic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
Index: cc/scheduler_state_machine_unittest.cc
diff --git a/cc/scheduler_state_machine_unittest.cc b/cc/scheduler_state_machine_unittest.cc
index a5af78c8dff62050f4f73617d617ff5e5aba2a59..779d1d5acaea4902c4c11d85465c97dbab8ff93b 100644
--- a/cc/scheduler_state_machine_unittest.cc
+++ b/cc/scheduler_state_machine_unittest.cc
@@ -28,9 +28,6 @@ public:
void setNeedsCommit(bool b) { m_needsCommit = b; }
bool needsCommit() const { return m_needsCommit; }
- void setNeedsForcedCommit(bool b) { m_needsForcedCommit = b; }
- bool needsForcedCommit() const { return m_needsForcedCommit; }
-
void setNeedsRedraw(bool b) { m_needsRedraw = b; }
bool needsRedraw() const { return m_needsRedraw; }
@@ -826,7 +823,7 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenInvisibleAndForceCommit)
state.setCanBeginFrame(true);
state.setVisible(false);
state.setNeedsCommit(true);
- state.setNeedsForcedCommit(true);
+ state.setNeedsForcedCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
}
@@ -836,7 +833,7 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenCanBeginFrameFalseAndForceComm
state.setVisible(true);
state.setCanDraw(true);
state.setNeedsCommit(true);
- state.setNeedsForcedCommit(true);
+ state.setNeedsForcedCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
}
@@ -847,7 +844,7 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress)
state.setVisible(false);
state.setCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS);
state.setNeedsCommit(true);
- state.setNeedsForcedCommit(true);
+ state.setNeedsForcedCommit();
state.beginFrameComplete();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
@@ -865,9 +862,66 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenContextLost)
state.setVisible(true);
state.setCanDraw(true);
state.setNeedsCommit(true);
- state.setNeedsForcedCommit(true);
+ state.setNeedsForcedCommit();
state.didLoseContext();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
}
+TEST(SchedulerStateMachineTest, TestImmediateBeginFrame)
+{
+ StateMachine state;
+ state.setCanBeginFrame(true);
+ state.setVisible(true);
+ state.setCanDraw(true);
+
+ // Schedule a forced frame, commit it, draw it.
+ state.setNeedsCommit(true);
+ 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.didEnterVSync();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, 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());
+}
+
+TEST(SchedulerStateMachineTest, TestImmediateBeginFrameDuringCommit)
+{
+ StateMachine state;
+ state.setCanBeginFrame(true);
+ state.setVisible(true);
+ state.setCanDraw(true);
+
+ // Start a normal commit.
+ state.setNeedsCommit(true);
+ state.updateState(state.nextAction());
+
+ // Schedule a forced frame, commit it, draw it.
+ state.setNeedsCommit(true);
+ 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.didEnterVSync();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, 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();
+}
+
+
}

Powered by Google App Engine
This is Rietveld 408576698