//Extensions for Dagger Hilt/it.czerwinski.android.hilt.fragment.testing/HiltFragmentScenario

HiltFragmentScenario

[androidJvm] class HiltFragmentScenario<F : Fragment, A : FragmentActivity>

HiltFragmentScenario provides API to start and drive a Fragment’s lifecycle state for testing.

Unlike the FragmentScenario from AndroidX Fragment Testing library, HiltFragmentScenario supports fragments annotated with dagger.hilt.android.AndroidEntryPoint.

It also supports testing fragment in a custom FragmentActivity.

Types

Name Summary
Companion [androidJvm]
Content
object Companion


EmptyFragmentActivity [androidJvm]
Content
class EmptyFragmentActivity : FragmentActivity
More info
An empty activity inheriting FragmentActivity, annotated with AndroidEntryPoint.


FragmentAction [androidJvm]
Content
fun fun interface FragmentAction<F : Fragment>
More info
FragmentAction interface should be implemented by any class whose instances are intended to be executed by the main thread.


FragmentFactoryViewModel [androidJvm]
Content
class FragmentFactoryViewModel : ViewModel
More info
A ViewModel to hold a fragment factory.


Functions

Name Summary
equals [androidJvm]
Content
open operator fun equals(other: Any?): Boolean


hashCode [androidJvm]
Content
open fun hashCode(): Int


moveToState [androidJvm]
Content
fun moveToState(newState: Lifecycle.State): HiltFragmentScenario<F, A>
More info
Moves Fragment state to a new state.


onActivity [androidJvm]
Content
fun onActivity(action: ActivityScenario.ActivityAction<A>): HiltFragmentScenario<F, A>
More info
Runs a given action on the current Activity’s main thread.


onFragment [androidJvm]
Content
fun onFragment(action: HiltFragmentScenario.FragmentAction<F>): HiltFragmentScenario<F, A>
More info
Runs a given action on the current Activity’s main thread.


recreate [androidJvm]
Content
fun recreate(): HiltFragmentScenario<F, A>
More info
Recreates the host Activity.


toString [androidJvm]
Content
open fun toString(): String