OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 10 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
11 | 11 |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "webrtc/test/gtest.h" |
13 | 13 |
14 namespace webrtc { | 14 namespace webrtc { |
15 | 15 |
16 TEST(TimeUtilTest, CompactNtp) { | 16 TEST(TimeUtilTest, CompactNtp) { |
17 const uint32_t kNtpSec = 0x12345678; | 17 const uint32_t kNtpSec = 0x12345678; |
18 const uint32_t kNtpFrac = 0x23456789; | 18 const uint32_t kNtpFrac = 0x23456789; |
19 const NtpTime kNtp(kNtpSec, kNtpFrac); | 19 const NtpTime kNtp(kNtpSec, kNtpFrac); |
20 const uint32_t kNtpMid = 0x56782345; | 20 const uint32_t kNtpMid = 0x56782345; |
21 EXPECT_EQ(kNtpMid, CompactNtp(kNtp)); | 21 EXPECT_EQ(kNtpMid, CompactNtp(kNtp)); |
22 } | 22 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const NtpTime ntp1(0x20000, 0x23456); | 64 const NtpTime ntp1(0x20000, 0x23456); |
65 const NtpTime ntp2(0x1ffff, 0x64335); | 65 const NtpTime ntp2(0x1ffff, 0x64335); |
66 int64_t ms_diff = ntp2.ToMs() - ntp1.ToMs(); | 66 int64_t ms_diff = ntp2.ToMs() - ntp1.ToMs(); |
67 ASSERT_GT(0, ms_diff); | 67 ASSERT_GT(0, ms_diff); |
68 // Ntp difference close to 2^16 seconds should be treated as negative. | 68 // Ntp difference close to 2^16 seconds should be treated as negative. |
69 uint32_t ntp_diff = CompactNtp(ntp2) - CompactNtp(ntp1); | 69 uint32_t ntp_diff = CompactNtp(ntp2) - CompactNtp(ntp1); |
70 int64_t ntp_to_ms_diff = CompactNtpRttToMs(ntp_diff); | 70 int64_t ntp_to_ms_diff = CompactNtpRttToMs(ntp_diff); |
71 EXPECT_EQ(1, ntp_to_ms_diff); | 71 EXPECT_EQ(1, ntp_to_ms_diff); |
72 } | 72 } |
73 } // namespace webrtc | 73 } // namespace webrtc |
OLD | NEW |