Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator_unittest.cc

Issue 2840873002: [scheduler] Rename member variables from task_runner_ to task_queue_. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/scheduler/renderer/idle_time_estimator.h" 5 #include "platform/scheduler/renderer/idle_time_estimator.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "cc/test/ordered_simple_task_runner.h" 9 #include "cc/test/ordered_simple_task_runner.h"
10 #include "platform/scheduler/base/task_queue_manager.h" 10 #include "platform/scheduler/base/task_queue_manager.h"
(...skipping 30 matching lines...) Expand all
41 clock_.reset(new base::SimpleTestTickClock()); 41 clock_.reset(new base::SimpleTestTickClock());
42 clock_->Advance(base::TimeDelta::FromMicroseconds(5000)); 42 clock_->Advance(base::TimeDelta::FromMicroseconds(5000));
43 test_time_source_.reset(new TestTimeSource(clock_.get())); 43 test_time_source_.reset(new TestTimeSource(clock_.get()));
44 mock_task_runner_ = make_scoped_refptr( 44 mock_task_runner_ = make_scoped_refptr(
45 new cc::OrderedSimpleTaskRunner(clock_.get(), false)); 45 new cc::OrderedSimpleTaskRunner(clock_.get(), false));
46 main_task_runner_ = SchedulerTqmDelegateForTest::Create( 46 main_task_runner_ = SchedulerTqmDelegateForTest::Create(
47 mock_task_runner_, base::MakeUnique<TestTimeSource>(clock_.get())); 47 mock_task_runner_, base::MakeUnique<TestTimeSource>(clock_.get()));
48 manager_ = base::MakeUnique<TaskQueueManager>( 48 manager_ = base::MakeUnique<TaskQueueManager>(
49 main_task_runner_, "test.scheduler", "test.scheduler", 49 main_task_runner_, "test.scheduler", "test.scheduler",
50 "test.scheduler.debug"); 50 "test.scheduler.debug");
51 compositor_task_runner_ = manager_->NewTaskQueue( 51 compositor_task_queue_ = manager_->NewTaskQueue(
52 TaskQueue::Spec(TaskQueue::QueueType::COMPOSITOR)); 52 TaskQueue::Spec(TaskQueue::QueueType::COMPOSITOR));
53 estimator_.reset(new IdleTimeEstimatorForTest( 53 estimator_.reset(new IdleTimeEstimatorForTest(
54 compositor_task_runner_, test_time_source_.get(), 10, 50)); 54 compositor_task_queue_, test_time_source_.get(), 10, 50));
55 } 55 }
56 56
57 void SimulateFrameWithOneCompositorTask(int compositor_time) { 57 void SimulateFrameWithOneCompositorTask(int compositor_time) {
58 base::TimeDelta non_idle_time = 58 base::TimeDelta non_idle_time =
59 base::TimeDelta::FromMilliseconds(compositor_time); 59 base::TimeDelta::FromMilliseconds(compositor_time);
60 base::PendingTask task(FROM_HERE, base::Closure()); 60 base::PendingTask task(FROM_HERE, base::Closure());
61 estimator_->WillProcessTask(task); 61 estimator_->WillProcessTask(task);
62 clock_->Advance(non_idle_time); 62 clock_->Advance(non_idle_time);
63 estimator_->DidCommitFrameToCompositor(); 63 estimator_->DidCommitFrameToCompositor();
64 estimator_->DidProcessTask(task); 64 estimator_->DidProcessTask(task);
(...skipping 19 matching lines...) Expand all
84 84
85 base::TimeDelta idle_time = frame_length_ - non_idle_time1 - non_idle_time2; 85 base::TimeDelta idle_time = frame_length_ - non_idle_time1 - non_idle_time2;
86 clock_->Advance(idle_time); 86 clock_->Advance(idle_time);
87 } 87 }
88 88
89 std::unique_ptr<base::SimpleTestTickClock> clock_; 89 std::unique_ptr<base::SimpleTestTickClock> clock_;
90 std::unique_ptr<TestTimeSource> test_time_source_; 90 std::unique_ptr<TestTimeSource> test_time_source_;
91 scoped_refptr<cc::OrderedSimpleTaskRunner> mock_task_runner_; 91 scoped_refptr<cc::OrderedSimpleTaskRunner> mock_task_runner_;
92 scoped_refptr<SchedulerTqmDelegate> main_task_runner_; 92 scoped_refptr<SchedulerTqmDelegate> main_task_runner_;
93 std::unique_ptr<TaskQueueManager> manager_; 93 std::unique_ptr<TaskQueueManager> manager_;
94 scoped_refptr<TaskQueue> compositor_task_runner_; 94 scoped_refptr<TaskQueue> compositor_task_queue_;
95 std::unique_ptr<IdleTimeEstimatorForTest> estimator_; 95 std::unique_ptr<IdleTimeEstimatorForTest> estimator_;
96 const base::TimeDelta frame_length_; 96 const base::TimeDelta frame_length_;
97 TestTaskTimeObserver test_task_time_observer_; 97 TestTaskTimeObserver test_task_time_observer_;
98 }; 98 };
99 99
100 TEST_F(IdleTimeEstimatorTest, InitialTimeEstimateWithNoData) { 100 TEST_F(IdleTimeEstimatorTest, InitialTimeEstimateWithNoData) {
101 EXPECT_EQ(frame_length_, estimator_->GetExpectedIdleDuration(frame_length_)); 101 EXPECT_EQ(frame_length_, estimator_->GetExpectedIdleDuration(frame_length_));
102 } 102 }
103 103
104 TEST_F(IdleTimeEstimatorTest, BasicEstimation_SteadyState) { 104 TEST_F(IdleTimeEstimatorTest, BasicEstimation_SteadyState) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 SimulateFrameWithTwoCompositorTasks(4, 4); 161 SimulateFrameWithTwoCompositorTasks(4, 4);
162 estimator_->DidCommitFrameToCompositor(); 162 estimator_->DidCommitFrameToCompositor();
163 estimator_->DidProcessTask(task); 163 estimator_->DidProcessTask(task);
164 164
165 EXPECT_EQ(base::TimeDelta::FromMilliseconds(11), 165 EXPECT_EQ(base::TimeDelta::FromMilliseconds(11),
166 estimator_->GetExpectedIdleDuration(frame_length_)); 166 estimator_->GetExpectedIdleDuration(frame_length_));
167 } 167 }
168 168
169 } // namespace scheduler 169 } // namespace scheduler
170 } // namespace blink 170 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698