TestLithoView

Holder class for the result of LithoViewRule.render call, exposing methods to for finding the views/components and assertions

 @RunWith(AndroidJUnit4::class)
class LithoSampleTest {

@Rule @JvmField val lithoViewRule = LithoViewRule()
@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

Link copied to clipboard
inner class InteractionsScope

Class which exposes interactions that can take place on a view. Exposing interactions in this class ensures that they are only accessible within act, where the proper threading is taken into account to properly update the components and views.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Explicitly attaches current root LithoView

Link copied to clipboard

Explicitly detaches current root LithoView

Link copied to clipboard
fun findAllComponents(vararg clazz: Class<out Component?>): List<Component>
fun findAllComponents(vararg clazz: KClass<out Component>): List<Component>

Returns a list of all components of the given classes from the ComponentTree or an empty list if not found

Link copied to clipboard

Returns the first LazyCollection from the ComponentTree, or null if not found.

Link copied to clipboard

Returns a component of the given class from the ComponentTree or null if not found

Link copied to clipboard

Returns a component of the given class only if it is a direct child of the root component

Link copied to clipboard
fun findViewWithContentDescription(contentDescription: String): View

Finds the first View with the specified content description in the rendered hierarchy, throwing if it doesn't exist.

Link copied to clipboard

Finds the first View with the specified content description in the rendered hierarchy, returning null if is doesn't exist.

Link copied to clipboard

Finds the first View with the specified tag in the rendered hierarchy, throwing if it doesn't exist.

Link copied to clipboard

Finds the first View with the specified tag in the rendered hierarchy, returning null if is doesn't exist.

Link copied to clipboard
fun findViewWithText(@StringRes resourceId: Int): View

Finds the first View with the specified text in the rendered hierarchy, throwing if it doesn't exist.

Link copied to clipboard

Finds the first View with the specified text in the rendered hierarchy, returning null if is doesn't exist.

Link copied to clipboard

Explicitly calls layout on the current root LithoView. If there are any async events triggered by layout use together with idle

Link copied to clipboard
Link copied to clipboard

Explicitly calls measure on the current root LithoView

Link copied to clipboard

Explicitly releases current root LithoView

Link copied to clipboard
fun setComponentTree(componentTree: ComponentTree)
Link copied to clipboard

Sets the new root Component.Builder to render.

fun setRoot(component: Component?): TestLithoView

Sets the new root Component to render.

Link copied to clipboard
fun setRootAndSizeSpecSync(component: Component?, widthSpec: Int, heightSpec: Int): TestLithoView

Sets the new root Component with new size spec to render.

Link copied to clipboard

Sets the new root Component.Builder to render asynchronously.

Sets the new root Component to render asynchronously.

Link copied to clipboard
fun setSizePx(widthPx: Int, heightPx: Int): TestLithoView

Sets a new width and height which should be used to render.

Link copied to clipboard
fun setSizeSpecs(widthSpec: Int, heightSpec: Int): TestLithoView

Sets a new width spec and height spec which should be used to render.

Link copied to clipboard

Sets a new ComponentTree which should be used to render.

Link copied to clipboard

Sets a new LithoView which should be used to render.