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

Unified Diff: webrtc/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java

Issue 2627043002: Update Android instrumentation tests to use JUnit4. (Closed)
Patch Set: Created 3 years, 11 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
Index: webrtc/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java
diff --git a/webrtc/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java b/webrtc/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java
index 3aaf7464546ee8c19da2f505b9a0f654fcae05dc..34d795b9b802fedc3824c8457a9eb019e9e132d7 100644
--- a/webrtc/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java
+++ b/webrtc/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java
@@ -10,40 +10,48 @@
package org.webrtc;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import static org.webrtc.RendererCommon.ScalingType.*;
import static org.webrtc.RendererCommon.getDisplaySize;
import static org.webrtc.RendererCommon.getLayoutMatrix;
import static org.webrtc.RendererCommon.rotateTextureMatrix;
import android.graphics.Point;
-import android.test.ActivityTestCase;
-import android.test.MoreAsserts;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public final class RendererCommonTest extends ActivityTestCase {
+import android.support.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
- static public void testDisplaySizeNoFrame() {
+ public void testDisplaySizeNoFrame() {
assertEquals(new Point(0, 0), getDisplaySize(SCALE_ASPECT_FIT, 0.0f, 0, 0));
assertEquals(new Point(0, 0), getDisplaySize(SCALE_ASPECT_FILL, 0.0f, 0, 0));
assertEquals(new Point(0, 0), getDisplaySize(SCALE_ASPECT_BALANCED, 0.0f, 0, 0));
}
+ @Test
@SmallTest
- public static void testDisplaySizeDegenerateAspectRatio() {
+ public void testDisplaySizeDegenerateAspectRatio() {
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_FIT, 0.0f, 1280, 720));
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_FILL, 0.0f, 1280, 720));
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_BALANCED, 0.0f, 1280, 720));
}
+ @Test
@SmallTest
- public static void testZeroDisplaySize() {
+ public void testZeroDisplaySize() {
assertEquals(new Point(0, 0), getDisplaySize(SCALE_ASPECT_FIT, 16.0f / 9, 0, 0));
assertEquals(new Point(0, 0), getDisplaySize(SCALE_ASPECT_FILL, 16.0f / 9, 0, 0));
assertEquals(new Point(0, 0), getDisplaySize(SCALE_ASPECT_BALANCED, 16.0f / 9, 0, 0));
}
+ @Test
@SmallTest
- public static void testDisplaySizePerfectFit() {
+ public void testDisplaySizePerfectFit() {
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_FIT, 16.0f / 9, 1280, 720));
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_FILL, 16.0f / 9, 1280, 720));
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_BALANCED, 16.0f / 9, 1280, 720));
@@ -52,22 +60,25 @@ public final class RendererCommonTest extends ActivityTestCase {
assertEquals(new Point(720, 1280), getDisplaySize(SCALE_ASPECT_BALANCED, 9.0f / 16, 720, 1280));
}
+ @Test
@SmallTest
- public static void testLandscapeVideoInPortraitDisplay() {
+ public void testLandscapeVideoInPortraitDisplay() {
assertEquals(new Point(720, 405), getDisplaySize(SCALE_ASPECT_FIT, 16.0f / 9, 720, 1280));
assertEquals(new Point(720, 1280), getDisplaySize(SCALE_ASPECT_FILL, 16.0f / 9, 720, 1280));
assertEquals(new Point(720, 720), getDisplaySize(SCALE_ASPECT_BALANCED, 16.0f / 9, 720, 1280));
}
+ @Test
@SmallTest
- public static void testPortraitVideoInLandscapeDisplay() {
+ public void testPortraitVideoInLandscapeDisplay() {
assertEquals(new Point(405, 720), getDisplaySize(SCALE_ASPECT_FIT, 9.0f / 16, 1280, 720));
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_FILL, 9.0f / 16, 1280, 720));
assertEquals(new Point(720, 720), getDisplaySize(SCALE_ASPECT_BALANCED, 9.0f / 16, 1280, 720));
}
+ @Test
@SmallTest
- public static void testFourToThreeVideoInSixteenToNineDisplay() {
+ public void testFourToThreeVideoInSixteenToNineDisplay() {
assertEquals(new Point(960, 720), getDisplaySize(SCALE_ASPECT_FIT, 4.0f / 3, 1280, 720));
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_FILL, 4.0f / 3, 1280, 720));
assertEquals(new Point(1280, 720), getDisplaySize(SCALE_ASPECT_BALANCED, 4.0f / 3, 1280, 720));
@@ -89,38 +100,41 @@ public final class RendererCommonTest extends ActivityTestCase {
// u' = u * m[0] + v * m[4] + m[12].
// v' = u * m[1] + v * m[5] + m[13].
+ @Test
@SmallTest
- public static void testLayoutMatrixDefault() {
+ public void testLayoutMatrixDefault() {
final float layoutMatrix[] = getLayoutMatrix(false, 1.0f, 1.0f);
// Assert:
// u' = u.
// v' = v.
// clang-format off
- MoreAsserts.assertEquals(new double[] {
+ assertArrayEquals(new double[] {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
- 0, 0, 0, 1}, round(layoutMatrix));
+ 0, 0, 0, 1}, round(layoutMatrix), 0.0);
// clang-format on
}
+ @Test
@SmallTest
- public static void testLayoutMatrixMirror() {
+ public void testLayoutMatrixMirror() {
final float layoutMatrix[] = getLayoutMatrix(true, 1.0f, 1.0f);
// Assert:
// u' = 1 - u.
// v' = v.
// clang-format off
- MoreAsserts.assertEquals(new double[] {
+ assertArrayEquals(new double[] {
-1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
- 1, 0, 0, 1}, round(layoutMatrix));
+ 1, 0, 0, 1}, round(layoutMatrix), 0.0);
// clang-format on
}
+ @Test
@SmallTest
- public static void testLayoutMatrixScale() {
+ public void testLayoutMatrixScale() {
// Video has aspect ratio 2, but layout is square. This will cause only the center part of the
// video to be visible, i.e. the u coordinate will go from 0.25 to 0.75 instead of from 0 to 1.
final float layoutMatrix[] = getLayoutMatrix(false, 2.0f, 1.0f);
@@ -128,16 +142,17 @@ public final class RendererCommonTest extends ActivityTestCase {
// u' = 0.25 + 0.5 u.
// v' = v.
// clang-format off
- MoreAsserts.assertEquals(new double[] {
+ assertArrayEquals(new double[] {
0.5, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
- 0.25, 0, 0, 1}, round(layoutMatrix));
+ 0.25, 0, 0, 1}, round(layoutMatrix), 0.0);
// clang-format on
}
+ @Test
@SmallTest
- public static void testRotateTextureMatrixDefault() {
+ public void testRotateTextureMatrixDefault() {
// Test that rotation with 0 degrees returns an identical matrix.
// clang-format off
final float[] matrix = new float[] {
@@ -148,36 +163,38 @@ public final class RendererCommonTest extends ActivityTestCase {
};
// clang-format on
final float rotatedMatrix[] = rotateTextureMatrix(matrix, 0);
- MoreAsserts.assertEquals(round(matrix), round(rotatedMatrix));
+ assertArrayEquals(round(matrix), round(rotatedMatrix), 0.0);
}
+ @Test
@SmallTest
- public static void testRotateTextureMatrix90Deg() {
+ public void testRotateTextureMatrix90Deg() {
final float samplingMatrix[] = rotateTextureMatrix(RendererCommon.identityMatrix(), 90);
// Assert:
// u' = 1 - v.
// v' = u.
// clang-format off
- MoreAsserts.assertEquals(new double[] {
+ assertArrayEquals(new double[] {
0, 1, 0, 0,
-1, 0, 0, 0,
0, 0, 1, 0,
- 1, 0, 0, 1}, round(samplingMatrix));
+ 1, 0, 0, 1}, round(samplingMatrix), 0.0);
// clang-format on
}
+ @Test
@SmallTest
- public static void testRotateTextureMatrix180Deg() {
+ public void testRotateTextureMatrix180Deg() {
final float samplingMatrix[] = rotateTextureMatrix(RendererCommon.identityMatrix(), 180);
// Assert:
// u' = 1 - u.
// v' = 1 - v.
// clang-format off
- MoreAsserts.assertEquals(new double[] {
+ assertArrayEquals(new double[] {
-1, 0, 0, 0,
0, -1, 0, 0,
0, 0, 1, 0,
- 1, 1, 0, 1}, round(samplingMatrix));
+ 1, 1, 0, 1}, round(samplingMatrix), 0.0);
// clang-format on
}
}

Powered by Google App Engine
This is Rietveld 408576698