| 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 869a742057ad6d83a6ed221534319a152bb7e47b..88af7db7cef69d110cf305a041ba98af0e3fe843 100644
|
| --- a/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc
|
| +++ b/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc
|
| @@ -143,6 +143,18 @@ void PostingYieldingTestTask(
|
| *should_yield_after = scheduler->ShouldYieldForHighPriorityWork();
|
| }
|
|
|
| +void AnticipationTestTask(RendererSchedulerImpl* scheduler,
|
| + bool simulate_input,
|
| + bool* should_anticipate_before,
|
| + bool* should_anticipate_after) {
|
| + *should_anticipate_before = scheduler->ShouldAnticipateHighPriorityWork();
|
| + if (simulate_input) {
|
| + scheduler->DidReceiveInputEventOnCompositorThread(
|
| + blink::WebInputEvent::GestureFlingStart);
|
| + }
|
| + *should_anticipate_after = scheduler->ShouldAnticipateHighPriorityWork();
|
| +}
|
| +
|
| TEST_F(RendererSchedulerImplTest, TestPostDefaultTask) {
|
| int result = 0;
|
| default_task_runner_->PostTask(FROM_HERE,
|
| @@ -467,6 +479,45 @@ TEST_F(RendererSchedulerImplTest, TestCompositorPolicyEnds) {
|
| std::string("D2"), std::string("C2")));
|
| }
|
|
|
| +TEST_F(RendererSchedulerImplTest, TestShouldAnticipate) {
|
| + bool should_anticipate_before = false;
|
| + bool should_anticipate_after = false;
|
| +
|
| + bool simulate_input = false;
|
| + default_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&AnticipationTestTask, scheduler_.get(), simulate_input,
|
| + &should_anticipate_before, &should_anticipate_after));
|
| + RunUntilIdle();
|
| + // In its default state, without input receipt, the scheduler should indicate
|
| + // that no high-priority is anticipated.
|
| + EXPECT_FALSE(should_anticipate_before);
|
| + EXPECT_FALSE(should_anticipate_after);
|
| +
|
| + simulate_input = true;
|
| + default_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&AnticipationTestTask, scheduler_.get(), simulate_input,
|
| + &should_anticipate_before, &should_anticipate_after));
|
| + RunUntilIdle();
|
| + // When input is received, the scheduler should indicate that high-priority
|
| + // work is anticipated.
|
| + EXPECT_FALSE(should_anticipate_before);
|
| + EXPECT_TRUE(should_anticipate_after);
|
| +
|
| + clock_->AdvanceNow(base::TimeDelta::FromMilliseconds(200));
|
| + simulate_input = false;
|
| + default_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&AnticipationTestTask, scheduler_.get(), simulate_input,
|
| + &should_anticipate_before, &should_anticipate_after));
|
| + RunUntilIdle();
|
| + // Without additional input, the scheduler should indicate that high-priority
|
| + // work is no longer anticipated.
|
| + EXPECT_FALSE(should_anticipate_before);
|
| + EXPECT_FALSE(should_anticipate_after);
|
| +}
|
| +
|
| TEST_F(RendererSchedulerImplTest, TestShouldYield) {
|
| bool should_yield_before = false;
|
| bool should_yield_after = false;
|
|
|