TestLithoView
Holder class for the result of LithoTestRule.render call, exposing methods to for finding the views/components and assertions
@RunWith(AndroidJUnit4::class)
class LithoSampleTest {
@Rule @JvmField val lithoViewRule = LithoTestRule()
@Test
fun test() {
val testLithoView = lithoViewRule.render { TestComponent() }
LithoAssertions.assertThat(testLithoView)
.willRenderContent()
.containsComponents(AnotherTestComponent::class)
.containsContentDescription(R.string.content_descr)
lithoViewRule.act(testLithoView) { clickOnTag("test_tag") }
LithoAssertions.assertThat(testLithoView)
.containsComponents(NewTestComponent::class)
}
}Types
Properties
Functions
An AccessibilityProbe over the rendered LithoView.
Explicitly attaches current root LithoView.
beginTouchInput targeting the rendered LithoView.
Explicitly detaches current root LithoView
Returns a list of all components of the given classes from the ComponentTree or an empty list if not found
Returns the first LazyCollection from the ComponentTree, or null if not found.
Returns a component of the given class from the ComponentTree or null if not found
Returns a component with the given key or null if not found
Returns a component of the given class only if it is a direct child of the root component
Finds the first View with the specified content description in the rendered hierarchy, throwing if it doesn't exist.
Finds the first View with the specified content description in the rendered hierarchy, returning null if is doesn't exist.
Finds the first View with the specified tag in the rendered hierarchy, throwing if it doesn't exist.
Finds the first View with the specified tag in the rendered hierarchy, returning null if is doesn't exist.
Finds the first View (the hosting com.facebook.litho.ComponentHost) for the component tagged with testKey in the rendered hierarchy, throwing if not found.
Finds the first View for the component tagged with testKey in the rendered hierarchy, returning null if not found. Returns the test-keyed component's own mounted view (when it mounts as a View, e.g. a com.facebook.litho.ComponentHost); falls back to the parent host if the test-keyed component mounted as a non-View (e.g. a Drawable).
Finds the first View with the specified text in the rendered hierarchy, throwing if it doesn't exist.
Finds the first View with the specified text in the rendered hierarchy, returning null if is doesn't exist.
Explicitly calls layout on the current root LithoView. If there are any async events triggered by layout use together with idle
Explicitly calls measure on the current root LithoView
Runs block against a TouchInjectionScope targeting the rendered LithoView, so a gesture enters at the root and is hit-tested down the real hierarchy. Coordinates are in the LithoView's space.
Explicitly releases current root LithoView
Sets the new root Component.Builder to render.
Sets the new root Component to render.
Sets the new root Component with new size spec to render.
Sets the new root Component.Builder to render asynchronously.
Sets the new root Component to render asynchronously.
Sets a new width and height which should be used to render.
Sets a new width spec and height spec which should be used to render.
Sets a new ComponentTree which should be used to render.
Sets a new LithoView which should be used to render.