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 |
523 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { | 593 TEST_F(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
524 scheduler_settings_.use_external_begin_frame_source = true; | 594 scheduler_settings_.use_external_begin_frame_source = true; |
525 SetUpScheduler(true); | 595 SetUpScheduler(true); |
526 | 596 |
527 // SetNeedsCommit should begin the frame. | 597 // SetNeedsCommit should begin the frame. |
528 scheduler_->SetNeedsCommit(); | 598 scheduler_->SetNeedsCommit(); |
529 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 599 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
530 | 600 |
531 client_->Reset(); | 601 client_->Reset(); |
532 EXPECT_SCOPED(AdvanceFrame()); | 602 EXPECT_SCOPED(AdvanceFrame()); |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 2341 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
2272 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2342 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2273 EXPECT_TRUE(client_->needs_begin_frames()); | 2343 EXPECT_TRUE(client_->needs_begin_frames()); |
2274 client_->Reset(); | 2344 client_->Reset(); |
2275 task_runner().RunPendingTasks(); // Run posted deadline. | 2345 task_runner().RunPendingTasks(); // Run posted deadline. |
2276 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 2346 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
2277 } | 2347 } |
2278 | 2348 |
2279 } // namespace | 2349 } // namespace |
2280 } // namespace cc | 2350 } // namespace cc |
OLD | NEW |