Decouple //rtc_base:rtc_base_tests_utils from gunit.

This CL decouples //rtc_base:rtc_base_tests_utils from gunit by
moving gunit helpers (rtc_base/gunit.h) and rtc_base/testclient.h
(which depends on gunit helpers) to their own build target.

It also removes some unused dependencies in the WebRTC build graph.

Bug: None
Change-Id: Ia9820e84ff697da39b351eef73c45f6e4bdf2623
Reviewed-on: https://webrtc-review.googlesource.com/c/111861
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25769}
diff --git a/BUILD.gn b/BUILD.gn
index 554c5b8..249094b 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -58,7 +58,6 @@
         "modules/video_capture:video_capture_internal_impl",
         "pc:peerconnection_unittests",
         "pc:rtc_pc_unittests",
-        "rtc_base:rtc_base_tests_utils",
         "stats:rtc_stats_unittests",
         "system_wrappers:system_wrappers_unittests",
         "test",
@@ -476,7 +475,6 @@
       "p2p:rtc_p2p_unittests",
       "rtc_base:rtc_base_approved_unittests",
       "rtc_base:rtc_base_tests_main",
-      "rtc_base:rtc_base_tests_utils",
       "rtc_base:rtc_base_unittests",
       "rtc_base:rtc_json_unittests",
       "rtc_base:rtc_numerics_unittests",
@@ -544,7 +542,6 @@
       # should move them to a more appropriate test suite.
       "call:call_tests",
       "modules/video_capture",
-      "rtc_base:rtc_base_tests_utils",
       "test:test_common",
       "test:test_main",
       "test:video_test_common",
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 22f6b2e..fe27c7b 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -674,8 +674,8 @@
       ":libjingle_peerconnection_api",
       ":loopback_media_transport",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base_approved",
-      "../rtc_base:rtc_base_tests_utils",
       "../test:test_support",
       "units:units_unittests",
     ]
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index c835f24..37a7e07 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -150,6 +150,7 @@
       "../logging:mocks",
       "../logging:rtc_event_log_api",
       "../modules/audio_device:mock_audio_device",
+      "../rtc_base:rtc_base_tests_utils",
 
       # For TestAudioDeviceModule
       "../modules/audio_device:audio_device_impl",
@@ -163,7 +164,6 @@
       "../modules/utility",
       "../rtc_base:checks",
       "../rtc_base:rtc_base_approved",
-      "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:rtc_task_queue",
       "../rtc_base:safe_compare",
       "../system_wrappers:system_wrappers",
diff --git a/media/BUILD.gn b/media/BUILD.gn
index ea23433..b6f98c6 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -457,6 +457,7 @@
       "../modules/video_coding:video_coding_utility",
       "../p2p:rtc_p2p",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_task_queue",
       "../rtc_base:stringutils",
       "//third_party/abseil-cpp/absl/memory",
@@ -507,7 +508,6 @@
       "../call:mock_rtp_interfaces",
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
-      "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:rtc_task_queue_for_test",
       "../rtc_base/third_party/sigslot",
       "../test:test_support",
@@ -554,6 +554,8 @@
       "../pc:rtc_pc",
       "../pc:rtc_pc_base",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
+      "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:rtc_task_queue",
       "../rtc_base:stringutils",
       "../test:field_trial",
@@ -656,7 +658,6 @@
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_main",
-      "../rtc_base:rtc_base_tests_utils",
       "../test:audio_codec_mocks",
       "../test:test_support",
       "../test:video_test_common",
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 3422665..db71079 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -1134,7 +1134,6 @@
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base",
     "../../rtc_base:rtc_base_approved",
-    "../../rtc_base:rtc_base_tests_utils",
     "../../rtc_base/system:arch",
     "../../test:rtp_test_utils",
     "../rtp_rtcp",
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index 4ea1e75..66b07df 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -414,6 +414,7 @@
       "../../rtc_base:protobuf_utils",
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
+      "../../rtc_base:rtc_base_tests_utils",
       "../../rtc_base:safe_minmax",
       "../../rtc_base/system:arch",
       "../../rtc_base/system:file_wrapper",
@@ -459,7 +460,6 @@
         ":audioproc_unittest_proto",
         ":runtime_settings_protobuf_utils",
         "../../api/audio:audio_frame_api",
-        "../../rtc_base:rtc_base_tests_utils",
         "../../rtc_base:rtc_task_queue",
         "aec_dump",
         "aec_dump:aec_dump_unittests",
diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn
index 22fd9db..5431a15 100644
--- a/modules/audio_processing/agc2/BUILD.gn
+++ b/modules/audio_processing/agc2/BUILD.gn
@@ -192,8 +192,8 @@
     "../../../api:array_view",
     "../../../common_audio",
     "../../../rtc_base:checks",
+    "../../../rtc_base:gunit_helpers",
     "../../../rtc_base:rtc_base_approved",
-    "../../../rtc_base:rtc_base_tests_utils",
   ]
 }
 
@@ -204,7 +204,7 @@
   ]
   deps = [
     ":biquad_filter",
-    "../../../rtc_base:rtc_base_tests_utils",
+    "../../../rtc_base:gunit_helpers",
   ]
 }
 
@@ -232,8 +232,8 @@
     "../../../api:array_view",
     "../../../common_audio",
     "../../../rtc_base:checks",
+    "../../../rtc_base:gunit_helpers",
     "../../../rtc_base:rtc_base_approved",
-    "../../../rtc_base:rtc_base_tests_utils",
     "../../../system_wrappers:metrics",
     "//third_party/abseil-cpp/absl/memory",
   ]
@@ -254,8 +254,8 @@
     "..:audio_frame_view",
     "../../../api:array_view",
     "../../../rtc_base:checks",
+    "../../../rtc_base:gunit_helpers",
     "../../../rtc_base:rtc_base_approved",
-    "../../../rtc_base:rtc_base_tests_utils",
   ]
 }
 
@@ -267,7 +267,7 @@
   deps = [
     ":rnn_vad_with_level",
     "..:audio_frame_view",
-    "../../../rtc_base:rtc_base_tests_utils",
+    "../../../rtc_base:gunit_helpers",
   ]
 }
 
diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn
index c2e4ea2..73d81f1 100644
--- a/modules/congestion_controller/BUILD.gn
+++ b/modules/congestion_controller/BUILD.gn
@@ -110,7 +110,6 @@
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
-      "../../rtc_base:rtc_base_tests_utils",
       "../../rtc_base/network:sent_packet",
       "../../system_wrappers",
       "../../test:field_trial",
diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn
index 394f3c3..38169bb 100644
--- a/modules/congestion_controller/goog_cc/BUILD.gn
+++ b/modules/congestion_controller/goog_cc/BUILD.gn
@@ -237,7 +237,6 @@
       "../../../logging:mocks",
       "../../../rtc_base:checks",
       "../../../rtc_base:rtc_base_approved",
-      "../../../rtc_base:rtc_base_tests_utils",
       "../../../rtc_base/experiments:alr_experiment",
       "../../../system_wrappers",
       "../../../system_wrappers:field_trial",
diff --git a/modules/congestion_controller/rtp/BUILD.gn b/modules/congestion_controller/rtp/BUILD.gn
index 5ee6b4f..bffe1f8 100644
--- a/modules/congestion_controller/rtp/BUILD.gn
+++ b/modules/congestion_controller/rtp/BUILD.gn
@@ -131,7 +131,6 @@
       "../../../rtc_base:checks",
       "../../../rtc_base:rtc_base",
       "../../../rtc_base:rtc_base_approved",
-      "../../../rtc_base:rtc_base_tests_utils",
       "../../../rtc_base/network:sent_packet",
       "../../../system_wrappers",
       "../../../test:field_trial",
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index f0033f1..29e633c 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -140,6 +140,7 @@
       ":rtc_p2p",
       "../api:libjingle_peerconnection_api",
       "../api:ortc_api",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_utils",
@@ -181,10 +182,12 @@
       ":rtc_p2p",
       "../api:ortc_api",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:stringutils",
+      "../rtc_base:testclient",
       "../system_wrappers:metrics",
       "../test:test_support",
       "//testing/gtest",
@@ -225,6 +228,7 @@
       ":p2p_test_utils",
       ":rtc_p2p",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_tests_utils",
       "//testing/gtest",
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 61df92f..65ab33a 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -279,6 +279,7 @@
       "../p2p:p2p_test_utils",
       "../p2p:rtc_p2p",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_main",
@@ -318,6 +319,7 @@
       "../p2p:p2p_test_utils",
       "../p2p:rtc_p2p",
       "../pc:peerconnection",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_utils",
@@ -380,9 +382,9 @@
       "../modules/audio_processing:audio_processing",
       "../p2p:p2p_test_utils",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
-      "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:rtc_task_queue",
       "../rtc_base/third_party/sigslot",
       "../test:test_support",
@@ -460,6 +462,8 @@
       "../api/units:time_delta",
       "../logging:fake_rtc_event_log",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
+      "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:stringutils",
       "../rtc_base/third_party/base64",
       "../system_wrappers:metrics",
@@ -504,7 +508,6 @@
       "../rtc_base:rtc_base",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_main",
-      "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:rtc_task_queue",
       "../rtc_base:safe_conversions",
       "../test:audio_codec_mocks",
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index ae89107..f188d47 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -934,11 +934,41 @@
   ]
 }
 
+rtc_source_set("gunit_helpers") {
+  testonly = true
+  sources = [
+    "gunit.cc",
+    "gunit.h",
+  ]
+  deps = [
+    ":logging",
+    ":rtc_base",
+    ":rtc_base_tests_utils",
+    ":stringutils",
+    "../test:test_support",
+  ]
+}
+
+rtc_source_set("testclient") {
+  testonly = true
+  sources = [
+    "testclient.cc",
+    "testclient.h",
+  ]
+  deps = [
+    ":criticalsection",
+    ":gunit_helpers",
+    ":macromagic",
+    ":rtc_base",
+    ":rtc_base_tests_utils",
+    ":timeutils",
+    "//third_party/abseil-cpp/absl/memory:memory",
+  ]
+}
+
 rtc_source_set("rtc_base_tests_utils") {
   testonly = true
   sources = [
-    # Also use this as a convenient dumping ground for misc files that are
-    # included by multiple targets below.
     "cpu_time.cc",
     "cpu_time.h",
     "fake_mdns_responder.h",
@@ -949,8 +979,6 @@
     "fakesslidentity.h",
     "firewallsocketserver.cc",
     "firewallsocketserver.h",
-    "gunit.cc",
-    "gunit.h",
     "memory_stream.cc",
     "memory_stream.h",
     "memory_usage.cc",
@@ -969,8 +997,6 @@
     "socketstream.h",
     "testbase64.h",
     "testcertificateverifier.h",
-    "testclient.cc",
-    "testclient.h",
     "testechoserver.cc",
     "testechoserver.h",
     "testutils.cc",
@@ -981,16 +1007,10 @@
   deps = [
     ":checks",
     ":rtc_base",
-    ":stringutils",
     "../api/units:time_delta",
-    "../test:test_support",
-    "system:fallthrough",
     "third_party/sigslot",
     "//third_party/abseil-cpp/absl/memory",
   ]
-  public_deps = [
-    "//testing/gtest",
-  ]
 }
 
 rtc_source_set("rtc_task_queue_for_test") {
@@ -1015,6 +1035,7 @@
       "sigslot_unittest.cc",
     ]
     deps = [
+      ":gunit_helpers",
       ":rtc_base",
       ":rtc_base_tests_utils",
       "third_party/sigslot",
@@ -1027,6 +1048,7 @@
       "unittest_main.cc",
     ]
     deps = [
+      ":gunit_helpers",
       ":rtc_base",
       ":rtc_base_approved",
       ":rtc_base_tests_utils",
@@ -1055,9 +1077,11 @@
     ]
     deps = [
       ":checks",
+      ":gunit_helpers",
       ":rtc_base",
       ":rtc_base_tests_main",
       ":rtc_base_tests_utils",
+      ":testclient",
       "../system_wrappers:system_wrappers",
       "../test:fileutils",
       "../test:test_support",
@@ -1124,6 +1148,7 @@
     }
     deps = [
       ":checks",
+      ":gunit_helpers",
       ":rate_limiter",
       ":rtc_base",
       ":rtc_base_approved",
@@ -1134,6 +1159,7 @@
       ":safe_minmax",
       ":sanitizer",
       ":stringutils",
+      ":testclient",
       "../api:array_view",
       "../system_wrappers:system_wrappers",
       "../test:fileutils",
@@ -1153,6 +1179,7 @@
       "task_queue_unittest.cc",
     ]
     deps = [
+      ":gunit_helpers",
       ":rtc_base_approved",
       ":rtc_base_tests_main",
       ":rtc_base_tests_utils",
@@ -1186,6 +1213,7 @@
       "weak_ptr_unittest.cc",
     ]
     deps = [
+      ":gunit_helpers",
       ":rtc_base_approved",
       ":rtc_base_tests_main",
       ":rtc_base_tests_utils",
@@ -1221,6 +1249,7 @@
       "strings/json_unittest.cc",
     ]
     deps = [
+      ":gunit_helpers",
       ":rtc_base_tests_main",
       ":rtc_base_tests_utils",
       ":rtc_json",
@@ -1272,9 +1301,11 @@
     }
     deps = [
       ":checks",
+      ":gunit_helpers",
       ":rtc_base_tests_main",
       ":rtc_base_tests_utils",
       ":stringutils",
+      ":testclient",
       "../api:array_view",
       "../test:fileutils",
       "../test:test_support",
diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn
index 35d1da9..d36a43e 100644
--- a/rtc_base/experiments/BUILD.gn
+++ b/rtc_base/experiments/BUILD.gn
@@ -129,6 +129,7 @@
       ":normalize_simulcast_size_experiment",
       ":quality_scaling_experiment",
       ":rtt_mult_experiment",
+      "..:gunit_helpers",
       "../:rtc_base_tests_main",
       "../:rtc_base_tests_utils",
       "../../system_wrappers:field_trial",
diff --git a/rtc_base/testutils.h b/rtc_base/testutils.h
index 6b3733f..ac74203 100644
--- a/rtc_base/testutils.h
+++ b/rtc_base/testutils.h
@@ -19,7 +19,6 @@
 #include <vector>
 #include "rtc_base/asyncsocket.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/gunit.h"
 #include "rtc_base/stream.h"
 
 namespace webrtc {
diff --git a/rtc_tools/network_tester/BUILD.gn b/rtc_tools/network_tester/BUILD.gn
index af84903..47b8143 100644
--- a/rtc_tools/network_tester/BUILD.gn
+++ b/rtc_tools/network_tester/BUILD.gn
@@ -6,8 +6,8 @@
 # in the file PATENTS.  All contributing project authors may
 # be found in the AUTHORS file in the root of the source tree.
 
-import("../../webrtc.gni")
 import("//third_party/protobuf/proto_library.gni")
+import("../../webrtc.gni")
 
 if (rtc_enable_protobuf) {
   proto_library("network_tester_config_proto") {
@@ -81,7 +81,7 @@
 
     deps = [
       ":network_tester",
-      "../../rtc_base:rtc_base_tests_utils",
+      "../../rtc_base:gunit_helpers",
       "../../test:fileutils",
       "../../test:test_support",
       "//testing/gtest",
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 4f67d18..60ea473 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -1073,8 +1073,8 @@
             "../media:rtc_media_base",
             "../media:rtc_media_tests_utils",
             "../modules:module_api",
+            "../rtc_base:gunit_helpers",
             "../rtc_base:rtc_base",
-            "../rtc_base:rtc_base_tests_utils",
             "../system_wrappers:system_wrappers",
             "//third_party/libyuv",
           ]
@@ -1193,7 +1193,7 @@
           "../modules/audio_processing:api",
           "../modules/audio_processing:audio_processing",
           "../modules/video_coding:video_codec_interface",
-          "../rtc_base:rtc_base_tests_utils",
+          "../rtc_base:gunit_helpers",
           "../rtc_base/system:unused",
           "../test:test_support",
           "//third_party/ocmock",
diff --git a/stats/BUILD.gn b/stats/BUILD.gn
index bd19952..c67a5be 100644
--- a/stats/BUILD.gn
+++ b/stats/BUILD.gn
@@ -57,9 +57,9 @@
       ":rtc_stats_test_utils",
       "../api:rtc_stats_api",
       "../rtc_base:checks",
+      "../rtc_base:gunit_helpers",
       "../rtc_base:rtc_base_approved",
       "../rtc_base:rtc_base_tests_main",
-      "../rtc_base:rtc_base_tests_utils",
       "../rtc_base:rtc_json",
     ]
 
diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn
index 1909c8a..43de5f9 100644
--- a/test/fuzzers/BUILD.gn
+++ b/test/fuzzers/BUILD.gn
@@ -6,9 +6,9 @@
 # in the file PATENTS.  All contributing project authors may
 # be found in the AUTHORS file in the root of the source tree.
 
-import("../../webrtc.gni")
 import("//build/config/features.gni")
 import("//testing/libfuzzer/fuzzer_test.gni")
+import("../../webrtc.gni")
 
 rtc_static_library("webrtc_fuzzer_main") {
   sources = [
@@ -364,7 +364,6 @@
     "../../modules/audio_coding:pcm16b",
     "../../modules/rtp_rtcp:rtp_rtcp_format",
     "../../rtc_base:rtc_base_approved",
-    "../../rtc_base:rtc_base_tests_utils",
   ]
 }
 
@@ -379,7 +378,6 @@
     "../../modules/audio_coding:neteq_tools_minimal",
     "../../modules/audio_coding:pcm16b",
     "../../rtc_base:rtc_base_approved",
-    "../../rtc_base:rtc_base_tests_utils",
   ]
 }
 
diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn
index 622827f..e9bda51 100644
--- a/test/scenario/BUILD.gn
+++ b/test/scenario/BUILD.gn
@@ -116,7 +116,6 @@
       "../../logging:mocks",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base_approved",
-      "../../rtc_base:rtc_base_tests_utils",
       "../../system_wrappers",
       "../../system_wrappers:field_trial",
       "../../test:field_trial",