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