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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 2158023005: cc: Remove retro frame logic from scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler_unittest.cc
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index c16eb978eaffc19d156f94b8522662f902b60187..4bb232d958abce3ba0d53d6d5d964563dadd6456 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -2038,238 +2038,74 @@ TEST_F(
EXPECT_ACTION("ScheduledActionCommit", client_, 1, 2);
}
-TEST_F(SchedulerTest, BeginRetroFrame) {
+TEST_F(SchedulerTest, BeginFrameWhileInsidePreviousFrame) {
scheduler_settings_.use_external_begin_frame_source = true;
SetUpScheduler(true);
- // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
scheduler_->SetNeedsBeginMainFrame();
EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
+ EXPECT_TRUE(scheduler_->begin_frames_expected());
client_->Reset();
- // Create a BeginFrame with a long deadline to avoid race conditions.
- // This is the first BeginFrame, which will be handled immediately.
- BeginFrameArgs args =
- CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
- args.deadline += base::TimeDelta::FromHours(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
+ EXPECT_SCOPED(AdvanceFrame());
EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
client_->Reset();
- // Queue BeginFrames while we are still handling the previous BeginFrame.
- args.frame_time += base::TimeDelta::FromSeconds(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
- args.frame_time += base::TimeDelta::FromSeconds(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
-
- // If we don't swap on the deadline, we wait for the next BeginImplFrame.
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_NO_ACTION(client_);
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
- client_->Reset();
-
- // NotifyReadyToCommit should trigger the commit.
scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
scheduler_->NotifyReadyToCommit();
EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
- EXPECT_TRUE(scheduler_->begin_frames_expected());
client_->Reset();
- // NotifyReadyToActivate should trigger the activation.
scheduler_->NotifyReadyToActivate();
EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
- EXPECT_TRUE(scheduler_->begin_frames_expected());
- client_->Reset();
-
- // BeginImplFrame should prepare the draw.
- task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
client_->Reset();
- // BeginImplFrame deadline should draw.
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
- client_->Reset();
-
- // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
- // to avoid excessive toggles.
- task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
- EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
+ // Send next begin frame while inside previous frame.
+ SendNextBeginFrame();
+ EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2);
+ EXPECT_ACTION("WillBeginImplFrame", client_, 1, 2);
EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- client_->Reset();
-
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
- client_->Reset();
}
-TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) {
+TEST_F(SchedulerTest, BeginFrameWhileWaitForReadyToDraw) {
scheduler_settings_.use_external_begin_frame_source = true;
+ scheduler_settings_.commit_to_active_tree = true;
SetUpScheduler(true);
scheduler_->SetNeedsBeginMainFrame();
- EXPECT_TRUE(scheduler_->begin_frames_expected());
EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
-
+ EXPECT_TRUE(scheduler_->begin_frames_expected());
client_->Reset();
+
EXPECT_SCOPED(AdvanceFrame());
EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
EXPECT_TRUE(client_->IsInsideBeginImplFrame());
-
- client_->Reset();
- scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
-
client_->Reset();
- BeginFrameArgs retro_frame_args = SendNextBeginFrame();
- // This BeginFrame is queued up as a retro frame.
- EXPECT_NO_ACTION(client_);
- // The previous deadline is still pending.
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- client_->Reset();
- // This main frame activating should schedule the (previous) deadline to
- // trigger immediately.
+ scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
scheduler_->NotifyReadyToCommit();
- scheduler_->NotifyReadyToActivate();
- EXPECT_ACTION("ScheduledActionCommit", client_, 0, 2);
- EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 2);
-
- client_->Reset();
- // The deadline task should trigger causing a draw.
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
-
- // Keep animating.
+ EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
client_->Reset();
- scheduler_->SetNeedsOneBeginImplFrame();
- scheduler_->SetNeedsRedraw();
- EXPECT_NO_ACTION(client_);
-
- // Let's advance to the retro frame's deadline.
- now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks());
- // The retro frame hasn't expired yet.
- task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false));
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
-
- // This is an immediate deadline case.
+ scheduler_->NotifyReadyToActivate();
+ EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
client_->Reset();
- task_runner().RunPendingTasks();
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
- EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
-}
-
-TEST_F(SchedulerTest, RetroFrameExpiresOnTime) {
- scheduler_settings_.use_external_begin_frame_source = true;
- SetUpScheduler(true);
-
- scheduler_->SetNeedsBeginMainFrame();
- EXPECT_TRUE(scheduler_->begin_frames_expected());
- EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
- client_->Reset();
- EXPECT_SCOPED(AdvanceFrame());
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
- EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
+ // Send next begin frame while inside previous frame. No draw while we're
+ // waiting for ready to draw.
+ SendNextBeginFrame();
+ EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
EXPECT_TRUE(client_->IsInsideBeginImplFrame());
-
client_->Reset();
- scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
- client_->Reset();
- BeginFrameArgs retro_frame_args = SendNextBeginFrame();
- // This BeginFrame is queued up as a retro frame.
+ scheduler_->NotifyReadyToDraw();
EXPECT_NO_ACTION(client_);
- // The previous deadline is still pending.
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
-
- client_->Reset();
- // This main frame activating should schedule the (previous) deadline to
- // trigger immediately.
- scheduler_->NotifyReadyToCommit();
- scheduler_->NotifyReadyToActivate();
- EXPECT_ACTION("ScheduledActionCommit", client_, 0, 2);
- EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 2);
- client_->Reset();
- // The deadline task should trigger causing a draw.
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
-
- // Keep animating.
- client_->Reset();
- scheduler_->SetNeedsOneBeginImplFrame();
- scheduler_->SetNeedsRedraw();
- EXPECT_NO_ACTION(client_);
-
- // Let's advance sufficiently past the retro frame's deadline.
- now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks() +
- base::TimeDelta::FromMicroseconds(1));
-
- // The retro frame should've expired.
- EXPECT_NO_ACTION(client_);
-}
-
-TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) {
- scheduler_settings_.use_external_begin_frame_source = true;
- SetUpScheduler(true);
-
- scheduler_->SetNeedsBeginMainFrame();
- EXPECT_TRUE(scheduler_->begin_frames_expected());
- EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
-
- BeginFrameArgs missed_frame_args =
- CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
- missed_frame_args.type = BeginFrameArgs::MISSED;
-
- // Advance to the deadline.
- now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks());
-
- // Missed frame is handled because it's on time.
- client_->Reset();
- fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args);
- EXPECT_TRUE(
- task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false)));
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
- EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
-}
-
-TEST_F(SchedulerTest, MissedFrameExpiresOnTime) {
- scheduler_settings_.use_external_begin_frame_source = true;
- SetUpScheduler(true);
-
- scheduler_->SetNeedsBeginMainFrame();
- EXPECT_TRUE(scheduler_->begin_frames_expected());
- EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
-
- BeginFrameArgs missed_frame_args =
- CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
- missed_frame_args.type = BeginFrameArgs::MISSED;
-
- // Advance sufficiently past the deadline.
- now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks() +
- base::TimeDelta::FromMicroseconds(1));
-
- // Missed frame is dropped because it's too late.
- client_->Reset();
- fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args);
- EXPECT_FALSE(
- task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false)));
- EXPECT_NO_ACTION(client_);
+ EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_);
EXPECT_FALSE(client_->IsInsideBeginImplFrame());
}
@@ -2289,16 +2125,17 @@ void SchedulerTest::BeginFramesNotFromClient(
// When the client-driven BeginFrame are disabled, the scheduler posts it's
// own BeginFrame tasks.
- task_runner().RunPendingTasks(); // Run posted BeginFrame.
+ task_runner().RunTasksWhile(client_->InsideBeginImplFrame(false));
EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
EXPECT_TRUE(client_->IsInsideBeginImplFrame());
client_->Reset();
- // If we don't swap on the deadline, we wait for the next BeginFrame.
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_NO_ACTION(client_);
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
+ // BeginImplFrame should prepare the draw.
+ // Run deadline and posted begin frame.
+ task_runner().RunTasksWhile(scheduler_->InCurrentFrame());
+ EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
+ EXPECT_TRUE(client_->IsInsideBeginImplFrame());
client_->Reset();
// NotifyReadyToCommit should trigger the commit.
@@ -2312,22 +2149,11 @@ void SchedulerTest::BeginFramesNotFromClient(
EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
client_->Reset();
- // BeginImplFrame should prepare the draw.
- task_runner().RunPendingTasks(); // Run posted BeginFrame.
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- client_->Reset();
-
- // BeginImplFrame deadline should draw.
- task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
- client_->Reset();
-
- // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
- // to avoid excessive toggles.
- task_runner().RunPendingTasks(); // Run posted BeginFrame.
- EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
+ // Deadline should draw and next begin frame should stop the source.
+ // Run deadline and posted begin frame.
+ task_runner().RunTasksWhile(scheduler_->InCurrentFrame());
+ EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 2);
+ EXPECT_ACTION("WillBeginImplFrame", client_, 1, 2);
EXPECT_TRUE(client_->IsInsideBeginImplFrame());
client_->Reset();
@@ -2627,140 +2453,6 @@ TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterSetNeedsPrepareTiles) {
EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4);
}
-TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) {
- scheduler_settings_.use_external_begin_frame_source = true;
- SetUpScheduler(true);
-
- // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
- scheduler_->SetNeedsBeginMainFrame();
- EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
-
- // Create a BeginFrame with a long deadline to avoid race conditions.
- // This is the first BeginFrame, which will be handled immediately.
- client_->Reset();
- BeginFrameArgs args =
- CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
- args.deadline += base::TimeDelta::FromHours(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
- EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- // Queue BeginFrames while we are still handling the previous BeginFrame.
- args.frame_time += base::TimeDelta::FromSeconds(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
- args.frame_time += base::TimeDelta::FromSeconds(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
-
- // If we don't swap on the deadline, we wait for the next BeginImplFrame.
- client_->Reset();
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_NO_ACTION(client_);
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- // NotifyReadyToCommit should trigger the commit.
- client_->Reset();
- scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
- scheduler_->NotifyReadyToCommit();
- EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- // NotifyReadyToActivate should trigger the activation.
- client_->Reset();
- scheduler_->NotifyReadyToActivate();
- EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- client_->Reset();
- EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty());
- scheduler_->DidLoseOutputSurface();
- EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
- EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
- EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty());
-
- // Posted BeginRetroFrame is aborted.
- client_->Reset();
- task_runner().RunPendingTasks();
- EXPECT_NO_ACTION(client_);
-}
-
-TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) {
- scheduler_settings_.use_external_begin_frame_source = true;
- SetUpScheduler(true);
-
- // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame.
- scheduler_->SetNeedsBeginMainFrame();
- EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
-
- // Create a BeginFrame with a long deadline to avoid race conditions.
- // This is the first BeginFrame, which will be handled immediately.
- client_->Reset();
- BeginFrameArgs args =
- CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
- args.deadline += base::TimeDelta::FromHours(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
- EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- // Queue BeginFrames while we are still handling the previous BeginFrame.
- args.frame_time += base::TimeDelta::FromSeconds(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
- args.frame_time += base::TimeDelta::FromSeconds(1);
- fake_external_begin_frame_source()->TestOnBeginFrame(args);
-
- // If we don't swap on the deadline, we wait for the next BeginImplFrame.
- client_->Reset();
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_NO_ACTION(client_);
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- // NotifyReadyToCommit should trigger the commit.
- client_->Reset();
- scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
- scheduler_->NotifyReadyToCommit();
- EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- // NotifyReadyToActivate should trigger the activation.
- client_->Reset();
- scheduler_->NotifyReadyToActivate();
- EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- // BeginImplFrame should prepare the draw.
- client_->Reset();
- task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
- EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1);
- EXPECT_TRUE(client_->IsInsideBeginImplFrame());
- EXPECT_TRUE(scheduler_->begin_frames_expected());
-
- client_->Reset();
- EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty());
- scheduler_->DidLoseOutputSurface();
- EXPECT_NO_ACTION(client_);
- EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty());
-
- // BeginImplFrame deadline should abort drawing.
- client_->Reset();
- task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
- EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
- EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
- EXPECT_FALSE(client_->IsInsideBeginImplFrame());
- EXPECT_FALSE(scheduler_->begin_frames_expected());
-
- // No more BeginRetroFrame because BeginRetroFrame queue is cleared.
- client_->Reset();
- task_runner().RunPendingTasks();
- EXPECT_NO_ACTION(client_);
-}
-
TEST_F(SchedulerTest, DidLoseOutputSurfaceWithDelayBasedBeginFrameSource) {
SetUpScheduler(true);

Powered by Google App Engine
This is Rietveld 408576698