| Index: content/renderer/scheduler/renderer_scheduler_impl_unittest.cc
|
| diff --git a/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc b/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc
|
| index ee16d04bece365535469dce5fa4acdbcb3be8ca3..7f49e514e5ee11502685567435011a3c02e160db 100644
|
| --- a/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc
|
| +++ b/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc
|
| @@ -36,6 +36,11 @@ class RendererSchedulerImplTest : public testing::Test {
|
| }
|
|
|
| protected:
|
| + static base::TimeDelta compositor_priority_after_touch_duration() {
|
| + return base::TimeDelta::FromMilliseconds(
|
| + RendererSchedulerImpl::kCompositorPriorityAfterTouchMillis);
|
| + }
|
| +
|
| scoped_refptr<cc::TestNowSource> clock_;
|
| scoped_refptr<cc::OrderedSimpleTaskRunner> mock_task_runner_;
|
|
|
| @@ -132,6 +137,18 @@ void PostingYieldingTestTask(
|
| *should_yield_after = scheduler->ShouldYieldForHighPriorityWork();
|
| }
|
|
|
| +void AnticipationTestTask(RendererSchedulerImpl* scheduler,
|
| + bool simulate_input,
|
| + bool* is_anticipated_before,
|
| + bool* is_anticipated_after) {
|
| + *is_anticipated_before = scheduler->IsHighPriorityWorkAnticipated();
|
| + if (simulate_input) {
|
| + scheduler->DidReceiveInputEventOnCompositorThread(
|
| + blink::WebInputEvent::GestureFlingStart);
|
| + }
|
| + *is_anticipated_after = scheduler->IsHighPriorityWorkAnticipated();
|
| +}
|
| +
|
| TEST_F(RendererSchedulerImplTest, TestPostDefaultTask) {
|
| int result = 0;
|
| default_task_runner_->PostTask(FROM_HERE,
|
| @@ -499,6 +516,45 @@ TEST_F(RendererSchedulerImplTest, TestCompositorPolicyEnds) {
|
| std::string("D2"), std::string("C2")));
|
| }
|
|
|
| +TEST_F(RendererSchedulerImplTest, TestIsHighPriorityWorkAnticipated) {
|
| + bool is_anticipated_before = false;
|
| + bool is_anticipated_after = false;
|
| +
|
| + bool simulate_input = false;
|
| + default_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&AnticipationTestTask, scheduler_.get(), simulate_input,
|
| + &is_anticipated_before, &is_anticipated_after));
|
| + RunUntilIdle();
|
| + // In its default state, without input receipt, the scheduler should indicate
|
| + // that no high-priority is anticipated.
|
| + EXPECT_FALSE(is_anticipated_before);
|
| + EXPECT_FALSE(is_anticipated_after);
|
| +
|
| + simulate_input = true;
|
| + default_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&AnticipationTestTask, scheduler_.get(), simulate_input,
|
| + &is_anticipated_before, &is_anticipated_after));
|
| + RunUntilIdle();
|
| + // When input is received, the scheduler should indicate that high-priority
|
| + // work is anticipated.
|
| + EXPECT_FALSE(is_anticipated_before);
|
| + EXPECT_TRUE(is_anticipated_after);
|
| +
|
| + clock_->AdvanceNow(compositor_priority_after_touch_duration() * 2);
|
| + simulate_input = false;
|
| + default_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&AnticipationTestTask, scheduler_.get(), simulate_input,
|
| + &is_anticipated_before, &is_anticipated_after));
|
| + RunUntilIdle();
|
| + // Without additional input, the scheduler should indicate that high-priority
|
| + // work is no longer anticipated.
|
| + EXPECT_FALSE(is_anticipated_before);
|
| + EXPECT_FALSE(is_anticipated_after);
|
| +}
|
| +
|
| TEST_F(RendererSchedulerImplTest, TestShouldYield) {
|
| bool should_yield_before = false;
|
| bool should_yield_after = false;
|
|
|