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

Side by Side Diff: components/scheduler/child/idle_helper_unittest.cc

Issue 1461143003: Revert of Adds TimeDomains to the TaskQueueManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/child/idle_helper.h" 5 #include "components/scheduler/child/idle_helper.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "cc/test/ordered_simple_task_runner.h" 9 #include "cc/test/ordered_simple_task_runner.h"
10 #include "components/scheduler/base/real_time_domain.h"
11 #include "components/scheduler/base/task_queue.h" 10 #include "components/scheduler/base/task_queue.h"
12 #include "components/scheduler/base/task_queue_manager.h" 11 #include "components/scheduler/base/task_queue_manager.h"
13 #include "components/scheduler/base/test_time_source.h" 12 #include "components/scheduler/base/test_time_source.h"
14 #include "components/scheduler/child/scheduler_helper.h" 13 #include "components/scheduler/child/scheduler_helper.h"
15 #include "components/scheduler/child/scheduler_tqm_delegate_for_test.h" 14 #include "components/scheduler/child/scheduler_tqm_delegate_for_test.h"
16 #include "components/scheduler/child/scheduler_tqm_delegate_impl.h" 15 #include "components/scheduler/child/scheduler_tqm_delegate_impl.h"
17 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 using testing::_; 19 using testing::_;
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 837
839 TEST_F(IdleHelperTest, TestLongIdlePeriodPaused) { 838 TEST_F(IdleHelperTest, TestLongIdlePeriodPaused) {
840 mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true); 839 mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
841 std::vector<base::TimeTicks> actual_deadlines; 840 std::vector<base::TimeTicks> actual_deadlines;
842 int run_count = 0; 841 int run_count = 0;
843 842
844 // If there are no idle tasks posted we should start in the paused state. 843 // If there are no idle tasks posted we should start in the paused state.
845 idle_helper_->EnableLongIdlePeriod(); 844 idle_helper_->EnableLongIdlePeriod();
846 CheckIdlePeriodStateIs("in_long_idle_period_paused"); 845 CheckIdlePeriodStateIs("in_long_idle_period_paused");
847 // There shouldn't be any delayed tasks posted by the idle helper when paused. 846 // There shouldn't be any delayed tasks posted by the idle helper when paused.
848 base::TimeTicks next_pending_delayed_task; 847 EXPECT_EQ(base::TimeTicks(),
849 EXPECT_FALSE(scheduler_helper_->real_time_domain()->NextScheduledRunTime( 848 scheduler_helper_->NextPendingDelayedTaskRunTime());
850 &next_pending_delayed_task));
851 849
852 // Posting a task should transition us to the an active state. 850 // Posting a task should transition us to the an active state.
853 max_idle_task_reposts = 2; 851 max_idle_task_reposts = 2;
854 base::TimeTicks clock_before(clock_->NowTicks()); 852 base::TimeTicks clock_before(clock_->NowTicks());
855 base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10)); 853 base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10));
856 idle_task_runner_->PostIdleTask( 854 idle_task_runner_->PostIdleTask(
857 FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask, 855 FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask,
858 idle_task_runner_, &run_count, clock_.get(), 856 idle_task_runner_, &run_count, clock_.get(),
859 idle_task_runtime, &actual_deadlines)); 857 idle_task_runtime, &actual_deadlines));
860 RunUntilIdle(); 858 RunUntilIdle();
861 EXPECT_EQ(2, run_count); 859 EXPECT_EQ(2, run_count);
862 EXPECT_THAT( 860 EXPECT_THAT(
863 actual_deadlines, 861 actual_deadlines,
864 testing::ElementsAre( 862 testing::ElementsAre(
865 clock_before + maximum_idle_period_duration(), 863 clock_before + maximum_idle_period_duration(),
866 clock_before + idle_task_runtime + maximum_idle_period_duration())); 864 clock_before + idle_task_runtime + maximum_idle_period_duration()));
867 865
868 // Once all task have been run we should go back to the paused state. 866 // Once all task have been run we should go back to the paused state.
869 CheckIdlePeriodStateIs("in_long_idle_period_paused"); 867 CheckIdlePeriodStateIs("in_long_idle_period_paused");
870 EXPECT_FALSE(scheduler_helper_->real_time_domain()->NextScheduledRunTime( 868 EXPECT_EQ(base::TimeTicks(),
871 &next_pending_delayed_task)); 869 scheduler_helper_->NextPendingDelayedTaskRunTime());
872 870
873 idle_helper_->EndIdlePeriod(); 871 idle_helper_->EndIdlePeriod();
874 CheckIdlePeriodStateIs("not_in_idle_period"); 872 CheckIdlePeriodStateIs("not_in_idle_period");
875 } 873 }
876 874
877 TEST_F(IdleHelperTest, TestLongIdlePeriodWhenShutdown) { 875 TEST_F(IdleHelperTest, TestLongIdlePeriodWhenShutdown) {
878 base::TimeTicks deadline_in_task; 876 base::TimeTicks deadline_in_task;
879 int run_count = 0; 877 int run_count = 0;
880 878
881 idle_task_runner_->PostIdleTask( 879 idle_task_runner_->PostIdleTask(
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 EXPECT_EQ(0, run_count); 1136 EXPECT_EQ(0, run_count);
1139 1137
1140 default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask), 1138 default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
1141 more_than_min_deadline_duration); 1139 more_than_min_deadline_duration);
1142 idle_helper_->EnableLongIdlePeriod(); 1140 idle_helper_->EnableLongIdlePeriod();
1143 RunUntilIdle(); 1141 RunUntilIdle();
1144 EXPECT_EQ(1, run_count); 1142 EXPECT_EQ(1, run_count);
1145 } 1143 }
1146 1144
1147 } // namespace scheduler 1145 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/child/idle_helper.cc ('k') | components/scheduler/child/scheduler_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698