Loading packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/ThreeFingerGestureRecognizerTest.kt +31 −4 Original line number Diff line number Diff line Loading @@ -83,13 +83,40 @@ class ThreeFingerGestureRecognizerTest( } @Test fun doesntTriggerGestureFinished_onTwoFingersSwipe() { assertStateAfterEvents(events = TwoFingerGesture.swipeRight(), expectedState = NotStarted) fun triggersGestureError_onTwoFingersSwipe() { assertStateAfterEvents(events = TwoFingerGesture.swipeRight(), expectedState = Error) } @Test fun doesntTriggerGestureFinished_onFourFingersSwipe() { assertStateAfterEvents(events = FourFingerGesture.swipeRight(), expectedState = NotStarted) fun doesntTriggerGestureError_TwoFingerSwipeInProgress() { assertStateAfterEvents( events = TwoFingerGesture.eventsForGestureInProgress { move(deltaX = SWIPE_DISTANCE) }, expectedState = NotStarted, ) } @Test fun triggersGestureError_onFourFingersSwipe() { assertStateAfterEvents(events = FourFingerGesture.swipeRight(), expectedState = Error) } @Test fun doesntTriggerGestureError_FourFingerSwipeInProgress() { assertStateAfterEvents( events = FourFingerGesture.eventsForGestureInProgress { move(deltaX = SWIPE_DISTANCE) }, expectedState = NotStarted, ) } @Test fun ignoresOneFingerSwipes() { val oneFingerSwipe = listOf( touchpadEvent(MotionEvent.ACTION_DOWN, 50f, 50f), touchpadEvent(MotionEvent.ACTION_MOVE, 55f, 55f), touchpadEvent(MotionEvent.ACTION_UP, 60f, 60f), ) assertStateAfterEvents(events = oneFingerSwipe, expectedState = NotStarted) } private fun assertStateAfterEvents(events: List<MotionEvent>, expectedState: GestureState) { Loading packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizer.kt +7 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,13 @@ class BackGestureRecognizer(private val gestureDistanceThresholdPx: Int) : Gestu } override fun accept(event: MotionEvent) { if (!isThreeFingerTouchpadSwipe(event)) return if (!isMultifingerTouchpadSwipe(event)) return if (!isThreeFingerTouchpadSwipe(event)) { if (event.actionMasked == MotionEvent.ACTION_UP) { gestureStateChangedCallback(GestureState.Error) } return } val gestureState = distanceTracker.processEvent(event) updateGestureState( gestureStateChangedCallback, Loading packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureRecognizer.kt +5 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,11 @@ private fun isNFingerTouchpadSwipe(event: MotionEvent, fingerCount: Int): Boolea event.getAxisValue(MotionEvent.AXIS_GESTURE_SWIPE_FINGER_COUNT) == fingerCount.toFloat() } fun isMultifingerTouchpadSwipe(event: MotionEvent): Boolean { return event.classification == MotionEvent.CLASSIFICATION_MULTI_FINGER_SWIPE || event.classification == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE } fun isTwoFingerSwipe(event: MotionEvent): Boolean { return event.classification == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE } packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizer.kt +7 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,13 @@ class HomeGestureRecognizer( } override fun accept(event: MotionEvent) { if (!isThreeFingerTouchpadSwipe(event)) return if (!isMultifingerTouchpadSwipe(event)) return if (!isThreeFingerTouchpadSwipe(event)) { if (event.actionMasked == MotionEvent.ACTION_UP) { gestureStateChangedCallback(GestureState.Error) } return } val gestureState = distanceTracker.processEvent(event) velocityTracker.accept(event) updateGestureState( Loading packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizer.kt +7 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,13 @@ class RecentAppsGestureRecognizer( } override fun accept(event: MotionEvent) { if (!isThreeFingerTouchpadSwipe(event)) return if (!isMultifingerTouchpadSwipe(event)) return if (!isThreeFingerTouchpadSwipe(event)) { if (event.actionMasked == MotionEvent.ACTION_UP) { gestureStateChangedCallback(GestureState.Error) } return } val gestureState = distanceTracker.processEvent(event) velocityTracker.accept(event) Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/ThreeFingerGestureRecognizerTest.kt +31 −4 Original line number Diff line number Diff line Loading @@ -83,13 +83,40 @@ class ThreeFingerGestureRecognizerTest( } @Test fun doesntTriggerGestureFinished_onTwoFingersSwipe() { assertStateAfterEvents(events = TwoFingerGesture.swipeRight(), expectedState = NotStarted) fun triggersGestureError_onTwoFingersSwipe() { assertStateAfterEvents(events = TwoFingerGesture.swipeRight(), expectedState = Error) } @Test fun doesntTriggerGestureFinished_onFourFingersSwipe() { assertStateAfterEvents(events = FourFingerGesture.swipeRight(), expectedState = NotStarted) fun doesntTriggerGestureError_TwoFingerSwipeInProgress() { assertStateAfterEvents( events = TwoFingerGesture.eventsForGestureInProgress { move(deltaX = SWIPE_DISTANCE) }, expectedState = NotStarted, ) } @Test fun triggersGestureError_onFourFingersSwipe() { assertStateAfterEvents(events = FourFingerGesture.swipeRight(), expectedState = Error) } @Test fun doesntTriggerGestureError_FourFingerSwipeInProgress() { assertStateAfterEvents( events = FourFingerGesture.eventsForGestureInProgress { move(deltaX = SWIPE_DISTANCE) }, expectedState = NotStarted, ) } @Test fun ignoresOneFingerSwipes() { val oneFingerSwipe = listOf( touchpadEvent(MotionEvent.ACTION_DOWN, 50f, 50f), touchpadEvent(MotionEvent.ACTION_MOVE, 55f, 55f), touchpadEvent(MotionEvent.ACTION_UP, 60f, 60f), ) assertStateAfterEvents(events = oneFingerSwipe, expectedState = NotStarted) } private fun assertStateAfterEvents(events: List<MotionEvent>, expectedState: GestureState) { Loading
packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/BackGestureRecognizer.kt +7 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,13 @@ class BackGestureRecognizer(private val gestureDistanceThresholdPx: Int) : Gestu } override fun accept(event: MotionEvent) { if (!isThreeFingerTouchpadSwipe(event)) return if (!isMultifingerTouchpadSwipe(event)) return if (!isThreeFingerTouchpadSwipe(event)) { if (event.actionMasked == MotionEvent.ACTION_UP) { gestureStateChangedCallback(GestureState.Error) } return } val gestureState = distanceTracker.processEvent(event) updateGestureState( gestureStateChangedCallback, Loading
packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureRecognizer.kt +5 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,11 @@ private fun isNFingerTouchpadSwipe(event: MotionEvent, fingerCount: Int): Boolea event.getAxisValue(MotionEvent.AXIS_GESTURE_SWIPE_FINGER_COUNT) == fingerCount.toFloat() } fun isMultifingerTouchpadSwipe(event: MotionEvent): Boolean { return event.classification == MotionEvent.CLASSIFICATION_MULTI_FINGER_SWIPE || event.classification == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE } fun isTwoFingerSwipe(event: MotionEvent): Boolean { return event.classification == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE }
packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizer.kt +7 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,13 @@ class HomeGestureRecognizer( } override fun accept(event: MotionEvent) { if (!isThreeFingerTouchpadSwipe(event)) return if (!isMultifingerTouchpadSwipe(event)) return if (!isThreeFingerTouchpadSwipe(event)) { if (event.actionMasked == MotionEvent.ACTION_UP) { gestureStateChangedCallback(GestureState.Error) } return } val gestureState = distanceTracker.processEvent(event) velocityTracker.accept(event) updateGestureState( Loading
packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizer.kt +7 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,13 @@ class RecentAppsGestureRecognizer( } override fun accept(event: MotionEvent) { if (!isThreeFingerTouchpadSwipe(event)) return if (!isMultifingerTouchpadSwipe(event)) return if (!isThreeFingerTouchpadSwipe(event)) { if (event.actionMasked == MotionEvent.ACTION_UP) { gestureStateChangedCallback(GestureState.Error) } return } val gestureState = distanceTracker.processEvent(event) velocityTracker.accept(event) Loading