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

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

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: android-vulkan Created 4 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
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/surfaces/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 PushAction("ScheduledActionDrawAndSwapForced"); 151 PushAction("ScheduledActionDrawAndSwapForced");
152 return DRAW_SUCCESS; 152 return DRAW_SUCCESS;
153 } 153 }
154 void ScheduledActionCommit() override { 154 void ScheduledActionCommit() override {
155 PushAction("ScheduledActionCommit"); 155 PushAction("ScheduledActionCommit");
156 scheduler_->DidCommit(); 156 scheduler_->DidCommit();
157 } 157 }
158 void ScheduledActionActivateSyncTree() override { 158 void ScheduledActionActivateSyncTree() override {
159 PushAction("ScheduledActionActivateSyncTree"); 159 PushAction("ScheduledActionActivateSyncTree");
160 } 160 }
161 void ScheduledActionBeginOutputSurfaceCreation() override { 161 void ScheduledActionBeginCompositorFrameSinkCreation() override {
162 PushAction("ScheduledActionBeginOutputSurfaceCreation"); 162 PushAction("ScheduledActionBeginCompositorFrameSinkCreation");
163 } 163 }
164 void ScheduledActionPrepareTiles() override { 164 void ScheduledActionPrepareTiles() override {
165 PushAction("ScheduledActionPrepareTiles"); 165 PushAction("ScheduledActionPrepareTiles");
166 scheduler_->WillPrepareTiles(); 166 scheduler_->WillPrepareTiles();
167 scheduler_->DidPrepareTiles(); 167 scheduler_->DidPrepareTiles();
168 } 168 }
169 void ScheduledActionInvalidateOutputSurface() override { 169 void ScheduledActionInvalidateCompositorFrameSink() override {
170 actions_.push_back("ScheduledActionInvalidateOutputSurface"); 170 actions_.push_back("ScheduledActionInvalidateCompositorFrameSink");
171 states_.push_back(scheduler_->AsValue()); 171 states_.push_back(scheduler_->AsValue());
172 } 172 }
173 173
174 void SendBeginMainFrameNotExpectedSoon() override { 174 void SendBeginMainFrameNotExpectedSoon() override {
175 PushAction("SendBeginMainFrameNotExpectedSoon"); 175 PushAction("SendBeginMainFrameNotExpectedSoon");
176 } 176 }
177 177
178 bool IsInsideBeginImplFrame() const { return inside_begin_impl_frame_; } 178 bool IsInsideBeginImplFrame() const { return inside_begin_impl_frame_; }
179 179
180 base::Callback<bool(void)> InsideBeginImplFrame(bool state) { 180 base::Callback<bool(void)> InsideBeginImplFrame(bool state) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 client_->set_scheduler(scheduler_.get()); 264 client_->set_scheduler(scheduler_.get());
265 265
266 // Use large estimates by default to avoid latency recovery in most tests. 266 // Use large estimates by default to avoid latency recovery in most tests.
267 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); 267 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration);
268 268
269 return scheduler_.get(); 269 return scheduler_.get();
270 } 270 }
271 271
272 void CreateSchedulerAndInitSurface() { 272 void CreateSchedulerAndInitSurface() {
273 CreateScheduler(); 273 CreateScheduler();
274 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); 274 EXPECT_SCOPED(InitializeCompositorFrameSinkAndFirstCommit());
275 } 275 }
276 276
277 void SetUpScheduler(bool initSurface) { 277 void SetUpScheduler(bool initSurface) {
278 SetUpScheduler(base::WrapUnique(new FakeSchedulerClient), initSurface); 278 SetUpScheduler(base::WrapUnique(new FakeSchedulerClient), initSurface);
279 } 279 }
280 280
281 void SetUpScheduler(std::unique_ptr<FakeSchedulerClient> client, 281 void SetUpScheduler(std::unique_ptr<FakeSchedulerClient> client,
282 bool initSurface) { 282 bool initSurface) {
283 client_ = std::move(client); 283 client_ = std::move(client);
284 if (initSurface) 284 if (initSurface)
285 CreateSchedulerAndInitSurface(); 285 CreateSchedulerAndInitSurface();
286 else 286 else
287 CreateScheduler(); 287 CreateScheduler();
288 } 288 }
289 289
290 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } 290 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; }
291 base::SimpleTestTickClock* now_src() { return now_src_.get(); } 291 base::SimpleTestTickClock* now_src() { return now_src_.get(); }
292 292
293 // As this function contains EXPECT macros, to allow debugging it should be 293 // As this function contains EXPECT macros, to allow debugging it should be
294 // called inside EXPECT_SCOPED like so; 294 // called inside EXPECT_SCOPED like so;
295 // EXPECT_SCOPED(client.InitializeOutputSurfaceAndFirstCommit(scheduler)); 295 // EXPECT_SCOPED(
296 void InitializeOutputSurfaceAndFirstCommit() { 296 // client.InitializeCompositorFrameSinkAndFirstCommit(scheduler));
297 TRACE_EVENT0("cc", 297 void InitializeCompositorFrameSinkAndFirstCommit() {
298 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); 298 TRACE_EVENT0(
299 "cc", "SchedulerUnitTest::InitializeCompositorFrameSinkAndFirstCommit");
299 DCHECK(scheduler_); 300 DCHECK(scheduler_);
300 301
301 // Check the client doesn't have any actions queued when calling this 302 // Check the client doesn't have any actions queued when calling this
302 // function. 303 // function.
303 EXPECT_NO_ACTION(client_); 304 EXPECT_NO_ACTION(client_);
304 EXPECT_FALSE(scheduler_->begin_frames_expected()); 305 EXPECT_FALSE(scheduler_->begin_frames_expected());
305 306
306 // Start the initial output surface creation. 307 // Start the initial CompositorFrameSink creation.
307 scheduler_->SetVisible(true); 308 scheduler_->SetVisible(true);
308 scheduler_->SetCanDraw(true); 309 scheduler_->SetCanDraw(true);
309 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 310 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation",
311 client_);
310 312
311 client_->Reset(); 313 client_->Reset();
312 314
313 // We don't see anything happening until the first impl frame. 315 // We don't see anything happening until the first impl frame.
314 scheduler_->DidCreateAndInitializeOutputSurface(); 316 scheduler_->DidCreateAndInitializeCompositorFrameSink();
315 scheduler_->SetNeedsBeginMainFrame(); 317 scheduler_->SetNeedsBeginMainFrame();
316 EXPECT_TRUE(scheduler_->begin_frames_expected()); 318 EXPECT_TRUE(scheduler_->begin_frames_expected());
317 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 319 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
318 client_->Reset(); 320 client_->Reset();
319 321
320 { 322 {
321 SCOPED_TRACE("Do first frame to commit after initialize."); 323 SCOPED_TRACE("Do first frame to commit after initialize.");
322 AdvanceFrame(); 324 AdvanceFrame();
323 325
324 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 326 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
325 scheduler_->NotifyReadyToCommit(); 327 scheduler_->NotifyReadyToCommit();
326 scheduler_->NotifyReadyToActivate(); 328 scheduler_->NotifyReadyToActivate();
327 scheduler_->NotifyReadyToDraw(); 329 scheduler_->NotifyReadyToDraw();
328 330
329 EXPECT_FALSE(scheduler_->CommitPending()); 331 EXPECT_FALSE(scheduler_->CommitPending());
330 332
331 if (scheduler_settings_.using_synchronous_renderer_compositor) { 333 if (scheduler_settings_.using_synchronous_renderer_compositor) {
332 scheduler_->SetNeedsRedraw(); 334 scheduler_->SetNeedsRedraw();
333 bool resourceless_software_draw = false; 335 bool resourceless_software_draw = false;
334 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 336 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
335 } else { 337 } else {
336 // Run the posted deadline task. 338 // Run the posted deadline task.
337 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 339 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
338 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); 340 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
339 } 341 }
340 342
341 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 343 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
342 } 344 }
343 345
344 client_->Reset(); 346 client_->Reset();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 std::unique_ptr<FakeExternalBeginFrameSource> 424 std::unique_ptr<FakeExternalBeginFrameSource>
423 fake_external_begin_frame_source_; 425 fake_external_begin_frame_source_;
424 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; 426 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_;
425 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_; 427 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_;
426 SchedulerSettings scheduler_settings_; 428 SchedulerSettings scheduler_settings_;
427 std::unique_ptr<FakeSchedulerClient> client_; 429 std::unique_ptr<FakeSchedulerClient> client_;
428 std::unique_ptr<TestScheduler> scheduler_; 430 std::unique_ptr<TestScheduler> scheduler_;
429 FakeCompositorTimingHistory* fake_compositor_timing_history_; 431 FakeCompositorTimingHistory* fake_compositor_timing_history_;
430 }; 432 };
431 433
432 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { 434 TEST_F(SchedulerTest, InitializeCompositorFrameSinkDoesNotBeginImplFrame) {
433 scheduler_settings_.use_external_begin_frame_source = true; 435 scheduler_settings_.use_external_begin_frame_source = true;
434 SetUpScheduler(false); 436 SetUpScheduler(false);
435 scheduler_->SetVisible(true); 437 scheduler_->SetVisible(true);
436 scheduler_->SetCanDraw(true); 438 scheduler_->SetCanDraw(true);
437 439
438 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 440 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation",
441 client_);
439 client_->Reset(); 442 client_->Reset();
440 scheduler_->DidCreateAndInitializeOutputSurface(); 443 scheduler_->DidCreateAndInitializeCompositorFrameSink();
441 EXPECT_NO_ACTION(client_); 444 EXPECT_NO_ACTION(client_);
442 } 445 }
443 446
444 TEST_F(SchedulerTest, VideoNeedsBeginFrames) { 447 TEST_F(SchedulerTest, VideoNeedsBeginFrames) {
445 scheduler_settings_.use_external_begin_frame_source = true; 448 scheduler_settings_.use_external_begin_frame_source = true;
446 SetUpScheduler(true); 449 SetUpScheduler(true);
447 450
448 scheduler_->SetVideoNeedsBeginFrames(true); 451 scheduler_->SetVideoNeedsBeginFrames(true);
449 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 452 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
450 EXPECT_TRUE(scheduler_->begin_frames_expected()); 453 EXPECT_TRUE(scheduler_->begin_frames_expected());
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 scheduler_->NotifyReadyToActivate(); 630 scheduler_->NotifyReadyToActivate();
628 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 631 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
629 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 632 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
630 client_->Reset(); 633 client_->Reset();
631 634
632 task_runner().RunPendingTasks(); // Run posted deadline. 635 task_runner().RunPendingTasks(); // Run posted deadline.
633 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 636 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
634 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 637 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
635 638
636 // Because we just swapped, the Scheduler should also request the next 639 // Because we just swapped, the Scheduler should also request the next
637 // BeginImplFrame from the OutputSurface. 640 // BeginImplFrame from the CompositorFrameSink.
638 EXPECT_TRUE(scheduler_->begin_frames_expected()); 641 EXPECT_TRUE(scheduler_->begin_frames_expected());
639 client_->Reset(); 642 client_->Reset();
640 // Since another commit is needed, the next BeginImplFrame should initiate 643 // Since another commit is needed, the next BeginImplFrame should initiate
641 // the second commit. 644 // the second commit.
642 EXPECT_SCOPED(AdvanceFrame()); 645 EXPECT_SCOPED(AdvanceFrame());
643 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 646 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
644 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 647 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
645 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 648 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
646 client_->Reset(); 649 client_->Reset();
647 650
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 EXPECT_NO_ACTION(client_); 1229 EXPECT_NO_ACTION(client_);
1227 1230
1228 // Scheduler received ready to draw signal, and posted deadline. 1231 // Scheduler received ready to draw signal, and posted deadline.
1229 scheduler_->NotifyReadyToDraw(); 1232 scheduler_->NotifyReadyToDraw();
1230 client_->Reset(); 1233 client_->Reset();
1231 task_runner().RunPendingTasks(); // Run posted deadline. 1234 task_runner().RunPendingTasks(); // Run posted deadline.
1232 EXPECT_EQ(1, client_->num_draws()); 1235 EXPECT_EQ(1, client_->num_draws());
1233 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1236 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1234 } 1237 }
1235 1238
1236 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostOutputSurface) { 1239 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostCompositorFrameSink) {
1237 SchedulerClientNeedsPrepareTilesInDraw* client = 1240 SchedulerClientNeedsPrepareTilesInDraw* client =
1238 new SchedulerClientNeedsPrepareTilesInDraw; 1241 new SchedulerClientNeedsPrepareTilesInDraw;
1239 scheduler_settings_.use_external_begin_frame_source = true; 1242 scheduler_settings_.use_external_begin_frame_source = true;
1240 scheduler_settings_.commit_to_active_tree = true; 1243 scheduler_settings_.commit_to_active_tree = true;
1241 SetUpScheduler(base::WrapUnique(client), true); 1244 SetUpScheduler(base::WrapUnique(client), true);
1242 1245
1243 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 1246 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
1244 scheduler_->SetNeedsBeginMainFrame(); 1247 scheduler_->SetNeedsBeginMainFrame();
1245 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 1248 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
1246 client_->Reset(); 1249 client_->Reset();
(...skipping 11 matching lines...) Expand all
1258 client_->Reset(); 1261 client_->Reset();
1259 scheduler_->NotifyReadyToActivate(); 1262 scheduler_->NotifyReadyToActivate();
1260 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 1263 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
1261 1264
1262 // Scheduler won't post deadline in the mode. 1265 // Scheduler won't post deadline in the mode.
1263 client_->Reset(); 1266 client_->Reset();
1264 task_runner().RunPendingTasks(); // Try to run posted deadline. 1267 task_runner().RunPendingTasks(); // Try to run posted deadline.
1265 // There is no posted deadline. 1268 // There is no posted deadline.
1266 EXPECT_NO_ACTION(client_); 1269 EXPECT_NO_ACTION(client_);
1267 1270
1268 // Scheduler loses output surface, and stops waiting for ready to draw signal. 1271 // Scheduler loses CompositorFrameSink, and stops waiting for ready to draw
1272 // signal.
1269 client_->Reset(); 1273 client_->Reset();
1270 scheduler_->DidLoseOutputSurface(); 1274 scheduler_->DidLoseCompositorFrameSink();
1271 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 1275 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
1272 task_runner().RunPendingTasks(); // Run posted deadline. 1276 task_runner().RunPendingTasks(); // Run posted deadline.
1273 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 1277 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
1278 3);
1274 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 1279 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
1275 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 1280 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
1276 } 1281 }
1277 1282
1278 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit( 1283 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit(
1279 bool expect_send_begin_main_frame) { 1284 bool expect_send_begin_main_frame) {
1280 // Impl thread hits deadline before commit finishes. 1285 // Impl thread hits deadline before commit finishes.
1281 scheduler_->SetNeedsBeginMainFrame(); 1286 scheduler_->SetNeedsBeginMainFrame();
1282 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); 1287 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline());
1283 EXPECT_SCOPED(AdvanceFrame()); 1288 EXPECT_SCOPED(AdvanceFrame());
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 } 2474 }
2470 2475
2471 TEST_F(SchedulerTest, 2476 TEST_F(SchedulerTest,
2472 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { 2477 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) {
2473 bool use_external_begin_frame_source = false; 2478 bool use_external_begin_frame_source = false;
2474 bool throttle_frame_production = false; 2479 bool throttle_frame_production = false;
2475 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, 2480 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source,
2476 throttle_frame_production); 2481 throttle_frame_production);
2477 } 2482 }
2478 2483
2479 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterOutputSurfaceIsInitialized) { 2484 TEST_F(SchedulerTest,
2485 DidLoseCompositorFrameSinkAfterCompositorFrameSinkIsInitialized) {
2480 scheduler_settings_.use_external_begin_frame_source = true; 2486 scheduler_settings_.use_external_begin_frame_source = true;
2481 SetUpScheduler(false); 2487 SetUpScheduler(false);
2482 2488
2483 scheduler_->SetVisible(true); 2489 scheduler_->SetVisible(true);
2484 scheduler_->SetCanDraw(true); 2490 scheduler_->SetCanDraw(true);
2485 2491
2486 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 2492 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation",
2493 client_);
2487 client_->Reset(); 2494 client_->Reset();
2488 scheduler_->DidCreateAndInitializeOutputSurface(); 2495 scheduler_->DidCreateAndInitializeCompositorFrameSink();
2489 EXPECT_NO_ACTION(client_); 2496 EXPECT_NO_ACTION(client_);
2490 2497
2491 scheduler_->DidLoseOutputSurface(); 2498 scheduler_->DidLoseCompositorFrameSink();
2492 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 2499 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation",
2500 client_);
2493 } 2501 }
2494 2502
2495 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginFrameStarted) { 2503 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterBeginFrameStarted) {
2496 scheduler_settings_.use_external_begin_frame_source = true; 2504 scheduler_settings_.use_external_begin_frame_source = true;
2497 SetUpScheduler(true); 2505 SetUpScheduler(true);
2498 2506
2499 // SetNeedsBeginMainFrame should begin the frame. 2507 // SetNeedsBeginMainFrame should begin the frame.
2500 scheduler_->SetNeedsBeginMainFrame(); 2508 scheduler_->SetNeedsBeginMainFrame();
2501 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2509 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2502 2510
2503 client_->Reset(); 2511 client_->Reset();
2504 EXPECT_SCOPED(AdvanceFrame()); 2512 EXPECT_SCOPED(AdvanceFrame());
2505 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2513 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2506 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2514 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2507 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2515 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2508 2516
2509 client_->Reset(); 2517 client_->Reset();
2510 scheduler_->DidLoseOutputSurface(); 2518 scheduler_->DidLoseCompositorFrameSink();
2511 // RemoveObserver(this) is not called until the end of the frame. 2519 // RemoveObserver(this) is not called until the end of the frame.
2512 EXPECT_NO_ACTION(client_); 2520 EXPECT_NO_ACTION(client_);
2513 2521
2514 client_->Reset(); 2522 client_->Reset();
2515 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2523 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2516 scheduler_->NotifyReadyToCommit(); 2524 scheduler_->NotifyReadyToCommit();
2517 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 2); 2525 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 2);
2518 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 2); 2526 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 2);
2519 2527
2520 client_->Reset(); 2528 client_->Reset();
2521 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2529 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2522 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2530 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
2531 3);
2523 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2532 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2524 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2533 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2525 } 2534 }
2526 2535
2527 TEST_F(SchedulerTest, 2536 TEST_F(SchedulerTest,
2528 DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency) { 2537 DidLoseCompositorFrameSinkAfterBeginFrameStartedWithHighLatency) {
2529 scheduler_settings_.use_external_begin_frame_source = true; 2538 scheduler_settings_.use_external_begin_frame_source = true;
2530 SetUpScheduler(true); 2539 SetUpScheduler(true);
2531 2540
2532 // SetNeedsBeginMainFrame should begin the frame. 2541 // SetNeedsBeginMainFrame should begin the frame.
2533 scheduler_->SetNeedsBeginMainFrame(); 2542 scheduler_->SetNeedsBeginMainFrame();
2534 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2543 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2535 2544
2536 client_->Reset(); 2545 client_->Reset();
2537 EXPECT_SCOPED(AdvanceFrame()); 2546 EXPECT_SCOPED(AdvanceFrame());
2538 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2547 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2539 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2548 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2540 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2549 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2541 2550
2542 client_->Reset(); 2551 client_->Reset();
2543 scheduler_->DidLoseOutputSurface(); 2552 scheduler_->DidLoseCompositorFrameSink();
2544 // Do nothing when impl frame is in deadine pending state. 2553 // Do nothing when impl frame is in deadine pending state.
2545 EXPECT_NO_ACTION(client_); 2554 EXPECT_NO_ACTION(client_);
2546 2555
2547 client_->Reset(); 2556 client_->Reset();
2548 // Run posted deadline. 2557 // Run posted deadline.
2549 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2558 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2550 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2559 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2551 // OnBeginImplFrameDeadline didn't schedule output surface creation because 2560 // OnBeginImplFrameDeadline didn't schedule CompositorFrameSink creation
2561 // because
2552 // main frame is not yet completed. 2562 // main frame is not yet completed.
2553 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); 2563 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
2554 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 2564 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
2555 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2565 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2556 2566
2557 // BeginImplFrame is not started. 2567 // BeginImplFrame is not started.
2558 client_->Reset(); 2568 client_->Reset();
2559 task_runner().RunUntilTime(now_src()->NowTicks() + 2569 task_runner().RunUntilTime(now_src()->NowTicks() +
2560 base::TimeDelta::FromMilliseconds(10)); 2570 base::TimeDelta::FromMilliseconds(10));
2561 EXPECT_NO_ACTION(client_); 2571 EXPECT_NO_ACTION(client_);
2562 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2572 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2563 2573
2564 client_->Reset(); 2574 client_->Reset();
2565 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2575 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2566 scheduler_->NotifyReadyToCommit(); 2576 scheduler_->NotifyReadyToCommit();
2567 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); 2577 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3);
2568 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); 2578 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3);
2569 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 2, 3); 2579 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 2,
2580 3);
2570 } 2581 }
2571 2582
2572 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) { 2583 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterReadyToCommit) {
2573 scheduler_settings_.use_external_begin_frame_source = true; 2584 scheduler_settings_.use_external_begin_frame_source = true;
2574 SetUpScheduler(true); 2585 SetUpScheduler(true);
2575 2586
2576 // SetNeedsBeginMainFrame should begin the frame. 2587 // SetNeedsBeginMainFrame should begin the frame.
2577 scheduler_->SetNeedsBeginMainFrame(); 2588 scheduler_->SetNeedsBeginMainFrame();
2578 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2589 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2579 2590
2580 client_->Reset(); 2591 client_->Reset();
2581 EXPECT_SCOPED(AdvanceFrame()); 2592 EXPECT_SCOPED(AdvanceFrame());
2582 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2593 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2583 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2594 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2584 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2595 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2585 2596
2586 client_->Reset(); 2597 client_->Reset();
2587 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2598 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2588 scheduler_->NotifyReadyToCommit(); 2599 scheduler_->NotifyReadyToCommit();
2589 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 2600 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
2590 2601
2591 client_->Reset(); 2602 client_->Reset();
2592 scheduler_->DidLoseOutputSurface(); 2603 scheduler_->DidLoseCompositorFrameSink();
2593 // Sync tree should be forced to activate. 2604 // Sync tree should be forced to activate.
2594 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 2605 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
2595 2606
2596 // RemoveObserver(this) is not called until the end of the frame. 2607 // RemoveObserver(this) is not called until the end of the frame.
2597 client_->Reset(); 2608 client_->Reset();
2598 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2609 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2599 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2610 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
2611 3);
2600 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2612 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2601 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2613 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2602 } 2614 }
2603 2615
2604 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterSetNeedsPrepareTiles) { 2616 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterSetNeedsPrepareTiles) {
2605 scheduler_settings_.use_external_begin_frame_source = true; 2617 scheduler_settings_.use_external_begin_frame_source = true;
2606 SetUpScheduler(true); 2618 SetUpScheduler(true);
2607 2619
2608 scheduler_->SetNeedsPrepareTiles(); 2620 scheduler_->SetNeedsPrepareTiles();
2609 scheduler_->SetNeedsRedraw(); 2621 scheduler_->SetNeedsRedraw();
2610 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2622 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2611 2623
2612 client_->Reset(); 2624 client_->Reset();
2613 EXPECT_SCOPED(AdvanceFrame()); 2625 EXPECT_SCOPED(AdvanceFrame());
2614 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 2626 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
2615 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2627 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2616 2628
2617 client_->Reset(); 2629 client_->Reset();
2618 scheduler_->DidLoseOutputSurface(); 2630 scheduler_->DidLoseCompositorFrameSink();
2619 // RemoveObserver(this) is not called until the end of the frame. 2631 // RemoveObserver(this) is not called until the end of the frame.
2620 EXPECT_NO_ACTION(client_); 2632 EXPECT_NO_ACTION(client_);
2621 2633
2622 client_->Reset(); 2634 client_->Reset();
2623 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2635 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2624 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4); 2636 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4);
2625 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 4); 2637 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 1,
2638 4);
2626 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); 2639 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4);
2627 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); 2640 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4);
2628 } 2641 }
2629 2642
2630 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { 2643 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterBeginRetroFramePosted) {
2631 scheduler_settings_.use_external_begin_frame_source = true; 2644 scheduler_settings_.use_external_begin_frame_source = true;
2632 SetUpScheduler(true); 2645 SetUpScheduler(true);
2633 2646
2634 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2647 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
2635 scheduler_->SetNeedsBeginMainFrame(); 2648 scheduler_->SetNeedsBeginMainFrame();
2636 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2649 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2637 2650
2638 // Create a BeginFrame with a long deadline to avoid race conditions. 2651 // Create a BeginFrame with a long deadline to avoid race conditions.
2639 // This is the first BeginFrame, which will be handled immediately. 2652 // This is the first BeginFrame, which will be handled immediately.
2640 client_->Reset(); 2653 client_->Reset();
(...skipping 27 matching lines...) Expand all
2668 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2681 EXPECT_TRUE(scheduler_->begin_frames_expected());
2669 2682
2670 // NotifyReadyToActivate should trigger the activation. 2683 // NotifyReadyToActivate should trigger the activation.
2671 client_->Reset(); 2684 client_->Reset();
2672 scheduler_->NotifyReadyToActivate(); 2685 scheduler_->NotifyReadyToActivate();
2673 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 2686 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
2674 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2687 EXPECT_TRUE(scheduler_->begin_frames_expected());
2675 2688
2676 client_->Reset(); 2689 client_->Reset();
2677 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); 2690 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty());
2678 scheduler_->DidLoseOutputSurface(); 2691 scheduler_->DidLoseCompositorFrameSink();
2679 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2692 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
2693 3);
2680 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2694 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2681 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2695 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2682 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); 2696 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty());
2683 2697
2684 // Posted BeginRetroFrame is aborted. 2698 // Posted BeginRetroFrame is aborted.
2685 client_->Reset(); 2699 client_->Reset();
2686 task_runner().RunPendingTasks(); 2700 task_runner().RunPendingTasks();
2687 EXPECT_NO_ACTION(client_); 2701 EXPECT_NO_ACTION(client_);
2688 } 2702 }
2689 2703
2690 TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { 2704 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkDuringBeginRetroFrameRunning) {
2691 scheduler_settings_.use_external_begin_frame_source = true; 2705 scheduler_settings_.use_external_begin_frame_source = true;
2692 SetUpScheduler(true); 2706 SetUpScheduler(true);
2693 2707
2694 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2708 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
2695 scheduler_->SetNeedsBeginMainFrame(); 2709 scheduler_->SetNeedsBeginMainFrame();
2696 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2710 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2697 2711
2698 // Create a BeginFrame with a long deadline to avoid race conditions. 2712 // Create a BeginFrame with a long deadline to avoid race conditions.
2699 // This is the first BeginFrame, which will be handled immediately. 2713 // This is the first BeginFrame, which will be handled immediately.
2700 client_->Reset(); 2714 client_->Reset();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 2749
2736 // BeginImplFrame should prepare the draw. 2750 // BeginImplFrame should prepare the draw.
2737 client_->Reset(); 2751 client_->Reset();
2738 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. 2752 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
2739 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); 2753 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
2740 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2754 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2741 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2755 EXPECT_TRUE(scheduler_->begin_frames_expected());
2742 2756
2743 client_->Reset(); 2757 client_->Reset();
2744 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); 2758 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty());
2745 scheduler_->DidLoseOutputSurface(); 2759 scheduler_->DidLoseCompositorFrameSink();
2746 EXPECT_NO_ACTION(client_); 2760 EXPECT_NO_ACTION(client_);
2747 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); 2761 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty());
2748 2762
2749 // BeginImplFrame deadline should abort drawing. 2763 // BeginImplFrame deadline should abort drawing.
2750 client_->Reset(); 2764 client_->Reset();
2751 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2765 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2752 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2766 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
2767 3);
2753 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2768 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2754 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2769 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2755 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 2770 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
2756 EXPECT_FALSE(scheduler_->begin_frames_expected()); 2771 EXPECT_FALSE(scheduler_->begin_frames_expected());
2757 2772
2758 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. 2773 // No more BeginRetroFrame because BeginRetroFrame queue is cleared.
2759 client_->Reset(); 2774 client_->Reset();
2760 task_runner().RunPendingTasks(); 2775 task_runner().RunPendingTasks();
2761 EXPECT_NO_ACTION(client_); 2776 EXPECT_NO_ACTION(client_);
2762 } 2777 }
2763 2778
2764 TEST_F(SchedulerTest, DidLoseOutputSurfaceWithDelayBasedBeginFrameSource) { 2779 TEST_F(SchedulerTest,
2780 DidLoseCompositorFrameSinkWithDelayBasedBeginFrameSource) {
2765 SetUpScheduler(true); 2781 SetUpScheduler(true);
2766 2782
2767 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. 2783 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
2768 EXPECT_FALSE(scheduler_->begin_frames_expected()); 2784 EXPECT_FALSE(scheduler_->begin_frames_expected());
2769 scheduler_->SetNeedsBeginMainFrame(); 2785 scheduler_->SetNeedsBeginMainFrame();
2770 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2786 EXPECT_TRUE(scheduler_->begin_frames_expected());
2771 2787
2772 client_->Reset(); 2788 client_->Reset();
2773 AdvanceFrame(); 2789 AdvanceFrame();
2774 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2790 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2775 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2791 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2776 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2792 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2777 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2793 EXPECT_TRUE(scheduler_->begin_frames_expected());
2778 2794
2779 // NotifyReadyToCommit should trigger the commit. 2795 // NotifyReadyToCommit should trigger the commit.
2780 client_->Reset(); 2796 client_->Reset();
2781 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2797 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2782 scheduler_->NotifyReadyToCommit(); 2798 scheduler_->NotifyReadyToCommit();
2783 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 2799 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
2784 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2800 EXPECT_TRUE(scheduler_->begin_frames_expected());
2785 2801
2786 // NotifyReadyToActivate should trigger the activation. 2802 // NotifyReadyToActivate should trigger the activation.
2787 client_->Reset(); 2803 client_->Reset();
2788 scheduler_->NotifyReadyToActivate(); 2804 scheduler_->NotifyReadyToActivate();
2789 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 2805 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
2790 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2806 EXPECT_TRUE(scheduler_->begin_frames_expected());
2791 2807
2792 client_->Reset(); 2808 client_->Reset();
2793 scheduler_->DidLoseOutputSurface(); 2809 scheduler_->DidLoseCompositorFrameSink();
2794 // RemoveObserver(this) is not called until the end of the frame. 2810 // RemoveObserver(this) is not called until the end of the frame.
2795 EXPECT_NO_ACTION(client_); 2811 EXPECT_NO_ACTION(client_);
2796 EXPECT_TRUE(scheduler_->begin_frames_expected()); 2812 EXPECT_TRUE(scheduler_->begin_frames_expected());
2797 2813
2798 client_->Reset(); 2814 client_->Reset();
2799 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2815 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2800 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 2); 2816 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
2817 2);
2801 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 2818 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
2802 EXPECT_FALSE(scheduler_->begin_frames_expected()); 2819 EXPECT_FALSE(scheduler_->begin_frames_expected());
2803 } 2820 }
2804 2821
2805 TEST_F(SchedulerTest, DidLoseOutputSurfaceWhenIdle) { 2822 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkWhenIdle) {
2806 scheduler_settings_.use_external_begin_frame_source = true; 2823 scheduler_settings_.use_external_begin_frame_source = true;
2807 SetUpScheduler(true); 2824 SetUpScheduler(true);
2808 2825
2809 // SetNeedsBeginMainFrame should begin the frame. 2826 // SetNeedsBeginMainFrame should begin the frame.
2810 scheduler_->SetNeedsBeginMainFrame(); 2827 scheduler_->SetNeedsBeginMainFrame();
2811 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 2828 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
2812 2829
2813 client_->Reset(); 2830 client_->Reset();
2814 EXPECT_SCOPED(AdvanceFrame()); 2831 EXPECT_SCOPED(AdvanceFrame());
2815 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2832 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2816 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 2833 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
2817 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 2834 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
2818 2835
2819 client_->Reset(); 2836 client_->Reset();
2820 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 2837 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
2821 scheduler_->NotifyReadyToCommit(); 2838 scheduler_->NotifyReadyToCommit();
2822 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 2839 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
2823 2840
2824 client_->Reset(); 2841 client_->Reset();
2825 scheduler_->NotifyReadyToActivate(); 2842 scheduler_->NotifyReadyToActivate();
2826 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 2843 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
2827 2844
2828 client_->Reset(); 2845 client_->Reset();
2829 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 2846 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
2830 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 2847 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
2831 2848
2832 // Idle time between BeginFrames. 2849 // Idle time between BeginFrames.
2833 client_->Reset(); 2850 client_->Reset();
2834 scheduler_->DidLoseOutputSurface(); 2851 scheduler_->DidLoseCompositorFrameSink();
2835 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 2852 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
2853 3);
2836 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 2854 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
2837 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 2855 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
2838 } 2856 }
2839 2857
2840 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) { 2858 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) {
2841 scheduler_settings_.use_external_begin_frame_source = true; 2859 scheduler_settings_.use_external_begin_frame_source = true;
2842 SetUpScheduler(true); 2860 SetUpScheduler(true);
2843 2861
2844 // SetNeedsBeginMainFrame should begin the frame. 2862 // SetNeedsBeginMainFrame should begin the frame.
2845 scheduler_->SetNeedsBeginMainFrame(); 2863 scheduler_->SetNeedsBeginMainFrame();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3093 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3076 3094
3077 client_->Reset(); 3095 client_->Reset();
3078 scheduler_->NotifyReadyToCommit(); 3096 scheduler_->NotifyReadyToCommit();
3079 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 3097 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
3080 3098
3081 client_->Reset(); 3099 client_->Reset();
3082 scheduler_->NotifyReadyToActivate(); 3100 scheduler_->NotifyReadyToActivate();
3083 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 3101 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
3084 3102
3085 // Scheduler loses output surface, and stops waiting for ready to draw signal. 3103 // Scheduler loses CompositorFrameSink, and stops waiting for ready to draw
3104 // signal.
3086 client_->Reset(); 3105 client_->Reset();
3087 scheduler_->DidLoseOutputSurface(); 3106 scheduler_->DidLoseCompositorFrameSink();
3088 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 3107 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
3089 task_runner().RunPendingTasks(); 3108 task_runner().RunPendingTasks();
3090 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 3109 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
3110 3);
3091 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3111 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3092 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3112 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3093 3113
3094 // Changing begin frame source doesn't do anything. 3114 // Changing begin frame source doesn't do anything.
3095 // The unthrottled source doesn't print Add/RemoveObserver like the fake one. 3115 // The unthrottled source doesn't print Add/RemoveObserver like the fake one.
3096 client_->Reset(); 3116 client_->Reset();
3097 scheduler_->SetBeginFrameSource(unthrottled_frame_source_.get()); 3117 scheduler_->SetBeginFrameSource(unthrottled_frame_source_.get());
3098 EXPECT_NO_ACTION(client_); 3118 EXPECT_NO_ACTION(client_);
3099 3119
3100 client_->Reset(); 3120 client_->Reset();
3101 scheduler_->DidCreateAndInitializeOutputSurface(); 3121 scheduler_->DidCreateAndInitializeCompositorFrameSink();
3102 EXPECT_NO_ACTION(client_); 3122 EXPECT_NO_ACTION(client_);
3103 3123
3104 client_->Reset(); 3124 client_->Reset();
3105 scheduler_->SetNeedsBeginMainFrame(); 3125 scheduler_->SetNeedsBeginMainFrame();
3106 EXPECT_NO_ACTION(client_); 3126 EXPECT_NO_ACTION(client_);
3107 3127
3108 client_->Reset(); 3128 client_->Reset();
3109 EXPECT_SCOPED(AdvanceFrame()); 3129 EXPECT_SCOPED(AdvanceFrame());
3110 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3130 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3111 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3131 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 client_->Reset(); 3177 client_->Reset();
3158 3178
3159 // Testing the case where animation ticks a fling scroll. 3179 // Testing the case where animation ticks a fling scroll.
3160 client_->SetWillBeginImplFrameCausesRedraw(true); 3180 client_->SetWillBeginImplFrameCausesRedraw(true);
3161 // The animation isn't done so it'll cause another tick in the future. 3181 // The animation isn't done so it'll cause another tick in the future.
3162 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); 3182 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true);
3163 3183
3164 // Next vsync. 3184 // Next vsync.
3165 AdvanceFrame(); 3185 AdvanceFrame();
3166 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3186 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3167 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3187 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2);
3168 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3188 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3169 client_->Reset(); 3189 client_->Reset();
3170 3190
3171 // Android onDraw. This doesn't consume the single begin frame request. 3191 // Android onDraw. This doesn't consume the single begin frame request.
3172 scheduler_->SetNeedsRedraw(); 3192 scheduler_->SetNeedsRedraw();
3173 bool resourceless_software_draw = false; 3193 bool resourceless_software_draw = false;
3174 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3194 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3175 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 3195 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
3176 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3196 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3177 client_->Reset(); 3197 client_->Reset();
3178 3198
3179 // The animation inside of WillBeginImplFrame changes stuff on the screen, but 3199 // The animation inside of WillBeginImplFrame changes stuff on the screen, but
3180 // ends here, so does not cause another frame to happen. 3200 // ends here, so does not cause another frame to happen.
3181 client_->SetWillBeginImplFrameCausesRedraw(true); 3201 client_->SetWillBeginImplFrameCausesRedraw(true);
3182 3202
3183 // Next vsync. 3203 // Next vsync.
3184 AdvanceFrame(); 3204 AdvanceFrame();
3185 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3205 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3186 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3206 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2);
3187 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3207 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3188 client_->Reset(); 3208 client_->Reset();
3189 3209
3190 // Android onDraw. 3210 // Android onDraw.
3191 scheduler_->SetNeedsRedraw(); 3211 scheduler_->SetNeedsRedraw();
3192 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3212 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3193 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 3213 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
3194 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3214 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3195 client_->Reset(); 3215 client_->Reset();
3196 3216
3197 // Idle on next vsync, as the animation has completed. 3217 // Idle on next vsync, as the animation has completed.
3198 AdvanceFrame(); 3218 AdvanceFrame();
3199 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3219 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3200 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3220 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3201 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3221 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3202 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3222 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3203 client_->Reset(); 3223 client_->Reset();
3204 } 3224 }
3205 3225
3206 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) { 3226 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) {
3207 scheduler_settings_.using_synchronous_renderer_compositor = true; 3227 scheduler_settings_.using_synchronous_renderer_compositor = true;
3208 scheduler_settings_.use_external_begin_frame_source = true; 3228 scheduler_settings_.use_external_begin_frame_source = true;
3209 SetUpScheduler(true); 3229 SetUpScheduler(true);
3210 3230
3211 scheduler_->SetNeedsRedraw(); 3231 scheduler_->SetNeedsRedraw();
3212 bool resourceless_software_draw = false; 3232 bool resourceless_software_draw = false;
3213 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3233 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3214 EXPECT_ACTION("AddObserver(this)", client_, 0, 2); 3234 EXPECT_ACTION("AddObserver(this)", client_, 0, 2);
3215 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); 3235 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2);
3216 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3236 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3217 client_->Reset(); 3237 client_->Reset();
3218 3238
3219 // Idle on next vsync. 3239 // Idle on next vsync.
3220 AdvanceFrame(); 3240 AdvanceFrame();
3221 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3241 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3222 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3242 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3223 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3243 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 3312 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
3293 client_->Reset(); 3313 client_->Reset();
3294 3314
3295 scheduler_->NotifyReadyToActivate(); 3315 scheduler_->NotifyReadyToActivate();
3296 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 3316 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
3297 client_->Reset(); 3317 client_->Reset();
3298 3318
3299 // Next vsync. 3319 // Next vsync.
3300 AdvanceFrame(); 3320 AdvanceFrame();
3301 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3321 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3302 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3322 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2);
3303 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3323 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3304 client_->Reset(); 3324 client_->Reset();
3305 3325
3306 // Android onDraw. 3326 // Android onDraw.
3307 scheduler_->SetNeedsRedraw(); 3327 scheduler_->SetNeedsRedraw();
3308 bool resourceless_software_draw = false; 3328 bool resourceless_software_draw = false;
3309 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3329 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3310 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 3330 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
3311 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3331 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3312 client_->Reset(); 3332 client_->Reset();
3313 3333
3314 // Idle on next vsync. 3334 // Idle on next vsync.
3315 AdvanceFrame(); 3335 AdvanceFrame();
3316 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3336 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3317 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3337 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3318 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3338 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3319 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3339 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
(...skipping 26 matching lines...) Expand all
3346 scheduler_->NotifyReadyToActivate(); 3366 scheduler_->NotifyReadyToActivate();
3347 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 3367 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
3348 client_->Reset(); 3368 client_->Reset();
3349 3369
3350 // Ask for another commit. 3370 // Ask for another commit.
3351 scheduler_->SetNeedsBeginMainFrame(); 3371 scheduler_->SetNeedsBeginMainFrame();
3352 3372
3353 AdvanceFrame(); 3373 AdvanceFrame();
3354 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3374 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3355 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 3); 3375 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 3);
3356 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 2, 3); 3376 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 2, 3);
3357 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3377 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3358 client_->Reset(); 3378 client_->Reset();
3359 3379
3360 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 3380 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
3361 EXPECT_NO_ACTION(client_); 3381 EXPECT_NO_ACTION(client_);
3362 3382
3363 // Allow new commit even though previous commit hasn't been drawn. 3383 // Allow new commit even though previous commit hasn't been drawn.
3364 scheduler_->NotifyReadyToCommit(); 3384 scheduler_->NotifyReadyToCommit();
3365 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 3385 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
3366 client_->Reset(); 3386 client_->Reset();
(...skipping 18 matching lines...) Expand all
3385 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw); 3405 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw);
3386 SetUpScheduler(std::move(client), true); 3406 SetUpScheduler(std::move(client), true);
3387 3407
3388 scheduler_->SetNeedsRedraw(); 3408 scheduler_->SetNeedsRedraw();
3389 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3409 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3390 client_->Reset(); 3410 client_->Reset();
3391 3411
3392 // Next vsync. 3412 // Next vsync.
3393 EXPECT_SCOPED(AdvanceFrame()); 3413 EXPECT_SCOPED(AdvanceFrame());
3394 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3414 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3395 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3415 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2);
3396 client_->Reset(); 3416 client_->Reset();
3397 3417
3398 // Android onDraw. 3418 // Android onDraw.
3399 scheduler_->SetNeedsRedraw(); 3419 scheduler_->SetNeedsRedraw();
3400 bool resourceless_software_draw = false; 3420 bool resourceless_software_draw = false;
3401 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3421 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3402 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2); 3422 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2);
3403 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); 3423 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2);
3404 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3424 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3405 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 3425 EXPECT_FALSE(scheduler_->PrepareTilesPending());
3406 client_->Reset(); 3426 client_->Reset();
3407 3427
3408 // Android onDraw. 3428 // Android onDraw.
3409 scheduler_->SetNeedsRedraw(); 3429 scheduler_->SetNeedsRedraw();
3410 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3430 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3411 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2); 3431 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2);
3412 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); 3432 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2);
3413 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3433 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3414 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 3434 EXPECT_FALSE(scheduler_->PrepareTilesPending());
3415 client_->Reset(); 3435 client_->Reset();
3416 3436
3417 // Next vsync. 3437 // Next vsync.
3418 EXPECT_SCOPED(AdvanceFrame()); 3438 EXPECT_SCOPED(AdvanceFrame());
3419 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 3439 EXPECT_FALSE(scheduler_->PrepareTilesPending());
3420 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); 3440 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3);
3421 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 3441 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
3422 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 3442 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
3423 EXPECT_FALSE(scheduler_->begin_frames_expected()); 3443 EXPECT_FALSE(scheduler_->begin_frames_expected());
3424 client_->Reset(); 3444 client_->Reset();
3425 } 3445 }
3426 3446
3427 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) { 3447 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) {
3428 scheduler_settings_.using_synchronous_renderer_compositor = true; 3448 scheduler_settings_.using_synchronous_renderer_compositor = true;
3429 scheduler_settings_.use_external_begin_frame_source = true; 3449 scheduler_settings_.use_external_begin_frame_source = true;
3430 3450
3431 SetUpScheduler(true); 3451 SetUpScheduler(true);
3432 3452
3433 scheduler_->SetNeedsRedraw(); 3453 scheduler_->SetNeedsRedraw();
3434 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 3454 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
3435 client_->Reset(); 3455 client_->Reset();
3436 3456
3437 // Next vsync. 3457 // Next vsync.
3438 EXPECT_SCOPED(AdvanceFrame()); 3458 EXPECT_SCOPED(AdvanceFrame());
3439 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3459 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3440 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3460 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2);
3441 client_->Reset(); 3461 client_->Reset();
3442 3462
3443 // Android onDraw. 3463 // Android onDraw.
3444 scheduler_->SetNeedsRedraw(); 3464 scheduler_->SetNeedsRedraw();
3445 bool resourceless_software_draw = false; 3465 bool resourceless_software_draw = false;
3446 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3466 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3447 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 3467 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
3448 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3468 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3449 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 3469 EXPECT_FALSE(scheduler_->PrepareTilesPending());
3450 client_->Reset(); 3470 client_->Reset();
3451 3471
3452 // Simulate SetNeedsBeginMainFrame due to input event. 3472 // Simulate SetNeedsBeginMainFrame due to input event.
3453 scheduler_->SetNeedsBeginMainFrame(); 3473 scheduler_->SetNeedsBeginMainFrame();
3454 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); 3474 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_);
3455 client_->Reset(); 3475 client_->Reset();
3456 3476
3457 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 3477 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
3458 scheduler_->NotifyReadyToCommit(); 3478 scheduler_->NotifyReadyToCommit();
3459 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 3479 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
3460 client_->Reset(); 3480 client_->Reset();
3461 3481
3462 scheduler_->NotifyReadyToActivate(); 3482 scheduler_->NotifyReadyToActivate();
3463 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); 3483 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
3464 client_->Reset(); 3484 client_->Reset();
3465 3485
3466 // Next vsync. 3486 // Next vsync.
3467 EXPECT_SCOPED(AdvanceFrame()); 3487 EXPECT_SCOPED(AdvanceFrame());
3468 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3488 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3469 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 1, 2); 3489 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2);
3470 client_->Reset(); 3490 client_->Reset();
3471 3491
3472 // Android onDraw. 3492 // Android onDraw.
3473 scheduler_->SetNeedsRedraw(); 3493 scheduler_->SetNeedsRedraw();
3474 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3494 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3475 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); 3495 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
3476 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3496 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3477 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 3497 EXPECT_FALSE(scheduler_->PrepareTilesPending());
3478 client_->Reset(); 3498 client_->Reset();
3479 3499
3480 // Simulate SetNeedsBeginMainFrame due to input event. 3500 // Simulate SetNeedsBeginMainFrame due to input event.
3481 scheduler_->SetNeedsBeginMainFrame(); 3501 scheduler_->SetNeedsBeginMainFrame();
3482 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); 3502 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_);
3483 client_->Reset(); 3503 client_->Reset();
3484 } 3504 }
3485 3505
3486 TEST_F(SchedulerTest, SynchronousCompositorResourcelessOnDrawWhenInvisible) { 3506 TEST_F(SchedulerTest, SynchronousCompositorResourcelessOnDrawWhenInvisible) {
3487 scheduler_settings_.using_synchronous_renderer_compositor = true; 3507 scheduler_settings_.using_synchronous_renderer_compositor = true;
3488 scheduler_settings_.use_external_begin_frame_source = true; 3508 scheduler_settings_.use_external_begin_frame_source = true;
3489 SetUpScheduler(true); 3509 SetUpScheduler(true);
3490 3510
3491 scheduler_->SetVisible(false); 3511 scheduler_->SetVisible(false);
3492 3512
3493 scheduler_->SetNeedsRedraw(); 3513 scheduler_->SetNeedsRedraw();
3494 bool resourceless_software_draw = true; 3514 bool resourceless_software_draw = true;
3495 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 3515 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
3496 // SynchronousCompositor has to draw regardless of visibility. 3516 // SynchronousCompositor has to draw regardless of visibility.
3497 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 3517 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
3498 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3518 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3499 client_->Reset(); 3519 client_->Reset();
3500 } 3520 }
3501 3521
3502 TEST_F(SchedulerTest, AuthoritativeVSyncInterval) { 3522 TEST_F(SchedulerTest, AuthoritativeVSyncInterval) {
3503 SetUpScheduler(true); 3523 SetUpScheduler(true);
3504 base::TimeDelta initial_interval = scheduler_->BeginImplFrameInterval(); 3524 base::TimeDelta initial_interval = scheduler_->BeginImplFrameInterval();
3505 base::TimeDelta authoritative_interval = 3525 base::TimeDelta authoritative_interval =
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3556 3576
3557 scheduler_->SetTreePrioritiesAndScrollState( 3577 scheduler_->SetTreePrioritiesAndScrollState(
3558 SAME_PRIORITY_FOR_BOTH_TREES, 3578 SAME_PRIORITY_FOR_BOTH_TREES,
3559 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER); 3579 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER);
3560 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true); 3580 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(true);
3561 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); 3581 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority());
3562 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false); 3582 scheduler_->SetCriticalBeginMainFrameToActivateIsFast(false);
3563 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); 3583 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority());
3564 } 3584 }
3565 3585
3566 TEST_F(SchedulerTest, NoOutputSurfaceCreationWhileCommitPending) { 3586 TEST_F(SchedulerTest, NoCompositorFrameSinkCreationWhileCommitPending) {
3567 SetUpScheduler(true); 3587 SetUpScheduler(true);
3568 3588
3569 // SetNeedsBeginMainFrame should begin the frame. 3589 // SetNeedsBeginMainFrame should begin the frame.
3570 scheduler_->SetNeedsBeginMainFrame(); 3590 scheduler_->SetNeedsBeginMainFrame();
3571 client_->Reset(); 3591 client_->Reset();
3572 EXPECT_SCOPED(AdvanceFrame()); 3592 EXPECT_SCOPED(AdvanceFrame());
3573 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3593 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3574 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3594 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3575 3595
3576 // Lose the output surface and trigger the deadline. 3596 // Lose the CompositorFrameSink and trigger the deadline.
3577 client_->Reset(); 3597 client_->Reset();
3578 scheduler_->DidLoseOutputSurface(); 3598 scheduler_->DidLoseCompositorFrameSink();
3579 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 3599 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
3580 EXPECT_NO_ACTION(client_); 3600 EXPECT_NO_ACTION(client_);
3581 3601
3582 // The scheduler should not trigger the output surface creation till the 3602 // The scheduler should not trigger the CompositorFrameSink creation till the
3583 // commit is aborted. 3603 // commit is aborted.
3584 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); 3604 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
3585 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3605 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3586 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); 3606 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_);
3587 3607
3588 // Abort the commit. 3608 // Abort the commit.
3589 client_->Reset(); 3609 client_->Reset();
3590 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); 3610 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now());
3591 scheduler_->BeginMainFrameAborted( 3611 scheduler_->BeginMainFrameAborted(
3592 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); 3612 CommitEarlyOutReason::ABORTED_COMPOSITOR_FRAME_SINK_LOST);
3593 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 3613 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation",
3614 client_);
3594 } 3615 }
3595 3616
3596 TEST_F(SchedulerTest, OutputSurfaceCreationWhileCommitPending) { 3617 TEST_F(SchedulerTest, CompositorFrameSinkCreationWhileCommitPending) {
3597 scheduler_settings_.abort_commit_before_output_surface_creation = false; 3618 scheduler_settings_.abort_commit_before_compositor_frame_sink_creation =
3619 false;
3598 SetUpScheduler(true); 3620 SetUpScheduler(true);
3599 3621
3600 // SetNeedsBeginMainFrame should begin the frame. 3622 // SetNeedsBeginMainFrame should begin the frame.
3601 scheduler_->SetNeedsBeginMainFrame(); 3623 scheduler_->SetNeedsBeginMainFrame();
3602 client_->Reset(); 3624 client_->Reset();
3603 EXPECT_SCOPED(AdvanceFrame()); 3625 EXPECT_SCOPED(AdvanceFrame());
3604 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 3626 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
3605 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 3627 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
3606 3628
3607 // Lose the output surface and trigger the deadline. 3629 // Lose the CompositorFrameSink and trigger the deadline.
3608 client_->Reset(); 3630 client_->Reset();
3609 scheduler_->DidLoseOutputSurface(); 3631 scheduler_->DidLoseCompositorFrameSink();
3610 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 3632 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
3611 EXPECT_NO_ACTION(client_); 3633 EXPECT_NO_ACTION(client_);
3612 3634
3613 // The scheduler should trigger the output surface creation immediately after 3635 // The scheduler should trigger the CompositorFrameSink creation immediately
3636 // after
3614 // the begin_impl_frame_state_ is cleared. 3637 // the begin_impl_frame_state_ is cleared.
3615 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); 3638 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
3616 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); 3639 EXPECT_FALSE(client_->IsInsideBeginImplFrame());
3617 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 2); 3640 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
3641 2);
3618 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); 3642 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
3619 } 3643 }
3620 3644
3621 // The three letters appeneded to each version of this test mean the following:s 3645 // The three letters appeneded to each version of this test mean the following:s
3622 // tree_priority: B = both trees same priority; A = active tree priority; 3646 // tree_priority: B = both trees same priority; A = active tree priority;
3623 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll 3647 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll
3624 // handler; 3648 // handler;
3625 // durations: F = fast durations; S = slow durations 3649 // durations: F = fast durations; S = slow durations
3626 bool SchedulerTest::BeginMainFrameOnCriticalPath( 3650 bool SchedulerTest::BeginMainFrameOnCriticalPath(
3627 TreePriority tree_priority, 3651 TreePriority tree_priority,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3687 } 3711 }
3688 3712
3689 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { 3713 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) {
3690 EXPECT_FALSE(BeginMainFrameOnCriticalPath( 3714 EXPECT_FALSE(BeginMainFrameOnCriticalPath(
3691 SMOOTHNESS_TAKES_PRIORITY, 3715 SMOOTHNESS_TAKES_PRIORITY,
3692 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); 3716 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration));
3693 } 3717 }
3694 3718
3695 } // namespace 3719 } // namespace
3696 } // namespace cc 3720 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/surfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698