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

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

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing Windows compile (no idea why this worked on non-windows!) Created 6 years, 3 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 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 25 matching lines...) Expand all
36 EXPECT_ACTION(action, client, 0, 1) 36 EXPECT_ACTION(action, client, 0, 1)
37 37
38 namespace cc { 38 namespace cc {
39 namespace { 39 namespace {
40 40
41 class FakeSchedulerClient; 41 class FakeSchedulerClient;
42 42
43 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, 43 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
44 FakeSchedulerClient* client); 44 FakeSchedulerClient* client);
45 45
46 class TestScheduler : public Scheduler {
47 public:
48 static scoped_ptr<TestScheduler> Create(
49 SchedulerClient* client,
50 const SchedulerSettings& scheduler_settings,
51 int layer_tree_host_id,
52 const scoped_refptr<base::SingleThreadTaskRunner>& impl_task_runner) {
53 return make_scoped_ptr(new TestScheduler(
54 client, scheduler_settings, layer_tree_host_id, impl_task_runner));
55 }
56
57 virtual ~TestScheduler() {}
58
59 bool IsBeginRetroFrameArgsEmpty() const {
60 return begin_retro_frame_args_.empty();
61 }
62
63 bool IsSyntheticBeginFrameSourceActive() const {
64 return synthetic_begin_frame_source_->IsActive();
65 }
66
67 private:
68 TestScheduler(
69 SchedulerClient* client,
70 const SchedulerSettings& scheduler_settings,
71 int layer_tree_host_id,
72 const scoped_refptr<base::SingleThreadTaskRunner> & impl_task_runner)
73 : Scheduler(client,
74 scheduler_settings,
75 layer_tree_host_id,
76 impl_task_runner) {
77 }
78 };
79
80 class FakeSchedulerClient : public SchedulerClient { 46 class FakeSchedulerClient : public SchedulerClient {
81 public: 47 public:
82 FakeSchedulerClient() 48 FakeSchedulerClient()
83 : needs_begin_frame_(false), 49 : needs_begin_frame_(false),
84 automatic_swap_ack_(true), 50 automatic_swap_ack_(true),
85 swap_contains_incomplete_tile_(false), 51 swap_contains_incomplete_tile_(false),
86 redraw_will_happen_if_update_visible_tiles_happens_(false) { 52 redraw_will_happen_if_update_visible_tiles_happens_(false),
53 now_src_(TestNowSource::Create()) {
87 Reset(); 54 Reset();
88 } 55 }
89 56
90 void Reset() { 57 void Reset() {
91 actions_.clear(); 58 actions_.clear();
92 states_.clear(); 59 states_.clear();
93 draw_will_happen_ = true; 60 draw_will_happen_ = true;
94 swap_will_happen_if_draw_happens_ = true; 61 swap_will_happen_if_draw_happens_ = true;
95 num_draws_ = 0; 62 num_draws_ = 0;
96 log_anticipated_draw_time_change_ = false; 63 log_anticipated_draw_time_change_ = false;
97 } 64 }
98 65
99 TestScheduler* CreateScheduler(const SchedulerSettings& settings) { 66 TestScheduler* CreateScheduler(const SchedulerSettings& settings) {
100 task_runner_ = new OrderedSimpleTaskRunner; 67 scheduler_ = TestScheduler::Create(now_src_, this, settings, 0);
101 scheduler_ = TestScheduler::Create(this, settings, 0, task_runner_); 68 // Fail if we need to run 100 tasks in a row.
69 task_runner().SetRunTaskLimit(100);
102 return scheduler_.get(); 70 return scheduler_.get();
103 } 71 }
104 72
105 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it 73 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it
106 // for tests that do. 74 // for tests that do.
107 void set_log_anticipated_draw_time_change(bool log) { 75 void set_log_anticipated_draw_time_change(bool log) {
108 log_anticipated_draw_time_change_ = log; 76 log_anticipated_draw_time_change_ = log;
109 } 77 }
110 bool needs_begin_frame() { return needs_begin_frame_; } 78 bool needs_begin_frame() { return needs_begin_frame_; }
111 int num_draws() const { return num_draws_; } 79 int num_draws() const { return num_draws_; }
112 int num_actions_() const { return static_cast<int>(actions_.size()); } 80 int num_actions_() const { return static_cast<int>(actions_.size()); }
113 const char* Action(int i) const { return actions_[i]; } 81 const char* Action(int i) const { return actions_[i]; }
114 std::string StateForAction(int i) const { return states_[i]->ToString(); } 82 std::string StateForAction(int i) const { return states_[i]->ToString(); }
115 base::TimeTicks posted_begin_impl_frame_deadline() const { 83 base::TimeTicks posted_begin_impl_frame_deadline() const {
116 return posted_begin_impl_frame_deadline_; 84 return posted_begin_impl_frame_deadline_;
117 } 85 }
118 86
119 OrderedSimpleTaskRunner& task_runner() { return *task_runner_.get(); } 87 base::Callback<bool(void)> WhileImplFrameDeadlinePending(bool state) {
Sami 2014/09/01 11:35:32 I didn't see any calls to this with |state| = fals
mithro-old 2014/09/01 12:00:19 Line 107 uses false, most of the other calls use t
88 return base::Bind(
89 &FakeSchedulerClient::WhileImplFrameDeadlinePendingCallback,
90 base::Unretained(this),
91 state);
92 }
93
94 bool WhileImplFrameDeadlinePendingCallback(bool state) {
Sami 2014/09/01 11:35:32 Could you move this under protected: (or private:)
mithro-old 2014/09/01 12:00:19 Done.
95 return scheduler_->BeginImplFrameDeadlinePending() == state;
96 }
97
98 void AdvanceFrame() {
99 bool external_begin_frame =
100 scheduler_->settings().begin_frame_scheduling_enabled &&
101 scheduler_->settings().throttle_frame_production;
102
103 if (external_begin_frame) {
104 scheduler_->BeginFrame(CreateBeginFrameArgsForTesting(now_src_));
105 }
106
107 EXPECT_TRUE(task_runner().RunTasks(WhileImplFrameDeadlinePending(false)));
108 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
109 }
110
111 OrderedSimpleTaskRunner& task_runner() { return scheduler_->task_runner(); }
112 TestNowSource* now_src() { return now_src_.get(); }
120 113
121 int ActionIndex(const char* action) const { 114 int ActionIndex(const char* action) const {
122 for (size_t i = 0; i < actions_.size(); i++) 115 for (size_t i = 0; i < actions_.size(); i++)
123 if (!strcmp(actions_[i], action)) 116 if (!strcmp(actions_[i], action))
124 return i; 117 return i;
125 return -1; 118 return -1;
126 } 119 }
127 120
128 void SetSwapContainsIncompleteTile(bool contain) { 121 void SetSwapContainsIncompleteTile(bool contain) {
129 swap_contains_incomplete_tile_ = contain; 122 swap_contains_incomplete_tile_ = contain;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 bool swap_will_happen_if_draw_happens_; 227 bool swap_will_happen_if_draw_happens_;
235 bool automatic_swap_ack_; 228 bool automatic_swap_ack_;
236 int num_draws_; 229 int num_draws_;
237 bool log_anticipated_draw_time_change_; 230 bool log_anticipated_draw_time_change_;
238 bool swap_contains_incomplete_tile_; 231 bool swap_contains_incomplete_tile_;
239 bool redraw_will_happen_if_update_visible_tiles_happens_; 232 bool redraw_will_happen_if_update_visible_tiles_happens_;
240 base::TimeTicks posted_begin_impl_frame_deadline_; 233 base::TimeTicks posted_begin_impl_frame_deadline_;
241 std::vector<const char*> actions_; 234 std::vector<const char*> actions_;
242 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_; 235 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_;
243 scoped_ptr<TestScheduler> scheduler_; 236 scoped_ptr<TestScheduler> scheduler_;
244 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; 237 scoped_refptr<TestNowSource> now_src_;
245 }; 238 };
246 239
247 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, 240 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
248 FakeSchedulerClient* client) { 241 FakeSchedulerClient* client) {
249 bool client_initiates_begin_frame = 242 TRACE_EVENT0("cc",
250 scheduler->settings().begin_frame_scheduling_enabled && 243 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit");
251 scheduler->settings().throttle_frame_production;
252 244
253 scheduler->DidCreateAndInitializeOutputSurface(); 245 scheduler->DidCreateAndInitializeOutputSurface();
254 scheduler->SetNeedsCommit(); 246 scheduler->SetNeedsCommit();
255 scheduler->NotifyBeginMainFrameStarted(); 247 scheduler->NotifyBeginMainFrameStarted();
256 scheduler->NotifyReadyToCommit(); 248 scheduler->NotifyReadyToCommit();
257 if (scheduler->settings().impl_side_painting) 249 if (scheduler->settings().impl_side_painting)
258 scheduler->NotifyReadyToActivate(); 250 scheduler->NotifyReadyToActivate();
251
259 // Go through the motions to draw the commit. 252 // Go through the motions to draw the commit.
260 if (client_initiates_begin_frame) 253 client->AdvanceFrame();
261 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
262 else
263 client->task_runner().RunPendingTasks(); // Run posted BeginFrame.
264 254
265 // Run the posted deadline task. 255 // Run the posted deadline task.
266 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 256 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
267 client->task_runner().RunPendingTasks(); 257 client->task_runner().RunTasks(client->WhileImplFrameDeadlinePending(true));
268 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 258 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
269 259
270 // We need another BeginImplFrame so Scheduler calls 260 // We need another BeginImplFrame so Scheduler calls
271 // SetNeedsBeginFrame(false). 261 // SetNeedsBeginFrame(false).
272 if (client_initiates_begin_frame) 262 client->AdvanceFrame();
273 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
274 else
275 client->task_runner().RunPendingTasks(); // Run posted BeginFrame.
276 263
277 // Run the posted deadline task. 264 // Run the posted deadline task.
278 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 265 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
279 client->task_runner().RunPendingTasks(); 266 client->task_runner().RunTasks(client->WhileImplFrameDeadlinePending(true));
280 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 267 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
281 } 268 }
282 269
283 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { 270 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
284 FakeSchedulerClient client; 271 FakeSchedulerClient client;
285 SchedulerSettings default_scheduler_settings; 272 SchedulerSettings default_scheduler_settings;
286 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 273 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
287 scheduler->SetCanStart(); 274 scheduler->SetCanStart();
288 scheduler->SetVisible(true); 275 scheduler->SetVisible(true);
289 scheduler->SetCanDraw(true); 276 scheduler->SetCanDraw(true);
(...skipping 15 matching lines...) Expand all
305 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 292 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
306 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 293 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
307 294
308 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 295 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
309 client.Reset(); 296 client.Reset();
310 scheduler->SetNeedsCommit(); 297 scheduler->SetNeedsCommit();
311 EXPECT_TRUE(client.needs_begin_frame()); 298 EXPECT_TRUE(client.needs_begin_frame());
312 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 299 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
313 client.Reset(); 300 client.Reset();
314 301
315 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 302 client.AdvanceFrame();
316 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 303 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
317 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 304 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
318 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 305 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
319 EXPECT_TRUE(client.needs_begin_frame()); 306 EXPECT_TRUE(client.needs_begin_frame());
320 client.Reset(); 307 client.Reset();
321 308
322 // If we don't swap on the deadline, we wait for the next BeginFrame. 309 // If we don't swap on the deadline, we wait for the next BeginFrame.
323 client.task_runner().RunPendingTasks(); // Run posted deadline. 310 client.task_runner().RunPendingTasks(); // Run posted deadline.
324 EXPECT_NO_ACTION(client); 311 EXPECT_NO_ACTION(client);
325 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 312 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
326 EXPECT_TRUE(client.needs_begin_frame()); 313 EXPECT_TRUE(client.needs_begin_frame());
327 client.Reset(); 314 client.Reset();
328 315
329 // NotifyReadyToCommit should trigger the commit. 316 // NotifyReadyToCommit should trigger the commit.
330 scheduler->NotifyBeginMainFrameStarted(); 317 scheduler->NotifyBeginMainFrameStarted();
331 scheduler->NotifyReadyToCommit(); 318 scheduler->NotifyReadyToCommit();
332 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 319 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
333 EXPECT_TRUE(client.needs_begin_frame()); 320 EXPECT_TRUE(client.needs_begin_frame());
334 client.Reset(); 321 client.Reset();
335 322
336 // BeginImplFrame should prepare the draw. 323 // BeginImplFrame should prepare the draw.
337 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 324 client.AdvanceFrame();
338 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 325 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
339 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 326 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
340 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 327 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
341 EXPECT_TRUE(client.needs_begin_frame()); 328 EXPECT_TRUE(client.needs_begin_frame());
342 client.Reset(); 329 client.Reset();
343 330
344 // BeginImplFrame deadline should draw. 331 // BeginImplFrame deadline should draw.
345 client.task_runner().RunPendingTasks(); // Run posted deadline. 332 client.task_runner().RunPendingTasks(); // Run posted deadline.
346 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); 333 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
347 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 334 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
348 EXPECT_TRUE(client.needs_begin_frame()); 335 EXPECT_TRUE(client.needs_begin_frame());
349 client.Reset(); 336 client.Reset();
350 337
351 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 338 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
352 // to avoid excessive toggles. 339 // to avoid excessive toggles.
353 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 340 client.AdvanceFrame();
354 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 341 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
355 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 342 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
356 client.Reset(); 343 client.Reset();
357 344
358 client.task_runner().RunPendingTasks(); // Run posted deadline. 345 client.task_runner().RunPendingTasks(); // Run posted deadline.
359 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 346 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
360 EXPECT_FALSE(client.needs_begin_frame()); 347 EXPECT_FALSE(client.needs_begin_frame());
361 client.Reset(); 348 client.Reset();
362 } 349 }
363 350
364 TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { 351 TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) {
365 FakeSchedulerClient client; 352 FakeSchedulerClient client;
366 SchedulerSettings scheduler_settings; 353 SchedulerSettings scheduler_settings;
367 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); 354 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings);
368 scheduler->SetCanStart(); 355 scheduler->SetCanStart();
369 scheduler->SetVisible(true); 356 scheduler->SetVisible(true);
370 scheduler->SetCanDraw(true); 357 scheduler->SetCanDraw(true);
371 358
372 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 359 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
373 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 360 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
374 client.Reset(); 361 client.Reset();
375 362
376 // SetNeedsCommit should begin the frame. 363 // SetNeedsCommit should begin the frame.
377 scheduler->SetNeedsCommit(); 364 scheduler->SetNeedsCommit();
378 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 365 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
379 366
380 client.Reset(); 367 client.Reset();
381 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 368 client.AdvanceFrame();
382 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 369 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
383 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 370 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
384 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 371 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
385 372
386 EXPECT_TRUE(client.needs_begin_frame()); 373 EXPECT_TRUE(client.needs_begin_frame());
387 client.Reset(); 374 client.Reset();
388 375
389 // Now SetNeedsCommit again. Calling here means we need a second commit. 376 // Now SetNeedsCommit again. Calling here means we need a second commit.
390 scheduler->SetNeedsCommit(); 377 scheduler->SetNeedsCommit();
391 EXPECT_EQ(client.num_actions_(), 0); 378 EXPECT_EQ(client.num_actions_(), 0);
392 client.Reset(); 379 client.Reset();
393 380
394 // Finish the first commit. 381 // Finish the first commit.
395 scheduler->NotifyBeginMainFrameStarted(); 382 scheduler->NotifyBeginMainFrameStarted();
396 scheduler->NotifyReadyToCommit(); 383 scheduler->NotifyReadyToCommit();
397 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 384 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
398 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 385 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
399 client.Reset(); 386 client.Reset();
400 client.task_runner().RunPendingTasks(); // Run posted deadline. 387 client.task_runner().RunPendingTasks(); // Run posted deadline.
401 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 388 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
402 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 389 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
403 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 390 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
404 391
405 // Because we just swapped, the Scheduler should also request the next 392 // Because we just swapped, the Scheduler should also request the next
406 // BeginImplFrame from the OutputSurface. 393 // BeginImplFrame from the OutputSurface.
407 EXPECT_TRUE(client.needs_begin_frame()); 394 EXPECT_TRUE(client.needs_begin_frame());
408 client.Reset(); 395 client.Reset();
409 // Since another commit is needed, the next BeginImplFrame should initiate 396 // Since another commit is needed, the next BeginImplFrame should initiate
410 // the second commit. 397 // the second commit.
411 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 398 client.AdvanceFrame();
412 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 399 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
413 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 400 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
414 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 401 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
415 client.Reset(); 402 client.Reset();
416 403
417 // Finishing the commit before the deadline should post a new deadline task 404 // Finishing the commit before the deadline should post a new deadline task
418 // to trigger the deadline early. 405 // to trigger the deadline early.
419 scheduler->NotifyBeginMainFrameStarted(); 406 scheduler->NotifyBeginMainFrameStarted();
420 scheduler->NotifyReadyToCommit(); 407 scheduler->NotifyReadyToCommit();
421 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 408 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
422 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 409 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
423 client.Reset(); 410 client.Reset();
424 client.task_runner().RunPendingTasks(); // Run posted deadline. 411 client.task_runner().RunPendingTasks(); // Run posted deadline.
425 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 412 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
426 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 413 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
427 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 414 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
428 EXPECT_TRUE(client.needs_begin_frame()); 415 EXPECT_TRUE(client.needs_begin_frame());
429 client.Reset(); 416 client.Reset();
430 417
431 // On the next BeginImplFrame, verify we go back to a quiescent state and 418 // On the next BeginImplFrame, verify we go back to a quiescent state and
432 // no longer request BeginImplFrames. 419 // no longer request BeginImplFrames.
433 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 420 client.AdvanceFrame();
434 client.task_runner().RunPendingTasks(); // Run posted deadline. 421 client.task_runner().RunPendingTasks(); // Run posted deadline.
435 EXPECT_FALSE(client.needs_begin_frame()); 422 EXPECT_FALSE(client.needs_begin_frame());
436 client.Reset(); 423 client.Reset();
437 } 424 }
438 425
439 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { 426 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
440 public: 427 public:
441 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {} 428 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {}
442 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() 429 virtual DrawResult ScheduledActionDrawAndSwapIfPossible()
443 OVERRIDE { 430 OVERRIDE {
(...skipping 25 matching lines...) Expand all
469 scheduler->SetVisible(true); 456 scheduler->SetVisible(true);
470 scheduler->SetCanDraw(true); 457 scheduler->SetCanDraw(true);
471 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 458 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
472 client.Reset(); 459 client.Reset();
473 460
474 scheduler->SetNeedsRedraw(); 461 scheduler->SetNeedsRedraw();
475 EXPECT_TRUE(scheduler->RedrawPending()); 462 EXPECT_TRUE(scheduler->RedrawPending());
476 EXPECT_TRUE(client.needs_begin_frame()); 463 EXPECT_TRUE(client.needs_begin_frame());
477 EXPECT_EQ(0, client.num_draws()); 464 EXPECT_EQ(0, client.num_draws());
478 465
479 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 466 client.AdvanceFrame();
480 client.task_runner().RunPendingTasks(); // Run posted deadline. 467 client.task_runner().RunPendingTasks(); // Run posted deadline.
481 EXPECT_EQ(1, client.num_draws()); 468 EXPECT_EQ(1, client.num_draws());
482 EXPECT_TRUE(scheduler->RedrawPending()); 469 EXPECT_TRUE(scheduler->RedrawPending());
483 EXPECT_TRUE(client.needs_begin_frame()); 470 EXPECT_TRUE(client.needs_begin_frame());
484 471
485 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 472 client.AdvanceFrame();
486 client.task_runner().RunPendingTasks(); // Run posted deadline. 473 client.task_runner().RunPendingTasks(); // Run posted deadline.
487 EXPECT_EQ(2, client.num_draws()); 474 EXPECT_EQ(2, client.num_draws());
488 EXPECT_FALSE(scheduler->RedrawPending()); 475 EXPECT_FALSE(scheduler->RedrawPending());
489 EXPECT_TRUE(client.needs_begin_frame()); 476 EXPECT_TRUE(client.needs_begin_frame());
490 477
491 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't 478 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't
492 // swap. 479 // swap.
493 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 480 client.AdvanceFrame();
494 client.task_runner().RunPendingTasks(); // Run posted deadline. 481 client.task_runner().RunPendingTasks(); // Run posted deadline.
495 EXPECT_EQ(2, client.num_draws()); 482 EXPECT_EQ(2, client.num_draws());
496 EXPECT_FALSE(scheduler->RedrawPending()); 483 EXPECT_FALSE(scheduler->RedrawPending());
497 EXPECT_FALSE(client.needs_begin_frame()); 484 EXPECT_FALSE(client.needs_begin_frame());
498 } 485 }
499 486
500 // Test that requesting redraw inside a failed draw doesn't lose the request. 487 // Test that requesting redraw inside a failed draw doesn't lose the request.
501 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { 488 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) {
502 SchedulerClientThatsetNeedsDrawInsideDraw client; 489 SchedulerClientThatsetNeedsDrawInsideDraw client;
503 SchedulerSettings default_scheduler_settings; 490 SchedulerSettings default_scheduler_settings;
504 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 491 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
505 scheduler->SetCanStart(); 492 scheduler->SetCanStart();
506 scheduler->SetVisible(true); 493 scheduler->SetVisible(true);
507 scheduler->SetCanDraw(true); 494 scheduler->SetCanDraw(true);
508 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 495 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
509 client.Reset(); 496 client.Reset();
510 497
511 client.SetDrawWillHappen(false); 498 client.SetDrawWillHappen(false);
512 499
513 scheduler->SetNeedsRedraw(); 500 scheduler->SetNeedsRedraw();
514 EXPECT_TRUE(scheduler->RedrawPending()); 501 EXPECT_TRUE(scheduler->RedrawPending());
515 EXPECT_TRUE(client.needs_begin_frame()); 502 EXPECT_TRUE(client.needs_begin_frame());
516 EXPECT_EQ(0, client.num_draws()); 503 EXPECT_EQ(0, client.num_draws());
517 504
518 // Fail the draw. 505 // Fail the draw.
519 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 506 client.AdvanceFrame();
520 client.task_runner().RunPendingTasks(); // Run posted deadline. 507 client.task_runner().RunPendingTasks(); // Run posted deadline.
521 EXPECT_EQ(1, client.num_draws()); 508 EXPECT_EQ(1, client.num_draws());
522 509
523 // We have a commit pending and the draw failed, and we didn't lose the redraw 510 // We have a commit pending and the draw failed, and we didn't lose the redraw
524 // request. 511 // request.
525 EXPECT_TRUE(scheduler->CommitPending()); 512 EXPECT_TRUE(scheduler->CommitPending());
526 EXPECT_TRUE(scheduler->RedrawPending()); 513 EXPECT_TRUE(scheduler->RedrawPending());
527 EXPECT_TRUE(client.needs_begin_frame()); 514 EXPECT_TRUE(client.needs_begin_frame());
528 515
529 // Fail the draw again. 516 // Fail the draw again.
530 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 517 client.AdvanceFrame();
531 client.task_runner().RunPendingTasks(); // Run posted deadline. 518 client.task_runner().RunPendingTasks(); // Run posted deadline.
532 EXPECT_EQ(2, client.num_draws()); 519 EXPECT_EQ(2, client.num_draws());
533 EXPECT_TRUE(scheduler->CommitPending()); 520 EXPECT_TRUE(scheduler->CommitPending());
534 EXPECT_TRUE(scheduler->RedrawPending()); 521 EXPECT_TRUE(scheduler->RedrawPending());
535 EXPECT_TRUE(client.needs_begin_frame()); 522 EXPECT_TRUE(client.needs_begin_frame());
536 523
537 // Draw successfully. 524 // Draw successfully.
538 client.SetDrawWillHappen(true); 525 client.SetDrawWillHappen(true);
539 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 526 client.AdvanceFrame();
540 client.task_runner().RunPendingTasks(); // Run posted deadline. 527 client.task_runner().RunPendingTasks(); // Run posted deadline.
541 EXPECT_EQ(3, client.num_draws()); 528 EXPECT_EQ(3, client.num_draws());
542 EXPECT_TRUE(scheduler->CommitPending()); 529 EXPECT_TRUE(scheduler->CommitPending());
543 EXPECT_FALSE(scheduler->RedrawPending()); 530 EXPECT_FALSE(scheduler->RedrawPending());
544 EXPECT_TRUE(client.needs_begin_frame()); 531 EXPECT_TRUE(client.needs_begin_frame());
545 } 532 }
546 533
547 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient { 534 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient {
548 public: 535 public:
549 SchedulerClientThatSetNeedsCommitInsideDraw() 536 SchedulerClientThatSetNeedsCommitInsideDraw()
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 574 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
588 client.Reset(); 575 client.Reset();
589 576
590 EXPECT_FALSE(client.needs_begin_frame()); 577 EXPECT_FALSE(client.needs_begin_frame());
591 scheduler->SetNeedsRedraw(); 578 scheduler->SetNeedsRedraw();
592 EXPECT_TRUE(scheduler->RedrawPending()); 579 EXPECT_TRUE(scheduler->RedrawPending());
593 EXPECT_EQ(0, client.num_draws()); 580 EXPECT_EQ(0, client.num_draws());
594 EXPECT_TRUE(client.needs_begin_frame()); 581 EXPECT_TRUE(client.needs_begin_frame());
595 582
596 client.SetNeedsCommitOnNextDraw(); 583 client.SetNeedsCommitOnNextDraw();
597 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 584 client.AdvanceFrame();
598 client.SetNeedsCommitOnNextDraw(); 585 client.SetNeedsCommitOnNextDraw();
599 client.task_runner().RunPendingTasks(); // Run posted deadline. 586 client.task_runner().RunPendingTasks(); // Run posted deadline.
600 EXPECT_EQ(1, client.num_draws()); 587 EXPECT_EQ(1, client.num_draws());
601 EXPECT_TRUE(scheduler->CommitPending()); 588 EXPECT_TRUE(scheduler->CommitPending());
602 EXPECT_TRUE(client.needs_begin_frame()); 589 EXPECT_TRUE(client.needs_begin_frame());
603 scheduler->NotifyBeginMainFrameStarted(); 590 scheduler->NotifyBeginMainFrameStarted();
604 scheduler->NotifyReadyToCommit(); 591 scheduler->NotifyReadyToCommit();
605 592
606 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 593 client.AdvanceFrame();
607 client.task_runner().RunPendingTasks(); // Run posted deadline. 594 client.task_runner().RunPendingTasks(); // Run posted deadline.
608 EXPECT_EQ(2, client.num_draws()); 595 EXPECT_EQ(2, client.num_draws());
609 596
610 EXPECT_FALSE(scheduler->RedrawPending()); 597 EXPECT_FALSE(scheduler->RedrawPending());
611 EXPECT_FALSE(scheduler->CommitPending()); 598 EXPECT_FALSE(scheduler->CommitPending());
612 EXPECT_TRUE(client.needs_begin_frame()); 599 EXPECT_TRUE(client.needs_begin_frame());
613 600
614 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't 601 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't
615 // swap. 602 // swap.
616 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 603 client.AdvanceFrame();
617 client.task_runner().RunPendingTasks(); // Run posted deadline. 604 client.task_runner().RunPendingTasks(); // Run posted deadline.
618 EXPECT_EQ(2, client.num_draws()); 605 EXPECT_EQ(2, client.num_draws());
619 EXPECT_FALSE(scheduler->RedrawPending()); 606 EXPECT_FALSE(scheduler->RedrawPending());
620 EXPECT_FALSE(scheduler->CommitPending()); 607 EXPECT_FALSE(scheduler->CommitPending());
621 EXPECT_FALSE(client.needs_begin_frame()); 608 EXPECT_FALSE(client.needs_begin_frame());
622 } 609 }
623 610
624 // Tests that when a draw fails then the pending commit should not be dropped. 611 // Tests that when a draw fails then the pending commit should not be dropped.
625 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { 612 TEST(SchedulerTest, RequestCommitInsideFailedDraw) {
626 SchedulerClientThatsetNeedsDrawInsideDraw client; 613 SchedulerClientThatsetNeedsDrawInsideDraw client;
627 SchedulerSettings default_scheduler_settings; 614 SchedulerSettings default_scheduler_settings;
628 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 615 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
629 scheduler->SetCanStart(); 616 scheduler->SetCanStart();
630 scheduler->SetVisible(true); 617 scheduler->SetVisible(true);
631 scheduler->SetCanDraw(true); 618 scheduler->SetCanDraw(true);
632 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 619 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
633 client.Reset(); 620 client.Reset();
634 621
635 client.SetDrawWillHappen(false); 622 client.SetDrawWillHappen(false);
636 623
637 scheduler->SetNeedsRedraw(); 624 scheduler->SetNeedsRedraw();
638 EXPECT_TRUE(scheduler->RedrawPending()); 625 EXPECT_TRUE(scheduler->RedrawPending());
639 EXPECT_TRUE(client.needs_begin_frame()); 626 EXPECT_TRUE(client.needs_begin_frame());
640 EXPECT_EQ(0, client.num_draws()); 627 EXPECT_EQ(0, client.num_draws());
641 628
642 // Fail the draw. 629 // Fail the draw.
643 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 630 client.AdvanceFrame();
644 client.task_runner().RunPendingTasks(); // Run posted deadline. 631 client.task_runner().RunPendingTasks(); // Run posted deadline.
645 EXPECT_EQ(1, client.num_draws()); 632 EXPECT_EQ(1, client.num_draws());
646 633
647 // We have a commit pending and the draw failed, and we didn't lose the commit 634 // We have a commit pending and the draw failed, and we didn't lose the commit
648 // request. 635 // request.
649 EXPECT_TRUE(scheduler->CommitPending()); 636 EXPECT_TRUE(scheduler->CommitPending());
650 EXPECT_TRUE(scheduler->RedrawPending()); 637 EXPECT_TRUE(scheduler->RedrawPending());
651 EXPECT_TRUE(client.needs_begin_frame()); 638 EXPECT_TRUE(client.needs_begin_frame());
652 639
653 // Fail the draw again. 640 // Fail the draw again.
654 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 641 client.AdvanceFrame();
655 642
656 client.task_runner().RunPendingTasks(); // Run posted deadline. 643 client.task_runner().RunPendingTasks(); // Run posted deadline.
657 EXPECT_EQ(2, client.num_draws()); 644 EXPECT_EQ(2, client.num_draws());
658 EXPECT_TRUE(scheduler->CommitPending()); 645 EXPECT_TRUE(scheduler->CommitPending());
659 EXPECT_TRUE(scheduler->RedrawPending()); 646 EXPECT_TRUE(scheduler->RedrawPending());
660 EXPECT_TRUE(client.needs_begin_frame()); 647 EXPECT_TRUE(client.needs_begin_frame());
661 648
662 // Draw successfully. 649 // Draw successfully.
663 client.SetDrawWillHappen(true); 650 client.SetDrawWillHappen(true);
664 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 651 client.AdvanceFrame();
665 client.task_runner().RunPendingTasks(); // Run posted deadline. 652 client.task_runner().RunPendingTasks(); // Run posted deadline.
666 EXPECT_EQ(3, client.num_draws()); 653 EXPECT_EQ(3, client.num_draws());
667 EXPECT_TRUE(scheduler->CommitPending()); 654 EXPECT_TRUE(scheduler->CommitPending());
668 EXPECT_FALSE(scheduler->RedrawPending()); 655 EXPECT_FALSE(scheduler->RedrawPending());
669 EXPECT_TRUE(client.needs_begin_frame()); 656 EXPECT_TRUE(client.needs_begin_frame());
670 } 657 }
671 658
672 TEST(SchedulerTest, NoSwapWhenDrawFails) { 659 TEST(SchedulerTest, NoSwapWhenDrawFails) {
673 SchedulerClientThatSetNeedsCommitInsideDraw client; 660 SchedulerClientThatSetNeedsCommitInsideDraw client;
674 SchedulerSettings default_scheduler_settings; 661 SchedulerSettings default_scheduler_settings;
675 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 662 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
676 scheduler->SetCanStart(); 663 scheduler->SetCanStart();
677 scheduler->SetVisible(true); 664 scheduler->SetVisible(true);
678 scheduler->SetCanDraw(true); 665 scheduler->SetCanDraw(true);
679 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 666 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
680 client.Reset(); 667 client.Reset();
681 668
682 scheduler->SetNeedsRedraw(); 669 scheduler->SetNeedsRedraw();
683 EXPECT_TRUE(scheduler->RedrawPending()); 670 EXPECT_TRUE(scheduler->RedrawPending());
684 EXPECT_TRUE(client.needs_begin_frame()); 671 EXPECT_TRUE(client.needs_begin_frame());
685 EXPECT_EQ(0, client.num_draws()); 672 EXPECT_EQ(0, client.num_draws());
686 673
687 // Draw successfully, this starts a new frame. 674 // Draw successfully, this starts a new frame.
688 client.SetNeedsCommitOnNextDraw(); 675 client.SetNeedsCommitOnNextDraw();
689 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 676 client.AdvanceFrame();
690 client.task_runner().RunPendingTasks(); // Run posted deadline. 677 client.task_runner().RunPendingTasks(); // Run posted deadline.
691 EXPECT_EQ(1, client.num_draws()); 678 EXPECT_EQ(1, client.num_draws());
692 679
693 scheduler->SetNeedsRedraw(); 680 scheduler->SetNeedsRedraw();
694 EXPECT_TRUE(scheduler->RedrawPending()); 681 EXPECT_TRUE(scheduler->RedrawPending());
695 EXPECT_TRUE(client.needs_begin_frame()); 682 EXPECT_TRUE(client.needs_begin_frame());
696 683
697 // Fail to draw, this should not start a frame. 684 // Fail to draw, this should not start a frame.
698 client.SetDrawWillHappen(false); 685 client.SetDrawWillHappen(false);
699 client.SetNeedsCommitOnNextDraw(); 686 client.SetNeedsCommitOnNextDraw();
700 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 687 client.AdvanceFrame();
701 client.task_runner().RunPendingTasks(); // Run posted deadline. 688 client.task_runner().RunPendingTasks(); // Run posted deadline.
702 EXPECT_EQ(2, client.num_draws()); 689 EXPECT_EQ(2, client.num_draws());
703 } 690 }
704 691
705 class SchedulerClientNeedsManageTilesInDraw : public FakeSchedulerClient { 692 class SchedulerClientNeedsManageTilesInDraw : public FakeSchedulerClient {
706 public: 693 public:
707 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() 694 virtual DrawResult ScheduledActionDrawAndSwapIfPossible()
708 OVERRIDE { 695 OVERRIDE {
709 scheduler_->SetNeedsManageTiles(); 696 scheduler_->SetNeedsManageTiles();
710 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 697 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
(...skipping 18 matching lines...) Expand all
729 EXPECT_TRUE(scheduler->RedrawPending()); 716 EXPECT_TRUE(scheduler->RedrawPending());
730 EXPECT_TRUE(scheduler->ManageTilesPending()); 717 EXPECT_TRUE(scheduler->ManageTilesPending());
731 EXPECT_TRUE(client.needs_begin_frame()); 718 EXPECT_TRUE(client.needs_begin_frame());
732 EXPECT_EQ(0, client.num_draws()); 719 EXPECT_EQ(0, client.num_draws());
733 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 720 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
734 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 721 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
735 722
736 // We have no immediate actions to perform, so the BeginImplFrame should post 723 // We have no immediate actions to perform, so the BeginImplFrame should post
737 // the deadline task. 724 // the deadline task.
738 client.Reset(); 725 client.Reset();
739 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 726 client.AdvanceFrame();
740 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 727 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
741 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 728 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
742 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 729 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
743 730
744 // On the deadline, he actions should have occured in the right order. 731 // On the deadline, he actions should have occured in the right order.
745 client.Reset(); 732 client.Reset();
746 client.task_runner().RunPendingTasks(); // Run posted deadline. 733 client.task_runner().RunPendingTasks(); // Run posted deadline.
747 EXPECT_EQ(1, client.num_draws()); 734 EXPECT_EQ(1, client.num_draws());
748 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 735 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
749 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 736 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
750 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 737 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
751 client.ActionIndex("ScheduledActionManageTiles")); 738 client.ActionIndex("ScheduledActionManageTiles"));
752 EXPECT_FALSE(scheduler->RedrawPending()); 739 EXPECT_FALSE(scheduler->RedrawPending());
753 EXPECT_FALSE(scheduler->ManageTilesPending()); 740 EXPECT_FALSE(scheduler->ManageTilesPending());
754 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 741 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
755 742
756 // Request a draw. We don't need a ManageTiles yet. 743 // Request a draw. We don't need a ManageTiles yet.
757 client.Reset(); 744 client.Reset();
758 scheduler->SetNeedsRedraw(); 745 scheduler->SetNeedsRedraw();
759 EXPECT_TRUE(scheduler->RedrawPending()); 746 EXPECT_TRUE(scheduler->RedrawPending());
760 EXPECT_FALSE(scheduler->ManageTilesPending()); 747 EXPECT_FALSE(scheduler->ManageTilesPending());
761 EXPECT_TRUE(client.needs_begin_frame()); 748 EXPECT_TRUE(client.needs_begin_frame());
762 EXPECT_EQ(0, client.num_draws()); 749 EXPECT_EQ(0, client.num_draws());
763 750
764 // We have no immediate actions to perform, so the BeginImplFrame should post 751 // We have no immediate actions to perform, so the BeginImplFrame should post
765 // the deadline task. 752 // the deadline task.
766 client.Reset(); 753 client.Reset();
767 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 754 client.AdvanceFrame();
768 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 755 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
769 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 756 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
770 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 757 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
771 758
772 // Draw. The draw will trigger SetNeedsManageTiles, and 759 // Draw. The draw will trigger SetNeedsManageTiles, and
773 // then the ManageTiles action will be triggered after the Draw. 760 // then the ManageTiles action will be triggered after the Draw.
774 // Afterwards, neither a draw nor ManageTiles are pending. 761 // Afterwards, neither a draw nor ManageTiles are pending.
775 client.Reset(); 762 client.Reset();
776 client.task_runner().RunPendingTasks(); // Run posted deadline. 763 client.task_runner().RunPendingTasks(); // Run posted deadline.
777 EXPECT_EQ(1, client.num_draws()); 764 EXPECT_EQ(1, client.num_draws());
778 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 765 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
779 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 766 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
780 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 767 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
781 client.ActionIndex("ScheduledActionManageTiles")); 768 client.ActionIndex("ScheduledActionManageTiles"));
782 EXPECT_FALSE(scheduler->RedrawPending()); 769 EXPECT_FALSE(scheduler->RedrawPending());
783 EXPECT_FALSE(scheduler->ManageTilesPending()); 770 EXPECT_FALSE(scheduler->ManageTilesPending());
784 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 771 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
785 772
786 // We need a BeginImplFrame where we don't swap to go idle. 773 // We need a BeginImplFrame where we don't swap to go idle.
787 client.Reset(); 774 client.Reset();
788 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 775 client.AdvanceFrame();
789 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 776 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
790 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 777 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
791 client.Reset(); 778 client.Reset();
792 client.task_runner().RunPendingTasks(); // Run posted deadline. 779 client.task_runner().RunPendingTasks(); // Run posted deadline.
793 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 780 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
794 EXPECT_FALSE(client.needs_begin_frame()); 781 EXPECT_FALSE(client.needs_begin_frame());
795 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 782 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
796 EXPECT_EQ(0, client.num_draws()); 783 EXPECT_EQ(0, client.num_draws());
797 784
798 // Now trigger a ManageTiles outside of a draw. We will then need 785 // Now trigger a ManageTiles outside of a draw. We will then need
799 // a begin-frame for the ManageTiles, but we don't need a draw. 786 // a begin-frame for the ManageTiles, but we don't need a draw.
800 client.Reset(); 787 client.Reset();
801 EXPECT_FALSE(client.needs_begin_frame()); 788 EXPECT_FALSE(client.needs_begin_frame());
802 scheduler->SetNeedsManageTiles(); 789 scheduler->SetNeedsManageTiles();
803 EXPECT_TRUE(client.needs_begin_frame()); 790 EXPECT_TRUE(client.needs_begin_frame());
804 EXPECT_TRUE(scheduler->ManageTilesPending()); 791 EXPECT_TRUE(scheduler->ManageTilesPending());
805 EXPECT_FALSE(scheduler->RedrawPending()); 792 EXPECT_FALSE(scheduler->RedrawPending());
806 793
807 // BeginImplFrame. There will be no draw, only ManageTiles. 794 // BeginImplFrame. There will be no draw, only ManageTiles.
808 client.Reset(); 795 client.Reset();
809 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 796 client.AdvanceFrame();
810 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 797 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
811 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 798 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
812 client.Reset(); 799 client.Reset();
813 client.task_runner().RunPendingTasks(); // Run posted deadline. 800 client.task_runner().RunPendingTasks(); // Run posted deadline.
814 EXPECT_EQ(0, client.num_draws()); 801 EXPECT_EQ(0, client.num_draws());
815 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 802 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
816 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 803 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
817 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 804 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
818 } 805 }
819 806
820 // Test that ManageTiles only happens once per frame. If an external caller 807 // Test that ManageTiles only happens once per frame. If an external caller
821 // initiates it, then the state machine should not ManageTiles on that frame. 808 // initiates it, then the state machine should not ManageTiles on that frame.
822 TEST(SchedulerTest, ManageTilesOncePerFrame) { 809 TEST(SchedulerTest, ManageTilesOncePerFrame) {
823 FakeSchedulerClient client; 810 FakeSchedulerClient client;
824 SchedulerSettings default_scheduler_settings; 811 SchedulerSettings default_scheduler_settings;
825 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 812 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
826 scheduler->SetCanStart(); 813 scheduler->SetCanStart();
827 scheduler->SetVisible(true); 814 scheduler->SetVisible(true);
828 scheduler->SetCanDraw(true); 815 scheduler->SetCanDraw(true);
829 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 816 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
830 817
831 // If DidManageTiles during a frame, then ManageTiles should not occur again. 818 // If DidManageTiles during a frame, then ManageTiles should not occur again.
832 scheduler->SetNeedsManageTiles(); 819 scheduler->SetNeedsManageTiles();
833 scheduler->SetNeedsRedraw(); 820 scheduler->SetNeedsRedraw();
834 client.Reset(); 821 client.Reset();
835 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 822 client.AdvanceFrame();
836 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 823 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
837 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 824 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
838 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 825 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
839 826
840 EXPECT_TRUE(scheduler->ManageTilesPending()); 827 EXPECT_TRUE(scheduler->ManageTilesPending());
841 scheduler->DidManageTiles(); // An explicit ManageTiles. 828 scheduler->DidManageTiles(); // An explicit ManageTiles.
842 EXPECT_FALSE(scheduler->ManageTilesPending()); 829 EXPECT_FALSE(scheduler->ManageTilesPending());
843 830
844 client.Reset(); 831 client.Reset();
845 client.task_runner().RunPendingTasks(); // Run posted deadline. 832 client.task_runner().RunPendingTasks(); // Run posted deadline.
846 EXPECT_EQ(1, client.num_draws()); 833 EXPECT_EQ(1, client.num_draws());
847 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 834 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
848 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 835 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
849 EXPECT_FALSE(scheduler->RedrawPending()); 836 EXPECT_FALSE(scheduler->RedrawPending());
850 EXPECT_FALSE(scheduler->ManageTilesPending()); 837 EXPECT_FALSE(scheduler->ManageTilesPending());
851 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 838 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
852 839
853 // Next frame without DidManageTiles should ManageTiles with draw. 840 // Next frame without DidManageTiles should ManageTiles with draw.
854 scheduler->SetNeedsManageTiles(); 841 scheduler->SetNeedsManageTiles();
855 scheduler->SetNeedsRedraw(); 842 scheduler->SetNeedsRedraw();
856 client.Reset(); 843 client.Reset();
857 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 844 client.AdvanceFrame();
858 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 845 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
859 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 846 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
860 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 847 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
861 848
862 client.Reset(); 849 client.Reset();
863 client.task_runner().RunPendingTasks(); // Run posted deadline. 850 client.task_runner().RunPendingTasks(); // Run posted deadline.
864 EXPECT_EQ(1, client.num_draws()); 851 EXPECT_EQ(1, client.num_draws());
865 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 852 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
866 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 853 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
867 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 854 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
868 client.ActionIndex("ScheduledActionManageTiles")); 855 client.ActionIndex("ScheduledActionManageTiles"));
869 EXPECT_FALSE(scheduler->RedrawPending()); 856 EXPECT_FALSE(scheduler->RedrawPending());
870 EXPECT_FALSE(scheduler->ManageTilesPending()); 857 EXPECT_FALSE(scheduler->ManageTilesPending());
871 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 858 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
872 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles 859 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles
873 860
874 // If we get another DidManageTiles within the same frame, we should 861 // If we get another DidManageTiles within the same frame, we should
875 // not ManageTiles on the next frame. 862 // not ManageTiles on the next frame.
876 scheduler->DidManageTiles(); // An explicit ManageTiles. 863 scheduler->DidManageTiles(); // An explicit ManageTiles.
877 scheduler->SetNeedsManageTiles(); 864 scheduler->SetNeedsManageTiles();
878 scheduler->SetNeedsRedraw(); 865 scheduler->SetNeedsRedraw();
879 client.Reset(); 866 client.Reset();
880 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 867 client.AdvanceFrame();
881 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 868 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
882 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 869 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
883 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 870 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
884 871
885 EXPECT_TRUE(scheduler->ManageTilesPending()); 872 EXPECT_TRUE(scheduler->ManageTilesPending());
886 873
887 client.Reset(); 874 client.Reset();
888 client.task_runner().RunPendingTasks(); // Run posted deadline. 875 client.task_runner().RunPendingTasks(); // Run posted deadline.
889 EXPECT_EQ(1, client.num_draws()); 876 EXPECT_EQ(1, client.num_draws());
890 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 877 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
891 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 878 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
892 EXPECT_FALSE(scheduler->RedrawPending()); 879 EXPECT_FALSE(scheduler->RedrawPending());
893 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 880 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
894 881
895 // If we get another DidManageTiles, we should not ManageTiles on the next 882 // If we get another DidManageTiles, we should not ManageTiles on the next
896 // frame. This verifies we don't alternate calling ManageTiles once and twice. 883 // frame. This verifies we don't alternate calling ManageTiles once and twice.
897 EXPECT_TRUE(scheduler->ManageTilesPending()); 884 EXPECT_TRUE(scheduler->ManageTilesPending());
898 scheduler->DidManageTiles(); // An explicit ManageTiles. 885 scheduler->DidManageTiles(); // An explicit ManageTiles.
899 EXPECT_FALSE(scheduler->ManageTilesPending()); 886 EXPECT_FALSE(scheduler->ManageTilesPending());
900 scheduler->SetNeedsManageTiles(); 887 scheduler->SetNeedsManageTiles();
901 scheduler->SetNeedsRedraw(); 888 scheduler->SetNeedsRedraw();
902 client.Reset(); 889 client.Reset();
903 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 890 client.AdvanceFrame();
904 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 891 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
905 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 892 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
906 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 893 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
907 894
908 EXPECT_TRUE(scheduler->ManageTilesPending()); 895 EXPECT_TRUE(scheduler->ManageTilesPending());
909 896
910 client.Reset(); 897 client.Reset();
911 client.task_runner().RunPendingTasks(); // Run posted deadline. 898 client.task_runner().RunPendingTasks(); // Run posted deadline.
912 EXPECT_EQ(1, client.num_draws()); 899 EXPECT_EQ(1, client.num_draws());
913 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 900 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
914 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 901 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
915 EXPECT_FALSE(scheduler->RedrawPending()); 902 EXPECT_FALSE(scheduler->RedrawPending());
916 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 903 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
917 904
918 // Next frame without DidManageTiles should ManageTiles with draw. 905 // Next frame without DidManageTiles should ManageTiles with draw.
919 scheduler->SetNeedsManageTiles(); 906 scheduler->SetNeedsManageTiles();
920 scheduler->SetNeedsRedraw(); 907 scheduler->SetNeedsRedraw();
921 client.Reset(); 908 client.Reset();
922 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 909 client.AdvanceFrame();
923 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 910 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
924 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 911 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
925 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 912 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
926 913
927 client.Reset(); 914 client.Reset();
928 client.task_runner().RunPendingTasks(); // Run posted deadline. 915 client.task_runner().RunPendingTasks(); // Run posted deadline.
929 EXPECT_EQ(1, client.num_draws()); 916 EXPECT_EQ(1, client.num_draws());
930 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 917 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
931 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 918 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
932 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 919 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
(...skipping 15 matching lines...) Expand all
948 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 935 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
949 936
950 client.SetRedrawWillHappenIfUpdateVisibleTilesHappens(true); 937 client.SetRedrawWillHappenIfUpdateVisibleTilesHappens(true);
951 938
952 // SetNeedsCommit should begin the frame. 939 // SetNeedsCommit should begin the frame.
953 client.Reset(); 940 client.Reset();
954 scheduler->SetNeedsCommit(); 941 scheduler->SetNeedsCommit();
955 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 942 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
956 943
957 client.Reset(); 944 client.Reset();
958 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 945 client.AdvanceFrame();
959 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 946 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
960 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 947 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
961 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 948 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
962 949
963 client.Reset(); 950 client.Reset();
964 scheduler->NotifyBeginMainFrameStarted(); 951 scheduler->NotifyBeginMainFrameStarted();
965 scheduler->NotifyReadyToCommit(); 952 scheduler->NotifyReadyToCommit();
966 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 953 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
967 954
968 client.Reset(); 955 client.Reset();
969 scheduler->NotifyReadyToActivate(); 956 scheduler->NotifyReadyToActivate();
970 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client); 957 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client);
971 958
972 client.Reset(); 959 client.Reset();
973 client.SetSwapContainsIncompleteTile(true); 960 client.SetSwapContainsIncompleteTile(true);
974 client.task_runner().RunPendingTasks(); // Run posted deadline. 961 client.task_runner().RunPendingTasks(); // Run posted deadline.
975 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 962 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
976 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 963 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
977 EXPECT_FALSE(scheduler->RedrawPending()); 964 EXPECT_FALSE(scheduler->RedrawPending());
978 965
979 client.Reset(); 966 client.Reset();
980 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 967 client.AdvanceFrame();
981 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 968 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
982 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 969 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
983 970
984 client.Reset(); 971 client.Reset();
985 client.task_runner().RunPendingTasks(); // Run posted deadline. 972 client.task_runner().RunPendingTasks(); // Run posted deadline.
986 EXPECT_ACTION("ScheduledActionUpdateVisibleTiles", client, 0, 3); 973 EXPECT_ACTION("ScheduledActionUpdateVisibleTiles", client, 0, 3);
987 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 3); 974 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 3);
988 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 2, 3); 975 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 2, 3);
989 976
990 client.Reset(); 977 client.Reset();
991 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 978 client.AdvanceFrame();
992 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 979 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
993 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 980 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
994 981
995 // No more UpdateVisibleTiles(). 982 // No more UpdateVisibleTiles().
996 client.Reset(); 983 client.Reset();
997 client.task_runner().RunPendingTasks(); // Run posted deadline. 984 client.task_runner().RunPendingTasks(); // Run posted deadline.
998 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 985 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
999 EXPECT_FALSE(client.needs_begin_frame()); 986 EXPECT_FALSE(client.needs_begin_frame());
1000 } 987 }
1001 988
1002 TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) { 989 TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) {
1003 SchedulerClientNeedsManageTilesInDraw client; 990 SchedulerClientNeedsManageTilesInDraw client;
1004 SchedulerSettings default_scheduler_settings; 991 SchedulerSettings default_scheduler_settings;
1005 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 992 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
1006 scheduler->SetCanStart(); 993 scheduler->SetCanStart();
1007 scheduler->SetVisible(true); 994 scheduler->SetVisible(true);
1008 scheduler->SetCanDraw(true); 995 scheduler->SetCanDraw(true);
1009 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 996 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1010 997
1011 client.Reset(); 998 client.Reset();
1012 scheduler->SetNeedsRedraw(); 999 scheduler->SetNeedsRedraw();
1013 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1000 client.AdvanceFrame();
1014 1001
1015 // The deadline should be zero since there is no work other than drawing 1002 // The deadline should be zero since there is no work other than drawing
1016 // pending. 1003 // pending.
1017 EXPECT_EQ(base::TimeTicks(), client.posted_begin_impl_frame_deadline()); 1004 EXPECT_EQ(base::TimeTicks(), client.posted_begin_impl_frame_deadline());
1018 } 1005 }
1019 1006
1020 class SchedulerClientWithFixedEstimates : public FakeSchedulerClient { 1007 class SchedulerClientWithFixedEstimates : public FakeSchedulerClient {
1021 public: 1008 public:
1022 SchedulerClientWithFixedEstimates( 1009 SchedulerClientWithFixedEstimates(
1023 base::TimeDelta draw_duration, 1010 base::TimeDelta draw_duration,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 scheduler->SetCanStart(); 1046 scheduler->SetCanStart();
1060 scheduler->SetVisible(true); 1047 scheduler->SetVisible(true);
1061 scheduler->SetCanDraw(true); 1048 scheduler->SetCanDraw(true);
1062 scheduler->SetSmoothnessTakesPriority(smoothness_takes_priority); 1049 scheduler->SetSmoothnessTakesPriority(smoothness_takes_priority);
1063 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1050 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1064 1051
1065 // Impl thread hits deadline before commit finishes. 1052 // Impl thread hits deadline before commit finishes.
1066 client.Reset(); 1053 client.Reset();
1067 scheduler->SetNeedsCommit(); 1054 scheduler->SetNeedsCommit();
1068 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1055 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1069 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1056 client.AdvanceFrame();
1070 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1057 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1071 client.task_runner().RunPendingTasks(); // Run posted deadline. 1058 client.task_runner().RunPendingTasks(); // Run posted deadline.
1072 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1059 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1073 scheduler->NotifyBeginMainFrameStarted(); 1060 scheduler->NotifyBeginMainFrameStarted();
1074 scheduler->NotifyReadyToCommit(); 1061 scheduler->NotifyReadyToCommit();
1075 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1062 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1076 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame")); 1063 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame"));
1077 1064
1078 client.Reset(); 1065 client.Reset();
1079 scheduler->SetNeedsCommit(); 1066 scheduler->SetNeedsCommit();
1080 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1067 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1081 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1068 client.AdvanceFrame();
1082 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1069 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1083 client.task_runner().RunPendingTasks(); // Run posted deadline. 1070 client.task_runner().RunPendingTasks(); // Run posted deadline.
1084 EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(), 1071 EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(),
1085 should_send_begin_main_frame); 1072 should_send_begin_main_frame);
1086 EXPECT_EQ(client.HasAction("ScheduledActionSendBeginMainFrame"), 1073 EXPECT_EQ(client.HasAction("ScheduledActionSendBeginMainFrame"),
1087 should_send_begin_main_frame); 1074 should_send_begin_main_frame);
1088 } 1075 }
1089 1076
1090 TEST(SchedulerTest, 1077 TEST(SchedulerTest,
1091 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) { 1078 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 scheduler->SetCanStart(); 1115 scheduler->SetCanStart();
1129 scheduler->SetVisible(true); 1116 scheduler->SetVisible(true);
1130 scheduler->DidCreateAndInitializeOutputSurface(); 1117 scheduler->DidCreateAndInitializeOutputSurface();
1131 1118
1132 scheduler->SetNeedsCommit(); 1119 scheduler->SetNeedsCommit();
1133 EXPECT_TRUE(scheduler->CommitPending()); 1120 EXPECT_TRUE(scheduler->CommitPending());
1134 scheduler->NotifyBeginMainFrameStarted(); 1121 scheduler->NotifyBeginMainFrameStarted();
1135 scheduler->NotifyReadyToCommit(); 1122 scheduler->NotifyReadyToCommit();
1136 scheduler->SetNeedsRedraw(); 1123 scheduler->SetNeedsRedraw();
1137 1124
1138 BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(); 1125 BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(client.now_src());
1139 frame_args.interval = base::TimeDelta::FromMilliseconds(1000); 1126 frame_args.interval = base::TimeDelta::FromMilliseconds(1000);
1140 scheduler->BeginFrame(frame_args); 1127 scheduler->BeginFrame(frame_args);
1141 1128
1142 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1129 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1143 client.task_runner().RunPendingTasks(); // Run posted deadline. 1130 client.task_runner().RunPendingTasks(); // Run posted deadline.
1144 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1131 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1145 1132
1146 scheduler->DidSwapBuffers(); 1133 scheduler->DidSwapBuffers();
1147 scheduler->DidSwapBuffersComplete(); 1134 scheduler->DidSwapBuffersComplete();
1148 1135
(...skipping 11 matching lines...) Expand all
1160 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1147 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1161 scheduler->DidSwapBuffers(); 1148 scheduler->DidSwapBuffers();
1162 1149
1163 // Spin the event loop a few times and make sure we get more 1150 // Spin the event loop a few times and make sure we get more
1164 // DidAnticipateDrawTimeChange calls every time. 1151 // DidAnticipateDrawTimeChange calls every time.
1165 int actions_so_far = client.num_actions_(); 1152 int actions_so_far = client.num_actions_();
1166 1153
1167 // Does three iterations to make sure that the timer is properly repeating. 1154 // Does three iterations to make sure that the timer is properly repeating.
1168 for (int i = 0; i < 3; ++i) { 1155 for (int i = 0; i < 3; ++i) {
1169 EXPECT_EQ((frame_args.interval * 2).InMicroseconds(), 1156 EXPECT_EQ((frame_args.interval * 2).InMicroseconds(),
1170 client.task_runner().NextPendingTaskDelay().InMicroseconds()) 1157 client.task_runner().DelayToNextTaskTime().InMicroseconds())
1171 << scheduler->AsValue()->ToString(); 1158 << scheduler->AsValue()->ToString();
1172 client.task_runner().RunPendingTasks(); 1159 client.task_runner().RunPendingTasks();
1173 EXPECT_GT(client.num_actions_(), actions_so_far); 1160 EXPECT_GT(client.num_actions_(), actions_so_far);
1174 EXPECT_STREQ(client.Action(client.num_actions_() - 1), 1161 EXPECT_STREQ(client.Action(client.num_actions_() - 1),
1175 "DidAnticipatedDrawTimeChange"); 1162 "DidAnticipatedDrawTimeChange");
1176 actions_so_far = client.num_actions_(); 1163 actions_so_far = client.num_actions_();
1177 } 1164 }
1178 1165
1179 // Do the same thing after BeginMainFrame starts but still before activation. 1166 // Do the same thing after BeginMainFrame starts but still before activation.
1180 scheduler->NotifyBeginMainFrameStarted(); 1167 scheduler->NotifyBeginMainFrameStarted();
1181 for (int i = 0; i < 3; ++i) { 1168 for (int i = 0; i < 3; ++i) {
1182 EXPECT_EQ((frame_args.interval * 2).InMicroseconds(), 1169 EXPECT_EQ((frame_args.interval * 2).InMicroseconds(),
1183 client.task_runner().NextPendingTaskDelay().InMicroseconds()) 1170 client.task_runner().DelayToNextTaskTime().InMicroseconds())
1184 << scheduler->AsValue()->ToString(); 1171 << scheduler->AsValue()->ToString();
1185 client.task_runner().RunPendingTasks(); 1172 client.task_runner().RunPendingTasks();
1186 EXPECT_GT(client.num_actions_(), actions_so_far); 1173 EXPECT_GT(client.num_actions_(), actions_so_far);
1187 EXPECT_STREQ(client.Action(client.num_actions_() - 1), 1174 EXPECT_STREQ(client.Action(client.num_actions_() - 1),
1188 "DidAnticipatedDrawTimeChange"); 1175 "DidAnticipatedDrawTimeChange");
1189 actions_so_far = client.num_actions_(); 1176 actions_so_far = client.num_actions_();
1190 } 1177 }
1191 } 1178 }
1192 1179
1193 TEST(SchedulerTest, BeginRetroFrame) { 1180 TEST(SchedulerTest, BeginRetroFrame) {
1194 FakeSchedulerClient client; 1181 FakeSchedulerClient client;
1195 SchedulerSettings scheduler_settings; 1182 SchedulerSettings scheduler_settings;
1196 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); 1183 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings);
1197 scheduler->SetCanStart(); 1184 scheduler->SetCanStart();
1198 scheduler->SetVisible(true); 1185 scheduler->SetVisible(true);
1199 scheduler->SetCanDraw(true); 1186 scheduler->SetCanDraw(true);
1200 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1187 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1201 1188
1202 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1189 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1203 client.Reset(); 1190 client.Reset();
1204 scheduler->SetNeedsCommit(); 1191 scheduler->SetNeedsCommit();
1205 EXPECT_TRUE(client.needs_begin_frame()); 1192 EXPECT_TRUE(client.needs_begin_frame());
1206 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1193 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1207 client.Reset(); 1194 client.Reset();
1208 1195
1209 // Create a BeginFrame with a long deadline to avoid race conditions. 1196 // Create a BeginFrame with a long deadline to avoid race conditions.
1210 // This is the first BeginFrame, which will be handled immediately. 1197 // This is the first BeginFrame, which will be handled immediately.
1211 BeginFrameArgs args = CreateBeginFrameArgsForTesting(); 1198 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1212 args.deadline += base::TimeDelta::FromHours(1); 1199 args.deadline += base::TimeDelta::FromHours(1);
1213 scheduler->BeginFrame(args); 1200 scheduler->BeginFrame(args);
1214 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1201 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1215 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1202 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1216 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1203 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1217 EXPECT_TRUE(client.needs_begin_frame()); 1204 EXPECT_TRUE(client.needs_begin_frame());
1218 client.Reset(); 1205 client.Reset();
1219 1206
1220 // Queue BeginFrames while we are still handling the previous BeginFrame. 1207 // Queue BeginFrames while we are still handling the previous BeginFrame.
1221 args.frame_time += base::TimeDelta::FromSeconds(1); 1208 args.frame_time += base::TimeDelta::FromSeconds(1);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 1267
1281 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1268 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1282 client.Reset(); 1269 client.Reset();
1283 scheduler->SetNeedsCommit(); 1270 scheduler->SetNeedsCommit();
1284 EXPECT_TRUE(client.needs_begin_frame()); 1271 EXPECT_TRUE(client.needs_begin_frame());
1285 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1272 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1286 client.Reset(); 1273 client.Reset();
1287 1274
1288 // Create a BeginFrame with a long deadline to avoid race conditions. 1275 // Create a BeginFrame with a long deadline to avoid race conditions.
1289 // This is the first BeginFrame, which will be handled immediately. 1276 // This is the first BeginFrame, which will be handled immediately.
1290 BeginFrameArgs args = CreateBeginFrameArgsForTesting(); 1277 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1291 args.deadline += base::TimeDelta::FromHours(1); 1278 args.deadline += base::TimeDelta::FromHours(1);
1292 scheduler->BeginFrame(args); 1279 scheduler->BeginFrame(args);
1293 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1280 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1294 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1281 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1295 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1282 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1296 EXPECT_TRUE(client.needs_begin_frame()); 1283 EXPECT_TRUE(client.needs_begin_frame());
1297 client.Reset(); 1284 client.Reset();
1298 1285
1299 // Queue BeginFrame while we are still handling the previous BeginFrame. 1286 // Queue BeginFrame while we are still handling the previous BeginFrame.
1300 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1287 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 1325
1339 // Take us out of a swap throttled state. 1326 // Take us out of a swap throttled state.
1340 scheduler->DidSwapBuffersComplete(); 1327 scheduler->DidSwapBuffersComplete();
1341 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); 1328 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1);
1342 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1329 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1343 EXPECT_TRUE(client.needs_begin_frame()); 1330 EXPECT_TRUE(client.needs_begin_frame());
1344 client.Reset(); 1331 client.Reset();
1345 1332
1346 // BeginImplFrame deadline should draw. 1333 // BeginImplFrame deadline should draw.
1347 scheduler->SetNeedsRedraw(); 1334 scheduler->SetNeedsRedraw();
1348 client.task_runner().RunPendingTasks(); // Run posted deadline. 1335
1336 EXPECT_TRUE(client.task_runner().RunTasks(
1337 client.WhileImplFrameDeadlinePending(true)));
1338
1349 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 1339 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
1350 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 1340 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
1351 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1341 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1352 EXPECT_TRUE(client.needs_begin_frame()); 1342 EXPECT_TRUE(client.needs_begin_frame());
1353 client.Reset(); 1343 client.Reset();
1354 } 1344 }
1355 1345
1356 void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, 1346 void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled,
1357 bool throttle_frame_production) { 1347 bool throttle_frame_production) {
1358 FakeSchedulerClient client; 1348 FakeSchedulerClient client;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 1389
1400 // BeginImplFrame should prepare the draw. 1390 // BeginImplFrame should prepare the draw.
1401 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1391 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1402 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1392 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1403 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 1393 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
1404 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1394 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1405 EXPECT_FALSE(client.needs_begin_frame()); 1395 EXPECT_FALSE(client.needs_begin_frame());
1406 client.Reset(); 1396 client.Reset();
1407 1397
1408 // BeginImplFrame deadline should draw. 1398 // BeginImplFrame deadline should draw.
1409 client.task_runner().RunPendingTasks(); // Run posted deadline. 1399 client.task_runner().RunTasks(client.WhileImplFrameDeadlinePending(true));
1410 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); 1400 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
1411 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1401 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1412 EXPECT_FALSE(client.needs_begin_frame()); 1402 EXPECT_FALSE(client.needs_begin_frame());
1413 client.Reset(); 1403 client.Reset();
1414 1404
1415 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 1405 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
1416 // to avoid excessive toggles. 1406 // to avoid excessive toggles.
1417 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1407 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1418 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 1408 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
1419 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1409 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1420 client.Reset(); 1410 client.Reset();
1421 1411
1422 // Make sure SetNeedsBeginFrame isn't called on the client 1412 // Make sure SetNeedsBeginFrame isn't called on the client
1423 // when the BeginFrame is no longer needed. 1413 // when the BeginFrame is no longer needed.
1424 client.task_runner().RunPendingTasks(); // Run posted deadline. 1414 client.task_runner().RunPendingTasks(); // Run posted deadline.
1425 EXPECT_NO_ACTION(client); 1415 EXPECT_NO_ACTION(client);
1426 EXPECT_FALSE(client.needs_begin_frame()); 1416 EXPECT_FALSE(client.needs_begin_frame());
1427 client.Reset(); 1417 client.Reset();
1428 } 1418 }
1429 1419
1430 // See: http://crbug.com/380889 1420 TEST(SchedulerTest, SyntheticBeginFrames) {
1431 TEST(SchedulerTest, DISABLED_SyntheticBeginFrames) {
1432 bool begin_frame_scheduling_enabled = false; 1421 bool begin_frame_scheduling_enabled = false;
1433 bool throttle_frame_production = true; 1422 bool throttle_frame_production = true;
1434 BeginFramesNotFromClient(begin_frame_scheduling_enabled, 1423 BeginFramesNotFromClient(begin_frame_scheduling_enabled,
1435 throttle_frame_production); 1424 throttle_frame_production);
1436 } 1425 }
1437 1426
1438 TEST(SchedulerTest, VSyncThrottlingDisabled) { 1427 TEST(SchedulerTest, VSyncThrottlingDisabled) {
1439 bool begin_frame_scheduling_enabled = true; 1428 bool begin_frame_scheduling_enabled = true;
1440 bool throttle_frame_production = false; 1429 bool throttle_frame_production = false;
1441 BeginFramesNotFromClient(begin_frame_scheduling_enabled, 1430 BeginFramesNotFromClient(begin_frame_scheduling_enabled,
1442 throttle_frame_production); 1431 throttle_frame_production);
1443 } 1432 }
1444 1433
1445 // See: http://crbug.com/380889 1434 TEST(SchedulerTest, SyntheticBeginFrames_And_VSyncThrottlingDisabled) {
1446 TEST(SchedulerTest, DISABLED_SyntheticBeginFrames_And_VSyncThrottlingDisabled) {
1447 bool begin_frame_scheduling_enabled = false; 1435 bool begin_frame_scheduling_enabled = false;
1448 bool throttle_frame_production = false; 1436 bool throttle_frame_production = false;
1449 BeginFramesNotFromClient(begin_frame_scheduling_enabled, 1437 BeginFramesNotFromClient(begin_frame_scheduling_enabled,
1450 throttle_frame_production); 1438 throttle_frame_production);
1451 } 1439 }
1452 1440
1453 void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled, 1441 void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled,
1454 bool throttle_frame_production) { 1442 bool throttle_frame_production) {
1455 FakeSchedulerClient client; 1443 FakeSchedulerClient client;
1456 SchedulerSettings scheduler_settings; 1444 SchedulerSettings scheduler_settings;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 // BeginImplFrame deadline should draw. 1504 // BeginImplFrame deadline should draw.
1517 scheduler->SetNeedsRedraw(); 1505 scheduler->SetNeedsRedraw();
1518 client.task_runner().RunPendingTasks(); // Run posted deadline. 1506 client.task_runner().RunPendingTasks(); // Run posted deadline.
1519 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 1507 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
1520 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 1508 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
1521 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1509 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1522 EXPECT_FALSE(client.needs_begin_frame()); 1510 EXPECT_FALSE(client.needs_begin_frame());
1523 client.Reset(); 1511 client.Reset();
1524 } 1512 }
1525 1513
1526 // See: http://crbug.com/380889 1514 TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) {
1527 TEST(SchedulerTest, DISABLED_SyntheticBeginFrames_SwapThrottled) {
1528 bool begin_frame_scheduling_enabled = false; 1515 bool begin_frame_scheduling_enabled = false;
1529 bool throttle_frame_production = true; 1516 bool throttle_frame_production = true;
1530 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, 1517 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled,
1531 throttle_frame_production); 1518 throttle_frame_production);
1532 } 1519 }
1533 1520
1534 TEST(SchedulerTest, VSyncThrottlingDisabled_SwapThrottled) { 1521 TEST(SchedulerTest, VSyncThrottlingDisabled_SwapThrottled) {
1535 bool begin_frame_scheduling_enabled = true; 1522 bool begin_frame_scheduling_enabled = true;
1536 bool throttle_frame_production = false; 1523 bool throttle_frame_production = false;
1537 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, 1524 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled,
1538 throttle_frame_production); 1525 throttle_frame_production);
1539 } 1526 }
1540 1527
1541 // See: http://crbug.com/380889
1542 TEST(SchedulerTest, 1528 TEST(SchedulerTest,
1543 DISABLED_SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { 1529 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) {
1544 bool begin_frame_scheduling_enabled = false; 1530 bool begin_frame_scheduling_enabled = false;
1545 bool throttle_frame_production = false; 1531 bool throttle_frame_production = false;
1546 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, 1532 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled,
1547 throttle_frame_production); 1533 throttle_frame_production);
1548 } 1534 }
1549 1535
1550 TEST(SchedulerTest, DidLoseOutputSurfaceAfterOutputSurfaceIsInitialized) { 1536 TEST(SchedulerTest, DidLoseOutputSurfaceAfterOutputSurfaceIsInitialized) {
1551 FakeSchedulerClient client; 1537 FakeSchedulerClient client;
1552 SchedulerSettings scheduler_settings; 1538 SchedulerSettings scheduler_settings;
1553 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); 1539 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings);
(...skipping 19 matching lines...) Expand all
1573 scheduler->SetCanDraw(true); 1559 scheduler->SetCanDraw(true);
1574 1560
1575 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 1561 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
1576 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1562 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1577 // SetNeedsCommit should begin the frame. 1563 // SetNeedsCommit should begin the frame.
1578 client.Reset(); 1564 client.Reset();
1579 scheduler->SetNeedsCommit(); 1565 scheduler->SetNeedsCommit();
1580 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1566 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1581 1567
1582 client.Reset(); 1568 client.Reset();
1583 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1569 client.AdvanceFrame();
1584 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1570 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1585 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1571 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1586 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1572 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1587 1573
1588 client.Reset(); 1574 client.Reset();
1589 scheduler->DidLoseOutputSurface(); 1575 scheduler->DidLoseOutputSurface();
1590 // Do nothing when impl frame is in deadine pending state. 1576 // Do nothing when impl frame is in deadine pending state.
1591 EXPECT_NO_ACTION(client); 1577 EXPECT_NO_ACTION(client);
1592 1578
1593 client.Reset(); 1579 client.Reset();
(...skipping 18 matching lines...) Expand all
1612 1598
1613 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 1599 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
1614 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1600 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1615 1601
1616 // SetNeedsCommit should begin the frame. 1602 // SetNeedsCommit should begin the frame.
1617 client.Reset(); 1603 client.Reset();
1618 scheduler->SetNeedsCommit(); 1604 scheduler->SetNeedsCommit();
1619 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1605 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1620 1606
1621 client.Reset(); 1607 client.Reset();
1622 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1608 client.AdvanceFrame();
1623 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1609 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1624 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1610 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1625 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1611 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1626 1612
1627 client.Reset(); 1613 client.Reset();
1628 scheduler->DidLoseOutputSurface(); 1614 scheduler->DidLoseOutputSurface();
1629 // Do nothing when impl frame is in deadine pending state. 1615 // Do nothing when impl frame is in deadine pending state.
1630 EXPECT_NO_ACTION(client); 1616 EXPECT_NO_ACTION(client);
1631 1617
1632 client.Reset(); 1618 client.Reset();
1633 client.task_runner().RunPendingTasks(); // Run posted deadline. 1619 // Run posted deadline.
1620 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1621 client.task_runner().RunTasks(client.WhileImplFrameDeadlinePending(true));
1634 // OnBeginImplFrameDeadline didn't schedule any actions because main frame is 1622 // OnBeginImplFrameDeadline didn't schedule any actions because main frame is
1635 // not yet completed. 1623 // not yet completed.
1636 EXPECT_NO_ACTION(client); 1624 EXPECT_NO_ACTION(client);
1625 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1637 1626
1638 // BeginImplFrame is not started. 1627 // BeginImplFrame is not started.
1639 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1628 client.task_runner().RunUntilTime(client.now_src()->Now() +
1629 base::TimeDelta::FromMilliseconds(10));
1640 EXPECT_NO_ACTION(client); 1630 EXPECT_NO_ACTION(client);
1641 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1631 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1642 1632
1643 client.Reset(); 1633 client.Reset();
1644 scheduler->NotifyBeginMainFrameStarted(); 1634 scheduler->NotifyBeginMainFrameStarted();
1645 scheduler->NotifyReadyToCommit(); 1635 scheduler->NotifyReadyToCommit();
1646 if (impl_side_painting) { 1636 if (impl_side_painting) {
1647 EXPECT_ACTION("ScheduledActionCommit", client, 0, 3); 1637 EXPECT_ACTION("ScheduledActionCommit", client, 0, 3);
1648 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 3); 1638 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 3);
1649 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client, 2, 3); 1639 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client, 2, 3);
(...skipping 25 matching lines...) Expand all
1675 1665
1676 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 1666 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
1677 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1667 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1678 1668
1679 // SetNeedsCommit should begin the frame. 1669 // SetNeedsCommit should begin the frame.
1680 client.Reset(); 1670 client.Reset();
1681 scheduler->SetNeedsCommit(); 1671 scheduler->SetNeedsCommit();
1682 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1672 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1683 1673
1684 client.Reset(); 1674 client.Reset();
1685 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1675 client.AdvanceFrame();
1686 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1676 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1687 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1677 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1688 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1678 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1689 1679
1690 client.Reset(); 1680 client.Reset();
1691 scheduler->NotifyBeginMainFrameStarted(); 1681 scheduler->NotifyBeginMainFrameStarted();
1692 scheduler->NotifyReadyToCommit(); 1682 scheduler->NotifyReadyToCommit();
1693 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 1683 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
1694 1684
1695 client.Reset(); 1685 client.Reset();
(...skipping 28 matching lines...) Expand all
1724 scheduler->SetCanDraw(true); 1714 scheduler->SetCanDraw(true);
1725 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1715 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1726 1716
1727 client.Reset(); 1717 client.Reset();
1728 scheduler->SetNeedsManageTiles(); 1718 scheduler->SetNeedsManageTiles();
1729 scheduler->SetNeedsRedraw(); 1719 scheduler->SetNeedsRedraw();
1730 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1720 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1731 EXPECT_TRUE(client.needs_begin_frame()); 1721 EXPECT_TRUE(client.needs_begin_frame());
1732 1722
1733 client.Reset(); 1723 client.Reset();
1734 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1724 client.AdvanceFrame();
1735 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1725 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1736 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 1726 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
1737 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1727 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1738 1728
1739 client.Reset(); 1729 client.Reset();
1740 scheduler->DidLoseOutputSurface(); 1730 scheduler->DidLoseOutputSurface();
1741 EXPECT_NO_ACTION(client); 1731 EXPECT_NO_ACTION(client);
1742 1732
1743 client.Reset(); 1733 client.Reset();
1744 client.task_runner().RunPendingTasks(); // Run posted deadline. 1734 client.task_runner().RunPendingTasks(); // Run posted deadline.
(...skipping 12 matching lines...) Expand all
1757 1747
1758 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1748 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1759 client.Reset(); 1749 client.Reset();
1760 scheduler->SetNeedsCommit(); 1750 scheduler->SetNeedsCommit();
1761 EXPECT_TRUE(client.needs_begin_frame()); 1751 EXPECT_TRUE(client.needs_begin_frame());
1762 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1752 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1763 1753
1764 // Create a BeginFrame with a long deadline to avoid race conditions. 1754 // Create a BeginFrame with a long deadline to avoid race conditions.
1765 // This is the first BeginFrame, which will be handled immediately. 1755 // This is the first BeginFrame, which will be handled immediately.
1766 client.Reset(); 1756 client.Reset();
1767 BeginFrameArgs args = CreateBeginFrameArgsForTesting(); 1757 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1768 args.deadline += base::TimeDelta::FromHours(1); 1758 args.deadline += base::TimeDelta::FromHours(1);
1769 scheduler->BeginFrame(args); 1759 scheduler->BeginFrame(args);
1770 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1760 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1771 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1761 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1772 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1762 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1773 EXPECT_TRUE(client.needs_begin_frame()); 1763 EXPECT_TRUE(client.needs_begin_frame());
1774 1764
1775 // Queue BeginFrames while we are still handling the previous BeginFrame. 1765 // Queue BeginFrames while we are still handling the previous BeginFrame.
1776 args.frame_time += base::TimeDelta::FromSeconds(1); 1766 args.frame_time += base::TimeDelta::FromSeconds(1);
1777 scheduler->BeginFrame(args); 1767 scheduler->BeginFrame(args);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 1806
1817 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1807 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1818 client.Reset(); 1808 client.Reset();
1819 scheduler->SetNeedsCommit(); 1809 scheduler->SetNeedsCommit();
1820 EXPECT_TRUE(client.needs_begin_frame()); 1810 EXPECT_TRUE(client.needs_begin_frame());
1821 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1811 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1822 1812
1823 // Create a BeginFrame with a long deadline to avoid race conditions. 1813 // Create a BeginFrame with a long deadline to avoid race conditions.
1824 // This is the first BeginFrame, which will be handled immediately. 1814 // This is the first BeginFrame, which will be handled immediately.
1825 client.Reset(); 1815 client.Reset();
1826 BeginFrameArgs args = CreateBeginFrameArgsForTesting(); 1816 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1827 args.deadline += base::TimeDelta::FromHours(1); 1817 args.deadline += base::TimeDelta::FromHours(1);
1828 scheduler->BeginFrame(args); 1818 scheduler->BeginFrame(args);
1829 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1819 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1830 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1820 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1831 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1821 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1832 EXPECT_TRUE(client.needs_begin_frame()); 1822 EXPECT_TRUE(client.needs_begin_frame());
1833 1823
1834 // Queue BeginFrames while we are still handling the previous BeginFrame. 1824 // Queue BeginFrames while we are still handling the previous BeginFrame.
1835 args.frame_time += base::TimeDelta::FromSeconds(1); 1825 args.frame_time += base::TimeDelta::FromSeconds(1);
1836 scheduler->BeginFrame(args); 1826 scheduler->BeginFrame(args);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 1861 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
1872 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1862 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1873 EXPECT_TRUE(client.needs_begin_frame()); 1863 EXPECT_TRUE(client.needs_begin_frame());
1874 1864
1875 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. 1865 // No more BeginRetroFrame because BeginRetroFrame queue is cleared.
1876 client.Reset(); 1866 client.Reset();
1877 client.task_runner().RunPendingTasks(); 1867 client.task_runner().RunPendingTasks();
1878 EXPECT_NO_ACTION(client); 1868 EXPECT_NO_ACTION(client);
1879 } 1869 }
1880 1870
1881 // See: http://crbug.com/380889 1871 TEST(SchedulerTest,
1882 TEST( 1872 StopBeginFrameAfterDidLoseOutputSurfaceWithSyntheticBeginFrameSource) {
1883 SchedulerTest,
1884 DISABLED_StopBeginFrameAfterDidLoseOutputSurfaceWithSyntheticBeginFrameSourc e) {
1885 FakeSchedulerClient client; 1873 FakeSchedulerClient client;
1886 SchedulerSettings scheduler_settings; 1874 SchedulerSettings scheduler_settings;
1887 scheduler_settings.begin_frame_scheduling_enabled = false; 1875 scheduler_settings.begin_frame_scheduling_enabled = false;
1888 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); 1876 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings);
1889 scheduler->SetCanStart(); 1877 scheduler->SetCanStart();
1890 scheduler->SetVisible(true); 1878 scheduler->SetVisible(true);
1891 scheduler->SetCanDraw(true); 1879 scheduler->SetCanDraw(true);
1892 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1880 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1893 1881
1894 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1882 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
(...skipping 22 matching lines...) Expand all
1917 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); 1905 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive());
1918 1906
1919 client.Reset(); 1907 client.Reset();
1920 client.task_runner().RunPendingTasks(); // Run posted deadline. 1908 client.task_runner().RunPendingTasks(); // Run posted deadline.
1921 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 1909 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
1922 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); 1910 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive());
1923 } 1911 }
1924 1912
1925 } // namespace 1913 } // namespace
1926 } // namespace cc 1914 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698