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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 987563002: cc: Simplify SetNeedsBeginFrames code in scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_retro_frame
Patch Set: Created 5 years, 10 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 46edf464e6b70fef8557591a7bea5e18c38ccb40..49d523dd46110d8417877599e1e3dbad7831fa4a 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -1590,9 +1590,8 @@ TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginFrameStarted) {
client_->Reset();
scheduler_->DidLoseOutputSurface();
- // Do nothing when impl frame is in deadine pending state.
- EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
+ // SetNeedsBeginFrames(false) is not called until the end of the frame.
+ EXPECT_NO_ACTION(client_);
client_->Reset();
scheduler_->NotifyBeginMainFrameStarted();
@@ -1600,8 +1599,10 @@ TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginFrameStarted) {
EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1);
client_->Reset();
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
+ task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true));
+ EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
+ EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3);
+ EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
}
void SchedulerTest::DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency(
@@ -1623,19 +1624,20 @@ void SchedulerTest::DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency(
client_->Reset();
scheduler_->DidLoseOutputSurface();
// Do nothing when impl frame is in deadine pending state.
- EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
+ EXPECT_NO_ACTION(client_);
client_->Reset();
// Run posted deadline.
EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true));
- // OnBeginImplFrameDeadline didn't schedule any actions because main frame is
- // not yet completed.
- EXPECT_NO_ACTION(client_);
+ // OnBeginImplFrameDeadline didn't schedule output surface creation because
+ // main frame is not yet completed.
+ EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2);
+ EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
// BeginImplFrame is not started.
+ client_->Reset();
task_runner().RunUntilTime(now_src()->Now() +
base::TimeDelta::FromMilliseconds(10));
EXPECT_NO_ACTION(client_);
@@ -1689,19 +1691,19 @@ void SchedulerTest::DidLoseOutputSurfaceAfterReadyToCommit(
client_->Reset();
scheduler_->DidLoseOutputSurface();
+ // SetNeedsBeginFrames(false) is not called until the end of the frame.
if (impl_side_painting) {
// Sync tree should be forced to activate.
- EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3);
- EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
+ EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_);
} else {
- EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
+ EXPECT_NO_ACTION(client_);
}
client_->Reset();
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
+ task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true));
+ EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
+ EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3);
+ EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
}
TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) {
@@ -1728,17 +1730,18 @@ TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterSetNeedsPrepareTiles) {
client_->Reset();
scheduler_->DidLoseOutputSurface();
- EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2);
- EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
+ // SetNeedsBeginFrames(false) is not called until the end of the frame.
+ EXPECT_NO_ACTION(client_);
client_->Reset();
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 2);
- EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 2);
+ task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true));
+ EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4);
+ EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 4);
+ EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 2, 4);
+ EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4);
}
-TEST_F(SchedulerTest,
- StopBeginFrameAfterDidLoseOutputSurfaceWithSyntheticBeginFrameSource) {
+TEST_F(SchedulerTest, DidLoseOutputSurfaceWithSyntheticBeginFrameSource) {
SetUpScheduler(true);
// SetNeedsCommit should begin the frame on the next BeginImplFrame.
@@ -1747,7 +1750,7 @@ TEST_F(SchedulerTest,
EXPECT_TRUE(scheduler_->frame_source().NeedsBeginFrames());
client_->Reset();
- task_runner().RunPendingTasks(); // Run posted Tick.
+ AdvanceFrame();
EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
@@ -1762,15 +1765,49 @@ TEST_F(SchedulerTest,
client_->Reset();
scheduler_->DidLoseOutputSurface();
- EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_);
- EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames());
+ // SetNeedsBeginFrames(false) is not called until the end of the frame.
+ EXPECT_NO_ACTION(client_);
+ EXPECT_TRUE(scheduler_->frame_source().NeedsBeginFrames());
client_->Reset();
- task_runner().RunPendingTasks(); // Run posted deadline.
- EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
+ task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true));
+ EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 2);
+ EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames());
}
+TEST_F(SchedulerTest, DidLoseOutputSurfaceWhenIdle) {
+ scheduler_settings_.use_external_begin_frame_source = true;
+ SetUpScheduler(true);
+
+ // SetNeedsCommit should begin the frame.
+ scheduler_->SetNeedsCommit();
+ EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
+
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
+ EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
+ EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
+
+ client_->Reset();
+ scheduler_->NotifyBeginMainFrameStarted();
+ scheduler_->NotifyReadyToCommit();
+ EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
+
+ client_->Reset();
+ task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true));
+ EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2);
+ EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2);
+
+ // Idle time between BeginFrames.
+ client_->Reset();
+ scheduler_->DidLoseOutputSurface();
+ EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
+ EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3);
+ EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
+}
+
TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) {
scheduler_settings_.impl_side_painting = true;
scheduler_settings_.use_external_begin_frame_source = true;
« cc/scheduler/scheduler_state_machine.cc ('K') | « cc/scheduler/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698