|
|
|
@ -41,7 +41,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testEmpty() { |
|
|
|
|
CameraOptions o = new CameraOptions(mock(Camera.Parameters.class), false); |
|
|
|
|
CameraOptions o = new CameraOptions(mock(Camera.Parameters.class), 0, false); |
|
|
|
|
assertTrue(o.getSupportedPictureAspectRatios().isEmpty()); |
|
|
|
|
assertTrue(o.getSupportedPictureSizes().isEmpty()); |
|
|
|
|
assertTrue(o.getSupportedWhiteBalance().isEmpty()); |
|
|
|
@ -71,7 +71,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
); |
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
when(params.getSupportedPictureSizes()).thenReturn(sizes); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<Size> supportedSizes = o.getSupportedPictureSizes(); |
|
|
|
|
assertEquals(supportedSizes.size(), sizes.size()); |
|
|
|
|
for (Camera.Size size : sizes) { |
|
|
|
@ -90,7 +90,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
); |
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
when(params.getSupportedPictureSizes()).thenReturn(sizes); |
|
|
|
|
CameraOptions o = new CameraOptions(params, true); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, true); |
|
|
|
|
Collection<Size> supportedSizes = o.getSupportedPictureSizes(); |
|
|
|
|
assertEquals(supportedSizes.size(), sizes.size()); |
|
|
|
|
for (Camera.Size size : sizes) { |
|
|
|
@ -115,7 +115,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
|
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
when(params.getSupportedPictureSizes()).thenReturn(sizes); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<AspectRatio> supportedRatios = o.getSupportedPictureAspectRatios(); |
|
|
|
|
assertEquals(supportedRatios.size(), expected.size()); |
|
|
|
|
for (AspectRatio ratio : expected) { |
|
|
|
@ -126,15 +126,17 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testVideoSizes() { |
|
|
|
|
// VideoSize are capped by CamcorderProfile.QUALITY_HIGH max size.
|
|
|
|
|
// This can be very small on an emulator, so use very small sizes to not hit that value.
|
|
|
|
|
List<Camera.Size> sizes = Arrays.asList( |
|
|
|
|
mockCameraSize(100, 200), |
|
|
|
|
mockCameraSize(50, 50), |
|
|
|
|
mockCameraSize(1600, 900), |
|
|
|
|
mockCameraSize(1000, 2000) |
|
|
|
|
mockCameraSize(10, 20), |
|
|
|
|
mockCameraSize(5, 5), |
|
|
|
|
mockCameraSize(16, 9), |
|
|
|
|
mockCameraSize(20, 40) |
|
|
|
|
); |
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
when(params.getSupportedVideoSizes()).thenReturn(sizes); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<Size> supportedSizes = o.getSupportedVideoSizes(); |
|
|
|
|
assertEquals(supportedSizes.size(), sizes.size()); |
|
|
|
|
for (Camera.Size size : sizes) { |
|
|
|
@ -147,15 +149,15 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
public void testVideoSizesNull() { |
|
|
|
|
// When videoSizes is null, we take the preview sizes.
|
|
|
|
|
List<Camera.Size> sizes = Arrays.asList( |
|
|
|
|
mockCameraSize(100, 200), |
|
|
|
|
mockCameraSize(50, 50), |
|
|
|
|
mockCameraSize(1600, 900), |
|
|
|
|
mockCameraSize(1000, 2000) |
|
|
|
|
mockCameraSize(10, 20), |
|
|
|
|
mockCameraSize(5, 5), |
|
|
|
|
mockCameraSize(16, 9), |
|
|
|
|
mockCameraSize(20, 40) |
|
|
|
|
); |
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
when(params.getSupportedVideoSizes()).thenReturn(null); |
|
|
|
|
when(params.getSupportedPreviewSizes()).thenReturn(sizes); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<Size> supportedSizes = o.getSupportedVideoSizes(); |
|
|
|
|
assertEquals(supportedSizes.size(), sizes.size()); |
|
|
|
|
for (Camera.Size size : sizes) { |
|
|
|
@ -167,14 +169,14 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
@Test |
|
|
|
|
public void testVideoSizesFlip() { |
|
|
|
|
List<Camera.Size> sizes = Arrays.asList( |
|
|
|
|
mockCameraSize(100, 200), |
|
|
|
|
mockCameraSize(50, 50), |
|
|
|
|
mockCameraSize(1600, 900), |
|
|
|
|
mockCameraSize(1000, 2000) |
|
|
|
|
mockCameraSize(10, 20), |
|
|
|
|
mockCameraSize(5, 5), |
|
|
|
|
mockCameraSize(16, 9), |
|
|
|
|
mockCameraSize(20, 40) |
|
|
|
|
); |
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
when(params.getSupportedVideoSizes()).thenReturn(sizes); |
|
|
|
|
CameraOptions o = new CameraOptions(params, true); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, true); |
|
|
|
|
Collection<Size> supportedSizes = o.getSupportedVideoSizes(); |
|
|
|
|
assertEquals(supportedSizes.size(), sizes.size()); |
|
|
|
|
for (Camera.Size size : sizes) { |
|
|
|
@ -186,10 +188,10 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
@Test |
|
|
|
|
public void testVideoAspectRatio() { |
|
|
|
|
List<Camera.Size> sizes = Arrays.asList( |
|
|
|
|
mockCameraSize(100, 200), |
|
|
|
|
mockCameraSize(50, 50), |
|
|
|
|
mockCameraSize(1600, 900), |
|
|
|
|
mockCameraSize(1000, 2000) |
|
|
|
|
mockCameraSize(10, 20), |
|
|
|
|
mockCameraSize(5, 5), |
|
|
|
|
mockCameraSize(16, 9), |
|
|
|
|
mockCameraSize(20, 40) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
Set<AspectRatio> expected = new HashSet<>(); |
|
|
|
@ -199,7 +201,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
|
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
when(params.getSupportedVideoSizes()).thenReturn(sizes); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<AspectRatio> supportedRatios = o.getSupportedVideoAspectRatios(); |
|
|
|
|
assertEquals(supportedRatios.size(), expected.size()); |
|
|
|
|
for (AspectRatio ratio : expected) { |
|
|
|
@ -215,7 +217,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
when(params.getMaxExposureCompensation()).thenReturn(0); |
|
|
|
|
when(params.getMinExposureCompensation()).thenReturn(0); |
|
|
|
|
|
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
assertFalse(o.supports(GestureAction.AUTO_FOCUS)); |
|
|
|
|
assertTrue(o.supports(GestureAction.TAKE_PICTURE)); |
|
|
|
|
assertTrue(o.supports(GestureAction.NONE)); |
|
|
|
@ -229,7 +231,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
public void testAlwaysSupportedControls() { |
|
|
|
|
// Grid, VideoQuality, SessionType and Audio are always supported.
|
|
|
|
|
Camera.Parameters params = mock(Camera.Parameters.class); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
|
|
|
|
|
Collection<Grid> grids = o.getSupportedControls(Grid.class); |
|
|
|
|
Collection<VideoCodec> video = o.getSupportedControls(VideoCodec.class); |
|
|
|
@ -250,7 +252,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
supported.add(cameraInfo.facing); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CameraOptions o = new CameraOptions(mock(Camera.Parameters.class), false); |
|
|
|
|
CameraOptions o = new CameraOptions(mock(Camera.Parameters.class), 0, false); |
|
|
|
|
Camera1Mapper m = Camera1Mapper.get(); |
|
|
|
|
Collection<Facing> s = o.getSupportedControls(Facing.class); |
|
|
|
|
assertEquals(s.size(), supported.size()); |
|
|
|
@ -269,7 +271,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
Camera.Parameters.WHITE_BALANCE_SHADE // Not supported
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<WhiteBalance> w = o.getSupportedControls(WhiteBalance.class); |
|
|
|
|
assertEquals(w.size(), 2); |
|
|
|
|
assertTrue(w.contains(WhiteBalance.AUTO)); |
|
|
|
@ -288,7 +290,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
Camera.Parameters.FLASH_MODE_RED_EYE // Not supported
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<Flash> f = o.getSupportedControls(Flash.class); |
|
|
|
|
assertEquals(f.size(), 3); |
|
|
|
|
assertTrue(f.contains(Flash.OFF)); |
|
|
|
@ -309,7 +311,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
Camera.Parameters.SCENE_MODE_FIREWORKS // Not supported
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
Collection<Hdr> h = o.getSupportedControls(Hdr.class); |
|
|
|
|
assertEquals(h.size(), 2); |
|
|
|
|
assertTrue(h.contains(Hdr.OFF)); |
|
|
|
@ -326,7 +328,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
when(params.isZoomSupported()).thenReturn(true); |
|
|
|
|
//noinspection ArraysAsListWithZeroOrOneArgument
|
|
|
|
|
when(params.getSupportedFocusModes()).thenReturn(Arrays.asList(Camera.Parameters.FOCUS_MODE_AUTO)); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
assertTrue(o.isZoomSupported()); |
|
|
|
|
assertTrue(o.isAutoFocusSupported()); |
|
|
|
|
} |
|
|
|
@ -337,7 +339,7 @@ public class CameraOptions1Test extends BaseTest { |
|
|
|
|
when(params.getMaxExposureCompensation()).thenReturn(10); |
|
|
|
|
when(params.getMinExposureCompensation()).thenReturn(-10); |
|
|
|
|
when(params.getExposureCompensationStep()).thenReturn(0.5f); |
|
|
|
|
CameraOptions o = new CameraOptions(params, false); |
|
|
|
|
CameraOptions o = new CameraOptions(params, 0, false); |
|
|
|
|
assertTrue(o.isExposureCorrectionSupported()); |
|
|
|
|
assertEquals(o.getExposureCorrectionMinValue(), -10f * 0.5f, 0f); |
|
|
|
|
assertEquals(o.getExposureCorrectionMaxValue(), 10f * 0.5f, 0f); |
|
|
|
|