Hi folks, I’m writing the UI test with Compose on ...
# compose
l
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
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)
Btw, you might need to use the
runBlockingTest
as onChildPositioned is async.
z