| 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_state_machine.h" | 5 #include "cc/scheduler_state_machine.h" |
| 6 | 6 |
| 7 #include "cc/scheduler.h" | 7 #include "cc/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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 EXPECT_FALSE(state.commitPending()); | 129 EXPECT_FALSE(state.commitPending()); |
| 130 | 130 |
| 131 // Failing the draw makes us require a commit. | 131 // Failing the draw makes us require a commit. |
| 132 state.didDrawIfPossibleCompleted(false); | 132 state.didDrawIfPossibleCompleted(false); |
| 133 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); | 133 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); |
| 134 state.updateState(SchedulerStateMachine::ACTION_BEGIN_FRAME); | 134 state.updateState(SchedulerStateMachine::ACTION_BEGIN_FRAME); |
| 135 EXPECT_TRUE(state.redrawPending()); | 135 EXPECT_TRUE(state.redrawPending()); |
| 136 EXPECT_TRUE(state.commitPending()); | 136 EXPECT_TRUE(state.commitPending()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST(SchedulerStateMachineTest, TestSetNeedsRedrawDuringFailedDrawDoesNotRemoveN
eedsRedraw) | 139 TEST(SchedulerStateMachineTest, TestsetNeedsRedrawDuringFailedDrawDoesNotRemoveN
eedsRedraw) |
| 140 { | 140 { |
| 141 SchedulerSettings defaultSchedulerSettings; | 141 SchedulerSettings defaultSchedulerSettings; |
| 142 SchedulerStateMachine state(defaultSchedulerSettings); | 142 SchedulerStateMachine state(defaultSchedulerSettings); |
| 143 state.setCanBeginFrame(true); | 143 state.setCanBeginFrame(true); |
| 144 state.setVisible(true); | 144 state.setVisible(true); |
| 145 state.setCanDraw(true); | 145 state.setCanDraw(true); |
| 146 state.setNeedsRedraw(); | 146 state.setNeedsRedraw(); |
| 147 EXPECT_TRUE(state.redrawPending()); | 147 EXPECT_TRUE(state.redrawPending()); |
| 148 EXPECT_TRUE(state.vsyncCallbackNeeded()); | 148 EXPECT_TRUE(state.vsyncCallbackNeeded()); |
| 149 state.didEnterVSync(); | 149 state.didEnterVSync(); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 StateMachine state(defaultSchedulerSettings); | 469 StateMachine state(defaultSchedulerSettings); |
| 470 state.setCommitState(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_D
RAW); | 470 state.setCommitState(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_D
RAW); |
| 471 state.setCanBeginFrame(true); | 471 state.setCanBeginFrame(true); |
| 472 state.setNeedsCommit(); | 472 state.setNeedsCommit(); |
| 473 state.setNeedsRedraw(true); | 473 state.setNeedsRedraw(true); |
| 474 state.setVisible(true); | 474 state.setVisible(true); |
| 475 state.setCanDraw(false); | 475 state.setCanDraw(false); |
| 476 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); | 476 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); |
| 477 } | 477 } |
| 478 | 478 |
| 479 TEST(SchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) | 479 TEST(SchedulerStateMachineTest, TestsetNeedsCommitIsNotLost) |
| 480 { | 480 { |
| 481 SchedulerSettings defaultSchedulerSettings; | 481 SchedulerSettings defaultSchedulerSettings; |
| 482 StateMachine state(defaultSchedulerSettings); | 482 StateMachine state(defaultSchedulerSettings); |
| 483 state.setCanBeginFrame(true); | 483 state.setCanBeginFrame(true); |
| 484 state.setNeedsCommit(); | 484 state.setNeedsCommit(); |
| 485 state.setVisible(true); | 485 state.setVisible(true); |
| 486 state.setCanDraw(true); | 486 state.setCanDraw(true); |
| 487 | 487 |
| 488 // Begin the frame. | 488 // Begin the frame. |
| 489 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); | 489 EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); | 1046 EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.nextAction()); |
| 1047 state.setNeedsForcedRedraw(true); | 1047 state.setNeedsForcedRedraw(true); |
| 1048 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction()); | 1048 EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction()); |
| 1049 state.updateState(state.nextAction()); | 1049 state.updateState(state.nextAction()); |
| 1050 state.didDrawIfPossibleCompleted(true); | 1050 state.didDrawIfPossibleCompleted(true); |
| 1051 state.didLeaveVSync(); | 1051 state.didLeaveVSync(); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 } // namespace | 1054 } // namespace |
| 1055 } // namespace cc | 1055 } // namespace cc |
| OLD | NEW |