TestContext

In package com.nhaarman.acorn.testing

class com.nhaarman.acorn.testing.TestContext

A class that provides simple Scene/Container management for tests.

This class acts as an observer to the Scene events provided by given navigator, and attaches and detaches the Container provided by given ContainerProvider to the Scene at appropriate points.

Users of this class should call start, stop and destroy at appropriate times. testWith does this for you.

Fields

var finished: Boolean

Returns true when the navigator has finished.

Methods

fun <T : Container> container(): T

Returns the currently attached Container, cast to T.

This function is here as syntax sugar: if the container instance is null or is not of type T, you may get exceptions thrown.

Parameters:
  • No parameters
fun start()
Parameters:
  • No parameters
fun scene(scene: Scene, data: TransitionData?)

Called when a Scene change occurs in the Navigator.

Will only be called if a Scene change occurs when the Navigator is in the started state, or when the Navigator enters the started state.

Parameters:
fun finished()

Called when the Navigator has finished.

Finish events occur when the Navigator has no more Scenes to show, such as a stack-based Navigator with an empty stack, or a wizard Navigator that reached the end of the wizard.

Parameters:
  • No parameters
fun pressBack()
Parameters:
  • No parameters
fun stop()
Parameters:
  • No parameters
fun destroy()
Parameters:
  • No parameters