OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "components/scheduler/renderer/renderer_scheduler_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2158 scheduler_->ResumeTimerQueue(); | 2158 scheduler_->ResumeTimerQueue(); |
2159 RunUntilIdle(); | 2159 RunUntilIdle(); |
2160 EXPECT_TRUE(run_order.empty()); | 2160 EXPECT_TRUE(run_order.empty()); |
2161 | 2161 |
2162 scheduler_->ResumeTimerQueue(); | 2162 scheduler_->ResumeTimerQueue(); |
2163 RunUntilIdle(); | 2163 RunUntilIdle(); |
2164 EXPECT_THAT(run_order, | 2164 EXPECT_THAT(run_order, |
2165 testing::ElementsAre(std::string("T1"), std::string("T2"))); | 2165 testing::ElementsAre(std::string("T1"), std::string("T2"))); |
2166 } | 2166 } |
2167 | 2167 |
2168 TEST_F(RendererSchedulerImplTest, SuspendRendererWhenBackgrounded) { | 2168 TEST_F(RendererSchedulerImplTest, SuspendRenderer) { |
2169 // Assume that the renderer is backgrounded. | 2169 // Assume that the renderer is backgrounded. |
2170 scheduler_->OnRendererBackgrounded(); | 2170 scheduler_->OnRendererBackgrounded(); |
2171 | 2171 |
2172 // Tasks don't fire when the renderer is suspended. | 2172 // Tasks in some queues don't fire when the renderer is suspended. |
2173 std::vector<std::string> run_order; | 2173 std::vector<std::string> run_order; |
2174 PostTestTasks(&run_order, "T1 T2"); | 2174 PostTestTasks(&run_order, "D1 C1 L1 I1 T1"); |
2175 scheduler_->SuspendRenderer(); | 2175 scheduler_->SuspendRenderer(); |
| 2176 EnableIdleTasks(); |
2176 RunUntilIdle(); | 2177 RunUntilIdle(); |
2177 EXPECT_TRUE(run_order.empty()); | 2178 EXPECT_THAT(run_order, |
| 2179 testing::ElementsAre(std::string("D1"), std::string("C1"), |
| 2180 std::string("I1"))); |
2178 | 2181 |
2179 // The queued tasks fire when the tab goes foregrounded. | 2182 // The rest queued tasks fire when the tab goes foregrounded. |
| 2183 run_order.clear(); |
2180 scheduler_->OnRendererForegrounded(); | 2184 scheduler_->OnRendererForegrounded(); |
2181 RunUntilIdle(); | 2185 RunUntilIdle(); |
2182 EXPECT_THAT(run_order, | 2186 EXPECT_THAT(run_order, |
2183 testing::ElementsAre(std::string("T1"), std::string("T2"))); | 2187 testing::ElementsAre(std::string("L1"), std::string("T1"))); |
2184 } | 2188 } |
2185 | 2189 |
2186 TEST_F(RendererSchedulerImplTest, UseCaseToString) { | 2190 TEST_F(RendererSchedulerImplTest, UseCaseToString) { |
2187 CheckAllUseCaseToString(); | 2191 CheckAllUseCaseToString(); |
2188 } | 2192 } |
2189 | 2193 |
2190 TEST_F(RendererSchedulerImplTest, MismatchedDidHandleInputEventOnMainThread) { | 2194 TEST_F(RendererSchedulerImplTest, MismatchedDidHandleInputEventOnMainThread) { |
2191 // This should not DCHECK because there was no corresponding compositor side | 2195 // This should not DCHECK because there was no corresponding compositor side |
2192 // call to DidHandleInputEventOnCompositorThread with | 2196 // call to DidHandleInputEventOnCompositorThread with |
2193 // INPUT_EVENT_ACK_STATE_NOT_CONSUMED. There are legitimate reasons for the | 2197 // INPUT_EVENT_ACK_STATE_NOT_CONSUMED. There are legitimate reasons for the |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3265 base::Unretained(this))); | 3269 base::Unretained(this))); |
3266 EXPECT_EQ(UseCase::MAIN_THREAD_GESTURE, CurrentUseCase()) << "i = " << i; | 3270 EXPECT_EQ(UseCase::MAIN_THREAD_GESTURE, CurrentUseCase()) << "i = " << i; |
3267 } | 3271 } |
3268 | 3272 |
3269 EXPECT_EQ(TaskQueue::HIGH_PRIORITY, | 3273 EXPECT_EQ(TaskQueue::HIGH_PRIORITY, |
3270 scheduler_->CompositorTaskRunner()->GetQueuePriority()); | 3274 scheduler_->CompositorTaskRunner()->GetQueuePriority()); |
3271 EXPECT_EQ(279u, run_order.size()); | 3275 EXPECT_EQ(279u, run_order.size()); |
3272 } | 3276 } |
3273 | 3277 |
3274 } // namespace scheduler | 3278 } // namespace scheduler |
OLD | NEW |