Aditya Wasan
02/25/2021, 7:47 AMprintToLog
method it seems that now there is an extra node in the compose hierarchy
|-Node #4 at (0.0, 171.0, 1080.0, 325.0)px
SelectableGroup = 'kotlin.Unit'
MergeDescendants = 'true'
Is this a planned change or a bug?
(Posting more details in the thread)@Composable
fun LobstersBottomNav(
currentDestination: Destination,
navigateToDestination: (destination: Destination) -> Unit,
jumpToIndex: (index: Int) -> Unit,
) {
BottomNavigation(modifier = Modifier.testTag("LobstersBottomNav").semantics(mergeDescendants = true) {}) {
Destination.values().forEach { screen ->
BottomNavigationItem(
icon = {
IconResource(
resourceId = screen.badgeRes,
contentDescription = stringResource(screen.labelRes),
)
},
label = { Text(stringResource(id = screen.labelRes)) },
selected = currentDestination == screen,
alwaysShowLabel = false,
onClick = {
if (screen != currentDestination) {
navigateToDestination(screen)
} else if (screen.route == Destination.Hottest.route) {
jumpToIndex(0)
}
}
)
}
}
}
and this was a sample test
composeTestRule.onNodeWithTag("LobstersBottomNav")
.assertIsDisplayed()
.onChildren()
.assertCountEquals(Destination.values().size)
Node #1 at (0.0, 171.0, 1080.0, 325.0)px
|-Node #2 at (0.0, 171.0, 1080.0, 325.0)px, Tag: 'LobstersBottomNav'
|-Node #4 at (0.0, 171.0, 1080.0, 325.0)px
SelectableGroup = 'kotlin.Unit'
MergeDescendants = 'true'
|-Node #5 at (0.0, 171.0, 540.0, 325.0)px
| Role = 'Tab'
| OnClick = 'AccessibilityAction(label=null, action=Function0<java.lang.Boolean>)'
| Selected = 'true'
| StateDescription = 'Selected'
| Text = 'Hottest'
| GetTextLayoutResult = 'AccessibilityAction(label=null, action=Function1<java.util.List<androidx.compose.ui.text.TextLayoutResult>, java.lang.Boolean>)'
| ContentDescription = 'Hottest'
| MergeDescendants = 'true'
|-Node #10 at (540.0, 171.0, 1080.0, 325.0)px
Role = 'Tab'
OnClick = 'AccessibilityAction(label=null, action=Function0<java.lang.Boolean>)'
Selected = 'false'
StateDescription = 'Not selected'
ContentDescription = 'Saved'
Text = 'Saved'
GetTextLayoutResult = 'AccessibilityAction(label=null, action=Function1<java.util.List<androidx.compose.ui.text.TextLayoutResult>, java.lang.Boolean>)'
MergeDescendants = 'true'
jim
02/25/2021, 10:49 AMAditya Wasan
02/25/2021, 2:12 PMjim
02/25/2021, 3:44 PMAditya Wasan
02/25/2021, 4:11 PMPedro Gomez
03/03/2021, 4:14 PMAditya Wasan
03/04/2021, 6:48 AMcomposeTestRule
into compareScreenshot()
method. Adding composeTestRule.onRoot().captureToImage().asAndroidBitmap()
to compareScreenshot()
worked fine. My initial guess is that shot has not been updated yet to support beta-01 but if it is something else I'll be happy to provide more logs to triage this.Pedro Gomez
03/04/2021, 7:51 AMAditya Wasan
03/04/2021, 11:24 AMVinay Gaba
03/07/2021, 6:56 PMAndroidXScreenshotRule
in the codebase but it doesn’t seem to be a part of the Androidx Rules Library. Any plans of doing that? Or should we simply copy paste it?