| OLD | NEW |
| 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 #include "media/cast/test/fake_single_thread_task_runner.h" | 5 #include "media/cast/test/fake_single_thread_task_runner.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/time/tick_clock.h" | 8 #include "base/time/tick_clock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 namespace cast { | 12 namespace cast { |
| 13 namespace test { | 13 namespace test { |
| 14 | 14 |
| 15 FakeSingleThreadTaskRunner::FakeSingleThreadTaskRunner( | 15 FakeSingleThreadTaskRunner::FakeSingleThreadTaskRunner( |
| 16 base::SimpleTestTickClock* clock) | 16 base::SimpleTestTickClock* clock) |
| 17 : clock_(clock), | 17 : clock_(clock), |
| 18 fail_on_next_task_(false) {} | 18 fail_on_next_task_(false) {} |
| 19 | 19 |
| 20 FakeSingleThreadTaskRunner::~FakeSingleThreadTaskRunner() {} | 20 FakeSingleThreadTaskRunner::~FakeSingleThreadTaskRunner() {} |
| 21 | 21 |
| 22 bool FakeSingleThreadTaskRunner::PostDelayedTask( | 22 bool FakeSingleThreadTaskRunner::PostDelayedTask( |
| 23 const tracked_objects::Location& from_here, | 23 const tracked_objects::Location& from_here, |
| 24 const base::Closure& task, | 24 const base::Closure& task, |
| 25 base::TimeDelta delay) { | 25 base::TimeDelta delay) { |
| 26 if (fail_on_next_task_) { | 26 if (fail_on_next_task_) { |
| 27 LOG(FATAL) << "Infinite task-add loop detected."; | 27 LOG(FATAL) << "Infinite task-add loop detected."; |
| 28 } | 28 } |
| 29 CHECK(delay >= base::TimeDelta()); | |
| 30 EXPECT_GE(delay, base::TimeDelta()); | 29 EXPECT_GE(delay, base::TimeDelta()); |
| 31 PostedTask posed_task(from_here, | 30 PostedTask posed_task(from_here, |
| 32 task, | 31 task, |
| 33 clock_->NowTicks(), | 32 clock_->NowTicks(), |
| 34 delay, | 33 delay, |
| 35 base::TestPendingTask::NESTABLE); | 34 base::TestPendingTask::NESTABLE); |
| 36 | 35 |
| 37 tasks_.insert(std::make_pair(posed_task.GetTimeToRun(), posed_task)); | 36 tasks_.insert(std::make_pair(posed_task.GetTimeToRun(), posed_task)); |
| 38 return false; | 37 return false; |
| 39 } | 38 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const tracked_objects::Location& from_here, | 93 const tracked_objects::Location& from_here, |
| 95 const base::Closure& task, | 94 const base::Closure& task, |
| 96 base::TimeDelta delay) { | 95 base::TimeDelta delay) { |
| 97 NOTIMPLEMENTED(); | 96 NOTIMPLEMENTED(); |
| 98 return false; | 97 return false; |
| 99 } | 98 } |
| 100 | 99 |
| 101 } // namespace test | 100 } // namespace test |
| 102 } // namespace cast | 101 } // namespace cast |
| 103 } // namespace media | 102 } // namespace media |
| OLD | NEW |