summaryrefslogtreecommitdiffstats
path: root/cc/scheduler/scheduler_unittest.cc
blob: a2c968cd300ad660b24ca538316e44bd93bc5f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
// Copyright 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/scheduler/scheduler.h"

#include <vector>

#include "base/logging.h"
#include "cc/test/scheduler_test_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {
namespace {

class FakeSchedulerClient : public SchedulerClient {
 public:
  FakeSchedulerClient() { Reset(); }
  void Reset() {
    actions_.clear();
    draw_will_happen_ = true;
    swap_will_happen_if_draw_happens_ = true;
    num_draws_ = 0;
  }

  int num_draws() const { return num_draws_; }
  int num_actions_() const { return static_cast<int>(actions_.size()); }
  const char* Action(int i) const { return actions_[i]; }

  bool HasAction(const char* action) const {
    for (size_t i = 0; i < actions_.size(); i++)
      if (!strcmp(actions_[i], action))
        return true;
    return false;
  }

  void SetDrawWillHappen(bool draw_will_happen) {
    draw_will_happen_ = draw_will_happen;
  }
  void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) {
    swap_will_happen_if_draw_happens_ = swap_will_happen_if_draw_happens;
  }

  // Scheduler Implementation.
  virtual void ScheduledActionBeginFrame() OVERRIDE {
    actions_.push_back("ScheduledActionBeginFrame");
  }
  virtual ScheduledActionDrawAndSwapResult
  ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
    actions_.push_back("ScheduledActionDrawAndSwapIfPossible");
    num_draws_++;
    return ScheduledActionDrawAndSwapResult(draw_will_happen_,
                                            draw_will_happen_ &&
                                            swap_will_happen_if_draw_happens_);
  }
  virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced()
      OVERRIDE {
    actions_.push_back("ScheduledActionDrawAndSwapForced");
    return ScheduledActionDrawAndSwapResult(true,
                                            swap_will_happen_if_draw_happens_);
  }
  virtual void ScheduledActionCommit() OVERRIDE {
    actions_.push_back("ScheduledActionCommit");
  }
  virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE {
    actions_.push_back("ScheduledActionCheckForCompletedTileUploads");
  }
  virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE {
    actions_.push_back("ScheduledActionActivatePendingTreeIfNeeded");
  }
  virtual void ScheduledActionBeginContextRecreation() OVERRIDE {
    actions_.push_back("ScheduledActionBeginContextRecreation");
  }
  virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE {
    actions_.push_back("ScheduledActionAcquireLayerTexturesForMainThread");
  }
  virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}

 protected:
  bool draw_will_happen_;
  bool swap_will_happen_if_draw_happens_;
  int num_draws_;
  std::vector<const char*> actions_;
};

TEST(SchedulerTest, RequestCommit) {
  FakeSchedulerClient client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  // SetNeedsCommit should begin the frame.
  scheduler->SetNeedsCommit();
  EXPECT_EQ(1, client.num_actions_());
  EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0));
  EXPECT_FALSE(time_source->Active());
  client.Reset();

  // BeginFrameComplete should commit
  scheduler->BeginFrameComplete();
  EXPECT_EQ(1, client.num_actions_());
  EXPECT_STREQ("ScheduledActionCommit", client.Action(0));
  EXPECT_TRUE(time_source->Active());
  client.Reset();

  // Tick should draw.
  time_source->Tick();
  EXPECT_EQ(1, client.num_actions_());
  EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0));
  EXPECT_FALSE(time_source->Active());
  client.Reset();

  // Timer should be off.
  EXPECT_FALSE(time_source->Active());
}

TEST(SchedulerTest, RequestCommitAfterBeginFrame) {
  FakeSchedulerClient client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  // SetNedsCommit should begin the frame.
  scheduler->SetNeedsCommit();
  EXPECT_EQ(1, client.num_actions_());
  EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0));
  client.Reset();

  // Now SetNeedsCommit again. Calling here means we need a second frame.
  scheduler->SetNeedsCommit();

  // Since, another commit is needed, BeginFrameComplete should commit,
  // then begin another frame.
  scheduler->BeginFrameComplete();
  EXPECT_EQ(1, client.num_actions_());
  EXPECT_STREQ("ScheduledActionCommit", client.Action(0));
  client.Reset();

  // Tick should draw but then begin another frame.
  time_source->Tick();
  EXPECT_FALSE(time_source->Active());
  EXPECT_EQ(2, client.num_actions_());
  EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0));
  EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(1));
  client.Reset();
}

TEST(SchedulerTest, TextureAcquisitionCollision) {
  FakeSchedulerClient client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  scheduler->SetNeedsCommit();
  scheduler->SetMainThreadNeedsLayerTextures();
  EXPECT_EQ(2, client.num_actions_());
  EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0));
  EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread",
               client.Action(1));
  client.Reset();

  // Compositor not scheduled to draw because textures are locked by main thread
  EXPECT_FALSE(time_source->Active());

  // Trigger the commit
  scheduler->BeginFrameComplete();
  EXPECT_TRUE(time_source->Active());
  client.Reset();

  // Between commit and draw, texture acquisition for main thread delayed,
  // and main thread blocks.
  scheduler->SetMainThreadNeedsLayerTextures();
  EXPECT_EQ(0, client.num_actions_());
  client.Reset();

  // Once compositor draw complete, the delayed texture acquisition fires.
  time_source->Tick();
  EXPECT_EQ(3, client.num_actions_());
  EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0));
  EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread",
               client.Action(1));
  EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(2));
  client.Reset();
}

TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
  FakeSchedulerClient client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  scheduler->SetNeedsCommit();
  scheduler->BeginFrameComplete();
  scheduler->SetMainThreadNeedsLayerTextures();
  client.Reset();
  // Verify that pending texture acquisition fires when visibility
  // is lost in order to avoid a deadlock.
  scheduler->SetVisible(false);
  EXPECT_EQ(1, client.num_actions_());
  EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread",
               client.Action(0));
  client.Reset();

  // Regaining visibility with textures acquired by main thread while
  // compositor is waiting for first draw should result in a request
  // for a new frame in order to escape a deadlock.
  scheduler->SetVisible(true);
  EXPECT_EQ(1, client.num_actions_());
  EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0));
  client.Reset();
}

class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
 public:
  SchedulerClientThatsetNeedsDrawInsideDraw() : scheduler_(NULL) {}

  void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; }

  virtual void ScheduledActionBeginFrame() OVERRIDE {}
  virtual ScheduledActionDrawAndSwapResult
  ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
    // Only SetNeedsRedraw the first time this is called
    if (!num_draws_)
      scheduler_->SetNeedsRedraw();
    return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
  }

  virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced()
      OVERRIDE {
    NOTREACHED();
    return ScheduledActionDrawAndSwapResult(true, true);
  }

  virtual void ScheduledActionCommit() OVERRIDE {}
  virtual void ScheduledActionBeginContextRecreation() OVERRIDE {}
  virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}

 protected:
  Scheduler* scheduler_;
};

// Tests for two different situations:
// 1. the scheduler dropping SetNeedsRedraw requests that happen inside
//    a ScheduledActionDrawAndSwap
// 2. the scheduler drawing twice inside a single tick
TEST(SchedulerTest, RequestRedrawInsideDraw) {
  SchedulerClientThatsetNeedsDrawInsideDraw client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  client.SetScheduler(scheduler.get());
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  scheduler->SetNeedsRedraw();
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());
  EXPECT_EQ(0, client.num_draws());

  time_source->Tick();
  EXPECT_EQ(1, client.num_draws());
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());

  time_source->Tick();
  EXPECT_EQ(2, client.num_draws());
  EXPECT_FALSE(scheduler->RedrawPending());
  EXPECT_FALSE(time_source->Active());
}

// Test that requesting redraw inside a failed draw doesn't lose the request.
TEST(SchedulerTest, RequestRedrawInsideFailedDraw) {
  SchedulerClientThatsetNeedsDrawInsideDraw client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  client.SetScheduler(scheduler.get());
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);
  client.SetDrawWillHappen(false);

  scheduler->SetNeedsRedraw();
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());
  EXPECT_EQ(0, client.num_draws());

  // Fail the draw.
  time_source->Tick();
  EXPECT_EQ(1, client.num_draws());

  // We have a commit pending and the draw failed, and we didn't lose the redraw
  // request.
  EXPECT_TRUE(scheduler->CommitPending());
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());

  // Fail the draw again.
  time_source->Tick();
  EXPECT_EQ(2, client.num_draws());
  EXPECT_TRUE(scheduler->CommitPending());
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());

  // Draw successfully.
  client.SetDrawWillHappen(true);
  time_source->Tick();
  EXPECT_EQ(3, client.num_draws());
  EXPECT_TRUE(scheduler->CommitPending());
  EXPECT_FALSE(scheduler->RedrawPending());
  EXPECT_FALSE(time_source->Active());
}

class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient {
 public:
  SchedulerClientThatsetNeedsCommitInsideDraw() : scheduler_(NULL) {}

  void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; }

  virtual void ScheduledActionBeginFrame() OVERRIDE {}
  virtual ScheduledActionDrawAndSwapResult
  ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
    // Only SetNeedsCommit the first time this is called
    if (!num_draws_)
      scheduler_->SetNeedsCommit();
    return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
  }

  virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced()
      OVERRIDE {
    NOTREACHED();
    return ScheduledActionDrawAndSwapResult(true, true);
  }

  virtual void ScheduledActionCommit() OVERRIDE {}
  virtual void ScheduledActionBeginContextRecreation() OVERRIDE {}
  virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}

 protected:
  Scheduler* scheduler_;
};

// Tests for the scheduler infinite-looping on SetNeedsCommit requests that
// happen inside a ScheduledActionDrawAndSwap
TEST(SchedulerTest, RequestCommitInsideDraw) {
  SchedulerClientThatsetNeedsCommitInsideDraw client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  client.SetScheduler(scheduler.get());
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  scheduler->SetNeedsRedraw();
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_EQ(0, client.num_draws());
  EXPECT_TRUE(time_source->Active());

  time_source->Tick();
  EXPECT_FALSE(time_source->Active());
  EXPECT_EQ(1, client.num_draws());
  EXPECT_TRUE(scheduler->CommitPending());
  scheduler->BeginFrameComplete();

  time_source->Tick();
  EXPECT_EQ(2, client.num_draws());
  EXPECT_FALSE(time_source->Active());
  EXPECT_FALSE(scheduler->RedrawPending());
}

// Tests that when a draw fails then the pending commit should not be dropped.
TEST(SchedulerTest, RequestCommitInsideFailedDraw) {
  SchedulerClientThatsetNeedsDrawInsideDraw client;
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        make_scoped_ptr(new FrameRateController(time_source)),
                        default_scheduler_settings);
  client.SetScheduler(scheduler.get());
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);
  client.SetDrawWillHappen(false);

  scheduler->SetNeedsRedraw();
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());
  EXPECT_EQ(0, client.num_draws());

  // Fail the draw.
  time_source->Tick();
  EXPECT_EQ(1, client.num_draws());

  // We have a commit pending and the draw failed, and we didn't lose the commit
  // request.
  EXPECT_TRUE(scheduler->CommitPending());
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());

  // Fail the draw again.
  time_source->Tick();
  EXPECT_EQ(2, client.num_draws());
  EXPECT_TRUE(scheduler->CommitPending());
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());

  // Draw successfully.
  client.SetDrawWillHappen(true);
  time_source->Tick();
  EXPECT_EQ(3, client.num_draws());
  EXPECT_TRUE(scheduler->CommitPending());
  EXPECT_FALSE(scheduler->RedrawPending());
  EXPECT_FALSE(time_source->Active());
}

TEST(SchedulerTest, NoBeginFrameWhenDrawFails) {
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  SchedulerClientThatsetNeedsCommitInsideDraw client;
  scoped_ptr<FakeFrameRateController> controller(
      new FakeFrameRateController(time_source));
  FakeFrameRateController* controller_ptr = controller.get();
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        controller.PassAs<FrameRateController>(),
                        default_scheduler_settings);
  client.SetScheduler(scheduler.get());
  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  EXPECT_EQ(0, controller_ptr->NumFramesPending());

  scheduler->SetNeedsRedraw();
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());
  EXPECT_EQ(0, client.num_draws());

  // Draw successfully, this starts a new frame.
  time_source->Tick();
  EXPECT_EQ(1, client.num_draws());
  EXPECT_EQ(1, controller_ptr->NumFramesPending());
  scheduler->DidSwapBuffersComplete();
  EXPECT_EQ(0, controller_ptr->NumFramesPending());

  scheduler->SetNeedsRedraw();
  EXPECT_TRUE(scheduler->RedrawPending());
  EXPECT_TRUE(time_source->Active());

  // Fail to draw, this should not start a frame.
  client.SetDrawWillHappen(false);
  time_source->Tick();
  EXPECT_EQ(2, client.num_draws());
  EXPECT_EQ(0, controller_ptr->NumFramesPending());
}

TEST(SchedulerTest, NoBeginFrameWhenSwapFailsDuringForcedCommit) {
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  FakeSchedulerClient client;
  scoped_ptr<FakeFrameRateController> controller(
      new FakeFrameRateController(time_source));
  FakeFrameRateController* controller_ptr = controller.get();
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        controller.PassAs<FrameRateController>(),
                        default_scheduler_settings);

  EXPECT_EQ(0, controller_ptr->NumFramesPending());

  // Tell the client that it will fail to swap.
  client.SetDrawWillHappen(true);
  client.SetSwapWillHappenIfDrawHappens(false);

  // Get the compositor to do a ScheduledActionDrawAndSwapForced.
  scheduler->SetNeedsRedraw();
  scheduler->SetNeedsForcedRedraw();
  EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapForced"));

  // We should not have told the frame rate controller that we began a frame.
  EXPECT_EQ(0, controller_ptr->NumFramesPending());
}

TEST(SchedulerTest, RecreateOutputSurfaceClearsPendingDrawCount) {
  scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
  FakeSchedulerClient client;
  scoped_ptr<FakeFrameRateController> controller(
      new FakeFrameRateController(time_source));
  FakeFrameRateController* controller_ptr = controller.get();
  SchedulerSettings default_scheduler_settings;
  scoped_ptr<Scheduler> scheduler =
      Scheduler::Create(&client,
                        controller.PassAs<FrameRateController>(),
                        default_scheduler_settings);

  scheduler->SetCanBeginFrame(true);
  scheduler->SetVisible(true);
  scheduler->SetCanDraw(true);

  // Draw successfully, this starts a new frame.
  scheduler->SetNeedsRedraw();
  time_source->Tick();
  EXPECT_EQ(1, controller_ptr->NumFramesPending());

  scheduler->DidLoseOutputSurface();
  // Verifying that it's 1 so that we know that it's reset on recreate.
  EXPECT_EQ(1, controller_ptr->NumFramesPending());

  scheduler->DidRecreateOutputSurface();
  EXPECT_EQ(0, controller_ptr->NumFramesPending());
}

}  // namespace
}  // namespace cc