OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/threading/platform_thread.h" | |
6 #include "base/test/simple_test_tick_clock.h" | |
7 #include "media/cast/cast_defines.h" | |
8 #include "media/cast/cast_ntp_tick_clock.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 namespace media { | |
12 namespace cast { | |
13 | |
14 class PeerCastNtpTickClock : public CastNtpTickClock { | |
15 public: | |
16 explicit PeerCastNtpTickClock() {} | |
17 | |
18 using CastNtpTickClock::SetTickClock; | |
19 }; | |
20 | |
21 class CastNtpTickClockTest : public ::testing::Test { | |
22 protected: | |
23 CastNtpTickClockTest() {} | |
24 virtual ~CastNtpTickClockTest() {} | |
25 }; | |
26 | |
27 // Note: This test will fail if the system clock is not between the years 2010 | |
28 // and 2030. | |
29 TEST_F(CastNtpTickClockTest, Basic) { | |
30 const int64 kSecondsbetweenYear1900and2010 = GG_INT64_C(40176 * 24 * 60 * 60); | |
31 const int64 kSecondsbetweenYear1900and2030 = GG_INT64_C(47481 * 24 * 60 * 60); | |
32 | |
33 CastNtpTickClock ntp_clock; | |
34 base::TimeTicks now_ticks = ntp_clock.NowTicks(); | |
35 base::TimeTicks year_2010_in_ticks; | |
36 base::TimeTicks year_2030_in_ticks; | |
37 year_2010_in_ticks += base::TimeDelta::FromSeconds( | |
38 kSecondsbetweenYear1900and2010); | |
39 year_2030_in_ticks += base::TimeDelta::FromSeconds( | |
40 kSecondsbetweenYear1900and2030); | |
41 | |
42 EXPECT_GT(now_ticks, year_2010_in_ticks); | |
43 EXPECT_LT(now_ticks, year_2030_in_ticks); | |
44 } | |
45 | |
46 TEST_F(CastNtpTickClockTest, Advance) { | |
47 const int64 kAdvanceTime = 123; | |
48 PeerCastNtpTickClock ntp_clock; | |
49 base::SimpleTestTickClock testing_clock; | |
50 ntp_clock.SetTickClock(&testing_clock); | |
51 base::TimeTicks start_ticks = ntp_clock.NowTicks(); | |
52 base::TimeDelta advence_time = base::TimeDelta::FromSeconds(kAdvanceTime); | |
miu
2013/10/23 18:24:02
typo: s/advence/advance/
pwestin
2013/10/23 21:07:49
Done.
pwestin
2013/10/23 21:07:49
Done.
| |
53 testing_clock.Advance(advence_time); | |
54 | |
55 EXPECT_EQ(ntp_clock.NowTicks(), start_ticks + advence_time); | |
56 } | |
57 | |
58 } // namespace cast | |
59 } // namespace media | |
60 | |
OLD | NEW |