# XrDeviceTestRule

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

*** ** * ** ***


```
class XrDeviceTestRule : 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.runtime.testing.XrDeviceTestRule](https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule) |

*** ** * ** ***

JUnit Rule containing properties that affect the results of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice` capability APIs.

## Summary

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

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

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#isProjectedServiceAvailable()` This property can be used to control whether the Projected service is available or not. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#lifecycleState()` Tests can set this property to control the lifecycle state of the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`. |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/DisplayBlendMode` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#preferredDisplayBlendMode()` The result of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#getPreferredDisplayBlendMode()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#spatialApiVersion()` The value to be returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/SpatialApiVersionHelper#spatialApiVersion()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/DepthEstimationMode>` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#supportedDepthEstimationModes()` The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/DepthEstimationMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/EyeTrackingMode>` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#supportedEyeTrackingModes()` The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/EyeTrackingMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode>` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#supportedGeospatialModes()` The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/HandTrackingMode>` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#supportedHandTrackingModes()` The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/HandTrackingMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/runtime/RenderingMode>` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/testing/XrDeviceTestRule#supportedRenderingModes()` The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/RenderingMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`. |

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

### XrDeviceTestRule

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

```
XrDeviceTestRule()
```

## Protected functions

### after

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

### before

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

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

## Public properties

### isProjectedServiceAvailable

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

```
var isProjectedServiceAvailable: Boolean
```

This property can be used to control whether the Projected service is available or not. By default, the Projected service is available.

### lifecycleState

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

```
var lifecycleState: Lifecycle.State
```

Tests can set this property to control the lifecycle state of the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`. By default, the value is set to `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#INITIALIZED`.

### preferredDisplayBlendMode

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

```
var preferredDisplayBlendMode: DisplayBlendMode
```

The result of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#getPreferredDisplayBlendMode()`.

Tests can set this property to control the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#getPreferredDisplayBlendMode()` during the test execution.

### spatialApiVersion

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

```
var spatialApiVersion: Int
```

The value to be returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/SpatialApiVersionHelper#spatialApiVersion()`.

Tests can set this property to control the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/SpatialApiVersionHelper#spatialApiVersion()` during the test execution. By default the value is set to the latest stable API level.

Value is one of the following:

- `0`
- `1`
- `2`
- `3`
- `4`

<br />

### supportedDepthEstimationModes

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

```
var supportedDepthEstimationModes: Set<DepthEstimationMode>
```

The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/DepthEstimationMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`.

Tests can modify this set to control the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#isDepthEstimationModeSupported(androidx.xr.runtime.DepthEstimationMode)` during the test execution.

### supportedEyeTrackingModes

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

```
var supportedEyeTrackingModes: Set<EyeTrackingMode>
```

The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/EyeTrackingMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`.

Tests can modify this set to control the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#isEyeTrackingModeSupported(androidx.xr.runtime.EyeTrackingMode)` during the test execution.

### supportedGeospatialModes

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

```
var supportedGeospatialModes: Set<GeospatialMode>
```

The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/GeospatialMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`.

Tests can modify this set to control the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#isGeospatialModeSupported(androidx.xr.runtime.GeospatialMode)` during the test execution.

### supportedHandTrackingModes

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

```
var supportedHandTrackingModes: Set<HandTrackingMode>
```

The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/HandTrackingMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`.

Tests can modify this set to control the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#isHandTrackingModeSupported(androidx.xr.runtime.HandTrackingMode)` during the test execution.

### supportedRenderingModes

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

```
var supportedRenderingModes: Set<RenderingMode>
```

The set of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/RenderingMode` instances supported by the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice`.

Tests can modify this set to control the value returned by `https://developer.android.com/reference/kotlin/androidx/xr/runtime/XrDevice#isRenderingModeSupported(androidx.xr.runtime.RenderingMode)` during the test execution.