OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 #include "webrtc/modules/rtp_rtcp/source/ntp_time.h" |
| 14 |
| 15 namespace webrtc { |
| 16 namespace rtcp { |
| 17 namespace { |
| 18 |
| 19 const uint32_t kNtpSec = 0x12345678; |
| 20 const uint32_t kNtpFrac = 0x23456789; |
| 21 const uint32_t kNtpMid = 0x56782345; |
| 22 |
| 23 TEST(NtpTimeTest, NoValue) { |
| 24 NtpTime ntp; |
| 25 EXPECT_FALSE(ntp.Valid()); |
| 26 } |
| 27 |
| 28 TEST(NtpTimeTest, CanResetValue) { |
| 29 NtpTime ntp(kNtpSec, kNtpFrac); |
| 30 EXPECT_TRUE(ntp.Valid()); |
| 31 ntp.Reset(); |
| 32 EXPECT_FALSE(ntp.Valid()); |
| 33 } |
| 34 |
| 35 TEST(NtpTimeTest, MidNtp) { |
| 36 EXPECT_EQ(kNtpMid, NtpTime(kNtpSec, kNtpFrac).MidNtp()); |
| 37 } |
| 38 |
| 39 TEST(NtpTimeTest, CanGetWhatIsSet) { |
| 40 NtpTime ntp; |
| 41 ntp.Set(kNtpSec, kNtpFrac); |
| 42 EXPECT_EQ(kNtpSec, ntp.seconds()); |
| 43 EXPECT_EQ(kNtpFrac, ntp.fractions()); |
| 44 } |
| 45 |
| 46 TEST(NtpTimeTest, SetIsSameAs2ParameterConstructor) { |
| 47 NtpTime ntp1(kNtpSec, kNtpFrac); |
| 48 NtpTime ntp2; |
| 49 EXPECT_NE(ntp1, ntp2); |
| 50 |
| 51 ntp2.Set(kNtpSec, kNtpFrac); |
| 52 EXPECT_EQ(ntp1, ntp2); |
| 53 } |
| 54 |
| 55 TEST(NtpTimeTest, SetCurrentIsSameAs1ParameterConstructor) { |
| 56 SimulatedClock clock(0x0123456789abcdef); |
| 57 |
| 58 NtpTime ntp1(clock); |
| 59 NtpTime ntp2; |
| 60 EXPECT_NE(ntp1, ntp2); |
| 61 |
| 62 ntp2.SetCurrent(clock); |
| 63 EXPECT_EQ(ntp1, ntp2); |
| 64 } |
| 65 |
| 66 TEST(NtpTimeTest, ToMsMeansToNtpMilliseconds) { |
| 67 SimulatedClock clock(0x123456789abc); |
| 68 |
| 69 NtpTime ntp(clock); |
| 70 EXPECT_EQ(ntp.ToMs(), Clock::NtpToMs(ntp.seconds(), ntp.fractions())); |
| 71 EXPECT_EQ(ntp.ToMs(), clock.CurrentNtpInMilliseconds()); |
| 72 } |
| 73 |
| 74 } // namespace |
| 75 } // namespace rtcp |
| 76 } // namespace webrtc |
OLD | NEW |