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

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

Issue 1132753008: Replaced TestNowSource with SimpleTestTickClock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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/child/task_queue_manager.h" 5 #include "components/scheduler/child/task_queue_manager.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/test/simple_test_tick_clock.h"
9 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
10 #include "cc/test/ordered_simple_task_runner.h" 11 #include "cc/test/ordered_simple_task_runner.h"
11 #include "cc/test/test_now_source.h"
12 #include "components/scheduler/child/nestable_task_runner_for_test.h" 12 #include "components/scheduler/child/nestable_task_runner_for_test.h"
13 #include "components/scheduler/child/scheduler_message_loop_delegate.h" 13 #include "components/scheduler/child/scheduler_message_loop_delegate.h"
14 #include "components/scheduler/child/task_queue_selector.h" 14 #include "components/scheduler/child/task_queue_selector.h"
15 #include "components/scheduler/child/test_time_source.h" 15 #include "components/scheduler/child/test_time_source.h"
16 #include "components/scheduler/test/test_always_fail_time_source.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 18
18 using testing::ElementsAre; 19 using testing::ElementsAre;
19 using testing::_; 20 using testing::_;
20 21
21 namespace scheduler { 22 namespace scheduler {
22 namespace { 23 namespace {
23 24
24 class SelectorForTest : public TaskQueueSelector { 25 class SelectorForTest : public TaskQueueSelector {
25 public: 26 public:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 public: 111 public:
111 void DeleteTaskQueueManager() { manager_.reset(); } 112 void DeleteTaskQueueManager() { manager_.reset(); }
112 113
113 protected: 114 protected:
114 enum class SelectorType { 115 enum class SelectorType {
115 Automatic, 116 Automatic,
116 Explicit, 117 Explicit,
117 }; 118 };
118 119
119 void Initialize(size_t num_queues, SelectorType type) { 120 void Initialize(size_t num_queues, SelectorType type) {
120 now_src_ = cc::TestNowSource::Create(1000); 121 now_src_.reset(new base::SimpleTestTickClock());
121 test_task_runner_ = 122 now_src_->Advance(base::TimeDelta::FromMicroseconds(1000));
122 make_scoped_refptr(new cc::OrderedSimpleTaskRunner(now_src_, false)); 123 test_task_runner_ = make_scoped_refptr(
124 new cc::OrderedSimpleTaskRunner(now_src_.get(), false));
123 selector_ = make_scoped_ptr(createSelectorForTest(type)); 125 selector_ = make_scoped_ptr(createSelectorForTest(type));
124 manager_ = make_scoped_ptr(new TaskQueueManager( 126 manager_ = make_scoped_ptr(new TaskQueueManager(
125 num_queues, NestableTaskRunnerForTest::Create(test_task_runner_.get()), 127 num_queues, NestableTaskRunnerForTest::Create(test_task_runner_.get()),
126 selector_.get(), "test.scheduler")); 128 selector_.get(), "test.scheduler"));
127 manager_->SetTimeSourceForTesting( 129 manager_->SetTimeSourceForTesting(
128 make_scoped_ptr(new TestTimeSource(now_src_))); 130 make_scoped_ptr(new TestTimeSource(now_src_.get())));
129 131
130 EXPECT_EQ(num_queues, selector_->work_queues().size()); 132 EXPECT_EQ(num_queues, selector_->work_queues().size());
131 } 133 }
132 134
133 void InitializeWithRealMessageLoop(size_t num_queues, SelectorType type) { 135 void InitializeWithRealMessageLoop(size_t num_queues, SelectorType type) {
134 message_loop_.reset(new base::MessageLoop()); 136 message_loop_.reset(new base::MessageLoop());
135 selector_ = make_scoped_ptr(createSelectorForTest(type)); 137 selector_ = make_scoped_ptr(createSelectorForTest(type));
136 manager_ = make_scoped_ptr(new TaskQueueManager( 138 manager_ = make_scoped_ptr(new TaskQueueManager(
137 num_queues, SchedulerMessageLoopDelegate::Create(message_loop_.get()), 139 num_queues, SchedulerMessageLoopDelegate::Create(message_loop_.get()),
138 selector_.get(), "test.scheduler")); 140 selector_.get(), "test.scheduler"));
(...skipping 29 matching lines...) Expand all
168 &TaskQueueManager::PumpPolicyToString); 170 &TaskQueueManager::PumpPolicyToString);
169 } 171 }
170 172
171 static void CheckAllWakeupPolicyToString() { 173 static void CheckAllWakeupPolicyToString() {
172 CallForEachEnumValue<TaskQueueManager::WakeupPolicy>( 174 CallForEachEnumValue<TaskQueueManager::WakeupPolicy>(
173 TaskQueueManager::WakeupPolicy::FIRST_WAKEUP_POLICY, 175 TaskQueueManager::WakeupPolicy::FIRST_WAKEUP_POLICY,
174 TaskQueueManager::WakeupPolicy::WAKEUP_POLICY_COUNT, 176 TaskQueueManager::WakeupPolicy::WAKEUP_POLICY_COUNT,
175 &TaskQueueManager::WakeupPolicyToString); 177 &TaskQueueManager::WakeupPolicyToString);
176 } 178 }
177 179
178 scoped_refptr<cc::TestNowSource> now_src_; 180 scoped_ptr<base::SimpleTestTickClock> now_src_;
179 scoped_refptr<cc::OrderedSimpleTaskRunner> test_task_runner_; 181 scoped_refptr<cc::OrderedSimpleTaskRunner> test_task_runner_;
180 scoped_ptr<SelectorForTest> selector_; 182 scoped_ptr<SelectorForTest> selector_;
181 scoped_ptr<TaskQueueManager> manager_; 183 scoped_ptr<TaskQueueManager> manager_;
182 scoped_ptr<base::MessageLoop> message_loop_; 184 scoped_ptr<base::MessageLoop> message_loop_;
183 }; 185 };
184 186
185 void PostFromNestedRunloop(base::MessageLoop* message_loop, 187 void PostFromNestedRunloop(base::MessageLoop* message_loop,
186 base::SingleThreadTaskRunner* runner, 188 base::SingleThreadTaskRunner* runner,
187 std::vector<std::pair<base::Closure, bool>>* tasks) { 189 std::vector<std::pair<base::Closure, bool>>* tasks) {
188 base::MessageLoop::ScopedNestableTaskAllower allow(message_loop); 190 base::MessageLoop::ScopedNestableTaskAllower allow(message_loop);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 test_task_runner_->RunUntilIdle(); 246 test_task_runner_->RunUntilIdle();
245 EXPECT_THAT(run_order, ElementsAre(1, 3, 5, 2, 4, 6)); 247 EXPECT_THAT(run_order, ElementsAre(1, 3, 5, 2, 4, 6));
246 } 248 }
247 249
248 void NopTask() { 250 void NopTask() {
249 } 251 }
250 252
251 TEST_F(TaskQueueManagerTest, NowNotCalledWhenThereAreNoDelayedTasks) { 253 TEST_F(TaskQueueManagerTest, NowNotCalledWhenThereAreNoDelayedTasks) {
252 Initialize(3u, SelectorType::Explicit); 254 Initialize(3u, SelectorType::Explicit);
253 255
254 scoped_refptr<cc::TestNowSource> now_src = cc::TestNowSource::Create(1000);
255 manager_->SetTimeSourceForTesting( 256 manager_->SetTimeSourceForTesting(
256 make_scoped_ptr(new TestTimeSource(now_src))); 257 make_scoped_ptr(new TestAlwaysFailTimeSource()));
257 258
258 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = { 259 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = {
259 manager_->TaskRunnerForQueue(0), 260 manager_->TaskRunnerForQueue(0),
260 manager_->TaskRunnerForQueue(1), 261 manager_->TaskRunnerForQueue(1),
261 manager_->TaskRunnerForQueue(2)}; 262 manager_->TaskRunnerForQueue(2)};
262 263
263 selector_->AppendQueueToService(0); 264 selector_->AppendQueueToService(0);
264 selector_->AppendQueueToService(1); 265 selector_->AppendQueueToService(1);
265 selector_->AppendQueueToService(2); 266 selector_->AppendQueueToService(2);
266 selector_->AppendQueueToService(0); 267 selector_->AppendQueueToService(0);
267 selector_->AppendQueueToService(1); 268 selector_->AppendQueueToService(1);
268 selector_->AppendQueueToService(2); 269 selector_->AppendQueueToService(2);
269 270
270 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask)); 271 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
271 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask)); 272 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
272 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask)); 273 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask));
273 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask)); 274 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask));
274 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask)); 275 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask));
275 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask)); 276 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask));
276 277
277 test_task_runner_->RunUntilIdle(); 278 test_task_runner_->RunUntilIdle();
278
279 EXPECT_EQ(0, now_src->NumNowCalls());
280 } 279 }
281 280
282 TEST_F(TaskQueueManagerTest, NonNestableTaskPosting) { 281 TEST_F(TaskQueueManagerTest, NonNestableTaskPosting) {
283 InitializeWithRealMessageLoop(1u, SelectorType::Automatic); 282 InitializeWithRealMessageLoop(1u, SelectorType::Automatic);
284 283
285 std::vector<int> run_order; 284 std::vector<int> run_order;
286 scoped_refptr<base::SingleThreadTaskRunner> runner = 285 scoped_refptr<base::SingleThreadTaskRunner> runner =
287 manager_->TaskRunnerForQueue(0); 286 manager_->TaskRunnerForQueue(0);
288 287
289 runner->PostNonNestableTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order)); 288 runner->PostNonNestableTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order));
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 base::TimeDelta delay(base::TimeDelta::FromMilliseconds(10)); 564 base::TimeDelta delay(base::TimeDelta::FromMilliseconds(10));
566 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order), 565 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order),
567 delay); 566 delay);
568 567
569 // After pumping but before the delay period has expired, task does not run. 568 // After pumping but before the delay period has expired, task does not run.
570 manager_->PumpQueue(0); 569 manager_->PumpQueue(0);
571 test_task_runner_->RunForPeriod(base::TimeDelta::FromMilliseconds(5)); 570 test_task_runner_->RunForPeriod(base::TimeDelta::FromMilliseconds(5));
572 EXPECT_TRUE(run_order.empty()); 571 EXPECT_TRUE(run_order.empty());
573 572
574 // Once the delay has expired, pumping causes the task to run. 573 // Once the delay has expired, pumping causes the task to run.
575 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(5)); 574 now_src_->Advance(base::TimeDelta::FromMilliseconds(5));
576 manager_->PumpQueue(0); 575 manager_->PumpQueue(0);
577 EXPECT_TRUE(test_task_runner_->HasPendingTasks()); 576 EXPECT_TRUE(test_task_runner_->HasPendingTasks());
578 test_task_runner_->RunPendingTasks(); 577 test_task_runner_->RunPendingTasks();
579 EXPECT_THAT(run_order, ElementsAre(1)); 578 EXPECT_THAT(run_order, ElementsAre(1));
580 } 579 }
581 580
582 TEST_F(TaskQueueManagerTest, ManualPumpingWithMultipleDelayedTasks) { 581 TEST_F(TaskQueueManagerTest, ManualPumpingWithMultipleDelayedTasks) {
583 Initialize(1u, SelectorType::Automatic); 582 Initialize(1u, SelectorType::Automatic);
584 manager_->SetPumpPolicy(0, TaskQueueManager::PumpPolicy::MANUAL); 583 manager_->SetPumpPolicy(0, TaskQueueManager::PumpPolicy::MANUAL);
585 584
586 std::vector<int> run_order; 585 std::vector<int> run_order;
587 scoped_refptr<base::SingleThreadTaskRunner> runner = 586 scoped_refptr<base::SingleThreadTaskRunner> runner =
588 manager_->TaskRunnerForQueue(0); 587 manager_->TaskRunnerForQueue(0);
589 588
590 // Posting a delayed task when pumping will apply the delay, but won't cause 589 // Posting a delayed task when pumping will apply the delay, but won't cause
591 // work to executed afterwards. 590 // work to executed afterwards.
592 base::TimeDelta delay1(base::TimeDelta::FromMilliseconds(1)); 591 base::TimeDelta delay1(base::TimeDelta::FromMilliseconds(1));
593 base::TimeDelta delay2(base::TimeDelta::FromMilliseconds(10)); 592 base::TimeDelta delay2(base::TimeDelta::FromMilliseconds(10));
594 base::TimeDelta delay3(base::TimeDelta::FromMilliseconds(20)); 593 base::TimeDelta delay3(base::TimeDelta::FromMilliseconds(20));
595 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order), 594 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order),
596 delay1); 595 delay1);
597 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 2, &run_order), 596 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 2, &run_order),
598 delay2); 597 delay2);
599 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 3, &run_order), 598 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 3, &run_order),
600 delay3); 599 delay3);
601 600
602 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(15)); 601 now_src_->Advance(base::TimeDelta::FromMilliseconds(15));
603 test_task_runner_->RunUntilIdle(); 602 test_task_runner_->RunUntilIdle();
604 EXPECT_TRUE(run_order.empty()); 603 EXPECT_TRUE(run_order.empty());
605 604
606 // Once the delay has expired, pumping causes the task to run. 605 // Once the delay has expired, pumping causes the task to run.
607 manager_->PumpQueue(0); 606 manager_->PumpQueue(0);
608 test_task_runner_->RunUntilIdle(); 607 test_task_runner_->RunUntilIdle();
609 EXPECT_THAT(run_order, ElementsAre(1, 2)); 608 EXPECT_THAT(run_order, ElementsAre(1, 2));
610 } 609 }
611 610
612 TEST_F(TaskQueueManagerTest, DelayedTasksDontAutoRunWithManualPumping) { 611 TEST_F(TaskQueueManagerTest, DelayedTasksDontAutoRunWithManualPumping) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 TEST_F(TaskQueueManagerTest, ThreadCheckAfterTermination) { 1036 TEST_F(TaskQueueManagerTest, ThreadCheckAfterTermination) {
1038 Initialize(1u, SelectorType::Automatic); 1037 Initialize(1u, SelectorType::Automatic);
1039 scoped_refptr<base::SingleThreadTaskRunner> runner = 1038 scoped_refptr<base::SingleThreadTaskRunner> runner =
1040 manager_->TaskRunnerForQueue(0); 1039 manager_->TaskRunnerForQueue(0);
1041 EXPECT_TRUE(runner->RunsTasksOnCurrentThread()); 1040 EXPECT_TRUE(runner->RunsTasksOnCurrentThread());
1042 manager_.reset(); 1041 manager_.reset();
1043 EXPECT_TRUE(runner->RunsTasksOnCurrentThread()); 1042 EXPECT_TRUE(runner->RunsTasksOnCurrentThread());
1044 } 1043 }
1045 1044
1046 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime) { 1045 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime) {
1047 scoped_refptr<cc::TestNowSource> clock(cc::TestNowSource::Create()); 1046 scoped_ptr<base::SimpleTestTickClock> clock(new base::SimpleTestTickClock());
1047 clock->Advance(base::TimeDelta::FromMicroseconds(10000));
1048 Initialize(2u, SelectorType::Explicit); 1048 Initialize(2u, SelectorType::Explicit);
1049 manager_->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock))); 1049 manager_->SetTimeSourceForTesting(
1050 make_scoped_ptr(new TestTimeSource(clock.get())));
1050 1051
1051 scoped_refptr<base::SingleThreadTaskRunner> runners[2] = { 1052 scoped_refptr<base::SingleThreadTaskRunner> runners[2] = {
1052 manager_->TaskRunnerForQueue(0), manager_->TaskRunnerForQueue(1)}; 1053 manager_->TaskRunnerForQueue(0), manager_->TaskRunnerForQueue(1)};
1053 1054
1054 // With no delayed tasks. 1055 // With no delayed tasks.
1055 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null()); 1056 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null());
1056 1057
1057 // With a non-delayed task. 1058 // With a non-delayed task.
1058 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask)); 1059 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
1059 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null()); 1060 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null());
1060 1061
1061 // With a delayed task. 1062 // With a delayed task.
1062 base::TimeDelta expected_delay = base::TimeDelta::FromMilliseconds(50); 1063 base::TimeDelta expected_delay = base::TimeDelta::FromMilliseconds(50);
1063 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay); 1064 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
1064 EXPECT_EQ(clock->Now() + expected_delay, 1065 EXPECT_EQ(clock->NowTicks() + expected_delay,
1065 manager_->NextPendingDelayedTaskRunTime()); 1066 manager_->NextPendingDelayedTaskRunTime());
1066 1067
1067 // With another delayed task in the same queue with a longer delay. 1068 // With another delayed task in the same queue with a longer delay.
1068 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), 1069 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask),
1069 base::TimeDelta::FromMilliseconds(100)); 1070 base::TimeDelta::FromMilliseconds(100));
1070 EXPECT_EQ(clock->Now() + expected_delay, 1071 EXPECT_EQ(clock->NowTicks() + expected_delay,
1071 manager_->NextPendingDelayedTaskRunTime()); 1072 manager_->NextPendingDelayedTaskRunTime());
1072 1073
1073 // With another delayed task in the same queue with a shorter delay. 1074 // With another delayed task in the same queue with a shorter delay.
1074 expected_delay = base::TimeDelta::FromMilliseconds(20); 1075 expected_delay = base::TimeDelta::FromMilliseconds(20);
1075 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay); 1076 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
1076 EXPECT_EQ(clock->Now() + expected_delay, 1077 EXPECT_EQ(clock->NowTicks() + expected_delay,
1077 manager_->NextPendingDelayedTaskRunTime()); 1078 manager_->NextPendingDelayedTaskRunTime());
1078 1079
1079 // With another delayed task in a different queue with a shorter delay. 1080 // With another delayed task in a different queue with a shorter delay.
1080 expected_delay = base::TimeDelta::FromMilliseconds(10); 1081 expected_delay = base::TimeDelta::FromMilliseconds(10);
1081 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay); 1082 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
1082 EXPECT_EQ(clock->Now() + expected_delay, 1083 EXPECT_EQ(clock->NowTicks() + expected_delay,
1083 manager_->NextPendingDelayedTaskRunTime()); 1084 manager_->NextPendingDelayedTaskRunTime());
1084 1085
1085 // Test it updates as time progresses 1086 // Test it updates as time progresses
1086 clock->AdvanceNow(expected_delay); 1087 clock->Advance(expected_delay);
1087 EXPECT_EQ(clock->Now(), manager_->NextPendingDelayedTaskRunTime()); 1088 EXPECT_EQ(clock->NowTicks(), manager_->NextPendingDelayedTaskRunTime());
1088 } 1089 }
1089 1090
1090 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime_MultipleQueues) { 1091 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime_MultipleQueues) {
1091 Initialize(3u, SelectorType::Automatic); 1092 Initialize(3u, SelectorType::Automatic);
1092 1093
1093 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = { 1094 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = {
1094 manager_->TaskRunnerForQueue(0), 1095 manager_->TaskRunnerForQueue(0),
1095 manager_->TaskRunnerForQueue(1), 1096 manager_->TaskRunnerForQueue(1),
1096 manager_->TaskRunnerForQueue(2)}; 1097 manager_->TaskRunnerForQueue(2)};
1097 1098
1098 base::TimeDelta delay1 = base::TimeDelta::FromMilliseconds(50); 1099 base::TimeDelta delay1 = base::TimeDelta::FromMilliseconds(50);
1099 base::TimeDelta delay2 = base::TimeDelta::FromMilliseconds(5); 1100 base::TimeDelta delay2 = base::TimeDelta::FromMilliseconds(5);
1100 base::TimeDelta delay3 = base::TimeDelta::FromMilliseconds(10); 1101 base::TimeDelta delay3 = base::TimeDelta::FromMilliseconds(10);
1101 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay1); 1102 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay1);
1102 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay2); 1103 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay2);
1103 runners[2]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay3); 1104 runners[2]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay3);
1104 1105
1105 EXPECT_EQ(now_src_->Now() + delay2, 1106 EXPECT_EQ(now_src_->NowTicks() + delay2,
1106 manager_->NextPendingDelayedTaskRunTime()); 1107 manager_->NextPendingDelayedTaskRunTime());
1107 } 1108 }
1108 1109
1109 TEST_F(TaskQueueManagerTest, DeleteTaskQueueManagerInsideATask) { 1110 TEST_F(TaskQueueManagerTest, DeleteTaskQueueManagerInsideATask) {
1110 Initialize(1u, SelectorType::Automatic); 1111 Initialize(1u, SelectorType::Automatic);
1111 1112
1112 scoped_refptr<base::SingleThreadTaskRunner> runner = 1113 scoped_refptr<base::SingleThreadTaskRunner> runner =
1113 manager_->TaskRunnerForQueue(0); 1114 manager_->TaskRunnerForQueue(0);
1114 runner->PostTask(FROM_HERE, 1115 runner->PostTask(FROM_HERE,
1115 base::Bind(&TaskQueueManagerTest::DeleteTaskQueueManager, 1116 base::Bind(&TaskQueueManagerTest::DeleteTaskQueueManager,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 manager_->GetQueueState(1)); 1236 manager_->GetQueueState(1));
1236 1237
1237 test_task_runner_->RunUntilIdle(); 1238 test_task_runner_->RunUntilIdle();
1238 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, 1239 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY,
1239 manager_->GetQueueState(0)); 1240 manager_->GetQueueState(0));
1240 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, 1241 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY,
1241 manager_->GetQueueState(1)); 1242 manager_->GetQueueState(1));
1242 } 1243 }
1243 1244
1244 } // namespace scheduler 1245 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/child/scheduler_helper_unittest.cc ('k') | components/scheduler/child/test_time_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698