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

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

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: android-vulkan Created 4 years, 3 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/scheduler/scheduler_unittest.cc » ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/scheduler/scheduler.h" 10 #include "cc/scheduler/scheduler.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 EXPECT_IMPL_FRAME_STATE( \ 42 EXPECT_IMPL_FRAME_STATE( \
43 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); \ 43 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); \
44 } \ 44 } \
45 PerformAction(&state, action); \ 45 PerformAction(&state, action); \
46 if (action == SchedulerStateMachine::ACTION_NONE) { \ 46 if (action == SchedulerStateMachine::ACTION_NONE) { \
47 if (state.begin_impl_frame_state() == \ 47 if (state.begin_impl_frame_state() == \
48 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \ 48 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) \
49 state.OnBeginImplFrameIdle(); \ 49 state.OnBeginImplFrameIdle(); \
50 } 50 }
51 51
52 #define SET_UP_STATE(state) \ 52 #define SET_UP_STATE(state) \
53 state.SetVisible(true); \ 53 state.SetVisible(true); \
54 EXPECT_ACTION_UPDATE_STATE( \ 54 EXPECT_ACTION_UPDATE_STATE( \
55 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); \ 55 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION); \
56 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); \ 56 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); \
57 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); \ 57 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit(); \
58 state.SetCanDraw(true); 58 state.SetCanDraw(true);
59 59
60 namespace cc { 60 namespace cc {
61 61
62 namespace { 62 namespace {
63 63
64 const SchedulerStateMachine::BeginImplFrameState all_begin_impl_frame_states[] = 64 const SchedulerStateMachine::BeginImplFrameState all_begin_impl_frame_states[] =
65 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE, 65 {SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE,
66 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME, 66 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME,
67 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, }; 67 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, };
68 68
69 const SchedulerStateMachine::BeginMainFrameState begin_main_frame_states[] = { 69 const SchedulerStateMachine::BeginMainFrameState begin_main_frame_states[] = {
70 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE, 70 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE,
71 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT, 71 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT,
72 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED, 72 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED,
73 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT, 73 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT,
74 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION, 74 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION,
75 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW}; 75 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW};
76 76
77 // Exposes the protected state fields of the SchedulerStateMachine for testing 77 // Exposes the protected state fields of the SchedulerStateMachine for testing
78 class StateMachine : public SchedulerStateMachine { 78 class StateMachine : public SchedulerStateMachine {
79 public: 79 public:
80 explicit StateMachine(const SchedulerSettings& scheduler_settings) 80 explicit StateMachine(const SchedulerSettings& scheduler_settings)
81 : SchedulerStateMachine(scheduler_settings), 81 : SchedulerStateMachine(scheduler_settings),
82 draw_result_for_test_(DRAW_SUCCESS) {} 82 draw_result_for_test_(DRAW_SUCCESS) {}
83 83
84 void CreateAndInitializeOutputSurfaceWithActivatedCommit() { 84 void CreateAndInitializeCompositorFrameSinkWithActivatedCommit() {
85 DidCreateAndInitializeOutputSurface(); 85 DidCreateAndInitializeCompositorFrameSink();
86 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; 86 compositor_frame_sink_state_ = COMPOSITOR_FRAME_SINK_ACTIVE;
87 } 87 }
88 88
89 void SetBeginMainFrameState(BeginMainFrameState cs) { 89 void SetBeginMainFrameState(BeginMainFrameState cs) {
90 begin_main_frame_state_ = cs; 90 begin_main_frame_state_ = cs;
91 } 91 }
92 BeginMainFrameState BeginMainFrameState() const { 92 BeginMainFrameState BeginMainFrameState() const {
93 return begin_main_frame_state_; 93 return begin_main_frame_state_;
94 } 94 }
95 95
96 ForcedRedrawOnTimeoutState ForcedRedrawState() const { 96 ForcedRedrawOnTimeoutState ForcedRedrawState() const {
97 return forced_redraw_state_; 97 return forced_redraw_state_;
98 } 98 }
99 99
100 void SetBeginImplFrameState(BeginImplFrameState bifs) { 100 void SetBeginImplFrameState(BeginImplFrameState bifs) {
101 begin_impl_frame_state_ = bifs; 101 begin_impl_frame_state_ = bifs;
102 } 102 }
103 103
104 BeginImplFrameState begin_impl_frame_state() const { 104 BeginImplFrameState begin_impl_frame_state() const {
105 return begin_impl_frame_state_; 105 return begin_impl_frame_state_;
106 } 106 }
107 107
108 OutputSurfaceState output_surface_state() const { 108 CompositorFrameSinkState compositor_frame_sink_state() const {
109 return output_surface_state_; 109 return compositor_frame_sink_state_;
110 } 110 }
111 111
112 void SetNeedsBeginMainFrameForTest(bool needs_begin_main_frame) { 112 void SetNeedsBeginMainFrameForTest(bool needs_begin_main_frame) {
113 needs_begin_main_frame_ = needs_begin_main_frame; 113 needs_begin_main_frame_ = needs_begin_main_frame;
114 } 114 }
115 115
116 bool NeedsCommit() const { return needs_begin_main_frame_; } 116 bool NeedsCommit() const { return needs_begin_main_frame_; }
117 117
118 void SetNeedsOneBeginImplFrame(bool needs_frame) { 118 void SetNeedsOneBeginImplFrame(bool needs_frame) {
119 needs_one_begin_impl_frame_ = needs_frame; 119 needs_one_begin_impl_frame_ = needs_frame;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 sm->WillDraw(); 182 sm->WillDraw();
183 sm->DidDraw(sm->draw_result_for_test()); 183 sm->DidDraw(sm->draw_result_for_test());
184 return; 184 return;
185 } 185 }
186 186
187 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: { 187 case SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT: {
188 sm->AbortDrawAndSwap(); 188 sm->AbortDrawAndSwap();
189 return; 189 return;
190 } 190 }
191 191
192 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION: 192 case SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION:
193 sm->WillBeginOutputSurfaceCreation(); 193 sm->WillBeginCompositorFrameSinkCreation();
194 return; 194 return;
195 195
196 case SchedulerStateMachine::ACTION_PREPARE_TILES: 196 case SchedulerStateMachine::ACTION_PREPARE_TILES:
197 sm->WillPrepareTiles(); 197 sm->WillPrepareTiles();
198 return; 198 return;
199 199
200 case SchedulerStateMachine::ACTION_INVALIDATE_OUTPUT_SURFACE: 200 case SchedulerStateMachine::ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK:
201 sm->WillInvalidateOutputSurface(); 201 sm->WillInvalidateCompositorFrameSink();
202 return; 202 return;
203 } 203 }
204 } 204 }
205 205
206 TEST(SchedulerStateMachineTest, BeginFrameNeeded) { 206 TEST(SchedulerStateMachineTest, BeginFrameNeeded) {
207 SchedulerSettings default_scheduler_settings; 207 SchedulerSettings default_scheduler_settings;
208 StateMachine state(default_scheduler_settings); 208 StateMachine state(default_scheduler_settings);
209 state.SetVisible(true); 209 state.SetVisible(true);
210 EXPECT_ACTION_UPDATE_STATE( 210 EXPECT_ACTION_UPDATE_STATE(
211 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 211 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
212 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 212 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
213 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 213 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
214 state.SetBeginMainFrameState( 214 state.SetBeginMainFrameState(
215 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 215 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
216 216
217 // Don't request BeginFrames if we are idle. 217 // Don't request BeginFrames if we are idle.
218 state.SetNeedsRedraw(false); 218 state.SetNeedsRedraw(false);
219 state.SetNeedsOneBeginImplFrame(false); 219 state.SetNeedsOneBeginImplFrame(false);
220 EXPECT_FALSE(state.BeginFrameNeeded()); 220 EXPECT_FALSE(state.BeginFrameNeeded());
221 221
222 // Request BeginFrames if we one is needed. 222 // Request BeginFrames if we one is needed.
223 state.SetNeedsRedraw(false); 223 state.SetNeedsRedraw(false);
(...skipping 30 matching lines...) Expand all
254 } 254 }
255 255
256 TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) { 256 TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) {
257 SchedulerSettings default_scheduler_settings; 257 SchedulerSettings default_scheduler_settings;
258 258
259 // If no commit needed, do nothing. 259 // If no commit needed, do nothing.
260 { 260 {
261 StateMachine state(default_scheduler_settings); 261 StateMachine state(default_scheduler_settings);
262 state.SetVisible(true); 262 state.SetVisible(true);
263 EXPECT_ACTION_UPDATE_STATE( 263 EXPECT_ACTION_UPDATE_STATE(
264 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 264 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
265 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 265 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
266 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 266 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
267 state.SetBeginMainFrameState( 267 state.SetBeginMainFrameState(
268 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 268 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
269 state.SetNeedsRedraw(false); 269 state.SetNeedsRedraw(false);
270 270
271 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 271 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
272 EXPECT_FALSE(state.NeedsCommit()); 272 EXPECT_FALSE(state.NeedsCommit());
273 273
274 state.OnBeginImplFrame(); 274 state.OnBeginImplFrame();
275 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 275 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
276 276
(...skipping 21 matching lines...) Expand all
298 EXPECT_TRUE(state.NeedsCommit()); 298 EXPECT_TRUE(state.NeedsCommit());
299 } 299 }
300 300
301 // If commit requested, begin a main frame. 301 // If commit requested, begin a main frame.
302 { 302 {
303 StateMachine state(default_scheduler_settings); 303 StateMachine state(default_scheduler_settings);
304 state.SetBeginMainFrameState( 304 state.SetBeginMainFrameState(
305 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 305 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
306 state.SetVisible(true); 306 state.SetVisible(true);
307 EXPECT_ACTION_UPDATE_STATE( 307 EXPECT_ACTION_UPDATE_STATE(
308 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 308 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
309 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 309 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
310 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 310 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
311 state.SetNeedsRedraw(false); 311 state.SetNeedsRedraw(false);
312 state.SetNeedsBeginMainFrame(); 312 state.SetNeedsBeginMainFrame();
313 313
314 // Expect nothing to happen until after OnBeginImplFrame. 314 // Expect nothing to happen until after OnBeginImplFrame.
315 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 315 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
316 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 316 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
317 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 317 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
318 EXPECT_TRUE(state.NeedsCommit()); 318 EXPECT_TRUE(state.NeedsCommit());
319 EXPECT_TRUE(state.BeginFrameNeeded()); 319 EXPECT_TRUE(state.BeginFrameNeeded());
320 320
321 state.OnBeginImplFrame(); 321 state.OnBeginImplFrame();
322 EXPECT_ACTION_UPDATE_STATE( 322 EXPECT_ACTION_UPDATE_STATE(
323 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 323 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
324 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 324 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
325 EXPECT_FALSE(state.NeedsCommit()); 325 EXPECT_FALSE(state.NeedsCommit());
326 } 326 }
327 327
328 // If commit requested and can't draw, still begin a main frame. 328 // If commit requested and can't draw, still begin a main frame.
329 { 329 {
330 StateMachine state(default_scheduler_settings); 330 StateMachine state(default_scheduler_settings);
331 state.SetBeginMainFrameState( 331 state.SetBeginMainFrameState(
332 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 332 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
333 state.SetVisible(true); 333 state.SetVisible(true);
334 EXPECT_ACTION_UPDATE_STATE( 334 EXPECT_ACTION_UPDATE_STATE(
335 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 335 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
336 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 336 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
337 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 337 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
338 state.SetNeedsRedraw(false); 338 state.SetNeedsRedraw(false);
339 state.SetNeedsBeginMainFrame(); 339 state.SetNeedsBeginMainFrame();
340 state.SetCanDraw(false); 340 state.SetCanDraw(false);
341 341
342 // Expect nothing to happen until after OnBeginImplFrame. 342 // Expect nothing to happen until after OnBeginImplFrame.
343 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 343 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
344 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE); 344 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_IDLE);
345 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 345 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
346 EXPECT_TRUE(state.BeginFrameNeeded()); 346 EXPECT_TRUE(state.BeginFrameNeeded());
347 347
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 sizeof(begin_main_frame_states) / 713 sizeof(begin_main_frame_states) /
714 sizeof(SchedulerStateMachine::BeginMainFrameState); 714 sizeof(SchedulerStateMachine::BeginMainFrameState);
715 size_t num_begin_impl_frame_states = 715 size_t num_begin_impl_frame_states =
716 sizeof(all_begin_impl_frame_states) / 716 sizeof(all_begin_impl_frame_states) /
717 sizeof(SchedulerStateMachine::BeginImplFrameState); 717 sizeof(SchedulerStateMachine::BeginImplFrameState);
718 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 718 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
719 for (size_t j = 0; j < num_begin_impl_frame_states; ++j) { 719 for (size_t j = 0; j < num_begin_impl_frame_states; ++j) {
720 StateMachine state(default_scheduler_settings); 720 StateMachine state(default_scheduler_settings);
721 state.SetVisible(true); 721 state.SetVisible(true);
722 EXPECT_ACTION_UPDATE_STATE( 722 EXPECT_ACTION_UPDATE_STATE(
723 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 723 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
724 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 724 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
725 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 725 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
726 state.SetBeginMainFrameState(begin_main_frame_states[i]); 726 state.SetBeginMainFrameState(begin_main_frame_states[i]);
727 state.SetBeginImplFrameState(all_begin_impl_frame_states[j]); 727 state.SetBeginImplFrameState(all_begin_impl_frame_states[j]);
728 bool visible = 728 bool visible =
729 (all_begin_impl_frame_states[j] != 729 (all_begin_impl_frame_states[j] !=
730 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 730 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
731 state.SetVisible(visible); 731 state.SetVisible(visible);
732 732
733 // Case 1: needs_begin_main_frame=false 733 // Case 1: needs_begin_main_frame=false
734 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 734 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
735 state.NextAction()); 735 state.NextAction());
736 736
737 // Case 2: needs_begin_main_frame=true 737 // Case 2: needs_begin_main_frame=true
738 state.SetNeedsBeginMainFrame(); 738 state.SetNeedsBeginMainFrame();
739 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 739 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
740 state.NextAction()) 740 state.NextAction())
741 << state.AsValue()->ToString(); 741 << state.AsValue()->ToString();
742 } 742 }
743 } 743 }
744 744
745 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw 745 // When in BeginImplFrame deadline we should always draw for SetNeedsRedraw
746 // except if we're ready to commit, in which case we expect a commit first. 746 // except if we're ready to commit, in which case we expect a commit first.
747 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 747 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
748 StateMachine state(default_scheduler_settings); 748 StateMachine state(default_scheduler_settings);
749 state.SetVisible(true); 749 state.SetVisible(true);
750 EXPECT_ACTION_UPDATE_STATE( 750 EXPECT_ACTION_UPDATE_STATE(
751 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 751 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
752 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 752 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
753 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 753 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
754 state.SetCanDraw(true); 754 state.SetCanDraw(true);
755 state.SetBeginMainFrameState(begin_main_frame_states[i]); 755 state.SetBeginMainFrameState(begin_main_frame_states[i]);
756 state.SetBeginImplFrameState( 756 state.SetBeginImplFrameState(
757 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 757 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
758 758
759 state.SetNeedsRedraw(true); 759 state.SetNeedsRedraw(true);
760 760
761 SchedulerStateMachine::Action expected_action; 761 SchedulerStateMachine::Action expected_action;
762 if (begin_main_frame_states[i] == 762 if (begin_main_frame_states[i] ==
763 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) { 763 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_READY_TO_COMMIT) {
(...skipping 16 matching lines...) Expand all
780 780
781 size_t num_begin_main_frame_states = 781 size_t num_begin_main_frame_states =
782 sizeof(begin_main_frame_states) / 782 sizeof(begin_main_frame_states) /
783 sizeof(SchedulerStateMachine::BeginMainFrameState); 783 sizeof(SchedulerStateMachine::BeginMainFrameState);
784 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 784 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
785 // There shouldn't be any drawing regardless of BeginImplFrame. 785 // There shouldn't be any drawing regardless of BeginImplFrame.
786 for (size_t j = 0; j < 2; ++j) { 786 for (size_t j = 0; j < 2; ++j) {
787 StateMachine state(default_scheduler_settings); 787 StateMachine state(default_scheduler_settings);
788 state.SetVisible(true); 788 state.SetVisible(true);
789 EXPECT_ACTION_UPDATE_STATE( 789 EXPECT_ACTION_UPDATE_STATE(
790 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 790 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
791 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 791 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
792 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 792 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
793 state.SetBeginMainFrameState(begin_main_frame_states[i]); 793 state.SetBeginMainFrameState(begin_main_frame_states[i]);
794 state.SetVisible(false); 794 state.SetVisible(false);
795 state.SetNeedsRedraw(true); 795 state.SetNeedsRedraw(true);
796 if (j == 1) { 796 if (j == 1) {
797 state.SetBeginImplFrameState( 797 state.SetBeginImplFrameState(
798 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 798 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
799 } 799 }
800 800
801 // Case 1: needs_begin_main_frame=false. 801 // Case 1: needs_begin_main_frame=false.
802 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 802 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
(...skipping 13 matching lines...) Expand all
816 816
817 size_t num_begin_main_frame_states = 817 size_t num_begin_main_frame_states =
818 sizeof(begin_main_frame_states) / 818 sizeof(begin_main_frame_states) /
819 sizeof(SchedulerStateMachine::BeginMainFrameState); 819 sizeof(SchedulerStateMachine::BeginMainFrameState);
820 for (size_t i = 0; i < num_begin_main_frame_states; ++i) { 820 for (size_t i = 0; i < num_begin_main_frame_states; ++i) {
821 // There shouldn't be any drawing regardless of BeginImplFrame. 821 // There shouldn't be any drawing regardless of BeginImplFrame.
822 for (size_t j = 0; j < 2; ++j) { 822 for (size_t j = 0; j < 2; ++j) {
823 StateMachine state(default_scheduler_settings); 823 StateMachine state(default_scheduler_settings);
824 state.SetVisible(true); 824 state.SetVisible(true);
825 EXPECT_ACTION_UPDATE_STATE( 825 EXPECT_ACTION_UPDATE_STATE(
826 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 826 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
827 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 827 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
828 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 828 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
829 state.SetBeginMainFrameState(begin_main_frame_states[i]); 829 state.SetBeginMainFrameState(begin_main_frame_states[i]);
830 state.SetVisible(false); 830 state.SetVisible(false);
831 state.SetNeedsRedraw(true); 831 state.SetNeedsRedraw(true);
832 if (j == 1) 832 if (j == 1)
833 state.OnBeginImplFrame(); 833 state.OnBeginImplFrame();
834 834
835 state.SetCanDraw(false); 835 state.SetCanDraw(false);
836 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 836 EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
837 state.NextAction()); 837 state.NextAction());
838 } 838 }
839 } 839 }
840 } 840 }
841 841
842 TEST(SchedulerStateMachineTest, 842 TEST(SchedulerStateMachineTest,
843 TestCanRedrawWithWaitingForFirstDrawMakesProgress) { 843 TestCanRedrawWithWaitingForFirstDrawMakesProgress) {
844 SchedulerSettings default_scheduler_settings; 844 SchedulerSettings default_scheduler_settings;
845 StateMachine state(default_scheduler_settings); 845 StateMachine state(default_scheduler_settings);
846 state.SetVisible(true); 846 state.SetVisible(true);
847 EXPECT_ACTION_UPDATE_STATE( 847 EXPECT_ACTION_UPDATE_STATE(
848 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 848 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
849 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 849 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
850 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 850 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
851 851
852 state.SetActiveTreeNeedsFirstDraw(true); 852 state.SetActiveTreeNeedsFirstDraw(true);
853 state.SetNeedsBeginMainFrame(); 853 state.SetNeedsBeginMainFrame();
854 state.SetNeedsRedraw(true); 854 state.SetNeedsRedraw(true);
855 state.SetCanDraw(false); 855 state.SetCanDraw(false);
856 state.OnBeginImplFrame(); 856 state.OnBeginImplFrame();
857 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 857 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
858 EXPECT_ACTION_UPDATE_STATE( 858 EXPECT_ACTION_UPDATE_STATE(
859 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 859 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
860 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 860 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 state.OnBeginImplFrame(); 1220 state.OnBeginImplFrame();
1221 EXPECT_ACTION_UPDATE_STATE( 1221 EXPECT_ACTION_UPDATE_STATE(
1222 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1222 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1223 } 1223 }
1224 1224
1225 TEST(SchedulerStateMachineTest, TestNoRequestCommitWhenInvisible) { 1225 TEST(SchedulerStateMachineTest, TestNoRequestCommitWhenInvisible) {
1226 SchedulerSettings default_scheduler_settings; 1226 SchedulerSettings default_scheduler_settings;
1227 StateMachine state(default_scheduler_settings); 1227 StateMachine state(default_scheduler_settings);
1228 state.SetVisible(true); 1228 state.SetVisible(true);
1229 EXPECT_ACTION_UPDATE_STATE( 1229 EXPECT_ACTION_UPDATE_STATE(
1230 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1230 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1231 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1231 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1232 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1232 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1233 state.SetVisible(false); 1233 state.SetVisible(false);
1234 state.SetNeedsBeginMainFrame(); 1234 state.SetNeedsBeginMainFrame();
1235 EXPECT_FALSE(state.CouldSendBeginMainFrame()); 1235 EXPECT_FALSE(state.CouldSendBeginMainFrame());
1236 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1236 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1237 } 1237 }
1238 1238
1239 TEST(SchedulerStateMachineTest, TestNoRequestCommitWhenBeginFrameSourcePaused) { 1239 TEST(SchedulerStateMachineTest, TestNoRequestCommitWhenBeginFrameSourcePaused) {
1240 SchedulerSettings default_scheduler_settings; 1240 SchedulerSettings default_scheduler_settings;
1241 StateMachine state(default_scheduler_settings); 1241 StateMachine state(default_scheduler_settings);
1242 state.SetVisible(true); 1242 state.SetVisible(true);
1243 EXPECT_ACTION_UPDATE_STATE( 1243 EXPECT_ACTION_UPDATE_STATE(
1244 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1244 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1245 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1245 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1246 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1246 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1247 state.SetBeginFrameSourcePaused(true); 1247 state.SetBeginFrameSourcePaused(true);
1248 state.SetNeedsBeginMainFrame(); 1248 state.SetNeedsBeginMainFrame();
1249 EXPECT_FALSE(state.CouldSendBeginMainFrame()); 1249 EXPECT_FALSE(state.CouldSendBeginMainFrame());
1250 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1250 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1251 } 1251 }
1252 1252
1253 TEST(SchedulerStateMachineTest, TestNoRequestOutputSurfaceWhenInvisible) { 1253 TEST(SchedulerStateMachineTest, TestNoRequestCompositorFrameSinkWhenInvisible) {
1254 SchedulerSettings default_scheduler_settings; 1254 SchedulerSettings default_scheduler_settings;
1255 StateMachine state(default_scheduler_settings); 1255 StateMachine state(default_scheduler_settings);
1256 // We should not request an OutputSurface when we are still invisible. 1256 // We should not request an CompositorFrameSink when we are still invisible.
1257 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1257 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1258 state.SetVisible(true); 1258 state.SetVisible(true);
1259 EXPECT_ACTION_UPDATE_STATE( 1259 EXPECT_ACTION_UPDATE_STATE(
1260 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1260 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1261 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1261 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1262 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1262 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1263 state.SetVisible(false); 1263 state.SetVisible(false);
1264 state.DidLoseOutputSurface(); 1264 state.DidLoseCompositorFrameSink();
1265 state.SetNeedsBeginMainFrame(); 1265 state.SetNeedsBeginMainFrame();
1266 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1266 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1267 state.SetVisible(true); 1267 state.SetVisible(true);
1268 EXPECT_ACTION_UPDATE_STATE( 1268 EXPECT_ACTION_UPDATE_STATE(
1269 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1269 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1270 } 1270 }
1271 1271
1272 // See ProxyMain::BeginMainFrame "EarlyOut_NotVisible" / 1272 // See ProxyMain::BeginMainFrame "EarlyOut_NotVisible" /
1273 // "EarlyOut_OutputSurfaceLost" cases. 1273 // "EarlyOut_CompositorFrameSinkLost" cases.
1274 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseInvisible) { 1274 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseInvisible) {
1275 SchedulerSettings default_scheduler_settings; 1275 SchedulerSettings default_scheduler_settings;
1276 StateMachine state(default_scheduler_settings); 1276 StateMachine state(default_scheduler_settings);
1277 SET_UP_STATE(state) 1277 SET_UP_STATE(state)
1278 1278
1279 // Start clean and set commit. 1279 // Start clean and set commit.
1280 state.SetNeedsBeginMainFrame(); 1280 state.SetNeedsBeginMainFrame();
1281 1281
1282 // Begin the frame while visible. 1282 // Begin the frame while visible.
1283 state.OnBeginImplFrame(); 1283 state.OnBeginImplFrame();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1322 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1323 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1323 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1324 } 1324 }
1325 1325
1326 // See ProxyMain::BeginMainFrame "EarlyOut_NoUpdates" case. 1326 // See ProxyMain::BeginMainFrame "EarlyOut_NoUpdates" case.
1327 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseCommitNotNeeded) { 1327 TEST(SchedulerStateMachineTest, TestAbortBeginMainFrameBecauseCommitNotNeeded) {
1328 SchedulerSettings default_scheduler_settings; 1328 SchedulerSettings default_scheduler_settings;
1329 StateMachine state(default_scheduler_settings); 1329 StateMachine state(default_scheduler_settings);
1330 state.SetVisible(true); 1330 state.SetVisible(true);
1331 EXPECT_ACTION_UPDATE_STATE( 1331 EXPECT_ACTION_UPDATE_STATE(
1332 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1332 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1333 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1333 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1334 state.DidCreateAndInitializeOutputSurface(); 1334 state.DidCreateAndInitializeCompositorFrameSink();
1335 state.SetCanDraw(true); 1335 state.SetCanDraw(true);
1336 1336
1337 // Get into a begin frame / commit state. 1337 // Get into a begin frame / commit state.
1338 state.SetNeedsBeginMainFrame(); 1338 state.SetNeedsBeginMainFrame();
1339 state.OnBeginImplFrame(); 1339 state.OnBeginImplFrame();
1340 EXPECT_ACTION_UPDATE_STATE( 1340 EXPECT_ACTION_UPDATE_STATE(
1341 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1341 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1342 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1342 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1343 EXPECT_FALSE(state.NeedsCommit()); 1343 EXPECT_FALSE(state.NeedsCommit());
1344 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1344 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
(...skipping 27 matching lines...) Expand all
1372 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1372 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1373 } 1373 }
1374 1374
1375 TEST(SchedulerStateMachineTest, TestFirstContextCreation) { 1375 TEST(SchedulerStateMachineTest, TestFirstContextCreation) {
1376 SchedulerSettings default_scheduler_settings; 1376 SchedulerSettings default_scheduler_settings;
1377 StateMachine state(default_scheduler_settings); 1377 StateMachine state(default_scheduler_settings);
1378 state.SetVisible(true); 1378 state.SetVisible(true);
1379 state.SetCanDraw(true); 1379 state.SetCanDraw(true);
1380 1380
1381 EXPECT_ACTION_UPDATE_STATE( 1381 EXPECT_ACTION_UPDATE_STATE(
1382 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1382 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1383 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1383 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1384 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1384 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1385 1385
1386 // Check that the first init does not SetNeedsBeginMainFrame. 1386 // Check that the first init does not SetNeedsBeginMainFrame.
1387 state.OnBeginImplFrame(); 1387 state.OnBeginImplFrame();
1388 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1388 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1389 state.OnBeginImplFrameDeadline(); 1389 state.OnBeginImplFrameDeadline();
1390 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1390 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1391 1391
1392 // Check that a needs commit initiates a BeginMainFrame. 1392 // Check that a needs commit initiates a BeginMainFrame.
1393 state.SetNeedsBeginMainFrame(); 1393 state.SetNeedsBeginMainFrame();
1394 state.OnBeginImplFrame(); 1394 state.OnBeginImplFrame();
1395 EXPECT_ACTION_UPDATE_STATE( 1395 EXPECT_ACTION_UPDATE_STATE(
1396 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1396 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1397 } 1397 }
1398 1398
1399 TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) { 1399 TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) {
1400 SchedulerSettings default_scheduler_settings; 1400 SchedulerSettings default_scheduler_settings;
1401 StateMachine state(default_scheduler_settings); 1401 StateMachine state(default_scheduler_settings);
1402 SET_UP_STATE(state) 1402 SET_UP_STATE(state)
1403 1403
1404 EXPECT_NE(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 1404 EXPECT_NE(SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION,
1405 state.NextAction()); 1405 state.NextAction());
1406 state.DidLoseOutputSurface(); 1406 state.DidLoseCompositorFrameSink();
1407 1407
1408 EXPECT_ACTION_UPDATE_STATE( 1408 EXPECT_ACTION_UPDATE_STATE(
1409 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1409 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1410 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1410 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1411 1411
1412 // Once context recreation begins, nothing should happen. 1412 // Once context recreation begins, nothing should happen.
1413 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1413 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1414 1414
1415 // Recreate the context. 1415 // Recreate the context.
1416 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1416 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1417 1417
1418 // When the context is recreated, we should begin a commit. 1418 // When the context is recreated, we should begin a commit.
1419 state.OnBeginImplFrame(); 1419 state.OnBeginImplFrame();
1420 EXPECT_ACTION_UPDATE_STATE( 1420 EXPECT_ACTION_UPDATE_STATE(
1421 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1421 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1422 } 1422 }
1423 1423
1424 TEST(SchedulerStateMachineTest, 1424 TEST(SchedulerStateMachineTest,
1425 TestContextLostWhenIdleAndCommitRequestedWhileRecreating) { 1425 TestContextLostWhenIdleAndCommitRequestedWhileRecreating) {
1426 SchedulerSettings default_scheduler_settings; 1426 SchedulerSettings default_scheduler_settings;
1427 StateMachine state(default_scheduler_settings); 1427 StateMachine state(default_scheduler_settings);
1428 SET_UP_STATE(state) 1428 SET_UP_STATE(state)
1429 1429
1430 EXPECT_NE(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 1430 EXPECT_NE(SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION,
1431 state.NextAction()); 1431 state.NextAction());
1432 state.DidLoseOutputSurface(); 1432 state.DidLoseCompositorFrameSink();
1433 EXPECT_EQ(state.output_surface_state(), 1433 EXPECT_EQ(state.compositor_frame_sink_state(),
1434 SchedulerStateMachine::OUTPUT_SURFACE_NONE); 1434 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_NONE);
1435 1435
1436 EXPECT_ACTION_UPDATE_STATE( 1436 EXPECT_ACTION_UPDATE_STATE(
1437 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1437 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1438 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1438 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1439 1439
1440 // Once context recreation begins, nothing should happen. 1440 // Once context recreation begins, nothing should happen.
1441 state.OnBeginImplFrame(); 1441 state.OnBeginImplFrame();
1442 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1442 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1443 state.OnBeginImplFrameDeadline(); 1443 state.OnBeginImplFrameDeadline();
1444 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1444 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1445 1445
1446 // While context is recreating, commits shouldn't begin. 1446 // While context is recreating, commits shouldn't begin.
1447 state.SetNeedsBeginMainFrame(); 1447 state.SetNeedsBeginMainFrame();
1448 state.OnBeginImplFrame(); 1448 state.OnBeginImplFrame();
1449 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1449 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1450 state.OnBeginImplFrameDeadline(); 1450 state.OnBeginImplFrameDeadline();
1451 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1451 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1452 1452
1453 // Recreate the context 1453 // Recreate the context
1454 state.DidCreateAndInitializeOutputSurface(); 1454 state.DidCreateAndInitializeCompositorFrameSink();
1455 EXPECT_EQ(state.output_surface_state(), 1455 EXPECT_EQ(
1456 SchedulerStateMachine::OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT); 1456 state.compositor_frame_sink_state(),
1457 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT);
1457 EXPECT_FALSE(state.RedrawPending()); 1458 EXPECT_FALSE(state.RedrawPending());
1458 1459
1459 // When the context is recreated, we wait until the next BeginImplFrame 1460 // When the context is recreated, we wait until the next BeginImplFrame
1460 // before starting. 1461 // before starting.
1461 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1462 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1462 1463
1463 // When the BeginFrame comes in we should begin a commit 1464 // When the BeginFrame comes in we should begin a commit
1464 state.OnBeginImplFrame(); 1465 state.OnBeginImplFrame();
1465 EXPECT_ACTION_UPDATE_STATE( 1466 EXPECT_ACTION_UPDATE_STATE(
1466 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1467 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1467 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1468 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1468 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1469 EXPECT_MAIN_FRAME_STATE(SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1469 1470
1470 // Until that commit finishes, we shouldn't be drawing. 1471 // Until that commit finishes, we shouldn't be drawing.
1471 state.OnBeginImplFrameDeadline(); 1472 state.OnBeginImplFrameDeadline();
1472 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1473 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1473 1474
1474 // Finish the commit, which should make the surface active. 1475 // Finish the commit, which should make the surface active.
1475 state.NotifyBeginMainFrameStarted(); 1476 state.NotifyBeginMainFrameStarted();
1476 state.NotifyReadyToCommit(); 1477 state.NotifyReadyToCommit();
1477 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1478 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1478 EXPECT_EQ(state.output_surface_state(), 1479 EXPECT_EQ(state.compositor_frame_sink_state(),
1479 SchedulerStateMachine::OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION); 1480 SchedulerStateMachine::
1481 COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_ACTIVATION);
1480 state.NotifyReadyToActivate(); 1482 state.NotifyReadyToActivate();
1481 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1483 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1482 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1484 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1483 EXPECT_EQ(state.output_surface_state(), 1485 EXPECT_EQ(state.compositor_frame_sink_state(),
1484 SchedulerStateMachine::OUTPUT_SURFACE_ACTIVE); 1486 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_ACTIVE);
1485 1487
1486 // Finishing the first commit after initializing an output surface should 1488 // Finishing the first commit after initializing an CompositorFrameSink should
1487 // automatically cause a redraw. 1489 // automatically cause a redraw.
1488 EXPECT_TRUE(state.RedrawPending()); 1490 EXPECT_TRUE(state.RedrawPending());
1489 state.OnBeginImplFrame(); 1491 state.OnBeginImplFrame();
1490 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1492 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1491 state.OnBeginImplFrameDeadline(); 1493 state.OnBeginImplFrameDeadline();
1492 EXPECT_ACTION_UPDATE_STATE( 1494 EXPECT_ACTION_UPDATE_STATE(
1493 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 1495 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1494 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1496 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1495 EXPECT_FALSE(state.RedrawPending()); 1497 EXPECT_FALSE(state.RedrawPending());
1496 1498
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1557 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1556 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1558 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1557 state.OnBeginImplFrameDeadline(); 1559 state.OnBeginImplFrameDeadline();
1558 EXPECT_ACTION_UPDATE_STATE( 1560 EXPECT_ACTION_UPDATE_STATE(
1559 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 1561 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1560 state.DidSwapBuffers(); 1562 state.DidSwapBuffers();
1561 state.DidSwapBuffersComplete(); 1563 state.DidSwapBuffersComplete();
1562 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1564 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1563 1565
1564 // Cause a lost context while the BeginMainFrame is in flight. 1566 // Cause a lost context while the BeginMainFrame is in flight.
1565 state.DidLoseOutputSurface(); 1567 state.DidLoseCompositorFrameSink();
1566 1568
1567 // Ask for another draw. Expect nothing happens. 1569 // Ask for another draw. Expect nothing happens.
1568 state.SetNeedsRedraw(true); 1570 state.SetNeedsRedraw(true);
1569 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1571 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1570 1572
1571 // Finish the frame, commit and activate. 1573 // Finish the frame, commit and activate.
1572 state.NotifyBeginMainFrameStarted(); 1574 state.NotifyBeginMainFrameStarted();
1573 state.NotifyReadyToCommit(); 1575 state.NotifyReadyToCommit();
1574 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1576 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1575 state.NotifyReadyToActivate(); 1577 state.NotifyReadyToActivate();
1576 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1578 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1577 1579
1578 // We will abort the draw when the output surface is lost if we are 1580 // We will abort the draw when the CompositorFrameSink is lost if we are
1579 // waiting for the first draw to unblock the main thread. 1581 // waiting for the first draw to unblock the main thread.
1580 EXPECT_TRUE(state.active_tree_needs_first_draw()); 1582 EXPECT_TRUE(state.active_tree_needs_first_draw());
1581 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1583 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1582 1584
1583 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE 1585 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE
1584 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 1586 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
1585 EXPECT_ACTION(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1587 EXPECT_ACTION(
1588 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1586 1589
1587 state.OnBeginImplFrame(); 1590 state.OnBeginImplFrame();
1588 EXPECT_IMPL_FRAME_STATE( 1591 EXPECT_IMPL_FRAME_STATE(
1589 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME); 1592 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME);
1590 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1593 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1591 1594
1592 state.OnBeginImplFrameDeadline(); 1595 state.OnBeginImplFrameDeadline();
1593 EXPECT_IMPL_FRAME_STATE( 1596 EXPECT_IMPL_FRAME_STATE(
1594 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 1597 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
1595 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1598 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
(...skipping 16 matching lines...) Expand all
1612 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1615 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1613 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1616 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1614 state.OnBeginImplFrameDeadline(); 1617 state.OnBeginImplFrameDeadline();
1615 EXPECT_ACTION_UPDATE_STATE( 1618 EXPECT_ACTION_UPDATE_STATE(
1616 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 1619 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1617 state.DidSwapBuffers(); 1620 state.DidSwapBuffers();
1618 state.DidSwapBuffersComplete(); 1621 state.DidSwapBuffersComplete();
1619 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1622 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1620 1623
1621 // Cause a lost context while the BeginMainFrame is in flight. 1624 // Cause a lost context while the BeginMainFrame is in flight.
1622 state.DidLoseOutputSurface(); 1625 state.DidLoseCompositorFrameSink();
1623 1626
1624 // Ask for another draw and also set needs commit. Expect nothing happens. 1627 // Ask for another draw and also set needs commit. Expect nothing happens.
1625 state.SetNeedsRedraw(true); 1628 state.SetNeedsRedraw(true);
1626 state.SetNeedsBeginMainFrame(); 1629 state.SetNeedsBeginMainFrame();
1627 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1630 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1628 1631
1629 // Finish the frame, and commit and activate. 1632 // Finish the frame, and commit and activate.
1630 state.NotifyBeginMainFrameStarted(); 1633 state.NotifyBeginMainFrameStarted();
1631 state.NotifyReadyToCommit(); 1634 state.NotifyReadyToCommit();
1632 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1635 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1633 state.NotifyReadyToActivate(); 1636 state.NotifyReadyToActivate();
1634 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1637 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1635 EXPECT_TRUE(state.active_tree_needs_first_draw()); 1638 EXPECT_TRUE(state.active_tree_needs_first_draw());
1636 1639
1637 // Because the output surface is missing, we expect the draw to abort. 1640 // Because the CompositorFrameSink is missing, we expect the draw to abort.
1638 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1641 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1639 1642
1640 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE 1643 // Expect to begin context recreation only in BEGIN_IMPL_FRAME_STATE_IDLE
1641 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 1644 EXPECT_IMPL_FRAME_STATE(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
1642 EXPECT_ACTION(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1645 EXPECT_ACTION(
1646 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1643 1647
1644 state.OnBeginImplFrame(); 1648 state.OnBeginImplFrame();
1645 EXPECT_IMPL_FRAME_STATE( 1649 EXPECT_IMPL_FRAME_STATE(
1646 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME); 1650 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME);
1647 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1651 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1648 1652
1649 state.OnBeginImplFrameDeadline(); 1653 state.OnBeginImplFrameDeadline();
1650 EXPECT_IMPL_FRAME_STATE( 1654 EXPECT_IMPL_FRAME_STATE(
1651 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE); 1655 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE);
1652 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1656 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1653 1657
1654 state.OnBeginImplFrameIdle(); 1658 state.OnBeginImplFrameIdle();
1655 EXPECT_ACTION_UPDATE_STATE( 1659 EXPECT_ACTION_UPDATE_STATE(
1656 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1660 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1657 1661
1658 // After we get a new output surface, the commit flow should start. 1662 // After we get a new CompositorFrameSink, the commit flow should start.
1659 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1663 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1660 state.OnBeginImplFrame(); 1664 state.OnBeginImplFrame();
1661 EXPECT_ACTION_UPDATE_STATE( 1665 EXPECT_ACTION_UPDATE_STATE(
1662 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1666 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1663 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1667 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1664 state.NotifyBeginMainFrameStarted(); 1668 state.NotifyBeginMainFrameStarted();
1665 state.NotifyReadyToCommit(); 1669 state.NotifyReadyToCommit();
1666 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1670 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1667 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1671 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1668 state.NotifyReadyToActivate(); 1672 state.NotifyReadyToActivate();
1669 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1673 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1670 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1674 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1671 state.OnBeginImplFrameDeadline(); 1675 state.OnBeginImplFrameDeadline();
1672 EXPECT_ACTION_UPDATE_STATE( 1676 EXPECT_ACTION_UPDATE_STATE(
1673 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); 1677 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE);
1674 state.DidSwapBuffers(); 1678 state.DidSwapBuffers();
1675 state.DidSwapBuffersComplete(); 1679 state.DidSwapBuffersComplete();
1676 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1680 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1677 } 1681 }
1678 1682
1679 TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) { 1683 TEST(SchedulerStateMachineTest,
1684 DontDrawBeforeCommitAfterLostCompositorFrameSink) {
1680 SchedulerSettings default_scheduler_settings; 1685 SchedulerSettings default_scheduler_settings;
1681 StateMachine state(default_scheduler_settings); 1686 StateMachine state(default_scheduler_settings);
1682 SET_UP_STATE(state) 1687 SET_UP_STATE(state)
1683 1688
1684 state.SetNeedsRedraw(true); 1689 state.SetNeedsRedraw(true);
1685 1690
1686 // Cause a lost output surface, and restore it. 1691 // Cause a lost CompositorFrameSink, and restore it.
1687 state.DidLoseOutputSurface(); 1692 state.DidLoseCompositorFrameSink();
1688 EXPECT_ACTION_UPDATE_STATE( 1693 EXPECT_ACTION_UPDATE_STATE(
1689 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1694 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1690 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1695 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1691 state.DidCreateAndInitializeOutputSurface(); 1696 state.DidCreateAndInitializeCompositorFrameSink();
1692 1697
1693 EXPECT_FALSE(state.RedrawPending()); 1698 EXPECT_FALSE(state.RedrawPending());
1694 state.OnBeginImplFrame(); 1699 state.OnBeginImplFrame();
1695 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1700 EXPECT_ACTION(SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1696 } 1701 }
1697 1702
1698 TEST(SchedulerStateMachineTest, 1703 TEST(SchedulerStateMachineTest,
1699 TestPendingActivationsShouldBeForcedAfterLostOutputSurface) { 1704 TestPendingActivationsShouldBeForcedAfterLostCompositorFrameSink) {
1700 SchedulerSettings default_scheduler_settings; 1705 SchedulerSettings default_scheduler_settings;
1701 StateMachine state(default_scheduler_settings); 1706 StateMachine state(default_scheduler_settings);
1702 SET_UP_STATE(state) 1707 SET_UP_STATE(state)
1703 1708
1704 state.SetBeginMainFrameState( 1709 state.SetBeginMainFrameState(
1705 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1710 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1706 1711
1707 // Cause a lost context. 1712 // Cause a lost context.
1708 state.DidLoseOutputSurface(); 1713 state.DidLoseCompositorFrameSink();
1709 1714
1710 state.NotifyBeginMainFrameStarted(); 1715 state.NotifyBeginMainFrameStarted();
1711 state.NotifyReadyToCommit(); 1716 state.NotifyReadyToCommit();
1712 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1717 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1713 1718
1714 EXPECT_TRUE(state.PendingActivationsShouldBeForced()); 1719 EXPECT_TRUE(state.PendingActivationsShouldBeForced());
1715 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1720 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1716 1721
1717 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1722 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1718 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1723 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1719 } 1724 }
1720 1725
1721 TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) { 1726 TEST(SchedulerStateMachineTest, TestNoBeginFrameNeededWhenInvisible) {
1722 SchedulerSettings default_scheduler_settings; 1727 SchedulerSettings default_scheduler_settings;
1723 StateMachine state(default_scheduler_settings); 1728 StateMachine state(default_scheduler_settings);
1724 state.SetVisible(true); 1729 state.SetVisible(true);
1725 EXPECT_ACTION_UPDATE_STATE( 1730 EXPECT_ACTION_UPDATE_STATE(
1726 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1731 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1727 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1732 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1728 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1733 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1729 1734
1730 EXPECT_FALSE(state.BeginFrameNeeded()); 1735 EXPECT_FALSE(state.BeginFrameNeeded());
1731 state.SetNeedsRedraw(true); 1736 state.SetNeedsRedraw(true);
1732 EXPECT_TRUE(state.BeginFrameNeeded()); 1737 EXPECT_TRUE(state.BeginFrameNeeded());
1733 1738
1734 state.SetVisible(false); 1739 state.SetVisible(false);
1735 EXPECT_FALSE(state.BeginFrameNeeded()); 1740 EXPECT_FALSE(state.BeginFrameNeeded());
1736 1741
1737 state.SetVisible(true); 1742 state.SetVisible(true);
1738 EXPECT_TRUE(state.BeginFrameNeeded()); 1743 EXPECT_TRUE(state.BeginFrameNeeded());
1739 } 1744 }
1740 1745
1741 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) { 1746 TEST(SchedulerStateMachineTest, TestNoBeginMainFrameWhenInvisible) {
1742 SchedulerSettings default_scheduler_settings; 1747 SchedulerSettings default_scheduler_settings;
1743 StateMachine state(default_scheduler_settings); 1748 StateMachine state(default_scheduler_settings);
1744 state.SetVisible(true); 1749 state.SetVisible(true);
1745 EXPECT_ACTION_UPDATE_STATE( 1750 EXPECT_ACTION_UPDATE_STATE(
1746 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1751 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1747 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1752 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1748 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1753 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1749 state.SetVisible(false); 1754 state.SetVisible(false);
1750 state.SetNeedsBeginMainFrame(); 1755 state.SetNeedsBeginMainFrame();
1751 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1756 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1752 EXPECT_FALSE(state.BeginFrameNeeded()); 1757 EXPECT_FALSE(state.BeginFrameNeeded());
1753 1758
1754 // When become visible again, the needs commit should still be pending. 1759 // When become visible again, the needs commit should still be pending.
1755 state.SetVisible(true); 1760 state.SetVisible(true);
1756 EXPECT_TRUE(state.BeginFrameNeeded()); 1761 EXPECT_TRUE(state.BeginFrameNeeded());
1757 state.OnBeginImplFrame(); 1762 state.OnBeginImplFrame();
1758 EXPECT_ACTION_UPDATE_STATE( 1763 EXPECT_ACTION_UPDATE_STATE(
1759 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 1764 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
1760 } 1765 }
1761 1766
1762 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) { 1767 TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) {
1763 SchedulerSettings default_scheduler_settings; 1768 SchedulerSettings default_scheduler_settings;
1764 StateMachine state(default_scheduler_settings); 1769 StateMachine state(default_scheduler_settings);
1765 state.SetVisible(true); 1770 state.SetVisible(true);
1766 EXPECT_ACTION_UPDATE_STATE( 1771 EXPECT_ACTION_UPDATE_STATE(
1767 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1772 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1768 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1773 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1769 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1774 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1770 state.SetVisible(false); 1775 state.SetVisible(false);
1771 state.SetBeginMainFrameState( 1776 state.SetBeginMainFrameState(
1772 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1777 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1773 state.SetNeedsBeginMainFrame(); 1778 state.SetNeedsBeginMainFrame();
1774 1779
1775 // After the commit completes, activation and draw happen immediately 1780 // After the commit completes, activation and draw happen immediately
1776 // because we are not visible. 1781 // because we are not visible.
1777 state.NotifyBeginMainFrameStarted(); 1782 state.NotifyBeginMainFrameStarted();
1778 state.NotifyReadyToCommit(); 1783 state.NotifyReadyToCommit();
1779 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1784 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1780 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1785 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1781 EXPECT_TRUE(state.active_tree_needs_first_draw()); 1786 EXPECT_TRUE(state.active_tree_needs_first_draw());
1782 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1787 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1783 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1788 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1784 } 1789 }
1785 1790
1786 TEST(SchedulerStateMachineTest, 1791 TEST(SchedulerStateMachineTest,
1787 TestFinishCommitWhenCommitInProgressAndBeginFrameSourcePaused) { 1792 TestFinishCommitWhenCommitInProgressAndBeginFrameSourcePaused) {
1788 SchedulerSettings default_scheduler_settings; 1793 SchedulerSettings default_scheduler_settings;
1789 StateMachine state(default_scheduler_settings); 1794 StateMachine state(default_scheduler_settings);
1790 state.SetVisible(true); 1795 state.SetVisible(true);
1791 EXPECT_ACTION_UPDATE_STATE( 1796 EXPECT_ACTION_UPDATE_STATE(
1792 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1797 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1793 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1798 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1794 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); 1799 state.CreateAndInitializeCompositorFrameSinkWithActivatedCommit();
1795 state.SetBeginFrameSourcePaused(true); 1800 state.SetBeginFrameSourcePaused(true);
1796 state.SetBeginMainFrameState( 1801 state.SetBeginMainFrameState(
1797 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT); 1802 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT);
1798 state.SetNeedsBeginMainFrame(); 1803 state.SetNeedsBeginMainFrame();
1799 1804
1800 // After the commit completes, activation and draw happen immediately 1805 // After the commit completes, activation and draw happen immediately
1801 // because we are not visible. 1806 // because we are not visible.
1802 state.NotifyBeginMainFrameStarted(); 1807 state.NotifyBeginMainFrameStarted();
1803 state.NotifyReadyToCommit(); 1808 state.NotifyReadyToCommit();
1804 EXPECT_TRUE(state.PendingActivationsShouldBeForced()); 1809 EXPECT_TRUE(state.PendingActivationsShouldBeForced());
1805 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); 1810 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT);
1806 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE); 1811 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE);
1807 EXPECT_TRUE(state.active_tree_needs_first_draw()); 1812 EXPECT_TRUE(state.active_tree_needs_first_draw());
1808 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT); 1813 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_ABORT);
1809 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 1814 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
1810 } 1815 }
1811 1816
1812 TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) { 1817 TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) {
1813 SchedulerSettings default_scheduler_settings; 1818 SchedulerSettings default_scheduler_settings;
1814 StateMachine state(default_scheduler_settings); 1819 StateMachine state(default_scheduler_settings);
1815 SET_UP_STATE(state) 1820 SET_UP_STATE(state)
1816 state.SetNeedsBeginMainFrame(); 1821 state.SetNeedsBeginMainFrame();
1817 state.DidLoseOutputSurface(); 1822 state.DidLoseCompositorFrameSink();
1818 1823
1819 // When we are visible, we normally want to begin output surface creation 1824 // When we are visible, we normally want to begin CompositorFrameSink creation
1820 // as soon as possible. 1825 // as soon as possible.
1821 EXPECT_ACTION_UPDATE_STATE( 1826 EXPECT_ACTION_UPDATE_STATE(
1822 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 1827 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
1823 1828
1824 state.DidCreateAndInitializeOutputSurface(); 1829 state.DidCreateAndInitializeCompositorFrameSink();
1825 EXPECT_EQ(state.output_surface_state(), 1830 EXPECT_EQ(
1826 SchedulerStateMachine::OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT); 1831 state.compositor_frame_sink_state(),
1832 SchedulerStateMachine::COMPOSITOR_FRAME_SINK_WAITING_FOR_FIRST_COMMIT);
1827 1833
1828 // We should not send a BeginMainFrame when we are invisible, even if we've 1834 // We should not send a BeginMainFrame when we are invisible, even if we've
1829 // lost the output surface and are trying to get the first commit, since the 1835 // lost the CompositorFrameSink and are trying to get the first commit, since
1836 // the
1830 // main thread will just abort anyway. 1837 // main thread will just abort anyway.
1831 state.SetVisible(false); 1838 state.SetVisible(false);
1832 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE); 1839 EXPECT_ACTION(SchedulerStateMachine::ACTION_NONE);
1833 } 1840 }
1834 1841
1835 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { 1842 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) {
1836 SchedulerSettings default_scheduler_settings; 1843 SchedulerSettings default_scheduler_settings;
1837 StateMachine state(default_scheduler_settings); 1844 StateMachine state(default_scheduler_settings);
1838 SET_UP_STATE(state) 1845 SET_UP_STATE(state)
1839 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); 1846 EXPECT_FALSE(state.PendingDrawsShouldBeAborted());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); 1887 EXPECT_FALSE(state.PendingDrawsShouldBeAborted());
1881 1888
1882 state.SetResourcelessSoftwareDraw(false); 1889 state.SetResourcelessSoftwareDraw(false);
1883 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1890 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1884 1891
1885 state.SetResourcelessSoftwareDraw(true); 1892 state.SetResourcelessSoftwareDraw(true);
1886 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); 1893 EXPECT_FALSE(state.PendingDrawsShouldBeAborted());
1887 state.SetBeginFrameSourcePaused(false); 1894 state.SetBeginFrameSourcePaused(false);
1888 1895
1889 state.SetVisible(false); 1896 state.SetVisible(false);
1890 state.DidLoseOutputSurface(); 1897 state.DidLoseCompositorFrameSink();
1891 1898
1892 state.SetCanDraw(false); 1899 state.SetCanDraw(false);
1893 state.WillBeginOutputSurfaceCreation(); 1900 state.WillBeginCompositorFrameSinkCreation();
1894 state.DidCreateAndInitializeOutputSurface(); 1901 state.DidCreateAndInitializeCompositorFrameSink();
1895 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1902 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1896 1903
1897 state.SetCanDraw(true); 1904 state.SetCanDraw(true);
1898 state.DidLoseOutputSurface(); 1905 state.DidLoseCompositorFrameSink();
1899 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1906 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1900 1907
1901 state.SetCanDraw(true); 1908 state.SetCanDraw(true);
1902 state.WillBeginOutputSurfaceCreation(); 1909 state.WillBeginCompositorFrameSinkCreation();
1903 state.DidCreateAndInitializeOutputSurface(); 1910 state.DidCreateAndInitializeCompositorFrameSink();
1904 EXPECT_FALSE(state.PendingDrawsShouldBeAborted()); 1911 EXPECT_FALSE(state.PendingDrawsShouldBeAborted());
1905 1912
1906 state.SetCanDraw(false); 1913 state.SetCanDraw(false);
1907 state.DidLoseOutputSurface(); 1914 state.DidLoseCompositorFrameSink();
1908 EXPECT_TRUE(state.PendingDrawsShouldBeAborted()); 1915 EXPECT_TRUE(state.PendingDrawsShouldBeAborted());
1909 } 1916 }
1910 1917
1911 TEST(SchedulerStateMachineTest, 1918 TEST(SchedulerStateMachineTest,
1912 TestTriggerDeadlineImmediatelyAfterAbortedCommit) { 1919 TestTriggerDeadlineImmediatelyAfterAbortedCommit) {
1913 SchedulerSettings default_scheduler_settings; 1920 SchedulerSettings default_scheduler_settings;
1914 StateMachine state(default_scheduler_settings); 1921 StateMachine state(default_scheduler_settings);
1915 SET_UP_STATE(state) 1922 SET_UP_STATE(state)
1916 1923
1917 // This test mirrors what happens during the first frame of a scroll gesture. 1924 // This test mirrors what happens during the first frame of a scroll gesture.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 state.SetNeedsBeginMainFrame(); 2016 state.SetNeedsBeginMainFrame();
2010 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2017 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2011 state.OnBeginImplFrame(); 2018 state.OnBeginImplFrame();
2012 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2019 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2013 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2020 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
2014 state.OnBeginImplFrameDeadline(); 2021 state.OnBeginImplFrameDeadline();
2015 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2022 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2016 } 2023 }
2017 2024
2018 TEST(SchedulerStateMachineTest, 2025 TEST(SchedulerStateMachineTest,
2019 TestTriggerDeadlineImmediatelyOnLostOutputSurface) { 2026 TestTriggerDeadlineImmediatelyOnLostCompositorFrameSink) {
2020 SchedulerSettings default_scheduler_settings; 2027 SchedulerSettings default_scheduler_settings;
2021 StateMachine state(default_scheduler_settings); 2028 StateMachine state(default_scheduler_settings);
2022 SET_UP_STATE(state) 2029 SET_UP_STATE(state)
2023 2030
2024 state.SetNeedsBeginMainFrame(); 2031 state.SetNeedsBeginMainFrame();
2025 2032
2026 state.OnBeginImplFrame(); 2033 state.OnBeginImplFrame();
2027 EXPECT_ACTION_UPDATE_STATE( 2034 EXPECT_ACTION_UPDATE_STATE(
2028 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2035 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2029 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2036 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2030 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2037 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
2031 2038
2032 state.DidLoseOutputSurface(); 2039 state.DidLoseCompositorFrameSink();
2033 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2040 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2034 // The deadline should be triggered immediately when output surface is lost. 2041 // The deadline should be triggered immediately when CompositorFrameSink is
2042 // lost.
2035 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately()); 2043 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineImmediately());
2036 } 2044 }
2037 2045
2038 TEST(SchedulerStateMachineTest, TestTriggerDeadlineImmediatelyWhenInvisible) { 2046 TEST(SchedulerStateMachineTest, TestTriggerDeadlineImmediatelyWhenInvisible) {
2039 SchedulerSettings default_scheduler_settings; 2047 SchedulerSettings default_scheduler_settings;
2040 StateMachine state(default_scheduler_settings); 2048 StateMachine state(default_scheduler_settings);
2041 SET_UP_STATE(state) 2049 SET_UP_STATE(state)
2042 2050
2043 state.SetNeedsBeginMainFrame(); 2051 state.SetNeedsBeginMainFrame();
2044 2052
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 SET_UP_STATE(state); 2111 SET_UP_STATE(state);
2104 2112
2105 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 2113 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
2106 bool commit_has_no_updates = true; 2114 bool commit_has_no_updates = true;
2107 state.WillCommit(commit_has_no_updates); 2115 state.WillCommit(commit_has_no_updates);
2108 EXPECT_TRUE(state.ProactiveBeginFrameWanted()); 2116 EXPECT_TRUE(state.ProactiveBeginFrameWanted());
2109 state.OnBeginImplFrame(); 2117 state.OnBeginImplFrame();
2110 EXPECT_FALSE(state.ProactiveBeginFrameWanted()); 2118 EXPECT_FALSE(state.ProactiveBeginFrameWanted());
2111 } 2119 }
2112 2120
2113 TEST(SchedulerStateMachineTest, NoOutputSurfaceCreationWhileCommitPending) { 2121 TEST(SchedulerStateMachineTest,
2122 NoCompositorFrameSinkCreationWhileCommitPending) {
2114 SchedulerSettings settings; 2123 SchedulerSettings settings;
2115 StateMachine state(settings); 2124 StateMachine state(settings);
2116 SET_UP_STATE(state); 2125 SET_UP_STATE(state);
2117 2126
2118 // Set up the request for a commit and start a frame. 2127 // Set up the request for a commit and start a frame.
2119 state.SetNeedsBeginMainFrame(); 2128 state.SetNeedsBeginMainFrame();
2120 state.OnBeginImplFrame(); 2129 state.OnBeginImplFrame();
2121 PerformAction(&state, SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2130 PerformAction(&state, SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2122 2131
2123 // Lose the output surface. 2132 // Lose the CompositorFrameSink.
2124 state.DidLoseOutputSurface(); 2133 state.DidLoseCompositorFrameSink();
2125 2134
2126 // The scheduler shouldn't trigger the output surface creation till the 2135 // The scheduler shouldn't trigger the CompositorFrameSink creation till the
2127 // previous commit has been cleared. 2136 // previous commit has been cleared.
2128 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2137 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2129 2138
2130 // Trigger the deadline and ensure that the scheduler does not trigger any 2139 // Trigger the deadline and ensure that the scheduler does not trigger any
2131 // actions until we receive a response for the pending commit. 2140 // actions until we receive a response for the pending commit.
2132 state.OnBeginImplFrameDeadline(); 2141 state.OnBeginImplFrameDeadline();
2133 state.OnBeginImplFrameIdle(); 2142 state.OnBeginImplFrameIdle();
2134 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2143 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2135 2144
2136 // Abort the commit, since that is what we expect the main thread to do if the 2145 // Abort the commit, since that is what we expect the main thread to do if the
2137 // output surface was lost due to a synchronous call from the main thread to 2146 // CompositorFrameSink was lost due to a synchronous call from the main thread
2138 // release the output surface. 2147 // to release the CompositorFrameSink.
2139 state.NotifyBeginMainFrameStarted(); 2148 state.NotifyBeginMainFrameStarted();
2140 state.BeginMainFrameAborted( 2149 state.BeginMainFrameAborted(
2141 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); 2150 CommitEarlyOutReason::ABORTED_COMPOSITOR_FRAME_SINK_LOST);
2142 2151
2143 // The scheduler should begin the output surface creation now. 2152 // The scheduler should begin the CompositorFrameSink creation now.
2144 EXPECT_ACTION_UPDATE_STATE( 2153 EXPECT_ACTION_UPDATE_STATE(
2145 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 2154 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
2146 } 2155 }
2147 2156
2148 TEST(SchedulerStateMachineTest, OutputSurfaceCreationWhileCommitPending) { 2157 TEST(SchedulerStateMachineTest, CompositorFrameSinkCreationWhileCommitPending) {
2149 SchedulerSettings settings; 2158 SchedulerSettings settings;
2150 settings.abort_commit_before_output_surface_creation = false; 2159 settings.abort_commit_before_compositor_frame_sink_creation = false;
2151 StateMachine state(settings); 2160 StateMachine state(settings);
2152 SET_UP_STATE(state); 2161 SET_UP_STATE(state);
2153 2162
2154 // Set up the request for a commit and start a frame. 2163 // Set up the request for a commit and start a frame.
2155 state.SetNeedsBeginMainFrame(); 2164 state.SetNeedsBeginMainFrame();
2156 state.OnBeginImplFrame(); 2165 state.OnBeginImplFrame();
2157 PerformAction(&state, SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); 2166 PerformAction(&state, SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME);
2158 2167
2159 // Lose the output surface. 2168 // Lose the CompositorFrameSink.
2160 state.DidLoseOutputSurface(); 2169 state.DidLoseCompositorFrameSink();
2161 2170
2162 // The scheduler shouldn't trigger the output surface creation till the 2171 // The scheduler shouldn't trigger the CompositorFrameSink creation till the
2163 // previous begin impl frame state is cleared from the pipeline. 2172 // previous begin impl frame state is cleared from the pipeline.
2164 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); 2173 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE);
2165 2174
2166 // Cycle through the frame stages to clear the scheduler state. 2175 // Cycle through the frame stages to clear the scheduler state.
2167 state.OnBeginImplFrameDeadline(); 2176 state.OnBeginImplFrameDeadline();
2168 state.OnBeginImplFrameIdle(); 2177 state.OnBeginImplFrameIdle();
2169 2178
2170 // The scheduler should begin the output surface creation now. 2179 // The scheduler should begin the CompositorFrameSink creation now.
2171 EXPECT_ACTION_UPDATE_STATE( 2180 EXPECT_ACTION_UPDATE_STATE(
2172 SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION); 2181 SchedulerStateMachine::ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION);
2173 } 2182 }
2174 2183
2175 } // namespace 2184 } // namespace
2176 } // namespace cc 2185 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698