| 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 3024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3035 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 3035 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 3036 | 3036 |
| 3037 client_->Reset(); | 3037 client_->Reset(); |
| 3038 fake_external_begin_frame_source_->SetPaused(true); | 3038 fake_external_begin_frame_source_->SetPaused(true); |
| 3039 task_runner().RunPendingTasks(); // Run posted deadline. | 3039 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3040 | 3040 |
| 3041 // Sync tree should be forced to activate. | 3041 // Sync tree should be forced to activate. |
| 3042 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 3042 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
| 3043 } | 3043 } |
| 3044 | 3044 |
| 3045 // Tests to ensure frame sources can be successfully changed while drawing. | |
| 3046 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { | |
| 3047 scheduler_settings_.use_external_begin_frame_source = true; | |
| 3048 SetUpScheduler(true); | |
| 3049 | |
| 3050 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | |
| 3051 scheduler_->SetNeedsRedraw(); | |
| 3052 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | |
| 3053 client_->Reset(); | |
| 3054 | |
| 3055 EXPECT_SCOPED(AdvanceFrame()); | |
| 3056 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3057 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3058 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3059 client_->Reset(); | |
| 3060 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3061 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | |
| 3062 scheduler_->SetNeedsRedraw(); | |
| 3063 | |
| 3064 // Switch to an unthrottled frame source. | |
| 3065 scheduler_->SetThrottleFrameProduction(false); | |
| 3066 client_->Reset(); | |
| 3067 | |
| 3068 // Unthrottled frame source will immediately begin a new frame. | |
| 3069 task_runner().RunPendingTasks(); // Run posted BeginFrame. | |
| 3070 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3071 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3072 client_->Reset(); | |
| 3073 | |
| 3074 // If we don't swap on the deadline, we wait for the next BeginFrame. | |
| 3075 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3076 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | |
| 3077 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3078 client_->Reset(); | |
| 3079 } | |
| 3080 | |
| 3081 // Tests to ensure frame sources can be successfully changed while a frame | |
| 3082 // deadline is pending. | |
| 3083 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottledBeforeDeadline) { | |
| 3084 scheduler_settings_.use_external_begin_frame_source = true; | |
| 3085 SetUpScheduler(true); | |
| 3086 | |
| 3087 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | |
| 3088 scheduler_->SetNeedsRedraw(); | |
| 3089 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | |
| 3090 client_->Reset(); | |
| 3091 | |
| 3092 EXPECT_SCOPED(AdvanceFrame()); | |
| 3093 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | |
| 3094 | |
| 3095 // Switch to an unthrottled frame source before the frame deadline is hit. | |
| 3096 scheduler_->SetThrottleFrameProduction(false); | |
| 3097 client_->Reset(); | |
| 3098 | |
| 3099 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3100 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3101 client_->Reset(); | |
| 3102 | |
| 3103 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3104 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | |
| 3105 client_->Reset(); | |
| 3106 | |
| 3107 // Unthrottled frame source will immediately begin a new frame. | |
| 3108 task_runner().RunPendingTasks(); // Run BeginFrame. | |
| 3109 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | |
| 3110 scheduler_->SetNeedsRedraw(); | |
| 3111 client_->Reset(); | |
| 3112 | |
| 3113 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3114 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | |
| 3115 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3116 client_->Reset(); | |
| 3117 } | |
| 3118 | |
| 3119 // Tests to ensure that the active frame source can successfully be changed from | |
| 3120 // unthrottled to throttled. | |
| 3121 TEST_F(SchedulerTest, SwitchFrameSourceToThrottled) { | |
| 3122 scheduler_settings_.throttle_frame_production = false; | |
| 3123 scheduler_settings_.use_external_begin_frame_source = true; | |
| 3124 SetUpScheduler(true); | |
| 3125 | |
| 3126 scheduler_->SetNeedsRedraw(); | |
| 3127 EXPECT_NO_ACTION(client_); | |
| 3128 client_->Reset(); | |
| 3129 | |
| 3130 task_runner().RunPendingTasks(); // Run posted BeginFrame. | |
| 3131 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3132 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3133 client_->Reset(); | |
| 3134 | |
| 3135 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3136 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | |
| 3137 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3138 client_->Reset(); | |
| 3139 | |
| 3140 // Switch to a throttled frame source. | |
| 3141 scheduler_->SetThrottleFrameProduction(true); | |
| 3142 client_->Reset(); | |
| 3143 | |
| 3144 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | |
| 3145 scheduler_->SetNeedsRedraw(); | |
| 3146 task_runner().RunPendingTasks(); | |
| 3147 EXPECT_NO_ACTION(client_); | |
| 3148 client_->Reset(); | |
| 3149 | |
| 3150 EXPECT_SCOPED(AdvanceFrame()); | |
| 3151 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3152 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 3153 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3154 client_->Reset(); | |
| 3155 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3156 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); | |
| 3157 } | |
| 3158 | |
| 3159 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. | 3045 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. |
| 3160 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { | 3046 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { |
| 3161 scheduler_settings_.use_external_begin_frame_source = true; | 3047 scheduler_settings_.use_external_begin_frame_source = true; |
| 3162 SetUpScheduler(true); | 3048 SetUpScheduler(true); |
| 3163 | 3049 |
| 3164 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 3050 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 3165 scheduler_->SetNeedsBeginMainFrame(); | 3051 scheduler_->SetNeedsBeginMainFrame(); |
| 3166 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3052 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3167 client_->Reset(); | 3053 client_->Reset(); |
| 3168 | 3054 |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3675 } | 3561 } |
| 3676 | 3562 |
| 3677 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3563 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3678 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3564 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3679 SMOOTHNESS_TAKES_PRIORITY, | 3565 SMOOTHNESS_TAKES_PRIORITY, |
| 3680 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3566 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3681 } | 3567 } |
| 3682 | 3568 |
| 3683 } // namespace | 3569 } // namespace |
| 3684 } // namespace cc | 3570 } // namespace cc |
| OLD | NEW |