ComponentTestHelper
class ComponentTestHelper
Helper class to simplify testing of components.
Allows simple and short creation of views that are created and mounted in a similar way to how they are in real apps.
Functions
Link copied to clipboard
open fun createScopedComponentContextWithStateForTest(parent: ComponentContext, component: Component, key: String): ComponentContext
Creates a ComponentContext scoped to a given component and initialized with its StateContainer.
Link copied to clipboard
open fun dispatchOnFocusedVisibleEvent(context: ComponentContext, onFocusedVisibleHandler: EventHandler, component: Component): LithoView
Mounts the component &triggers the focused visibility event.
Link copied to clipboard
open fun dispatchOnInvisibleEvent(context: ComponentContext, onInvisibleHandler: EventHandler, component: Component): LithoView
Mounts the component &triggers the invisible event.
Link copied to clipboard
open fun dispatchOnVisibleEvent(context: ComponentContext, onVisibleHandler: EventHandler, component: Component): LithoView
Mounts the component &triggers the visibility event.
Link copied to clipboard
Access the default layout thread looper for testing purposes only.
Link copied to clipboard
Access the shadow of the default layout thread looper for testing purposes only.
Link copied to clipboard
Link copied to clipboard
open fun <T : Component?> getSubComponent(component: Component.Builder, componentClass: Class<T>): Component
Returns the first subComponent of type class.
Link copied to clipboard
open fun getSubComponents(component: Component.Builder, widthSpec: Int, heightSpec: Int): List<SubComponent>
open fun getSubComponents(context: ComponentContext, component: Component, widthSpec: Int, heightSpec: Int): List<SubComponent>
Get the subcomponents of a component
Link copied to clipboard
Measure and layout a component view.
Link copied to clipboard
open fun mountComponent(component: Component.Builder, incrementalMountEnabled: Boolean, visibilityProcessingEnabled: Boolean): LithoView
open fun mountComponent(context: ComponentContext, lithoView: LithoView, component: Component): LithoView
open fun mountComponent(context: ComponentContext, component: Component, incrementalMountEnabled: Boolean, visibilityProcessingEnabled: Boolean): LithoView
open fun mountComponent(context: ComponentContext, component: Component, width: Int, height: Int): LithoView
open fun mountComponent(context: ComponentContext, lithoView: LithoView, component: Component, width: Int, height: Int): LithoView
open fun mountComponent(context: ComponentContext, lithoView: LithoView, component: Component, incrementalMountEnabled: Boolean, visibilityProcessingEnabled: Boolean, width: Int, height: Int): LithoView
Mount a component into a component view.
open fun mountComponent(lithoView: LithoView, componentTree: ComponentTree, widthSpec: Int, heightSpec: Int): LithoView
Mount a component tree into a component view.
open fun mountComponent(lithoView: LithoView, componentTree: ComponentTree, component: Component): LithoView
Set a root component to a component tree, and mount it into a component view.
Link copied to clipboard
Sets a TreeProp that will be visible to all Components which are created from the given Context (unless a child overwrites its).
Link copied to clipboard
Sets a TreeProp that will be visible to all Components which are created from the given Context (unless a child overwrites its).
Link copied to clipboard
Triggers a Litho visibility event The event needs to be one of VisibleEvent, InvisibleEvent, , UnfocusedVisibleEvent, or FullImpressionVisibleEvent.
Link copied to clipboard
Unbinds a component tree from a component view.
Link copied to clipboard
Unmounts a component tree from a component view.