parent
c0142c11a9
commit
0a1d4d709d
@ -0,0 +1,27 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.annotation.TargetApi; |
||||
import android.hardware.Camera; |
||||
import android.hardware.camera2.CameraCharacteristics; |
||||
import android.util.SizeF; |
||||
|
||||
import org.junit.Test; |
||||
import org.mockito.Mockito; |
||||
|
||||
import static org.mockito.Mockito.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
public class ExtraPropertiesTest { |
||||
|
||||
@Test |
||||
public void testConstructor1() { |
||||
Camera.Parameters params = mock(Camera.Parameters.class); |
||||
when(params.getVerticalViewAngle()).thenReturn(10f); |
||||
when(params.getHorizontalViewAngle()).thenReturn(5f); |
||||
ExtraProperties e = new ExtraProperties(params); |
||||
assertEquals(e.getVerticalViewingAngle(), 10f, 0f); |
||||
assertEquals(e.getHorizontalViewingAngle(), 5f, 0f); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,54 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.hardware.Camera; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
public class Mapper1Test { |
||||
|
||||
private Mapper mapper = new Mapper.Mapper1(); |
||||
|
||||
@Test |
||||
public void testMap() { |
||||
assertEquals(mapper.map(Flash.OFF), Camera.Parameters.FLASH_MODE_OFF); |
||||
assertEquals(mapper.map(Flash.ON), Camera.Parameters.FLASH_MODE_ON); |
||||
assertEquals(mapper.map(Flash.AUTO), Camera.Parameters.FLASH_MODE_AUTO); |
||||
assertEquals(mapper.map(Flash.TORCH), Camera.Parameters.FLASH_MODE_TORCH); |
||||
|
||||
assertEquals(mapper.map(Facing.BACK), Camera.CameraInfo.CAMERA_FACING_BACK); |
||||
assertEquals(mapper.map(Facing.FRONT), Camera.CameraInfo.CAMERA_FACING_FRONT); |
||||
|
||||
assertEquals(mapper.map(Hdr.OFF), Camera.Parameters.SCENE_MODE_AUTO); |
||||
assertEquals(mapper.map(Hdr.ON), Camera.Parameters.SCENE_MODE_HDR); |
||||
|
||||
assertEquals(mapper.map(WhiteBalance.AUTO), Camera.Parameters.WHITE_BALANCE_AUTO); |
||||
assertEquals(mapper.map(WhiteBalance.DAYLIGHT), Camera.Parameters.WHITE_BALANCE_DAYLIGHT); |
||||
assertEquals(mapper.map(WhiteBalance.CLOUDY), Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT); |
||||
assertEquals(mapper.map(WhiteBalance.INCANDESCENT), Camera.Parameters.WHITE_BALANCE_INCANDESCENT); |
||||
assertEquals(mapper.map(WhiteBalance.FLUORESCENT), Camera.Parameters.WHITE_BALANCE_FLUORESCENT); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testUnmap() { |
||||
assertEquals(Flash.OFF, mapper.unmapFlash(Camera.Parameters.FLASH_MODE_OFF)); |
||||
assertEquals(Flash.ON, mapper.unmapFlash(Camera.Parameters.FLASH_MODE_ON)); |
||||
assertEquals(Flash.AUTO, mapper.unmapFlash(Camera.Parameters.FLASH_MODE_AUTO)); |
||||
assertEquals(Flash.TORCH, mapper.unmapFlash(Camera.Parameters.FLASH_MODE_TORCH)); |
||||
|
||||
assertEquals(Facing.BACK, mapper.unmapFacing(Camera.CameraInfo.CAMERA_FACING_BACK)); |
||||
assertEquals(Facing.FRONT, mapper.unmapFacing(Camera.CameraInfo.CAMERA_FACING_FRONT)); |
||||
|
||||
assertEquals(Hdr.OFF, mapper.unmapHdr(Camera.Parameters.SCENE_MODE_AUTO)); |
||||
assertEquals(Hdr.ON, mapper.unmapHdr(Camera.Parameters.SCENE_MODE_HDR)); |
||||
|
||||
assertEquals(WhiteBalance.AUTO, mapper.unmapWhiteBalance(Camera.Parameters.WHITE_BALANCE_AUTO)); |
||||
assertEquals(WhiteBalance.DAYLIGHT, mapper.unmapWhiteBalance(Camera.Parameters.WHITE_BALANCE_DAYLIGHT)); |
||||
assertEquals(WhiteBalance.CLOUDY, mapper.unmapWhiteBalance(Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT)); |
||||
assertEquals(WhiteBalance.INCANDESCENT, mapper.unmapWhiteBalance(Camera.Parameters.WHITE_BALANCE_INCANDESCENT)); |
||||
assertEquals(WhiteBalance.FLUORESCENT, mapper.unmapWhiteBalance(Camera.Parameters.WHITE_BALANCE_FLUORESCENT)); |
||||
} |
||||
} |
@ -0,0 +1,37 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import org.junit.Test; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
public class SizeTest { |
||||
|
||||
|
||||
@Test |
||||
public void testDimensions() { |
||||
Size size = new Size(10, 20); |
||||
assertEquals(size.getWidth(), 10f, 0f); |
||||
assertEquals(size.getHeight(), 20f, 0f); |
||||
assertEquals("10x20", size.toString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testEquals() { |
||||
Size s1 = new Size(10, 20); |
||||
Size s2 = new Size(10, 0); |
||||
Size s3 = new Size(10, 20); |
||||
assertTrue(s1.equals(s3)); |
||||
assertFalse(s1.equals(s2)); |
||||
} |
||||
|
||||
@Test |
||||
public void testCompare() { |
||||
Size s1 = new Size(10, 20); |
||||
Size s2 = new Size(10, 0); |
||||
Size s3 = new Size(10, 20); |
||||
assertTrue(s1.compareTo(s3) == 0); |
||||
assertTrue(s1.compareTo(s2) > 0); |
||||
assertTrue(s2.compareTo(s1) < 0); |
||||
} |
||||
} |
Loading…
Reference in new issue