Run instrumentation tests with the default runner

This migrates all tests that work by just changing their runner.

This excludes tests using `@RunWith(ParameterizedRunner.class)`, and a
few other non-parameterized tests that fail with the default runner.

Bug: webrtc:13662
Change-Id: Ia0b7c80e04a6a6b7a51348b3a7f587d10061b58e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256367
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Xavier Lepaul‎ <xalep@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36298}
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java b/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java
index 976f718..8c9119e 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java
@@ -15,10 +15,7 @@
 import androidx.test.filters.SmallTest;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
 
-@RunWith(JUnit4.class)
 public final class BuiltinAudioCodecsFactoryFactoryTest {
   @Before
   public void setUp() {
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java
index 981eeef..37d03d9 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java
@@ -15,13 +15,10 @@
 import androidx.test.filters.LargeTest;
 import androidx.test.filters.MediumTest;
 import androidx.test.filters.SmallTest;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class Camera1CapturerUsingByteBufferTest {
   static final String TAG = "Camera1CapturerUsingByteBufferTest";
 
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java
index 2c06935..e041917 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java
@@ -15,13 +15,10 @@
 import androidx.test.filters.LargeTest;
 import androidx.test.filters.MediumTest;
 import androidx.test.filters.SmallTest;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class Camera1CapturerUsingTextureTest {
   static final String TAG = "Camera1CapturerUsingTextureTest";
 
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java
index ae84df0..b017371 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java
@@ -24,13 +24,10 @@
 import androidx.test.filters.MediumTest;
 import androidx.test.filters.SmallTest;
 import java.util.concurrent.CountDownLatch;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class Camera2CapturerTest {
   static final String TAG = "Camera2CapturerTest";
 
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java b/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java
index 197a5bc..9721cbd 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java
@@ -16,13 +16,10 @@
 import androidx.test.filters.SmallTest;
 import java.util.ArrayList;
 import java.util.HashMap;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
 /** Unit tests for {@link DefaultVideoEncoderFactory}. */
-@RunWith(BaseJUnit4ClassRunner.class)
 public class DefaultVideoEncoderFactoryTest {
   static class CustomHardwareVideoEncoderFactory implements VideoEncoderFactory {
     private ArrayList<VideoCodecInfo> codecs = new ArrayList<>();
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java b/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java
index 2bd9190..8b5e95b 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java
@@ -27,14 +27,11 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.concurrent.CountDownLatch;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
 // EmptyActivity is needed for the surface.
-@RunWith(BaseJUnit4ClassRunner.class)
 public class EglRendererTest {
   private final static String TAG = "EglRendererTest";
   private final static int RENDER_WAIT_MS = 1000;
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java
index c58d87b..8584ddf 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java
@@ -19,12 +19,9 @@
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class FileVideoCapturerTest {
   public static class MockCapturerObserver implements CapturerObserver {
     private final ArrayList<VideoFrame> frames = new ArrayList<VideoFrame>();
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java
index 0760d64..4cee3bd 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java
@@ -19,11 +19,8 @@
 import androidx.test.filters.SmallTest;
 import java.nio.ByteBuffer;
 import java.util.Random;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class GlRectDrawerTest {
   // Resolution of the test image.
   private static final int WIDTH = 16;
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java b/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java
index ff5cfee..780eeb6 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java
@@ -14,16 +14,13 @@
 import static org.junit.Assert.assertTrue;
 
 import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
 import androidx.test.filters.SmallTest;
 import java.util.ArrayList;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.Loggable;
 import org.webrtc.Logging.Severity;
 import org.webrtc.PeerConnectionFactory;
 
-@RunWith(AndroidJUnit4.class)
 public class LoggableTest {
   private static String TAG = "LoggableTest";
   private static String NATIVE_FILENAME_TAG = "loggable_test.cc";
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java
index e045285..a0a86d5 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java
@@ -38,12 +38,9 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
-import org.chromium.base.test.UiThreadTest;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.NetworkChangeDetector.ConnectionType;
 import org.webrtc.NetworkChangeDetector.NetworkInformation;
 import org.webrtc.NetworkMonitorAutoDetect.ConnectivityManagerDelegate;
@@ -58,7 +55,6 @@
  * class is used in practice in WebRTC.
  */
 @SuppressLint("NewApi")
-@RunWith(BaseJUnit4ClassRunner.class)
 public class NetworkMonitorTest {
   private static final long INVALID_NET_ID = -1;
   private NetworkChangeDetector detector;
@@ -226,7 +222,6 @@
    * Tests that the receiver registers for connectivity intents during construction.
    */
   @Test
-  @UiThreadTest
   @SmallTest
   public void testNetworkMonitorRegistersInConstructor() throws InterruptedException {
     Context context = InstrumentationRegistry.getTargetContext();
@@ -243,7 +238,6 @@
    * notification to Java observers.
    */
   @Test
-  @UiThreadTest
   @MediumTest
   public void testNetworkMonitorJavaObservers() throws InterruptedException {
     // Initialize the NetworkMonitor with a connection.
@@ -290,7 +284,6 @@
    * that the functions don't crash.
    */
   @Test
-  @UiThreadTest
   @SmallTest
   public void testConnectivityManagerDelegateDoesNotCrash() {
     ConnectivityManagerDelegate delegate = new ConnectivityManagerDelegate(
@@ -376,7 +369,6 @@
    * least check that the functions don't crash.
    */
   @Test
-  @UiThreadTest
   @SmallTest
   public void testQueryableAPIsDoNotCrash() {
     NetworkMonitorAutoDetect.Observer observer = new TestNetworkMonitorAutoDetectObserver();
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java
index 588e647..8efefb3 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java
@@ -36,17 +36,14 @@
 import java.util.TreeSet;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.PeerConnection.IceConnectionState;
 import org.webrtc.PeerConnection.IceGatheringState;
 import org.webrtc.PeerConnection.PeerConnectionState;
 import org.webrtc.PeerConnection.SignalingState;
 
 /** End-to-end tests for {@link PeerConnection}. */
-@RunWith(BaseJUnit4ClassRunner.class)
 public class PeerConnectionEndToEndTest {
   private static final String TAG = "PeerConnectionEndToEndTest";
   private static final int DEFAULT_TIMEOUT_SECONDS = 20;
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java
index 92d4469..8eebfb5 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java
@@ -11,12 +11,9 @@
 package org.webrtc;
 
 import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
 import androidx.test.filters.SmallTest;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(AndroidJUnit4.class)
 public class PeerConnectionFactoryTest {
   @SmallTest
   @Test
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java
index 7d19143..7ced991 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java
@@ -22,14 +22,11 @@
 import androidx.test.filters.SmallTest;
 import java.util.Arrays;
 import java.util.List;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.PeerConnection.TlsCertPolicy;
 
 /** Unit tests for {@link PeerConnection}. */
-@RunWith(BaseJUnit4ClassRunner.class)
 public class PeerConnectionTest {
   @Before
   public void setUp() {
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java
index 01eb4c8..8b1cd67 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java
@@ -20,11 +20,8 @@
 
 import android.graphics.Point;
 import androidx.test.filters.SmallTest;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class RendererCommonTest {
   @Test
   @SmallTest
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java
index 70bceff..4127bb2 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java
@@ -13,15 +13,12 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import androidx.test.filters.SmallTest;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.PeerConnection;
 import org.webrtc.RtcCertificatePem;
 
 /** Tests for RtcCertificatePem.java. */
-@RunWith(BaseJUnit4ClassRunner.class)
 public class RtcCertificatePemTest {
   @Before
   public void setUp() {
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java
index 70bc43e..9f315d5 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java
@@ -19,14 +19,11 @@
 import android.support.test.InstrumentationRegistry;
 import androidx.test.filters.SmallTest;
 import java.util.Arrays;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.RtpParameters.DegradationPreference;
 
 /** Unit-tests for {@link RtpSender}. */
-@RunWith(BaseJUnit4ClassRunner.class)
 public class RtpSenderTest {
   private PeerConnectionFactory factory;
   private PeerConnection pc;
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java
index e97bd3d..a53ff20 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java
@@ -19,15 +19,12 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.RtpParameters.Encoding;
 import org.webrtc.RtpTransceiver.RtpTransceiverInit;
 
 /** Unit-tests for {@link RtpTransceiver}. */
-@RunWith(BaseJUnit4ClassRunner.class)
 public class RtpTransceiverTest {
   private PeerConnectionFactory factory;
   private PeerConnection pc;
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java b/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java
index 3964d22..9781d03 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java
@@ -21,12 +21,9 @@
 import androidx.test.filters.SmallTest;
 import java.nio.ByteBuffer;
 import java.util.concurrent.CountDownLatch;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class SurfaceTextureHelperTest {
   /**
    * Mock texture listener with blocking wait functionality.
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java
index 930a450..46cb37e 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java
@@ -11,12 +11,9 @@
 package org.webrtc;
 
 import androidx.test.filters.SmallTest;
-import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
-import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class)
 public class TimestampAlignerTest {
   @BeforeClass
   public static void setUp() {
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java b/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java
index 70950b9..9c66edd 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java
@@ -19,12 +19,9 @@
 import java.io.RandomAccessFile;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class VideoFileRendererTest {
   @Before
   public void setUp() {
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java b/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java
index 938f488..8d7894c 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java
@@ -15,13 +15,10 @@
 
 import android.support.test.InstrumentationRegistry;
 import androidx.test.filters.SmallTest;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
 /** Unit tests for {@link VideoTrack}. */
-@RunWith(BaseJUnit4ClassRunner.class)
 public class VideoTrackTest {
   private PeerConnectionFactory factory;
   private VideoSource videoSource;
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java b/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java
index 5819900..b1badd5 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java
@@ -11,16 +11,13 @@
 package org.webrtc;
 
 import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
 import androidx.test.filters.SmallTest;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.webrtc.PeerConnectionFactory;
 
 // This test is intended to run on ARM and catch LoadLibrary errors when we load the WebRTC
 // JNI. It can't really be setting up calls since ARM emulators are too slow, but instantiating
 // a peer connection isn't timing-sensitive, so we can at least do that.
-@RunWith(AndroidJUnit4.class)
 public class WebRtcJniBootTest {
   @Test
   @SmallTest
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java b/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java
index 0a63bd7..7c58e95 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java
@@ -15,12 +15,9 @@
 
 import androidx.test.filters.SmallTest;
 import java.nio.ByteBuffer;
-import org.chromium.base.test.BaseJUnit4ClassRunner;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(BaseJUnit4ClassRunner.class)
 public class YuvHelperTest {
   private static final int TEST_WIDTH = 3;
   private static final int TEST_HEIGHT = 3;