OnDisplayContext

class OnDisplayContext(    val primaryActivityScenarioStateProvider: () -> Lifecycle.State,     val moveFocusToDisplay: (DisplayId) -> Unit,     val displayIdProvider: () -> DisplayId)

The context for onDisplay invocation.

In the lambda given to onDisplay it is important to always use ActiveDisplayScope.rootMatcher when obtaining a ViewInteraction.

The obtainSecondaryDisplayIds routine is helpful to get the list of all available secondary displays and dedicate the one ID to be provided by the displayIdProvider.

You can use createPrimaryOnDisplayContext and createSecondaryOnDisplayContext to construct OnDisplayContext instance when the R.id::ttivi_status_bar_clock view on each display can be used to click on to move the focus to the display.

Example

class MultidisplayE2eTest : DigitalCockpitTestCase() {

private val primary = createOnDisplayContextPrimary()

private val secondary = createOnDisplayContextSecondary {
obtainSecondaryDisplayIds().last()
}

// ...

@Test
fun testSomething() {
// Launch activity on the secondary display. The display ID of the secondary display
// needs to match with the display ID returned by the lambda given to `secondary`.
// ...

onDisplay(primary) {
// Actions and assertions.
onView(withId(R.id.ttivi_some_button))
.inRoot(rootMatcher)
.check(matches(isDisplayed()))
.perform(click())
}
onDisplay(secondary) {
// Actions and assertions.
onView(withId(R.id.ttivi_some_button_on_secondary_display))
.inRoot(rootMatcher)
.check(matches(isDisplayed()))
.perform(click())
}
}
}

Constructors

Link copied to clipboard
fun OnDisplayContext(    primaryActivityScenarioStateProvider: () -> Lifecycle.State,     moveFocusToDisplay: (DisplayId) -> Unit,     displayIdProvider: () -> DisplayId)

Properties

Link copied to clipboard
val displayIdProvider: () -> DisplayId

The DisplayId of display in this context. Should match the DisplayId where the activity under test has been launched.

Link copied to clipboard
val moveFocusToDisplay: (DisplayId) -> Unit

Lambda to move the focus to the display. This is typically archived by clicking on the screen at a location that has no other side affects. See for instance moveFocusToPrimaryDisplayIviActivity and moveFocusToSecondaryDisplayIviActivity as possible implementations.

Link copied to clipboard
val primaryActivityScenarioStateProvider: () -> Lifecycle.State

The state provider of the ActivityScenario of the primary activity under test. Required to verify the Lifecycle.State.