Package org.robolectric.shadows
Class ShadowCamera
- java.lang.Object
-
- org.robolectric.shadows.ShadowCamera
-
@Implements(android.hardware.Camera.class) public class ShadowCamera extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowCamera.ShadowParametersShadows the AndroidCamera.Parametersclass.static classShadowCamera.ShadowSize
-
Constructor Summary
Constructors Constructor Description ShadowCamera()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void__constructor__()protected voidaddCallbackBuffer(byte[] callbackBuffer)static voidaddCameraInfo(int id, Camera.CameraInfo camInfo)Add a mockCamera.CameraInfoobject to simulate the existence of one or more cameras.protected voidautoFocus(Camera.AutoFocusCallback callback)protected voidcancelAutoFocus()static voidclearCameraInfo()protected booleanenableShutterSound(boolean enabled)List<byte[]>getAddedCallbackBuffers()protected static voidgetCameraInfo(int cameraId, Camera.CameraInfo cameraInfo)intgetDisplayOrientation()static intgetLastOpenedCameraId()protected static intgetNumberOfCameras()protected Camera.ParametersgetParameters()SurfaceHoldergetPreviewDisplay()booleanhasRequestedAutoFocus()voidinvokeAutoFocusCallback(boolean success, Camera camera)voidinvokePreviewCallback(byte[] data)Allows test cases to invoke the preview callback, to simulate a frame of camera data.booleanisLocked()booleanisPreviewing()booleanisReleased()booleanisShutterSoundEnabled()Returnstrueif the default shutter sound is played when taking a picture.protected static Cameraopen()protected static Cameraopen(int cameraId)protected voidreconnect()protected voidrelease()protected voidsetDisplayOrientation(int degrees)protected voidsetOneShotPreviewCallback(Camera.PreviewCallback cb)protected voidsetParameters(Camera.Parameters params)protected voidsetPreviewCallback(Camera.PreviewCallback cb)protected voidsetPreviewCallbackWithBuffer(Camera.PreviewCallback cb)protected voidsetPreviewDisplay(SurfaceHolder holder)protected voidstartPreview()protected voidstopPreview()protected voidtakePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg)protected voidunlock()
-
-
-
Method Detail
-
__constructor__
@Implementation protected void __constructor__()
-
open
@Implementation protected static Camera open()
-
open
@Implementation protected static Camera open(int cameraId)
-
getLastOpenedCameraId
public static int getLastOpenedCameraId()
-
unlock
@Implementation protected void unlock()
-
reconnect
@Implementation protected void reconnect()
-
getParameters
@Implementation protected Camera.Parameters getParameters()
-
setParameters
@Implementation protected void setParameters(Camera.Parameters params)
-
setPreviewDisplay
@Implementation protected void setPreviewDisplay(SurfaceHolder holder)
-
startPreview
@Implementation protected void startPreview()
-
stopPreview
@Implementation protected void stopPreview()
-
release
@Implementation protected void release()
-
setPreviewCallback
@Implementation protected void setPreviewCallback(Camera.PreviewCallback cb)
-
setOneShotPreviewCallback
@Implementation protected void setOneShotPreviewCallback(Camera.PreviewCallback cb)
-
setPreviewCallbackWithBuffer
@Implementation protected void setPreviewCallbackWithBuffer(Camera.PreviewCallback cb)
-
invokePreviewCallback
public void invokePreviewCallback(byte[] data)
Allows test cases to invoke the preview callback, to simulate a frame of camera data.- Parameters:
data- byte buffer of simulated camera data
-
addCallbackBuffer
@Implementation protected void addCallbackBuffer(byte[] callbackBuffer)
-
getAddedCallbackBuffers
public List<byte[]> getAddedCallbackBuffers()
-
setDisplayOrientation
@Implementation protected void setDisplayOrientation(int degrees)
-
getDisplayOrientation
public int getDisplayOrientation()
-
autoFocus
@Implementation protected void autoFocus(Camera.AutoFocusCallback callback)
-
cancelAutoFocus
@Implementation protected void cancelAutoFocus()
-
hasRequestedAutoFocus
public boolean hasRequestedAutoFocus()
-
invokeAutoFocusCallback
public void invokeAutoFocusCallback(boolean success, Camera camera)
-
getCameraInfo
@Implementation protected static void getCameraInfo(int cameraId, Camera.CameraInfo cameraInfo)
-
getNumberOfCameras
@Implementation protected static int getNumberOfCameras()
-
takePicture
@Implementation protected void takePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg)
-
enableShutterSound
@Implementation(minSdk=17) protected boolean enableShutterSound(boolean enabled)
-
isShutterSoundEnabled
public boolean isShutterSoundEnabled()
Returnstrueif the default shutter sound is played when taking a picture.
-
isLocked
public boolean isLocked()
-
isPreviewing
public boolean isPreviewing()
-
isReleased
public boolean isReleased()
-
getPreviewDisplay
public SurfaceHolder getPreviewDisplay()
-
addCameraInfo
public static void addCameraInfo(int id, Camera.CameraInfo camInfo)Add a mockCamera.CameraInfoobject to simulate the existence of one or more cameras. By default, no cameras are defined.- Parameters:
id- The camera idcamInfo- The CameraInfo
-
clearCameraInfo
public static void clearCameraInfo()
-
-