Update AppRTCMobile tests to use JUnit4.

BUG=webrtc:6597

Review-Url: https://codereview.webrtc.org/2621253002
Cr-Commit-Position: refs/heads/master@{#16010}
This commit is contained in:
sakal
2017-01-11 06:21:26 -08:00
committed by Commit bot
parent c80e741ad0
commit cb79d519fa
5 changed files with 84 additions and 43 deletions

View File

@ -116,6 +116,9 @@ if (is_android) {
deps = [
":AppRTCMobile_javalib",
"//base:base_java_test_support",
"//third_party/android_support_test_runner:runner_java",
"//third_party/junit",
"//webrtc/sdk/android:libjingle_peerconnection_java",
]

View File

@ -1,17 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.appspot.apprtc.test"
android:versionCode="1"
android:versionName="1.0" >
<!--
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.appspot.apprtc.test">
<uses-sdk android:minSdkVersion="13" android:targetSdkVersion="21" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="org.appspot.apprtc" />
<uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />
<application>
<uses-library android:name="android.test.runner" />
</application>
</manifest>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="org.appspot.apprtc"
android:label="Tests for AppRTCMobile"/>
</manifest>

View File

@ -10,21 +10,25 @@
package org.appspot.apprtc.test;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import org.webrtc.FileVideoCapturer;
import org.webrtc.VideoCapturer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
import java.io.IOException;
import java.lang.Thread;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.webrtc.FileVideoCapturer;
import org.webrtc.VideoCapturer;
public class FileVideoCapturerTest extends InstrumentationTestCase {
@RunWith(BaseJUnit4ClassRunner.class)
public class FileVideoCapturerTest {
private static class Frame {
public byte[] data;
public int width;
@ -71,6 +75,7 @@ public class FileVideoCapturerTest extends InstrumentationTestCase {
}
}
@Test
@SmallTest
public void testVideoCaptureFromFile() throws InterruptedException, IOException {
final int FRAME_WIDTH = 4;

View File

@ -10,17 +10,29 @@
package org.appspot.apprtc.test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.os.Build;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.FlakyTest;
import android.support.test.filters.SmallTest;
import android.util.Log;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.appspot.apprtc.PeerConnectionClient;
import org.appspot.apprtc.PeerConnectionClient.PeerConnectionEvents;
import org.appspot.apprtc.PeerConnectionClient.PeerConnectionParameters;
import android.os.Build;
import android.test.FlakyTest;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.webrtc.Camera1Enumerator;
import org.webrtc.Camera2Enumerator;
import org.webrtc.CameraEnumerator;
@ -34,15 +46,8 @@ import org.webrtc.StatsReport;
import org.webrtc.VideoCapturer;
import org.webrtc.VideoRenderer;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class PeerConnectionClientTest
extends InstrumentationTestCase implements PeerConnectionEvents {
@RunWith(BaseJUnit4ClassRunner.class)
public class PeerConnectionClientTest implements PeerConnectionEvents {
private static final String TAG = "RTCClientTest";
private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000;
private static final int WAIT_TIMEOUT = 7000;
@ -251,7 +256,7 @@ public class PeerConnectionClientTest
options.disableNetworkMonitor = true;
client.setPeerConnectionFactoryOptions(options);
client.createPeerConnectionFactory(
getInstrumentation().getTargetContext(), peerConnectionParameters, this);
InstrumentationRegistry.getTargetContext(), peerConnectionParameters, this);
client.createPeerConnection(
eglContext, localRenderer, remoteRenderer, videoCapturer, signalingParameters);
client.createOffer();
@ -283,12 +288,12 @@ public class PeerConnectionClientTest
}
private VideoCapturer createCameraCapturer(boolean captureToTexture) {
final boolean useCamera2 =
captureToTexture && Camera2Enumerator.isSupported(getInstrumentation().getTargetContext());
final boolean useCamera2 = captureToTexture
&& Camera2Enumerator.isSupported(InstrumentationRegistry.getTargetContext());
CameraEnumerator enumerator;
if (useCamera2) {
enumerator = new Camera2Enumerator(getInstrumentation().getTargetContext());
enumerator = new Camera2Enumerator(InstrumentationRegistry.getTargetContext());
} else {
enumerator = new Camera1Enumerator(captureToTexture);
}
@ -320,7 +325,7 @@ public class PeerConnectionClientTest
return peerConnectionParameters;
}
@Override
@Before
public void setUp() {
signalingExecutor = Executors.newSingleThreadExecutor();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
@ -328,7 +333,7 @@ public class PeerConnectionClientTest
}
}
@Override
@After
public void tearDown() {
signalingExecutor.shutdown();
if (eglBase != null) {
@ -336,6 +341,7 @@ public class PeerConnectionClientTest
}
}
@Test
@SmallTest
public void testSetLocalOfferMakesVideoFlowLocally() throws InterruptedException {
Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally");
@ -399,29 +405,34 @@ public class PeerConnectionClientTest
Log.d(TAG, "testLoopback done.");
}
@Test
@SmallTest
public void testLoopbackAudio() throws InterruptedException {
doLoopbackTest(createParametersForAudioCall(), null, false /* decodeToTexture */);
}
@Test
@SmallTest
public void testLoopbackVp8() throws InterruptedException {
doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8),
createCameraCapturer(false /* captureToTexture */), false /* decodeToTexture */);
}
@Test
@SmallTest
public void testLoopbackVp9() throws InterruptedException {
doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP9),
createCameraCapturer(false /* captureToTexture */), false /* decodeToTexture */);
}
@Test
@SmallTest
public void testLoopbackH264() throws InterruptedException {
doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264),
createCameraCapturer(false /* captureToTexture */), false /* decodeToTexture */);
}
@Test
@SmallTest
public void testLoopbackVp8DecodeToTexture() throws InterruptedException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
@ -432,6 +443,7 @@ public class PeerConnectionClientTest
createCameraCapturer(false /* captureToTexture */), true /* decodeToTexture */);
}
@Test
@SmallTest
public void testLoopbackVp9DecodeToTexture() throws InterruptedException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
@ -442,6 +454,7 @@ public class PeerConnectionClientTest
createCameraCapturer(false /* captureToTexture */), true /* decodeToTexture */);
}
@Test
@SmallTest
public void testLoopbackH264DecodeToTexture() throws InterruptedException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
@ -452,6 +465,7 @@ public class PeerConnectionClientTest
createCameraCapturer(false /* captureToTexture */), true /* decodeToTexture */);
}
@Test
@SmallTest
public void testLoopbackVp8CaptureToTexture() throws InterruptedException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
@ -471,6 +485,7 @@ public class PeerConnectionClientTest
// Test that a call can be setup even if the EGL context used during initialization is
// released before the Video codecs are created. The HW encoder and decoder is setup to use
// textures.
@Test
@SmallTest
public void testLoopbackEglContextReleasedAfterCreatingPc() throws InterruptedException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
@ -511,6 +526,7 @@ public class PeerConnectionClientTest
Log.d(TAG, "testLoopback done.");
}
@Test
@SmallTest
public void testLoopbackH264CaptureToTexture() throws InterruptedException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
@ -529,6 +545,7 @@ public class PeerConnectionClientTest
// Checks if default front camera can be switched to back camera and then
// again to front camera.
@Test
@SmallTest
public void testCameraSwitch() throws InterruptedException {
Log.d(TAG, "testCameraSwitch");
@ -577,6 +594,7 @@ public class PeerConnectionClientTest
// Checks if video source can be restarted - simulate app goes to
// background and back to foreground.
// Disabled because of https://bugs.chromium.org/p/webrtc/issues/detail?id=6478
@Test
@FlakyTest
//@SmallTest
public void testVideoSourceRestart() throws InterruptedException {
@ -627,6 +645,7 @@ public class PeerConnectionClientTest
// Checks if capture format can be changed on fly and decoder can be reset properly.
// Disabled because of https://bugs.chromium.org/p/webrtc/issues/detail?id=6478
@Test
@FlakyTest
//@SmallTest
public void testCaptureFormatChange() throws InterruptedException {

View File

@ -10,19 +10,24 @@
package org.webrtc;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import static org.junit.Assert.assertEquals;
import android.support.test.filters.SmallTest;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.Thread;
import java.nio.charset.StandardCharsets;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Random;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
public class VideoFileRendererTest extends InstrumentationTestCase {
@RunWith(BaseJUnit4ClassRunner.class)
public class VideoFileRendererTest {
@Test
@SmallTest
public void testYuvRenderingToFile() throws InterruptedException, IOException {
EglBase eglBase = EglBase.create();