# FakeCaptureResult

Artifact: [androidx.camera:camera-common-testing](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/testing/FakeCaptureResult.kt+class:androidx.camera.common.testing.FakeCaptureResult) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
class FakeCaptureResult : CaptureResultWrapper
```

<br />

*** ** * ** ***

A fake implementation of `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper` for testing.

Allows mock values to be configured for capture result parameters, custom metadata, camera ID, frame number, and capture request via its companion `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#invoke(androidx.camera.common.CameraId,androidx.camera.common.CameraFrameNumber,androidx.camera.common.CaptureRequestWrapper,kotlin.collections.Map,kotlin.collections.Map)` operator (Kotlin) or `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#create(kotlin.String,kotlin.Long,androidx.camera.common.CaptureRequestWrapper,kotlin.collections.Map,kotlin.collections.Map)` factory method (Java).

### Example (Kotlin)

```kotlin
val fakeResult = FakeCaptureResult(
    cameraId = CameraId("0"),
    frameNumber = CameraFrameNumber(1L),
    resultParameters = mapOf(CaptureResult.LENS_STATE to CaptureResult.LENS_STATE_MOVING)
)
```

### Example (Java)

```kotlin
FakeCaptureResult fakeResult = FakeCaptureResult.create(
    "0",
    1L,
    new FakeCaptureRequest(),
    resultParametersMap,
    resultMetadataMap
);
```

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` | `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#create(kotlin.String,kotlin.Long,androidx.camera.common.CaptureRequestWrapper,kotlin.collections.Map,kotlin.collections.Map)( cameraId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, frameNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, captureRequest: https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper, resultParameters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>, resultMetadata: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> )` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` instance for Java compatibility. |
| `operator https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` | `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#invoke(androidx.camera.common.CameraId,androidx.camera.common.CameraFrameNumber,androidx.camera.common.CaptureRequestWrapper,kotlin.collections.Map,kotlin.collections.Map)( cameraId: https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId, frameNumber: https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber, captureRequest: https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper, resultParameters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>, resultMetadata: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> )` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` instance for Kotlin clients. |

| ### Public functions |
|---|---|
| `open operator T?` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#get(android.hardware.camera2.CaptureResult.Key)(key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<T>)` Retrieves the mock value for the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`. |
| `open operator T?` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#get(androidx.camera.common.Metadata.Key)(key: https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<T>)` Retrieves the mock value for the specified custom metadata `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#get(androidx.camera.common.Metadata.Key)`. |
| `open T?` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#unwrapAs(java.lang.Class)(type: https://developer.android.com/reference/java/lang/Class.html<T>)` Attempts to unwrap this fake object. |

| ### Public properties |
|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId` | `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#cameraId()` The `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId` of the camera that produced this result. |
| `open https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#captureRequest()` The `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper` that generated this capture result. |
| `open https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber` | `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#frameNumber()` The `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber` associated with this result. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<*>>` | `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#keys()` List of all `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s supported by this capture result. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<*>>` | `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#metadataKeys()` The set of all custom `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`s currently available in this container. |

### Inherited functions

From [androidx.camera.common.CaptureResultMetadata](https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata) `open T` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)(key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<T>, default: T)`

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`, or returns `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)` if the key is not present or its value is null.
From [androidx.camera.common.Metadata](https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata) `open T` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)(key: https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<T>, default: T)`

Retrieves the value associated with the specified `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`, or returns `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)` if the key is not present.

## Public companion functions

### create

```
fun create(
    cameraId: String,
    frameNumber: Long,
    captureRequest: CaptureRequestWrapper = FakeCaptureRequest(),
    resultParameters: Map<CaptureResult.Key<*>, Any?> = emptyMap(),
    resultMetadata: Map<Metadata.Key<*>, Any?> = emptyMap()
): FakeCaptureResult
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` instance for Java compatibility.

This method is overloaded for Java callers to allow omitting trailing parameters with default values.

| Parameters |
|---|---|
| `cameraId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The camera ID string. |
| `frameNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The frame number. |
| `captureRequest: https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper = FakeCaptureRequest()` | The capture request wrapper that generated this result. Defaults to a default `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureRequest`. |
| `resultParameters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> = emptyMap()` | The map of capture result keys to their mock values. Defaults to an empty map. |
| `resultMetadata: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> = emptyMap()` | The map of custom metadata keys to their mock values. Defaults to an empty map. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` | A configured `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` instance. |

### invoke

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
operator fun invoke(
    cameraId: CameraId,
    frameNumber: CameraFrameNumber,
    captureRequest: CaptureRequestWrapper = FakeCaptureRequest(),
    resultParameters: Map<CaptureResult.Key<*>, Any?> = emptyMap(),
    resultMetadata: Map<Metadata.Key<*>, Any?> = emptyMap()
): FakeCaptureResult
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` instance for Kotlin clients.

Allows constructor-like syntax in Kotlin: `FakeCaptureResult(...)`.

| Parameters |
|---|---|
| `cameraId: https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId` | The strongly typed `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId` associated with the result. |
| `frameNumber: https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber` | The strongly typed `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber` associated with the result. |
| `captureRequest: https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper = FakeCaptureRequest()` | Optional wrapped `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper` that produced this result. Defaults to a default `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureRequest`. |
| `resultParameters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> = emptyMap()` | Optional map of capture result keys to their mock values. Defaults to an empty map. |
| `resultMetadata: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<*>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> = emptyMap()` | Optional map of custom metadata keys to their mock values. Defaults to an empty map. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` | A configured `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` instance. |

## Public functions

### get

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open operator fun <T : Any> get(key: CaptureResult.Key<T>): T?
```

Retrieves the mock value for the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`.

| Returns |
|---|---|
| `T?` | The configured mock value, or `null` if not set. |

### get

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open operator fun <T : Any> get(key: Metadata.Key<T>): T?
```

Retrieves the mock value for the specified custom metadata `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#get(androidx.camera.common.Metadata.Key)`.

| Returns |
|---|---|
| `T?` | The configured mock value, or `null` if not set. |

### unwrapAs

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open fun <T : Any> unwrapAs(type: Class<T>): T?
```

Attempts to unwrap this fake object.

Since this is a fake implementation, it does not wrap a native platform `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html`. This method will return `null` for `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html`. It only returns `this` cast to `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#unwrapAs(java.lang.Class)` if `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult#unwrapAs(java.lang.Class)` is compatible with `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult`.

## Public properties

### cameraId

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open val cameraId: CameraId
```

The `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId` of the camera that produced this result.

### captureRequest

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open val captureRequest: CaptureRequestWrapper
```

The `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper` that generated this capture result.

This represents the request settings that were active when this result was produced.

### frameNumber

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open val frameNumber: CameraFrameNumber
```

The `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber` associated with this result.

The frame number is a unique, monotonically increasing identifier for the frame.

### keys

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open val keys: List<CaptureResult.Key<*>>
```

List of all `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s supported by this capture result.

The list of all `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s that are supported and can be queried from this result.

| See also |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html#getKeys()` |   |

### metadataKeys

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
open val metadataKeys: Set<Metadata.Key<*>>
```

The set of all custom `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`s currently available in this container.

Note that this set contains *only* custom library-defined keys. It does not include platform-specific keys (such as `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html` or `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`), which are managed separately by the implementing wrappers.