OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/test/simple_test_clock.h" | 7 #include "base/test/simple_test_tick_clock.h" |
8 #include "base/time/clock.h" | 8 #include "base/time/clock.h" |
9 #include "media/base/clock.h" | 9 #include "media/base/clock.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 | 11 |
12 using ::testing::InSequence; | 12 using ::testing::InSequence; |
13 using ::testing::Return; | 13 using ::testing::Return; |
14 using ::testing::StrictMock; | 14 using ::testing::StrictMock; |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 // Provide a stream output operator so we can use EXPECT_EQ(...) with TimeDelta. | 18 // Provide a stream output operator so we can use EXPECT_EQ(...) with TimeDelta. |
19 // | 19 // |
20 // TODO(scherkus): move this into the testing package. | 20 // TODO(scherkus): move this into the testing package. |
21 static std::ostream& operator<<(std::ostream& stream, const TimeDelta& time) { | 21 static std::ostream& operator<<(std::ostream& stream, const TimeDelta& time) { |
22 return (stream << time.ToInternalValue()); | 22 return (stream << time.ToInternalValue()); |
23 } | 23 } |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 namespace media { | 27 namespace media { |
28 | 28 |
29 static const int kDurationInSeconds = 120; | 29 static const int kDurationInSeconds = 120; |
30 | 30 |
31 class ClockTest : public ::testing::Test { | 31 class ClockTest : public ::testing::Test { |
32 public: | 32 public: |
33 ClockTest() : clock_(&test_clock_) { | 33 ClockTest() : clock_(&test_tick_clock_) { |
34 SetDuration(); | 34 SetDuration(); |
35 } | 35 } |
36 | 36 |
37 protected: | 37 protected: |
38 void SetDuration() { | 38 void SetDuration() { |
39 const base::TimeDelta kDuration = | 39 const base::TimeDelta kDuration = |
40 base::TimeDelta::FromSeconds(kDurationInSeconds); | 40 base::TimeDelta::FromSeconds(kDurationInSeconds); |
41 clock_.SetDuration(kDuration); | 41 clock_.SetDuration(kDuration); |
42 EXPECT_EQ(kDuration, clock_.Duration()); | 42 EXPECT_EQ(kDuration, clock_.Duration()); |
43 } | 43 } |
44 | 44 |
45 void AdvanceSystemTime(base::TimeDelta delta) { | 45 void AdvanceSystemTime(base::TimeDelta delta) { |
46 test_clock_.Advance(delta); | 46 test_tick_clock_.Advance(delta); |
47 } | 47 } |
48 | 48 |
49 base::SimpleTestClock test_clock_; | 49 base::SimpleTestTickClock test_tick_clock_; |
50 Clock clock_; | 50 Clock clock_; |
51 base::TimeDelta time_elapsed_; | 51 base::TimeDelta time_elapsed_; |
52 }; | 52 }; |
53 | 53 |
54 TEST_F(ClockTest, Created) { | 54 TEST_F(ClockTest, Created) { |
55 const base::TimeDelta kExpected = base::TimeDelta::FromSeconds(0); | 55 const base::TimeDelta kExpected = base::TimeDelta::FromSeconds(0); |
56 EXPECT_EQ(kExpected, clock_.Elapsed()); | 56 EXPECT_EQ(kExpected, clock_.Elapsed()); |
57 } | 57 } |
58 | 58 |
59 TEST_F(ClockTest, Play_NormalSpeed) { | 59 TEST_F(ClockTest, Play_NormalSpeed) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 EXPECT_EQ(kMaxTime1, clock_.Elapsed()); | 244 EXPECT_EQ(kMaxTime1, clock_.Elapsed()); |
245 | 245 |
246 AdvanceSystemTime(kTimeInterval); | 246 AdvanceSystemTime(kTimeInterval); |
247 EXPECT_EQ(kMaxTime1 + kTimeInterval, clock_.Elapsed()); | 247 EXPECT_EQ(kMaxTime1 + kTimeInterval, clock_.Elapsed()); |
248 | 248 |
249 AdvanceSystemTime(kTimeInterval); | 249 AdvanceSystemTime(kTimeInterval); |
250 EXPECT_EQ(kMaxTime2, clock_.Elapsed()); | 250 EXPECT_EQ(kMaxTime2, clock_.Elapsed()); |
251 } | 251 } |
252 | 252 |
253 } // namespace media | 253 } // namespace media |
OLD | NEW |