Reputation: 29
I have a Fragment screen which launches a WebView using a registerActivityForResult
and I want to have an End-to-End Instrumented test which has this Fragment in the flow.
class OAuthLoginScreen(
registry: ActivityResultRegistry? = null,
private val loginToOldPlatformUseCase: AccountsApiLoginToOldPlatformUseCase
= DefaultAccountsApiLoginToOldPlatformUseCase(),
) : Fragment(), Screen {
private val loginLauncher = registry?.let {
registerForActivityResult(ActivityResultContracts.StartActivityForResult(), it) { result ->
val data = result.data
if (result.resultCode == ComponentActivity.RESULT_OK && data != null) {
setAuthStateFromResult(data)
} else {
activity?.finish()
}
}
} ?: registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
val data = result.data
if (result.resultCode == ComponentActivity.RESULT_OK && data != null) {
setAuthStateFromResult(data)
} else {
activity?.finish()
}
}
...
What I am able to do right now:
What I am unable to do:
Is it even possible? I want to launch this Fragment from my previous Activity but have test doubles and not launch my WebView at all. I understand this is possible with launchInContainer()
as I already did in case 1 but how can I implement something similar when multiple screens and navigations are involved?
Upvotes: 1
Views: 38