# SpatialEnvironmentTester

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

*** ** * ** ***


```
public final class SpatialEnvironmentTester
```

<br />

*** ** * ** ***

A test utility for accessing and inspecting the spatial data associated with the `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment`.

## Summary

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/testing/SpatialEnvironmentTester#triggerPassthroughOpacityChanged(kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float opacity )` Simulates a change in the user-visible passthrough opacity, notifying all registered listeners. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/testing/SpatialEnvironmentTester#triggerSpatialEnvironmentChanged(kotlin.Boolean)(boolean active)` Simulates a change in the active state of the preferred spatial environment, notifying all registered listeners. |

## Public methods

### triggerPassthroughOpacityChanged

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

```
public final void triggerPassthroughOpacityChanged(
    @FloatRange(from = 0.0, to = 1.0) float opacity
)
```

Simulates a change in the user-visible passthrough opacity, notifying all registered listeners.

This affects the value returned by `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment#currentPassthroughOpacity()` and triggers callbacks registered via `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment#addPassthroughOpacityChangedListener(java.util.function.Consumer)`.

A value of 0.0f means no passthrough is shown, and a value of 1.0f means the passthrough completely obscures the spatial environment geometry and skybox.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float opacity` | The current passthrough opacity value between 0.0f and 1.0f. |

### triggerSpatialEnvironmentChanged

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

```
public final void triggerSpatialEnvironmentChanged(boolean active)
```

Simulates a change in the active state of the preferred spatial environment, notifying all registered listeners.

This affects the value returned by `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment#isPreferredSpatialEnvironmentActive()` and triggers callbacks registered via `https://developer.android.com/reference/androidx/xr/scenecore/SpatialEnvironment#addSpatialEnvironmentChangedListener(java.util.function.Consumer)`.

| Parameters |
|---|---|
| `boolean active` | True if the environment preference is active. |