ArCoreTestRule


public final class ArCoreTestRule extends ExternalResource


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

Public methods

final void

Adds the given TestTrackable objects and registers them with this ArCoreTestRule.

final void

Clears the map of UUID instances to Pose instances.

final int

The maximum number of androidx.xr.arcore.Anchor objects that can be loaded at once in the runtime.

final @NonNull List<@NonNull TestAugmentedImage>

A list of all TestAugmentedImage objects in the environment.

final @NonNull List<@NonNull TestAugmentedObject>

A list of all TestAugmentedObject objects in the environment.

final @NonNull ArDeviceTester

The object representing the user's device in the environment.

final @NonNull FaceTester

The object representing the user's face.

final @NonNull GeospatialTester

A test representation of the device's androidx.xr.arcore.Geospatial status.

final @NonNull DepthTester

A test representation of the device's left androidx.xr.arcore.Depth data.

final @NonNull EyeTester

The object representing the user's left eye in the environment.

final @NonNull HandTester

The object representing the user's left hand in the environment.

final @NonNull RenderViewpointTester

A test representation of the device's left androidx.xr.arcore.RenderViewpoint.

final @NonNull DepthTester

A test representation of the device's mono androidx.xr.arcore.Depth data.

final @NonNull RenderViewpointTester

A test representation of the device's mono androidx.xr.arcore.RenderViewpoint.

final @NonNull Map<@NonNull UUID, @NonNull Pose>

A Map of UUID to Anchor Poses stored outside the session.

final @NonNull List<@NonNull TestPlane>

A list of all TestPlane objects in the environment.

final @NonNull List<@NonNull TestQrCode>

A list of all TestQrCode objects in the environment.

final @NonNull DepthTester

A test representation of the device's right androidx.xr.arcore.Depth data.

final @NonNull EyeTester

The object representing the user's right eye in the environment.

final @NonNull HandTester

The object representing the user's right hand in the environment.

final @NonNull RenderViewpointTester

A test representation of the device's right androidx.xr.arcore.RenderViewpoint.

final @NonNull UUID

Supply the Pose of an androidx.xr.arcore.Anchor to be persisted outside the androidx.xr.runtime.Session.

final void

The maximum number of androidx.xr.arcore.Anchor objects that can be loaded at once in the runtime.

Protected methods

void
void

Inherited methods

From org.junit.rules.TestRule

Public constructors

ArCoreTestRule

Added in 1.0.0-alpha15
public ArCoreTestRule()

Public methods

addTrackables

Added in 1.0.0-alpha15
public final void addTrackables(@NonNull TestTrackable... trackables)

Adds the given TestTrackable objects and registers them with this ArCoreTestRule.

Objects that are added are not removed during the lifetime of the test. Instead, their TrackingState will be updated based on their TestTrackable.isVisible property and the androidx.xr.runtime.Session configuration.

Parameters
@NonNull TestTrackable... trackables

TestTrackable objects to add

clearPersistedAnchors

Added in 1.0.0-alpha15
public final void clearPersistedAnchors()

Clears the map of UUID instances to Pose instances.

getAnchorResourceLimit

Added in 1.0.0-alpha15
public final int getAnchorResourceLimit()

The maximum number of androidx.xr.arcore.Anchor objects that can be loaded at once in the runtime. Defaults to 6.

getAugmentedImages

Added in 1.0.0-alpha15
public final @NonNull List<@NonNull TestAugmentedImagegetAugmentedImages()

A list of all TestAugmentedImage objects in the environment. Tracking must be configured via androidx.xr.runtime.Session.configure in order for an added object to be ingested by the runtime.

getAugmentedObjects

Added in 1.0.0-alpha15
public final @NonNull List<@NonNull TestAugmentedObjectgetAugmentedObjects()

A list of all TestAugmentedObject objects in the environment. Tracking must be configured via androidx.xr.runtime.Session.configure in order for an added object to be ingested by the runtime.

getDeviceTester

Added in 1.0.0-alpha15
public final @NonNull ArDeviceTester getDeviceTester()

The object representing the user's device in the environment. androidx.xr.runtime.DeviceTrackingMode.LAST_KNOWN must be configured for it to be ingested by the runtime.

getFaceTester

Added in 1.0.0-alpha15
public final @NonNull FaceTester getFaceTester()

The object representing the user's face. Config.faceTracking must be set to androidx.xr.runtime.FaceTrackingMode.BLEND_SHAPES for it to be integrated by the runtime. 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-alpha15
public final @NonNull GeospatialTester getGeospatialTester()

A test representation of the device's androidx.xr.arcore.Geospatial status.

getLeftDepthTester

Added in 1.0.0-alpha15
public final @NonNull DepthTester getLeftDepthTester()

A test representation of the device's left androidx.xr.arcore.Depth data.

getLeftEyeTester

Added in 1.0.0-alpha15
public final @NonNull EyeTester getLeftEyeTester()

The object representing the user's left eye in the environment. androidx.xr.runtime.EyeTrackingMode.COARSE_TRACKING or androidx.xr.runtime.EyeTrackingMode.FINE_TRACKING must be configured for it to be ingested by the runtime. EyeTester.isOpen must be set to true for the eye's pose to update in the API.

getLeftHandTester

Added in 1.0.0-alpha15
public final @NonNull HandTester getLeftHandTester()

The object representing the user's left hand in the environment. androidx.xr.runtime.HandTrackingMode.BOTH must be configured for it to be ingested by the runtime. HandTester.isVisible must be set to true for the hand's pose to update in the API.

getLeftRenderViewpointTester

Added in 1.0.0-alpha15
public final @NonNull RenderViewpointTester getLeftRenderViewpointTester()

A test representation of the device's left androidx.xr.arcore.RenderViewpoint.

getMonoDepthTester

Added in 1.0.0-alpha15
public final @NonNull DepthTester getMonoDepthTester()

A test representation of the device's mono androidx.xr.arcore.Depth data.

getMonoRenderViewpointTester

Added in 1.0.0-alpha15
public final @NonNull RenderViewpointTester getMonoRenderViewpointTester()

A test representation of the device's mono androidx.xr.arcore.RenderViewpoint.

getPersistedAnchorPoses

Added in 1.0.0-alpha15
public final @NonNull Map<@NonNull UUID, @NonNull PosegetPersistedAnchorPoses()

A Map of UUID to Anchor Poses stored outside the session.

getPlanes

Added in 1.0.0-alpha15
public final @NonNull List<@NonNull TestPlanegetPlanes()

A list of all TestPlane objects in the environment. Tracking must be configured via androidx.xr.runtime.Session.configure in order for an added plane to be ingested by the runtime.

getQrCodes

Added in 1.0.0-alpha15
public final @NonNull List<@NonNull TestQrCodegetQrCodes()

A list of all TestQrCode objects in the environment. Tracking must be configured via androidx.xr.runtime.Session.configure in order for an added object to be ingested by the runtime.

getRightDepthTester

Added in 1.0.0-alpha15
public final @NonNull DepthTester getRightDepthTester()

A test representation of the device's right androidx.xr.arcore.Depth data.

getRightEyeTester

Added in 1.0.0-alpha15
public final @NonNull EyeTester getRightEyeTester()

The object representing the user's right eye in the environment. androidx.xr.runtime.EyeTrackingMode.COARSE_TRACKING or androidx.xr.runtime.EyeTrackingMode.FINE_TRACKING must be configured for it to be ingested by the runtime. EyeTester.isOpen must be set to true for the eye's pose to update in the API.

getRightHandTester

Added in 1.0.0-alpha15
public final @NonNull HandTester getRightHandTester()

The object representing the user's right hand in the environment. androidx.xr.runtime.HandTrackingMode.BOTH must be configured for it to be ingested by the runtime. HandTester.isVisible must be set to true for the hand's pose to update in the API.

getRightRenderViewpointTester

Added in 1.0.0-alpha15
public final @NonNull RenderViewpointTester getRightRenderViewpointTester()

A test representation of the device's right androidx.xr.arcore.RenderViewpoint.

persistAnchor

Added in 1.0.0-alpha15
public final @NonNull UUID persistAnchor(@NonNull Pose pose)

Supply the Pose of an androidx.xr.arcore.Anchor to be persisted outside the androidx.xr.runtime.Session. Persisted Anchors can be loaded by their UUID.

Parameters
@NonNull Pose pose

the Pose at which the test will persist an Anchor

Returns
@NonNull UUID

the UUID of the newly persisted Anchor

setAnchorResourceLimit

Added in 1.0.0-alpha15
public final void setAnchorResourceLimit(int value)

The maximum number of 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-alpha15
protected void before()