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 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 scheduler_->ResumeTimerQueue(); | 2050 scheduler_->ResumeTimerQueue(); |
2051 RunUntilIdle(); | 2051 RunUntilIdle(); |
2052 EXPECT_TRUE(run_order.empty()); | 2052 EXPECT_TRUE(run_order.empty()); |
2053 | 2053 |
2054 scheduler_->ResumeTimerQueue(); | 2054 scheduler_->ResumeTimerQueue(); |
2055 RunUntilIdle(); | 2055 RunUntilIdle(); |
2056 EXPECT_THAT(run_order, | 2056 EXPECT_THAT(run_order, |
2057 testing::ElementsAre(std::string("T1"), std::string("T2"))); | 2057 testing::ElementsAre(std::string("T1"), std::string("T2"))); |
2058 } | 2058 } |
2059 | 2059 |
| 2060 TEST_F(RendererSchedulerImplTest, SuspendRendererWhenBackgrounded) { |
| 2061 // Assume that the renderer is backgrounded. |
| 2062 scheduler_->OnRendererBackgrounded(); |
| 2063 |
| 2064 // Tasks don't fire when the renderer is suspended. |
| 2065 std::vector<std::string> run_order; |
| 2066 PostTestTasks(&run_order, "T1 T2"); |
| 2067 scheduler_->SuspendRendererWhenBackgrounded(); |
| 2068 RunUntilIdle(); |
| 2069 EXPECT_TRUE(run_order.empty()); |
| 2070 |
| 2071 // The queued tasks fire when the tab goes foregrounded. |
| 2072 scheduler_->OnRendererForegrounded(); |
| 2073 RunUntilIdle(); |
| 2074 EXPECT_THAT(run_order, |
| 2075 testing::ElementsAre(std::string("T1"), std::string("T2"))); |
| 2076 |
| 2077 // Even if the renderer is foregrounded when trying to suspend it, the |
| 2078 // renderer is not suspended. |
| 2079 run_order.clear(); |
| 2080 PostTestTasks(&run_order, "T3 T4"); |
| 2081 scheduler_->SuspendRendererWhenBackgrounded(); |
| 2082 RunUntilIdle(); |
| 2083 EXPECT_THAT(run_order, |
| 2084 testing::ElementsAre(std::string("T3"), std::string("T4"))); |
| 2085 } |
| 2086 |
2060 TEST_F(RendererSchedulerImplTest, UseCaseToString) { | 2087 TEST_F(RendererSchedulerImplTest, UseCaseToString) { |
2061 CheckAllUseCaseToString(); | 2088 CheckAllUseCaseToString(); |
2062 } | 2089 } |
2063 | 2090 |
2064 TEST_F(RendererSchedulerImplTest, MismatchedDidHandleInputEventOnMainThread) { | 2091 TEST_F(RendererSchedulerImplTest, MismatchedDidHandleInputEventOnMainThread) { |
2065 // This should not DCHECK because there was no corresponding compositor side | 2092 // This should not DCHECK because there was no corresponding compositor side |
2066 // call to DidHandleInputEventOnCompositorThread with | 2093 // call to DidHandleInputEventOnCompositorThread with |
2067 // INPUT_EVENT_ACK_STATE_NOT_CONSUMED. There are legitimate reasons for the | 2094 // INPUT_EVENT_ACK_STATE_NOT_CONSUMED. There are legitimate reasons for the |
2068 // compositor to not be there and we don't want to make debugging impossible. | 2095 // compositor to not be there and we don't want to make debugging impossible. |
2069 scheduler_->DidHandleInputEventOnMainThread( | 2096 scheduler_->DidHandleInputEventOnMainThread( |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2883 } | 2910 } |
2884 | 2911 |
2885 // Timer tasks should not have been starved by the expensive compositor | 2912 // Timer tasks should not have been starved by the expensive compositor |
2886 // tasks. | 2913 // tasks. |
2887 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY, | 2914 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY, |
2888 scheduler_->CompositorTaskRunner()->GetQueuePriority()); | 2915 scheduler_->CompositorTaskRunner()->GetQueuePriority()); |
2889 EXPECT_EQ(1000u, run_order.size()); | 2916 EXPECT_EQ(1000u, run_order.size()); |
2890 } | 2917 } |
2891 | 2918 |
2892 } // namespace scheduler | 2919 } // namespace scheduler |
OLD | NEW |