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

Side by Side Diff: trunk/src/cc/scheduler/scheduler_unittest.cc

Issue 17204002: Revert 206020 "cc: Emulate BeginFrame in OutputSurfaces that don..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | Annotate | Revision Log
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 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 12 matching lines...) Expand all
23 } while (false) 23 } while (false)
24 24
25 #define EXPECT_SINGLE_ACTION(action, client) \ 25 #define EXPECT_SINGLE_ACTION(action, client) \
26 EXPECT_ACTION(action, client, 0, 1) 26 EXPECT_ACTION(action, client, 0, 1)
27 27
28 namespace cc { 28 namespace cc {
29 namespace { 29 namespace {
30 30
31 class FakeSchedulerClient : public SchedulerClient { 31 class FakeSchedulerClient : public SchedulerClient {
32 public: 32 public:
33 FakeSchedulerClient() 33 FakeSchedulerClient() { Reset(); }
34 : needs_begin_frame_(false) {
35 Reset();
36 }
37
38 void Reset() { 34 void Reset() {
39 actions_.clear(); 35 actions_.clear();
40 states_.clear(); 36 states_.clear();
41 draw_will_happen_ = true; 37 draw_will_happen_ = true;
42 swap_will_happen_if_draw_happens_ = true; 38 swap_will_happen_if_draw_happens_ = true;
43 num_draws_ = 0; 39 num_draws_ = 0;
44 } 40 }
45 41
46 Scheduler* CreateScheduler(const SchedulerSettings& settings) { 42 Scheduler* CreateScheduler(
47 scheduler_ = Scheduler::Create(this, settings); 43 scoped_ptr<FrameRateController> frame_rate_controller,
44 const SchedulerSettings& settings) {
45 scheduler_ =
46 Scheduler::Create(this, frame_rate_controller.Pass(), settings);
48 return scheduler_.get(); 47 return scheduler_.get();
49 } 48 }
50 49
51 bool needs_begin_frame() { return needs_begin_frame_; } 50
52 int num_draws() const { return num_draws_; } 51 int num_draws() const { return num_draws_; }
53 int num_actions_() const { return static_cast<int>(actions_.size()); } 52 int num_actions_() const { return static_cast<int>(actions_.size()); }
54 const char* Action(int i) const { return actions_[i]; } 53 const char* Action(int i) const { return actions_[i]; }
55 std::string StateForAction(int i) const { return states_[i]; } 54 std::string StateForAction(int i) const { return states_[i]; }
56 55
57 bool HasAction(const char* action) const { 56 bool HasAction(const char* action) const {
58 for (size_t i = 0; i < actions_.size(); i++) 57 for (size_t i = 0; i < actions_.size(); i++)
59 if (!strcmp(actions_[i], action)) 58 if (!strcmp(actions_[i], action))
60 return true; 59 return true;
61 return false; 60 return false;
62 } 61 }
63 62
64 void SetDrawWillHappen(bool draw_will_happen) { 63 void SetDrawWillHappen(bool draw_will_happen) {
65 draw_will_happen_ = draw_will_happen; 64 draw_will_happen_ = draw_will_happen;
66 } 65 }
67 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) { 66 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) {
68 swap_will_happen_if_draw_happens_ = swap_will_happen_if_draw_happens; 67 swap_will_happen_if_draw_happens_ = swap_will_happen_if_draw_happens;
69 } 68 }
70 69
71 // Scheduler Implementation. 70 // Scheduler Implementation.
72 virtual void SetNeedsBeginFrameOnImplThread(bool enable) OVERRIDE {
73 actions_.push_back("SetNeedsBeginFrameOnImplThread");
74 states_.push_back(scheduler_->StateAsStringForTesting());
75 needs_begin_frame_ = enable;
76 }
77 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE { 71 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {
78 actions_.push_back("ScheduledActionSendBeginFrameToMainThread"); 72 actions_.push_back("ScheduledActionSendBeginFrameToMainThread");
79 states_.push_back(scheduler_->StateAsStringForTesting()); 73 states_.push_back(scheduler_->StateAsStringForTesting());
80 } 74 }
81 virtual ScheduledActionDrawAndSwapResult 75 virtual ScheduledActionDrawAndSwapResult
82 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { 76 ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
83 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); 77 actions_.push_back("ScheduledActionDrawAndSwapIfPossible");
84 states_.push_back(scheduler_->StateAsStringForTesting()); 78 states_.push_back(scheduler_->StateAsStringForTesting());
85 num_draws_++; 79 num_draws_++;
86 return ScheduledActionDrawAndSwapResult(draw_will_happen_, 80 return ScheduledActionDrawAndSwapResult(draw_will_happen_,
(...skipping 26 matching lines...) Expand all
113 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE { 107 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE {
114 actions_.push_back("ScheduledActionAcquireLayerTexturesForMainThread"); 108 actions_.push_back("ScheduledActionAcquireLayerTexturesForMainThread");
115 states_.push_back(scheduler_->StateAsStringForTesting()); 109 states_.push_back(scheduler_->StateAsStringForTesting());
116 } 110 }
117 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} 111 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}
118 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE { 112 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE {
119 return base::TimeDelta(); 113 return base::TimeDelta();
120 } 114 }
121 115
122 protected: 116 protected:
123 bool needs_begin_frame_;
124 bool draw_will_happen_; 117 bool draw_will_happen_;
125 bool swap_will_happen_if_draw_happens_; 118 bool swap_will_happen_if_draw_happens_;
126 int num_draws_; 119 int num_draws_;
127 std::vector<const char*> actions_; 120 std::vector<const char*> actions_;
128 std::vector<std::string> states_; 121 std::vector<std::string> states_;
129 scoped_ptr<Scheduler> scheduler_; 122 scoped_ptr<Scheduler> scheduler_;
130 }; 123 };
131 124
132 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginFrame) { 125 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginFrame) {
133 FakeSchedulerClient client; 126 FakeSchedulerClient client;
127 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
134 SchedulerSettings default_scheduler_settings; 128 SchedulerSettings default_scheduler_settings;
135 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 129 Scheduler* scheduler = client.CreateScheduler(
130 make_scoped_ptr(new FrameRateController(time_source)),
131 default_scheduler_settings);
136 scheduler->SetCanStart(); 132 scheduler->SetCanStart();
137 scheduler->SetVisible(true); 133 scheduler->SetVisible(true);
138 scheduler->SetCanDraw(true); 134 scheduler->SetCanDraw(true);
139 135
140 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 136 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
141 client.Reset(); 137 client.Reset();
142 scheduler->DidCreateAndInitializeOutputSurface(); 138 scheduler->DidCreateAndInitializeOutputSurface();
143 EXPECT_EQ(0, client.num_actions_()); 139 EXPECT_EQ(0, client.num_actions_());
144 } 140 }
145 141
146 TEST(SchedulerTest, RequestCommit) { 142 TEST(SchedulerTest, RequestCommit) {
147 FakeSchedulerClient client; 143 FakeSchedulerClient client;
144 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
148 SchedulerSettings default_scheduler_settings; 145 SchedulerSettings default_scheduler_settings;
149 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 146 Scheduler* scheduler = client.CreateScheduler(
147 make_scoped_ptr(new FrameRateController(time_source)),
148 default_scheduler_settings);
150 scheduler->SetCanStart(); 149 scheduler->SetCanStart();
151 scheduler->SetVisible(true); 150 scheduler->SetVisible(true);
152 scheduler->SetCanDraw(true); 151 scheduler->SetCanDraw(true);
153 152
154 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 153 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
155 client.Reset(); 154 client.Reset();
156 scheduler->DidCreateAndInitializeOutputSurface(); 155 scheduler->DidCreateAndInitializeOutputSurface();
157 156
158 // SetNeedsCommit should begin the frame. 157 // SetNeedsCommit should begin the frame.
159 scheduler->SetNeedsCommit(); 158 scheduler->SetNeedsCommit();
160 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2); 159 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client);
161 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2); 160 EXPECT_FALSE(time_source->Active());
162 EXPECT_TRUE(client.needs_begin_frame());
163 client.Reset(); 161 client.Reset();
164 162
165 // FinishCommit should commit 163 // FinishCommit should commit
166 scheduler->FinishCommit(); 164 scheduler->FinishCommit();
167 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 165 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
168 EXPECT_TRUE(client.needs_begin_frame()); 166 EXPECT_TRUE(time_source->Active());
169 client.Reset(); 167 client.Reset();
170 168
171 // BeginFrame should draw. 169 // Tick should draw.
172 scheduler->BeginFrame(base::TimeTicks::Now()); 170 time_source->Tick();
173 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 171 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client);
174 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2); 172 EXPECT_FALSE(time_source->Active());
175 EXPECT_FALSE(client.needs_begin_frame());
176 client.Reset(); 173 client.Reset();
174
175 // Timer should be off.
176 EXPECT_FALSE(time_source->Active());
177 } 177 }
178 178
179 TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) { 179 TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) {
180 FakeSchedulerClient client; 180 FakeSchedulerClient client;
181 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
181 SchedulerSettings default_scheduler_settings; 182 SchedulerSettings default_scheduler_settings;
182 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 183 Scheduler* scheduler = client.CreateScheduler(
184 make_scoped_ptr(new FrameRateController(time_source)),
185 default_scheduler_settings);
183 scheduler->SetCanStart(); 186 scheduler->SetCanStart();
184 scheduler->SetVisible(true); 187 scheduler->SetVisible(true);
185 scheduler->SetCanDraw(true); 188 scheduler->SetCanDraw(true);
186 189
187 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 190 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
188 client.Reset(); 191 client.Reset();
189 scheduler->DidCreateAndInitializeOutputSurface(); 192 scheduler->DidCreateAndInitializeOutputSurface();
190 193
191 // SetNedsCommit should begin the frame. 194 // SetNedsCommit should begin the frame.
192 scheduler->SetNeedsCommit(); 195 scheduler->SetNeedsCommit();
193 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2); 196 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client);
194 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
195 client.Reset(); 197 client.Reset();
196 198
197 // Now SetNeedsCommit again. Calling here means we need a second frame. 199 // Now SetNeedsCommit again. Calling here means we need a second frame.
198 scheduler->SetNeedsCommit(); 200 scheduler->SetNeedsCommit();
199 201
200 // Since another commit is needed, FinishCommit should commit, 202 // Since another commit is needed, FinishCommit should commit,
201 // then begin another frame. 203 // then begin another frame.
202 scheduler->FinishCommit(); 204 scheduler->FinishCommit();
203 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 205 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
204 client.Reset(); 206 client.Reset();
205 207
206 // Tick should draw but then begin another frame. 208 // Tick should draw but then begin another frame.
207 scheduler->BeginFrame(base::TimeTicks::Now()); 209 time_source->Tick();
208 EXPECT_TRUE(client.needs_begin_frame()); 210 EXPECT_FALSE(time_source->Active());
209 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 211 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
210 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2); 212 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2);
211 client.Reset(); 213 client.Reset();
212
213 // Go back to quiescent state and verify we no longer request BeginFrames.
214 scheduler->FinishCommit();
215 scheduler->BeginFrame(base::TimeTicks::Now());
216 EXPECT_FALSE(client.needs_begin_frame());
217 } 214 }
218 215
219 TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) { 216 TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) {
220 FakeSchedulerClient client; 217 FakeSchedulerClient client;
218 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
221 SchedulerSettings default_scheduler_settings; 219 SchedulerSettings default_scheduler_settings;
222 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 220 Scheduler* scheduler = client.CreateScheduler(
221 make_scoped_ptr(new FrameRateController(time_source)),
222 default_scheduler_settings);
223 scheduler->SetCanStart(); 223 scheduler->SetCanStart();
224 scheduler->SetVisible(true); 224 scheduler->SetVisible(true);
225 scheduler->SetCanDraw(true); 225 scheduler->SetCanDraw(true);
226
226 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 227 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
227
228 client.Reset(); 228 client.Reset();
229 scheduler->DidCreateAndInitializeOutputSurface(); 229 scheduler->DidCreateAndInitializeOutputSurface();
230
230 scheduler->SetNeedsRedraw(); 231 scheduler->SetNeedsRedraw();
231 EXPECT_TRUE(scheduler->RedrawPending()); 232 EXPECT_TRUE(scheduler->RedrawPending());
232 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client); 233 EXPECT_TRUE(time_source->Active());
233 EXPECT_TRUE(client.needs_begin_frame());
234 234
235 time_source->Tick();
236 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
237 EXPECT_FALSE(scheduler->RedrawPending());
238 EXPECT_FALSE(time_source->Active());
235 client.Reset(); 239 client.Reset();
236 scheduler->BeginFrame(base::TimeTicks::Now());
237 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
238 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
239 EXPECT_FALSE(scheduler->RedrawPending());
240 EXPECT_FALSE(client.needs_begin_frame());
241 240
242 client.Reset();
243 scheduler->SetMainThreadNeedsLayerTextures(); 241 scheduler->SetMainThreadNeedsLayerTextures();
244 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 242 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
245 client, 243 client,
246 0, 244 0,
247 3); 245 2);
248 // A commit was started by SetMainThreadNeedsLayerTextures(). 246 // A commit was started by SetMainThreadNeedsLayerTextures().
249 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 3); 247 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2);
250 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 2, 3); 248 client.Reset();
251 249
252 // We should request a BeginFrame in anticipation of a draw.
253 client.Reset();
254 scheduler->SetNeedsRedraw(); 250 scheduler->SetNeedsRedraw();
255 EXPECT_TRUE(scheduler->RedrawPending()); 251 EXPECT_TRUE(scheduler->RedrawPending());
256 EXPECT_TRUE(client.needs_begin_frame()); 252 EXPECT_TRUE(time_source->Active());
257 253
258 // No draw happens since the textures are acquired by the main thread. 254 // No draw happens since the textures are acquired by the main thread.
255 time_source->Tick();
256 EXPECT_EQ(0, client.num_actions_());
257 EXPECT_TRUE(scheduler->RedrawPending());
258 EXPECT_TRUE(time_source->Active());
259
260 scheduler->FinishCommit();
261 EXPECT_ACTION("ScheduledActionCommit", client, 0, 1);
262 EXPECT_TRUE(scheduler->RedrawPending());
263 EXPECT_TRUE(time_source->Active());
259 client.Reset(); 264 client.Reset();
260 scheduler->BeginFrame(base::TimeTicks::Now());
261 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
262 EXPECT_TRUE(scheduler->RedrawPending());
263 EXPECT_TRUE(client.needs_begin_frame());
264
265 // Commit will release the texture.
266 client.Reset();
267 scheduler->FinishCommit();
268 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
269 EXPECT_TRUE(scheduler->RedrawPending());
270 EXPECT_TRUE(client.needs_begin_frame());
271 265
272 // Now we can draw again after the commit happens. 266 // Now we can draw again after the commit happens.
273 client.Reset(); 267 time_source->Tick();
274 scheduler->BeginFrame(base::TimeTicks::Now()); 268 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
275 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
276 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
277 EXPECT_FALSE(scheduler->RedrawPending()); 269 EXPECT_FALSE(scheduler->RedrawPending());
278 EXPECT_FALSE(client.needs_begin_frame()); 270 EXPECT_FALSE(time_source->Active());
279 client.Reset(); 271 client.Reset();
280 } 272 }
281 273
282 TEST(SchedulerTest, TextureAcquisitionCollision) { 274 TEST(SchedulerTest, TextureAcquisitionCollision) {
283 FakeSchedulerClient client; 275 FakeSchedulerClient client;
276 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
284 SchedulerSettings default_scheduler_settings; 277 SchedulerSettings default_scheduler_settings;
285 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 278 Scheduler* scheduler = client.CreateScheduler(
279 make_scoped_ptr(new FrameRateController(time_source)),
280 default_scheduler_settings);
286 scheduler->SetCanStart(); 281 scheduler->SetCanStart();
287 scheduler->SetVisible(true); 282 scheduler->SetVisible(true);
288 scheduler->SetCanDraw(true); 283 scheduler->SetCanDraw(true);
289 284
290 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 285 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
291 client.Reset(); 286 client.Reset();
292 scheduler->DidCreateAndInitializeOutputSurface(); 287 scheduler->DidCreateAndInitializeOutputSurface();
293 288
294 scheduler->SetNeedsCommit(); 289 scheduler->SetNeedsCommit();
295 scheduler->SetMainThreadNeedsLayerTextures(); 290 scheduler->SetMainThreadNeedsLayerTextures();
296 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 3); 291 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
297 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 3);
298 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 292 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
299 client, 293 client,
300 2, 294 1,
301 3); 295 2);
302 client.Reset(); 296 client.Reset();
303 297
304 // Although the compositor cannot draw because textures are locked by main 298 // Compositor not scheduled to draw because textures are locked by main thread
305 // thread, we continue requesting SetNeedsBeginFrame in anticipation of the 299 EXPECT_FALSE(time_source->Active());
306 // unlock.
307 EXPECT_TRUE(client.needs_begin_frame());
308 300
309 // Trigger the commit 301 // Trigger the commit
310 scheduler->FinishCommit(); 302 scheduler->FinishCommit();
311 EXPECT_TRUE(client.needs_begin_frame()); 303 EXPECT_TRUE(time_source->Active());
312 client.Reset(); 304 client.Reset();
313 305
314 // Between commit and draw, texture acquisition for main thread delayed, 306 // Between commit and draw, texture acquisition for main thread delayed,
315 // and main thread blocks. 307 // and main thread blocks.
316 scheduler->SetMainThreadNeedsLayerTextures(); 308 scheduler->SetMainThreadNeedsLayerTextures();
317 EXPECT_EQ(0, client.num_actions_()); 309 EXPECT_EQ(0, client.num_actions_());
318 client.Reset(); 310 client.Reset();
319 311
320 // Once compositor draw complete, the delayed texture acquisition fires. 312 // Once compositor draw complete, the delayed texture acquisition fires.
321 scheduler->BeginFrame(base::TimeTicks::Now()); 313 time_source->Tick();
322 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); 314 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3);
323 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 315 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
324 client, 316 client,
325 1, 317 1,
326 3); 318 3);
327 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 2, 3); 319 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 2, 3);
328 client.Reset(); 320 client.Reset();
329 } 321 }
330 322
331 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { 323 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
332 FakeSchedulerClient client; 324 FakeSchedulerClient client;
325 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
333 SchedulerSettings default_scheduler_settings; 326 SchedulerSettings default_scheduler_settings;
334 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 327 Scheduler* scheduler = client.CreateScheduler(
328 make_scoped_ptr(new FrameRateController(time_source)),
329 default_scheduler_settings);
335 scheduler->SetCanStart(); 330 scheduler->SetCanStart();
336 scheduler->SetVisible(true); 331 scheduler->SetVisible(true);
337 scheduler->SetCanDraw(true); 332 scheduler->SetCanDraw(true);
338 333
339 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 334 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
340 client.Reset(); 335 client.Reset();
341 scheduler->DidCreateAndInitializeOutputSurface(); 336 scheduler->DidCreateAndInitializeOutputSurface();
342 337
343 scheduler->SetNeedsCommit(); 338 scheduler->SetNeedsCommit();
344 scheduler->FinishCommit(); 339 scheduler->FinishCommit();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} 375 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {}
381 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} 376 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}
382 }; 377 };
383 378
384 // Tests for two different situations: 379 // Tests for two different situations:
385 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside 380 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside
386 // a ScheduledActionDrawAndSwap 381 // a ScheduledActionDrawAndSwap
387 // 2. the scheduler drawing twice inside a single tick 382 // 2. the scheduler drawing twice inside a single tick
388 TEST(SchedulerTest, RequestRedrawInsideDraw) { 383 TEST(SchedulerTest, RequestRedrawInsideDraw) {
389 SchedulerClientThatsetNeedsDrawInsideDraw client; 384 SchedulerClientThatsetNeedsDrawInsideDraw client;
385 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
390 SchedulerSettings default_scheduler_settings; 386 SchedulerSettings default_scheduler_settings;
391 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 387 Scheduler* scheduler = client.CreateScheduler(
388 make_scoped_ptr(new FrameRateController(time_source)),
389 default_scheduler_settings);
392 scheduler->SetCanStart(); 390 scheduler->SetCanStart();
393 scheduler->SetVisible(true); 391 scheduler->SetVisible(true);
394 scheduler->SetCanDraw(true); 392 scheduler->SetCanDraw(true);
395 scheduler->DidCreateAndInitializeOutputSurface(); 393 scheduler->DidCreateAndInitializeOutputSurface();
396 394
397 scheduler->SetNeedsRedraw(); 395 scheduler->SetNeedsRedraw();
398 EXPECT_TRUE(scheduler->RedrawPending()); 396 EXPECT_TRUE(scheduler->RedrawPending());
399 EXPECT_TRUE(client.needs_begin_frame()); 397 EXPECT_TRUE(time_source->Active());
400 EXPECT_EQ(0, client.num_draws()); 398 EXPECT_EQ(0, client.num_draws());
401 399
402 scheduler->BeginFrame(base::TimeTicks::Now()); 400 time_source->Tick();
403 EXPECT_EQ(1, client.num_draws()); 401 EXPECT_EQ(1, client.num_draws());
404 EXPECT_TRUE(scheduler->RedrawPending()); 402 EXPECT_TRUE(scheduler->RedrawPending());
405 EXPECT_TRUE(client.needs_begin_frame()); 403 EXPECT_TRUE(time_source->Active());
406 404
407 scheduler->BeginFrame(base::TimeTicks::Now()); 405 time_source->Tick();
408 EXPECT_EQ(2, client.num_draws()); 406 EXPECT_EQ(2, client.num_draws());
409 EXPECT_FALSE(scheduler->RedrawPending()); 407 EXPECT_FALSE(scheduler->RedrawPending());
410 EXPECT_FALSE(client.needs_begin_frame()); 408 EXPECT_FALSE(time_source->Active());
411 } 409 }
412 410
413 // Test that requesting redraw inside a failed draw doesn't lose the request. 411 // Test that requesting redraw inside a failed draw doesn't lose the request.
414 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { 412 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) {
415 SchedulerClientThatsetNeedsDrawInsideDraw client; 413 SchedulerClientThatsetNeedsDrawInsideDraw client;
414 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
416 SchedulerSettings default_scheduler_settings; 415 SchedulerSettings default_scheduler_settings;
417 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 416 Scheduler* scheduler = client.CreateScheduler(
417 make_scoped_ptr(new FrameRateController(time_source)),
418 default_scheduler_settings);
418 scheduler->SetCanStart(); 419 scheduler->SetCanStart();
419 scheduler->SetVisible(true); 420 scheduler->SetVisible(true);
420 scheduler->SetCanDraw(true); 421 scheduler->SetCanDraw(true);
421 scheduler->DidCreateAndInitializeOutputSurface(); 422 scheduler->DidCreateAndInitializeOutputSurface();
422 423
423 client.SetDrawWillHappen(false); 424 client.SetDrawWillHappen(false);
424 425
425 scheduler->SetNeedsRedraw(); 426 scheduler->SetNeedsRedraw();
426 EXPECT_TRUE(scheduler->RedrawPending()); 427 EXPECT_TRUE(scheduler->RedrawPending());
427 EXPECT_TRUE(client.needs_begin_frame()); 428 EXPECT_TRUE(time_source->Active());
428 EXPECT_EQ(0, client.num_draws()); 429 EXPECT_EQ(0, client.num_draws());
429 430
430 // Fail the draw. 431 // Fail the draw.
431 scheduler->BeginFrame(base::TimeTicks::Now()); 432 time_source->Tick();
432 EXPECT_EQ(1, client.num_draws()); 433 EXPECT_EQ(1, client.num_draws());
433 434
434 // We have a commit pending and the draw failed, and we didn't lose the redraw 435 // We have a commit pending and the draw failed, and we didn't lose the redraw
435 // request. 436 // request.
436 EXPECT_TRUE(scheduler->CommitPending()); 437 EXPECT_TRUE(scheduler->CommitPending());
437 EXPECT_TRUE(scheduler->RedrawPending()); 438 EXPECT_TRUE(scheduler->RedrawPending());
438 EXPECT_TRUE(client.needs_begin_frame()); 439 EXPECT_TRUE(time_source->Active());
439 440
440 // Fail the draw again. 441 // Fail the draw again.
441 scheduler->BeginFrame(base::TimeTicks::Now()); 442 time_source->Tick();
442 EXPECT_EQ(2, client.num_draws()); 443 EXPECT_EQ(2, client.num_draws());
443 EXPECT_TRUE(scheduler->CommitPending()); 444 EXPECT_TRUE(scheduler->CommitPending());
444 EXPECT_TRUE(scheduler->RedrawPending()); 445 EXPECT_TRUE(scheduler->RedrawPending());
445 EXPECT_TRUE(client.needs_begin_frame()); 446 EXPECT_TRUE(time_source->Active());
446 447
447 // Draw successfully. 448 // Draw successfully.
448 client.SetDrawWillHappen(true); 449 client.SetDrawWillHappen(true);
449 scheduler->BeginFrame(base::TimeTicks::Now()); 450 time_source->Tick();
450 EXPECT_EQ(3, client.num_draws()); 451 EXPECT_EQ(3, client.num_draws());
451 EXPECT_TRUE(scheduler->CommitPending()); 452 EXPECT_TRUE(scheduler->CommitPending());
452 EXPECT_FALSE(scheduler->RedrawPending()); 453 EXPECT_FALSE(scheduler->RedrawPending());
453 EXPECT_TRUE(client.needs_begin_frame()); 454 EXPECT_FALSE(time_source->Active());
454 } 455 }
455 456
456 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { 457 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient {
457 public: 458 public:
458 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {} 459 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {}
459 virtual ScheduledActionDrawAndSwapResult 460 virtual ScheduledActionDrawAndSwapResult
460 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { 461 ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
461 // Only SetNeedsCommit the first time this is called 462 // Only SetNeedsCommit the first time this is called
462 if (!num_draws_) 463 if (!num_draws_)
463 scheduler_->SetNeedsCommit(); 464 scheduler_->SetNeedsCommit();
464 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 465 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
465 } 466 }
466 467
467 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() 468 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced()
468 OVERRIDE { 469 OVERRIDE {
469 NOTREACHED(); 470 NOTREACHED();
470 return ScheduledActionDrawAndSwapResult(true, true); 471 return ScheduledActionDrawAndSwapResult(true, true);
471 } 472 }
472 473
473 virtual void ScheduledActionCommit() OVERRIDE {} 474 virtual void ScheduledActionCommit() OVERRIDE {}
474 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} 475 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {}
475 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} 476 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}
476 }; 477 };
477 478
478 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that 479 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that
479 // happen inside a ScheduledActionDrawAndSwap 480 // happen inside a ScheduledActionDrawAndSwap
480 TEST(SchedulerTest, RequestCommitInsideDraw) { 481 TEST(SchedulerTest, RequestCommitInsideDraw) {
481 SchedulerClientThatsetNeedsCommitInsideDraw client; 482 SchedulerClientThatsetNeedsCommitInsideDraw client;
483 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
482 SchedulerSettings default_scheduler_settings; 484 SchedulerSettings default_scheduler_settings;
483 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 485 Scheduler* scheduler = client.CreateScheduler(
486 make_scoped_ptr(new FrameRateController(time_source)),
487 default_scheduler_settings);
484 scheduler->SetCanStart(); 488 scheduler->SetCanStart();
485 scheduler->SetVisible(true); 489 scheduler->SetVisible(true);
486 scheduler->SetCanDraw(true); 490 scheduler->SetCanDraw(true);
487 scheduler->DidCreateAndInitializeOutputSurface(); 491 scheduler->DidCreateAndInitializeOutputSurface();
488 492
489 scheduler->SetNeedsRedraw(); 493 scheduler->SetNeedsRedraw();
490 EXPECT_TRUE(scheduler->RedrawPending()); 494 EXPECT_TRUE(scheduler->RedrawPending());
491 EXPECT_EQ(0, client.num_draws()); 495 EXPECT_EQ(0, client.num_draws());
492 EXPECT_TRUE(client.needs_begin_frame()); 496 EXPECT_TRUE(time_source->Active());
493 497
494 scheduler->BeginFrame(base::TimeTicks::Now()); 498 time_source->Tick();
499 EXPECT_FALSE(time_source->Active());
495 EXPECT_EQ(1, client.num_draws()); 500 EXPECT_EQ(1, client.num_draws());
496 EXPECT_TRUE(scheduler->CommitPending()); 501 EXPECT_TRUE(scheduler->CommitPending());
497 EXPECT_TRUE(client.needs_begin_frame());
498 scheduler->FinishCommit(); 502 scheduler->FinishCommit();
499 503
500 scheduler->BeginFrame(base::TimeTicks::Now()); 504 time_source->Tick();
501 EXPECT_EQ(2, client.num_draws());; 505 EXPECT_EQ(2, client.num_draws());
506 EXPECT_FALSE(time_source->Active());
502 EXPECT_FALSE(scheduler->RedrawPending()); 507 EXPECT_FALSE(scheduler->RedrawPending());
503 EXPECT_FALSE(scheduler->CommitPending());
504 EXPECT_FALSE(client.needs_begin_frame());
505 } 508 }
506 509
507 // Tests that when a draw fails then the pending commit should not be dropped. 510 // Tests that when a draw fails then the pending commit should not be dropped.
508 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { 511 TEST(SchedulerTest, RequestCommitInsideFailedDraw) {
509 SchedulerClientThatsetNeedsDrawInsideDraw client; 512 SchedulerClientThatsetNeedsDrawInsideDraw client;
513 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
510 SchedulerSettings default_scheduler_settings; 514 SchedulerSettings default_scheduler_settings;
511 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 515 Scheduler* scheduler = client.CreateScheduler(
516 make_scoped_ptr(new FrameRateController(time_source)),
517 default_scheduler_settings);
512 scheduler->SetCanStart(); 518 scheduler->SetCanStart();
513 scheduler->SetVisible(true); 519 scheduler->SetVisible(true);
514 scheduler->SetCanDraw(true); 520 scheduler->SetCanDraw(true);
515 scheduler->DidCreateAndInitializeOutputSurface(); 521 scheduler->DidCreateAndInitializeOutputSurface();
516 522
517 client.SetDrawWillHappen(false); 523 client.SetDrawWillHappen(false);
518 524
519 scheduler->SetNeedsRedraw(); 525 scheduler->SetNeedsRedraw();
520 EXPECT_TRUE(scheduler->RedrawPending()); 526 EXPECT_TRUE(scheduler->RedrawPending());
521 EXPECT_TRUE(client.needs_begin_frame()); 527 EXPECT_TRUE(time_source->Active());
522 EXPECT_EQ(0, client.num_draws()); 528 EXPECT_EQ(0, client.num_draws());
523 529
524 // Fail the draw. 530 // Fail the draw.
525 scheduler->BeginFrame(base::TimeTicks::Now()); 531 time_source->Tick();
526 EXPECT_EQ(1, client.num_draws()); 532 EXPECT_EQ(1, client.num_draws());
527 533
528 // We have a commit pending and the draw failed, and we didn't lose the commit 534 // We have a commit pending and the draw failed, and we didn't lose the commit
529 // request. 535 // request.
530 EXPECT_TRUE(scheduler->CommitPending()); 536 EXPECT_TRUE(scheduler->CommitPending());
531 EXPECT_TRUE(scheduler->RedrawPending()); 537 EXPECT_TRUE(scheduler->RedrawPending());
532 EXPECT_TRUE(client.needs_begin_frame()); 538 EXPECT_TRUE(time_source->Active());
533 539
534 // Fail the draw again. 540 // Fail the draw again.
535 scheduler->BeginFrame(base::TimeTicks::Now()); 541 time_source->Tick();
536 EXPECT_EQ(2, client.num_draws()); 542 EXPECT_EQ(2, client.num_draws());
537 EXPECT_TRUE(scheduler->CommitPending()); 543 EXPECT_TRUE(scheduler->CommitPending());
538 EXPECT_TRUE(scheduler->RedrawPending()); 544 EXPECT_TRUE(scheduler->RedrawPending());
539 EXPECT_TRUE(client.needs_begin_frame()); 545 EXPECT_TRUE(time_source->Active());
540 546
541 // Draw successfully. 547 // Draw successfully.
542 client.SetDrawWillHappen(true); 548 client.SetDrawWillHappen(true);
543 scheduler->BeginFrame(base::TimeTicks::Now()); 549 time_source->Tick();
544 EXPECT_EQ(3, client.num_draws()); 550 EXPECT_EQ(3, client.num_draws());
545 EXPECT_TRUE(scheduler->CommitPending()); 551 EXPECT_TRUE(scheduler->CommitPending());
546 EXPECT_FALSE(scheduler->RedrawPending()); 552 EXPECT_FALSE(scheduler->RedrawPending());
547 EXPECT_TRUE(client.needs_begin_frame()); 553 EXPECT_FALSE(time_source->Active());
548 } 554 }
549 555
550 TEST(SchedulerTest, NoSwapWhenDrawFails) { 556 TEST(SchedulerTest, NoSwapWhenDrawFails) {
557 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
551 SchedulerClientThatsetNeedsCommitInsideDraw client; 558 SchedulerClientThatsetNeedsCommitInsideDraw client;
559 scoped_ptr<FakeFrameRateController> controller(
560 new FakeFrameRateController(time_source));
561 FakeFrameRateController* controller_ptr = controller.get();
552 SchedulerSettings default_scheduler_settings; 562 SchedulerSettings default_scheduler_settings;
553 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 563 Scheduler* scheduler = client.CreateScheduler(
564 controller.PassAs<FrameRateController>(),
565 default_scheduler_settings);
554 scheduler->SetCanStart(); 566 scheduler->SetCanStart();
555 scheduler->SetVisible(true); 567 scheduler->SetVisible(true);
556 scheduler->SetCanDraw(true); 568 scheduler->SetCanDraw(true);
557 scheduler->DidCreateAndInitializeOutputSurface(); 569 scheduler->DidCreateAndInitializeOutputSurface();
558 570
571 EXPECT_EQ(0, controller_ptr->NumFramesPending());
572
559 scheduler->SetNeedsRedraw(); 573 scheduler->SetNeedsRedraw();
560 EXPECT_TRUE(scheduler->RedrawPending()); 574 EXPECT_TRUE(scheduler->RedrawPending());
561 EXPECT_TRUE(client.needs_begin_frame()); 575 EXPECT_TRUE(time_source->Active());
562 EXPECT_EQ(0, client.num_draws()); 576 EXPECT_EQ(0, client.num_draws());
563 577
564 // Draw successfully, this starts a new frame. 578 // Draw successfully, this starts a new frame.
565 scheduler->BeginFrame(base::TimeTicks::Now()); 579 time_source->Tick();
566 EXPECT_EQ(1, client.num_draws()); 580 EXPECT_EQ(1, client.num_draws());
581 EXPECT_EQ(1, controller_ptr->NumFramesPending());
582 scheduler->DidSwapBuffersComplete();
583 EXPECT_EQ(0, controller_ptr->NumFramesPending());
567 584
568 scheduler->SetNeedsRedraw(); 585 scheduler->SetNeedsRedraw();
569 EXPECT_TRUE(scheduler->RedrawPending()); 586 EXPECT_TRUE(scheduler->RedrawPending());
570 EXPECT_TRUE(client.needs_begin_frame()); 587 EXPECT_TRUE(time_source->Active());
571 588
572 // Fail to draw, this should not start a frame. 589 // Fail to draw, this should not start a frame.
573 client.SetDrawWillHappen(false); 590 client.SetDrawWillHappen(false);
574 scheduler->BeginFrame(base::TimeTicks::Now()); 591 time_source->Tick();
575 EXPECT_EQ(2, client.num_draws()); 592 EXPECT_EQ(2, client.num_draws());
593 EXPECT_EQ(0, controller_ptr->NumFramesPending());
576 } 594 }
577 595
578 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) { 596 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) {
597 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
579 FakeSchedulerClient client; 598 FakeSchedulerClient client;
599 scoped_ptr<FakeFrameRateController> controller(
600 new FakeFrameRateController(time_source));
601 FakeFrameRateController* controller_ptr = controller.get();
580 SchedulerSettings default_scheduler_settings; 602 SchedulerSettings default_scheduler_settings;
581 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 603 Scheduler* scheduler = client.CreateScheduler(
604 controller.PassAs<FrameRateController>(),
605 default_scheduler_settings);
606
607 EXPECT_EQ(0, controller_ptr->NumFramesPending());
582 608
583 // Tell the client that it will fail to swap. 609 // Tell the client that it will fail to swap.
584 client.SetDrawWillHappen(true); 610 client.SetDrawWillHappen(true);
585 client.SetSwapWillHappenIfDrawHappens(false); 611 client.SetSwapWillHappenIfDrawHappens(false);
586 612
587 // Get the compositor to do a ScheduledActionDrawAndSwapForced. 613 // Get the compositor to do a ScheduledActionDrawAndSwapForced.
588 scheduler->SetCanDraw(true);
589 scheduler->SetNeedsRedraw(); 614 scheduler->SetNeedsRedraw();
590 scheduler->SetNeedsForcedRedraw(); 615 scheduler->SetNeedsForcedRedraw();
591 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapForced")); 616 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapForced"));
617
618 // We should not have told the frame rate controller that we began a frame.
619 EXPECT_EQ(0, controller_ptr->NumFramesPending());
620 }
621
622 TEST(SchedulerTest, RecreateOutputSurfaceClearsPendingDrawCount) {
623 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
624 FakeSchedulerClient client;
625 scoped_ptr<FakeFrameRateController> controller(
626 new FakeFrameRateController(time_source));
627 FakeFrameRateController* controller_ptr = controller.get();
628 SchedulerSettings default_scheduler_settings;
629 Scheduler* scheduler = client.CreateScheduler(
630 controller.PassAs<FrameRateController>(),
631 default_scheduler_settings);
632
633 scheduler->SetCanStart();
634 scheduler->SetVisible(true);
635 scheduler->SetCanDraw(true);
636 scheduler->DidCreateAndInitializeOutputSurface();
637
638 // Draw successfully, this starts a new frame.
639 scheduler->SetNeedsRedraw();
640 time_source->Tick();
641 EXPECT_EQ(1, controller_ptr->NumFramesPending());
642
643 scheduler->DidLoseOutputSurface();
644 // Verifying that it's 1 so that we know that it's reset on recreate.
645 EXPECT_EQ(1, controller_ptr->NumFramesPending());
646
647 scheduler->DidCreateAndInitializeOutputSurface();
648 EXPECT_EQ(0, controller_ptr->NumFramesPending());
592 } 649 }
593 650
594 } // namespace 651 } // namespace
595 } // namespace cc 652 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/scheduler/scheduler_state_machine_unittest.cc ('k') | trunk/src/cc/scheduler/vsync_time_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698