Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: webrtc/system_wrappers/source/clock_unittest.cc

Issue 2694713002: Replace use of Clock::CurrentNtp with Clock::CurrentNtpTime (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 10
11 #include "webrtc/system_wrappers/include/clock.h" 11 #include "webrtc/system_wrappers/include/clock.h"
12 12
13 #include "webrtc/test/gtest.h" 13 #include "webrtc/test/gtest.h"
14 14
15 namespace webrtc { 15 namespace webrtc {
16 16
17 TEST(ClockTest, NtpTime) { 17 TEST(ClockTest, NtpTime) {
18 Clock* clock = Clock::GetRealTimeClock(); 18 Clock* clock = Clock::GetRealTimeClock();
19 uint32_t seconds;
20 uint32_t fractions;
21 19
22 // To ensure the test runs correctly even on a heavily loaded system, do not 20 // To ensure the test runs correctly even on a heavily loaded system, do not
23 // compare the seconds/fractions and millisecond values directly. Instead, 21 // compare the seconds/fractions and millisecond values directly. Instead,
24 // we check that the NTP time is between the "milliseconds" values returned 22 // we check that the NTP time is between the "milliseconds" values returned
25 // right before and right after the call. 23 // right before and right after the call.
26 // The comparison includes 1 ms of margin to account for the rounding error in 24 // The comparison includes 1 ms of margin to account for the rounding error in
27 // the conversion. 25 // the conversion.
28 int64_t milliseconds_lower_bound = clock->CurrentNtpInMilliseconds(); 26 int64_t milliseconds_lower_bound = clock->CurrentNtpInMilliseconds();
29 clock->CurrentNtp(seconds, fractions); 27 NtpTime ntp_time = clock->CurrentNtpTime();
30 int64_t milliseconds_upper_bound = clock->CurrentNtpInMilliseconds(); 28 int64_t milliseconds_upper_bound = clock->CurrentNtpInMilliseconds();
31 EXPECT_GT(milliseconds_lower_bound / 1000, kNtpJan1970); 29 EXPECT_GT(milliseconds_lower_bound / 1000, kNtpJan1970);
32 EXPECT_LE(milliseconds_lower_bound - 1, Clock::NtpToMs(seconds, fractions)); 30 EXPECT_LE(milliseconds_lower_bound - 1, ntp_time.ToMs());
33 EXPECT_GE(milliseconds_upper_bound + 1, Clock::NtpToMs(seconds, fractions)); 31 EXPECT_GE(milliseconds_upper_bound + 1, ntp_time.ToMs());
34 } 32 }
35 33
36 } // namespace webrtc 34 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698