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 #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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 void SetDrawWillHappen(bool draw_will_happen) { | 63 void SetDrawWillHappen(bool draw_will_happen) { |
64 draw_will_happen_ = draw_will_happen; | 64 draw_will_happen_ = draw_will_happen; |
65 } | 65 } |
66 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) { | 66 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) { |
67 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; |
68 } | 68 } |
69 | 69 |
70 // Scheduler Implementation. | 70 // Scheduler Implementation. |
71 virtual void ScheduledActionBeginFrame() OVERRIDE { | 71 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE { |
72 actions_.push_back("ScheduledActionBeginFrame"); | 72 actions_.push_back("ScheduledActionSendBeginFrameToMainThread"); |
73 states_.push_back(scheduler_->StateAsStringForTesting()); | 73 states_.push_back(scheduler_->StateAsStringForTesting()); |
74 } | 74 } |
75 virtual ScheduledActionDrawAndSwapResult | 75 virtual ScheduledActionDrawAndSwapResult |
76 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { | 76 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { |
77 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); | 77 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); |
78 states_.push_back(scheduler_->StateAsStringForTesting()); | 78 states_.push_back(scheduler_->StateAsStringForTesting()); |
79 num_draws_++; | 79 num_draws_++; |
80 return ScheduledActionDrawAndSwapResult(draw_will_happen_, | 80 return ScheduledActionDrawAndSwapResult(draw_will_happen_, |
81 draw_will_happen_ && | 81 draw_will_happen_ && |
82 swap_will_happen_if_draw_happens_); | 82 swap_will_happen_if_draw_happens_); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 scheduler->SetCanStart(); | 146 scheduler->SetCanStart(); |
147 scheduler->SetVisible(true); | 147 scheduler->SetVisible(true); |
148 scheduler->SetCanDraw(true); | 148 scheduler->SetCanDraw(true); |
149 | 149 |
150 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); | 150 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); |
151 client.Reset(); | 151 client.Reset(); |
152 scheduler->DidCreateAndInitializeOutputSurface(); | 152 scheduler->DidCreateAndInitializeOutputSurface(); |
153 | 153 |
154 // SetNeedsCommit should begin the frame. | 154 // SetNeedsCommit should begin the frame. |
155 scheduler->SetNeedsCommit(); | 155 scheduler->SetNeedsCommit(); |
156 EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client); | 156 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client); |
157 EXPECT_FALSE(time_source->Active()); | 157 EXPECT_FALSE(time_source->Active()); |
158 client.Reset(); | 158 client.Reset(); |
159 | 159 |
160 // BeginFrameComplete should commit | 160 // FinishCommit should commit |
161 scheduler->BeginFrameComplete(); | 161 scheduler->FinishCommit(); |
162 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 162 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
163 EXPECT_TRUE(time_source->Active()); | 163 EXPECT_TRUE(time_source->Active()); |
164 client.Reset(); | 164 client.Reset(); |
165 | 165 |
166 // Tick should draw. | 166 // Tick should draw. |
167 time_source->Tick(); | 167 time_source->Tick(); |
168 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client); | 168 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client); |
169 EXPECT_FALSE(time_source->Active()); | 169 EXPECT_FALSE(time_source->Active()); |
170 client.Reset(); | 170 client.Reset(); |
171 | 171 |
172 // Timer should be off. | 172 // Timer should be off. |
173 EXPECT_FALSE(time_source->Active()); | 173 EXPECT_FALSE(time_source->Active()); |
174 } | 174 } |
175 | 175 |
176 TEST(SchedulerTest, RequestCommitAfterBeginFrame) { | 176 TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) { |
177 FakeSchedulerClient client; | 177 FakeSchedulerClient client; |
178 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 178 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
179 SchedulerSettings default_scheduler_settings; | 179 SchedulerSettings default_scheduler_settings; |
180 Scheduler* scheduler = client.CreateScheduler( | 180 Scheduler* scheduler = client.CreateScheduler( |
181 make_scoped_ptr(new FrameRateController(time_source)), | 181 make_scoped_ptr(new FrameRateController(time_source)), |
182 default_scheduler_settings); | 182 default_scheduler_settings); |
183 scheduler->SetCanStart(); | 183 scheduler->SetCanStart(); |
184 scheduler->SetVisible(true); | 184 scheduler->SetVisible(true); |
185 scheduler->SetCanDraw(true); | 185 scheduler->SetCanDraw(true); |
186 | 186 |
187 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); | 187 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); |
188 client.Reset(); | 188 client.Reset(); |
189 scheduler->DidCreateAndInitializeOutputSurface(); | 189 scheduler->DidCreateAndInitializeOutputSurface(); |
190 | 190 |
191 // SetNedsCommit should begin the frame. | 191 // SetNedsCommit should begin the frame. |
192 scheduler->SetNeedsCommit(); | 192 scheduler->SetNeedsCommit(); |
193 EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client); | 193 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client); |
194 client.Reset(); | 194 client.Reset(); |
195 | 195 |
196 // Now SetNeedsCommit again. Calling here means we need a second frame. | 196 // Now SetNeedsCommit again. Calling here means we need a second frame. |
197 scheduler->SetNeedsCommit(); | 197 scheduler->SetNeedsCommit(); |
198 | 198 |
199 // Since, another commit is needed, BeginFrameComplete should commit, | 199 // Since another commit is needed, FinishCommit should commit, |
200 // then begin another frame. | 200 // then begin another frame. |
201 scheduler->BeginFrameComplete(); | 201 scheduler->FinishCommit(); |
202 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 202 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
203 client.Reset(); | 203 client.Reset(); |
204 | 204 |
205 // Tick should draw but then begin another frame. | 205 // Tick should draw but then begin another frame. |
206 time_source->Tick(); | 206 time_source->Tick(); |
207 EXPECT_FALSE(time_source->Active()); | 207 EXPECT_FALSE(time_source->Active()); |
208 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 208 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
209 EXPECT_ACTION("ScheduledActionBeginFrame", client, 1, 2); | 209 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2); |
210 client.Reset(); | 210 client.Reset(); |
211 } | 211 } |
212 | 212 |
213 TEST(SchedulerTest, TextureAcquisitionCollision) { | 213 TEST(SchedulerTest, TextureAcquisitionCollision) { |
214 FakeSchedulerClient client; | 214 FakeSchedulerClient client; |
215 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 215 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
216 SchedulerSettings default_scheduler_settings; | 216 SchedulerSettings default_scheduler_settings; |
217 Scheduler* scheduler = client.CreateScheduler( | 217 Scheduler* scheduler = client.CreateScheduler( |
218 make_scoped_ptr(new FrameRateController(time_source)), | 218 make_scoped_ptr(new FrameRateController(time_source)), |
219 default_scheduler_settings); | 219 default_scheduler_settings); |
220 scheduler->SetCanStart(); | 220 scheduler->SetCanStart(); |
221 scheduler->SetVisible(true); | 221 scheduler->SetVisible(true); |
222 scheduler->SetCanDraw(true); | 222 scheduler->SetCanDraw(true); |
223 | 223 |
224 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); | 224 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); |
225 client.Reset(); | 225 client.Reset(); |
226 scheduler->DidCreateAndInitializeOutputSurface(); | 226 scheduler->DidCreateAndInitializeOutputSurface(); |
227 | 227 |
228 scheduler->SetNeedsCommit(); | 228 scheduler->SetNeedsCommit(); |
229 scheduler->SetMainThreadNeedsLayerTextures(); | 229 scheduler->SetMainThreadNeedsLayerTextures(); |
230 EXPECT_ACTION("ScheduledActionBeginFrame", client, 0, 2); | 230 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2); |
231 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", | 231 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", |
232 client, | 232 client, |
233 1, | 233 1, |
234 2); | 234 2); |
235 client.Reset(); | 235 client.Reset(); |
236 | 236 |
237 // Compositor not scheduled to draw because textures are locked by main thread | 237 // Compositor not scheduled to draw because textures are locked by main thread |
238 EXPECT_FALSE(time_source->Active()); | 238 EXPECT_FALSE(time_source->Active()); |
239 | 239 |
240 // Trigger the commit | 240 // Trigger the commit |
241 scheduler->BeginFrameComplete(); | 241 scheduler->FinishCommit(); |
242 EXPECT_TRUE(time_source->Active()); | 242 EXPECT_TRUE(time_source->Active()); |
243 client.Reset(); | 243 client.Reset(); |
244 | 244 |
245 // Between commit and draw, texture acquisition for main thread delayed, | 245 // Between commit and draw, texture acquisition for main thread delayed, |
246 // and main thread blocks. | 246 // and main thread blocks. |
247 scheduler->SetMainThreadNeedsLayerTextures(); | 247 scheduler->SetMainThreadNeedsLayerTextures(); |
248 EXPECT_EQ(0, client.num_actions_()); | 248 EXPECT_EQ(0, client.num_actions_()); |
249 client.Reset(); | 249 client.Reset(); |
250 | 250 |
251 // Once compositor draw complete, the delayed texture acquisition fires. | 251 // Once compositor draw complete, the delayed texture acquisition fires. |
252 time_source->Tick(); | 252 time_source->Tick(); |
253 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); | 253 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); |
254 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", | 254 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", |
255 client, | 255 client, |
256 1, | 256 1, |
257 3); | 257 3); |
258 EXPECT_ACTION("ScheduledActionBeginFrame", client, 2, 3); | 258 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 2, 3); |
259 client.Reset(); | 259 client.Reset(); |
260 } | 260 } |
261 | 261 |
262 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { | 262 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { |
263 FakeSchedulerClient client; | 263 FakeSchedulerClient client; |
264 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 264 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
265 SchedulerSettings default_scheduler_settings; | 265 SchedulerSettings default_scheduler_settings; |
266 Scheduler* scheduler = client.CreateScheduler( | 266 Scheduler* scheduler = client.CreateScheduler( |
267 make_scoped_ptr(new FrameRateController(time_source)), | 267 make_scoped_ptr(new FrameRateController(time_source)), |
268 default_scheduler_settings); | 268 default_scheduler_settings); |
269 scheduler->SetCanStart(); | 269 scheduler->SetCanStart(); |
270 scheduler->SetVisible(true); | 270 scheduler->SetVisible(true); |
271 scheduler->SetCanDraw(true); | 271 scheduler->SetCanDraw(true); |
272 | 272 |
273 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); | 273 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); |
274 client.Reset(); | 274 client.Reset(); |
275 scheduler->DidCreateAndInitializeOutputSurface(); | 275 scheduler->DidCreateAndInitializeOutputSurface(); |
276 | 276 |
277 scheduler->SetNeedsCommit(); | 277 scheduler->SetNeedsCommit(); |
278 scheduler->BeginFrameComplete(); | 278 scheduler->FinishCommit(); |
279 scheduler->SetMainThreadNeedsLayerTextures(); | 279 scheduler->SetMainThreadNeedsLayerTextures(); |
280 client.Reset(); | 280 client.Reset(); |
281 // Verify that pending texture acquisition fires when visibility | 281 // Verify that pending texture acquisition fires when visibility |
282 // is lost in order to avoid a deadlock. | 282 // is lost in order to avoid a deadlock. |
283 scheduler->SetVisible(false); | 283 scheduler->SetVisible(false); |
284 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", | 284 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", |
285 client); | 285 client); |
286 client.Reset(); | 286 client.Reset(); |
287 | 287 |
288 // Regaining visibility with textures acquired by main thread while | 288 // Regaining visibility with textures acquired by main thread while |
289 // compositor is waiting for first draw should result in a request | 289 // compositor is waiting for first draw should result in a request |
290 // for a new frame in order to escape a deadlock. | 290 // for a new frame in order to escape a deadlock. |
291 scheduler->SetVisible(true); | 291 scheduler->SetVisible(true); |
292 EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client); | 292 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client); |
293 client.Reset(); | 293 client.Reset(); |
294 } | 294 } |
295 | 295 |
296 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { | 296 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { |
297 public: | 297 public: |
298 virtual void ScheduledActionBeginFrame() OVERRIDE {} | 298 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {} |
299 virtual ScheduledActionDrawAndSwapResult | 299 virtual ScheduledActionDrawAndSwapResult |
300 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { | 300 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { |
301 // Only SetNeedsRedraw the first time this is called | 301 // Only SetNeedsRedraw the first time this is called |
302 if (!num_draws_) | 302 if (!num_draws_) |
303 scheduler_->SetNeedsRedraw(); | 303 scheduler_->SetNeedsRedraw(); |
304 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 304 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
305 } | 305 } |
306 | 306 |
307 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 307 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
308 OVERRIDE { | 308 OVERRIDE { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 client.SetDrawWillHappen(true); | 388 client.SetDrawWillHappen(true); |
389 time_source->Tick(); | 389 time_source->Tick(); |
390 EXPECT_EQ(3, client.num_draws()); | 390 EXPECT_EQ(3, client.num_draws()); |
391 EXPECT_TRUE(scheduler->CommitPending()); | 391 EXPECT_TRUE(scheduler->CommitPending()); |
392 EXPECT_FALSE(scheduler->RedrawPending()); | 392 EXPECT_FALSE(scheduler->RedrawPending()); |
393 EXPECT_FALSE(time_source->Active()); | 393 EXPECT_FALSE(time_source->Active()); |
394 } | 394 } |
395 | 395 |
396 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { | 396 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { |
397 public: | 397 public: |
398 virtual void ScheduledActionBeginFrame() OVERRIDE {} | 398 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {} |
399 virtual ScheduledActionDrawAndSwapResult | 399 virtual ScheduledActionDrawAndSwapResult |
400 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { | 400 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { |
401 // Only SetNeedsCommit the first time this is called | 401 // Only SetNeedsCommit the first time this is called |
402 if (!num_draws_) | 402 if (!num_draws_) |
403 scheduler_->SetNeedsCommit(); | 403 scheduler_->SetNeedsCommit(); |
404 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 404 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
405 } | 405 } |
406 | 406 |
407 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 407 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
408 OVERRIDE { | 408 OVERRIDE { |
(...skipping 22 matching lines...) Expand all Loading... |
431 | 431 |
432 scheduler->SetNeedsRedraw(); | 432 scheduler->SetNeedsRedraw(); |
433 EXPECT_TRUE(scheduler->RedrawPending()); | 433 EXPECT_TRUE(scheduler->RedrawPending()); |
434 EXPECT_EQ(0, client.num_draws()); | 434 EXPECT_EQ(0, client.num_draws()); |
435 EXPECT_TRUE(time_source->Active()); | 435 EXPECT_TRUE(time_source->Active()); |
436 | 436 |
437 time_source->Tick(); | 437 time_source->Tick(); |
438 EXPECT_FALSE(time_source->Active()); | 438 EXPECT_FALSE(time_source->Active()); |
439 EXPECT_EQ(1, client.num_draws()); | 439 EXPECT_EQ(1, client.num_draws()); |
440 EXPECT_TRUE(scheduler->CommitPending()); | 440 EXPECT_TRUE(scheduler->CommitPending()); |
441 scheduler->BeginFrameComplete(); | 441 scheduler->FinishCommit(); |
442 | 442 |
443 time_source->Tick(); | 443 time_source->Tick(); |
444 EXPECT_EQ(2, client.num_draws()); | 444 EXPECT_EQ(2, client.num_draws()); |
445 EXPECT_FALSE(time_source->Active()); | 445 EXPECT_FALSE(time_source->Active()); |
446 EXPECT_FALSE(scheduler->RedrawPending()); | 446 EXPECT_FALSE(scheduler->RedrawPending()); |
447 } | 447 } |
448 | 448 |
449 // Tests that when a draw fails then the pending commit should not be dropped. | 449 // Tests that when a draw fails then the pending commit should not be dropped. |
450 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { | 450 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
451 SchedulerClientThatsetNeedsDrawInsideDraw client; | 451 SchedulerClientThatsetNeedsDrawInsideDraw client; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 485 |
486 // Draw successfully. | 486 // Draw successfully. |
487 client.SetDrawWillHappen(true); | 487 client.SetDrawWillHappen(true); |
488 time_source->Tick(); | 488 time_source->Tick(); |
489 EXPECT_EQ(3, client.num_draws()); | 489 EXPECT_EQ(3, client.num_draws()); |
490 EXPECT_TRUE(scheduler->CommitPending()); | 490 EXPECT_TRUE(scheduler->CommitPending()); |
491 EXPECT_FALSE(scheduler->RedrawPending()); | 491 EXPECT_FALSE(scheduler->RedrawPending()); |
492 EXPECT_FALSE(time_source->Active()); | 492 EXPECT_FALSE(time_source->Active()); |
493 } | 493 } |
494 | 494 |
495 TEST(SchedulerTest, NoBeginFrameWhenDrawFails) { | 495 TEST(SchedulerTest, NoSwapWhenDrawFails) { |
496 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 496 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
497 SchedulerClientThatsetNeedsCommitInsideDraw client; | 497 SchedulerClientThatsetNeedsCommitInsideDraw client; |
498 scoped_ptr<FakeFrameRateController> controller( | 498 scoped_ptr<FakeFrameRateController> controller( |
499 new FakeFrameRateController(time_source)); | 499 new FakeFrameRateController(time_source)); |
500 FakeFrameRateController* controller_ptr = controller.get(); | 500 FakeFrameRateController* controller_ptr = controller.get(); |
501 SchedulerSettings default_scheduler_settings; | 501 SchedulerSettings default_scheduler_settings; |
502 Scheduler* scheduler = client.CreateScheduler( | 502 Scheduler* scheduler = client.CreateScheduler( |
503 controller.PassAs<FrameRateController>(), | 503 controller.PassAs<FrameRateController>(), |
504 default_scheduler_settings); | 504 default_scheduler_settings); |
505 scheduler->SetCanStart(); | 505 scheduler->SetCanStart(); |
(...skipping 19 matching lines...) Expand all Loading... |
525 EXPECT_TRUE(scheduler->RedrawPending()); | 525 EXPECT_TRUE(scheduler->RedrawPending()); |
526 EXPECT_TRUE(time_source->Active()); | 526 EXPECT_TRUE(time_source->Active()); |
527 | 527 |
528 // Fail to draw, this should not start a frame. | 528 // Fail to draw, this should not start a frame. |
529 client.SetDrawWillHappen(false); | 529 client.SetDrawWillHappen(false); |
530 time_source->Tick(); | 530 time_source->Tick(); |
531 EXPECT_EQ(2, client.num_draws()); | 531 EXPECT_EQ(2, client.num_draws()); |
532 EXPECT_EQ(0, controller_ptr->NumFramesPending()); | 532 EXPECT_EQ(0, controller_ptr->NumFramesPending()); |
533 } | 533 } |
534 | 534 |
535 TEST(SchedulerTest, NoBeginFrameWhenSwapFailsDuringForcedCommit) { | 535 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) { |
536 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 536 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
537 FakeSchedulerClient client; | 537 FakeSchedulerClient client; |
538 scoped_ptr<FakeFrameRateController> controller( | 538 scoped_ptr<FakeFrameRateController> controller( |
539 new FakeFrameRateController(time_source)); | 539 new FakeFrameRateController(time_source)); |
540 FakeFrameRateController* controller_ptr = controller.get(); | 540 FakeFrameRateController* controller_ptr = controller.get(); |
541 SchedulerSettings default_scheduler_settings; | 541 SchedulerSettings default_scheduler_settings; |
542 Scheduler* scheduler = client.CreateScheduler( | 542 Scheduler* scheduler = client.CreateScheduler( |
543 controller.PassAs<FrameRateController>(), | 543 controller.PassAs<FrameRateController>(), |
544 default_scheduler_settings); | 544 default_scheduler_settings); |
545 | 545 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 scheduler->DidLoseOutputSurface(); | 582 scheduler->DidLoseOutputSurface(); |
583 // Verifying that it's 1 so that we know that it's reset on recreate. | 583 // Verifying that it's 1 so that we know that it's reset on recreate. |
584 EXPECT_EQ(1, controller_ptr->NumFramesPending()); | 584 EXPECT_EQ(1, controller_ptr->NumFramesPending()); |
585 | 585 |
586 scheduler->DidCreateAndInitializeOutputSurface(); | 586 scheduler->DidCreateAndInitializeOutputSurface(); |
587 EXPECT_EQ(0, controller_ptr->NumFramesPending()); | 587 EXPECT_EQ(0, controller_ptr->NumFramesPending()); |
588 } | 588 } |
589 | 589 |
590 } // namespace | 590 } // namespace |
591 } // namespace cc | 591 } // namespace cc |
OLD | NEW |