OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 5 #ifndef BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 6 #define BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <deque> |
10 #include <memory> | 11 #include <memory> |
11 #include <queue> | 12 #include <queue> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "base/test/test_pending_task.h" | 18 #include "base/test/test_pending_task.h" |
18 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 TimeTicks NowTicks() const; | 77 TimeTicks NowTicks() const; |
77 | 78 |
78 // Returns a Clock that uses the virtual time of |this| as its time source. | 79 // Returns a Clock that uses the virtual time of |this| as its time source. |
79 // The returned Clock will hold a reference to |this|. | 80 // The returned Clock will hold a reference to |this|. |
80 std::unique_ptr<Clock> GetMockClock() const; | 81 std::unique_ptr<Clock> GetMockClock() const; |
81 | 82 |
82 // Returns a TickClock that uses the virtual time ticks of |this| as its tick | 83 // Returns a TickClock that uses the virtual time ticks of |this| as its tick |
83 // source. The returned TickClock will hold a reference to |this|. | 84 // source. The returned TickClock will hold a reference to |this|. |
84 std::unique_ptr<TickClock> GetMockTickClock() const; | 85 std::unique_ptr<TickClock> GetMockTickClock() const; |
85 | 86 |
| 87 std::deque<TestPendingTask> TakePendingTasks(); |
86 bool HasPendingTask() const; | 88 bool HasPendingTask() const; |
87 size_t GetPendingTaskCount() const; | 89 size_t GetPendingTaskCount() const; |
88 TimeDelta NextPendingTaskDelay() const; | 90 TimeDelta NextPendingTaskDelay() const; |
89 | 91 |
90 // SingleThreadTaskRunner: | 92 // SingleThreadTaskRunner: |
91 bool RunsTasksOnCurrentThread() const override; | 93 bool RunsTasksOnCurrentThread() const override; |
92 bool PostDelayedTask(const tracked_objects::Location& from_here, | 94 bool PostDelayedTask(const tracked_objects::Location& from_here, |
93 const Closure& task, | 95 const Closure& task, |
94 TimeDelta delay) override; | 96 TimeDelta delay) override; |
95 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, | 97 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 size_t next_task_ordinal_; | 163 size_t next_task_ordinal_; |
162 | 164 |
163 Lock tasks_lock_; | 165 Lock tasks_lock_; |
164 | 166 |
165 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); | 167 DISALLOW_COPY_AND_ASSIGN(TestMockTimeTaskRunner); |
166 }; | 168 }; |
167 | 169 |
168 } // namespace base | 170 } // namespace base |
169 | 171 |
170 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ | 172 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ |
OLD | NEW |