OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_ | 5 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_ |
6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_ | 6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "cc/scheduler/delay_based_time_source.h" | 13 #include "cc/scheduler/compositor_timing_history.h" |
14 #include "cc/scheduler/scheduler.h" | 14 #include "cc/scheduler/scheduler.h" |
15 #include "cc/test/ordered_simple_task_runner.h" | 15 #include "cc/test/ordered_simple_task_runner.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
| 20 class RenderingStatsInstrumentation; |
| 21 |
20 class FakeTimeSourceClient : public TimeSourceClient { | 22 class FakeTimeSourceClient : public TimeSourceClient { |
21 public: | 23 public: |
22 FakeTimeSourceClient() : tick_called_(false) {} | 24 FakeTimeSourceClient() : tick_called_(false) {} |
23 void Reset() { tick_called_ = false; } | 25 void Reset() { tick_called_ = false; } |
24 bool TickCalled() const { return tick_called_; } | 26 bool TickCalled() const { return tick_called_; } |
25 | 27 |
26 // TimeSourceClient implementation. | 28 // TimeSourceClient implementation. |
27 void OnTimerTick() override; | 29 void OnTimerTick() override; |
28 | 30 |
29 protected: | 31 protected: |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 154 } |
153 | 155 |
154 protected: | 156 protected: |
155 explicit TestSyntheticBeginFrameSource( | 157 explicit TestSyntheticBeginFrameSource( |
156 scoped_ptr<DelayBasedTimeSource> time_source); | 158 scoped_ptr<DelayBasedTimeSource> time_source); |
157 | 159 |
158 private: | 160 private: |
159 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource); | 161 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource); |
160 }; | 162 }; |
161 | 163 |
| 164 class FakeCompositorTimingHistory : public CompositorTimingHistory { |
| 165 public: |
| 166 static scoped_ptr<FakeCompositorTimingHistory> Create(); |
| 167 ~FakeCompositorTimingHistory() override; |
| 168 |
| 169 void SetDrawDurationEstimate(base::TimeDelta duration); |
| 170 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); |
| 171 void SetCommitToActivateDurationEstimate(base::TimeDelta duration); |
| 172 |
| 173 base::TimeDelta DrawDurationEstimate() const override; |
| 174 base::TimeDelta BeginMainFrameToCommitDurationEstimate() const override; |
| 175 base::TimeDelta CommitToActivateDurationEstimate() const override; |
| 176 |
| 177 protected: |
| 178 FakeCompositorTimingHistory(scoped_ptr<RenderingStatsInstrumentation> |
| 179 rendering_stats_instrumentation_owned); |
| 180 |
| 181 scoped_ptr<RenderingStatsInstrumentation> |
| 182 rendering_stats_instrumentation_owned_; |
| 183 |
| 184 base::TimeDelta draw_duration_; |
| 185 base::TimeDelta begin_main_frame_to_commit_duration_; |
| 186 base::TimeDelta commit_to_activate_duration_; |
| 187 |
| 188 private: |
| 189 DISALLOW_COPY_AND_ASSIGN(FakeCompositorTimingHistory); |
| 190 }; |
| 191 |
162 class TestScheduler : public Scheduler { | 192 class TestScheduler : public Scheduler { |
163 public: | 193 public: |
164 static scoped_ptr<TestScheduler> Create( | 194 static scoped_ptr<TestScheduler> Create( |
165 base::SimpleTestTickClock* now_src, | 195 base::SimpleTestTickClock* now_src, |
166 SchedulerClient* client, | 196 SchedulerClient* client, |
167 const SchedulerSettings& scheduler_settings, | 197 const SchedulerSettings& scheduler_settings, |
168 int layer_tree_host_id, | 198 int layer_tree_host_id, |
169 OrderedSimpleTaskRunner* task_runner, | 199 OrderedSimpleTaskRunner* task_runner, |
170 BeginFrameSource* external_frame_source); | 200 BeginFrameSource* external_frame_source, |
| 201 scoped_ptr<CompositorTimingHistory> compositor_timing_history); |
171 | 202 |
172 // Extra test helper functionality | 203 // Extra test helper functionality |
173 bool IsBeginRetroFrameArgsEmpty() const { | 204 bool IsBeginRetroFrameArgsEmpty() const { |
174 return begin_retro_frame_args_.empty(); | 205 return begin_retro_frame_args_.empty(); |
175 } | 206 } |
176 | 207 |
177 bool CanStart() const { return state_machine_.CanStartForTesting(); } | 208 bool CanStart() const { return state_machine_.CanStartForTesting(); } |
178 | 209 |
179 BeginFrameSource& frame_source() { return *frame_source_; } | 210 BeginFrameSource& frame_source() { return *frame_source_; } |
180 bool FrameProductionThrottled() { return throttle_frame_production_; } | 211 bool FrameProductionThrottled() { return throttle_frame_production_; } |
(...skipping 10 matching lines...) Expand all Loading... |
191 | 222 |
192 private: | 223 private: |
193 TestScheduler( | 224 TestScheduler( |
194 base::SimpleTestTickClock* now_src, | 225 base::SimpleTestTickClock* now_src, |
195 SchedulerClient* client, | 226 SchedulerClient* client, |
196 const SchedulerSettings& scheduler_settings, | 227 const SchedulerSettings& scheduler_settings, |
197 int layer_tree_host_id, | 228 int layer_tree_host_id, |
198 OrderedSimpleTaskRunner* task_runner, | 229 OrderedSimpleTaskRunner* task_runner, |
199 BeginFrameSource* external_frame_source, | 230 BeginFrameSource* external_frame_source, |
200 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source, | 231 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source, |
201 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source); | 232 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source, |
| 233 scoped_ptr<CompositorTimingHistory> compositor_timing_history); |
202 | 234 |
203 // Not owned. | |
204 base::SimpleTestTickClock* now_src_; | 235 base::SimpleTestTickClock* now_src_; |
205 | 236 |
206 DISALLOW_COPY_AND_ASSIGN(TestScheduler); | 237 DISALLOW_COPY_AND_ASSIGN(TestScheduler); |
207 }; | 238 }; |
208 | 239 |
209 } // namespace cc | 240 } // namespace cc |
210 | 241 |
211 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 242 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
OLD | NEW |