Hi, i'm trying to write tests for a composable fun...
# compose
Hi, i'm trying to write tests for a composable function that does calculations on a lazy list when it's scrolled. I'm using
Copy code
listNode.performTouchInput {
  swipeUp(endY = height - 3.dp.toPx())
to simulate a scroll. Now this works fine if I'm using higher values than
but since I want to test a specific edge case, I'd like to use low values. However, by capturing before and after screenshots, I noticed that when using low values like
, it doesn't scroll at all. Is there a minimum threshold or something?
This is probably under the system-level touch slop
Print the value of
to verify that threshold
that prints 22
ok so I would need to swipe by at least 22px
Probably not pixels, you would want to stay in the dp land
Or maybe pixels if that’s what
operates in
One last thing - don’t hardcode 22 into your test. Use
so that it works across different devices
yeah, i'm looking into how to incorporate this best. I don't think I can test my edge cases given this limitation.
Touch slop will be there for the “real” user interaction on device. Not sure what is the edge case you’re trying to test, but it might be that you’re trying to test something that can not happen in the app / on device.
yeah, thinking about, my test was not setup right. What I wanted is to test is that something changed at the right moment when scrolling. So I scrolled very close to the breaking point, asserted everything is how it should be, then scrolled just passed it (hence the small value) and asserted the change. But it's clear to me now that this is not how the user would interact. I need to restructure the test to do a bigger swipe just over the breaking point and assert then.
Thanks for your input, very helpful!