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

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

Issue 2323123002: Make disable vsync run the renderer independently (Closed)
Patch Set: With additional comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 bool automatic_swap_ack_; 208 bool automatic_swap_ack_;
209 int num_draws_; 209 int num_draws_;
210 BeginFrameArgs last_begin_main_frame_args_; 210 BeginFrameArgs last_begin_main_frame_args_;
211 base::TimeTicks posted_begin_impl_frame_deadline_; 211 base::TimeTicks posted_begin_impl_frame_deadline_;
212 std::vector<const char*> actions_; 212 std::vector<const char*> actions_;
213 std::vector<std::unique_ptr<base::trace_event::ConvertableToTraceFormat>> 213 std::vector<std::unique_ptr<base::trace_event::ConvertableToTraceFormat>>
214 states_; 214 states_;
215 TestScheduler* scheduler_; 215 TestScheduler* scheduler_;
216 }; 216 };
217 217
218 enum BeginFrameSourceType {
219 EXTERNAL_BFS,
220 UNTHROTTLED_BFS,
221 THROTTLED_BFS,
222 };
223
218 class SchedulerTest : public testing::Test { 224 class SchedulerTest : public testing::Test {
219 public: 225 public:
220 SchedulerTest() 226 SchedulerTest()
221 : now_src_(new base::SimpleTestTickClock()), 227 : now_src_(new base::SimpleTestTickClock()),
222 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)), 228 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)),
223 fake_external_begin_frame_source_(nullptr) { 229 fake_external_begin_frame_source_(nullptr) {
224 now_src_->Advance(base::TimeDelta::FromMicroseconds(10000)); 230 now_src_->Advance(base::TimeDelta::FromMicroseconds(10000));
225 // A bunch of tests require NowTicks() 231 // A bunch of tests require NowTicks()
226 // to be > BeginFrameArgs::DefaultInterval() 232 // to be > BeginFrameArgs::DefaultInterval()
227 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); 233 now_src_->Advance(base::TimeDelta::FromMilliseconds(100));
228 // Fail if we need to run 100 tasks in a row. 234 // Fail if we need to run 100 tasks in a row.
229 task_runner_->SetRunTaskLimit(100); 235 task_runner_->SetRunTaskLimit(100);
230 } 236 }
231 237
232 ~SchedulerTest() override {} 238 ~SchedulerTest() override {}
233 239
234 protected: 240 protected:
235 TestScheduler* CreateScheduler() { 241 TestScheduler* CreateScheduler(BeginFrameSourceType bfs_type) {
236 BeginFrameSource* frame_source; 242 BeginFrameSource* frame_source = nullptr;
237 unthrottled_frame_source_.reset(new BackToBackBeginFrameSource( 243 unthrottled_frame_source_.reset(new BackToBackBeginFrameSource(
238 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), 244 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(),
239 task_runner_.get()))); 245 task_runner_.get())));
240 fake_external_begin_frame_source_.reset( 246 fake_external_begin_frame_source_.reset(
241 new FakeExternalBeginFrameSource(0.f, false)); 247 new FakeExternalBeginFrameSource(0.f, false));
242 fake_external_begin_frame_source_->SetClient(client_.get()); 248 fake_external_begin_frame_source_->SetClient(client_.get());
243 synthetic_frame_source_.reset(new DelayBasedBeginFrameSource( 249 synthetic_frame_source_.reset(new DelayBasedBeginFrameSource(
244 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), 250 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(),
245 task_runner_.get()))); 251 task_runner_.get())));
246 if (!scheduler_settings_.throttle_frame_production) { 252 switch (bfs_type) {
247 frame_source = unthrottled_frame_source_.get(); 253 case EXTERNAL_BFS:
248 } else if (scheduler_settings_.use_external_begin_frame_source) { 254 frame_source = fake_external_begin_frame_source_.get();
249 frame_source = fake_external_begin_frame_source_.get(); 255 break;
250 } else { 256 case UNTHROTTLED_BFS:
251 frame_source = synthetic_frame_source_.get(); 257 frame_source = unthrottled_frame_source_.get();
258 break;
259 case THROTTLED_BFS:
260 frame_source = synthetic_frame_source_.get();
261 break;
252 } 262 }
263 DCHECK(frame_source);
253 264
254 std::unique_ptr<FakeCompositorTimingHistory> 265 std::unique_ptr<FakeCompositorTimingHistory>
255 fake_compositor_timing_history = FakeCompositorTimingHistory::Create( 266 fake_compositor_timing_history = FakeCompositorTimingHistory::Create(
256 scheduler_settings_.using_synchronous_renderer_compositor); 267 scheduler_settings_.using_synchronous_renderer_compositor);
257 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); 268 fake_compositor_timing_history_ = fake_compositor_timing_history.get();
258 269
259 scheduler_.reset( 270 scheduler_.reset(
260 new TestScheduler(now_src_.get(), client_.get(), scheduler_settings_, 0, 271 new TestScheduler(now_src_.get(), client_.get(), scheduler_settings_, 0,
261 task_runner_.get(), frame_source, 272 task_runner_.get(), frame_source,
262 std::move(fake_compositor_timing_history))); 273 std::move(fake_compositor_timing_history)));
263 DCHECK(scheduler_); 274 DCHECK(scheduler_);
264 client_->set_scheduler(scheduler_.get()); 275 client_->set_scheduler(scheduler_.get());
265 276
266 // Use large estimates by default to avoid latency recovery in most tests. 277 // Use large estimates by default to avoid latency recovery in most tests.
267 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); 278 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration);
268 279
269 return scheduler_.get(); 280 return scheduler_.get();
270 } 281 }
271 282
272 void CreateSchedulerAndInitSurface() { 283 void SetUpScheduler(BeginFrameSourceType bfs_type,
273 CreateScheduler(); 284 std::unique_ptr<FakeSchedulerClient> client) {
285 client_ = std::move(client);
286 CreateScheduler(bfs_type);
274 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); 287 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit());
275 } 288 }
276 289
277 void SetUpScheduler(bool initSurface) { 290 void SetUpScheduler(BeginFrameSourceType bfs_type) {
278 SetUpScheduler(base::WrapUnique(new FakeSchedulerClient), initSurface); 291 SetUpScheduler(bfs_type, base::MakeUnique<FakeSchedulerClient>());
279 } 292 }
280 293
281 void SetUpScheduler(std::unique_ptr<FakeSchedulerClient> client, 294 void SetUpSchedulerWithNoOutputSurface(BeginFrameSourceType bfs_type) {
282 bool initSurface) { 295 client_ = base::MakeUnique<FakeSchedulerClient>();
283 client_ = std::move(client); 296 CreateScheduler(bfs_type);
284 if (initSurface)
285 CreateSchedulerAndInitSurface();
286 else
287 CreateScheduler();
288 } 297 }
289 298
290 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } 299 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; }
291 base::SimpleTestTickClock* now_src() { return now_src_.get(); } 300 base::SimpleTestTickClock* now_src() { return now_src_.get(); }
292 301
293 // As this function contains EXPECT macros, to allow debugging it should be 302 // As this function contains EXPECT macros, to allow debugging it should be
294 // called inside EXPECT_SCOPED like so; 303 // called inside EXPECT_SCOPED like so;
295 // EXPECT_SCOPED(client.InitializeOutputSurfaceAndFirstCommit(scheduler)); 304 // EXPECT_SCOPED(client.InitializeOutputSurfaceAndFirstCommit(scheduler));
296 void InitializeOutputSurfaceAndFirstCommit() { 305 void InitializeOutputSurfaceAndFirstCommit() {
297 TRACE_EVENT0("cc", 306 TRACE_EVENT0("cc",
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return args; 410 return args;
402 } 411 }
403 412
404 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { 413 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const {
405 return fake_external_begin_frame_source_.get(); 414 return fake_external_begin_frame_source_.get();
406 } 415 }
407 416
408 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); 417 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame);
409 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline); 418 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline);
410 void ImplFrameNotSkippedAfterLateSwapAck(); 419 void ImplFrameNotSkippedAfterLateSwapAck();
411 void BeginFramesNotFromClient(bool use_external_begin_frame_source, 420 void BeginFramesNotFromClient(BeginFrameSourceType bfs_type);
412 bool throttle_frame_production); 421 void BeginFramesNotFromClient_SwapThrottled(BeginFrameSourceType bfs_type);
413 void BeginFramesNotFromClient_SwapThrottled(
414 bool use_external_begin_frame_source,
415 bool throttle_frame_production);
416 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, 422 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority,
417 ScrollHandlerState scroll_handler_state, 423 ScrollHandlerState scroll_handler_state,
418 base::TimeDelta durations); 424 base::TimeDelta durations);
419 425
420 std::unique_ptr<base::SimpleTestTickClock> now_src_; 426 std::unique_ptr<base::SimpleTestTickClock> now_src_;
421 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; 427 scoped_refptr<OrderedSimpleTaskRunner> task_runner_;
422 std::unique_ptr<FakeExternalBeginFrameSource> 428 std::unique_ptr<FakeExternalBeginFrameSource>
423 fake_external_begin_frame_source_; 429 fake_external_begin_frame_source_;
424 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; 430 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_;
425 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_; 431 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_;
426 SchedulerSettings scheduler_settings_; 432 SchedulerSettings scheduler_settings_;
427 std::unique_ptr<FakeSchedulerClient> client_; 433 std::unique_ptr<FakeSchedulerClient> client_;
428 std::unique_ptr<TestScheduler> scheduler_; 434 std::unique_ptr<TestScheduler> scheduler_;
429 FakeCompositorTimingHistory* fake_compositor_timing_history_; 435 FakeCompositorTimingHistory* fake_compositor_timing_history_;
430 }; 436 };
431 437
432 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { 438 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
433 scheduler_settings_.use_external_begin_frame_source = true; 439 SetUpSchedulerWithNoOutputSurface(EXTERNAL_BFS);
434 SetUpScheduler(false);
435 scheduler_->SetVisible(true); 440 scheduler_->SetVisible(true);
436 scheduler_->SetCanDraw(true); 441 scheduler_->SetCanDraw(true);
437 442
438 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 443 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
439 client_->Reset(); 444 client_->Reset();
440 scheduler_->DidCreateAndInitializeOutputSurface(); 445 scheduler_->DidCreateAndInitializeOutputSurface();
441 EXPECT_NO_ACTION(client_); 446 EXPECT_NO_ACTION(client_);
442 } 447 }
443 448
444 TEST_F(SchedulerTest, VideoNeedsBeginFrames) { 449 TEST_F(SchedulerTest, VideoNeedsBeginFrames) {
445 scheduler_settings_.use_external_begin_frame_source = true; 450 SetUpScheduler(EXTERNAL_BFS);
446 SetUpScheduler(true);
447 451
448 scheduler_->SetVideoNeedsBeginFrames(true); 452 scheduler_->SetVideoNeedsBeginFrames(true);
449 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 453 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
450 EXPECT_TRUE(scheduler_->begin_frames_expected()); 454 EXPECT_TRUE(scheduler_->begin_frames_expected());
451 455
452 client_->Reset(); 456 client_->Reset();
453 EXPECT_SCOPED(AdvanceFrame()); 457 EXPECT_SCOPED(AdvanceFrame());
454 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 458 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
455 // WillBeginImplFrame is responsible for sending BeginFrames to video. 459 // WillBeginImplFrame is responsible for sending BeginFrames to video.
456 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 460 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
457 461
458 client_->Reset(); 462 client_->Reset();
459 EXPECT_SCOPED(AdvanceFrame()); 463 EXPECT_SCOPED(AdvanceFrame());
460 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 464 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
461 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 465 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
462 466
463 client_->Reset(); 467 client_->Reset();
464 scheduler_->SetVideoNeedsBeginFrames(false); 468 scheduler_->SetVideoNeedsBeginFrames(false);
465 EXPECT_NO_ACTION(client_); 469 EXPECT_NO_ACTION(client_);
466 470
467 client_->Reset(); 471 client_->Reset();
468 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); 472 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
469 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 473 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
470 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); 474 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
471 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 475 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
472 EXPECT_FALSE(scheduler_->begin_frames_expected()); 476 EXPECT_FALSE(scheduler_->begin_frames_expected());
473 } 477 }
474 478
475 TEST_F(SchedulerTest, RequestCommit) { 479 TEST_F(SchedulerTest, RequestCommit) {
476 scheduler_settings_.use_external_begin_frame_source = true; 480 SetUpScheduler(EXTERNAL_BFS);
477 SetUpScheduler(true);
478 481
479 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 482 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
480 scheduler_->SetNeedsBeginMainFrame(); 483 scheduler_->SetNeedsBeginMainFrame();
481 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 484 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
482 client_->Reset(); 485 client_->Reset();
483 486
484 EXPECT_SCOPED(AdvanceFrame()); 487 EXPECT_SCOPED(AdvanceFrame());
485 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 488 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
486 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 489 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
487 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 490 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 532 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
530 client_->Reset(); 533 client_->Reset();
531 534
532 task_runner().RunPendingTasks(); // Run posted deadline. 535 task_runner().RunPendingTasks(); // Run posted deadline.
533 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); 536 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
534 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 537 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
535 client_->Reset(); 538 client_->Reset();
536 } 539 }
537 540
538 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { 541 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) {
539 scheduler_settings_.use_external_begin_frame_source = true; 542 SetUpScheduler(EXTERNAL_BFS);
540 SetUpScheduler(true);
541 543
542 scheduler_->SetDeferCommits(true); 544 scheduler_->SetDeferCommits(true);
543 545
544 scheduler_->SetNeedsBeginMainFrame(); 546 scheduler_->SetNeedsBeginMainFrame();
545 EXPECT_NO_ACTION(client_); 547 EXPECT_NO_ACTION(client_);
546 548
547 client_->Reset(); 549 client_->Reset();
548 task_runner().RunPendingTasks(); 550 task_runner().RunPendingTasks();
549 // There are no pending tasks or actions. 551 // There are no pending tasks or actions.
550 EXPECT_NO_ACTION(client_); 552 EXPECT_NO_ACTION(client_);
551 EXPECT_FALSE(scheduler_->begin_frames_expected()); 553 EXPECT_FALSE(scheduler_->begin_frames_expected());
552 554
553 client_->Reset(); 555 client_->Reset();
554 scheduler_->SetDeferCommits(false); 556 scheduler_->SetDeferCommits(false);
555 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 557 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
556 558
557 // Start new BeginMainFrame after defer commit is off. 559 // Start new BeginMainFrame after defer commit is off.
558 client_->Reset(); 560 client_->Reset();
559 EXPECT_SCOPED(AdvanceFrame()); 561 EXPECT_SCOPED(AdvanceFrame());
560 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 562 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
561 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 563 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
562 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 564 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
563 } 565 }
564 566
565 TEST_F(SchedulerTest, DeferCommitWithRedraw) { 567 TEST_F(SchedulerTest, DeferCommitWithRedraw) {
566 scheduler_settings_.use_external_begin_frame_source = true; 568 SetUpScheduler(EXTERNAL_BFS);
567 SetUpScheduler(true);
568 569
569 scheduler_->SetDeferCommits(true); 570 scheduler_->SetDeferCommits(true);
570 571
571 scheduler_->SetNeedsBeginMainFrame(); 572 scheduler_->SetNeedsBeginMainFrame();
572 EXPECT_NO_ACTION(client_); 573 EXPECT_NO_ACTION(client_);
573 574
574 // The SetNeedsRedraw will override the SetDeferCommits(true), to allow a 575 // The SetNeedsRedraw will override the SetDeferCommits(true), to allow a
575 // begin frame to be needed. 576 // begin frame to be needed.
576 client_->Reset(); 577 client_->Reset();
577 scheduler_->SetNeedsRedraw(); 578 scheduler_->SetNeedsRedraw();
578 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 579 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
579 580
580 client_->Reset(); 581 client_->Reset();
581 AdvanceFrame(); 582 AdvanceFrame();
582 // BeginMainFrame is not sent during the defer commit is on. 583 // BeginMainFrame is not sent during the defer commit is on.
583 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 584 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
584 585
585 client_->Reset(); 586 client_->Reset();
586 task_runner().RunPendingTasks(); // Run posted deadline. 587 task_runner().RunPendingTasks(); // Run posted deadline.
587 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 588 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
588 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 589 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
589 EXPECT_TRUE(scheduler_->begin_frames_expected()); 590 EXPECT_TRUE(scheduler_->begin_frames_expected());
590 591
591 client_->Reset(); 592 client_->Reset();
592 AdvanceFrame(); 593 AdvanceFrame();
593 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 594 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
594 } 595 }
595 596
596 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { 597 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) {
597 scheduler_settings_.use_external_begin_frame_source = true; 598 SetUpScheduler(EXTERNAL_BFS);
598 SetUpScheduler(true);
599 599
600 // SetNeedsBeginMainFrame should begin the frame. 600 // SetNeedsBeginMainFrame should begin the frame.
601 scheduler_->SetNeedsBeginMainFrame(); 601 scheduler_->SetNeedsBeginMainFrame();
602 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 602 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
603 603
604 client_->Reset(); 604 client_->Reset();
605 EXPECT_SCOPED(AdvanceFrame()); 605 EXPECT_SCOPED(AdvanceFrame());
606 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 606 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
607 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 607 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
608 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 608 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 bool request_redraws_; 694 bool request_redraws_;
695 }; 695 };
696 696
697 // Tests for two different situations: 697 // Tests for two different situations:
698 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside 698 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside
699 // a ScheduledActionDrawAndSwap 699 // a ScheduledActionDrawAndSwap
700 // 2. the scheduler drawing twice inside a single tick 700 // 2. the scheduler drawing twice inside a single tick
701 TEST_F(SchedulerTest, RequestRedrawInsideDraw) { 701 TEST_F(SchedulerTest, RequestRedrawInsideDraw) {
702 SchedulerClientThatsetNeedsDrawInsideDraw* client = 702 SchedulerClientThatsetNeedsDrawInsideDraw* client =
703 new SchedulerClientThatsetNeedsDrawInsideDraw; 703 new SchedulerClientThatsetNeedsDrawInsideDraw;
704 scheduler_settings_.use_external_begin_frame_source = true; 704 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
705 SetUpScheduler(base::WrapUnique(client), true);
706 client->SetRequestRedrawsInsideDraw(true); 705 client->SetRequestRedrawsInsideDraw(true);
707 706
708 scheduler_->SetNeedsRedraw(); 707 scheduler_->SetNeedsRedraw();
709 EXPECT_TRUE(scheduler_->RedrawPending()); 708 EXPECT_TRUE(scheduler_->RedrawPending());
710 EXPECT_TRUE(client->needs_begin_frames()); 709 EXPECT_TRUE(client->needs_begin_frames());
711 EXPECT_EQ(0, client->num_draws()); 710 EXPECT_EQ(0, client->num_draws());
712 711
713 EXPECT_SCOPED(AdvanceFrame()); 712 EXPECT_SCOPED(AdvanceFrame());
714 task_runner().RunPendingTasks(); // Run posted deadline. 713 task_runner().RunPendingTasks(); // Run posted deadline.
715 EXPECT_EQ(1, client->num_draws()); 714 EXPECT_EQ(1, client->num_draws());
(...skipping 14 matching lines...) Expand all
730 task_runner().RunPendingTasks(); // Run posted deadline. 729 task_runner().RunPendingTasks(); // Run posted deadline.
731 EXPECT_EQ(2, client->num_draws()); 730 EXPECT_EQ(2, client->num_draws());
732 EXPECT_FALSE(scheduler_->RedrawPending()); 731 EXPECT_FALSE(scheduler_->RedrawPending());
733 EXPECT_FALSE(client->needs_begin_frames()); 732 EXPECT_FALSE(client->needs_begin_frames());
734 } 733 }
735 734
736 // Test that requesting redraw inside a failed draw doesn't lose the request. 735 // Test that requesting redraw inside a failed draw doesn't lose the request.
737 TEST_F(SchedulerTest, RequestRedrawInsideFailedDraw) { 736 TEST_F(SchedulerTest, RequestRedrawInsideFailedDraw) {
738 SchedulerClientThatsetNeedsDrawInsideDraw* client = 737 SchedulerClientThatsetNeedsDrawInsideDraw* client =
739 new SchedulerClientThatsetNeedsDrawInsideDraw; 738 new SchedulerClientThatsetNeedsDrawInsideDraw;
740 scheduler_settings_.use_external_begin_frame_source = true; 739 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
741 SetUpScheduler(base::WrapUnique(client), true);
742 740
743 client->SetRequestRedrawsInsideDraw(true); 741 client->SetRequestRedrawsInsideDraw(true);
744 client->SetDrawWillHappen(false); 742 client->SetDrawWillHappen(false);
745 743
746 scheduler_->SetNeedsRedraw(); 744 scheduler_->SetNeedsRedraw();
747 EXPECT_TRUE(scheduler_->RedrawPending()); 745 EXPECT_TRUE(scheduler_->RedrawPending());
748 EXPECT_TRUE(client->needs_begin_frames()); 746 EXPECT_TRUE(client->needs_begin_frames());
749 EXPECT_EQ(0, client->num_draws()); 747 EXPECT_EQ(0, client->num_draws());
750 748
751 // Fail the draw. 749 // Fail the draw.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 803
806 private: 804 private:
807 bool set_needs_commit_on_next_draw_; 805 bool set_needs_commit_on_next_draw_;
808 }; 806 };
809 807
810 // Tests for the scheduler infinite-looping on SetNeedsBeginMainFrame requests 808 // Tests for the scheduler infinite-looping on SetNeedsBeginMainFrame requests
811 // that happen inside a ScheduledActionDrawAndSwap 809 // that happen inside a ScheduledActionDrawAndSwap
812 TEST_F(SchedulerTest, RequestCommitInsideDraw) { 810 TEST_F(SchedulerTest, RequestCommitInsideDraw) {
813 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client = 811 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client =
814 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw; 812 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw;
815 813 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
816 scheduler_settings_.use_external_begin_frame_source = true;
817 SetUpScheduler(base::WrapUnique(client), true);
818 814
819 EXPECT_FALSE(client->needs_begin_frames()); 815 EXPECT_FALSE(client->needs_begin_frames());
820 scheduler_->SetNeedsRedraw(); 816 scheduler_->SetNeedsRedraw();
821 EXPECT_TRUE(scheduler_->RedrawPending()); 817 EXPECT_TRUE(scheduler_->RedrawPending());
822 EXPECT_EQ(0, client->num_draws()); 818 EXPECT_EQ(0, client->num_draws());
823 EXPECT_TRUE(client->needs_begin_frames()); 819 EXPECT_TRUE(client->needs_begin_frames());
824 820
825 client->SetNeedsBeginMainFrameOnNextDraw(); 821 client->SetNeedsBeginMainFrameOnNextDraw();
826 EXPECT_SCOPED(AdvanceFrame()); 822 EXPECT_SCOPED(AdvanceFrame());
827 client->SetNeedsBeginMainFrameOnNextDraw(); 823 client->SetNeedsBeginMainFrameOnNextDraw();
(...skipping 20 matching lines...) Expand all
848 EXPECT_EQ(2, client->num_draws()); 844 EXPECT_EQ(2, client->num_draws());
849 EXPECT_FALSE(scheduler_->RedrawPending()); 845 EXPECT_FALSE(scheduler_->RedrawPending());
850 EXPECT_FALSE(scheduler_->CommitPending()); 846 EXPECT_FALSE(scheduler_->CommitPending());
851 EXPECT_FALSE(client->needs_begin_frames()); 847 EXPECT_FALSE(client->needs_begin_frames());
852 } 848 }
853 849
854 // Tests that when a draw fails then the pending commit should not be dropped. 850 // Tests that when a draw fails then the pending commit should not be dropped.
855 TEST_F(SchedulerTest, RequestCommitInsideFailedDraw) { 851 TEST_F(SchedulerTest, RequestCommitInsideFailedDraw) {
856 SchedulerClientThatsetNeedsDrawInsideDraw* client = 852 SchedulerClientThatsetNeedsDrawInsideDraw* client =
857 new SchedulerClientThatsetNeedsDrawInsideDraw; 853 new SchedulerClientThatsetNeedsDrawInsideDraw;
858 scheduler_settings_.use_external_begin_frame_source = true; 854 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
859 SetUpScheduler(base::WrapUnique(client), true);
860 855
861 client->SetDrawWillHappen(false); 856 client->SetDrawWillHappen(false);
862 857
863 scheduler_->SetNeedsRedraw(); 858 scheduler_->SetNeedsRedraw();
864 EXPECT_TRUE(scheduler_->RedrawPending()); 859 EXPECT_TRUE(scheduler_->RedrawPending());
865 EXPECT_TRUE(client->needs_begin_frames()); 860 EXPECT_TRUE(client->needs_begin_frames());
866 EXPECT_EQ(0, client->num_draws()); 861 EXPECT_EQ(0, client->num_draws());
867 862
868 // Fail the draw. 863 // Fail the draw.
869 EXPECT_SCOPED(AdvanceFrame()); 864 EXPECT_SCOPED(AdvanceFrame());
(...skipping 21 matching lines...) Expand all
891 task_runner().RunPendingTasks(); // Run posted deadline. 886 task_runner().RunPendingTasks(); // Run posted deadline.
892 EXPECT_EQ(3, client->num_draws()); 887 EXPECT_EQ(3, client->num_draws());
893 EXPECT_TRUE(scheduler_->CommitPending()); 888 EXPECT_TRUE(scheduler_->CommitPending());
894 EXPECT_FALSE(scheduler_->RedrawPending()); 889 EXPECT_FALSE(scheduler_->RedrawPending());
895 EXPECT_TRUE(client->needs_begin_frames()); 890 EXPECT_TRUE(client->needs_begin_frames());
896 } 891 }
897 892
898 TEST_F(SchedulerTest, NoSwapWhenDrawFails) { 893 TEST_F(SchedulerTest, NoSwapWhenDrawFails) {
899 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client = 894 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client =
900 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw; 895 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw;
901 scheduler_settings_.use_external_begin_frame_source = true; 896 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
902 SetUpScheduler(base::WrapUnique(client), true);
903 897
904 scheduler_->SetNeedsRedraw(); 898 scheduler_->SetNeedsRedraw();
905 EXPECT_TRUE(scheduler_->RedrawPending()); 899 EXPECT_TRUE(scheduler_->RedrawPending());
906 EXPECT_TRUE(client->needs_begin_frames()); 900 EXPECT_TRUE(client->needs_begin_frames());
907 EXPECT_EQ(0, client->num_draws()); 901 EXPECT_EQ(0, client->num_draws());
908 902
909 // Draw successfully, this starts a new frame. 903 // Draw successfully, this starts a new frame.
910 client->SetNeedsBeginMainFrameOnNextDraw(); 904 client->SetNeedsBeginMainFrameOnNextDraw();
911 EXPECT_SCOPED(AdvanceFrame()); 905 EXPECT_SCOPED(AdvanceFrame());
912 task_runner().RunPendingTasks(); // Run posted deadline. 906 task_runner().RunPendingTasks(); // Run posted deadline.
(...skipping 16 matching lines...) Expand all
929 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 923 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
930 scheduler_->SetNeedsPrepareTiles(); 924 scheduler_->SetNeedsPrepareTiles();
931 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 925 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
932 } 926 }
933 }; 927 };
934 928
935 // Test prepare tiles is independant of draws. 929 // Test prepare tiles is independant of draws.
936 TEST_F(SchedulerTest, PrepareTiles) { 930 TEST_F(SchedulerTest, PrepareTiles) {
937 SchedulerClientNeedsPrepareTilesInDraw* client = 931 SchedulerClientNeedsPrepareTilesInDraw* client =
938 new SchedulerClientNeedsPrepareTilesInDraw; 932 new SchedulerClientNeedsPrepareTilesInDraw;
939 scheduler_settings_.use_external_begin_frame_source = true; 933 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
940 SetUpScheduler(base::WrapUnique(client), true);
941 934
942 // Request both draw and prepare tiles. PrepareTiles shouldn't 935 // Request both draw and prepare tiles. PrepareTiles shouldn't
943 // be trigged until BeginImplFrame. 936 // be trigged until BeginImplFrame.
944 client->Reset(); 937 client->Reset();
945 scheduler_->SetNeedsPrepareTiles(); 938 scheduler_->SetNeedsPrepareTiles();
946 scheduler_->SetNeedsRedraw(); 939 scheduler_->SetNeedsRedraw();
947 EXPECT_TRUE(scheduler_->RedrawPending()); 940 EXPECT_TRUE(scheduler_->RedrawPending());
948 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 941 EXPECT_TRUE(scheduler_->PrepareTilesPending());
949 EXPECT_TRUE(client->needs_begin_frames()); 942 EXPECT_TRUE(client->needs_begin_frames());
950 EXPECT_EQ(0, client->num_draws()); 943 EXPECT_EQ(0, client->num_draws());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 task_runner().RunPendingTasks(); // Run posted deadline. 1022 task_runner().RunPendingTasks(); // Run posted deadline.
1030 EXPECT_EQ(0, client->num_draws()); 1023 EXPECT_EQ(0, client->num_draws());
1031 EXPECT_FALSE(client->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1024 EXPECT_FALSE(client->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1032 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); 1025 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles"));
1033 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 1026 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
1034 } 1027 }
1035 1028
1036 // Test that PrepareTiles only happens once per frame. If an external caller 1029 // Test that PrepareTiles only happens once per frame. If an external caller
1037 // initiates it, then the state machine should not PrepareTiles on that frame. 1030 // initiates it, then the state machine should not PrepareTiles on that frame.
1038 TEST_F(SchedulerTest, PrepareTilesOncePerFrame) { 1031 TEST_F(SchedulerTest, PrepareTilesOncePerFrame) {
1039 scheduler_settings_.use_external_begin_frame_source = true; 1032 SetUpScheduler(EXTERNAL_BFS);
1040 SetUpScheduler(true);
1041 1033
1042 // If DidPrepareTiles during a frame, then PrepareTiles should not occur 1034 // If DidPrepareTiles during a frame, then PrepareTiles should not occur
1043 // again. 1035 // again.
1044 scheduler_->SetNeedsPrepareTiles(); 1036 scheduler_->SetNeedsPrepareTiles();
1045 scheduler_->SetNeedsRedraw(); 1037 scheduler_->SetNeedsRedraw();
1046 client_->Reset(); 1038 client_->Reset();
1047 EXPECT_SCOPED(AdvanceFrame()); 1039 EXPECT_SCOPED(AdvanceFrame());
1048 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 1040 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
1049 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 1041 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
1050 1042
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 1134 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
1143 client_->ActionIndex("ScheduledActionPrepareTiles")); 1135 client_->ActionIndex("ScheduledActionPrepareTiles"));
1144 EXPECT_FALSE(scheduler_->RedrawPending()); 1136 EXPECT_FALSE(scheduler_->RedrawPending());
1145 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1137 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1146 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 1138 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
1147 } 1139 }
1148 1140
1149 TEST_F(SchedulerTest, PrepareTilesFunnelResetOnVisibilityChange) { 1141 TEST_F(SchedulerTest, PrepareTilesFunnelResetOnVisibilityChange) {
1150 std::unique_ptr<SchedulerClientNeedsPrepareTilesInDraw> client = 1142 std::unique_ptr<SchedulerClientNeedsPrepareTilesInDraw> client =
1151 base::WrapUnique(new SchedulerClientNeedsPrepareTilesInDraw); 1143 base::WrapUnique(new SchedulerClientNeedsPrepareTilesInDraw);
1152 scheduler_settings_.use_external_begin_frame_source = true; 1144 SetUpScheduler(EXTERNAL_BFS, std::move(client));
1153 SetUpScheduler(std::move(client), true);
1154 1145
1155 // Simulate a few visibility changes and associated PrepareTiles. 1146 // Simulate a few visibility changes and associated PrepareTiles.
1156 for (int i = 0; i < 10; i++) { 1147 for (int i = 0; i < 10; i++) {
1157 scheduler_->SetVisible(false); 1148 scheduler_->SetVisible(false);
1158 scheduler_->WillPrepareTiles(); 1149 scheduler_->WillPrepareTiles();
1159 scheduler_->DidPrepareTiles(); 1150 scheduler_->DidPrepareTiles();
1160 1151
1161 scheduler_->SetVisible(true); 1152 scheduler_->SetVisible(true);
1162 scheduler_->WillPrepareTiles(); 1153 scheduler_->WillPrepareTiles();
1163 scheduler_->DidPrepareTiles(); 1154 scheduler_->DidPrepareTiles();
(...skipping 11 matching lines...) Expand all
1175 client_->Reset(); 1166 client_->Reset();
1176 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 1167 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
1177 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 1168 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
1178 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2); 1169 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2);
1179 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); 1170 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2);
1180 } 1171 }
1181 1172
1182 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) { 1173 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) {
1183 SchedulerClientNeedsPrepareTilesInDraw* client = 1174 SchedulerClientNeedsPrepareTilesInDraw* client =
1184 new SchedulerClientNeedsPrepareTilesInDraw; 1175 new SchedulerClientNeedsPrepareTilesInDraw;
1185 scheduler_settings_.use_external_begin_frame_source = true; 1176 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
1186 SetUpScheduler(base::WrapUnique(client), true);
1187 1177
1188 scheduler_->SetNeedsRedraw(); 1178 scheduler_->SetNeedsRedraw();
1189 EXPECT_SCOPED(AdvanceFrame()); 1179 EXPECT_SCOPED(AdvanceFrame());
1190 1180
1191 // The deadline should be zero since there is no work other than drawing 1181 // The deadline should be zero since there is no work other than drawing
1192 // pending. 1182 // pending.
1193 EXPECT_EQ(base::TimeTicks(), client->posted_begin_impl_frame_deadline()); 1183 EXPECT_EQ(base::TimeTicks(), client->posted_begin_impl_frame_deadline());
1194 } 1184 }
1195 1185
1196 TEST_F(SchedulerTest, WaitForReadyToDrawDoNotPostDeadline) { 1186 TEST_F(SchedulerTest, WaitForReadyToDrawDoNotPostDeadline) {
1197 SchedulerClientNeedsPrepareTilesInDraw* client = 1187 SchedulerClientNeedsPrepareTilesInDraw* client =
1198 new SchedulerClientNeedsPrepareTilesInDraw; 1188 new SchedulerClientNeedsPrepareTilesInDraw;
1199 scheduler_settings_.use_external_begin_frame_source = true;
1200 scheduler_settings_.commit_to_active_tree = true; 1189 scheduler_settings_.commit_to_active_tree = true;
1201 SetUpScheduler(base::WrapUnique(client), true); 1190 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
1202 1191
1203 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 1192 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
1204 scheduler_->SetNeedsBeginMainFrame(); 1193 scheduler_->SetNeedsBeginMainFrame();
1205 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 1194 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
1206 client_->Reset(); 1195 client_->Reset();
1207 1196
1208 // Begin new frame. 1197 // Begin new frame.
1209 EXPECT_SCOPED(AdvanceFrame()); 1198 EXPECT_SCOPED(AdvanceFrame());
1210 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 1199 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
1211 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1200 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
(...skipping 17 matching lines...) Expand all
1229 scheduler_->NotifyReadyToDraw(); 1218 scheduler_->NotifyReadyToDraw();
1230 client_->Reset(); 1219 client_->Reset();
1231 task_runner().RunPendingTasks(); // Run posted deadline. 1220 task_runner().RunPendingTasks(); // Run posted deadline.
1232 EXPECT_EQ(1, client_->num_draws()); 1221 EXPECT_EQ(1, client_->num_draws());
1233 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1222 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1234 } 1223 }
1235 1224
1236 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostOutputSurface) { 1225 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostOutputSurface) {
1237 SchedulerClientNeedsPrepareTilesInDraw* client = 1226 SchedulerClientNeedsPrepareTilesInDraw* client =
1238 new SchedulerClientNeedsPrepareTilesInDraw; 1227 new SchedulerClientNeedsPrepareTilesInDraw;
1239 scheduler_settings_.use_external_begin_frame_source = true;
1240 scheduler_settings_.commit_to_active_tree = true; 1228 scheduler_settings_.commit_to_active_tree = true;
1241 SetUpScheduler(base::WrapUnique(client), true); 1229 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client));
1242 1230
1243 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 1231 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
1244 scheduler_->SetNeedsBeginMainFrame(); 1232 scheduler_->SetNeedsBeginMainFrame();
1245 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 1233 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
1246 client_->Reset(); 1234 client_->Reset();
1247 1235
1248 // Begin new frame. 1236 // Begin new frame.
1249 EXPECT_SCOPED(AdvanceFrame()); 1237 EXPECT_SCOPED(AdvanceFrame());
1250 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 1238 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
1251 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1239 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); 1289 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline());
1302 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 1290 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
1303 EXPECT_EQ(expect_send_begin_main_frame, 1291 EXPECT_EQ(expect_send_begin_main_frame,
1304 scheduler_->MainThreadMissedLastDeadline()); 1292 scheduler_->MainThreadMissedLastDeadline());
1305 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); 1293 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame"));
1306 EXPECT_EQ(expect_send_begin_main_frame, 1294 EXPECT_EQ(expect_send_begin_main_frame,
1307 client_->HasAction("ScheduledActionSendBeginMainFrame")); 1295 client_->HasAction("ScheduledActionSendBeginMainFrame"));
1308 } 1296 }
1309 1297
1310 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { 1298 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) {
1311 scheduler_settings_.use_external_begin_frame_source = true; 1299 SetUpScheduler(EXTERNAL_BFS);
1312 SetUpScheduler(true);
1313 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1300 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1314 1301
1315 bool expect_send_begin_main_frame = false; 1302 bool expect_send_begin_main_frame = false;
1316 EXPECT_SCOPED( 1303 EXPECT_SCOPED(
1317 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1304 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1318 } 1305 }
1319 1306
1320 // Response times of BeginMainFrame's without the critical path flag set 1307 // Response times of BeginMainFrame's without the critical path flag set
1321 // should not affect whether we recover latency or not. 1308 // should not affect whether we recover latency or not.
1322 TEST_F(SchedulerTest, 1309 TEST_F(SchedulerTest,
1323 MainFrameSkippedAfterLateCommit_LongMainFrameQueueDurationNotCritical) { 1310 MainFrameSkippedAfterLateCommit_LongMainFrameQueueDurationNotCritical) {
1324 scheduler_settings_.use_external_begin_frame_source = true; 1311 SetUpScheduler(EXTERNAL_BFS);
1325 SetUpScheduler(true);
1326 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1312 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1327 fake_compositor_timing_history_ 1313 fake_compositor_timing_history_
1328 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); 1314 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration);
1329 1315
1330 bool expect_send_begin_main_frame = false; 1316 bool expect_send_begin_main_frame = false;
1331 EXPECT_SCOPED( 1317 EXPECT_SCOPED(
1332 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1318 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1333 } 1319 }
1334 1320
1335 // Response times of BeginMainFrame's with the critical path flag set 1321 // Response times of BeginMainFrame's with the critical path flag set
1336 // should affect whether we recover latency or not. 1322 // should affect whether we recover latency or not.
1337 TEST_F(SchedulerTest, 1323 TEST_F(SchedulerTest,
1338 MainFrameNotSkippedAfterLateCommit_LongMainFrameQueueDurationCritical) { 1324 MainFrameNotSkippedAfterLateCommit_LongMainFrameQueueDurationCritical) {
1339 scheduler_settings_.use_external_begin_frame_source = true; 1325 SetUpScheduler(EXTERNAL_BFS);
1340 SetUpScheduler(true);
1341 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1326 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1342 fake_compositor_timing_history_ 1327 fake_compositor_timing_history_
1343 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); 1328 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration);
1344 fake_compositor_timing_history_ 1329 fake_compositor_timing_history_
1345 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); 1330 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration);
1346 1331
1347 bool expect_send_begin_main_frame = true; 1332 bool expect_send_begin_main_frame = true;
1348 EXPECT_SCOPED( 1333 EXPECT_SCOPED(
1349 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1334 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1350 } 1335 }
1351 1336
1352 TEST_F(SchedulerTest, 1337 TEST_F(SchedulerTest,
1353 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) { 1338 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) {
1354 scheduler_settings_.use_external_begin_frame_source = true; 1339 SetUpScheduler(EXTERNAL_BFS);
1355 SetUpScheduler(true);
1356 scheduler_->SetTreePrioritiesAndScrollState( 1340 scheduler_->SetTreePrioritiesAndScrollState(
1357 SMOOTHNESS_TAKES_PRIORITY, 1341 SMOOTHNESS_TAKES_PRIORITY,
1358 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); 1342 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER);
1359 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1343 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1360 1344
1361 bool expect_send_begin_main_frame = true; 1345 bool expect_send_begin_main_frame = true;
1362 EXPECT_SCOPED( 1346 EXPECT_SCOPED(
1363 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1347 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1364 } 1348 }
1365 1349
1366 TEST_F(SchedulerTest, 1350 TEST_F(SchedulerTest,
1367 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) { 1351 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) {
1368 scheduler_settings_.use_external_begin_frame_source = true; 1352 SetUpScheduler(EXTERNAL_BFS);
1369 SetUpScheduler(true);
1370 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1353 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1371 fake_compositor_timing_history_ 1354 fake_compositor_timing_history_
1372 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); 1355 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration);
1373 1356
1374 bool expect_send_begin_main_frame = true; 1357 bool expect_send_begin_main_frame = true;
1375 EXPECT_SCOPED( 1358 EXPECT_SCOPED(
1376 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1359 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1377 } 1360 }
1378 1361
1379 TEST_F(SchedulerTest, 1362 TEST_F(SchedulerTest,
1380 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) { 1363 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) {
1381 scheduler_settings_.use_external_begin_frame_source = true; 1364 SetUpScheduler(EXTERNAL_BFS);
1382 SetUpScheduler(true);
1383 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1365 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1384 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( 1366 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1385 kSlowDuration); 1367 kSlowDuration);
1386 1368
1387 bool expect_send_begin_main_frame = true; 1369 bool expect_send_begin_main_frame = true;
1388 EXPECT_SCOPED( 1370 EXPECT_SCOPED(
1389 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1371 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1390 } 1372 }
1391 1373
1392 TEST_F(SchedulerTest, 1374 TEST_F(SchedulerTest,
1393 MainFrameNotSkippedAfterLateCommit_ActivateEstimateTooLong) { 1375 MainFrameNotSkippedAfterLateCommit_ActivateEstimateTooLong) {
1394 scheduler_settings_.use_external_begin_frame_source = true; 1376 SetUpScheduler(EXTERNAL_BFS);
1395 SetUpScheduler(true);
1396 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1377 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1397 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); 1378 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration);
1398 1379
1399 bool expect_send_begin_main_frame = true; 1380 bool expect_send_begin_main_frame = true;
1400 EXPECT_SCOPED( 1381 EXPECT_SCOPED(
1401 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1382 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1402 } 1383 }
1403 1384
1404 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateCommit_DrawEstimateTooLong) { 1385 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateCommit_DrawEstimateTooLong) {
1405 scheduler_settings_.use_external_begin_frame_source = true; 1386 SetUpScheduler(EXTERNAL_BFS);
1406 SetUpScheduler(true);
1407 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1387 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1408 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); 1388 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration);
1409 1389
1410 bool expect_send_begin_main_frame = true; 1390 bool expect_send_begin_main_frame = true;
1411 EXPECT_SCOPED( 1391 EXPECT_SCOPED(
1412 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1392 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1413 } 1393 }
1414 1394
1415 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the 1395 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the
1416 // queue, which means there is no latency to recover. 1396 // queue, which means there is no latency to recover.
1417 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateBeginMainFrameAbort) { 1397 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateBeginMainFrameAbort) {
1418 scheduler_settings_.use_external_begin_frame_source = true; 1398 SetUpScheduler(EXTERNAL_BFS);
1419 SetUpScheduler(true);
1420 1399
1421 // Use fast estimates so we think we can recover latency if needed. 1400 // Use fast estimates so we think we can recover latency if needed.
1422 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1401 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1423 1402
1424 // Impl thread hits deadline before BeginMainFrame aborts. 1403 // Impl thread hits deadline before BeginMainFrame aborts.
1425 scheduler_->SetNeedsBeginMainFrame(); 1404 scheduler_->SetNeedsBeginMainFrame();
1426 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); 1405 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline());
1427 EXPECT_SCOPED(AdvanceFrame()); 1406 EXPECT_SCOPED(AdvanceFrame());
1428 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); 1407 EXPECT_ACTION("AddObserver(this)", client_, 0, 3);
1429 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); 1408 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3);
(...skipping 15 matching lines...) Expand all
1445 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); 1424 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame"));
1446 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); 1425 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame"));
1447 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); 1426 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline());
1448 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 1427 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
1449 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); 1428 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline());
1450 } 1429 }
1451 1430
1452 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the 1431 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the
1453 // queue, which means there is no latency to recover. 1432 // queue, which means there is no latency to recover.
1454 TEST_F(SchedulerTest, MainFrameNotSkippedAfterCanDrawChanges) { 1433 TEST_F(SchedulerTest, MainFrameNotSkippedAfterCanDrawChanges) {
1455 scheduler_settings_.use_external_begin_frame_source = true; 1434 SetUpScheduler(EXTERNAL_BFS);
1456 SetUpScheduler(true);
1457 1435
1458 // Use fast estimates so we think we can recover latency if needed. 1436 // Use fast estimates so we think we can recover latency if needed.
1459 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1437 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1460 1438
1461 // Impl thread hits deadline before BeginMainFrame aborts. 1439 // Impl thread hits deadline before BeginMainFrame aborts.
1462 scheduler_->SetNeedsBeginMainFrame(); 1440 scheduler_->SetNeedsBeginMainFrame();
1463 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); 1441 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline());
1464 EXPECT_SCOPED(AdvanceFrame()); 1442 EXPECT_SCOPED(AdvanceFrame());
1465 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); 1443 EXPECT_ACTION("AddObserver(this)", client_, 0, 3);
1466 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); 1444 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 scheduler_->NotifyReadyToActivate(); 1545 scheduler_->NotifyReadyToActivate();
1568 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 1546 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
1569 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); 1547 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3);
1570 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); 1548 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3);
1571 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); 1549 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3);
1572 } 1550 }
1573 } 1551 }
1574 1552
1575 TEST_F(SchedulerTest, 1553 TEST_F(SchedulerTest,
1576 ImplFrameSkippedAfterLateSwapAck_FastEstimates_SwapAckThenDeadline) { 1554 ImplFrameSkippedAfterLateSwapAck_FastEstimates_SwapAckThenDeadline) {
1577 scheduler_settings_.use_external_begin_frame_source = true; 1555 SetUpScheduler(EXTERNAL_BFS);
1578 SetUpScheduler(true);
1579 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1556 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1580 1557
1581 bool swap_ack_before_deadline = true; 1558 bool swap_ack_before_deadline = true;
1582 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); 1559 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline));
1583 } 1560 }
1584 1561
1585 TEST_F(SchedulerTest, 1562 TEST_F(SchedulerTest,
1586 ImplFrameSkippedAfterLateSwapAck_FastEstimates_DeadlineThenSwapAck) { 1563 ImplFrameSkippedAfterLateSwapAck_FastEstimates_DeadlineThenSwapAck) {
1587 scheduler_settings_.use_external_begin_frame_source = true; 1564 SetUpScheduler(EXTERNAL_BFS);
1588 SetUpScheduler(true);
1589 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1565 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1590 1566
1591 bool swap_ack_before_deadline = false; 1567 bool swap_ack_before_deadline = false;
1592 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); 1568 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline));
1593 } 1569 }
1594 1570
1595 TEST_F(SchedulerTest, 1571 TEST_F(SchedulerTest,
1596 ImplFrameSkippedAfterLateSwapAck_LongMainFrameQueueDurationNotCritical) { 1572 ImplFrameSkippedAfterLateSwapAck_LongMainFrameQueueDurationNotCritical) {
1597 scheduler_settings_.use_external_begin_frame_source = true; 1573 SetUpScheduler(EXTERNAL_BFS);
1598 SetUpScheduler(true);
1599 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1574 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1600 fake_compositor_timing_history_ 1575 fake_compositor_timing_history_
1601 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); 1576 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration);
1602 1577
1603 bool swap_ack_before_deadline = false; 1578 bool swap_ack_before_deadline = false;
1604 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); 1579 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline));
1605 } 1580 }
1606 1581
1607 TEST_F(SchedulerTest, 1582 TEST_F(SchedulerTest,
1608 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) { 1583 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) {
1609 scheduler_settings_.use_external_begin_frame_source = true; 1584 SetUpScheduler(EXTERNAL_BFS);
1610 SetUpScheduler(true);
1611 1585
1612 // Even if every estimate related to the main thread is slow, we should 1586 // Even if every estimate related to the main thread is slow, we should
1613 // still expect to recover impl thread latency if the draw is fast and we 1587 // still expect to recover impl thread latency if the draw is fast and we
1614 // are in impl latency takes priority. 1588 // are in impl latency takes priority.
1615 scheduler_->SetTreePrioritiesAndScrollState( 1589 scheduler_->SetTreePrioritiesAndScrollState(
1616 SMOOTHNESS_TAKES_PRIORITY, 1590 SMOOTHNESS_TAKES_PRIORITY,
1617 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); 1591 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER);
1618 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); 1592 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration);
1619 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); 1593 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration);
1620 1594
1621 bool swap_ack_before_deadline = false; 1595 bool swap_ack_before_deadline = false;
1622 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); 1596 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline));
1623 } 1597 }
1624 1598
1625 TEST_F(SchedulerTest, 1599 TEST_F(SchedulerTest,
1626 ImplFrameSkippedAfterLateSwapAck_OnlyImplSideUpdatesExpected) { 1600 ImplFrameSkippedAfterLateSwapAck_OnlyImplSideUpdatesExpected) {
1627 // This tests that we recover impl thread latency when there are no commits. 1601 // This tests that we recover impl thread latency when there are no commits.
1628 scheduler_settings_.use_external_begin_frame_source = true; 1602 SetUpScheduler(EXTERNAL_BFS);
1629 SetUpScheduler(true);
1630 1603
1631 // To get into a high latency state, this test disables automatic swap acks. 1604 // To get into a high latency state, this test disables automatic swap acks.
1632 client_->SetAutomaticSwapAck(false); 1605 client_->SetAutomaticSwapAck(false);
1633 1606
1634 // Even if every estimate related to the main thread is slow, we should 1607 // Even if every estimate related to the main thread is slow, we should
1635 // still expect to recover impl thread latency if there are no commits from 1608 // still expect to recover impl thread latency if there are no commits from
1636 // the main thread. 1609 // the main thread.
1637 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); 1610 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration);
1638 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); 1611 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration);
1639 1612
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 4); 1706 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 4);
1734 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 4); 1707 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 4);
1735 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 2, 4); 1708 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 2, 4);
1736 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); 1709 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4);
1737 } 1710 }
1738 } 1711 }
1739 1712
1740 TEST_F( 1713 TEST_F(
1741 SchedulerTest, 1714 SchedulerTest,
1742 ImplFrameNotSkippedAfterLateSwapAck_MainFrameQueueDurationCriticalTooLong) { 1715 ImplFrameNotSkippedAfterLateSwapAck_MainFrameQueueDurationCriticalTooLong) {
1743 scheduler_settings_.use_external_begin_frame_source = true; 1716 SetUpScheduler(EXTERNAL_BFS);
1744 SetUpScheduler(true);
1745 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1717 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1746 fake_compositor_timing_history_ 1718 fake_compositor_timing_history_
1747 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); 1719 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration);
1748 fake_compositor_timing_history_ 1720 fake_compositor_timing_history_
1749 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); 1721 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration);
1750 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); 1722 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck());
1751 } 1723 }
1752 1724
1753 TEST_F(SchedulerTest, 1725 TEST_F(SchedulerTest,
1754 ImplFrameNotSkippedAfterLateSwapAck_CommitEstimateTooLong) { 1726 ImplFrameNotSkippedAfterLateSwapAck_CommitEstimateTooLong) {
1755 scheduler_settings_.use_external_begin_frame_source = true; 1727 SetUpScheduler(EXTERNAL_BFS);
1756 SetUpScheduler(true);
1757 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1728 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1758 fake_compositor_timing_history_ 1729 fake_compositor_timing_history_
1759 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); 1730 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration);
1760 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); 1731 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck());
1761 } 1732 }
1762 1733
1763 TEST_F(SchedulerTest, 1734 TEST_F(SchedulerTest,
1764 ImplFrameNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) { 1735 ImplFrameNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) {
1765 scheduler_settings_.use_external_begin_frame_source = true; 1736 SetUpScheduler(EXTERNAL_BFS);
1766 SetUpScheduler(true);
1767 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1737 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1768 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( 1738 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1769 kSlowDuration); 1739 kSlowDuration);
1770 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); 1740 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck());
1771 } 1741 }
1772 1742
1773 TEST_F(SchedulerTest, 1743 TEST_F(SchedulerTest,
1774 ImplFrameNotSkippedAfterLateSwapAck_ActivateEstimateTooLong) { 1744 ImplFrameNotSkippedAfterLateSwapAck_ActivateEstimateTooLong) {
1775 scheduler_settings_.use_external_begin_frame_source = true; 1745 SetUpScheduler(EXTERNAL_BFS);
1776 SetUpScheduler(true);
1777 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1746 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1778 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); 1747 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration);
1779 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); 1748 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck());
1780 } 1749 }
1781 1750
1782 TEST_F(SchedulerTest, ImplFrameNotSkippedAfterLateSwapAck_DrawEstimateTooLong) { 1751 TEST_F(SchedulerTest, ImplFrameNotSkippedAfterLateSwapAck_DrawEstimateTooLong) {
1783 scheduler_settings_.use_external_begin_frame_source = true; 1752 SetUpScheduler(EXTERNAL_BFS);
1784 SetUpScheduler(true);
1785 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1753 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1786 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); 1754 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration);
1787 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); 1755 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck());
1788 } 1756 }
1789 1757
1790 TEST_F(SchedulerTest, 1758 TEST_F(SchedulerTest,
1791 MainFrameThenImplFrameSkippedAfterLateCommitAndLateSwapAck) { 1759 MainFrameThenImplFrameSkippedAfterLateCommitAndLateSwapAck) {
1792 // Set up client with custom estimates. 1760 // Set up client with custom estimates.
1793 // This test starts off with expensive estimates to prevent latency recovery 1761 // This test starts off with expensive estimates to prevent latency recovery
1794 // initially, then lowers the estimates to enable it once both the main 1762 // initially, then lowers the estimates to enable it once both the main
1795 // and impl threads are in a high latency mode. 1763 // and impl threads are in a high latency mode.
1796 scheduler_settings_.use_external_begin_frame_source = true; 1764 SetUpScheduler(EXTERNAL_BFS);
1797 SetUpScheduler(true);
1798 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); 1765 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration);
1799 1766
1800 // To get into a high latency state, this test disables automatic swap acks. 1767 // To get into a high latency state, this test disables automatic swap acks.
1801 client_->SetAutomaticSwapAck(false); 1768 client_->SetAutomaticSwapAck(false);
1802 1769
1803 // Impl thread hits deadline before commit finishes to make 1770 // Impl thread hits deadline before commit finishes to make
1804 // MainThreadMissedLastDeadline true 1771 // MainThreadMissedLastDeadline true
1805 client_->Reset(); 1772 client_->Reset();
1806 scheduler_->SetNeedsBeginMainFrame(); 1773 scheduler_->SetNeedsBeginMainFrame();
1807 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); 1774 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 5); 1875 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 5);
1909 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5); 1876 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5);
1910 } 1877 }
1911 1878
1912 TEST_F( 1879 TEST_F(
1913 SchedulerTest, 1880 SchedulerTest,
1914 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { 1881 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) {
1915 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main 1882 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main
1916 // thread. This prevents the scheduler from receiving any pending swap acks. 1883 // thread. This prevents the scheduler from receiving any pending swap acks.
1917 1884
1918 scheduler_settings_.use_external_begin_frame_source = true;
1919 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1885 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1920 SetUpScheduler(true); 1886 SetUpScheduler(EXTERNAL_BFS);
1921 1887
1922 // Disables automatic swap acks so this test can force swap ack throttling 1888 // Disables automatic swap acks so this test can force swap ack throttling
1923 // to simulate a blocked Browser ui thread. 1889 // to simulate a blocked Browser ui thread.
1924 client_->SetAutomaticSwapAck(false); 1890 client_->SetAutomaticSwapAck(false);
1925 1891
1926 // Get a new active tree in main-thread high latency mode and put us 1892 // Get a new active tree in main-thread high latency mode and put us
1927 // in a swap throttled state. 1893 // in a swap throttled state.
1928 client_->Reset(); 1894 client_->Reset();
1929 EXPECT_FALSE(scheduler_->CommitPending()); 1895 EXPECT_FALSE(scheduler_->CommitPending());
1930 scheduler_->SetNeedsBeginMainFrame(); 1896 scheduler_->SetNeedsBeginMainFrame();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 } 1938 }
1973 1939
1974 TEST_F( 1940 TEST_F(
1975 SchedulerTest, 1941 SchedulerTest,
1976 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { 1942 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) {
1977 // This verifies we don't block commits longer than we need to 1943 // This verifies we don't block commits longer than we need to
1978 // for performance reasons - not deadlock reasons. 1944 // for performance reasons - not deadlock reasons.
1979 1945
1980 // Since we are simulating a long commit, set up a client with draw duration 1946 // Since we are simulating a long commit, set up a client with draw duration
1981 // estimates that prevent skipping main frames to get to low latency mode. 1947 // estimates that prevent skipping main frames to get to low latency mode.
1982 scheduler_settings_.use_external_begin_frame_source = true;
1983 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1948 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1984 scheduler_settings_.main_frame_before_activation_enabled = true; 1949 scheduler_settings_.main_frame_before_activation_enabled = true;
1985 SetUpScheduler(true); 1950 SetUpScheduler(EXTERNAL_BFS);
1986 1951
1987 // Disables automatic swap acks so this test can force swap ack throttling 1952 // Disables automatic swap acks so this test can force swap ack throttling
1988 // to simulate a blocked Browser ui thread. 1953 // to simulate a blocked Browser ui thread.
1989 client_->SetAutomaticSwapAck(false); 1954 client_->SetAutomaticSwapAck(false);
1990 1955
1991 // Start a new commit in main-thread high latency mode and hold off on 1956 // Start a new commit in main-thread high latency mode and hold off on
1992 // activation. 1957 // activation.
1993 client_->Reset(); 1958 client_->Reset();
1994 EXPECT_FALSE(scheduler_->CommitPending()); 1959 EXPECT_FALSE(scheduler_->CommitPending());
1995 scheduler_->SetNeedsBeginMainFrame(); 1960 scheduler_->SetNeedsBeginMainFrame();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 1997
2033 // Activate the pending tree, which also unblocks the commit immediately 1998 // Activate the pending tree, which also unblocks the commit immediately
2034 // while we are in an idle state. 1999 // while we are in an idle state.
2035 client_->Reset(); 2000 client_->Reset();
2036 scheduler_->NotifyReadyToActivate(); 2001 scheduler_->NotifyReadyToActivate();
2037 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 2); 2002 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 2);
2038 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 2); 2003 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 2);
2039 } 2004 }
2040 2005
2041 TEST_F(SchedulerTest, BeginRetroFrame) { 2006 TEST_F(SchedulerTest, BeginRetroFrame) {
2042 scheduler_settings_.use_external_begin_frame_source = true; 2007 SetUpScheduler(EXTERNAL_BFS);
2043 SetUpScheduler(true);
2044 2008
2045 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2009 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
2046 scheduler_->SetNeedsBeginMainFrame(); 2010 scheduler_->SetNeedsBeginMainFrame();
2047 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2011 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2048 client_->Reset(); 2012 client_->Reset();
2049 2013
2050 // Create a BeginFrame with a long deadline to avoid race conditions. 2014 // Create a BeginFrame with a long deadline to avoid race conditions.
2051 // This is the first BeginFrame, which will be handled immediately. 2015 // This is the first BeginFrame, which will be handled immediately.
2052 BeginFrameArgs args = 2016 BeginFrameArgs args =
2053 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 2017 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2070 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2107 client_->Reset(); 2071 client_->Reset();
2108 2072
2109 task_runner().RunPendingTasks(); // Run posted deadline. 2073 task_runner().RunPendingTasks(); // Run posted deadline.
2110 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); 2074 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
2111 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 2075 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
2112 client_->Reset(); 2076 client_->Reset();
2113 } 2077 }
2114 2078
2115 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) { 2079 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) {
2116 scheduler_settings_.use_external_begin_frame_source = true; 2080 SetUpScheduler(EXTERNAL_BFS);
2117 SetUpScheduler(true);
2118 2081
2119 scheduler_->SetNeedsBeginMainFrame(); 2082 scheduler_->SetNeedsBeginMainFrame();
2120 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2083 EXPECT_TRUE(scheduler_->begin_frames_expected());
2121 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2084 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2122 2085
2123 client_->Reset(); 2086 client_->Reset();
2124 EXPECT_SCOPED(AdvanceFrame()); 2087 EXPECT_SCOPED(AdvanceFrame());
2125 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2088 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2126 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2089 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2127 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2090 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2128 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2166 2129
2167 // This is an immediate deadline case. 2130 // This is an immediate deadline case.
2168 client_->Reset(); 2131 client_->Reset();
2169 task_runner().RunPendingTasks(); 2132 task_runner().RunPendingTasks();
2170 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2133 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2171 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 2134 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
2172 } 2135 }
2173 2136
2174 TEST_F(SchedulerTest, RetroFrameExpiresOnTime) { 2137 TEST_F(SchedulerTest, RetroFrameExpiresOnTime) {
2175 scheduler_settings_.use_external_begin_frame_source = true; 2138 SetUpScheduler(EXTERNAL_BFS);
2176 SetUpScheduler(true);
2177 2139
2178 scheduler_->SetNeedsBeginMainFrame(); 2140 scheduler_->SetNeedsBeginMainFrame();
2179 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2141 EXPECT_TRUE(scheduler_->begin_frames_expected());
2180 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2142 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2181 2143
2182 client_->Reset(); 2144 client_->Reset();
2183 EXPECT_SCOPED(AdvanceFrame()); 2145 EXPECT_SCOPED(AdvanceFrame());
2184 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2146 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2185 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2147 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2186 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2148 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 30 matching lines...) Expand all
2217 2179
2218 // Let's advance sufficiently past the retro frame's deadline. 2180 // Let's advance sufficiently past the retro frame's deadline.
2219 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks() + 2181 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks() +
2220 base::TimeDelta::FromMicroseconds(1)); 2182 base::TimeDelta::FromMicroseconds(1));
2221 2183
2222 // The retro frame should've expired. 2184 // The retro frame should've expired.
2223 EXPECT_NO_ACTION(client_); 2185 EXPECT_NO_ACTION(client_);
2224 } 2186 }
2225 2187
2226 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) { 2188 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) {
2227 scheduler_settings_.use_external_begin_frame_source = true; 2189 SetUpScheduler(EXTERNAL_BFS);
2228 SetUpScheduler(true);
2229 2190
2230 scheduler_->SetNeedsBeginMainFrame(); 2191 scheduler_->SetNeedsBeginMainFrame();
2231 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2192 EXPECT_TRUE(scheduler_->begin_frames_expected());
2232 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2193 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2233 2194
2234 BeginFrameArgs missed_frame_args = 2195 BeginFrameArgs missed_frame_args =
2235 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 2196 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
2236 missed_frame_args.type = BeginFrameArgs::MISSED; 2197 missed_frame_args.type = BeginFrameArgs::MISSED;
2237 2198
2238 // Advance to the deadline. 2199 // Advance to the deadline.
2239 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks()); 2200 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks());
2240 2201
2241 // Missed frame is handled because it's on time. 2202 // Missed frame is handled because it's on time.
2242 client_->Reset(); 2203 client_->Reset();
2243 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); 2204 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args);
2244 EXPECT_TRUE( 2205 EXPECT_TRUE(
2245 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false))); 2206 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false)));
2246 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2207 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2247 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2208 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2248 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2209 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2249 } 2210 }
2250 2211
2251 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) { 2212 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) {
2252 scheduler_settings_.use_external_begin_frame_source = true; 2213 SetUpScheduler(EXTERNAL_BFS);
2253 SetUpScheduler(true);
2254 2214
2255 scheduler_->SetNeedsBeginMainFrame(); 2215 scheduler_->SetNeedsBeginMainFrame();
2256 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2216 EXPECT_TRUE(scheduler_->begin_frames_expected());
2257 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2217 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2258 2218
2259 BeginFrameArgs missed_frame_args = 2219 BeginFrameArgs missed_frame_args =
2260 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 2220 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
2261 missed_frame_args.type = BeginFrameArgs::MISSED; 2221 missed_frame_args.type = BeginFrameArgs::MISSED;
2262 2222
2263 // Advance sufficiently past the deadline. 2223 // Advance sufficiently past the deadline.
2264 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks() + 2224 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks() +
2265 base::TimeDelta::FromMicroseconds(1)); 2225 base::TimeDelta::FromMicroseconds(1));
2266 2226
2267 // Missed frame is dropped because it's too late. 2227 // Missed frame is dropped because it's too late.
2268 client_->Reset(); 2228 client_->Reset();
2269 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); 2229 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args);
2270 EXPECT_FALSE( 2230 EXPECT_FALSE(
2271 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false))); 2231 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false)));
2272 EXPECT_NO_ACTION(client_); 2232 EXPECT_NO_ACTION(client_);
2273 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2233 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2274 } 2234 }
2275 2235
2276 void SchedulerTest::BeginFramesNotFromClient( 2236 void SchedulerTest::BeginFramesNotFromClient(BeginFrameSourceType bfs_type) {
2277 bool use_external_begin_frame_source, 2237 SetUpScheduler(bfs_type);
2278 bool throttle_frame_production) {
2279 scheduler_settings_.use_external_begin_frame_source =
2280 use_external_begin_frame_source;
2281 scheduler_settings_.throttle_frame_production = throttle_frame_production;
2282 SetUpScheduler(true);
2283 2238
2284 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame 2239 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame
2285 // without calling SetNeedsBeginFrame. 2240 // without calling SetNeedsBeginFrame.
2286 scheduler_->SetNeedsBeginMainFrame(); 2241 scheduler_->SetNeedsBeginMainFrame();
2287 EXPECT_NO_ACTION(client_); 2242 EXPECT_NO_ACTION(client_);
2288 client_->Reset(); 2243 client_->Reset();
2289 2244
2290 // When the client-driven BeginFrame are disabled, the scheduler posts it's 2245 // When the client-driven BeginFrame are disabled, the scheduler posts it's
2291 // own BeginFrame tasks. 2246 // own BeginFrame tasks.
2292 task_runner().RunPendingTasks(); // Run posted BeginFrame. 2247 task_runner().RunPendingTasks(); // Run posted BeginFrame.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 client_->Reset(); 2287 client_->Reset();
2333 2288
2334 // Make sure SetNeedsBeginFrame isn't called on the client 2289 // Make sure SetNeedsBeginFrame isn't called on the client
2335 // when the BeginFrame is no longer needed. 2290 // when the BeginFrame is no longer needed.
2336 task_runner().RunPendingTasks(); // Run posted deadline. 2291 task_runner().RunPendingTasks(); // Run posted deadline.
2337 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); 2292 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_);
2338 client_->Reset(); 2293 client_->Reset();
2339 } 2294 }
2340 2295
2341 TEST_F(SchedulerTest, SyntheticBeginFrames) { 2296 TEST_F(SchedulerTest, SyntheticBeginFrames) {
2342 bool use_external_begin_frame_source = false; 2297 BeginFramesNotFromClient(THROTTLED_BFS);
2343 bool throttle_frame_production = true;
2344 BeginFramesNotFromClient(use_external_begin_frame_source,
2345 throttle_frame_production);
2346 } 2298 }
2347 2299
2348 TEST_F(SchedulerTest, VSyncThrottlingDisabled) { 2300 TEST_F(SchedulerTest, UnthrottledBeginFrames) {
2349 bool use_external_begin_frame_source = true; 2301 BeginFramesNotFromClient(UNTHROTTLED_BFS);
2350 bool throttle_frame_production = false;
2351 BeginFramesNotFromClient(use_external_begin_frame_source,
2352 throttle_frame_production);
2353 }
2354
2355 TEST_F(SchedulerTest, SyntheticBeginFrames_And_VSyncThrottlingDisabled) {
2356 bool use_external_begin_frame_source = false;
2357 bool throttle_frame_production = false;
2358 BeginFramesNotFromClient(use_external_begin_frame_source,
2359 throttle_frame_production);
2360 } 2302 }
2361 2303
2362 void SchedulerTest::BeginFramesNotFromClient_SwapThrottled( 2304 void SchedulerTest::BeginFramesNotFromClient_SwapThrottled(
2363 bool use_external_begin_frame_source, 2305 BeginFrameSourceType bfs_type) {
2364 bool throttle_frame_production) { 2306 SetUpScheduler(bfs_type);
2365 scheduler_settings_.use_external_begin_frame_source =
2366 use_external_begin_frame_source;
2367 scheduler_settings_.throttle_frame_production = throttle_frame_production;
2368 SetUpScheduler(true);
2369 2307
2370 scheduler_->SetEstimatedParentDrawTime( 2308 scheduler_->SetEstimatedParentDrawTime(
2371 BeginFrameArgs::DefaultEstimatedParentDrawTime()); 2309 BeginFrameArgs::DefaultEstimatedParentDrawTime());
2372 2310
2373 // Set the draw duration estimate to zero so that deadlines are accurate. 2311 // Set the draw duration estimate to zero so that deadlines are accurate.
2374 fake_compositor_timing_history_->SetDrawDurationEstimate(base::TimeDelta()); 2312 fake_compositor_timing_history_->SetDrawDurationEstimate(base::TimeDelta());
2375 2313
2376 // To test swap ack throttling, this test disables automatic swap acks. 2314 // To test swap ack throttling, this test disables automatic swap acks.
2377 client_->SetAutomaticSwapAck(false); 2315 client_->SetAutomaticSwapAck(false);
2378 2316
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 // We can't do an equality comparison here because the scheduler uses a fudge 2386 // We can't do an equality comparison here because the scheduler uses a fudge
2449 // factor that's an internal implementation detail. 2387 // factor that's an internal implementation detail.
2450 EXPECT_GT(after_deadline, before_deadline); 2388 EXPECT_GT(after_deadline, before_deadline);
2451 EXPECT_LT(after_deadline, 2389 EXPECT_LT(after_deadline,
2452 before_deadline + BeginFrameArgs::DefaultInterval()); 2390 before_deadline + BeginFrameArgs::DefaultInterval());
2453 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2391 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2454 client_->Reset(); 2392 client_->Reset();
2455 } 2393 }
2456 2394
2457 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { 2395 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) {
2458 bool use_external_begin_frame_source = false; 2396 BeginFramesNotFromClient_SwapThrottled(THROTTLED_BFS);
2459 bool throttle_frame_production = true;
2460 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source,
2461 throttle_frame_production);
2462 } 2397 }
2463 2398
2464 TEST_F(SchedulerTest, VSyncThrottlingDisabled_SwapThrottled) { 2399 TEST_F(SchedulerTest, UnthrottledBeginFrames_SwapThrottled) {
2465 bool use_external_begin_frame_source = true; 2400 BeginFramesNotFromClient_SwapThrottled(UNTHROTTLED_BFS);
2466 bool throttle_frame_production = false;
2467 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source,
2468 throttle_frame_production);
2469 }
2470
2471 TEST_F(SchedulerTest,
2472 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) {
2473 bool use_external_begin_frame_source = false;
2474 bool throttle_frame_production = false;
2475 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source,
2476 throttle_frame_production);
2477 } 2401 }
2478 2402
2479 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterOutputSurfaceIsInitialized) { 2403 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterOutputSurfaceIsInitialized) {
2480 scheduler_settings_.use_external_begin_frame_source = true; 2404 SetUpSchedulerWithNoOutputSurface(EXTERNAL_BFS);
2481 SetUpScheduler(false);
2482 2405
2483 scheduler_->SetVisible(true); 2406 scheduler_->SetVisible(true);
2484 scheduler_->SetCanDraw(true); 2407 scheduler_->SetCanDraw(true);
2485 2408
2486 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 2409 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
2487 client_->Reset(); 2410 client_->Reset();
2488 scheduler_->DidCreateAndInitializeOutputSurface(); 2411 scheduler_->DidCreateAndInitializeOutputSurface();
2489 EXPECT_NO_ACTION(client_); 2412 EXPECT_NO_ACTION(client_);
2490 2413
2491 scheduler_->DidLoseOutputSurface(); 2414 scheduler_->DidLoseOutputSurface();
2492 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 2415 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
2493 } 2416 }
2494 2417
2495 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginFrameStarted) { 2418 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginFrameStarted) {
2496 scheduler_settings_.use_external_begin_frame_source = true; 2419 SetUpScheduler(EXTERNAL_BFS);
2497 SetUpScheduler(true);
2498 2420
2499 // SetNeedsBeginMainFrame should begin the frame. 2421 // SetNeedsBeginMainFrame should begin the frame.
2500 scheduler_->SetNeedsBeginMainFrame(); 2422 scheduler_->SetNeedsBeginMainFrame();
2501 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2423 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2502 2424
2503 client_->Reset(); 2425 client_->Reset();
2504 EXPECT_SCOPED(AdvanceFrame()); 2426 EXPECT_SCOPED(AdvanceFrame());
2505 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2427 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2506 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2428 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2507 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2429 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 11 matching lines...) Expand all
2519 2441
2520 client_->Reset(); 2442 client_->Reset();
2521 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2443 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2522 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2444 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
2523 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2445 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2524 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2446 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2525 } 2447 }
2526 2448
2527 TEST_F(SchedulerTest, 2449 TEST_F(SchedulerTest,
2528 DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency) { 2450 DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency) {
2529 scheduler_settings_.use_external_begin_frame_source = true; 2451 SetUpScheduler(EXTERNAL_BFS);
2530 SetUpScheduler(true);
2531 2452
2532 // SetNeedsBeginMainFrame should begin the frame. 2453 // SetNeedsBeginMainFrame should begin the frame.
2533 scheduler_->SetNeedsBeginMainFrame(); 2454 scheduler_->SetNeedsBeginMainFrame();
2534 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2455 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2535 2456
2536 client_->Reset(); 2457 client_->Reset();
2537 EXPECT_SCOPED(AdvanceFrame()); 2458 EXPECT_SCOPED(AdvanceFrame());
2538 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2459 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2539 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2460 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2540 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2461 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 22 matching lines...) Expand all
2563 2484
2564 client_->Reset(); 2485 client_->Reset();
2565 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2486 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2566 scheduler_->NotifyReadyToCommit(); 2487 scheduler_->NotifyReadyToCommit();
2567 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); 2488 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3);
2568 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); 2489 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3);
2569 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 2, 3); 2490 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 2, 3);
2570 } 2491 }
2571 2492
2572 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) { 2493 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) {
2573 scheduler_settings_.use_external_begin_frame_source = true; 2494 SetUpScheduler(EXTERNAL_BFS);
2574 SetUpScheduler(true);
2575 2495
2576 // SetNeedsBeginMainFrame should begin the frame. 2496 // SetNeedsBeginMainFrame should begin the frame.
2577 scheduler_->SetNeedsBeginMainFrame(); 2497 scheduler_->SetNeedsBeginMainFrame();
2578 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2498 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2579 2499
2580 client_->Reset(); 2500 client_->Reset();
2581 EXPECT_SCOPED(AdvanceFrame()); 2501 EXPECT_SCOPED(AdvanceFrame());
2582 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2502 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2583 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2503 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2584 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2504 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 10 matching lines...) Expand all
2595 2515
2596 // RemoveObserver(this) is not called until the end of the frame. 2516 // RemoveObserver(this) is not called until the end of the frame.
2597 client_->Reset(); 2517 client_->Reset();
2598 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2518 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2599 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2519 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
2600 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2520 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2601 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2521 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2602 } 2522 }
2603 2523
2604 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterSetNeedsPrepareTiles) { 2524 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterSetNeedsPrepareTiles) {
2605 scheduler_settings_.use_external_begin_frame_source = true; 2525 SetUpScheduler(EXTERNAL_BFS);
2606 SetUpScheduler(true);
2607 2526
2608 scheduler_->SetNeedsPrepareTiles(); 2527 scheduler_->SetNeedsPrepareTiles();
2609 scheduler_->SetNeedsRedraw(); 2528 scheduler_->SetNeedsRedraw();
2610 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2529 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2611 2530
2612 client_->Reset(); 2531 client_->Reset();
2613 EXPECT_SCOPED(AdvanceFrame()); 2532 EXPECT_SCOPED(AdvanceFrame());
2614 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 2533 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
2615 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2534 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2616 2535
2617 client_->Reset(); 2536 client_->Reset();
2618 scheduler_->DidLoseOutputSurface(); 2537 scheduler_->DidLoseOutputSurface();
2619 // RemoveObserver(this) is not called until the end of the frame. 2538 // RemoveObserver(this) is not called until the end of the frame.
2620 EXPECT_NO_ACTION(client_); 2539 EXPECT_NO_ACTION(client_);
2621 2540
2622 client_->Reset(); 2541 client_->Reset();
2623 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2542 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2624 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4); 2543 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4);
2625 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 4); 2544 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 4);
2626 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); 2545 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4);
2627 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); 2546 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4);
2628 } 2547 }
2629 2548
2630 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { 2549 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) {
2631 scheduler_settings_.use_external_begin_frame_source = true; 2550 SetUpScheduler(EXTERNAL_BFS);
2632 SetUpScheduler(true);
2633 2551
2634 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2552 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
2635 scheduler_->SetNeedsBeginMainFrame(); 2553 scheduler_->SetNeedsBeginMainFrame();
2636 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2554 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2637 2555
2638 // Create a BeginFrame with a long deadline to avoid race conditions. 2556 // Create a BeginFrame with a long deadline to avoid race conditions.
2639 // This is the first BeginFrame, which will be handled immediately. 2557 // This is the first BeginFrame, which will be handled immediately.
2640 client_->Reset(); 2558 client_->Reset();
2641 BeginFrameArgs args = 2559 BeginFrameArgs args =
2642 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 2560 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2599 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2682 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); 2600 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty());
2683 2601
2684 // Posted BeginRetroFrame is aborted. 2602 // Posted BeginRetroFrame is aborted.
2685 client_->Reset(); 2603 client_->Reset();
2686 task_runner().RunPendingTasks(); 2604 task_runner().RunPendingTasks();
2687 EXPECT_NO_ACTION(client_); 2605 EXPECT_NO_ACTION(client_);
2688 } 2606 }
2689 2607
2690 TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { 2608 TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) {
2691 scheduler_settings_.use_external_begin_frame_source = true; 2609 SetUpScheduler(EXTERNAL_BFS);
2692 SetUpScheduler(true);
2693 2610
2694 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2611 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
2695 scheduler_->SetNeedsBeginMainFrame(); 2612 scheduler_->SetNeedsBeginMainFrame();
2696 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2613 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2697 2614
2698 // Create a BeginFrame with a long deadline to avoid race conditions. 2615 // Create a BeginFrame with a long deadline to avoid race conditions.
2699 // This is the first BeginFrame, which will be handled immediately. 2616 // This is the first BeginFrame, which will be handled immediately.
2700 client_->Reset(); 2617 client_->Reset();
2701 BeginFrameArgs args = 2618 BeginFrameArgs args =
2702 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 2619 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2672 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2756 EXPECT_FALSE(scheduler_->begin_frames_expected()); 2673 EXPECT_FALSE(scheduler_->begin_frames_expected());
2757 2674
2758 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. 2675 // No more BeginRetroFrame because BeginRetroFrame queue is cleared.
2759 client_->Reset(); 2676 client_->Reset();
2760 task_runner().RunPendingTasks(); 2677 task_runner().RunPendingTasks();
2761 EXPECT_NO_ACTION(client_); 2678 EXPECT_NO_ACTION(client_);
2762 } 2679 }
2763 2680
2764 TEST_F(SchedulerTest, DidLoseOutputSurfaceWithDelayBasedBeginFrameSource) { 2681 TEST_F(SchedulerTest, DidLoseOutputSurfaceWithDelayBasedBeginFrameSource) {
2765 SetUpScheduler(true); 2682 SetUpScheduler(THROTTLED_BFS);
2766 2683
2767 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2684 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
2768 EXPECT_FALSE(scheduler_->begin_frames_expected()); 2685 EXPECT_FALSE(scheduler_->begin_frames_expected());
2769 scheduler_->SetNeedsBeginMainFrame(); 2686 scheduler_->SetNeedsBeginMainFrame();
2770 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2687 EXPECT_TRUE(scheduler_->begin_frames_expected());
2771 2688
2772 client_->Reset(); 2689 client_->Reset();
2773 AdvanceFrame(); 2690 AdvanceFrame();
2774 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2691 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2775 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2692 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
(...skipping 20 matching lines...) Expand all
2796 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2713 EXPECT_TRUE(scheduler_->begin_frames_expected());
2797 2714
2798 client_->Reset(); 2715 client_->Reset();
2799 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2716 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2800 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 2); 2717 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 2);
2801 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 2718 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
2802 EXPECT_FALSE(scheduler_->begin_frames_expected()); 2719 EXPECT_FALSE(scheduler_->begin_frames_expected());
2803 } 2720 }
2804 2721
2805 TEST_F(SchedulerTest, DidLoseOutputSurfaceWhenIdle) { 2722 TEST_F(SchedulerTest, DidLoseOutputSurfaceWhenIdle) {
2806 scheduler_settings_.use_external_begin_frame_source = true; 2723 SetUpScheduler(EXTERNAL_BFS);
2807 SetUpScheduler(true);
2808 2724
2809 // SetNeedsBeginMainFrame should begin the frame. 2725 // SetNeedsBeginMainFrame should begin the frame.
2810 scheduler_->SetNeedsBeginMainFrame(); 2726 scheduler_->SetNeedsBeginMainFrame();
2811 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2727 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2812 2728
2813 client_->Reset(); 2729 client_->Reset();
2814 EXPECT_SCOPED(AdvanceFrame()); 2730 EXPECT_SCOPED(AdvanceFrame());
2815 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2731 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2816 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2732 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2817 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2733 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
(...skipping 13 matching lines...) Expand all
2831 2747
2832 // Idle time between BeginFrames. 2748 // Idle time between BeginFrames.
2833 client_->Reset(); 2749 client_->Reset();
2834 scheduler_->DidLoseOutputSurface(); 2750 scheduler_->DidLoseOutputSurface();
2835 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2751 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
2836 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2752 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2837 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2753 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2838 } 2754 }
2839 2755
2840 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) { 2756 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) {
2841 scheduler_settings_.use_external_begin_frame_source = true; 2757 SetUpScheduler(EXTERNAL_BFS);
2842 SetUpScheduler(true);
2843 2758
2844 // SetNeedsBeginMainFrame should begin the frame. 2759 // SetNeedsBeginMainFrame should begin the frame.
2845 scheduler_->SetNeedsBeginMainFrame(); 2760 scheduler_->SetNeedsBeginMainFrame();
2846 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2761 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2847 2762
2848 client_->Reset(); 2763 client_->Reset();
2849 EXPECT_SCOPED(AdvanceFrame()); 2764 EXPECT_SCOPED(AdvanceFrame());
2850 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2765 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2851 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2766 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2852 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2767 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2853 2768
2854 client_->Reset(); 2769 client_->Reset();
2855 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2770 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2856 scheduler_->NotifyReadyToCommit(); 2771 scheduler_->NotifyReadyToCommit();
2857 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 2772 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
2858 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2773 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2859 2774
2860 client_->Reset(); 2775 client_->Reset();
2861 scheduler_->SetVisible(false); 2776 scheduler_->SetVisible(false);
2862 task_runner().RunPendingTasks(); // Run posted deadline. 2777 task_runner().RunPendingTasks(); // Run posted deadline.
2863 2778
2864 // Sync tree should be forced to activate. 2779 // Sync tree should be forced to activate.
2865 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3); 2780 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3);
2866 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2781 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2867 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2782 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2868 } 2783 }
2869 2784
2870 TEST_F(SchedulerTest, ScheduledActionActivateAfterBeginFrameSourcePaused) { 2785 TEST_F(SchedulerTest, ScheduledActionActivateAfterBeginFrameSourcePaused) {
2871 scheduler_settings_.use_external_begin_frame_source = true; 2786 SetUpScheduler(EXTERNAL_BFS);
2872 SetUpScheduler(true);
2873 2787
2874 // SetNeedsBeginMainFrame should begin the frame. 2788 // SetNeedsBeginMainFrame should begin the frame.
2875 scheduler_->SetNeedsBeginMainFrame(); 2789 scheduler_->SetNeedsBeginMainFrame();
2876 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2790 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2877 2791
2878 client_->Reset(); 2792 client_->Reset();
2879 EXPECT_SCOPED(AdvanceFrame()); 2793 EXPECT_SCOPED(AdvanceFrame());
2880 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2794 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2881 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2795 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2882 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2796 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2883 2797
2884 client_->Reset(); 2798 client_->Reset();
2885 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2799 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2886 scheduler_->NotifyReadyToCommit(); 2800 scheduler_->NotifyReadyToCommit();
2887 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 2801 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
2888 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2802 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2889 2803
2890 client_->Reset(); 2804 client_->Reset();
2891 fake_external_begin_frame_source_->SetPaused(true); 2805 fake_external_begin_frame_source_->SetPaused(true);
2892 task_runner().RunPendingTasks(); // Run posted deadline. 2806 task_runner().RunPendingTasks(); // Run posted deadline.
2893 2807
2894 // Sync tree should be forced to activate. 2808 // Sync tree should be forced to activate.
2895 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 2809 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
2896 } 2810 }
2897 2811
2898 // Tests to ensure frame sources can be successfully changed while drawing. 2812 // Tests to ensure frame sources can be successfully changed while drawing.
2899 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { 2813 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) {
2900 scheduler_settings_.use_external_begin_frame_source = true; 2814 SetUpScheduler(EXTERNAL_BFS);
2901 SetUpScheduler(true);
2902 2815
2903 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. 2816 // SetNeedsRedraw should begin the frame on the next BeginImplFrame.
2904 scheduler_->SetNeedsRedraw(); 2817 scheduler_->SetNeedsRedraw();
2905 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2818 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2906 client_->Reset(); 2819 client_->Reset();
2907 2820
2908 EXPECT_SCOPED(AdvanceFrame()); 2821 EXPECT_SCOPED(AdvanceFrame());
2909 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 2822 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
2910 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2823 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2911 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2824 EXPECT_TRUE(scheduler_->begin_frames_expected());
(...skipping 15 matching lines...) Expand all
2927 // If we don't swap on the deadline, we wait for the next BeginFrame. 2840 // If we don't swap on the deadline, we wait for the next BeginFrame.
2928 task_runner().RunPendingTasks(); // Run posted deadline. 2841 task_runner().RunPendingTasks(); // Run posted deadline.
2929 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 2842 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
2930 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2843 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2931 client_->Reset(); 2844 client_->Reset();
2932 } 2845 }
2933 2846
2934 // Tests to ensure frame sources can be successfully changed while a frame 2847 // Tests to ensure frame sources can be successfully changed while a frame
2935 // deadline is pending. 2848 // deadline is pending.
2936 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottledBeforeDeadline) { 2849 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottledBeforeDeadline) {
2937 scheduler_settings_.use_external_begin_frame_source = true; 2850 SetUpScheduler(EXTERNAL_BFS);
2938 SetUpScheduler(true);
2939 2851
2940 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. 2852 // SetNeedsRedraw should begin the frame on the next BeginImplFrame.
2941 scheduler_->SetNeedsRedraw(); 2853 scheduler_->SetNeedsRedraw();
2942 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2854 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2943 client_->Reset(); 2855 client_->Reset();
2944 2856
2945 EXPECT_SCOPED(AdvanceFrame()); 2857 EXPECT_SCOPED(AdvanceFrame());
2946 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 2858 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
2947 2859
2948 // Switch to an unthrottled frame source before the frame deadline is hit. 2860 // Switch to an unthrottled frame source before the frame deadline is hit.
(...skipping 13 matching lines...) Expand all
2962 2874
2963 task_runner().RunPendingTasks(); // Run posted deadline. 2875 task_runner().RunPendingTasks(); // Run posted deadline.
2964 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 2876 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
2965 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2877 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2966 client_->Reset(); 2878 client_->Reset();
2967 } 2879 }
2968 2880
2969 // Tests to ensure that the active frame source can successfully be changed from 2881 // Tests to ensure that the active frame source can successfully be changed from
2970 // unthrottled to throttled. 2882 // unthrottled to throttled.
2971 TEST_F(SchedulerTest, SwitchFrameSourceToThrottled) { 2883 TEST_F(SchedulerTest, SwitchFrameSourceToThrottled) {
2972 scheduler_settings_.throttle_frame_production = false; 2884 SetUpScheduler(UNTHROTTLED_BFS);
2973 scheduler_settings_.use_external_begin_frame_source = true;
2974 SetUpScheduler(true);
2975 2885
2976 scheduler_->SetNeedsRedraw(); 2886 scheduler_->SetNeedsRedraw();
2977 EXPECT_NO_ACTION(client_); 2887 EXPECT_NO_ACTION(client_);
2978 client_->Reset(); 2888 client_->Reset();
2979 2889
2980 task_runner().RunPendingTasks(); // Run posted BeginFrame. 2890 task_runner().RunPendingTasks(); // Run posted BeginFrame.
2981 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 2891 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
2982 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2892 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2983 client_->Reset(); 2893 client_->Reset();
2984 2894
(...skipping 15 matching lines...) Expand all
3000 EXPECT_SCOPED(AdvanceFrame()); 2910 EXPECT_SCOPED(AdvanceFrame());
3001 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 2911 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
3002 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2912 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
3003 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2913 EXPECT_TRUE(scheduler_->begin_frames_expected());
3004 client_->Reset(); 2914 client_->Reset();
3005 task_runner().RunPendingTasks(); // Run posted deadline. 2915 task_runner().RunPendingTasks(); // Run posted deadline.
3006 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 2916 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
3007 } 2917 }
3008 2918
3009 TEST_F(SchedulerTest, SwitchFrameSourceToNullInsideDeadline) { 2919 TEST_F(SchedulerTest, SwitchFrameSourceToNullInsideDeadline) {
3010 scheduler_settings_.use_external_begin_frame_source = true; 2920 SetUpScheduler(EXTERNAL_BFS);
3011 SetUpScheduler(true);
3012 2921
3013 scheduler_->SetNeedsRedraw(); 2922 scheduler_->SetNeedsRedraw();
3014 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2923 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3015 client_->Reset(); 2924 client_->Reset();
3016 2925
3017 EXPECT_SCOPED(AdvanceFrame()); 2926 EXPECT_SCOPED(AdvanceFrame());
3018 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 2927 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
3019 client_->Reset(); 2928 client_->Reset();
3020 2929
3021 // Switch to a null frame source. 2930 // Switch to a null frame source.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2962 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
3054 client_->Reset(); 2963 client_->Reset();
3055 2964
3056 task_runner().RunPendingTasks(); 2965 task_runner().RunPendingTasks();
3057 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 2966 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
3058 } 2967 }
3059 2968
3060 // This test maskes sure that switching a frame source when not observing 2969 // This test maskes sure that switching a frame source when not observing
3061 // such as when not visible also works. 2970 // such as when not visible also works.
3062 TEST_F(SchedulerTest, SwitchFrameSourceWhenNotObserving) { 2971 TEST_F(SchedulerTest, SwitchFrameSourceWhenNotObserving) {
3063 scheduler_settings_.use_external_begin_frame_source = true; 2972 SetUpScheduler(EXTERNAL_BFS);
3064 SetUpScheduler(true);
3065 2973
3066 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2974 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
3067 scheduler_->SetNeedsBeginMainFrame(); 2975 scheduler_->SetNeedsBeginMainFrame();
3068 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2976 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3069 client_->Reset(); 2977 client_->Reset();
3070 2978
3071 // Begin new frame. 2979 // Begin new frame.
3072 EXPECT_SCOPED(AdvanceFrame()); 2980 EXPECT_SCOPED(AdvanceFrame());
3073 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2981 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
3074 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2982 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 EXPECT_NO_ACTION(client_); 3014 EXPECT_NO_ACTION(client_);
3107 3015
3108 client_->Reset(); 3016 client_->Reset();
3109 EXPECT_SCOPED(AdvanceFrame()); 3017 EXPECT_SCOPED(AdvanceFrame());
3110 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3018 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3111 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3019 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3112 } 3020 }
3113 3021
3114 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. 3022 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected.
3115 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { 3023 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) {
3116 scheduler_settings_.use_external_begin_frame_source = true; 3024 SetUpScheduler(EXTERNAL_BFS);
3117 SetUpScheduler(true);
3118 3025
3119 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 3026 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
3120 scheduler_->SetNeedsBeginMainFrame(); 3027 scheduler_->SetNeedsBeginMainFrame();
3121 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3028 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3122 client_->Reset(); 3029 client_->Reset();
3123 3030
3124 // Trigger a frame draw. 3031 // Trigger a frame draw.
3125 EXPECT_SCOPED(AdvanceFrame()); 3032 EXPECT_SCOPED(AdvanceFrame());
3126 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 3033 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
3127 scheduler_->NotifyReadyToCommit(); 3034 scheduler_->NotifyReadyToCommit();
(...skipping 14 matching lines...) Expand all
3142 client_->Reset(); 3049 client_->Reset();
3143 3050
3144 task_runner().RunPendingTasks(); // Run posted deadline. 3051 task_runner().RunPendingTasks(); // Run posted deadline.
3145 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); 3052 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
3146 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 3053 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
3147 client_->Reset(); 3054 client_->Reset();
3148 } 3055 }
3149 3056
3150 TEST_F(SchedulerTest, SynchronousCompositorAnimation) { 3057 TEST_F(SchedulerTest, SynchronousCompositorAnimation) {
3151 scheduler_settings_.using_synchronous_renderer_compositor = true; 3058 scheduler_settings_.using_synchronous_renderer_compositor = true;
3152 scheduler_settings_.use_external_begin_frame_source = true; 3059 SetUpScheduler(EXTERNAL_BFS);
3153 SetUpScheduler(true);
3154 3060
3155 scheduler_->SetNeedsOneBeginImplFrame(); 3061 scheduler_->SetNeedsOneBeginImplFrame();
3156 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3062 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3157 client_->Reset(); 3063 client_->Reset();
3158 3064
3159 // Testing the case where animation ticks a fling scroll. 3065 // Testing the case where animation ticks a fling scroll.
3160 client_->SetWillBeginImplFrameCausesRedraw(true); 3066 client_->SetWillBeginImplFrameCausesRedraw(true);
3161 // The animation isn't done so it'll cause another tick in the future. 3067 // The animation isn't done so it'll cause another tick in the future.
3162 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); 3068 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true);
3163 3069
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3198 AdvanceFrame(); 3104 AdvanceFrame();
3199 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3105 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3200 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3106 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3201 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3107 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3202 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3108 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3203 client_->Reset(); 3109 client_->Reset();
3204 } 3110 }
3205 3111
3206 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) { 3112 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) {
3207 scheduler_settings_.using_synchronous_renderer_compositor = true; 3113 scheduler_settings_.using_synchronous_renderer_compositor = true;
3208 scheduler_settings_.use_external_begin_frame_source = true; 3114 SetUpScheduler(EXTERNAL_BFS);
3209 SetUpScheduler(true);
3210 3115
3211 scheduler_->SetNeedsRedraw(); 3116 scheduler_->SetNeedsRedraw();
3212 bool resourceless_software_draw = false; 3117 bool resourceless_software_draw = false;
3213 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3118 scheduler_->OnDrawForOutputSurface(resourceless_software_draw);
3214 EXPECT_ACTION("AddObserver(this)", client_, 0, 2); 3119 EXPECT_ACTION("AddObserver(this)", client_, 0, 2);
3215 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); 3120 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2);
3216 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3121 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3217 client_->Reset(); 3122 client_->Reset();
3218 3123
3219 // Idle on next vsync. 3124 // Idle on next vsync.
3220 AdvanceFrame(); 3125 AdvanceFrame();
3221 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3126 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3222 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3127 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3223 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3128 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3224 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3129 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3225 client_->Reset(); 3130 client_->Reset();
3226 } 3131 }
3227 3132
3228 TEST_F(SchedulerTest, SetNeedsOneBeginImplFrame) { 3133 TEST_F(SchedulerTest, SetNeedsOneBeginImplFrame) {
3229 scheduler_settings_.use_external_begin_frame_source = true; 3134 SetUpScheduler(EXTERNAL_BFS);
3230 SetUpScheduler(true);
3231 3135
3232 EXPECT_FALSE(scheduler_->begin_frames_expected()); 3136 EXPECT_FALSE(scheduler_->begin_frames_expected());
3233 3137
3234 // Request a frame, should kick the source. 3138 // Request a frame, should kick the source.
3235 scheduler_->SetNeedsOneBeginImplFrame(); 3139 scheduler_->SetNeedsOneBeginImplFrame();
3236 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3140 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3237 client_->Reset(); 3141 client_->Reset();
3238 3142
3239 // The incoming WillBeginImplFrame will request another one. 3143 // The incoming WillBeginImplFrame will request another one.
3240 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); 3144 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true);
(...skipping 17 matching lines...) Expand all
3258 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); 3162 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
3259 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3163 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3260 3164
3261 // Scheduler shuts down the source now that no begin frame is requested. 3165 // Scheduler shuts down the source now that no begin frame is requested.
3262 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); 3166 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
3263 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 3167 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
3264 } 3168 }
3265 3169
3266 TEST_F(SchedulerTest, SynchronousCompositorCommit) { 3170 TEST_F(SchedulerTest, SynchronousCompositorCommit) {
3267 scheduler_settings_.using_synchronous_renderer_compositor = true; 3171 scheduler_settings_.using_synchronous_renderer_compositor = true;
3268 scheduler_settings_.use_external_begin_frame_source = true; 3172 SetUpScheduler(EXTERNAL_BFS);
3269 SetUpScheduler(true);
3270 3173
3271 scheduler_->SetNeedsBeginMainFrame(); 3174 scheduler_->SetNeedsBeginMainFrame();
3272 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3175 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3273 client_->Reset(); 3176 client_->Reset();
3274 3177
3275 // Next vsync. 3178 // Next vsync.
3276 AdvanceFrame(); 3179 AdvanceFrame();
3277 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3180 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3278 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3181 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3279 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3182 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 AdvanceFrame(); 3218 AdvanceFrame();
3316 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3219 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3317 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3220 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3318 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3221 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3319 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3222 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3320 client_->Reset(); 3223 client_->Reset();
3321 } 3224 }
3322 3225
3323 TEST_F(SchedulerTest, SynchronousCompositorDoubleCommitWithoutDraw) { 3226 TEST_F(SchedulerTest, SynchronousCompositorDoubleCommitWithoutDraw) {
3324 scheduler_settings_.using_synchronous_renderer_compositor = true; 3227 scheduler_settings_.using_synchronous_renderer_compositor = true;
3325 scheduler_settings_.use_external_begin_frame_source = true; 3228 SetUpScheduler(EXTERNAL_BFS);
3326 SetUpScheduler(true);
3327 3229
3328 scheduler_->SetNeedsBeginMainFrame(); 3230 scheduler_->SetNeedsBeginMainFrame();
3329 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3231 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3330 client_->Reset(); 3232 client_->Reset();
3331 3233
3332 // Next vsync. 3234 // Next vsync.
3333 AdvanceFrame(); 3235 AdvanceFrame();
3334 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3236 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3335 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3237 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3336 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3238 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3372 3274
3373 protected: 3275 protected:
3374 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 3276 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
3375 scheduler_->SetNeedsPrepareTiles(); 3277 scheduler_->SetNeedsPrepareTiles();
3376 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 3278 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
3377 } 3279 }
3378 }; 3280 };
3379 3281
3380 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { 3282 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) {
3381 scheduler_settings_.using_synchronous_renderer_compositor = true; 3283 scheduler_settings_.using_synchronous_renderer_compositor = true;
3382 scheduler_settings_.use_external_begin_frame_source = true;
3383 3284
3384 std::unique_ptr<FakeSchedulerClient> client = 3285 std::unique_ptr<FakeSchedulerClient> client =
3385 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw); 3286 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw);
3386 SetUpScheduler(std::move(client), true); 3287 SetUpScheduler(EXTERNAL_BFS, std::move(client));
3387 3288
3388 scheduler_->SetNeedsRedraw(); 3289 scheduler_->SetNeedsRedraw();
3389 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3290 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3390 client_->Reset(); 3291 client_->Reset();
3391 3292
3392 // Next vsync. 3293 // Next vsync.
3393 EXPECT_SCOPED(AdvanceFrame()); 3294 EXPECT_SCOPED(AdvanceFrame());
3394 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3295 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3395 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3296 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2);
3396 client_->Reset(); 3297 client_->Reset();
(...skipping 22 matching lines...) Expand all
3419 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 3320 EXPECT_FALSE(scheduler_->PrepareTilesPending());
3420 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3321 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3421 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3322 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3422 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3323 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3423 EXPECT_FALSE(scheduler_->begin_frames_expected()); 3324 EXPECT_FALSE(scheduler_->begin_frames_expected());
3424 client_->Reset(); 3325 client_->Reset();
3425 } 3326 }
3426 3327
3427 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) { 3328 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) {
3428 scheduler_settings_.using_synchronous_renderer_compositor = true; 3329 scheduler_settings_.using_synchronous_renderer_compositor = true;
3429 scheduler_settings_.use_external_begin_frame_source = true; 3330 SetUpScheduler(EXTERNAL_BFS);
3430
3431 SetUpScheduler(true);
3432 3331
3433 scheduler_->SetNeedsRedraw(); 3332 scheduler_->SetNeedsRedraw();
3434 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3333 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3435 client_->Reset(); 3334 client_->Reset();
3436 3335
3437 // Next vsync. 3336 // Next vsync.
3438 EXPECT_SCOPED(AdvanceFrame()); 3337 EXPECT_SCOPED(AdvanceFrame());
3439 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3338 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3440 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3339 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2);
3441 client_->Reset(); 3340 client_->Reset();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 client_->Reset(); 3377 client_->Reset();
3479 3378
3480 // Simulate SetNeedsBeginMainFrame due to input event. 3379 // Simulate SetNeedsBeginMainFrame due to input event.
3481 scheduler_->SetNeedsBeginMainFrame(); 3380 scheduler_->SetNeedsBeginMainFrame();
3482 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); 3381 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_);
3483 client_->Reset(); 3382 client_->Reset();
3484 } 3383 }
3485 3384
3486 TEST_F(SchedulerTest, SynchronousCompositorResourcelessOnDrawWhenInvisible) { 3385 TEST_F(SchedulerTest, SynchronousCompositorResourcelessOnDrawWhenInvisible) {
3487 scheduler_settings_.using_synchronous_renderer_compositor = true; 3386 scheduler_settings_.using_synchronous_renderer_compositor = true;
3488 scheduler_settings_.use_external_begin_frame_source = true; 3387 SetUpScheduler(EXTERNAL_BFS);
3489 SetUpScheduler(true);
3490 3388
3491 scheduler_->SetVisible(false); 3389 scheduler_->SetVisible(false);
3492 3390
3493 scheduler_->SetNeedsRedraw(); 3391 scheduler_->SetNeedsRedraw();
3494 bool resourceless_software_draw = true; 3392 bool resourceless_software_draw = true;
3495 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3393 scheduler_->OnDrawForOutputSurface(resourceless_software_draw);
3496 // SynchronousCompositor has to draw regardless of visibility. 3394 // SynchronousCompositor has to draw regardless of visibility.
3497 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 3395 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
3498 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3396 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3499 client_->Reset(); 3397 client_->Reset();
3500 } 3398 }
3501 3399
3502 TEST_F(SchedulerTest, AuthoritativeVSyncInterval) { 3400 TEST_F(SchedulerTest, AuthoritativeVSyncInterval) {
3503 SetUpScheduler(true); 3401 SetUpScheduler(THROTTLED_BFS);
3504 base::TimeDelta initial_interval = scheduler_->BeginImplFrameInterval(); 3402 base::TimeDelta initial_interval = scheduler_->BeginImplFrameInterval();
3505 base::TimeDelta authoritative_interval = 3403 base::TimeDelta authoritative_interval =
3506 base::TimeDelta::FromMilliseconds(33); 3404 base::TimeDelta::FromMilliseconds(33);
3507 3405
3508 scheduler_->SetNeedsBeginMainFrame(); 3406 scheduler_->SetNeedsBeginMainFrame();
3509 EXPECT_SCOPED(AdvanceFrame()); 3407 EXPECT_SCOPED(AdvanceFrame());
3510 3408
3511 EXPECT_EQ(initial_interval, scheduler_->BeginImplFrameInterval()); 3409 EXPECT_EQ(initial_interval, scheduler_->BeginImplFrameInterval());
3512 3410
3513 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 3411 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
3514 scheduler_->NotifyReadyToCommit(); 3412 scheduler_->NotifyReadyToCommit();
3515 scheduler_->NotifyReadyToActivate(); 3413 scheduler_->NotifyReadyToActivate();
3516 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 3414 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
3517 3415
3518 // Test changing the interval on the frame source external to the scheduler. 3416 // Test changing the interval on the frame source external to the scheduler.
3519 synthetic_frame_source_->OnUpdateVSyncParameters(now_src_->NowTicks(), 3417 synthetic_frame_source_->OnUpdateVSyncParameters(now_src_->NowTicks(),
3520 authoritative_interval); 3418 authoritative_interval);
3521 3419
3522 EXPECT_SCOPED(AdvanceFrame()); 3420 EXPECT_SCOPED(AdvanceFrame());
3523 3421
3524 // At the next BeginFrame, authoritative interval is used instead of previous 3422 // At the next BeginFrame, authoritative interval is used instead of previous
3525 // interval. 3423 // interval.
3526 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); 3424 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval());
3527 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); 3425 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval());
3528 } 3426 }
3529 3427
3530 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { 3428 TEST_F(SchedulerTest, ImplLatencyTakesPriority) {
3531 SetUpScheduler(true); 3429 SetUpScheduler(THROTTLED_BFS);
3532 3430
3533 scheduler_->SetTreePrioritiesAndScrollState( 3431 scheduler_->SetTreePrioritiesAndScrollState(
3534 SMOOTHNESS_TAKES_PRIORITY, 3432 SMOOTHNESS_TAKES_PRIORITY,
3535 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); 3433 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER);
3536 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); 3434 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true);
3537 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); 3435 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority());
3538 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); 3436 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false);
3539 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); 3437 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority());
3540 3438
3541 scheduler_->SetTreePrioritiesAndScrollState( 3439 scheduler_->SetTreePrioritiesAndScrollState(
(...skipping 15 matching lines...) Expand all
3557 scheduler_->SetTreePrioritiesAndScrollState( 3455 scheduler_->SetTreePrioritiesAndScrollState(
3558 SAME_PRIORITY_FOR_BOTH_TREES, 3456 SAME_PRIORITY_FOR_BOTH_TREES,
3559 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER); 3457 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER);
3560 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); 3458 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true);
3561 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); 3459 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority());
3562 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); 3460 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false);
3563 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); 3461 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority());
3564 } 3462 }
3565 3463
3566 TEST_F(SchedulerTest, NoOutputSurfaceCreationWhileCommitPending) { 3464 TEST_F(SchedulerTest, NoOutputSurfaceCreationWhileCommitPending) {
3567 SetUpScheduler(true); 3465 SetUpScheduler(THROTTLED_BFS);
3568 3466
3569 // SetNeedsBeginMainFrame should begin the frame. 3467 // SetNeedsBeginMainFrame should begin the frame.
3570 scheduler_->SetNeedsBeginMainFrame(); 3468 scheduler_->SetNeedsBeginMainFrame();
3571 client_->Reset(); 3469 client_->Reset();
3572 EXPECT_SCOPED(AdvanceFrame()); 3470 EXPECT_SCOPED(AdvanceFrame());
3573 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3471 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3574 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3472 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3575 3473
3576 // Lose the output surface and trigger the deadline. 3474 // Lose the output surface and trigger the deadline.
3577 client_->Reset(); 3475 client_->Reset();
(...skipping 10 matching lines...) Expand all
3588 // Abort the commit. 3486 // Abort the commit.
3589 client_->Reset(); 3487 client_->Reset();
3590 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); 3488 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now());
3591 scheduler_->BeginMainFrameAborted( 3489 scheduler_->BeginMainFrameAborted(
3592 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); 3490 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST);
3593 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 3491 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
3594 } 3492 }
3595 3493
3596 TEST_F(SchedulerTest, OutputSurfaceCreationWhileCommitPending) { 3494 TEST_F(SchedulerTest, OutputSurfaceCreationWhileCommitPending) {
3597 scheduler_settings_.abort_commit_before_output_surface_creation = false; 3495 scheduler_settings_.abort_commit_before_output_surface_creation = false;
3598 SetUpScheduler(true); 3496 SetUpScheduler(THROTTLED_BFS);
3599 3497
3600 // SetNeedsBeginMainFrame should begin the frame. 3498 // SetNeedsBeginMainFrame should begin the frame.
3601 scheduler_->SetNeedsBeginMainFrame(); 3499 scheduler_->SetNeedsBeginMainFrame();
3602 client_->Reset(); 3500 client_->Reset();
3603 EXPECT_SCOPED(AdvanceFrame()); 3501 EXPECT_SCOPED(AdvanceFrame());
3604 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3502 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3605 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3503 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3606 3504
3607 // Lose the output surface and trigger the deadline. 3505 // Lose the output surface and trigger the deadline.
3608 client_->Reset(); 3506 client_->Reset();
(...skipping 11 matching lines...) Expand all
3620 3518
3621 // The three letters appeneded to each version of this test mean the following:s 3519 // The three letters appeneded to each version of this test mean the following:s
3622 // tree_priority: B = both trees same priority; A = active tree priority; 3520 // tree_priority: B = both trees same priority; A = active tree priority;
3623 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll 3521 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll
3624 // handler; 3522 // handler;
3625 // durations: F = fast durations; S = slow durations 3523 // durations: F = fast durations; S = slow durations
3626 bool SchedulerTest::BeginMainFrameOnCriticalPath( 3524 bool SchedulerTest::BeginMainFrameOnCriticalPath(
3627 TreePriority tree_priority, 3525 TreePriority tree_priority,
3628 ScrollHandlerState scroll_handler_state, 3526 ScrollHandlerState scroll_handler_state,
3629 base::TimeDelta durations) { 3527 base::TimeDelta durations) {
3630 scheduler_settings_.use_external_begin_frame_source = true; 3528 SetUpScheduler(EXTERNAL_BFS);
3631 SetUpScheduler(true);
3632 fake_compositor_timing_history_->SetAllEstimatesTo(durations); 3529 fake_compositor_timing_history_->SetAllEstimatesTo(durations);
3633 client_->Reset(); 3530 client_->Reset();
3634 scheduler_->SetTreePrioritiesAndScrollState(tree_priority, 3531 scheduler_->SetTreePrioritiesAndScrollState(tree_priority,
3635 scroll_handler_state); 3532 scroll_handler_state);
3636 scheduler_->SetNeedsBeginMainFrame(); 3533 scheduler_->SetNeedsBeginMainFrame();
3637 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); 3534 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid());
3638 EXPECT_SCOPED(AdvanceFrame()); 3535 EXPECT_SCOPED(AdvanceFrame());
3639 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); 3536 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid());
3640 return client_->last_begin_main_frame_args().on_critical_path; 3537 return client_->last_begin_main_frame_args().on_critical_path;
3641 } 3538 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3687 } 3584 }
3688 3585
3689 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { 3586 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) {
3690 EXPECT_FALSE(BeginMainFrameOnCriticalPath( 3587 EXPECT_FALSE(BeginMainFrameOnCriticalPath(
3691 SMOOTHNESS_TAKES_PRIORITY, 3588 SMOOTHNESS_TAKES_PRIORITY,
3692 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); 3589 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration));
3693 } 3590 }
3694 3591
3695 } // namespace 3592 } // namespace
3696 } // namespace cc 3593 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698