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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 23451055: cc: Always use SetNeedsBeginFrame to request the next BeginFrame (Closed) Base URL: http://git.chromium.org/chromium/src.git@pollForDrawTriggers
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler_unittest.cc
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index 7074bbef4f7a41dbd027ac3cde8f23c6ba741d66..cb6e8db718f6609620dd856bd5c9551e013e7ff2 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -201,7 +201,7 @@ TEST(SchedulerTest, RequestCommit) {
scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
- EXPECT_FALSE(client.needs_begin_frame());
+ EXPECT_TRUE(client.needs_begin_frame());
client.Reset();
}
@@ -232,16 +232,27 @@ TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) {
client.Reset();
// Tick should draw but then begin another frame for the second commit.
+ // Because we just swapped, the Scheduler should also request the next
+ // BeginFrame from the OutputSurface.
scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_TRUE(client.needs_begin_frame());
- EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
- EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2);
+ EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3);
+ EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 3);
+ EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 2, 3);
client.Reset();
- // Finish the second commit to go back to quiescent state and verify we no
- // longer request BeginFrames.
+ // Finish the second commit.
scheduler->FinishCommit();
scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
+ EXPECT_ACTION("ScheduledActionCommit", client, 0, 3);
+ EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 3);
+ EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 2, 3);
+ EXPECT_TRUE(client.needs_begin_frame());
+ client.Reset();
+
+ // On the next BeginFrame, verify we go back to a quiescent state and
+ // no longer request BeginFrames.
+ scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_FALSE(client.needs_begin_frame());
}
@@ -266,6 +277,12 @@ TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) {
EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
EXPECT_FALSE(scheduler->RedrawPending());
+ EXPECT_TRUE(client.needs_begin_frame());
+
+ client.Reset();
+ scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
+ EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
+ EXPECT_FALSE(scheduler->RedrawPending());
EXPECT_FALSE(client.needs_begin_frame());
client.Reset();
@@ -305,8 +322,13 @@ TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) {
EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
EXPECT_FALSE(scheduler->RedrawPending());
- EXPECT_FALSE(client.needs_begin_frame());
+ EXPECT_TRUE(client.needs_begin_frame());
+
+ // Make sure we stop requesting BeginFrames if we don't swap.
client.Reset();
+ scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
+ EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
+ EXPECT_FALSE(client.needs_begin_frame());
}
TEST(SchedulerTest, TextureAcquisitionCollision) {
@@ -353,11 +375,15 @@ TEST(SchedulerTest, TextureAcquisitionCollision) {
1,
3);
EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 2, 3);
+ EXPECT_TRUE(client.needs_begin_frame());
client.Reset();
// Compositor not scheduled to draw because textures are locked by main
// thread.
+ scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
+ EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
EXPECT_FALSE(client.needs_begin_frame());
+ client.Reset();
// Needs an explicit commit from the main thread.
scheduler->SetNeedsCommit();
@@ -367,7 +393,16 @@ TEST(SchedulerTest, TextureAcquisitionCollision) {
// Trigger the commit
scheduler->FinishCommit();
+ EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
+ EXPECT_TRUE(client.needs_begin_frame());
+ client.Reset();
+
+ // Verify we draw on the next BeginFrame.
+ scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
+ EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
+ EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
EXPECT_TRUE(client.needs_begin_frame());
+ client.Reset();
}
TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
@@ -458,6 +493,12 @@ TEST(SchedulerTest, RequestRedrawInsideDraw) {
scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
EXPECT_EQ(2, client.num_draws());
EXPECT_FALSE(scheduler->RedrawPending());
+ EXPECT_TRUE(client.needs_begin_frame());
+
+ // We stop requesting BeginFrames after a BeginFrame where we don't swap.
+ scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
+ EXPECT_EQ(2, client.num_draws());
+ EXPECT_FALSE(scheduler->RedrawPending());
EXPECT_FALSE(client.needs_begin_frame());
}
@@ -567,6 +608,13 @@ TEST(SchedulerTest, RequestCommitInsideDraw) {
EXPECT_EQ(2, client.num_draws());;
EXPECT_FALSE(scheduler->RedrawPending());
EXPECT_FALSE(scheduler->CommitPending());
+ EXPECT_TRUE(client.needs_begin_frame());
+
+ // We stop requesting BeginFrames after a BeginFrame where we don't swap.
+ scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
+ EXPECT_EQ(2, client.num_draws());
+ EXPECT_FALSE(scheduler->RedrawPending());
+ EXPECT_FALSE(scheduler->CommitPending());
EXPECT_FALSE(client.needs_begin_frame());
}
« no previous file with comments | « cc/scheduler/scheduler_state_machine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698