Delete NtpOffsetMs and TimeMicrosToNtp methods.
This consolidates the querying of the Ntp time in once place, the clock. Bug: webrtc:11327 Change-Id: I14b19c2380996571d8c67c2c186629c209787162 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219794 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Paul Hallak <phallak@google.com> Cr-Commit-Position: refs/heads/master@{#34083}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
46fbefa302
commit
cab90db24a
@ -9,34 +9,10 @@
|
||||
*/
|
||||
#include "modules/rtp_rtcp/source/time_util.h"
|
||||
|
||||
#include "rtc_base/fake_clock.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(TimeUtilTest, TimeMicrosToNtpDoesntChangeBetweenRuns) {
|
||||
rtc::ScopedFakeClock clock;
|
||||
// TimeMicrosToNtp is not pure: it behave differently between different
|
||||
// execution of the program, but should behave same during same execution.
|
||||
const int64_t time_us = 12345;
|
||||
clock.SetTime(Timestamp::Micros(2));
|
||||
NtpTime time_ntp = TimeMicrosToNtp(time_us);
|
||||
clock.SetTime(Timestamp::Micros(time_us));
|
||||
EXPECT_EQ(TimeMicrosToNtp(time_us), time_ntp);
|
||||
clock.SetTime(Timestamp::Micros(1000000));
|
||||
EXPECT_EQ(TimeMicrosToNtp(time_us), time_ntp);
|
||||
}
|
||||
|
||||
TEST(TimeUtilTest, TimeMicrosToNtpKeepsIntervals) {
|
||||
rtc::ScopedFakeClock clock;
|
||||
NtpTime time_ntp1 = TimeMicrosToNtp(rtc::TimeMicros());
|
||||
clock.AdvanceTime(TimeDelta::Millis(20));
|
||||
NtpTime time_ntp2 = TimeMicrosToNtp(rtc::TimeMicros());
|
||||
EXPECT_EQ(time_ntp2.ToMs() - time_ntp1.ToMs(), 20);
|
||||
}
|
||||
|
||||
TEST(TimeUtilTest, CompactNtp) {
|
||||
const uint32_t kNtpSec = 0x12345678;
|
||||
const uint32_t kNtpFrac = 0x23456789;
|
||||
|
||||
Reference in New Issue
Block a user