Last active
January 25, 2023 22:08
-
-
Save alexvanyo/062530ce4d4b135175fb71b5088a1a54 to your computer and use it in GitHub Desktop.
A fixed test that verifies the rounding behavior that occurs on device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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