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

Loading…
Cancel
Save