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 #define EXPECT_ACTION_UPDATE_STATE(action) \ | 10 #define EXPECT_ACTION_UPDATE_STATE(action) \ |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 132 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
133 state.OnBeginImplFrameDeadline(); | 133 state.OnBeginImplFrameDeadline(); |
134 } | 134 } |
135 | 135 |
136 // If commit requested but can_start is still false, do nothing. | 136 // If commit requested but can_start is still false, do nothing. |
137 { | 137 { |
138 StateMachine state(default_scheduler_settings); | 138 StateMachine state(default_scheduler_settings); |
139 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); | 139 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); |
140 state.SetNeedsRedraw(false); | 140 state.SetNeedsRedraw(false); |
141 state.SetVisible(true); | 141 state.SetVisible(true); |
| 142 state.SetNeedsCommit(); |
142 | 143 |
143 EXPECT_FALSE(state.BeginImplFrameNeeded()); | 144 EXPECT_FALSE(state.BeginImplFrameNeeded()); |
144 | 145 |
145 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 146 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
146 EXPECT_FALSE(state.BeginImplFrameNeeded()); | 147 EXPECT_FALSE(state.BeginImplFrameNeeded()); |
147 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 148 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
148 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 149 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
149 state.OnBeginImplFrameDeadline(); | 150 state.OnBeginImplFrameDeadline(); |
150 } | 151 } |
151 | 152 |
152 // If commit requested, begin a main frame. | 153 // If commit requested, begin a main frame. |
153 { | 154 { |
154 StateMachine state(default_scheduler_settings); | 155 StateMachine state(default_scheduler_settings); |
155 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); | 156 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); |
156 state.SetCanStart(); | 157 state.SetCanStart(); |
| 158 state.UpdateState(state.NextAction()); |
| 159 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
157 state.SetNeedsRedraw(false); | 160 state.SetNeedsRedraw(false); |
158 state.SetVisible(true); | 161 state.SetVisible(true); |
159 EXPECT_FALSE(state.BeginImplFrameNeeded()); | 162 state.SetNeedsCommit(); |
| 163 |
| 164 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
| 165 |
| 166 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| 167 EXPECT_ACTION_UPDATE_STATE( |
| 168 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
160 } | 169 } |
161 | 170 |
162 // Begin the frame, make sure needs_commit and commit_state update correctly. | 171 // Begin the frame, make sure needs_commit and commit_state update correctly. |
163 { | 172 { |
164 StateMachine state(default_scheduler_settings); | 173 StateMachine state(default_scheduler_settings); |
165 state.SetCanStart(); | 174 state.SetCanStart(); |
166 state.UpdateState(state.NextAction()); | 175 state.UpdateState(state.NextAction()); |
167 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 176 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
168 state.SetVisible(true); | 177 state.SetVisible(true); |
169 state.UpdateState(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 178 state.UpdateState(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1795 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1787 | 1796 |
1788 // The deadline is not triggered early until we enter prefer smoothness mode. | 1797 // The deadline is not triggered early until we enter prefer smoothness mode. |
1789 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1798 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1790 state.SetSmoothnessTakesPriority(true); | 1799 state.SetSmoothnessTakesPriority(true); |
1791 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1800 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1792 } | 1801 } |
1793 | 1802 |
1794 } // namespace | 1803 } // namespace |
1795 } // namespace cc | 1804 } // namespace cc |
OLD | NEW |