| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 EXPECT_SCOPED(AdvanceFrame()); | 513 EXPECT_SCOPED(AdvanceFrame()); |
| 514 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 514 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 515 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 515 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 516 client_->Reset(); | 516 client_->Reset(); |
| 517 | 517 |
| 518 task_runner().RunPendingTasks(); // Run posted deadline. | 518 task_runner().RunPendingTasks(); // Run posted deadline. |
| 519 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); | 519 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_); |
| 520 client_->Reset(); | 520 client_->Reset(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { | |
| 524 scheduler_settings_.use_external_begin_frame_source = true; | |
| 525 SetUpScheduler(true); | |
| 526 | |
| 527 scheduler_->SetCanStart(); | |
| 528 scheduler_->SetVisible(true); | |
| 529 scheduler_->SetCanDraw(true); | |
| 530 | |
| 531 scheduler_->SetDeferCommits(true); | |
| 532 | |
| 533 scheduler_->SetNeedsCommit(); | |
| 534 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | |
| 535 | |
| 536 client_->Reset(); | |
| 537 AdvanceFrame(); | |
| 538 // BeginMainFrame is not sent during the defer commit is on. | |
| 539 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | |
| 540 | |
| 541 client_->Reset(); | |
| 542 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 543 // There is no posted deadline. | |
| 544 EXPECT_NO_ACTION(client_); | |
| 545 EXPECT_TRUE(client_->needs_begin_frames()); | |
| 546 | |
| 547 client_->Reset(); | |
| 548 scheduler_->SetDeferCommits(false); | |
| 549 EXPECT_NO_ACTION(client_); | |
| 550 | |
| 551 // Start new BeginMainFrame after defer commit is off. | |
| 552 client_->Reset(); | |
| 553 AdvanceFrame(); | |
| 554 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 555 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | |
| 556 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 557 } | |
| 558 | |
| 559 TEST_F(SchedulerTest, DeferCommitWithRedraw) { | |
| 560 scheduler_settings_.use_external_begin_frame_source = true; | |
| 561 SetUpScheduler(true); | |
| 562 | |
| 563 scheduler_->SetCanStart(); | |
| 564 scheduler_->SetVisible(true); | |
| 565 scheduler_->SetCanDraw(true); | |
| 566 | |
| 567 scheduler_->SetDeferCommits(true); | |
| 568 | |
| 569 scheduler_->SetNeedsCommit(); | |
| 570 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | |
| 571 | |
| 572 client_->Reset(); | |
| 573 scheduler_->SetNeedsRedraw(); | |
| 574 EXPECT_NO_ACTION(client_); | |
| 575 | |
| 576 client_->Reset(); | |
| 577 AdvanceFrame(); | |
| 578 // BeginMainFrame is not sent during the defer commit is on. | |
| 579 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 580 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | |
| 581 | |
| 582 client_->Reset(); | |
| 583 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 584 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | |
| 585 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 586 EXPECT_TRUE(client_->needs_begin_frames()); | |
| 587 | |
| 588 client_->Reset(); | |
| 589 AdvanceFrame(); | |
| 590 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | |
| 591 } | |
| 592 | |
| 593 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { | 523 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| 594 scheduler_settings_.use_external_begin_frame_source = true; | 524 scheduler_settings_.use_external_begin_frame_source = true; |
| 595 SetUpScheduler(true); | 525 SetUpScheduler(true); |
| 596 | 526 |
| 597 // SetNeedsCommit should begin the frame. | 527 // SetNeedsCommit should begin the frame. |
| 598 scheduler_->SetNeedsCommit(); | 528 scheduler_->SetNeedsCommit(); |
| 599 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 529 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 600 | 530 |
| 601 client_->Reset(); | 531 client_->Reset(); |
| 602 EXPECT_SCOPED(AdvanceFrame()); | 532 EXPECT_SCOPED(AdvanceFrame()); |
| (...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2341 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 2271 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 2342 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2272 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2343 EXPECT_TRUE(client_->needs_begin_frames()); | 2273 EXPECT_TRUE(client_->needs_begin_frames()); |
| 2344 client_->Reset(); | 2274 client_->Reset(); |
| 2345 task_runner().RunPendingTasks(); // Run posted deadline. | 2275 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2346 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 2276 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 2347 } | 2277 } |
| 2348 | 2278 |
| 2349 } // namespace | 2279 } // namespace |
| 2350 } // namespace cc | 2280 } // namespace cc |
| OLD | NEW |