LegacyLithoTestRule
Deprecated
Please use LithoTestRule and TestLithoView instead
This test utility allows clients to test assertion on the view hierarchy rendered by a Litho components. The utility has methods to override the default {@link LithoView}, {@link ComponentTree}, width, and height specs.
@RunWith(AndroidJUnit4::class)
class LithoSampleTest {
@Rule @JvmField val lithoViewRule = LegacyLithoTestRule()
@Test
fun test() {
lithoViewRule.render { TestComponent() }
// or you can use setRoot/measure/layout for more fine-grained control
val lithoViewTest = lithoViewRule.attachToWindow().setRoot(TestComponent()).measure().layout()
// Test your assertions on the litho view.
}
}
Constructors
Types
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
Functions
Perform any interactions defined in the InteractionScope or on the LegacyLithoTestRule.
Explicitly attaches current root LithoView
Explicitly detaches current root LithoView
Returns a list of all components of the given classes from the ComponentTree or an empty list if not found
Returns a component of the given class from the ComponentTree or null if not found
Returns a component of the given class only if it is a direct child of the root component
Finds the first View with the specified content description in the rendered hierarchy, throwing if it doesn't exist.
Finds the first View with the specified content description in the rendered hierarchy, returning null if is doesn't exist.
Finds the first View with the specified tag in the rendered hierarchy, throwing if it doesn't exist.
Finds the first View with the specified tag in the rendered hierarchy, returning null if is doesn't exist.
Finds the first View with the specified text in the rendered hierarchy, throwing if it doesn't exist.
Finds the first View with the specified text in the rendered hierarchy, returning null if is doesn't exist.
Explicitly calls measure on the current root LithoView
Explicitly releases current root LithoView
Sets the new root to render.
Runs through all tasks on the background thread only, not touching the main lopper, blocking until it completes.
Sets the new root Component.Builder to render.
Sets the new root Component to render.
Sets the new root Component with new size spec to render.
Sets the new root Component.Builder to render asynchronously.
Sets the new root Component to render asynchronously.
Sets a new width and height which should be used to render.
Sets a new width spec and height spec which should be used to render.
Sets a new TreeProp for the next layout pass.
Sets a new ComponentTree which should be used to render.
Sets a new LithoView which should be used to render.