public final class ComponentTestHelper extends Object
Allows simple and short creation of views that are created and mounted in a similar way to how they are in real apps.
Modifier and Type | Method and Description |
---|---|
static LithoView |
dispatchOnFocusedVisibleEvent(ComponentContext context,
EventHandler onFocusedVisibleHandler,
Component component)
Deprecated.
|
static LithoView |
dispatchOnInvisibleEvent(ComponentContext context,
EventHandler onInvisibleHandler,
Component component)
Deprecated.
|
static LithoView |
dispatchOnVisibleEvent(ComponentContext context,
EventHandler onVisibleHandler,
Component component)
Deprecated.
|
static Looper |
getDefaultLayoutThreadLooper()
Access the default layout thread looper for testing purposes only.
|
static ShadowLooper |
getDefaultLayoutThreadShadowLooper()
Access the shadow of the default layout thread looper for testing purposes only.
|
static <T extends Component> |
getSubComponent(Component.Builder component,
Class<T> componentClass)
Deprecated.
Use ComponentAssert#extractingSubComponents() instead.
|
static List<SubComponent> |
getSubComponents(Component.Builder component)
Deprecated.
Use ComponentAssert#extractingSubComponents() instead.
|
static List<SubComponent> |
getSubComponents(Component.Builder component,
int widthSpec,
int heightSpec)
Deprecated.
Use ComponentAssert#extractingSubComponents() instead.
|
static List<SubComponent> |
getSubComponents(ComponentContext context,
Component component)
Deprecated.
Use ComponentAssert#extractingSubComponents() instead.
|
static List<SubComponent> |
getSubComponents(ComponentContext context,
Component component,
int widthSpec,
int heightSpec)
Deprecated.
Use ComponentAssert#extractingSubComponents() instead.
|
static void |
measureAndLayout(View view)
Measure and layout a component view.
|
static LithoView |
mountComponent(Component.Builder component)
Mount a component into a component view.
|
static LithoView |
mountComponent(Component.Builder component,
boolean incrementalMountEnabled,
boolean visibilityProcessingEnabled)
Mount a component into a component view.
|
static LithoView |
mountComponent(ComponentContext context,
Component component)
Mount a component into a component view.
|
static LithoView |
mountComponent(ComponentContext context,
Component component,
boolean incrementalMountEnabled,
boolean visibilityProcessingEnabled)
Mount a component into a component view.
|
static LithoView |
mountComponent(ComponentContext context,
Component component,
int width,
int height)
Mount a component into a component view.
|
static LithoView |
mountComponent(ComponentContext context,
LithoView lithoView,
Component component)
Mount a component into a component view.
|
static LithoView |
mountComponent(ComponentContext context,
LithoView lithoView,
Component component,
boolean incrementalMountEnabled,
boolean visibilityProcessingEnabled,
int width,
int height)
Mount a component into a component view.
|
static LithoView |
mountComponent(ComponentContext context,
LithoView lithoView,
Component component,
int width,
int height)
Mount a component into a component view.
|
static LithoView |
mountComponent(LithoView lithoView,
ComponentTree componentTree)
Mount a component tree into a component view.
|
static LithoView |
mountComponent(LithoView lithoView,
ComponentTree componentTree,
Component component)
Set a root component to a component tree, and mount it into a component view.
|
static LithoView |
mountComponent(LithoView lithoView,
ComponentTree componentTree,
int widthSpec,
int heightSpec)
Mount a component tree into a component view.
|
static void |
setTreeProp(ComponentContext context,
Class propClass,
Object prop)
Sets a TreeProp that will be visible to all Components which are created from the given Context
(unless a child overwrites its).
|
static boolean |
triggerVisibilityEvent(LithoView lithoView,
Class<?> visibilityClass)
Triggers a Litho visibility event
|
static void |
unbindComponent(LithoView lithoView)
Unbinds a component tree from a component view.
|
static void |
unmountComponent(LithoView lithoView)
Unmounts a component tree from a component view.
|
public static LithoView mountComponent(Component.Builder component)
component
- The component builder to mountpublic static LithoView mountComponent(Component.Builder component, boolean incrementalMountEnabled, boolean visibilityProcessingEnabled)
component
- The component builder to mountincrementalMountEnabled
- States whether incremental mount is enabledpublic static LithoView mountComponent(ComponentContext context, Component component)
context
- A components contextcomponent
- The component to mountpublic static LithoView mountComponent(ComponentContext context, Component component, boolean incrementalMountEnabled, boolean visibilityProcessingEnabled)
context
- A components contextcomponent
- The component to mountincrementalMountEnabled
- States whether incremental mount is enabledpublic static LithoView mountComponent(ComponentContext context, Component component, int width, int height)
context
- A components contextcomponent
- The component to mountwidth
- The width of the resulting viewheight
- The height of the resulting viewpublic static LithoView mountComponent(ComponentContext context, LithoView lithoView, Component component)
context
- A components contextlithoView
- The view to mount the component intocomponent
- The component to mountpublic static LithoView mountComponent(ComponentContext context, LithoView lithoView, Component component, int width, int height)
context
- A components contextlithoView
- The view to mount the component intocomponent
- The component to mountwidth
- The width of the resulting viewheight
- The height of the resulting viewpublic static LithoView mountComponent(ComponentContext context, LithoView lithoView, Component component, boolean incrementalMountEnabled, boolean visibilityProcessingEnabled, int width, int height)
context
- A components contextlithoView
- The view to mount the component intocomponent
- The component to mountincrementalMountEnabled
- States whether incremental mount is enabledwidth
- The width of the resulting viewheight
- The height of the resulting viewpublic static LithoView mountComponent(LithoView lithoView, ComponentTree componentTree)
lithoView
- The view to mount the component tree intocomponentTree
- The component tree to mountpublic static LithoView mountComponent(LithoView lithoView, ComponentTree componentTree, Component component)
lithoView
- The view to mount the component tree intocomponentTree
- The component tree to mountcomponent
- The root componentpublic static LithoView mountComponent(LithoView lithoView, ComponentTree componentTree, int widthSpec, int heightSpec)
lithoView
- The view to mount the component tree intocomponentTree
- The component tree to mountwidthSpec
- The width spec used to measure the resulting viewheightSpec
- The height spec used to measure the resulting viewpublic static void unmountComponent(LithoView lithoView)
lithoView
- the view to unmountpublic static void unbindComponent(LithoView lithoView)
lithoView
- The view to unbind.@Deprecated public static List<SubComponent> getSubComponents(Component.Builder component)
component
- The component builder which to get the subcomponents of@Deprecated public static List<SubComponent> getSubComponents(ComponentContext context, Component component)
context
- A components contextcomponent
- The component which to get the subcomponents of@Deprecated public static List<SubComponent> getSubComponents(Component.Builder component, int widthSpec, int heightSpec)
component
- The component which to get the subcomponents ofwidthSpec
- The width to measure the component withheightSpec
- The height to measure the component with@Deprecated public static List<SubComponent> getSubComponents(ComponentContext context, Component component, int widthSpec, int heightSpec)
context
- A components contextcomponent
- The component which to get the subcomponents ofwidthSpec
- The width to measure the component withheightSpec
- The height to measure the component with@Deprecated public static <T extends Component> Component getSubComponent(Component.Builder component, Class<T> componentClass)
component
- The component builder which to get the subcomponent fromcomponentClass
- the class type of the requested sub componentpublic static void measureAndLayout(View view)
view
- The component view to measure and layout@Deprecated public static LithoView dispatchOnVisibleEvent(ComponentContext context, EventHandler onVisibleHandler, Component component)
DEPRECATED: Prefer using triggerVisibilityEvent(LithoView, Class)
instead
context
- A components contextonVisibleHandler
- SpecificComponent.onVisible(component)component
- The component builder which to get the subcomponent from@Deprecated public static LithoView dispatchOnFocusedVisibleEvent(ComponentContext context, EventHandler onFocusedVisibleHandler, Component component)
DEPRECATED: Prefer using triggerVisibilityEvent(LithoView, Class)
instead
context
- A components contextonFocusedVisibleHandler
- SpecificComponent.onFocusedVisible(component)component
- The component builder which to get the subcomponent from@Deprecated public static LithoView dispatchOnInvisibleEvent(ComponentContext context, EventHandler onInvisibleHandler, Component component)
DEPRECATED: Prefer using triggerVisibilityEvent(LithoView, Class)
instead
context
- A components contextonInvisibleHandler
- SpecificComponent.onInvisible(component)component
- The component builder which to get the subcomponent frompublic static boolean triggerVisibilityEvent(LithoView lithoView, Class<?> visibilityClass)
The event needs to be one of VisibleEvent
, InvisibleEvent
, FocusedVisibleEvent
, UnfocusedVisibleEvent
, or FullImpressionVisibleEvent
.
lithoView
- the view to invoke the event on its component treevisibilityClass
- the type of the event to invokepublic static void setTreeProp(ComponentContext context, Class propClass, Object prop)
public static Looper getDefaultLayoutThreadLooper()
public static ShadowLooper getDefaultLayoutThreadShadowLooper()