Use RunLoop in call/ tests

Bug: webrtc:469327588
Change-Id: Ia88b913a96175f8926208f7fd6bb4d1d6a6a6964
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/461345
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#47312}
diff --git a/call/BUILD.gn b/call/BUILD.gn
index a8ad708..815d28a 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -660,6 +660,7 @@
         "../test:encoder_settings",
         "../test:fake_video_codecs",
         "../test:frame_generator_capturer",
+        "../test:run_loop",
         "../test:test_common",
         "../test:test_flags",
         "../test:test_support",
@@ -699,6 +700,7 @@
       "../rtc_base:network_route",
       "../rtc_base/containers:flat_map",
       "../rtc_base/network:sent_packet",
+      "../test:run_loop",
       "../test:test_support",
       "//third_party/abseil-cpp/absl/strings:string_view",
     ]
@@ -709,6 +711,7 @@
     sources = [ "test/mock_bitrate_allocator.h" ]
     deps = [
       ":bitrate_allocator",
+      "../test:run_loop",
       "../test:test_support",
     ]
   }
@@ -730,6 +733,7 @@
       "../api/audio_codecs:audio_codecs_api",
       "../api/crypto:frame_decryptor_interface",
       "../api/transport/rtp:rtp_source",
+      "../test:run_loop",
       "../test:test_support",
     ]
   }
@@ -760,6 +764,7 @@
       "../rtc_base:checks",
       "../rtc_base:copy_on_write_buffer",
       "../system_wrappers",
+      "../test:run_loop",
       "../test:test_support",
       "../test/network:simulated_network",
     ]
diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn
index 3149c13..0b0da34 100644
--- a/call/adaptation/BUILD.gn
+++ b/call/adaptation/BUILD.gn
@@ -89,6 +89,7 @@
       "../../rtc_base:task_queue_for_test",
       "../../rtc_base:threading",
       "../../test:create_test_field_trials",
+      "../../test:run_loop",
       "../../test:test_support",
       "../../test:wait_until",
       "../../video/config:encoder_config",
diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc
index 4f63960..413f6fe 100644
--- a/call/adaptation/resource_adaptation_processor_unittest.cc
+++ b/call/adaptation/resource_adaptation_processor_unittest.cc
@@ -27,11 +27,11 @@
 #include "call/adaptation/video_stream_input_state_provider.h"
 #include "rtc_base/event.h"
 #include "rtc_base/task_queue_for_test.h"
-#include "rtc_base/thread.h"
 #include "rtc_base/thread_annotations.h"
 #include "test/create_test_field_trials.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
+#include "test/run_loop.h"
 #include "test/wait_until.h"
 
 namespace webrtc {
@@ -141,12 +141,10 @@
     processor_.reset();
   }
 
-  static void WaitUntilTaskQueueIdle() {
-    ASSERT_TRUE(Thread::Current()->ProcessMessages(0));
-  }
+  void WaitUntilTaskQueueIdle() { main_thread_.Flush(); }
 
  protected:
-  AutoThread main_thread_;
+  test::RunLoop main_thread_;
   FakeFrameRateProvider frame_rate_provider_;
   VideoStreamInputStateProvider input_state_provider_;
   scoped_refptr<FakeResource> resource_;
diff --git a/call/flexfec_receive_stream_unittest.cc b/call/flexfec_receive_stream_unittest.cc
index 27c8d2c..c4df175 100644
--- a/call/flexfec_receive_stream_unittest.cc
+++ b/call/flexfec_receive_stream_unittest.cc
@@ -25,10 +25,10 @@
 #include "modules/rtp_rtcp/mocks/mock_rtcp_rtt_stats.h"
 #include "modules/rtp_rtcp/source/byte_io.h"
 #include "modules/rtp_rtcp/source/rtp_packet_received.h"
-#include "rtc_base/thread.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
 #include "test/mock_transport.h"
+#include "test/run_loop.h"
 
 namespace webrtc {
 
@@ -94,7 +94,7 @@
     receive_stream_->UnregisterFromTransport();
   }
 
-  AutoThread main_thread_;
+  test::RunLoop main_thread_;
   MockTransport rtcp_send_transport_;
   MockRtcEventLog log_;
   FlexfecReceiveStream::Config config_;
diff --git a/call/rtp_transport_controller_send_unittest.cc b/call/rtp_transport_controller_send_unittest.cc
index 3e07614..5bf29ea7 100644
--- a/call/rtp_transport_controller_send_unittest.cc
+++ b/call/rtp_transport_controller_send_unittest.cc
@@ -23,10 +23,10 @@
 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
 #include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h"
 #include "rtc_base/containers/flat_map.h"
-#include "rtc_base/thread.h"
 #include "test/create_test_environment.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
+#include "test/run_loop.h"
 
 namespace webrtc {
 namespace {
@@ -102,7 +102,7 @@
 
 TEST(RtpTransportControllerSendTest,
      IgnoresFeedbackForReportedReceivedPacketThatWereNotSent) {
-  AutoThread main_thread;
+  test::RunLoop main_thread;
   RtpTransportControllerSend transport({.env = CreateTestEnvironment()});
   transport.SetPreferredRtcpCcAckType(RtcpFeedbackType::CCFB);
   PacketSender sender(transport);
@@ -131,7 +131,7 @@
      AccumulatesNumberOfReportedReceivedPacketsPerSsrcPerEcnMarkingType) {
   constexpr uint32_t kSsrc1 = 1'000;
   constexpr uint32_t kSsrc2 = 2'000;
-  AutoThread main_thread;
+  test::RunLoop main_thread;
   RtpTransportControllerSend transport({.env = CreateTestEnvironment()});
   transport.SetPreferredRtcpCcAckType(RtcpFeedbackType::CCFB);
 
@@ -176,7 +176,7 @@
 }
 
 TEST(RtpTransportControllerSendTest, CalculatesNumberOfBleachedPackets) {
-  AutoThread main_thread;
+  test::RunLoop main_thread;
   RtpTransportControllerSend transport({.env = CreateTestEnvironment()});
   transport.SetPreferredRtcpCcAckType(RtcpFeedbackType::CCFB);
   PacketSender sender(transport);
@@ -211,7 +211,7 @@
 
 TEST(RtpTransportControllerSendTest,
      AccumulatesNumberOfReportedLostAndRecoveredPackets) {
-  AutoThread main_thread;
+  test::RunLoop main_thread;
   RtpTransportControllerSend transport({.env = CreateTestEnvironment()});
   transport.SetPreferredRtcpCcAckType(RtcpFeedbackType::CCFB);
 
@@ -258,7 +258,7 @@
 
 TEST(RtpTransportControllerSendTest,
      DoesNotCountGapsInSequenceNumberBetweenReportsAsLoss) {
-  AutoThread main_thread;
+  test::RunLoop main_thread;
   RtpTransportControllerSend transport({.env = CreateTestEnvironment()});
   transport.SetPreferredRtcpCcAckType(RtcpFeedbackType::CCFB);