Skip to content

Commit

Permalink
Cleanup java test
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakovschectman committed Oct 15, 2024
1 parent 97d72b8 commit 020afbc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,6 @@ public void startVideoRecording(@Nullable EventChannel imageStreamChannel) {
recordingVideo = true;
try {
startCapture(true, imageStreamChannel != null);
return;
} catch (CameraAccessException e) {
recordingVideo = false;
captureFile = null;
Expand Down Expand Up @@ -1083,8 +1082,7 @@ DeviceOrientationManager getDeviceOrientationManager() {
* @param result Flutter result.
* @param zoom new value.
*/
public void setZoomLevel(@NonNull final Messages.VoidResult result, float zoom)
throws CameraAccessException {
public void setZoomLevel(@NonNull final Messages.VoidResult result, float zoom) {
final ZoomLevelFeature zoomLevel = cameraFeatures.getZoomLevel();
float maxZoom = zoomLevel.getMaximumZoomLevel();
float minZoom = zoomLevel.getMinimumZoomLevel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public void startVideoRecording(
camera.startVideoRecording(Objects.equals(enableStream, true) ? imageStreamChannel : null);
}

@NonNull
@Override
public String stopVideoRecording(@NonNull Long cameraId) {
return camera.stopVideoRecording();
Expand Down Expand Up @@ -358,12 +359,7 @@ public void setZoomLevel(
@NonNull Long cameraId, @NonNull Double zoom, @NonNull Messages.VoidResult result) {

assert camera != null;

try {
camera.setZoomLevel(result, zoom.floatValue());
} catch (Exception e) {
handleException(e, result);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.flutter.plugins.camera;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -49,27 +50,23 @@ public void shouldNotImplementLifecycleObserverInterface() {
@Test
public void onMethodCall_pausePreview_shouldPausePreviewAndSendSuccessResult()
throws CameraAccessException {
handler.pausePreview(1L, mockResult);
handler.pausePreview(1L);

verify(mockCamera, times(1)).pausePreview();
verify(mockResult, times(1)).success();
}

@Test
public void onMethodCall_pausePreview_shouldSendErrorResultOnCameraAccessException()
throws CameraAccessException {
doThrow(new CameraAccessException(0)).when(mockCamera).pausePreview();

handler.pausePreview(1L, mockResult);

verify(mockResult, times(1)).error(any(CameraAccessException.class));
assertThrows(Messages.FlutterError.class, () -> handler.pausePreview(1L));
}

@Test
public void onMethodCall_resumePreview_shouldResumePreviewAndSendSuccessResult() {
handler.resumePreview(1L, mockResult);
handler.resumePreview(1L);

verify(mockCamera, times(1)).resumePreview();
verify(mockResult, times(1)).success();
}
}
Loading

0 comments on commit 020afbc

Please sign in to comment.