| 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/delay_based_time_source.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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 }; | 158 }; |
| 157 | 159 |
| 158 class TestScheduler : public Scheduler { | 160 class TestScheduler : public Scheduler { |
| 159 public: | 161 public: |
| 160 static scoped_ptr<TestScheduler> Create( | 162 static scoped_ptr<TestScheduler> Create( |
| 161 base::SimpleTestTickClock* now_src, | 163 base::SimpleTestTickClock* now_src, |
| 162 SchedulerClient* client, | 164 SchedulerClient* client, |
| 163 const SchedulerSettings& scheduler_settings, | 165 const SchedulerSettings& scheduler_settings, |
| 164 int layer_tree_host_id, | 166 int layer_tree_host_id, |
| 165 const scoped_refptr<OrderedSimpleTaskRunner>& task_runner, | 167 const scoped_refptr<OrderedSimpleTaskRunner>& task_runner, |
| 166 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 168 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 169 RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
| 167 TestSchedulerFrameSourcesConstructor frame_sources_constructor( | 170 TestSchedulerFrameSourcesConstructor frame_sources_constructor( |
| 168 task_runner.get(), now_src); | 171 task_runner.get(), now_src); |
| 169 return make_scoped_ptr(new TestScheduler( | 172 return make_scoped_ptr(new TestScheduler( |
| 170 now_src, | 173 now_src, client, scheduler_settings, layer_tree_host_id, task_runner, |
| 171 client, | 174 &frame_sources_constructor, external_begin_frame_source.Pass(), |
| 172 scheduler_settings, | 175 rendering_stats_instrumentation)); |
| 173 layer_tree_host_id, | |
| 174 task_runner, | |
| 175 &frame_sources_constructor, | |
| 176 external_begin_frame_source.Pass())); | |
| 177 } | 176 } |
| 178 | 177 |
| 179 // Extra test helper functionality | 178 // Extra test helper functionality |
| 180 bool IsBeginRetroFrameArgsEmpty() const { | 179 bool IsBeginRetroFrameArgsEmpty() const { |
| 181 return begin_retro_frame_args_.empty(); | 180 return begin_retro_frame_args_.empty(); |
| 182 } | 181 } |
| 183 | 182 |
| 184 bool CanStart() const { return state_machine_.CanStartForTesting(); } | 183 bool CanStart() const { return state_machine_.CanStartForTesting(); } |
| 185 | 184 |
| 186 BeginFrameSource& frame_source() { return *frame_source_; } | 185 BeginFrameSource& frame_source() { return *frame_source_; } |
| 187 bool FrameProductionThrottled() { return throttle_frame_production_; } | 186 bool FrameProductionThrottled() { return throttle_frame_production_; } |
| 188 | 187 |
| 189 ~TestScheduler() override; | 188 ~TestScheduler() override; |
| 190 | 189 |
| 191 base::TimeDelta BeginImplFrameInterval() { | 190 base::TimeDelta BeginImplFrameInterval() { |
| 192 return begin_impl_frame_tracker_.Interval(); | 191 return begin_impl_frame_tracker_.Interval(); |
| 193 } | 192 } |
| 194 | 193 |
| 194 void SetDrawDurationEstimate(base::TimeDelta duration); |
| 195 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); |
| 196 void SetCommitToActivateDurationEstimate(base::TimeDelta duration); |
| 197 |
| 198 base::TimeDelta DrawDurationEstimate() const override; |
| 199 base::TimeDelta BeginMainFrameToCommitDurationEstimate() const override; |
| 200 base::TimeDelta CommitToActivateDurationEstimate() const override; |
| 201 |
| 195 protected: | 202 protected: |
| 196 // Overridden from Scheduler. | 203 // Overridden from Scheduler. |
| 197 base::TimeTicks Now() const override; | 204 base::TimeTicks Now() const override; |
| 198 | 205 |
| 199 private: | 206 private: |
| 200 TestScheduler(base::SimpleTestTickClock* now_src, | 207 TestScheduler(base::SimpleTestTickClock* now_src, |
| 201 SchedulerClient* client, | 208 SchedulerClient* client, |
| 202 const SchedulerSettings& scheduler_settings, | 209 const SchedulerSettings& scheduler_settings, |
| 203 int layer_tree_host_id, | 210 int layer_tree_host_id, |
| 204 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner, | 211 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner, |
| 205 TestSchedulerFrameSourcesConstructor* frame_sources_constructor, | 212 TestSchedulerFrameSourcesConstructor* frame_sources_constructor, |
| 206 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 213 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 214 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
| 207 | 215 |
| 208 // Not owned. | 216 // Not owned. |
| 209 base::SimpleTestTickClock* now_src_; | 217 base::SimpleTestTickClock* now_src_; |
| 218 |
| 219 base::TimeDelta draw_duration_; |
| 220 base::TimeDelta begin_main_frame_to_commit_duration_; |
| 221 base::TimeDelta commit_to_activate_duration_; |
| 210 }; | 222 }; |
| 211 | 223 |
| 212 } // namespace cc | 224 } // namespace cc |
| 213 | 225 |
| 214 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 226 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
| OLD | NEW |