Zhelyazko Atanasov
02/22/2024, 1:38 PMDisposableEffect
to register/unregister broadcast receiver. In some cases this composable function is part of the Composable tree and in others - it's not. I would like to write an instrumentation test to verify that the composable is not present in some scenarios. Essentially, I'd like to be able to do something like:
nonUiComposable.assertDoesNotExist()
but I have no idea how can I match a composable that doesn't emit UI.
Here's an example how such a composable looks like:
@Composable
fun BroadcastListener(onBroadcastReceived: (Payload) -> Unit) {
DisposableEffect(context) {
registerReceiver(onBroadcastReceived)
onDispose {
unregisterReceiver()
}
}
}
Zach Klippenstein (he/him) [MOD]
02/22/2024, 3:33 PMAlbert Chang
02/22/2024, 4:19 PMZhelyazko Atanasov
02/22/2024, 4:41 PMif (listenForUpdates) {
BroadcastListener(...)
}
and listenForUpdates
is false
how can I test/validate that BroadcastListener
wasn't added to the tree (essentially doesn't exist)Zach Klippenstein (he/him) [MOD]
02/22/2024, 5:32 PMZach Klippenstein (he/him) [MOD]
02/22/2024, 5:33 PMZhelyazko Atanasov
02/22/2024, 5:43 PMZach Klippenstein (he/him) [MOD]
02/22/2024, 5:54 PM