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

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

Issue 275543004: Refactoring the debug creation of BeginFrameArgs objects to be in unittest code only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing onto upstream master. Created 6 years, 7 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/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/begin_frame_args_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/test/test_simple_task_runner.h" 13 #include "base/test/test_simple_task_runner.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "cc/test/begin_frame_args_test.h"
15 #include "cc/test/scheduler_test_common.h" 16 #include "cc/test/scheduler_test_common.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 #define EXPECT_ACTION(action, client, action_index, expected_num_actions) \ 20 #define EXPECT_ACTION(action, client, action_index, expected_num_actions) \
20 EXPECT_EQ(expected_num_actions, client.num_actions_()); \ 21 EXPECT_EQ(expected_num_actions, client.num_actions_()); \
21 ASSERT_LT(action_index, client.num_actions_()); \ 22 ASSERT_LT(action_index, client.num_actions_()); \
22 do { \ 23 do { \
23 EXPECT_STREQ(action, client.Action(action_index)); \ 24 EXPECT_STREQ(action, client.Action(action_index)); \
24 for (int i = expected_num_actions; i < client.num_actions_(); ++i) \ 25 for (int i = expected_num_actions; i < client.num_actions_(); ++i) \
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bool client_initiates_begin_frame = 207 bool client_initiates_begin_frame =
207 scheduler->settings().begin_frame_scheduling_enabled && 208 scheduler->settings().begin_frame_scheduling_enabled &&
208 scheduler->settings().throttle_frame_production; 209 scheduler->settings().throttle_frame_production;
209 210
210 scheduler->DidCreateAndInitializeOutputSurface(); 211 scheduler->DidCreateAndInitializeOutputSurface();
211 scheduler->SetNeedsCommit(); 212 scheduler->SetNeedsCommit();
212 scheduler->NotifyBeginMainFrameStarted(); 213 scheduler->NotifyBeginMainFrameStarted();
213 scheduler->NotifyReadyToCommit(); 214 scheduler->NotifyReadyToCommit();
214 // Go through the motions to draw the commit. 215 // Go through the motions to draw the commit.
215 if (client_initiates_begin_frame) 216 if (client_initiates_begin_frame)
216 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 217 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
217 else 218 else
218 client->task_runner().RunPendingTasks(); // Run posted BeginFrame. 219 client->task_runner().RunPendingTasks(); // Run posted BeginFrame.
219 220
220 // Run the posted deadline task. 221 // Run the posted deadline task.
221 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 222 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
222 client->task_runner().RunPendingTasks(); 223 client->task_runner().RunPendingTasks();
223 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 224 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
224 225
225 // We need another BeginImplFrame so Scheduler calls 226 // We need another BeginImplFrame so Scheduler calls
226 // SetNeedsBeginFrame(false). 227 // SetNeedsBeginFrame(false).
227 if (client_initiates_begin_frame) 228 if (client_initiates_begin_frame)
228 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 229 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
229 else 230 else
230 client->task_runner().RunPendingTasks(); // Run posted BeginFrame. 231 client->task_runner().RunPendingTasks(); // Run posted BeginFrame.
231 232
232 // Run the posted deadline task. 233 // Run the posted deadline task.
233 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 234 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
234 client->task_runner().RunPendingTasks(); 235 client->task_runner().RunPendingTasks();
235 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 236 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
236 } 237 }
237 238
238 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { 239 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
(...skipping 21 matching lines...) Expand all
260 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 261 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
261 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 262 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
262 263
263 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 264 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
264 client.Reset(); 265 client.Reset();
265 scheduler->SetNeedsCommit(); 266 scheduler->SetNeedsCommit();
266 EXPECT_TRUE(client.needs_begin_frame()); 267 EXPECT_TRUE(client.needs_begin_frame());
267 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 268 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
268 client.Reset(); 269 client.Reset();
269 270
270 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 271 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
271 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 272 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
272 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 273 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
273 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 274 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
274 EXPECT_TRUE(client.needs_begin_frame()); 275 EXPECT_TRUE(client.needs_begin_frame());
275 client.Reset(); 276 client.Reset();
276 277
277 // If we don't swap on the deadline, we wait for the next BeginFrame. 278 // If we don't swap on the deadline, we wait for the next BeginFrame.
278 client.task_runner().RunPendingTasks(); // Run posted deadline. 279 client.task_runner().RunPendingTasks(); // Run posted deadline.
279 EXPECT_EQ(0, client.num_actions_()); 280 EXPECT_EQ(0, client.num_actions_());
280 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 281 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
281 EXPECT_TRUE(client.needs_begin_frame()); 282 EXPECT_TRUE(client.needs_begin_frame());
282 client.Reset(); 283 client.Reset();
283 284
284 // NotifyReadyToCommit should trigger the commit. 285 // NotifyReadyToCommit should trigger the commit.
285 scheduler->NotifyBeginMainFrameStarted(); 286 scheduler->NotifyBeginMainFrameStarted();
286 scheduler->NotifyReadyToCommit(); 287 scheduler->NotifyReadyToCommit();
287 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 288 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
288 EXPECT_TRUE(client.needs_begin_frame()); 289 EXPECT_TRUE(client.needs_begin_frame());
289 client.Reset(); 290 client.Reset();
290 291
291 // BeginImplFrame should prepare the draw. 292 // BeginImplFrame should prepare the draw.
292 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 293 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
293 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 294 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
294 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 295 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
295 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 296 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
296 EXPECT_TRUE(client.needs_begin_frame()); 297 EXPECT_TRUE(client.needs_begin_frame());
297 client.Reset(); 298 client.Reset();
298 299
299 // BeginImplFrame deadline should draw. 300 // BeginImplFrame deadline should draw.
300 client.task_runner().RunPendingTasks(); // Run posted deadline. 301 client.task_runner().RunPendingTasks(); // Run posted deadline.
301 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); 302 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
302 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 303 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
303 EXPECT_TRUE(client.needs_begin_frame()); 304 EXPECT_TRUE(client.needs_begin_frame());
304 client.Reset(); 305 client.Reset();
305 306
306 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 307 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
307 // to avoid excessive toggles. 308 // to avoid excessive toggles.
308 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 309 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
309 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 310 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
310 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 311 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
311 client.Reset(); 312 client.Reset();
312 313
313 client.task_runner().RunPendingTasks(); // Run posted deadline. 314 client.task_runner().RunPendingTasks(); // Run posted deadline.
314 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 315 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
315 EXPECT_FALSE(client.needs_begin_frame()); 316 EXPECT_FALSE(client.needs_begin_frame());
316 client.Reset(); 317 client.Reset();
317 } 318 }
318 319
319 TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { 320 TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) {
320 FakeSchedulerClient client; 321 FakeSchedulerClient client;
321 SchedulerSettings scheduler_settings; 322 SchedulerSettings scheduler_settings;
322 Scheduler* scheduler = client.CreateScheduler(scheduler_settings); 323 Scheduler* scheduler = client.CreateScheduler(scheduler_settings);
323 scheduler->SetCanStart(); 324 scheduler->SetCanStart();
324 scheduler->SetVisible(true); 325 scheduler->SetVisible(true);
325 scheduler->SetCanDraw(true); 326 scheduler->SetCanDraw(true);
326 327
327 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 328 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
328 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 329 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
329 client.Reset(); 330 client.Reset();
330 331
331 // SetNeedsCommit should begin the frame. 332 // SetNeedsCommit should begin the frame.
332 scheduler->SetNeedsCommit(); 333 scheduler->SetNeedsCommit();
333 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 334 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
334 335
335 client.Reset(); 336 client.Reset();
336 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 337 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
337 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 338 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
338 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 339 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
339 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 340 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
340 341
341 EXPECT_TRUE(client.needs_begin_frame()); 342 EXPECT_TRUE(client.needs_begin_frame());
342 client.Reset(); 343 client.Reset();
343 344
344 // Now SetNeedsCommit again. Calling here means we need a second commit. 345 // Now SetNeedsCommit again. Calling here means we need a second commit.
345 scheduler->SetNeedsCommit(); 346 scheduler->SetNeedsCommit();
346 EXPECT_EQ(client.num_actions_(), 0); 347 EXPECT_EQ(client.num_actions_(), 0);
347 client.Reset(); 348 client.Reset();
348 349
349 // Finish the first commit. 350 // Finish the first commit.
350 scheduler->NotifyBeginMainFrameStarted(); 351 scheduler->NotifyBeginMainFrameStarted();
351 scheduler->NotifyReadyToCommit(); 352 scheduler->NotifyReadyToCommit();
352 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 353 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
353 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 354 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
354 client.Reset(); 355 client.Reset();
355 client.task_runner().RunPendingTasks(); // Run posted deadline. 356 client.task_runner().RunPendingTasks(); // Run posted deadline.
356 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 357 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
357 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 358 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
358 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 359 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
359 360
360 // Because we just swapped, the Scheduler should also request the next 361 // Because we just swapped, the Scheduler should also request the next
361 // BeginImplFrame from the OutputSurface. 362 // BeginImplFrame from the OutputSurface.
362 EXPECT_TRUE(client.needs_begin_frame()); 363 EXPECT_TRUE(client.needs_begin_frame());
363 client.Reset(); 364 client.Reset();
364 // Since another commit is needed, the next BeginImplFrame should initiate 365 // Since another commit is needed, the next BeginImplFrame should initiate
365 // the second commit. 366 // the second commit.
366 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 367 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
367 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 368 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
368 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 369 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
369 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 370 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
370 client.Reset(); 371 client.Reset();
371 372
372 // Finishing the commit before the deadline should post a new deadline task 373 // Finishing the commit before the deadline should post a new deadline task
373 // to trigger the deadline early. 374 // to trigger the deadline early.
374 scheduler->NotifyBeginMainFrameStarted(); 375 scheduler->NotifyBeginMainFrameStarted();
375 scheduler->NotifyReadyToCommit(); 376 scheduler->NotifyReadyToCommit();
376 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 377 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
377 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 378 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
378 client.Reset(); 379 client.Reset();
379 client.task_runner().RunPendingTasks(); // Run posted deadline. 380 client.task_runner().RunPendingTasks(); // Run posted deadline.
380 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 381 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
381 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 382 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
382 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 383 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
383 EXPECT_TRUE(client.needs_begin_frame()); 384 EXPECT_TRUE(client.needs_begin_frame());
384 client.Reset(); 385 client.Reset();
385 386
386 // On the next BeginImplFrame, verify we go back to a quiescent state and 387 // On the next BeginImplFrame, verify we go back to a quiescent state and
387 // no longer request BeginImplFrames. 388 // no longer request BeginImplFrames.
388 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 389 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
389 client.task_runner().RunPendingTasks(); // Run posted deadline. 390 client.task_runner().RunPendingTasks(); // Run posted deadline.
390 EXPECT_FALSE(client.needs_begin_frame()); 391 EXPECT_FALSE(client.needs_begin_frame());
391 client.Reset(); 392 client.Reset();
392 } 393 }
393 394
394 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { 395 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
395 public: 396 public:
396 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {} 397 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {}
397 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() 398 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible()
398 OVERRIDE { 399 OVERRIDE {
(...skipping 28 matching lines...) Expand all
427 scheduler->SetVisible(true); 428 scheduler->SetVisible(true);
428 scheduler->SetCanDraw(true); 429 scheduler->SetCanDraw(true);
429 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 430 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
430 client.Reset(); 431 client.Reset();
431 432
432 scheduler->SetNeedsRedraw(); 433 scheduler->SetNeedsRedraw();
433 EXPECT_TRUE(scheduler->RedrawPending()); 434 EXPECT_TRUE(scheduler->RedrawPending());
434 EXPECT_TRUE(client.needs_begin_frame()); 435 EXPECT_TRUE(client.needs_begin_frame());
435 EXPECT_EQ(0, client.num_draws()); 436 EXPECT_EQ(0, client.num_draws());
436 437
437 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 438 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
438 client.task_runner().RunPendingTasks(); // Run posted deadline. 439 client.task_runner().RunPendingTasks(); // Run posted deadline.
439 EXPECT_EQ(1, client.num_draws()); 440 EXPECT_EQ(1, client.num_draws());
440 EXPECT_TRUE(scheduler->RedrawPending()); 441 EXPECT_TRUE(scheduler->RedrawPending());
441 EXPECT_TRUE(client.needs_begin_frame()); 442 EXPECT_TRUE(client.needs_begin_frame());
442 443
443 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 444 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
444 client.task_runner().RunPendingTasks(); // Run posted deadline. 445 client.task_runner().RunPendingTasks(); // Run posted deadline.
445 EXPECT_EQ(2, client.num_draws()); 446 EXPECT_EQ(2, client.num_draws());
446 EXPECT_FALSE(scheduler->RedrawPending()); 447 EXPECT_FALSE(scheduler->RedrawPending());
447 EXPECT_TRUE(client.needs_begin_frame()); 448 EXPECT_TRUE(client.needs_begin_frame());
448 449
449 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't 450 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't
450 // swap. 451 // swap.
451 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 452 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
452 client.task_runner().RunPendingTasks(); // Run posted deadline. 453 client.task_runner().RunPendingTasks(); // Run posted deadline.
453 EXPECT_EQ(2, client.num_draws()); 454 EXPECT_EQ(2, client.num_draws());
454 EXPECT_FALSE(scheduler->RedrawPending()); 455 EXPECT_FALSE(scheduler->RedrawPending());
455 EXPECT_FALSE(client.needs_begin_frame()); 456 EXPECT_FALSE(client.needs_begin_frame());
456 } 457 }
457 458
458 // Test that requesting redraw inside a failed draw doesn't lose the request. 459 // Test that requesting redraw inside a failed draw doesn't lose the request.
459 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { 460 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) {
460 SchedulerClientThatsetNeedsDrawInsideDraw client; 461 SchedulerClientThatsetNeedsDrawInsideDraw client;
461 SchedulerSettings default_scheduler_settings; 462 SchedulerSettings default_scheduler_settings;
462 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 463 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
463 scheduler->SetCanStart(); 464 scheduler->SetCanStart();
464 scheduler->SetVisible(true); 465 scheduler->SetVisible(true);
465 scheduler->SetCanDraw(true); 466 scheduler->SetCanDraw(true);
466 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 467 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
467 client.Reset(); 468 client.Reset();
468 469
469 client.SetDrawWillHappen(false); 470 client.SetDrawWillHappen(false);
470 471
471 scheduler->SetNeedsRedraw(); 472 scheduler->SetNeedsRedraw();
472 EXPECT_TRUE(scheduler->RedrawPending()); 473 EXPECT_TRUE(scheduler->RedrawPending());
473 EXPECT_TRUE(client.needs_begin_frame()); 474 EXPECT_TRUE(client.needs_begin_frame());
474 EXPECT_EQ(0, client.num_draws()); 475 EXPECT_EQ(0, client.num_draws());
475 476
476 // Fail the draw. 477 // Fail the draw.
477 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 478 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
478 client.task_runner().RunPendingTasks(); // Run posted deadline. 479 client.task_runner().RunPendingTasks(); // Run posted deadline.
479 EXPECT_EQ(1, client.num_draws()); 480 EXPECT_EQ(1, client.num_draws());
480 481
481 // We have a commit pending and the draw failed, and we didn't lose the redraw 482 // We have a commit pending and the draw failed, and we didn't lose the redraw
482 // request. 483 // request.
483 EXPECT_TRUE(scheduler->CommitPending()); 484 EXPECT_TRUE(scheduler->CommitPending());
484 EXPECT_TRUE(scheduler->RedrawPending()); 485 EXPECT_TRUE(scheduler->RedrawPending());
485 EXPECT_TRUE(client.needs_begin_frame()); 486 EXPECT_TRUE(client.needs_begin_frame());
486 487
487 // Fail the draw again. 488 // Fail the draw again.
488 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 489 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
489 client.task_runner().RunPendingTasks(); // Run posted deadline. 490 client.task_runner().RunPendingTasks(); // Run posted deadline.
490 EXPECT_EQ(2, client.num_draws()); 491 EXPECT_EQ(2, client.num_draws());
491 EXPECT_TRUE(scheduler->CommitPending()); 492 EXPECT_TRUE(scheduler->CommitPending());
492 EXPECT_TRUE(scheduler->RedrawPending()); 493 EXPECT_TRUE(scheduler->RedrawPending());
493 EXPECT_TRUE(client.needs_begin_frame()); 494 EXPECT_TRUE(client.needs_begin_frame());
494 495
495 // Draw successfully. 496 // Draw successfully.
496 client.SetDrawWillHappen(true); 497 client.SetDrawWillHappen(true);
497 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 498 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
498 client.task_runner().RunPendingTasks(); // Run posted deadline. 499 client.task_runner().RunPendingTasks(); // Run posted deadline.
499 EXPECT_EQ(3, client.num_draws()); 500 EXPECT_EQ(3, client.num_draws());
500 EXPECT_TRUE(scheduler->CommitPending()); 501 EXPECT_TRUE(scheduler->CommitPending());
501 EXPECT_FALSE(scheduler->RedrawPending()); 502 EXPECT_FALSE(scheduler->RedrawPending());
502 EXPECT_TRUE(client.needs_begin_frame()); 503 EXPECT_TRUE(client.needs_begin_frame());
503 } 504 }
504 505
505 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient { 506 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient {
506 public: 507 public:
507 SchedulerClientThatSetNeedsCommitInsideDraw() 508 SchedulerClientThatSetNeedsCommitInsideDraw()
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 549 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
549 client.Reset(); 550 client.Reset();
550 551
551 EXPECT_FALSE(client.needs_begin_frame()); 552 EXPECT_FALSE(client.needs_begin_frame());
552 scheduler->SetNeedsRedraw(); 553 scheduler->SetNeedsRedraw();
553 EXPECT_TRUE(scheduler->RedrawPending()); 554 EXPECT_TRUE(scheduler->RedrawPending());
554 EXPECT_EQ(0, client.num_draws()); 555 EXPECT_EQ(0, client.num_draws());
555 EXPECT_TRUE(client.needs_begin_frame()); 556 EXPECT_TRUE(client.needs_begin_frame());
556 557
557 client.SetNeedsCommitOnNextDraw(); 558 client.SetNeedsCommitOnNextDraw();
558 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 559 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
559 client.SetNeedsCommitOnNextDraw(); 560 client.SetNeedsCommitOnNextDraw();
560 client.task_runner().RunPendingTasks(); // Run posted deadline. 561 client.task_runner().RunPendingTasks(); // Run posted deadline.
561 EXPECT_EQ(1, client.num_draws()); 562 EXPECT_EQ(1, client.num_draws());
562 EXPECT_TRUE(scheduler->CommitPending()); 563 EXPECT_TRUE(scheduler->CommitPending());
563 EXPECT_TRUE(client.needs_begin_frame()); 564 EXPECT_TRUE(client.needs_begin_frame());
564 scheduler->NotifyBeginMainFrameStarted(); 565 scheduler->NotifyBeginMainFrameStarted();
565 scheduler->NotifyReadyToCommit(); 566 scheduler->NotifyReadyToCommit();
566 567
567 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 568 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
568 client.task_runner().RunPendingTasks(); // Run posted deadline. 569 client.task_runner().RunPendingTasks(); // Run posted deadline.
569 EXPECT_EQ(2, client.num_draws()); 570 EXPECT_EQ(2, client.num_draws());
570 571
571 EXPECT_FALSE(scheduler->RedrawPending()); 572 EXPECT_FALSE(scheduler->RedrawPending());
572 EXPECT_FALSE(scheduler->CommitPending()); 573 EXPECT_FALSE(scheduler->CommitPending());
573 EXPECT_TRUE(client.needs_begin_frame()); 574 EXPECT_TRUE(client.needs_begin_frame());
574 575
575 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't 576 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't
576 // swap. 577 // swap.
577 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 578 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
578 client.task_runner().RunPendingTasks(); // Run posted deadline. 579 client.task_runner().RunPendingTasks(); // Run posted deadline.
579 EXPECT_EQ(2, client.num_draws()); 580 EXPECT_EQ(2, client.num_draws());
580 EXPECT_FALSE(scheduler->RedrawPending()); 581 EXPECT_FALSE(scheduler->RedrawPending());
581 EXPECT_FALSE(scheduler->CommitPending()); 582 EXPECT_FALSE(scheduler->CommitPending());
582 EXPECT_FALSE(client.needs_begin_frame()); 583 EXPECT_FALSE(client.needs_begin_frame());
583 } 584 }
584 585
585 // Tests that when a draw fails then the pending commit should not be dropped. 586 // Tests that when a draw fails then the pending commit should not be dropped.
586 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { 587 TEST(SchedulerTest, RequestCommitInsideFailedDraw) {
587 SchedulerClientThatsetNeedsDrawInsideDraw client; 588 SchedulerClientThatsetNeedsDrawInsideDraw client;
588 SchedulerSettings default_scheduler_settings; 589 SchedulerSettings default_scheduler_settings;
589 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 590 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
590 scheduler->SetCanStart(); 591 scheduler->SetCanStart();
591 scheduler->SetVisible(true); 592 scheduler->SetVisible(true);
592 scheduler->SetCanDraw(true); 593 scheduler->SetCanDraw(true);
593 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 594 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
594 client.Reset(); 595 client.Reset();
595 596
596 client.SetDrawWillHappen(false); 597 client.SetDrawWillHappen(false);
597 598
598 scheduler->SetNeedsRedraw(); 599 scheduler->SetNeedsRedraw();
599 EXPECT_TRUE(scheduler->RedrawPending()); 600 EXPECT_TRUE(scheduler->RedrawPending());
600 EXPECT_TRUE(client.needs_begin_frame()); 601 EXPECT_TRUE(client.needs_begin_frame());
601 EXPECT_EQ(0, client.num_draws()); 602 EXPECT_EQ(0, client.num_draws());
602 603
603 // Fail the draw. 604 // Fail the draw.
604 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 605 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
605 client.task_runner().RunPendingTasks(); // Run posted deadline. 606 client.task_runner().RunPendingTasks(); // Run posted deadline.
606 EXPECT_EQ(1, client.num_draws()); 607 EXPECT_EQ(1, client.num_draws());
607 608
608 // We have a commit pending and the draw failed, and we didn't lose the commit 609 // We have a commit pending and the draw failed, and we didn't lose the commit
609 // request. 610 // request.
610 EXPECT_TRUE(scheduler->CommitPending()); 611 EXPECT_TRUE(scheduler->CommitPending());
611 EXPECT_TRUE(scheduler->RedrawPending()); 612 EXPECT_TRUE(scheduler->RedrawPending());
612 EXPECT_TRUE(client.needs_begin_frame()); 613 EXPECT_TRUE(client.needs_begin_frame());
613 614
614 // Fail the draw again. 615 // Fail the draw again.
615 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 616 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
616 617
617 client.task_runner().RunPendingTasks(); // Run posted deadline. 618 client.task_runner().RunPendingTasks(); // Run posted deadline.
618 EXPECT_EQ(2, client.num_draws()); 619 EXPECT_EQ(2, client.num_draws());
619 EXPECT_TRUE(scheduler->CommitPending()); 620 EXPECT_TRUE(scheduler->CommitPending());
620 EXPECT_TRUE(scheduler->RedrawPending()); 621 EXPECT_TRUE(scheduler->RedrawPending());
621 EXPECT_TRUE(client.needs_begin_frame()); 622 EXPECT_TRUE(client.needs_begin_frame());
622 623
623 // Draw successfully. 624 // Draw successfully.
624 client.SetDrawWillHappen(true); 625 client.SetDrawWillHappen(true);
625 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 626 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
626 client.task_runner().RunPendingTasks(); // Run posted deadline. 627 client.task_runner().RunPendingTasks(); // Run posted deadline.
627 EXPECT_EQ(3, client.num_draws()); 628 EXPECT_EQ(3, client.num_draws());
628 EXPECT_TRUE(scheduler->CommitPending()); 629 EXPECT_TRUE(scheduler->CommitPending());
629 EXPECT_FALSE(scheduler->RedrawPending()); 630 EXPECT_FALSE(scheduler->RedrawPending());
630 EXPECT_TRUE(client.needs_begin_frame()); 631 EXPECT_TRUE(client.needs_begin_frame());
631 } 632 }
632 633
633 TEST(SchedulerTest, NoSwapWhenDrawFails) { 634 TEST(SchedulerTest, NoSwapWhenDrawFails) {
634 SchedulerClientThatSetNeedsCommitInsideDraw client; 635 SchedulerClientThatSetNeedsCommitInsideDraw client;
635 SchedulerSettings default_scheduler_settings; 636 SchedulerSettings default_scheduler_settings;
636 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 637 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
637 scheduler->SetCanStart(); 638 scheduler->SetCanStart();
638 scheduler->SetVisible(true); 639 scheduler->SetVisible(true);
639 scheduler->SetCanDraw(true); 640 scheduler->SetCanDraw(true);
640 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 641 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
641 client.Reset(); 642 client.Reset();
642 643
643 scheduler->SetNeedsRedraw(); 644 scheduler->SetNeedsRedraw();
644 EXPECT_TRUE(scheduler->RedrawPending()); 645 EXPECT_TRUE(scheduler->RedrawPending());
645 EXPECT_TRUE(client.needs_begin_frame()); 646 EXPECT_TRUE(client.needs_begin_frame());
646 EXPECT_EQ(0, client.num_draws()); 647 EXPECT_EQ(0, client.num_draws());
647 648
648 // Draw successfully, this starts a new frame. 649 // Draw successfully, this starts a new frame.
649 client.SetNeedsCommitOnNextDraw(); 650 client.SetNeedsCommitOnNextDraw();
650 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 651 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
651 client.task_runner().RunPendingTasks(); // Run posted deadline. 652 client.task_runner().RunPendingTasks(); // Run posted deadline.
652 EXPECT_EQ(1, client.num_draws()); 653 EXPECT_EQ(1, client.num_draws());
653 654
654 scheduler->SetNeedsRedraw(); 655 scheduler->SetNeedsRedraw();
655 EXPECT_TRUE(scheduler->RedrawPending()); 656 EXPECT_TRUE(scheduler->RedrawPending());
656 EXPECT_TRUE(client.needs_begin_frame()); 657 EXPECT_TRUE(client.needs_begin_frame());
657 658
658 // Fail to draw, this should not start a frame. 659 // Fail to draw, this should not start a frame.
659 client.SetDrawWillHappen(false); 660 client.SetDrawWillHappen(false);
660 client.SetNeedsCommitOnNextDraw(); 661 client.SetNeedsCommitOnNextDraw();
661 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 662 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
662 client.task_runner().RunPendingTasks(); // Run posted deadline. 663 client.task_runner().RunPendingTasks(); // Run posted deadline.
663 EXPECT_EQ(2, client.num_draws()); 664 EXPECT_EQ(2, client.num_draws());
664 } 665 }
665 666
666 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) { 667 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) {
667 FakeSchedulerClient client; 668 FakeSchedulerClient client;
668 SchedulerSettings default_scheduler_settings; 669 SchedulerSettings default_scheduler_settings;
669 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 670 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
670 671
671 // Tell the client that it will fail to swap. 672 // Tell the client that it will fail to swap.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 EXPECT_TRUE(scheduler->RedrawPending()); 738 EXPECT_TRUE(scheduler->RedrawPending());
738 EXPECT_TRUE(scheduler->ManageTilesPending()); 739 EXPECT_TRUE(scheduler->ManageTilesPending());
739 EXPECT_TRUE(client.needs_begin_frame()); 740 EXPECT_TRUE(client.needs_begin_frame());
740 EXPECT_EQ(0, client.num_draws()); 741 EXPECT_EQ(0, client.num_draws());
741 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 742 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
742 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 743 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
743 744
744 // We have no immediate actions to perform, so the BeginImplFrame should post 745 // We have no immediate actions to perform, so the BeginImplFrame should post
745 // the deadline task. 746 // the deadline task.
746 client.Reset(); 747 client.Reset();
747 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 748 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
748 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 749 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
749 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 750 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
750 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 751 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
751 752
752 // On the deadline, he actions should have occured in the right order. 753 // On the deadline, he actions should have occured in the right order.
753 client.Reset(); 754 client.Reset();
754 client.task_runner().RunPendingTasks(); // Run posted deadline. 755 client.task_runner().RunPendingTasks(); // Run posted deadline.
755 EXPECT_EQ(1, client.num_draws()); 756 EXPECT_EQ(1, client.num_draws());
756 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 757 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
757 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 758 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
758 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 759 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
759 client.ActionIndex("ScheduledActionManageTiles")); 760 client.ActionIndex("ScheduledActionManageTiles"));
760 EXPECT_FALSE(scheduler->RedrawPending()); 761 EXPECT_FALSE(scheduler->RedrawPending());
761 EXPECT_FALSE(scheduler->ManageTilesPending()); 762 EXPECT_FALSE(scheduler->ManageTilesPending());
762 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 763 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
763 764
764 // Request a draw. We don't need a ManageTiles yet. 765 // Request a draw. We don't need a ManageTiles yet.
765 client.Reset(); 766 client.Reset();
766 scheduler->SetNeedsRedraw(); 767 scheduler->SetNeedsRedraw();
767 EXPECT_TRUE(scheduler->RedrawPending()); 768 EXPECT_TRUE(scheduler->RedrawPending());
768 EXPECT_FALSE(scheduler->ManageTilesPending()); 769 EXPECT_FALSE(scheduler->ManageTilesPending());
769 EXPECT_TRUE(client.needs_begin_frame()); 770 EXPECT_TRUE(client.needs_begin_frame());
770 EXPECT_EQ(0, client.num_draws()); 771 EXPECT_EQ(0, client.num_draws());
771 772
772 // We have no immediate actions to perform, so the BeginImplFrame should post 773 // We have no immediate actions to perform, so the BeginImplFrame should post
773 // the deadline task. 774 // the deadline task.
774 client.Reset(); 775 client.Reset();
775 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 776 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
776 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 777 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
777 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 778 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
778 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 779 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
779 780
780 // Draw. The draw will trigger SetNeedsManageTiles, and 781 // Draw. The draw will trigger SetNeedsManageTiles, and
781 // then the ManageTiles action will be triggered after the Draw. 782 // then the ManageTiles action will be triggered after the Draw.
782 // Afterwards, neither a draw nor ManageTiles are pending. 783 // Afterwards, neither a draw nor ManageTiles are pending.
783 client.Reset(); 784 client.Reset();
784 client.task_runner().RunPendingTasks(); // Run posted deadline. 785 client.task_runner().RunPendingTasks(); // Run posted deadline.
785 EXPECT_EQ(1, client.num_draws()); 786 EXPECT_EQ(1, client.num_draws());
786 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 787 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
787 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 788 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
788 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 789 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
789 client.ActionIndex("ScheduledActionManageTiles")); 790 client.ActionIndex("ScheduledActionManageTiles"));
790 EXPECT_FALSE(scheduler->RedrawPending()); 791 EXPECT_FALSE(scheduler->RedrawPending());
791 EXPECT_FALSE(scheduler->ManageTilesPending()); 792 EXPECT_FALSE(scheduler->ManageTilesPending());
792 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 793 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
793 794
794 // We need a BeginImplFrame where we don't swap to go idle. 795 // We need a BeginImplFrame where we don't swap to go idle.
795 client.Reset(); 796 client.Reset();
796 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 797 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
797 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 798 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
798 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 799 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
799 client.Reset(); 800 client.Reset();
800 client.task_runner().RunPendingTasks(); // Run posted deadline. 801 client.task_runner().RunPendingTasks(); // Run posted deadline.
801 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 802 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
802 EXPECT_FALSE(client.needs_begin_frame()); 803 EXPECT_FALSE(client.needs_begin_frame());
803 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 804 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
804 EXPECT_EQ(0, client.num_draws()); 805 EXPECT_EQ(0, client.num_draws());
805 806
806 // Now trigger a ManageTiles outside of a draw. We will then need 807 // Now trigger a ManageTiles outside of a draw. We will then need
807 // a begin-frame for the ManageTiles, but we don't need a draw. 808 // a begin-frame for the ManageTiles, but we don't need a draw.
808 client.Reset(); 809 client.Reset();
809 EXPECT_FALSE(client.needs_begin_frame()); 810 EXPECT_FALSE(client.needs_begin_frame());
810 scheduler->SetNeedsManageTiles(); 811 scheduler->SetNeedsManageTiles();
811 EXPECT_TRUE(client.needs_begin_frame()); 812 EXPECT_TRUE(client.needs_begin_frame());
812 EXPECT_TRUE(scheduler->ManageTilesPending()); 813 EXPECT_TRUE(scheduler->ManageTilesPending());
813 EXPECT_FALSE(scheduler->RedrawPending()); 814 EXPECT_FALSE(scheduler->RedrawPending());
814 815
815 // BeginImplFrame. There will be no draw, only ManageTiles. 816 // BeginImplFrame. There will be no draw, only ManageTiles.
816 client.Reset(); 817 client.Reset();
817 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 818 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
818 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 819 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
819 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 820 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
820 client.Reset(); 821 client.Reset();
821 client.task_runner().RunPendingTasks(); // Run posted deadline. 822 client.task_runner().RunPendingTasks(); // Run posted deadline.
822 EXPECT_EQ(0, client.num_draws()); 823 EXPECT_EQ(0, client.num_draws());
823 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 824 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
824 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 825 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
825 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 826 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
826 } 827 }
827 828
828 // Test that ManageTiles only happens once per frame. If an external caller 829 // Test that ManageTiles only happens once per frame. If an external caller
829 // initiates it, then the state machine should not ManageTiles on that frame. 830 // initiates it, then the state machine should not ManageTiles on that frame.
830 TEST(SchedulerTest, ManageTilesOncePerFrame) { 831 TEST(SchedulerTest, ManageTilesOncePerFrame) {
831 FakeSchedulerClient client; 832 FakeSchedulerClient client;
832 SchedulerSettings default_scheduler_settings; 833 SchedulerSettings default_scheduler_settings;
833 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 834 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
834 scheduler->SetCanStart(); 835 scheduler->SetCanStart();
835 scheduler->SetVisible(true); 836 scheduler->SetVisible(true);
836 scheduler->SetCanDraw(true); 837 scheduler->SetCanDraw(true);
837 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 838 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
838 839
839 // If DidManageTiles during a frame, then ManageTiles should not occur again. 840 // If DidManageTiles during a frame, then ManageTiles should not occur again.
840 scheduler->SetNeedsManageTiles(); 841 scheduler->SetNeedsManageTiles();
841 scheduler->SetNeedsRedraw(); 842 scheduler->SetNeedsRedraw();
842 client.Reset(); 843 client.Reset();
843 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 844 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
844 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 845 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
845 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 846 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
846 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 847 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
847 848
848 EXPECT_TRUE(scheduler->ManageTilesPending()); 849 EXPECT_TRUE(scheduler->ManageTilesPending());
849 scheduler->DidManageTiles(); // An explicit ManageTiles. 850 scheduler->DidManageTiles(); // An explicit ManageTiles.
850 EXPECT_FALSE(scheduler->ManageTilesPending()); 851 EXPECT_FALSE(scheduler->ManageTilesPending());
851 852
852 client.Reset(); 853 client.Reset();
853 client.task_runner().RunPendingTasks(); // Run posted deadline. 854 client.task_runner().RunPendingTasks(); // Run posted deadline.
854 EXPECT_EQ(1, client.num_draws()); 855 EXPECT_EQ(1, client.num_draws());
855 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 856 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
856 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 857 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
857 EXPECT_FALSE(scheduler->RedrawPending()); 858 EXPECT_FALSE(scheduler->RedrawPending());
858 EXPECT_FALSE(scheduler->ManageTilesPending()); 859 EXPECT_FALSE(scheduler->ManageTilesPending());
859 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 860 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
860 861
861 // Next frame without DidManageTiles should ManageTiles with draw. 862 // Next frame without DidManageTiles should ManageTiles with draw.
862 scheduler->SetNeedsManageTiles(); 863 scheduler->SetNeedsManageTiles();
863 scheduler->SetNeedsRedraw(); 864 scheduler->SetNeedsRedraw();
864 client.Reset(); 865 client.Reset();
865 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 866 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
866 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 867 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
867 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 868 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
868 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 869 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
869 870
870 client.Reset(); 871 client.Reset();
871 client.task_runner().RunPendingTasks(); // Run posted deadline. 872 client.task_runner().RunPendingTasks(); // Run posted deadline.
872 EXPECT_EQ(1, client.num_draws()); 873 EXPECT_EQ(1, client.num_draws());
873 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 874 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
874 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 875 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
875 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 876 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
876 client.ActionIndex("ScheduledActionManageTiles")); 877 client.ActionIndex("ScheduledActionManageTiles"));
877 EXPECT_FALSE(scheduler->RedrawPending()); 878 EXPECT_FALSE(scheduler->RedrawPending());
878 EXPECT_FALSE(scheduler->ManageTilesPending()); 879 EXPECT_FALSE(scheduler->ManageTilesPending());
879 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 880 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
880 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles 881 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles
881 882
882 // If we get another DidManageTiles within the same frame, we should 883 // If we get another DidManageTiles within the same frame, we should
883 // not ManageTiles on the next frame. 884 // not ManageTiles on the next frame.
884 scheduler->DidManageTiles(); // An explicit ManageTiles. 885 scheduler->DidManageTiles(); // An explicit ManageTiles.
885 scheduler->SetNeedsManageTiles(); 886 scheduler->SetNeedsManageTiles();
886 scheduler->SetNeedsRedraw(); 887 scheduler->SetNeedsRedraw();
887 client.Reset(); 888 client.Reset();
888 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 889 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
889 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 890 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
890 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 891 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
891 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 892 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
892 893
893 EXPECT_TRUE(scheduler->ManageTilesPending()); 894 EXPECT_TRUE(scheduler->ManageTilesPending());
894 895
895 client.Reset(); 896 client.Reset();
896 client.task_runner().RunPendingTasks(); // Run posted deadline. 897 client.task_runner().RunPendingTasks(); // Run posted deadline.
897 EXPECT_EQ(1, client.num_draws()); 898 EXPECT_EQ(1, client.num_draws());
898 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 899 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
899 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 900 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
900 EXPECT_FALSE(scheduler->RedrawPending()); 901 EXPECT_FALSE(scheduler->RedrawPending());
901 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 902 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
902 903
903 // If we get another DidManageTiles, we should not ManageTiles on the next 904 // If we get another DidManageTiles, we should not ManageTiles on the next
904 // frame. This verifies we don't alternate calling ManageTiles once and twice. 905 // frame. This verifies we don't alternate calling ManageTiles once and twice.
905 EXPECT_TRUE(scheduler->ManageTilesPending()); 906 EXPECT_TRUE(scheduler->ManageTilesPending());
906 scheduler->DidManageTiles(); // An explicit ManageTiles. 907 scheduler->DidManageTiles(); // An explicit ManageTiles.
907 EXPECT_FALSE(scheduler->ManageTilesPending()); 908 EXPECT_FALSE(scheduler->ManageTilesPending());
908 scheduler->SetNeedsManageTiles(); 909 scheduler->SetNeedsManageTiles();
909 scheduler->SetNeedsRedraw(); 910 scheduler->SetNeedsRedraw();
910 client.Reset(); 911 client.Reset();
911 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 912 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
912 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 913 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
913 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 914 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
914 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 915 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
915 916
916 EXPECT_TRUE(scheduler->ManageTilesPending()); 917 EXPECT_TRUE(scheduler->ManageTilesPending());
917 918
918 client.Reset(); 919 client.Reset();
919 client.task_runner().RunPendingTasks(); // Run posted deadline. 920 client.task_runner().RunPendingTasks(); // Run posted deadline.
920 EXPECT_EQ(1, client.num_draws()); 921 EXPECT_EQ(1, client.num_draws());
921 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 922 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
922 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 923 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
923 EXPECT_FALSE(scheduler->RedrawPending()); 924 EXPECT_FALSE(scheduler->RedrawPending());
924 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 925 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
925 926
926 // Next frame without DidManageTiles should ManageTiles with draw. 927 // Next frame without DidManageTiles should ManageTiles with draw.
927 scheduler->SetNeedsManageTiles(); 928 scheduler->SetNeedsManageTiles();
928 scheduler->SetNeedsRedraw(); 929 scheduler->SetNeedsRedraw();
929 client.Reset(); 930 client.Reset();
930 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 931 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
931 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 932 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
932 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 933 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
933 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 934 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
934 935
935 client.Reset(); 936 client.Reset();
936 client.task_runner().RunPendingTasks(); // Run posted deadline. 937 client.task_runner().RunPendingTasks(); // Run posted deadline.
937 EXPECT_EQ(1, client.num_draws()); 938 EXPECT_EQ(1, client.num_draws());
938 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 939 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
939 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 940 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
940 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 941 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
941 client.ActionIndex("ScheduledActionManageTiles")); 942 client.ActionIndex("ScheduledActionManageTiles"));
942 EXPECT_FALSE(scheduler->RedrawPending()); 943 EXPECT_FALSE(scheduler->RedrawPending());
943 EXPECT_FALSE(scheduler->ManageTilesPending()); 944 EXPECT_FALSE(scheduler->ManageTilesPending());
944 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 945 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
945 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles 946 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles
946 } 947 }
947 948
948 TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) { 949 TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) {
949 SchedulerClientNeedsManageTilesInDraw client; 950 SchedulerClientNeedsManageTilesInDraw client;
950 SchedulerSettings default_scheduler_settings; 951 SchedulerSettings default_scheduler_settings;
951 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 952 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
952 scheduler->SetCanStart(); 953 scheduler->SetCanStart();
953 scheduler->SetVisible(true); 954 scheduler->SetVisible(true);
954 scheduler->SetCanDraw(true); 955 scheduler->SetCanDraw(true);
955 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 956 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
956 957
957 client.Reset(); 958 client.Reset();
958 scheduler->SetNeedsRedraw(); 959 scheduler->SetNeedsRedraw();
959 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 960 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
960 961
961 // The deadline should be zero since there is no work other than drawing 962 // The deadline should be zero since there is no work other than drawing
962 // pending. 963 // pending.
963 EXPECT_EQ(base::TimeTicks(), client.posted_begin_impl_frame_deadline()); 964 EXPECT_EQ(base::TimeTicks(), client.posted_begin_impl_frame_deadline());
964 } 965 }
965 966
966 class SchedulerClientWithFixedEstimates : public FakeSchedulerClient { 967 class SchedulerClientWithFixedEstimates : public FakeSchedulerClient {
967 public: 968 public:
968 SchedulerClientWithFixedEstimates( 969 SchedulerClientWithFixedEstimates(
969 base::TimeDelta draw_duration, 970 base::TimeDelta draw_duration,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 scheduler->SetCanStart(); 1006 scheduler->SetCanStart();
1006 scheduler->SetVisible(true); 1007 scheduler->SetVisible(true);
1007 scheduler->SetCanDraw(true); 1008 scheduler->SetCanDraw(true);
1008 scheduler->SetSmoothnessTakesPriority(smoothness_takes_priority); 1009 scheduler->SetSmoothnessTakesPriority(smoothness_takes_priority);
1009 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1010 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1010 1011
1011 // Impl thread hits deadline before commit finishes. 1012 // Impl thread hits deadline before commit finishes.
1012 client.Reset(); 1013 client.Reset();
1013 scheduler->SetNeedsCommit(); 1014 scheduler->SetNeedsCommit();
1014 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1015 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1015 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 1016 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
1016 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1017 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1017 client.task_runner().RunPendingTasks(); // Run posted deadline. 1018 client.task_runner().RunPendingTasks(); // Run posted deadline.
1018 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1019 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1019 scheduler->NotifyBeginMainFrameStarted(); 1020 scheduler->NotifyBeginMainFrameStarted();
1020 scheduler->NotifyReadyToCommit(); 1021 scheduler->NotifyReadyToCommit();
1021 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1022 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1022 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame")); 1023 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame"));
1023 1024
1024 client.Reset(); 1025 client.Reset();
1025 scheduler->SetNeedsCommit(); 1026 scheduler->SetNeedsCommit();
1026 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1027 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1027 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 1028 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
1028 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1029 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1029 client.task_runner().RunPendingTasks(); // Run posted deadline. 1030 client.task_runner().RunPendingTasks(); // Run posted deadline.
1030 EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(), 1031 EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(),
1031 should_send_begin_main_frame); 1032 should_send_begin_main_frame);
1032 EXPECT_EQ(client.HasAction("ScheduledActionSendBeginMainFrame"), 1033 EXPECT_EQ(client.HasAction("ScheduledActionSendBeginMainFrame"),
1033 should_send_begin_main_frame); 1034 should_send_begin_main_frame);
1034 } 1035 }
1035 1036
1036 TEST(SchedulerTest, 1037 TEST(SchedulerTest,
1037 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) { 1038 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 scheduler->SetCanStart(); 1075 scheduler->SetCanStart();
1075 scheduler->SetVisible(true); 1076 scheduler->SetVisible(true);
1076 scheduler->DidCreateAndInitializeOutputSurface(); 1077 scheduler->DidCreateAndInitializeOutputSurface();
1077 1078
1078 scheduler->SetNeedsCommit(); 1079 scheduler->SetNeedsCommit();
1079 EXPECT_TRUE(scheduler->CommitPending()); 1080 EXPECT_TRUE(scheduler->CommitPending());
1080 scheduler->NotifyBeginMainFrameStarted(); 1081 scheduler->NotifyBeginMainFrameStarted();
1081 scheduler->NotifyReadyToCommit(); 1082 scheduler->NotifyReadyToCommit();
1082 scheduler->SetNeedsRedraw(); 1083 scheduler->SetNeedsRedraw();
1083 1084
1084 BeginFrameArgs frame_args = BeginFrameArgs::CreateForTesting(); 1085 BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting();
1085 frame_args.interval = base::TimeDelta::FromMilliseconds(1000); 1086 frame_args.interval = base::TimeDelta::FromMilliseconds(1000);
1086 scheduler->BeginFrame(frame_args); 1087 scheduler->BeginFrame(frame_args);
1087 1088
1088 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1089 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1089 client.task_runner().RunPendingTasks(); // Run posted deadline. 1090 client.task_runner().RunPendingTasks(); // Run posted deadline.
1090 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1091 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1091 1092
1092 scheduler->DidSwapBuffers(); 1093 scheduler->DidSwapBuffers();
1093 scheduler->DidSwapBuffersComplete(); 1094 scheduler->DidSwapBuffersComplete();
1094 1095
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1148
1148 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1149 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1149 client.Reset(); 1150 client.Reset();
1150 scheduler->SetNeedsCommit(); 1151 scheduler->SetNeedsCommit();
1151 EXPECT_TRUE(client.needs_begin_frame()); 1152 EXPECT_TRUE(client.needs_begin_frame());
1152 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1153 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1153 client.Reset(); 1154 client.Reset();
1154 1155
1155 // Create a BeginFrame with a long deadline to avoid race conditions. 1156 // Create a BeginFrame with a long deadline to avoid race conditions.
1156 // This is the first BeginFrame, which will be handled immediately. 1157 // This is the first BeginFrame, which will be handled immediately.
1157 BeginFrameArgs args = BeginFrameArgs::CreateForTesting(); 1158 BeginFrameArgs args = CreateBeginFrameArgsForTesting();
1158 args.deadline += base::TimeDelta::FromHours(1); 1159 args.deadline += base::TimeDelta::FromHours(1);
1159 scheduler->BeginFrame(args); 1160 scheduler->BeginFrame(args);
1160 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1161 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1161 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1162 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1162 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1163 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1163 EXPECT_TRUE(client.needs_begin_frame()); 1164 EXPECT_TRUE(client.needs_begin_frame());
1164 client.Reset(); 1165 client.Reset();
1165 1166
1166 // Queue BeginFrames while we are still handling the previous BeginFrame. 1167 // Queue BeginFrames while we are still handling the previous BeginFrame.
1167 args.frame_time += base::TimeDelta::FromSeconds(1); 1168 args.frame_time += base::TimeDelta::FromSeconds(1);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 1227
1227 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1228 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1228 client.Reset(); 1229 client.Reset();
1229 scheduler->SetNeedsCommit(); 1230 scheduler->SetNeedsCommit();
1230 EXPECT_TRUE(client.needs_begin_frame()); 1231 EXPECT_TRUE(client.needs_begin_frame());
1231 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1232 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1232 client.Reset(); 1233 client.Reset();
1233 1234
1234 // Create a BeginFrame with a long deadline to avoid race conditions. 1235 // Create a BeginFrame with a long deadline to avoid race conditions.
1235 // This is the first BeginFrame, which will be handled immediately. 1236 // This is the first BeginFrame, which will be handled immediately.
1236 BeginFrameArgs args = BeginFrameArgs::CreateForTesting(); 1237 BeginFrameArgs args = CreateBeginFrameArgsForTesting();
1237 args.deadline += base::TimeDelta::FromHours(1); 1238 args.deadline += base::TimeDelta::FromHours(1);
1238 scheduler->BeginFrame(args); 1239 scheduler->BeginFrame(args);
1239 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1240 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1240 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1241 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1241 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1242 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1242 EXPECT_TRUE(client.needs_begin_frame()); 1243 EXPECT_TRUE(client.needs_begin_frame());
1243 client.Reset(); 1244 client.Reset();
1244 1245
1245 // Queue BeginFrame while we are still handling the previous BeginFrame. 1246 // Queue BeginFrame while we are still handling the previous BeginFrame.
1246 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1247 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 TEST(SchedulerTest, 1485 TEST(SchedulerTest,
1485 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { 1486 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) {
1486 bool begin_frame_scheduling_enabled = false; 1487 bool begin_frame_scheduling_enabled = false;
1487 bool throttle_frame_production = false; 1488 bool throttle_frame_production = false;
1488 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, 1489 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled,
1489 throttle_frame_production); 1490 throttle_frame_production);
1490 } 1491 }
1491 1492
1492 } // namespace 1493 } // namespace
1493 } // namespace cc 1494 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/test/begin_frame_args_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698