The goal of this CL is to separate Obj-C/Obj-C++ code from targets which have
also C++ code (see https://bugs.chromium.org/p/webrtc/issues/detail?id=7743
for more information).

We have moved .mm files out of test_support and fileutils (into test_support_objc
and fileutils_objc).

To achieve the goal for run_test and test_renderer (in the next part of the phrase
X is run_test or test_renderer) we have created 2 targets (X_objc and X_generic)
and X will act as a proxy between these targets (this way we can avoid a circular
dependency between X_generic and X_objc).

BUG=webrtc:7743

Review-Url: https://codereview.webrtc.org/2991323003
Cr-Original-Commit-Position: refs/heads/master@{#19479}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: cd95a4ec76cc607886c21144b451c1b8e871013a
diff --git a/test/BUILD.gn b/test/BUILD.gn
index f5c0afd..b7b2319 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -109,6 +109,17 @@
   ]
 }
 
+if (is_ios) {
+  rtc_source_set("test_support_objc") {
+    testonly = true
+    visibility = [ ":*" ]
+    sources = [
+      "ios/test_support.h",
+      "ios/test_support.mm",
+    ]
+  }
+}
+
 rtc_source_set("test_support") {
   testonly = true
 
@@ -124,11 +135,11 @@
     "testsupport/unittest_utils.h",
   ]
 
+  public_deps = [
+    ":fileutils",
+  ]
   if (is_ios) {
-    sources += [
-      "ios/test_support.h",
-      "ios/test_support.mm",
-    ]
+    public_deps += [ ":test_support_objc" ]
   }
 
   deps = [
@@ -141,10 +152,6 @@
     "//testing/gtest",
   ]
 
-  public_deps = [
-    ":fileutils",
-  ]
-
   if (!build_with_chromium && is_clang) {
     # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
     suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
@@ -343,8 +350,23 @@
   }
 }
 
+if (is_ios) {
+  rtc_source_set("fileutils_objc") {
+    visibility = [ ":*" ]
+    sources = [
+      "testsupport/iosfileutils.mm",
+    ]
+    deps = [
+      "..:webrtc_common",
+      "../rtc_base:rtc_base_approved",
+      "../sdk:objc_common",
+    ]
+  }
+}
+
 rtc_source_set("fileutils") {
   testonly = true
+  visibility = [ ":*" ]
   sources = [
     "testsupport/fileutils.cc",
     "testsupport/fileutils.h",
@@ -354,27 +376,58 @@
     "../rtc_base:rtc_base_approved",
   ]
   if (is_ios) {
-    sources += [ "testsupport/iosfileutils.mm" ]
-    deps += [ "../sdk:objc_common" ]
+    deps += [ ":fileutils_objc" ]
   }
   if (is_win) {
     deps += [ "../rtc_base:rtc_base" ]
   }
-  visibility = [ ":*" ]
 }
 
 rtc_source_set("run_test") {
   testonly = true
+  if (is_mac) {
+    public_deps = [
+      ":run_test_objc",
+    ]
+  } else {
+    public_deps = [
+      ":run_test_generic",
+    ]
+  }
+}
+
+rtc_source_set("run_test_interface") {
+  testonly = true
+  visibility = [ ":*" ]
   sources = [
     "run_test.h",
   ]
-  if (is_mac) {
-    sources += [ "mac/run_test.mm" ]
-  } else {
-    sources += [ "run_test.cc" ]
+}
+
+if (is_mac) {
+  rtc_source_set("run_test_objc") {
+    testonly = true
+    visibility = [ ":*" ]
+    sources = [
+      "mac/run_test.mm",
+    ]
+    public_deps = [
+      ":run_test_interface",
+    ]
   }
 }
 
+rtc_source_set("run_test_generic") {
+  testonly = true
+  visibility = [ ":*" ]
+  sources = [
+    "run_test.cc",
+  ]
+  public_deps = [
+    ":run_test_interface",
+  ]
+}
+
 rtc_source_set("fileutils_unittests") {
   testonly = true
   visibility = [ ":*" ]  # Only targets in this file can depend on this.
@@ -543,18 +596,64 @@
 
 rtc_source_set("test_renderer") {
   testonly = true
+  if (is_mac) {
+    public_deps = [
+      ":test_renderer_objc",
+    ]
+  } else {
+    public_deps = [
+      ":test_renderer_generic",
+    ]
+  }
+}
+
+if (is_mac) {
+  rtc_source_set("test_renderer_objc") {
+    testonly = true
+    visibility = [ ":*" ]
+    sources = [
+      "mac/video_renderer_mac.h",
+      "mac/video_renderer_mac.mm",
+    ]
+    public_deps = [
+      ":test_renderer_generic",
+    ]
+    deps = [
+      "../rtc_base:rtc_base_approved",
+    ]
+    libs = [
+      "Cocoa.framework",
+      "OpenGL.framework",
+      "CoreVideo.framework",
+    ]
+    if (!build_with_chromium && is_clang) {
+      # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
+      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
+    }
+  }
+}
+
+rtc_source_set("test_renderer_generic") {
+  testonly = true
+  visibility = [ ":*" ]
   libs = []
   sources = [
     "linux/glx_renderer.cc",
     "linux/glx_renderer.h",
     "linux/video_renderer_linux.cc",
-    "mac/video_renderer_mac.h",
-    "mac/video_renderer_mac.mm",
     "video_renderer.cc",
     "video_renderer.h",
     "win/d3d_renderer.cc",
     "win/d3d_renderer.h",
   ]
+  deps = [
+    ":test_support",
+    "..:webrtc_common",
+    "../common_video",
+    "../modules/media_file",
+    "../rtc_base:rtc_base_approved",
+    "//testing/gtest",
+  ]
   if (!is_linux && !is_mac && !is_win) {
     sources += [ "null_platform_renderer.cc" ]
   }
@@ -578,13 +677,6 @@
       "log",
     ]
   }
-  if (is_mac) {
-    libs = [
-      "Cocoa.framework",
-      "OpenGL.framework",
-      "CoreVideo.framework",
-    ]
-  }
 
   public_configs = [ ":test_renderer_exported_config" ]
 
@@ -592,15 +684,6 @@
     # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
     suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
   }
-
-  deps = [
-    ":test_support",
-    "..:webrtc_common",
-    "../common_video",
-    "../modules/media_file",
-    "../rtc_base:rtc_base_approved",
-    "//testing/gtest",
-  ]
 }
 
 rtc_source_set("audio_codec_mocks") {