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

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

Issue 1958283005: Throttling Helper to disable task queue until PumpThrottledTasks called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo 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 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 timer_queue->PostTask(FROM_HERE, base::Bind(SlowCountingTask, count, clock, 2665 timer_queue->PostTask(FROM_HERE, base::Bind(SlowCountingTask, count, clock,
2666 task_duration, timer_queue)); 2666 task_duration, timer_queue));
2667 } 2667 }
2668 } 2668 }
2669 } 2669 }
2670 2670
2671 TEST_F(RendererSchedulerImplTest, 2671 TEST_F(RendererSchedulerImplTest,
2672 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_expensive) { 2672 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_expensive) {
2673 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); 2673 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
2674 2674
2675 base::TimeTicks first_throttled_run_time =
2676 ThrottlingHelper::ThrottledRunTime(clock_->NowTicks());
2677
2675 size_t count = 0; 2678 size_t count = 0;
2676 // With the compositor task taking 10ms, there is not enough time to run this 2679 // With the compositor task taking 10ms, there is not enough time to run this
2677 // 7ms timer task in the 16ms frame. 2680 // 7ms timer task in the 16ms frame.
2678 scheduler_->TimerTaskRunner()->PostTask( 2681 scheduler_->TimerTaskRunner()->PostTask(
2679 FROM_HERE, base::Bind(SlowCountingTask, &count, clock_.get(), 7, 2682 FROM_HERE, base::Bind(SlowCountingTask, &count, clock_.get(), 7,
2680 scheduler_->TimerTaskRunner())); 2683 scheduler_->TimerTaskRunner()));
2681 2684
2682 for (int i = 0; i < 1000; i++) { 2685 for (int i = 0; i < 1000; i++) {
2683 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( 2686 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
2684 BEGINFRAME_FROM_HERE, clock_->NowTicks(), base::TimeTicks(), 2687 BEGINFRAME_FROM_HERE, clock_->NowTicks(), base::TimeTicks(),
2685 base::TimeDelta::FromMilliseconds(16), cc::BeginFrameArgs::NORMAL); 2688 base::TimeDelta::FromMilliseconds(16), cc::BeginFrameArgs::NORMAL);
2686 begin_frame_args.on_critical_path = true; 2689 begin_frame_args.on_critical_path = true;
2687 scheduler_->WillBeginFrame(begin_frame_args); 2690 scheduler_->WillBeginFrame(begin_frame_args);
2688 scheduler_->DidHandleInputEventOnCompositorThread( 2691 scheduler_->DidHandleInputEventOnCompositorThread(
2689 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate), 2692 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate),
2690 RendererScheduler::InputEventState::EVENT_CONSUMED_BY_COMPOSITOR); 2693 RendererScheduler::InputEventState::EVENT_CONSUMED_BY_COMPOSITOR);
2691 2694
2692 simulate_compositor_task_ran_ = false; 2695 simulate_compositor_task_ran_ = false;
2693 compositor_task_runner_->PostTask( 2696 compositor_task_runner_->PostTask(
2694 FROM_HERE, 2697 FROM_HERE,
2695 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask, 2698 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask,
2696 base::Unretained(this), 2699 base::Unretained(this),
2697 base::TimeDelta::FromMilliseconds(10))); 2700 base::TimeDelta::FromMilliseconds(10)));
2698 2701
2699 mock_task_runner_->RunTasksWhile( 2702 mock_task_runner_->RunTasksWhile(
2700 base::Bind(&RendererSchedulerImplTest::SimulatedCompositorTaskPending, 2703 base::Bind(&RendererSchedulerImplTest::SimulatedCompositorTaskPending,
2701 base::Unretained(this))); 2704 base::Unretained(this)));
2702 EXPECT_EQ(UseCase::SYNCHRONIZED_GESTURE, CurrentUseCase()) << "i = " << i; 2705 EXPECT_EQ(UseCase::SYNCHRONIZED_GESTURE, CurrentUseCase()) << "i = " << i;
2703 EXPECT_TRUE(scheduler_->TimerTaskRunner()->IsQueueEnabled()) << "i = " << i; 2706
2707 // Before the policy is updated the queue will be enabled. Subsequently it
2708 // will be disabled until the throttled queue is pumped.
2709 bool expect_queue_enabled =
2710 (i == 0) || (clock_->NowTicks() > first_throttled_run_time);
2711 EXPECT_EQ(expect_queue_enabled,
2712 scheduler_->TimerTaskRunner()->IsQueueEnabled())
2713 << "i = " << i;
2704 } 2714 }
2705 2715
2706 // Task is throttled but not completely blocked. 2716 // Task is throttled but not completely blocked.
2707 EXPECT_EQ(13u, count); 2717 EXPECT_EQ(12u, count);
2708 } 2718 }
2709 2719
2710 TEST_F(RendererSchedulerImplTest, 2720 TEST_F(RendererSchedulerImplTest,
2711 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_not_expensive) { 2721 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_not_expensive) {
2712 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); 2722 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
2713 2723
2714 size_t count = 0; 2724 size_t count = 0;
2715 // With the compositor task taking 10ms, there is enough time to run this 6ms 2725 // With the compositor task taking 10ms, there is enough time to run this 6ms
2716 // timer task in the 16ms frame. 2726 // timer task in the 16ms frame.
2717 scheduler_->TimerTaskRunner()->PostTask( 2727 scheduler_->TimerTaskRunner()->PostTask(
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2883 } 2893 }
2884 2894
2885 // Timer tasks should not have been starved by the expensive compositor 2895 // Timer tasks should not have been starved by the expensive compositor
2886 // tasks. 2896 // tasks.
2887 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY, 2897 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY,
2888 scheduler_->CompositorTaskRunner()->GetQueuePriority()); 2898 scheduler_->CompositorTaskRunner()->GetQueuePriority());
2889 EXPECT_EQ(1000u, run_order.size()); 2899 EXPECT_EQ(1000u, run_order.size());
2890 } 2900 }
2891 2901
2892 } // namespace scheduler 2902 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.cc ('k') | components/scheduler/renderer/throttling_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698