Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: components/scheduler/renderer/renderer_scheduler_impl_unittest.cc

Issue 1914143002: Experimental 'purging and suspending' backgrounded tabs behind the flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address on haraken's review Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 scheduler_->ResumeTimerQueue(); 2117 scheduler_->ResumeTimerQueue();
2118 RunUntilIdle(); 2118 RunUntilIdle();
2119 EXPECT_TRUE(run_order.empty()); 2119 EXPECT_TRUE(run_order.empty());
2120 2120
2121 scheduler_->ResumeTimerQueue(); 2121 scheduler_->ResumeTimerQueue();
2122 RunUntilIdle(); 2122 RunUntilIdle();
2123 EXPECT_THAT(run_order, 2123 EXPECT_THAT(run_order,
2124 testing::ElementsAre(std::string("T1"), std::string("T2"))); 2124 testing::ElementsAre(std::string("T1"), std::string("T2")));
2125 } 2125 }
2126 2126
2127 TEST_F(RendererSchedulerImplTest, SuspendRendererWhenBackgrounded) {
2128 // Assume that the renderer is backgrounded.
2129 scheduler_->OnRendererBackgrounded();
2130
2131 // Tasks don't fire when the renderer is suspended.
2132 std::vector<std::string> run_order;
2133 PostTestTasks(&run_order, "T1 T2");
2134 scheduler_->SuspendRenderer();
2135 RunUntilIdle();
2136 EXPECT_TRUE(run_order.empty());
2137
2138 // The queued tasks fire when the tab goes foregrounded.
2139 scheduler_->OnRendererForegrounded();
2140 RunUntilIdle();
2141 EXPECT_THAT(run_order,
2142 testing::ElementsAre(std::string("T1"), std::string("T2")));
2143 }
2144
2127 TEST_F(RendererSchedulerImplTest, UseCaseToString) { 2145 TEST_F(RendererSchedulerImplTest, UseCaseToString) {
2128 CheckAllUseCaseToString(); 2146 CheckAllUseCaseToString();
2129 } 2147 }
2130 2148
2131 TEST_F(RendererSchedulerImplTest, MismatchedDidHandleInputEventOnMainThread) { 2149 TEST_F(RendererSchedulerImplTest, MismatchedDidHandleInputEventOnMainThread) {
2132 // This should not DCHECK because there was no corresponding compositor side 2150 // This should not DCHECK because there was no corresponding compositor side
2133 // call to DidHandleInputEventOnCompositorThread with 2151 // call to DidHandleInputEventOnCompositorThread with
2134 // INPUT_EVENT_ACK_STATE_NOT_CONSUMED. There are legitimate reasons for the 2152 // INPUT_EVENT_ACK_STATE_NOT_CONSUMED. There are legitimate reasons for the
2135 // compositor to not be there and we don't want to make debugging impossible. 2153 // compositor to not be there and we don't want to make debugging impossible.
2136 scheduler_->DidHandleInputEventOnMainThread( 2154 scheduler_->DidHandleInputEventOnMainThread(
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
2984 } 3002 }
2985 3003
2986 // Timer tasks should not have been starved by the expensive compositor 3004 // Timer tasks should not have been starved by the expensive compositor
2987 // tasks. 3005 // tasks.
2988 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY, 3006 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY,
2989 scheduler_->CompositorTaskRunner()->GetQueuePriority()); 3007 scheduler_->CompositorTaskRunner()->GetQueuePriority());
2990 EXPECT_EQ(1000u, run_order.size()); 3008 EXPECT_EQ(1000u, run_order.size());
2991 } 3009 }
2992 3010
2993 } // namespace scheduler 3011 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.cc ('k') | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698