Chromium Code Reviews| Index: cc/scheduler/scheduler_unittest.cc |
| diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc |
| index 67a064b59d6e93cfefa37f02dc34dfb25edcc217..a8b5b3092306d6452b8ccb805f19ab4fab6dcc9f 100644 |
| --- a/cc/scheduler/scheduler_unittest.cc |
| +++ b/cc/scheduler/scheduler_unittest.cc |
| @@ -94,11 +94,15 @@ class FakeSchedulerClient : public SchedulerClient { |
| } |
| // SchedulerClient implementation. |
| - virtual void SetNeedsBeginImplFrame(bool enable) OVERRIDE { |
| - actions_.push_back("SetNeedsBeginImplFrame"); |
| + virtual void SetNeedsBeginFrame(bool enable) OVERRIDE { |
| + actions_.push_back("SetNeedsBeginFrame"); |
| states_.push_back(scheduler_->StateAsValue().release()); |
| needs_begin_impl_frame_ = enable; |
| } |
| + virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE { |
| + actions_.push_back("WillBeginImplFrame"); |
| + states_.push_back(scheduler_->StateAsValue().release()); |
| + } |
| virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { |
| actions_.push_back("ScheduledActionSendBeginMainFrame"); |
| states_.push_back(scheduler_->StateAsValue().release()); |
| @@ -194,7 +198,7 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, |
| scheduler->NotifyBeginMainFrameStarted(); |
| scheduler->NotifyReadyToCommit(); |
| // Go through the motions to draw the commit. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| // Run the posted deadline task. |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -202,8 +206,8 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| // We need another BeginImplFrame so Scheduler calls |
| - // SetNeedsBeginImplFrame(false). |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| + // SetNeedsBeginFrame(false). |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| // Run the posted deadline task. |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -240,19 +244,20 @@ TEST(SchedulerTest, RequestCommit) { |
| client.Reset(); |
| scheduler->SetNeedsCommit(); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| // If we don't swap on the deadline, we need to request another |
| // BeginImplFrame. |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| @@ -265,29 +270,29 @@ TEST(SchedulerTest, RequestCommit) { |
| client.Reset(); |
| // BeginImplFrame should prepare the draw. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| // BeginImplFrame deadline should draw. |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| - EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| - // The following BeginImplFrame deadline should SetNeedsBeginImplFrame(false) |
| + // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| // to avoid excessive toggles. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_FALSE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| } |
| @@ -306,11 +311,12 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| // SetNeedsCommit should begin the frame. |
| scheduler->SetNeedsCommit(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| @@ -327,20 +333,20 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| - EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| // Because we just swapped, the Scheduler should also request the next |
| // BeginImplFrame from the OutputSurface. |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| - |
| // Since another commit is needed, the next BeginImplFrame should initiate |
| // the second commit. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| @@ -351,17 +357,17 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| - EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| // On the next BeginImplFrame, verify we go back to a quiescent state and |
| // no longer request BeginImplFrames. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_FALSE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| } |
| @@ -379,28 +385,28 @@ TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) { |
| client.Reset(); |
| scheduler->SetNeedsRedraw(); |
| EXPECT_TRUE(scheduler->RedrawPending()); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| - EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| EXPECT_FALSE(client.needs_begin_impl_frame()); |
| @@ -414,17 +420,17 @@ TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) { |
| client.Reset(); |
| scheduler->SetNeedsRedraw(); |
| EXPECT_TRUE(scheduler->RedrawPending()); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| // No draw happens since the textures are acquired by the main thread. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(scheduler->RedrawPending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| @@ -434,8 +440,9 @@ TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) { |
| EXPECT_EQ(0, client.num_actions_()); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| // Commit will release the texture. |
| @@ -448,21 +455,21 @@ TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) { |
| // Now we can draw again after the commit happens. |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| - EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| // Make sure we stop requesting BeginImplFrames if we don't swap. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_FALSE(client.needs_begin_impl_frame()); |
| } |
| @@ -479,7 +486,7 @@ TEST(SchedulerTest, TextureAcquisitionCollision) { |
| client.Reset(); |
| scheduler->SetNeedsCommit(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| scheduler->SetMainThreadNeedsLayerTextures(); |
| @@ -487,16 +494,17 @@ TEST(SchedulerTest, TextureAcquisitionCollision) { |
| "ScheduledActionAcquireLayerTexturesForMainThread", client); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| // Although the compositor cannot draw because textures are locked by main |
| - // thread, we continue requesting SetNeedsBeginImplFrame in anticipation of |
| + // thread, we continue requesting SetNeedsBeginFrame in anticipation of |
| // the unlock. |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| @@ -513,28 +521,28 @@ TEST(SchedulerTest, TextureAcquisitionCollision) { |
| // No implicit commit is expected. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); |
| EXPECT_ACTION( |
| "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 3); |
| - EXPECT_ACTION("SetNeedsBeginImplFrame", client, 2, 3); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 2, 3); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| // The compositor should not draw because textures are locked by main |
| // thread. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_FALSE(client.needs_begin_impl_frame()); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -542,12 +550,13 @@ TEST(SchedulerTest, TextureAcquisitionCollision) { |
| // the textures. |
| client.Reset(); |
| scheduler->SetNeedsCommit(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| @@ -560,9 +569,9 @@ TEST(SchedulerTest, TextureAcquisitionCollision) { |
| client.Reset(); |
| // Verify we draw on the next BeginImplFrame deadline |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| - EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| @@ -581,8 +590,8 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { |
| scheduler->DidCreateAndInitializeOutputSurface(); |
| scheduler->SetNeedsCommit(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| scheduler->NotifyBeginMainFrameStarted(); |
| scheduler->NotifyReadyToCommit(); |
| scheduler->SetMainThreadNeedsLayerTextures(); |
| @@ -603,8 +612,9 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { |
| // compositor is waiting for first draw should result in a request |
| // for a new frame in order to escape a deadlock. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| } |
| @@ -651,22 +661,22 @@ TEST(SchedulerTest, RequestRedrawInsideDraw) { |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| EXPECT_EQ(0, client.num_draws()); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(scheduler->RedrawPending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| // We stop requesting BeginImplFrames after a BeginImplFrame where we don't |
| // swap. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| EXPECT_FALSE(client.needs_begin_impl_frame()); |
| @@ -691,8 +701,8 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { |
| EXPECT_EQ(0, client.num_draws()); |
| // Fail the draw. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| // We have a commit pending and the draw failed, and we didn't lose the redraw |
| @@ -702,8 +712,8 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| // Fail the draw again. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| EXPECT_TRUE(scheduler->RedrawPending()); |
| @@ -711,8 +721,8 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { |
| // Draw successfully. |
| client.SetDrawWillHappen(true); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(3, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| @@ -772,17 +782,17 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| client.SetNeedsCommitOnNextDraw(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| client.SetNeedsCommitOnNextDraw(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| scheduler->NotifyBeginMainFrameStarted(); |
| scheduler->NotifyReadyToCommit(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| @@ -791,8 +801,8 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { |
| // We stop requesting BeginImplFrames after a BeginImplFrame where we don't |
| // swap. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| EXPECT_FALSE(scheduler->CommitPending()); |
| @@ -818,8 +828,8 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
| EXPECT_EQ(0, client.num_draws()); |
| // Fail the draw. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| // We have a commit pending and the draw failed, and we didn't lose the commit |
| @@ -829,8 +839,9 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
| EXPECT_TRUE(client.needs_begin_impl_frame()); |
| // Fail the draw again. |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| EXPECT_TRUE(scheduler->RedrawPending()); |
| @@ -838,8 +849,8 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
| // Draw successfully. |
| client.SetDrawWillHappen(true); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(3, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| @@ -863,8 +874,8 @@ TEST(SchedulerTest, NoSwapWhenDrawFails) { |
| // Draw successfully, this starts a new frame. |
| client.SetNeedsCommitOnNextDraw(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| scheduler->SetNeedsRedraw(); |
| @@ -874,8 +885,8 @@ TEST(SchedulerTest, NoSwapWhenDrawFails) { |
| // Fail to draw, this should not start a frame. |
| client.SetDrawWillHappen(false); |
| client.SetNeedsCommitOnNextDraw(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| } |
| @@ -960,13 +971,13 @@ TEST(SchedulerTest, ManageTiles) { |
| // We have no immediate actions to perform, so the BeginImplFrame should post |
| // the deadline task. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| // On the deadline, he actions should have occured in the right order. |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -987,15 +998,15 @@ TEST(SchedulerTest, ManageTiles) { |
| // We have no immediate actions to perform, so the BeginImplFrame should post |
| // the deadline task. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| // Draw. The draw will trigger SetNeedsManageTiles, and |
| // then the ManageTiles action will be triggered after the Draw. |
| // Afterwards, neither a draw nor ManageTiles are pending. |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -1007,12 +1018,12 @@ TEST(SchedulerTest, ManageTiles) { |
| // We need a BeginImplFrame where we don't swap to go idle. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| - EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_EQ(0, client.num_draws()); |
| @@ -1027,11 +1038,11 @@ TEST(SchedulerTest, ManageTiles) { |
| // BeginImplFrame. There will be no draw, only ManageTiles. |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(0, client.num_draws()); |
| EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -1053,8 +1064,8 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(scheduler->ManageTilesPending()); |
| @@ -1062,7 +1073,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| EXPECT_FALSE(scheduler->ManageTilesPending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -1074,12 +1085,12 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -1096,14 +1107,14 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(scheduler->ManageTilesPending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -1118,14 +1129,14 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(scheduler->ManageTilesPending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -1136,12 +1147,12 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| - EXPECT_EQ(client.num_actions_(), 0); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
| @@ -1163,9 +1174,8 @@ TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) { |
| InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
| client.Reset(); |
| - BeginFrameArgs impl_frame_args = BeginFrameArgs::CreateForTesting(); |
| scheduler->SetNeedsRedraw(); |
| - scheduler->BeginImplFrame(impl_frame_args); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| // The deadline should be zero since there is no work other than drawing |
| // pending. |
| @@ -1221,9 +1231,9 @@ void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms, |
| client.Reset(); |
| scheduler->SetNeedsCommit(); |
| EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); |
| scheduler->NotifyBeginMainFrameStarted(); |
| scheduler->NotifyReadyToCommit(); |
| @@ -1233,9 +1243,9 @@ void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms, |
| client.Reset(); |
| scheduler->SetNeedsCommit(); |
| EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); |
| - scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); |
| + scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); |
| - scheduler->OnBeginImplFrameDeadline(); |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(), |
| should_send_begin_main_frame); |
| EXPECT_EQ(client.HasAction("ScheduledActionSendBeginMainFrame"), |
| @@ -1290,9 +1300,9 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| scheduler->NotifyReadyToCommit(); |
| scheduler->SetNeedsRedraw(); |
| - BeginFrameArgs impl_frame_args = BeginFrameArgs::CreateForTesting(); |
| - impl_frame_args.interval = base::TimeDelta::FromMilliseconds(1000); |
| - scheduler->BeginImplFrame(impl_frame_args); |
| + BeginFrameArgs frame_args = BeginFrameArgs::CreateForTesting(); |
| + frame_args.interval = base::TimeDelta::FromMilliseconds(1000); |
| + scheduler->BeginFrame(frame_args); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| @@ -1302,7 +1312,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| // the NotifyReadyToCommit for now. |
| EXPECT_FALSE(scheduler->CommitPending()); |
| scheduler->SetNeedsCommit(); |
| - scheduler->BeginImplFrame(impl_frame_args); |
| + scheduler->BeginFrame(frame_args); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| // Spin the event loop a few times and make sure we get more |
| @@ -1311,7 +1321,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| // Does three iterations to make sure that the timer is properly repeating. |
| for (int i = 0; i < 3; ++i) { |
| - EXPECT_EQ((impl_frame_args.interval * 2).InMicroseconds(), |
| + EXPECT_EQ((frame_args.interval * 2).InMicroseconds(), |
| client.task_runner().NextPendingTaskDelay().InMicroseconds()) |
| << *scheduler->StateAsValue(); |
| client.task_runner().RunPendingTasks(); |
| @@ -1324,7 +1334,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| // Do the same thing after BeginMainFrame starts but still before activation. |
| scheduler->NotifyBeginMainFrameStarted(); |
| for (int i = 0; i < 3; ++i) { |
| - EXPECT_EQ((impl_frame_args.interval * 2).InMicroseconds(), |
| + EXPECT_EQ((frame_args.interval * 2).InMicroseconds(), |
| client.task_runner().NextPendingTaskDelay().InMicroseconds()) |
| << *scheduler->StateAsValue(); |
| client.task_runner().RunPendingTasks(); |
| @@ -1335,5 +1345,82 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| } |
| } |
| +TEST(SchedulerTest, BeginRetroFrame) { |
| + FakeSchedulerClient client; |
| + SchedulerSettings scheduler_settings; |
| + Scheduler* scheduler = client.CreateScheduler(scheduler_settings); |
| + scheduler->SetCanStart(); |
| + scheduler->SetVisible(true); |
| + scheduler->SetCanDraw(true); |
| + InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
| + |
| + // SetNeedsCommit should begin the frame on the next BeginImplFrame. |
| + client.Reset(); |
| + scheduler->SetNeedsCommit(); |
| + EXPECT_TRUE(client.needs_begin_impl_frame()); |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| + 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 = BeginFrameArgs::CreateForTesting(); |
| + args.deadline += base::TimeDelta::FromHours(1); |
|
Sami
2014/04/08 11:25:25
I wish all our deadlines were this long :)
|
| + scheduler->BeginFrame(args); |
| + |
| + EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| + EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| + EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| + EXPECT_TRUE(client.needs_begin_impl_frame()); |
| + client.Reset(); |
| + |
| + // Queue BeginFrames while we are still handling the previous BeginFrame. |
| + args.frame_time += base::TimeDelta::FromSeconds(1); |
| + scheduler->BeginFrame(args); |
| + args.frame_time += base::TimeDelta::FromSeconds(1); |
| + scheduler->BeginFrame(args); |
| + |
| + // If we don't swap on the deadline, we need to request another |
| + // BeginImplFrame. |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| + EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| + EXPECT_TRUE(client.needs_begin_impl_frame()); |
| + client.Reset(); |
| + |
| + // NotifyReadyToCommit should trigger the commit. |
| + scheduler->NotifyBeginMainFrameStarted(); |
| + scheduler->NotifyReadyToCommit(); |
| + EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| + EXPECT_TRUE(client.needs_begin_impl_frame()); |
| + client.Reset(); |
| + |
| + // BeginImplFrame should prepare the draw. |
| + client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| + EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| + EXPECT_TRUE(client.needs_begin_impl_frame()); |
| + client.Reset(); |
| + |
| + // BeginImplFrame deadline should draw. |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| + EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); |
| + EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| + EXPECT_TRUE(client.needs_begin_impl_frame()); |
| + client.Reset(); |
| + |
| + // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| + // to avoid excessive toggles. |
| + client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| + EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| + EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| + client.Reset(); |
| + |
| + client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| + EXPECT_FALSE(client.needs_begin_impl_frame()); |
| + client.Reset(); |
| +} |
| + |
| } // namespace |
| } // namespace cc |