Start with a BeginLog event in event log encoder unittest

Also rename encoding_ to encoding_type_

Bug: webrtc:11933
Change-Id: If4848199b96e9de612695dfe7ec52266ccd80bd3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219285
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34070}
This commit is contained in:
Björn Terelius
2021-05-19 01:10:09 +02:00
committed by WebRTC LUCI CQ
parent b8dc7fa5a6
commit 0cff39137b

View File

@ -49,12 +49,12 @@ class RtcEventLogEncoderTest
RtcEventLogEncoderTest()
: seed_(std::get<0>(GetParam())),
prng_(seed_),
encoding_(std::get<1>(GetParam())),
encoding_type_(std::get<1>(GetParam())),
event_count_(std::get<2>(GetParam())),
force_repeated_fields_(std::get<3>(GetParam())),
gen_(seed_ * 880001UL),
verifier_(encoding_) {
switch (encoding_) {
verifier_(encoding_type_) {
switch (encoding_type_) {
case RtcEventLog::EncodingType::Legacy:
encoder_ = std::make_unique<RtcEventLogEncoderLegacy>();
break;
@ -62,6 +62,8 @@ class RtcEventLogEncoderTest
encoder_ = std::make_unique<RtcEventLogEncoderNewFormat>();
break;
}
encoded_ =
encoder_->EncodeLogStart(rtc::TimeMillis(), rtc::TimeUTCMillis());
}
~RtcEventLogEncoderTest() override = default;
@ -89,11 +91,12 @@ class RtcEventLogEncoderTest
ParsedRtcEventLog parsed_log_;
const uint64_t seed_;
Random prng_;
const RtcEventLog::EncodingType encoding_;
const RtcEventLog::EncodingType encoding_type_;
const size_t event_count_;
const bool force_repeated_fields_;
test::EventGenerator gen_;
test::EventVerifier verifier_;
std::string encoded_;
};
void RtcEventLogEncoderTest::TestRtcEventAudioNetworkAdaptation(
@ -105,8 +108,8 @@ void RtcEventLogEncoderTest::TestRtcEventAudioNetworkAdaptation(
history_.push_back(event->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& ana_configs = parsed_log_.audio_network_adaptation_events();
ASSERT_EQ(ana_configs.size(), events.size());
@ -167,7 +170,7 @@ void RtcEventLogEncoderTest::TestRtpPackets() {
// TODO(terelius): Test extensions for legacy encoding, too.
RtpHeaderExtensionMap extension_map;
if (encoding_ != RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ != RtcEventLog::EncodingType::Legacy) {
extension_map = gen_.NewRtpHeaderExtensionMap(true);
}
@ -185,8 +188,8 @@ void RtcEventLogEncoderTest::TestRtpPackets() {
}
// Encode and parse.
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
// For each SSRC, make sure the RTP packets associated with it to have been
// correctly encoded and parsed.
@ -212,8 +215,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAlrState) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& alr_state_events = parsed_log_.alr_state_events();
ASSERT_EQ(alr_state_events.size(), event_count_);
@ -223,7 +226,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAlrState) {
}
TEST_P(RtcEventLogEncoderTest, RtcEventRouteChange) {
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
return;
}
std::vector<std::unique_ptr<RtcEventRouteChange>> events(event_count_);
@ -233,8 +236,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRouteChange) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& route_change_events = parsed_log_.route_change_events();
ASSERT_EQ(route_change_events.size(), event_count_);
@ -244,7 +247,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRouteChange) {
}
TEST_P(RtcEventLogEncoderTest, RtcEventRemoteEstimate) {
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
return;
}
std::vector<std::unique_ptr<RtcEventRemoteEstimate>> events(event_count_);
@ -255,8 +258,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRemoteEstimate) {
history_.push_back(std::make_unique<RtcEventRemoteEstimate>(*events[i]));
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& parsed_events = parsed_log_.remote_estimate_events();
ASSERT_EQ(parsed_events.size(), event_count_);
@ -409,8 +412,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioPlayout) {
original_events_by_ssrc[ssrc].push_back(std::move(event));
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& parsed_playout_events_by_ssrc =
parsed_log_.audio_playout_events();
@ -445,8 +448,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioReceiveStreamConfig) {
gen_.NewAudioReceiveStreamConfig(ssrc, extensions);
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& audio_recv_configs = parsed_log_.audio_recv_configs();
ASSERT_EQ(audio_recv_configs.size(), 1u);
@ -461,8 +464,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventAudioSendStreamConfig) {
gen_.NewAudioSendStreamConfig(ssrc, extensions);
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& audio_send_configs = parsed_log_.audio_send_configs();
ASSERT_EQ(audio_send_configs.size(), 1u);
@ -479,8 +482,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateDelayBased) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& bwe_delay_updates = parsed_log_.bwe_delay_updates();
ASSERT_EQ(bwe_delay_updates.size(), event_count_);
@ -499,8 +502,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateLossBased) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& bwe_loss_updates = parsed_log_.bwe_loss_updates();
ASSERT_EQ(bwe_loss_updates.size(), event_count_);
@ -511,7 +514,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventBweUpdateLossBased) {
}
TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketReceived) {
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
return;
}
std::vector<std::unique_ptr<RtcEventGenericPacketReceived>> events(
@ -523,8 +526,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketReceived) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& packets_received = parsed_log_.generic_packets_received();
ASSERT_EQ(packets_received.size(), event_count_);
@ -536,7 +539,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketReceived) {
}
TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketSent) {
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
return;
}
std::vector<std::unique_ptr<RtcEventGenericPacketSent>> events(event_count_);
@ -547,8 +550,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketSent) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& packets_sent = parsed_log_.generic_packets_sent();
ASSERT_EQ(packets_sent.size(), event_count_);
@ -559,7 +562,7 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericPacketSent) {
}
TEST_P(RtcEventLogEncoderTest, RtcEventGenericAcksReceived) {
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
return;
}
std::vector<std::unique_ptr<RtcEventGenericAckReceived>> events(event_count_);
@ -570,8 +573,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventGenericAcksReceived) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& decoded_events = parsed_log_.generic_acks_received();
ASSERT_EQ(decoded_events.size(), event_count_);
@ -590,12 +593,11 @@ TEST_P(RtcEventLogEncoderTest, RtcEventDtlsTransportState) {
history_.push_back(events[i]->Copy());
}
const std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& dtls_transport_states = parsed_log_.dtls_transport_states();
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
ASSERT_EQ(dtls_transport_states.size(), 0u);
return;
}
@ -616,12 +618,11 @@ TEST_P(RtcEventLogEncoderTest, RtcEventDtlsWritableState) {
history_.push_back(events[i]->Copy());
}
const std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& dtls_writable_states = parsed_log_.dtls_writable_states();
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
ASSERT_EQ(dtls_writable_states.size(), 0u);
return;
}
@ -654,15 +655,14 @@ TEST_P(RtcEventLogEncoderTest, RtcEventFrameDecoded) {
original_events_by_ssrc[ssrc].push_back(std::move(event));
}
const std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
auto status = parsed_log_.ParseString(encoded);
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
auto status = parsed_log_.ParseString(encoded_);
if (!status.ok())
RTC_LOG(LS_ERROR) << status.message();
ASSERT_TRUE(status.ok());
const auto& decoded_frames_by_ssrc = parsed_log_.decoded_frames();
if (encoding_ == RtcEventLog::EncodingType::Legacy) {
if (encoding_type_ == RtcEventLog::EncodingType::Legacy) {
ASSERT_EQ(decoded_frames_by_ssrc.size(), 0u);
return;
}
@ -695,8 +695,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventIceCandidatePairConfig) {
gen_.NewIceCandidatePairConfig();
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& ice_candidate_pair_configs =
parsed_log_.ice_candidate_pair_configs();
@ -710,8 +710,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventIceCandidatePair) {
std::unique_ptr<RtcEventIceCandidatePair> event = gen_.NewIceCandidatePair();
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& ice_candidate_pair_events =
parsed_log_.ice_candidate_pair_events();
@ -724,8 +724,9 @@ TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStarted) {
const int64_t timestamp_us = rtc::TimeMicros();
const int64_t utc_time_us = rtc::TimeUTCMicros();
std::string encoded = encoder_->EncodeLogStart(timestamp_us, utc_time_us);
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
// Overwrite the previously encoded LogStart event.
encoded_ = encoder_->EncodeLogStart(timestamp_us, utc_time_us);
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& start_log_events = parsed_log_.start_log_events();
ASSERT_EQ(start_log_events.size(), 1u);
@ -736,12 +737,13 @@ TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStarted) {
TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStopped) {
const int64_t start_timestamp_us = rtc::TimeMicros();
const int64_t start_utc_time_us = rtc::TimeUTCMicros();
std::string encoded =
encoder_->EncodeLogStart(start_timestamp_us, start_utc_time_us);
// Overwrite the previously encoded LogStart event.
encoded_ = encoder_->EncodeLogStart(start_timestamp_us, start_utc_time_us);
const int64_t stop_timestamp_us = rtc::TimeMicros();
encoded += encoder_->EncodeLogEnd(stop_timestamp_us);
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeLogEnd(stop_timestamp_us);
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& stop_log_events = parsed_log_.stop_log_events();
ASSERT_EQ(stop_log_events.size(), 1u);
@ -754,8 +756,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeClusterCreated) {
gen_.NewProbeClusterCreated();
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& bwe_probe_cluster_created_events =
parsed_log_.bwe_probe_cluster_created_events();
@ -770,8 +772,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultFailure) {
gen_.NewProbeResultFailure();
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& bwe_probe_failure_events = parsed_log_.bwe_probe_failure_events();
ASSERT_EQ(bwe_probe_failure_events.size(), 1u);
@ -785,8 +787,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventProbeResultSuccess) {
gen_.NewProbeResultSuccess();
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& bwe_probe_success_events = parsed_log_.bwe_probe_success_events();
ASSERT_EQ(bwe_probe_success_events.size(), 1u);
@ -809,8 +811,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPacketIncoming) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& incoming_rtcp_packets = parsed_log_.incoming_rtcp_packets();
ASSERT_EQ(incoming_rtcp_packets.size(), event_count_);
@ -830,8 +832,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPacketOutgoing) {
history_.push_back(events[i]->Copy());
}
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& outgoing_rtcp_packets = parsed_log_.outgoing_rtcp_packets();
ASSERT_EQ(outgoing_rtcp_packets.size(), event_count_);
@ -867,9 +869,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpReceiverReport) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& receiver_reports = parsed_log_.receiver_reports(direction);
ASSERT_EQ(receiver_reports.size(), event_count_);
@ -906,9 +907,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpSenderReport) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& sender_reports = parsed_log_.sender_reports(direction);
ASSERT_EQ(sender_reports.size(), event_count_);
@ -945,9 +945,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpExtendedReports) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& extended_reports = parsed_log_.extended_reports(direction);
ASSERT_EQ(extended_reports.size(), event_count_);
@ -984,9 +983,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpFir) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& firs = parsed_log_.firs(direction);
ASSERT_EQ(firs.size(), event_count_);
@ -1022,9 +1020,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpPli) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& plis = parsed_log_.plis(direction);
ASSERT_EQ(plis.size(), event_count_);
@ -1060,9 +1057,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpBye) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& byes = parsed_log_.byes(direction);
ASSERT_EQ(byes.size(), event_count_);
@ -1098,9 +1094,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpNack) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& nacks = parsed_log_.nacks(direction);
ASSERT_EQ(nacks.size(), event_count_);
@ -1136,9 +1131,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpRemb) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& rembs = parsed_log_.rembs(direction);
ASSERT_EQ(rembs.size(), event_count_);
@ -1175,9 +1169,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpTransportFeedback) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& transport_feedbacks =
parsed_log_.transport_feedbacks(direction);
@ -1216,9 +1209,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventRtcpLossNotification) {
fake_clock.AdvanceTime(TimeDelta::Millis(prng_.Rand(0, 1000)));
}
std::string encoded =
encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& loss_notifications = parsed_log_.loss_notifications(direction);
ASSERT_EQ(loss_notifications.size(), event_count_);
@ -1246,8 +1238,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoReceiveStreamConfig) {
gen_.NewVideoReceiveStreamConfig(ssrc, extensions);
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& video_recv_configs = parsed_log_.video_recv_configs();
ASSERT_EQ(video_recv_configs.size(), 1u);
@ -1262,8 +1254,8 @@ TEST_P(RtcEventLogEncoderTest, RtcEventVideoSendStreamConfig) {
gen_.NewVideoSendStreamConfig(ssrc, extensions);
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded).ok());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ASSERT_TRUE(parsed_log_.ParseString(encoded_).ok());
const auto& video_send_configs = parsed_log_.video_send_configs();
ASSERT_EQ(video_send_configs.size(), 1u);
@ -1283,8 +1275,8 @@ INSTANTIATE_TEST_SUITE_P(
class RtcEventLogEncoderSimpleTest
: public ::testing::TestWithParam<RtcEventLog::EncodingType> {
protected:
RtcEventLogEncoderSimpleTest() : encoding_(GetParam()) {
switch (encoding_) {
RtcEventLogEncoderSimpleTest() : encoding_type_(GetParam()) {
switch (encoding_type_) {
case RtcEventLog::EncodingType::Legacy:
encoder_ = std::make_unique<RtcEventLogEncoderLegacy>();
break;
@ -1292,13 +1284,16 @@ class RtcEventLogEncoderSimpleTest
encoder_ = std::make_unique<RtcEventLogEncoderNewFormat>();
break;
}
encoded_ =
encoder_->EncodeLogStart(rtc::TimeMillis(), rtc::TimeUTCMillis());
}
~RtcEventLogEncoderSimpleTest() override = default;
std::deque<std::unique_ptr<RtcEvent>> history_;
std::unique_ptr<RtcEventLogEncoder> encoder_;
ParsedRtcEventLog parsed_log_;
const RtcEventLog::EncodingType encoding_;
const RtcEventLog::EncodingType encoding_type_;
std::string encoded_;
};
TEST_P(RtcEventLogEncoderSimpleTest, RtcEventLargeCompoundRtcpPacketIncoming) {
@ -1320,9 +1315,9 @@ TEST_P(RtcEventLogEncoderSimpleTest, RtcEventLargeCompoundRtcpPacketIncoming) {
EXPECT_GT(packet.size(), static_cast<size_t>(IP_PACKET_SIZE));
auto event = std::make_unique<RtcEventRtcpPacketIncoming>(packet);
history_.push_back(event->Copy());
std::string encoded = encoder_->EncodeBatch(history_.begin(), history_.end());
encoded_ += encoder_->EncodeBatch(history_.begin(), history_.end());
ParsedRtcEventLog::ParseStatus status = parsed_log_.ParseString(encoded);
ParsedRtcEventLog::ParseStatus status = parsed_log_.ParseString(encoded_);
ASSERT_TRUE(status.ok()) << status.message();
const auto& incoming_rtcp_packets = parsed_log_.incoming_rtcp_packets();