# 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)

*** ** * ** ***


```
public final class ArCoreTestRule extends ExternalResource
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.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/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/androidx/xr/arcore/testing/ArCoreTestRule#ArCoreTestRule()()` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#addTrackables(kotlin.Array)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/TestTrackable... trackables)` Adds the given `https://developer.android.com/reference/androidx/xr/arcore/testing/TestTrackable` objects and registers them with this ArCoreTestRule. |
| `final void` | `https://developer.android.com/reference/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/androidx/xr/runtime/math/Pose` instances. |
| `final int` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getAnchorResourceLimit()()` The maximum number of `https://developer.android.com/reference/androidx/xr/arcore/Anchor` objects that can be loaded at once in the runtime. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/TestAugmentedImage>` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getAugmentedImages()()` A list of all `https://developer.android.com/reference/androidx/xr/arcore/testing/TestAugmentedImage` objects in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/TestAugmentedObject>` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getAugmentedObjects()()` A list of all `https://developer.android.com/reference/androidx/xr/arcore/testing/TestAugmentedObject` objects in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/ArDeviceTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getDeviceTester()()` The object representing the user's device in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/FaceTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getFaceTester()()` The object representing the user's face. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/GeospatialTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getGeospatialTester()()` A test representation of the device's `https://developer.android.com/reference/androidx/xr/arcore/Geospatial` status. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/DepthTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getLeftDepthTester()()` A test representation of the device's left `https://developer.android.com/reference/androidx/xr/arcore/Depth` data. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/EyeTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getLeftEyeTester()()` The object representing the user's left eye in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/HandTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getLeftHandTester()()` The object representing the user's left hand in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/RenderViewpointTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getLeftRenderViewpointTester()()` A test representation of the device's left `https://developer.android.com/reference/androidx/xr/arcore/RenderViewpoint`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/DepthTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getMonoDepthTester()()` A test representation of the device's mono `https://developer.android.com/reference/androidx/xr/arcore/Depth` data. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/RenderViewpointTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getMonoRenderViewpointTester()()` A test representation of the device's mono `https://developer.android.com/reference/androidx/xr/arcore/RenderViewpoint`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/UUID.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose>` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getPersistedAnchorPoses()()` A Map of `https://developer.android.com/reference/java/util/UUID.html` to `Anchor` `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` stored outside the session. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/TestPlane>` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getPlanes()()` A list of all `https://developer.android.com/reference/androidx/xr/arcore/testing/TestPlane` objects in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/TestQrCode>` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getQrCodes()()` A list of all `https://developer.android.com/reference/androidx/xr/arcore/testing/TestQrCode` objects in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/DepthTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getRightDepthTester()()` A test representation of the device's right `https://developer.android.com/reference/androidx/xr/arcore/Depth` data. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/EyeTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getRightEyeTester()()` The object representing the user's right eye in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/HandTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getRightHandTester()()` The object representing the user's right hand in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/RenderViewpointTester` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getRightRenderViewpointTester()()` A test representation of the device's right `https://developer.android.com/reference/androidx/xr/arcore/RenderViewpoint`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/TestSpatialAnnotation>` | `@https://developer.android.com/reference/androidx/xr/runtime/ExperimentalSpatialAnnotationsApi https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#getSpatialAnnotations()()` A list of all `https://developer.android.com/reference/androidx/xr/arcore/testing/TestSpatialAnnotation` objects in the environment. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/UUID.html` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#persistAnchor(androidx.xr.runtime.math.Pose)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose pose)` Supply the `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of an `https://developer.android.com/reference/androidx/xr/arcore/Anchor` to be persisted outside the `https://developer.android.com/reference/androidx/xr/runtime/Session`. |
| `final void` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#setAnchorResourceLimit(kotlin.Int)(int value)` The maximum number of `https://developer.android.com/reference/androidx/xr/arcore/Anchor` objects that can be loaded at once in the runtime. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#after()()` |
| `void` | `https://developer.android.com/reference/androidx/xr/arcore/testing/ArCoreTestRule#before()()` |

### Inherited methods

From [org.junit.rules.ExternalResource](https://junit.org/junit4/javadoc/latest/org/junit/rules/ExternalResource.html) `@https://developer.android.com/reference/androidx/annotation/NonNull 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-(@https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html base, @https://developer.android.com/reference/androidx/annotation/NonNull https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html description)`

## Public constructors

### ArCoreTestRule

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

```
public ArCoreTestRule()
```

## Public methods

### addTrackables

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

```
public final void addTrackables(@NonNull TestTrackable... trackables)
```

Adds the given `https://developer.android.com/reference/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/androidx/xr/arcore/testing/TestTrackable#isVisible()` property and the `https://developer.android.com/reference/androidx/xr/runtime/Session` configuration.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/testing/TestTrackable... trackables` | `https://developer.android.com/reference/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)

```
public final void clearPersistedAnchors()
```

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

### getAnchorResourceLimit

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

```
public final int getAnchorResourceLimit()
```

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

### getAugmentedImages

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

```
public final @NonNull List<@NonNull TestAugmentedImage> getAugmentedImages()
```

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

### getAugmentedObjects

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

```
public final @NonNull List<@NonNull TestAugmentedObject> getAugmentedObjects()
```

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

### getDeviceTester

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

```
public final @NonNull ArDeviceTester getDeviceTester()
```

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

### getFaceTester

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

```
public final @NonNull FaceTester getFaceTester()
```

The object representing the user's face. `https://developer.android.com/reference/androidx/xr/runtime/Config#faceTracking()` must be set to `https://developer.android.com/reference/androidx/xr/runtime/FaceTrackingMode#BLEND_SHAPES()` for it to be integrated by the runtime. `https://developer.android.com/reference/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.

### getGeospatialTester

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

```
public final @NonNull GeospatialTester getGeospatialTester()
```

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

### getLeftDepthTester

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

```
public final @NonNull DepthTester getLeftDepthTester()
```

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

### getLeftEyeTester

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

```
public final @NonNull EyeTester getLeftEyeTester()
```

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

### getLeftHandTester

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

```
public final @NonNull HandTester getLeftHandTester()
```

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

### getLeftRenderViewpointTester

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

```
public final @NonNull RenderViewpointTester getLeftRenderViewpointTester()
```

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

### getMonoDepthTester

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

```
public final @NonNull DepthTester getMonoDepthTester()
```

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

### getMonoRenderViewpointTester

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

```
public final @NonNull RenderViewpointTester getMonoRenderViewpointTester()
```

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

### getPersistedAnchorPoses

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

```
public final @NonNull Map<@NonNull UUID, @NonNull Pose> getPersistedAnchorPoses()
```

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

### getPlanes

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

```
public final @NonNull List<@NonNull TestPlane> getPlanes()
```

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

### getQrCodes

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

```
public final @NonNull List<@NonNull TestQrCode> getQrCodes()
```

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

### getRightDepthTester

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

```
public final @NonNull DepthTester getRightDepthTester()
```

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

### getRightEyeTester

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

```
public final @NonNull EyeTester getRightEyeTester()
```

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

### getRightHandTester

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

```
public final @NonNull HandTester getRightHandTester()
```

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

### getRightRenderViewpointTester

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

```
public final @NonNull RenderViewpointTester getRightRenderViewpointTester()
```

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

### getSpatialAnnotations

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

```
@ExperimentalSpatialAnnotationsApi
public final @NonNull List<@NonNull TestSpatialAnnotation> getSpatialAnnotations()
```

A list of all `https://developer.android.com/reference/androidx/xr/arcore/testing/TestSpatialAnnotation` objects in the environment. Tracking must be configured via `https://developer.android.com/reference/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)

```
public final @NonNull UUID persistAnchor(@NonNull Pose pose)
```

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

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

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

### setAnchorResourceLimit

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

```
public final void setAnchorResourceLimit(int value)
```

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

## Protected methods

### after

```
protected void after()
```

### before

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

```
protected void before()
```