|
|
@ -39,7 +39,6 @@ public class IntegrationTest extends BaseTest { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
camera = new CameraView(rule.getActivity()) { |
|
|
|
camera = new CameraView(rule.getActivity()) { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected CameraController instantiateCameraController(CameraCallbacks callbacks, Preview preview) { |
|
|
|
protected CameraController instantiateCameraController(CameraCallbacks callbacks, Preview preview) { |
|
|
|
controller = new Camera1(callbacks, preview); |
|
|
|
controller = new Camera1(callbacks, preview); |
|
|
@ -115,7 +114,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
|
|
|
|
|
|
|
|
//region test open/close
|
|
|
|
//region test open/close
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testOpenClose() throws Exception { |
|
|
|
public void testOpenClose() throws Exception { |
|
|
|
// Starting and stopping are hard to get since they happen on another thread.
|
|
|
|
// Starting and stopping are hard to get since they happen on another thread.
|
|
|
|
assertEquals(controller.getState(), CameraController.STATE_STOPPED); |
|
|
|
assertEquals(controller.getState(), CameraController.STATE_STOPPED); |
|
|
@ -129,7 +128,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertEquals(controller.getState(), CameraController.STATE_STOPPED); |
|
|
|
assertEquals(controller.getState(), CameraController.STATE_STOPPED); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testOpenTwice() { |
|
|
|
public void testOpenTwice() { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
waitForOpen(true); |
|
|
|
waitForOpen(true); |
|
|
@ -137,14 +136,14 @@ public class IntegrationTest extends BaseTest { |
|
|
|
waitForOpen(false); |
|
|
|
waitForOpen(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testCloseTwice() { |
|
|
|
public void testCloseTwice() { |
|
|
|
camera.stop(); |
|
|
|
camera.stop(); |
|
|
|
waitForClose(false); |
|
|
|
waitForClose(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
// @Test
|
|
|
|
// This works great on the device but crashes on the emulator.
|
|
|
|
// TODO: This works great on the device but crashes 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?
|
|
|
|
public void testConcurrentCalls() throws Exception { |
|
|
|
public void testConcurrentCalls() throws Exception { |
|
|
@ -161,7 +160,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertTrue("Handles concurrent calls to start & stop, " + latch.getCount(), did); |
|
|
|
assertTrue("Handles concurrent calls to start & stop, " + latch.getCount(), did); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testStartInitializesOptions() { |
|
|
|
public void testStartInitializesOptions() { |
|
|
|
assertNull(camera.getCameraOptions()); |
|
|
|
assertNull(camera.getCameraOptions()); |
|
|
|
assertNull(camera.getExtraProperties()); |
|
|
|
assertNull(camera.getExtraProperties()); |
|
|
@ -176,7 +175,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
//region test Facing/SessionType
|
|
|
|
//region test Facing/SessionType
|
|
|
|
// Test things that should reset the camera.
|
|
|
|
// Test things that should reset the camera.
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetFacing() throws Exception { |
|
|
|
public void testSetFacing() throws Exception { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
CameraOptions o = waitForOpen(true); |
|
|
|
CameraOptions o = waitForOpen(true); |
|
|
@ -194,7 +193,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetSessionType() throws Exception { |
|
|
|
public void testSetSessionType() throws Exception { |
|
|
|
camera.setSessionType(SessionType.PICTURE); |
|
|
|
camera.setSessionType(SessionType.PICTURE); |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -217,7 +216,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
//region test Set Parameters
|
|
|
|
//region test Set Parameters
|
|
|
|
// When camera is open, parameters will be set only if supported.
|
|
|
|
// When camera is open, parameters will be set only if supported.
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetZoom() { |
|
|
|
public void testSetZoom() { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
@ -228,7 +227,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertEquals(can ? newValue : oldValue, camera.getZoom(), 0f); |
|
|
|
assertEquals(can ? newValue : oldValue, camera.getZoom(), 0f); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetExposureCorrection() { |
|
|
|
public void testSetExposureCorrection() { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
@ -239,7 +238,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertEquals(can ? newValue : oldValue, camera.getExposureCorrection(), 0f); |
|
|
|
assertEquals(can ? newValue : oldValue, camera.getExposureCorrection(), 0f); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetFlash() { |
|
|
|
public void testSetFlash() { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
@ -256,7 +255,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetWhiteBalance() { |
|
|
|
public void testSetWhiteBalance() { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
@ -273,7 +272,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetHdr() { |
|
|
|
public void testSetHdr() { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
|
CameraOptions options = waitForOpen(true); |
|
|
@ -290,7 +289,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetAudio() { |
|
|
|
public void testSetAudio() { |
|
|
|
// TODO: when permissions are managed, check that Audio.ON triggers the audio permission
|
|
|
|
// TODO: when permissions are managed, check that Audio.ON triggers the audio permission
|
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -302,14 +301,26 @@ public class IntegrationTest extends BaseTest { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-@Test
|
|
|
|
|
|
|
|
public void testSetLocation() { |
|
|
|
|
|
|
|
camera.start(); |
|
|
|
|
|
|
|
waitForOpen(true); |
|
|
|
|
|
|
|
camera.setLocation(10d, 2d); |
|
|
|
|
|
|
|
assertNotNull(camera.getLocation()); |
|
|
|
|
|
|
|
assertEquals(camera.getLocation().getLatitude(), 10d, 0d); |
|
|
|
|
|
|
|
assertEquals(camera.getLocation().getLongitude(), 2d, 0d); |
|
|
|
|
|
|
|
// This also ensures there are no crashes when attaching it to camera parameters.
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//endregion
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
|
|
|
|
//region testSetVideoQuality
|
|
|
|
//region testSetVideoQuality
|
|
|
|
// This can be tricky because can trigger layout changes.
|
|
|
|
// This can be tricky because can trigger layout changes.
|
|
|
|
|
|
|
|
|
|
|
|
// @Test(expected = IllegalStateException.class)
|
|
|
|
// @Test(expected = IllegalStateException.class)
|
|
|
|
// TODO: Removing. See comments below in the video region. Video is
|
|
|
|
// TODO: Can't run on Travis, MediaRecorder not supported.
|
|
|
|
// not reliable on emulators, MediaRecorder might not be supported.
|
|
|
|
// Error while starting MediaRecorder. java.lang.RuntimeException: start failed.
|
|
|
|
|
|
|
|
@Test |
|
|
|
public void testSetVideoQuality_whileRecording() { |
|
|
|
public void testSetVideoQuality_whileRecording() { |
|
|
|
camera.setSessionType(SessionType.VIDEO); |
|
|
|
camera.setSessionType(SessionType.VIDEO); |
|
|
|
camera.setVideoQuality(VideoQuality.HIGHEST); |
|
|
|
camera.setVideoQuality(VideoQuality.HIGHEST); |
|
|
@ -317,9 +328,10 @@ public class IntegrationTest extends BaseTest { |
|
|
|
waitForOpen(true); |
|
|
|
waitForOpen(true); |
|
|
|
camera.startCapturingVideo(null); |
|
|
|
camera.startCapturingVideo(null); |
|
|
|
camera.setVideoQuality(VideoQuality.LOWEST); |
|
|
|
camera.setVideoQuality(VideoQuality.LOWEST); |
|
|
|
|
|
|
|
throw new RuntimeException(CameraLogger.lastTag + ":" + CameraLogger.lastMessage); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetVideoQuality_whileInPictureSessionType() { |
|
|
|
public void testSetVideoQuality_whileInPictureSessionType() { |
|
|
|
camera.setSessionType(SessionType.PICTURE); |
|
|
|
camera.setSessionType(SessionType.PICTURE); |
|
|
|
camera.setVideoQuality(VideoQuality.HIGHEST); |
|
|
|
camera.setVideoQuality(VideoQuality.HIGHEST); |
|
|
@ -329,7 +341,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertEquals(camera.getVideoQuality(), VideoQuality.LOWEST); |
|
|
|
assertEquals(camera.getVideoQuality(), VideoQuality.LOWEST); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetVideoQuality_whileNotStarted() { |
|
|
|
public void testSetVideoQuality_whileNotStarted() { |
|
|
|
camera.setVideoQuality(VideoQuality.HIGHEST); |
|
|
|
camera.setVideoQuality(VideoQuality.HIGHEST); |
|
|
|
assertEquals(camera.getVideoQuality(), VideoQuality.HIGHEST); |
|
|
|
assertEquals(camera.getVideoQuality(), VideoQuality.HIGHEST); |
|
|
@ -337,7 +349,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertEquals(camera.getVideoQuality(), VideoQuality.LOWEST); |
|
|
|
assertEquals(camera.getVideoQuality(), VideoQuality.LOWEST); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testSetVideoQuality_shouldRecompute() { |
|
|
|
public void testSetVideoQuality_shouldRecompute() { |
|
|
|
// If video quality changes bring to a new capture size,
|
|
|
|
// If video quality changes bring to a new capture size,
|
|
|
|
// this might bring to a new aspect ratio,
|
|
|
|
// this might bring to a new aspect ratio,
|
|
|
@ -350,7 +362,9 @@ public class IntegrationTest extends BaseTest { |
|
|
|
//region test startVideo
|
|
|
|
//region test startVideo
|
|
|
|
|
|
|
|
|
|
|
|
// @Test(expected = IllegalStateException.class)
|
|
|
|
// @Test(expected = IllegalStateException.class)
|
|
|
|
// TODO: fails on Travis. Might be that some emulators can't deal with MediaRecorder
|
|
|
|
// TODO: fails on Travis. Some emulators can't deal with MediaRecorder
|
|
|
|
|
|
|
|
// Error while starting MediaRecorder. java.lang.RuntimeException: start failed.
|
|
|
|
|
|
|
|
// as documented. This works locally though.
|
|
|
|
public void testStartVideo_whileInPictureMode() { |
|
|
|
public void testStartVideo_whileInPictureMode() { |
|
|
|
camera.setSessionType(SessionType.PICTURE); |
|
|
|
camera.setSessionType(SessionType.PICTURE); |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -359,8 +373,9 @@ public class IntegrationTest extends BaseTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
// @Test
|
|
|
|
// TODO: fails on Travis. Might be that some emulators can't deal with MediaRecorder,
|
|
|
|
// TODO: fails on Travis. Some emulators can't deal with MediaRecorder,
|
|
|
|
// as documented. Or the File passed is invalid. Hard to know, this works locally.
|
|
|
|
// Error while starting MediaRecorder. java.lang.RuntimeException: start failed.
|
|
|
|
|
|
|
|
// as documented. This works locally though.
|
|
|
|
public void testStartEndVideo() { |
|
|
|
public void testStartEndVideo() { |
|
|
|
camera.setSessionType(SessionType.VIDEO); |
|
|
|
camera.setSessionType(SessionType.VIDEO); |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -369,7 +384,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
waitForVideo(true); // waits 2000
|
|
|
|
waitForVideo(true); // waits 2000
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testEndVideo_withoutStarting() { |
|
|
|
public void testEndVideo_withoutStarting() { |
|
|
|
camera.setSessionType(SessionType.VIDEO); |
|
|
|
camera.setSessionType(SessionType.VIDEO); |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -383,7 +398,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
//region startAutoFocus
|
|
|
|
//region startAutoFocus
|
|
|
|
// TODO: won't test onStopAutoFocus because that is not guaranteed to be called
|
|
|
|
// TODO: won't test onStopAutoFocus because that is not guaranteed to be called
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testStartAutoFocus() { |
|
|
|
public void testStartAutoFocus() { |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|
CameraOptions o = waitForOpen(true); |
|
|
|
CameraOptions o = waitForOpen(true); |
|
|
@ -399,13 +414,13 @@ public class IntegrationTest extends BaseTest { |
|
|
|
|
|
|
|
|
|
|
|
//region capture
|
|
|
|
//region capture
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testCapturePicture_beforeStarted() { |
|
|
|
public void testCapturePicture_beforeStarted() { |
|
|
|
camera.capturePicture(); |
|
|
|
camera.capturePicture(); |
|
|
|
waitForPicture(false); |
|
|
|
waitForPicture(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testCapturePicture_concurrentCalls() throws Exception { |
|
|
|
public void testCapturePicture_concurrentCalls() throws Exception { |
|
|
|
// Second take should fail.
|
|
|
|
// Second take should fail.
|
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -421,7 +436,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertEquals(latch.getCount(), 1); |
|
|
|
assertEquals(latch.getCount(), 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testCapturePicture_size() throws Exception { |
|
|
|
public void testCapturePicture_size() throws Exception { |
|
|
|
camera.setCropOutput(false); |
|
|
|
camera.setCropOutput(false); |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -437,13 +452,13 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertTrue(b.getHeight() == size.getHeight() || b.getHeight() == size.getWidth()); |
|
|
|
assertTrue(b.getHeight() == size.getHeight() || b.getHeight() == size.getWidth()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testCaptureSnapshot_beforeStarted() { |
|
|
|
public void testCaptureSnapshot_beforeStarted() { |
|
|
|
camera.captureSnapshot(); |
|
|
|
camera.captureSnapshot(); |
|
|
|
waitForPicture(false); |
|
|
|
waitForPicture(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testCaptureSnapshot_concurrentCalls() throws Exception { |
|
|
|
public void testCaptureSnapshot_concurrentCalls() throws Exception { |
|
|
|
// Second take should fail.
|
|
|
|
// Second take should fail.
|
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
@ -459,7 +474,7 @@ public class IntegrationTest extends BaseTest { |
|
|
|
assertEquals(latch.getCount(), 1); |
|
|
|
assertEquals(latch.getCount(), 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
//-@Test
|
|
|
|
public void testCaptureSnapshot_size() throws Exception { |
|
|
|
public void testCaptureSnapshot_size() throws Exception { |
|
|
|
camera.setCropOutput(false); |
|
|
|
camera.setCropOutput(false); |
|
|
|
camera.start(); |
|
|
|
camera.start(); |
|
|
|