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

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
open fun getDefaultLayoutThreadShadowLooper(): ShadowLooper
Access the shadow of the default layout thread looper for testing purposes only.
Link copied to clipboard
open fun getDefaultResolveThreadShadowLooper(): ShadowLooper
Link copied to clipboard
open fun getDefaultThreadShadowLoopers(): Array<ShadowLooper>
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
open fun measureAndLayout(view: View)
open fun measureAndLayout(view: View, width: Int, height: Int)
Measure and layout a component view.
Link copied to clipboard
open fun mountComponent(context: ComponentContext, component: Component): LithoView
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): LithoView
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
open fun setParentTreeProp(context: ComponentContext, propClass: Class, prop: Any)
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
open fun setTreeProp(context: ComponentContext, propClass: Class, prop: Any)
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
open fun triggerVisibilityEvent(lithoView: LithoView, visibilityClass: Class<out Any>): Boolean
Triggers a Litho visibility event The event needs to be one of VisibleEvent, InvisibleEvent, , UnfocusedVisibleEvent, or FullImpressionVisibleEvent.
Link copied to clipboard
open fun unbindComponent(lithoView: LithoView)
Unbinds a component tree from a component view.
Link copied to clipboard
open fun unmountComponent(lithoView: LithoView)
Unmounts a component tree from a component view.