| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 return CallOnBeginFrame(args); | 246 return CallOnBeginFrame(args); |
| 247 } | 247 } |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 FakeSchedulerClient* client_; | 250 FakeSchedulerClient* client_; |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 class SchedulerTest : public testing::Test { | 253 class SchedulerTest : public testing::Test { |
| 254 public: | 254 public: |
| 255 SchedulerTest() | 255 SchedulerTest() |
| 256 : now_src_(TestNowSource::Create()), | 256 : now_src_(new base::SimpleTestTickClock( |
| 257 base::TimeTicks::FromInternalValue(10000))), |
| 257 task_runner_(new OrderedSimpleTaskRunner(now_src_, true)), | 258 task_runner_(new OrderedSimpleTaskRunner(now_src_, true)), |
| 258 fake_external_begin_frame_source_(nullptr) { | 259 fake_external_begin_frame_source_(nullptr) { |
| 259 // A bunch of tests require Now() to be > BeginFrameArgs::DefaultInterval() | 260 // A bunch of tests require NowTicks() to be > |
| 260 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(100)); | 261 // BeginFrameArgs::DefaultInterval() |
| 262 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); |
| 261 // Fail if we need to run 100 tasks in a row. | 263 // Fail if we need to run 100 tasks in a row. |
| 262 task_runner_->SetRunTaskLimit(100); | 264 task_runner_->SetRunTaskLimit(100); |
| 263 } | 265 } |
| 264 | 266 |
| 265 ~SchedulerTest() override {} | 267 ~SchedulerTest() override {} |
| 266 | 268 |
| 267 protected: | 269 protected: |
| 268 TestScheduler* CreateScheduler() { | 270 TestScheduler* CreateScheduler() { |
| 269 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source; | 271 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source; |
| 270 if (scheduler_settings_.use_external_begin_frame_source) { | 272 if (scheduler_settings_.use_external_begin_frame_source) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 293 void SetUpScheduler(scoped_ptr<FakeSchedulerClient> client, | 295 void SetUpScheduler(scoped_ptr<FakeSchedulerClient> client, |
| 294 bool initSurface) { | 296 bool initSurface) { |
| 295 client_ = client.Pass(); | 297 client_ = client.Pass(); |
| 296 if (initSurface) | 298 if (initSurface) |
| 297 CreateSchedulerAndInitSurface(); | 299 CreateSchedulerAndInitSurface(); |
| 298 else | 300 else |
| 299 CreateScheduler(); | 301 CreateScheduler(); |
| 300 } | 302 } |
| 301 | 303 |
| 302 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } | 304 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } |
| 303 TestNowSource* now_src() { return now_src_.get(); } | 305 base::SimpleTestTickClock* now_src() { return now_src_; } |
| 304 | 306 |
| 305 // As this function contains EXPECT macros, to allow debugging it should be | 307 // As this function contains EXPECT macros, to allow debugging it should be |
| 306 // called inside EXPECT_SCOPED like so; | 308 // called inside EXPECT_SCOPED like so; |
| 307 // EXPECT_SCOPED(client.InitializeOutputSurfaceAndFirstCommit(scheduler)); | 309 // EXPECT_SCOPED(client.InitializeOutputSurfaceAndFirstCommit(scheduler)); |
| 308 void InitializeOutputSurfaceAndFirstCommit() { | 310 void InitializeOutputSurfaceAndFirstCommit() { |
| 309 TRACE_EVENT0("cc", | 311 TRACE_EVENT0("cc", |
| 310 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); | 312 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); |
| 311 DCHECK(scheduler_); | 313 DCHECK(scheduler_); |
| 312 | 314 |
| 313 // Check the client doesn't have any actions queued when calling this | 315 // Check the client doesn't have any actions queued when calling this |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 EXPECT_TRUE(task_runner_->RunTasksWhile( | 399 EXPECT_TRUE(task_runner_->RunTasksWhile( |
| 398 client_->ImplFrameDeadlinePending(false))); | 400 client_->ImplFrameDeadlinePending(false))); |
| 399 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 401 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 400 } | 402 } |
| 401 } | 403 } |
| 402 | 404 |
| 403 BeginFrameArgs SendNextBeginFrame() { | 405 BeginFrameArgs SendNextBeginFrame() { |
| 404 DCHECK(scheduler_->settings().use_external_begin_frame_source); | 406 DCHECK(scheduler_->settings().use_external_begin_frame_source); |
| 405 // Creep the time forward so that any BeginFrameArgs is not equal to the | 407 // Creep the time forward so that any BeginFrameArgs is not equal to the |
| 406 // last one otherwise we violate the BeginFrameSource contract. | 408 // last one otherwise we violate the BeginFrameSource contract. |
| 407 now_src_->AdvanceNow(BeginFrameArgs::DefaultInterval()); | 409 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
| 408 BeginFrameArgs args = | 410 BeginFrameArgs args = |
| 409 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 411 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| 410 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 412 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
| 411 return args; | 413 return args; |
| 412 } | 414 } |
| 413 | 415 |
| 414 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { | 416 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { |
| 415 return fake_external_begin_frame_source_; | 417 return fake_external_begin_frame_source_; |
| 416 } | 418 } |
| 417 | 419 |
| 418 void MainFrameInHighLatencyMode( | 420 void MainFrameInHighLatencyMode( |
| 419 int64 begin_main_frame_to_commit_estimate_in_ms, | 421 int64 begin_main_frame_to_commit_estimate_in_ms, |
| 420 int64 commit_to_activate_estimate_in_ms, | 422 int64 commit_to_activate_estimate_in_ms, |
| 421 bool impl_latency_takes_priority, | 423 bool impl_latency_takes_priority, |
| 422 bool should_send_begin_main_frame); | 424 bool should_send_begin_main_frame); |
| 423 void BeginFramesNotFromClient(bool use_external_begin_frame_source, | 425 void BeginFramesNotFromClient(bool use_external_begin_frame_source, |
| 424 bool throttle_frame_production); | 426 bool throttle_frame_production); |
| 425 void BeginFramesNotFromClient_SwapThrottled( | 427 void BeginFramesNotFromClient_SwapThrottled( |
| 426 bool use_external_begin_frame_source, | 428 bool use_external_begin_frame_source, |
| 427 bool throttle_frame_production); | 429 bool throttle_frame_production); |
| 428 void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( | 430 void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( |
| 429 bool impl_side_painting); | 431 bool impl_side_painting); |
| 430 void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting); | 432 void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting); |
| 431 | 433 |
| 432 scoped_refptr<TestNowSource> now_src_; | 434 base::SimpleTestTickClock* now_src_; |
| 433 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 435 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 434 FakeExternalBeginFrameSource* fake_external_begin_frame_source_; | 436 FakeExternalBeginFrameSource* fake_external_begin_frame_source_; |
| 435 SchedulerSettings scheduler_settings_; | 437 SchedulerSettings scheduler_settings_; |
| 436 scoped_ptr<FakeSchedulerClient> client_; | 438 scoped_ptr<FakeSchedulerClient> client_; |
| 437 scoped_ptr<TestScheduler> scheduler_; | 439 scoped_ptr<TestScheduler> scheduler_; |
| 438 }; | 440 }; |
| 439 | 441 |
| 440 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { | 442 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { |
| 441 scheduler_settings_.use_external_begin_frame_source = true; | 443 scheduler_settings_.use_external_begin_frame_source = true; |
| 442 SetUpScheduler(false); | 444 SetUpScheduler(false); |
| (...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 // Run posted BeginRetroFrame. | 1565 // Run posted BeginRetroFrame. |
| 1564 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); | 1566 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); |
| 1565 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1567 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1566 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1568 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1567 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1569 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1568 EXPECT_TRUE(client_->needs_begin_frames()); | 1570 EXPECT_TRUE(client_->needs_begin_frames()); |
| 1569 client_->Reset(); | 1571 client_->Reset(); |
| 1570 | 1572 |
| 1571 // Let time pass sufficiently beyond the regular deadline but not beyond the | 1573 // Let time pass sufficiently beyond the regular deadline but not beyond the |
| 1572 // late deadline. | 1574 // late deadline. |
| 1573 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - | 1575 now_src()->Advance(BeginFrameArgs::DefaultInterval() - |
| 1574 base::TimeDelta::FromMicroseconds(1)); | 1576 base::TimeDelta::FromMicroseconds(1)); |
| 1575 task_runner().RunUntilTime(now_src()->Now()); | 1577 task_runner().RunUntilTime(now_src()->NowTicks()); |
| 1576 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1578 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1577 | 1579 |
| 1578 // Take us out of a swap throttled state. | 1580 // Take us out of a swap throttled state. |
| 1579 scheduler_->DidSwapBuffersComplete(); | 1581 scheduler_->DidSwapBuffersComplete(); |
| 1580 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); | 1582 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
| 1581 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1583 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1582 EXPECT_TRUE(client_->needs_begin_frames()); | 1584 EXPECT_TRUE(client_->needs_begin_frames()); |
| 1583 client_->Reset(); | 1585 client_->Reset(); |
| 1584 | 1586 |
| 1585 // Verify that the deadline was rescheduled. | 1587 // Verify that the deadline was rescheduled. |
| 1586 task_runner().RunUntilTime(now_src()->Now()); | 1588 task_runner().RunUntilTime(now_src()->NowTicks()); |
| 1587 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 1589 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 1588 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1590 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1589 EXPECT_TRUE(client_->needs_begin_frames()); | 1591 EXPECT_TRUE(client_->needs_begin_frames()); |
| 1590 client_->Reset(); | 1592 client_->Reset(); |
| 1591 } | 1593 } |
| 1592 | 1594 |
| 1593 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) { | 1595 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) { |
| 1594 scheduler_settings_.use_external_begin_frame_source = true; | 1596 scheduler_settings_.use_external_begin_frame_source = true; |
| 1595 SetUpScheduler(true); | 1597 SetUpScheduler(true); |
| 1596 | 1598 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1626 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); | 1628 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); |
| 1627 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); | 1629 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); |
| 1628 | 1630 |
| 1629 // Keep animating. | 1631 // Keep animating. |
| 1630 client_->Reset(); | 1632 client_->Reset(); |
| 1631 scheduler_->SetNeedsAnimate(); | 1633 scheduler_->SetNeedsAnimate(); |
| 1632 scheduler_->SetNeedsRedraw(); | 1634 scheduler_->SetNeedsRedraw(); |
| 1633 EXPECT_NO_ACTION(client_); | 1635 EXPECT_NO_ACTION(client_); |
| 1634 | 1636 |
| 1635 // Let's advance to the retro frame's deadline. | 1637 // Let's advance to the retro frame's deadline. |
| 1636 now_src()->AdvanceNow(retro_frame_args.deadline - now_src()->Now()); | 1638 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks()); |
| 1637 | 1639 |
| 1638 // The retro frame hasn't expired yet. | 1640 // The retro frame hasn't expired yet. |
| 1639 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); | 1641 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); |
| 1640 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1642 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1641 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1643 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1642 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1644 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1643 | 1645 |
| 1644 // This is an immediate deadline case. | 1646 // This is an immediate deadline case. |
| 1645 client_->Reset(); | 1647 client_->Reset(); |
| 1646 task_runner().RunPendingTasks(); | 1648 task_runner().RunPendingTasks(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1684 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); | 1686 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); |
| 1685 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); | 1687 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); |
| 1686 | 1688 |
| 1687 // Keep animating. | 1689 // Keep animating. |
| 1688 client_->Reset(); | 1690 client_->Reset(); |
| 1689 scheduler_->SetNeedsAnimate(); | 1691 scheduler_->SetNeedsAnimate(); |
| 1690 scheduler_->SetNeedsRedraw(); | 1692 scheduler_->SetNeedsRedraw(); |
| 1691 EXPECT_NO_ACTION(client_); | 1693 EXPECT_NO_ACTION(client_); |
| 1692 | 1694 |
| 1693 // Let's advance sufficiently past the retro frame's deadline. | 1695 // Let's advance sufficiently past the retro frame's deadline. |
| 1694 now_src()->AdvanceNow(retro_frame_args.deadline - now_src()->Now() + | 1696 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks() + |
| 1695 base::TimeDelta::FromMicroseconds(1)); | 1697 base::TimeDelta::FromMicroseconds(1)); |
| 1696 | 1698 |
| 1697 // The retro frame should've expired. | 1699 // The retro frame should've expired. |
| 1698 EXPECT_NO_ACTION(client_); | 1700 EXPECT_NO_ACTION(client_); |
| 1699 } | 1701 } |
| 1700 | 1702 |
| 1701 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) { | 1703 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) { |
| 1702 scheduler_settings_.use_external_begin_frame_source = true; | 1704 scheduler_settings_.use_external_begin_frame_source = true; |
| 1703 SetUpScheduler(true); | 1705 SetUpScheduler(true); |
| 1704 | 1706 |
| 1705 scheduler_->SetNeedsCommit(); | 1707 scheduler_->SetNeedsCommit(); |
| 1706 EXPECT_TRUE(client_->needs_begin_frames()); | 1708 EXPECT_TRUE(client_->needs_begin_frames()); |
| 1707 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 1709 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 1708 | 1710 |
| 1709 BeginFrameArgs missed_frame_args = | 1711 BeginFrameArgs missed_frame_args = |
| 1710 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 1712 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| 1711 missed_frame_args.type = BeginFrameArgs::MISSED; | 1713 missed_frame_args.type = BeginFrameArgs::MISSED; |
| 1712 | 1714 |
| 1713 // Advance to the deadline. | 1715 // Advance to the deadline. |
| 1714 now_src()->AdvanceNow(missed_frame_args.deadline - now_src()->Now()); | 1716 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks()); |
| 1715 | 1717 |
| 1716 // Missed frame is handled because it's on time. | 1718 // Missed frame is handled because it's on time. |
| 1717 client_->Reset(); | 1719 client_->Reset(); |
| 1718 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); | 1720 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); |
| 1719 EXPECT_TRUE( | 1721 EXPECT_TRUE( |
| 1720 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); | 1722 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); |
| 1721 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1723 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1722 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 1724 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 1723 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1725 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1724 } | 1726 } |
| 1725 | 1727 |
| 1726 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) { | 1728 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) { |
| 1727 scheduler_settings_.use_external_begin_frame_source = true; | 1729 scheduler_settings_.use_external_begin_frame_source = true; |
| 1728 SetUpScheduler(true); | 1730 SetUpScheduler(true); |
| 1729 | 1731 |
| 1730 scheduler_->SetNeedsCommit(); | 1732 scheduler_->SetNeedsCommit(); |
| 1731 EXPECT_TRUE(client_->needs_begin_frames()); | 1733 EXPECT_TRUE(client_->needs_begin_frames()); |
| 1732 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 1734 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 1733 | 1735 |
| 1734 BeginFrameArgs missed_frame_args = | 1736 BeginFrameArgs missed_frame_args = |
| 1735 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 1737 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| 1736 missed_frame_args.type = BeginFrameArgs::MISSED; | 1738 missed_frame_args.type = BeginFrameArgs::MISSED; |
| 1737 | 1739 |
| 1738 // Advance sufficiently past the deadline. | 1740 // Advance sufficiently past the deadline. |
| 1739 now_src()->AdvanceNow(missed_frame_args.deadline - now_src()->Now() + | 1741 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks() + |
| 1740 base::TimeDelta::FromMicroseconds(1)); | 1742 base::TimeDelta::FromMicroseconds(1)); |
| 1741 | 1743 |
| 1742 // Missed frame is dropped because it's too late. | 1744 // Missed frame is dropped because it's too late. |
| 1743 client_->Reset(); | 1745 client_->Reset(); |
| 1744 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); | 1746 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); |
| 1745 EXPECT_FALSE( | 1747 EXPECT_FALSE( |
| 1746 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); | 1748 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); |
| 1747 EXPECT_NO_ACTION(client_); | 1749 EXPECT_NO_ACTION(client_); |
| 1748 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1750 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1749 } | 1751 } |
| 1750 | 1752 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 scheduler_->SetNeedsCommit(); | 1878 scheduler_->SetNeedsCommit(); |
| 1877 scheduler_->SetNeedsRedraw(); | 1879 scheduler_->SetNeedsRedraw(); |
| 1878 EXPECT_SCOPED(AdvanceFrame()); // Run posted BeginFrame. | 1880 EXPECT_SCOPED(AdvanceFrame()); // Run posted BeginFrame. |
| 1879 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1881 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1880 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1882 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1881 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1883 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1882 client_->Reset(); | 1884 client_->Reset(); |
| 1883 | 1885 |
| 1884 // Let time pass sufficiently beyond the regular deadline but not beyond the | 1886 // Let time pass sufficiently beyond the regular deadline but not beyond the |
| 1885 // late deadline. | 1887 // late deadline. |
| 1886 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - | 1888 now_src()->Advance(BeginFrameArgs::DefaultInterval() - |
| 1887 base::TimeDelta::FromMicroseconds(1)); | 1889 base::TimeDelta::FromMicroseconds(1)); |
| 1888 task_runner().RunUntilTime(now_src()->Now()); | 1890 task_runner().RunUntilTime(now_src()->NowTicks()); |
| 1889 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1891 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1890 | 1892 |
| 1891 // Take us out of a swap throttled state. | 1893 // Take us out of a swap throttled state. |
| 1892 scheduler_->DidSwapBuffersComplete(); | 1894 scheduler_->DidSwapBuffersComplete(); |
| 1893 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); | 1895 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
| 1894 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1896 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1895 client_->Reset(); | 1897 client_->Reset(); |
| 1896 | 1898 |
| 1897 // Verify that the deadline was rescheduled. | 1899 // Verify that the deadline was rescheduled. |
| 1898 // We can't use RunUntilTime(now) here because the next frame is also | 1900 // We can't use RunUntilTime(now) here because the next frame is also |
| 1899 // scheduled if throttle_frame_production = false. | 1901 // scheduled if throttle_frame_production = false. |
| 1900 base::TimeTicks before_deadline = now_src()->Now(); | 1902 base::TimeTicks before_deadline = now_src()->NowTicks(); |
| 1901 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1903 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1902 base::TimeTicks after_deadline = now_src()->Now(); | 1904 base::TimeTicks after_deadline = now_src()->NowTicks(); |
| 1903 EXPECT_EQ(after_deadline, before_deadline); | 1905 EXPECT_EQ(after_deadline, before_deadline); |
| 1904 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1906 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1905 client_->Reset(); | 1907 client_->Reset(); |
| 1906 } | 1908 } |
| 1907 | 1909 |
| 1908 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { | 1910 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { |
| 1909 bool use_external_begin_frame_source = false; | 1911 bool use_external_begin_frame_source = false; |
| 1910 bool throttle_frame_production = true; | 1912 bool throttle_frame_production = true; |
| 1911 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, | 1913 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, |
| 1912 throttle_frame_production); | 1914 throttle_frame_production); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2003 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2002 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 2004 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 2003 // OnBeginImplFrameDeadline didn't schedule output surface creation because | 2005 // OnBeginImplFrameDeadline didn't schedule output surface creation because |
| 2004 // main frame is not yet completed. | 2006 // main frame is not yet completed. |
| 2005 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); | 2007 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
| 2006 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2008 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 2007 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 2009 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2008 | 2010 |
| 2009 // BeginImplFrame is not started. | 2011 // BeginImplFrame is not started. |
| 2010 client_->Reset(); | 2012 client_->Reset(); |
| 2011 task_runner().RunUntilTime(now_src()->Now() + | 2013 task_runner().RunUntilTime(now_src()->NowTicks() + |
| 2012 base::TimeDelta::FromMilliseconds(10)); | 2014 base::TimeDelta::FromMilliseconds(10)); |
| 2013 EXPECT_NO_ACTION(client_); | 2015 EXPECT_NO_ACTION(client_); |
| 2014 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 2016 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 2015 | 2017 |
| 2016 client_->Reset(); | 2018 client_->Reset(); |
| 2017 scheduler_->NotifyBeginMainFrameStarted(); | 2019 scheduler_->NotifyBeginMainFrameStarted(); |
| 2018 scheduler_->NotifyReadyToCommit(); | 2020 scheduler_->NotifyReadyToCommit(); |
| 2019 if (impl_side_painting) { | 2021 if (impl_side_painting) { |
| 2020 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); | 2022 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); |
| 2021 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); | 2023 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 | 2691 |
| 2690 // At the next BeginFrame, authoritative interval is used instead of previous | 2692 // At the next BeginFrame, authoritative interval is used instead of previous |
| 2691 // interval. | 2693 // interval. |
| 2692 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); | 2694 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); |
| 2693 EXPECT_EQ(authoritative_interval, | 2695 EXPECT_EQ(authoritative_interval, |
| 2694 scheduler_->begin_impl_frame_args().interval); | 2696 scheduler_->begin_impl_frame_args().interval); |
| 2695 } | 2697 } |
| 2696 | 2698 |
| 2697 } // namespace | 2699 } // namespace |
| 2698 } // namespace cc | 2700 } // namespace cc |
| OLD | NEW |