| 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 { |
| 219 EXTERNAL_BFS, |
| 220 UNTHROTTLED_BFS, |
| 221 THROTTLED_BFS, |
| 222 }; |
| 223 |
| 218 class SchedulerTest : public testing::Test { | 224 class SchedulerTest : public testing::Test { |
| 219 public: | 225 public: |
| 220 SchedulerTest() | 226 SchedulerTest() |
| 221 : now_src_(new base::SimpleTestTickClock()), | 227 : now_src_(new base::SimpleTestTickClock()), |
| 222 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)), | 228 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)), |
| 223 fake_external_begin_frame_source_(nullptr) { | 229 fake_external_begin_frame_source_(nullptr) { |
| 224 now_src_->Advance(base::TimeDelta::FromMicroseconds(10000)); | 230 now_src_->Advance(base::TimeDelta::FromMicroseconds(10000)); |
| 225 // A bunch of tests require NowTicks() | 231 // A bunch of tests require NowTicks() |
| 226 // to be > BeginFrameArgs::DefaultInterval() | 232 // to be > BeginFrameArgs::DefaultInterval() |
| 227 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); | 233 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); |
| 228 // Fail if we need to run 100 tasks in a row. | 234 // Fail if we need to run 100 tasks in a row. |
| 229 task_runner_->SetRunTaskLimit(100); | 235 task_runner_->SetRunTaskLimit(100); |
| 230 } | 236 } |
| 231 | 237 |
| 232 ~SchedulerTest() override {} | 238 ~SchedulerTest() override {} |
| 233 | 239 |
| 234 protected: | 240 protected: |
| 235 TestScheduler* CreateScheduler() { | 241 TestScheduler* CreateScheduler(BeginFrameSourceType bfs_type) { |
| 236 BeginFrameSource* frame_source; | 242 BeginFrameSource* frame_source = nullptr; |
| 237 unthrottled_frame_source_.reset(new BackToBackBeginFrameSource( | 243 unthrottled_frame_source_.reset(new BackToBackBeginFrameSource( |
| 238 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), | 244 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), |
| 239 task_runner_.get()))); | 245 task_runner_.get()))); |
| 240 fake_external_begin_frame_source_.reset( | 246 fake_external_begin_frame_source_.reset( |
| 241 new FakeExternalBeginFrameSource(0.f, false)); | 247 new FakeExternalBeginFrameSource(0.f, false)); |
| 242 fake_external_begin_frame_source_->SetClient(client_.get()); | 248 fake_external_begin_frame_source_->SetClient(client_.get()); |
| 243 synthetic_frame_source_.reset(new DelayBasedBeginFrameSource( | 249 synthetic_frame_source_.reset(new DelayBasedBeginFrameSource( |
| 244 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), | 250 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), |
| 245 task_runner_.get()))); | 251 task_runner_.get()))); |
| 246 if (!scheduler_settings_.throttle_frame_production) { | 252 switch (bfs_type) { |
| 247 frame_source = unthrottled_frame_source_.get(); | 253 case EXTERNAL_BFS: |
| 248 } else if (scheduler_settings_.use_external_begin_frame_source) { | 254 frame_source = fake_external_begin_frame_source_.get(); |
| 249 frame_source = fake_external_begin_frame_source_.get(); | 255 break; |
| 250 } else { | 256 case UNTHROTTLED_BFS: |
| 251 frame_source = synthetic_frame_source_.get(); | 257 frame_source = unthrottled_frame_source_.get(); |
| 258 break; |
| 259 case THROTTLED_BFS: |
| 260 frame_source = synthetic_frame_source_.get(); |
| 261 break; |
| 252 } | 262 } |
| 263 DCHECK(frame_source); |
| 253 | 264 |
| 254 std::unique_ptr<FakeCompositorTimingHistory> | 265 std::unique_ptr<FakeCompositorTimingHistory> |
| 255 fake_compositor_timing_history = FakeCompositorTimingHistory::Create( | 266 fake_compositor_timing_history = FakeCompositorTimingHistory::Create( |
| 256 scheduler_settings_.using_synchronous_renderer_compositor); | 267 scheduler_settings_.using_synchronous_renderer_compositor); |
| 257 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); | 268 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); |
| 258 | 269 |
| 259 scheduler_.reset( | 270 scheduler_.reset( |
| 260 new TestScheduler(now_src_.get(), client_.get(), scheduler_settings_, 0, | 271 new TestScheduler(now_src_.get(), client_.get(), scheduler_settings_, 0, |
| 261 task_runner_.get(), frame_source, | 272 task_runner_.get(), frame_source, |
| 262 std::move(fake_compositor_timing_history))); | 273 std::move(fake_compositor_timing_history))); |
| 263 DCHECK(scheduler_); | 274 DCHECK(scheduler_); |
| 264 client_->set_scheduler(scheduler_.get()); | 275 client_->set_scheduler(scheduler_.get()); |
| 265 | 276 |
| 266 // Use large estimates by default to avoid latency recovery in most tests. | 277 // Use large estimates by default to avoid latency recovery in most tests. |
| 267 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); | 278 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 268 | 279 |
| 269 return scheduler_.get(); | 280 return scheduler_.get(); |
| 270 } | 281 } |
| 271 | 282 |
| 272 void CreateSchedulerAndInitSurface() { | 283 void SetUpScheduler(BeginFrameSourceType bfs_type, |
| 273 CreateScheduler(); | 284 std::unique_ptr<FakeSchedulerClient> client) { |
| 285 client_ = std::move(client); |
| 286 CreateScheduler(bfs_type); |
| 274 EXPECT_SCOPED(InitializeCompositorFrameSinkAndFirstCommit()); | 287 EXPECT_SCOPED(InitializeCompositorFrameSinkAndFirstCommit()); |
| 275 } | 288 } |
| 276 | 289 |
| 277 void SetUpScheduler(bool initSurface) { | 290 void SetUpScheduler(BeginFrameSourceType bfs_type) { |
| 278 SetUpScheduler(base::WrapUnique(new FakeSchedulerClient), initSurface); | 291 SetUpScheduler(bfs_type, base::MakeUnique<FakeSchedulerClient>()); |
| 279 } | 292 } |
| 280 | 293 |
| 281 void SetUpScheduler(std::unique_ptr<FakeSchedulerClient> client, | 294 void SetUpSchedulerWithNoCompositorFrameSink(BeginFrameSourceType bfs_type) { |
| 282 bool initSurface) { | 295 client_ = base::MakeUnique<FakeSchedulerClient>(); |
| 283 client_ = std::move(client); | 296 CreateScheduler(bfs_type); |
| 284 if (initSurface) | |
| 285 CreateSchedulerAndInitSurface(); | |
| 286 else | |
| 287 CreateScheduler(); | |
| 288 } | 297 } |
| 289 | 298 |
| 290 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } | 299 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } |
| 291 base::SimpleTestTickClock* now_src() { return now_src_.get(); } | 300 base::SimpleTestTickClock* now_src() { return now_src_.get(); } |
| 292 | 301 |
| 293 // As this function contains EXPECT macros, to allow debugging it should be | 302 // As this function contains EXPECT macros, to allow debugging it should be |
| 294 // called inside EXPECT_SCOPED like so; | 303 // called inside EXPECT_SCOPED like so; |
| 295 // EXPECT_SCOPED( | 304 // EXPECT_SCOPED( |
| 296 // client.InitializeCompositorFrameSinkAndFirstCommit(scheduler)); | 305 // client.InitializeCompositorFrameSinkAndFirstCommit(scheduler)); |
| 297 void InitializeCompositorFrameSinkAndFirstCommit() { | 306 void InitializeCompositorFrameSinkAndFirstCommit() { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 return args; | 412 return args; |
| 404 } | 413 } |
| 405 | 414 |
| 406 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { | 415 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { |
| 407 return fake_external_begin_frame_source_.get(); | 416 return fake_external_begin_frame_source_.get(); |
| 408 } | 417 } |
| 409 | 418 |
| 410 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); | 419 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); |
| 411 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline); | 420 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline); |
| 412 void ImplFrameNotSkippedAfterLateSwapAck(); | 421 void ImplFrameNotSkippedAfterLateSwapAck(); |
| 413 void BeginFramesNotFromClient(bool use_external_begin_frame_source, | 422 void BeginFramesNotFromClient(BeginFrameSourceType bfs_type); |
| 414 bool throttle_frame_production); | 423 void BeginFramesNotFromClient_SwapThrottled(BeginFrameSourceType bfs_type); |
| 415 void BeginFramesNotFromClient_SwapThrottled( | |
| 416 bool use_external_begin_frame_source, | |
| 417 bool throttle_frame_production); | |
| 418 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, | 424 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, |
| 419 ScrollHandlerState scroll_handler_state, | 425 ScrollHandlerState scroll_handler_state, |
| 420 base::TimeDelta durations); | 426 base::TimeDelta durations); |
| 421 | 427 |
| 422 std::unique_ptr<base::SimpleTestTickClock> now_src_; | 428 std::unique_ptr<base::SimpleTestTickClock> now_src_; |
| 423 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 429 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 424 std::unique_ptr<FakeExternalBeginFrameSource> | 430 std::unique_ptr<FakeExternalBeginFrameSource> |
| 425 fake_external_begin_frame_source_; | 431 fake_external_begin_frame_source_; |
| 426 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; | 432 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; |
| 427 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_; | 433 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_; |
| 428 SchedulerSettings scheduler_settings_; | 434 SchedulerSettings scheduler_settings_; |
| 429 std::unique_ptr<FakeSchedulerClient> client_; | 435 std::unique_ptr<FakeSchedulerClient> client_; |
| 430 std::unique_ptr<TestScheduler> scheduler_; | 436 std::unique_ptr<TestScheduler> scheduler_; |
| 431 FakeCompositorTimingHistory* fake_compositor_timing_history_; | 437 FakeCompositorTimingHistory* fake_compositor_timing_history_; |
| 432 }; | 438 }; |
| 433 | 439 |
| 434 TEST_F(SchedulerTest, InitializeCompositorFrameSinkDoesNotBeginImplFrame) { | 440 TEST_F(SchedulerTest, InitializeCompositorFrameSinkDoesNotBeginImplFrame) { |
| 435 scheduler_settings_.use_external_begin_frame_source = true; | 441 SetUpSchedulerWithNoCompositorFrameSink(EXTERNAL_BFS); |
| 436 SetUpScheduler(false); | |
| 437 scheduler_->SetVisible(true); | 442 scheduler_->SetVisible(true); |
| 438 scheduler_->SetCanDraw(true); | 443 scheduler_->SetCanDraw(true); |
| 439 | 444 |
| 440 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", | 445 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", |
| 441 client_); | 446 client_); |
| 442 client_->Reset(); | 447 client_->Reset(); |
| 443 scheduler_->DidCreateAndInitializeCompositorFrameSink(); | 448 scheduler_->DidCreateAndInitializeCompositorFrameSink(); |
| 444 EXPECT_NO_ACTION(client_); | 449 EXPECT_NO_ACTION(client_); |
| 445 } | 450 } |
| 446 | 451 |
| 447 TEST_F(SchedulerTest, VideoNeedsBeginFrames) { | 452 TEST_F(SchedulerTest, VideoNeedsBeginFrames) { |
| 448 scheduler_settings_.use_external_begin_frame_source = true; | 453 SetUpScheduler(EXTERNAL_BFS); |
| 449 SetUpScheduler(true); | |
| 450 | 454 |
| 451 scheduler_->SetVideoNeedsBeginFrames(true); | 455 scheduler_->SetVideoNeedsBeginFrames(true); |
| 452 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 456 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 453 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 457 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 454 | 458 |
| 455 client_->Reset(); | 459 client_->Reset(); |
| 456 EXPECT_SCOPED(AdvanceFrame()); | 460 EXPECT_SCOPED(AdvanceFrame()); |
| 457 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 461 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 458 // WillBeginImplFrame is responsible for sending BeginFrames to video. | 462 // WillBeginImplFrame is responsible for sending BeginFrames to video. |
| 459 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 463 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 460 | 464 |
| 461 client_->Reset(); | 465 client_->Reset(); |
| 462 EXPECT_SCOPED(AdvanceFrame()); | 466 EXPECT_SCOPED(AdvanceFrame()); |
| 463 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 467 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 464 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 468 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 465 | 469 |
| 466 client_->Reset(); | 470 client_->Reset(); |
| 467 scheduler_->SetVideoNeedsBeginFrames(false); | 471 scheduler_->SetVideoNeedsBeginFrames(false); |
| 468 EXPECT_NO_ACTION(client_); | 472 EXPECT_NO_ACTION(client_); |
| 469 | 473 |
| 470 client_->Reset(); | 474 client_->Reset(); |
| 471 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | 475 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 472 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 476 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 473 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 477 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 474 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 478 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 475 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 479 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 476 } | 480 } |
| 477 | 481 |
| 478 TEST_F(SchedulerTest, RequestCommit) { | 482 TEST_F(SchedulerTest, RequestCommit) { |
| 479 scheduler_settings_.use_external_begin_frame_source = true; | 483 SetUpScheduler(EXTERNAL_BFS); |
| 480 SetUpScheduler(true); | |
| 481 | 484 |
| 482 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 485 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 483 scheduler_->SetNeedsBeginMainFrame(); | 486 scheduler_->SetNeedsBeginMainFrame(); |
| 484 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 487 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 485 client_->Reset(); | 488 client_->Reset(); |
| 486 | 489 |
| 487 EXPECT_SCOPED(AdvanceFrame()); | 490 EXPECT_SCOPED(AdvanceFrame()); |
| 488 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 491 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 489 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 492 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 490 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 493 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 535 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 533 client_->Reset(); | 536 client_->Reset(); |
| 534 | 537 |
| 535 task_runner().RunPendingTasks(); // Run posted deadline. | 538 task_runner().RunPendingTasks(); // Run posted deadline. |
| 536 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 539 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 537 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 540 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 538 client_->Reset(); | 541 client_->Reset(); |
| 539 } | 542 } |
| 540 | 543 |
| 541 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { | 544 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { |
| 542 scheduler_settings_.use_external_begin_frame_source = true; | 545 SetUpScheduler(EXTERNAL_BFS); |
| 543 SetUpScheduler(true); | |
| 544 | 546 |
| 545 scheduler_->SetDeferCommits(true); | 547 scheduler_->SetDeferCommits(true); |
| 546 | 548 |
| 547 scheduler_->SetNeedsBeginMainFrame(); | 549 scheduler_->SetNeedsBeginMainFrame(); |
| 548 EXPECT_NO_ACTION(client_); | 550 EXPECT_NO_ACTION(client_); |
| 549 | 551 |
| 550 client_->Reset(); | 552 client_->Reset(); |
| 551 task_runner().RunPendingTasks(); | 553 task_runner().RunPendingTasks(); |
| 552 // There are no pending tasks or actions. | 554 // There are no pending tasks or actions. |
| 553 EXPECT_NO_ACTION(client_); | 555 EXPECT_NO_ACTION(client_); |
| 554 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 556 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 555 | 557 |
| 556 client_->Reset(); | 558 client_->Reset(); |
| 557 scheduler_->SetDeferCommits(false); | 559 scheduler_->SetDeferCommits(false); |
| 558 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 560 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 559 | 561 |
| 560 // Start new BeginMainFrame after defer commit is off. | 562 // Start new BeginMainFrame after defer commit is off. |
| 561 client_->Reset(); | 563 client_->Reset(); |
| 562 EXPECT_SCOPED(AdvanceFrame()); | 564 EXPECT_SCOPED(AdvanceFrame()); |
| 563 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 565 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 564 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 566 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 565 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 567 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 566 } | 568 } |
| 567 | 569 |
| 568 TEST_F(SchedulerTest, DeferCommitWithRedraw) { | 570 TEST_F(SchedulerTest, DeferCommitWithRedraw) { |
| 569 scheduler_settings_.use_external_begin_frame_source = true; | 571 SetUpScheduler(EXTERNAL_BFS); |
| 570 SetUpScheduler(true); | |
| 571 | 572 |
| 572 scheduler_->SetDeferCommits(true); | 573 scheduler_->SetDeferCommits(true); |
| 573 | 574 |
| 574 scheduler_->SetNeedsBeginMainFrame(); | 575 scheduler_->SetNeedsBeginMainFrame(); |
| 575 EXPECT_NO_ACTION(client_); | 576 EXPECT_NO_ACTION(client_); |
| 576 | 577 |
| 577 // The SetNeedsRedraw will override the SetDeferCommits(true), to allow a | 578 // The SetNeedsRedraw will override the SetDeferCommits(true), to allow a |
| 578 // begin frame to be needed. | 579 // begin frame to be needed. |
| 579 client_->Reset(); | 580 client_->Reset(); |
| 580 scheduler_->SetNeedsRedraw(); | 581 scheduler_->SetNeedsRedraw(); |
| 581 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 582 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 582 | 583 |
| 583 client_->Reset(); | 584 client_->Reset(); |
| 584 AdvanceFrame(); | 585 AdvanceFrame(); |
| 585 // BeginMainFrame is not sent during the defer commit is on. | 586 // BeginMainFrame is not sent during the defer commit is on. |
| 586 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 587 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 587 | 588 |
| 588 client_->Reset(); | 589 client_->Reset(); |
| 589 task_runner().RunPendingTasks(); // Run posted deadline. | 590 task_runner().RunPendingTasks(); // Run posted deadline. |
| 590 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 591 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 591 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 592 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 592 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 593 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 593 | 594 |
| 594 client_->Reset(); | 595 client_->Reset(); |
| 595 AdvanceFrame(); | 596 AdvanceFrame(); |
| 596 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 597 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 597 } | 598 } |
| 598 | 599 |
| 599 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { | 600 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| 600 scheduler_settings_.use_external_begin_frame_source = true; | 601 SetUpScheduler(EXTERNAL_BFS); |
| 601 SetUpScheduler(true); | |
| 602 | 602 |
| 603 // SetNeedsBeginMainFrame should begin the frame. | 603 // SetNeedsBeginMainFrame should begin the frame. |
| 604 scheduler_->SetNeedsBeginMainFrame(); | 604 scheduler_->SetNeedsBeginMainFrame(); |
| 605 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 605 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 606 | 606 |
| 607 client_->Reset(); | 607 client_->Reset(); |
| 608 EXPECT_SCOPED(AdvanceFrame()); | 608 EXPECT_SCOPED(AdvanceFrame()); |
| 609 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 609 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 610 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 610 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 611 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 611 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 bool request_redraws_; | 697 bool request_redraws_; |
| 698 }; | 698 }; |
| 699 | 699 |
| 700 // Tests for two different situations: | 700 // Tests for two different situations: |
| 701 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside | 701 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside |
| 702 // a ScheduledActionDrawAndSwap | 702 // a ScheduledActionDrawAndSwap |
| 703 // 2. the scheduler drawing twice inside a single tick | 703 // 2. the scheduler drawing twice inside a single tick |
| 704 TEST_F(SchedulerTest, RequestRedrawInsideDraw) { | 704 TEST_F(SchedulerTest, RequestRedrawInsideDraw) { |
| 705 SchedulerClientThatsetNeedsDrawInsideDraw* client = | 705 SchedulerClientThatsetNeedsDrawInsideDraw* client = |
| 706 new SchedulerClientThatsetNeedsDrawInsideDraw; | 706 new SchedulerClientThatsetNeedsDrawInsideDraw; |
| 707 scheduler_settings_.use_external_begin_frame_source = true; | 707 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 708 SetUpScheduler(base::WrapUnique(client), true); | |
| 709 client->SetRequestRedrawsInsideDraw(true); | 708 client->SetRequestRedrawsInsideDraw(true); |
| 710 | 709 |
| 711 scheduler_->SetNeedsRedraw(); | 710 scheduler_->SetNeedsRedraw(); |
| 712 EXPECT_TRUE(scheduler_->RedrawPending()); | 711 EXPECT_TRUE(scheduler_->RedrawPending()); |
| 713 EXPECT_TRUE(client->needs_begin_frames()); | 712 EXPECT_TRUE(client->needs_begin_frames()); |
| 714 EXPECT_EQ(0, client->num_draws()); | 713 EXPECT_EQ(0, client->num_draws()); |
| 715 | 714 |
| 716 EXPECT_SCOPED(AdvanceFrame()); | 715 EXPECT_SCOPED(AdvanceFrame()); |
| 717 task_runner().RunPendingTasks(); // Run posted deadline. | 716 task_runner().RunPendingTasks(); // Run posted deadline. |
| 718 EXPECT_EQ(1, client->num_draws()); | 717 EXPECT_EQ(1, client->num_draws()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 733 task_runner().RunPendingTasks(); // Run posted deadline. | 732 task_runner().RunPendingTasks(); // Run posted deadline. |
| 734 EXPECT_EQ(2, client->num_draws()); | 733 EXPECT_EQ(2, client->num_draws()); |
| 735 EXPECT_FALSE(scheduler_->RedrawPending()); | 734 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 736 EXPECT_FALSE(client->needs_begin_frames()); | 735 EXPECT_FALSE(client->needs_begin_frames()); |
| 737 } | 736 } |
| 738 | 737 |
| 739 // Test that requesting redraw inside a failed draw doesn't lose the request. | 738 // Test that requesting redraw inside a failed draw doesn't lose the request. |
| 740 TEST_F(SchedulerTest, RequestRedrawInsideFailedDraw) { | 739 TEST_F(SchedulerTest, RequestRedrawInsideFailedDraw) { |
| 741 SchedulerClientThatsetNeedsDrawInsideDraw* client = | 740 SchedulerClientThatsetNeedsDrawInsideDraw* client = |
| 742 new SchedulerClientThatsetNeedsDrawInsideDraw; | 741 new SchedulerClientThatsetNeedsDrawInsideDraw; |
| 743 scheduler_settings_.use_external_begin_frame_source = true; | 742 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 744 SetUpScheduler(base::WrapUnique(client), true); | |
| 745 | 743 |
| 746 client->SetRequestRedrawsInsideDraw(true); | 744 client->SetRequestRedrawsInsideDraw(true); |
| 747 client->SetDrawWillHappen(false); | 745 client->SetDrawWillHappen(false); |
| 748 | 746 |
| 749 scheduler_->SetNeedsRedraw(); | 747 scheduler_->SetNeedsRedraw(); |
| 750 EXPECT_TRUE(scheduler_->RedrawPending()); | 748 EXPECT_TRUE(scheduler_->RedrawPending()); |
| 751 EXPECT_TRUE(client->needs_begin_frames()); | 749 EXPECT_TRUE(client->needs_begin_frames()); |
| 752 EXPECT_EQ(0, client->num_draws()); | 750 EXPECT_EQ(0, client->num_draws()); |
| 753 | 751 |
| 754 // Fail the draw. | 752 // Fail the draw. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 | 806 |
| 809 private: | 807 private: |
| 810 bool set_needs_commit_on_next_draw_; | 808 bool set_needs_commit_on_next_draw_; |
| 811 }; | 809 }; |
| 812 | 810 |
| 813 // Tests for the scheduler infinite-looping on SetNeedsBeginMainFrame requests | 811 // Tests for the scheduler infinite-looping on SetNeedsBeginMainFrame requests |
| 814 // that happen inside a ScheduledActionDrawAndSwap | 812 // that happen inside a ScheduledActionDrawAndSwap |
| 815 TEST_F(SchedulerTest, RequestCommitInsideDraw) { | 813 TEST_F(SchedulerTest, RequestCommitInsideDraw) { |
| 816 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client = | 814 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client = |
| 817 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw; | 815 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw; |
| 818 | 816 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 819 scheduler_settings_.use_external_begin_frame_source = true; | |
| 820 SetUpScheduler(base::WrapUnique(client), true); | |
| 821 | 817 |
| 822 EXPECT_FALSE(client->needs_begin_frames()); | 818 EXPECT_FALSE(client->needs_begin_frames()); |
| 823 scheduler_->SetNeedsRedraw(); | 819 scheduler_->SetNeedsRedraw(); |
| 824 EXPECT_TRUE(scheduler_->RedrawPending()); | 820 EXPECT_TRUE(scheduler_->RedrawPending()); |
| 825 EXPECT_EQ(0, client->num_draws()); | 821 EXPECT_EQ(0, client->num_draws()); |
| 826 EXPECT_TRUE(client->needs_begin_frames()); | 822 EXPECT_TRUE(client->needs_begin_frames()); |
| 827 | 823 |
| 828 client->SetNeedsBeginMainFrameOnNextDraw(); | 824 client->SetNeedsBeginMainFrameOnNextDraw(); |
| 829 EXPECT_SCOPED(AdvanceFrame()); | 825 EXPECT_SCOPED(AdvanceFrame()); |
| 830 client->SetNeedsBeginMainFrameOnNextDraw(); | 826 client->SetNeedsBeginMainFrameOnNextDraw(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 851 EXPECT_EQ(2, client->num_draws()); | 847 EXPECT_EQ(2, client->num_draws()); |
| 852 EXPECT_FALSE(scheduler_->RedrawPending()); | 848 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 853 EXPECT_FALSE(scheduler_->CommitPending()); | 849 EXPECT_FALSE(scheduler_->CommitPending()); |
| 854 EXPECT_FALSE(client->needs_begin_frames()); | 850 EXPECT_FALSE(client->needs_begin_frames()); |
| 855 } | 851 } |
| 856 | 852 |
| 857 // Tests that when a draw fails then the pending commit should not be dropped. | 853 // Tests that when a draw fails then the pending commit should not be dropped. |
| 858 TEST_F(SchedulerTest, RequestCommitInsideFailedDraw) { | 854 TEST_F(SchedulerTest, RequestCommitInsideFailedDraw) { |
| 859 SchedulerClientThatsetNeedsDrawInsideDraw* client = | 855 SchedulerClientThatsetNeedsDrawInsideDraw* client = |
| 860 new SchedulerClientThatsetNeedsDrawInsideDraw; | 856 new SchedulerClientThatsetNeedsDrawInsideDraw; |
| 861 scheduler_settings_.use_external_begin_frame_source = true; | 857 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 862 SetUpScheduler(base::WrapUnique(client), true); | |
| 863 | 858 |
| 864 client->SetDrawWillHappen(false); | 859 client->SetDrawWillHappen(false); |
| 865 | 860 |
| 866 scheduler_->SetNeedsRedraw(); | 861 scheduler_->SetNeedsRedraw(); |
| 867 EXPECT_TRUE(scheduler_->RedrawPending()); | 862 EXPECT_TRUE(scheduler_->RedrawPending()); |
| 868 EXPECT_TRUE(client->needs_begin_frames()); | 863 EXPECT_TRUE(client->needs_begin_frames()); |
| 869 EXPECT_EQ(0, client->num_draws()); | 864 EXPECT_EQ(0, client->num_draws()); |
| 870 | 865 |
| 871 // Fail the draw. | 866 // Fail the draw. |
| 872 EXPECT_SCOPED(AdvanceFrame()); | 867 EXPECT_SCOPED(AdvanceFrame()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 894 task_runner().RunPendingTasks(); // Run posted deadline. | 889 task_runner().RunPendingTasks(); // Run posted deadline. |
| 895 EXPECT_EQ(3, client->num_draws()); | 890 EXPECT_EQ(3, client->num_draws()); |
| 896 EXPECT_TRUE(scheduler_->CommitPending()); | 891 EXPECT_TRUE(scheduler_->CommitPending()); |
| 897 EXPECT_FALSE(scheduler_->RedrawPending()); | 892 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 898 EXPECT_TRUE(client->needs_begin_frames()); | 893 EXPECT_TRUE(client->needs_begin_frames()); |
| 899 } | 894 } |
| 900 | 895 |
| 901 TEST_F(SchedulerTest, NoSwapWhenDrawFails) { | 896 TEST_F(SchedulerTest, NoSwapWhenDrawFails) { |
| 902 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client = | 897 SchedulerClientThatSetNeedsBeginMainFrameInsideDraw* client = |
| 903 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw; | 898 new SchedulerClientThatSetNeedsBeginMainFrameInsideDraw; |
| 904 scheduler_settings_.use_external_begin_frame_source = true; | 899 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 905 SetUpScheduler(base::WrapUnique(client), true); | |
| 906 | 900 |
| 907 scheduler_->SetNeedsRedraw(); | 901 scheduler_->SetNeedsRedraw(); |
| 908 EXPECT_TRUE(scheduler_->RedrawPending()); | 902 EXPECT_TRUE(scheduler_->RedrawPending()); |
| 909 EXPECT_TRUE(client->needs_begin_frames()); | 903 EXPECT_TRUE(client->needs_begin_frames()); |
| 910 EXPECT_EQ(0, client->num_draws()); | 904 EXPECT_EQ(0, client->num_draws()); |
| 911 | 905 |
| 912 // Draw successfully, this starts a new frame. | 906 // Draw successfully, this starts a new frame. |
| 913 client->SetNeedsBeginMainFrameOnNextDraw(); | 907 client->SetNeedsBeginMainFrameOnNextDraw(); |
| 914 EXPECT_SCOPED(AdvanceFrame()); | 908 EXPECT_SCOPED(AdvanceFrame()); |
| 915 task_runner().RunPendingTasks(); // Run posted deadline. | 909 task_runner().RunPendingTasks(); // Run posted deadline. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 932 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 926 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
| 933 scheduler_->SetNeedsPrepareTiles(); | 927 scheduler_->SetNeedsPrepareTiles(); |
| 934 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 928 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
| 935 } | 929 } |
| 936 }; | 930 }; |
| 937 | 931 |
| 938 // Test prepare tiles is independant of draws. | 932 // Test prepare tiles is independant of draws. |
| 939 TEST_F(SchedulerTest, PrepareTiles) { | 933 TEST_F(SchedulerTest, PrepareTiles) { |
| 940 SchedulerClientNeedsPrepareTilesInDraw* client = | 934 SchedulerClientNeedsPrepareTilesInDraw* client = |
| 941 new SchedulerClientNeedsPrepareTilesInDraw; | 935 new SchedulerClientNeedsPrepareTilesInDraw; |
| 942 scheduler_settings_.use_external_begin_frame_source = true; | 936 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 943 SetUpScheduler(base::WrapUnique(client), true); | |
| 944 | 937 |
| 945 // Request both draw and prepare tiles. PrepareTiles shouldn't | 938 // Request both draw and prepare tiles. PrepareTiles shouldn't |
| 946 // be trigged until BeginImplFrame. | 939 // be trigged until BeginImplFrame. |
| 947 client->Reset(); | 940 client->Reset(); |
| 948 scheduler_->SetNeedsPrepareTiles(); | 941 scheduler_->SetNeedsPrepareTiles(); |
| 949 scheduler_->SetNeedsRedraw(); | 942 scheduler_->SetNeedsRedraw(); |
| 950 EXPECT_TRUE(scheduler_->RedrawPending()); | 943 EXPECT_TRUE(scheduler_->RedrawPending()); |
| 951 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 944 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| 952 EXPECT_TRUE(client->needs_begin_frames()); | 945 EXPECT_TRUE(client->needs_begin_frames()); |
| 953 EXPECT_EQ(0, client->num_draws()); | 946 EXPECT_EQ(0, client->num_draws()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 task_runner().RunPendingTasks(); // Run posted deadline. | 1025 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1033 EXPECT_EQ(0, client->num_draws()); | 1026 EXPECT_EQ(0, client->num_draws()); |
| 1034 EXPECT_FALSE(client->HasAction("ScheduledActionDrawAndSwapIfPossible")); | 1027 EXPECT_FALSE(client->HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| 1035 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); | 1028 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); |
| 1036 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1029 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1037 } | 1030 } |
| 1038 | 1031 |
| 1039 // Test that PrepareTiles only happens once per frame. If an external caller | 1032 // Test that PrepareTiles only happens once per frame. If an external caller |
| 1040 // initiates it, then the state machine should not PrepareTiles on that frame. | 1033 // initiates it, then the state machine should not PrepareTiles on that frame. |
| 1041 TEST_F(SchedulerTest, PrepareTilesOncePerFrame) { | 1034 TEST_F(SchedulerTest, PrepareTilesOncePerFrame) { |
| 1042 scheduler_settings_.use_external_begin_frame_source = true; | 1035 SetUpScheduler(EXTERNAL_BFS); |
| 1043 SetUpScheduler(true); | |
| 1044 | 1036 |
| 1045 // If DidPrepareTiles during a frame, then PrepareTiles should not occur | 1037 // If DidPrepareTiles during a frame, then PrepareTiles should not occur |
| 1046 // again. | 1038 // again. |
| 1047 scheduler_->SetNeedsPrepareTiles(); | 1039 scheduler_->SetNeedsPrepareTiles(); |
| 1048 scheduler_->SetNeedsRedraw(); | 1040 scheduler_->SetNeedsRedraw(); |
| 1049 client_->Reset(); | 1041 client_->Reset(); |
| 1050 EXPECT_SCOPED(AdvanceFrame()); | 1042 EXPECT_SCOPED(AdvanceFrame()); |
| 1051 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1043 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 1052 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1044 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1053 | 1045 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), | 1137 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), |
| 1146 client_->ActionIndex("ScheduledActionPrepareTiles")); | 1138 client_->ActionIndex("ScheduledActionPrepareTiles")); |
| 1147 EXPECT_FALSE(scheduler_->RedrawPending()); | 1139 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1148 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1140 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1149 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1141 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1150 } | 1142 } |
| 1151 | 1143 |
| 1152 TEST_F(SchedulerTest, PrepareTilesFunnelResetOnVisibilityChange) { | 1144 TEST_F(SchedulerTest, PrepareTilesFunnelResetOnVisibilityChange) { |
| 1153 std::unique_ptr<SchedulerClientNeedsPrepareTilesInDraw> client = | 1145 std::unique_ptr<SchedulerClientNeedsPrepareTilesInDraw> client = |
| 1154 base::WrapUnique(new SchedulerClientNeedsPrepareTilesInDraw); | 1146 base::WrapUnique(new SchedulerClientNeedsPrepareTilesInDraw); |
| 1155 scheduler_settings_.use_external_begin_frame_source = true; | 1147 SetUpScheduler(EXTERNAL_BFS, std::move(client)); |
| 1156 SetUpScheduler(std::move(client), true); | |
| 1157 | 1148 |
| 1158 // Simulate a few visibility changes and associated PrepareTiles. | 1149 // Simulate a few visibility changes and associated PrepareTiles. |
| 1159 for (int i = 0; i < 10; i++) { | 1150 for (int i = 0; i < 10; i++) { |
| 1160 scheduler_->SetVisible(false); | 1151 scheduler_->SetVisible(false); |
| 1161 scheduler_->WillPrepareTiles(); | 1152 scheduler_->WillPrepareTiles(); |
| 1162 scheduler_->DidPrepareTiles(); | 1153 scheduler_->DidPrepareTiles(); |
| 1163 | 1154 |
| 1164 scheduler_->SetVisible(true); | 1155 scheduler_->SetVisible(true); |
| 1165 scheduler_->WillPrepareTiles(); | 1156 scheduler_->WillPrepareTiles(); |
| 1166 scheduler_->DidPrepareTiles(); | 1157 scheduler_->DidPrepareTiles(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1178 client_->Reset(); | 1169 client_->Reset(); |
| 1179 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 1170 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 1180 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1171 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1181 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2); | 1172 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2); |
| 1182 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); | 1173 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); |
| 1183 } | 1174 } |
| 1184 | 1175 |
| 1185 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) { | 1176 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) { |
| 1186 SchedulerClientNeedsPrepareTilesInDraw* client = | 1177 SchedulerClientNeedsPrepareTilesInDraw* client = |
| 1187 new SchedulerClientNeedsPrepareTilesInDraw; | 1178 new SchedulerClientNeedsPrepareTilesInDraw; |
| 1188 scheduler_settings_.use_external_begin_frame_source = true; | 1179 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 1189 SetUpScheduler(base::WrapUnique(client), true); | |
| 1190 | 1180 |
| 1191 scheduler_->SetNeedsRedraw(); | 1181 scheduler_->SetNeedsRedraw(); |
| 1192 EXPECT_SCOPED(AdvanceFrame()); | 1182 EXPECT_SCOPED(AdvanceFrame()); |
| 1193 | 1183 |
| 1194 // The deadline should be zero since there is no work other than drawing | 1184 // The deadline should be zero since there is no work other than drawing |
| 1195 // pending. | 1185 // pending. |
| 1196 EXPECT_EQ(base::TimeTicks(), client->posted_begin_impl_frame_deadline()); | 1186 EXPECT_EQ(base::TimeTicks(), client->posted_begin_impl_frame_deadline()); |
| 1197 } | 1187 } |
| 1198 | 1188 |
| 1199 TEST_F(SchedulerTest, WaitForReadyToDrawDoNotPostDeadline) { | 1189 TEST_F(SchedulerTest, WaitForReadyToDrawDoNotPostDeadline) { |
| 1200 SchedulerClientNeedsPrepareTilesInDraw* client = | 1190 SchedulerClientNeedsPrepareTilesInDraw* client = |
| 1201 new SchedulerClientNeedsPrepareTilesInDraw; | 1191 new SchedulerClientNeedsPrepareTilesInDraw; |
| 1202 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1203 scheduler_settings_.commit_to_active_tree = true; | 1192 scheduler_settings_.commit_to_active_tree = true; |
| 1204 SetUpScheduler(base::WrapUnique(client), true); | 1193 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 1205 | 1194 |
| 1206 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 1195 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 1207 scheduler_->SetNeedsBeginMainFrame(); | 1196 scheduler_->SetNeedsBeginMainFrame(); |
| 1208 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 1197 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 1209 client_->Reset(); | 1198 client_->Reset(); |
| 1210 | 1199 |
| 1211 // Begin new frame. | 1200 // Begin new frame. |
| 1212 EXPECT_SCOPED(AdvanceFrame()); | 1201 EXPECT_SCOPED(AdvanceFrame()); |
| 1213 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 1202 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 1214 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1203 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1232 scheduler_->NotifyReadyToDraw(); | 1221 scheduler_->NotifyReadyToDraw(); |
| 1233 client_->Reset(); | 1222 client_->Reset(); |
| 1234 task_runner().RunPendingTasks(); // Run posted deadline. | 1223 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1235 EXPECT_EQ(1, client_->num_draws()); | 1224 EXPECT_EQ(1, client_->num_draws()); |
| 1236 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); | 1225 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| 1237 } | 1226 } |
| 1238 | 1227 |
| 1239 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostCompositorFrameSink) { | 1228 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostCompositorFrameSink) { |
| 1240 SchedulerClientNeedsPrepareTilesInDraw* client = | 1229 SchedulerClientNeedsPrepareTilesInDraw* client = |
| 1241 new SchedulerClientNeedsPrepareTilesInDraw; | 1230 new SchedulerClientNeedsPrepareTilesInDraw; |
| 1242 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1243 scheduler_settings_.commit_to_active_tree = true; | 1231 scheduler_settings_.commit_to_active_tree = true; |
| 1244 SetUpScheduler(base::WrapUnique(client), true); | 1232 SetUpScheduler(EXTERNAL_BFS, base::WrapUnique(client)); |
| 1245 | 1233 |
| 1246 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 1234 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 1247 scheduler_->SetNeedsBeginMainFrame(); | 1235 scheduler_->SetNeedsBeginMainFrame(); |
| 1248 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 1236 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 1249 client_->Reset(); | 1237 client_->Reset(); |
| 1250 | 1238 |
| 1251 // Begin new frame. | 1239 // Begin new frame. |
| 1252 EXPECT_SCOPED(AdvanceFrame()); | 1240 EXPECT_SCOPED(AdvanceFrame()); |
| 1253 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 1241 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 1254 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1242 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1294 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1307 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 1295 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 1308 EXPECT_EQ(expect_send_begin_main_frame, | 1296 EXPECT_EQ(expect_send_begin_main_frame, |
| 1309 scheduler_->MainThreadMissedLastDeadline()); | 1297 scheduler_->MainThreadMissedLastDeadline()); |
| 1310 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); | 1298 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); |
| 1311 EXPECT_EQ(expect_send_begin_main_frame, | 1299 EXPECT_EQ(expect_send_begin_main_frame, |
| 1312 client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1300 client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1313 } | 1301 } |
| 1314 | 1302 |
| 1315 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { | 1303 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { |
| 1316 scheduler_settings_.use_external_begin_frame_source = true; | 1304 SetUpScheduler(EXTERNAL_BFS); |
| 1317 SetUpScheduler(true); | |
| 1318 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1305 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1319 | 1306 |
| 1320 bool expect_send_begin_main_frame = false; | 1307 bool expect_send_begin_main_frame = false; |
| 1321 EXPECT_SCOPED( | 1308 EXPECT_SCOPED( |
| 1322 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1309 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1323 } | 1310 } |
| 1324 | 1311 |
| 1325 // Response times of BeginMainFrame's without the critical path flag set | 1312 // Response times of BeginMainFrame's without the critical path flag set |
| 1326 // should not affect whether we recover latency or not. | 1313 // should not affect whether we recover latency or not. |
| 1327 TEST_F(SchedulerTest, | 1314 TEST_F(SchedulerTest, |
| 1328 MainFrameSkippedAfterLateCommit_LongMainFrameQueueDurationNotCritical) { | 1315 MainFrameSkippedAfterLateCommit_LongMainFrameQueueDurationNotCritical) { |
| 1329 scheduler_settings_.use_external_begin_frame_source = true; | 1316 SetUpScheduler(EXTERNAL_BFS); |
| 1330 SetUpScheduler(true); | |
| 1331 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1317 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1332 fake_compositor_timing_history_ | 1318 fake_compositor_timing_history_ |
| 1333 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); | 1319 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1334 | 1320 |
| 1335 bool expect_send_begin_main_frame = false; | 1321 bool expect_send_begin_main_frame = false; |
| 1336 EXPECT_SCOPED( | 1322 EXPECT_SCOPED( |
| 1337 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1323 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1338 } | 1324 } |
| 1339 | 1325 |
| 1340 // Response times of BeginMainFrame's with the critical path flag set | 1326 // Response times of BeginMainFrame's with the critical path flag set |
| 1341 // should affect whether we recover latency or not. | 1327 // should affect whether we recover latency or not. |
| 1342 TEST_F(SchedulerTest, | 1328 TEST_F(SchedulerTest, |
| 1343 MainFrameNotSkippedAfterLateCommit_LongMainFrameQueueDurationCritical) { | 1329 MainFrameNotSkippedAfterLateCommit_LongMainFrameQueueDurationCritical) { |
| 1344 scheduler_settings_.use_external_begin_frame_source = true; | 1330 SetUpScheduler(EXTERNAL_BFS); |
| 1345 SetUpScheduler(true); | |
| 1346 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1331 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1347 fake_compositor_timing_history_ | 1332 fake_compositor_timing_history_ |
| 1348 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); | 1333 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); |
| 1349 fake_compositor_timing_history_ | 1334 fake_compositor_timing_history_ |
| 1350 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); | 1335 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1351 | 1336 |
| 1352 bool expect_send_begin_main_frame = true; | 1337 bool expect_send_begin_main_frame = true; |
| 1353 EXPECT_SCOPED( | 1338 EXPECT_SCOPED( |
| 1354 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1339 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1355 } | 1340 } |
| 1356 | 1341 |
| 1357 TEST_F(SchedulerTest, | 1342 TEST_F(SchedulerTest, |
| 1358 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) { | 1343 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) { |
| 1359 scheduler_settings_.use_external_begin_frame_source = true; | 1344 SetUpScheduler(EXTERNAL_BFS); |
| 1360 SetUpScheduler(true); | |
| 1361 scheduler_->SetTreePrioritiesAndScrollState( | 1345 scheduler_->SetTreePrioritiesAndScrollState( |
| 1362 SMOOTHNESS_TAKES_PRIORITY, | 1346 SMOOTHNESS_TAKES_PRIORITY, |
| 1363 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); | 1347 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); |
| 1364 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1348 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1365 | 1349 |
| 1366 bool expect_send_begin_main_frame = true; | 1350 bool expect_send_begin_main_frame = true; |
| 1367 EXPECT_SCOPED( | 1351 EXPECT_SCOPED( |
| 1368 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1352 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1369 } | 1353 } |
| 1370 | 1354 |
| 1371 TEST_F(SchedulerTest, | 1355 TEST_F(SchedulerTest, |
| 1372 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) { | 1356 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) { |
| 1373 scheduler_settings_.use_external_begin_frame_source = true; | 1357 SetUpScheduler(EXTERNAL_BFS); |
| 1374 SetUpScheduler(true); | |
| 1375 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1358 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1376 fake_compositor_timing_history_ | 1359 fake_compositor_timing_history_ |
| 1377 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); | 1360 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); |
| 1378 | 1361 |
| 1379 bool expect_send_begin_main_frame = true; | 1362 bool expect_send_begin_main_frame = true; |
| 1380 EXPECT_SCOPED( | 1363 EXPECT_SCOPED( |
| 1381 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1364 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1382 } | 1365 } |
| 1383 | 1366 |
| 1384 TEST_F(SchedulerTest, | 1367 TEST_F(SchedulerTest, |
| 1385 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) { | 1368 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) { |
| 1386 scheduler_settings_.use_external_begin_frame_source = true; | 1369 SetUpScheduler(EXTERNAL_BFS); |
| 1387 SetUpScheduler(true); | |
| 1388 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1370 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1389 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1371 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( |
| 1390 kSlowDuration); | 1372 kSlowDuration); |
| 1391 | 1373 |
| 1392 bool expect_send_begin_main_frame = true; | 1374 bool expect_send_begin_main_frame = true; |
| 1393 EXPECT_SCOPED( | 1375 EXPECT_SCOPED( |
| 1394 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1376 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1395 } | 1377 } |
| 1396 | 1378 |
| 1397 TEST_F(SchedulerTest, | 1379 TEST_F(SchedulerTest, |
| 1398 MainFrameNotSkippedAfterLateCommit_ActivateEstimateTooLong) { | 1380 MainFrameNotSkippedAfterLateCommit_ActivateEstimateTooLong) { |
| 1399 scheduler_settings_.use_external_begin_frame_source = true; | 1381 SetUpScheduler(EXTERNAL_BFS); |
| 1400 SetUpScheduler(true); | |
| 1401 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1382 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1402 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); | 1383 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); |
| 1403 | 1384 |
| 1404 bool expect_send_begin_main_frame = true; | 1385 bool expect_send_begin_main_frame = true; |
| 1405 EXPECT_SCOPED( | 1386 EXPECT_SCOPED( |
| 1406 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1387 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1407 } | 1388 } |
| 1408 | 1389 |
| 1409 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateCommit_DrawEstimateTooLong) { | 1390 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateCommit_DrawEstimateTooLong) { |
| 1410 scheduler_settings_.use_external_begin_frame_source = true; | 1391 SetUpScheduler(EXTERNAL_BFS); |
| 1411 SetUpScheduler(true); | |
| 1412 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1392 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1413 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); | 1393 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); |
| 1414 | 1394 |
| 1415 bool expect_send_begin_main_frame = true; | 1395 bool expect_send_begin_main_frame = true; |
| 1416 EXPECT_SCOPED( | 1396 EXPECT_SCOPED( |
| 1417 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | 1397 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1418 } | 1398 } |
| 1419 | 1399 |
| 1420 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the | 1400 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the |
| 1421 // queue, which means there is no latency to recover. | 1401 // queue, which means there is no latency to recover. |
| 1422 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateBeginMainFrameAbort) { | 1402 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateBeginMainFrameAbort) { |
| 1423 scheduler_settings_.use_external_begin_frame_source = true; | 1403 SetUpScheduler(EXTERNAL_BFS); |
| 1424 SetUpScheduler(true); | |
| 1425 | 1404 |
| 1426 // Use fast estimates so we think we can recover latency if needed. | 1405 // Use fast estimates so we think we can recover latency if needed. |
| 1427 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1406 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1428 | 1407 |
| 1429 // Impl thread hits deadline before BeginMainFrame aborts. | 1408 // Impl thread hits deadline before BeginMainFrame aborts. |
| 1430 scheduler_->SetNeedsBeginMainFrame(); | 1409 scheduler_->SetNeedsBeginMainFrame(); |
| 1431 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1410 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1432 EXPECT_SCOPED(AdvanceFrame()); | 1411 EXPECT_SCOPED(AdvanceFrame()); |
| 1433 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); | 1412 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); |
| 1434 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | 1413 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1450 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); | 1429 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); |
| 1451 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1430 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1452 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1431 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1453 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 1432 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 1454 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1433 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1455 } | 1434 } |
| 1456 | 1435 |
| 1457 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the | 1436 // If the BeginMainFrame aborts, it doesn't actually insert a frame into the |
| 1458 // queue, which means there is no latency to recover. | 1437 // queue, which means there is no latency to recover. |
| 1459 TEST_F(SchedulerTest, MainFrameNotSkippedAfterCanDrawChanges) { | 1438 TEST_F(SchedulerTest, MainFrameNotSkippedAfterCanDrawChanges) { |
| 1460 scheduler_settings_.use_external_begin_frame_source = true; | 1439 SetUpScheduler(EXTERNAL_BFS); |
| 1461 SetUpScheduler(true); | |
| 1462 | 1440 |
| 1463 // Use fast estimates so we think we can recover latency if needed. | 1441 // Use fast estimates so we think we can recover latency if needed. |
| 1464 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1442 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1465 | 1443 |
| 1466 // Impl thread hits deadline before BeginMainFrame aborts. | 1444 // Impl thread hits deadline before BeginMainFrame aborts. |
| 1467 scheduler_->SetNeedsBeginMainFrame(); | 1445 scheduler_->SetNeedsBeginMainFrame(); |
| 1468 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1446 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1469 EXPECT_SCOPED(AdvanceFrame()); | 1447 EXPECT_SCOPED(AdvanceFrame()); |
| 1470 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); | 1448 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); |
| 1471 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | 1449 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 scheduler_->NotifyReadyToActivate(); | 1550 scheduler_->NotifyReadyToActivate(); |
| 1573 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 1551 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 1574 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); | 1552 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); |
| 1575 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); | 1553 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); |
| 1576 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); | 1554 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); |
| 1577 } | 1555 } |
| 1578 } | 1556 } |
| 1579 | 1557 |
| 1580 TEST_F(SchedulerTest, | 1558 TEST_F(SchedulerTest, |
| 1581 ImplFrameSkippedAfterLateSwapAck_FastEstimates_SwapAckThenDeadline) { | 1559 ImplFrameSkippedAfterLateSwapAck_FastEstimates_SwapAckThenDeadline) { |
| 1582 scheduler_settings_.use_external_begin_frame_source = true; | 1560 SetUpScheduler(EXTERNAL_BFS); |
| 1583 SetUpScheduler(true); | |
| 1584 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1561 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1585 | 1562 |
| 1586 bool swap_ack_before_deadline = true; | 1563 bool swap_ack_before_deadline = true; |
| 1587 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); | 1564 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1588 } | 1565 } |
| 1589 | 1566 |
| 1590 TEST_F(SchedulerTest, | 1567 TEST_F(SchedulerTest, |
| 1591 ImplFrameSkippedAfterLateSwapAck_FastEstimates_DeadlineThenSwapAck) { | 1568 ImplFrameSkippedAfterLateSwapAck_FastEstimates_DeadlineThenSwapAck) { |
| 1592 scheduler_settings_.use_external_begin_frame_source = true; | 1569 SetUpScheduler(EXTERNAL_BFS); |
| 1593 SetUpScheduler(true); | |
| 1594 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1570 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1595 | 1571 |
| 1596 bool swap_ack_before_deadline = false; | 1572 bool swap_ack_before_deadline = false; |
| 1597 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); | 1573 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1598 } | 1574 } |
| 1599 | 1575 |
| 1600 TEST_F(SchedulerTest, | 1576 TEST_F(SchedulerTest, |
| 1601 ImplFrameSkippedAfterLateSwapAck_LongMainFrameQueueDurationNotCritical) { | 1577 ImplFrameSkippedAfterLateSwapAck_LongMainFrameQueueDurationNotCritical) { |
| 1602 scheduler_settings_.use_external_begin_frame_source = true; | 1578 SetUpScheduler(EXTERNAL_BFS); |
| 1603 SetUpScheduler(true); | |
| 1604 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1579 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1605 fake_compositor_timing_history_ | 1580 fake_compositor_timing_history_ |
| 1606 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); | 1581 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1607 | 1582 |
| 1608 bool swap_ack_before_deadline = false; | 1583 bool swap_ack_before_deadline = false; |
| 1609 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); | 1584 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1610 } | 1585 } |
| 1611 | 1586 |
| 1612 TEST_F(SchedulerTest, | 1587 TEST_F(SchedulerTest, |
| 1613 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) { | 1588 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) { |
| 1614 scheduler_settings_.use_external_begin_frame_source = true; | 1589 SetUpScheduler(EXTERNAL_BFS); |
| 1615 SetUpScheduler(true); | |
| 1616 | 1590 |
| 1617 // Even if every estimate related to the main thread is slow, we should | 1591 // Even if every estimate related to the main thread is slow, we should |
| 1618 // still expect to recover impl thread latency if the draw is fast and we | 1592 // still expect to recover impl thread latency if the draw is fast and we |
| 1619 // are in impl latency takes priority. | 1593 // are in impl latency takes priority. |
| 1620 scheduler_->SetTreePrioritiesAndScrollState( | 1594 scheduler_->SetTreePrioritiesAndScrollState( |
| 1621 SMOOTHNESS_TAKES_PRIORITY, | 1595 SMOOTHNESS_TAKES_PRIORITY, |
| 1622 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); | 1596 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); |
| 1623 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); | 1597 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 1624 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); | 1598 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); |
| 1625 | 1599 |
| 1626 bool swap_ack_before_deadline = false; | 1600 bool swap_ack_before_deadline = false; |
| 1627 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); | 1601 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); |
| 1628 } | 1602 } |
| 1629 | 1603 |
| 1630 TEST_F(SchedulerTest, | 1604 TEST_F(SchedulerTest, |
| 1631 ImplFrameSkippedAfterLateSwapAck_OnlyImplSideUpdatesExpected) { | 1605 ImplFrameSkippedAfterLateSwapAck_OnlyImplSideUpdatesExpected) { |
| 1632 // This tests that we recover impl thread latency when there are no commits. | 1606 // This tests that we recover impl thread latency when there are no commits. |
| 1633 scheduler_settings_.use_external_begin_frame_source = true; | 1607 SetUpScheduler(EXTERNAL_BFS); |
| 1634 SetUpScheduler(true); | |
| 1635 | 1608 |
| 1636 // To get into a high latency state, this test disables automatic swap acks. | 1609 // To get into a high latency state, this test disables automatic swap acks. |
| 1637 client_->SetAutomaticSwapAck(false); | 1610 client_->SetAutomaticSwapAck(false); |
| 1638 | 1611 |
| 1639 // Even if every estimate related to the main thread is slow, we should | 1612 // Even if every estimate related to the main thread is slow, we should |
| 1640 // still expect to recover impl thread latency if there are no commits from | 1613 // still expect to recover impl thread latency if there are no commits from |
| 1641 // the main thread. | 1614 // the main thread. |
| 1642 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); | 1615 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 1643 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); | 1616 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); |
| 1644 | 1617 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 4); | 1711 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 4); |
| 1739 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 4); | 1712 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 4); |
| 1740 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 2, 4); | 1713 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 2, 4); |
| 1741 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | 1714 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); |
| 1742 } | 1715 } |
| 1743 } | 1716 } |
| 1744 | 1717 |
| 1745 TEST_F( | 1718 TEST_F( |
| 1746 SchedulerTest, | 1719 SchedulerTest, |
| 1747 ImplFrameNotSkippedAfterLateSwapAck_MainFrameQueueDurationCriticalTooLong) { | 1720 ImplFrameNotSkippedAfterLateSwapAck_MainFrameQueueDurationCriticalTooLong) { |
| 1748 scheduler_settings_.use_external_begin_frame_source = true; | 1721 SetUpScheduler(EXTERNAL_BFS); |
| 1749 SetUpScheduler(true); | |
| 1750 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1722 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1751 fake_compositor_timing_history_ | 1723 fake_compositor_timing_history_ |
| 1752 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); | 1724 ->SetBeginMainFrameQueueDurationCriticalEstimate(kSlowDuration); |
| 1753 fake_compositor_timing_history_ | 1725 fake_compositor_timing_history_ |
| 1754 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); | 1726 ->SetBeginMainFrameQueueDurationNotCriticalEstimate(kSlowDuration); |
| 1755 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); | 1727 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); |
| 1756 } | 1728 } |
| 1757 | 1729 |
| 1758 TEST_F(SchedulerTest, | 1730 TEST_F(SchedulerTest, |
| 1759 ImplFrameNotSkippedAfterLateSwapAck_CommitEstimateTooLong) { | 1731 ImplFrameNotSkippedAfterLateSwapAck_CommitEstimateTooLong) { |
| 1760 scheduler_settings_.use_external_begin_frame_source = true; | 1732 SetUpScheduler(EXTERNAL_BFS); |
| 1761 SetUpScheduler(true); | |
| 1762 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1733 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1763 fake_compositor_timing_history_ | 1734 fake_compositor_timing_history_ |
| 1764 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); | 1735 ->SetBeginMainFrameStartToCommitDurationEstimate(kSlowDuration); |
| 1765 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); | 1736 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); |
| 1766 } | 1737 } |
| 1767 | 1738 |
| 1768 TEST_F(SchedulerTest, | 1739 TEST_F(SchedulerTest, |
| 1769 ImplFrameNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) { | 1740 ImplFrameNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) { |
| 1770 scheduler_settings_.use_external_begin_frame_source = true; | 1741 SetUpScheduler(EXTERNAL_BFS); |
| 1771 SetUpScheduler(true); | |
| 1772 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1742 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1773 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1743 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( |
| 1774 kSlowDuration); | 1744 kSlowDuration); |
| 1775 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); | 1745 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); |
| 1776 } | 1746 } |
| 1777 | 1747 |
| 1778 TEST_F(SchedulerTest, | 1748 TEST_F(SchedulerTest, |
| 1779 ImplFrameNotSkippedAfterLateSwapAck_ActivateEstimateTooLong) { | 1749 ImplFrameNotSkippedAfterLateSwapAck_ActivateEstimateTooLong) { |
| 1780 scheduler_settings_.use_external_begin_frame_source = true; | 1750 SetUpScheduler(EXTERNAL_BFS); |
| 1781 SetUpScheduler(true); | |
| 1782 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1751 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1783 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); | 1752 fake_compositor_timing_history_->SetActivateDurationEstimate(kSlowDuration); |
| 1784 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); | 1753 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); |
| 1785 } | 1754 } |
| 1786 | 1755 |
| 1787 TEST_F(SchedulerTest, ImplFrameNotSkippedAfterLateSwapAck_DrawEstimateTooLong) { | 1756 TEST_F(SchedulerTest, ImplFrameNotSkippedAfterLateSwapAck_DrawEstimateTooLong) { |
| 1788 scheduler_settings_.use_external_begin_frame_source = true; | 1757 SetUpScheduler(EXTERNAL_BFS); |
| 1789 SetUpScheduler(true); | |
| 1790 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1758 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1791 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); | 1759 fake_compositor_timing_history_->SetDrawDurationEstimate(kSlowDuration); |
| 1792 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); | 1760 EXPECT_SCOPED(ImplFrameNotSkippedAfterLateSwapAck()); |
| 1793 } | 1761 } |
| 1794 | 1762 |
| 1795 TEST_F(SchedulerTest, | 1763 TEST_F(SchedulerTest, |
| 1796 MainFrameThenImplFrameSkippedAfterLateCommitAndLateSwapAck) { | 1764 MainFrameThenImplFrameSkippedAfterLateCommitAndLateSwapAck) { |
| 1797 // Set up client with custom estimates. | 1765 // Set up client with custom estimates. |
| 1798 // This test starts off with expensive estimates to prevent latency recovery | 1766 // This test starts off with expensive estimates to prevent latency recovery |
| 1799 // initially, then lowers the estimates to enable it once both the main | 1767 // initially, then lowers the estimates to enable it once both the main |
| 1800 // and impl threads are in a high latency mode. | 1768 // and impl threads are in a high latency mode. |
| 1801 scheduler_settings_.use_external_begin_frame_source = true; | 1769 SetUpScheduler(EXTERNAL_BFS); |
| 1802 SetUpScheduler(true); | |
| 1803 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); | 1770 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 1804 | 1771 |
| 1805 // To get into a high latency state, this test disables automatic swap acks. | 1772 // To get into a high latency state, this test disables automatic swap acks. |
| 1806 client_->SetAutomaticSwapAck(false); | 1773 client_->SetAutomaticSwapAck(false); |
| 1807 | 1774 |
| 1808 // Impl thread hits deadline before commit finishes to make | 1775 // Impl thread hits deadline before commit finishes to make |
| 1809 // MainThreadMissedLastDeadline true | 1776 // MainThreadMissedLastDeadline true |
| 1810 client_->Reset(); | 1777 client_->Reset(); |
| 1811 scheduler_->SetNeedsBeginMainFrame(); | 1778 scheduler_->SetNeedsBeginMainFrame(); |
| 1812 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1779 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 5); | 1880 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 5); |
| 1914 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5); | 1881 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5); |
| 1915 } | 1882 } |
| 1916 | 1883 |
| 1917 TEST_F( | 1884 TEST_F( |
| 1918 SchedulerTest, | 1885 SchedulerTest, |
| 1919 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { | 1886 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { |
| 1920 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main | 1887 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main |
| 1921 // thread. This prevents the scheduler from receiving any pending swap acks. | 1888 // thread. This prevents the scheduler from receiving any pending swap acks. |
| 1922 | 1889 |
| 1923 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1924 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1890 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1925 SetUpScheduler(true); | 1891 SetUpScheduler(EXTERNAL_BFS); |
| 1926 | 1892 |
| 1927 // Disables automatic swap acks so this test can force swap ack throttling | 1893 // Disables automatic swap acks so this test can force swap ack throttling |
| 1928 // to simulate a blocked Browser ui thread. | 1894 // to simulate a blocked Browser ui thread. |
| 1929 client_->SetAutomaticSwapAck(false); | 1895 client_->SetAutomaticSwapAck(false); |
| 1930 | 1896 |
| 1931 // Get a new active tree in main-thread high latency mode and put us | 1897 // Get a new active tree in main-thread high latency mode and put us |
| 1932 // in a swap throttled state. | 1898 // in a swap throttled state. |
| 1933 client_->Reset(); | 1899 client_->Reset(); |
| 1934 EXPECT_FALSE(scheduler_->CommitPending()); | 1900 EXPECT_FALSE(scheduler_->CommitPending()); |
| 1935 scheduler_->SetNeedsBeginMainFrame(); | 1901 scheduler_->SetNeedsBeginMainFrame(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 } | 1943 } |
| 1978 | 1944 |
| 1979 TEST_F( | 1945 TEST_F( |
| 1980 SchedulerTest, | 1946 SchedulerTest, |
| 1981 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { | 1947 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { |
| 1982 // This verifies we don't block commits longer than we need to | 1948 // This verifies we don't block commits longer than we need to |
| 1983 // for performance reasons - not deadlock reasons. | 1949 // for performance reasons - not deadlock reasons. |
| 1984 | 1950 |
| 1985 // Since we are simulating a long commit, set up a client with draw duration | 1951 // Since we are simulating a long commit, set up a client with draw duration |
| 1986 // estimates that prevent skipping main frames to get to low latency mode. | 1952 // estimates that prevent skipping main frames to get to low latency mode. |
| 1987 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1988 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1953 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1989 scheduler_settings_.main_frame_before_activation_enabled = true; | 1954 scheduler_settings_.main_frame_before_activation_enabled = true; |
| 1990 SetUpScheduler(true); | 1955 SetUpScheduler(EXTERNAL_BFS); |
| 1991 | 1956 |
| 1992 // Disables automatic swap acks so this test can force swap ack throttling | 1957 // Disables automatic swap acks so this test can force swap ack throttling |
| 1993 // to simulate a blocked Browser ui thread. | 1958 // to simulate a blocked Browser ui thread. |
| 1994 client_->SetAutomaticSwapAck(false); | 1959 client_->SetAutomaticSwapAck(false); |
| 1995 | 1960 |
| 1996 // Start a new commit in main-thread high latency mode and hold off on | 1961 // Start a new commit in main-thread high latency mode and hold off on |
| 1997 // activation. | 1962 // activation. |
| 1998 client_->Reset(); | 1963 client_->Reset(); |
| 1999 EXPECT_FALSE(scheduler_->CommitPending()); | 1964 EXPECT_FALSE(scheduler_->CommitPending()); |
| 2000 scheduler_->SetNeedsBeginMainFrame(); | 1965 scheduler_->SetNeedsBeginMainFrame(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 | 2002 |
| 2038 // Activate the pending tree, which also unblocks the commit immediately | 2003 // Activate the pending tree, which also unblocks the commit immediately |
| 2039 // while we are in an idle state. | 2004 // while we are in an idle state. |
| 2040 client_->Reset(); | 2005 client_->Reset(); |
| 2041 scheduler_->NotifyReadyToActivate(); | 2006 scheduler_->NotifyReadyToActivate(); |
| 2042 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 2); | 2007 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 2); |
| 2043 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 2); | 2008 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 2); |
| 2044 } | 2009 } |
| 2045 | 2010 |
| 2046 TEST_F(SchedulerTest, BeginRetroFrame) { | 2011 TEST_F(SchedulerTest, BeginRetroFrame) { |
| 2047 scheduler_settings_.use_external_begin_frame_source = true; | 2012 SetUpScheduler(EXTERNAL_BFS); |
| 2048 SetUpScheduler(true); | |
| 2049 | 2013 |
| 2050 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 2014 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 2051 scheduler_->SetNeedsBeginMainFrame(); | 2015 scheduler_->SetNeedsBeginMainFrame(); |
| 2052 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2016 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2053 client_->Reset(); | 2017 client_->Reset(); |
| 2054 | 2018 |
| 2055 // Create a BeginFrame with a long deadline to avoid race conditions. | 2019 // Create a BeginFrame with a long deadline to avoid race conditions. |
| 2056 // This is the first BeginFrame, which will be handled immediately. | 2020 // This is the first BeginFrame, which will be handled immediately. |
| 2057 BeginFrameArgs args = | 2021 BeginFrameArgs args = |
| 2058 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 2022 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2075 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2112 client_->Reset(); | 2076 client_->Reset(); |
| 2113 | 2077 |
| 2114 task_runner().RunPendingTasks(); // Run posted deadline. | 2078 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2115 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 2079 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 2116 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2080 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 2117 client_->Reset(); | 2081 client_->Reset(); |
| 2118 } | 2082 } |
| 2119 | 2083 |
| 2120 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) { | 2084 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) { |
| 2121 scheduler_settings_.use_external_begin_frame_source = true; | 2085 SetUpScheduler(EXTERNAL_BFS); |
| 2122 SetUpScheduler(true); | |
| 2123 | 2086 |
| 2124 scheduler_->SetNeedsBeginMainFrame(); | 2087 scheduler_->SetNeedsBeginMainFrame(); |
| 2125 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2088 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2126 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2089 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2127 | 2090 |
| 2128 client_->Reset(); | 2091 client_->Reset(); |
| 2129 EXPECT_SCOPED(AdvanceFrame()); | 2092 EXPECT_SCOPED(AdvanceFrame()); |
| 2130 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2093 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2131 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2094 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2132 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2095 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2133 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2171 | 2134 |
| 2172 // This is an immediate deadline case. | 2135 // This is an immediate deadline case. |
| 2173 client_->Reset(); | 2136 client_->Reset(); |
| 2174 task_runner().RunPendingTasks(); | 2137 task_runner().RunPendingTasks(); |
| 2175 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2138 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2176 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 2139 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 2177 } | 2140 } |
| 2178 | 2141 |
| 2179 TEST_F(SchedulerTest, RetroFrameExpiresOnTime) { | 2142 TEST_F(SchedulerTest, RetroFrameExpiresOnTime) { |
| 2180 scheduler_settings_.use_external_begin_frame_source = true; | 2143 SetUpScheduler(EXTERNAL_BFS); |
| 2181 SetUpScheduler(true); | |
| 2182 | 2144 |
| 2183 scheduler_->SetNeedsBeginMainFrame(); | 2145 scheduler_->SetNeedsBeginMainFrame(); |
| 2184 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2146 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2185 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2147 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2186 | 2148 |
| 2187 client_->Reset(); | 2149 client_->Reset(); |
| 2188 EXPECT_SCOPED(AdvanceFrame()); | 2150 EXPECT_SCOPED(AdvanceFrame()); |
| 2189 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2151 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2190 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2152 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2191 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2153 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2222 | 2184 |
| 2223 // Let's advance sufficiently past the retro frame's deadline. | 2185 // Let's advance sufficiently past the retro frame's deadline. |
| 2224 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks() + | 2186 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks() + |
| 2225 base::TimeDelta::FromMicroseconds(1)); | 2187 base::TimeDelta::FromMicroseconds(1)); |
| 2226 | 2188 |
| 2227 // The retro frame should've expired. | 2189 // The retro frame should've expired. |
| 2228 EXPECT_NO_ACTION(client_); | 2190 EXPECT_NO_ACTION(client_); |
| 2229 } | 2191 } |
| 2230 | 2192 |
| 2231 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) { | 2193 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) { |
| 2232 scheduler_settings_.use_external_begin_frame_source = true; | 2194 SetUpScheduler(EXTERNAL_BFS); |
| 2233 SetUpScheduler(true); | |
| 2234 | 2195 |
| 2235 scheduler_->SetNeedsBeginMainFrame(); | 2196 scheduler_->SetNeedsBeginMainFrame(); |
| 2236 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2197 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2237 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2198 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2238 | 2199 |
| 2239 BeginFrameArgs missed_frame_args = | 2200 BeginFrameArgs missed_frame_args = |
| 2240 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 2201 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| 2241 missed_frame_args.type = BeginFrameArgs::MISSED; | 2202 missed_frame_args.type = BeginFrameArgs::MISSED; |
| 2242 | 2203 |
| 2243 // Advance to the deadline. | 2204 // Advance to the deadline. |
| 2244 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks()); | 2205 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks()); |
| 2245 | 2206 |
| 2246 // Missed frame is handled because it's on time. | 2207 // Missed frame is handled because it's on time. |
| 2247 client_->Reset(); | 2208 client_->Reset(); |
| 2248 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); | 2209 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); |
| 2249 EXPECT_TRUE( | 2210 EXPECT_TRUE( |
| 2250 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false))); | 2211 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false))); |
| 2251 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2212 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2252 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2213 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2253 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2214 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2254 } | 2215 } |
| 2255 | 2216 |
| 2256 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) { | 2217 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) { |
| 2257 scheduler_settings_.use_external_begin_frame_source = true; | 2218 SetUpScheduler(EXTERNAL_BFS); |
| 2258 SetUpScheduler(true); | |
| 2259 | 2219 |
| 2260 scheduler_->SetNeedsBeginMainFrame(); | 2220 scheduler_->SetNeedsBeginMainFrame(); |
| 2261 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2221 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2262 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2222 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2263 | 2223 |
| 2264 BeginFrameArgs missed_frame_args = | 2224 BeginFrameArgs missed_frame_args = |
| 2265 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 2225 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| 2266 missed_frame_args.type = BeginFrameArgs::MISSED; | 2226 missed_frame_args.type = BeginFrameArgs::MISSED; |
| 2267 | 2227 |
| 2268 // Advance sufficiently past the deadline. | 2228 // Advance sufficiently past the deadline. |
| 2269 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks() + | 2229 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks() + |
| 2270 base::TimeDelta::FromMicroseconds(1)); | 2230 base::TimeDelta::FromMicroseconds(1)); |
| 2271 | 2231 |
| 2272 // Missed frame is dropped because it's too late. | 2232 // Missed frame is dropped because it's too late. |
| 2273 client_->Reset(); | 2233 client_->Reset(); |
| 2274 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); | 2234 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); |
| 2275 EXPECT_FALSE( | 2235 EXPECT_FALSE( |
| 2276 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false))); | 2236 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false))); |
| 2277 EXPECT_NO_ACTION(client_); | 2237 EXPECT_NO_ACTION(client_); |
| 2278 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2238 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2279 } | 2239 } |
| 2280 | 2240 |
| 2281 void SchedulerTest::BeginFramesNotFromClient( | 2241 void SchedulerTest::BeginFramesNotFromClient(BeginFrameSourceType bfs_type) { |
| 2282 bool use_external_begin_frame_source, | 2242 SetUpScheduler(bfs_type); |
| 2283 bool throttle_frame_production) { | |
| 2284 scheduler_settings_.use_external_begin_frame_source = | |
| 2285 use_external_begin_frame_source; | |
| 2286 scheduler_settings_.throttle_frame_production = throttle_frame_production; | |
| 2287 SetUpScheduler(true); | |
| 2288 | 2243 |
| 2289 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame | 2244 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame |
| 2290 // without calling SetNeedsBeginFrame. | 2245 // without calling SetNeedsBeginFrame. |
| 2291 scheduler_->SetNeedsBeginMainFrame(); | 2246 scheduler_->SetNeedsBeginMainFrame(); |
| 2292 EXPECT_NO_ACTION(client_); | 2247 EXPECT_NO_ACTION(client_); |
| 2293 client_->Reset(); | 2248 client_->Reset(); |
| 2294 | 2249 |
| 2295 // When the client-driven BeginFrame are disabled, the scheduler posts it's | 2250 // When the client-driven BeginFrame are disabled, the scheduler posts it's |
| 2296 // own BeginFrame tasks. | 2251 // own BeginFrame tasks. |
| 2297 task_runner().RunPendingTasks(); // Run posted BeginFrame. | 2252 task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 client_->Reset(); | 2292 client_->Reset(); |
| 2338 | 2293 |
| 2339 // Make sure SetNeedsBeginFrame isn't called on the client | 2294 // Make sure SetNeedsBeginFrame isn't called on the client |
| 2340 // when the BeginFrame is no longer needed. | 2295 // when the BeginFrame is no longer needed. |
| 2341 task_runner().RunPendingTasks(); // Run posted deadline. | 2296 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2342 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); | 2297 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); |
| 2343 client_->Reset(); | 2298 client_->Reset(); |
| 2344 } | 2299 } |
| 2345 | 2300 |
| 2346 TEST_F(SchedulerTest, SyntheticBeginFrames) { | 2301 TEST_F(SchedulerTest, SyntheticBeginFrames) { |
| 2347 bool use_external_begin_frame_source = false; | 2302 BeginFramesNotFromClient(THROTTLED_BFS); |
| 2348 bool throttle_frame_production = true; | |
| 2349 BeginFramesNotFromClient(use_external_begin_frame_source, | |
| 2350 throttle_frame_production); | |
| 2351 } | 2303 } |
| 2352 | 2304 |
| 2353 TEST_F(SchedulerTest, VSyncThrottlingDisabled) { | 2305 TEST_F(SchedulerTest, UnthrottledBeginFrames) { |
| 2354 bool use_external_begin_frame_source = true; | 2306 BeginFramesNotFromClient(UNTHROTTLED_BFS); |
| 2355 bool throttle_frame_production = false; | |
| 2356 BeginFramesNotFromClient(use_external_begin_frame_source, | |
| 2357 throttle_frame_production); | |
| 2358 } | |
| 2359 | |
| 2360 TEST_F(SchedulerTest, SyntheticBeginFrames_And_VSyncThrottlingDisabled) { | |
| 2361 bool use_external_begin_frame_source = false; | |
| 2362 bool throttle_frame_production = false; | |
| 2363 BeginFramesNotFromClient(use_external_begin_frame_source, | |
| 2364 throttle_frame_production); | |
| 2365 } | 2307 } |
| 2366 | 2308 |
| 2367 void SchedulerTest::BeginFramesNotFromClient_SwapThrottled( | 2309 void SchedulerTest::BeginFramesNotFromClient_SwapThrottled( |
| 2368 bool use_external_begin_frame_source, | 2310 BeginFrameSourceType bfs_type) { |
| 2369 bool throttle_frame_production) { | 2311 SetUpScheduler(bfs_type); |
| 2370 scheduler_settings_.use_external_begin_frame_source = | |
| 2371 use_external_begin_frame_source; | |
| 2372 scheduler_settings_.throttle_frame_production = throttle_frame_production; | |
| 2373 SetUpScheduler(true); | |
| 2374 | 2312 |
| 2375 scheduler_->SetEstimatedParentDrawTime( | 2313 scheduler_->SetEstimatedParentDrawTime( |
| 2376 BeginFrameArgs::DefaultEstimatedParentDrawTime()); | 2314 BeginFrameArgs::DefaultEstimatedParentDrawTime()); |
| 2377 | 2315 |
| 2378 // Set the draw duration estimate to zero so that deadlines are accurate. | 2316 // Set the draw duration estimate to zero so that deadlines are accurate. |
| 2379 fake_compositor_timing_history_->SetDrawDurationEstimate(base::TimeDelta()); | 2317 fake_compositor_timing_history_->SetDrawDurationEstimate(base::TimeDelta()); |
| 2380 | 2318 |
| 2381 // To test swap ack throttling, this test disables automatic swap acks. | 2319 // To test swap ack throttling, this test disables automatic swap acks. |
| 2382 client_->SetAutomaticSwapAck(false); | 2320 client_->SetAutomaticSwapAck(false); |
| 2383 | 2321 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 // We can't do an equality comparison here because the scheduler uses a fudge | 2391 // We can't do an equality comparison here because the scheduler uses a fudge |
| 2454 // factor that's an internal implementation detail. | 2392 // factor that's an internal implementation detail. |
| 2455 EXPECT_GT(after_deadline, before_deadline); | 2393 EXPECT_GT(after_deadline, before_deadline); |
| 2456 EXPECT_LT(after_deadline, | 2394 EXPECT_LT(after_deadline, |
| 2457 before_deadline + BeginFrameArgs::DefaultInterval()); | 2395 before_deadline + BeginFrameArgs::DefaultInterval()); |
| 2458 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2396 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2459 client_->Reset(); | 2397 client_->Reset(); |
| 2460 } | 2398 } |
| 2461 | 2399 |
| 2462 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { | 2400 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { |
| 2463 bool use_external_begin_frame_source = false; | 2401 BeginFramesNotFromClient_SwapThrottled(THROTTLED_BFS); |
| 2464 bool throttle_frame_production = true; | |
| 2465 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, | |
| 2466 throttle_frame_production); | |
| 2467 } | 2402 } |
| 2468 | 2403 |
| 2469 TEST_F(SchedulerTest, VSyncThrottlingDisabled_SwapThrottled) { | 2404 TEST_F(SchedulerTest, UnthrottledBeginFrames_SwapThrottled) { |
| 2470 bool use_external_begin_frame_source = true; | 2405 BeginFramesNotFromClient_SwapThrottled(UNTHROTTLED_BFS); |
| 2471 bool throttle_frame_production = false; | |
| 2472 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, | |
| 2473 throttle_frame_production); | |
| 2474 } | |
| 2475 | |
| 2476 TEST_F(SchedulerTest, | |
| 2477 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { | |
| 2478 bool use_external_begin_frame_source = false; | |
| 2479 bool throttle_frame_production = false; | |
| 2480 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, | |
| 2481 throttle_frame_production); | |
| 2482 } | 2406 } |
| 2483 | 2407 |
| 2484 TEST_F(SchedulerTest, | 2408 TEST_F(SchedulerTest, |
| 2485 DidLoseCompositorFrameSinkAfterCompositorFrameSinkIsInitialized) { | 2409 DidLoseCompositorFrameSinkAfterCompositorFrameSinkIsInitialized) { |
| 2486 scheduler_settings_.use_external_begin_frame_source = true; | 2410 SetUpSchedulerWithNoCompositorFrameSink(EXTERNAL_BFS); |
| 2487 SetUpScheduler(false); | |
| 2488 | 2411 |
| 2489 scheduler_->SetVisible(true); | 2412 scheduler_->SetVisible(true); |
| 2490 scheduler_->SetCanDraw(true); | 2413 scheduler_->SetCanDraw(true); |
| 2491 | 2414 |
| 2492 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", | 2415 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", |
| 2493 client_); | 2416 client_); |
| 2494 client_->Reset(); | 2417 client_->Reset(); |
| 2495 scheduler_->DidCreateAndInitializeCompositorFrameSink(); | 2418 scheduler_->DidCreateAndInitializeCompositorFrameSink(); |
| 2496 EXPECT_NO_ACTION(client_); | 2419 EXPECT_NO_ACTION(client_); |
| 2497 | 2420 |
| 2498 scheduler_->DidLoseCompositorFrameSink(); | 2421 scheduler_->DidLoseCompositorFrameSink(); |
| 2499 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", | 2422 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", |
| 2500 client_); | 2423 client_); |
| 2501 } | 2424 } |
| 2502 | 2425 |
| 2503 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterBeginFrameStarted) { | 2426 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterBeginFrameStarted) { |
| 2504 scheduler_settings_.use_external_begin_frame_source = true; | 2427 SetUpScheduler(EXTERNAL_BFS); |
| 2505 SetUpScheduler(true); | |
| 2506 | 2428 |
| 2507 // SetNeedsBeginMainFrame should begin the frame. | 2429 // SetNeedsBeginMainFrame should begin the frame. |
| 2508 scheduler_->SetNeedsBeginMainFrame(); | 2430 scheduler_->SetNeedsBeginMainFrame(); |
| 2509 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2431 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2510 | 2432 |
| 2511 client_->Reset(); | 2433 client_->Reset(); |
| 2512 EXPECT_SCOPED(AdvanceFrame()); | 2434 EXPECT_SCOPED(AdvanceFrame()); |
| 2513 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2435 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2514 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2436 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2515 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2437 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2528 client_->Reset(); | 2450 client_->Reset(); |
| 2529 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 2451 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 2530 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, | 2452 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, |
| 2531 3); | 2453 3); |
| 2532 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 2454 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 2533 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2455 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 2534 } | 2456 } |
| 2535 | 2457 |
| 2536 TEST_F(SchedulerTest, | 2458 TEST_F(SchedulerTest, |
| 2537 DidLoseCompositorFrameSinkAfterBeginFrameStartedWithHighLatency) { | 2459 DidLoseCompositorFrameSinkAfterBeginFrameStartedWithHighLatency) { |
| 2538 scheduler_settings_.use_external_begin_frame_source = true; | 2460 SetUpScheduler(EXTERNAL_BFS); |
| 2539 SetUpScheduler(true); | |
| 2540 | 2461 |
| 2541 // SetNeedsBeginMainFrame should begin the frame. | 2462 // SetNeedsBeginMainFrame should begin the frame. |
| 2542 scheduler_->SetNeedsBeginMainFrame(); | 2463 scheduler_->SetNeedsBeginMainFrame(); |
| 2543 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2464 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2544 | 2465 |
| 2545 client_->Reset(); | 2466 client_->Reset(); |
| 2546 EXPECT_SCOPED(AdvanceFrame()); | 2467 EXPECT_SCOPED(AdvanceFrame()); |
| 2547 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2468 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2548 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2469 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2549 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2470 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2574 client_->Reset(); | 2495 client_->Reset(); |
| 2575 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 2496 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 2576 scheduler_->NotifyReadyToCommit(); | 2497 scheduler_->NotifyReadyToCommit(); |
| 2577 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); | 2498 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); |
| 2578 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); | 2499 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); |
| 2579 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 2, | 2500 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 2, |
| 2580 3); | 2501 3); |
| 2581 } | 2502 } |
| 2582 | 2503 |
| 2583 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterReadyToCommit) { | 2504 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterReadyToCommit) { |
| 2584 scheduler_settings_.use_external_begin_frame_source = true; | 2505 SetUpScheduler(EXTERNAL_BFS); |
| 2585 SetUpScheduler(true); | |
| 2586 | 2506 |
| 2587 // SetNeedsBeginMainFrame should begin the frame. | 2507 // SetNeedsBeginMainFrame should begin the frame. |
| 2588 scheduler_->SetNeedsBeginMainFrame(); | 2508 scheduler_->SetNeedsBeginMainFrame(); |
| 2589 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2509 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2590 | 2510 |
| 2591 client_->Reset(); | 2511 client_->Reset(); |
| 2592 EXPECT_SCOPED(AdvanceFrame()); | 2512 EXPECT_SCOPED(AdvanceFrame()); |
| 2593 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2513 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2594 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2514 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2595 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2515 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2607 // RemoveObserver(this) is not called until the end of the frame. | 2527 // RemoveObserver(this) is not called until the end of the frame. |
| 2608 client_->Reset(); | 2528 client_->Reset(); |
| 2609 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 2529 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 2610 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, | 2530 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, |
| 2611 3); | 2531 3); |
| 2612 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 2532 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 2613 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2533 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 2614 } | 2534 } |
| 2615 | 2535 |
| 2616 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterSetNeedsPrepareTiles) { | 2536 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterSetNeedsPrepareTiles) { |
| 2617 scheduler_settings_.use_external_begin_frame_source = true; | 2537 SetUpScheduler(EXTERNAL_BFS); |
| 2618 SetUpScheduler(true); | |
| 2619 | 2538 |
| 2620 scheduler_->SetNeedsPrepareTiles(); | 2539 scheduler_->SetNeedsPrepareTiles(); |
| 2621 scheduler_->SetNeedsRedraw(); | 2540 scheduler_->SetNeedsRedraw(); |
| 2622 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2541 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2623 | 2542 |
| 2624 client_->Reset(); | 2543 client_->Reset(); |
| 2625 EXPECT_SCOPED(AdvanceFrame()); | 2544 EXPECT_SCOPED(AdvanceFrame()); |
| 2626 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2545 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 2627 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2546 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2628 | 2547 |
| 2629 client_->Reset(); | 2548 client_->Reset(); |
| 2630 scheduler_->DidLoseCompositorFrameSink(); | 2549 scheduler_->DidLoseCompositorFrameSink(); |
| 2631 // RemoveObserver(this) is not called until the end of the frame. | 2550 // RemoveObserver(this) is not called until the end of the frame. |
| 2632 EXPECT_NO_ACTION(client_); | 2551 EXPECT_NO_ACTION(client_); |
| 2633 | 2552 |
| 2634 client_->Reset(); | 2553 client_->Reset(); |
| 2635 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 2554 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 2636 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4); | 2555 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4); |
| 2637 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 1, | 2556 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 1, |
| 2638 4); | 2557 4); |
| 2639 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); | 2558 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); |
| 2640 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); | 2559 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); |
| 2641 } | 2560 } |
| 2642 | 2561 |
| 2643 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterBeginRetroFramePosted) { | 2562 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterBeginRetroFramePosted) { |
| 2644 scheduler_settings_.use_external_begin_frame_source = true; | 2563 SetUpScheduler(EXTERNAL_BFS); |
| 2645 SetUpScheduler(true); | |
| 2646 | 2564 |
| 2647 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 2565 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 2648 scheduler_->SetNeedsBeginMainFrame(); | 2566 scheduler_->SetNeedsBeginMainFrame(); |
| 2649 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2567 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2650 | 2568 |
| 2651 // Create a BeginFrame with a long deadline to avoid race conditions. | 2569 // Create a BeginFrame with a long deadline to avoid race conditions. |
| 2652 // This is the first BeginFrame, which will be handled immediately. | 2570 // This is the first BeginFrame, which will be handled immediately. |
| 2653 client_->Reset(); | 2571 client_->Reset(); |
| 2654 BeginFrameArgs args = | 2572 BeginFrameArgs args = |
| 2655 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 2573 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2613 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 2696 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); | 2614 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); |
| 2697 | 2615 |
| 2698 // Posted BeginRetroFrame is aborted. | 2616 // Posted BeginRetroFrame is aborted. |
| 2699 client_->Reset(); | 2617 client_->Reset(); |
| 2700 task_runner().RunPendingTasks(); | 2618 task_runner().RunPendingTasks(); |
| 2701 EXPECT_NO_ACTION(client_); | 2619 EXPECT_NO_ACTION(client_); |
| 2702 } | 2620 } |
| 2703 | 2621 |
| 2704 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkDuringBeginRetroFrameRunning) { | 2622 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkDuringBeginRetroFrameRunning) { |
| 2705 scheduler_settings_.use_external_begin_frame_source = true; | 2623 SetUpScheduler(EXTERNAL_BFS); |
| 2706 SetUpScheduler(true); | |
| 2707 | 2624 |
| 2708 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 2625 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 2709 scheduler_->SetNeedsBeginMainFrame(); | 2626 scheduler_->SetNeedsBeginMainFrame(); |
| 2710 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2627 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2711 | 2628 |
| 2712 // Create a BeginFrame with a long deadline to avoid race conditions. | 2629 // Create a BeginFrame with a long deadline to avoid race conditions. |
| 2713 // This is the first BeginFrame, which will be handled immediately. | 2630 // This is the first BeginFrame, which will be handled immediately. |
| 2714 client_->Reset(); | 2631 client_->Reset(); |
| 2715 BeginFrameArgs args = | 2632 BeginFrameArgs args = |
| 2716 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 2633 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 2688 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 2772 | 2689 |
| 2773 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. | 2690 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. |
| 2774 client_->Reset(); | 2691 client_->Reset(); |
| 2775 task_runner().RunPendingTasks(); | 2692 task_runner().RunPendingTasks(); |
| 2776 EXPECT_NO_ACTION(client_); | 2693 EXPECT_NO_ACTION(client_); |
| 2777 } | 2694 } |
| 2778 | 2695 |
| 2779 TEST_F(SchedulerTest, | 2696 TEST_F(SchedulerTest, |
| 2780 DidLoseCompositorFrameSinkWithDelayBasedBeginFrameSource) { | 2697 DidLoseCompositorFrameSinkWithDelayBasedBeginFrameSource) { |
| 2781 SetUpScheduler(true); | 2698 SetUpScheduler(THROTTLED_BFS); |
| 2782 | 2699 |
| 2783 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 2700 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 2784 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 2701 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 2785 scheduler_->SetNeedsBeginMainFrame(); | 2702 scheduler_->SetNeedsBeginMainFrame(); |
| 2786 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2703 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2787 | 2704 |
| 2788 client_->Reset(); | 2705 client_->Reset(); |
| 2789 AdvanceFrame(); | 2706 AdvanceFrame(); |
| 2790 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2707 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2791 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2708 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2813 | 2730 |
| 2814 client_->Reset(); | 2731 client_->Reset(); |
| 2815 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 2732 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 2816 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, | 2733 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, |
| 2817 2); | 2734 2); |
| 2818 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2735 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 2819 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 2736 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 2820 } | 2737 } |
| 2821 | 2738 |
| 2822 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkWhenIdle) { | 2739 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkWhenIdle) { |
| 2823 scheduler_settings_.use_external_begin_frame_source = true; | 2740 SetUpScheduler(EXTERNAL_BFS); |
| 2824 SetUpScheduler(true); | |
| 2825 | 2741 |
| 2826 // SetNeedsBeginMainFrame should begin the frame. | 2742 // SetNeedsBeginMainFrame should begin the frame. |
| 2827 scheduler_->SetNeedsBeginMainFrame(); | 2743 scheduler_->SetNeedsBeginMainFrame(); |
| 2828 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2744 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2829 | 2745 |
| 2830 client_->Reset(); | 2746 client_->Reset(); |
| 2831 EXPECT_SCOPED(AdvanceFrame()); | 2747 EXPECT_SCOPED(AdvanceFrame()); |
| 2832 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2748 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2833 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2749 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2834 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2750 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2849 // Idle time between BeginFrames. | 2765 // Idle time between BeginFrames. |
| 2850 client_->Reset(); | 2766 client_->Reset(); |
| 2851 scheduler_->DidLoseCompositorFrameSink(); | 2767 scheduler_->DidLoseCompositorFrameSink(); |
| 2852 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, | 2768 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, |
| 2853 3); | 2769 3); |
| 2854 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 2770 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 2855 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2771 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 2856 } | 2772 } |
| 2857 | 2773 |
| 2858 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) { | 2774 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) { |
| 2859 scheduler_settings_.use_external_begin_frame_source = true; | 2775 SetUpScheduler(EXTERNAL_BFS); |
| 2860 SetUpScheduler(true); | |
| 2861 | 2776 |
| 2862 // SetNeedsBeginMainFrame should begin the frame. | 2777 // SetNeedsBeginMainFrame should begin the frame. |
| 2863 scheduler_->SetNeedsBeginMainFrame(); | 2778 scheduler_->SetNeedsBeginMainFrame(); |
| 2864 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2779 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2865 | 2780 |
| 2866 client_->Reset(); | 2781 client_->Reset(); |
| 2867 EXPECT_SCOPED(AdvanceFrame()); | 2782 EXPECT_SCOPED(AdvanceFrame()); |
| 2868 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2783 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2869 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2784 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2870 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2785 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2871 | 2786 |
| 2872 client_->Reset(); | 2787 client_->Reset(); |
| 2873 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 2788 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 2874 scheduler_->NotifyReadyToCommit(); | 2789 scheduler_->NotifyReadyToCommit(); |
| 2875 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 2790 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 2876 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2791 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2877 | 2792 |
| 2878 client_->Reset(); | 2793 client_->Reset(); |
| 2879 scheduler_->SetVisible(false); | 2794 scheduler_->SetVisible(false); |
| 2880 task_runner().RunPendingTasks(); // Run posted deadline. | 2795 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2881 | 2796 |
| 2882 // Sync tree should be forced to activate. | 2797 // Sync tree should be forced to activate. |
| 2883 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3); | 2798 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3); |
| 2884 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 2799 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 2885 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2800 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 2886 } | 2801 } |
| 2887 | 2802 |
| 2888 TEST_F(SchedulerTest, ScheduledActionActivateAfterBeginFrameSourcePaused) { | 2803 TEST_F(SchedulerTest, ScheduledActionActivateAfterBeginFrameSourcePaused) { |
| 2889 scheduler_settings_.use_external_begin_frame_source = true; | 2804 SetUpScheduler(EXTERNAL_BFS); |
| 2890 SetUpScheduler(true); | |
| 2891 | 2805 |
| 2892 // SetNeedsBeginMainFrame should begin the frame. | 2806 // SetNeedsBeginMainFrame should begin the frame. |
| 2893 scheduler_->SetNeedsBeginMainFrame(); | 2807 scheduler_->SetNeedsBeginMainFrame(); |
| 2894 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2808 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2895 | 2809 |
| 2896 client_->Reset(); | 2810 client_->Reset(); |
| 2897 EXPECT_SCOPED(AdvanceFrame()); | 2811 EXPECT_SCOPED(AdvanceFrame()); |
| 2898 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2812 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2899 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2813 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2900 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2814 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2901 | 2815 |
| 2902 client_->Reset(); | 2816 client_->Reset(); |
| 2903 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 2817 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 2904 scheduler_->NotifyReadyToCommit(); | 2818 scheduler_->NotifyReadyToCommit(); |
| 2905 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 2819 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 2906 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2820 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2907 | 2821 |
| 2908 client_->Reset(); | 2822 client_->Reset(); |
| 2909 fake_external_begin_frame_source_->SetPaused(true); | 2823 fake_external_begin_frame_source_->SetPaused(true); |
| 2910 task_runner().RunPendingTasks(); // Run posted deadline. | 2824 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2911 | 2825 |
| 2912 // Sync tree should be forced to activate. | 2826 // Sync tree should be forced to activate. |
| 2913 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 2827 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
| 2914 } | 2828 } |
| 2915 | 2829 |
| 2916 // Tests to ensure frame sources can be successfully changed while drawing. | 2830 // Tests to ensure frame sources can be successfully changed while drawing. |
| 2917 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { | 2831 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { |
| 2918 scheduler_settings_.use_external_begin_frame_source = true; | 2832 SetUpScheduler(EXTERNAL_BFS); |
| 2919 SetUpScheduler(true); | |
| 2920 | 2833 |
| 2921 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | 2834 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. |
| 2922 scheduler_->SetNeedsRedraw(); | 2835 scheduler_->SetNeedsRedraw(); |
| 2923 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2836 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2924 client_->Reset(); | 2837 client_->Reset(); |
| 2925 | 2838 |
| 2926 EXPECT_SCOPED(AdvanceFrame()); | 2839 EXPECT_SCOPED(AdvanceFrame()); |
| 2927 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2840 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 2928 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2841 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2929 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2842 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2945 // If we don't swap on the deadline, we wait for the next BeginFrame. | 2858 // If we don't swap on the deadline, we wait for the next BeginFrame. |
| 2946 task_runner().RunPendingTasks(); // Run posted deadline. | 2859 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2947 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 2860 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 2948 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2861 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2949 client_->Reset(); | 2862 client_->Reset(); |
| 2950 } | 2863 } |
| 2951 | 2864 |
| 2952 // Tests to ensure frame sources can be successfully changed while a frame | 2865 // Tests to ensure frame sources can be successfully changed while a frame |
| 2953 // deadline is pending. | 2866 // deadline is pending. |
| 2954 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottledBeforeDeadline) { | 2867 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottledBeforeDeadline) { |
| 2955 scheduler_settings_.use_external_begin_frame_source = true; | 2868 SetUpScheduler(EXTERNAL_BFS); |
| 2956 SetUpScheduler(true); | |
| 2957 | 2869 |
| 2958 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | 2870 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. |
| 2959 scheduler_->SetNeedsRedraw(); | 2871 scheduler_->SetNeedsRedraw(); |
| 2960 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2872 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2961 client_->Reset(); | 2873 client_->Reset(); |
| 2962 | 2874 |
| 2963 EXPECT_SCOPED(AdvanceFrame()); | 2875 EXPECT_SCOPED(AdvanceFrame()); |
| 2964 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 2876 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 2965 | 2877 |
| 2966 // Switch to an unthrottled frame source before the frame deadline is hit. | 2878 // Switch to an unthrottled frame source before the frame deadline is hit. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2980 | 2892 |
| 2981 task_runner().RunPendingTasks(); // Run posted deadline. | 2893 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2982 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 2894 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 2983 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2895 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2984 client_->Reset(); | 2896 client_->Reset(); |
| 2985 } | 2897 } |
| 2986 | 2898 |
| 2987 // Tests to ensure that the active frame source can successfully be changed from | 2899 // Tests to ensure that the active frame source can successfully be changed from |
| 2988 // unthrottled to throttled. | 2900 // unthrottled to throttled. |
| 2989 TEST_F(SchedulerTest, SwitchFrameSourceToThrottled) { | 2901 TEST_F(SchedulerTest, SwitchFrameSourceToThrottled) { |
| 2990 scheduler_settings_.throttle_frame_production = false; | 2902 SetUpScheduler(UNTHROTTLED_BFS); |
| 2991 scheduler_settings_.use_external_begin_frame_source = true; | |
| 2992 SetUpScheduler(true); | |
| 2993 | 2903 |
| 2994 scheduler_->SetNeedsRedraw(); | 2904 scheduler_->SetNeedsRedraw(); |
| 2995 EXPECT_NO_ACTION(client_); | 2905 EXPECT_NO_ACTION(client_); |
| 2996 client_->Reset(); | 2906 client_->Reset(); |
| 2997 | 2907 |
| 2998 task_runner().RunPendingTasks(); // Run posted BeginFrame. | 2908 task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| 2999 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2909 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 3000 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2910 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3001 client_->Reset(); | 2911 client_->Reset(); |
| 3002 | 2912 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3018 EXPECT_SCOPED(AdvanceFrame()); | 2928 EXPECT_SCOPED(AdvanceFrame()); |
| 3019 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2929 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 3020 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2930 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3021 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2931 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3022 client_->Reset(); | 2932 client_->Reset(); |
| 3023 task_runner().RunPendingTasks(); // Run posted deadline. | 2933 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3024 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 2934 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 3025 } | 2935 } |
| 3026 | 2936 |
| 3027 TEST_F(SchedulerTest, SwitchFrameSourceToNullInsideDeadline) { | 2937 TEST_F(SchedulerTest, SwitchFrameSourceToNullInsideDeadline) { |
| 3028 scheduler_settings_.use_external_begin_frame_source = true; | 2938 SetUpScheduler(EXTERNAL_BFS); |
| 3029 SetUpScheduler(true); | |
| 3030 | 2939 |
| 3031 scheduler_->SetNeedsRedraw(); | 2940 scheduler_->SetNeedsRedraw(); |
| 3032 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2941 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3033 client_->Reset(); | 2942 client_->Reset(); |
| 3034 | 2943 |
| 3035 EXPECT_SCOPED(AdvanceFrame()); | 2944 EXPECT_SCOPED(AdvanceFrame()); |
| 3036 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 2945 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 3037 client_->Reset(); | 2946 client_->Reset(); |
| 3038 | 2947 |
| 3039 // Switch to a null frame source. | 2948 // Switch to a null frame source. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3071 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2980 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3072 client_->Reset(); | 2981 client_->Reset(); |
| 3073 | 2982 |
| 3074 task_runner().RunPendingTasks(); | 2983 task_runner().RunPendingTasks(); |
| 3075 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 2984 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 3076 } | 2985 } |
| 3077 | 2986 |
| 3078 // This test maskes sure that switching a frame source when not observing | 2987 // This test maskes sure that switching a frame source when not observing |
| 3079 // such as when not visible also works. | 2988 // such as when not visible also works. |
| 3080 TEST_F(SchedulerTest, SwitchFrameSourceWhenNotObserving) { | 2989 TEST_F(SchedulerTest, SwitchFrameSourceWhenNotObserving) { |
| 3081 scheduler_settings_.use_external_begin_frame_source = true; | 2990 SetUpScheduler(EXTERNAL_BFS); |
| 3082 SetUpScheduler(true); | |
| 3083 | 2991 |
| 3084 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 2992 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 3085 scheduler_->SetNeedsBeginMainFrame(); | 2993 scheduler_->SetNeedsBeginMainFrame(); |
| 3086 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2994 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3087 client_->Reset(); | 2995 client_->Reset(); |
| 3088 | 2996 |
| 3089 // Begin new frame. | 2997 // Begin new frame. |
| 3090 EXPECT_SCOPED(AdvanceFrame()); | 2998 EXPECT_SCOPED(AdvanceFrame()); |
| 3091 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 2999 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 3092 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3000 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3126 EXPECT_NO_ACTION(client_); | 3034 EXPECT_NO_ACTION(client_); |
| 3127 | 3035 |
| 3128 client_->Reset(); | 3036 client_->Reset(); |
| 3129 EXPECT_SCOPED(AdvanceFrame()); | 3037 EXPECT_SCOPED(AdvanceFrame()); |
| 3130 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3038 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3131 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 3039 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3132 } | 3040 } |
| 3133 | 3041 |
| 3134 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. | 3042 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. |
| 3135 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { | 3043 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { |
| 3136 scheduler_settings_.use_external_begin_frame_source = true; | 3044 SetUpScheduler(EXTERNAL_BFS); |
| 3137 SetUpScheduler(true); | |
| 3138 | 3045 |
| 3139 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 3046 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 3140 scheduler_->SetNeedsBeginMainFrame(); | 3047 scheduler_->SetNeedsBeginMainFrame(); |
| 3141 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3048 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3142 client_->Reset(); | 3049 client_->Reset(); |
| 3143 | 3050 |
| 3144 // Trigger a frame draw. | 3051 // Trigger a frame draw. |
| 3145 EXPECT_SCOPED(AdvanceFrame()); | 3052 EXPECT_SCOPED(AdvanceFrame()); |
| 3146 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 3053 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 3147 scheduler_->NotifyReadyToCommit(); | 3054 scheduler_->NotifyReadyToCommit(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3162 client_->Reset(); | 3069 client_->Reset(); |
| 3163 | 3070 |
| 3164 task_runner().RunPendingTasks(); // Run posted deadline. | 3071 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3165 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 3072 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 3166 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 3073 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 3167 client_->Reset(); | 3074 client_->Reset(); |
| 3168 } | 3075 } |
| 3169 | 3076 |
| 3170 TEST_F(SchedulerTest, SynchronousCompositorAnimation) { | 3077 TEST_F(SchedulerTest, SynchronousCompositorAnimation) { |
| 3171 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3078 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3172 scheduler_settings_.use_external_begin_frame_source = true; | 3079 SetUpScheduler(EXTERNAL_BFS); |
| 3173 SetUpScheduler(true); | |
| 3174 | 3080 |
| 3175 scheduler_->SetNeedsOneBeginImplFrame(); | 3081 scheduler_->SetNeedsOneBeginImplFrame(); |
| 3176 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3082 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3177 client_->Reset(); | 3083 client_->Reset(); |
| 3178 | 3084 |
| 3179 // Testing the case where animation ticks a fling scroll. | 3085 // Testing the case where animation ticks a fling scroll. |
| 3180 client_->SetWillBeginImplFrameCausesRedraw(true); | 3086 client_->SetWillBeginImplFrameCausesRedraw(true); |
| 3181 // The animation isn't done so it'll cause another tick in the future. | 3087 // The animation isn't done so it'll cause another tick in the future. |
| 3182 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); | 3088 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); |
| 3183 | 3089 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3218 AdvanceFrame(); | 3124 AdvanceFrame(); |
| 3219 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 3125 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 3220 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 3126 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 3221 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 3127 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 3222 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3128 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3223 client_->Reset(); | 3129 client_->Reset(); |
| 3224 } | 3130 } |
| 3225 | 3131 |
| 3226 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) { | 3132 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) { |
| 3227 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3133 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3228 scheduler_settings_.use_external_begin_frame_source = true; | 3134 SetUpScheduler(EXTERNAL_BFS); |
| 3229 SetUpScheduler(true); | |
| 3230 | 3135 |
| 3231 scheduler_->SetNeedsRedraw(); | 3136 scheduler_->SetNeedsRedraw(); |
| 3232 bool resourceless_software_draw = false; | 3137 bool resourceless_software_draw = false; |
| 3233 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 3138 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 3234 EXPECT_ACTION("AddObserver(this)", client_, 0, 2); | 3139 EXPECT_ACTION("AddObserver(this)", client_, 0, 2); |
| 3235 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); | 3140 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); |
| 3236 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3141 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3237 client_->Reset(); | 3142 client_->Reset(); |
| 3238 | 3143 |
| 3239 // Idle on next vsync. | 3144 // Idle on next vsync. |
| 3240 AdvanceFrame(); | 3145 AdvanceFrame(); |
| 3241 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 3146 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 3242 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 3147 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 3243 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 3148 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 3244 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3149 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3245 client_->Reset(); | 3150 client_->Reset(); |
| 3246 } | 3151 } |
| 3247 | 3152 |
| 3248 TEST_F(SchedulerTest, SetNeedsOneBeginImplFrame) { | 3153 TEST_F(SchedulerTest, SetNeedsOneBeginImplFrame) { |
| 3249 scheduler_settings_.use_external_begin_frame_source = true; | 3154 SetUpScheduler(EXTERNAL_BFS); |
| 3250 SetUpScheduler(true); | |
| 3251 | 3155 |
| 3252 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 3156 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 3253 | 3157 |
| 3254 // Request a frame, should kick the source. | 3158 // Request a frame, should kick the source. |
| 3255 scheduler_->SetNeedsOneBeginImplFrame(); | 3159 scheduler_->SetNeedsOneBeginImplFrame(); |
| 3256 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3160 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3257 client_->Reset(); | 3161 client_->Reset(); |
| 3258 | 3162 |
| 3259 // The incoming WillBeginImplFrame will request another one. | 3163 // The incoming WillBeginImplFrame will request another one. |
| 3260 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); | 3164 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3278 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | 3182 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 3279 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3183 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3280 | 3184 |
| 3281 // Scheduler shuts down the source now that no begin frame is requested. | 3185 // Scheduler shuts down the source now that no begin frame is requested. |
| 3282 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 3186 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 3283 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 3187 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 3284 } | 3188 } |
| 3285 | 3189 |
| 3286 TEST_F(SchedulerTest, SynchronousCompositorCommit) { | 3190 TEST_F(SchedulerTest, SynchronousCompositorCommit) { |
| 3287 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3191 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3288 scheduler_settings_.use_external_begin_frame_source = true; | 3192 SetUpScheduler(EXTERNAL_BFS); |
| 3289 SetUpScheduler(true); | |
| 3290 | 3193 |
| 3291 scheduler_->SetNeedsBeginMainFrame(); | 3194 scheduler_->SetNeedsBeginMainFrame(); |
| 3292 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3195 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3293 client_->Reset(); | 3196 client_->Reset(); |
| 3294 | 3197 |
| 3295 // Next vsync. | 3198 // Next vsync. |
| 3296 AdvanceFrame(); | 3199 AdvanceFrame(); |
| 3297 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3200 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3298 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 3201 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3299 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3202 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3335 AdvanceFrame(); | 3238 AdvanceFrame(); |
| 3336 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 3239 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 3337 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 3240 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 3338 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 3241 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 3339 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3242 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3340 client_->Reset(); | 3243 client_->Reset(); |
| 3341 } | 3244 } |
| 3342 | 3245 |
| 3343 TEST_F(SchedulerTest, SynchronousCompositorDoubleCommitWithoutDraw) { | 3246 TEST_F(SchedulerTest, SynchronousCompositorDoubleCommitWithoutDraw) { |
| 3344 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3247 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3345 scheduler_settings_.use_external_begin_frame_source = true; | 3248 SetUpScheduler(EXTERNAL_BFS); |
| 3346 SetUpScheduler(true); | |
| 3347 | 3249 |
| 3348 scheduler_->SetNeedsBeginMainFrame(); | 3250 scheduler_->SetNeedsBeginMainFrame(); |
| 3349 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3251 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3350 client_->Reset(); | 3252 client_->Reset(); |
| 3351 | 3253 |
| 3352 // Next vsync. | 3254 // Next vsync. |
| 3353 AdvanceFrame(); | 3255 AdvanceFrame(); |
| 3354 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3256 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3355 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 3257 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3356 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3258 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3392 | 3294 |
| 3393 protected: | 3295 protected: |
| 3394 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 3296 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
| 3395 scheduler_->SetNeedsPrepareTiles(); | 3297 scheduler_->SetNeedsPrepareTiles(); |
| 3396 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 3298 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
| 3397 } | 3299 } |
| 3398 }; | 3300 }; |
| 3399 | 3301 |
| 3400 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { | 3302 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { |
| 3401 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3303 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3402 scheduler_settings_.use_external_begin_frame_source = true; | |
| 3403 | 3304 |
| 3404 std::unique_ptr<FakeSchedulerClient> client = | 3305 std::unique_ptr<FakeSchedulerClient> client = |
| 3405 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw); | 3306 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw); |
| 3406 SetUpScheduler(std::move(client), true); | 3307 SetUpScheduler(EXTERNAL_BFS, std::move(client)); |
| 3407 | 3308 |
| 3408 scheduler_->SetNeedsRedraw(); | 3309 scheduler_->SetNeedsRedraw(); |
| 3409 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3310 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3410 client_->Reset(); | 3311 client_->Reset(); |
| 3411 | 3312 |
| 3412 // Next vsync. | 3313 // Next vsync. |
| 3413 EXPECT_SCOPED(AdvanceFrame()); | 3314 EXPECT_SCOPED(AdvanceFrame()); |
| 3414 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3315 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3415 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 3316 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); |
| 3416 client_->Reset(); | 3317 client_->Reset(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3439 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 3340 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 3440 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 3341 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 3441 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 3342 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
| 3442 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 3343 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 3443 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 3344 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 3444 client_->Reset(); | 3345 client_->Reset(); |
| 3445 } | 3346 } |
| 3446 | 3347 |
| 3447 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) { | 3348 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) { |
| 3448 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3349 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3449 scheduler_settings_.use_external_begin_frame_source = true; | 3350 SetUpScheduler(EXTERNAL_BFS); |
| 3450 | |
| 3451 SetUpScheduler(true); | |
| 3452 | 3351 |
| 3453 scheduler_->SetNeedsRedraw(); | 3352 scheduler_->SetNeedsRedraw(); |
| 3454 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3353 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3455 client_->Reset(); | 3354 client_->Reset(); |
| 3456 | 3355 |
| 3457 // Next vsync. | 3356 // Next vsync. |
| 3458 EXPECT_SCOPED(AdvanceFrame()); | 3357 EXPECT_SCOPED(AdvanceFrame()); |
| 3459 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3358 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3460 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 3359 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); |
| 3461 client_->Reset(); | 3360 client_->Reset(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3498 client_->Reset(); | 3397 client_->Reset(); |
| 3499 | 3398 |
| 3500 // Simulate SetNeedsBeginMainFrame due to input event. | 3399 // Simulate SetNeedsBeginMainFrame due to input event. |
| 3501 scheduler_->SetNeedsBeginMainFrame(); | 3400 scheduler_->SetNeedsBeginMainFrame(); |
| 3502 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); | 3401 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
| 3503 client_->Reset(); | 3402 client_->Reset(); |
| 3504 } | 3403 } |
| 3505 | 3404 |
| 3506 TEST_F(SchedulerTest, SynchronousCompositorResourcelessOnDrawWhenInvisible) { | 3405 TEST_F(SchedulerTest, SynchronousCompositorResourcelessOnDrawWhenInvisible) { |
| 3507 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3406 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3508 scheduler_settings_.use_external_begin_frame_source = true; | 3407 SetUpScheduler(EXTERNAL_BFS); |
| 3509 SetUpScheduler(true); | |
| 3510 | 3408 |
| 3511 scheduler_->SetVisible(false); | 3409 scheduler_->SetVisible(false); |
| 3512 | 3410 |
| 3513 scheduler_->SetNeedsRedraw(); | 3411 scheduler_->SetNeedsRedraw(); |
| 3514 bool resourceless_software_draw = true; | 3412 bool resourceless_software_draw = true; |
| 3515 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 3413 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 3516 // SynchronousCompositor has to draw regardless of visibility. | 3414 // SynchronousCompositor has to draw regardless of visibility. |
| 3517 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 3415 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 3518 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3416 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3519 client_->Reset(); | 3417 client_->Reset(); |
| 3520 } | 3418 } |
| 3521 | 3419 |
| 3522 TEST_F(SchedulerTest, AuthoritativeVSyncInterval) { | 3420 TEST_F(SchedulerTest, AuthoritativeVSyncInterval) { |
| 3523 SetUpScheduler(true); | 3421 SetUpScheduler(THROTTLED_BFS); |
| 3524 base::TimeDelta initial_interval = scheduler_->BeginImplFrameInterval(); | 3422 base::TimeDelta initial_interval = scheduler_->BeginImplFrameInterval(); |
| 3525 base::TimeDelta authoritative_interval = | 3423 base::TimeDelta authoritative_interval = |
| 3526 base::TimeDelta::FromMilliseconds(33); | 3424 base::TimeDelta::FromMilliseconds(33); |
| 3527 | 3425 |
| 3528 scheduler_->SetNeedsBeginMainFrame(); | 3426 scheduler_->SetNeedsBeginMainFrame(); |
| 3529 EXPECT_SCOPED(AdvanceFrame()); | 3427 EXPECT_SCOPED(AdvanceFrame()); |
| 3530 | 3428 |
| 3531 EXPECT_EQ(initial_interval, scheduler_->BeginImplFrameInterval()); | 3429 EXPECT_EQ(initial_interval, scheduler_->BeginImplFrameInterval()); |
| 3532 | 3430 |
| 3533 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 3431 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 3534 scheduler_->NotifyReadyToCommit(); | 3432 scheduler_->NotifyReadyToCommit(); |
| 3535 scheduler_->NotifyReadyToActivate(); | 3433 scheduler_->NotifyReadyToActivate(); |
| 3536 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 3434 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 3537 | 3435 |
| 3538 // Test changing the interval on the frame source external to the scheduler. | 3436 // Test changing the interval on the frame source external to the scheduler. |
| 3539 synthetic_frame_source_->OnUpdateVSyncParameters(now_src_->NowTicks(), | 3437 synthetic_frame_source_->OnUpdateVSyncParameters(now_src_->NowTicks(), |
| 3540 authoritative_interval); | 3438 authoritative_interval); |
| 3541 | 3439 |
| 3542 EXPECT_SCOPED(AdvanceFrame()); | 3440 EXPECT_SCOPED(AdvanceFrame()); |
| 3543 | 3441 |
| 3544 // At the next BeginFrame, authoritative interval is used instead of previous | 3442 // At the next BeginFrame, authoritative interval is used instead of previous |
| 3545 // interval. | 3443 // interval. |
| 3546 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); | 3444 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); |
| 3547 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); | 3445 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); |
| 3548 } | 3446 } |
| 3549 | 3447 |
| 3550 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { | 3448 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { |
| 3551 SetUpScheduler(true); | 3449 SetUpScheduler(THROTTLED_BFS); |
| 3552 | 3450 |
| 3553 scheduler_->SetTreePrioritiesAndScrollState( | 3451 scheduler_->SetTreePrioritiesAndScrollState( |
| 3554 SMOOTHNESS_TAKES_PRIORITY, | 3452 SMOOTHNESS_TAKES_PRIORITY, |
| 3555 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); | 3453 ScrollHandlerState::SCROLL_DOES_NOT_AFFECT_SCROLL_HANDLER); |
| 3556 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); | 3454 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); |
| 3557 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); | 3455 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); |
| 3558 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); | 3456 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); |
| 3559 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); | 3457 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); |
| 3560 | 3458 |
| 3561 scheduler_->SetTreePrioritiesAndScrollState( | 3459 scheduler_->SetTreePrioritiesAndScrollState( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3577 scheduler_->SetTreePrioritiesAndScrollState( | 3475 scheduler_->SetTreePrioritiesAndScrollState( |
| 3578 SAME_PRIORITY_FOR_BOTH_TREES, | 3476 SAME_PRIORITY_FOR_BOTH_TREES, |
| 3579 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER); | 3477 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER); |
| 3580 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); | 3478 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); |
| 3581 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); | 3479 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
| 3582 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); | 3480 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); |
| 3583 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); | 3481 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); |
| 3584 } | 3482 } |
| 3585 | 3483 |
| 3586 TEST_F(SchedulerTest, NoCompositorFrameSinkCreationWhileCommitPending) { | 3484 TEST_F(SchedulerTest, NoCompositorFrameSinkCreationWhileCommitPending) { |
| 3587 SetUpScheduler(true); | 3485 SetUpScheduler(THROTTLED_BFS); |
| 3588 | 3486 |
| 3589 // SetNeedsBeginMainFrame should begin the frame. | 3487 // SetNeedsBeginMainFrame should begin the frame. |
| 3590 scheduler_->SetNeedsBeginMainFrame(); | 3488 scheduler_->SetNeedsBeginMainFrame(); |
| 3591 client_->Reset(); | 3489 client_->Reset(); |
| 3592 EXPECT_SCOPED(AdvanceFrame()); | 3490 EXPECT_SCOPED(AdvanceFrame()); |
| 3593 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3491 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3594 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 3492 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3595 | 3493 |
| 3596 // Lose the CompositorFrameSink and trigger the deadline. | 3494 // Lose the CompositorFrameSink and trigger the deadline. |
| 3597 client_->Reset(); | 3495 client_->Reset(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3610 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); | 3508 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); |
| 3611 scheduler_->BeginMainFrameAborted( | 3509 scheduler_->BeginMainFrameAborted( |
| 3612 CommitEarlyOutReason::ABORTED_COMPOSITOR_FRAME_SINK_LOST); | 3510 CommitEarlyOutReason::ABORTED_COMPOSITOR_FRAME_SINK_LOST); |
| 3613 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", | 3511 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", |
| 3614 client_); | 3512 client_); |
| 3615 } | 3513 } |
| 3616 | 3514 |
| 3617 TEST_F(SchedulerTest, CompositorFrameSinkCreationWhileCommitPending) { | 3515 TEST_F(SchedulerTest, CompositorFrameSinkCreationWhileCommitPending) { |
| 3618 scheduler_settings_.abort_commit_before_compositor_frame_sink_creation = | 3516 scheduler_settings_.abort_commit_before_compositor_frame_sink_creation = |
| 3619 false; | 3517 false; |
| 3620 SetUpScheduler(true); | 3518 SetUpScheduler(THROTTLED_BFS); |
| 3621 | 3519 |
| 3622 // SetNeedsBeginMainFrame should begin the frame. | 3520 // SetNeedsBeginMainFrame should begin the frame. |
| 3623 scheduler_->SetNeedsBeginMainFrame(); | 3521 scheduler_->SetNeedsBeginMainFrame(); |
| 3624 client_->Reset(); | 3522 client_->Reset(); |
| 3625 EXPECT_SCOPED(AdvanceFrame()); | 3523 EXPECT_SCOPED(AdvanceFrame()); |
| 3626 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3524 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3627 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 3525 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3628 | 3526 |
| 3629 // Lose the CompositorFrameSink and trigger the deadline. | 3527 // Lose the CompositorFrameSink and trigger the deadline. |
| 3630 client_->Reset(); | 3528 client_->Reset(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3644 | 3542 |
| 3645 // The three letters appeneded to each version of this test mean the following:s | 3543 // The three letters appeneded to each version of this test mean the following:s |
| 3646 // tree_priority: B = both trees same priority; A = active tree priority; | 3544 // tree_priority: B = both trees same priority; A = active tree priority; |
| 3647 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll | 3545 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll |
| 3648 // handler; | 3546 // handler; |
| 3649 // durations: F = fast durations; S = slow durations | 3547 // durations: F = fast durations; S = slow durations |
| 3650 bool SchedulerTest::BeginMainFrameOnCriticalPath( | 3548 bool SchedulerTest::BeginMainFrameOnCriticalPath( |
| 3651 TreePriority tree_priority, | 3549 TreePriority tree_priority, |
| 3652 ScrollHandlerState scroll_handler_state, | 3550 ScrollHandlerState scroll_handler_state, |
| 3653 base::TimeDelta durations) { | 3551 base::TimeDelta durations) { |
| 3654 scheduler_settings_.use_external_begin_frame_source = true; | 3552 SetUpScheduler(EXTERNAL_BFS); |
| 3655 SetUpScheduler(true); | |
| 3656 fake_compositor_timing_history_->SetAllEstimatesTo(durations); | 3553 fake_compositor_timing_history_->SetAllEstimatesTo(durations); |
| 3657 client_->Reset(); | 3554 client_->Reset(); |
| 3658 scheduler_->SetTreePrioritiesAndScrollState(tree_priority, | 3555 scheduler_->SetTreePrioritiesAndScrollState(tree_priority, |
| 3659 scroll_handler_state); | 3556 scroll_handler_state); |
| 3660 scheduler_->SetNeedsBeginMainFrame(); | 3557 scheduler_->SetNeedsBeginMainFrame(); |
| 3661 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); | 3558 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); |
| 3662 EXPECT_SCOPED(AdvanceFrame()); | 3559 EXPECT_SCOPED(AdvanceFrame()); |
| 3663 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); | 3560 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); |
| 3664 return client_->last_begin_main_frame_args().on_critical_path; | 3561 return client_->last_begin_main_frame_args().on_critical_path; |
| 3665 } | 3562 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3711 } | 3608 } |
| 3712 | 3609 |
| 3713 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3610 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3714 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3611 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3715 SMOOTHNESS_TAKES_PRIORITY, | 3612 SMOOTHNESS_TAKES_PRIORITY, |
| 3716 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3613 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3717 } | 3614 } |
| 3718 | 3615 |
| 3719 } // namespace | 3616 } // namespace |
| 3720 } // namespace cc | 3617 } // namespace cc |
| OLD | NEW |