Skip to content
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

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

veyndan
Copy link
Contributor

@veyndan veyndan commented Nov 7, 2023

No description provided.

@veyndan veyndan force-pushed the veyndan/2023-11-07/BackHandler-tests branch from 06d09ba to 406eca9 Compare November 7, 2023 15:46
@veyndan veyndan force-pushed the veyndan/2023-11-07/BackHandler-tests branch from 406eca9 to 1c71e36 Compare November 7, 2023 15:55
Comment on lines +184 to +186
private suspend fun TestRedwoodComposition<List<WidgetValue>>.assertNoSnapshot() {
assertFailure { awaitSnapshot() }.isInstanceOf<TimeoutCancellationException>()
}
Copy link
Collaborator

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.

Copy link
Collaborator

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 }
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@veyndan veyndan enabled auto-merge (squash) November 8, 2023 11:43
@veyndan veyndan merged commit 8d94e8f into trunk Nov 8, 2023
8 checks passed
@veyndan veyndan deleted the veyndan/2023-11-07/BackHandler-tests branch November 8, 2023 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants