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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // Consume any previous deadline first, if no deadline is currently | 340 // Consume any previous deadline first, if no deadline is currently |
341 // pending, ImplFrameDeadlinePending will return false straight away and we | 341 // pending, ImplFrameDeadlinePending will return false straight away and we |
342 // will run no tasks. | 342 // will run no tasks. |
343 task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 343 task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
344 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 344 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
345 | 345 |
346 // Send the next BeginFrame message if using an external source, otherwise | 346 // Send the next BeginFrame message if using an external source, otherwise |
347 // it will be already in the task queue. | 347 // it will be already in the task queue. |
348 if (scheduler_->settings().use_external_begin_frame_source && | 348 if (scheduler_->settings().use_external_begin_frame_source && |
349 scheduler_->FrameProductionThrottled()) { | 349 scheduler_->FrameProductionThrottled()) { |
| 350 EXPECT_TRUE(client_->needs_begin_frames()); |
350 SendNextBeginFrame(); | 351 SendNextBeginFrame(); |
351 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 352 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
352 } | 353 } |
353 | 354 |
354 // Then run tasks until new deadline is scheduled. | 355 // Then run tasks until new deadline is scheduled. |
355 EXPECT_TRUE( | 356 EXPECT_TRUE( |
356 task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(false))); | 357 task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(false))); |
357 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 358 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
358 } | 359 } |
359 | 360 |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 client_->Reset(); | 2106 client_->Reset(); |
2106 EXPECT_SCOPED(AdvanceFrame()); | 2107 EXPECT_SCOPED(AdvanceFrame()); |
2107 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2108 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
2108 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2109 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
2109 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2110 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2110 | 2111 |
2111 client_->Reset(); | 2112 client_->Reset(); |
2112 scheduler_->NotifyBeginMainFrameStarted(); | 2113 scheduler_->NotifyBeginMainFrameStarted(); |
2113 scheduler_->NotifyReadyToCommit(); | 2114 scheduler_->NotifyReadyToCommit(); |
2114 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 2115 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 2116 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2115 | 2117 |
2116 client_->Reset(); | 2118 client_->Reset(); |
2117 scheduler_->SetVisible(false); | 2119 scheduler_->SetVisible(false); |
| 2120 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2121 |
2118 // Sync tree should be forced to activate. | 2122 // Sync tree should be forced to activate. |
2119 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); | 2123 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3); |
2120 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 2); | 2124 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 2125 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
2121 } | 2126 } |
2122 | 2127 |
2123 // Tests to ensure frame sources can be successfully changed while drawing. | 2128 // Tests to ensure frame sources can be successfully changed while drawing. |
2124 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { | 2129 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { |
2125 scheduler_settings_.use_external_begin_frame_source = true; | 2130 scheduler_settings_.use_external_begin_frame_source = true; |
2126 SetUpScheduler(true); | 2131 SetUpScheduler(true); |
2127 | 2132 |
2128 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | 2133 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. |
2129 scheduler_->SetNeedsRedraw(); | 2134 scheduler_->SetNeedsRedraw(); |
2130 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 2135 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2295 | 2300 |
2296 // At the next BeginFrame, authoritative interval is used instead of previous | 2301 // At the next BeginFrame, authoritative interval is used instead of previous |
2297 // interval. | 2302 // interval. |
2298 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); | 2303 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); |
2299 EXPECT_EQ(authoritative_interval, | 2304 EXPECT_EQ(authoritative_interval, |
2300 scheduler_->begin_impl_frame_args().interval); | 2305 scheduler_->begin_impl_frame_args().interval); |
2301 } | 2306 } |
2302 | 2307 |
2303 } // namespace | 2308 } // namespace |
2304 } // namespace cc | 2309 } // namespace cc |
OLD | NEW |