Hi folks, I’m writing the UI test with Compose on LazyVerticalGrid, Is there any way to assert that x columns are displayed when I set columns = GridCells.Fixed(x) in LazyVerticalGrid?
a
Abhishek Sharma
01/12/2023, 10:11 AM
I think you can do this using
onChildPositioned
callback. Maybe something like
Copy code
var childCount = 0
LazyVerticalGrid(columns = GridCells.Fixed(x)) {
items((1..100).toList()) {
Text("Item $it")
onChildPositioned {
childCount++
}
}
}
// Assert that the number of children positioned within the grid is equal to x
assertEquals(x, childCount)