| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
| 9 #include "media/base/wall_clock_time_source.h" | 9 #include "media/base/wall_clock_time_source.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 class WallClockTimeSourceTest : public testing::Test { | 14 class WallClockTimeSourceTest : public testing::Test { |
| 15 public: | 15 public: |
| 16 WallClockTimeSourceTest() : tick_clock_(new base::SimpleTestTickClock()) { | 16 WallClockTimeSourceTest() : tick_clock_(new base::SimpleTestTickClock()) { |
| 17 time_source_.set_tick_clock_for_testing(tick_clock_.get()); | 17 time_source_.set_tick_clock_for_testing(tick_clock_.get()); |
| 18 AdvanceTimeInSeconds(1); | 18 AdvanceTimeInSeconds(1); |
| 19 } | 19 } |
| 20 ~WallClockTimeSourceTest() override {} | 20 ~WallClockTimeSourceTest() override {} |
| 21 | 21 |
| 22 void AdvanceTimeInSeconds(int seconds) { | 22 void AdvanceTimeInSeconds(int seconds) { |
| 23 tick_clock_->Advance(base::TimeDelta::FromSeconds(seconds)); | 23 tick_clock_->Advance(base::TimeDelta::FromSeconds(seconds)); |
| 24 } | 24 } |
| 25 | 25 |
| 26 int CurrentMediaTimeInSeconds() { | 26 int CurrentMediaTimeInSeconds() { |
| 27 return time_source_.CurrentMediaTime().InSeconds(); | 27 return time_source_.CurrentMediaTime(nullptr).InSeconds(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void SetMediaTimeInSeconds(int seconds) { | 30 void SetMediaTimeInSeconds(int seconds) { |
| 31 return time_source_.SetMediaTime(base::TimeDelta::FromSeconds(seconds)); | 31 return time_source_.SetMediaTime(base::TimeDelta::FromSeconds(seconds)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 base::TimeTicks ConvertMediaTime(base::TimeDelta timestamp, | 34 base::TimeTicks ConvertMediaTime(base::TimeDelta timestamp, |
| 35 bool* is_time_moving) { | 35 bool* is_time_moving) { |
| 36 std::vector<base::TimeTicks> wall_clock_times; | 36 std::vector<base::TimeTicks> wall_clock_times; |
| 37 *is_time_moving = time_source_.GetWallClockTimes( | 37 *is_time_moving = time_source_.GetWallClockTimes( |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 wall_clock_times.clear(); | 160 wall_clock_times.clear(); |
| 161 time_source_.StopTicking(); | 161 time_source_.StopTicking(); |
| 162 is_time_moving = time_source_.GetWallClockTimes( | 162 is_time_moving = time_source_.GetWallClockTimes( |
| 163 std::vector<base::TimeDelta>(), &wall_clock_times); | 163 std::vector<base::TimeDelta>(), &wall_clock_times); |
| 164 EXPECT_FALSE(is_time_moving); | 164 EXPECT_FALSE(is_time_moving); |
| 165 EXPECT_EQ(tick_clock_->NowTicks(), wall_clock_times[0]); | 165 EXPECT_EQ(tick_clock_->NowTicks(), wall_clock_times[0]); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace media | 168 } // namespace media |
| OLD | NEW |