Fixed
Status Update
Comments
kl...@google.com <kl...@google.com>
gr...@google.com <gr...@google.com> #2
Any update on this?
so...@google.com <so...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 27cadf68c7811032ce1ac7fd3dce114d74e3653f
Author: Anastasia Soboleva <soboleva@google.com>
Date: Thu May 23 12:48:59 2024
Add testing API for links
Relnote: "Added new API that helps testing links present in the text"
Bug: 207325144, 298871605, 336282132
Test: new tests in BoundsAssertionsTest
Change-Id: Ia20d61e1c910728a78ddf12cc537927216e3c58d
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/BasicTextLinkTest.kt
M compose/ui/ui-test/api/current.txt
M compose/ui/ui-test/api/restricted_current.txt
A compose/ui/ui-test/samples/src/main/java/androidx/compose/ui/test/samples/BoundsAssertionsSamples.kt
M compose/ui/ui-test/src/androidInstrumentedTest/kotlin/androidx/compose/ui/test/assertions/BoundsAssertionsTest.kt
M compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/BoundsAssertions.kt
https://android-review.googlesource.com/3099876
Branch: androidx-main
commit 27cadf68c7811032ce1ac7fd3dce114d74e3653f
Author: Anastasia Soboleva <soboleva@google.com>
Date: Thu May 23 12:48:59 2024
Add testing API for links
Relnote: "Added new API that helps testing links present in the text"
Bug: 207325144, 298871605, 336282132
Test: new tests in BoundsAssertionsTest
Change-Id: Ia20d61e1c910728a78ddf12cc537927216e3c58d
M compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/text/BasicTextLinkTest.kt
M compose/ui/ui-test/api/current.txt
M compose/ui/ui-test/api/restricted_current.txt
A compose/ui/ui-test/samples/src/main/java/androidx/compose/ui/test/samples/BoundsAssertionsSamples.kt
M compose/ui/ui-test/src/androidInstrumentedTest/kotlin/androidx/compose/ui/test/assertions/BoundsAssertionsTest.kt
M compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/BoundsAssertions.kt
so...@google.com <so...@google.com>
me...@thomaskeller.biz <me...@thomaskeller.biz> #4
Seems to be present in ui-test 1.8.0-alphas, thanks for the fix!
Usage (per kdoc):
composeTestRule
.onNodeWithText("YOUR_TEXT_WITH_LINK")
.performFirstLinkClick {
(it.item as? LinkAnnotation.Url)?.url == "YOUR_URL"
}
Description
When using a
ClickableText
(with say an annotated string) and you want to handle clicks only on a certain portion of the string, you cannot easily reason about and write tests for the click handler callback.For example, given a clickable text like this:
This is a contrived example, but it's useful to demonstrate the problem. When writing tests (particularly an integration or end-to-end test), it's very difficult to test the click functionality on the above:
It would be useful if there was an action that could do this for me. Something like: