Chromium Code Reviews| Index: cc/scheduler/scheduler_unittest.cc |
| diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc |
| index cb04c5e7d267db5d601e25e03eb8488cfe2b72b9..cbac41b6c547b31a3fbe296d14363e9c413f7ff1 100644 |
| --- a/cc/scheduler/scheduler_unittest.cc |
| +++ b/cc/scheduler/scheduler_unittest.cc |
| @@ -38,52 +38,34 @@ |
| namespace cc { |
| namespace { |
| -class FakeSchedulerClient; |
| - |
| -void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, |
| - FakeSchedulerClient* client); |
| - |
| -class TestScheduler : public Scheduler { |
| +class RunWhileImplFrameDeadlinePending |
| + : public OrderedSimpleTaskRunner::RunCheck { |
| public: |
| - static scoped_ptr<TestScheduler> Create( |
| - SchedulerClient* client, |
| - const SchedulerSettings& scheduler_settings, |
| - int layer_tree_host_id, |
| - const scoped_refptr<base::SingleThreadTaskRunner>& impl_task_runner) { |
| - return make_scoped_ptr(new TestScheduler( |
| - client, scheduler_settings, layer_tree_host_id, impl_task_runner)); |
| - } |
| + explicit RunWhileImplFrameDeadlinePending(Scheduler* scheduler, bool state) |
| + : scheduler_(scheduler), state_(state) {} |
| - virtual ~TestScheduler() {} |
| - |
| - bool IsBeginRetroFrameArgsEmpty() const { |
| - return begin_retro_frame_args_.empty(); |
| - } |
| - |
| - bool IsSyntheticBeginFrameSourceActive() const { |
| - return synthetic_begin_frame_source_->IsActive(); |
| + virtual bool Check() OVERRIDE { |
| + return scheduler_->BeginImplFrameDeadlinePending() != state_; |
| } |
| private: |
| - TestScheduler( |
| - SchedulerClient* client, |
| - const SchedulerSettings& scheduler_settings, |
| - int layer_tree_host_id, |
| - const scoped_refptr<base::SingleThreadTaskRunner> & impl_task_runner) |
| - : Scheduler(client, |
| - scheduler_settings, |
| - layer_tree_host_id, |
| - impl_task_runner) { |
| - } |
| + Scheduler* scheduler_; |
| + bool state_; |
| }; |
| +class FakeSchedulerClient; |
| + |
| +void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, |
| + FakeSchedulerClient* client); |
| + |
| class FakeSchedulerClient : public SchedulerClient { |
| public: |
| FakeSchedulerClient() |
| : needs_begin_frame_(false), |
| automatic_swap_ack_(true), |
| swap_contains_incomplete_tile_(false), |
| - redraw_will_happen_if_update_visible_tiles_happens_(false) { |
| + redraw_will_happen_if_update_visible_tiles_happens_(false), |
| + now_src_(TestNowSource::Create()) { |
| Reset(); |
| } |
| @@ -97,8 +79,9 @@ class FakeSchedulerClient : public SchedulerClient { |
| } |
| TestScheduler* CreateScheduler(const SchedulerSettings& settings) { |
| - task_runner_ = new OrderedSimpleTaskRunner; |
| - scheduler_ = TestScheduler::Create(this, settings, 0, task_runner_); |
| + scheduler_ = TestScheduler::Create(now_src_, this, settings, 0); |
| + // Fail if we need to run 100 tasks in a row. |
| + task_runner().SetTimeout(100); |
|
Sami
2014/08/29 13:13:51
Please call this something that makes it clear 100
mithro-old
2014/09/01 06:19:46
Done.
I went with "SetRunTaskLimit".
|
| return scheduler_.get(); |
| } |
| @@ -116,7 +99,26 @@ class FakeSchedulerClient : public SchedulerClient { |
| return posted_begin_impl_frame_deadline_; |
| } |
| - OrderedSimpleTaskRunner& task_runner() { return *task_runner_.get(); } |
| + void AdvanceFrame() { |
| + bool external_begin_frame = |
| + scheduler_->settings().begin_frame_scheduling_enabled && |
| + scheduler_->settings().throttle_frame_production; |
| + |
| + if (external_begin_frame) { |
| + TRACE_EVENT1("cc", |
| + "SchedulerUnitTest::AdvanceFrame", |
| + "external_begin_frame", |
| + external_begin_frame); |
|
Sami
2014/08/29 13:13:51
Having |external_begin_frame| here is redundant be
mithro-old
2014/09/01 06:19:46
Removed.
This trace only existed to make the inde
|
| + scheduler_->BeginFrame(CreateBeginFrameArgsForTesting(now_src_)); |
| + } |
| + |
| + EXPECT_TRUE(task_runner().RunTasksUntil( |
| + RunWhileImplFrameDeadlinePending(scheduler_.get(), true))); |
| + EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| + } |
| + |
| + OrderedSimpleTaskRunner& task_runner() { return scheduler_->task_runner(); } |
| + scoped_refptr<TestNowSource> now_src() { return now_src_; } |
|
Sami
2014/08/29 13:13:51
Could this be a raw pointer? Nobody needs to hang
mithro-old
2014/09/01 06:19:46
Done.
|
| int ActionIndex(const char* action) const { |
| for (size_t i = 0; i < actions_.size(); i++) |
| @@ -241,14 +243,13 @@ class FakeSchedulerClient : public SchedulerClient { |
| std::vector<const char*> actions_; |
| std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_; |
| scoped_ptr<TestScheduler> scheduler_; |
| - scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| + scoped_refptr<TestNowSource> now_src_; |
|
Sami
2014/08/29 13:13:51
scoped_ptr?
mithro-old
2014/09/01 06:19:46
now_src is currently ref-counted. The fact that th
Sami
2014/09/01 11:35:32
Right, I was just wondering if the the scheduler's
|
| }; |
| void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, |
| FakeSchedulerClient* client) { |
| - bool client_initiates_begin_frame = |
| - scheduler->settings().begin_frame_scheduling_enabled && |
| - scheduler->settings().throttle_frame_production; |
| + TRACE_EVENT0("cc", |
| + "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); |
| scheduler->DidCreateAndInitializeOutputSurface(); |
| scheduler->SetNeedsCommit(); |
| @@ -256,27 +257,24 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, |
| scheduler->NotifyReadyToCommit(); |
| if (scheduler->settings().impl_side_painting) |
| scheduler->NotifyReadyToActivate(); |
| + |
| // Go through the motions to draw the commit. |
| - if (client_initiates_begin_frame) |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| - else |
| - client->task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| + client->AdvanceFrame(); |
| // Run the posted deadline task. |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| - client->task_runner().RunPendingTasks(); |
| + client->task_runner().RunTasksUntil( |
|
Sami
2014/08/29 13:13:51
This reads a bit oddly -- "Run tasks until while i
mithro-old
2014/09/01 06:19:46
With the other changes this now reads as;
RunTask
|
| + RunWhileImplFrameDeadlinePending(scheduler, false)); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| // We need another BeginImplFrame so Scheduler calls |
| // SetNeedsBeginFrame(false). |
| - if (client_initiates_begin_frame) |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| - else |
| - client->task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| + client->AdvanceFrame(); |
| // Run the posted deadline task. |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| - client->task_runner().RunPendingTasks(); |
| + client->task_runner().RunTasksUntil( |
| + RunWhileImplFrameDeadlinePending(scheduler, false)); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| } |
| @@ -312,7 +310,7 @@ TEST(SchedulerTest, RequestCommit) { |
| EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -334,7 +332,7 @@ TEST(SchedulerTest, RequestCommit) { |
| client.Reset(); |
| // BeginImplFrame should prepare the draw. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -350,7 +348,7 @@ TEST(SchedulerTest, RequestCommit) { |
| // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| // to avoid excessive toggles. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| @@ -378,7 +376,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -408,7 +406,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| client.Reset(); |
| // Since another commit is needed, the next BeginImplFrame should initiate |
| // the second commit. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -430,7 +428,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginMainFrameSent) { |
| // On the next BeginImplFrame, verify we go back to a quiescent state and |
| // no longer request BeginImplFrames. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_FALSE(client.needs_begin_frame()); |
| client.Reset(); |
| @@ -476,13 +474,13 @@ TEST(SchedulerTest, RequestRedrawInsideDraw) { |
| EXPECT_TRUE(client.needs_begin_frame()); |
| EXPECT_EQ(0, client.num_draws()); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| EXPECT_TRUE(scheduler->RedrawPending()); |
| EXPECT_TRUE(client.needs_begin_frame()); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| @@ -490,7 +488,7 @@ TEST(SchedulerTest, RequestRedrawInsideDraw) { |
| // We stop requesting BeginImplFrames after a BeginImplFrame where we don't |
| // swap. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| @@ -516,7 +514,7 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { |
| EXPECT_EQ(0, client.num_draws()); |
| // Fail the draw. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| @@ -527,7 +525,7 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { |
| EXPECT_TRUE(client.needs_begin_frame()); |
| // Fail the draw again. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| @@ -536,7 +534,7 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { |
| // Draw successfully. |
| client.SetDrawWillHappen(true); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(3, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| @@ -594,7 +592,7 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { |
| EXPECT_TRUE(client.needs_begin_frame()); |
| client.SetNeedsCommitOnNextDraw(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.SetNeedsCommitOnNextDraw(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| @@ -603,7 +601,7 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { |
| scheduler->NotifyBeginMainFrameStarted(); |
| scheduler->NotifyReadyToCommit(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| @@ -613,7 +611,7 @@ TEST(SchedulerTest, RequestCommitInsideDraw) { |
| // We stop requesting BeginImplFrames after a BeginImplFrame where we don't |
| // swap. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| @@ -640,7 +638,7 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
| EXPECT_EQ(0, client.num_draws()); |
| // Fail the draw. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| @@ -651,7 +649,7 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
| EXPECT_TRUE(client.needs_begin_frame()); |
| // Fail the draw again. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| @@ -661,7 +659,7 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
| // Draw successfully. |
| client.SetDrawWillHappen(true); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(3, client.num_draws()); |
| EXPECT_TRUE(scheduler->CommitPending()); |
| @@ -686,7 +684,7 @@ TEST(SchedulerTest, NoSwapWhenDrawFails) { |
| // Draw successfully, this starts a new frame. |
| client.SetNeedsCommitOnNextDraw(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(1, client.num_draws()); |
| @@ -697,7 +695,7 @@ TEST(SchedulerTest, NoSwapWhenDrawFails) { |
| // Fail to draw, this should not start a frame. |
| client.SetDrawWillHappen(false); |
| client.SetNeedsCommitOnNextDraw(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(2, client.num_draws()); |
| } |
| @@ -736,7 +734,7 @@ TEST(SchedulerTest, ManageTiles) { |
| // We have no immediate actions to perform, so the BeginImplFrame should post |
| // the deadline task. |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -764,7 +762,7 @@ TEST(SchedulerTest, ManageTiles) { |
| // We have no immediate actions to perform, so the BeginImplFrame should post |
| // the deadline task. |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -785,7 +783,7 @@ TEST(SchedulerTest, ManageTiles) { |
| // We need a BeginImplFrame where we don't swap to go idle. |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| @@ -806,7 +804,7 @@ TEST(SchedulerTest, ManageTiles) { |
| // BeginImplFrame. There will be no draw, only ManageTiles. |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| @@ -832,7 +830,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -854,7 +852,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -877,7 +875,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -900,7 +898,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -919,7 +917,7 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) { |
| scheduler->SetNeedsManageTiles(); |
| scheduler->SetNeedsRedraw(); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -955,7 +953,7 @@ TEST(SchedulerTest, ShouldUpdateVisibleTiles) { |
| EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -977,7 +975,7 @@ TEST(SchedulerTest, ShouldUpdateVisibleTiles) { |
| EXPECT_FALSE(scheduler->RedrawPending()); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -988,7 +986,7 @@ TEST(SchedulerTest, ShouldUpdateVisibleTiles) { |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 2, 3); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1010,7 +1008,7 @@ TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) { |
| client.Reset(); |
| scheduler->SetNeedsRedraw(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| // The deadline should be zero since there is no work other than drawing |
| // pending. |
| @@ -1066,7 +1064,7 @@ void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms, |
| client.Reset(); |
| scheduler->SetNeedsCommit(); |
| EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); |
| @@ -1078,7 +1076,7 @@ void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms, |
| client.Reset(); |
| scheduler->SetNeedsCommit(); |
| EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(), |
| @@ -1135,9 +1133,15 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| scheduler->NotifyReadyToCommit(); |
| scheduler->SetNeedsRedraw(); |
| - BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(); |
| + BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(client.now_src()); |
| frame_args.interval = base::TimeDelta::FromMilliseconds(1000); |
| - scheduler->BeginFrame(frame_args); |
| + { |
| + TRACE_EVENT1("cc", |
| + "SchedulerTest::PollForCommitCompletion", |
| + "frame_args", |
| + frame_args.AsValue()); |
| + scheduler->BeginFrame(frame_args); |
| + } |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| @@ -1150,7 +1154,13 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| // the NotifyReadyToCommit for now. |
| EXPECT_FALSE(scheduler->CommitPending()); |
| scheduler->SetNeedsCommit(); |
| - scheduler->BeginFrame(frame_args); |
| + { |
| + TRACE_EVENT1("cc", |
| + "SchedulerTest::PollForCommitCompletion", |
| + "frame_args", |
| + frame_args.AsValue()); |
| + scheduler->BeginFrame(frame_args); |
| + } |
| EXPECT_TRUE(scheduler->CommitPending()); |
| // Draw and swap the frame, but don't ack the swap to simulate the Browser |
| @@ -1167,7 +1177,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((frame_args.interval * 2).InMicroseconds(), |
| - client.task_runner().NextPendingTaskDelay().InMicroseconds()) |
| + client.task_runner().DelayToNextPendingTask().InMicroseconds()) |
| << scheduler->AsValue()->ToString(); |
| client.task_runner().RunPendingTasks(); |
| EXPECT_GT(client.num_actions_(), actions_so_far); |
| @@ -1180,7 +1190,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { |
| scheduler->NotifyBeginMainFrameStarted(); |
| for (int i = 0; i < 3; ++i) { |
| EXPECT_EQ((frame_args.interval * 2).InMicroseconds(), |
| - client.task_runner().NextPendingTaskDelay().InMicroseconds()) |
| + client.task_runner().DelayToNextPendingTask().InMicroseconds()) |
| << scheduler->AsValue()->ToString(); |
| client.task_runner().RunPendingTasks(); |
| EXPECT_GT(client.num_actions_(), actions_so_far); |
| @@ -1208,9 +1218,13 @@ TEST(SchedulerTest, BeginRetroFrame) { |
| // Create a BeginFrame with a long deadline to avoid race conditions. |
| // This is the first BeginFrame, which will be handled immediately. |
| - BeginFrameArgs args = CreateBeginFrameArgsForTesting(); |
| + BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); |
| args.deadline += base::TimeDelta::FromHours(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", "SchedulerTest::BeginRetroFrame", "frame_args", args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1219,9 +1233,17 @@ TEST(SchedulerTest, BeginRetroFrame) { |
| // Queue BeginFrames while we are still handling the previous BeginFrame. |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", "SchedulerTest::BeginRetroFrame", "frame_args", args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", "SchedulerTest::BeginRetroFrame", "frame_args", args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| // If we don't swap on the deadline, we wait for the next BeginImplFrame. |
| client.task_runner().RunPendingTasks(); // Run posted deadline. |
| @@ -1287,9 +1309,15 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { |
| // Create a BeginFrame with a long deadline to avoid race conditions. |
| // This is the first BeginFrame, which will be handled immediately. |
| - BeginFrameArgs args = CreateBeginFrameArgsForTesting(); |
| + BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); |
| args.deadline += base::TimeDelta::FromHours(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1("cc", |
| + "SchedulerTest::BeginRetroFrame_SwapThrottled", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1299,7 +1327,13 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { |
| // Queue BeginFrame while we are still handling the previous BeginFrame. |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1("cc", |
| + "SchedulerTest::BeginRetroFrame_SwapThrottled", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| EXPECT_NO_ACTION(client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| client.Reset(); |
| @@ -1330,7 +1364,13 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { |
| // Queue BeginFrame while we are still handling the previous BeginFrame. |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1("cc", |
| + "SchedulerTest::BeginRetroFrame_SwapThrottled", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| EXPECT_NO_ACTION(client); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_TRUE(client.needs_begin_frame()); |
| @@ -1345,7 +1385,10 @@ TEST(SchedulerTest, BeginRetroFrame_SwapThrottled) { |
| // BeginImplFrame deadline should draw. |
| scheduler->SetNeedsRedraw(); |
| - client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + |
| + EXPECT_TRUE(client.task_runner().RunTasksUntil( |
| + RunWhileImplFrameDeadlinePending(scheduler, false))); |
| + |
| EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1406,7 +1449,8 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, |
| client.Reset(); |
| // BeginImplFrame deadline should draw. |
| - client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + client.task_runner().RunTasksUntil( |
| + RunWhileImplFrameDeadlinePending(scheduler, false)); |
| EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| EXPECT_FALSE(client.needs_begin_frame()); |
| @@ -1427,8 +1471,7 @@ void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, |
| client.Reset(); |
| } |
| -// See: http://crbug.com/380889 |
| -TEST(SchedulerTest, DISABLED_SyntheticBeginFrames) { |
| +TEST(SchedulerTest, SyntheticBeginFrames) { |
| bool begin_frame_scheduling_enabled = false; |
| bool throttle_frame_production = true; |
| BeginFramesNotFromClient(begin_frame_scheduling_enabled, |
| @@ -1442,8 +1485,7 @@ TEST(SchedulerTest, VSyncThrottlingDisabled) { |
| throttle_frame_production); |
| } |
| -// See: http://crbug.com/380889 |
| -TEST(SchedulerTest, DISABLED_SyntheticBeginFrames_And_VSyncThrottlingDisabled) { |
| +TEST(SchedulerTest, SyntheticBeginFrames_And_VSyncThrottlingDisabled) { |
| bool begin_frame_scheduling_enabled = false; |
| bool throttle_frame_production = false; |
| BeginFramesNotFromClient(begin_frame_scheduling_enabled, |
| @@ -1523,8 +1565,7 @@ void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled, |
| client.Reset(); |
| } |
| -// See: http://crbug.com/380889 |
| -TEST(SchedulerTest, DISABLED_SyntheticBeginFrames_SwapThrottled) { |
| +TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { |
| bool begin_frame_scheduling_enabled = false; |
| bool throttle_frame_production = true; |
| BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, |
| @@ -1538,9 +1579,8 @@ TEST(SchedulerTest, VSyncThrottlingDisabled_SwapThrottled) { |
| throttle_frame_production); |
| } |
| -// See: http://crbug.com/380889 |
| TEST(SchedulerTest, |
| - DISABLED_SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { |
| + SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { |
| bool begin_frame_scheduling_enabled = false; |
| bool throttle_frame_production = false; |
| BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, |
| @@ -1580,7 +1620,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterBeginFrameStarted) { |
| EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1619,7 +1659,7 @@ void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( |
| EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1630,13 +1670,17 @@ void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( |
| EXPECT_NO_ACTION(client); |
| client.Reset(); |
| - client.task_runner().RunPendingTasks(); // Run posted deadline. |
| + // Run posted deadline. |
| + EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| + client.task_runner().RunTasksUntil( |
| + RunWhileImplFrameDeadlinePending(scheduler, false)); |
| // OnBeginImplFrameDeadline didn't schedule any actions because main frame is |
| // not yet completed. |
| EXPECT_NO_ACTION(client); |
| // BeginImplFrame is not started. |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.task_runner().RunUntilTime(client.now_src()->Now() + |
| + base::TimeDelta::FromMilliseconds(10)); |
| EXPECT_NO_ACTION(client); |
| EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1682,7 +1726,7 @@ void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting) { |
| EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1731,7 +1775,7 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterSetNeedsManageTiles) { |
| EXPECT_TRUE(client.needs_begin_frame()); |
| client.Reset(); |
| - scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); |
| + client.AdvanceFrame(); |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1764,9 +1808,16 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { |
| // 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(); |
| + BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); |
| args.deadline += base::TimeDelta::FromHours(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", |
| + "SchedulerTest::DidLoseOutputSurfaceAfterBeginRetroFramePosted", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1774,9 +1825,23 @@ TEST(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { |
| // Queue BeginFrames while we are still handling the previous BeginFrame. |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", |
| + "SchedulerTest::DidLoseOutputSurfaceAfterBeginRetroFramePosted", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", |
| + "SchedulerTest::DidLoseOutputSurfaceAfterBeginRetroFramePosted", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| // If we don't swap on the deadline, we wait for the next BeginImplFrame. |
| client.Reset(); |
| @@ -1823,9 +1888,16 @@ TEST(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { |
| // 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(); |
| + BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); |
| args.deadline += base::TimeDelta::FromHours(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", |
| + "SchedulerTest::DidLoseOutputSurfaceDuringBeginRetroFrameRunning", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| @@ -1833,9 +1905,23 @@ TEST(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { |
| // Queue BeginFrames while we are still handling the previous BeginFrame. |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", |
| + "SchedulerTest::DidLoseOutputSurfaceDuringBeginRetroFrameRunning", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| args.frame_time += base::TimeDelta::FromSeconds(1); |
| - scheduler->BeginFrame(args); |
| + { |
| + TRACE_EVENT1( |
| + "cc", |
| + "SchedulerTest::DidLoseOutputSurfaceDuringBeginRetroFrameRunning", |
| + "frame_args", |
| + args.AsValue()); |
| + scheduler->BeginFrame(args); |
| + } |
| // If we don't swap on the deadline, we wait for the next BeginImplFrame. |
| client.Reset(); |
| @@ -1878,10 +1964,8 @@ TEST(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { |
| EXPECT_NO_ACTION(client); |
| } |
| -// See: http://crbug.com/380889 |
| -TEST( |
| - SchedulerTest, |
| - DISABLED_StopBeginFrameAfterDidLoseOutputSurfaceWithSyntheticBeginFrameSource) { |
| +TEST(SchedulerTest, |
| + StopBeginFrameAfterDidLoseOutputSurfaceWithSyntheticBeginFrameSource) { |
| FakeSchedulerClient client; |
| SchedulerSettings scheduler_settings; |
| scheduler_settings.begin_frame_scheduling_enabled = false; |