I am working on a utility class that subscribes to the app going foreground/background via ProcessLifecycleOwner api. The class takes in a ProcessLifecycleOwner instance, and has the following methods which observe on lifecycle events:
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun startSomething() {
appStatusSubject.onNext(AppStatus.FOREGROUNDED)
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun stopSomething() {
appStatusSubject.onNext(AppStatus.BACKGROUNDED)
}
I would like to write a unit test for this utility class. Is there anyway I can mock the ProcessLifecycleOwner object, have it emit certain lifecycle events, and assert that appStatusSubject.onNext(...) is called?
Would really appreciate any advice.