| Index: media/cast/cast_ntp_tick_clock_unittest.cc
|
| diff --git a/media/cast/cast_ntp_tick_clock_unittest.cc b/media/cast/cast_ntp_tick_clock_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a707494519a427a4481f0f82679ef403fad80cad
|
| --- /dev/null
|
| +++ b/media/cast/cast_ntp_tick_clock_unittest.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/test/simple_test_tick_clock.h"
|
| +#include "media/cast/cast_defines.h"
|
| +#include "media/cast/cast_ntp_tick_clock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace media {
|
| +namespace cast {
|
| +
|
| +class PeerCastNtpTickClock : public CastNtpTickClock {
|
| + public:
|
| + explicit PeerCastNtpTickClock() {}
|
| +
|
| + using CastNtpTickClock::SetTickClock;
|
| +};
|
| +
|
| +class CastNtpTickClockTest : public ::testing::Test {
|
| + protected:
|
| + CastNtpTickClockTest() {}
|
| + virtual ~CastNtpTickClockTest() {}
|
| +};
|
| +
|
| +// Note: This test will fail if the system clock is not between the years 2010
|
| +// and 2030.
|
| +TEST_F(CastNtpTickClockTest, Basic) {
|
| + const int64 kSecondsbetweenYear1900and2010 = GG_INT64_C(40176 * 24 * 60 * 60);
|
| + const int64 kSecondsbetweenYear1900and2030 = GG_INT64_C(47481 * 24 * 60 * 60);
|
| +
|
| + CastNtpTickClock ntp_clock;
|
| + base::TimeTicks now_ticks = ntp_clock.NowTicks();
|
| + base::TimeTicks year_2010_in_ticks;
|
| + base::TimeTicks year_2030_in_ticks;
|
| + year_2010_in_ticks += base::TimeDelta::FromSeconds(
|
| + kSecondsbetweenYear1900and2010);
|
| + year_2030_in_ticks += base::TimeDelta::FromSeconds(
|
| + kSecondsbetweenYear1900and2030);
|
| +
|
| + EXPECT_GT(now_ticks, year_2010_in_ticks);
|
| + EXPECT_LT(now_ticks, year_2030_in_ticks);
|
| +}
|
| +
|
| +TEST_F(CastNtpTickClockTest, Advance) {
|
| + const int64 kAdvanceTime = 123;
|
| + PeerCastNtpTickClock ntp_clock;
|
| + base::SimpleTestTickClock testing_clock;
|
| + ntp_clock.SetTickClock(&testing_clock);
|
| + base::TimeTicks start_ticks = ntp_clock.NowTicks();
|
| + base::TimeDelta advance_time = base::TimeDelta::FromSeconds(kAdvanceTime);
|
| + testing_clock.Advance(advance_time);
|
| +
|
| + EXPECT_EQ(ntp_clock.NowTicks(), start_ticks + advance_time);
|
| +}
|
| +
|
| +} // namespace cast
|
| +} // namespace media
|
| +
|
|
|