Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MatkovIvan committed Feb 6, 2024
1 parent 1052cc8 commit 1fdf908
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private class AnimatedMouseWheelScrollPhysics(
}
return with(scrollingLogic) {
val delta = scrollDelta.reverseIfNeeded().toFloat()
if (canConsumeDelta(delta)) {
if (delta != 0f && canConsumeDelta(delta)) {
if (mouseWheelScrollConfig.isPreciseWheelScroll(pointerEvent)) {
// In case of high-resolution wheel, such as a freely rotating wheel with no notches
// or trackpads, delta should apply directly without any delays.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,17 +768,19 @@ class ScrollableTest {

@OptIn(ExperimentalTestApi::class)
@Test
fun scrollable_nestedScroll_disabledForMouseWheel() = runSkikoComposeUiTest {
fun scrollable_nestedScroll_childPartialConsumptionForMouseWheel() = runSkikoComposeUiTest {
var innerDrag = 0f
var outerDrag = 0f
val outerState = ScrollableState(
consumeScrollDelta = {
// Since the child has already consumed half, the parent will consume the rest.
outerDrag += it
it
}
)
val innerState = ScrollableState(
consumeScrollDelta = {
// Child consumes half, leaving the rest for the parent to consume.
innerDrag += it / 2
it / 2
}
Expand Down Expand Up @@ -812,7 +814,10 @@ class ScrollableTest {
}
runOnIdle {
assertThat(innerDrag).isGreaterThan(0f)
assertThat(outerDrag).isEqualTo(0f)
assertThat(outerDrag).isGreaterThan(0f)
// Since child (inner) consumes half of the scroll, the parent (outer) consumes the
// remainder (which is half as well), so they will be equal.
assertThat(innerDrag).isEqualTo(outerDrag)
}
}

Expand Down

0 comments on commit 1fdf908

Please sign in to comment.