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/test/simple_test_tick_clock.h" | 5 #include "base/test/simple_test_tick_clock.h" |
6 #include "media/base/wall_clock_time_source.h" | 6 #include "media/base/wall_clock_time_source.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace media { | 9 namespace media { |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 int CurrentMediaTimeInSeconds() { | 24 int CurrentMediaTimeInSeconds() { |
25 return time_source_.CurrentMediaTime().InSeconds(); | 25 return time_source_.CurrentMediaTime().InSeconds(); |
26 } | 26 } |
27 | 27 |
28 void SetMediaTimeInSeconds(int seconds) { | 28 void SetMediaTimeInSeconds(int seconds) { |
29 return time_source_.SetMediaTime(base::TimeDelta::FromSeconds(seconds)); | 29 return time_source_.SetMediaTime(base::TimeDelta::FromSeconds(seconds)); |
30 } | 30 } |
31 | 31 |
32 bool IsWallClockNowForMediaTimeInSeconds(int seconds) { | 32 bool IsWallClockNowForMediaTimeInSeconds(int seconds) { |
33 return tick_clock_->NowTicks() == | 33 return tick_clock_->NowTicks() == |
34 time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds)); | 34 time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds), |
| 35 TimeSource::SINGLE_TIMESTAMP); |
35 } | 36 } |
36 | 37 |
37 bool IsWallClockNullForMediaTimeInSeconds(int seconds) { | 38 bool IsWallClockNullForMediaTimeInSeconds(int seconds) { |
38 return time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds)) | 39 return time_source_.GetWallClockTime(base::TimeDelta::FromSeconds(seconds), |
| 40 TimeSource::SINGLE_TIMESTAMP) |
39 .is_null(); | 41 .is_null(); |
40 } | 42 } |
41 | 43 |
42 protected: | 44 protected: |
43 WallClockTimeSource time_source_; | 45 WallClockTimeSource time_source_; |
44 base::SimpleTestTickClock* tick_clock_; // Owned by |time_source_|. | 46 base::SimpleTestTickClock* tick_clock_; // Owned by |time_source_|. |
45 | 47 |
46 DISALLOW_COPY_AND_ASSIGN(WallClockTimeSourceTest); | 48 DISALLOW_COPY_AND_ASSIGN(WallClockTimeSourceTest); |
47 }; | 49 }; |
48 | 50 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(10)); | 107 EXPECT_TRUE(IsWallClockNowForMediaTimeInSeconds(10)); |
106 | 108 |
107 time_source_.StopTicking(); | 109 time_source_.StopTicking(); |
108 | 110 |
109 AdvanceTimeInSeconds(10); | 111 AdvanceTimeInSeconds(10); |
110 EXPECT_EQ(10, CurrentMediaTimeInSeconds()); | 112 EXPECT_EQ(10, CurrentMediaTimeInSeconds()); |
111 EXPECT_TRUE(IsWallClockNullForMediaTimeInSeconds(10)); | 113 EXPECT_TRUE(IsWallClockNullForMediaTimeInSeconds(10)); |
112 } | 114 } |
113 | 115 |
114 } // namespace media | 116 } // namespace media |
OLD | NEW |