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

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

Issue 1253203003: cc: Remove SchedulerStateMachine::UpdateState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nix WillAction Created 5 years, 4 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') | no next file » | 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/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 22 matching lines...) Expand all
33 EXPECT_ENUM_EQ(ActionToString, expected, state.NextAction()) \ 33 EXPECT_ENUM_EQ(ActionToString, expected, state.NextAction()) \
34 << state.AsValue()->ToString() 34 << state.AsValue()->ToString()
35 35
36 #define EXPECT_ACTION_UPDATE_STATE(action) \ 36 #define EXPECT_ACTION_UPDATE_STATE(action) \
37 EXPECT_ACTION(action); \ 37 EXPECT_ACTION(action); \
38 if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \ 38 if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \
39 action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \ 39 action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \
40 EXPECT_IMPL_FRAME_STATE( \ 40 EXPECT_IMPL_FRAME_STATE( \
41 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); \ 41 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); \
42 } \ 42 } \
43 state.UpdateState(action); \ 43 WillPerformAction(&state, action); \
44 if (action == SchedulerStateMachine::ACTION_NONE) { \ 44 if (action == SchedulerStateMachine::ACTION_NONE) { \
45 if (state.begin_impl_frame_state() == \ 45 if (state.begin_impl_frame_state() == \
46 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) \ 46 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) \
47 state.OnBeginImplFrameDeadlinePending(); \ 47 state.OnBeginImplFrameDeadlinePending(); \
48 if (state.begin_impl_frame_state() == \ 48 if (state.begin_impl_frame_state() == \
49 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \ 49 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \
50 state.OnBeginImplFrameIdle(); \ 50 state.OnBeginImplFrameIdle(); \
51 } 51 }
52 52
53 #define SET_UP_STATE(state) \ 53 #define SET_UP_STATE(state) \
54 state.SetCanStart(); \ 54 state.SetCanStart(); \
55 state.UpdateState(state.NextAction()); \ 55 EXPECT_ACTION_UPDATE_STATE( \
56 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); \ 56 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); \
57 state.SetVisible(true); \ 57 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); \
58 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); \
59 state.SetVisible(true); \
58 state.SetCanDraw(true); 60 state.SetCanDraw(true);
59 61
60 namespace cc { 62 namespace cc {
61 63
62 namespace { 64 namespace {
63 65
66 void WillPerformAction(SchedulerStateMachine* sm,
67 SchedulerStateMachine::Action action) {
68 switch (action) {
69 case SchedulerStateMachine::ACTION_NONE:
70 return;
71
72 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE:
73 sm->WillActivate();
74 return;
75
76 case SchedulerStateMachine::ACTION_ANIMATE:
77 sm->WillAnimate();
78 return;
79
80 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME:
81 sm->WillSendBeginMainFrame();
82 return;
83
84 case SchedulerStateMachine::ACTION_COMMIT: {
85 bool commit_has_no_updates = false;
86 sm->WillCommit(commit_has_no_updates);
87 return;
88 }
89
90 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED:
91 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE: {
92 bool did_request_swap = true;
93 sm->WillDraw(did_request_swap);
94 return;
95 }
96
97 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: {
98 bool did_request_swap = false;
99 sm->WillDraw(did_request_swap);
100 return;
101 }
102
103 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
104 sm->WillBeginOutputSurfaceCreation();
105 return;
106
107 case SchedulerStateMachine::ACTION_PREPARE_TILES:
108 sm->WillPrepareTiles();
109 return;
110
111 case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE:
112 sm->WillInvalidateOutputSurface();
113 return;
114 }
115 }
116
64 const SchedulerStateMachine::BeginImplFrameState all_begin_impl_frame_states[] = 117 const SchedulerStateMachine::BeginImplFrameState all_begin_impl_frame_states[] =
65 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, 118 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE,
66 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, 119 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING,
67 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME, 120 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME,
68 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, }; 121 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, };
69 122
70 const SchedulerStateMachine::BeginMainFrameState begin_main_frame_states[] = { 123 const SchedulerStateMachine::BeginMainFrameState begin_main_frame_states[] = {
71 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE, 124 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE,
72 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT, 125 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT,
73 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED, 126 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 bool PendingActivationsShouldBeForced() const { 192 bool PendingActivationsShouldBeForced() const {
140 return SchedulerStateMachine::PendingActivationsShouldBeForced(); 193 return SchedulerStateMachine::PendingActivationsShouldBeForced();
141 } 194 }
142 195
143 void SetHasPendingTree(bool has_pending_tree) { 196 void SetHasPendingTree(bool has_pending_tree) {
144 has_pending_tree_ = has_pending_tree; 197 has_pending_tree_ = has_pending_tree;
145 } 198 }
146 199
147 using SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately; 200 using SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately;
148 using SchedulerStateMachine::ProactiveBeginFrameWanted; 201 using SchedulerStateMachine::ProactiveBeginFrameWanted;
149 using SchedulerStateMachine::UpdateStateOnCommit; 202 using SchedulerStateMachine::WillCommit;
150 }; 203 };
151 204
152 TEST(SchedulerStateMachineTest, BeginFrameNeeded) { 205 TEST(SchedulerStateMachineTest, BeginFrameNeeded) {
153 SchedulerSettings default_scheduler_settings; 206 SchedulerSettings default_scheduler_settings;
154 StateMachine state(default_scheduler_settings); 207 StateMachine state(default_scheduler_settings);
155 state.SetCanStart(); 208 state.SetCanStart();
156 EXPECT_ACTION_UPDATE_STATE( 209 EXPECT_ACTION_UPDATE_STATE(
157 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION) 210 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
211 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
158 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 212 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
159 state.SetBeginMainFrameState( 213 state.SetBeginMainFrameState(
160 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 214 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
161 215
162 // Don't request BeginFrames if we are idle. 216 // Don't request BeginFrames if we are idle.
163 state.SetVisible(true); 217 state.SetVisible(true);
164 state.SetNeedsRedraw(false); 218 state.SetNeedsRedraw(false);
165 state.SetNeedsAnimateForTest(false); 219 state.SetNeedsAnimateForTest(false);
166 EXPECT_FALSE(state.BeginFrameNeeded()); 220 EXPECT_FALSE(state.BeginFrameNeeded());
167 221
(...skipping 27 matching lines...) Expand all
195 } 249 }
196 250
197 TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { 251 TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) {
198 SchedulerSettings default_scheduler_settings; 252 SchedulerSettings default_scheduler_settings;
199 253
200 // If no commit needed, do nothing. 254 // If no commit needed, do nothing.
201 { 255 {
202 StateMachine state(default_scheduler_settings); 256 StateMachine state(default_scheduler_settings);
203 state.SetCanStart(); 257 state.SetCanStart();
204 EXPECT_ACTION_UPDATE_STATE( 258 EXPECT_ACTION_UPDATE_STATE(
205 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION) 259 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
260 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
206 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 261 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
207 state.SetBeginMainFrameState( 262 state.SetBeginMainFrameState(
208 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 263 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
209 state.SetNeedsRedraw(false); 264 state.SetNeedsRedraw(false);
210 state.SetVisible(true); 265 state.SetVisible(true);
211 266
212 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 267 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
213 EXPECT_FALSE(state.NeedsCommit()); 268 EXPECT_FALSE(state.NeedsCommit());
214 269
215 state.OnBeginImplFrame(); 270 state.OnBeginImplFrame();
(...skipping 23 matching lines...) Expand all
239 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 294 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
240 EXPECT_TRUE(state.NeedsCommit()); 295 EXPECT_TRUE(state.NeedsCommit());
241 } 296 }
242 297
243 // If commit requested, begin a main frame. 298 // If commit requested, begin a main frame.
244 { 299 {
245 StateMachine state(default_scheduler_settings); 300 StateMachine state(default_scheduler_settings);
246 state.SetBeginMainFrameState( 301 state.SetBeginMainFrameState(
247 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 302 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
248 state.SetCanStart(); 303 state.SetCanStart();
249 state.UpdateState(state.NextAction()); 304 EXPECT_ACTION_UPDATE_STATE(
305 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
306 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
250 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 307 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
251 state.SetNeedsRedraw(false); 308 state.SetNeedsRedraw(false);
252 state.SetVisible(true); 309 state.SetVisible(true);
253 state.SetNeedsBeginMainFrame(); 310 state.SetNeedsBeginMainFrame();
254 311
255 // Expect nothing to happen until after OnBeginImplFrame. 312 // Expect nothing to happen until after OnBeginImplFrame.
256 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 313 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
257 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 314 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
258 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 315 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
259 EXPECT_TRUE(state.NeedsCommit()); 316 EXPECT_TRUE(state.NeedsCommit());
260 EXPECT_TRUE(state.BeginFrameNeeded()); 317 EXPECT_TRUE(state.BeginFrameNeeded());
261 318
262 state.OnBeginImplFrame(); 319 state.OnBeginImplFrame();
263 EXPECT_ACTION_UPDATE_STATE( 320 EXPECT_ACTION_UPDATE_STATE(
264 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 321 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
265 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 322 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
266 EXPECT_FALSE(state.NeedsCommit()); 323 EXPECT_FALSE(state.NeedsCommit());
267 } 324 }
268 325
269 // If commit requested and can't draw, still begin a main frame. 326 // If commit requested and can't draw, still begin a main frame.
270 { 327 {
271 StateMachine state(default_scheduler_settings); 328 StateMachine state(default_scheduler_settings);
272 state.SetBeginMainFrameState( 329 state.SetBeginMainFrameState(
273 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 330 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
274 state.SetCanStart(); 331 state.SetCanStart();
275 state.UpdateState(state.NextAction()); 332 EXPECT_ACTION_UPDATE_STATE(
333 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
334 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
276 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 335 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
277 state.SetNeedsRedraw(false); 336 state.SetNeedsRedraw(false);
278 state.SetVisible(true); 337 state.SetVisible(true);
279 state.SetNeedsBeginMainFrame(); 338 state.SetNeedsBeginMainFrame();
280 state.SetCanDraw(false); 339 state.SetCanDraw(false);
281 340
282 // Expect nothing to happen until after OnBeginImplFrame. 341 // Expect nothing to happen until after OnBeginImplFrame.
283 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 342 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
284 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 343 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
285 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 344 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 size_t num_begin_main_frame_states = 714 size_t num_begin_main_frame_states =
656 sizeof(begin_main_frame_states) / 715 sizeof(begin_main_frame_states) /
657 sizeof(SchedulerStateMachine::BeginMainFrameState); 716 sizeof(SchedulerStateMachine::BeginMainFrameState);
658 size_t num_begin_impl_frame_states = 717 size_t num_begin_impl_frame_states =
659 sizeof(all_begin_impl_frame_states) / 718 sizeof(all_begin_impl_frame_states) /
660 sizeof(SchedulerStateMachine::BeginImplFrameState); 719 sizeof(SchedulerStateMachine::BeginImplFrameState);
661 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 720 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
662 for (size_t j = 0; j < num_begin_impl_frame_states; ++j) { 721 for (size_t j = 0; j < num_begin_impl_frame_states; ++j) {
663 StateMachine state(default_scheduler_settings); 722 StateMachine state(default_scheduler_settings);
664 state.SetCanStart(); 723 state.SetCanStart();
665 state.UpdateState(state.NextAction()); 724 EXPECT_ACTION_UPDATE_STATE(
725 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
726 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
666 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 727 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
667 state.SetBeginMainFrameState(begin_main_frame_states[i]); 728 state.SetBeginMainFrameState(begin_main_frame_states[i]);
668 state.SetBeginImplFrameState(all_begin_impl_frame_states[j]); 729 state.SetBeginImplFrameState(all_begin_impl_frame_states[j]);
669 bool visible = 730 bool visible =
670 (all_begin_impl_frame_states[j] != 731 (all_begin_impl_frame_states[j] !=
671 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 732 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
672 state.SetVisible(visible); 733 state.SetVisible(visible);
673 734
674 // Case 1: needs_begin_main_frame=false 735 // Case 1: needs_begin_main_frame=false
675 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 736 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
676 state.NextAction()); 737 state.NextAction());
677 738
678 // Case 2: needs_begin_main_frame=true 739 // Case 2: needs_begin_main_frame=true
679 state.SetNeedsBeginMainFrame(); 740 state.SetNeedsBeginMainFrame();
680 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 741 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
681 state.NextAction()) 742 state.NextAction())
682 << state.AsValue()->ToString(); 743 << state.AsValue()->ToString();
683 } 744 }
684 } 745 }
685 746
686 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw 747 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw
687 // except if we're ready to commit, in which case we expect a commit first. 748 // except if we're ready to commit, in which case we expect a commit first.
688 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 749 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
689 StateMachine state(default_scheduler_settings); 750 StateMachine state(default_scheduler_settings);
690 state.SetCanStart(); 751 state.SetCanStart();
691 state.UpdateState(state.NextAction()); 752 EXPECT_ACTION_UPDATE_STATE(
753 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
754 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
692 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 755 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
693 state.SetCanDraw(true); 756 state.SetCanDraw(true);
694 state.SetBeginMainFrameState(begin_main_frame_states[i]); 757 state.SetBeginMainFrameState(begin_main_frame_states[i]);
695 state.SetBeginImplFrameState( 758 state.SetBeginImplFrameState(
696 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 759 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
697 760
698 state.SetNeedsRedraw(true); 761 state.SetNeedsRedraw(true);
699 state.SetVisible(true); 762 state.SetVisible(true);
700 763
701 SchedulerStateMachine::Action expected_action; 764 SchedulerStateMachine::Action expected_action;
702 if (begin_main_frame_states[i] == 765 if (begin_main_frame_states[i] ==
703 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) { 766 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) {
704 expected_action = SchedulerStateMachine::ACTION_COMMIT; 767 expected_action = SchedulerStateMachine::ACTION_COMMIT;
705 } else { 768 } else {
706 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE; 769 expected_action = SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE;
707 EXPECT_ACTION(SchedulerStateMachine::ACTION_ANIMATE); 770 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
708 state.UpdateState(state.NextAction());
709 } 771 }
710 772
711 // Case 1: needs_begin_main_frame=false. 773 // Case 1: needs_begin_main_frame=false.
712 EXPECT_ACTION(expected_action); 774 EXPECT_ACTION(expected_action);
713 775
714 // Case 2: needs_begin_main_frame=true. 776 // Case 2: needs_begin_main_frame=true.
715 state.SetNeedsBeginMainFrame(); 777 state.SetNeedsBeginMainFrame();
716 EXPECT_ACTION(expected_action); 778 EXPECT_ACTION(expected_action);
717 } 779 }
718 } 780 }
719 781
720 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameStatesRedrawWhenInvisible) { 782 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameStatesRedrawWhenInvisible) {
721 SchedulerSettings default_scheduler_settings; 783 SchedulerSettings default_scheduler_settings;
722 784
723 size_t num_begin_main_frame_states = 785 size_t num_begin_main_frame_states =
724 sizeof(begin_main_frame_states) / 786 sizeof(begin_main_frame_states) /
725 sizeof(SchedulerStateMachine::BeginMainFrameState); 787 sizeof(SchedulerStateMachine::BeginMainFrameState);
726 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 788 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
727 // There shouldn't be any drawing regardless of BeginImplFrame. 789 // There shouldn't be any drawing regardless of BeginImplFrame.
728 for (size_t j = 0; j < 2; ++j) { 790 for (size_t j = 0; j < 2; ++j) {
729 StateMachine state(default_scheduler_settings); 791 StateMachine state(default_scheduler_settings);
730 state.SetCanStart(); 792 state.SetCanStart();
731 state.UpdateState(state.NextAction()); 793 EXPECT_ACTION_UPDATE_STATE(
794 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
795 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
732 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 796 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
733 state.SetBeginMainFrameState(begin_main_frame_states[i]); 797 state.SetBeginMainFrameState(begin_main_frame_states[i]);
734 state.SetVisible(false); 798 state.SetVisible(false);
735 state.SetNeedsRedraw(true); 799 state.SetNeedsRedraw(true);
736 if (j == 1) { 800 if (j == 1) {
737 state.SetBeginImplFrameState( 801 state.SetBeginImplFrameState(
738 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 802 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
739 } 803 }
740 804
741 // Case 1: needs_begin_main_frame=false. 805 // Case 1: needs_begin_main_frame=false.
(...skipping 13 matching lines...) Expand all
755 SchedulerSettings default_scheduler_settings; 819 SchedulerSettings default_scheduler_settings;
756 820
757 size_t num_begin_main_frame_states = 821 size_t num_begin_main_frame_states =
758 sizeof(begin_main_frame_states) / 822 sizeof(begin_main_frame_states) /
759 sizeof(SchedulerStateMachine::BeginMainFrameState); 823 sizeof(SchedulerStateMachine::BeginMainFrameState);
760 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 824 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
761 // There shouldn't be any drawing regardless of BeginImplFrame. 825 // There shouldn't be any drawing regardless of BeginImplFrame.
762 for (size_t j = 0; j < 2; ++j) { 826 for (size_t j = 0; j < 2; ++j) {
763 StateMachine state(default_scheduler_settings); 827 StateMachine state(default_scheduler_settings);
764 state.SetCanStart(); 828 state.SetCanStart();
765 state.UpdateState(state.NextAction()); 829 EXPECT_ACTION_UPDATE_STATE(
830 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
831 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
766 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 832 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
767 state.SetBeginMainFrameState(begin_main_frame_states[i]); 833 state.SetBeginMainFrameState(begin_main_frame_states[i]);
768 state.SetVisible(false); 834 state.SetVisible(false);
769 state.SetNeedsRedraw(true); 835 state.SetNeedsRedraw(true);
770 if (j == 1) 836 if (j == 1)
771 state.OnBeginImplFrame(); 837 state.OnBeginImplFrame();
772 838
773 state.SetCanDraw(false); 839 state.SetCanDraw(false);
774 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 840 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
775 state.NextAction()); 841 state.NextAction());
776 } 842 }
777 } 843 }
778 } 844 }
779 845
780 TEST(SchedulerStateMachineTest, 846 TEST(SchedulerStateMachineTest,
781 TestCanRedrawWithWaitingForFirstDrawMakesProgress) { 847 TestCanRedrawWithWaitingForFirstDrawMakesProgress) {
782 SchedulerSettings default_scheduler_settings; 848 SchedulerSettings default_scheduler_settings;
783 StateMachine state(default_scheduler_settings); 849 StateMachine state(default_scheduler_settings);
784 state.SetCanStart(); 850 state.SetCanStart();
785 state.UpdateState(state.NextAction()); 851 EXPECT_ACTION_UPDATE_STATE(
852 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
853 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
786 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 854 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
787 855
788 state.SetActiveTreeNeedsFirstDraw(true); 856 state.SetActiveTreeNeedsFirstDraw(true);
789 state.SetNeedsBeginMainFrame(); 857 state.SetNeedsBeginMainFrame();
790 state.SetNeedsRedraw(true); 858 state.SetNeedsRedraw(true);
791 state.SetVisible(true); 859 state.SetVisible(true);
792 state.SetCanDraw(false); 860 state.SetCanDraw(false);
793 state.OnBeginImplFrame(); 861 state.OnBeginImplFrame();
794 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE); 862 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ANIMATE);
795 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 863 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 // Next BeginImplFrame should initiate second commit. 1186 // Next BeginImplFrame should initiate second commit.
1119 state.OnBeginImplFrame(); 1187 state.OnBeginImplFrame();
1120 EXPECT_ACTION_UPDATE_STATE( 1188 EXPECT_ACTION_UPDATE_STATE(
1121 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1189 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1122 } 1190 }
1123 1191
1124 TEST(SchedulerStateMachineTest, TestRequestCommitInvisible) { 1192 TEST(SchedulerStateMachineTest, TestRequestCommitInvisible) {
1125 SchedulerSettings default_scheduler_settings; 1193 SchedulerSettings default_scheduler_settings;
1126 StateMachine state(default_scheduler_settings); 1194 StateMachine state(default_scheduler_settings);
1127 state.SetCanStart(); 1195 state.SetCanStart();
1128 state.UpdateState(state.NextAction()); 1196 EXPECT_ACTION_UPDATE_STATE(
1197 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
1198 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1129 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1199 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1130 state.SetNeedsBeginMainFrame(); 1200 state.SetNeedsBeginMainFrame();
1131 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1201 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1132 } 1202 }
1133 1203
1134 // See ThreadProxy::BeginMainFrame "EarlyOut_NotVisible" / 1204 // See ThreadProxy::BeginMainFrame "EarlyOut_NotVisible" /
1135 // "EarlyOut_OutputSurfaceLost" cases. 1205 // "EarlyOut_OutputSurfaceLost" cases.
1136 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseInvisible) { 1206 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseInvisible) {
1137 SchedulerSettings default_scheduler_settings; 1207 SchedulerSettings default_scheduler_settings;
1138 StateMachine state(default_scheduler_settings); 1208 StateMachine state(default_scheduler_settings);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 // We should be starting the commit now. 1252 // We should be starting the commit now.
1183 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1253 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1184 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1254 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1185 } 1255 }
1186 1256
1187 // See ThreadProxy::BeginMainFrame "EarlyOut_NoUpdates" case. 1257 // See ThreadProxy::BeginMainFrame "EarlyOut_NoUpdates" case.
1188 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseCommitNotNeeded) { 1258 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseCommitNotNeeded) {
1189 SchedulerSettings default_scheduler_settings; 1259 SchedulerSettings default_scheduler_settings;
1190 StateMachine state(default_scheduler_settings); 1260 StateMachine state(default_scheduler_settings);
1191 state.SetCanStart(); 1261 state.SetCanStart();
1192 state.UpdateState(state.NextAction()); 1262 EXPECT_ACTION_UPDATE_STATE(
1263 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
1264 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1193 state.DidCreateAndInitializeOutputSurface(); 1265 state.DidCreateAndInitializeOutputSurface();
1194 state.SetVisible(true); 1266 state.SetVisible(true);
1195 state.SetCanDraw(true); 1267 state.SetCanDraw(true);
1196 1268
1197 // Get into a begin frame / commit state. 1269 // Get into a begin frame / commit state.
1198 state.SetNeedsBeginMainFrame(); 1270 state.SetNeedsBeginMainFrame();
1199 state.OnBeginImplFrame(); 1271 state.OnBeginImplFrame();
1200 EXPECT_ACTION_UPDATE_STATE( 1272 EXPECT_ACTION_UPDATE_STATE(
1201 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1273 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1202 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1274 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1335
1264 TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) { 1336 TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) {
1265 SchedulerSettings default_scheduler_settings; 1337 SchedulerSettings default_scheduler_settings;
1266 StateMachine state(default_scheduler_settings); 1338 StateMachine state(default_scheduler_settings);
1267 SET_UP_STATE(state) 1339 SET_UP_STATE(state)
1268 1340
1269 EXPECT_NE(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 1341 EXPECT_NE(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
1270 state.NextAction()); 1342 state.NextAction());
1271 state.DidLoseOutputSurface(); 1343 state.DidLoseOutputSurface();
1272 1344
1273 EXPECT_ACTION(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1345 EXPECT_ACTION_UPDATE_STATE(
1274 state.UpdateState(state.NextAction()); 1346 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
1347 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1275 1348
1276 // Once context recreation begins, nothing should happen. 1349 // Once context recreation begins, nothing should happen.
1277 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1350 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1278 1351
1279 // Recreate the context. 1352 // Recreate the context.
1280 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1353 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1281 1354
1282 // When the context is recreated, we should begin a commit. 1355 // When the context is recreated, we should begin a commit.
1283 state.OnBeginImplFrame(); 1356 state.OnBeginImplFrame();
1284 EXPECT_ACTION_UPDATE_STATE( 1357 EXPECT_ACTION_UPDATE_STATE(
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 1632
1560 TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) { 1633 TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) {
1561 SchedulerSettings default_scheduler_settings; 1634 SchedulerSettings default_scheduler_settings;
1562 StateMachine state(default_scheduler_settings); 1635 StateMachine state(default_scheduler_settings);
1563 SET_UP_STATE(state) 1636 SET_UP_STATE(state)
1564 1637
1565 state.SetNeedsRedraw(true); 1638 state.SetNeedsRedraw(true);
1566 1639
1567 // Cause a lost output surface, and restore it. 1640 // Cause a lost output surface, and restore it.
1568 state.DidLoseOutputSurface(); 1641 state.DidLoseOutputSurface();
1569 EXPECT_ACTION(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1642 EXPECT_ACTION_UPDATE_STATE(
1570 state.UpdateState(state.NextAction()); 1643 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
1644 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1571 state.DidCreateAndInitializeOutputSurface(); 1645 state.DidCreateAndInitializeOutputSurface();
1572 1646
1573 EXPECT_FALSE(state.RedrawPending()); 1647 EXPECT_FALSE(state.RedrawPending());
1574 state.OnBeginImplFrame(); 1648 state.OnBeginImplFrame();
1575 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1649 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1576 } 1650 }
1577 1651
1578 TEST(SchedulerStateMachineTest, 1652 TEST(SchedulerStateMachineTest,
1579 TestPendingActivationsShouldBeForcedAfterLostOutputSurface) { 1653 TestPendingActivationsShouldBeForcedAfterLostOutputSurface) {
1580 SchedulerSettings default_scheduler_settings; 1654 SchedulerSettings default_scheduler_settings;
(...skipping 14 matching lines...) Expand all
1595 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1669 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1596 1670
1597 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1671 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1598 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1672 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1599 } 1673 }
1600 1674
1601 TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) { 1675 TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) {
1602 SchedulerSettings default_scheduler_settings; 1676 SchedulerSettings default_scheduler_settings;
1603 StateMachine state(default_scheduler_settings); 1677 StateMachine state(default_scheduler_settings);
1604 state.SetCanStart(); 1678 state.SetCanStart();
1605 state.UpdateState(state.NextAction()); 1679 EXPECT_ACTION_UPDATE_STATE(
1680 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
1681 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1606 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1682 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1607 state.SetVisible(true); 1683 state.SetVisible(true);
1608 1684
1609 EXPECT_FALSE(state.BeginFrameNeeded()); 1685 EXPECT_FALSE(state.BeginFrameNeeded());
1610 state.SetNeedsRedraw(true); 1686 state.SetNeedsRedraw(true);
1611 EXPECT_TRUE(state.BeginFrameNeeded()); 1687 EXPECT_TRUE(state.BeginFrameNeeded());
1612 1688
1613 state.SetVisible(false); 1689 state.SetVisible(false);
1614 EXPECT_FALSE(state.BeginFrameNeeded()); 1690 EXPECT_FALSE(state.BeginFrameNeeded());
1615 1691
1616 state.SetVisible(true); 1692 state.SetVisible(true);
1617 EXPECT_TRUE(state.BeginFrameNeeded()); 1693 EXPECT_TRUE(state.BeginFrameNeeded());
1618 } 1694 }
1619 1695
1620 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) { 1696 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) {
1621 SchedulerSettings default_scheduler_settings; 1697 SchedulerSettings default_scheduler_settings;
1622 StateMachine state(default_scheduler_settings); 1698 StateMachine state(default_scheduler_settings);
1623 state.SetCanStart(); 1699 state.SetCanStart();
1624 state.UpdateState(state.NextAction()); 1700 EXPECT_ACTION_UPDATE_STATE(
1701 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
1702 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1625 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1703 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1626 state.SetVisible(false); 1704 state.SetVisible(false);
1627 state.SetNeedsBeginMainFrame(); 1705 state.SetNeedsBeginMainFrame();
1628 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1706 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1629 EXPECT_FALSE(state.BeginFrameNeeded()); 1707 EXPECT_FALSE(state.BeginFrameNeeded());
1630 1708
1631 // When become visible again, the needs commit should still be pending. 1709 // When become visible again, the needs commit should still be pending.
1632 state.SetVisible(true); 1710 state.SetVisible(true);
1633 EXPECT_TRUE(state.BeginFrameNeeded()); 1711 EXPECT_TRUE(state.BeginFrameNeeded());
1634 state.OnBeginImplFrame(); 1712 state.OnBeginImplFrame();
1635 EXPECT_ACTION_UPDATE_STATE( 1713 EXPECT_ACTION_UPDATE_STATE(
1636 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1714 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1637 } 1715 }
1638 1716
1639 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) { 1717 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) {
1640 SchedulerSettings default_scheduler_settings; 1718 SchedulerSettings default_scheduler_settings;
1641 StateMachine state(default_scheduler_settings); 1719 StateMachine state(default_scheduler_settings);
1642 state.SetCanStart(); 1720 state.SetCanStart();
1643 state.UpdateState(state.NextAction()); 1721 EXPECT_ACTION_UPDATE_STATE(
1722 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION);
1723 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1644 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1724 state.CreateAndInitializeOutputSurfaceWithActivatedCommit();
1645 state.SetVisible(false); 1725 state.SetVisible(false);
1646 state.SetBeginMainFrameState( 1726 state.SetBeginMainFrameState(
1647 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1727 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1648 state.SetNeedsBeginMainFrame(); 1728 state.SetNeedsBeginMainFrame();
1649 1729
1730 // After the commit completes, activation and draw happen immediately
1731 // because we are not visible.
1650 state.NotifyBeginMainFrameStarted(); 1732 state.NotifyBeginMainFrameStarted();
1651 state.NotifyReadyToCommit(); 1733 state.NotifyReadyToCommit();
1652 EXPECT_ACTION(SchedulerStateMachine::ACTION_COMMIT); 1734 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1653 state.UpdateState(state.NextAction()); 1735 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1654 state.NotifyReadyToActivate();
1655 EXPECT_ACTION(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1656 state.UpdateState(state.NextAction());
1657
1658 EXPECT_TRUE(state.active_tree_needs_first_draw()); 1736 EXPECT_TRUE(state.active_tree_needs_first_draw());
1659 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1737 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1738 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1660 } 1739 }
1661 1740
1662 TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) { 1741 TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) {
1663 SchedulerSettings default_scheduler_settings; 1742 SchedulerSettings default_scheduler_settings;
1664 StateMachine state(default_scheduler_settings); 1743 StateMachine state(default_scheduler_settings);
1665 SET_UP_STATE(state) 1744 SET_UP_STATE(state)
1666 state.SetNeedsBeginMainFrame(); 1745 state.SetNeedsBeginMainFrame();
1667 state.DidLoseOutputSurface(); 1746 state.DidLoseOutputSurface();
1668 1747
1669 // When we are visible, we normally want to begin output surface creation 1748 // When we are visible, we normally want to begin output surface creation
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2054 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1976 } 2055 }
1977 2056
1978 TEST(SchedulerStateMachineTest, EarlyOutCommitWantsProactiveBeginFrame) { 2057 TEST(SchedulerStateMachineTest, EarlyOutCommitWantsProactiveBeginFrame) {
1979 SchedulerSettings settings; 2058 SchedulerSettings settings;
1980 StateMachine state(settings); 2059 StateMachine state(settings);
1981 SET_UP_STATE(state); 2060 SET_UP_STATE(state);
1982 2061
1983 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 2062 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
1984 bool commit_has_no_updates = true; 2063 bool commit_has_no_updates = true;
1985 state.UpdateStateOnCommit(commit_has_no_updates); 2064 state.WillCommit(commit_has_no_updates);
1986 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); 2065 EXPECT_TRUE(state.ProactiveBeginFrameWanted());
1987 state.OnBeginImplFrame(); 2066 state.OnBeginImplFrame();
1988 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 2067 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
1989 } 2068 }
1990 2069
1991 } // namespace 2070 } // namespace
1992 } // namespace cc 2071 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698