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

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 again. Replaces TimeSource with TickClock in TestAlwaysFailTimeSource 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::FromInternalValue(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); 256 scoped_ptr<base::SimpleTestTickClock> now_src(
257 new base::SimpleTestTickClock());
258 now_src->Advance(base::TimeDelta::FromInternalValue(1000));
255 manager_->SetTimeSourceForTesting( 259 manager_->SetTimeSourceForTesting(
256 make_scoped_ptr(new TestTimeSource(now_src))); 260 make_scoped_ptr(new TestAlwaysFailTimeSource(now_src.get())));
257 261
258 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = { 262 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = {
259 manager_->TaskRunnerForQueue(0), 263 manager_->TaskRunnerForQueue(0),
260 manager_->TaskRunnerForQueue(1), 264 manager_->TaskRunnerForQueue(1),
261 manager_->TaskRunnerForQueue(2)}; 265 manager_->TaskRunnerForQueue(2)};
262 266
263 selector_->AppendQueueToService(0); 267 selector_->AppendQueueToService(0);
264 selector_->AppendQueueToService(1); 268 selector_->AppendQueueToService(1);
265 selector_->AppendQueueToService(2); 269 selector_->AppendQueueToService(2);
266 selector_->AppendQueueToService(0); 270 selector_->AppendQueueToService(0);
267 selector_->AppendQueueToService(1); 271 selector_->AppendQueueToService(1);
268 selector_->AppendQueueToService(2); 272 selector_->AppendQueueToService(2);
269 273
270 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask)); 274 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
271 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask)); 275 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
272 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask)); 276 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask));
273 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask)); 277 runners[1]->PostTask(FROM_HERE, base::Bind(&NopTask));
274 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask)); 278 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask));
275 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask)); 279 runners[2]->PostTask(FROM_HERE, base::Bind(&NopTask));
276 280
277 test_task_runner_->RunUntilIdle(); 281 test_task_runner_->RunUntilIdle();
278
279 EXPECT_EQ(0, now_src->NumNowCalls());
280 } 282 }
281 283
282 TEST_F(TaskQueueManagerTest, NonNestableTaskPosting) { 284 TEST_F(TaskQueueManagerTest, NonNestableTaskPosting) {
283 InitializeWithRealMessageLoop(1u, SelectorType::Automatic); 285 InitializeWithRealMessageLoop(1u, SelectorType::Automatic);
284 286
285 std::vector<int> run_order; 287 std::vector<int> run_order;
286 scoped_refptr<base::SingleThreadTaskRunner> runner = 288 scoped_refptr<base::SingleThreadTaskRunner> runner =
287 manager_->TaskRunnerForQueue(0); 289 manager_->TaskRunnerForQueue(0);
288 290
289 runner->PostNonNestableTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order)); 291 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)); 567 base::TimeDelta delay(base::TimeDelta::FromMilliseconds(10));
566 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order), 568 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order),
567 delay); 569 delay);
568 570
569 // After pumping but before the delay period has expired, task does not run. 571 // After pumping but before the delay period has expired, task does not run.
570 manager_->PumpQueue(0); 572 manager_->PumpQueue(0);
571 test_task_runner_->RunForPeriod(base::TimeDelta::FromMilliseconds(5)); 573 test_task_runner_->RunForPeriod(base::TimeDelta::FromMilliseconds(5));
572 EXPECT_TRUE(run_order.empty()); 574 EXPECT_TRUE(run_order.empty());
573 575
574 // Once the delay has expired, pumping causes the task to run. 576 // Once the delay has expired, pumping causes the task to run.
575 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(5)); 577 now_src_->Advance(base::TimeDelta::FromMilliseconds(5));
576 manager_->PumpQueue(0); 578 manager_->PumpQueue(0);
577 EXPECT_TRUE(test_task_runner_->HasPendingTasks()); 579 EXPECT_TRUE(test_task_runner_->HasPendingTasks());
578 test_task_runner_->RunPendingTasks(); 580 test_task_runner_->RunPendingTasks();
579 EXPECT_THAT(run_order, ElementsAre(1)); 581 EXPECT_THAT(run_order, ElementsAre(1));
580 } 582 }
581 583
582 TEST_F(TaskQueueManagerTest, ManualPumpingWithMultipleDelayedTasks) { 584 TEST_F(TaskQueueManagerTest, ManualPumpingWithMultipleDelayedTasks) {
583 Initialize(1u, SelectorType::Automatic); 585 Initialize(1u, SelectorType::Automatic);
584 manager_->SetPumpPolicy(0, TaskQueueManager::PumpPolicy::MANUAL); 586 manager_->SetPumpPolicy(0, TaskQueueManager::PumpPolicy::MANUAL);
585 587
586 std::vector<int> run_order; 588 std::vector<int> run_order;
587 scoped_refptr<base::SingleThreadTaskRunner> runner = 589 scoped_refptr<base::SingleThreadTaskRunner> runner =
588 manager_->TaskRunnerForQueue(0); 590 manager_->TaskRunnerForQueue(0);
589 591
590 // Posting a delayed task when pumping will apply the delay, but won't cause 592 // Posting a delayed task when pumping will apply the delay, but won't cause
591 // work to executed afterwards. 593 // work to executed afterwards.
592 base::TimeDelta delay1(base::TimeDelta::FromMilliseconds(1)); 594 base::TimeDelta delay1(base::TimeDelta::FromMilliseconds(1));
593 base::TimeDelta delay2(base::TimeDelta::FromMilliseconds(10)); 595 base::TimeDelta delay2(base::TimeDelta::FromMilliseconds(10));
594 base::TimeDelta delay3(base::TimeDelta::FromMilliseconds(20)); 596 base::TimeDelta delay3(base::TimeDelta::FromMilliseconds(20));
595 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order), 597 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order),
596 delay1); 598 delay1);
597 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 2, &run_order), 599 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 2, &run_order),
598 delay2); 600 delay2);
599 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 3, &run_order), 601 runner->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 3, &run_order),
600 delay3); 602 delay3);
601 603
602 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(15)); 604 now_src_->Advance(base::TimeDelta::FromMilliseconds(15));
603 test_task_runner_->RunUntilIdle(); 605 test_task_runner_->RunUntilIdle();
604 EXPECT_TRUE(run_order.empty()); 606 EXPECT_TRUE(run_order.empty());
605 607
606 // Once the delay has expired, pumping causes the task to run. 608 // Once the delay has expired, pumping causes the task to run.
607 manager_->PumpQueue(0); 609 manager_->PumpQueue(0);
608 test_task_runner_->RunUntilIdle(); 610 test_task_runner_->RunUntilIdle();
609 EXPECT_THAT(run_order, ElementsAre(1, 2)); 611 EXPECT_THAT(run_order, ElementsAre(1, 2));
610 } 612 }
611 613
612 TEST_F(TaskQueueManagerTest, DelayedTasksDontAutoRunWithManualPumping) { 614 TEST_F(TaskQueueManagerTest, DelayedTasksDontAutoRunWithManualPumping) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 TEST_F(TaskQueueManagerTest, ThreadCheckAfterTermination) { 1039 TEST_F(TaskQueueManagerTest, ThreadCheckAfterTermination) {
1038 Initialize(1u, SelectorType::Automatic); 1040 Initialize(1u, SelectorType::Automatic);
1039 scoped_refptr<base::SingleThreadTaskRunner> runner = 1041 scoped_refptr<base::SingleThreadTaskRunner> runner =
1040 manager_->TaskRunnerForQueue(0); 1042 manager_->TaskRunnerForQueue(0);
1041 EXPECT_TRUE(runner->RunsTasksOnCurrentThread()); 1043 EXPECT_TRUE(runner->RunsTasksOnCurrentThread());
1042 manager_.reset(); 1044 manager_.reset();
1043 EXPECT_TRUE(runner->RunsTasksOnCurrentThread()); 1045 EXPECT_TRUE(runner->RunsTasksOnCurrentThread());
1044 } 1046 }
1045 1047
1046 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime) { 1048 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime) {
1047 scoped_refptr<cc::TestNowSource> clock(cc::TestNowSource::Create()); 1049 scoped_ptr<base::SimpleTestTickClock> clock(new base::SimpleTestTickClock());
1050 clock->Advance(base::TimeDelta::FromInternalValue(10000));
1048 Initialize(2u, SelectorType::Explicit); 1051 Initialize(2u, SelectorType::Explicit);
1049 manager_->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock))); 1052 manager_->SetTimeSourceForTesting(
1053 make_scoped_ptr(new TestTimeSource(clock.get())));
1050 1054
1051 scoped_refptr<base::SingleThreadTaskRunner> runners[2] = { 1055 scoped_refptr<base::SingleThreadTaskRunner> runners[2] = {
1052 manager_->TaskRunnerForQueue(0), manager_->TaskRunnerForQueue(1)}; 1056 manager_->TaskRunnerForQueue(0), manager_->TaskRunnerForQueue(1)};
1053 1057
1054 // With no delayed tasks. 1058 // With no delayed tasks.
1055 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null()); 1059 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null());
1056 1060
1057 // With a non-delayed task. 1061 // With a non-delayed task.
1058 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask)); 1062 runners[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
1059 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null()); 1063 EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null());
1060 1064
1061 // With a delayed task. 1065 // With a delayed task.
1062 base::TimeDelta expected_delay = base::TimeDelta::FromMilliseconds(50); 1066 base::TimeDelta expected_delay = base::TimeDelta::FromMilliseconds(50);
1063 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay); 1067 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
1064 EXPECT_EQ(clock->Now() + expected_delay, 1068 EXPECT_EQ(clock->NowTicks() + expected_delay,
1065 manager_->NextPendingDelayedTaskRunTime()); 1069 manager_->NextPendingDelayedTaskRunTime());
1066 1070
1067 // With another delayed task in the same queue with a longer delay. 1071 // With another delayed task in the same queue with a longer delay.
1068 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), 1072 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask),
1069 base::TimeDelta::FromMilliseconds(100)); 1073 base::TimeDelta::FromMilliseconds(100));
1070 EXPECT_EQ(clock->Now() + expected_delay, 1074 EXPECT_EQ(clock->NowTicks() + expected_delay,
1071 manager_->NextPendingDelayedTaskRunTime()); 1075 manager_->NextPendingDelayedTaskRunTime());
1072 1076
1073 // With another delayed task in the same queue with a shorter delay. 1077 // With another delayed task in the same queue with a shorter delay.
1074 expected_delay = base::TimeDelta::FromMilliseconds(20); 1078 expected_delay = base::TimeDelta::FromMilliseconds(20);
1075 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay); 1079 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
1076 EXPECT_EQ(clock->Now() + expected_delay, 1080 EXPECT_EQ(clock->NowTicks() + expected_delay,
1077 manager_->NextPendingDelayedTaskRunTime()); 1081 manager_->NextPendingDelayedTaskRunTime());
1078 1082
1079 // With another delayed task in a different queue with a shorter delay. 1083 // With another delayed task in a different queue with a shorter delay.
1080 expected_delay = base::TimeDelta::FromMilliseconds(10); 1084 expected_delay = base::TimeDelta::FromMilliseconds(10);
1081 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay); 1085 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
1082 EXPECT_EQ(clock->Now() + expected_delay, 1086 EXPECT_EQ(clock->NowTicks() + expected_delay,
1083 manager_->NextPendingDelayedTaskRunTime()); 1087 manager_->NextPendingDelayedTaskRunTime());
1084 1088
1085 // Test it updates as time progresses 1089 // Test it updates as time progresses
1086 clock->AdvanceNow(expected_delay); 1090 clock->Advance(expected_delay);
1087 EXPECT_EQ(clock->Now(), manager_->NextPendingDelayedTaskRunTime()); 1091 EXPECT_EQ(clock->NowTicks(), manager_->NextPendingDelayedTaskRunTime());
1088 } 1092 }
1089 1093
1090 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime_MultipleQueues) { 1094 TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime_MultipleQueues) {
1091 Initialize(3u, SelectorType::Automatic); 1095 Initialize(3u, SelectorType::Automatic);
1092 1096
1093 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = { 1097 scoped_refptr<base::SingleThreadTaskRunner> runners[3] = {
1094 manager_->TaskRunnerForQueue(0), 1098 manager_->TaskRunnerForQueue(0),
1095 manager_->TaskRunnerForQueue(1), 1099 manager_->TaskRunnerForQueue(1),
1096 manager_->TaskRunnerForQueue(2)}; 1100 manager_->TaskRunnerForQueue(2)};
1097 1101
1098 base::TimeDelta delay1 = base::TimeDelta::FromMilliseconds(50); 1102 base::TimeDelta delay1 = base::TimeDelta::FromMilliseconds(50);
1099 base::TimeDelta delay2 = base::TimeDelta::FromMilliseconds(5); 1103 base::TimeDelta delay2 = base::TimeDelta::FromMilliseconds(5);
1100 base::TimeDelta delay3 = base::TimeDelta::FromMilliseconds(10); 1104 base::TimeDelta delay3 = base::TimeDelta::FromMilliseconds(10);
1101 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay1); 1105 runners[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay1);
1102 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay2); 1106 runners[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay2);
1103 runners[2]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay3); 1107 runners[2]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay3);
1104 1108
1105 EXPECT_EQ(now_src_->Now() + delay2, 1109 EXPECT_EQ(now_src_->NowTicks() + delay2,
1106 manager_->NextPendingDelayedTaskRunTime()); 1110 manager_->NextPendingDelayedTaskRunTime());
1107 } 1111 }
1108 1112
1109 TEST_F(TaskQueueManagerTest, DeleteTaskQueueManagerInsideATask) { 1113 TEST_F(TaskQueueManagerTest, DeleteTaskQueueManagerInsideATask) {
1110 Initialize(1u, SelectorType::Automatic); 1114 Initialize(1u, SelectorType::Automatic);
1111 1115
1112 scoped_refptr<base::SingleThreadTaskRunner> runner = 1116 scoped_refptr<base::SingleThreadTaskRunner> runner =
1113 manager_->TaskRunnerForQueue(0); 1117 manager_->TaskRunnerForQueue(0);
1114 runner->PostTask(FROM_HERE, 1118 runner->PostTask(FROM_HERE,
1115 base::Bind(&TaskQueueManagerTest::DeleteTaskQueueManager, 1119 base::Bind(&TaskQueueManagerTest::DeleteTaskQueueManager,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 manager_->GetQueueState(1)); 1239 manager_->GetQueueState(1));
1236 1240
1237 test_task_runner_->RunUntilIdle(); 1241 test_task_runner_->RunUntilIdle();
1238 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, 1242 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY,
1239 manager_->GetQueueState(0)); 1243 manager_->GetQueueState(0));
1240 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, 1244 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY,
1241 manager_->GetQueueState(1)); 1245 manager_->GetQueueState(1));
1242 } 1246 }
1243 1247
1244 } // namespace scheduler 1248 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698