-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for BackHandler
composable
#1670
Conversation
06d09ba
to
406eca9
Compare
406eca9
to
1c71e36
Compare
private suspend fun TestRedwoodComposition<List<WidgetValue>>.assertNoSnapshot() { | ||
assertFailure { awaitSnapshot() }.isInstanceOf<TimeoutCancellationException>() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can provide a proper API for this rather than relying on the timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like it
} | ||
|
||
fun onBackPressed() { | ||
val callbackToNotify = onBackPressedCallbacks.lastOrNull { it.isEnabled } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this fake implements the behavior that chooses the last callback to invoke, the tests which put multiple back handlers into the composition (at least when both are enabled) are exercising this behavior and not any actual library behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Just updated the PR to inline this function and add the desired assertions.
No description provided.