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 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 protected: | 34 protected: |
35 bool tick_called_; | 35 bool tick_called_; |
36 | 36 |
37 private: | 37 private: |
38 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSourceClient); | 38 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSourceClient); |
39 }; | 39 }; |
40 | 40 |
41 class FakeDelayBasedTimeSource : public DelayBasedTimeSource { | 41 class FakeDelayBasedTimeSource : public DelayBasedTimeSource { |
42 public: | 42 public: |
43 static std::unique_ptr<FakeDelayBasedTimeSource> Create( | 43 explicit FakeDelayBasedTimeSource(base::SingleThreadTaskRunner* task_runner) |
44 base::TimeDelta interval, | 44 : DelayBasedTimeSource(task_runner) {} |
45 base::SingleThreadTaskRunner* task_runner) { | |
46 return base::WrapUnique( | |
47 new FakeDelayBasedTimeSource(interval, task_runner)); | |
48 } | |
49 | |
50 ~FakeDelayBasedTimeSource() override {} | 45 ~FakeDelayBasedTimeSource() override {} |
51 | 46 |
52 void SetNow(base::TimeTicks time) { now_ = time; } | 47 void SetNow(base::TimeTicks time) { now_ = time; } |
53 base::TimeTicks Now() const override; | 48 base::TimeTicks Now() const override; |
54 | 49 |
55 protected: | 50 protected: |
56 FakeDelayBasedTimeSource(base::TimeDelta interval, | |
57 base::SingleThreadTaskRunner* task_runner) | |
58 : DelayBasedTimeSource(interval, task_runner) {} | |
59 | |
60 base::TimeTicks now_; | 51 base::TimeTicks now_; |
61 | 52 |
62 private: | 53 private: |
63 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSource); | 54 DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSource); |
64 }; | 55 }; |
65 | 56 |
66 class TestDelayBasedTimeSource : public DelayBasedTimeSource { | 57 class TestDelayBasedTimeSource : public DelayBasedTimeSource { |
67 public: | 58 public: |
68 static std::unique_ptr<TestDelayBasedTimeSource> Create( | 59 TestDelayBasedTimeSource(base::SimpleTestTickClock* now_src, |
69 base::SimpleTestTickClock* now_src, | 60 OrderedSimpleTaskRunner* task_runner); |
70 base::TimeDelta interval, | |
71 OrderedSimpleTaskRunner* task_runner) { | |
72 return base::WrapUnique( | |
73 new TestDelayBasedTimeSource(now_src, interval, task_runner)); | |
74 } | |
75 | |
76 ~TestDelayBasedTimeSource() override; | 61 ~TestDelayBasedTimeSource() override; |
77 | 62 |
78 protected: | 63 protected: |
79 TestDelayBasedTimeSource(base::SimpleTestTickClock* now_src, | |
80 base::TimeDelta interval, | |
81 OrderedSimpleTaskRunner* task_runner); | |
82 | |
83 // Overridden from DelayBasedTimeSource | 64 // Overridden from DelayBasedTimeSource |
84 base::TimeTicks Now() const override; | 65 base::TimeTicks Now() const override; |
85 std::string TypeString() const override; | 66 std::string TypeString() const override; |
86 | 67 |
87 // Not owned. | 68 // Not owned. |
88 base::SimpleTestTickClock* now_src_; | 69 base::SimpleTestTickClock* now_src_; |
89 | 70 |
90 private: | 71 private: |
91 DISALLOW_COPY_AND_ASSIGN(TestDelayBasedTimeSource); | 72 DISALLOW_COPY_AND_ASSIGN(TestDelayBasedTimeSource); |
92 }; | 73 }; |
(...skipping 15 matching lines...) Expand all Loading... | |
108 } | 89 } |
109 | 90 |
110 bool has_observers() const { return !observers_.empty(); } | 91 bool has_observers() const { return !observers_.empty(); } |
111 | 92 |
112 using BeginFrameSourceBase::SetBeginFrameSourcePaused; | 93 using BeginFrameSourceBase::SetBeginFrameSourcePaused; |
113 | 94 |
114 private: | 95 private: |
115 DISALLOW_COPY_AND_ASSIGN(FakeBeginFrameSource); | 96 DISALLOW_COPY_AND_ASSIGN(FakeBeginFrameSource); |
116 }; | 97 }; |
117 | 98 |
118 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { | 99 class TestBackToBackBeginFrameSource : public BeginFrameSourceBase { |
enne (OOO)
2016/06/14 21:25:17
Why can't this be a BackToBackBeginFrameSource? It
danakj
2016/06/14 21:53:23
Oh, I did that first so I could ignore some tests.
danakj
2016/06/14 22:00:16
It is now deleted.
| |
119 public: | 100 public: |
120 TestBackToBackBeginFrameSource(base::SimpleTestTickClock* now_src, | 101 TestBackToBackBeginFrameSource(base::SimpleTestTickClock* now_src, |
121 base::SingleThreadTaskRunner* task_runner); | 102 base::SingleThreadTaskRunner* task_runner); |
122 ~TestBackToBackBeginFrameSource() override; | 103 ~TestBackToBackBeginFrameSource() override; |
123 | 104 |
124 protected: | 105 // BeginFrameSourceBase overrides. |
125 base::TimeTicks Now() override; | 106 void AddObserver(BeginFrameObserver* obs) override; |
126 // Not owned. | 107 void RemoveObserver(BeginFrameObserver* obs) override; |
127 base::SimpleTestTickClock* now_src_; | 108 void DidFinishFrame(BeginFrameObserver* obs, |
109 size_t remaining_frames) override; | |
128 | 110 |
129 private: | 111 private: |
112 base::TimeTicks Now(); | |
113 void PostPendingBeginFramesTask(); | |
114 void SendPendingBeginFrames(); | |
115 | |
116 base::SimpleTestTickClock* now_src_; | |
117 base::SingleThreadTaskRunner* task_runner_; | |
118 base::CancelableClosure begin_frame_task_; | |
119 std::set<BeginFrameObserver*> pending_begin_frame_observers_; | |
120 base::WeakPtrFactory<TestBackToBackBeginFrameSource> weak_factory_; | |
121 | |
130 DISALLOW_COPY_AND_ASSIGN(TestBackToBackBeginFrameSource); | 122 DISALLOW_COPY_AND_ASSIGN(TestBackToBackBeginFrameSource); |
131 }; | 123 }; |
132 | 124 |
133 class TestSyntheticBeginFrameSource : public SyntheticBeginFrameSource { | |
134 public: | |
135 explicit TestSyntheticBeginFrameSource(base::SimpleTestTickClock* now_src, | |
136 OrderedSimpleTaskRunner* task_runner, | |
137 base::TimeDelta initial_interval); | |
138 ~TestSyntheticBeginFrameSource() override; | |
139 | |
140 private: | |
141 DISALLOW_COPY_AND_ASSIGN(TestSyntheticBeginFrameSource); | |
142 }; | |
143 | |
144 class FakeCompositorTimingHistory : public CompositorTimingHistory { | 125 class FakeCompositorTimingHistory : public CompositorTimingHistory { |
145 public: | 126 public: |
146 static std::unique_ptr<FakeCompositorTimingHistory> Create( | 127 static std::unique_ptr<FakeCompositorTimingHistory> Create( |
147 bool using_synchronous_renderer_compositor); | 128 bool using_synchronous_renderer_compositor); |
148 ~FakeCompositorTimingHistory() override; | 129 ~FakeCompositorTimingHistory() override; |
149 | 130 |
150 void SetAllEstimatesTo(base::TimeDelta duration); | 131 void SetAllEstimatesTo(base::TimeDelta duration); |
151 | 132 |
152 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); | 133 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); |
153 void SetBeginMainFrameQueueDurationCriticalEstimate(base::TimeDelta duration); | 134 void SetBeginMainFrameQueueDurationCriticalEstimate(base::TimeDelta duration); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 | 223 |
243 private: | 224 private: |
244 base::SimpleTestTickClock* now_src_; | 225 base::SimpleTestTickClock* now_src_; |
245 | 226 |
246 DISALLOW_COPY_AND_ASSIGN(TestScheduler); | 227 DISALLOW_COPY_AND_ASSIGN(TestScheduler); |
247 }; | 228 }; |
248 | 229 |
249 } // namespace cc | 230 } // namespace cc |
250 | 231 |
251 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 232 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
OLD | NEW |