John O'Reilly
09/25/2023, 7:44 PMval personListNode = composeTestRule.onNodeWithTag(PersonListTag)
personListNode.assertIsDisplayed()
.onChildren().assertCountEquals(people.size)
people.forEachIndexed { index, person ->
val rowNode = personListNode.onChildAt(index)
rowNode.printToLog("TAG")
rowNode.assertTextContains(person.name)
rowNode.assertTextContains(person.homeworld.name)
}
John O'Reilly
09/25/2023, 7:45 PMListItem(
headlineContent = { Text(person.name, style = MaterialTheme.typography.titleLarge) },
supportingContent = { Text(person.homeworld.name, style = MaterialTheme.typography.titleMedium, color = Color.DarkGray) }
)
John O'Reilly
09/25/2023, 7:46 PMjava.lang.AssertionError: Failed to assert the following: (Text + EditableText contains 'Name 1' (ignoreCase: false))
Semantics of the node:
Node #4 at (l=0.0, t=136.0, r=1440.0, b=388.0)px
IsTraversalGroup = 'true'
Has 1 child
Selector used: (((TestTag = 'PersonList').children)[0])
John O'Reilly
09/25/2023, 7:48 PMprintToLog
(for material 2 and 3)
// Material 2 (working)
09-25 20:35:08.518 6279 6298 D TAG : Node #4 at (l=0.0, t=136.0, r=1440.0, b=360.0)px
09-25 20:35:08.518 6279 6298 D TAG : Text = '[Name 1, Home world 1]'
09-25 20:35:08.518 6279 6298 D TAG : Actions = [GetTextLayoutResult]
// Material 3 (not working)
09-25 20:28:03.039 5953 5972 D TAG : Node #4 at (l=0.0, t=136.0, r=1440.0, b=388.0)px
09-25 20:28:03.039 5953 5972 D TAG : IsTraversalGroup = 'true'
09-25 20:28:03.039 5953 5972 D TAG : |-Node #5 at (l=56.0, t=164.0, r=1384.0, b=360.0)px
09-25 20:28:03.039 5953 5972 D TAG : Text = '[Name 1, Home world 1]'
09-25 20:28:03.039 5953 5972 D TAG : Actions = [GetTextLayoutResult]
John O'Reilly
09/30/2023, 9:07 AMListItem
is using a Surface
(whereas it didn't in Material 2 where test was passing).....and Surface
in turn contains following. Not fully sure what best fix is yet.
.semantics(mergeDescendants = false) {
isContainer = true
}
John O'Reilly
09/30/2023, 9:28 AMrowNode.onChild().assertTextContains(person.name)