Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: cc/test/scheduler_test_common.h

Issue 1132753008: Replaced TestNowSource with SimpleTestTickClock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased again. Replaces TimeSource with TickClock in TestAlwaysFailTimeSource Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 base::SingleThreadTaskRunner* task_runner) 46 base::SingleThreadTaskRunner* task_runner)
47 : DelayBasedTimeSource(interval, task_runner) {} 47 : DelayBasedTimeSource(interval, task_runner) {}
48 ~FakeDelayBasedTimeSource() override {} 48 ~FakeDelayBasedTimeSource() override {}
49 49
50 base::TimeTicks now_; 50 base::TimeTicks now_;
51 }; 51 };
52 52
53 class TestDelayBasedTimeSource : public DelayBasedTimeSource { 53 class TestDelayBasedTimeSource : public DelayBasedTimeSource {
54 public: 54 public:
55 static scoped_refptr<TestDelayBasedTimeSource> Create( 55 static scoped_refptr<TestDelayBasedTimeSource> Create(
56 scoped_refptr<TestNowSource> now_src, 56 base::SimpleTestTickClock* now_src,
57 base::TimeDelta interval, 57 base::TimeDelta interval,
58 OrderedSimpleTaskRunner* task_runner) { 58 OrderedSimpleTaskRunner* task_runner) {
59 return make_scoped_refptr( 59 return make_scoped_refptr(
60 new TestDelayBasedTimeSource(now_src, interval, task_runner)); 60 new TestDelayBasedTimeSource(now_src, interval, task_runner));
61 } 61 }
62 62
63 protected: 63 protected:
64 TestDelayBasedTimeSource(scoped_refptr<TestNowSource> now_src, 64 TestDelayBasedTimeSource(base::SimpleTestTickClock* now_src,
65 base::TimeDelta interval, 65 base::TimeDelta interval,
66 OrderedSimpleTaskRunner* task_runner); 66 OrderedSimpleTaskRunner* task_runner);
67 67
68 // Overridden from DelayBasedTimeSource 68 // Overridden from DelayBasedTimeSource
69 ~TestDelayBasedTimeSource() override; 69 ~TestDelayBasedTimeSource() override;
70 base::TimeTicks Now() const override; 70 base::TimeTicks Now() const override;
71 std::string TypeString() const override; 71 std::string TypeString() const override;
72 72
73 scoped_refptr<TestNowSource> now_src_; 73 base::SimpleTestTickClock* now_src_;
Sami 2015/06/05 17:11:07 In general it would be good to document ownership
Ankur Verma 2015/06/08 07:11:34 Done.
74 }; 74 };
75 75
76 struct FakeBeginFrameSource : public BeginFrameSourceMixIn { 76 struct FakeBeginFrameSource : public BeginFrameSourceMixIn {
77 bool remaining_frames_ = false; 77 bool remaining_frames_ = false;
78 78
79 BeginFrameObserver* GetObserver() { return observer_; } 79 BeginFrameObserver* GetObserver() { return observer_; }
80 80
81 BeginFrameArgs TestLastUsedBeginFrameArgs() { 81 BeginFrameArgs TestLastUsedBeginFrameArgs() {
82 if (observer_) { 82 if (observer_) {
83 return observer_->LastUsedBeginFrameArgs(); 83 return observer_->LastUsedBeginFrameArgs();
84 } 84 }
85 return BeginFrameArgs(); 85 return BeginFrameArgs();
86 } 86 }
87 void TestOnBeginFrame(const BeginFrameArgs& args) { 87 void TestOnBeginFrame(const BeginFrameArgs& args) {
88 return CallOnBeginFrame(args); 88 return CallOnBeginFrame(args);
89 } 89 }
90 90
91 // BeginFrameSource 91 // BeginFrameSource
92 void DidFinishFrame(size_t remaining_frames) override; 92 void DidFinishFrame(size_t remaining_frames) override;
93 void AsValueInto(base::trace_event::TracedValue* dict) const override; 93 void AsValueInto(base::trace_event::TracedValue* dict) const override;
94 94
95 ~FakeBeginFrameSource() override {} 95 ~FakeBeginFrameSource() override {}
96 }; 96 };
97 97
98 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { 98 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource {
99 public: 99 public:
100 ~TestBackToBackBeginFrameSource() override; 100 ~TestBackToBackBeginFrameSource() override;
101 101
102 static scoped_ptr<TestBackToBackBeginFrameSource> Create( 102 static scoped_ptr<TestBackToBackBeginFrameSource> Create(
103 scoped_refptr<TestNowSource> now_src, 103 base::SimpleTestTickClock* now_src,
104 base::SingleThreadTaskRunner* task_runner) { 104 base::SingleThreadTaskRunner* task_runner) {
105 return make_scoped_ptr( 105 return make_scoped_ptr(
106 new TestBackToBackBeginFrameSource(now_src, task_runner)); 106 new TestBackToBackBeginFrameSource(now_src, task_runner));
107 } 107 }
108 108
109 protected: 109 protected:
110 TestBackToBackBeginFrameSource(scoped_refptr<TestNowSource> now_src, 110 TestBackToBackBeginFrameSource(base::SimpleTestTickClock* now_src,
111 base::SingleThreadTaskRunner* task_runner); 111 base::SingleThreadTaskRunner* task_runner);
112 112
113 base::TimeTicks Now() override; 113 base::TimeTicks Now() override;
114 114
115 scoped_refptr<TestNowSource> now_src_; 115 base::SimpleTestTickClock* now_src_;
116 }; 116 };
117 117
118 class TestSyntheticBeginFrameSource : public SyntheticBeginFrameSource { 118 class TestSyntheticBeginFrameSource : public SyntheticBeginFrameSource {
119 public: 119 public:
120 ~TestSyntheticBeginFrameSource() override; 120 ~TestSyntheticBeginFrameSource() override;
121 121
122 static scoped_ptr<TestSyntheticBeginFrameSource> Create( 122 static scoped_ptr<TestSyntheticBeginFrameSource> Create(
123 scoped_refptr<TestNowSource> now_src, 123 base::SimpleTestTickClock* now_src,
124 OrderedSimpleTaskRunner* task_runner, 124 OrderedSimpleTaskRunner* task_runner,
125 base::TimeDelta initial_interval) { 125 base::TimeDelta initial_interval) {
126 return make_scoped_ptr( 126 return make_scoped_ptr(
127 new TestSyntheticBeginFrameSource(TestDelayBasedTimeSource::Create( 127 new TestSyntheticBeginFrameSource(TestDelayBasedTimeSource::Create(
128 now_src, initial_interval, task_runner))); 128 now_src, initial_interval, task_runner)));
129 } 129 }
130 130
131 protected: 131 protected:
132 TestSyntheticBeginFrameSource( 132 TestSyntheticBeginFrameSource(
133 scoped_refptr<DelayBasedTimeSource> time_source); 133 scoped_refptr<DelayBasedTimeSource> time_source);
134 }; 134 };
135 135
136 class TestScheduler; 136 class TestScheduler;
137 class TestSchedulerFrameSourcesConstructor 137 class TestSchedulerFrameSourcesConstructor
138 : public SchedulerFrameSourcesConstructor { 138 : public SchedulerFrameSourcesConstructor {
139 public: 139 public:
140 ~TestSchedulerFrameSourcesConstructor() override; 140 ~TestSchedulerFrameSourcesConstructor() override;
141 141
142 protected: 142 protected:
143 BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler) override; 143 BeginFrameSource* ConstructPrimaryFrameSource(Scheduler* scheduler) override;
144 BeginFrameSource* ConstructUnthrottledFrameSource( 144 BeginFrameSource* ConstructUnthrottledFrameSource(
145 Scheduler* scheduler) override; 145 Scheduler* scheduler) override;
146 146
147 OrderedSimpleTaskRunner* test_task_runner_; 147 OrderedSimpleTaskRunner* test_task_runner_;
148 TestNowSource* now_src_; 148 base::SimpleTestTickClock* now_src_;
149 149
150 protected: 150 protected:
151 explicit TestSchedulerFrameSourcesConstructor( 151 explicit TestSchedulerFrameSourcesConstructor(
152 OrderedSimpleTaskRunner* test_task_runner, 152 OrderedSimpleTaskRunner* test_task_runner,
153 TestNowSource* now_src); 153 base::SimpleTestTickClock* now_src);
154 friend class TestScheduler; 154 friend class TestScheduler;
155 }; 155 };
156 156
157 class TestScheduler : public Scheduler { 157 class TestScheduler : public Scheduler {
158 public: 158 public:
159 static scoped_ptr<TestScheduler> Create( 159 static scoped_ptr<TestScheduler> Create(
160 scoped_refptr<TestNowSource> now_src, 160 base::SimpleTestTickClock* now_src,
161 SchedulerClient* client, 161 SchedulerClient* client,
162 const SchedulerSettings& scheduler_settings, 162 const SchedulerSettings& scheduler_settings,
163 int layer_tree_host_id, 163 int layer_tree_host_id,
164 const scoped_refptr<OrderedSimpleTaskRunner>& task_runner, 164 const scoped_refptr<OrderedSimpleTaskRunner>& task_runner,
165 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 165 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
166 TestSchedulerFrameSourcesConstructor frame_sources_constructor( 166 TestSchedulerFrameSourcesConstructor frame_sources_constructor(
167 task_runner.get(), now_src.get()); 167 task_runner.get(), now_src);
168 return make_scoped_ptr(new TestScheduler( 168 return make_scoped_ptr(new TestScheduler(
169 now_src, 169 now_src,
170 client, 170 client,
171 scheduler_settings, 171 scheduler_settings,
172 layer_tree_host_id, 172 layer_tree_host_id,
173 task_runner, 173 task_runner,
174 &frame_sources_constructor, 174 &frame_sources_constructor,
175 external_begin_frame_source.Pass())); 175 external_begin_frame_source.Pass()));
176 } 176 }
177 177
(...skipping 18 matching lines...) Expand all
196 196
197 base::TimeDelta BeginImplFrameInterval() { 197 base::TimeDelta BeginImplFrameInterval() {
198 return begin_impl_frame_tracker_.Interval(); 198 return begin_impl_frame_tracker_.Interval();
199 } 199 }
200 200
201 protected: 201 protected:
202 // Overridden from Scheduler. 202 // Overridden from Scheduler.
203 base::TimeTicks Now() const override; 203 base::TimeTicks Now() const override;
204 204
205 private: 205 private:
206 TestScheduler( 206 TestScheduler(base::SimpleTestTickClock* now_src,
207 scoped_refptr<TestNowSource> now_src, 207 SchedulerClient* client,
208 SchedulerClient* client, 208 const SchedulerSettings& scheduler_settings,
209 const SchedulerSettings& scheduler_settings, 209 int layer_tree_host_id,
210 int layer_tree_host_id, 210 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner,
211 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner, 211 TestSchedulerFrameSourcesConstructor* frame_sources_constructor,
212 TestSchedulerFrameSourcesConstructor* frame_sources_constructor, 212 scoped_ptr<BeginFrameSource> external_begin_frame_source);
213 scoped_ptr<BeginFrameSource> external_begin_frame_source);
214 213
215 scoped_refptr<TestNowSource> now_src_; 214 base::SimpleTestTickClock* now_src_;
216 }; 215 };
217 216
218 } // namespace cc 217 } // namespace cc
219 218
220 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ 219 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698