Parameterize EglRendererTest to also run with RenderSynchronizer

Bug: b/307672498
Change-Id: I3577bdcaf1dc4c4ccca02e8d9e53a799b680ecc1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325183
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Linus Nilsson <lnilsson@webrtc.org>
Auto-Submit: Linus Nilsson <lnilsson@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41027}
diff --git a/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java b/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java
index 04e4ab4..5b3749a 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java
@@ -26,12 +26,18 @@
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
 
 // EmptyActivity is needed for the surface.
+@RunWith(Parameterized.class)
 public class EglRendererTest {
   private final static String TAG = "EglRendererTest";
   private final static int RENDER_WAIT_MS = 1000;
@@ -100,6 +106,9 @@
     }
   }
 
+  @Parameter(0)
+  public boolean useRenderSynchronizer;
+
   final TestFrameListener testFrameListener = new TestFrameListener();
 
   EglRenderer eglRenderer;
@@ -108,14 +117,24 @@
   int oesTextureId;
   SurfaceTexture surfaceTexture;
 
+  @Parameters
+  public static Collection<Object[]> data() {
+    return Arrays.asList(new Object[] {true}, new Object[] {false});
+  }
+
   @Before
   public void setUp() throws Exception {
     PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions
                                          .builder(InstrumentationRegistry.getTargetContext())
                                          .setNativeLibraryName(TestConstants.NATIVE_LIBRARY)
                                          .createInitializationOptions());
+    RenderSynchronizer renderSynchronizer = useRenderSynchronizer ? new RenderSynchronizer() : null;
     eglThread =
-        EglThread.create(null /* releaseMonitor */, null /* sharedContext */, EglBase.CONFIG_RGBA);
+        EglThread.create(
+            null /* releaseMonitor */,
+            null /* sharedContext */,
+            EglBase.CONFIG_RGBA,
+            renderSynchronizer);
     eglRenderer = new EglRenderer("TestRenderer: ");
     eglRenderer.init(eglThread, new GlRectDrawer(), false /* usePresentationTimeStamp */);
     oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);