pull/482/head
Mattia Iavarone 6 years ago
parent c3f6e59fdc
commit 3341c49256
  1. 14
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java
  2. 7
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java
  3. 2
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/picture/PictureRecorderTest.java
  4. 2
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/video/VideoRecorderTest.java
  5. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java

@ -150,19 +150,21 @@ public class CameraViewCallbacksTest extends BaseTest {
@Test
public void testDispatchOnVideoTaken() {
completeTask().when(listener).onVideoTaken(null);
camera.mCameraCallbacks.dispatchOnVideoTaken(null);
VideoResult.Stub stub = new VideoResult.Stub();
completeTask().when(listener).onVideoTaken(any(VideoResult.class));
camera.mCameraCallbacks.dispatchOnVideoTaken(stub);
assertNotNull(task.await(200));
verify(listener, times(1)).onVideoTaken(null);
verify(listener, times(1)).onVideoTaken(any(VideoResult.class));
}
@Test
public void testDispatchOnPictureTaken() {
completeTask().when(listener).onPictureTaken(null);
camera.mCameraCallbacks.dispatchOnPictureTaken(null);
PictureResult.Stub stub = new PictureResult.Stub();
completeTask().when(listener).onPictureTaken(any(PictureResult.class));
camera.mCameraCallbacks.dispatchOnPictureTaken(stub);
assertNotNull(task.await(200));
verify(listener, times(1)).onPictureTaken(null);
verify(listener, times(1)).onPictureTaken(any(PictureResult.class));
}
@Test

@ -215,6 +215,8 @@ public class CameraViewTest extends BaseTest {
@Test
public void testGestureAction_capture() {
CameraOptions o = mock(CameraOptions.class);
mockController.setMockCameraOptions(o);
mockController.mockStarted(true);
MotionEvent event = MotionEvent.obtain(0L, 0L, 0, 0f, 0f, 0);
ui(new Runnable() {
@ -235,6 +237,8 @@ public class CameraViewTest extends BaseTest {
@Test
public void testGestureAction_focus() {
CameraOptions o = mock(CameraOptions.class);
mockController.setMockCameraOptions(o);
mockController.mockStarted(true);
MotionEvent event = MotionEvent.obtain(0L, 0L, 0, 0f, 0f, 0);
ui(new Runnable() {
@ -264,6 +268,8 @@ public class CameraViewTest extends BaseTest {
@Test
public void testGestureAction_zoom() {
CameraOptions o = mock(CameraOptions.class);
mockController.setMockCameraOptions(o);
mockController.mockStarted(true);
mockController.mZoomChanged = false;
MotionEvent event = MotionEvent.obtain(0L, 0L, 0, 0f, 0f, 0);
@ -301,7 +307,6 @@ public class CameraViewTest extends BaseTest {
@Test
public void testGestureAction_exposureCorrection() {
// This needs a valid CameraOptions value.
CameraOptions o = mock(CameraOptions.class);
when(o.getExposureCorrectionMinValue()).thenReturn(-10f);
when(o.getExposureCorrectionMaxValue()).thenReturn(10f);

@ -37,7 +37,7 @@ public class PictureRecorderTest extends BaseTest {
}
private PictureResult.Stub createStub() throws Exception {
Constructor<PictureResult.Stub> constructor = PictureResult.Stub.class.getConstructor();
Constructor<PictureResult.Stub> constructor = PictureResult.Stub.class.getDeclaredConstructor();
constructor.setAccessible(true);
return constructor.newInstance();
}

@ -41,7 +41,7 @@ public class VideoRecorderTest extends BaseTest {
}
private VideoResult.Stub createStub() throws Exception {
Constructor<VideoResult.Stub> constructor = VideoResult.Stub.class.getConstructor();
Constructor<VideoResult.Stub> constructor = VideoResult.Stub.class.getDeclaredConstructor();
constructor.setAccessible(true);
return constructor.newInstance();
}

@ -287,7 +287,7 @@ public class Camera1Engine extends CameraEngine implements Camera.PreviewCallbac
@WorkerThread
@Override
void onStart() {
protected void onStart() {
if (isCameraAvailable()) {
LOG.w("onStart:", "Camera not available. Should not happen.");
onStop(); // Should not happen.
@ -305,7 +305,7 @@ public class Camera1Engine extends CameraEngine implements Camera.PreviewCallbac
@WorkerThread
@Override
void onStop() {
protected void onStop() {
LOG.i("onStop:", "About to clean up.");
mHandler.get().removeCallbacks(mPostFocusResetRunnable);
if (mVideoRecorder != null) {

Loading…
Cancel
Save