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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cc/test/scheduler_test_common.h" | 8 #include "cc/test/scheduler_test_common.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 make_scoped_ptr(new FrameRateController(time_source)), | 91 make_scoped_ptr(new FrameRateController(time_source)), |
92 default_scheduler_settings); | 92 default_scheduler_settings); |
93 scheduler->SetCanBeginFrame(true); | 93 scheduler->SetCanBeginFrame(true); |
94 scheduler->SetVisible(true); | 94 scheduler->SetVisible(true); |
95 scheduler->SetCanDraw(true); | 95 scheduler->SetCanDraw(true); |
96 | 96 |
97 // SetNeedsCommit should begin the frame. | 97 // SetNeedsCommit should begin the frame. |
98 scheduler->SetNeedsCommit(); | 98 scheduler->SetNeedsCommit(); |
99 EXPECT_EQ(1, client.num_actions_()); | 99 EXPECT_EQ(1, client.num_actions_()); |
100 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); | 100 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); |
101 EXPECT_FALSE(time_source->active()); | 101 EXPECT_FALSE(time_source->Active()); |
102 client.Reset(); | 102 client.Reset(); |
103 | 103 |
104 // BeginFrameComplete should commit | 104 // BeginFrameComplete should commit |
105 scheduler->BeginFrameComplete(); | 105 scheduler->BeginFrameComplete(); |
106 EXPECT_EQ(1, client.num_actions_()); | 106 EXPECT_EQ(1, client.num_actions_()); |
107 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); | 107 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); |
108 EXPECT_TRUE(time_source->active()); | 108 EXPECT_TRUE(time_source->Active()); |
109 client.Reset(); | 109 client.Reset(); |
110 | 110 |
111 // Tick should draw. | 111 // Tick should draw. |
112 time_source->tick(); | 112 time_source->tick(); |
113 EXPECT_EQ(1, client.num_actions_()); | 113 EXPECT_EQ(1, client.num_actions_()); |
114 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); | 114 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); |
115 EXPECT_FALSE(time_source->active()); | 115 EXPECT_FALSE(time_source->Active()); |
116 client.Reset(); | 116 client.Reset(); |
117 | 117 |
118 // Timer should be off. | 118 // Timer should be off. |
119 EXPECT_FALSE(time_source->active()); | 119 EXPECT_FALSE(time_source->Active()); |
120 } | 120 } |
121 | 121 |
122 TEST(SchedulerTest, RequestCommitAfterBeginFrame) { | 122 TEST(SchedulerTest, RequestCommitAfterBeginFrame) { |
123 FakeSchedulerClient client; | 123 FakeSchedulerClient client; |
124 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 124 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
125 SchedulerSettings default_scheduler_settings; | 125 SchedulerSettings default_scheduler_settings; |
126 scoped_ptr<Scheduler> scheduler = | 126 scoped_ptr<Scheduler> scheduler = |
127 Scheduler::Create(&client, | 127 Scheduler::Create(&client, |
128 make_scoped_ptr(new FrameRateController(time_source)), | 128 make_scoped_ptr(new FrameRateController(time_source)), |
129 default_scheduler_settings); | 129 default_scheduler_settings); |
(...skipping 12 matching lines...) Expand all Loading... |
142 | 142 |
143 // Since, another commit is needed, BeginFrameComplete should commit, | 143 // Since, another commit is needed, BeginFrameComplete should commit, |
144 // then begin another frame. | 144 // then begin another frame. |
145 scheduler->BeginFrameComplete(); | 145 scheduler->BeginFrameComplete(); |
146 EXPECT_EQ(1, client.num_actions_()); | 146 EXPECT_EQ(1, client.num_actions_()); |
147 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); | 147 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); |
148 client.Reset(); | 148 client.Reset(); |
149 | 149 |
150 // Tick should draw but then begin another frame. | 150 // Tick should draw but then begin another frame. |
151 time_source->tick(); | 151 time_source->tick(); |
152 EXPECT_FALSE(time_source->active()); | 152 EXPECT_FALSE(time_source->Active()); |
153 EXPECT_EQ(2, client.num_actions_()); | 153 EXPECT_EQ(2, client.num_actions_()); |
154 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); | 154 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); |
155 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(1)); | 155 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(1)); |
156 client.Reset(); | 156 client.Reset(); |
157 } | 157 } |
158 | 158 |
159 TEST(SchedulerTest, TextureAcquisitionCollision) { | 159 TEST(SchedulerTest, TextureAcquisitionCollision) { |
160 FakeSchedulerClient client; | 160 FakeSchedulerClient client; |
161 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 161 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
162 SchedulerSettings default_scheduler_settings; | 162 SchedulerSettings default_scheduler_settings; |
163 scoped_ptr<Scheduler> scheduler = | 163 scoped_ptr<Scheduler> scheduler = |
164 Scheduler::Create(&client, | 164 Scheduler::Create(&client, |
165 make_scoped_ptr(new FrameRateController(time_source)), | 165 make_scoped_ptr(new FrameRateController(time_source)), |
166 default_scheduler_settings); | 166 default_scheduler_settings); |
167 scheduler->SetCanBeginFrame(true); | 167 scheduler->SetCanBeginFrame(true); |
168 scheduler->SetVisible(true); | 168 scheduler->SetVisible(true); |
169 scheduler->SetCanDraw(true); | 169 scheduler->SetCanDraw(true); |
170 | 170 |
171 scheduler->SetNeedsCommit(); | 171 scheduler->SetNeedsCommit(); |
172 scheduler->SetMainThreadNeedsLayerTextures(); | 172 scheduler->SetMainThreadNeedsLayerTextures(); |
173 EXPECT_EQ(2, client.num_actions_()); | 173 EXPECT_EQ(2, client.num_actions_()); |
174 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); | 174 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); |
175 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", | 175 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", |
176 client.Action(1)); | 176 client.Action(1)); |
177 client.Reset(); | 177 client.Reset(); |
178 | 178 |
179 // Compositor not scheduled to draw because textures are locked by main thread | 179 // Compositor not scheduled to draw because textures are locked by main thread |
180 EXPECT_FALSE(time_source->active()); | 180 EXPECT_FALSE(time_source->Active()); |
181 | 181 |
182 // Trigger the commit | 182 // Trigger the commit |
183 scheduler->BeginFrameComplete(); | 183 scheduler->BeginFrameComplete(); |
184 EXPECT_TRUE(time_source->active()); | 184 EXPECT_TRUE(time_source->Active()); |
185 client.Reset(); | 185 client.Reset(); |
186 | 186 |
187 // Between commit and draw, texture acquisition for main thread delayed, | 187 // Between commit and draw, texture acquisition for main thread delayed, |
188 // and main thread blocks. | 188 // and main thread blocks. |
189 scheduler->SetMainThreadNeedsLayerTextures(); | 189 scheduler->SetMainThreadNeedsLayerTextures(); |
190 EXPECT_EQ(0, client.num_actions_()); | 190 EXPECT_EQ(0, client.num_actions_()); |
191 client.Reset(); | 191 client.Reset(); |
192 | 192 |
193 // Once compositor draw complete, the delayed texture acquisition fires. | 193 // Once compositor draw complete, the delayed texture acquisition fires. |
194 time_source->tick(); | 194 time_source->tick(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 Scheduler::Create(&client, | 274 Scheduler::Create(&client, |
275 make_scoped_ptr(new FrameRateController(time_source)), | 275 make_scoped_ptr(new FrameRateController(time_source)), |
276 default_scheduler_settings); | 276 default_scheduler_settings); |
277 client.SetScheduler(scheduler.get()); | 277 client.SetScheduler(scheduler.get()); |
278 scheduler->SetCanBeginFrame(true); | 278 scheduler->SetCanBeginFrame(true); |
279 scheduler->SetVisible(true); | 279 scheduler->SetVisible(true); |
280 scheduler->SetCanDraw(true); | 280 scheduler->SetCanDraw(true); |
281 | 281 |
282 scheduler->SetNeedsRedraw(); | 282 scheduler->SetNeedsRedraw(); |
283 EXPECT_TRUE(scheduler->RedrawPending()); | 283 EXPECT_TRUE(scheduler->RedrawPending()); |
284 EXPECT_TRUE(time_source->active()); | 284 EXPECT_TRUE(time_source->Active()); |
285 EXPECT_EQ(0, client.num_draws()); | 285 EXPECT_EQ(0, client.num_draws()); |
286 | 286 |
287 time_source->tick(); | 287 time_source->tick(); |
288 EXPECT_EQ(1, client.num_draws()); | 288 EXPECT_EQ(1, client.num_draws()); |
289 EXPECT_TRUE(scheduler->RedrawPending()); | 289 EXPECT_TRUE(scheduler->RedrawPending()); |
290 EXPECT_TRUE(time_source->active()); | 290 EXPECT_TRUE(time_source->Active()); |
291 | 291 |
292 time_source->tick(); | 292 time_source->tick(); |
293 EXPECT_EQ(2, client.num_draws()); | 293 EXPECT_EQ(2, client.num_draws()); |
294 EXPECT_FALSE(scheduler->RedrawPending()); | 294 EXPECT_FALSE(scheduler->RedrawPending()); |
295 EXPECT_FALSE(time_source->active()); | 295 EXPECT_FALSE(time_source->Active()); |
296 } | 296 } |
297 | 297 |
298 // Test that requesting redraw inside a failed draw doesn't lose the request. | 298 // Test that requesting redraw inside a failed draw doesn't lose the request. |
299 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { | 299 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { |
300 SchedulerClientThatsetNeedsDrawInsideDraw client; | 300 SchedulerClientThatsetNeedsDrawInsideDraw client; |
301 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 301 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
302 SchedulerSettings default_scheduler_settings; | 302 SchedulerSettings default_scheduler_settings; |
303 scoped_ptr<Scheduler> scheduler = | 303 scoped_ptr<Scheduler> scheduler = |
304 Scheduler::Create(&client, | 304 Scheduler::Create(&client, |
305 make_scoped_ptr(new FrameRateController(time_source)), | 305 make_scoped_ptr(new FrameRateController(time_source)), |
306 default_scheduler_settings); | 306 default_scheduler_settings); |
307 client.SetScheduler(scheduler.get()); | 307 client.SetScheduler(scheduler.get()); |
308 scheduler->SetCanBeginFrame(true); | 308 scheduler->SetCanBeginFrame(true); |
309 scheduler->SetVisible(true); | 309 scheduler->SetVisible(true); |
310 scheduler->SetCanDraw(true); | 310 scheduler->SetCanDraw(true); |
311 client.SetDrawWillHappen(false); | 311 client.SetDrawWillHappen(false); |
312 | 312 |
313 scheduler->SetNeedsRedraw(); | 313 scheduler->SetNeedsRedraw(); |
314 EXPECT_TRUE(scheduler->RedrawPending()); | 314 EXPECT_TRUE(scheduler->RedrawPending()); |
315 EXPECT_TRUE(time_source->active()); | 315 EXPECT_TRUE(time_source->Active()); |
316 EXPECT_EQ(0, client.num_draws()); | 316 EXPECT_EQ(0, client.num_draws()); |
317 | 317 |
318 // Fail the draw. | 318 // Fail the draw. |
319 time_source->tick(); | 319 time_source->tick(); |
320 EXPECT_EQ(1, client.num_draws()); | 320 EXPECT_EQ(1, client.num_draws()); |
321 | 321 |
322 // We have a commit pending and the draw failed, and we didn't lose the redraw | 322 // We have a commit pending and the draw failed, and we didn't lose the redraw |
323 // request. | 323 // request. |
324 EXPECT_TRUE(scheduler->CommitPending()); | 324 EXPECT_TRUE(scheduler->CommitPending()); |
325 EXPECT_TRUE(scheduler->RedrawPending()); | 325 EXPECT_TRUE(scheduler->RedrawPending()); |
326 EXPECT_TRUE(time_source->active()); | 326 EXPECT_TRUE(time_source->Active()); |
327 | 327 |
328 // Fail the draw again. | 328 // Fail the draw again. |
329 time_source->tick(); | 329 time_source->tick(); |
330 EXPECT_EQ(2, client.num_draws()); | 330 EXPECT_EQ(2, client.num_draws()); |
331 EXPECT_TRUE(scheduler->CommitPending()); | 331 EXPECT_TRUE(scheduler->CommitPending()); |
332 EXPECT_TRUE(scheduler->RedrawPending()); | 332 EXPECT_TRUE(scheduler->RedrawPending()); |
333 EXPECT_TRUE(time_source->active()); | 333 EXPECT_TRUE(time_source->Active()); |
334 | 334 |
335 // Draw successfully. | 335 // Draw successfully. |
336 client.SetDrawWillHappen(true); | 336 client.SetDrawWillHappen(true); |
337 time_source->tick(); | 337 time_source->tick(); |
338 EXPECT_EQ(3, client.num_draws()); | 338 EXPECT_EQ(3, client.num_draws()); |
339 EXPECT_TRUE(scheduler->CommitPending()); | 339 EXPECT_TRUE(scheduler->CommitPending()); |
340 EXPECT_FALSE(scheduler->RedrawPending()); | 340 EXPECT_FALSE(scheduler->RedrawPending()); |
341 EXPECT_FALSE(time_source->active()); | 341 EXPECT_FALSE(time_source->Active()); |
342 } | 342 } |
343 | 343 |
344 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { | 344 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { |
345 public: | 345 public: |
346 SchedulerClientThatsetNeedsCommitInsideDraw() : scheduler_(NULL) {} | 346 SchedulerClientThatsetNeedsCommitInsideDraw() : scheduler_(NULL) {} |
347 | 347 |
348 void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; } | 348 void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; } |
349 | 349 |
350 virtual void ScheduledActionBeginFrame() OVERRIDE {} | 350 virtual void ScheduledActionBeginFrame() OVERRIDE {} |
351 virtual ScheduledActionDrawAndSwapResult | 351 virtual ScheduledActionDrawAndSwapResult |
(...skipping 29 matching lines...) Expand all Loading... |
381 make_scoped_ptr(new FrameRateController(time_source)), | 381 make_scoped_ptr(new FrameRateController(time_source)), |
382 default_scheduler_settings); | 382 default_scheduler_settings); |
383 client.SetScheduler(scheduler.get()); | 383 client.SetScheduler(scheduler.get()); |
384 scheduler->SetCanBeginFrame(true); | 384 scheduler->SetCanBeginFrame(true); |
385 scheduler->SetVisible(true); | 385 scheduler->SetVisible(true); |
386 scheduler->SetCanDraw(true); | 386 scheduler->SetCanDraw(true); |
387 | 387 |
388 scheduler->SetNeedsRedraw(); | 388 scheduler->SetNeedsRedraw(); |
389 EXPECT_TRUE(scheduler->RedrawPending()); | 389 EXPECT_TRUE(scheduler->RedrawPending()); |
390 EXPECT_EQ(0, client.num_draws()); | 390 EXPECT_EQ(0, client.num_draws()); |
391 EXPECT_TRUE(time_source->active()); | 391 EXPECT_TRUE(time_source->Active()); |
392 | 392 |
393 time_source->tick(); | 393 time_source->tick(); |
394 EXPECT_FALSE(time_source->active()); | 394 EXPECT_FALSE(time_source->Active()); |
395 EXPECT_EQ(1, client.num_draws()); | 395 EXPECT_EQ(1, client.num_draws()); |
396 EXPECT_TRUE(scheduler->CommitPending()); | 396 EXPECT_TRUE(scheduler->CommitPending()); |
397 scheduler->BeginFrameComplete(); | 397 scheduler->BeginFrameComplete(); |
398 | 398 |
399 time_source->tick(); | 399 time_source->tick(); |
400 EXPECT_EQ(2, client.num_draws()); | 400 EXPECT_EQ(2, client.num_draws()); |
401 EXPECT_FALSE(time_source->active()); | 401 EXPECT_FALSE(time_source->Active()); |
402 EXPECT_FALSE(scheduler->RedrawPending()); | 402 EXPECT_FALSE(scheduler->RedrawPending()); |
403 } | 403 } |
404 | 404 |
405 // Tests that when a draw fails then the pending commit should not be dropped. | 405 // Tests that when a draw fails then the pending commit should not be dropped. |
406 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { | 406 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
407 SchedulerClientThatsetNeedsDrawInsideDraw client; | 407 SchedulerClientThatsetNeedsDrawInsideDraw client; |
408 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 408 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
409 SchedulerSettings default_scheduler_settings; | 409 SchedulerSettings default_scheduler_settings; |
410 scoped_ptr<Scheduler> scheduler = | 410 scoped_ptr<Scheduler> scheduler = |
411 Scheduler::Create(&client, | 411 Scheduler::Create(&client, |
412 make_scoped_ptr(new FrameRateController(time_source)), | 412 make_scoped_ptr(new FrameRateController(time_source)), |
413 default_scheduler_settings); | 413 default_scheduler_settings); |
414 client.SetScheduler(scheduler.get()); | 414 client.SetScheduler(scheduler.get()); |
415 scheduler->SetCanBeginFrame(true); | 415 scheduler->SetCanBeginFrame(true); |
416 scheduler->SetVisible(true); | 416 scheduler->SetVisible(true); |
417 scheduler->SetCanDraw(true); | 417 scheduler->SetCanDraw(true); |
418 client.SetDrawWillHappen(false); | 418 client.SetDrawWillHappen(false); |
419 | 419 |
420 scheduler->SetNeedsRedraw(); | 420 scheduler->SetNeedsRedraw(); |
421 EXPECT_TRUE(scheduler->RedrawPending()); | 421 EXPECT_TRUE(scheduler->RedrawPending()); |
422 EXPECT_TRUE(time_source->active()); | 422 EXPECT_TRUE(time_source->Active()); |
423 EXPECT_EQ(0, client.num_draws()); | 423 EXPECT_EQ(0, client.num_draws()); |
424 | 424 |
425 // Fail the draw. | 425 // Fail the draw. |
426 time_source->tick(); | 426 time_source->tick(); |
427 EXPECT_EQ(1, client.num_draws()); | 427 EXPECT_EQ(1, client.num_draws()); |
428 | 428 |
429 // We have a commit pending and the draw failed, and we didn't lose the commit | 429 // We have a commit pending and the draw failed, and we didn't lose the commit |
430 // request. | 430 // request. |
431 EXPECT_TRUE(scheduler->CommitPending()); | 431 EXPECT_TRUE(scheduler->CommitPending()); |
432 EXPECT_TRUE(scheduler->RedrawPending()); | 432 EXPECT_TRUE(scheduler->RedrawPending()); |
433 EXPECT_TRUE(time_source->active()); | 433 EXPECT_TRUE(time_source->Active()); |
434 | 434 |
435 // Fail the draw again. | 435 // Fail the draw again. |
436 time_source->tick(); | 436 time_source->tick(); |
437 EXPECT_EQ(2, client.num_draws()); | 437 EXPECT_EQ(2, client.num_draws()); |
438 EXPECT_TRUE(scheduler->CommitPending()); | 438 EXPECT_TRUE(scheduler->CommitPending()); |
439 EXPECT_TRUE(scheduler->RedrawPending()); | 439 EXPECT_TRUE(scheduler->RedrawPending()); |
440 EXPECT_TRUE(time_source->active()); | 440 EXPECT_TRUE(time_source->Active()); |
441 | 441 |
442 // Draw successfully. | 442 // Draw successfully. |
443 client.SetDrawWillHappen(true); | 443 client.SetDrawWillHappen(true); |
444 time_source->tick(); | 444 time_source->tick(); |
445 EXPECT_EQ(3, client.num_draws()); | 445 EXPECT_EQ(3, client.num_draws()); |
446 EXPECT_TRUE(scheduler->CommitPending()); | 446 EXPECT_TRUE(scheduler->CommitPending()); |
447 EXPECT_FALSE(scheduler->RedrawPending()); | 447 EXPECT_FALSE(scheduler->RedrawPending()); |
448 EXPECT_FALSE(time_source->active()); | 448 EXPECT_FALSE(time_source->Active()); |
449 } | 449 } |
450 | 450 |
451 TEST(SchedulerTest, NoBeginFrameWhenDrawFails) { | 451 TEST(SchedulerTest, NoBeginFrameWhenDrawFails) { |
452 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 452 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
453 SchedulerClientThatsetNeedsCommitInsideDraw client; | 453 SchedulerClientThatsetNeedsCommitInsideDraw client; |
454 scoped_ptr<FakeFrameRateController> controller( | 454 scoped_ptr<FakeFrameRateController> controller( |
455 new FakeFrameRateController(time_source)); | 455 new FakeFrameRateController(time_source)); |
456 FakeFrameRateController* controller_ptr = controller.get(); | 456 FakeFrameRateController* controller_ptr = controller.get(); |
457 SchedulerSettings default_scheduler_settings; | 457 SchedulerSettings default_scheduler_settings; |
458 scoped_ptr<Scheduler> scheduler = | 458 scoped_ptr<Scheduler> scheduler = |
459 Scheduler::Create(&client, | 459 Scheduler::Create(&client, |
460 controller.PassAs<FrameRateController>(), | 460 controller.PassAs<FrameRateController>(), |
461 default_scheduler_settings); | 461 default_scheduler_settings); |
462 client.SetScheduler(scheduler.get()); | 462 client.SetScheduler(scheduler.get()); |
463 scheduler->SetCanBeginFrame(true); | 463 scheduler->SetCanBeginFrame(true); |
464 scheduler->SetVisible(true); | 464 scheduler->SetVisible(true); |
465 scheduler->SetCanDraw(true); | 465 scheduler->SetCanDraw(true); |
466 | 466 |
467 EXPECT_EQ(0, controller_ptr->numFramesPending()); | 467 EXPECT_EQ(0, controller_ptr->numFramesPending()); |
468 | 468 |
469 scheduler->SetNeedsRedraw(); | 469 scheduler->SetNeedsRedraw(); |
470 EXPECT_TRUE(scheduler->RedrawPending()); | 470 EXPECT_TRUE(scheduler->RedrawPending()); |
471 EXPECT_TRUE(time_source->active()); | 471 EXPECT_TRUE(time_source->Active()); |
472 EXPECT_EQ(0, client.num_draws()); | 472 EXPECT_EQ(0, client.num_draws()); |
473 | 473 |
474 // Draw successfully, this starts a new frame. | 474 // Draw successfully, this starts a new frame. |
475 time_source->tick(); | 475 time_source->tick(); |
476 EXPECT_EQ(1, client.num_draws()); | 476 EXPECT_EQ(1, client.num_draws()); |
477 EXPECT_EQ(1, controller_ptr->numFramesPending()); | 477 EXPECT_EQ(1, controller_ptr->numFramesPending()); |
478 scheduler->DidSwapBuffersComplete(); | 478 scheduler->DidSwapBuffersComplete(); |
479 EXPECT_EQ(0, controller_ptr->numFramesPending()); | 479 EXPECT_EQ(0, controller_ptr->numFramesPending()); |
480 | 480 |
481 scheduler->SetNeedsRedraw(); | 481 scheduler->SetNeedsRedraw(); |
482 EXPECT_TRUE(scheduler->RedrawPending()); | 482 EXPECT_TRUE(scheduler->RedrawPending()); |
483 EXPECT_TRUE(time_source->active()); | 483 EXPECT_TRUE(time_source->Active()); |
484 | 484 |
485 // Fail to draw, this should not start a frame. | 485 // Fail to draw, this should not start a frame. |
486 client.SetDrawWillHappen(false); | 486 client.SetDrawWillHappen(false); |
487 time_source->tick(); | 487 time_source->tick(); |
488 EXPECT_EQ(2, client.num_draws()); | 488 EXPECT_EQ(2, client.num_draws()); |
489 EXPECT_EQ(0, controller_ptr->numFramesPending()); | 489 EXPECT_EQ(0, controller_ptr->numFramesPending()); |
490 } | 490 } |
491 | 491 |
492 TEST(SchedulerTest, NoBeginFrameWhenSwapFailsDuringForcedCommit) { | 492 TEST(SchedulerTest, NoBeginFrameWhenSwapFailsDuringForcedCommit) { |
493 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 493 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 scheduler->DidLoseOutputSurface(); | 540 scheduler->DidLoseOutputSurface(); |
541 // Verifying that it's 1 so that we know that it's reset on recreate. | 541 // Verifying that it's 1 so that we know that it's reset on recreate. |
542 EXPECT_EQ(1, controller_ptr->numFramesPending()); | 542 EXPECT_EQ(1, controller_ptr->numFramesPending()); |
543 | 543 |
544 scheduler->DidRecreateOutputSurface(); | 544 scheduler->DidRecreateOutputSurface(); |
545 EXPECT_EQ(0, controller_ptr->numFramesPending()); | 545 EXPECT_EQ(0, controller_ptr->numFramesPending()); |
546 } | 546 } |
547 | 547 |
548 } // namespace | 548 } // namespace |
549 } // namespace cc | 549 } // namespace cc |
OLD | NEW |