public final class SceneCoreTestRule extends ExternalResource


A JUnit Rule for establishing a test environment for SceneCore applications.

This rule provides fake implementations and test accessors for SceneCore components, allowing you to configure and verify the internal runtime states of SceneCore's public API objects like Entity and Component.

To enable the test rule to manage the lifecycle and state of SceneCore objects, you must register the created instance with the rule after its creation using the createTester method provided by this rule. These methods return test-specific accessors that allow inspection and manipulation of the underlying fake instance.

Example usage:

@Rule @JvmField val testRule = SceneCoreTestRule()

// Inside a test method:
// Create a SceneCore Entity
val
entity = PanelEntity.create(...)
// Register it with the rule and get the test accessor
val
entityTester = testRule.createTester<PanelEntityTester>(entity)
// Use entityTester to interact with the entity's state

// Create a SceneCore Component
val component = MovableComponent.create(...)
// Register it and get the test accessor
val componentTester = testRule.createTester<MovableComponentTester>(component)
// Use componentTester to interact with the component'
s state

Summary

Public constructors

Public methods

final @NonNull ImageBasedLightingAssetTester

Creates a test data accessor for the given ImageBasedLightingAsset.

final @NonNull T
<T extends Object> createTester(@NonNull Component component)

Creates a specific test data accessor for the given Component.

final @NonNull T
<T extends Object> createTester(@NonNull Entity entity)

Creates a specific test data accessor for the given Entity.

final @NonNull GltfModelTester

Retrieves a test data accessor for the given GltfModel.

final @NonNull SpatialMediaPlayerTester

Creates the test data accessor for the given MediaPlayer.

final @NonNull SoundEffectPoolTester

Retrieves a test data accessor for the given SoundEffectPool.

final @NonNull TextureTester

Creates a test data accessor for the given Texture.

final @NonNull ActivitySpaceTester

Provides the instance of ActivitySpaceTester which is a test data accessor of the ActivitySpace.

final @NonNull MainPanelEntityTester

Provides the test-only accessor for MainPanelEntity that enables direct manipulation and inspection of its internal state.

final @NonNull PerceptionSpaceTester

Provides the instance of PerceptionSpaceTester which is a test data accessor of the PerceptionSpace.

final @NonNull SceneTester

Provides access to a controller for simulating runtime spatial states of the Scene.

final @NonNull SpatialEnvironmentTester

The test data accessor for the SpatialEnvironment.

final @NonNull SpatialSoundPoolTester

This provides a SpatialSoundPoolTester instance for accessing the SpatialSoundPool's underlying fake test data.

final @NonNull SpatialWindowTester

Provides the SpatialWindowTester test data accessor for the SpatialWindow.

Protected methods

void
void

Inherited methods

From org.junit.rules.TestRule

Public constructors

SceneCoreTestRule

Added in 1.0.0-alpha16
public SceneCoreTestRule()

Public methods

createTester

Added in 1.0.0-alpha16
public final @NonNull ImageBasedLightingAssetTester createTester(@NonNull ImageBasedLightingAsset asset)

Creates a test data accessor for the given ImageBasedLightingAsset.

In the test environment, each asset created via ImageBasedLightingAsset.createFromZip has corresponding underlying fake data. This function provides access to that fake data, allowing for verification or manipulation in tests.

Parameters
@NonNull ImageBasedLightingAsset asset

The ImageBasedLightingAsset instance for which to retrieve test data.

Returns
@NonNull ImageBasedLightingAssetTester

A ImageBasedLightingAssetTester instance used to inspect and manipulate the test data.

createTester

public final @NonNull T <T extends Object> createTester(@NonNull Component component)

Creates a specific test data accessor for the given Component.

In the test environment, components have corresponding underlying fake data. This function provides a convenient, type-safe way to access the specific tester associated with a component's subclass, allowing for verification or manipulation in tests.

Example usage:

val componentTester = rule.createTester<BoundsComponentTester>(myBoundsComponent)
Parameters
<T extends Object>

The expected type of the component tester (e.g., BoundsComponentTester).

@NonNull Component component

The Component instance for which to retrieve the test data accessor.

Returns
@NonNull T

A tester instance of type T.

Throws
IllegalArgumentException

If the underlying tester created for the component does not match the expected type T, or if no tester is found.

createTester

public final @NonNull T <T extends Object> createTester(@NonNull Entity entity)

Creates a specific test data accessor for the given Entity.

In the test environment, entities have corresponding underlying fake data. This function provides a convenient, type-safe way to access the specific tester associated with an entity's subclass, allowing for verification or manipulation in tests.

Example usage:

val entityTester = rule.createTester<PanelEntityTester>(myPanelEntity)
Parameters
<T extends Object>

The expected type of the entity tester (e.g., PanelEntityTester).

@NonNull Entity entity

The Entity instance for which to retrieve the test data accessor.

Returns
@NonNull T

A tester instance of type T.

Throws
IllegalArgumentException

If the underlying tester created for the entity does not match the expected type T.

createTester

Added in 1.0.0-alpha16
public final @NonNull GltfModelTester createTester(@NonNull GltfModel gltfModel)

Retrieves a test data accessor for the given GltfModel.

In the test environment, each model created via GltfModel.create has corresponding underlying fake data. This function provides access to that fake data, allowing for verification or manipulation in tests.

Parameters
@NonNull GltfModel gltfModel

The GltfModel instance for which to retrieve test data.

Returns
@NonNull GltfModelTester

A GltfModelTester instance used to inspect and manipulate the test data.

createTester

Added in 1.0.0-alpha16
public final @NonNull SpatialMediaPlayerTester createTester(@NonNull MediaPlayer mediaPlayer)

Creates the test data accessor for the given MediaPlayer.

This class provides a mechanism for tests to inspect and verify spatial audio attributes associated with a MediaPlayer that are otherwise encapsulated within the SceneCore runtime.

Parameters
@NonNull MediaPlayer mediaPlayer

The MediaPlayer audio attributes are associated with.

Returns
@NonNull SpatialMediaPlayerTester

A SpatialMediaPlayerTester instance used to inspect and manipulate the test data.

createTester

Added in 1.0.0-alpha16
public final @NonNull SoundEffectPoolTester createTester(@NonNull SoundEffectPool soundEffectPool)

Retrieves a test data accessor for the given SoundEffectPool.

In the test environment, each SoundEffectPool created via SoundEffectPool.create has corresponding underlying fake data. This function provides access to that fake data, allowing for verification or manipulation in tests.

Parameters
@NonNull SoundEffectPool soundEffectPool

The SoundEffectPool instance for which to retrieve test data.

Returns
@NonNull SoundEffectPoolTester

A SoundEffectPoolTester instance used to inspect and manipulate the test data.

createTester

Added in 1.0.0-alpha16
public final @NonNull TextureTester createTester(@NonNull Texture texture)

Creates a test data accessor for the given Texture.

In the test environment, each texture created via Texture.create has corresponding underlying fake data. This function provides access to that fake data, allowing for verification or manipulation in tests.

Parameters
@NonNull Texture texture

The Texture instance for which to retrieve test data.

Returns
@NonNull TextureTester

A TextureTester instance used to inspect and manipulate the test data.

getActivitySpaceTester

Added in 1.0.0-alpha16
public final @NonNull ActivitySpaceTester getActivitySpaceTester()

Provides the instance of ActivitySpaceTester which is a test data accessor of the ActivitySpace.

The ActivitySpace is an Entity used to track the system-managed pose and boundary of the volume associated with a spatialized Activity. The Application cannot directly control this volume, but the system might update it in response to the User moving it or entering or exiting Full Space Mode.

getMainPanelEntityTester

Added in 1.0.0-alpha16
public final @NonNull MainPanelEntityTester getMainPanelEntityTester()

Provides the test-only accessor for MainPanelEntity that enables direct manipulation and inspection of its internal state.

getPerceptionSpaceTester

Added in 1.0.0-alpha16
public final @NonNull PerceptionSpaceTester getPerceptionSpaceTester()

Provides the instance of PerceptionSpaceTester which is a test data accessor of the PerceptionSpace.

The PerceptionSpace represents the origin of the space in which ARCore for Jetpack XR provides tracking info. The transformations provided by the PerceptionSpace are only valid for the call frame, as the transformation can be changed by the system at any time.

getSceneTester

Added in 1.0.0-alpha16
public final @NonNull SceneTester getSceneTester()

Provides access to a controller for simulating runtime spatial states of the Scene.

Use this to test how your application responds to changes in various spatial-related runtime states, such as visibility, capability and so on.

getSpatialEnvironmentTester

Added in 1.0.0-alpha16
public final @NonNull SpatialEnvironmentTester getSpatialEnvironmentTester()

The test data accessor for the SpatialEnvironment.

getSpatialSoundPoolTester

Added in 1.0.0-alpha16
public final @NonNull SpatialSoundPoolTester getSpatialSoundPoolTester()

This provides a SpatialSoundPoolTester instance for accessing the SpatialSoundPool's underlying fake test data.

getSpatialWindowTester

Added in 1.0.0-alpha16
public final @NonNull SpatialWindowTester getSpatialWindowTester()

Provides the SpatialWindowTester test data accessor for the SpatialWindow.

Protected methods

after

protected void after()

before

protected void before()