Loading packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt +2 −2 Original line number Diff line number Diff line Loading @@ -263,10 +263,10 @@ private suspend fun PointerInputScope.detectDragGestures( val deltaOffset = drag.position - initialDown.position val delta = when (orientation) { Orientation.Horizontal -> deltaOffset.y Orientation.Horizontal -> deltaOffset.x Orientation.Vertical -> deltaOffset.y } check(delta != 0f) check(delta != 0f) { "delta is equal to 0" } overSlop = delta.sign } Loading packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -442,6 +442,23 @@ class SwipeToSceneTest { transition = layoutState.currentTransition assertThat(transition).isNotNull() assertThat(transition?.toScene).isEqualTo(TestScenes.SceneB) // Release the finger, animating back to scene A. rule.onRoot().performTouchInput { up() } rule.waitForIdle() assertThat(layoutState.currentTransition).isNull() assertThat(layoutState.transitionState.currentScene).isEqualTo(TestScenes.SceneA) // Swipe left by exactly touchSlop, so that the drag overSlop is 0f. rule.onRoot().performTouchInput { down(middle) moveBy(Offset(-touchSlop, 0f), delayMillis = 1_000) } // We should still correctly compute that we are swiping down to scene B. transition = layoutState.currentTransition assertThat(transition).isNotNull() assertThat(transition?.toScene).isEqualTo(TestScenes.SceneB) } @Test Loading Loading
packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt +2 −2 Original line number Diff line number Diff line Loading @@ -263,10 +263,10 @@ private suspend fun PointerInputScope.detectDragGestures( val deltaOffset = drag.position - initialDown.position val delta = when (orientation) { Orientation.Horizontal -> deltaOffset.y Orientation.Horizontal -> deltaOffset.x Orientation.Vertical -> deltaOffset.y } check(delta != 0f) check(delta != 0f) { "delta is equal to 0" } overSlop = delta.sign } Loading
packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -442,6 +442,23 @@ class SwipeToSceneTest { transition = layoutState.currentTransition assertThat(transition).isNotNull() assertThat(transition?.toScene).isEqualTo(TestScenes.SceneB) // Release the finger, animating back to scene A. rule.onRoot().performTouchInput { up() } rule.waitForIdle() assertThat(layoutState.currentTransition).isNull() assertThat(layoutState.transitionState.currentScene).isEqualTo(TestScenes.SceneA) // Swipe left by exactly touchSlop, so that the drag overSlop is 0f. rule.onRoot().performTouchInput { down(middle) moveBy(Offset(-touchSlop, 0f), delayMillis = 1_000) } // We should still correctly compute that we are swiping down to scene B. transition = layoutState.currentTransition assertThat(transition).isNotNull() assertThat(transition?.toScene).isEqualTo(TestScenes.SceneB) } @Test Loading