| 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 5f413b33a7e7f6d683ca637dd7246965d92f9942..5a6027683539049090159f49ed76f401df814f06 100644
|
| --- a/cc/scheduler/scheduler_state_machine_unittest.cc
|
| +++ b/cc/scheduler/scheduler_state_machine_unittest.cc
|
| @@ -1079,7 +1079,9 @@ TEST(SchedulerStateMachineTest, TestRequestCommitInvisible) {
|
| EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
|
| }
|
|
|
| -TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeFinishCommit) {
|
| +// See ThreadProxy::BeginMainFrame "EarlyOut_NotVisible" /
|
| +// "EarlyOut_OutputSurfaceLost" cases.
|
| +TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseInvisible) {
|
| SchedulerSettings default_scheduler_settings;
|
| StateMachine state(default_scheduler_settings);
|
| state.SetCanStart();
|
| @@ -1102,7 +1104,11 @@ TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeFinishCommit) {
|
|
|
| // Become invisible and abort BeginMainFrame.
|
| state.SetVisible(false);
|
| - state.BeginMainFrameAborted(false);
|
| + state.BeginMainFrameAborted(CommitEarlyOutReason::ABORTED_NOT_VISIBLE);
|
| +
|
| + // NeedsCommit should now be true again because we never actually did a
|
| + // commit.
|
| + EXPECT_TRUE(state.NeedsCommit());
|
|
|
| // We should now be back in the idle state as if we never started the frame.
|
| EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| @@ -1132,7 +1138,8 @@ TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeFinishCommit) {
|
| EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
|
| }
|
|
|
| -TEST(SchedulerStateMachineTest, AbortBeginMainFrameAndCancelCommit) {
|
| +// See ThreadProxy::BeginMainFrame "EarlyOut_NoUpdates" case.
|
| +TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseCommitNotNeeded) {
|
| SchedulerSettings default_scheduler_settings;
|
| StateMachine state(default_scheduler_settings);
|
| state.SetCanStart();
|
| @@ -1151,72 +1158,20 @@ TEST(SchedulerStateMachineTest, AbortBeginMainFrameAndCancelCommit) {
|
| EXPECT_FALSE(state.NeedsCommit());
|
| EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
|
|
| - // Abort the commit, cancelling future commits.
|
| - state.BeginMainFrameAborted(true);
|
| -
|
| - // Verify that another commit doesn't start on the same frame.
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| - EXPECT_FALSE(state.NeedsCommit());
|
| -
|
| - // Start a new frame; draw because this is the first frame since output
|
| - // surface init'd.
|
| - state.OnBeginImplFrame(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
|
| - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
|
| - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
|
| - state.OnBeginImplFrameDeadline();
|
| - EXPECT_ACTION_UPDATE_STATE(
|
| - SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
|
| - state.DidSwapBuffers();
|
| - state.DidSwapBuffersComplete();
|
| + // Abort the commit, true means that the BeginMainFrame was sent but there
|
| + // was no work to do on the main thread.
|
| + state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
|
|
|
| - // Verify another commit doesn't start on another frame either.
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| + // NeedsCommit should now be false because the commit was actually handled.
|
| EXPECT_FALSE(state.NeedsCommit());
|
| -
|
| - // Verify another commit can start if requested, though.
|
| - state.SetNeedsCommit();
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
|
| -}
|
| -
|
| -TEST(SchedulerStateMachineTest,
|
| - AbortBeginMainFrameAndCancelCommitWhenInvisible) {
|
| - SchedulerSettings default_scheduler_settings;
|
| - StateMachine state(default_scheduler_settings);
|
| - state.SetCanStart();
|
| - state.UpdateState(state.NextAction());
|
| - state.DidCreateAndInitializeOutputSurface();
|
| - state.SetVisible(true);
|
| - state.SetCanDraw(true);
|
| -
|
| - // Get into a begin frame / commit state.
|
| - state.SetNeedsCommit();
|
| -
|
| - EXPECT_ACTION_UPDATE_STATE(
|
| - SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
|
| - EXPECT_COMMIT_STATE(
|
| - SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
|
| - EXPECT_FALSE(state.NeedsCommit());
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| -
|
| - // Become invisible and abort BeginMainFrame.
|
| - state.SetVisible(false);
|
| - state.BeginMainFrameAborted(true);
|
| -
|
| // Verify that another commit doesn't start on the same frame.
|
| EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| - EXPECT_FALSE(state.NeedsCommit());
|
|
|
| - // Become visible and start a new frame.
|
| - state.SetVisible(true);
|
| + // Even though the commit was aborted, we still expect to draw the new frame.
|
| state.OnBeginImplFrame(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
|
| EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
|
| EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
|
| -
|
| - // Draw because this is the first frame since output surface init'd.
|
| state.OnBeginImplFrameDeadline();
|
| EXPECT_ACTION_UPDATE_STATE(
|
| SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
|
| @@ -1234,98 +1189,6 @@ TEST(SchedulerStateMachineTest,
|
| EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
|
| }
|
|
|
| -TEST(SchedulerStateMachineTest,
|
| - AbortBeginMainFrameAndRequestCommitWhenInvisible) {
|
| - SchedulerSettings default_scheduler_settings;
|
| - StateMachine state(default_scheduler_settings);
|
| - state.SetCanStart();
|
| - state.UpdateState(state.NextAction());
|
| - state.DidCreateAndInitializeOutputSurface();
|
| - state.SetVisible(true);
|
| - state.SetCanDraw(true);
|
| -
|
| - // Get into a begin frame / commit state.
|
| - state.SetNeedsCommit();
|
| -
|
| - EXPECT_ACTION_UPDATE_STATE(
|
| - SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
|
| - EXPECT_COMMIT_STATE(
|
| - SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
|
| - EXPECT_FALSE(state.NeedsCommit());
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| -
|
| - // Become invisible and abort BeginMainFrame.
|
| - state.SetVisible(false);
|
| - state.BeginMainFrameAborted(true);
|
| -
|
| - // Verify that another commit doesn't start on the same frame.
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| - EXPECT_FALSE(state.NeedsCommit());
|
| -
|
| - // Asking for a commit while not visible won't make it happen.
|
| - state.SetNeedsCommit();
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| - EXPECT_TRUE(state.NeedsCommit());
|
| -
|
| - // Become visible but nothing happens until the next frame.
|
| - state.SetVisible(true);
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| - EXPECT_TRUE(state.NeedsCommit());
|
| -
|
| - // We should get that commit when we begin the next frame.
|
| - state.OnBeginImplFrame(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
|
| - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
|
| - EXPECT_ACTION_UPDATE_STATE(
|
| - SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
|
| -}
|
| -
|
| -TEST(SchedulerStateMachineTest,
|
| - AbortBeginMainFrameAndRequestCommitAndBeginImplFrameWhenInvisible) {
|
| - SchedulerSettings default_scheduler_settings;
|
| - StateMachine state(default_scheduler_settings);
|
| - state.SetCanStart();
|
| - state.UpdateState(state.NextAction());
|
| - state.DidCreateAndInitializeOutputSurface();
|
| - state.SetVisible(true);
|
| - state.SetCanDraw(true);
|
| -
|
| - // Get into a begin frame / commit state.
|
| - state.SetNeedsCommit();
|
| -
|
| - EXPECT_ACTION_UPDATE_STATE(
|
| - SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
|
| - EXPECT_COMMIT_STATE(
|
| - SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
|
| - EXPECT_FALSE(state.NeedsCommit());
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| -
|
| - // Become invisible and abort BeginMainFrame.
|
| - state.SetVisible(false);
|
| - state.BeginMainFrameAborted(true);
|
| -
|
| - // Asking for a commit while not visible won't make it happen.
|
| - state.SetNeedsCommit();
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| - EXPECT_TRUE(state.NeedsCommit());
|
| -
|
| - // Begin a frame when not visible, the scheduler animates but does not commit.
|
| - state.OnBeginImplFrame(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
|
| - EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
|
| - EXPECT_TRUE(state.NeedsCommit());
|
| -
|
| - // Become visible and the requested commit happens immediately.
|
| - state.SetVisible(true);
|
| - EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE);
|
| - EXPECT_ACTION_UPDATE_STATE(
|
| - SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
|
| -}
|
| -
|
| TEST(SchedulerStateMachineTest, TestFirstContextCreation) {
|
| SchedulerSettings default_scheduler_settings;
|
| StateMachine state(default_scheduler_settings);
|
| @@ -1757,7 +1620,7 @@ TEST(SchedulerStateMachineTest,
|
|
|
| // Since only the scroll offset changed, the main thread will abort the
|
| // commit.
|
| - state.BeginMainFrameAborted(true);
|
| + state.BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES);
|
|
|
| // Since the commit was aborted, we should draw right away instead of waiting
|
| // for the deadline.
|
|
|