Remove SemanticsNodeInteraction.semanticsId()
We added a semanticsNodeInteraction.semanticsId() as a convenience
function instead of using
SemanticsNodeInteraction.fetchSemanticsNode().id
Bug: 379671515
Relnote: "SemanticsNodeInteraction.semanticsId() has been removed. Use SemanticsNodeInteraction.fetchSemanticsNode().id instead."
Test: Updated affected tests
Change-Id: Ie397a87c7e8bfd754474ebbb03c26f4a3215ba52
diff --git a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/grid/LazyGridSlotsReuseTest.kt b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/grid/LazyGridSlotsReuseTest.kt
index d988a6a..5b743a5a 100644
--- a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/grid/LazyGridSlotsReuseTest.kt
+++ b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/grid/LazyGridSlotsReuseTest.kt
@@ -59,7 +59,7 @@
}
}
- val id0 = rule.onNodeWithTag("0").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
rule.onNodeWithTag("0").assertIsDisplayed()
rule.runOnIdle { runBlocking { state.scrollToItem(1) } }
@@ -78,8 +78,8 @@
}
}
// Semantics IDs must be fetched before scrolling.
- val id0 = rule.onNodeWithTag("0").semanticsId()
- val id1 = rule.onNodeWithTag("1").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
+ val id1 = rule.onNodeWithTag("1").fetchSemanticsNode().id
rule.onNodeWithTag("0").assertIsDisplayed()
rule.onNodeWithTag("1").assertIsDisplayed()
@@ -105,7 +105,7 @@
}
val deactivatedIds = mutableListOf<Int>()
repeat(DefaultMaxItemsToRetain) {
- deactivatedIds.add(rule.onNodeWithTag("$it").semanticsId())
+ deactivatedIds.add(rule.onNodeWithTag("$it").fetchSemanticsNode().id)
}
rule.runOnIdle { runBlocking { state.scrollToItem(DefaultMaxItemsToRetain + 1) } }
@@ -127,8 +127,8 @@
}
}
- val id0 = rule.onNodeWithTag("0").semanticsId()
- val id1 = rule.onNodeWithTag("1").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
+ val id1 = rule.onNodeWithTag("1").fetchSemanticsNode().id
rule.onNodeWithTag("0").assertIsDisplayed()
rule.onNodeWithTag("1").assertIsDisplayed()
@@ -172,7 +172,7 @@
}
// 3 should be visible at this point, so save its ID to check later
- val id3 = rule.onNodeWithTag("3").semanticsId()
+ val id3 = rule.onNodeWithTag("3").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -204,8 +204,8 @@
}
}
- val id10 = rule.onNodeWithTag("10").semanticsId()
- val id11 = rule.onNodeWithTag("11").semanticsId()
+ val id10 = rule.onNodeWithTag("10").fetchSemanticsNode().id
+ val id11 = rule.onNodeWithTag("11").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -238,7 +238,7 @@
}
}
// 8 should be visible at this point, so save its ID to check later
- val id8 = rule.onNodeWithTag("8").semanticsId()
+ val id8 = rule.onNodeWithTag("8").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
state.scrollToItem(6) // 9 reused, buffer is [8]
@@ -294,8 +294,8 @@
}
// 2 and 3 should be visible at this point, so save its ID to check later
- val id2 = rule.onNodeWithTag("2").semanticsId()
- val id3 = rule.onNodeWithTag("3").semanticsId()
+ val id2 = rule.onNodeWithTag("2").fetchSemanticsNode().id
+ val id3 = rule.onNodeWithTag("3").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -341,7 +341,7 @@
val deactivatedIds = mutableListOf<Int>()
for (i in 0 until visibleItemsCount) {
- deactivatedIds.add(rule.onNodeWithTag("$i").semanticsId())
+ deactivatedIds.add(rule.onNodeWithTag("$i").fetchSemanticsNode().id)
rule.onNodeWithTag("$i").assertIsDisplayed()
}
for (i in startOfType1 until startOfType1 + DefaultMaxItemsToRetain) {
@@ -382,8 +382,8 @@
}
}
- val id0 = rule.onNodeWithTag("0").semanticsId()
- val id1 = rule.onNodeWithTag("1").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
+ val id1 = rule.onNodeWithTag("1").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -418,4 +418,4 @@
}
}
-private val DefaultMaxItemsToRetain = 7
+private const val DefaultMaxItemsToRetain = 7
diff --git a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListSlotsReuseTest.kt b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListSlotsReuseTest.kt
index 0ab752c..85af651 100644
--- a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListSlotsReuseTest.kt
+++ b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListSlotsReuseTest.kt
@@ -65,7 +65,7 @@
}
}
- val id0 = rule.onNodeWithTag("0").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
rule.onNodeWithTag("0").assertIsDisplayed()
rule.runOnIdle { runBlocking { state.scrollToItem(1) } }
@@ -86,8 +86,8 @@
}
}
- val id0 = rule.onNodeWithTag("0").semanticsId()
- val id1 = rule.onNodeWithTag("1").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
+ val id1 = rule.onNodeWithTag("1").fetchSemanticsNode().id
rule.onNodeWithTag("0").assertIsDisplayed()
rule.onNodeWithTag("1").assertIsDisplayed()
@@ -112,7 +112,7 @@
// Semantics IDs must be fetched before scrolling.
val deactivatedIds = mutableListOf<Int>()
repeat(DefaultMaxItemsToRetain) {
- deactivatedIds.add(rule.onNodeWithTag("$it").semanticsId())
+ deactivatedIds.add(rule.onNodeWithTag("$it").fetchSemanticsNode().id)
}
rule.runOnIdle { runBlocking { state.scrollToItem(DefaultMaxItemsToRetain + 1) } }
@@ -136,8 +136,8 @@
}
}
- val id0 = rule.onNodeWithTag("0").semanticsId()
- val id1 = rule.onNodeWithTag("1").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
+ val id1 = rule.onNodeWithTag("1").fetchSemanticsNode().id
rule.onNodeWithTag("0").assertIsDisplayed()
rule.onNodeWithTag("1").assertIsDisplayed()
@@ -183,7 +183,7 @@
}
// 3 should be visible at this point, so save its ID to check later
- val id3 = rule.onNodeWithTag("3").semanticsId()
+ val id3 = rule.onNodeWithTag("3").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -217,8 +217,8 @@
}
}
- val id10 = rule.onNodeWithTag("10").semanticsId()
- val id11 = rule.onNodeWithTag("11").semanticsId()
+ val id10 = rule.onNodeWithTag("10").fetchSemanticsNode().id
+ val id11 = rule.onNodeWithTag("11").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -253,7 +253,7 @@
}
}
// 8 should be visible at this point, so save its ID to check later
- val id8 = rule.onNodeWithTag("8").semanticsId()
+ val id8 = rule.onNodeWithTag("8").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
state.scrollToItem(6) // 9 reused, buffer is [8]
@@ -314,8 +314,8 @@
}
// 2 and 3 should be visible at this point, so save its ID to check later
- val id2 = rule.onNodeWithTag("2").semanticsId()
- val id3 = rule.onNodeWithTag("3").semanticsId()
+ val id2 = rule.onNodeWithTag("2").fetchSemanticsNode().id
+ val id3 = rule.onNodeWithTag("3").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -357,7 +357,7 @@
val deactivatedIds = mutableListOf<Int>()
for (i in 0 until visibleItemsCount) {
- deactivatedIds.add(rule.onNodeWithTag("$i").semanticsId())
+ deactivatedIds.add(rule.onNodeWithTag("$i").fetchSemanticsNode().id)
rule.onNodeWithTag("$i").assertIsDisplayed()
}
for (i in startOfType1 until startOfType1 + DefaultMaxItemsToRetain) {
@@ -398,8 +398,8 @@
}
}
- val id0 = rule.onNodeWithTag("0").semanticsId()
- val id1 = rule.onNodeWithTag("1").semanticsId()
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
+ val id1 = rule.onNodeWithTag("1").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -434,4 +434,4 @@
}
}
-private val DefaultMaxItemsToRetain = 7
+private const val DefaultMaxItemsToRetain = 7
diff --git a/compose/ui/ui-test/api/current.txt b/compose/ui/ui-test/api/current.txt
index 1a28106..9c3549c 100644
--- a/compose/ui/ui-test/api/current.txt
+++ b/compose/ui/ui-test/api/current.txt
@@ -495,7 +495,6 @@
method public androidx.compose.ui.test.SemanticsNodeInteraction assertExists(optional String? errorMessageOnFail);
method public void assertIsDeactivated(optional String? errorMessageOnFail);
method public androidx.compose.ui.semantics.SemanticsNode fetchSemanticsNode(optional String? errorMessageOnFail);
- method public int semanticsId();
}
public final class SemanticsNodeInteractionCollection {
diff --git a/compose/ui/ui-test/api/restricted_current.txt b/compose/ui/ui-test/api/restricted_current.txt
index 0e101d0..5ded425 100644
--- a/compose/ui/ui-test/api/restricted_current.txt
+++ b/compose/ui/ui-test/api/restricted_current.txt
@@ -497,7 +497,6 @@
method public androidx.compose.ui.test.SemanticsNodeInteraction assertExists(optional String? errorMessageOnFail);
method public void assertIsDeactivated(optional String? errorMessageOnFail);
method public androidx.compose.ui.semantics.SemanticsNode fetchSemanticsNode(optional String? errorMessageOnFail);
- method public int semanticsId();
}
public final class SemanticsNodeInteractionCollection {
diff --git a/compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/SemanticsNodeInteraction.kt b/compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/SemanticsNodeInteraction.kt
index 63c3346..81f94f3 100644
--- a/compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/SemanticsNodeInteraction.kt
+++ b/compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/SemanticsNodeInteraction.kt
@@ -147,11 +147,6 @@
}
}
- /** Fetch the semantics ID. */
- fun semanticsId(): Int {
- return fetchSemanticsNode().id
- }
-
private fun fetchOneOrThrow(
errorMessageOnFail: String? = null,
skipDeactivatedNodes: Boolean = true
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
index 7a030d67..5758c8a 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidAccessibilityTest.kt
@@ -149,13 +149,13 @@
import androidx.compose.ui.semantics.paneTitle
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.semantics.textSelectionRange
import androidx.compose.ui.semantics.traversalIndex
import androidx.compose.ui.test.SemanticsMatcher.Companion.expectValue
-import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertContentDescriptionEquals
@@ -307,7 +307,7 @@
BasicText("ToggleableText")
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -387,7 +387,7 @@
}
}
- val passwordFieldId = rule.onNodeWithTag(tag, true).semanticsId
+ val passwordFieldId = rule.onNodeWithTag(tag, true).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(passwordFieldId) }
@@ -424,7 +424,7 @@
repeat(5) { DropdownMenuItem(onClick = {}) { Text("Menu Item $it") } }
}
}
- val virtualId = rule.onNodeWithTag(tag, true).semanticsId
+ val virtualId = rule.onNodeWithTag(tag, true).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -453,7 +453,7 @@
BasicText("Text")
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -484,7 +484,7 @@
BasicText("Text")
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -517,7 +517,7 @@
BasicText("Text")
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -546,7 +546,7 @@
Text("Filter chip")
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -575,7 +575,7 @@
setContent {
Box(Modifier.semantics { pageUp { true } }.testTag(tag)) { BasicText("Text") }
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -604,7 +604,7 @@
BasicText("Text")
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -624,7 +624,7 @@
fun testCreateAccessibilityNodeInfo_numberPicker_expectedClassName() {
// Arrange.
setContent { Box(Modifier.semantics { role = Role.ValuePicker }.testTag(tag)) }
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -639,7 +639,7 @@
fun testCreateAccessibilityNodeInfo_progressIndicator_determinate() {
// Arrange.
setContent { Box(Modifier.progressSemantics(0.5f).testTag(tag)) { BasicText("Text") } }
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -664,7 +664,7 @@
fun testCreateAccessibilityNodeInfo_progressIndicator_determinate_indeterminate() {
// Arrange.
setContent { Box(Modifier.progressSemantics().testTag(tag)) { BasicText("Text") } }
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -692,7 +692,7 @@
onValueChange = { value = it }
)
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -736,7 +736,7 @@
fun emptyTextField_hasStateDescription() {
setContent { BasicTextField(rememberTextFieldState(), modifier = Modifier.testTag(tag)) }
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
rule.runOnIdle {
@@ -758,7 +758,7 @@
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
rule.runOnIdle {
@@ -783,7 +783,7 @@
)
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
rule.runOnIdle { with(info) { assertThat(stateDescription).isNull() } }
@@ -809,7 +809,7 @@
)
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
rule.runOnIdle { with(info) { assertThat(stateDescription).isNull() } }
@@ -820,7 +820,7 @@
// Arrange.
val text = "Test"
setContent { BasicText(text = text) }
- val virtualId = rule.onNodeWithText(text).semanticsId
+ val virtualId = rule.onNodeWithText(text).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -833,7 +833,7 @@
fun testCreateAccessibilityNodeInfo_forFocusable_notFocused() {
// Arrange.
setContent { Box(Modifier.testTag(tag).focusable()) { BasicText("focusable") } }
- val virtualId = rule.onNodeWithTag(tag).assert(expectValue(Focused, false)).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).assert(expectValue(Focused, false)).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -861,7 +861,7 @@
}
}
rule.runOnIdle { focusRequester.requestFocus() }
- val virtualId = rule.onNodeWithTag(tag).assert(expectValue(Focused, true)).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).assert(expectValue(Focused, true)).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -922,8 +922,8 @@
Row { Text(overlaidText) }
}
}
- val node3VirtualId = rule.onNodeWithText(text3).semanticsId
- val overlaidNodeVirtualId = rule.onNodeWithText(overlaidText).semanticsId
+ val node3VirtualId = rule.onNodeWithText(text3).semanticsId()
+ val overlaidNodeVirtualId = rule.onNodeWithText(overlaidText).semanticsId()
// Act.
val ani3 = rule.runOnIdle { createAccessibilityNodeInfo(node3VirtualId) }
@@ -958,8 +958,8 @@
Row { Text(overlaidText) }
}
}
- val node3VirtualId = rule.onNodeWithText(text3).semanticsId
- val overlaidNodeVirtualId = rule.onNodeWithText(overlaidText).semanticsId
+ val node3VirtualId = rule.onNodeWithText(text3).semanticsId()
+ val overlaidNodeVirtualId = rule.onNodeWithText(overlaidText).semanticsId()
// Act.
val ani3 = rule.runOnIdle { createAccessibilityNodeInfo(node3VirtualId) }
@@ -1000,8 +1000,8 @@
}
}
}
- val rowVirtualId = rule.onNodeWithTag(clickableRowTag).semanticsId
- val buttonId = rule.onNodeWithTag(clickableButtonTag).semanticsId
+ val rowVirtualId = rule.onNodeWithTag(clickableRowTag).semanticsId()
+ val buttonId = rule.onNodeWithTag(clickableButtonTag).semanticsId()
// Act.
val rowANI = rule.runOnIdle { createAccessibilityNodeInfo(rowVirtualId) }
@@ -1048,8 +1048,8 @@
}
}
- val titleId = rule.onNodeWithTag(clickableTitle).semanticsId
- val firstElementId = rule.onNodeWithTag(clickableFirstListElement).semanticsId
+ val titleId = rule.onNodeWithTag(clickableTitle).semanticsId()
+ val firstElementId = rule.onNodeWithTag(clickableFirstListElement).semanticsId()
// Act.
val titleANI = rule.runOnIdle { createAccessibilityNodeInfo(titleId) }
@@ -1105,10 +1105,10 @@
}
}
}
- val topText1 = rule.onNodeWithText(topSampleText + 1).semanticsId
- val topText2 = rule.onNodeWithText(topSampleText + 2).semanticsId
- val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId
- val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId
+ val topText1 = rule.onNodeWithText(topSampleText + 1).semanticsId()
+ val topText2 = rule.onNodeWithText(topSampleText + 2).semanticsId()
+ val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId()
+ val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1150,10 +1150,10 @@
}
}
}
- val topText1 = rule.onNodeWithText(topSampleText + 1).semanticsId
- val topText2 = rule.onNodeWithText(topSampleText + 2).semanticsId
- val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId
- val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId
+ val topText1 = rule.onNodeWithText(topSampleText + 1).semanticsId()
+ val topText2 = rule.onNodeWithText(topSampleText + 2).semanticsId()
+ val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId()
+ val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1198,8 +1198,8 @@
}
}
}
- val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId
- val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId
+ val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId()
+ val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId()
// Act.
val bottomText1ANI = rule.runOnIdle { createAccessibilityNodeInfo(bottomText1) }
@@ -1241,10 +1241,10 @@
)
}
}
- val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId
- val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId
- val bottomText3 = rule.onNodeWithText(bottomSampleText + 3).semanticsId
- val topText3 = rule.onNodeWithText(topSampleText + 3).semanticsId
+ val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId()
+ val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId()
+ val bottomText3 = rule.onNodeWithText(bottomSampleText + 3).semanticsId()
+ val topText3 = rule.onNodeWithText(topSampleText + 3).semanticsId()
// Act.
rule.waitForIdle()
@@ -1297,8 +1297,8 @@
)
}
}
- val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId
- val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId
+ val bottomText1 = rule.onNodeWithText(bottomSampleText + 1).semanticsId()
+ val bottomText2 = rule.onNodeWithText(bottomSampleText + 2).semanticsId()
// Act.
val bottomText1ANI = rule.runOnIdle { createAccessibilityNodeInfo(bottomText1) }
@@ -1337,8 +1337,8 @@
}
}
}
- val node1 = rule.onNodeWithText(text1).semanticsId
- val overlaidNode = rule.onNodeWithText(overlaidText).semanticsId
+ val node1 = rule.onNodeWithText(text1).semanticsId()
+ val overlaidNode = rule.onNodeWithText(overlaidText).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(overlaidNode) }
@@ -1390,12 +1390,12 @@
Row { Text(text = text0) }
}
}
- val virtualViewId0 = rule.onNodeWithText(text0).semanticsId
- val virtualViewId1 = rule.onNodeWithText(text1).semanticsId
- val virtualViewId2 = rule.onNodeWithText(text2).semanticsId
- val virtualViewId3 = rule.onNodeWithText(text3).semanticsId
- val virtualViewId4 = rule.onNodeWithText(text4).semanticsId
- val virtualViewId5 = rule.onNodeWithText(text5).semanticsId
+ val virtualViewId0 = rule.onNodeWithText(text0).semanticsId()
+ val virtualViewId1 = rule.onNodeWithText(text1).semanticsId()
+ val virtualViewId2 = rule.onNodeWithText(text2).semanticsId()
+ val virtualViewId3 = rule.onNodeWithText(text3).semanticsId()
+ val virtualViewId4 = rule.onNodeWithText(text4).semanticsId()
+ val virtualViewId5 = rule.onNodeWithText(text5).semanticsId()
// Act.
rule.waitForIdle()
@@ -1445,8 +1445,8 @@
}
}
}
- val node3Id = rule.onNodeWithText(text3).semanticsId
- val overlayId = rule.onNodeWithText(overlaidText).semanticsId
+ val node3Id = rule.onNodeWithText(text3).semanticsId()
+ val overlayId = rule.onNodeWithText(overlaidText).semanticsId()
// Act.
val node3ANI = rule.runOnIdle { createAccessibilityNodeInfo(node3Id) }
@@ -1487,8 +1487,8 @@
}
}
}
- val node3Id = rule.onNodeWithText(text3).semanticsId
- val overlayId = rule.onNodeWithText(overlaidText).semanticsId
+ val node3Id = rule.onNodeWithText(text3).semanticsId()
+ val overlayId = rule.onNodeWithText(overlaidText).semanticsId()
// Act.
val node3ANI = rule.runOnIdle { createAccessibilityNodeInfo(node3Id) }
@@ -1507,8 +1507,8 @@
TopAppBar(title = { Text(text = topAppBarText) })
}
- val textBoxId = rule.onNodeWithTag(textBoxTag).semanticsId
- val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId
+ val textBoxId = rule.onNodeWithTag(textBoxTag).semanticsId()
+ val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId()
// Act.
val topAppBarANI = rule.runOnIdle { createAccessibilityNodeInfo(topAppBarId) }
@@ -1531,9 +1531,9 @@
repeat(100) { Text(sampleText + counter++) }
}
}
- val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId
- val node1Id = rule.onNodeWithText(sampleText1).semanticsId
- val node2Id = rule.onNodeWithText(sampleText2).semanticsId
+ val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId()
+ val node1Id = rule.onNodeWithText(sampleText1).semanticsId()
+ val node2Id = rule.onNodeWithText(sampleText2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1570,9 +1570,9 @@
bottomBar = { BottomAppBar { Text(bottomAppBarText) } }
)
}
- val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId
- val contentId = rule.onNodeWithText(contentText).semanticsId
- val bottomAppBarId = rule.onNodeWithText(bottomAppBarText).semanticsId
+ val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId()
+ val contentId = rule.onNodeWithText(contentText).semanticsId()
+ val bottomAppBarId = rule.onNodeWithText(bottomAppBarText).semanticsId()
// Act.
rule.waitForIdle()
@@ -1611,9 +1611,9 @@
content = { padding -> Text(contentText, modifier = Modifier.padding(padding)) }
)
}
- val face1Id = rule.onNodeWithContentDescription(content1).semanticsId
- val face3Id = rule.onNodeWithContentDescription(content3).semanticsId
- val contentId = rule.onNodeWithText(contentText).semanticsId
+ val face1Id = rule.onNodeWithContentDescription(content1).semanticsId()
+ val face3Id = rule.onNodeWithContentDescription(content3).semanticsId()
+ val contentId = rule.onNodeWithText(contentText).semanticsId()
// Act.
rule.waitForIdle()
@@ -1666,10 +1666,10 @@
Box { BasicText("Child Three", Modifier.testTag(childThreeTag)) }
}
}
- val parentBox1Id = rule.onNodeWithTag(parentBox1Tag).semanticsId
- val childOneId = rule.onNodeWithTag(childOneTag, useUnmergedTree = true).semanticsId
- val childTwoId = rule.onNodeWithTag(childTwoTag, useUnmergedTree = true).semanticsId
- val childThreeId = rule.onNodeWithTag(childThreeTag, useUnmergedTree = true).semanticsId
+ val parentBox1Id = rule.onNodeWithTag(parentBox1Tag).semanticsId()
+ val childOneId = rule.onNodeWithTag(childOneTag, useUnmergedTree = true).semanticsId()
+ val childTwoId = rule.onNodeWithTag(childTwoTag, useUnmergedTree = true).semanticsId()
+ val childThreeId = rule.onNodeWithTag(childThreeTag, useUnmergedTree = true).semanticsId()
// Act.
rule.waitForIdle()
@@ -1728,9 +1728,9 @@
)
}
- val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId
- val firstContentId = rule.onNodeWithTag(firstContentText).semanticsId
- val lastContentId = rule.onNodeWithTag(lastContentText).semanticsId
+ val topAppBarId = rule.onNodeWithText(topAppBarText).semanticsId()
+ val firstContentId = rule.onNodeWithTag(firstContentText).semanticsId()
+ val lastContentId = rule.onNodeWithTag(lastContentText).semanticsId()
// Act.
rule.waitForIdle()
@@ -1766,8 +1766,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithTag(childTag1).semanticsId
- val child2Id = rule.onNodeWithTag(childTag2).semanticsId
+ val child1Id = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2Id = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1795,8 +1795,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithTag(childTag1).semanticsId
- val child2Id = rule.onNodeWithTag(childTag2).semanticsId
+ val child1Id = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2Id = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1826,8 +1826,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithTag(childTag1).semanticsId
- val child2Id = rule.onNodeWithTag(childTag2).semanticsId
+ val child1Id = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2Id = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1857,8 +1857,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithTag(childTag1).semanticsId
- val child2Id = rule.onNodeWithTag(childTag2).semanticsId
+ val child1Id = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2Id = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1888,8 +1888,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1 = rule.onNodeWithTag(childTag1).semanticsId
- val child2 = rule.onNodeWithTag(childTag2).semanticsId
+ val child1 = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2 = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1929,8 +1929,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithTag(childTag1).semanticsId
- val child2Id = rule.onNodeWithTag(childTag2).semanticsId
+ val child1Id = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2Id = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
val child2ANI = rule.runOnIdle { createAccessibilityNodeInfo(child2Id) }
@@ -1962,8 +1962,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithTag(childTag1).semanticsId
- val child2Id = rule.onNodeWithTag(childTag2).semanticsId
+ val child1Id = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2Id = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
rule.waitForIdle()
@@ -1998,8 +1998,8 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithTag(childTag1).semanticsId
- val child2Id = rule.onNodeWithTag(childTag2).semanticsId
+ val child1Id = rule.onNodeWithTag(childTag1).semanticsId()
+ val child2Id = rule.onNodeWithTag(childTag2).semanticsId()
// Act.
rule.waitForIdle()
@@ -2045,13 +2045,13 @@
}
}
val root = rule.onNodeWithTag(rootTag).fetchSemanticsNode()
- val child1Id = rule.onNodeWithText(childText1).semanticsId
- val child2Id = rule.onNodeWithText(childText2).semanticsId
- val child3Id = rule.onNodeWithText(childText3).semanticsId
+ val child1Id = rule.onNodeWithText(childText1).semanticsId()
+ val child2Id = rule.onNodeWithText(childText2).semanticsId()
+ val child3Id = rule.onNodeWithText(childText3).semanticsId()
- val rtlChild1Id = rule.onNodeWithText(rtlChildText1).semanticsId
- val rtlChild2Id = rule.onNodeWithText(rtlChildText2).semanticsId
- val rtlChild3Id = rule.onNodeWithText(rtlChildText3).semanticsId
+ val rtlChild1Id = rule.onNodeWithText(rtlChildText1).semanticsId()
+ val rtlChild2Id = rule.onNodeWithText(rtlChildText2).semanticsId()
+ val rtlChild3Id = rule.onNodeWithText(rtlChildText3).semanticsId()
// Act.
rule.waitForIdle()
@@ -2135,8 +2135,8 @@
androidComposeView.androidViewsHandler.layoutNodeToHolder[
colSemanticsNode.replacedChildren[1].layoutNode]
checkNotNull(viewHolder)
- val firstButtonId = rule.onNodeWithText(firstButtonText).semanticsId
- val lastButtonId = rule.onNodeWithText(lastButtonText).semanticsId
+ val firstButtonId = rule.onNodeWithText(firstButtonText).semanticsId()
+ val lastButtonId = rule.onNodeWithText(lastButtonText).semanticsId()
// Act.
rule.waitForIdle()
@@ -2233,9 +2233,9 @@
androidComposeView.androidViewsHandler.layoutNodeToHolder[
colSemanticsNode.replacedChildren[1].layoutNode]
checkNotNull(viewHolder) // Check that the View exists
- val firstButtonId = rule.onNodeWithText(firstButtonText).semanticsId
- val thirdButtonId = rule.onNodeWithText(thirdButtonText).semanticsId
- val fourthButtonId = rule.onNodeWithText(fourthButtonText).semanticsId
+ val firstButtonId = rule.onNodeWithText(firstButtonText).semanticsId()
+ val thirdButtonId = rule.onNodeWithText(thirdButtonText).semanticsId()
+ val fourthButtonId = rule.onNodeWithText(fourthButtonText).semanticsId()
// Act.
rule.waitForIdle()
@@ -2293,14 +2293,14 @@
assertThat(scrollState.value).isEqualTo(0)
val showOnScreen = android.R.id.accessibilityActionShowOnScreen
- val target1Id = rule.onNodeWithTag(target1Tag).semanticsId
+ val target1Id = rule.onNodeWithTag(target1Tag).semanticsId()
rule.runOnUiThread {
assertThat(provider.performAction(target1Id, showOnScreen, null)).isTrue()
}
rule.mainClock.advanceTimeBy(5000)
assertThat(scrollState.value).isGreaterThan(99)
- val target2Id = rule.onNodeWithTag(target2Tag).semanticsId
+ val target2Id = rule.onNodeWithTag(target2Tag).semanticsId()
rule.runOnUiThread {
assertThat(provider.performAction(target2Id, showOnScreen, null)).isTrue()
}
@@ -2330,7 +2330,7 @@
assertThat(lazyState.firstVisibleItemScrollOffset).isEqualTo(0)
val showOnScreen = android.R.id.accessibilityActionShowOnScreen
- val target1Id = rule.onNodeWithTag(target1Tag).semanticsId
+ val target1Id = rule.onNodeWithTag(target1Tag).semanticsId()
rule.runOnUiThread {
assertThat(provider.performAction(target1Id, showOnScreen, null)).isTrue()
}
@@ -2338,7 +2338,7 @@
assertThat(lazyState.firstVisibleItemIndex).isEqualTo(0)
assertThat(lazyState.firstVisibleItemScrollOffset).isGreaterThan(99)
- val target2Id = rule.onNodeWithTag(target2Tag).semanticsId
+ val target2Id = rule.onNodeWithTag(target2Tag).semanticsId()
rule.runOnUiThread {
assertThat(provider.performAction(target2Id, showOnScreen, null)).isTrue()
}
@@ -2384,7 +2384,7 @@
// influenced by or influencing the parent row.
// TODO(b/190865803): Is this the ultimate right behavior we want?
val showOnScreen = android.R.id.accessibilityActionShowOnScreen
- val target1Id = rule.onNodeWithTag(target1Tag).semanticsId
+ val target1Id = rule.onNodeWithTag(target1Tag).semanticsId()
rule.runOnUiThread {
assertThat(provider.performAction(target1Id, showOnScreen, null)).isTrue()
}
@@ -2393,7 +2393,7 @@
assertThat(lazyState.firstVisibleItemScrollOffset).isGreaterThan(99)
assertThat(parentLazyState.firstVisibleItemScrollOffset).isEqualTo(0)
- val target2Id = rule.onNodeWithTag(target2Tag).semanticsId
+ val target2Id = rule.onNodeWithTag(target2Tag).semanticsId()
rule.runOnUiThread {
assertThat(provider.performAction(target2Id, showOnScreen, null)).isTrue()
}
@@ -2407,7 +2407,8 @@
fun testPerformAction_focus() {
// Arrange.
setContent { Box(Modifier.testTag(tag).focusable()) { BasicText("focusable") } }
- val virtualViewId = rule.onNodeWithTag(tag).assert(expectValue(Focused, false)).semanticsId
+ val virtualViewId =
+ rule.onNodeWithTag(tag).assert(expectValue(Focused, false)).semanticsId()
// Act.
rule.runOnUiThread {
@@ -2432,7 +2433,7 @@
}
}
rule.runOnIdle { focusRequester.requestFocus() }
- val virtualViewId = rule.onNodeWithTag(tag).assert(expectValue(Focused, true)).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).assert(expectValue(Focused, true)).semanticsId()
// Act.
rule.runOnUiThread {
@@ -2455,7 +2456,7 @@
}
}
rule.onNodeWithTag(tag).assertIsDisplayed().assertIsOn()
- val toggleableNodeId = rule.onNodeWithTag(tag).semanticsId
+ val toggleableNodeId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val actionPerformed =
@@ -2482,7 +2483,7 @@
content = { BasicText("ToggleableText") }
)
}
- val toggleableId = rule.onNodeWithTag(tag).assertIsDisplayed().assertIsOn().semanticsId
+ val toggleableId = rule.onNodeWithTag(tag).assertIsDisplayed().assertIsOn().semanticsId()
// Act.
val actionPerformed =
@@ -2499,7 +2500,7 @@
setContent {
BasicTextField(modifier = Modifier.testTag(tag), value = "value", onValueChange = {})
}
- val textFieldNodeId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId
+ val textFieldNodeId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId()
// Act.
val actionPerformed =
@@ -2530,7 +2531,7 @@
onValueChange = { value = it }
)
}
- val textFieldId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId
+ val textFieldId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId()
val argument = Bundle()
argument.putInt(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_START_INT, 1)
argument.putInt(AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_END_INT, 1)
@@ -2562,7 +2563,7 @@
)
}
}
- val textFieldId = rule.onNodeWithTag(tag).assert(expectValue(Focused, false)).semanticsId
+ val textFieldId = rule.onNodeWithTag(tag).assert(expectValue(Focused, false)).semanticsId()
// Act.
var actionPerformed =
@@ -2613,7 +2614,7 @@
}
}
rule.runOnIdle { focusRequester.requestFocus() }
- val virtualViewId = rule.onNodeWithTag(tag).assert(expectValue(Focused, true)).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).assert(expectValue(Focused, true)).semanticsId()
val expectedNode = provider.createAccessibilityNodeInfo(virtualViewId)
// Act.
@@ -2679,7 +2680,7 @@
fun getSemanticsNodeIdFromExtraData() {
// Arrange.
setContent { BasicText("texy") }
- val textId = rule.onNodeWithText("texy").semanticsId
+ val textId = rule.onNodeWithText("texy").semanticsId()
val info = AccessibilityNodeInfoCompat.obtain()
val argument = Bundle()
val idKey = "androidx.compose.ui.semantics.id"
@@ -2697,7 +2698,7 @@
fun sendClickedEvent_whenClick() {
// Arrange.
setContent { Box(Modifier.clickable(onClick = {}).testTag(tag)) { BasicText("Text") } }
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val actionPerformed =
@@ -2727,7 +2728,7 @@
setContent {
Box(Modifier.semantics { stateDescription = state }.testTag(tag)) { BasicText("Text") }
}
- val virtualViewId = rule.onNodeWithTag(tag).assertValueEquals("state one").semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).assertValueEquals("state one").semanticsId()
// Act.
rule.runOnIdle { state = "state two" }
@@ -2774,7 +2775,7 @@
BasicText("ToggleableText")
}
}
- val virtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().assertIsOn().semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().assertIsOn().semanticsId()
// Act.
rule.onNodeWithTag(tag).performClick()
@@ -2828,7 +2829,7 @@
}
}
}
- val toggleableVirtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId
+ val toggleableVirtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId()
// Act.
val actionPerformed =
@@ -2881,7 +2882,7 @@
}
}
val virtualViewId =
- rule.onNodeWithTag(tag).assertIsDisplayed().assertIsNotSelected().semanticsId
+ rule.onNodeWithTag(tag).assertIsDisplayed().assertIsNotSelected().semanticsId()
// Act.
rule.onNodeWithTag(tag).performClick()
@@ -2935,7 +2936,7 @@
}
}
val virtualViewId =
- rule.onNodeWithTag(tag).assertIsDisplayed().assertIsNotSelected().semanticsId
+ rule.onNodeWithTag(tag).assertIsDisplayed().assertIsNotSelected().semanticsId()
// Act.
rule.onNodeWithTag(tag).performClick()
@@ -2964,7 +2965,7 @@
// Arrange.
var current by mutableStateOf(0.5f)
setContent { Box(Modifier.progressSemantics(current).testTag(tag)) { BasicText("Text") } }
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
rule.runOnIdle { current = 0.9f }
@@ -3036,7 +3037,7 @@
rule
.onNodeWithTag(tag)
.assert(expectValue(EditableText, AnnotatedString("HELLO")))
- .semanticsId
+ .semanticsId()
rule.runOnIdle {
verify(container, atLeastOnce())
.requestSendAccessibilityEvent(eq(androidComposeView), argument.capture())
@@ -3085,7 +3086,7 @@
}
}
}
- val columnId = rule.onNodeWithTag(columnTag).semanticsId
+ val columnId = rule.onNodeWithTag(columnTag).semanticsId()
rule.runOnIdle {
verify(container, atLeastOnce())
@@ -3140,7 +3141,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId()
// TODO(b/272068594): Extra TYPE_WINDOW_CONTENT_CHANGED sent 100ms after setup.
rule.mainClock.advanceTimeBy(accessibilityEventLoopIntervalMs)
@@ -3193,7 +3194,7 @@
// Arrange.
val text = "h"
setContent { BasicText(text, Modifier.testTag(tag)) }
- val virtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).assertIsDisplayed().semanticsId()
// TODO(b/272068594): Extra TYPE_WINDOW_CONTENT_CHANGED sent 100ms after setup.
rule.mainClock.advanceTimeBy(accessibilityEventLoopIntervalMs)
@@ -3250,7 +3251,7 @@
Box { BasicText("TextNode") }
}
}
- val toggleableId = rule.onNodeWithTag(tag).semanticsId
+ val toggleableId = rule.onNodeWithTag(tag).semanticsId()
val textNode =
rule
.onNodeWithText("TextNode", useUnmergedTree = true)
@@ -3272,9 +3273,7 @@
rule.runOnUiThread {
// Directly call onLayoutChange because this guarantees short time.
- for (i in 1..10) {
- delegate.onLayoutChange(textNode.layoutNode)
- }
+ repeat(10) { delegate.onLayoutChange(textNode.layoutNode) }
}
rule.mainClock.advanceTimeBy(accessibilityEventLoopIntervalMs)
@@ -3306,7 +3305,7 @@
}
}
- val toggleableId = rule.onNodeWithTag(tag).semanticsId
+ val toggleableId = rule.onNodeWithTag(tag).semanticsId()
val textNode =
rule
.onNodeWithText("TextNode", useUnmergedTree = true)
@@ -3329,7 +3328,7 @@
rule.runOnUiThread {
// Directly call onLayoutChange because this guarantees short time.
- for (i in 1..10) {
+ repeat(10) {
// layout change for the parent box node
delegate.onLayoutChange(textNode.layoutNode.parent!!)
}
@@ -3363,7 +3362,7 @@
BasicText("ToggleableText")
}
}
- val toggleableId = rule.onNodeWithTag(tag).semanticsId
+ val toggleableId = rule.onNodeWithTag(tag).semanticsId()
val toggleableBounds =
with(rule.density) { rule.onNodeWithTag(tag).getBoundsInRoot().toRect() }
@@ -3396,8 +3395,8 @@
}
}
}
- val childOneId = rule.onNodeWithTag(childOneTag).semanticsId
- val childTwoId = rule.onNodeWithTag(childTwoTag).semanticsId
+ val childOneId = rule.onNodeWithTag(childOneTag).semanticsId()
+ val childTwoId = rule.onNodeWithTag(childTwoTag).semanticsId()
val overlappedChildNodeBounds =
with(rule.density) { rule.onNodeWithTag(childTwoTag).getBoundsInRoot().toRect() }
@@ -3442,7 +3441,7 @@
assertThat(scrollState.value).isGreaterThan(199)
- val vitrualViewId = rule.onNodeWithTag(tag).semanticsId
+ val vitrualViewId = rule.onNodeWithTag(tag).semanticsId()
val childNodeBounds =
with(rule.density) { rule.onNodeWithTag(tag).getBoundsInRoot().toRect() }
val hitTestedId =
@@ -3543,7 +3542,7 @@
Box(Modifier.size(100.dp).clickable {}.testTag(innertag)) { BasicText("") }
}
}
- val outerNodeId = rule.onNodeWithTag(outertag).semanticsId
+ val outerNodeId = rule.onNodeWithTag(outertag).semanticsId()
val bounds =
with(rule.density) { rule.onNodeWithTag(innertag, true).getBoundsInRoot().toRect() }
@@ -3701,7 +3700,7 @@
)
}
- val virtualViewId = rule.onNodeWithTag(textTag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(textTag).semanticsId()
val bounds = with(rule.density) { rule.onNodeWithTag(textTag).getBoundsInRoot().toRect() }
rule.runOnUiThread {
val hoverEnter =
@@ -3839,9 +3838,9 @@
}
}
}
- val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId
- val overlappedChildOneNodeId = rule.onNodeWithTag(childOneTag).semanticsId
- val overlappedChildTwoNodeId = rule.onNodeWithTag(childTwoTag).semanticsId
+ val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId()
+ val overlappedChildOneNodeId = rule.onNodeWithTag(childOneTag).semanticsId()
+ val overlappedChildTwoNodeId = rule.onNodeWithTag(childTwoTag).semanticsId()
// Assert.
rule.runOnIdle {
@@ -3867,8 +3866,8 @@
}
}
}
- val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId
- val childTwoId = rule.onNodeWithText("Child Two").semanticsId
+ val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId()
+ val childTwoId = rule.onNodeWithText("Child Two").semanticsId()
val childTwoBounds = Rect()
// Act.
@@ -3898,8 +3897,8 @@
}
}
}
- val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId
- val overlappedChildTwoNodeId = rule.onNodeWithTag(childTwoTag).semanticsId
+ val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId()
+ val overlappedChildTwoNodeId = rule.onNodeWithTag(childTwoTag).semanticsId()
rule.runOnIdle {
assertThat(createAccessibilityNodeInfo(parentNodeId).childCount).isEqualTo(2)
@@ -3929,7 +3928,7 @@
.onNodeWithTag(tag)
.assert(expectValue(SemanticsProperties.PaneTitle, "pane title"))
.assertIsDisplayed()
- .semanticsId
+ .semanticsId()
rule.runOnIdle {
verify(container, times(1))
.requestSendAccessibilityEvent(
@@ -3972,7 +3971,7 @@
rule
.onNodeWithTag(tag)
.assert(expectValue(SemanticsProperties.PaneTitle, "new pane title"))
- .semanticsId
+ .semanticsId()
rule.runOnIdle {
verify(container, times(1))
.requestSendAccessibilityEvent(
@@ -4127,7 +4126,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag("node").semanticsId
+ val virtualViewId = rule.onNodeWithTag("node").semanticsId()
var info = AccessibilityNodeInfoCompat.obtain()
rule.runOnUiThread { info = createAccessibilityNodeInfo(virtualViewId) }
@@ -4165,7 +4164,7 @@
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
var info = AccessibilityNodeInfoCompat.obtain()
rule.runOnUiThread { info = createAccessibilityNodeInfo(virtualViewId) }
val rect = Rect()
@@ -4227,8 +4226,8 @@
}
}
}
- val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId
- val overlappedChildTwoNodeId = rule.onNodeWithTag(childTwoTag).semanticsId
+ val parentNodeId = rule.onNodeWithTag(parentTag).semanticsId()
+ val overlappedChildTwoNodeId = rule.onNodeWithTag(childTwoTag).semanticsId()
rule.runOnIdle {
assertThat(createAccessibilityNodeInfo(parentNodeId).childCount).isEqualTo(2)
@@ -4258,7 +4257,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithText("text").semanticsId
+ val virtualViewId = rule.onNodeWithText("text").semanticsId()
var info = AccessibilityNodeInfoCompat.obtain()
rule.runOnUiThread { info = createAccessibilityNodeInfo(virtualViewId) }
@@ -4326,13 +4325,13 @@
}
}
}
- val box1Id = rule.onNodeWithTag(tag1).semanticsId
- val box2Id = rule.onNodeWithTag(tag2).semanticsId
- val box3Id = rule.onNodeWithTag(tag3).semanticsId
- val box4Id = rule.onNodeWithTag(tag4).semanticsId
- val box5Id = rule.onNodeWithTag(tag5).semanticsId
- val box6Id = rule.onNodeWithTag(tag6, true).semanticsId
- val box7Id = rule.onNodeWithTag(tag7, true).semanticsId
+ val box1Id = rule.onNodeWithTag(tag1).semanticsId()
+ val box2Id = rule.onNodeWithTag(tag2).semanticsId()
+ val box3Id = rule.onNodeWithTag(tag3).semanticsId()
+ val box4Id = rule.onNodeWithTag(tag4).semanticsId()
+ val box5Id = rule.onNodeWithTag(tag5).semanticsId()
+ val box6Id = rule.onNodeWithTag(tag6, true).semanticsId()
+ val box7Id = rule.onNodeWithTag(tag7, true).semanticsId()
// Act.
rule.waitForIdle()
@@ -4367,7 +4366,7 @@
}
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualId) }
@@ -4387,7 +4386,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4404,7 +4403,7 @@
Box(Modifier.size(100.toDp()).testTag(tag).semantics { contentDescription = "Box" })
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4425,7 +4424,7 @@
)
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4451,7 +4450,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4471,7 +4470,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag("Row").semanticsId
+ val virtualViewId = rule.onNodeWithTag("Row").semanticsId()
// Act.
val info = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4498,7 +4497,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag("tag").semanticsId
+ val virtualViewId = rule.onNodeWithTag("tag").semanticsId()
// Act.
val accessibilityNodeInfo =
@@ -4537,7 +4536,7 @@
}
}
- val virtualViewId = rule.onNodeWithTag("tag").semanticsId
+ val virtualViewId = rule.onNodeWithTag("tag").semanticsId()
// Act.
val accessibilityNodeInfo =
@@ -4572,7 +4571,7 @@
}
}
- val virtualViewId = rule.onNodeWithTag("tag").semanticsId
+ val virtualViewId = rule.onNodeWithTag("tag").semanticsId()
// Act.
val accessibilityNodeInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4606,7 +4605,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val accessibilityNodeInfo =
@@ -4640,7 +4639,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val accessibilityNodeInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4676,7 +4675,7 @@
}
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val accessibilityNodeInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4922,7 +4921,7 @@
setContent {
Column(Modifier.semantics(true) {}) { BasicText("test", Modifier.testTag(tag)) }
}
- val virtualViewId = rule.onNodeWithTag(tag, useUnmergedTree = true).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag, useUnmergedTree = true).semanticsId()
// Act.
val childInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4938,7 +4937,7 @@
setContent {
Column(Modifier.semantics(false) {}) { BasicText("test", Modifier.testTag(tag)) }
}
- val virtualViewId = rule.onNodeWithTag(tag, useUnmergedTree = true).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag, useUnmergedTree = true).semanticsId()
// Act.
val childInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4954,7 +4953,7 @@
setContent {
Column(Modifier.semantics(false) {}) { Box(Modifier.testTag(tag).size(100.dp)) }
}
- val virtualViewId = rule.onNodeWithTag(tag, useUnmergedTree = true).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag, useUnmergedTree = true).semanticsId()
// Act.
val childInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4971,7 +4970,7 @@
Image(ImageBitmap(100, 100), "Image", Modifier.testTag(tag))
}
}
- val virtualViewId = rule.onNodeWithTag(tag, true).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag, true).semanticsId()
// Act.
val imageInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -4988,7 +4987,7 @@
Image(ImageBitmap(100, 100), "Image", Modifier.testTag(tag))
}
}
- val virtualViewId = rule.onNodeWithTag(tag, true).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag, true).semanticsId()
// Act.
val imageInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -5009,7 +5008,7 @@
)
}
}
- val virtualViewId = rule.onNodeWithTag(tag, true).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag, true).semanticsId()
// Act.
val imageInfo = rule.runOnIdle { createAccessibilityNodeInfo(virtualViewId) }
@@ -5035,8 +5034,8 @@
}
}
}
- val columnId = rule.onNodeWithTag(tagColumn).semanticsId
- val rowId = rule.onNodeWithTag(tagRow).semanticsId
+ val columnId = rule.onNodeWithTag(tagColumn).semanticsId()
+ val rowId = rule.onNodeWithTag(tagRow).semanticsId()
// Act.
rule.waitForIdle()
@@ -5130,12 +5129,12 @@
)
}
}
- val parentId = rule.onNodeWithTag("parent").semanticsId
- val child1Id = rule.onNodeWithTag("child1").semanticsId
- val child2Id = rule.onNodeWithTag("child2").semanticsId
- val child3Id = rule.onNodeWithTag("child3").semanticsId
- val child4Id = rule.onNodeWithTag("child4").semanticsId
- val child5Id = rule.onNodeWithTag("child5").semanticsId
+ val parentId = rule.onNodeWithTag("parent").semanticsId()
+ val child1Id = rule.onNodeWithTag("child1").semanticsId()
+ val child2Id = rule.onNodeWithTag("child2").semanticsId()
+ val child3Id = rule.onNodeWithTag("child3").semanticsId()
+ val child4Id = rule.onNodeWithTag("child4").semanticsId()
+ val child5Id = rule.onNodeWithTag("child5").semanticsId()
// Act.
rule.waitForIdle()
@@ -5189,10 +5188,10 @@
)
}
}
- val parentId = rule.onNodeWithTag("parent").semanticsId
- val child1Id = rule.onNodeWithTag("child1").semanticsId
- val child2Id = rule.onNodeWithTag("child2").semanticsId
- val child3Id = rule.onNodeWithTag("child3").semanticsId
+ val parentId = rule.onNodeWithTag("parent").semanticsId()
+ val child1Id = rule.onNodeWithTag("child1").semanticsId()
+ val child2Id = rule.onNodeWithTag("child2").semanticsId()
+ val child3Id = rule.onNodeWithTag("child3").semanticsId()
// Act.
rule.waitForIdle()
@@ -5219,8 +5218,8 @@
BasicText("test", Modifier.testTag("child"))
}
}
- val boxId = rule.onNodeWithTag("box", useUnmergedTree = true).semanticsId
- val textId = rule.onNodeWithTag("child", useUnmergedTree = true).semanticsId
+ val boxId = rule.onNodeWithTag("box", useUnmergedTree = true).semanticsId()
+ val textId = rule.onNodeWithTag("child", useUnmergedTree = true).semanticsId()
// Act.
rule.waitForIdle()
@@ -5243,8 +5242,8 @@
BasicText("test", Modifier.testTag("child"))
}
}
- val boxId = rule.onNodeWithTag("box", useUnmergedTree = true).semanticsId
- val textId = rule.onNodeWithTag("child", useUnmergedTree = true).semanticsId
+ val boxId = rule.onNodeWithTag("box", useUnmergedTree = true).semanticsId()
+ val textId = rule.onNodeWithTag("child", useUnmergedTree = true).semanticsId()
// Act.
rule.waitForIdle()
@@ -5494,10 +5493,6 @@
Bottom
}
-// TODO(b/272068594): Add api to fetch the semantics id from SemanticsNodeInteraction directly.
-private val SemanticsNodeInteraction.semanticsId: Int
- get() = fetchSemanticsNode().id
-
// TODO(b/304359126): Move this to AccessibilityEventCompat and use it wherever we use obtain().
private fun AccessibilityEvent(): android.view.accessibility.AccessibilityEvent {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
index fb3cf39..193b509 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
@@ -73,6 +73,7 @@
import androidx.compose.ui.semantics.progressBarRangeInfo
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.semantics.setProgress
import androidx.compose.ui.semantics.setSelection
import androidx.compose.ui.semantics.setText
@@ -81,7 +82,6 @@
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.semantics.text
import androidx.compose.ui.semantics.textSelectionRange
-import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule
@@ -143,7 +143,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -174,7 +174,7 @@
rule.setContentWithAccessibilityEnabled {
Box(Modifier.size(10.dp).semantics(mergeDescendants = true) { testTag = tag })
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -189,7 +189,7 @@
rule.setContentWithAccessibilityEnabled {
Box(Modifier.size(10.dp).semantics(mergeDescendants = false) { testTag = tag })
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -209,7 +209,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -245,7 +245,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -293,7 +293,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -313,7 +313,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -333,7 +333,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -353,7 +353,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -373,7 +373,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -393,7 +393,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -413,7 +413,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -429,7 +429,7 @@
rule.setContentWithAccessibilityEnabled {
Box(Modifier.size(10.dp).semantics(mergeDescendants = false) { testTag = tag })
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -445,7 +445,7 @@
rule.setContentWithAccessibilityEnabled {
Box(Modifier.size(10.dp).semantics(mergeDescendants = true) { testTag = tag })
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -468,7 +468,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -490,7 +490,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -511,7 +511,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -535,7 +535,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -557,7 +557,7 @@
Box(Modifier.semantics { text = AnnotatedString("foo") })
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -578,7 +578,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -600,7 +600,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -620,7 +620,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -650,8 +650,8 @@
)
}
}
- val virtualViewId1 = rule.onNodeWithTag(testTag1).semanticsId
- val virtualViewId2 = rule.onNodeWithTag(testTag2).semanticsId
+ val virtualViewId1 = rule.onNodeWithTag(testTag1).semanticsId()
+ val virtualViewId2 = rule.onNodeWithTag(testTag2).semanticsId()
// Act.
lateinit var info1: AccessibilityNodeInfoCompat
@@ -680,7 +680,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
val info1 = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
dispatchedAccessibilityEvents.clear()
@@ -717,7 +717,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -763,7 +763,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -821,7 +821,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -846,7 +846,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -879,7 +879,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -907,7 +907,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -930,7 +930,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -958,7 +958,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -987,7 +987,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -1013,7 +1013,7 @@
}
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { androidComposeView.createAccessibilityNodeInfo(virtualViewId) }
@@ -1273,7 +1273,7 @@
}
)
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
rule.runOnIdle { textChanged = true }
@@ -1426,10 +1426,6 @@
ViewCompat.getAccessibilityDelegate(this)
as AndroidComposeViewAccessibilityDelegateCompat
- // TODO(b/272068594): Add api to fetch the semantics id from SemanticsNodeInteraction directly.
- private val SemanticsNodeInteraction.semanticsId: Int
- get() = fetchSemanticsNode().id
-
// TODO(b/304359126): Move this to AccessibilityEventCompat and use it wherever we use obtain().
private fun AccessibilityEvent(): AccessibilityEvent =
if (SDK_INT >= R) {
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/CollectionInfoTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/CollectionInfoTest.kt
index a4a05d7..ab7504f 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/CollectionInfoTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/CollectionInfoTest.kt
@@ -38,7 +38,7 @@
import androidx.compose.ui.semantics.collectionInfo
import androidx.compose.ui.semantics.collectionItemInfo
import androidx.compose.ui.semantics.semantics
-import androidx.compose.ui.test.SemanticsNodeInteraction
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule
@@ -88,7 +88,7 @@
Box(Modifier.size(50.dp).selectable(selected = false, onClick = {}))
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -109,7 +109,7 @@
rule.setContentWithAccessibilityEnabled {
LazyColumn(Modifier.testTag(tag)) { items(2) { BasicText("Text") } }
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -132,7 +132,7 @@
items(2) { BasicText("Text") }
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -153,7 +153,7 @@
rule.setContentWithAccessibilityEnabled {
LazyColumn(Modifier.testTag(tag).selectableGroup()) { items(2) { BasicText("Text") } }
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -180,7 +180,7 @@
items(2) { BasicText("Text") }
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -205,7 +205,7 @@
Box(Modifier.size(50.dp).selectable(selected = false, onClick = {}))
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -230,7 +230,7 @@
itemsIndexed(listOf("Text", "Text")) { index, item -> BasicText(item + index) }
}
}
- val virtualId = rule.onNodeWithText("Text0").semanticsId
+ val virtualId = rule.onNodeWithText("Text0").semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -254,7 +254,7 @@
}
}
}
- val virtualId = rule.onNodeWithText("Text0").semanticsId
+ val virtualId = rule.onNodeWithText("Text0").semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -286,7 +286,7 @@
}
}
}
- val virtualId = rule.onNodeWithText("Text0").semanticsId
+ val virtualId = rule.onNodeWithText("Text0").semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -318,7 +318,7 @@
}
}
}
- val virtualId = rule.onNodeWithText("Text0").semanticsId
+ val virtualId = rule.onNodeWithText("Text0").semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -347,7 +347,7 @@
// items
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -370,7 +370,7 @@
Box(Modifier.size(10.dp).selectable(selected = false, onClick = {}))
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -390,7 +390,7 @@
// items
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -407,7 +407,7 @@
// items
}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -441,9 +441,9 @@
)
}
}
- val virtualId0 = rule.onNodeWithTag("item0").semanticsId
- val virtualId1 = rule.onNodeWithTag("item1").semanticsId
- val virtualId2 = rule.onNodeWithTag("item2").semanticsId
+ val virtualId0 = rule.onNodeWithTag("item0").semanticsId()
+ val virtualId1 = rule.onNodeWithTag("item1").semanticsId()
+ val virtualId2 = rule.onNodeWithTag("item2").semanticsId()
// Act.
rule.waitForIdle()
@@ -466,7 +466,7 @@
rule.setContentWithAccessibilityEnabled {
HorizontalPager(rememberPagerState { pageCount }, Modifier.size(10.dp).testTag(tag)) {}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -482,7 +482,7 @@
rule.setContentWithAccessibilityEnabled {
VerticalPager(rememberPagerState { pageCount }, Modifier.size(10.dp).testTag(tag)) {}
}
- val virtualId = rule.onNodeWithTag(tag).semanticsId
+ val virtualId = rule.onNodeWithTag(tag).semanticsId()
// Act.
val info = rule.runOnIdle { composeView.createAccessibilityNodeInfo(virtualId) }
@@ -491,10 +491,6 @@
rule.runOnIdle { assertThat(info.collectionInfo.rowCount).isEqualTo(pageCount) }
}
- // TODO(b/272068594): Add api to fetch the semantics id from SemanticsNodeInteraction directly.
- private val SemanticsNodeInteraction.semanticsId: Int
- get() = fetchSemanticsNode().id
-
private fun ComposeContentTestRule.setContentWithAccessibilityEnabled(
content: @Composable () -> Unit
) {
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/ScrollingTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/ScrollingTest.kt
index 8b1f629..7a5eb34 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/ScrollingTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/accessibility/ScrollingTest.kt
@@ -47,9 +47,9 @@
import androidx.compose.ui.semantics.horizontalScrollAxisRange
import androidx.compose.ui.semantics.scrollBy
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.semantics.verticalScrollAxisRange
-import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule
@@ -113,7 +113,7 @@
}
}
rule.mainClock.advanceTimeBy(accessibilityEventLoopIntervalMs)
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
rule.runOnIdle { dispatchedAccessibilityEvents.clear() }
// Act.
@@ -461,7 +461,7 @@
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
rule.runOnIdle {
androidComposeView.accessibilityNodeProvider.performAction(
virtualViewId,
@@ -499,7 +499,7 @@
)
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
rule.runOnIdle {
androidComposeView.accessibilityNodeProvider.performAction(
virtualViewId,
@@ -608,10 +608,6 @@
ViewCompat.getAccessibilityDelegate(this)
as AndroidComposeViewAccessibilityDelegateCompat
- // TODO(b/272068594): Add api to fetch the semantics id from SemanticsNodeInteraction directly.
- private val SemanticsNodeInteraction.semanticsId: Int
- get() = fetchSemanticsNode().id
-
// TODO(b/304359126): Move this to AccessibilityEventCompat and use it wherever we use obtain().
private fun AccessibilityEvent(): AccessibilityEvent =
if (SDK_INT >= R) {
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/MixedAutofillTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/MixedAutofillTest.kt
index a955f9d..9cd6fe7 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/MixedAutofillTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/MixedAutofillTest.kt
@@ -41,6 +41,7 @@
import androidx.compose.ui.semantics.contentType
import androidx.compose.ui.semantics.onAutofillText
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/PerformAndroidAutofillManagerTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/PerformAndroidAutofillManagerTest.kt
index 4d142e5..e82f664 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/PerformAndroidAutofillManagerTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/PerformAndroidAutofillManagerTest.kt
@@ -54,12 +54,12 @@
import androidx.compose.ui.semantics.password
import androidx.compose.ui.semantics.requestFocus
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.semantics.setText
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.assertTextEquals
-import androidx.compose.ui.test.isEnabled
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.requestFocus
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldStateSemanticAutofillTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldStateSemanticAutofillTest.kt
index c53af64..fa1cdfd 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldStateSemanticAutofillTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldStateSemanticAutofillTest.kt
@@ -33,6 +33,7 @@
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.contentType
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.junit4.createAndroidComposeRule
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldsSemanticAutofillTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldsSemanticAutofillTest.kt
index 1b5a6e5..bb5a3dc 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldsSemanticAutofillTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/autofill/TextFieldsSemanticAutofillTest.kt
@@ -41,6 +41,7 @@
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.contentType
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.captureToImage
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/contentcapture/ContentCaptureTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/contentcapture/ContentCaptureTest.kt
index 147a430..0ccc6aa 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/contentcapture/ContentCaptureTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/contentcapture/ContentCaptureTest.kt
@@ -47,12 +47,12 @@
import androidx.compose.ui.semantics.clearTextSubstitution
import androidx.compose.ui.semantics.isShowingTextSubstitution
import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.semantics.setTextSubstitution
import androidx.compose.ui.semantics.showTextSubstitution
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.semantics.text
import androidx.compose.ui.semantics.textSubstitution
-import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule
@@ -585,7 +585,7 @@
)
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
val ids = LongArray(1).apply { this[0] = virtualViewId.toLong() }
val requestsCollector: Consumer<ViewTranslationRequest?> = mock()
@@ -639,7 +639,7 @@
)
}
}
- val virtualViewId = rule.onNodeWithTag(tag).semanticsId
+ val virtualViewId = rule.onNodeWithTag(tag).semanticsId()
// Act.
rule.runOnIdle {
@@ -785,10 +785,6 @@
}
}
- // TODO(b/272068594): Add api to fetch the semantics id from SemanticsNodeInteraction directly.
- private val SemanticsNodeInteraction.semanticsId: Int
- get() = fetchSemanticsNode().id
-
@Composable
private fun ContentCaptureTestLazyList(listState: LazyListState) {
val itemCount = 20
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/FocusListenerTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/FocusListenerTest.kt
index e1be2f7..12b5593 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/FocusListenerTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/focus/FocusListenerTest.kt
@@ -30,6 +30,7 @@
import androidx.compose.ui.node.requireSemanticsInfo
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/OnGlobalLayoutListenerTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/OnGlobalLayoutListenerTest.kt
index 3ba5d10..1bc9aff 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/OnGlobalLayoutListenerTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/OnGlobalLayoutListenerTest.kt
@@ -42,6 +42,7 @@
import androidx.compose.ui.node.requireOwner
import androidx.compose.ui.platform.InspectorInfo
import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.spatial.RelativeLayoutBounds
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.SemanticsNodeInteraction
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
index 2846ab6..e8f8e7d 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
@@ -67,6 +67,7 @@
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.SemanticsNode
+import androidx.compose.ui.semantics.semanticsId
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.assertCountEquals
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/semantics/SemanticsListenerTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/semantics/SemanticsListenerTest.kt
index 4311904..5d7a5ff 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/semantics/SemanticsListenerTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/semantics/SemanticsListenerTest.kt
@@ -42,7 +42,6 @@
import androidx.compose.ui.node.invalidateSemantics
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
-import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
@@ -183,7 +182,7 @@
rule.runOnIdle { addModifier = true }
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -220,7 +219,7 @@
rule.runOnIdle { removeModifier = true }
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -248,7 +247,7 @@
rule.runOnIdle { text = AnnotatedString("text2") }
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -281,7 +280,7 @@
rule.runOnIdle { text = AnnotatedString("text2") }
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -319,7 +318,7 @@
}
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -347,7 +346,7 @@
rule.runOnIdle { text = "text2" }
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -376,7 +375,7 @@
rule.runOnIdle { text = "text3" }
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -417,7 +416,7 @@
rule.runOnIdle { text = "text2" }
// Assert.
- val semanticsId = rule.onNodeWithTag("item").semanticsId
+ val semanticsId = rule.onNodeWithTag("item").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -455,8 +454,8 @@
rule.onNodeWithTag("item2").requestFocus()
// Assert.
- val item1 = rule.onNodeWithTag("item1").semanticsId
- val item2 = rule.onNodeWithTag("item2").semanticsId
+ val item1 = rule.onNodeWithTag("item1").semanticsId()
+ val item2 = rule.onNodeWithTag("item2").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -497,8 +496,8 @@
rule.onNodeWithTag("item2").requestFocus()
// Assert.
- val item1 = rule.onNodeWithTag("item1").semanticsId
- val item2 = rule.onNodeWithTag("item2").semanticsId
+ val item1 = rule.onNodeWithTag("item1").semanticsId()
+ val item2 = rule.onNodeWithTag("item2").semanticsId()
rule.runOnIdle {
if (isSemanticAutofillEnabled) {
assertThat(events)
@@ -543,10 +542,6 @@
data class Event<T>(val semanticsId: Int, val prevSemantics: T?, val newSemantics: T?)
- // TODO(b/272068594): Add api to fetch the semantics id from SemanticsNodeInteraction directly.
- private val SemanticsNodeInteraction.semanticsId: Int
- get() = fetchSemanticsNode().id
-
@Composable
private fun FocusableBox(
modifier: Modifier = Modifier,
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/semantics/SemanticsTestUtils.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/semantics/SemanticsTestUtils.kt
new file mode 100644
index 0000000..2f5767c
--- /dev/null
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/semantics/SemanticsTestUtils.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.ui.semantics
+
+import androidx.compose.ui.test.SemanticsNodeInteraction
+
+/** Fetch the id of the semantics node. */
+internal fun SemanticsNodeInteraction.semanticsId(): Int = fetchSemanticsNode().id
diff --git a/paging/paging-compose/src/androidInstrumentedTest/kotlin/androidx/paging/compose/LazyPagingItemsTest.kt b/paging/paging-compose/src/androidInstrumentedTest/kotlin/androidx/paging/compose/LazyPagingItemsTest.kt
index dc64222..edf4bf1 100644
--- a/paging/paging-compose/src/androidInstrumentedTest/kotlin/androidx/paging/compose/LazyPagingItemsTest.kt
+++ b/paging/paging-compose/src/androidInstrumentedTest/kotlin/androidx/paging/compose/LazyPagingItemsTest.kt
@@ -263,8 +263,8 @@
}
}
- val idMinus1 = rule.onNodeWithTag("-1").semanticsId()
- val id0 = rule.onNodeWithTag("0").semanticsId()
+ val idMinus1 = rule.onNodeWithTag("-1").fetchSemanticsNode().id
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
state.scrollToItem(2)
@@ -327,8 +327,8 @@
rule.waitUntil { loadedItem6 }
- val idMinus1 = rule.onNodeWithTag("-1").semanticsId()
- val id0 = rule.onNodeWithTag("0").semanticsId()
+ val idMinus1 = rule.onNodeWithTag("-1").fetchSemanticsNode().id
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {
@@ -381,8 +381,8 @@
}
}
- val idMinus1 = rule.onNodeWithTag("-1").semanticsId()
- val id0 = rule.onNodeWithTag("0").semanticsId()
+ val idMinus1 = rule.onNodeWithTag("-1").fetchSemanticsNode().id
+ val id0 = rule.onNodeWithTag("0").fetchSemanticsNode().id
rule.runOnIdle {
runBlocking {