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

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

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

Powered by Google App Engine
This is Rietveld 408576698