OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // Consume any previous deadline first, if no deadline is currently | 353 // Consume any previous deadline first, if no deadline is currently |
354 // pending, ImplFrameDeadlinePending will return false straight away and we | 354 // pending, ImplFrameDeadlinePending will return false straight away and we |
355 // will run no tasks. | 355 // will run no tasks. |
356 task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 356 task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
357 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 357 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
358 | 358 |
359 // Send the next BeginFrame message if using an external source, otherwise | 359 // Send the next BeginFrame message if using an external source, otherwise |
360 // it will be already in the task queue. | 360 // it will be already in the task queue. |
361 if (scheduler_->settings().use_external_begin_frame_source && | 361 if (scheduler_->settings().use_external_begin_frame_source && |
362 scheduler_->FrameProductionThrottled()) { | 362 scheduler_->FrameProductionThrottled()) { |
| 363 EXPECT_TRUE(client_->needs_begin_frames()); |
363 SendNextBeginFrame(); | 364 SendNextBeginFrame(); |
364 } | 365 } |
365 | 366 |
366 if (!scheduler_->settings().using_synchronous_renderer_compositor) { | 367 if (!scheduler_->settings().using_synchronous_renderer_compositor) { |
367 // Then run tasks until new deadline is scheduled. | 368 // Then run tasks until new deadline is scheduled. |
368 EXPECT_TRUE(task_runner_->RunTasksWhile( | 369 EXPECT_TRUE(task_runner_->RunTasksWhile( |
369 client_->ImplFrameDeadlinePending(false))); | 370 client_->ImplFrameDeadlinePending(false))); |
370 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 371 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
371 } | 372 } |
372 } | 373 } |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 client_->Reset(); | 2203 client_->Reset(); |
2203 EXPECT_SCOPED(AdvanceFrame()); | 2204 EXPECT_SCOPED(AdvanceFrame()); |
2204 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2205 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
2205 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2206 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
2206 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2207 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2207 | 2208 |
2208 client_->Reset(); | 2209 client_->Reset(); |
2209 scheduler_->NotifyBeginMainFrameStarted(); | 2210 scheduler_->NotifyBeginMainFrameStarted(); |
2210 scheduler_->NotifyReadyToCommit(); | 2211 scheduler_->NotifyReadyToCommit(); |
2211 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 2212 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 2213 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2212 | 2214 |
2213 client_->Reset(); | 2215 client_->Reset(); |
2214 scheduler_->SetVisible(false); | 2216 scheduler_->SetVisible(false); |
| 2217 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2218 |
2215 // Sync tree should be forced to activate. | 2219 // Sync tree should be forced to activate. |
2216 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); | 2220 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3); |
2217 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 2); | 2221 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 2222 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
2218 } | 2223 } |
2219 | 2224 |
2220 // Tests to ensure frame sources can be successfully changed while drawing. | 2225 // Tests to ensure frame sources can be successfully changed while drawing. |
2221 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { | 2226 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { |
2222 scheduler_settings_.use_external_begin_frame_source = true; | 2227 scheduler_settings_.use_external_begin_frame_source = true; |
2223 SetUpScheduler(true); | 2228 SetUpScheduler(true); |
2224 | 2229 |
2225 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | 2230 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. |
2226 scheduler_->SetNeedsRedraw(); | 2231 scheduler_->SetNeedsRedraw(); |
2227 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 2232 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 | 2523 |
2519 // At the next BeginFrame, authoritative interval is used instead of previous | 2524 // At the next BeginFrame, authoritative interval is used instead of previous |
2520 // interval. | 2525 // interval. |
2521 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); | 2526 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); |
2522 EXPECT_EQ(authoritative_interval, | 2527 EXPECT_EQ(authoritative_interval, |
2523 scheduler_->begin_impl_frame_args().interval); | 2528 scheduler_->begin_impl_frame_args().interval); |
2524 } | 2529 } |
2525 | 2530 |
2526 } // namespace | 2531 } // namespace |
2527 } // namespace cc | 2532 } // namespace cc |
OLD | NEW |