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