class SceneCoreTestRule : 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 functions

ImageBasedLightingAssetTester

Creates a test data accessor for the given ImageBasedLightingAsset.

inline T
<T : Any> createTester(component: Component)

Creates a specific test data accessor for the given Component.

inline T
<T : Any> createTester(entity: Entity)

Creates a specific test data accessor for the given Entity.

GltfModelTester
createTester(gltfModel: GltfModel)

Retrieves a test data accessor for the given GltfModel.

SpatialMediaPlayerTester
createTester(mediaPlayer: MediaPlayer)

Creates the test data accessor for the given MediaPlayer.

SoundEffectPoolTester
createTester(soundEffectPool: SoundEffectPool)

Retrieves a test data accessor for the given SoundEffectPool.

TextureTester

Creates a test data accessor for the given Texture.

Protected functions

open Unit
open Unit

Public properties

ActivitySpaceTester

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

MainPanelEntityTester

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

PerceptionSpaceTester

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

SceneTester

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

SpatialEnvironmentTester

The test data accessor for the SpatialEnvironment.

SpatialSoundPoolTester

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

SpatialWindowTester

Provides the SpatialWindowTester test data accessor for the SpatialWindow.

Inherited functions

From org.junit.rules.TestRule
open Statement
apply(base: Statement, description: Description)

Public constructors

SceneCoreTestRule

Added in 1.0.0-alpha16
SceneCoreTestRule()

Public functions

createTester

Added in 1.0.0-alpha16
fun createTester(asset: ImageBasedLightingAsset): ImageBasedLightingAssetTester

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
asset: ImageBasedLightingAsset

The ImageBasedLightingAsset instance for which to retrieve test data.

Returns
ImageBasedLightingAssetTester

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

createTester

inline fun <T : Any> createTester(component: Component): T

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 : Any>

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

component: Component

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

Returns
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

inline fun <T : Any> createTester(entity: Entity): T

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 : Any>

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

entity: Entity

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

Returns
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
fun createTester(gltfModel: GltfModel): GltfModelTester

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
gltfModel: GltfModel

The GltfModel instance for which to retrieve test data.

Returns
GltfModelTester

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

createTester

Added in 1.0.0-alpha16
fun createTester(mediaPlayer: MediaPlayer): SpatialMediaPlayerTester

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
mediaPlayer: MediaPlayer

The MediaPlayer audio attributes are associated with.

Returns
SpatialMediaPlayerTester

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

createTester

Added in 1.0.0-alpha16
fun createTester(soundEffectPool: SoundEffectPool): SoundEffectPoolTester

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
soundEffectPool: SoundEffectPool

The SoundEffectPool instance for which to retrieve test data.

Returns
SoundEffectPoolTester

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

createTester

Added in 1.0.0-alpha16
fun createTester(texture: Texture): TextureTester

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
texture: Texture

The Texture instance for which to retrieve test data.

Returns
TextureTester

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

Protected functions

after

protected open fun after(): Unit

before

protected open fun before(): Unit

Public properties

activitySpaceTester

Added in 1.0.0-alpha16
val activitySpaceTesterActivitySpaceTester

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.

mainPanelEntityTester

Added in 1.0.0-alpha16
val mainPanelEntityTesterMainPanelEntityTester

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

perceptionSpaceTester

Added in 1.0.0-alpha16
val perceptionSpaceTesterPerceptionSpaceTester

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.

sceneTester

Added in 1.0.0-alpha16
val sceneTesterSceneTester

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.

spatialEnvironmentTester

Added in 1.0.0-alpha16
val spatialEnvironmentTesterSpatialEnvironmentTester

The test data accessor for the SpatialEnvironment.

spatialSoundPoolTester

Added in 1.0.0-alpha16
val spatialSoundPoolTesterSpatialSoundPoolTester

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

spatialWindowTester

Added in 1.0.0-alpha16
val spatialWindowTesterSpatialWindowTester

Provides the SpatialWindowTester test data accessor for the SpatialWindow.