• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
6 #define MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
7 
8 #include <map>
9 
10 #include "base/basictypes.h"
11 #include "base/task_runner.h"
12 #include "base/test/simple_test_tick_clock.h"
13 #include "base/test/test_pending_task.h"
14 
15 namespace media {
16 namespace cast {
17 namespace test {
18 
19 typedef base::TestPendingTask PostedTask;
20 
21 class FakeTaskRunner : public base::TaskRunner {
22  public:
23   explicit FakeTaskRunner(base::SimpleTestTickClock* clock);
24 
25   void RunTasks();
26 
27   // base::TaskRunner implementation.
28   virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
29                                const base::Closure& task,
30                                base::TimeDelta delay) OVERRIDE;
31 
32   virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
33 
34  protected:
35   virtual ~FakeTaskRunner();
36 
37  private:
38   base::SimpleTestTickClock* const clock_;
39   std::multimap<base::TimeTicks, PostedTask> tasks_;
40 
41   DISALLOW_COPY_AND_ASSIGN(FakeTaskRunner);
42 };
43 
44 }  // namespace test
45 }  // namespace cast
46 }  // namespace media
47 
48 #endif  // MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
49