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

Side by Side Diff: media/cast/test/fake_single_thread_task_runner.h

Issue 289083002: Cast: Add tests for clocks being slow/fast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 7 months 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 | « media/cast/test/end2end_unittest.cc ('k') | media/cast/test/fake_single_thread_task_runner.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ 5 #ifndef MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
6 #define MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ 6 #define MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/test/simple_test_tick_clock.h" 12 #include "base/test/simple_test_tick_clock.h"
13 #include "base/test/test_pending_task.h" 13 #include "base/test/test_pending_task.h"
14 14
15 namespace media { 15 namespace media {
16 namespace cast { 16 namespace cast {
17 namespace test { 17 namespace test {
18 18
19 typedef base::TestPendingTask PostedTask; 19 typedef base::TestPendingTask PostedTask;
20 20
21 class FakeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { 21 class FakeSingleThreadTaskRunner : public base::SingleThreadTaskRunner {
22 public: 22 public:
23 explicit FakeSingleThreadTaskRunner(base::SimpleTestTickClock* clock); 23 explicit FakeSingleThreadTaskRunner(base::SimpleTestTickClock* clock);
24 24
25 void RunTasks(); 25 void RunTasks();
26 26
27 // Note: Advances |clock_|.
28 void Sleep(base::TimeDelta t);
29
27 // base::SingleThreadTaskRunner implementation. 30 // base::SingleThreadTaskRunner implementation.
28 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, 31 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
29 const base::Closure& task, 32 const base::Closure& task,
30 base::TimeDelta delay) OVERRIDE; 33 base::TimeDelta delay) OVERRIDE;
31 34
32 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; 35 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
33 36
34 // This function is currently not used, and will return false. 37 // This function is currently not used, and will return false.
35 virtual bool PostNonNestableDelayedTask( 38 virtual bool PostNonNestableDelayedTask(
36 const tracked_objects::Location& from_here, 39 const tracked_objects::Location& from_here,
37 const base::Closure& task, 40 const base::Closure& task,
38 base::TimeDelta delay) OVERRIDE; 41 base::TimeDelta delay) OVERRIDE;
39 42
40 protected: 43 protected:
41 virtual ~FakeSingleThreadTaskRunner(); 44 virtual ~FakeSingleThreadTaskRunner();
42 45
43 private: 46 private:
44 base::SimpleTestTickClock* const clock_; 47 base::SimpleTestTickClock* const clock_;
45 std::multimap<base::TimeTicks, PostedTask> tasks_; 48 std::multimap<base::TimeTicks, PostedTask> tasks_;
49 bool fail_on_next_task_;
46 50
47 DISALLOW_COPY_AND_ASSIGN(FakeSingleThreadTaskRunner); 51 DISALLOW_COPY_AND_ASSIGN(FakeSingleThreadTaskRunner);
48 }; 52 };
49 53
50 } // namespace test 54 } // namespace test
51 } // namespace cast 55 } // namespace cast
52 } // namespace media 56 } // namespace media
53 57
54 #endif // MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ 58 #endif // MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « media/cast/test/end2end_unittest.cc ('k') | media/cast/test/fake_single_thread_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698