diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc')
-rw-r--r-- | third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc index 3730a080dd..a3005729ab 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -19,8 +19,9 @@ #include <utility> #include <vector> +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/task_queue/default_task_queue_factory.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" #include "logging/rtc_event_log/events/rtc_event_audio_playout.h" #include "logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h" @@ -50,6 +51,7 @@ #include "rtc_base/checks.h" #include "rtc_base/fake_clock.h" #include "rtc_base/random.h" +#include "test/explicit_key_value_config.h" #include "test/gtest.h" #include "test/logging/memory_log_writer.h" #include "test/testsupport/file_utils.h" @@ -58,6 +60,8 @@ namespace webrtc { namespace { +using test::ExplicitKeyValueConfig; + struct EventCounts { size_t audio_send_streams = 0; size_t audio_recv_streams = 0; @@ -105,6 +109,21 @@ struct EventCounts { } }; +std::unique_ptr<FieldTrialsView> CreateFieldTrialsFor( + RtcEventLog::EncodingType encoding_type) { + switch (encoding_type) { + case RtcEventLog::EncodingType::Legacy: + return std::make_unique<ExplicitKeyValueConfig>( + "WebRTC-RtcEventLogNewFormat/Disabled/"); + case RtcEventLog::EncodingType::NewFormat: + return std::make_unique<ExplicitKeyValueConfig>( + "WebRTC-RtcEventLogNewFormat/Enabled/"); + case RtcEventLog::EncodingType::ProtoFree: + RTC_CHECK(false); + return nullptr; + } +} + class RtcEventLogSession : public ::testing::TestWithParam< std::tuple<uint64_t, int64_t, RtcEventLog::EncodingType>> { @@ -336,14 +355,13 @@ void RtcEventLogSession::WriteVideoSendConfigs(size_t video_send_streams, void RtcEventLogSession::WriteLog(EventCounts count, size_t num_events_before_start) { - // TODO(terelius): Allow test to run with either a real or a fake clock_. - // Maybe always use the ScopedFakeClock, but conditionally SleepMs()? + // TODO(terelius): Allow test to run with either a real or a fake clock_ + // e.g. by using clock and task_queue_factory from TimeController + // when RtcEventLogImpl switches to use injected clock from the environment. - auto task_queue_factory = CreateDefaultTaskQueueFactory(); - RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get()); // The log will be flushed to output when the event_log goes out of scope. - std::unique_ptr<RtcEventLog> event_log = - rtc_event_log_factory.CreateRtcEventLog(encoding_type_); + std::unique_ptr<RtcEventLog> event_log = RtcEventLogFactory().Create( + CreateEnvironment(CreateFieldTrialsFor(encoding_type_))); // We can't send or receive packets without configured streams. RTC_CHECK_GE(count.video_recv_streams, 1); @@ -934,12 +952,9 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) { int64_t start_time_us, utc_start_time_us, stop_time_us; { - auto task_queue_factory = CreateDefaultTaskQueueFactory(); - RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get()); - // When `log` goes out of scope, the contents are flushed - // to the output. - std::unique_ptr<RtcEventLog> log = - rtc_event_log_factory.CreateRtcEventLog(encoding_type_); + // When `log` goes out of scope, the contents are flushed to the output. + std::unique_ptr<RtcEventLog> log = RtcEventLogFactory().Create( + CreateEnvironment(CreateFieldTrialsFor(encoding_type_))); for (size_t i = 0; i < kNumEvents; i++) { // The purpose of the test is to verify that the log can handle |