Migrate test_support_unittests to rtc_test_suite

This keeps some larger test groups around, these can be further split
later.

Test count remains the same as before.

Before:
test_support_unittests / TotalTestCount= {mean=500, stddev=-} Count (BiggerIsBetter)
test_support_unittests / RunTestCount= {mean=492, stddev=-} Count (BiggerIsBetter)
test_support_unittests / DisabledTestCount= {mean=8, stddev=-} Count (SmallerIsBetter)

After:
RESULT: test_support_unittests / TotalTestCount= {mean=500, stddev=-} Count (BiggerIsBetter)
RESULT: test_support_unittests / RunTestCount= {mean=492, stddev=-} Count (BiggerIsBetter)
RESULT: test_support_unittests / DisabledTestCount= {mean=8, stddev=-} Count (SmallerIsBetter)

Bug: webrtc:498394143
Change-Id: I552f65f6e5e6708a132393fd05cd329c6a6a6964
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/468621
Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#47603}
diff --git a/BUILD.gn b/BUILD.gn
index b6d3d04..317acec 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -134,6 +134,7 @@
       "//call:call_tests",
       "//call/adaptation:resource_adaptation_tests",
       "//pc:peerconnection_unittests",
+      "//test:test_support_unittests",
       "//video:video_tests",
       "//video/adaptation:video_adaptation_tests",
     ]
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 97bfc93..0825d6f 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -681,8 +681,7 @@
       }
     }
 
-    rtc_library("fixed_fps_video_frame_writer_adapter_test") {
-      testonly = true
+    rtc_cc_test("fixed_fps_video_frame_writer_adapter_test") {
       sources = [ "testsupport/fixed_fps_video_frame_writer_adapter_test.cc" ]
       deps = [
         ":fixed_fps_video_frame_writer_adapter",
@@ -699,92 +698,558 @@
       ]
     }
 
-    rtc_test("test_support_unittests") {
+    rtc_cc_test("call_config_utils_unittest") {
+      sources = [ "call_config_utils_unittest.cc" ]
       deps = [
         ":call_config_utils",
-        ":copy_to_file_audio_capturer_unittest",
-        ":create_frame_generator_capturer",
-        ":create_test_environment",
-        ":create_test_field_trials",
-        ":direct_transport",
-        ":fake_video_codecs",
-        ":fileutils",
-        ":fileutils_unittests",
-        ":fixed_fps_video_frame_writer_adapter_test",
-        ":frame_generator_capturer",
-        ":frame_generator_impl",
-        ":near_matcher",
-        ":perf_test",
-        ":rtc_expect_death",
-        ":rtp_test_utils",
-        ":run_loop",
         ":test_support",
-        ":test_support_test_artifacts",
-        ":video_codec_tester",
-        ":video_frame_matcher",
-        ":video_frame_writer",
-        ":video_test_common",
-        ":video_test_support",
-        ":wait_until",
-        ":y4m_frame_generator",
-        "../api:create_frame_generator",
-        "../api:create_simulcast_test_fixture_api",
-        "../api:create_time_controller",
-        "../api:field_trials",
-        "../api:frame_generator_api",
-        "../api:mock_video_codec_factory",
-        "../api:mock_video_decoder",
-        "../api:mock_video_encoder",
-        "../api:rtc_error",
-        "../api:rtc_error_matchers",
         "../api:rtp_headers",
+        "../call:video_receive_stream_api",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("create_test_field_trials_unittest") {
+      sources = [ "create_test_field_trials_unittest.cc" ]
+      deps = [
+        ":create_test_field_trials",
+        ":test_support",
+        "../api:field_trials",
+        "//third_party/abseil-cpp/absl/flags:flag",
+        "//third_party/abseil-cpp/absl/strings:string_view",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("direct_transport_unittest") {
+      sources = [ "direct_transport_unittest.cc" ]
+      deps = [
+        ":direct_transport",
+        ":test_support",
         "../api:rtp_parameters",
-        "../api:scoped_refptr",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("fake_vp8_encoder_unittest") {
+      sources = [ "fake_vp8_encoder_unittest.cc" ]
+      deps = [
+        ":fake_video_codecs",
+        ":test_support",
+        "../api:create_simulcast_test_fixture_api",
         "../api:simulcast_test_fixture_api",
-        "../api:time_controller",
         "../api/environment",
-        "../api/environment:environment_factory",
-        "../api/numerics",
-        "../api/task_queue",
-        "../api/task_queue:task_queue_test",
         "../api/test/video:function_video_factory",
-        "../api/test/video:video_frame_writer",
-        "../api/units:data_rate",
-        "../api/units:data_size",
-        "../api/units:frequency",
+        "../api/video_codecs:video_codecs_api",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("frame_generator_capturer_unittest") {
+      sources = [ "frame_generator_capturer_unittest.cc" ]
+      deps = [
+        ":create_frame_generator_capturer",
+        ":frame_generator_capturer",
+        ":test_support",
         "../api/units:time_delta",
         "../api/units:timestamp",
+        "../api/video:video_frame",
+        "time_controller",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("frame_generator_unittest") {
+      sources = [ "frame_generator_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        "../api:create_frame_generator",
+        "../api:frame_generator_api",
+        "../api:scoped_refptr",
+        "../api/video:video_frame",
+        "../rtc_base:checks",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("near_matcher_unittest") {
+      sources = [ "near_matcher_unittest.cc" ]
+      deps = [
+        ":near_matcher",
+        ":test_support",
+        "../api/units:data_rate",
+        "../api/units:time_delta",
+        "../api/units:timestamp",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("rtp_file_reader_unittest") {
+      sources = [ "rtp_file_reader_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":rtp_test_utils",
+        ":test_support",
+        "../modules/rtp_rtcp:rtp_rtcp_format",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("rtp_file_writer_unittest") {
+      sources = [ "rtp_file_writer_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":rtp_test_utils",
+        ":test_support",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("run_loop_unittest") {
+      sources = [ "run_loop_unittest.cc" ]
+      deps = [
+        ":create_test_environment",
+        ":run_loop",
+        ":test_support",
+        "../api/environment",
+        "../api/task_queue",
+        "../api/units:time_delta",
+        "../api/units:timestamp",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("ivf_frame_reader_unittest") {
+      sources = [ "testsupport/ivf_frame_reader_unittest.cc" ]
+      deps = [
+        ":create_test_environment",
+        ":fileutils",
+        ":test_support",
+        ":video_test_common",
+        ":video_test_support",
+        "../api:create_frame_generator",
+        "../api:frame_generator_api",
+        "../api:scoped_refptr",
+        "../api/environment",
+        "../api/units:time_delta",
         "../api/video:encoded_image",
         "../api/video:resolution",
         "../api/video:video_bitrate_allocation",
         "../api/video:video_frame",
-        "../api/video:video_frame_type",
-        "../api/video_codecs:builtin_video_decoder_factory",
-        "../api/video_codecs:builtin_video_encoder_factory",
-        "../api/video_codecs:scalability_mode",
         "../api/video_codecs:video_codecs_api",
-        "../call:video_receive_stream_api",
-        "../common_video",
-        "../media:codec",
-        "../media:media_constants",
         "../modules/rtp_rtcp:rtp_rtcp_format",
-        "../modules/video_coding:simulcast_test_fixture_impl",
         "../modules/video_coding:video_codec_interface",
         "../modules/video_coding:video_coding_utility",
         "../modules/video_coding:webrtc_h264",
         "../modules/video_coding:webrtc_vp8",
         "../modules/video_coding:webrtc_vp9",
         "../modules/video_coding/codecs/av1:libaom_av1_encoder",
-        "../modules/video_coding/svc:scalability_mode_util",
         "../rtc_base:checks",
-        "../rtc_base:criticalsection",
         "../rtc_base:macromagic",
-        "../rtc_base:rtc_base_tests_utils",
         "../rtc_base:rtc_event",
-        "../rtc_base:threading",
         "../rtc_base/synchronization:mutex",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("ivf_video_frame_generator_unittest") {
+      sources = [ "testsupport/ivf_video_frame_generator_unittest.cc" ]
+      deps = [
+        ":create_test_environment",
+        ":fileutils",
+        ":frame_generator_impl",
+        ":test_support",
+        ":video_test_common",
+        "../api:create_frame_generator",
+        "../api:frame_generator_api",
+        "../api:scoped_refptr",
+        "../api/environment",
+        "../api/units:time_delta",
+        "../api/video:encoded_image",
+        "../api/video:video_bitrate_allocation",
+        "../api/video:video_frame",
+        "../api/video_codecs:video_codecs_api",
+        "../common_video",
+        "../modules/rtp_rtcp:rtp_rtcp_format",
+        "../modules/video_coding:video_codec_interface",
+        "../modules/video_coding:video_coding_utility",
+        "../modules/video_coding:webrtc_h264",
+        "../modules/video_coding:webrtc_vp8",
+        "../modules/video_coding:webrtc_vp9",
+        "../rtc_base:checks",
+        "../rtc_base:macromagic",
+        "../rtc_base:rtc_event",
+        "../rtc_base/synchronization:mutex",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("perf_test_unittest") {
+      sources = [ "testsupport/perf_test_unittest.cc" ]
+      deps = [
+        ":perf_test",
+        ":rtc_expect_death",
+        ":test_support",
+        "../api/numerics",
+        "../api/units:timestamp",
+        "//third_party/catapult/tracing/tracing:histogram",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("test_artifacts_unittest") {
+      sources = [ "testsupport/test_artifacts_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        ":test_support_test_artifacts",
         "../rtc_base/system:file_wrapper",
+        "//third_party/abseil-cpp/absl/flags:flag",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("video_frame_writer_unittest") {
+      sources = [ "testsupport/video_frame_writer_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        ":video_frame_writer",
+        ":video_test_support",
+        "../api:scoped_refptr",
+        "../api/test/video:video_frame_writer",
+        "../api/video:resolution",
+        "../api/video:video_frame",
+        "//third_party/abseil-cpp/absl/strings:string_view",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("y4m_frame_generator_test") {
+      sources = [ "testsupport/y4m_frame_generator_test.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        ":y4m_frame_generator",
+        "../api:frame_generator_api",
+        "//third_party/abseil-cpp/absl/strings:string_view",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("y4m_frame_reader_unittest") {
+      sources = [ "testsupport/y4m_frame_reader_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        ":video_test_support",
+        "../api:scoped_refptr",
+        "../api/video:resolution",
+        "../api/video:video_frame",
+        "//third_party/abseil-cpp/absl/strings:string_view",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("y4m_frame_writer_unittest") {
+      sources = [ "testsupport/y4m_frame_writer_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        ":video_frame_writer",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("yuv_frame_reader_unittest") {
+      sources = [ "testsupport/yuv_frame_reader_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        ":video_test_support",
+        "../api:scoped_refptr",
+        "../api/video:resolution",
+        "../api/video:video_frame",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("yuv_frame_writer_unittest") {
+      sources = [ "testsupport/yuv_frame_writer_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        ":video_frame_writer",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("video_codec_tester_unittest") {
+      sources = [ "video_codec_tester_unittest.cc" ]
+      deps = [
+        ":create_test_environment",
+        ":fileutils",
+        ":test_support",
+        ":video_codec_tester",
+        "../api:mock_video_codec_factory",
+        "../api:mock_video_decoder",
+        "../api:mock_video_encoder",
+        "../api:scoped_refptr",
+        "../api/environment",
+        "../api/units:data_rate",
+        "../api/units:data_size",
+        "../api/units:frequency",
+        "../api/units:time_delta",
+        "../api/video:encoded_image",
+        "../api/video:video_frame",
+        "../api/video:video_frame_type",
+        "../api/video_codecs:builtin_video_decoder_factory",
+        "../api/video_codecs:builtin_video_encoder_factory",
+        "../api/video_codecs:scalability_mode",
+        "../api/video_codecs:video_codecs_api",
+        "../modules/video_coding:video_codec_interface",
+        "../modules/video_coding/svc:scalability_mode_util",
+        "//third_party/libyuv",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("video_frame_matcher_unittest") {
+      sources = [ "video_frame_matcher_unittest.cc" ]
+      deps = [
+        ":test_support",
+        ":video_frame_matcher",
+        "../api/video:video_frame",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    rtc_cc_test("wait_until_unittest") {
+      sources = [ "wait_until_unittest.cc" ]
+      deps = [
+        ":run_loop",
+        ":test_support",
+        ":wait_until",
+        "../api:create_time_controller",
+        "../api:rtc_error",
+        "../api:rtc_error_matchers",
+        "../api:time_controller",
+        "../api/task_queue",
+        "../api/units:time_delta",
+        "../api/units:timestamp",
+        "../rtc_base:rtc_base_tests_utils",
         "../system_wrappers",
+      ]
+      data = test_support_unittests_resources
+      if (is_ios) {
+        deps += [ ":test_support_unittests_bundle_data" ]
+      }
+      if (!is_android) {
+        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+      }
+    }
+
+    if (rtc_enable_protobuf) {
+      rtc_cc_test("perf_test_histogram_writer_unittest") {
+        sources = [ "testsupport/perf_test_histogram_writer_unittest.cc" ]
+        deps = [
+          ":perf_test",
+          ":test_support",
+          "//third_party/catapult/tracing/tracing:histogram",
+        ]
+        data = test_support_unittests_resources
+        if (is_ios) {
+          deps += [ ":test_support_unittests_bundle_data" ]
+        }
+        if (!is_android) {
+          deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+        }
+      }
+    }
+
+    rtc_cc_test("fileutils_unittests") {
+      sources = [ "testsupport/file_utils_unittest.cc" ]
+      deps = [
+        ":fileutils",
+        ":test_support",
+        "../rtc_base:checks",
+        "../rtc_base:crypto_random",
+        "//third_party/abseil-cpp/absl/strings:string_view",
+      ]
+    }
+
+    rtc_cc_test("copy_to_file_audio_capturer_unittest") {
+      sources = [ "testsupport/copy_to_file_audio_capturer_unittest.cc" ]
+      deps = [
+        ":copy_to_file_audio_capturer",
+        ":fileutils",
+        ":test_support",
+        "../modules/audio_device:test_audio_device_module",
+        "../rtc_base:buffer",
+      ]
+    }
+
+    rtc_test_suite("test_support_unittests") {
+      tests = [
+        ":call_config_utils_unittest",
+        ":create_test_field_trials_unittest",
+        ":direct_transport_unittest",
+        ":fake_vp8_encoder_unittest",
+        ":frame_generator_capturer_unittest",
+        ":frame_generator_unittest",
+        ":near_matcher_unittest",
+        ":rtp_file_reader_unittest",
+        ":rtp_file_writer_unittest",
+        ":run_loop_unittest",
+        ":ivf_frame_reader_unittest",
+        ":ivf_video_frame_generator_unittest",
+        ":perf_test_unittest",
+        ":test_artifacts_unittest",
+        ":video_frame_writer_unittest",
+        ":y4m_frame_generator_test",
+        ":y4m_frame_reader_unittest",
+        ":y4m_frame_writer_unittest",
+        ":yuv_frame_reader_unittest",
+        ":yuv_frame_writer_unittest",
+        ":video_codec_tester_unittest",
+        ":video_frame_matcher_unittest",
+        ":wait_until_unittest",
+        ":copy_to_file_audio_capturer_unittest",
+        ":fileutils_unittests",
+        ":fixed_fps_video_frame_writer_adapter_test",
         "fuzzers:fuzz_data_helper_unittest",
         "jitter:jitter_unittests",
         "pc/e2e:e2e_unittests",
@@ -793,56 +1258,10 @@
         "peer_scenario/bwe_integration_tests",
         "peer_scenario/tests",
         "scenario:scenario_unittests",
-        "time_controller",
         "time_controller:time_controller_unittests",
-        "//third_party/abseil-cpp/absl/flags:flag",
-        "//third_party/abseil-cpp/absl/strings:string_view",
-        "//third_party/libyuv",
       ]
-      sources = [
-        "call_config_utils_unittest.cc",
-        "create_test_field_trials_unittest.cc",
-        "direct_transport_unittest.cc",
-        "fake_vp8_encoder_unittest.cc",
-        "frame_generator_capturer_unittest.cc",
-        "frame_generator_unittest.cc",
-        "near_matcher_unittest.cc",
-        "rtp_file_reader_unittest.cc",
-        "rtp_file_writer_unittest.cc",
-        "run_loop_unittest.cc",
-        "testsupport/ivf_frame_reader_unittest.cc",
-        "testsupport/ivf_video_frame_generator_unittest.cc",
-        "testsupport/perf_test_unittest.cc",
-        "testsupport/test_artifacts_unittest.cc",
-        "testsupport/video_frame_writer_unittest.cc",
-        "testsupport/y4m_frame_generator_test.cc",
-        "testsupport/y4m_frame_reader_unittest.cc",
-        "testsupport/y4m_frame_writer_unittest.cc",
-        "testsupport/yuv_frame_reader_unittest.cc",
-        "testsupport/yuv_frame_writer_unittest.cc",
-        "video_codec_tester_unittest.cc",
-        "video_frame_matcher_unittest.cc",
-        "wait_until_unittest.cc",
-      ]
-
       if (rtc_enable_protobuf) {
-        sources += [ "testsupport/perf_test_histogram_writer_unittest.cc" ]
-        deps += [ "//third_party/catapult/tracing/tracing:histogram" ]
-      }
-
-      data = test_support_unittests_resources
-      if (is_android) {
-        shard_timeout = 900
-      }
-
-      if (is_ios) {
-        deps += [ ":test_support_unittests_bundle_data" ]
-      }
-
-      if (!is_android) {
-        # This is needed in order to avoid:
-        # undefined symbol: webrtc::videocapturemodule::VideoCaptureImpl::Create
-        deps += [ "../modules/video_capture:video_capture_internal_impl" ]
+        tests += [ ":perf_test_histogram_writer_unittest" ]
       }
     }
   }
@@ -966,19 +1385,6 @@
   deps = [ ":run_test_interface" ]
 }
 
-rtc_library("fileutils_unittests") {
-  testonly = true
-  visibility = [ ":*" ]  # Only targets in this file can depend on this.
-  sources = [ "testsupport/file_utils_unittest.cc" ]
-  deps = [
-    ":fileutils",
-    ":test_support",
-    "../rtc_base:checks",
-    "../rtc_base:crypto_random",
-    "//third_party/abseil-cpp/absl/strings:string_view",
-  ]
-}
-
 rtc_library("direct_transport") {
   visibility = [ "*" ]
   testonly = true
@@ -1284,18 +1690,6 @@
     ]
   }
 
-  rtc_library("copy_to_file_audio_capturer_unittest") {
-    testonly = true
-    sources = [ "testsupport/copy_to_file_audio_capturer_unittest.cc" ]
-    deps = [
-      ":copy_to_file_audio_capturer",
-      ":fileutils",
-      ":test_support",
-      "../modules/audio_device:test_audio_device_module",
-      "../rtc_base:buffer",
-    ]
-  }
-
   rtc_library("test_flags") {
     testonly = true
     sources = [
diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn
index f68cf15..0112423 100644
--- a/test/fuzzers/BUILD.gn
+++ b/test/fuzzers/BUILD.gn
@@ -41,8 +41,7 @@
   ]
 }
 
-rtc_library("fuzz_data_helper_unittest") {
-  testonly = true
+rtc_cc_test("fuzz_data_helper_unittest") {
   sources = [ "fuzz_data_helper_unittest.cc" ]
   deps = [
     ":fuzz_data_helper",
diff --git a/test/jitter/BUILD.gn b/test/jitter/BUILD.gn
index 08d298b..20cda40 100644
--- a/test/jitter/BUILD.gn
+++ b/test/jitter/BUILD.gn
@@ -47,8 +47,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_library("jitter_unittests") {
-    testonly = true
+  rtc_cc_test("jitter_unittests") {
     sources = [
       "delay_variation_calculator_unittest.cc",
       "logging_delay_variation_calculator_unittest.cc",
diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn
index d52cae5..0230409 100644
--- a/test/pc/e2e/BUILD.gn
+++ b/test/pc/e2e/BUILD.gn
@@ -27,9 +27,7 @@
   }
 
   if (rtc_include_tests) {
-    group("e2e_unittests") {
-      testonly = true
-
+    rtc_cc_test("e2e_unittests") {
       deps = [
         ":peer_connection_e2e_smoke_test",
         ":peer_connection_quality_test_metric_names_test",
diff --git a/test/pc/e2e/analyzer/video/BUILD.gn b/test/pc/e2e/analyzer/video/BUILD.gn
index 96b5faf..5afc2b9 100644
--- a/test/pc/e2e/analyzer/video/BUILD.gn
+++ b/test/pc/e2e/analyzer/video/BUILD.gn
@@ -35,9 +35,7 @@
   }
 
   if (rtc_include_tests) {
-    group("video_analyzer_unittests") {
-      testonly = true
-
+    rtc_cc_test("video_analyzer_unittests") {
       deps = [
         ":analyzing_video_sink_test",
         ":analyzing_video_sinks_helper_test",
diff --git a/test/pc/e2e/analyzer/video/dvqa/BUILD.gn b/test/pc/e2e/analyzer/video/dvqa/BUILD.gn
index 26d3ad9..3a16a63 100644
--- a/test/pc/e2e/analyzer/video/dvqa/BUILD.gn
+++ b/test/pc/e2e/analyzer/video/dvqa/BUILD.gn
@@ -19,12 +19,22 @@
   }
 
   if (rtc_include_tests) {
-    group("dvqa_unittests") {
-      testonly = true
-
+    rtc_cc_test("dvqa_unittests") {
+      sources = [
+        "frames_storage_test.cc",
+        "pausable_state_test.cc",
+      ]
       deps = [
-        ":frames_storage_test",
-        ":pausable_state_test",
+        ":frames_storage",
+        ":pausable_state",
+        "../../../../..:test_support",
+        "../../../../../../api:scoped_refptr",
+        "../../../../../../api:time_controller",
+        "../../../../../../api/units:time_delta",
+        "../../../../../../api/units:timestamp",
+        "../../../../../../api/video:video_frame",
+        "../../../../../../system_wrappers",
+        "../../../../../time_controller",
       ]
     }
   }
@@ -36,7 +46,7 @@
 rtc_library("pausable_state") {
   visibility = [
     ":dvqa",
-    ":pausable_state_test",
+    ":dvqa_unittests",
     "..:default_video_quality_analyzer_internal",
   ]
 
@@ -57,7 +67,7 @@
 rtc_library("frames_storage") {
   visibility = [
     ":dvqa",
-    ":frames_storage_test",
+    ":dvqa_unittests",
     "..:default_video_quality_analyzer",
   ]
 
@@ -75,35 +85,3 @@
     "../../../../../../system_wrappers",
   ]
 }
-
-if (rtc_include_tests) {
-  rtc_library("pausable_state_test") {
-    testonly = true
-    sources = [ "pausable_state_test.cc" ]
-    deps = [
-      ":pausable_state",
-      "../../../../..:test_support",
-      "../../../../../../api:time_controller",
-      "../../../../../../api/units:time_delta",
-      "../../../../../../api/units:timestamp",
-      "../../../../../../system_wrappers",
-      "../../../../../time_controller",
-    ]
-  }
-
-  rtc_library("frames_storage_test") {
-    testonly = true
-    sources = [ "frames_storage_test.cc" ]
-    deps = [
-      ":frames_storage",
-      "../../../../..:test_support",
-      "../../../../../../api:scoped_refptr",
-      "../../../../../../api:time_controller",
-      "../../../../../../api/units:time_delta",
-      "../../../../../../api/units:timestamp",
-      "../../../../../../api/video:video_frame",
-      "../../../../../../system_wrappers",
-      "../../../../../time_controller",
-    ]
-  }
-}
diff --git a/test/peer_scenario/bwe_integration_tests/BUILD.gn b/test/peer_scenario/bwe_integration_tests/BUILD.gn
index 8badef6..240dbfb 100644
--- a/test/peer_scenario/bwe_integration_tests/BUILD.gn
+++ b/test/peer_scenario/bwe_integration_tests/BUILD.gn
@@ -9,7 +9,7 @@
 import("../../../webrtc.gni")
 
 if (rtc_include_tests) {
-  rtc_library("bwe_integration_tests") {
+  rtc_cc_test("bwe_integration_tests") {
     testonly = true
     sources = []
 
diff --git a/test/peer_scenario/tests/BUILD.gn b/test/peer_scenario/tests/BUILD.gn
index 6eeedcd..164738e 100644
--- a/test/peer_scenario/tests/BUILD.gn
+++ b/test/peer_scenario/tests/BUILD.gn
@@ -9,7 +9,7 @@
 import("../../../webrtc.gni")
 
 if (rtc_include_tests) {
-  rtc_library("tests") {
+  rtc_cc_test("tests") {
     testonly = true
     sources = [
       "peer_scenario_quality_test.cc",
diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn
index ec99e60..3e30a4a 100644
--- a/test/scenario/BUILD.gn
+++ b/test/scenario/BUILD.gn
@@ -193,7 +193,7 @@
       deps += [ ":scenario_resources_bundle_data" ]
     }
   }
-  rtc_library("scenario_unittests") {
+  rtc_cc_test("scenario_unittests") {
     testonly = true
     sources = [
       "performance_stats_unittest.cc",
diff --git a/test/time_controller/BUILD.gn b/test/time_controller/BUILD.gn
index 808bdd5..1186734 100644
--- a/test/time_controller/BUILD.gn
+++ b/test/time_controller/BUILD.gn
@@ -84,7 +84,7 @@
 }
 
 if (rtc_include_tests) {
-  rtc_library("time_controller_unittests") {
+  rtc_cc_test("time_controller_unittests") {
     testonly = true
     sources = [
       "simulated_time_controller_unittest.cc",