Update Android instrumentation tests to use JUnit4.
BUG=webrtc:6597 Review-Url: https://codereview.webrtc.org/2627043002 Cr-Commit-Position: refs/heads/master@{#16011}
This commit is contained in:
parent
cb79d519fa
commit
e1674efd2d
@ -207,6 +207,10 @@ if (rtc_include_tests) {
|
||||
|
||||
deps = [
|
||||
"//base:base_java",
|
||||
"//base:base_java_test_support",
|
||||
"//third_party/android_support_test_runner:rules_java",
|
||||
"//third_party/android_support_test_runner:runner_java",
|
||||
"//third_party/junit",
|
||||
"//webrtc/base:base_java",
|
||||
"//webrtc/sdk/android:libjingle_peerconnection_java",
|
||||
"//webrtc/sdk/android:libjingle_peerconnection_metrics_default_java",
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.webrtc.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.webrtc">
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
@ -16,14 +24,13 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />
|
||||
|
||||
<instrumentation
|
||||
android:name="android.test.InstrumentationTestRunner"
|
||||
android:targetPackage="org.webrtc.test" />
|
||||
|
||||
<application
|
||||
android:label="AndroidPeerconnectionTests" >
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="org.webrtc"
|
||||
android:label="Tests for WebRTC Android SDK"/>
|
||||
</manifest>
|
||||
|
||||
@ -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;
|
||||
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;
|
||||
|
||||
public class Camera1CapturerUsingByteBufferTest extends InstrumentationTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class Camera1CapturerUsingByteBufferTest {
|
||||
static final String TAG = "Camera1CapturerUsingByteBufferTest";
|
||||
|
||||
private class TestObjectFactory extends CameraVideoCapturerTestFixtures.TestObjectFactory {
|
||||
@ -32,7 +38,7 @@ public class Camera1CapturerUsingByteBufferTest extends InstrumentationTestCase
|
||||
|
||||
@Override
|
||||
public Context getAppContext() {
|
||||
return getInstrumentation().getTargetContext();
|
||||
return InstrumentationRegistry.getTargetContext();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -50,21 +56,23 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -73,6 +81,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -81,6 +90,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -89,6 +99,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -97,17 +108,20 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -115,6 +129,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -122,6 +137,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -129,6 +145,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -137,6 +154,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -144,6 +162,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -151,6 +170,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -158,6 +178,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
@ -165,6 +186,7 @@ public class Camera1CapturerUsingByteBufferTest 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();
|
||||
|
||||
@ -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;
|
||||
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;
|
||||
|
||||
public class Camera1CapturerUsingTextureTest extends InstrumentationTestCase {
|
||||
@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();
|
||||
|
||||
@ -10,20 +10,29 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraDevice;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.test.InstrumentationTestCase;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.LargeTest;
|
||||
import android.support.test.filters.MediumTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
public class Camera2CapturerTest extends InstrumentationTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class Camera2CapturerTest {
|
||||
static final String TAG = "Camera2CapturerTest";
|
||||
|
||||
/**
|
||||
@ -151,7 +160,7 @@ public class Camera2CapturerTest extends InstrumentationTestCase {
|
||||
|
||||
@Override
|
||||
public Context getAppContext() {
|
||||
return getInstrumentation().getTargetContext();
|
||||
return InstrumentationRegistry.getTargetContext();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -169,21 +178,23 @@ public class Camera2CapturerTest 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();
|
||||
@ -192,6 +203,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -200,6 +212,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -208,6 +221,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -216,17 +230,20 @@ public class Camera2CapturerTest 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();
|
||||
@ -234,6 +251,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -241,6 +259,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -248,6 +267,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -256,6 +276,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -263,6 +284,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -270,6 +292,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -277,6 +300,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -284,6 +308,7 @@ public class Camera2CapturerTest 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();
|
||||
@ -291,6 +316,7 @@ public class Camera2CapturerTest 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();
|
||||
|
||||
@ -7,18 +7,22 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static junit.framework.Assert.*;
|
||||
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.VideoRenderer.I420Frame;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.VideoRenderer.I420Frame;
|
||||
|
||||
class CameraVideoCapturerTestFixtures {
|
||||
static final String TAG = "CameraVideoCapturerTestFixtures";
|
||||
|
||||
@ -10,20 +10,33 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.opengl.GLES11Ext;
|
||||
import android.opengl.GLES20;
|
||||
import android.test.InstrumentationTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
// EmptyActivity is needed for the surface.
|
||||
public class EglRendererTest extends InstrumentationTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class EglRendererTest {
|
||||
final static String TAG = "EglRendererTest";
|
||||
final static int RENDER_WAIT_MS = 1000;
|
||||
final static int SURFACE_WAIT_MS = 1000;
|
||||
@ -88,9 +101,9 @@ public class EglRendererTest extends InstrumentationTestCase {
|
||||
int oesTextureId;
|
||||
SurfaceTexture surfaceTexture;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
PeerConnectionFactory.initializeAndroidGlobals(getInstrumentation().getTargetContext(),
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getTargetContext(),
|
||||
true /* initializeAudio */, true /* initializeVideo */, true /* videoHwAcceleration */);
|
||||
eglRenderer = new EglRenderer("TestRenderer: ");
|
||||
eglRenderer.init(null /* sharedContext */, EglBase.CONFIG_RGBA, new GlRectDrawer());
|
||||
@ -100,7 +113,7 @@ public class EglRendererTest extends InstrumentationTestCase {
|
||||
eglRenderer.createEglSurface(surfaceTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() {
|
||||
surfaceTexture.release();
|
||||
GLES20.glDeleteTextures(1 /* n */, new int[] {oesTextureId}, 0 /* offset */);
|
||||
@ -227,6 +240,7 @@ public class EglRendererTest extends InstrumentationTestCase {
|
||||
0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testAddFrameListener() throws Exception {
|
||||
eglRenderer.addFrameListener(testFrameListener, 0f /* scaleFactor */);
|
||||
@ -242,6 +256,7 @@ public class EglRendererTest extends InstrumentationTestCase {
|
||||
assertFalse(testFrameListener.waitForBitmap(RENDER_WAIT_MS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testAddFrameListenerBitmap() throws Exception {
|
||||
eglRenderer.addFrameListener(testFrameListener, 1f /* scaleFactor */);
|
||||
@ -254,6 +269,7 @@ public class EglRendererTest extends InstrumentationTestCase {
|
||||
checkBitmapContent(testFrameListener.resetAndGetBitmap(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testAddFrameListenerBitmapScale() throws Exception {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
@ -269,6 +285,7 @@ public class EglRendererTest extends InstrumentationTestCase {
|
||||
* Checks that the frame listener will not be called with a frame that was delivered before the
|
||||
* frame listener was added.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testFrameListenerNotCalledWithOldFrames() throws Exception {
|
||||
feedFrame(0);
|
||||
@ -278,6 +295,7 @@ public class EglRendererTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
/** Checks that the frame listener will not be called after it is removed. */
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testRemoveFrameListenerNotRacy() throws Exception {
|
||||
for (int i = 0; i < REMOVE_FRAME_LISTENER_RACY_NUM_TESTS; i++) {
|
||||
|
||||
@ -7,18 +7,25 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.opengl.GLES20;
|
||||
import android.test.ActivityTestCase;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import android.support.test.filters.MediumTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Random;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
public final class GlRectDrawerTest extends ActivityTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class GlRectDrawerTest {
|
||||
// Resolution of the test image.
|
||||
private static final int WIDTH = 16;
|
||||
private static final int HEIGHT = 16;
|
||||
@ -36,7 +43,8 @@ public final class GlRectDrawerTest extends ActivityTestCase {
|
||||
}
|
||||
|
||||
// Assert RGB ByteBuffers are pixel perfect identical.
|
||||
private static void assertEquals(int width, int height, ByteBuffer actual, ByteBuffer expected) {
|
||||
private static void assertByteBufferEquals(
|
||||
int width, int height, ByteBuffer actual, ByteBuffer expected) {
|
||||
actual.rewind();
|
||||
expected.rewind();
|
||||
assertEquals(actual.remaining(), width * height * 3);
|
||||
@ -77,6 +85,7 @@ public final class GlRectDrawerTest extends ActivityTestCase {
|
||||
return rgbBuffer;
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testRgbRendering() {
|
||||
// Create EGL base with a pixel buffer as display output.
|
||||
@ -108,13 +117,14 @@ public final class GlRectDrawerTest extends ActivityTestCase {
|
||||
GlUtil.checkNoGLES2Error("glReadPixels");
|
||||
|
||||
// Assert rendered image is pixel perfect to source RGB.
|
||||
assertEquals(WIDTH, HEIGHT, stripAlphaChannel(rgbaData), rgbPlane);
|
||||
assertByteBufferEquals(WIDTH, HEIGHT, stripAlphaChannel(rgbaData), rgbPlane);
|
||||
|
||||
drawer.release();
|
||||
GLES20.glDeleteTextures(1, new int[] {rgbTexture}, 0);
|
||||
eglBase.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testYuvRendering() {
|
||||
// Create EGL base with a pixel buffer as display output.
|
||||
@ -202,6 +212,7 @@ public final class GlRectDrawerTest extends ActivityTestCase {
|
||||
* - Render the OES texture onto the pixel buffer.
|
||||
* - Read back the pixel buffer and compare it with the known RGB data.
|
||||
*/
|
||||
@Test
|
||||
@MediumTest
|
||||
public void testOesRendering() throws InterruptedException {
|
||||
/**
|
||||
@ -283,7 +294,7 @@ public final class GlRectDrawerTest extends ActivityTestCase {
|
||||
GlUtil.checkNoGLES2Error("glReadPixels");
|
||||
|
||||
// Assert rendered image is pixel perfect to source RGB.
|
||||
assertEquals(WIDTH, HEIGHT, stripAlphaChannel(rgbaData), rgbPlane);
|
||||
assertByteBufferEquals(WIDTH, HEIGHT, stripAlphaChannel(rgbaData), rgbPlane);
|
||||
|
||||
drawer.release();
|
||||
surfaceTextureHelper.returnTextureFrame();
|
||||
|
||||
@ -7,26 +7,33 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import org.webrtc.MediaCodecVideoEncoder.OutputBufferInfo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.opengl.GLES11Ext;
|
||||
import android.opengl.GLES20;
|
||||
import android.os.Build;
|
||||
import android.test.ActivityTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.util.Log;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.webrtc.MediaCodecVideoEncoder.OutputBufferInfo;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
||||
public final class MediaCodecVideoEncoderTest extends ActivityTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class MediaCodecVideoEncoderTest {
|
||||
final static String TAG = "MediaCodecVideoEncoderTest";
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testInitializeUsingByteBuffer() {
|
||||
public void testInitializeUsingByteBuffer() {
|
||||
if (!MediaCodecVideoEncoder.isVp8HwSupported()) {
|
||||
Log.i(TAG, "Hardware does not support VP8 encoding, skipping testInitReleaseUsingByteBuffer");
|
||||
return;
|
||||
@ -37,8 +44,9 @@ public final class MediaCodecVideoEncoderTest extends ActivityTestCase {
|
||||
encoder.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testInitilizeUsingTextures() {
|
||||
public void testInitilizeUsingTextures() {
|
||||
if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) {
|
||||
Log.i(TAG, "hardware does not support VP8 encoding, skipping testEncoderUsingTextures");
|
||||
return;
|
||||
@ -51,8 +59,9 @@ public final class MediaCodecVideoEncoderTest extends ActivityTestCase {
|
||||
eglBase.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testInitializeUsingByteBufferReInitilizeUsingTextures() {
|
||||
public void testInitializeUsingByteBufferReInitilizeUsingTextures() {
|
||||
if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) {
|
||||
Log.i(TAG, "hardware does not support VP8 encoding, skipping testEncoderUsingTextures");
|
||||
return;
|
||||
@ -68,8 +77,9 @@ public final class MediaCodecVideoEncoderTest extends ActivityTestCase {
|
||||
eglBase.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testEncoderUsingByteBuffer() throws InterruptedException {
|
||||
public void testEncoderUsingByteBuffer() throws InterruptedException {
|
||||
if (!MediaCodecVideoEncoder.isVp8HwSupported()) {
|
||||
Log.i(TAG, "Hardware does not support VP8 encoding, skipping testEncoderUsingByteBuffer");
|
||||
return;
|
||||
@ -111,8 +121,9 @@ public final class MediaCodecVideoEncoderTest extends ActivityTestCase {
|
||||
encoder.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testEncoderUsingTextures() throws InterruptedException {
|
||||
public void testEncoderUsingTextures() throws InterruptedException {
|
||||
if (!MediaCodecVideoEncoder.isVp8HwSupportedUsingTextures()) {
|
||||
Log.i(TAG, "Hardware does not support VP8 encoding, skipping testEncoderUsingTextures");
|
||||
return;
|
||||
|
||||
@ -7,8 +7,12 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.webrtc.NetworkMonitorAutoDetect.ConnectionType;
|
||||
import static org.webrtc.NetworkMonitorAutoDetect.ConnectivityManagerDelegate;
|
||||
import static org.webrtc.NetworkMonitorAutoDetect.INVALID_NET_ID;
|
||||
@ -24,16 +28,25 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.test.ActivityTestCase;
|
||||
import android.test.UiThreadTest;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.annotation.UiThreadTest;
|
||||
import android.support.test.filters.MediumTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.rule.UiThreadTestRule;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests for org.webrtc.NetworkMonitor.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public class NetworkMonitorTest extends ActivityTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class NetworkMonitorTest {
|
||||
@Rule public UiThreadTestRule uiThreadTestRule = new UiThreadTestRule();
|
||||
|
||||
/**
|
||||
* Listens for alerts fired by the NetworkMonitor when network status changes.
|
||||
*/
|
||||
@ -147,7 +160,7 @@ public class NetworkMonitorTest extends ActivityTestCase {
|
||||
* Helper method to create a network monitor and delegates for testing.
|
||||
*/
|
||||
private void createTestMonitor() {
|
||||
Context context = getInstrumentation().getTargetContext();
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
NetworkMonitor.resetInstanceForTests(context);
|
||||
NetworkMonitor.setAutoDetectConnectivityState(true);
|
||||
receiver = NetworkMonitor.getAutoDetectorForTest();
|
||||
@ -167,23 +180,19 @@ public class NetworkMonitorTest extends ActivityTestCase {
|
||||
return receiver.getConnectionType(networkState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
getUiThreadHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
createTestMonitor();
|
||||
}
|
||||
});
|
||||
@Before
|
||||
public void setUp() {
|
||||
createTestMonitor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the receiver registers for connectivity intents during construction.
|
||||
*/
|
||||
@Test
|
||||
@UiThreadTest
|
||||
@SmallTest
|
||||
public void testNetworkMonitorRegistersInConstructor() throws InterruptedException {
|
||||
Context context = getInstrumentation().getTargetContext();
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
NetworkMonitorAutoDetect.Observer observer = new TestNetworkMonitorAutoDetectObserver();
|
||||
|
||||
@ -196,44 +205,45 @@ public class NetworkMonitorTest extends ActivityTestCase {
|
||||
* Tests that when there is an intent indicating a change in network connectivity, it sends a
|
||||
* notification to Java observers.
|
||||
*/
|
||||
@Test
|
||||
@UiThreadTest
|
||||
@MediumTest
|
||||
public void testNetworkMonitorJavaObservers() throws InterruptedException {
|
||||
// Initialize the NetworkMonitor with a connection.
|
||||
Intent connectivityIntent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
receiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
|
||||
receiver.onReceive(InstrumentationRegistry.getTargetContext(), connectivityIntent);
|
||||
|
||||
// We shouldn't be re-notified if the connection hasn't actually changed.
|
||||
NetworkMonitorTestObserver observer = new NetworkMonitorTestObserver();
|
||||
NetworkMonitor.addNetworkObserver(observer);
|
||||
receiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
|
||||
receiver.onReceive(InstrumentationRegistry.getTargetContext(), connectivityIntent);
|
||||
assertFalse(observer.hasReceivedNotification());
|
||||
|
||||
// We shouldn't be notified if we're connected to non-Wifi and the Wifi SSID changes.
|
||||
wifiDelegate.setWifiSSID("bar");
|
||||
receiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
|
||||
receiver.onReceive(InstrumentationRegistry.getTargetContext(), connectivityIntent);
|
||||
assertFalse(observer.hasReceivedNotification());
|
||||
|
||||
// We should be notified when we change to Wifi.
|
||||
connectivityDelegate.setNetworkType(ConnectivityManager.TYPE_WIFI);
|
||||
receiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
|
||||
receiver.onReceive(InstrumentationRegistry.getTargetContext(), connectivityIntent);
|
||||
assertTrue(observer.hasReceivedNotification());
|
||||
observer.resetHasReceivedNotification();
|
||||
|
||||
// We should be notified when the Wifi SSID changes.
|
||||
wifiDelegate.setWifiSSID("foo");
|
||||
receiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
|
||||
receiver.onReceive(InstrumentationRegistry.getTargetContext(), connectivityIntent);
|
||||
assertTrue(observer.hasReceivedNotification());
|
||||
observer.resetHasReceivedNotification();
|
||||
|
||||
// We shouldn't be re-notified if the Wifi SSID hasn't actually changed.
|
||||
receiver.onReceive(getInstrumentation().getTargetContext(), connectivityIntent);
|
||||
receiver.onReceive(InstrumentationRegistry.getTargetContext(), connectivityIntent);
|
||||
assertFalse(observer.hasReceivedNotification());
|
||||
|
||||
// Mimic that connectivity has been lost and ensure that the observer gets the notification.
|
||||
connectivityDelegate.setActiveNetworkExists(false);
|
||||
Intent noConnectivityIntent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
receiver.onReceive(getInstrumentation().getTargetContext(), noConnectivityIntent);
|
||||
receiver.onReceive(InstrumentationRegistry.getTargetContext(), noConnectivityIntent);
|
||||
assertTrue(observer.hasReceivedNotification());
|
||||
}
|
||||
|
||||
@ -242,11 +252,12 @@ public class NetworkMonitorTest extends ActivityTestCase {
|
||||
* active network connections so it cannot usefully check results, but it can at least check
|
||||
* that the functions don't crash.
|
||||
*/
|
||||
@Test
|
||||
@UiThreadTest
|
||||
@SmallTest
|
||||
public void testConnectivityManagerDelegateDoesNotCrash() {
|
||||
ConnectivityManagerDelegate delegate =
|
||||
new ConnectivityManagerDelegate(getInstrumentation().getTargetContext());
|
||||
new ConnectivityManagerDelegate(InstrumentationRegistry.getTargetContext());
|
||||
delegate.getNetworkState();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Network[] networks = delegate.getAllNetworks();
|
||||
@ -263,12 +274,13 @@ public class NetworkMonitorTest extends ActivityTestCase {
|
||||
* on having any active network connections so it cannot usefully check results, but it can at
|
||||
* least check that the functions don't crash.
|
||||
*/
|
||||
@Test
|
||||
@UiThreadTest
|
||||
@SmallTest
|
||||
public void testQueryableAPIsDoNotCrash() {
|
||||
NetworkMonitorAutoDetect.Observer observer = new TestNetworkMonitorAutoDetectObserver();
|
||||
NetworkMonitorAutoDetect ncn =
|
||||
new NetworkMonitorAutoDetect(observer, getInstrumentation().getTargetContext());
|
||||
new NetworkMonitorAutoDetect(observer, InstrumentationRegistry.getTargetContext());
|
||||
ncn.getDefaultNetId();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,14 +10,14 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import org.webrtc.Metrics.HistogramInfo;
|
||||
import org.webrtc.PeerConnection.IceConnectionState;
|
||||
import org.webrtc.PeerConnection.IceGatheringState;
|
||||
import org.webrtc.PeerConnection.SignalingState;
|
||||
|
||||
import android.test.ActivityTestCase;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.MediumTest;
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.ByteBuffer;
|
||||
@ -31,16 +31,25 @@ import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.webrtc.Metrics.HistogramInfo;
|
||||
import org.webrtc.PeerConnection.IceConnectionState;
|
||||
import org.webrtc.PeerConnection.IceGatheringState;
|
||||
import org.webrtc.PeerConnection.SignalingState;
|
||||
|
||||
/** End-to-end tests for PeerConnection.java. */
|
||||
public class PeerConnectionTest extends ActivityTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class PeerConnectionTest {
|
||||
private static final int TIMEOUT_SECONDS = 20;
|
||||
private TreeSet<String> threadsBeforeTest = null;
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
@Before
|
||||
public void setUp() {
|
||||
assertTrue(PeerConnectionFactory.initializeAndroidGlobals(
|
||||
getInstrumentation().getContext(), true, true, true));
|
||||
InstrumentationRegistry.getContext(), true, true, true));
|
||||
}
|
||||
|
||||
private static class ObserverExpectations
|
||||
@ -539,6 +548,7 @@ public class PeerConnectionTest extends ActivityTestCase {
|
||||
// in JNI-style programming; make sure no typos!
|
||||
// - Test that shutdown mid-interaction is crash-free.
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
public void testCompleteSession() throws Exception {
|
||||
Metrics.enable();
|
||||
@ -766,6 +776,7 @@ public class PeerConnectionTest extends ActivityTestCase {
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
public void testTrackRemovalAndAddition() throws Exception {
|
||||
// Allow loopback interfaces too since our Android devices often don't
|
||||
|
||||
@ -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;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
public final class RendererCommonTest extends ActivityTestCase {
|
||||
@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
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,19 +7,26 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.opengl.GLES20;
|
||||
import android.os.SystemClock;
|
||||
import android.test.ActivityTestCase;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import android.support.test.filters.MediumTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class SurfaceTextureHelperTest {
|
||||
/**
|
||||
* Mock texture listener with blocking wait functionality.
|
||||
*/
|
||||
@ -84,7 +91,8 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
public static void assertClose(int threshold, int expected, int actual) {
|
||||
if (Math.abs(expected - actual) <= threshold)
|
||||
return;
|
||||
failNotEquals("Not close enough, threshold " + threshold, expected, actual);
|
||||
fail("Not close enough, threshold " + threshold + ". Expected: " + expected + " Actual: "
|
||||
+ actual);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,8 +100,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
* as possible. The texture pixel values are inspected by drawing the texture frame to a pixel
|
||||
* buffer and reading it back with glReadPixels().
|
||||
*/
|
||||
@Test
|
||||
@MediumTest
|
||||
public static void testThreeConstantColorFrames() throws InterruptedException {
|
||||
public void testThreeConstantColorFrames() throws InterruptedException {
|
||||
final int width = 16;
|
||||
final int height = 16;
|
||||
// Create EGL base with a pixel buffer as display output.
|
||||
@ -160,8 +169,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
* texture frame should still be valid, and this is tested by drawing the texture frame to a pixel
|
||||
* buffer and reading it back with glReadPixels().
|
||||
*/
|
||||
@Test
|
||||
@MediumTest
|
||||
public static void testLateReturnFrame() throws InterruptedException {
|
||||
public void testLateReturnFrame() throws InterruptedException {
|
||||
final int width = 16;
|
||||
final int height = 16;
|
||||
// Create EGL base with a pixel buffer as display output.
|
||||
@ -226,8 +236,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
* Test disposing the SurfaceTextureHelper, but keep trying to produce more texture frames. No
|
||||
* frames should be delivered to the listener.
|
||||
*/
|
||||
@Test
|
||||
@MediumTest
|
||||
public static void testDispose() throws InterruptedException {
|
||||
public void testDispose() throws InterruptedException {
|
||||
// Create SurfaceTextureHelper and listener.
|
||||
final SurfaceTextureHelper surfaceTextureHelper =
|
||||
SurfaceTextureHelper.create("SurfaceTextureHelper test" /* threadName */, null);
|
||||
@ -263,8 +274,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
* Test disposing the SurfaceTextureHelper immediately after is has been setup to use a
|
||||
* shared context. No frames should be delivered to the listener.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testDisposeImmediately() {
|
||||
public void testDisposeImmediately() {
|
||||
final SurfaceTextureHelper surfaceTextureHelper =
|
||||
SurfaceTextureHelper.create("SurfaceTextureHelper test" /* threadName */, null);
|
||||
surfaceTextureHelper.dispose();
|
||||
@ -274,8 +286,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
* Call stopListening(), but keep trying to produce more texture frames. No frames should be
|
||||
* delivered to the listener.
|
||||
*/
|
||||
@Test
|
||||
@MediumTest
|
||||
public static void testStopListening() throws InterruptedException {
|
||||
public void testStopListening() throws InterruptedException {
|
||||
// Create SurfaceTextureHelper and listener.
|
||||
final SurfaceTextureHelper surfaceTextureHelper =
|
||||
SurfaceTextureHelper.create("SurfaceTextureHelper test" /* threadName */, null);
|
||||
@ -311,8 +324,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
/**
|
||||
* Test stopListening() immediately after the SurfaceTextureHelper has been setup.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testStopListeningImmediately() throws InterruptedException {
|
||||
public void testStopListeningImmediately() throws InterruptedException {
|
||||
final SurfaceTextureHelper surfaceTextureHelper =
|
||||
SurfaceTextureHelper.create("SurfaceTextureHelper test" /* threadName */, null);
|
||||
final MockTextureListener listener = new MockTextureListener();
|
||||
@ -325,8 +339,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
* Test stopListening() immediately after the SurfaceTextureHelper has been setup on the handler
|
||||
* thread.
|
||||
*/
|
||||
@Test
|
||||
@SmallTest
|
||||
public static void testStopListeningImmediatelyOnHandlerThread() throws InterruptedException {
|
||||
public void testStopListeningImmediatelyOnHandlerThread() throws InterruptedException {
|
||||
final SurfaceTextureHelper surfaceTextureHelper =
|
||||
SurfaceTextureHelper.create("SurfaceTextureHelper test" /* threadName */, null);
|
||||
final MockTextureListener listener = new MockTextureListener();
|
||||
@ -367,8 +382,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
/**
|
||||
* Test calling startListening() with a new listener after stopListening() has been called.
|
||||
*/
|
||||
@Test
|
||||
@MediumTest
|
||||
public static void testRestartListeningWithNewListener() throws InterruptedException {
|
||||
public void testRestartListeningWithNewListener() throws InterruptedException {
|
||||
// Create SurfaceTextureHelper and listener.
|
||||
final SurfaceTextureHelper surfaceTextureHelper =
|
||||
SurfaceTextureHelper.create("SurfaceTextureHelper test" /* threadName */, null);
|
||||
@ -410,8 +426,9 @@ public final class SurfaceTextureHelperTest extends ActivityTestCase {
|
||||
eglBase.release();
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
public static void testTexturetoYUV() throws InterruptedException {
|
||||
public void testTexturetoYUV() throws InterruptedException {
|
||||
final int width = 16;
|
||||
final int height = 16;
|
||||
|
||||
|
||||
@ -10,16 +10,27 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.test.ActivityTestCase;
|
||||
import android.test.UiThreadTest;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.annotation.UiThreadTest;
|
||||
import android.support.test.filters.MediumTest;
|
||||
import android.support.test.rule.UiThreadTestRule;
|
||||
import android.view.View.MeasureSpec;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class SurfaceViewRendererOnMeasureTest {
|
||||
@Rule public UiThreadTestRule uiThreadTestRule = new UiThreadTestRule();
|
||||
|
||||
public final class SurfaceViewRendererOnMeasureTest extends ActivityTestCase {
|
||||
/**
|
||||
* List with all possible scaling types.
|
||||
*/
|
||||
@ -68,11 +79,12 @@ public final class SurfaceViewRendererOnMeasureTest extends ActivityTestCase {
|
||||
/**
|
||||
* Test how SurfaceViewRenderer.onMeasure() behaves when no frame has been delivered.
|
||||
*/
|
||||
@Test
|
||||
@UiThreadTest
|
||||
@MediumTest
|
||||
public void testNoFrame() {
|
||||
final SurfaceViewRenderer surfaceViewRenderer =
|
||||
new SurfaceViewRenderer(getInstrumentation().getContext());
|
||||
new SurfaceViewRenderer(InstrumentationRegistry.getContext());
|
||||
final String frameDimensions = "null";
|
||||
|
||||
// Test behaviour before SurfaceViewRenderer.init() is called.
|
||||
@ -106,11 +118,12 @@ public final class SurfaceViewRendererOnMeasureTest extends ActivityTestCase {
|
||||
/**
|
||||
* Test how SurfaceViewRenderer.onMeasure() behaves with a 1280x720 frame.
|
||||
*/
|
||||
@Test
|
||||
@UiThreadTest
|
||||
@MediumTest
|
||||
public void testFrame1280x720() throws InterruptedException {
|
||||
final SurfaceViewRenderer surfaceViewRenderer =
|
||||
new SurfaceViewRenderer(getInstrumentation().getContext());
|
||||
new SurfaceViewRenderer(InstrumentationRegistry.getContext());
|
||||
/**
|
||||
* Mock renderer events with blocking wait functionality for frame size changes.
|
||||
*/
|
||||
|
||||
@ -10,18 +10,22 @@
|
||||
|
||||
package org.appspot.apprtc.test;
|
||||
|
||||
import android.test.InstrumentationTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.webrtc.PeerConnectionFactory;
|
||||
|
||||
// This test is intended to run on ARM and catch LoadLibrary errors when we load the WebRTC
|
||||
// JNI. It can't really be setting up calls since ARM emulators are too slow, but instantiating
|
||||
// a peer connection isn't timing-sensitive, so we can at least do that.
|
||||
public class WebRtcJniBootTest extends InstrumentationTestCase {
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class WebRtcJniBootTest {
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testJniLoadsWithoutError() throws InterruptedException {
|
||||
PeerConnectionFactory.initializeAndroidGlobals(getInstrumentation().getTargetContext(),
|
||||
PeerConnectionFactory.initializeAndroidGlobals(InstrumentationRegistry.getTargetContext(),
|
||||
true /* initializeAudio */, true /* initializeVideo */,
|
||||
false /* videoCodecHwAcceleration */);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user