-
Notifications
You must be signed in to change notification settings - Fork 0
Using unmerged tree
Devrath edited this page Mar 4, 2024
·
3 revisions
@Composable
fun UsingUnMergedTreeDemo() {
Button(
modifier = Modifier.semantics { contentDescription = "our tag" },
onClick = {}) {
Text(text = "Hello")
Text(text = "World")
}
}
class UsingUnMergedTreeDemoKtTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun mergedTreeLog() {
composeTestRule.setContent {
UsingUnMergedTreeDemo()
}
composeTestRule.onRoot().printToLog("TAG")
}
@Test
fun unMergedTreeLog() {
composeTestRule.setContent {
UsingUnMergedTreeDemo()
}
composeTestRule.onRoot(useUnmergedTree = true).printToLog("TAG")
}
}
MERGED TREE
printToLog:
Printing with useUnmergedTree = 'false'
Node #1 at (l=0.0, t=66.0, r=325.0, b=198.0)px
|-Node #2 at (l=0.0, t=77.0, r=325.0, b=187.0)px
Focused = 'false'
Role = 'Button'
ContentDescription = '[our tag]'
Text = '[Hello, World]'
Actions = [OnClick, RequestFocus, SetTextSubstitution, ShowTextSubstitution, ClearTextSubstitution, GetTextLayoutResult]
MergeDescendants = 'true'
UN-MERGED TREE
printToLog:
Printing with useUnmergedTree = 'true'
Node #1 at (l=0.0, t=66.0, r=325.0, b=198.0)px
|-Node #2 at (l=0.0, t=77.0, r=325.0, b=187.0)px
Focused = 'false'
Role = 'Button'
ContentDescription = '[our tag]'
Actions = [OnClick, RequestFocus]
MergeDescendants = 'true'
|-Node #4 at (l=66.0, t=106.0, r=158.0, b=158.0)px
| Text = '[Hello]'
| Actions = [SetTextSubstitution, ShowTextSubstitution, ClearTextSubstitution, GetTextLayoutResult]
|-Node #5 at (l=158.0, t=106.0, r=259.0, b=158.0)px
Text = '[World]'
Actions = [SetTextSubstitution, ShowTextSubstitution, ClearTextSubstitution, GetTextLayoutResult]