diff options
Diffstat (limited to 'content/renderer/scheduler')
3 files changed, 40 insertions, 11 deletions
diff --git a/content/renderer/scheduler/renderer_scheduler_impl.cc b/content/renderer/scheduler/renderer_scheduler_impl.cc index be1eaf4..7ca3eb7 100644 --- a/content/renderer/scheduler/renderer_scheduler_impl.cc +++ b/content/renderer/scheduler/renderer_scheduler_impl.cc @@ -485,9 +485,8 @@ bool RendererSchedulerImpl::CanEnterLongIdlePeriod( return true; } -void RendererSchedulerImpl::SetTimeSourceForTesting( - scoped_refptr<cc::TestNowSource> time_source) { - helper_.SetTimeSourceForTesting(time_source); +SchedulerHelper* RendererSchedulerImpl::GetSchedulerHelperForTesting() { + return &helper_; } void RendererSchedulerImpl::SetWorkBatchSizeForTesting(size_t work_batch_size) { diff --git a/content/renderer/scheduler/renderer_scheduler_impl.h b/content/renderer/scheduler/renderer_scheduler_impl.h index 588bb9b..04c9ab8 100644 --- a/content/renderer/scheduler/renderer_scheduler_impl.h +++ b/content/renderer/scheduler/renderer_scheduler_impl.h @@ -51,7 +51,7 @@ class CONTENT_EXPORT RendererSchedulerImpl void SuspendTimerQueue() override; void ResumeTimerQueue() override; - void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); + SchedulerHelper* GetSchedulerHelperForTesting(); void SetWorkBatchSizeForTesting(size_t work_batch_size); base::TimeTicks CurrentIdleTaskDeadlineForTesting() const; diff --git a/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc b/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc index b3f6aff..150be2e 100644 --- a/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc +++ b/content/renderer/scheduler/renderer_scheduler_impl_unittest.cc @@ -7,8 +7,10 @@ #include "base/callback.h" #include "cc/output/begin_frame_args.h" #include "cc/test/ordered_simple_task_runner.h" +#include "cc/test/test_now_source.h" #include "content/child/scheduler/nestable_task_runner_for_test.h" #include "content/child/scheduler/scheduler_message_loop_delegate.h" +#include "content/test/test_time_source.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -136,7 +138,11 @@ class RendererSchedulerImplTest : public testing::Test { loading_task_runner_(scheduler_->LoadingTaskRunner()), idle_task_runner_(scheduler_->IdleTaskRunner()), timer_task_runner_(scheduler_->TimerTaskRunner()) { - scheduler_->SetTimeSourceForTesting(clock_); + scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( + make_scoped_ptr(new TestTimeSource(clock_))); + scheduler_->GetSchedulerHelperForTesting() + ->GetTaskQueueManagerForTesting() + ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_))); } RendererSchedulerImplTest(base::MessageLoop* message_loop) @@ -150,7 +156,11 @@ class RendererSchedulerImplTest : public testing::Test { loading_task_runner_(scheduler_->LoadingTaskRunner()), idle_task_runner_(scheduler_->IdleTaskRunner()), timer_task_runner_(scheduler_->TimerTaskRunner()) { - scheduler_->SetTimeSourceForTesting(clock_); + scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( + make_scoped_ptr(new TestTimeSource(clock_))); + scheduler_->GetSchedulerHelperForTesting() + ->GetTaskQueueManagerForTesting() + ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_))); } ~RendererSchedulerImplTest() override {} @@ -954,7 +964,11 @@ TEST_F(RendererSchedulerImplTest, OnePendingDelayedAndOneUrgentUpdatePolicy) { RendererSchedulerImplForTest* mock_scheduler = new RendererSchedulerImplForTest(nestable_task_runner_); scheduler_.reset(mock_scheduler); - scheduler_->SetTimeSourceForTesting(clock_); + scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( + make_scoped_ptr(new TestTimeSource(clock_))); + scheduler_->GetSchedulerHelperForTesting() + ->GetTaskQueueManagerForTesting() + ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_))); mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true); ScheduleDelayedPolicyUpdate(base::TimeDelta::FromMilliseconds(1)); @@ -970,7 +984,11 @@ TEST_F(RendererSchedulerImplTest, OneUrgentAndOnePendingDelayedUpdatePolicy) { RendererSchedulerImplForTest* mock_scheduler = new RendererSchedulerImplForTest(nestable_task_runner_); scheduler_.reset(mock_scheduler); - scheduler_->SetTimeSourceForTesting(clock_); + scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( + make_scoped_ptr(new TestTimeSource(clock_))); + scheduler_->GetSchedulerHelperForTesting() + ->GetTaskQueueManagerForTesting() + ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_))); mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true); EnsureUrgentPolicyUpdatePostedOnMainThread(); @@ -986,7 +1004,11 @@ TEST_F(RendererSchedulerImplTest, UpdatePolicyCountTriggeredByOneInputEvent) { RendererSchedulerImplForTest* mock_scheduler = new RendererSchedulerImplForTest(nestable_task_runner_); scheduler_.reset(mock_scheduler); - scheduler_->SetTimeSourceForTesting(clock_); + scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( + make_scoped_ptr(new TestTimeSource(clock_))); + scheduler_->GetSchedulerHelperForTesting() + ->GetTaskQueueManagerForTesting() + ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_))); mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true); scheduler_->DidReceiveInputEventOnCompositorThread( @@ -1002,7 +1024,11 @@ TEST_F(RendererSchedulerImplTest, UpdatePolicyCountTriggeredByTwoInputEvents) { RendererSchedulerImplForTest* mock_scheduler = new RendererSchedulerImplForTest(nestable_task_runner_); scheduler_.reset(mock_scheduler); - scheduler_->SetTimeSourceForTesting(clock_); + scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( + make_scoped_ptr(new TestTimeSource(clock_))); + scheduler_->GetSchedulerHelperForTesting() + ->GetTaskQueueManagerForTesting() + ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_))); mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true); scheduler_->DidReceiveInputEventOnCompositorThread( @@ -1020,7 +1046,11 @@ TEST_F(RendererSchedulerImplTest, EnsureUpdatePolicyNotTriggeredTooOften) { RendererSchedulerImplForTest* mock_scheduler = new RendererSchedulerImplForTest(nestable_task_runner_); scheduler_.reset(mock_scheduler); - scheduler_->SetTimeSourceForTesting(clock_); + scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( + make_scoped_ptr(new TestTimeSource(clock_))); + scheduler_->GetSchedulerHelperForTesting() + ->GetTaskQueueManagerForTesting() + ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_))); mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true); scheduler_->DidReceiveInputEventOnCompositorThread( |