Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/magnetictarget/MagnetizedObject.kt +5 −2 Original line number Diff line number Diff line Loading @@ -548,8 +548,11 @@ abstract class MagnetizedObject<T : Any>( // Whether velocity is sufficient, depending on whether we're flinging into a target at the // top or the bottom of the screen. val velocitySufficient = if (rawY < target.centerOnDisplayY()) velY > flingToTargetMinVelocity else velY < flingToTargetMinVelocity if (rawY < target.centerOnDisplayY()) { velY > flingToTargetMinVelocity } else { velY < -flingToTargetMinVelocity } if (!velocitySufficient) { return false Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/magnetictarget/MagnetizedObjectTest.kt +21 −1 Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ class MagnetizedObjectTest : ShellTestCase() { } @Test fun testFlingTowardsTarget_towardsButTooSlow() { fun testFlingTowardsTarget_downTowardsButTooSlow() { // Very, very slowly fling the object towards the target (but never touch the magnetic // field). This value is only used to create MotionEvent timestamps, it will not block the // test for 10 seconds. Loading @@ -320,6 +320,26 @@ class MagnetizedObjectTest : ShellTestCase() { verifyNoMoreInteractions(magnetListener) } @Test fun testFlingTowardsTarget_upTowardsButTooSlow() { timeStep = 10000 dispatchMotionEvents( getMotionEvent( x = targetCenterX, y = targetCenterY * 2, action = MotionEvent.ACTION_DOWN), getMotionEvent( x = targetCenterX, y = (targetCenterY * 1.5).toInt()), getMotionEvent( x = targetCenterX, y = targetCenterY + magneticFieldRadius * 2, action = MotionEvent.ACTION_UP)) // No sticking should have occurred. verifyNoMoreInteractions(magnetListener) } @Test fun testFlingTowardsTarget_missTarget() { timeStep = 10 Loading Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/magnetictarget/MagnetizedObject.kt +5 −2 Original line number Diff line number Diff line Loading @@ -548,8 +548,11 @@ abstract class MagnetizedObject<T : Any>( // Whether velocity is sufficient, depending on whether we're flinging into a target at the // top or the bottom of the screen. val velocitySufficient = if (rawY < target.centerOnDisplayY()) velY > flingToTargetMinVelocity else velY < flingToTargetMinVelocity if (rawY < target.centerOnDisplayY()) { velY > flingToTargetMinVelocity } else { velY < -flingToTargetMinVelocity } if (!velocitySufficient) { return false Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/magnetictarget/MagnetizedObjectTest.kt +21 −1 Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ class MagnetizedObjectTest : ShellTestCase() { } @Test fun testFlingTowardsTarget_towardsButTooSlow() { fun testFlingTowardsTarget_downTowardsButTooSlow() { // Very, very slowly fling the object towards the target (but never touch the magnetic // field). This value is only used to create MotionEvent timestamps, it will not block the // test for 10 seconds. Loading @@ -320,6 +320,26 @@ class MagnetizedObjectTest : ShellTestCase() { verifyNoMoreInteractions(magnetListener) } @Test fun testFlingTowardsTarget_upTowardsButTooSlow() { timeStep = 10000 dispatchMotionEvents( getMotionEvent( x = targetCenterX, y = targetCenterY * 2, action = MotionEvent.ACTION_DOWN), getMotionEvent( x = targetCenterX, y = (targetCenterY * 1.5).toInt()), getMotionEvent( x = targetCenterX, y = targetCenterY + magneticFieldRadius * 2, action = MotionEvent.ACTION_UP)) // No sticking should have occurred. verifyNoMoreInteractions(magnetListener) } @Test fun testFlingTowardsTarget_missTarget() { timeStep = 10 Loading