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

Side by Side Diff: cc/CCSchedulerStateMachineTest.cpp

Issue 10907075: Roll cc snapshot up to 127605 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/CCSchedulerStateMachine.cpp ('k') | cc/CCSchedulerTest.cpp » ('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 "config.h" 5 #include "config.h"
6 6
7 #include "CCSchedulerStateMachine.h" 7 #include "CCSchedulerStateMachine.h"
8 8
9 #include <gtest/gtest.h> 9 #include <gtest/gtest.h>
10 #include <wtf/text/CString.h> 10 #include <wtf/text/CString.h>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 109 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
110 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state .commitState()); 110 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state .commitState());
111 EXPECT_FALSE(state.needsCommit()); 111 EXPECT_FALSE(state.needsCommit());
112 EXPECT_FALSE(state.vsyncCallbackNeeded()); 112 EXPECT_FALSE(state.vsyncCallbackNeeded());
113 } 113 }
114 } 114 }
115 115
116 TEST(CCSchedulerStateMachineTest, TestSetForcedRedrawDoesNotSetsNormalRedraw) 116 TEST(CCSchedulerStateMachineTest, TestSetForcedRedrawDoesNotSetsNormalRedraw)
117 { 117 {
118 CCSchedulerStateMachine state; 118 CCSchedulerStateMachine state;
119 state.setCanDraw(true);
119 state.setNeedsForcedRedraw(); 120 state.setNeedsForcedRedraw();
120 EXPECT_FALSE(state.redrawPending()); 121 EXPECT_FALSE(state.redrawPending());
121 EXPECT_TRUE(state.vsyncCallbackNeeded()); 122 EXPECT_TRUE(state.vsyncCallbackNeeded());
122 } 123 }
123 124
124 TEST(CCSchedulerStateMachineTest, TestFailedDrawSetsNeedsCommitAndDoesNotDrawAga in) 125 TEST(CCSchedulerStateMachineTest, TestFailedDrawSetsNeedsCommitAndDoesNotDrawAga in)
125 { 126 {
126 CCSchedulerStateMachine state; 127 CCSchedulerStateMachine state;
127 state.setCanBeginFrame(true); 128 state.setCanBeginFrame(true);
128 state.setVisible(true); 129 state.setVisible(true);
130 state.setCanDraw(true);
129 state.setNeedsRedraw(); 131 state.setNeedsRedraw();
130 EXPECT_TRUE(state.redrawPending()); 132 EXPECT_TRUE(state.redrawPending());
131 EXPECT_TRUE(state.vsyncCallbackNeeded()); 133 EXPECT_TRUE(state.vsyncCallbackNeeded());
132 state.didEnterVSync(); 134 state.didEnterVSync();
133 135
134 // We're drawing now. 136 // We're drawing now.
135 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 137 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
136 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 138 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
137 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 139 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
138 EXPECT_FALSE(state.redrawPending()); 140 EXPECT_FALSE(state.redrawPending());
139 EXPECT_FALSE(state.commitPending()); 141 EXPECT_FALSE(state.commitPending());
140 142
141 // Failing the draw makes us require a commit. 143 // Failing the draw makes us require a commit.
142 state.didDrawIfPossibleCompleted(false); 144 state.didDrawIfPossibleCompleted(false);
143 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 145 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
144 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 146 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
145 EXPECT_TRUE(state.redrawPending()); 147 EXPECT_TRUE(state.redrawPending());
146 EXPECT_TRUE(state.commitPending()); 148 EXPECT_TRUE(state.commitPending());
147 } 149 }
148 150
149 TEST(CCSchedulerStateMachineTest, TestSetNeedsRedrawDuringFailedDrawDoesNotRemov eNeedsRedraw) 151 TEST(CCSchedulerStateMachineTest, TestSetNeedsRedrawDuringFailedDrawDoesNotRemov eNeedsRedraw)
150 { 152 {
151 CCSchedulerStateMachine state; 153 CCSchedulerStateMachine state;
152 state.setCanBeginFrame(true); 154 state.setCanBeginFrame(true);
153 state.setVisible(true); 155 state.setVisible(true);
156 state.setCanDraw(true);
154 state.setNeedsRedraw(); 157 state.setNeedsRedraw();
155 EXPECT_TRUE(state.redrawPending()); 158 EXPECT_TRUE(state.redrawPending());
156 EXPECT_TRUE(state.vsyncCallbackNeeded()); 159 EXPECT_TRUE(state.vsyncCallbackNeeded());
157 state.didEnterVSync(); 160 state.didEnterVSync();
158 161
159 // We're drawing now. 162 // We're drawing now.
160 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 163 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
161 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 164 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
162 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 165 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
163 EXPECT_FALSE(state.redrawPending()); 166 EXPECT_FALSE(state.redrawPending());
164 EXPECT_FALSE(state.commitPending()); 167 EXPECT_FALSE(state.commitPending());
165 168
166 // While still in the same vsync callback, set needs redraw again. 169 // While still in the same vsync callback, set needs redraw again.
167 // This should not redraw. 170 // This should not redraw.
168 state.setNeedsRedraw(); 171 state.setNeedsRedraw();
169 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 172 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
170 173
171 // Failing the draw makes us require a commit. 174 // Failing the draw makes us require a commit.
172 state.didDrawIfPossibleCompleted(false); 175 state.didDrawIfPossibleCompleted(false);
173 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 176 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
174 EXPECT_TRUE(state.redrawPending()); 177 EXPECT_TRUE(state.redrawPending());
175 } 178 }
176 179
177 TEST(CCSchedulerStateMachineTest, TestCommitAfterFailedDrawAllowsDrawInSameFrame ) 180 TEST(CCSchedulerStateMachineTest, TestCommitAfterFailedDrawAllowsDrawInSameFrame )
178 { 181 {
179 CCSchedulerStateMachine state; 182 CCSchedulerStateMachine state;
180 state.setCanBeginFrame(true); 183 state.setCanBeginFrame(true);
181 state.setVisible(true); 184 state.setVisible(true);
185 state.setCanDraw(true);
182 186
183 // Start a commit. 187 // Start a commit.
184 state.setNeedsCommit(); 188 state.setNeedsCommit();
185 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 189 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
186 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 190 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
187 EXPECT_TRUE(state.commitPending()); 191 EXPECT_TRUE(state.commitPending());
188 192
189 // Then initiate a draw. 193 // Then initiate a draw.
190 state.setNeedsRedraw(); 194 state.setNeedsRedraw();
191 EXPECT_TRUE(state.vsyncCallbackNeeded()); 195 EXPECT_TRUE(state.vsyncCallbackNeeded());
(...skipping 20 matching lines...) Expand all
212 216
213 // And we should be allowed to draw again. 217 // And we should be allowed to draw again.
214 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 218 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
215 } 219 }
216 220
217 TEST(CCSchedulerStateMachineTest, TestCommitAfterFailedAndSuccessfulDrawDoesNotA llowDrawInSameFrame) 221 TEST(CCSchedulerStateMachineTest, TestCommitAfterFailedAndSuccessfulDrawDoesNotA llowDrawInSameFrame)
218 { 222 {
219 CCSchedulerStateMachine state; 223 CCSchedulerStateMachine state;
220 state.setCanBeginFrame(true); 224 state.setCanBeginFrame(true);
221 state.setVisible(true); 225 state.setVisible(true);
226 state.setCanDraw(true);
222 227
223 // Start a commit. 228 // Start a commit.
224 state.setNeedsCommit(); 229 state.setNeedsCommit();
225 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 230 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
226 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 231 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
227 EXPECT_TRUE(state.commitPending()); 232 EXPECT_TRUE(state.commitPending());
228 233
229 // Then initiate a draw. 234 // Then initiate a draw.
230 state.setNeedsRedraw(); 235 state.setNeedsRedraw();
231 EXPECT_TRUE(state.vsyncCallbackNeeded()); 236 EXPECT_TRUE(state.vsyncCallbackNeeded());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 268
264 // And we should not be allowed to draw again in the same frame.. 269 // And we should not be allowed to draw again in the same frame..
265 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 270 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
266 } 271 }
267 272
268 TEST(CCSchedulerStateMachineTest, TestFailedDrawsWillEventuallyForceADrawAfterTh eNextCommit) 273 TEST(CCSchedulerStateMachineTest, TestFailedDrawsWillEventuallyForceADrawAfterTh eNextCommit)
269 { 274 {
270 CCSchedulerStateMachine state; 275 CCSchedulerStateMachine state;
271 state.setCanBeginFrame(true); 276 state.setCanBeginFrame(true);
272 state.setVisible(true); 277 state.setVisible(true);
278 state.setCanDraw(true);
273 state.setMaximumNumberOfFailedDrawsBeforeDrawIsForced(1); 279 state.setMaximumNumberOfFailedDrawsBeforeDrawIsForced(1);
274 280
275 // Start a commit. 281 // Start a commit.
276 state.setNeedsCommit(); 282 state.setNeedsCommit();
277 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 283 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
278 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 284 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
279 EXPECT_TRUE(state.commitPending()); 285 EXPECT_TRUE(state.commitPending());
280 286
281 // Then initiate a draw. 287 // Then initiate a draw.
282 state.setNeedsRedraw(); 288 state.setNeedsRedraw();
(...skipping 22 matching lines...) Expand all
305 311
306 // The redraw should be forced in this case. 312 // The redraw should be forced in this case.
307 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction()); 313 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
308 } 314 }
309 315
310 TEST(CCSchedulerStateMachineTest, TestFailedDrawIsRetriedNextVSync) 316 TEST(CCSchedulerStateMachineTest, TestFailedDrawIsRetriedNextVSync)
311 { 317 {
312 CCSchedulerStateMachine state; 318 CCSchedulerStateMachine state;
313 state.setCanBeginFrame(true); 319 state.setCanBeginFrame(true);
314 state.setVisible(true); 320 state.setVisible(true);
321 state.setCanDraw(true);
315 322
316 // Start a draw. 323 // Start a draw.
317 state.setNeedsRedraw(); 324 state.setNeedsRedraw();
318 EXPECT_TRUE(state.vsyncCallbackNeeded()); 325 EXPECT_TRUE(state.vsyncCallbackNeeded());
319 state.didEnterVSync(); 326 state.didEnterVSync();
320 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 327 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
321 EXPECT_TRUE(state.redrawPending()); 328 EXPECT_TRUE(state.redrawPending());
322 329
323 // Fail the draw. 330 // Fail the draw.
324 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 331 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
325 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 332 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
326 state.didDrawIfPossibleCompleted(false); 333 state.didDrawIfPossibleCompleted(false);
327 EXPECT_TRUE(state.redrawPending()); 334 EXPECT_TRUE(state.redrawPending());
328 335
329 // We should not be trying to draw again now, but we have a commit pending. 336 // We should not be trying to draw again now, but we have a commit pending.
330 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 337 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
331 338
332 state.didLeaveVSync(); 339 state.didLeaveVSync();
333 EXPECT_TRUE(state.vsyncCallbackNeeded()); 340 EXPECT_TRUE(state.vsyncCallbackNeeded());
334 state.didEnterVSync(); 341 state.didEnterVSync();
335 342
336 // We should try draw again in the next vsync. 343 // We should try draw again in the next vsync.
337 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 344 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
338 } 345 }
339 346
340 TEST(CCSchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) 347 TEST(CCSchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame)
341 { 348 {
342 CCSchedulerStateMachine state; 349 CCSchedulerStateMachine state;
343 state.setVisible(true); 350 state.setVisible(true);
351 state.setCanDraw(true);
344 state.setNeedsRedraw(); 352 state.setNeedsRedraw();
345 EXPECT_TRUE(state.vsyncCallbackNeeded()); 353 EXPECT_TRUE(state.vsyncCallbackNeeded());
346 state.didEnterVSync(); 354 state.didEnterVSync();
347 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 355 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
348 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 356 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
349 357
350 // While still in the same vsync callback, set needs redraw again. 358 // While still in the same vsync callback, set needs redraw again.
351 // This should not redraw. 359 // This should not redraw.
352 state.setNeedsRedraw(); 360 state.setNeedsRedraw();
353 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 361 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // Case 2: needsCommit=true 394 // Case 2: needsCommit=true
387 state.setNeedsCommit(true); 395 state.setNeedsCommit(true);
388 EXPECT_NE(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.ne xtAction()); 396 EXPECT_NE(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.ne xtAction());
389 } 397 }
390 } 398 }
391 399
392 // When on vsync, or not on vsync but needsForcedRedraw set, should always d raw except if you're ready to commit, in which case commit. 400 // When on vsync, or not on vsync but needsForcedRedraw set, should always d raw except if you're ready to commit, in which case commit.
393 for (size_t i = 0; i < numCommitStates; ++i) { 401 for (size_t i = 0; i < numCommitStates; ++i) {
394 for (unsigned j = 0; j < 2; ++j) { 402 for (unsigned j = 0; j < 2; ++j) {
395 StateMachine state; 403 StateMachine state;
404 state.setCanDraw(true);
396 state.setCommitState(allCommitStates[i]); 405 state.setCommitState(allCommitStates[i]);
397 bool forcedDraw = j; 406 bool forcedDraw = j;
398 if (!forcedDraw) { 407 if (!forcedDraw) {
399 state.didEnterVSync(); 408 state.didEnterVSync();
400 state.setNeedsRedraw(true); 409 state.setNeedsRedraw(true);
401 state.setVisible(true); 410 state.setVisible(true);
402 } else 411 } else
403 state.setNeedsForcedRedraw(true); 412 state.setNeedsForcedRedraw(true);
404 413
405 CCSchedulerStateMachine::Action expectedAction; 414 CCSchedulerStateMachine::Action expectedAction;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST _DRAW); 507 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST _DRAW);
499 state.setCanBeginFrame(true); 508 state.setCanBeginFrame(true);
500 state.setNeedsCommit(true); 509 state.setNeedsCommit(true);
501 state.setNeedsRedraw(true); 510 state.setNeedsRedraw(true);
502 state.setUpdateMoreResourcesPending(false); 511 state.setUpdateMoreResourcesPending(false);
503 state.setVisible(true); 512 state.setVisible(true);
504 state.setCanDraw(false); 513 state.setCanDraw(false);
505 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 514 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
506 } 515 }
507 516
517 TEST(CCSchedulerStateMachineTest, TestVsyncCallbackNeededOnCanDrawAndResourceUpd ates)
518 {
519 StateMachine state;
520 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST _DRAW);
521 state.setCanBeginFrame(true);
522 state.setNeedsCommit(true);
523 state.setNeedsRedraw(true);
524 state.setUpdateMoreResourcesPending(false);
525 state.setVisible(true);
526 state.setCanDraw(false);
527 EXPECT_FALSE(state.vsyncCallbackNeeded());
528
529 state.setUpdateMoreResourcesPending(true);
530 EXPECT_TRUE(state.vsyncCallbackNeeded());
531
532 state.setUpdateMoreResourcesPending(false);
533 EXPECT_FALSE(state.vsyncCallbackNeeded());
534
535 state.setCanDraw(true);
536 EXPECT_TRUE(state.vsyncCallbackNeeded());
537 }
538
508 TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_OneRoundOfUpdates) 539 TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_OneRoundOfUpdates)
509 { 540 {
510 StateMachine state; 541 StateMachine state;
511 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S); 542 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S);
512 state.setNeedsRedraw(false); 543 state.setNeedsRedraw(false);
513 state.setUpdateMoreResourcesPending(false); 544 state.setUpdateMoreResourcesPending(false);
514 state.setVisible(true); 545 state.setVisible(true);
546 state.setCanDraw(true);
515 547
516 // Verify we begin update, both for vsync and not vsync. 548 // Verify we begin update, both for vsync and not vsync.
517 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction()); 549 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction());
518 state.didEnterVSync(); 550 state.didEnterVSync();
519 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction()); 551 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction());
520 552
521 // Begin an update. 553 // Begin an update.
522 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCE S); 554 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCE S);
523 555
524 // Verify we don't do anything, both for vsync and not vsync. 556 // Verify we don't do anything, both for vsync and not vsync.
525 state.didLeaveVSync(); 557 state.didLeaveVSync();
526 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 558 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
527 state.didEnterVSync(); 559 state.didEnterVSync();
528 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 560 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
529 561
530 // End update with no more updates pending. 562 // End update with no more updates pending.
531 state.beginUpdateMoreResourcesComplete(false); 563 state.beginUpdateMoreResourcesComplete(false);
532 state.didLeaveVSync(); 564 state.didLeaveVSync();
533 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); 565 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction());
534 } 566 }
535 567
536 TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_TwoRoundsOfUpdates) 568 TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_TwoRoundsOfUpdates)
537 { 569 {
538 StateMachine state; 570 StateMachine state;
539 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S); 571 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S);
540 state.setNeedsRedraw(false); 572 state.setNeedsRedraw(false);
541 state.setUpdateMoreResourcesPending(false); 573 state.setUpdateMoreResourcesPending(false);
542 state.setVisible(true); 574 state.setVisible(true);
575 state.setCanDraw(true);
543 576
544 // Verify the update begins, both for vsync and not vsync. 577 // Verify the update begins, both for vsync and not vsync.
545 state.didEnterVSync(); 578 state.didEnterVSync();
546 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction()); 579 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction());
547 state.didLeaveVSync(); 580 state.didLeaveVSync();
548 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction()); 581 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction());
549 582
550 // Begin an update. 583 // Begin an update.
551 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCE S); 584 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCE S);
552 585
(...skipping 19 matching lines...) Expand all
572 state.didLeaveVSync(); 605 state.didLeaveVSync();
573 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); 606 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction());
574 state.didEnterVSync(); 607 state.didEnterVSync();
575 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); 608 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction());
576 } 609 }
577 610
578 611
579 TEST(CCSchedulerStateMachineTest, TestVSyncNeededWhenUpdatesPendingButInvisible) 612 TEST(CCSchedulerStateMachineTest, TestVSyncNeededWhenUpdatesPendingButInvisible)
580 { 613 {
581 StateMachine state; 614 StateMachine state;
615 state.setCanDraw(true);
582 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S); 616 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S);
583 state.setNeedsRedraw(false); 617 state.setNeedsRedraw(false);
584 state.setVisible(false); 618 state.setVisible(false);
585 state.setUpdateMoreResourcesPending(true); 619 state.setUpdateMoreResourcesPending(true);
586 EXPECT_TRUE(state.vsyncCallbackNeeded()); 620 EXPECT_TRUE(state.vsyncCallbackNeeded());
587 621
588 state.setUpdateMoreResourcesPending(false); 622 state.setUpdateMoreResourcesPending(false);
589 EXPECT_TRUE(state.vsyncCallbackNeeded()); 623 EXPECT_TRUE(state.vsyncCallbackNeeded());
590 } 624 }
591 625
592 TEST(CCSchedulerStateMachineTest, TestUpdates_WithRedraw_OneRoundOfUpdates) 626 TEST(CCSchedulerStateMachineTest, TestUpdates_WithRedraw_OneRoundOfUpdates)
593 { 627 {
594 StateMachine state; 628 StateMachine state;
595 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S); 629 state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_UPDATING_RESOURCE S);
596 state.setNeedsRedraw(true); 630 state.setNeedsRedraw(true);
597 state.setUpdateMoreResourcesPending(false); 631 state.setUpdateMoreResourcesPending(false);
598 state.setVisible(true); 632 state.setVisible(true);
633 state.setCanDraw(true);
599 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction()); 634 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES, state .nextAction());
600 635
601 // Begin an update. 636 // Begin an update.
602 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCE S); 637 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCE S);
603 638
604 // Ensure we draw on the next vsync even though an update is in-progress. 639 // Ensure we draw on the next vsync even though an update is in-progress.
605 state.didEnterVSync(); 640 state.didEnterVSync();
606 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 641 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
607 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE); 642 state.updateState(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
608 state.didDrawIfPossibleCompleted(true); 643 state.didDrawIfPossibleCompleted(true);
(...skipping 27 matching lines...) Expand all
636 state.didEnterVSync(); 671 state.didEnterVSync();
637 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction()); 672 EXPECT_EQ(CCSchedulerStateMachine::ACTION_COMMIT, state.nextAction());
638 } 673 }
639 674
640 TEST(CCSchedulerStateMachineTest, TestSetNeedsCommitIsNotLost) 675 TEST(CCSchedulerStateMachineTest, TestSetNeedsCommitIsNotLost)
641 { 676 {
642 StateMachine state; 677 StateMachine state;
643 state.setCanBeginFrame(true); 678 state.setCanBeginFrame(true);
644 state.setNeedsCommit(true); 679 state.setNeedsCommit(true);
645 state.setVisible(true); 680 state.setVisible(true);
681 state.setCanDraw(true);
646 682
647 // Begin the frame. 683 // Begin the frame.
648 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 684 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
649 state.updateState(state.nextAction()); 685 state.updateState(state.nextAction());
650 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState()); 686 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState());
651 687
652 // Now, while the frame is in progress, set another commit. 688 // Now, while the frame is in progress, set another commit.
653 state.setNeedsCommit(true); 689 state.setNeedsCommit(true);
654 EXPECT_TRUE(state.needsCommit()); 690 EXPECT_TRUE(state.needsCommit());
655 691
(...skipping 22 matching lines...) Expand all
678 // Verify that another commit will begin. 714 // Verify that another commit will begin.
679 state.didLeaveVSync(); 715 state.didLeaveVSync();
680 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 716 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
681 } 717 }
682 718
683 TEST(CCSchedulerStateMachineTest, TestFullCycle) 719 TEST(CCSchedulerStateMachineTest, TestFullCycle)
684 { 720 {
685 StateMachine state; 721 StateMachine state;
686 state.setCanBeginFrame(true); 722 state.setCanBeginFrame(true);
687 state.setVisible(true); 723 state.setVisible(true);
724 state.setCanDraw(true);
688 725
689 // Start clean and set commit. 726 // Start clean and set commit.
690 state.setNeedsCommit(true); 727 state.setNeedsCommit(true);
691 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 728 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
692 729
693 // Begin the frame. 730 // Begin the frame.
694 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 731 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
695 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState()); 732 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState());
696 EXPECT_FALSE(state.needsCommit()); 733 EXPECT_FALSE(state.needsCommit());
697 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 734 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
(...skipping 28 matching lines...) Expand all
726 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState()); 763 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState());
727 EXPECT_FALSE(state.needsRedraw()); 764 EXPECT_FALSE(state.needsRedraw());
728 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 765 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
729 } 766 }
730 767
731 TEST(CCSchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) 768 TEST(CCSchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween)
732 { 769 {
733 StateMachine state; 770 StateMachine state;
734 state.setCanBeginFrame(true); 771 state.setCanBeginFrame(true);
735 state.setVisible(true); 772 state.setVisible(true);
773 state.setCanDraw(true);
736 774
737 // Start clean and set commit. 775 // Start clean and set commit.
738 state.setNeedsCommit(true); 776 state.setNeedsCommit(true);
739 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 777 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
740 778
741 // Begin the frame. 779 // Begin the frame.
742 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 780 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
743 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState()); 781 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState());
744 EXPECT_FALSE(state.needsCommit()); 782 EXPECT_FALSE(state.needsCommit());
745 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 783 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 StateMachine state; 823 StateMachine state;
786 state.setNeedsCommit(true); 824 state.setNeedsCommit(true);
787 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 825 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
788 } 826 }
789 827
790 TEST(CCSchedulerStateMachineTest, TestGoesInvisibleBeforeBeginFrameCompletes) 828 TEST(CCSchedulerStateMachineTest, TestGoesInvisibleBeforeBeginFrameCompletes)
791 { 829 {
792 StateMachine state; 830 StateMachine state;
793 state.setCanBeginFrame(true); 831 state.setCanBeginFrame(true);
794 state.setVisible(true); 832 state.setVisible(true);
833 state.setCanDraw(true);
795 834
796 // Start clean and set commit. 835 // Start clean and set commit.
797 state.setNeedsCommit(true); 836 state.setNeedsCommit(true);
798 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 837 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
799 838
800 // Begin the frame while visible. 839 // Begin the frame while visible.
801 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME); 840 state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
802 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState()); 841 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState());
803 EXPECT_FALSE(state.needsCommit()); 842 EXPECT_FALSE(state.needsCommit());
804 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 843 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
(...skipping 18 matching lines...) Expand all
823 862
824 // We should be starting the commit now 863 // We should be starting the commit now
825 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState()); 864 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.com mitState());
826 } 865 }
827 866
828 TEST(CCSchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) 867 TEST(CCSchedulerStateMachineTest, TestContextLostWhenCompletelyIdle)
829 { 868 {
830 StateMachine state; 869 StateMachine state;
831 state.setCanBeginFrame(true); 870 state.setCanBeginFrame(true);
832 state.setVisible(true); 871 state.setVisible(true);
872 state.setCanDraw(true);
833 873
834 state.didLoseContext(); 874 state.didLoseContext();
835 875
836 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction()); 876 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction());
837 state.updateState(state.nextAction()); 877 state.updateState(state.nextAction());
838 878
839 // Once context recreation begins, nothing should happen. 879 // Once context recreation begins, nothing should happen.
840 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 880 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
841 881
842 // Recreate the context 882 // Recreate the context
843 state.didRecreateContext(); 883 state.didRecreateContext();
844 884
845 // When the context is recreated, we should begin a commit 885 // When the context is recreated, we should begin a commit
846 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 886 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
847 state.updateState(state.nextAction()); 887 state.updateState(state.nextAction());
848 } 888 }
849 889
850 TEST(CCSchedulerStateMachineTest, TestContextLostWhenIdleAndCommitRequestedWhile Recreating) 890 TEST(CCSchedulerStateMachineTest, TestContextLostWhenIdleAndCommitRequestedWhile Recreating)
851 { 891 {
852 StateMachine state; 892 StateMachine state;
853 state.setCanBeginFrame(true); 893 state.setCanBeginFrame(true);
854 state.setVisible(true); 894 state.setVisible(true);
895 state.setCanDraw(true);
855 896
856 state.didLoseContext(); 897 state.didLoseContext();
857 898
858 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction()); 899 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction());
859 state.updateState(state.nextAction()); 900 state.updateState(state.nextAction());
860 901
861 // Once context recreation begins, nothing should happen. 902 // Once context recreation begins, nothing should happen.
862 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 903 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
863 904
864 // While context is recreating, commits shouldn't begin. 905 // While context is recreating, commits shouldn't begin.
(...skipping 16 matching lines...) Expand all
881 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction()); 922 EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
882 state.setCanDraw(true); 923 state.setCanDraw(true);
883 state.didLeaveVSync(); 924 state.didLeaveVSync();
884 } 925 }
885 926
886 TEST(CCSchedulerStateMachineTest, TestContextLostWhileCommitInProgress) 927 TEST(CCSchedulerStateMachineTest, TestContextLostWhileCommitInProgress)
887 { 928 {
888 StateMachine state; 929 StateMachine state;
889 state.setCanBeginFrame(true); 930 state.setCanBeginFrame(true);
890 state.setVisible(true); 931 state.setVisible(true);
932 state.setCanDraw(true);
891 933
892 // Get a commit in flight. 934 // Get a commit in flight.
893 state.setNeedsCommit(true); 935 state.setNeedsCommit(true);
894 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 936 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
895 state.updateState(state.nextAction()); 937 state.updateState(state.nextAction());
896 938
897 // Set damage and expect a draw. 939 // Set damage and expect a draw.
898 state.setNeedsRedraw(true); 940 state.setNeedsRedraw(true);
899 state.didEnterVSync(); 941 state.didEnterVSync();
900 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 942 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
(...skipping 21 matching lines...) Expand all
922 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction()); 964 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction());
923 state.didLeaveVSync(); 965 state.didLeaveVSync();
924 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction()); 966 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction());
925 } 967 }
926 968
927 TEST(CCSchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnother CommitRequested) 969 TEST(CCSchedulerStateMachineTest, TestContextLostWhileCommitInProgressAndAnother CommitRequested)
928 { 970 {
929 StateMachine state; 971 StateMachine state;
930 state.setCanBeginFrame(true); 972 state.setCanBeginFrame(true);
931 state.setVisible(true); 973 state.setVisible(true);
974 state.setCanDraw(true);
932 975
933 // Get a commit in flight. 976 // Get a commit in flight.
934 state.setNeedsCommit(true); 977 state.setNeedsCommit(true);
935 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 978 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
936 state.updateState(state.nextAction()); 979 state.updateState(state.nextAction());
937 980
938 // Set damage and expect a draw. 981 // Set damage and expect a draw.
939 state.setNeedsRedraw(true); 982 state.setNeedsRedraw(true);
940 state.didEnterVSync(); 983 state.didEnterVSync();
941 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ()); 984 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.nextAction ());
(...skipping 30 matching lines...) Expand all
972 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction()); 1015 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction());
973 state.didLeaveVSync(); 1016 state.didLeaveVSync();
974 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction()); 1017 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_CONTEXT_RECREATION, state.ne xtAction());
975 } 1018 }
976 1019
977 1020
978 TEST(CCSchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) 1021 TEST(CCSchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost)
979 { 1022 {
980 StateMachine state; 1023 StateMachine state;
981 state.setVisible(true); 1024 state.setVisible(true);
1025 state.setCanDraw(true);
982 1026
983 // Cause a lost context lost. 1027 // Cause a lost context lost.
984 state.didLoseContext(); 1028 state.didLoseContext();
985 1029
986 // Ask a forced redraw and verify it ocurrs. 1030 // Ask a forced redraw and verify it ocurrs.
987 state.setNeedsForcedRedraw(true); 1031 state.setNeedsForcedRedraw(true);
988 state.didEnterVSync(); 1032 state.didEnterVSync();
989 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction()); 1033 EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW_FORCED, state.nextAction());
990 state.didLeaveVSync(); 1034 state.didLeaveVSync();
991 1035
(...skipping 18 matching lines...) Expand all
1010 state.setVisible(false); 1054 state.setVisible(false);
1011 state.setNeedsCommit(true); 1055 state.setNeedsCommit(true);
1012 state.setNeedsForcedCommit(true); 1056 state.setNeedsForcedCommit(true);
1013 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 1057 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
1014 } 1058 }
1015 1059
1016 TEST(CCSchedulerStateMachineTest, TestBeginFrameWhenCanBeginFrameFalseAndForceCo mmit) 1060 TEST(CCSchedulerStateMachineTest, TestBeginFrameWhenCanBeginFrameFalseAndForceCo mmit)
1017 { 1061 {
1018 StateMachine state; 1062 StateMachine state;
1019 state.setVisible(true); 1063 state.setVisible(true);
1064 state.setCanDraw(true);
1020 state.setNeedsCommit(true); 1065 state.setNeedsCommit(true);
1021 state.setNeedsForcedCommit(true); 1066 state.setNeedsForcedCommit(true);
1022 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 1067 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
1023 } 1068 }
1024 1069
1025 TEST(CCSchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress) 1070 TEST(CCSchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress)
1026 { 1071 {
1027 StateMachine state; 1072 StateMachine state;
1028 state.setCanBeginFrame(true); 1073 state.setCanBeginFrame(true);
1029 state.setVisible(false); 1074 state.setVisible(false);
(...skipping 12 matching lines...) Expand all
1042 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState()); 1087 EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_IDLE, state.commitState());
1043 1088
1044 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 1089 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
1045 } 1090 }
1046 1091
1047 TEST(CCSchedulerStateMachineTest, TestBeginFrameWhenContextLost) 1092 TEST(CCSchedulerStateMachineTest, TestBeginFrameWhenContextLost)
1048 { 1093 {
1049 StateMachine state; 1094 StateMachine state;
1050 state.setCanBeginFrame(true); 1095 state.setCanBeginFrame(true);
1051 state.setVisible(true); 1096 state.setVisible(true);
1097 state.setCanDraw(true);
1052 state.setNeedsCommit(true); 1098 state.setNeedsCommit(true);
1053 state.setNeedsForcedCommit(true); 1099 state.setNeedsForcedCommit(true);
1054 state.didLoseContext(); 1100 state.didLoseContext();
1055 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction()); 1101 EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
1056 } 1102 }
1057 1103
1058 } 1104 }
OLDNEW
« no previous file with comments | « cc/CCSchedulerStateMachine.cpp ('k') | cc/CCSchedulerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698