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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 3151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3162 | 3162 |
3163 EXPECT_SCOPED(AdvanceFrame()); | 3163 EXPECT_SCOPED(AdvanceFrame()); |
3164 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 3164 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
3165 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 3165 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
3166 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3166 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3167 client_->Reset(); | 3167 client_->Reset(); |
3168 task_runner().RunPendingTasks(); // Run posted deadline. | 3168 task_runner().RunPendingTasks(); // Run posted deadline. |
3169 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | 3169 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
3170 } | 3170 } |
3171 | 3171 |
| 3172 TEST_F(SchedulerTest, SwitchFrameSourceToNullInsideDeadline) { |
| 3173 scheduler_settings_.use_external_begin_frame_source = true; |
| 3174 SetUpScheduler(true); |
| 3175 |
| 3176 scheduler_->SetNeedsRedraw(); |
| 3177 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3178 client_->Reset(); |
| 3179 |
| 3180 EXPECT_SCOPED(AdvanceFrame()); |
| 3181 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 3182 client_->Reset(); |
| 3183 |
| 3184 // Switch to a null frame source. |
| 3185 scheduler_->SetBeginFrameSource(nullptr); |
| 3186 EXPECT_SINGLE_ACTION("RemoveObserver(this)", client_); |
| 3187 client_->Reset(); |
| 3188 |
| 3189 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 3190 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3191 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 3192 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 3193 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 3194 client_->Reset(); |
| 3195 |
| 3196 // AdvanceFrame helper can't be used here because there's no deadline posted. |
| 3197 scheduler_->SetNeedsRedraw(); |
| 3198 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 3199 EXPECT_NO_ACTION(client_); |
| 3200 client_->Reset(); |
| 3201 |
| 3202 scheduler_->SetNeedsBeginMainFrame(); |
| 3203 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 3204 EXPECT_NO_ACTION(client_); |
| 3205 client_->Reset(); |
| 3206 |
| 3207 // Switch back to the same source, make sure frames continue to be produced. |
| 3208 scheduler_->SetBeginFrameSource(fake_external_begin_frame_source_.get()); |
| 3209 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3210 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 3211 client_->Reset(); |
| 3212 |
| 3213 EXPECT_SCOPED(AdvanceFrame()); |
| 3214 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3215 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3216 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 3217 client_->Reset(); |
| 3218 |
| 3219 task_runner().RunPendingTasks(); |
| 3220 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); |
| 3221 } |
| 3222 |
3172 // This test maskes sure that switching a frame source when not observing | 3223 // This test maskes sure that switching a frame source when not observing |
3173 // such as when not visible also works. | 3224 // such as when not visible also works. |
3174 TEST_F(SchedulerTest, SwitchFrameSourceWhenNotObserving) { | 3225 TEST_F(SchedulerTest, SwitchFrameSourceWhenNotObserving) { |
3175 scheduler_settings_.use_external_begin_frame_source = true; | 3226 scheduler_settings_.use_external_begin_frame_source = true; |
3176 SetUpScheduler(true); | 3227 SetUpScheduler(true); |
3177 | 3228 |
3178 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 3229 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
3179 scheduler_->SetNeedsBeginMainFrame(); | 3230 scheduler_->SetNeedsBeginMainFrame(); |
3180 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3231 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
3181 client_->Reset(); | 3232 client_->Reset(); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3799 } | 3850 } |
3800 | 3851 |
3801 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3852 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
3802 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3853 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
3803 SMOOTHNESS_TAKES_PRIORITY, | 3854 SMOOTHNESS_TAKES_PRIORITY, |
3804 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3855 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
3805 } | 3856 } |
3806 | 3857 |
3807 } // namespace | 3858 } // namespace |
3808 } // namespace cc | 3859 } // namespace cc |
OLD | NEW |