public class LithoViewTestHelper extends Object
LithoView
that is relevant during end to end tests.
In order for the data to be collected, ComponentsConfiguration.isEndToEndTestRun
must be
enabled.Modifier and Type | Class and Description |
---|---|
static class |
LithoViewTestHelper.InternalNodeRef
Holds an opaque reference to an
InternalNode without giving the holder any access to
it. |
Constructor and Description |
---|
LithoViewTestHelper() |
Modifier and Type | Method and Description |
---|---|
static TestItem |
findTestItem(LithoView lithoView,
String testKey) |
static Deque<TestItem> |
findTestItems(LithoView lithoView,
String testKey)
|
static LithoViewTestHelper.InternalNodeRef |
getRootLayoutRef(LithoView view)
Obtain a reference to a LithoView's internal layout root, if present.
|
static void |
setRootLayoutRef(LithoView view,
LithoViewTestHelper.InternalNodeRef rootLayoutNode)
Restore a previously saved root layout reference.
|
static String |
toDebugString(LithoView lithoView) |
static String |
viewToString(LithoView view) |
static String |
viewToString(LithoView view,
boolean embedded)
Provide a nested string representation of a LithoView and its nested components for debugging
purposes.
|
public static TestItem findTestItem(LithoView lithoView, String testKey)
lithoView
- The component view the component is mounted to.testKey
- The unique identifier the component was constructed with.UnsupportedOperationException
- If the e2e flag is not enabled in the configuration.Note: If there is more than one element mounted under the given key,
the last one to render will be returned.
public static Deque<TestItem> findTestItems(LithoView lithoView, String testKey)
TestItem
given a LithoView
based on the test key it was assigned during
construction.
Example use:
{@code final LithoView lithoView = ComponentTestHelper.mountComponent( mContext, new InlineLayoutSpec() {
lithoView
- The component view the component is mounted to.testKey
- The unique identifier the component was constructed with.UnsupportedOperationException
- If the e2e flag is not enabled in the configuration.public static String viewToString(LithoView view, boolean embedded)
view
- A Litho view with mounted components.embedded
- if the call is embedded in "adb dumpsys activity"public static LithoViewTestHelper.InternalNodeRef getRootLayoutRef(LithoView view)
public static void setRootLayoutRef(LithoView view, LithoViewTestHelper.InternalNodeRef rootLayoutNode)
getRootLayoutRef(LithoView)