Package org.robolectric.shadows
Class ShadowCamera
java.lang.Object
org.robolectric.shadows.ShadowCamera
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Shadows the AndroidCamera.Parameters
class. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addCallbackBuffer
(byte[] callbackBuffer) static void
addCameraInfo
(int id, Camera.CameraInfo camInfo) Add a mockCamera.CameraInfo
object to simulate the existence of one or more cameras.protected void
autoFocus
(Camera.AutoFocusCallback callback) protected void
static void
protected boolean
enableShutterSound
(boolean enabled) List<byte[]>
protected static void
getCameraInfo
(int cameraId, Camera.CameraInfo cameraInfo) int
static int
protected static int
protected Camera.Parameters
boolean
void
invokeAutoFocusCallback
(boolean success, Camera camera) void
invokePreviewCallback
(byte[] data) Allows test cases to invoke the preview callback, to simulate a frame of camera data.boolean
isLocked()
boolean
boolean
boolean
Returnstrue
if the default shutter sound is played when taking a picture.protected static Camera
open()
protected static Camera
open
(int cameraId) protected void
protected void
release()
protected void
setDisplayOrientation
(int degrees) protected void
protected void
setParameters
(Camera.Parameters params) protected void
protected void
protected void
setPreviewDisplay
(SurfaceHolder holder) protected void
protected void
protected void
takePicture
(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg) protected void
unlock()
-
Constructor Details
-
ShadowCamera
public ShadowCamera()
-
-
Method Details
-
open
-
open
-
getLastOpenedCameraId
public static int getLastOpenedCameraId() -
unlock
-
reconnect
-
getParameters
-
setParameters
-
setPreviewDisplay
-
startPreview
-
stopPreview
-
release
-
setPreviewCallback
-
setOneShotPreviewCallback
-
setPreviewCallbackWithBuffer
-
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
-
getAddedCallbackBuffers
-
setDisplayOrientation
-
getDisplayOrientation
public int getDisplayOrientation() -
autoFocus
-
cancelAutoFocus
-
hasRequestedAutoFocus
public boolean hasRequestedAutoFocus() -
invokeAutoFocusCallback
-
getCameraInfo
-
getNumberOfCameras
-
takePicture
@Implementation protected void takePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg) -
enableShutterSound
-
isShutterSoundEnabled
public boolean isShutterSoundEnabled()Returnstrue
if the default shutter sound is played when taking a picture. -
isLocked
public boolean isLocked() -
isPreviewing
public boolean isPreviewing() -
isReleased
public boolean isReleased() -
getPreviewDisplay
-
addCameraInfo
Add a mockCamera.CameraInfo
object to simulate the existence of one or more cameras. By default, no cameras are defined.- Parameters:
id
- The camera idcamInfo
- The CameraInfo
-
clearCameraInfo
-