Last active
January 25, 2023 22:08
-
-
Save alexvanyo/110abf35a8b39c78efc7ef599466207b to your computer and use it in GitHub Desktop.
A flaky test with behavior that depends on the density of the 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 */ | |
@Ignore("Flaky test, don't do this!) | |
@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) { 60.dp.roundToPx() }, layoutCoordinates.size.height) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment