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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 class TestScheduler : public Scheduler { | 121 class TestScheduler : public Scheduler { |
122 public: | 122 public: |
123 TestScheduler( | 123 TestScheduler( |
124 base::SimpleTestTickClock* now_src, | 124 base::SimpleTestTickClock* now_src, |
125 SchedulerClient* client, | 125 SchedulerClient* client, |
126 const SchedulerSettings& scheduler_settings, | 126 const SchedulerSettings& scheduler_settings, |
127 int layer_tree_host_id, | 127 int layer_tree_host_id, |
128 OrderedSimpleTaskRunner* task_runner, | 128 OrderedSimpleTaskRunner* task_runner, |
129 std::unique_ptr<CompositorTimingHistory> compositor_timing_history); | 129 std::unique_ptr<CompositorTimingHistory> compositor_timing_history); |
130 | 130 |
131 // Extra test helper functionality | |
132 bool IsBeginRetroFrameArgsEmpty() const { | |
133 return begin_retro_frame_args_.empty(); | |
134 } | |
135 | |
136 bool SwapThrottled() const { return state_machine_.SwapThrottled(); } | 131 bool SwapThrottled() const { return state_machine_.SwapThrottled(); } |
137 | 132 |
138 bool NeedsBeginMainFrame() const { | 133 bool NeedsBeginMainFrame() const { |
139 return state_machine_.needs_begin_main_frame(); | 134 return state_machine_.needs_begin_main_frame(); |
140 } | 135 } |
141 | 136 |
142 BeginFrameSource& frame_source() { return *begin_frame_source_; } | 137 BeginFrameSource& frame_source() { return *begin_frame_source_; } |
143 | 138 |
144 bool MainThreadMissedLastDeadline() const { | 139 bool MainThreadMissedLastDeadline() const { |
145 return state_machine_.main_thread_missed_last_deadline(); | 140 return state_machine_.main_thread_missed_last_deadline(); |
146 } | 141 } |
147 | 142 |
148 bool begin_frames_expected() const { | 143 bool begin_frames_expected() const { |
149 return begin_frame_source_ && observing_begin_frame_source_; | 144 return begin_frame_source_ && observing_begin_frame_source_; |
150 } | 145 } |
151 | 146 |
| 147 int current_frame_number() const { |
| 148 return state_machine_.current_frame_number(); |
| 149 } |
| 150 |
152 ~TestScheduler() override; | 151 ~TestScheduler() override; |
153 | 152 |
154 base::TimeDelta BeginImplFrameInterval() { | 153 base::TimeDelta BeginImplFrameInterval() { |
155 return begin_impl_frame_tracker_.Interval(); | 154 return begin_impl_frame_tracker_.Interval(); |
156 } | 155 } |
157 | 156 |
158 // Note: This setting will be overriden on the next BeginFrame in the | 157 // Note: This setting will be overriden on the next BeginFrame in the |
159 // scheduler. To control the value it gets on the next BeginFrame | 158 // scheduler. To control the value it gets on the next BeginFrame |
160 // Pass in a fake CompositorTimingHistory that indicates BeginMainFrame | 159 // Pass in a fake CompositorTimingHistory that indicates BeginMainFrame |
161 // to Activation is fast. | 160 // to Activation is fast. |
162 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast) { | 161 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast) { |
163 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(is_fast); | 162 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(is_fast); |
164 } | 163 } |
165 | 164 |
166 protected: | 165 protected: |
167 // Overridden from Scheduler. | 166 // Overridden from Scheduler. |
168 base::TimeTicks Now() const override; | 167 base::TimeTicks Now() const override; |
169 | 168 |
170 private: | 169 private: |
171 base::SimpleTestTickClock* now_src_; | 170 base::SimpleTestTickClock* now_src_; |
172 | 171 |
173 DISALLOW_COPY_AND_ASSIGN(TestScheduler); | 172 DISALLOW_COPY_AND_ASSIGN(TestScheduler); |
174 }; | 173 }; |
175 | 174 |
176 } // namespace cc | 175 } // namespace cc |
177 | 176 |
178 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 177 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
OLD | NEW |