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

Unified Diff: cc/scheduler_state_machine_unittest.cc

Issue 11348083: Revert 168095 - Merge 167537 - Use message passing for BeginFrameAndCommitState and clean up forced… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/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
« no previous file with comments | « cc/scheduler_state_machine.cc ('k') | cc/thread_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler_state_machine_unittest.cc
===================================================================
--- cc/scheduler_state_machine_unittest.cc (revision 168100)
+++ cc/scheduler_state_machine_unittest.cc (working copy)
@@ -25,8 +25,12 @@
void setCommitState(CommitState cs) { m_commitState = cs; }
CommitState commitState() const { return m_commitState; }
+ 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; }
@@ -46,6 +50,7 @@
state.setCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE);
state.setCanBeginFrame(true);
state.setNeedsRedraw(false);
+ state.setNeedsCommit(false);
state.setVisible(true);
EXPECT_FALSE(state.vsyncCallbackNeeded());
@@ -62,6 +67,7 @@
StateMachine state;
state.setCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE);
state.setNeedsRedraw(false);
+ state.setNeedsCommit(false);
state.setVisible(true);
EXPECT_FALSE(state.vsyncCallbackNeeded());
@@ -80,6 +86,7 @@
state.setCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE);
state.setCanBeginFrame(true);
state.setNeedsRedraw(false);
+ state.setNeedsCommit(true);
state.setVisible(true);
EXPECT_FALSE(state.vsyncCallbackNeeded());
}
@@ -362,10 +369,11 @@
state.setVisible(true);
// Case 1: needsCommit=false
+ state.setNeedsCommit(false);
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction());
// Case 2: needsCommit=true
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction());
}
}
@@ -391,11 +399,12 @@
expectedAction = SchedulerStateMachine::ACTION_COMMIT;
// Case 1: needsCommit=false.
+ state.setNeedsCommit(false);
EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_EQ(expectedAction, state.nextAction());
// Case 2: needsCommit=true.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_EQ(expectedAction, state.nextAction());
}
@@ -417,10 +426,11 @@
state.didEnterVSync();
// Case 1: needsCommit=false.
+ state.setNeedsCommit(false);
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction());
// Case 2: needsCommit=true.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction());
}
}
@@ -451,7 +461,7 @@
StateMachine state;
state.setCommitState(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
state.setCanBeginFrame(true);
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
state.setNeedsRedraw(true);
state.setVisible(true);
state.setCanDraw(false);
@@ -462,7 +472,7 @@
{
StateMachine state;
state.setCanBeginFrame(true);
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
state.setVisible(true);
state.setCanDraw(true);
@@ -472,7 +482,7 @@
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState());
// Now, while the frame is in progress, set another commit.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_TRUE(state.needsCommit());
// Let the frame finish.
@@ -505,7 +515,7 @@
state.setCanDraw(true);
// Start clean and set commit.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
// Begin the frame.
@@ -548,7 +558,7 @@
state.setCanDraw(true);
// Start clean and set commit.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
// Begin the frame.
@@ -558,7 +568,7 @@
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
// Request another commit while the commit is in flight.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
// Tell the scheduler the frame finished.
@@ -590,7 +600,7 @@
TEST(SchedulerStateMachineTest, TestRequestCommitInvisible)
{
StateMachine state;
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
}
@@ -602,7 +612,7 @@
state.setCanDraw(true);
// Start clean and set commit.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
// Begin the frame while visible.
@@ -672,7 +682,7 @@
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
// While context is recreating, commits shouldn't begin.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
// Recreate the context
@@ -701,7 +711,7 @@
state.setCanDraw(true);
// Get a commit in flight.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
state.updateState(state.nextAction());
@@ -744,7 +754,7 @@
state.setCanDraw(true);
// Get a commit in flight.
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
state.updateState(state.nextAction());
@@ -760,7 +770,7 @@
// Ask for another draw and also set needs commit. Expect nothing happens.
state.setNeedsRedraw(true);
- state.setNeedsCommit();
+ state.setNeedsCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction());
// Finish the frame, and commit.
@@ -815,8 +825,8 @@
StateMachine state;
state.setCanBeginFrame(true);
state.setVisible(false);
- state.setNeedsCommit();
- state.setNeedsForcedCommit();
+ state.setNeedsCommit(true);
+ state.setNeedsForcedCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
}
@@ -825,8 +835,8 @@
StateMachine state;
state.setVisible(true);
state.setCanDraw(true);
- state.setNeedsCommit();
- state.setNeedsForcedCommit();
+ state.setNeedsCommit(true);
+ state.setNeedsForcedCommit(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
}
@@ -836,8 +846,8 @@
state.setCanBeginFrame(true);
state.setVisible(false);
state.setCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS);
- state.setNeedsCommit();
- state.setNeedsForcedCommit();
+ state.setNeedsCommit(true);
+ state.setNeedsForcedCommit(true);
state.beginFrameComplete();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.nextAction());
@@ -854,104 +864,10 @@
state.setCanBeginFrame(true);
state.setVisible(true);
state.setCanDraw(true);
- state.setNeedsCommit();
- state.setNeedsForcedCommit();
+ state.setNeedsCommit(true);
+ state.setNeedsForcedCommit(true);
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();
- 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();
- 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());
-
- 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();
-}
-
-TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileInvisible)
-{
- 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.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();
-
-
- // Become invisible and abort the "normal" begin frame.
- state.setVisible(false);
- state.beginFrameAborted();
-
- // Should be back in the idle state, but needing a commit.
- EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState());
- EXPECT_TRUE(state.needsCommit());
-}
-
-} // namespace
« no previous file with comments | « cc/scheduler_state_machine.cc ('k') | cc/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698