Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: cc/scheduler/scheduler_state_machine_unittest.cc

Issue 609003002: cc:: Remove main_frame_before_draw_enabled from scheduler settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DCHECK Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/trace_event.h" 7 #include "base/debug/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 24 matching lines...) Expand all
35 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, 35 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE,
36 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, 36 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING,
37 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME, 37 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME,
38 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, }; 38 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, };
39 39
40 const SchedulerStateMachine::CommitState all_commit_states[] = { 40 const SchedulerStateMachine::CommitState all_commit_states[] = {
41 SchedulerStateMachine::COMMIT_STATE_IDLE, 41 SchedulerStateMachine::COMMIT_STATE_IDLE,
42 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, 42 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
43 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED, 43 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED,
44 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, 44 SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
45 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_ACTIVATION, 45 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_ACTIVATION};
46 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW};
47 46
48 // Exposes the protected state fields of the SchedulerStateMachine for testing 47 // Exposes the protected state fields of the SchedulerStateMachine for testing
49 class StateMachine : public SchedulerStateMachine { 48 class StateMachine : public SchedulerStateMachine {
50 public: 49 public:
51 explicit StateMachine(const SchedulerSettings& scheduler_settings) 50 explicit StateMachine(const SchedulerSettings& scheduler_settings)
52 : SchedulerStateMachine(scheduler_settings) {} 51 : SchedulerStateMachine(scheduler_settings) {}
53 52
54 void CreateAndInitializeOutputSurfaceWithActivatedCommit() { 53 void CreateAndInitializeOutputSurfaceWithActivatedCommit() {
55 DidCreateAndInitializeOutputSurface(); 54 DidCreateAndInitializeOutputSurface();
56 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; 55 output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 state.UpdateState(state.NextAction()); 168 state.UpdateState(state.NextAction());
170 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 169 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
171 state.SetVisible(true); 170 state.SetVisible(true);
172 state.UpdateState(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 171 state.UpdateState(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
173 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, 172 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
174 state.CommitState()); 173 state.CommitState());
175 EXPECT_FALSE(state.NeedsCommit()); 174 EXPECT_FALSE(state.NeedsCommit());
176 } 175 }
177 } 176 }
178 177
179 // Explicitly test main_frame_before_draw_enabled = false
180 TEST(SchedulerStateMachineTest, MainFrameBeforeDrawDisabled) {
181 SchedulerSettings scheduler_settings;
182 scheduler_settings.impl_side_painting = true;
183 scheduler_settings.main_frame_before_draw_enabled = false;
184 StateMachine state(scheduler_settings);
185 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE);
186 state.SetCanStart();
187 state.UpdateState(state.NextAction());
188 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
189 state.SetNeedsRedraw(false);
190 state.SetVisible(true);
191 state.SetCanDraw(true);
192 state.SetNeedsCommit();
193
194 EXPECT_TRUE(state.BeginFrameNeeded());
195
196 // Commit to the pending tree.
197 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
198 EXPECT_ACTION_UPDATE_STATE(
199 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
200 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
201 state.NotifyBeginMainFrameStarted();
202 state.NotifyReadyToCommit();
203 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
204 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
205 EXPECT_EQ(state.CommitState(),
206 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
207
208 state.OnBeginImplFrameDeadline();
209 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
210 EXPECT_EQ(state.CommitState(),
211 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
212
213 // Verify that the next commit doesn't start until the previous
214 // commit has been drawn.
215 state.SetNeedsCommit();
216 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
217 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
218
219 // Make sure that a draw of the active tree doesn't spuriously advance
220 // the commit state and unblock the next commit.
221 state.SetNeedsRedraw(true);
222 state.OnBeginImplFrameDeadline();
223 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
224 EXPECT_ACTION_UPDATE_STATE(
225 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
226 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
227 EXPECT_EQ(state.CommitState(),
228 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
229 EXPECT_TRUE(state.has_pending_tree());
230
231 // Verify NotifyReadyToActivate unblocks activation, draw, and
232 // commit in that order.
233 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
234
235 state.NotifyReadyToActivate();
236 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
237 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
238 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
239 EXPECT_EQ(state.CommitState(),
240 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
241
242 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly());
243 state.OnBeginImplFrameDeadline();
244 EXPECT_ACTION_UPDATE_STATE(
245 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
246 state.DidSwapBuffers();
247 state.DidSwapBuffersComplete();
248 EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE);
249 EXPECT_ACTION_UPDATE_STATE(
250 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
251 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
252 EXPECT_EQ(state.CommitState(),
253 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
254
255 state.NotifyBeginMainFrameStarted();
256 state.NotifyReadyToCommit();
257 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
258 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
259 EXPECT_EQ(state.CommitState(),
260 SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
261 }
262
263 // Explicitly test main_frame_before_activation_enabled = true 178 // Explicitly test main_frame_before_activation_enabled = true
264 TEST(SchedulerStateMachineTest, MainFrameBeforeActivationEnabled) { 179 TEST(SchedulerStateMachineTest, MainFrameBeforeActivationEnabled) {
265 SchedulerSettings scheduler_settings; 180 SchedulerSettings scheduler_settings;
266 scheduler_settings.impl_side_painting = true; 181 scheduler_settings.impl_side_painting = true;
267 scheduler_settings.main_frame_before_activation_enabled = true; 182 scheduler_settings.main_frame_before_activation_enabled = true;
268 StateMachine state(scheduler_settings); 183 StateMachine state(scheduler_settings);
269 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE); 184 state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE);
270 state.SetCanStart(); 185 state.SetCanStart();
271 state.UpdateState(state.NextAction()); 186 state.UpdateState(state.NextAction());
272 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 187 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
273 state.SetNeedsRedraw(false); 188 state.SetNeedsRedraw(false);
274 state.SetVisible(true); 189 state.SetVisible(true);
275 state.SetCanDraw(true); 190 state.SetCanDraw(true);
276 state.SetNeedsCommit(); 191 state.SetNeedsCommit();
277 192
278 EXPECT_TRUE(state.BeginFrameNeeded()); 193 EXPECT_TRUE(state.BeginFrameNeeded());
279 194
280 // Commit to the pending tree. 195 // Commit to the pending tree.
281 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); 196 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
282 EXPECT_ACTION_UPDATE_STATE( 197 EXPECT_ACTION_UPDATE_STATE(
283 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 198 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
284 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 199 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
285 200
286 state.NotifyBeginMainFrameStarted(); 201 state.NotifyBeginMainFrameStarted();
287 state.NotifyReadyToCommit(); 202 state.NotifyReadyToCommit();
288 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 203 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
289 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 204 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
290 EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE); 205 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
291 206
292 state.OnBeginImplFrameDeadline(); 207 state.OnBeginImplFrameDeadline();
293 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 208 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
294 209
295 // Verify that the next commit starts while there is still a pending tree. 210 // Verify that the next commit starts while there is still a pending tree.
296 state.SetNeedsCommit(); 211 state.SetNeedsCommit();
297 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); 212 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
298 EXPECT_ACTION_UPDATE_STATE( 213 EXPECT_ACTION_UPDATE_STATE(
299 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 214 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
300 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 215 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 12 matching lines...) Expand all
313 228
314 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); 229 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly());
315 state.OnBeginImplFrameDeadline(); 230 state.OnBeginImplFrameDeadline();
316 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); 231 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
317 EXPECT_ACTION_UPDATE_STATE( 232 EXPECT_ACTION_UPDATE_STATE(
318 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 233 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
319 state.DidSwapBuffers(); 234 state.DidSwapBuffers();
320 state.DidSwapBuffersComplete(); 235 state.DidSwapBuffersComplete();
321 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 236 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
322 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 237 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
323 EXPECT_EQ(state.CommitState(), SchedulerStateMachine::COMMIT_STATE_IDLE); 238 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
324 } 239 }
325 240
326 TEST(SchedulerStateMachineTest, 241 TEST(SchedulerStateMachineTest,
327 TestFailedDrawForAnimationCheckerboardSetsNeedsCommitAndDoesNotDrawAgain) { 242 TestFailedDrawForAnimationCheckerboardSetsNeedsCommitAndDoesNotDrawAgain) {
328 SchedulerSettings default_scheduler_settings; 243 SchedulerSettings default_scheduler_settings;
329 StateMachine state(default_scheduler_settings); 244 StateMachine state(default_scheduler_settings);
330 state.SetCanStart(); 245 state.SetCanStart();
331 state.UpdateState(state.NextAction()); 246 state.UpdateState(state.NextAction());
332 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 247 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
333 state.SetVisible(true); 248 state.SetVisible(true);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 342
428 // Failing the draw for animation checkerboards makes us require a commit. 343 // Failing the draw for animation checkerboards makes us require a commit.
429 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); 344 state.DidDrawIfPossibleCompleted(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS);
430 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); 345 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
431 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); 346 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
432 EXPECT_ACTION_UPDATE_STATE( 347 EXPECT_ACTION_UPDATE_STATE(
433 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 348 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
434 EXPECT_TRUE(state.RedrawPending()); 349 EXPECT_TRUE(state.RedrawPending());
435 } 350 }
436 351
437 void TestFailedDrawsEventuallyForceDrawAfterNextCommit( 352 TEST(SchedulerStateMachineTest,
438 bool main_frame_before_draw_enabled) { 353 TestFailedDrawsEventuallyForceDrawAfterNextCommit) {
439 SchedulerSettings scheduler_settings; 354 SchedulerSettings scheduler_settings;
440 scheduler_settings.main_frame_before_draw_enabled =
441 main_frame_before_draw_enabled;
442 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = 1; 355 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = 1;
443 StateMachine state(scheduler_settings); 356 StateMachine state(scheduler_settings);
444 state.SetCanStart(); 357 state.SetCanStart();
445 state.UpdateState(state.NextAction()); 358 state.UpdateState(state.NextAction());
446 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 359 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
447 state.SetVisible(true); 360 state.SetVisible(true);
448 state.SetCanDraw(true); 361 state.SetCanDraw(true);
449 362
450 // Start a commit. 363 // Start a commit.
451 state.SetNeedsCommit(); 364 state.SetNeedsCommit();
(...skipping 23 matching lines...) Expand all
475 // continue the commit as usual. 388 // continue the commit as usual.
476 state.NotifyBeginMainFrameStarted(); 389 state.NotifyBeginMainFrameStarted();
477 state.NotifyReadyToCommit(); 390 state.NotifyReadyToCommit();
478 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 391 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
479 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 392 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
480 EXPECT_TRUE(state.RedrawPending()); 393 EXPECT_TRUE(state.RedrawPending());
481 394
482 // The redraw should be forced at the end of the next BeginImplFrame. 395 // The redraw should be forced at the end of the next BeginImplFrame.
483 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); 396 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
484 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); 397 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
485 if (main_frame_before_draw_enabled) { 398 EXPECT_ACTION_UPDATE_STATE(
486 EXPECT_ACTION_UPDATE_STATE( 399 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
487 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
488 }
489 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 400 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
490 state.OnBeginImplFrameDeadline(); 401 state.OnBeginImplFrameDeadline();
491 EXPECT_ACTION_UPDATE_STATE( 402 EXPECT_ACTION_UPDATE_STATE(
492 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED); 403 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED);
493 state.DidSwapBuffers(); 404 state.DidSwapBuffers();
494 state.DidSwapBuffersComplete(); 405 state.DidSwapBuffersComplete();
495 } 406 }
496 407
497 TEST(SchedulerStateMachineTest,
498 TestFailedDrawsEventuallyForceDrawAfterNextCommit) {
499 bool main_frame_before_draw_enabled = false;
500 TestFailedDrawsEventuallyForceDrawAfterNextCommit(
501 main_frame_before_draw_enabled);
502 }
503
504 TEST(SchedulerStateMachineTest,
505 TestFailedDrawsEventuallyForceDrawAfterNextCommit_CommitBeforeDraw) {
506 bool main_frame_before_draw_enabled = true;
507 TestFailedDrawsEventuallyForceDrawAfterNextCommit(
508 main_frame_before_draw_enabled);
509 }
510
511 TEST(SchedulerStateMachineTest, TestFailedDrawsDoNotRestartForcedDraw) { 408 TEST(SchedulerStateMachineTest, TestFailedDrawsDoNotRestartForcedDraw) {
512 SchedulerSettings scheduler_settings; 409 SchedulerSettings scheduler_settings;
513 int draw_limit = 1; 410 int draw_limit = 1;
514 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = 411 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ =
515 draw_limit; 412 draw_limit;
516 scheduler_settings.impl_side_painting = true; 413 scheduler_settings.impl_side_painting = true;
517 StateMachine state(scheduler_settings); 414 StateMachine state(scheduler_settings);
518 state.SetCanStart(); 415 state.SetCanStart();
519 state.UpdateState(state.NextAction()); 416 state.UpdateState(state.NextAction());
520 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 417 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 706 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
810 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 707 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
811 state.NotifyBeginMainFrameStarted(); 708 state.NotifyBeginMainFrameStarted();
812 state.NotifyReadyToCommit(); 709 state.NotifyReadyToCommit();
813 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 710 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
814 state.OnBeginImplFrameDeadline(); 711 state.OnBeginImplFrameDeadline();
815 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 712 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
816 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 713 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
817 } 714 }
818 715
819 void TestSetNeedsCommitIsNotLost(bool main_frame_before_draw_enabled) { 716 TEST(SchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) {
820 SchedulerSettings scheduler_settings; 717 SchedulerSettings scheduler_settings;
821 scheduler_settings.main_frame_before_draw_enabled =
822 main_frame_before_draw_enabled;
823 StateMachine state(scheduler_settings); 718 StateMachine state(scheduler_settings);
824 state.SetCanStart(); 719 state.SetCanStart();
825 state.UpdateState(state.NextAction()); 720 state.UpdateState(state.NextAction());
826 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 721 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
827 state.SetNeedsCommit(); 722 state.SetNeedsCommit();
828 state.SetVisible(true); 723 state.SetVisible(true);
829 state.SetCanDraw(true); 724 state.SetCanDraw(true);
830 725
831 EXPECT_TRUE(state.BeginFrameNeeded()); 726 EXPECT_TRUE(state.BeginFrameNeeded());
832 727
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 764
870 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting()); 765 state.OnBeginImplFrame(CreateBeginFrameArgsForTesting());
871 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, 766 EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING,
872 state.begin_impl_frame_state()); 767 state.begin_impl_frame_state());
873 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); 768 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
874 769
875 // Finish the commit, then make sure we start the next commit immediately 770 // Finish the commit, then make sure we start the next commit immediately
876 // and draw on the next BeginImplFrame. 771 // and draw on the next BeginImplFrame.
877 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 772 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
878 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); 773 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
879 if (main_frame_before_draw_enabled) { 774 EXPECT_ACTION_UPDATE_STATE(
880 EXPECT_ACTION_UPDATE_STATE( 775 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
881 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
882 }
883 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 776 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
884 777
885 state.OnBeginImplFrameDeadline(); 778 state.OnBeginImplFrameDeadline();
886 779
887 EXPECT_TRUE(state.active_tree_needs_first_draw()); 780 EXPECT_TRUE(state.active_tree_needs_first_draw());
888 EXPECT_ACTION_UPDATE_STATE( 781 EXPECT_ACTION_UPDATE_STATE(
889 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 782 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
890 state.DidSwapBuffers(); 783 state.DidSwapBuffers();
891 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS); 784 state.DidDrawIfPossibleCompleted(DRAW_SUCCESS);
892 state.DidSwapBuffersComplete(); 785 state.DidSwapBuffersComplete();
893 if (!main_frame_before_draw_enabled) {
894 EXPECT_ACTION_UPDATE_STATE(
895 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
896 }
897 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 786 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
898 } 787 }
899 788
900 TEST(SchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) {
901 bool main_frame_before_draw_enabled = false;
902 TestSetNeedsCommitIsNotLost(main_frame_before_draw_enabled);
903 }
904
905 TEST(SchedulerStateMachineTest, TestSetNeedsCommitIsNotLost_CommitBeforeDraw) {
906 bool main_frame_before_draw_enabled = true;
907 TestSetNeedsCommitIsNotLost(main_frame_before_draw_enabled);
908 }
909
910 TEST(SchedulerStateMachineTest, TestFullCycle) { 789 TEST(SchedulerStateMachineTest, TestFullCycle) {
911 SchedulerSettings default_scheduler_settings; 790 SchedulerSettings default_scheduler_settings;
912 StateMachine state(default_scheduler_settings); 791 StateMachine state(default_scheduler_settings);
913 state.SetCanStart(); 792 state.SetCanStart();
914 state.UpdateState(state.NextAction()); 793 state.UpdateState(state.NextAction());
915 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 794 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
916 state.SetVisible(true); 795 state.SetVisible(true);
917 state.SetCanDraw(true); 796 state.SetCanDraw(true);
918 797
919 // Start clean and set commit. 798 // Start clean and set commit.
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 state.SetNeedsAnimate(); 1781 state.SetNeedsAnimate();
1903 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1782 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1904 1783
1905 state.OnBeginImplFrameDeadline(); 1784 state.OnBeginImplFrameDeadline();
1906 EXPECT_ACTION_UPDATE_STATE( 1785 EXPECT_ACTION_UPDATE_STATE(
1907 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 1786 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1908 } 1787 }
1909 1788
1910 } // namespace 1789 } // namespace
1911 } // namespace cc 1790 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698