Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DragToBubblesZoneChangeListener.kt +8 −5 Original line number Diff line number Diff line Loading @@ -44,16 +44,19 @@ class DragToBubblesZoneChangeListener( from: DragZone?, to: DragZone?, ) { val updateLocation = to.toBubbleBarLocation() updateBubbleBarLocation(updateLocation) lastUpdateLocation = updateLocation processLocationUpdate(to.toBubbleBarLocation()) } override fun onDragEnded(zone: DragZone?) { updateBubbleBarLocation(updateLocation = null) processLocationUpdate(updateLocation = null) } private fun processLocationUpdate(updateLocation: BubbleBarLocation?) { actOnLocationUpdate(updateLocation) lastUpdateLocation = updateLocation } fun updateBubbleBarLocation(updateLocation: BubbleBarLocation?) { private fun actOnLocationUpdate(updateLocation: BubbleBarLocation?) { val updatedBefore = lastUpdateLocation != null val originalLocation = callback.getStartingBubbleBarLocation() val isLocationUpdated = isDifferentSides(lastUpdateLocation, updateLocation, isRtl) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/DragToBubblesZoneChangeListenerTest.kt +19 −0 Original line number Diff line number Diff line Loading @@ -361,4 +361,23 @@ class DragToBubblesZoneChangeListenerTest { // Then animate should NOT be called verify(mockCallback, never()).animateBubbleBarLocation(any()) } @Test fun onDragZoneChanged_dragToSameLocationTwice_onDragEnteredLocationCalledOnSecondDrag() { // // Given has bubbles, starting on LEFT setUpListener(hasBubbles = false, startingLocation = BubbleBarLocation.LEFT) // First drag to the left zone listener.onDragZoneChanged(draggedObject, null, leftZone) listener.onDragEnded(leftZone) verify(mockCallback).onDragEnteredLocation(BubbleBarLocation.LEFT) clearInvocations(mockCallback) // Reset mock to clear interactions for the next assertion // Second drag to the same left zone listener.onDragZoneChanged(draggedObject, null, leftZone) listener.onDragEnded(leftZone) // Verify onDragEnteredLocation is called again for the same location verify(mockCallback).onDragEnteredLocation(BubbleBarLocation.LEFT) } } Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/DragToBubblesZoneChangeListener.kt +8 −5 Original line number Diff line number Diff line Loading @@ -44,16 +44,19 @@ class DragToBubblesZoneChangeListener( from: DragZone?, to: DragZone?, ) { val updateLocation = to.toBubbleBarLocation() updateBubbleBarLocation(updateLocation) lastUpdateLocation = updateLocation processLocationUpdate(to.toBubbleBarLocation()) } override fun onDragEnded(zone: DragZone?) { updateBubbleBarLocation(updateLocation = null) processLocationUpdate(updateLocation = null) } private fun processLocationUpdate(updateLocation: BubbleBarLocation?) { actOnLocationUpdate(updateLocation) lastUpdateLocation = updateLocation } fun updateBubbleBarLocation(updateLocation: BubbleBarLocation?) { private fun actOnLocationUpdate(updateLocation: BubbleBarLocation?) { val updatedBefore = lastUpdateLocation != null val originalLocation = callback.getStartingBubbleBarLocation() val isLocationUpdated = isDifferentSides(lastUpdateLocation, updateLocation, isRtl) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/DragToBubblesZoneChangeListenerTest.kt +19 −0 Original line number Diff line number Diff line Loading @@ -361,4 +361,23 @@ class DragToBubblesZoneChangeListenerTest { // Then animate should NOT be called verify(mockCallback, never()).animateBubbleBarLocation(any()) } @Test fun onDragZoneChanged_dragToSameLocationTwice_onDragEnteredLocationCalledOnSecondDrag() { // // Given has bubbles, starting on LEFT setUpListener(hasBubbles = false, startingLocation = BubbleBarLocation.LEFT) // First drag to the left zone listener.onDragZoneChanged(draggedObject, null, leftZone) listener.onDragEnded(leftZone) verify(mockCallback).onDragEnteredLocation(BubbleBarLocation.LEFT) clearInvocations(mockCallback) // Reset mock to clear interactions for the next assertion // Second drag to the same left zone listener.onDragZoneChanged(draggedObject, null, leftZone) listener.onDragEnded(leftZone) // Verify onDragEnteredLocation is called again for the same location verify(mockCallback).onDragEnteredLocation(BubbleBarLocation.LEFT) } }