Removes TimeMicros interface from ThreadProcessingFakeClock.

Bug: webrtc:9883
Change-Id: Ib48872f81f734b09e3ffa4d9d26da79177b02303
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133341
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27668}
This commit is contained in:
Sebastian Jansson
2019-04-17 12:11:20 +02:00
committed by Commit Bot
parent e47aee3b86
commit 40889f35fc
13 changed files with 86 additions and 94 deletions

View File

@ -741,7 +741,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpReceiverReport) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::ReceiverReport> events(event_count_);
@ -757,7 +757,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpReceiverReport) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -780,7 +780,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpSenderReport) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::SenderReport> events(event_count_);
@ -796,7 +796,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpSenderReport) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -819,7 +819,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpExtendedReports) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::ExtendedReports> events(event_count_);
@ -835,7 +835,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpExtendedReports) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -858,7 +858,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpFir) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::Fir> events(event_count_);
@ -874,7 +874,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpFir) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -896,7 +896,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPli) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::Pli> events(event_count_);
@ -912,7 +912,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPli) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -934,7 +934,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpNack) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::Nack> events(event_count_);
@ -950,7 +950,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpNack) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -972,7 +972,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpRemb) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::Remb> events(event_count_);
@ -988,7 +988,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpRemb) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -1010,7 +1010,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpTransportFeedback) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::TransportFeedback> events;
@ -1027,7 +1027,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpTransportFeedback) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =
@ -1051,7 +1051,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpLossNotification) {
}
rtc::ScopedFakeClock fake_clock;
fake_clock.SetTimeMicros(static_cast<int64_t>(prng_.Rand<uint32_t>()) * 1000);
fake_clock.SetTime(Timestamp::ms(prng_.Rand<uint32_t>()));
for (auto direction : {kIncomingPacket, kOutgoingPacket}) {
std::vector<rtcp::LossNotification> events;
@ -1068,7 +1068,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpLossNotification) {
history_.push_back(
absl::make_unique<RtcEventRtcpPacketOutgoing>(buffer));
}
fake_clock.AdvanceTimeMicros(prng_.Rand(0, 1000) * 1000);
fake_clock.AdvanceTime(TimeDelta::ms(prng_.Rand(0, 1000)));
}
std::string encoded =

View File

@ -113,7 +113,7 @@ class RtcEventLogSession
encoding_type_(std::get<2>(GetParam())),
gen_(seed_ * 880001UL),
verifier_(encoding_type_) {
clock_.SetTimeMicros(prng_.Rand<uint32_t>());
clock_.SetTime(Timestamp::us(prng_.Rand<uint32_t>()));
// Find the name of the current test, in order to use it as a temporary
// filename.
// TODO(terelius): Use a general utility function to generate a temp file.
@ -215,7 +215,7 @@ void RtcEventLogSession::WriteAudioRecvConfigs(size_t audio_recv_streams,
RTC_CHECK(event_log != nullptr);
uint32_t ssrc;
for (size_t i = 0; i < audio_recv_streams; i++) {
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
do {
ssrc = prng_.Rand<uint32_t>();
} while (SsrcUsed(ssrc, incoming_extensions_));
@ -232,7 +232,7 @@ void RtcEventLogSession::WriteAudioSendConfigs(size_t audio_send_streams,
RTC_CHECK(event_log != nullptr);
uint32_t ssrc;
for (size_t i = 0; i < audio_send_streams; i++) {
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
do {
ssrc = prng_.Rand<uint32_t>();
} while (SsrcUsed(ssrc, outgoing_extensions_));
@ -254,14 +254,14 @@ void RtcEventLogSession::WriteVideoRecvConfigs(size_t video_recv_streams,
RtpHeaderExtensionMap all_extensions =
ParsedRtcEventLog::GetDefaultHeaderExtensionMap();
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
uint32_t ssrc = prng_.Rand<uint32_t>();
incoming_extensions_.emplace_back(prng_.Rand<uint32_t>(), all_extensions);
auto event = gen_.NewVideoReceiveStreamConfig(ssrc, all_extensions);
event_log->Log(event->Copy());
video_recv_config_list_.push_back(std::move(event));
for (size_t i = 1; i < video_recv_streams; i++) {
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
do {
ssrc = prng_.Rand<uint32_t>();
} while (SsrcUsed(ssrc, incoming_extensions_));
@ -283,14 +283,14 @@ void RtcEventLogSession::WriteVideoSendConfigs(size_t video_send_streams,
RtpHeaderExtensionMap all_extensions =
ParsedRtcEventLog::GetDefaultHeaderExtensionMap();
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
uint32_t ssrc = prng_.Rand<uint32_t>();
outgoing_extensions_.emplace_back(prng_.Rand<uint32_t>(), all_extensions);
auto event = gen_.NewVideoSendStreamConfig(ssrc, all_extensions);
event_log->Log(event->Copy());
video_send_config_list_.push_back(std::move(event));
for (size_t i = 1; i < video_send_streams; i++) {
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
do {
ssrc = prng_.Rand<uint32_t>();
} while (SsrcUsed(ssrc, outgoing_extensions_));
@ -327,7 +327,7 @@ void RtcEventLogSession::WriteLog(EventCounts count,
size_t remaining_events_at_start = remaining_events - num_events_before_start;
for (; remaining_events > 0; remaining_events--) {
if (remaining_events == remaining_events_at_start) {
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
event_log->StartLogging(
absl::make_unique<RtcEventLogOutputFile>(temp_filename_, 10000000),
output_period_ms_);
@ -335,7 +335,7 @@ void RtcEventLogSession::WriteLog(EventCounts count,
utc_start_time_us_ = rtc::TimeUTCMicros();
}
clock_.AdvanceTimeMicros(prng_.Rand(20) * 1000);
clock_.AdvanceTime(TimeDelta::ms(prng_.Rand(20)));
size_t selection = prng_.Rand(remaining_events - 1);
first_timestamp_ms_ = std::min(first_timestamp_ms_, rtc::TimeMillis());
last_timestamp_ms_ = std::max(last_timestamp_ms_, rtc::TimeMillis());
@ -814,7 +814,7 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
// TODO(terelius): Maybe make a separate RtcEventLogImplTest that can access
// the size of the cyclic buffer?
constexpr size_t kNumEvents = 20000;
constexpr int64_t kStartTime = 1000000;
constexpr int64_t kStartTimeSeconds = 1;
constexpr int32_t kStartBitrate = 1000000;
auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
@ -825,7 +825,7 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
std::unique_ptr<rtc::ScopedFakeClock> fake_clock =
absl::make_unique<rtc::ScopedFakeClock>();
fake_clock->SetTimeMicros(kStartTime);
fake_clock->SetTime(Timestamp::seconds(kStartTimeSeconds));
auto task_queue_factory = CreateDefaultTaskQueueFactory();
RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get());
@ -843,14 +843,14 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
// consistency checks when we read back.
log_dumper->Log(absl::make_unique<RtcEventProbeResultSuccess>(
i, kStartBitrate + i * 1000));
fake_clock->AdvanceTimeMicros(10000);
fake_clock->AdvanceTime(TimeDelta::ms(10));
}
int64_t start_time_us = rtc::TimeMicros();
int64_t utc_start_time_us = rtc::TimeUTCMicros();
log_dumper->StartLogging(
absl::make_unique<RtcEventLogOutputFile>(temp_filename, 10000000),
RtcEventLog::kImmediateOutput);
fake_clock->AdvanceTimeMicros(10000);
fake_clock->AdvanceTime(TimeDelta::ms(10));
int64_t stop_time_us = rtc::TimeMicros();
log_dumper->StopLogging();
@ -883,9 +883,9 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) {
// destroyed before the new one is created, so we have to reset() first.
fake_clock.reset();
fake_clock = absl::make_unique<rtc::ScopedFakeClock>();
fake_clock->SetTimeMicros(first_timestamp_us);
fake_clock->SetTime(Timestamp::us(first_timestamp_us));
for (size_t i = 1; i < probe_success_events.size(); i++) {
fake_clock->AdvanceTimeMicros(10000);
fake_clock->AdvanceTime(TimeDelta::ms(10));
verifier_.VerifyLoggedBweProbeSuccessEvent(
RtcEventProbeResultSuccess(first_id + i, first_bitrate_bps + i * 1000),
probe_success_events[i]);