[Eraser strings] Remove unused Supervised User infobar and corresponding strings
[chromium-blink-merge.git] / cc / test / scheduler_test_common.cc
blobffbc244777aa93bd06b81bdba6241145f0923e8b
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/test/scheduler_test_common.h"
7 #include <string>
9 #include "base/logging.h"
10 #include "cc/debug/rendering_stats_instrumentation.h"
12 namespace cc {
14 void FakeDelayBasedTimeSourceClient::OnTimerTick() {
15 tick_called_ = true;
18 base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; }
20 TestDelayBasedTimeSource::TestDelayBasedTimeSource(
21 base::SimpleTestTickClock* now_src,
22 base::TimeDelta interval,
23 OrderedSimpleTaskRunner* task_runner)
24 : DelayBasedTimeSource(interval, task_runner), now_src_(now_src) {
27 base::TimeTicks TestDelayBasedTimeSource::Now() const {
28 return now_src_->NowTicks();
31 std::string TestDelayBasedTimeSource::TypeString() const {
32 return "TestDelayBasedTimeSource";
35 TestDelayBasedTimeSource::~TestDelayBasedTimeSource() {
38 void FakeBeginFrameSource::DidFinishFrame(size_t remaining_frames) {
39 remaining_frames_ = remaining_frames;
42 void FakeBeginFrameSource::AsValueInto(
43 base::trace_event::TracedValue* dict) const {
44 dict->SetString("type", "FakeBeginFrameSource");
45 BeginFrameSourceBase::AsValueInto(dict);
48 TestBackToBackBeginFrameSource::TestBackToBackBeginFrameSource(
49 base::SimpleTestTickClock* now_src,
50 base::SingleThreadTaskRunner* task_runner)
51 : BackToBackBeginFrameSource(task_runner), now_src_(now_src) {
54 TestBackToBackBeginFrameSource::~TestBackToBackBeginFrameSource() {
57 base::TimeTicks TestBackToBackBeginFrameSource::Now() {
58 return now_src_->NowTicks();
61 TestSyntheticBeginFrameSource::TestSyntheticBeginFrameSource(
62 scoped_ptr<DelayBasedTimeSource> time_source)
63 : SyntheticBeginFrameSource(time_source.Pass()) {
66 TestSyntheticBeginFrameSource::~TestSyntheticBeginFrameSource() {
69 scoped_ptr<FakeCompositorTimingHistory> FakeCompositorTimingHistory::Create() {
70 scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation =
71 RenderingStatsInstrumentation::Create();
72 return make_scoped_ptr(
73 new FakeCompositorTimingHistory(rendering_stats_instrumentation.Pass()));
76 FakeCompositorTimingHistory::FakeCompositorTimingHistory(
77 scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation)
78 : CompositorTimingHistory(CompositorTimingHistory::NULL_UMA,
79 rendering_stats_instrumentation.get()),
80 rendering_stats_instrumentation_owned_(
81 rendering_stats_instrumentation.Pass()) {}
83 FakeCompositorTimingHistory::~FakeCompositorTimingHistory() {
86 void FakeCompositorTimingHistory::SetAllEstimatesTo(base::TimeDelta duration) {
87 begin_main_frame_to_commit_duration_ = duration;
88 commit_to_ready_to_activate_duration_ = duration;
89 prepare_tiles_duration_ = duration;
90 activate_duration_ = duration;
91 draw_duration_ = duration;
94 void FakeCompositorTimingHistory::SetBeginMainFrameToCommitDurationEstimate(
95 base::TimeDelta duration) {
96 begin_main_frame_to_commit_duration_ = duration;
99 void FakeCompositorTimingHistory::SetCommitToReadyToActivateDurationEstimate(
100 base::TimeDelta duration) {
101 commit_to_ready_to_activate_duration_ = duration;
104 void FakeCompositorTimingHistory::SetPrepareTilesDurationEstimate(
105 base::TimeDelta duration) {
106 prepare_tiles_duration_ = duration;
109 void FakeCompositorTimingHistory::SetActivateDurationEstimate(
110 base::TimeDelta duration) {
111 activate_duration_ = duration;
114 void FakeCompositorTimingHistory::SetDrawDurationEstimate(
115 base::TimeDelta duration) {
116 draw_duration_ = duration;
119 base::TimeDelta
120 FakeCompositorTimingHistory::BeginMainFrameToCommitDurationEstimate() const {
121 return begin_main_frame_to_commit_duration_;
124 base::TimeDelta
125 FakeCompositorTimingHistory::CommitToReadyToActivateDurationEstimate() const {
126 return commit_to_ready_to_activate_duration_;
129 base::TimeDelta FakeCompositorTimingHistory::PrepareTilesDurationEstimate()
130 const {
131 return prepare_tiles_duration_;
134 base::TimeDelta FakeCompositorTimingHistory::ActivateDurationEstimate() const {
135 return activate_duration_;
138 base::TimeDelta FakeCompositorTimingHistory::DrawDurationEstimate() const {
139 return draw_duration_;
142 scoped_ptr<TestScheduler> TestScheduler::Create(
143 base::SimpleTestTickClock* now_src,
144 SchedulerClient* client,
145 const SchedulerSettings& settings,
146 int layer_tree_host_id,
147 OrderedSimpleTaskRunner* task_runner,
148 BeginFrameSource* external_frame_source,
149 scoped_ptr<CompositorTimingHistory> compositor_timing_history) {
150 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source;
151 if (!settings.use_external_begin_frame_source) {
152 synthetic_frame_source = TestSyntheticBeginFrameSource::Create(
153 now_src, task_runner, BeginFrameArgs::DefaultInterval());
155 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source =
156 TestBackToBackBeginFrameSource::Create(now_src, task_runner);
157 return make_scoped_ptr(new TestScheduler(
158 now_src, client, settings, layer_tree_host_id, task_runner,
159 external_frame_source, synthetic_frame_source.Pass(),
160 unthrottled_frame_source.Pass(), compositor_timing_history.Pass()));
163 TestScheduler::TestScheduler(
164 base::SimpleTestTickClock* now_src,
165 SchedulerClient* client,
166 const SchedulerSettings& scheduler_settings,
167 int layer_tree_host_id,
168 OrderedSimpleTaskRunner* task_runner,
169 BeginFrameSource* external_frame_source,
170 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source,
171 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source,
172 scoped_ptr<CompositorTimingHistory> compositor_timing_history)
173 : Scheduler(client,
174 scheduler_settings,
175 layer_tree_host_id,
176 task_runner,
177 external_frame_source,
178 synthetic_frame_source.Pass(),
179 unthrottled_frame_source.Pass(),
180 compositor_timing_history.Pass()),
181 now_src_(now_src) {
184 base::TimeTicks TestScheduler::Now() const {
185 return now_src_->NowTicks();
188 TestScheduler::~TestScheduler() {
191 } // namespace cc