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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl_unittest.cc

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 "platform/scheduler/renderer/renderer_scheduler_impl.h" 5 #include "platform/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 *deadline_out = deadline; 69 *deadline_out = deadline;
70 } 70 }
71 71
72 int max_idle_task_reposts = 2; 72 int max_idle_task_reposts = 2;
73 73
74 void RepostingIdleTestTask(SingleThreadIdleTaskRunner* idle_task_runner, 74 void RepostingIdleTestTask(SingleThreadIdleTaskRunner* idle_task_runner,
75 int* run_count, 75 int* run_count,
76 base::TimeTicks deadline) { 76 base::TimeTicks deadline) {
77 if ((*run_count + 1) < max_idle_task_reposts) { 77 if ((*run_count + 1) < max_idle_task_reposts) {
78 idle_task_runner->PostIdleTask( 78 idle_task_runner->PostIdleTask(
79 FROM_HERE, base::Bind(&RepostingIdleTestTask, 79 FROM_HERE,
80 base::Unretained(idle_task_runner), run_count)); 80 base::Bind(&RepostingIdleTestTask, base::Unretained(idle_task_runner),
81 run_count));
81 } 82 }
82 (*run_count)++; 83 (*run_count)++;
83 } 84 }
84 85
85 void RepostingUpdateClockIdleTestTask( 86 void RepostingUpdateClockIdleTestTask(
86 SingleThreadIdleTaskRunner* idle_task_runner, 87 SingleThreadIdleTaskRunner* idle_task_runner,
87 int* run_count, 88 int* run_count,
88 base::SimpleTestTickClock* clock, 89 base::SimpleTestTickClock* clock,
89 base::TimeDelta advance_time, 90 base::TimeDelta advance_time,
90 std::vector<base::TimeTicks>* deadlines, 91 std::vector<base::TimeTicks>* deadlines,
91 base::TimeTicks deadline) { 92 base::TimeTicks deadline) {
92 if ((*run_count + 1) < max_idle_task_reposts) { 93 if ((*run_count + 1) < max_idle_task_reposts) {
93 idle_task_runner->PostIdleTask( 94 idle_task_runner->PostIdleTask(
94 FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, 95 FROM_HERE,
95 base::Unretained(idle_task_runner), run_count, 96 base::Bind(&RepostingUpdateClockIdleTestTask,
96 clock, advance_time, deadlines)); 97 base::Unretained(idle_task_runner), run_count, clock,
98 advance_time, deadlines));
97 } 99 }
98 deadlines->push_back(deadline); 100 deadlines->push_back(deadline);
99 (*run_count)++; 101 (*run_count)++;
100 clock->Advance(advance_time); 102 clock->Advance(advance_time);
101 } 103 }
102 104
103 void WillBeginFrameIdleTask(RendererScheduler* scheduler, 105 void WillBeginFrameIdleTask(RendererScheduler* scheduler,
104 uint64_t sequence_number, 106 uint64_t sequence_number,
105 base::SimpleTestTickClock* clock, 107 base::SimpleTestTickClock* clock,
106 base::TimeTicks deadline) { 108 base::TimeTicks deadline) {
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 PostTestTasks(&run_order, "D1 C1"); 695 PostTestTasks(&run_order, "D1 C1");
694 RunUntilIdle(); 696 RunUntilIdle();
695 EXPECT_THAT(run_order, testing::Contains("D1")); 697 EXPECT_THAT(run_order, testing::Contains("D1"));
696 EXPECT_THAT(run_order, testing::Contains("C1")); 698 EXPECT_THAT(run_order, testing::Contains("C1"));
697 } 699 }
698 700
699 TEST_F(RendererSchedulerImplTest, TestRentrantTask) { 701 TEST_F(RendererSchedulerImplTest, TestRentrantTask) {
700 int count = 0; 702 int count = 0;
701 std::vector<int> run_order; 703 std::vector<int> run_order;
702 default_task_runner_->PostTask( 704 default_task_runner_->PostTask(
703 FROM_HERE, base::Bind(AppendToVectorReentrantTask, 705 FROM_HERE,
704 base::RetainedRef(default_task_runner_), &run_order, 706 base::Bind(AppendToVectorReentrantTask,
705 &count, 5)); 707 base::RetainedRef(default_task_runner_), &run_order, &count,
708 5));
706 RunUntilIdle(); 709 RunUntilIdle();
707 710
708 EXPECT_THAT(run_order, testing::ElementsAre(0, 1, 2, 3, 4)); 711 EXPECT_THAT(run_order, testing::ElementsAre(0, 1, 2, 3, 4));
709 } 712 }
710 713
711 TEST_F(RendererSchedulerImplTest, TestPostIdleTask) { 714 TEST_F(RendererSchedulerImplTest, TestPostIdleTask) {
712 int run_count = 0; 715 int run_count = 0;
713 base::TimeTicks expected_deadline = 716 base::TimeTicks expected_deadline =
714 clock_->NowTicks() + base::TimeDelta::FromMilliseconds(2300); 717 clock_->NowTicks() + base::TimeDelta::FromMilliseconds(2300);
715 base::TimeTicks deadline_in_task; 718 base::TimeTicks deadline_in_task;
(...skipping 26 matching lines...) Expand all
742 RunUntilIdle(); 745 RunUntilIdle();
743 EXPECT_EQ(1, run_count); 746 EXPECT_EQ(1, run_count);
744 EXPECT_EQ(expected_deadline, deadline_in_task); 747 EXPECT_EQ(expected_deadline, deadline_in_task);
745 } 748 }
746 749
747 TEST_F(RendererSchedulerImplTest, TestRepostingIdleTask) { 750 TEST_F(RendererSchedulerImplTest, TestRepostingIdleTask) {
748 int run_count = 0; 751 int run_count = 0;
749 752
750 max_idle_task_reposts = 2; 753 max_idle_task_reposts = 2;
751 idle_task_runner_->PostIdleTask( 754 idle_task_runner_->PostIdleTask(
752 FROM_HERE, base::Bind(&RepostingIdleTestTask, 755 FROM_HERE,
753 base::RetainedRef(idle_task_runner_), &run_count)); 756 base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_),
757 &run_count));
754 EnableIdleTasks(); 758 EnableIdleTasks();
755 RunUntilIdle(); 759 RunUntilIdle();
756 EXPECT_EQ(1, run_count); 760 EXPECT_EQ(1, run_count);
757 761
758 // Reposted tasks shouldn't run until next idle period. 762 // Reposted tasks shouldn't run until next idle period.
759 RunUntilIdle(); 763 RunUntilIdle();
760 EXPECT_EQ(1, run_count); 764 EXPECT_EQ(1, run_count);
761 765
762 EnableIdleTasks(); 766 EnableIdleTasks();
763 RunUntilIdle(); 767 RunUntilIdle();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 CurrentUseCase()); 894 CurrentUseCase());
891 } 895 }
892 896
893 TEST_F(RendererSchedulerImplTest, 897 TEST_F(RendererSchedulerImplTest,
894 TestCompositorPolicy_CompositorHandlesInput_LongGestureDuration) { 898 TestCompositorPolicy_CompositorHandlesInput_LongGestureDuration) {
895 scheduler_->SetHasVisibleRenderWidgetWithTouchHandler(true); 899 scheduler_->SetHasVisibleRenderWidgetWithTouchHandler(true);
896 EnableIdleTasks(); 900 EnableIdleTasks();
897 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); 901 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
898 902
899 base::TimeTicks loop_end_time = 903 base::TimeTicks loop_end_time =
900 clock_->NowTicks() + base::TimeDelta::FromMilliseconds( 904 clock_->NowTicks() +
901 UserModel::kMedianGestureDurationMillis * 2); 905 base::TimeDelta::FromMilliseconds(
906 UserModel::kMedianGestureDurationMillis * 2);
902 907
903 // The UseCase::COMPOSITOR_GESTURE usecase initially deprioritizes compositor 908 // The UseCase::COMPOSITOR_GESTURE usecase initially deprioritizes compositor
904 // tasks (see TestCompositorPolicy_CompositorHandlesInput_WithTouchHandler) 909 // tasks (see TestCompositorPolicy_CompositorHandlesInput_WithTouchHandler)
905 // but if the gesture is long enough, compositor tasks get prioritized again. 910 // but if the gesture is long enough, compositor tasks get prioritized again.
906 while (clock_->NowTicks() < loop_end_time) { 911 while (clock_->NowTicks() < loop_end_time) {
907 scheduler_->DidHandleInputEventOnCompositorThread( 912 scheduler_->DidHandleInputEventOnCompositorThread(
908 FakeInputEvent(blink::WebInputEvent::TouchMove), 913 FakeInputEvent(blink::WebInputEvent::TouchMove),
909 RendererScheduler::InputEventState::EVENT_CONSUMED_BY_COMPOSITOR); 914 RendererScheduler::InputEventState::EVENT_CONSUMED_BY_COMPOSITOR);
910 clock_->Advance(base::TimeDelta::FromMilliseconds(16)); 915 clock_->Advance(base::TimeDelta::FromMilliseconds(16));
911 RunUntilIdle(); 916 RunUntilIdle();
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 RunUntilIdle(); 1636 RunUntilIdle();
1632 EXPECT_THAT(run_order, testing::ElementsAre(std::string("L1"))); 1637 EXPECT_THAT(run_order, testing::ElementsAre(std::string("L1")));
1633 } 1638 }
1634 1639
1635 TEST_F(RendererSchedulerImplTest, TestIsHighPriorityWorkAnticipated) { 1640 TEST_F(RendererSchedulerImplTest, TestIsHighPriorityWorkAnticipated) {
1636 bool is_anticipated_before = false; 1641 bool is_anticipated_before = false;
1637 bool is_anticipated_after = false; 1642 bool is_anticipated_after = false;
1638 1643
1639 scheduler_->SetHasVisibleRenderWidgetWithTouchHandler(true); 1644 scheduler_->SetHasVisibleRenderWidgetWithTouchHandler(true);
1640 default_task_runner_->PostTask( 1645 default_task_runner_->PostTask(
1641 FROM_HERE, base::Bind(&AnticipationTestTask, scheduler_.get(), 1646 FROM_HERE,
1642 SimulateInputType::None, &is_anticipated_before, 1647 base::Bind(&AnticipationTestTask, scheduler_.get(),
1643 &is_anticipated_after)); 1648 SimulateInputType::None, &is_anticipated_before,
1649 &is_anticipated_after));
1644 RunUntilIdle(); 1650 RunUntilIdle();
1645 // In its default state, without input receipt, the scheduler should indicate 1651 // In its default state, without input receipt, the scheduler should indicate
1646 // that no high-priority is anticipated. 1652 // that no high-priority is anticipated.
1647 EXPECT_FALSE(is_anticipated_before); 1653 EXPECT_FALSE(is_anticipated_before);
1648 EXPECT_FALSE(is_anticipated_after); 1654 EXPECT_FALSE(is_anticipated_after);
1649 1655
1650 default_task_runner_->PostTask( 1656 default_task_runner_->PostTask(
1651 FROM_HERE, base::Bind(&AnticipationTestTask, scheduler_.get(), 1657 FROM_HERE,
1652 SimulateInputType::TouchStart, 1658 base::Bind(&AnticipationTestTask, scheduler_.get(),
1653 &is_anticipated_before, &is_anticipated_after)); 1659 SimulateInputType::TouchStart, &is_anticipated_before,
1660 &is_anticipated_after));
1654 bool dummy; 1661 bool dummy;
1655 default_task_runner_->PostTask( 1662 default_task_runner_->PostTask(
1656 FROM_HERE, base::Bind(&AnticipationTestTask, scheduler_.get(),
1657 SimulateInputType::TouchEnd, &dummy, &dummy));
1658 default_task_runner_->PostTask(
1659 FROM_HERE, 1663 FROM_HERE,
1660 base::Bind(&AnticipationTestTask, scheduler_.get(), 1664 base::Bind(&AnticipationTestTask, scheduler_.get(),
1665 SimulateInputType::TouchEnd, &dummy, &dummy));
1666 default_task_runner_->PostTask(
1667 FROM_HERE,
1668 base::Bind(&AnticipationTestTask, scheduler_.get(),
1661 SimulateInputType::GestureScrollBegin, &dummy, &dummy)); 1669 SimulateInputType::GestureScrollBegin, &dummy, &dummy));
1662 default_task_runner_->PostTask( 1670 default_task_runner_->PostTask(
1663 FROM_HERE, 1671 FROM_HERE,
1664 base::Bind(&AnticipationTestTask, scheduler_.get(), 1672 base::Bind(&AnticipationTestTask, scheduler_.get(),
1665 SimulateInputType::GestureScrollEnd, &dummy, &dummy)); 1673 SimulateInputType::GestureScrollEnd, &dummy, &dummy));
1666 1674
1667 RunUntilIdle(); 1675 RunUntilIdle();
1668 // When input is received, the scheduler should indicate that high-priority 1676 // When input is received, the scheduler should indicate that high-priority
1669 // work is anticipated. 1677 // work is anticipated.
1670 EXPECT_FALSE(is_anticipated_before); 1678 EXPECT_FALSE(is_anticipated_before);
1671 EXPECT_TRUE(is_anticipated_after); 1679 EXPECT_TRUE(is_anticipated_after);
1672 1680
1673 clock_->Advance(priority_escalation_after_input_duration() * 2); 1681 clock_->Advance(priority_escalation_after_input_duration() * 2);
1674 default_task_runner_->PostTask( 1682 default_task_runner_->PostTask(
1675 FROM_HERE, base::Bind(&AnticipationTestTask, scheduler_.get(), 1683 FROM_HERE,
1676 SimulateInputType::None, &is_anticipated_before, 1684 base::Bind(&AnticipationTestTask, scheduler_.get(),
1677 &is_anticipated_after)); 1685 SimulateInputType::None, &is_anticipated_before,
1686 &is_anticipated_after));
1678 RunUntilIdle(); 1687 RunUntilIdle();
1679 // Without additional input, the scheduler should go into NONE 1688 // Without additional input, the scheduler should go into NONE
1680 // use case but with scrolling expected where high-priority work is still 1689 // use case but with scrolling expected where high-priority work is still
1681 // anticipated. 1690 // anticipated.
1682 EXPECT_EQ(UseCase::NONE, CurrentUseCase()); 1691 EXPECT_EQ(UseCase::NONE, CurrentUseCase());
1683 EXPECT_TRUE(TouchStartExpectedSoon()); 1692 EXPECT_TRUE(TouchStartExpectedSoon());
1684 EXPECT_TRUE(is_anticipated_before); 1693 EXPECT_TRUE(is_anticipated_before);
1685 EXPECT_TRUE(is_anticipated_after); 1694 EXPECT_TRUE(is_anticipated_after);
1686 1695
1687 clock_->Advance(subsequent_input_expected_after_input_duration() * 2); 1696 clock_->Advance(subsequent_input_expected_after_input_duration() * 2);
1688 default_task_runner_->PostTask( 1697 default_task_runner_->PostTask(
1689 FROM_HERE, base::Bind(&AnticipationTestTask, scheduler_.get(), 1698 FROM_HERE,
1690 SimulateInputType::None, &is_anticipated_before, 1699 base::Bind(&AnticipationTestTask, scheduler_.get(),
1691 &is_anticipated_after)); 1700 SimulateInputType::None, &is_anticipated_before,
1701 &is_anticipated_after));
1692 RunUntilIdle(); 1702 RunUntilIdle();
1693 // Eventually the scheduler should go into the default use case where 1703 // Eventually the scheduler should go into the default use case where
1694 // high-priority work is no longer anticipated. 1704 // high-priority work is no longer anticipated.
1695 EXPECT_EQ(UseCase::NONE, CurrentUseCase()); 1705 EXPECT_EQ(UseCase::NONE, CurrentUseCase());
1696 EXPECT_FALSE(TouchStartExpectedSoon()); 1706 EXPECT_FALSE(TouchStartExpectedSoon());
1697 EXPECT_FALSE(is_anticipated_before); 1707 EXPECT_FALSE(is_anticipated_before);
1698 EXPECT_FALSE(is_anticipated_after); 1708 EXPECT_FALSE(is_anticipated_after);
1699 } 1709 }
1700 1710
1701 TEST_F(RendererSchedulerImplTest, TestShouldYield) { 1711 TEST_F(RendererSchedulerImplTest, TestShouldYield) {
1702 bool should_yield_before = false; 1712 bool should_yield_before = false;
1703 bool should_yield_after = false; 1713 bool should_yield_after = false;
1704 1714
1705 default_task_runner_->PostTask( 1715 default_task_runner_->PostTask(
1706 FROM_HERE, base::Bind(&PostingYieldingTestTask, scheduler_.get(), 1716 FROM_HERE,
1707 base::RetainedRef(default_task_runner_), false, 1717 base::Bind(&PostingYieldingTestTask, scheduler_.get(),
1708 &should_yield_before, &should_yield_after)); 1718 base::RetainedRef(default_task_runner_), false,
1719 &should_yield_before, &should_yield_after));
1709 RunUntilIdle(); 1720 RunUntilIdle();
1710 // Posting to default runner shouldn't cause yielding. 1721 // Posting to default runner shouldn't cause yielding.
1711 EXPECT_FALSE(should_yield_before); 1722 EXPECT_FALSE(should_yield_before);
1712 EXPECT_FALSE(should_yield_after); 1723 EXPECT_FALSE(should_yield_after);
1713 1724
1714 default_task_runner_->PostTask( 1725 default_task_runner_->PostTask(
1715 FROM_HERE, base::Bind(&PostingYieldingTestTask, scheduler_.get(), 1726 FROM_HERE,
1716 base::RetainedRef(compositor_task_runner_), false, 1727 base::Bind(&PostingYieldingTestTask, scheduler_.get(),
1717 &should_yield_before, &should_yield_after)); 1728 base::RetainedRef(compositor_task_runner_), false,
1729 &should_yield_before, &should_yield_after));
1718 RunUntilIdle(); 1730 RunUntilIdle();
1719 // Posting while not mainthread scrolling shouldn't cause yielding. 1731 // Posting while not mainthread scrolling shouldn't cause yielding.
1720 EXPECT_FALSE(should_yield_before); 1732 EXPECT_FALSE(should_yield_before);
1721 EXPECT_FALSE(should_yield_after); 1733 EXPECT_FALSE(should_yield_after);
1722 1734
1723 default_task_runner_->PostTask( 1735 default_task_runner_->PostTask(
1724 FROM_HERE, base::Bind(&PostingYieldingTestTask, scheduler_.get(), 1736 FROM_HERE,
1725 base::RetainedRef(compositor_task_runner_), true, 1737 base::Bind(&PostingYieldingTestTask, scheduler_.get(),
1726 &should_yield_before, &should_yield_after)); 1738 base::RetainedRef(compositor_task_runner_), true,
1739 &should_yield_before, &should_yield_after));
1727 RunUntilIdle(); 1740 RunUntilIdle();
1728 // We should be able to switch to compositor priority mid-task. 1741 // We should be able to switch to compositor priority mid-task.
1729 EXPECT_FALSE(should_yield_before); 1742 EXPECT_FALSE(should_yield_before);
1730 EXPECT_TRUE(should_yield_after); 1743 EXPECT_TRUE(should_yield_after);
1731 } 1744 }
1732 1745
1733 TEST_F(RendererSchedulerImplTest, TestShouldYield_TouchStart) { 1746 TEST_F(RendererSchedulerImplTest, TestShouldYield_TouchStart) {
1734 // Receiving a touchstart should immediately trigger yielding, even if 1747 // Receiving a touchstart should immediately trigger yielding, even if
1735 // there's no immediately pending work in the compositor queue. 1748 // there's no immediately pending work in the compositor queue.
1736 EXPECT_FALSE(scheduler_->ShouldYieldForHighPriorityWork()); 1749 EXPECT_FALSE(scheduler_->ShouldYieldForHighPriorityWork());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 default_task_runner_->PostTask( 2063 default_task_runner_->PostTask(
2051 FROM_HERE, 2064 FROM_HERE,
2052 base::Bind( 2065 base::Bind(
2053 &RendererSchedulerImplWithMessageLoopTest::PostFromNestedRunloop, 2066 &RendererSchedulerImplWithMessageLoopTest::PostFromNestedRunloop,
2054 base::Unretained(this), 2067 base::Unretained(this),
2055 base::Unretained(&tasks_to_post_from_nested_loop))); 2068 base::Unretained(&tasks_to_post_from_nested_loop)));
2056 2069
2057 EnableIdleTasks(); 2070 EnableIdleTasks();
2058 RunUntilIdle(); 2071 RunUntilIdle();
2059 // Note we expect task 3 to run last because it's non-nestable. 2072 // Note we expect task 3 to run last because it's non-nestable.
2060 EXPECT_THAT(order, testing::ElementsAre(std::string("1"), std::string("2"), 2073 EXPECT_THAT(
2061 std::string("4"), std::string("5"), 2074 order,
2062 std::string("3"))); 2075 testing::ElementsAre(std::string("1"), std::string("2"), std::string("4"),
2076 std::string("5"), std::string("3")));
2063 } 2077 }
2064 2078
2065 TEST_F(RendererSchedulerImplTest, TestLongIdlePeriod) { 2079 TEST_F(RendererSchedulerImplTest, TestLongIdlePeriod) {
2066 base::TimeTicks expected_deadline = 2080 base::TimeTicks expected_deadline =
2067 clock_->NowTicks() + maximum_idle_period_duration(); 2081 clock_->NowTicks() + maximum_idle_period_duration();
2068 base::TimeTicks deadline_in_task; 2082 base::TimeTicks deadline_in_task;
2069 int run_count = 0; 2083 int run_count = 0;
2070 2084
2071 idle_task_runner_->PostIdleTask( 2085 idle_task_runner_->PostIdleTask(
2072 FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task)); 2086 FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 base::TimeTicks(), base::TimeDelta::FromMilliseconds(1000), 2255 base::TimeTicks(), base::TimeDelta::FromMilliseconds(1000),
2242 cc::BeginFrameArgs::NORMAL)); 2256 cc::BeginFrameArgs::NORMAL));
2243 EXPECT_FALSE(scheduler_->CanExceedIdleDeadlineIfRequired()); 2257 EXPECT_FALSE(scheduler_->CanExceedIdleDeadlineIfRequired());
2244 } 2258 }
2245 2259
2246 TEST_F(RendererSchedulerImplTest, TestRendererHiddenIdlePeriod) { 2260 TEST_F(RendererSchedulerImplTest, TestRendererHiddenIdlePeriod) {
2247 int run_count = 0; 2261 int run_count = 0;
2248 2262
2249 max_idle_task_reposts = 2; 2263 max_idle_task_reposts = 2;
2250 idle_task_runner_->PostIdleTask( 2264 idle_task_runner_->PostIdleTask(
2251 FROM_HERE, base::Bind(&RepostingIdleTestTask, 2265 FROM_HERE,
2252 base::RetainedRef(idle_task_runner_), &run_count)); 2266 base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_),
2267 &run_count));
2253 2268
2254 // Renderer should start in visible state. 2269 // Renderer should start in visible state.
2255 RunUntilIdle(); 2270 RunUntilIdle();
2256 EXPECT_EQ(0, run_count); 2271 EXPECT_EQ(0, run_count);
2257 2272
2258 // When we hide the renderer it should start a max deadline idle period, which 2273 // When we hide the renderer it should start a max deadline idle period, which
2259 // will run an idle task and then immediately start a new idle period, which 2274 // will run an idle task and then immediately start a new idle period, which
2260 // runs the second idle task. 2275 // runs the second idle task.
2261 scheduler_->SetAllRenderWidgetsHidden(true); 2276 scheduler_->SetAllRenderWidgetsHidden(true);
2262 RunUntilIdle(); 2277 RunUntilIdle();
2263 EXPECT_EQ(2, run_count); 2278 EXPECT_EQ(2, run_count);
2264 2279
2265 // Advance time by amount of time by the maximum amount of time we execute 2280 // Advance time by amount of time by the maximum amount of time we execute
2266 // idle tasks when hidden (plus some slack) - idle period should have ended. 2281 // idle tasks when hidden (plus some slack) - idle period should have ended.
2267 max_idle_task_reposts = 3; 2282 max_idle_task_reposts = 3;
2268 idle_task_runner_->PostIdleTask( 2283 idle_task_runner_->PostIdleTask(
2269 FROM_HERE, base::Bind(&RepostingIdleTestTask, 2284 FROM_HERE,
2270 base::RetainedRef(idle_task_runner_), &run_count)); 2285 base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_),
2286 &run_count));
2271 clock_->Advance(end_idle_when_hidden_delay() + 2287 clock_->Advance(end_idle_when_hidden_delay() +
2272 base::TimeDelta::FromMilliseconds(10)); 2288 base::TimeDelta::FromMilliseconds(10));
2273 RunUntilIdle(); 2289 RunUntilIdle();
2274 EXPECT_EQ(2, run_count); 2290 EXPECT_EQ(2, run_count);
2275 } 2291 }
2276 2292
2277 TEST_F(RendererSchedulerImplTest, TimerQueueEnabledByDefault) { 2293 TEST_F(RendererSchedulerImplTest, TimerQueueEnabledByDefault) {
2278 std::vector<std::string> run_order; 2294 std::vector<std::string> run_order;
2279 PostTestTasks(&run_order, "T1 T2"); 2295 PostTestTasks(&run_order, "T1 T2");
2280 RunUntilIdle(); 2296 RunUntilIdle();
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 simulate_timer_task_ran_ = false; 2846 simulate_timer_task_ran_ = false;
2831 2847
2832 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( 2848 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
2833 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(), 2849 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(),
2834 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16), 2850 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16),
2835 cc::BeginFrameArgs::NORMAL); 2851 cc::BeginFrameArgs::NORMAL);
2836 begin_frame_args.on_critical_path = false; 2852 begin_frame_args.on_critical_path = false;
2837 scheduler_->WillBeginFrame(begin_frame_args); 2853 scheduler_->WillBeginFrame(begin_frame_args);
2838 2854
2839 compositor_task_runner_->PostTask( 2855 compositor_task_runner_->PostTask(
2840 FROM_HERE, base::Bind(&RendererSchedulerImplTest:: 2856 FROM_HERE,
2841 SimulateMainThreadInputHandlingCompositorTask, 2857 base::Bind(&RendererSchedulerImplTest::
2842 base::Unretained(this), 2858 SimulateMainThreadInputHandlingCompositorTask,
2843 base::TimeDelta::FromMilliseconds(8))); 2859 base::Unretained(this),
2860 base::TimeDelta::FromMilliseconds(8)));
2844 timer_task_runner_->PostTask( 2861 timer_task_runner_->PostTask(
2845 FROM_HERE, base::Bind(&RendererSchedulerImplTest::SimulateTimerTask, 2862 FROM_HERE,
2846 base::Unretained(this), 2863 base::Bind(&RendererSchedulerImplTest::SimulateTimerTask,
2847 base::TimeDelta::FromMilliseconds(4))); 2864 base::Unretained(this),
2865 base::TimeDelta::FromMilliseconds(4)));
2848 2866
2849 RunUntilIdle(); 2867 RunUntilIdle();
2850 EXPECT_TRUE(simulate_timer_task_ran_) << " i = " << i; 2868 EXPECT_TRUE(simulate_timer_task_ran_) << " i = " << i;
2851 EXPECT_EQ(RendererSchedulerImpl::UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING, 2869 EXPECT_EQ(RendererSchedulerImpl::UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING,
2852 CurrentUseCase()) 2870 CurrentUseCase())
2853 << " i = " << i; 2871 << " i = " << i;
2854 EXPECT_FALSE(LoadingTasksSeemExpensive()) << " i = " << i; 2872 EXPECT_FALSE(LoadingTasksSeemExpensive()) << " i = " << i;
2855 EXPECT_FALSE(TimerTasksSeemExpensive()) << " i = " << i; 2873 EXPECT_FALSE(TimerTasksSeemExpensive()) << " i = " << i;
2856 2874
2857 base::TimeDelta time_till_next_frame = 2875 base::TimeDelta time_till_next_frame =
(...skipping 17 matching lines...) Expand all
2875 begin_frame_args.on_critical_path = false; 2893 begin_frame_args.on_critical_path = false;
2876 scheduler_->WillBeginFrame(begin_frame_args); 2894 scheduler_->WillBeginFrame(begin_frame_args);
2877 scheduler_->DidAnimateForInputOnCompositorThread(); 2895 scheduler_->DidAnimateForInputOnCompositorThread();
2878 2896
2879 compositor_task_runner_->PostTask( 2897 compositor_task_runner_->PostTask(
2880 FROM_HERE, 2898 FROM_HERE,
2881 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask, 2899 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask,
2882 base::Unretained(this), 2900 base::Unretained(this),
2883 base::TimeDelta::FromMilliseconds(8))); 2901 base::TimeDelta::FromMilliseconds(8)));
2884 timer_task_runner_->PostTask( 2902 timer_task_runner_->PostTask(
2885 FROM_HERE, base::Bind(&RendererSchedulerImplTest::SimulateTimerTask, 2903 FROM_HERE,
2886 base::Unretained(this), 2904 base::Bind(&RendererSchedulerImplTest::SimulateTimerTask,
2887 base::TimeDelta::FromMilliseconds(40))); 2905 base::Unretained(this),
2906 base::TimeDelta::FromMilliseconds(40)));
2888 2907
2889 RunUntilIdle(); 2908 RunUntilIdle();
2890 EXPECT_TRUE(simulate_timer_task_ran_) << " i = " << i; 2909 EXPECT_TRUE(simulate_timer_task_ran_) << " i = " << i;
2891 EXPECT_EQ(RendererSchedulerImpl::UseCase::COMPOSITOR_GESTURE, 2910 EXPECT_EQ(RendererSchedulerImpl::UseCase::COMPOSITOR_GESTURE,
2892 CurrentUseCase()) 2911 CurrentUseCase())
2893 << " i = " << i; 2912 << " i = " << i;
2894 EXPECT_FALSE(LoadingTasksSeemExpensive()) << " i = " << i; 2913 EXPECT_FALSE(LoadingTasksSeemExpensive()) << " i = " << i;
2895 EXPECT_FALSE(TimerTasksSeemExpensive()) << " i = " << i; 2914 EXPECT_FALSE(TimerTasksSeemExpensive()) << " i = " << i;
2896 2915
2897 base::TimeDelta time_till_next_frame = 2916 base::TimeDelta time_till_next_frame =
(...skipping 13 matching lines...) Expand all
2911 simulate_timer_task_ran_ = false; 2930 simulate_timer_task_ran_ = false;
2912 2931
2913 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( 2932 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
2914 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(), 2933 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(),
2915 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16), 2934 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16),
2916 cc::BeginFrameArgs::NORMAL); 2935 cc::BeginFrameArgs::NORMAL);
2917 begin_frame_args.on_critical_path = false; 2936 begin_frame_args.on_critical_path = false;
2918 scheduler_->WillBeginFrame(begin_frame_args); 2937 scheduler_->WillBeginFrame(begin_frame_args);
2919 2938
2920 compositor_task_runner_->PostTask( 2939 compositor_task_runner_->PostTask(
2921 FROM_HERE, base::Bind(&RendererSchedulerImplTest:: 2940 FROM_HERE,
2922 SimulateMainThreadInputHandlingCompositorTask, 2941 base::Bind(&RendererSchedulerImplTest::
2923 base::Unretained(this), 2942 SimulateMainThreadInputHandlingCompositorTask,
2924 base::TimeDelta::FromMilliseconds(8))); 2943 base::Unretained(this),
2944 base::TimeDelta::FromMilliseconds(8)));
2925 timer_task_runner_->PostTask( 2945 timer_task_runner_->PostTask(
2926 FROM_HERE, base::Bind(&RendererSchedulerImplTest::SimulateTimerTask, 2946 FROM_HERE,
2927 base::Unretained(this), 2947 base::Bind(&RendererSchedulerImplTest::SimulateTimerTask,
2928 base::TimeDelta::FromMilliseconds(10))); 2948 base::Unretained(this),
2949 base::TimeDelta::FromMilliseconds(10)));
2929 2950
2930 RunUntilIdle(); 2951 RunUntilIdle();
2931 EXPECT_EQ(RendererSchedulerImpl::UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING, 2952 EXPECT_EQ(RendererSchedulerImpl::UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING,
2932 CurrentUseCase()) 2953 CurrentUseCase())
2933 << " i = " << i; 2954 << " i = " << i;
2934 EXPECT_FALSE(LoadingTasksSeemExpensive()) << " i = " << i; 2955 EXPECT_FALSE(LoadingTasksSeemExpensive()) << " i = " << i;
2935 if (i == 0) { 2956 if (i == 0) {
2936 EXPECT_FALSE(TimerTasksSeemExpensive()) << " i = " << i; 2957 EXPECT_FALSE(TimerTasksSeemExpensive()) << " i = " << i;
2937 } else { 2958 } else {
2938 EXPECT_TRUE(TimerTasksSeemExpensive()) << " i = " << i; 2959 EXPECT_TRUE(TimerTasksSeemExpensive()) << " i = " << i;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 EXPECT_EQ(0u, web_view_scheduler.interventions().size()); 3175 EXPECT_EQ(0u, web_view_scheduler.interventions().size());
3155 } 3176 }
3156 3177
3157 namespace { 3178 namespace {
3158 void SlowCountingTask(size_t* count, 3179 void SlowCountingTask(size_t* count,
3159 base::SimpleTestTickClock* clock, 3180 base::SimpleTestTickClock* clock,
3160 int task_duration, 3181 int task_duration,
3161 scoped_refptr<base::SingleThreadTaskRunner> timer_queue) { 3182 scoped_refptr<base::SingleThreadTaskRunner> timer_queue) {
3162 clock->Advance(base::TimeDelta::FromMilliseconds(task_duration)); 3183 clock->Advance(base::TimeDelta::FromMilliseconds(task_duration));
3163 if (++(*count) < 500) { 3184 if (++(*count) < 500) {
3164 timer_queue->PostTask(FROM_HERE, base::Bind(SlowCountingTask, count, clock, 3185 timer_queue->PostTask(
3165 task_duration, timer_queue)); 3186 FROM_HERE,
3187 base::Bind(SlowCountingTask, count, clock, task_duration, timer_queue));
3166 } 3188 }
3167 } 3189 }
3168 } 3190 }
3169 3191
3170 TEST_F(RendererSchedulerImplTest, 3192 TEST_F(RendererSchedulerImplTest,
3171 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_expensive) { 3193 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_expensive) {
3172 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); 3194 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
3173 3195
3174 base::TimeTicks first_throttled_run_time = 3196 base::TimeTicks first_throttled_run_time =
3175 TaskQueueThrottler::AlignedThrottledRunTime(clock_->NowTicks()); 3197 TaskQueueThrottler::AlignedThrottledRunTime(clock_->NowTicks());
3176 3198
3177 size_t count = 0; 3199 size_t count = 0;
3178 // With the compositor task taking 10ms, there is not enough time to run this 3200 // With the compositor task taking 10ms, there is not enough time to run this
3179 // 7ms timer task in the 16ms frame. 3201 // 7ms timer task in the 16ms frame.
3180 scheduler_->TimerTaskRunner()->PostTask( 3202 scheduler_->TimerTaskRunner()->PostTask(
3181 FROM_HERE, base::Bind(SlowCountingTask, &count, clock_.get(), 7, 3203 FROM_HERE,
3182 scheduler_->TimerTaskRunner())); 3204 base::Bind(SlowCountingTask, &count, clock_.get(), 7,
3205 scheduler_->TimerTaskRunner()));
3183 3206
3184 for (int i = 0; i < 1000; i++) { 3207 for (int i = 0; i < 1000; i++) {
3185 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( 3208 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
3186 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(), 3209 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(),
3187 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16), 3210 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16),
3188 cc::BeginFrameArgs::NORMAL); 3211 cc::BeginFrameArgs::NORMAL);
3189 begin_frame_args.on_critical_path = true; 3212 begin_frame_args.on_critical_path = true;
3190 scheduler_->WillBeginFrame(begin_frame_args); 3213 scheduler_->WillBeginFrame(begin_frame_args);
3191 scheduler_->DidHandleInputEventOnCompositorThread( 3214 scheduler_->DidHandleInputEventOnCompositorThread(
3192 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate), 3215 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3234 SYNCHRONIZED_GESTURE_TimerTaskThrottling_TimersSuspended) { 3257 SYNCHRONIZED_GESTURE_TimerTaskThrottling_TimersSuspended) {
3235 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); 3258 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
3236 3259
3237 base::TimeTicks first_throttled_run_time = 3260 base::TimeTicks first_throttled_run_time =
3238 TaskQueueThrottler::AlignedThrottledRunTime(clock_->NowTicks()); 3261 TaskQueueThrottler::AlignedThrottledRunTime(clock_->NowTicks());
3239 3262
3240 size_t count = 0; 3263 size_t count = 0;
3241 // With the compositor task taking 10ms, there is not enough time to run this 3264 // With the compositor task taking 10ms, there is not enough time to run this
3242 // 7ms timer task in the 16ms frame. 3265 // 7ms timer task in the 16ms frame.
3243 scheduler_->TimerTaskRunner()->PostTask( 3266 scheduler_->TimerTaskRunner()->PostTask(
3244 FROM_HERE, base::Bind(SlowCountingTask, &count, clock_.get(), 7, 3267 FROM_HERE,
3245 scheduler_->TimerTaskRunner())); 3268 base::Bind(SlowCountingTask, &count, clock_.get(), 7,
3269 scheduler_->TimerTaskRunner()));
3246 3270
3247 bool suspended = false; 3271 bool suspended = false;
3248 for (int i = 0; i < 1000; i++) { 3272 for (int i = 0; i < 1000; i++) {
3249 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( 3273 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
3250 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(), 3274 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(),
3251 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16), 3275 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16),
3252 cc::BeginFrameArgs::NORMAL); 3276 cc::BeginFrameArgs::NORMAL);
3253 begin_frame_args.on_critical_path = true; 3277 begin_frame_args.on_critical_path = true;
3254 scheduler_->WillBeginFrame(begin_frame_args); 3278 scheduler_->WillBeginFrame(begin_frame_args);
3255 scheduler_->DidHandleInputEventOnCompositorThread( 3279 scheduler_->DidHandleInputEventOnCompositorThread(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 } 3317 }
3294 3318
3295 TEST_F(RendererSchedulerImplTest, 3319 TEST_F(RendererSchedulerImplTest,
3296 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_not_expensive) { 3320 SYNCHRONIZED_GESTURE_TimerTaskThrottling_task_not_expensive) {
3297 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); 3321 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
3298 3322
3299 size_t count = 0; 3323 size_t count = 0;
3300 // With the compositor task taking 10ms, there is enough time to run this 6ms 3324 // With the compositor task taking 10ms, there is enough time to run this 6ms
3301 // timer task in the 16ms frame. 3325 // timer task in the 16ms frame.
3302 scheduler_->TimerTaskRunner()->PostTask( 3326 scheduler_->TimerTaskRunner()->PostTask(
3303 FROM_HERE, base::Bind(SlowCountingTask, &count, clock_.get(), 6, 3327 FROM_HERE,
3304 scheduler_->TimerTaskRunner())); 3328 base::Bind(SlowCountingTask, &count, clock_.get(), 6,
3329 scheduler_->TimerTaskRunner()));
3305 3330
3306 for (int i = 0; i < 1000; i++) { 3331 for (int i = 0; i < 1000; i++) {
3307 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( 3332 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
3308 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(), 3333 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(),
3309 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16), 3334 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16),
3310 cc::BeginFrameArgs::NORMAL); 3335 cc::BeginFrameArgs::NORMAL);
3311 begin_frame_args.on_critical_path = true; 3336 begin_frame_args.on_critical_path = true;
3312 scheduler_->WillBeginFrame(begin_frame_args); 3337 scheduler_->WillBeginFrame(begin_frame_args);
3313 scheduler_->DidHandleInputEventOnCompositorThread( 3338 scheduler_->DidHandleInputEventOnCompositorThread(
3314 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate), 3339 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate),
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3602 TEST_F(RendererSchedulerImplTest, UnthrottledTaskRunner) { 3627 TEST_F(RendererSchedulerImplTest, UnthrottledTaskRunner) {
3603 // Ensure neither suspension nor timer task throttling affects an unthrottled 3628 // Ensure neither suspension nor timer task throttling affects an unthrottled
3604 // task runner. 3629 // task runner.
3605 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START); 3630 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
3606 scoped_refptr<TaskQueue> unthrottled_task_runner = 3631 scoped_refptr<TaskQueue> unthrottled_task_runner =
3607 scheduler_->NewUnthrottledTaskRunner(TaskQueue::QueueType::UNTHROTTLED); 3632 scheduler_->NewUnthrottledTaskRunner(TaskQueue::QueueType::UNTHROTTLED);
3608 3633
3609 size_t timer_count = 0; 3634 size_t timer_count = 0;
3610 size_t unthrottled_count = 0; 3635 size_t unthrottled_count = 0;
3611 scheduler_->TimerTaskRunner()->PostTask( 3636 scheduler_->TimerTaskRunner()->PostTask(
3612 FROM_HERE, base::Bind(SlowCountingTask, &timer_count, clock_.get(), 7, 3637 FROM_HERE,
3613 scheduler_->TimerTaskRunner())); 3638 base::Bind(SlowCountingTask, &timer_count, clock_.get(), 7,
3639 scheduler_->TimerTaskRunner()));
3614 unthrottled_task_runner->PostTask( 3640 unthrottled_task_runner->PostTask(
3615 FROM_HERE, base::Bind(SlowCountingTask, &unthrottled_count, clock_.get(), 3641 FROM_HERE,
3616 7, unthrottled_task_runner)); 3642 base::Bind(SlowCountingTask, &unthrottled_count, clock_.get(), 7,
3643 unthrottled_task_runner));
3617 scheduler_->SuspendTimerQueue(); 3644 scheduler_->SuspendTimerQueue();
3618 3645
3619 for (int i = 0; i < 1000; i++) { 3646 for (int i = 0; i < 1000; i++) {
3620 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create( 3647 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
3621 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(), 3648 BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, clock_->NowTicks(),
3622 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16), 3649 base::TimeTicks(), base::TimeDelta::FromMilliseconds(16),
3623 cc::BeginFrameArgs::NORMAL); 3650 cc::BeginFrameArgs::NORMAL);
3624 begin_frame_args.on_critical_path = true; 3651 begin_frame_args.on_critical_path = true;
3625 scheduler_->WillBeginFrame(begin_frame_args); 3652 scheduler_->WillBeginFrame(begin_frame_args);
3626 scheduler_->DidHandleInputEventOnCompositorThread( 3653 scheduler_->DidHandleInputEventOnCompositorThread(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 scheduler_->OnRendererBackgrounded(); 3755 scheduler_->OnRendererBackgrounded();
3729 3756
3730 std::vector<base::TimeTicks> run_times; 3757 std::vector<base::TimeTicks> run_times;
3731 3758
3732 timer_task_runner_->PostTask( 3759 timer_task_runner_->PostTask(
3733 FROM_HERE, base::Bind(&RecordingTimeTestTask, &run_times, clock_.get())); 3760 FROM_HERE, base::Bind(&RecordingTimeTestTask, &run_times, clock_.get()));
3734 3761
3735 mock_task_runner_->RunUntilTime(base::TimeTicks() + 3762 mock_task_runner_->RunUntilTime(base::TimeTicks() +
3736 base::TimeDelta::FromMilliseconds(1100)); 3763 base::TimeDelta::FromMilliseconds(1100));
3737 3764
3738 EXPECT_THAT(run_times, testing::ElementsAre(base::TimeTicks() + 3765 EXPECT_THAT(run_times,
3739 base::TimeDelta::FromSeconds(1))); 3766 testing::ElementsAre(base::TimeTicks() +
3767 base::TimeDelta::FromSeconds(1)));
3740 run_times.clear(); 3768 run_times.clear();
3741 3769
3742 timer_task_runner_->PostDelayedTask( 3770 timer_task_runner_->PostDelayedTask(
3743 FROM_HERE, base::Bind(&RecordingTimeTestTask, &run_times, clock_.get()), 3771 FROM_HERE, base::Bind(&RecordingTimeTestTask, &run_times, clock_.get()),
3744 base::TimeDelta::FromMilliseconds(200)); 3772 base::TimeDelta::FromMilliseconds(200));
3745 3773
3746 scheduler_->OnRendererForegrounded(); 3774 scheduler_->OnRendererForegrounded();
3747 3775
3748 mock_task_runner_->RunUntilTime(base::TimeTicks() + 3776 mock_task_runner_->RunUntilTime(base::TimeTicks() +
3749 base::TimeDelta::FromMilliseconds(1500)); 3777 base::TimeDelta::FromMilliseconds(1500));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3798 EXPECT_TRUE( 3826 EXPECT_TRUE(
3799 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold())); 3827 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold()));
3800 // Once we've dropped the lock, we realize the main thread is responsive. 3828 // Once we've dropped the lock, we realize the main thread is responsive.
3801 DropQueueingTimeEstimatorLock(); 3829 DropQueueingTimeEstimatorLock();
3802 EXPECT_FALSE( 3830 EXPECT_FALSE(
3803 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold())); 3831 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold()));
3804 } 3832 }
3805 3833
3806 } // namespace scheduler 3834 } // namespace scheduler
3807 } // namespace blink 3835 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698