Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Unified Diff: webrtc/api/androidtests/src/org/webrtc/SurfaceViewRendererOnMeasureTest.java

Issue 2147463002: SurfaceViewRendererOnMeasureTest: Wait for frame size change to take effect (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix spelling error Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/androidtests/src/org/webrtc/SurfaceViewRendererOnMeasureTest.java
diff --git a/webrtc/api/androidtests/src/org/webrtc/SurfaceViewRendererOnMeasureTest.java b/webrtc/api/androidtests/src/org/webrtc/SurfaceViewRendererOnMeasureTest.java
index 302e2a1aac65baf2de5f9ba0116302713d5989f1..60720ff955dc155f75ad276afea96fb1141f40eb 100644
--- a/webrtc/api/androidtests/src/org/webrtc/SurfaceViewRendererOnMeasureTest.java
+++ b/webrtc/api/androidtests/src/org/webrtc/SurfaceViewRendererOnMeasureTest.java
@@ -112,10 +112,37 @@ public final class SurfaceViewRendererOnMeasureTest extends ActivityTestCase {
* Test how SurfaceViewRenderer.onMeasure() behaves with a 1280x720 frame.
*/
@MediumTest
- public void testFrame1280x720() {
+ public void testFrame1280x720() throws InterruptedException {
final SurfaceViewRenderer surfaceViewRenderer =
new SurfaceViewRenderer(getInstrumentation().getContext());
- surfaceViewRenderer.init((EglBase.Context) null, null);
+ /**
+ * Mock renderer events with blocking wait functionality for frame size changes.
+ */
+ class MockRendererEvents implements RendererCommon.RendererEvents {
+ private int frameWidth;
+ private int frameHeight;
+ private int rotation;
+
+ public synchronized void waitForFrameSize(int frameWidth, int frameHeight, int rotation)
+ throws InterruptedException {
+ while (this.frameWidth != frameWidth || this.frameHeight != frameHeight
+ || this.rotation != rotation) {
+ wait();
+ }
+ }
+
+ public void onFirstFrameRendered() {}
+
+ public synchronized void onFrameResolutionChanged(
+ int frameWidth, int frameHeight, int rotation) {
+ this.frameWidth = frameWidth;
+ this.frameHeight = frameHeight;
+ this.rotation = rotation;
+ notifyAll();
+ }
+ }
+ final MockRendererEvents rendererEvents = new MockRendererEvents();
+ surfaceViewRenderer.init((EglBase.Context) null, rendererEvents);
// Test different rotation degress, but same rotated size.
for (int rotationDegree : new int[] {0, 90, 180, 270}) {
@@ -130,6 +157,7 @@ public final class SurfaceViewRendererOnMeasureTest extends ActivityTestCase {
final String frameDimensions =
unrotatedWidth + "x" + unrotatedHeight + " with rotation " + rotationDegree;
surfaceViewRenderer.renderFrame(frame);
+ rendererEvents.waitForFrameSize(unrotatedWidth, unrotatedHeight, rotationDegree);
// Test forcing to zero size.
for (RendererCommon.ScalingType scalingType : scalingTypes) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698