Chromium Code Reviews| Index: webrtc/api/androidtests/src/org/webrtc/Camera1CapturerTest.java |
| diff --git a/webrtc/api/androidtests/src/org/webrtc/Camera1CapturerTest.java b/webrtc/api/androidtests/src/org/webrtc/Camera1CapturerTest.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a757fde10f21d0b793c5a97e2cba31998d7326f3 |
| --- /dev/null |
| +++ b/webrtc/api/androidtests/src/org/webrtc/Camera1CapturerTest.java |
| @@ -0,0 +1,155 @@ |
| +/* |
| + * Copyright 2016 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. |
| + */ |
| + |
| +package org.webrtc; |
| + |
| +import android.test.suitebuilder.annotation.MediumTest; |
| +import android.test.suitebuilder.annotation.SmallTest; |
| + |
| +import org.webrtc.Logging; |
| +import org.webrtc.CameraEnumerationAndroid.CaptureFormat; |
| + |
| +public class Camera1CapturerTest extends CameraVideoCapturerTest { |
| + static final String TAG = "Camera1CapturerTest"; |
| + |
| + @Override |
| + protected CameraVideoCapturer createCapturer( |
| + String name, |
| + CameraVideoCapturer.CameraEventsHandler eventsHandler) { |
| + return new VideoCapturerAndroid(name, eventsHandler, isCapturingToTexture()); |
| + } |
| + |
| + @Override |
| + protected String getNameOfFrontFacingDevice() { |
| + return CameraEnumerationAndroid.getNameOfFrontFacingDevice(); |
| + } |
| + |
| + @Override |
| + protected String getNameOfBackFacingDevice() { |
| + return CameraEnumerationAndroid.getNameOfBackFacingDevice(); |
| + } |
| + |
| + // Return true if the device under test have at least two cameras. |
| + @SuppressWarnings("deprecation") |
| + @Override |
| + protected boolean haveTwoCameras() { |
| + return (android.hardware.Camera.getNumberOfCameras() >= 2); |
| + } |
| + |
| + @Override |
| + protected boolean isCapturingToTexture() { |
| + return false; |
| + } |
| + |
| + // This test that an error is reported if the camera is already opened |
| + // when CameraVideoCapturer is started. |
| + @SmallTest |
| + public void testStartWhileCameraAlreadyOpened() throws InterruptedException { |
| + String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
| + VideoCapturerAndroid capturer = (VideoCapturerAndroid) |
| + createCapturer(deviceName, null); |
| + Camera1CapturerTestFixtures.startWhileCameraIsAlreadyOpen( |
| + capturer, getInstrumentation().getContext()); |
| + } |
| + |
| + // 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. |
| + @SmallTest |
| + public void testStartWhileCameraIsAlreadyOpenAndCloseCamera() throws InterruptedException { |
| + String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
| + VideoCapturerAndroid capturer = (VideoCapturerAndroid) |
| + createCapturer(deviceName, null); |
| + Camera1CapturerTestFixtures.startWhileCameraIsAlreadyOpenAndCloseCamera( |
| + capturer, getInstrumentation().getContext()); |
| + } |
| + |
| + // This test that CameraVideoCapturer.stop can be called while CameraVideoCapturer is |
| + // re-trying to start. |
| + @SmallTest |
| + public void startWhileCameraIsAlreadyOpenAndStop() throws InterruptedException { |
| + String deviceName = CameraEnumerationAndroid.getDeviceName(0); |
| + VideoCapturerAndroid capturer = (VideoCapturerAndroid) |
| + createCapturer(deviceName, null); |
| + Camera1CapturerTestFixtures.startWhileCameraIsAlreadyOpenAndStop( |
| + capturer, getInstrumentation().getContext()); |
| + } |
| + |
| + // Common tests |
| + @SmallTest |
| + public void testSwitchVideoCapturer() throws InterruptedException { |
|
perkj_webrtc
2016/06/08 08:48:10
Why is this needed if super already implement a me
sakal
2016/06/08 09:20:14
Test runner doesn't see the tests unless they are
|
| + super.testSwitchVideoCapturer(); |
| + } |
| + |
| + @SmallTest |
| + public void testCreateAndRelease() { |
| + super.testCreateAndRelease(); |
| + } |
| + |
| + @SmallTest |
| + public void testCreateNonExistingCamera() { |
| + super.testCreateNonExistingCamera(); |
| + } |
| + |
| + @SmallTest |
| + public void testStartVideoCapturer() throws InterruptedException { |
| + super.testStartVideoCapturer(); |
| + } |
| + |
| + @MediumTest |
| + public void testCameraEvents() throws InterruptedException { |
| + super.testCameraEvents(); |
| + } |
| + |
| + @SmallTest |
| + public void testStopRestartVideoSource() throws InterruptedException { |
| + super.testStopRestartVideoSource(); |
| + } |
| + |
| + @SmallTest |
| + public void testStartStopWithDifferentResolutions() throws InterruptedException { |
| + super.testStartStopWithDifferentResolutions(); |
| + } |
| + |
| + @SmallTest |
| + public void testReturnBufferLate() throws InterruptedException { |
| + super.testReturnBufferLate(); |
| + } |
| + |
| + @MediumTest |
| + public void testReturnBufferLateEndToEnd() throws InterruptedException { |
| + super.testReturnBufferLateEndToEnd(); |
| + } |
| + |
| + // This test only supports textures |
| + // @MediumTest |
| + // public void testCameraFreezedEventOnBufferStarvation() throws InterruptedException { |
|
perkj_webrtc
2016/06/08 08:48:10
Please fix.
sakal
2016/06/08 09:20:14
The test doesn't really make sense for byte-buffer
|
| + // super.testCameraFreezedEventOnBufferStarvation(); |
| + // } |
| + |
| + @MediumTest |
| + public void testScaleCameraOutput() throws InterruptedException { |
| + super.testScaleCameraOutput(); |
| + } |
| + |
| + @SmallTest |
| + public void testStartFrontFacingVideoCapturer() throws InterruptedException { |
| + super.testStartFrontFacingVideoCapturer(); |
| + } |
| + |
| + @SmallTest |
| + public void testStartBackFacingVideoCapturer() throws InterruptedException { |
| + super.testStartBackFacingVideoCapturer(); |
| + } |
| + |
| + @MediumTest |
| + public void testCameraCallsAfterStop() throws InterruptedException { |
| + super.testCameraCallsAfterStop(); |
| + } |
| +} |