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

Unified Diff: webrtc/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.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/Camera1CapturerUsingTextureTest.java
diff --git a/webrtc/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java b/webrtc/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java
index ce282f91745e514f7708c71c02cee95b4f858f83..d15927222e54b2777a89da5ea6dcbab6eb7af48c 100644
--- a/webrtc/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java
+++ b/webrtc/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java
@@ -11,12 +11,18 @@
package org.webrtc;
import android.content.Context;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.LargeTest;
+import android.support.test.filters.MediumTest;
+import android.support.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";
private class TestObjectFactory extends CameraVideoCapturerTestFixtures.TestObjectFactory {
@@ -27,7 +33,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
@Override
public Context getAppContext() {
- return getInstrumentation().getTargetContext();
+ return InstrumentationRegistry.getTargetContext();
}
@SuppressWarnings("deprecation")
@@ -45,21 +51,23 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
private CameraVideoCapturerTestFixtures fixtures;
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
fixtures = new CameraVideoCapturerTestFixtures(new TestObjectFactory());
}
- @Override
- protected void tearDown() {
+ @After
+ public void tearDown() {
fixtures.dispose();
}
+ @Test
@SmallTest
public void testCreateAndDispose() throws InterruptedException {
fixtures.createCapturerAndDispose();
}
+ @Test
@SmallTest
public void testCreateNonExistingCamera() throws InterruptedException {
fixtures.createNonExistingCamera();
@@ -68,6 +76,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that the camera can be started and that the frames are forwarded
// to a Java video renderer using a "default" capturer.
// It tests both the Java and the C++ layer.
+ @Test
@MediumTest
public void testCreateCapturerAndRender() throws InterruptedException {
fixtures.createCapturerAndRender();
@@ -76,6 +85,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that the camera can be started and that the frames are forwarded
// to a Java video renderer using the front facing video capturer.
// It tests both the Java and the C++ layer.
+ @Test
@MediumTest
public void testStartFrontFacingVideoCapturer() throws InterruptedException {
fixtures.createFrontFacingCapturerAndRender();
@@ -84,6 +94,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that the camera can be started and that the frames are forwarded
// to a Java video renderer using the back facing video capturer.
// It tests both the Java and the C++ layer.
+ @Test
@MediumTest
public void testStartBackFacingVideoCapturer() throws InterruptedException {
fixtures.createBackFacingCapturerAndRender();
@@ -92,17 +103,20 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that the default camera can be started and that the camera can
// later be switched to another camera.
// It tests both the Java and the C++ layer.
+ @Test
@MediumTest
public void testSwitchVideoCapturer() throws InterruptedException {
fixtures.switchCamera();
}
+ @Test
@MediumTest
public void testCameraEvents() throws InterruptedException {
fixtures.cameraEventsInvoked();
}
// Test what happens when attempting to call e.g. switchCamera() after camera has been stopped.
+ @Test
@MediumTest
public void testCameraCallsAfterStop() throws InterruptedException {
fixtures.cameraCallsAfterStop();
@@ -110,6 +124,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that the VideoSource that the CameraVideoCapturer is connected to can
// be stopped and restarted. It tests both the Java and the C++ layer.
+ @Test
@LargeTest
public void testStopRestartVideoSource() throws InterruptedException {
fixtures.stopRestartVideoSource();
@@ -117,6 +132,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that the camera can be started at different resolutions.
// It does not test or use the C++ layer.
+ @Test
@LargeTest
public void testStartStopWithDifferentResolutions() throws InterruptedException {
fixtures.startStopWithDifferentResolutions();
@@ -124,6 +140,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test what happens if buffers are returned after the capturer have
// been stopped and restarted. It does not test or use the C++ layer.
+ @Test
@LargeTest
public void testReturnBufferLate() throws InterruptedException {
fixtures.returnBufferLate();
@@ -132,6 +149,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that we can capture frames, keep the frames in a local renderer, stop capturing,
// and then return the frames. The difference between the test testReturnBufferLate() is that we
// also test the JNI and C++ AndroidVideoCapturer parts.
+ @Test
@MediumTest
public void testReturnBufferLateEndToEnd() throws InterruptedException {
fixtures.returnBufferLateEndToEnd();
@@ -139,6 +157,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that CameraEventsHandler.onError is triggered if video buffers are not returned to
// the capturer.
+ @Test
@LargeTest
public void testCameraFreezedEventOnBufferStarvation() throws InterruptedException {
fixtures.cameraFreezedEventOnBufferStarvation();
@@ -146,6 +165,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that frames forwarded to a renderer is scaled if adaptOutputFormat is
// called. This test both Java and C++ parts of of the stack.
+ @Test
@MediumTest
public void testScaleCameraOutput() throws InterruptedException {
fixtures.scaleCameraOutput();
@@ -153,6 +173,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that an error is reported if the camera is already opened
// when CameraVideoCapturer is started.
+ @Test
@LargeTest
public void testStartWhileCameraIsAlreadyOpen() throws InterruptedException {
fixtures.startWhileCameraIsAlreadyOpen();
@@ -160,6 +181,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that CameraVideoCapturer can be started, even if the camera is already opened
// if the camera is closed while CameraVideoCapturer is re-trying to start.
+ @Test
@LargeTest
public void testStartWhileCameraIsAlreadyOpenAndCloseCamera() throws InterruptedException {
fixtures.startWhileCameraIsAlreadyOpenAndCloseCamera();
@@ -167,6 +189,7 @@ public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
// This test that CameraVideoCapturer.stop can be called while CameraVideoCapturer is
// re-trying to start.
+ @Test
@MediumTest
public void testStartWhileCameraIsAlreadyOpenAndStop() throws InterruptedException {
fixtures.startWhileCameraIsAlreadyOpenAndStop();

Powered by Google App Engine
This is Rietveld 408576698