Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/scheduler/scheduler_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
| 6 | 6 |
| 7 #include "cc/scheduler/scheduler.h" | 7 #include "cc/scheduler/scheduler.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 // Begin the frame while visible. | 711 // Begin the frame while visible. |
| 712 state.UpdateState( | 712 state.UpdateState( |
| 713 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); | 713 SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD); |
| 714 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 714 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| 715 state.CommitState()); | 715 state.CommitState()); |
| 716 EXPECT_FALSE(state.NeedsCommit()); | 716 EXPECT_FALSE(state.NeedsCommit()); |
| 717 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 717 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
| 718 | 718 |
| 719 // Become invisible and abort the main thread's begin frame. | 719 // Become invisible and abort the main thread's begin frame. |
| 720 state.SetVisible(false); | 720 state.SetVisible(false); |
| 721 state.BeginFrameAbortedByMainThread(); | 721 state.BeginFrameAbortedByMainThread(false); |
| 722 | 722 |
| 723 // We should now be back in the idle state as if we didn't start a frame at | 723 // We should now be back in the idle state as if we didn't start a frame at |
| 724 // all. | 724 // all. |
| 725 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 725 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
| 726 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | 726 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); |
| 727 | 727 |
| 728 // Become visible again. | 728 // Become visible again. |
| 729 state.SetVisible(true); | 729 state.SetVisible(true); |
| 730 | 730 |
| 731 // Because we have aborted on this frame, don't start another frame yet. | |
| 732 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | |
| 733 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | |
| 734 | |
| 735 // Start a new frame. | |
| 736 state.DidEnterBeginFrame(BeginFrameArgs::CreateForTesting()); | |
| 737 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()); | |
| 738 state.DidLeaveBeginFrame(); | |
| 739 | |
| 731 // We should be beginning a frame now. | 740 // We should be beginning a frame now. |
| 732 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 741 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
| 733 EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, | 742 EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, |
| 734 state.NextAction()); | 743 state.NextAction()); |
| 735 | 744 |
| 736 // Begin the frame. | 745 // Begin the frame. |
| 737 state.UpdateState(state.NextAction()); | 746 state.UpdateState(state.NextAction()); |
| 738 | 747 |
| 739 // We should be starting the commit now. | 748 // We should be starting the commit now. |
| 740 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 749 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1185 state.UpdateState(state.NextAction()); | 1194 state.UpdateState(state.NextAction()); |
| 1186 state.DidDrawIfPossibleCompleted(true); | 1195 state.DidDrawIfPossibleCompleted(true); |
| 1187 state.DidLeaveBeginFrame(); | 1196 state.DidLeaveBeginFrame(); |
| 1188 | 1197 |
| 1189 // Should be waiting for the main thread's begin frame. | 1198 // Should be waiting for the main thread's begin frame. |
| 1190 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1199 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
| 1191 state.CommitState()) << state.ToString(); | 1200 state.CommitState()) << state.ToString(); |
| 1192 | 1201 |
| 1193 // Become invisible and abort the main thread's begin frame. | 1202 // Become invisible and abort the main thread's begin frame. |
| 1194 state.SetVisible(false); | 1203 state.SetVisible(false); |
| 1195 state.BeginFrameAbortedByMainThread(); | 1204 state.BeginFrameAbortedByMainThread(false); |
|
brianderson
2013/07/13 01:26:42
Should we add a test for BeginFrameAbortedByMainTh
enne (OOO)
2013/07/15 22:23:28
Oh, quite right, done.
| |
| 1196 | 1205 |
| 1197 // Should be back in the idle state, but needing a commit. | 1206 // Should be back in the idle state, but needing a commit. |
| 1198 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 1207 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
| 1199 EXPECT_TRUE(state.NeedsCommit()); | 1208 EXPECT_TRUE(state.NeedsCommit()); |
| 1200 } | 1209 } |
| 1201 | 1210 |
| 1202 TEST(SchedulerStateMachineTest, ImmediateFinishCommitWhileCantDraw) { | 1211 TEST(SchedulerStateMachineTest, ImmediateFinishCommitWhileCantDraw) { |
| 1203 SchedulerSettings default_scheduler_settings; | 1212 SchedulerSettings default_scheduler_settings; |
| 1204 StateMachine state(default_scheduler_settings); | 1213 StateMachine state(default_scheduler_settings); |
| 1205 state.SetCanStart(); | 1214 state.SetCanStart(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1290 EXPECT_TRUE(state.DrawSuspendedUntilCommit()); | 1299 EXPECT_TRUE(state.DrawSuspendedUntilCommit()); |
| 1291 | 1300 |
| 1292 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); | 1301 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); |
| 1293 | 1302 |
| 1294 state.UpdateState(state.NextAction()); | 1303 state.UpdateState(state.NextAction()); |
| 1295 EXPECT_FALSE(state.DrawSuspendedUntilCommit()); | 1304 EXPECT_FALSE(state.DrawSuspendedUntilCommit()); |
| 1296 } | 1305 } |
| 1297 | 1306 |
| 1298 } // namespace | 1307 } // namespace |
| 1299 } // namespace cc | 1308 } // namespace cc |
| OLD | NEW |