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

Side by Side Diff: base/test/test_mock_time_task_runner.h

Issue 2494943005: [ash-md] Added a delay between system menu default/detailed view transitions. (Closed)
Patch Set: Addressed review comments. 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 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 160
159 // The ordinal to use for the next task. Must only be accessed while the 161 // The ordinal to use for the next task. Must only be accessed while the
160 // |tasks_lock_| is held. 162 // |tasks_lock_| is held.
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
170 // A scoped wrapper around TestMockTimeTaskRunner that replaces message loop's
171 // task runner with a TestMockTimeTaskRunner and resets it back at the end of
172 // the scope.
173 class ScopedMockTaskRunnerWrapper {
danakj 2016/11/15 21:56:37 This moved to another file right? Why's it here to
bruthig 2016/11/15 22:00:52 Just to make sure my reviewers are on the ball. Ku
174 public:
175 ScopedMockTaskRunnerWrapper();
176 virtual ~ScopedMockTaskRunnerWrapper();
177
178 base::TestMockTimeTaskRunner* task_runner() { return task_runner_.get(); }
179
180 private:
181 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
182 scoped_refptr<base::SingleThreadTaskRunner> previous_task_runner_;
183
184 DISALLOW_COPY_AND_ASSIGN(ScopedMockTaskRunnerWrapper);
185 };
186
168 } // namespace base 187 } // namespace base
169 188
170 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_ 189 #endif // BASE_TEST_TEST_MOCK_TIME_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698