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

Unified Diff: cc/scheduler/scheduler_state_machine_unittest.cc

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Tweaks; Address more comments; Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler_state_machine_unittest.cc
diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc
index 51f167a567f603ffaeb0a91dee1f1fe26b88b913..c9ea831af7552d7c8c0fba8ffb69b37068a2fc5d 100644
--- a/cc/scheduler/scheduler_state_machine_unittest.cc
+++ b/cc/scheduler/scheduler_state_machine_unittest.cc
@@ -53,10 +53,10 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) {
EXPECT_FALSE(state.BeginFrameNeededToDrawByImplThread());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
EXPECT_FALSE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
@@ -69,10 +69,10 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) {
EXPECT_FALSE(state.BeginFrameNeededToDrawByImplThread());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
EXPECT_FALSE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
@@ -123,7 +123,7 @@ TEST(SchedulerStateMachineTest,
state.SetNeedsRedraw();
EXPECT_TRUE(state.RedrawPending());
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
// We're drawing now.
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
@@ -155,7 +155,7 @@ TEST(SchedulerStateMachineTest,
state.SetNeedsRedraw();
EXPECT_TRUE(state.RedrawPending());
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
// We're drawing now.
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
@@ -197,7 +197,7 @@ TEST(SchedulerStateMachineTest,
// Then initiate a draw.
state.SetNeedsRedraw();
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -240,7 +240,7 @@ TEST(SchedulerStateMachineTest,
// Then initiate a draw.
state.SetNeedsRedraw();
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -295,7 +295,7 @@ TEST(SchedulerStateMachineTest,
// Then initiate a draw.
state.SetNeedsRedraw();
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -331,7 +331,7 @@ TEST(SchedulerStateMachineTest,
// Start a draw.
state.SetNeedsRedraw();
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -345,9 +345,9 @@ TEST(SchedulerStateMachineTest,
EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
state.NextAction());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
// We should try to draw again in the next begin frame on the impl thread.
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
@@ -363,7 +363,7 @@ TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) {
state.SetCanDraw(true);
state.SetNeedsRedraw();
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
@@ -374,9 +374,9 @@ TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) {
// Move to another frame. This should now draw.
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_TRUE(state.BeginFrameNeededToDrawByImplThread());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
@@ -400,7 +400,7 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginFrame) {
state.SetCommitState(all_commit_states[i]);
bool visible = j;
if (!visible) {
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
state.SetVisible(false);
} else {
state.SetVisible(true);
@@ -430,7 +430,7 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginFrame) {
state.SetCommitState(all_commit_states[i]);
bool forced_draw = j;
if (!forced_draw) {
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
state.SetNeedsRedraw(true);
state.SetVisible(true);
} else {
@@ -476,7 +476,7 @@ TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) {
state.SetNeedsRedraw(true);
state.SetNeedsForcedRedraw(false);
if (j == 1)
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
// Case 1: needs_commit=false.
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE,
@@ -507,7 +507,7 @@ TEST(SchedulerStateMachineTest, TestCanRedraw_StopsDraw) {
state.SetNeedsRedraw(true);
state.SetNeedsForcedRedraw(false);
if (j == 1)
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
state.SetCanDraw(false);
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE,
@@ -560,9 +560,9 @@ TEST(SchedulerStateMachineTest, TestsetNeedsCommitIsNotLost) {
state.CommitState());
// Expect to commit regardless of BeginFrame state.
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
// Commit and make sure we draw on next BeginFrame
@@ -574,7 +574,7 @@ TEST(SchedulerStateMachineTest, TestsetNeedsCommitIsNotLost) {
state.DidDrawIfPossibleCompleted(true);
// Verify that another commit will begin.
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
state.NextAction());
}
@@ -617,11 +617,11 @@ TEST(SchedulerStateMachineTest, TestFullCycle) {
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// At BeginFrame, draw.
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Should be synchronized, no draw needed, no action needed.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
@@ -671,11 +671,11 @@ TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) {
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// At BeginFrame, draw.
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Should be synchronized, no draw needed, no action needed.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
@@ -825,12 +825,12 @@ TEST(SchedulerStateMachineTest,
// Once the context is recreated, whether we draw should be based on
// SetCanDraw.
state.SetNeedsRedraw(true);
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.SetCanDraw(false);
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
state.SetCanDraw(true);
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
}
TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) {
@@ -850,10 +850,10 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) {
// Set damage and expect a draw.
state.SetNeedsRedraw(true);
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(state.NextAction());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Cause a lost context while the begin frame is in flight
// for the main thread.
@@ -876,10 +876,10 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) {
// Expect to be told to begin context recreation, independent of
// BeginFrame state.
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
}
@@ -902,10 +902,10 @@ TEST(SchedulerStateMachineTest,
// Set damage and expect a draw.
state.SetNeedsRedraw(true);
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(state.NextAction());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Cause a lost context while the begin frame is in flight
// for the main thread.
@@ -929,10 +929,10 @@ TEST(SchedulerStateMachineTest,
// Expect to be told to begin context recreation, independent of
// BeginFrame state
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
}
@@ -951,9 +951,9 @@ TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) {
// Ask a forced redraw and verify it ocurrs.
state.SetNeedsForcedRedraw(true);
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Clear the forced redraw bit.
state.SetNeedsForcedRedraw(false);
@@ -966,9 +966,9 @@ TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) {
// Ask a forced redraw and verify it ocurrs.
state.SetNeedsForcedRedraw(true);
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
- state.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
}
TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) {
@@ -1100,13 +1100,13 @@ TEST(SchedulerStateMachineTest, TestImmediateFinishCommit) {
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
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.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Should be waiting for the normal begin frame from the main thread.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
@@ -1139,13 +1139,13 @@ TEST(SchedulerStateMachineTest, TestImmediateFinishCommitDuringCommit) {
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
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.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Should be waiting for the normal begin frame from the main thread.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
@@ -1178,13 +1178,13 @@ TEST(SchedulerStateMachineTest,
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
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.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
// Should be waiting for the main thread's begin frame.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
@@ -1224,13 +1224,13 @@ TEST(SchedulerStateMachineTest, ImmediateFinishCommitWhileCantDraw) {
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting());
+ state.OnBeginFrame(BeginFrameArgs::CreateForTesting());
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.DidLeaveBeginFrame();
+ state.OnBeginFrameDeadline();
}
TEST(SchedulerStateMachineTest, ReportIfNotDrawing) {

Powered by Google App Engine
This is Rietveld 408576698