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

Side by Side Diff: base/task_scheduler/delayed_task_manager_unittest.cc

Issue 2464963002: TaskScheduler: Remove base::ExecutionMode. (Closed)
Patch Set: self-review Created 4 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 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"
11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/sequenced_task_runner.h"
13 #include "base/single_thread_task_runner.h"
gab 2016/10/31 19:10:11 Was previously missing task_runner.h
fdoray 2016/10/31 19:44:51 Done.
13 #include "base/task_scheduler/scheduler_worker_pool.h" 14 #include "base/task_scheduler/scheduler_worker_pool.h"
14 #include "base/task_scheduler/sequence.h" 15 #include "base/task_scheduler/sequence.h"
15 #include "base/task_scheduler/task.h" 16 #include "base/task_scheduler/task.h"
16 #include "base/test/test_mock_time_task_runner.h" 17 #include "base/test/test_mock_time_task_runner.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace base { 22 namespace base {
22 namespace internal { 23 namespace internal {
23 namespace { 24 namespace {
24 25
25 constexpr TimeDelta kLongDelay = TimeDelta::FromHours(1); 26 constexpr TimeDelta kLongDelay = TimeDelta::FromHours(1);
26 27
27 class MockSchedulerWorkerPool : public SchedulerWorkerPool { 28 class MockSchedulerWorkerPool : public SchedulerWorkerPool {
28 public: 29 public:
29 // SchedulerWorkerPool: 30 // SchedulerWorkerPool:
30 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( 31 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
31 const TaskTraits& traits, 32 const TaskTraits& traits) override {
32 ExecutionMode execution_mode) override { 33 ADD_FAILURE() << "Call to unimplemented method.";
33 NOTREACHED(); 34 return nullptr;
35 }
36
37 scoped_refptr<SequencedTaskRunner> CreateSequencedTaskRunnerWithTraits(
38 const TaskTraits& traits) override {
39 ADD_FAILURE() << "Call to unimplemented method.";
40 return nullptr;
41 }
42
43 scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits(
44 const TaskTraits& traits) override {
45 ADD_FAILURE() << "Call to unimplemented method.";
34 return nullptr; 46 return nullptr;
35 } 47 }
36 48
37 void ReEnqueueSequence(scoped_refptr<Sequence> sequence, 49 void ReEnqueueSequence(scoped_refptr<Sequence> sequence,
38 const SequenceSortKey& sequence_sort_key) override { 50 const SequenceSortKey& sequence_sort_key) override {
39 NOTREACHED(); 51 ADD_FAILURE() << "Call to unimplemented method.";
40 } 52 }
41 53
42 bool PostTaskWithSequence(std::unique_ptr<Task> task, 54 bool PostTaskWithSequence(std::unique_ptr<Task> task,
43 scoped_refptr<Sequence> sequence, 55 scoped_refptr<Sequence> sequence,
44 SchedulerWorker* worker) override { 56 SchedulerWorker* worker) override {
45 NOTREACHED(); 57 ADD_FAILURE() << "Call to unimplemented method.";
46 return true; 58 return true;
47 } 59 }
48 60
49 void PostTaskWithSequenceNow(std::unique_ptr<Task> task, 61 void PostTaskWithSequenceNow(std::unique_ptr<Task> task,
50 scoped_refptr<Sequence> sequence, 62 scoped_refptr<Sequence> sequence,
51 SchedulerWorker* worker) override { 63 SchedulerWorker* worker) override {
52 PostTaskWithSequenceNowMock(task.get(), sequence.get(), worker); 64 PostTaskWithSequenceNowMock(task.get(), sequence.get(), worker);
53 } 65 }
54 66
55 MOCK_METHOD3(PostTaskWithSequenceNowMock, 67 MOCK_METHOD3(PostTaskWithSequenceNowMock,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 156
145 // Fast-forward time. Expect |task_b_raw| to be forwarded to the worker pool. 157 // Fast-forward time. Expect |task_b_raw| to be forwarded to the worker pool.
146 EXPECT_CALL(worker_pool, 158 EXPECT_CALL(worker_pool,
147 PostTaskWithSequenceNowMock(task_b_raw, sequence.get(), nullptr)); 159 PostTaskWithSequenceNowMock(task_b_raw, sequence.get(), nullptr));
148 service_thread_task_runner->FastForwardBy(TimeDelta::FromHours(1)); 160 service_thread_task_runner->FastForwardBy(TimeDelta::FromHours(1));
149 testing::Mock::VerifyAndClear(&worker_pool); 161 testing::Mock::VerifyAndClear(&worker_pool);
150 } 162 }
151 163
152 } // namespace internal 164 } // namespace internal
153 } // namespace base 165 } // namespace base
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/task_scheduler/post_task.h » ('j') | base/task_scheduler/post_task.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698