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

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

Issue 1950913005: scheduler: Only prioritize rAF if it is fast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after
2799 ForceUpdatePolicyAndGetCurrentUseCase()); 2799 ForceUpdatePolicyAndGetCurrentUseCase());
2800 2800
2801 // Make sure TouchStart causes a policy change. 2801 // Make sure TouchStart causes a policy change.
2802 scheduler_->DidHandleInputEventOnCompositorThread( 2802 scheduler_->DidHandleInputEventOnCompositorThread(
2803 FakeInputEvent(blink::WebInputEvent::TouchStart), 2803 FakeInputEvent(blink::WebInputEvent::TouchStart),
2804 RendererScheduler::InputEventState::EVENT_FORWARDED_TO_MAIN_THREAD); 2804 RendererScheduler::InputEventState::EVENT_FORWARDED_TO_MAIN_THREAD);
2805 EXPECT_EQ(RendererScheduler::UseCase::TOUCHSTART, 2805 EXPECT_EQ(RendererScheduler::UseCase::TOUCHSTART,
2806 ForceUpdatePolicyAndGetCurrentUseCase()); 2806 ForceUpdatePolicyAndGetCurrentUseCase());
2807 } 2807 }
2808 2808
2809 TEST_F(RendererSchedulerImplTest, SYNCHRONIZED_GESTURE_CompositingExpensive) {
2810 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
2811
2812 // With the compositor task taking 20ms, there is not enough time to run
2813 // other tasks in the same 16ms frame. To avoid starvation, compositing tasks
2814 // should therefore not get prioritized.
2815 std::vector<std::string> run_order;
2816 for (int i = 0; i < 1000; i++)
2817 PostTestTasks(&run_order, "T1");
2818
2819 for (int i = 0; i < 100; i++) {
2820 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
2821 BEGINFRAME_FROM_HERE, clock_->NowTicks(), base::TimeTicks(),
2822 base::TimeDelta::FromMilliseconds(16), cc::BeginFrameArgs::NORMAL);
2823 begin_frame_args.on_critical_path = true;
2824 scheduler_->WillBeginFrame(begin_frame_args);
2825 scheduler_->DidHandleInputEventOnCompositorThread(
2826 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate),
2827 RendererScheduler::InputEventState::EVENT_CONSUMED_BY_COMPOSITOR);
2828
2829 simulate_compositor_task_ran_ = false;
2830 compositor_task_runner_->PostTask(
2831 FROM_HERE,
2832 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask,
2833 base::Unretained(this),
2834 base::TimeDelta::FromMilliseconds(20)));
2835
2836 mock_task_runner_->RunTasksWhile(
2837 base::Bind(&RendererSchedulerImplTest::SimulatedCompositorTaskPending,
2838 base::Unretained(this)));
2839 EXPECT_EQ(UseCase::SYNCHRONIZED_GESTURE, CurrentUseCase()) << "i = " << i;
2840 }
2841
2842 // Timer tasks should not have been starved by the expensive compositor
2843 // tasks.
2844 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY,
2845 scheduler_->CompositorTaskRunner()->GetQueuePriority());
2846 EXPECT_EQ(1000u, run_order.size());
2847 }
2848
2849 TEST_F(RendererSchedulerImplTest, MAIN_THREAD_GESTURE_CompositingExpensive) {
2850 SimulateMainThreadGestureStart(TouchEventPolicy::DONT_SEND_TOUCH_START,
2851 blink::WebInputEvent::GestureScrollBegin);
2852
2853 // With the compositor task taking 20ms, there is not enough time to run
2854 // other tasks in the same 16ms frame. To avoid starvation, compositing tasks
2855 // should therefore not get prioritized.
2856 std::vector<std::string> run_order;
2857 for (int i = 0; i < 1000; i++)
2858 PostTestTasks(&run_order, "T1");
2859
2860 for (int i = 0; i < 100; i++) {
2861 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
2862 BEGINFRAME_FROM_HERE, clock_->NowTicks(), base::TimeTicks(),
2863 base::TimeDelta::FromMilliseconds(16), cc::BeginFrameArgs::NORMAL);
2864 begin_frame_args.on_critical_path = true;
2865 scheduler_->WillBeginFrame(begin_frame_args);
2866 scheduler_->DidHandleInputEventOnCompositorThread(
2867 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate),
2868 RendererScheduler::InputEventState::EVENT_FORWARDED_TO_MAIN_THREAD);
2869
2870 simulate_compositor_task_ran_ = false;
2871 compositor_task_runner_->PostTask(
2872 FROM_HERE,
2873 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask,
2874 base::Unretained(this),
2875 base::TimeDelta::FromMilliseconds(20)));
2876
2877 mock_task_runner_->RunTasksWhile(
2878 base::Bind(&RendererSchedulerImplTest::SimulatedCompositorTaskPending,
2879 base::Unretained(this)));
2880 EXPECT_EQ(UseCase::MAIN_THREAD_GESTURE, CurrentUseCase()) << "i = " << i;
2881 }
2882
2883 // Timer tasks should not have been starved by the expensive compositor
2884 // tasks.
2885 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY,
2886 scheduler_->CompositorTaskRunner()->GetQueuePriority());
2887 EXPECT_EQ(1000u, run_order.size());
2888 }
2889
2809 } // namespace scheduler 2890 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698