19b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org/*
29b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
39b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org *
49b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org *  Use of this source code is governed by a BSD-style license
59b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org *  that can be found in the LICENSE file in the root of the source
69b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org *  tree. An additional intellectual property rights grant can be found
79b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org *  in the file PATENTS.  All contributing project authors may
89b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
99b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org */
109b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org
119b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org#include "webrtc/system_wrappers/interface/clock.h"
129b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org
139b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org#include "testing/gtest/include/gtest/gtest.h"
149b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org
159b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.orgnamespace webrtc {
169b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org
179b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.orgTEST(ClockTest, NtpTime) {
189b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org  Clock* clock = Clock::GetRealTimeClock();
199b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org  uint32_t seconds;
209b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org  uint32_t fractions;
219b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org  clock->CurrentNtp(seconds, fractions);
229b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org  int64_t milliseconds = clock->CurrentNtpInMilliseconds();
23752b879b5ea7ed7cfb606694bcd3834c5354519cwu@webrtc.org  EXPECT_GT(milliseconds / 1000, kNtpJan1970);
249b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org  EXPECT_GE(milliseconds, Clock::NtpToMs(seconds, fractions));
259b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org  EXPECT_NEAR(milliseconds, Clock::NtpToMs(seconds, fractions), 5);
269b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org}
279b5315258a9a931a4fb8b0806a79a4758a1ddc13stefan@webrtc.org}  // namespace webrtc
28