pull/696/head
Mattia Iavarone 6 years ago
parent 075f6e3bfe
commit f6dabceee1
  1. 37
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/engine/CameraIntegrationTest.java

@ -345,6 +345,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
//region test open/close
@Test
@Retry(emulatorOnly = true)
public void testOpenClose() {
assertEquals(CameraState.OFF, controller.getState());
openSync(true);
@ -354,17 +355,20 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testOpenTwice() {
openSync(true);
openSync(false);
}
@Test
@Retry(emulatorOnly = true)
public void testCloseTwice() {
closeSync(false);
}
@Test
@Retry(emulatorOnly = true)
// This works great on the device but crashes often on the emulator.
// There must be something wrong with the emulated camera...
// Like stopPreview() and release() are not really sync calls?
@ -383,6 +387,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testStartInitializesOptions() {
assertNull(camera.getCameraOptions());
openSync(true);
@ -395,6 +400,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
// Test things that should reset the camera.
@Test
@Retry(emulatorOnly = true)
public void testSetFacing() throws Exception {
CameraOptions o = openSync(true);
int size = o.getSupportedFacing().size();
@ -412,6 +418,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetMode() throws Exception {
camera.setMode(Mode.PICTURE);
openSync(true);
@ -434,6 +441,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
// When camera is open, parameters will be set only if supported.
@Test
@Retry(emulatorOnly = true)
public void testSetZoom() {
CameraOptions options = openSync(true);
float oldValue = camera.getZoom();
@ -450,6 +458,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetExposureCorrection() {
CameraOptions options = openSync(true);
float oldValue = camera.getExposureCorrection();
@ -466,6 +475,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetFlash() {
CameraOptions options = openSync(true);
Flash[] values = Flash.values();
@ -485,6 +495,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetWhiteBalance() {
CameraOptions options = openSync(true);
WhiteBalance[] values = WhiteBalance.values();
@ -503,6 +514,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetHdr() {
CameraOptions options = openSync(true);
Hdr[] values = Hdr.values();
@ -521,6 +533,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetAudio() {
openSync(true);
Audio[] values = Audio.values();
@ -531,6 +544,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetLocation() {
openSync(true);
camera.setLocation(10d, 2d);
@ -543,6 +557,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetPreviewFrameRate() {
openSync(true);
camera.setPreviewFrameRate(30);
@ -552,6 +567,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testSetPlaySounds() {
boolean oldValue = camera.getPlaySounds();
boolean newValue = !oldValue;
@ -580,6 +596,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
//region test takeVideo
@Test(expected = RuntimeException.class)
@Retry(emulatorOnly = true)
public void testStartVideo_whileInPictureMode() throws Throwable {
camera.setMode(Mode.PICTURE);
openSync(true);
@ -645,6 +662,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testEndVideo_withoutStarting() {
camera.setMode(Mode.VIDEO);
openSync(true);
@ -707,6 +725,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
//region startAutoFocus
@Test
@Retry(emulatorOnly = true)
public void testStartAutoFocus() {
CameraOptions o = openSync(true);
@ -724,6 +743,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testStopAutoFocus() {
CameraOptions o = openSync(true);
@ -748,12 +768,14 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
//region capture
@Test
@Retry(emulatorOnly = true)
public void testCapturePicture_beforeStarted() {
camera.takePicture();
waitForPictureResult(false);
}
@Test
@Retry(emulatorOnly = true)
public void testCapturePicture_concurrentCalls() throws Exception {
// Second take should fail.
openSync(true);
@ -769,6 +791,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testCapturePicture_size() {
// Decoding can fail for large bitmaps. set a small size.
camera.setPictureSize(SizeSelectors.smallest());
@ -792,6 +815,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test(expected = RuntimeException.class)
@Retry(emulatorOnly = true)
public void testCapturePicture_whileInVideoMode() throws Throwable {
camera.setMode(Mode.VIDEO);
openSync(true);
@ -802,6 +826,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testCapturePicture_withMetering() {
openSync(true);
camera.setPictureMetering(true);
@ -810,6 +835,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testCapturePicture_withoutMetering() {
openSync(true);
camera.setPictureMetering(false);
@ -818,12 +844,14 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testCaptureSnapshot_beforeStarted() {
camera.takePictureSnapshot();
waitForPictureResult(false);
}
@Test
@Retry(emulatorOnly = true)
public void testCaptureSnapshot_concurrentCalls() throws Exception {
// Second take should fail.
openSync(true);
@ -839,6 +867,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testCaptureSnapshot_size() {
openSync(true);
Size size = camera.getSnapshotSize();
@ -861,6 +890,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testCaptureSnapshot_withMetering() {
openSync(true);
camera.setPictureSnapshotMetering(true);
@ -869,6 +899,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testCaptureSnapshot_withoutMetering() {
openSync(true);
camera.setPictureSnapshotMetering(false);
@ -882,6 +913,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
@SuppressWarnings("ConstantConditions")
@Test
@Retry(emulatorOnly = true)
public void testPictureFormat_DNG() {
openSync(true);
if (camera.getCameraOptions().supports(PictureFormat.DNG)) {
@ -914,6 +946,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testFrameProcessing_simple() throws Exception {
FrameProcessor processor = mock(FrameProcessor.class);
camera.addFrameProcessor(processor);
@ -923,6 +956,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testFrameProcessing_afterSnapshot() throws Exception {
FrameProcessor processor = mock(FrameProcessor.class);
camera.addFrameProcessor(processor);
@ -937,6 +971,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testFrameProcessing_afterRestart() throws Exception {
FrameProcessor processor = mock(FrameProcessor.class);
camera.addFrameProcessor(processor);
@ -962,6 +997,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
}
@Test
@Retry(emulatorOnly = true)
public void testFrameProcessing_freezeRelease() throws Exception {
// Ensure that freeze/release cycles do not cause OOMs.
// There was a bug doing this and it might resurface for any improper
@ -986,6 +1022,7 @@ public abstract class CameraIntegrationTest<E extends CameraEngine> extends Base
//region Overlays
@Test
@Retry(emulatorOnly = true)
public void testOverlay_forPictureSnapshot() {
Overlay overlay = mock(Overlay.class);
when(overlay.drawsOn(any(Overlay.Target.class))).thenReturn(true);

Loading…
Cancel
Save