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 "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "cc/scheduler/scheduler.h" | 8 #include "cc/scheduler/scheduler.h" |
9 #include "cc/test/begin_frame_args_test.h" | 9 #include "cc/test/begin_frame_args_test.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); | 241 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); |
242 state.SetCanStart(); | 242 state.SetCanStart(); |
243 state.UpdateState(state.NextAction()); | 243 state.UpdateState(state.NextAction()); |
244 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 244 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
245 state.SetNeedsRedraw(false); | 245 state.SetNeedsRedraw(false); |
246 state.SetVisible(true); | 246 state.SetVisible(true); |
247 state.SetNeedsCommit(); | 247 state.SetNeedsCommit(); |
248 | 248 |
249 EXPECT_TRUE(state.BeginFrameNeeded()); | 249 EXPECT_TRUE(state.BeginFrameNeeded()); |
250 | 250 |
| 251 // Expect nothing to happen until after OnBeginImplFrame. |
| 252 EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE); |
| 253 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 254 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); |
| 255 |
251 state.OnBeginImplFrame(); | 256 state.OnBeginImplFrame(); |
252 EXPECT_ACTION_UPDATE_STATE( | 257 EXPECT_ACTION_UPDATE_STATE( |
253 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 258 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
| 259 } |
| 260 |
| 261 // If commit requested and can't draw, still begin a main frame. |
| 262 { |
| 263 StateMachine state(default_scheduler_settings); |
| 264 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); |
| 265 state.SetCanStart(); |
| 266 state.UpdateState(state.NextAction()); |
| 267 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
| 268 state.SetNeedsRedraw(false); |
| 269 state.SetVisible(true); |
| 270 state.SetNeedsCommit(); |
| 271 state.SetCanDraw(false); |
| 272 |
| 273 EXPECT_TRUE(state.BeginFrameNeeded()); |
| 274 |
| 275 // Expect nothing to happen until after OnBeginImplFrame. |
| 276 EXPECT_COMMIT_STATE(SchedulerStateMachine::COMMIT_STATE_IDLE); |
| 277 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 278 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); |
| 279 |
| 280 state.OnBeginImplFrame(); |
| 281 EXPECT_ACTION_UPDATE_STATE( |
| 282 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
254 } | 283 } |
255 | 284 |
256 // Begin the frame, make sure needs_commit and commit_state update correctly. | 285 // Begin the frame, make sure needs_commit and commit_state update correctly. |
257 { | 286 { |
258 StateMachine state(default_scheduler_settings); | 287 StateMachine state(default_scheduler_settings); |
259 state.SetCanStart(); | 288 state.SetCanStart(); |
260 state.UpdateState(state.NextAction()); | 289 state.UpdateState(state.NextAction()); |
261 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 290 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
262 state.SetVisible(true); | 291 state.SetVisible(true); |
263 state.UpdateState(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 292 state.UpdateState(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1947 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1919 bool commit_has_no_updates = true; | 1948 bool commit_has_no_updates = true; |
1920 state.UpdateStateOnCommit(commit_has_no_updates); | 1949 state.UpdateStateOnCommit(commit_has_no_updates); |
1921 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); | 1950 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); |
1922 state.OnBeginImplFrame(); | 1951 state.OnBeginImplFrame(); |
1923 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); | 1952 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); |
1924 } | 1953 } |
1925 | 1954 |
1926 } // namespace | 1955 } // namespace |
1927 } // namespace cc | 1956 } // namespace cc |
OLD | NEW |