androidx.fragment.app.testing
Interfaces
FragmentAction |
Classes
FragmentScenario |
FragmentScenario provides API to start and drive a Fragment's lifecycle state for testing. |
Top-level functions summary
FragmentScenario<F> |
launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, factory: FragmentFactory? = null) |
FragmentScenario<F> |
launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, crossinline instantiate: () -> F) |
FragmentScenario<F> |
launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, initialState: Lifecycle.State = Lifecycle.State.RESUMED, factory: FragmentFactory? = null) Launches a Fragment with given arguments hosted by an empty FragmentActivity using given FragmentFactory and waits for it to reach initialState. |
FragmentScenario<F> |
launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, initialState: Lifecycle.State = Lifecycle.State.RESUMED, crossinline instantiate: () -> F) Launches a Fragment with given arguments hosted by an empty FragmentActivity using instantiate to create the Fragment and waits for it to reach initialState. |
FragmentScenario<F> |
launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, factory: FragmentFactory? = null) |
FragmentScenario<F> |
launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, crossinline instantiate: () -> F) |
FragmentScenario<F> |
launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, initialState: Lifecycle.State = Lifecycle.State.RESUMED, factory: FragmentFactory? = null) Launches a Fragment in the Activity's root view container |
FragmentScenario<F> |
launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, initialState: Lifecycle.State = Lifecycle.State.RESUMED, crossinline instantiate: () -> F) Launches a Fragment in the Activity's root view container |
Extension functions summary
For FragmentScenario | |
T |
FragmentScenario<F>.withFragment(crossinline block: F.() -> T) Run block using FragmentScenario.onFragment, returning the result of the block. |
Top-level functions
launchFragment
inline fun <reified F : Fragment>launchFragment(
fragmentArgs: Bundle? = null,
@StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
factory: FragmentFactory? = null
): FragmentScenario<F>
Deprecated.
launchFragment
inline fun <reified F : Fragment>launchFragment(
fragmentArgs: Bundle? = null,
@StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
crossinline instantiate: () -> F
): FragmentScenario<F>
Deprecated.
launchFragment
inline fun <reified F : Fragment> launchFragment(
fragmentArgs: Bundle? = null,
@StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme,
initialState: Lifecycle.State = Lifecycle.State.RESUMED,
factory: FragmentFactory? = null
): FragmentScenario<F>
Launches a Fragment with given arguments hosted by an empty FragmentActivity using given FragmentFactory and waits for it to reach initialState.
This method cannot be called from the main thread.
Parameters | |
---|---|
fragmentArgs: Bundle? = null | a bundle to passed into fragment |
themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme | a style resource id to be set to the host activity's theme |
initialState: Lifecycle.State = Lifecycle.State.RESUMED | the initial Lifecycle.State. This must be one of Lifecycle.State.CREATED, Lifecycle.State.STARTED, or Lifecycle.State.RESUMED. |
factory: FragmentFactory? = null | a fragment factory to use or null to use default factory |