Skip to content

Instantly share code, notes, and snippets.

@alexvanyo
Last active January 25, 2023 22:08
Show Gist options
  • Save alexvanyo/062530ce4d4b135175fb71b5088a1a54 to your computer and use it in GitHub Desktop.
Save alexvanyo/062530ce4d4b135175fb71b5088a1a54 to your computer and use it in GitHub Desktop.
A fixed test that verifies the rounding behavior that occurs on device
/* Copyright 2023 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@Test
fun checkHeightOfColumn() {
lateinit var density: Density
lateinit var layoutCoordinates: LayoutCoordinates
composeTestRule.setContent {
density = LocalDensity.current
Column(
Modifier.onPlaced { layoutCoordinates = it }
) {
repeat(6) {
Spacer(Modifier.height(10.dp))
}
}
}
composeTestRule.waitForIdle()
assertEquals(with(density) { 10.dp.roundToPx() } * 6, layoutCoordinates.size.height)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment