Skip to content

Instantly share code, notes, and snippets.

@PiotrPrus
Created December 31, 2021 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PiotrPrus/e3cc8e0c44ffb8698aa01ffd3d17c15b to your computer and use it in GitHub Desktop.
Save PiotrPrus/e3cc8e0c44ffb8698aa01ffd3d17c15b to your computer and use it in GitHub Desktop.
@Test
fun cancelSelectionOfThirdElement() {
val list = mutableStateOf(listOf(1, 2, 3, 4, 5, 6, 7, 8))
val selectedItem = mutableStateOf(list.value.first())
val distance = with(composeTestRule.density) { (12.dp + 20.dp.times(3)).toPx() }
composeTestRule.setContent {
BarChartCanvas(list = list.value, barSelected = { selectedItem.value = it })
}
composeTestRule.onNodeWithTag(testTag = "BarChart")
.performGesture { down(Offset(distance, 1f)) }
.performGesture { moveBy(Offset(distance, 0f)) }
.performGesture { up() }
assertEquals(1, selectedItem.value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment