# ArCoreTestRule

Artifact: [androidx.xr.arcore:arcore-testing](https://developer.android.com/jetpack/androidx/releases/xr-arcore) [View Source](https://cs.android.com/search?q=file:androidx/xr/arcore/testing/ArCoreTestRule.kt+class:androidx.xr.arcore.testing.ArCoreTestRule) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

*** ** * ** ***


```
class ArCoreTestRule : ExternalResource
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [org.junit.rules.ExternalResource](https://junit.org/junit4/javadoc/latest/org/junit/rules/ExternalResource.html) ||
|   | ↳ | [androidx.xr.arcore.testing.ArCoreTestRule](https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule) |

*** ** * ** ***

A JUnit Rule for creating a test environment for ARCore for Jetpack XR applications. This rule allows you to write unit tests where you alter the state of the perception system.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#ArCoreTestRule()()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#addTrackables(kotlin.Array)(vararg trackables: https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestTrackable)` Adds the given `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestTrackable` objects and registers them with this ArCoreTestRule. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#clearPersistedAnchors()()` Clears the map of `https://developer.android.com/reference/java/util/UUID.html` instances to `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` instances. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestSpatialAnnotation>` | `@https://developer.android.com/reference/kotlin/androidx/xr/runtime/ExperimentalSpatialAnnotationsApi https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#getSpatialAnnotations()()` A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestSpatialAnnotation` objects in the environment. |
| `https://developer.android.com/reference/java/util/UUID.html` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#persistAnchor(androidx.xr.runtime.math.Pose)(pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose)` Supply the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` of an `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Anchor` to be persisted outside the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session`. |

| ### Protected functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#after()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#before()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#anchorResourceLimit()` The maximum number of `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Anchor` objects that can be loaded at once in the runtime. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestAugmentedImage>` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#augmentedImages()` A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestAugmentedImage` objects in the environment. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestAugmentedObject>` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#augmentedObjects()` A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestAugmentedObject` objects in the environment. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArDeviceTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#deviceTester()` The object representing the user's device in the environment. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/FaceTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#faceTester()` The object representing the user's face. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/GeospatialTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#geospatialTester()` A test representation of the device's `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Geospatial` status. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/DepthTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#leftDepthTester()` A test representation of the device's left `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Depth` data. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/EyeTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#leftEyeTester()` The object representing the user's left eye in the environment. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/HandTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#leftHandTester()` The object representing the user's left hand in the environment. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/RenderViewpointTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#leftRenderViewpointTester()` A test representation of the device's left `https://developer.android.com/reference/kotlin/androidx/xr/arcore/RenderViewpoint`. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/DepthTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#monoDepthTester()` A test representation of the device's mono `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Depth` data. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/RenderViewpointTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#monoRenderViewpointTester()` A test representation of the device's mono `https://developer.android.com/reference/kotlin/androidx/xr/arcore/RenderViewpoint`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/java/util/UUID.html, https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose>` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#persistedAnchorPoses()` A Map of `https://developer.android.com/reference/java/util/UUID.html` to `Anchor` `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` stored outside the session. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestPlane>` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#planes()` A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestPlane` objects in the environment. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestQrCode>` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#qrCodes()` A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestQrCode` objects in the environment. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/DepthTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#rightDepthTester()` A test representation of the device's right `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Depth` data. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/EyeTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#rightEyeTester()` The object representing the user's right eye in the environment. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/HandTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#rightHandTester()` The object representing the user's right hand in the environment. |
| `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/RenderViewpointTester` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/ArCoreTestRule#rightRenderViewpointTester()` A test representation of the device's right `https://developer.android.com/reference/kotlin/androidx/xr/arcore/RenderViewpoint`. |

### Inherited functions

From [org.junit.rules.ExternalResource](https://junit.org/junit4/javadoc/latest/org/junit/rules/ExternalResource.html) `https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html` `https://junit.org/junit4/javadoc/latest/org/junit/rules/ExternalResource.html#apply-org.junit.runners.model.Statement-org.junit.runner.Description-(base: https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html, description: https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html)`

## Public constructors

### ArCoreTestRule

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
ArCoreTestRule()
```

## Public functions

### addTrackables

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
fun addTrackables(vararg trackables: TestTrackable): Unit
```

Adds the given `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestTrackable` objects and registers them with this ArCoreTestRule.

Objects that are added are not removed during the lifetime of the test. Instead, their will be updated based on their `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestTrackable#isVisible()` property and the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` configuration.

| Parameters |
|---|---|
| `vararg trackables: https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestTrackable` | `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestTrackable` objects to add |

### clearPersistedAnchors

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
fun clearPersistedAnchors(): Unit
```

Clears the map of `https://developer.android.com/reference/java/util/UUID.html` instances to `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` instances.

### getSpatialAnnotations

Added in [1.1.0-alpha01](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.1.0-alpha01)

```
@ExperimentalSpatialAnnotationsApi
fun getSpatialAnnotations(): List<TestSpatialAnnotation>
```

A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestSpatialAnnotation` objects in the environment. Tracking must be configured via `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` in order for an added object to be ingested by the runtime.

### persistAnchor

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
fun persistAnchor(pose: Pose): UUID
```

Supply the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` of an `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Anchor` to be persisted outside the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session`. Persisted Anchors can be loaded by their `https://developer.android.com/reference/java/util/UUID.html`.

| Parameters |
|---|---|
| `pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` | the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` at which the test will persist an Anchor |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/UUID.html` | the `https://developer.android.com/reference/java/util/UUID.html` of the newly persisted Anchor |

## Protected functions

### after

```
protected open fun after(): Unit
```

### before

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
protected open fun before(): Unit
```

## Public properties

### anchorResourceLimit

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
var anchorResourceLimit: Int
```

The maximum number of `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Anchor` objects that can be loaded at once in the runtime. Defaults to 6.

### augmentedImages

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val augmentedImages: List<TestAugmentedImage>
```

A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestAugmentedImage` objects in the environment. Tracking must be configured via `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` in order for an added object to be ingested by the runtime.

### augmentedObjects

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val augmentedObjects: List<TestAugmentedObject>
```

A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestAugmentedObject` objects in the environment. Tracking must be configured via `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` in order for an added object to be ingested by the runtime.

### deviceTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val deviceTester: ArDeviceTester
```

The object representing the user's device in the environment. `https://developer.android.com/reference/kotlin/androidx/xr/runtime/DeviceTrackingMode.Companion#LAST_KNOWN()` must be configured for it to be ingested by the runtime.

### faceTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val faceTester: FaceTester
```

The object representing the user's face. `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Config#faceTracking()` must be set to `https://developer.android.com/reference/kotlin/androidx/xr/runtime/FaceTrackingMode#BLEND_SHAPES()` for it to be integrated by the runtime. `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/FaceTester#isValid()` must be set to true for the face's blend shape and confidence values to update in the API.

### geospatialTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val geospatialTester: GeospatialTester
```

A test representation of the device's `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Geospatial` status.

### leftDepthTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val leftDepthTester: DepthTester
```

A test representation of the device's left `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Depth` data.

### leftEyeTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val leftEyeTester: EyeTester
```

The object representing the user's left eye in the environment. `https://developer.android.com/reference/kotlin/androidx/xr/runtime/EyeTrackingMode#COARSE_TRACKING()` or `https://developer.android.com/reference/kotlin/androidx/xr/runtime/EyeTrackingMode#FINE_TRACKING()` must be configured for it to be ingested by the runtime. `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/EyeTester#isOpen()` must be set to true for the eye's pose to update in the API.

### leftHandTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val leftHandTester: HandTester
```

The object representing the user's left hand in the environment. `https://developer.android.com/reference/kotlin/androidx/xr/runtime/HandTrackingMode#BOTH()` must be configured for it to be ingested by the runtime. `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/HandTester#isVisible()` must be set to true for the hand's pose to update in the API.

### leftRenderViewpointTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val leftRenderViewpointTester: RenderViewpointTester
```

A test representation of the device's left `https://developer.android.com/reference/kotlin/androidx/xr/arcore/RenderViewpoint`.

### monoDepthTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val monoDepthTester: DepthTester
```

A test representation of the device's mono `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Depth` data.

### monoRenderViewpointTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val monoRenderViewpointTester: RenderViewpointTester
```

A test representation of the device's mono `https://developer.android.com/reference/kotlin/androidx/xr/arcore/RenderViewpoint`.

### persistedAnchorPoses

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val persistedAnchorPoses: Map<UUID, Pose>
```

A Map of `https://developer.android.com/reference/java/util/UUID.html` to `Anchor` `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` stored outside the session.

### planes

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val planes: List<TestPlane>
```

A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestPlane` objects in the environment. Tracking must be configured via `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` in order for an added plane to be ingested by the runtime.

### qrCodes

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val qrCodes: List<TestQrCode>
```

A list of all `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/TestQrCode` objects in the environment. Tracking must be configured via `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` in order for an added object to be ingested by the runtime.

### rightDepthTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val rightDepthTester: DepthTester
```

A test representation of the device's right `https://developer.android.com/reference/kotlin/androidx/xr/arcore/Depth` data.

### rightEyeTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val rightEyeTester: EyeTester
```

The object representing the user's right eye in the environment. `https://developer.android.com/reference/kotlin/androidx/xr/runtime/EyeTrackingMode#COARSE_TRACKING()` or `https://developer.android.com/reference/kotlin/androidx/xr/runtime/EyeTrackingMode#FINE_TRACKING()` must be configured for it to be ingested by the runtime. `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/EyeTester#isOpen()` must be set to true for the eye's pose to update in the API.

### rightHandTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val rightHandTester: HandTester
```

The object representing the user's right hand in the environment. `https://developer.android.com/reference/kotlin/androidx/xr/runtime/HandTrackingMode#BOTH()` must be configured for it to be ingested by the runtime. `https://developer.android.com/reference/kotlin/androidx/xr/arcore/testing/HandTester#isVisible()` must be set to true for the hand's pose to update in the API.

### rightRenderViewpointTester

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-arcore#1.0.0)

```
val rightRenderViewpointTester: RenderViewpointTester
```

A test representation of the device's right `https://developer.android.com/reference/kotlin/androidx/xr/arcore/RenderViewpoint`.