| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/task_scheduler/delayed_task_manager.h" | 5 #include "base/task_scheduler/delayed_task_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 DelayedTaskManager manager(service_thread_task_runner); | 68 DelayedTaskManager manager(service_thread_task_runner); |
| 69 | 69 |
| 70 std::unique_ptr<Task> task( | 70 std::unique_ptr<Task> task( |
| 71 new Task(FROM_HERE, Bind(&DoNothing), TaskTraits(), kLongDelay)); | 71 new Task(FROM_HERE, Bind(&DoNothing), TaskTraits(), kLongDelay)); |
| 72 scoped_refptr<Sequence> sequence(new Sequence); | 72 scoped_refptr<Sequence> sequence(new Sequence); |
| 73 testing::StrictMock<MockSchedulerWorkerPool> worker_pool; | 73 testing::StrictMock<MockSchedulerWorkerPool> worker_pool; |
| 74 | 74 |
| 75 // Send |task| to the DelayedTaskManager. | 75 // Send |task| to the DelayedTaskManager. |
| 76 manager.AddDelayedTask(std::move(task), sequence, nullptr, &worker_pool); | 76 manager.AddDelayedTask(std::move(task), sequence, nullptr, &worker_pool); |
| 77 | 77 |
| 78 // Run tasks that are ripe for execution on the service thread. Don't expect | 78 // Run tasks that are ripe for execution. Don't expect any call to the mock |
| 79 // any call to the mock method of |worker_pool|. | 79 // method of |worker_pool|. |
| 80 service_thread_task_runner->RunUntilIdle(); | 80 service_thread_task_runner->RunUntilIdle(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Verify that a delayed task is forwarded to its SchedulerWorkerPool when it is | 83 // Verify that a delayed task is forwarded to its SchedulerWorkerPool when it is |
| 84 // ripe for execution. | 84 // ripe for execution. |
| 85 TEST(TaskSchedulerDelayedTaskManagerTest, DelayedTaskRunsAfterDelay) { | 85 TEST(TaskSchedulerDelayedTaskManagerTest, DelayedTaskRunsAfterDelay) { |
| 86 scoped_refptr<TestMockTimeTaskRunner> service_thread_task_runner( | 86 scoped_refptr<TestMockTimeTaskRunner> service_thread_task_runner( |
| 87 new TestMockTimeTaskRunner); | 87 new TestMockTimeTaskRunner); |
| 88 DelayedTaskManager manager(service_thread_task_runner); | 88 DelayedTaskManager manager(service_thread_task_runner); |
| 89 | 89 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // Fast-forward time. Expect |task_b_raw| to be forwarded to the worker pool. | 145 // Fast-forward time. Expect |task_b_raw| to be forwarded to the worker pool. |
| 146 EXPECT_CALL(worker_pool, | 146 EXPECT_CALL(worker_pool, |
| 147 PostTaskWithSequenceNowMock(task_b_raw, sequence.get(), nullptr)); | 147 PostTaskWithSequenceNowMock(task_b_raw, sequence.get(), nullptr)); |
| 148 service_thread_task_runner->FastForwardBy(TimeDelta::FromHours(1)); | 148 service_thread_task_runner->FastForwardBy(TimeDelta::FromHours(1)); |
| 149 testing::Mock::VerifyAndClear(&worker_pool); | 149 testing::Mock::VerifyAndClear(&worker_pool); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace internal | 152 } // namespace internal |
| 153 } // namespace base | 153 } // namespace base |
| OLD | NEW |