Centralize shard_timeout=4500 android config in rtc_test definition.

this way if there is a deadlock it would get surfaced with a swarming timeout instead of being hidden if the test succeeds after a retry.

Change-Id: I9868f7d565a443602d49516a35a218619bfeba02
Bug: webrtc:524165465
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/480660
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#48009}
diff --git a/BUILD.gn b/BUILD.gn
index eead53f..4be1961 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -705,7 +705,6 @@
         "sdk/android:native_unittests",
         "sdk/android:native_unittests_java",
       ]
-      shard_timeout = 900
     }
   }
 
@@ -750,7 +749,6 @@
 
     if (is_android) {
       deps += [ "//build/android/gtest_apk:native_test_instrumentation_test_runner_java" ]
-      shard_timeout = 4500
     }
     if (is_ios) {
       deps += [ "resources:webrtc_perf_tests_bundle_data" ]
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn
index e7de9bd..4516c65 100644
--- a/common_audio/BUILD.gn
+++ b/common_audio/BUILD.gn
@@ -386,9 +386,5 @@
       "//testing/gtest",
       "//third_party/abseil-cpp/absl/base:core_headers",
     ]
-
-    if (is_android) {
-      shard_timeout = 900
-    }
   }
 }
diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn
index 5275321..868d09a 100644
--- a/common_video/BUILD.gn
+++ b/common_video/BUILD.gn
@@ -165,9 +165,6 @@
     ]
 
     data = common_video_resources
-    if (is_android) {
-      shard_timeout = 900
-    }
 
     if (is_ios) {
       deps += [ ":common_video_unittests_bundle_data" ]
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 190f162..db6d02b 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -1124,10 +1124,6 @@
 
       data = rtc_media_unittests_resources
 
-      if (is_android) {
-        shard_timeout = 900
-      }
-
       if (is_ios) {
         deps += [ ":rtc_media_unittests_bundle_data" ]
       }
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index 3517a56..f0a150f 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -60,10 +60,6 @@
 
     data_deps = [ "../resources:modules_tests_data" ]
 
-    if (is_android) {
-      shard_timeout = 900
-    }
-
     if (is_ios) {
       deps += [ "../resources:modules_tests_bundle_data" ]
     }
@@ -103,7 +99,6 @@
 
     if (is_android) {
       deps += [ "../sdk/android:libjingle_peerconnection_java" ]
-      shard_timeout = 900
     }
     if (is_ios) {
       info_plist = "../test/ios/Info.plist"
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 695889e..bb05e11 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -979,7 +979,6 @@
 
       if (is_android) {
         deps += [ "//build/android/gtest_apk:native_test_instrumentation_test_runner_java" ]
-        shard_timeout = 900
       }
       if (is_ios) {
         deps += [ ":audio_decoder_unittests_bundle_data" ]
@@ -1067,7 +1066,6 @@
 
       if (is_android) {
         deps += [ "//build/android/gtest_apk:native_test_instrumentation_test_runner_java" ]
-        shard_timeout = 900
       }
 
       if (is_ios) {
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index faa8b7d..af9ef7e 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -1005,7 +1005,6 @@
         ":android_codec_factory_helper",
         "../../sdk/android:hwcodecs_java",
       ]
-      shard_timeout = 900
     }
 
     data = [ "../../resources/FourPeople_1280x720_30.yuv" ]
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 491631b..8f0e8f3 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -4181,9 +4181,6 @@
       ":rtc_stats_integrationtest",
       ":peer_connection_field_trial_tests",
     ]
-    if (is_android) {
-      shard_timeout = 900
-    }
   }
 
   rtc_cc_test("data_channel_controller_unittest") {
@@ -4571,10 +4568,6 @@
       "//third_party/abseil-cpp/absl/strings:string_view",
     ]
 
-    if (is_android) {
-      shard_timeout = 900
-    }
-
     if (is_ios) {
       deps += [ ":svc_tests_bundle_data" ]
     }
diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn
index deea82a..4cb8e56 100644
--- a/rtc_tools/BUILD.gn
+++ b/rtc_tools/BUILD.gn
@@ -582,9 +582,6 @@
       }
 
       data = tools_unittests_resources
-      if (is_android) {
-        shard_timeout = 900
-      }
       if (is_ios) {
         deps += [ ":tools_unittests_bundle_data" ]
       }
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn
index a3e9a49..f730c86 100644
--- a/system_wrappers/BUILD.gn
+++ b/system_wrappers/BUILD.gn
@@ -86,9 +86,5 @@
       "//testing/gtest",
       "//third_party/abseil-cpp/absl/strings:string_view",
     ]
-
-    if (is_android) {
-      shard_timeout = 900
-    }
   }
 }
diff --git a/webrtc.gni b/webrtc.gni
index d053de1..0af4c7e 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -528,6 +528,10 @@
       # Do not use Chromium's launcher. native_unittests defines its own
       # JNI_OnLoad.
       use_default_launcher = false
+
+      # Without this setting some tests only succeed after the first retry.
+      # Value is high enough for webrtc_perf_tests to complete.
+      shard_timeout = 4500
       android_manifest = webrtc_root + "test/android/AndroidManifest.xml"
       use_raw_android_executable = false
       min_sdk_version = 23
@@ -1370,9 +1374,6 @@
     if (defined(invoker.data_deps)) {
       data_deps = invoker.data_deps
     }
-    if (defined(invoker.shard_timeout)) {
-      shard_timeout = invoker.shard_timeout
-    }
   }
 }
 
@@ -1443,15 +1444,10 @@
 
   assert(!defined(invoker.deps), "rtc_test_suite does not allow deps")
 
-  # TODO(webrtc:498394143): Infer shard_timeout for the suite based on the
-  # individual test timeouts if shard_timeouts are still required.
   rtc_test(_suite_name) {
     testonly = true
     deps = invoker.tests
     deps += [ ":${_suite_name}_verify_metadata" ]
-    if (defined(invoker.shard_timeout)) {
-      shard_timeout = invoker.shard_timeout
-    }
   }
 }