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

Side by Side Diff: webrtc/api/androidtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java

Issue 2024843002: Refactor VideoCapturerAndroid tests in WebRTC. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixes according to perkj's comments #2 Created 4 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 package org.webrtc;
12
13 import android.content.Context;
14 import android.test.InstrumentationTestCase;
15 import android.test.suitebuilder.annotation.SmallTest;
16 import android.test.suitebuilder.annotation.MediumTest;
17 import android.test.suitebuilder.annotation.LargeTest;
18
19 import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
20
21 public class Camera1CapturerUsingByteBufferTest extends InstrumentationTestCase {
22 static final String TAG = "Camera1CapturerUsingByteBufferTest";
23
24 private class TestObjectFactory
25 implements CameraVideoCapturerTestFixtures.TestObjectFactory {
26 @Override
27 public CameraVideoCapturer createCapturer(
28 String name,
29 CameraVideoCapturer.CameraEventsHandler eventsHandler) {
30 return new VideoCapturerAndroid(name, eventsHandler, isCapturingToTexture( ));
31 }
32
33 @Override
34 public String getNameOfFrontFacingDevice() {
35 return CameraEnumerationAndroid.getNameOfFrontFacingDevice();
36 }
37
38 @Override
39 public String getNameOfBackFacingDevice() {
40 return CameraEnumerationAndroid.getNameOfBackFacingDevice();
41 }
42
43 // Return true if the device under test have at least two cameras.
44 @SuppressWarnings("deprecation")
45 @Override
46 public boolean haveTwoCameras() {
47 return (android.hardware.Camera.getNumberOfCameras() >= 2);
48 }
49
50 @Override
51 public boolean isCapturingToTexture() {
52 return false;
53 }
54
55 @Override
56 public Context getAppContext() {
57 return getInstrumentation().getTargetContext();
58 }
59
60 @SuppressWarnings("deprecation")
61 @Override
62 public Object rawOpenCamera(String cameraId) {
perkj_webrtc 2016/06/14 06:02:34 You use a String here. Why did you change getCamer
sakal 2016/06/14 08:40:55 I use String here because in Camera2 API camera id
63 return android.hardware.Camera.open(Integer.parseInt(cameraId));
64 }
65
66 @SuppressWarnings("deprecation")
67 @Override
68 public void rawCloseCamera(Object camera) {
69 ((android.hardware.Camera) camera).release();
70 }
71 }
72
73 private CameraVideoCapturerTestFixtures fixtures;
74
75 @Override
76 protected void setUp() {
77 fixtures = new CameraVideoCapturerTestFixtures(new TestObjectFactory());
78 }
79
80 @Override
81 protected void tearDown() {
82 fixtures.dispose();
83 }
84
85 @SmallTest
86 public void testCreateAndDispose() {
87 fixtures.createCapturerAndDispose();
88 }
89
90 @SmallTest
91 public void testCreateNonExistingCamera() {
92 fixtures.createNonExistingCamera();
93 }
94
95 // This test that the camera can be started and that the frames are forwarded
96 // to a Java video renderer using a "default" capturer.
97 // It tests both the Java and the C++ layer.
98 @MediumTest
99 public void testCreateCapturerAndRender() throws InterruptedException {
100 fixtures.createCapturerAndRender();
101 }
102
103 // This test that the camera can be started and that the frames are forwarded
104 // to a Java video renderer using the front facing video capturer.
105 // It tests both the Java and the C++ layer.
106 @MediumTest
107 public void testStartFrontFacingVideoCapturer() throws InterruptedException {
108 fixtures.createFrontFacingCapturerAndRender();
109 }
110
111 // This test that the camera can be started and that the frames are forwarded
112 // to a Java video renderer using the back facing video capturer.
113 // It tests both the Java and the C++ layer.
114 @MediumTest
115 public void testStartBackFacingVideoCapturer() throws InterruptedException {
116 fixtures.createBackFacingCapturerAndRender();
117 }
118
119 // This test that the default camera can be started and that the camera can
120 // later be switched to another camera.
121 // It tests both the Java and the C++ layer.
122 @MediumTest
123 public void testSwitchVideoCapturer() throws InterruptedException {
124 fixtures.switchCamera();
125 }
126
127 @MediumTest
128 public void testCameraEvents() throws InterruptedException {
129 fixtures.cameraEventsInvoked();
130 }
131
132 // Test what happens when attempting to call e.g. switchCamera() after camera has been stopped.
133 @MediumTest
134 public void testCameraCallsAfterStop() throws InterruptedException {
135 fixtures.cameraCallsAfterStop();
136 }
137
138 // This test that the VideoSource that the CameraVideoCapturer is connected to can
139 // be stopped and restarted. It tests both the Java and the C++ layer.
140 @LargeTest
141 public void testStopRestartVideoSource() throws InterruptedException {
142 fixtures.stopRestartVideoSource();
143 }
144
145 // This test that the camera can be started at different resolutions.
146 // It does not test or use the C++ layer.
147 @LargeTest
148 public void testStartStopWithDifferentResolutions() throws InterruptedExceptio n {
149 fixtures.startStopWithDifferentResolutions();
150 }
151
152 // This test what happens if buffers are returned after the capturer have
153 // been stopped and restarted. It does not test or use the C++ layer.
154 @LargeTest
155 public void testReturnBufferLate() throws InterruptedException {
156 fixtures.returnBufferLateEndToEnd();
157 }
158
159 // This test that we can capture frames, keep the frames in a local renderer, stop capturing,
160 // and then return the frames. The difference between the test testReturnBuffe rLate() is that we
161 // also test the JNI and C++ AndroidVideoCapturer parts.
162 @MediumTest
163 public void testReturnBufferLateEndToEnd() throws InterruptedException {
164 fixtures.returnBufferLateEndToEnd();
165 }
166
167 // This test that frames forwarded to a renderer is scaled if onOutputFormatRe quest is
168 // called. This test both Java and C++ parts of of the stack.
169 @MediumTest
170 public void testScaleCameraOutput() throws InterruptedException {
171 fixtures.scaleCameraOutput();
172 }
173
174 // This test that an error is reported if the camera is already opened
175 // when CameraVideoCapturer is started.
176 @LargeTest
177 public void testStartWhileCameraIsAlreadyOpen() throws InterruptedException {
178 fixtures.startWhileCameraIsAlreadyOpen();
179 }
180
181 // This test that CameraVideoCapturer can be started, even if the camera is al ready opened
182 // if the camera is closed while CameraVideoCapturer is re-trying to start.
183 @LargeTest
184 public void testStartWhileCameraIsAlreadyOpenAndCloseCamera() throws Interrupt edException {
185 fixtures.startWhileCameraIsAlreadyOpenAndCloseCamera();
186 }
187
188 // This test that CameraVideoCapturer.stop can be called while CameraVideoCapt urer is
189 // re-trying to start.
190 @MediumTest
191 public void testStartWhileCameraIsAlreadyOpenAndStop() throws InterruptedExcep tion {
192 fixtures.startWhileCameraIsAlreadyOpenAndStop();
193 }
194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698