Created
March 4, 2019 13:26
-
-
Save atomgomba/e7c03bf20033ef770c7c9de9455affbd to your computer and use it in GitHub Desktop.
Android LifecycleOwner for unit testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.lifecycle.Lifecycle.State | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.LifecycleRegistry | |
/** | |
* @author Károly Kiripolszky <[email protected]> | |
*/ | |
class TestLifecycleOwner(state: State = State.STARTED) : LifecycleOwner { | |
private val lifecycle = LifecycleRegistry(this) | |
init { | |
lifecycle.markState(state) | |
} | |
override fun getLifecycle() = lifecycle | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment