Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerViewTest.kt +2 −93 Original line number Diff line number Diff line Loading @@ -19,15 +19,12 @@ package com.android.wm.shell.bubbles.bar import android.app.ActivityManager import android.content.Context import android.content.pm.LauncherApps import android.graphics.PointF import android.os.Handler import android.os.UserManager import android.view.IWindowManager import android.view.LayoutInflater import android.view.MotionEvent import android.view.View import android.view.WindowManager import androidx.core.animation.AnimatorTestRule import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading @@ -51,7 +48,6 @@ import com.android.wm.shell.bubbles.BubbleTaskViewFactory import com.android.wm.shell.bubbles.Bubbles.SysuiProxy import com.android.wm.shell.bubbles.FakeBubbleFactory import com.android.wm.shell.bubbles.UiEventSubject.Companion.assertThat import com.android.wm.shell.bubbles.animation.AnimatableScaleMatrix import com.android.wm.shell.bubbles.properties.BubbleProperties import com.android.wm.shell.bubbles.storage.BubblePersistentRepository import com.android.wm.shell.common.DisplayController Loading @@ -61,7 +57,6 @@ import com.android.wm.shell.common.ShellExecutor import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.common.TaskStackListenerImpl import com.android.wm.shell.shared.TransactionPool import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils import com.android.wm.shell.shared.bubbles.BubbleBarLocation import com.android.wm.shell.sysui.ShellCommandHandler import com.android.wm.shell.sysui.ShellController Loading @@ -71,10 +66,8 @@ import com.android.wm.shell.taskview.TaskViewTaskController import com.android.wm.shell.taskview.TaskViewTransitions import com.android.wm.shell.transition.Transitions import com.google.common.truth.Truth.assertThat import org.junit.After import java.util.Collections import org.junit.Before import org.junit.ClassRule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.mock Loading @@ -86,28 +79,18 @@ import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) class BubbleBarLayerViewTest { companion object { @JvmField @ClassRule val animatorTestRule: AnimatorTestRule = AnimatorTestRule() } private val context = ApplicationProvider.getApplicationContext<Context>() private lateinit var bubbleBarLayerView: BubbleBarLayerView private lateinit var uiEventLoggerFake: UiEventLoggerFake private lateinit var bubbleController: BubbleController private lateinit var bubblePositioner: BubblePositioner private lateinit var bubble: Bubble @Before fun setUp() { ProtoLog.REQUIRE_PROTOLOGTOOL = false ProtoLog.init() PhysicsAnimatorTestUtils.prepareForTest() uiEventLoggerFake = UiEventLoggerFake() val bubbleLogger = BubbleLogger(uiEventLoggerFake) Loading @@ -117,7 +100,7 @@ class BubbleBarLayerViewTest { val windowManager = context.getSystemService(WindowManager::class.java) bubblePositioner = BubblePositioner(context, windowManager) val bubblePositioner = BubblePositioner(context, windowManager) bubblePositioner.setShowingInBubbleBar(true) val bubbleData = Loading @@ -130,7 +113,7 @@ class BubbleBarLayerViewTest { bgExecutor, ) bubbleController = val bubbleController = createBubbleController( bubbleData, windowManager, Loading Loading @@ -168,11 +151,6 @@ class BubbleBarLayerViewTest { bubble = FakeBubbleFactory.createChatBubbleWithViewInfo(context, viewInfo = viewInfo) } @After fun tearDown() { PhysicsAnimatorTestUtils.tearDown() } private fun createBubbleController( bubbleData: BubbleData, windowManager: WindowManager?, Loading Loading @@ -246,70 +224,6 @@ class BubbleBarLayerViewTest { assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble) } @Test fun testEventLogging_dragExpandedViewLeft() { bubblePositioner.bubbleBarLocation = BubbleBarLocation.RIGHT getInstrumentation().runOnMainSync { bubbleBarLayerView.showExpandedView(bubble) } waitForExpandedViewAnimation() val handleView = bubbleBarLayerView.findViewById<View>(R.id.bubble_bar_handle_view) assertThat(handleView).isNotNull() // Drag from right to left handleView.dispatchTouchEvent(0L, MotionEvent.ACTION_DOWN, rightEdge()) handleView.dispatchTouchEvent(10L, MotionEvent.ACTION_MOVE, leftEdge()) handleView.dispatchTouchEvent(20L, MotionEvent.ACTION_UP, leftEdge()) assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) assertThat(uiEventLoggerFake.logs[0].eventId) .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_DRAG_EXP_VIEW.id) assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble) } @Test fun testEventLogging_dragExpandedViewRight() { bubblePositioner.bubbleBarLocation = BubbleBarLocation.LEFT getInstrumentation().runOnMainSync { bubbleBarLayerView.showExpandedView(bubble) } waitForExpandedViewAnimation() val handleView = bubbleBarLayerView.findViewById<View>(R.id.bubble_bar_handle_view) assertThat(handleView).isNotNull() // Drag from left to right handleView.dispatchTouchEvent(0L, MotionEvent.ACTION_DOWN, leftEdge()) handleView.dispatchTouchEvent(10L, MotionEvent.ACTION_MOVE, rightEdge()) handleView.dispatchTouchEvent(20L, MotionEvent.ACTION_UP, rightEdge()) assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) assertThat(uiEventLoggerFake.logs[0].eventId) .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_EXP_VIEW.id) assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble) } private fun leftEdge(): PointF { val screenSize = bubblePositioner.availableRect return PointF(screenSize.left.toFloat(), screenSize.height() / 2f) } private fun rightEdge(): PointF { val screenSize = bubblePositioner.availableRect return PointF(screenSize.right.toFloat(), screenSize.height() / 2f) } private fun waitForExpandedViewAnimation() { // wait for idle to allow the animation to start getInstrumentation().waitForIdleSync() getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(200) } PhysicsAnimatorTestUtils.blockUntilAnimationsEnd( AnimatableScaleMatrix.SCALE_X, AnimatableScaleMatrix.SCALE_Y) } private inner class FakeBubbleTaskViewFactory(private val mainExecutor: ShellExecutor) : BubbleTaskViewFactory { override fun create(): BubbleTaskView { Loading Loading @@ -376,9 +290,4 @@ class BubbleBarLayerViewTest { } } } private fun View.dispatchTouchEvent(eventTime: Long, action: Int, point: PointF) { val event = MotionEvent.obtain(0L, eventTime, action, point.x, point.y, 0) getInstrumentation().runOnMainSync { dispatchTouchEvent(event) } } } libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleExpandedViewPinControllerTest.kt +3 −24 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ class BubbleExpandedViewPinControllerTest { @Before fun setUp() { ProtoLog.REQUIRE_PROTOLOGTOOL = false ProtoLog.init() container = FrameLayout(context) val windowManager = context.getSystemService(WindowManager::class.java) positioner = BubblePositioner(context, windowManager) Loading @@ -86,7 +85,7 @@ class BubbleExpandedViewPinControllerTest { isSmallTablet = false, isLandscape = true, isRtl = false, insets = Insets.of(10, 20, 30, 40), insets = Insets.of(10, 20, 30, 40) ) positioner.update(deviceConfig) positioner.bubbleBarTopOnScreen = Loading Loading @@ -408,26 +407,12 @@ class BubbleExpandedViewPinControllerTest { assertThat(testListener.locationReleases).containsExactly(RIGHT) } /** Send drag start event when on left */ @Test fun start_onLeft_sendStartEventOnLeft() { getInstrumentation().runOnMainSync { controller.onDragStart(initialLocationOnLeft = true) } assertThat(testListener.locationStart).containsExactly(LEFT) } /** Send drag start event when on right */ @Test fun start_onRight_sendStartEventOnRight() { getInstrumentation().runOnMainSync { controller.onDragStart(initialLocationOnLeft = false) } assertThat(testListener.locationStart).containsExactly(RIGHT) } private fun getExpectedDropTargetBoundsOnLeft(): Rect = Rect().also { positioner.getBubbleBarExpandedViewBounds( true /* onLeft */, false /* isOverflowExpanded */, it, it ) } Loading @@ -436,7 +421,7 @@ class BubbleExpandedViewPinControllerTest { positioner.getBubbleBarExpandedViewBounds( false /* onLeft */, false /* isOverflowExpanded */, it, it ) } Loading @@ -461,14 +446,8 @@ class BubbleExpandedViewPinControllerTest { } internal class TestLocationChangeListener : BaseBubblePinController.LocationChangeListener { val locationStart = mutableListOf<BubbleBarLocation>() val locationChanges = mutableListOf<BubbleBarLocation>() val locationReleases = mutableListOf<BubbleBarLocation>() override fun onStart(location: BubbleBarLocation) { locationStart.add(location) } override fun onChange(location: BubbleBarLocation) { locationChanges.add(location) } Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/animation/PhysicsAnimatorTestUtils.kt +8 −12 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.os.Looper import android.util.ArrayMap import androidx.dynamicanimation.animation.FloatPropertyCompat import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils.prepareForTest import java.util.ArrayDeque import java.util.* import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit import kotlin.collections.ArrayList Loading Loading @@ -74,16 +74,13 @@ object PhysicsAnimatorTestUtils { @JvmStatic fun tearDown() { if (Looper.myLooper() == animationThreadHandler.looper) { animatorTestHelpers.keys.forEach { it.cancel() } } else { val latch = CountDownLatch(1) animationThreadHandler.post { animatorTestHelpers.keys.forEach { it.cancel() } latch.countDown() } latch.await(5, TimeUnit.SECONDS) } latch.await() animatorTestHelpers.clear() animators.clear() Loading Loading @@ -351,9 +348,8 @@ object PhysicsAnimatorTestUtils { * Returns all of the values that have ever been reported to update listeners, per property. */ @Suppress("UNCHECKED_CAST") fun <T : Any> getAnimationUpdateFrames( animator: PhysicsAnimator<T> ): UpdateFramesPerProperty<T> { fun <T : Any> getAnimationUpdateFrames(animator: PhysicsAnimator<T>): UpdateFramesPerProperty<T> { return animatorTestHelpers[animator]?.getUpdates() as UpdateFramesPerProperty<T> } Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/BaseBubblePinController.kt +0 −5 Original line number Diff line number Diff line Loading @@ -56,7 +56,6 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi onLeft = initialLocationOnLeft screenCenterX = screenSizeProvider.invoke().x / 2 dismissZone = getExclusionRect() listener?.onStart(if (initialLocationOnLeft) LEFT else RIGHT) } /** View has moved to [x] and [y] screen coordinates */ Loading Loading @@ -110,7 +109,6 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi /** Get width for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectWidth(): Float /** Get height for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectHeight(): Float Loading Loading @@ -186,9 +184,6 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi /** Receive updates on location changes */ interface LocationChangeListener { /** Bubble bar dragging has started. Includes the initial location of the bar */ fun onStart(location: BubbleBarLocation) {} /** * Bubble bar has been dragged to a new [BubbleBarLocation]. And the drag is still in * progress. Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java +17 −39 Original line number Diff line number Diff line Loading @@ -124,7 +124,18 @@ public class BubbleBarLayerView extends FrameLayout mBubbleExpandedViewPinController = new BubbleExpandedViewPinController( context, this, mPositioner); mBubbleExpandedViewPinController.setListener(new LocationChangeListener()); mBubbleExpandedViewPinController.setListener( new BaseBubblePinController.LocationChangeListener() { @Override public void onChange(@NonNull BubbleBarLocation bubbleBarLocation) { mBubbleController.animateBubbleBarLocation(bubbleBarLocation); } @Override public void onRelease(@NonNull BubbleBarLocation location) { mBubbleController.setBubbleBarLocation(location); } }); setOnClickListener(view -> hideModalOrCollapse()); } Loading Loading @@ -227,7 +238,11 @@ public class BubbleBarLayerView extends FrameLayout DragListener dragListener = inDismiss -> { if (inDismiss && mExpandedBubble != null) { mBubbleController.dismissBubble(mExpandedBubble.getKey(), DISMISS_USER_GESTURE); logBubbleEvent(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_EXP_VIEW); if (mExpandedBubble instanceof Bubble) { // Only a bubble can be dragged to dismiss mBubbleLogger.log((Bubble) mExpandedBubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_EXP_VIEW); } } }; mDragController = new BubbleBarExpandedViewDragController( Loading Loading @@ -408,47 +423,10 @@ public class BubbleBarLayerView extends FrameLayout } } /** * Log the event only if {@link #mExpandedBubble} is a {@link Bubble}. * <p> * Skips logging if it is {@link BubbleOverflow}. */ private void logBubbleEvent(BubbleLogger.Event event) { if (mExpandedBubble != null && mExpandedBubble instanceof Bubble bubble) { mBubbleLogger.log(bubble, event); } } @Nullable @VisibleForTesting public BubbleBarExpandedViewDragController getDragController() { return mDragController; } private class LocationChangeListener implements BaseBubblePinController.LocationChangeListener { private BubbleBarLocation mInitialLocation; @Override public void onStart(@NonNull BubbleBarLocation location) { mInitialLocation = location; } @Override public void onChange(@NonNull BubbleBarLocation bubbleBarLocation) { mBubbleController.animateBubbleBarLocation(bubbleBarLocation); } @Override public void onRelease(@NonNull BubbleBarLocation location) { mBubbleController.setBubbleBarLocation(location); if (location != mInitialLocation) { BubbleLogger.Event event = location.isOnLeft(isLayoutRtl()) ? BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_DRAG_EXP_VIEW : BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_EXP_VIEW; logBubbleEvent(event); } } } } Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerViewTest.kt +2 −93 Original line number Diff line number Diff line Loading @@ -19,15 +19,12 @@ package com.android.wm.shell.bubbles.bar import android.app.ActivityManager import android.content.Context import android.content.pm.LauncherApps import android.graphics.PointF import android.os.Handler import android.os.UserManager import android.view.IWindowManager import android.view.LayoutInflater import android.view.MotionEvent import android.view.View import android.view.WindowManager import androidx.core.animation.AnimatorTestRule import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading @@ -51,7 +48,6 @@ import com.android.wm.shell.bubbles.BubbleTaskViewFactory import com.android.wm.shell.bubbles.Bubbles.SysuiProxy import com.android.wm.shell.bubbles.FakeBubbleFactory import com.android.wm.shell.bubbles.UiEventSubject.Companion.assertThat import com.android.wm.shell.bubbles.animation.AnimatableScaleMatrix import com.android.wm.shell.bubbles.properties.BubbleProperties import com.android.wm.shell.bubbles.storage.BubblePersistentRepository import com.android.wm.shell.common.DisplayController Loading @@ -61,7 +57,6 @@ import com.android.wm.shell.common.ShellExecutor import com.android.wm.shell.common.SyncTransactionQueue import com.android.wm.shell.common.TaskStackListenerImpl import com.android.wm.shell.shared.TransactionPool import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils import com.android.wm.shell.shared.bubbles.BubbleBarLocation import com.android.wm.shell.sysui.ShellCommandHandler import com.android.wm.shell.sysui.ShellController Loading @@ -71,10 +66,8 @@ import com.android.wm.shell.taskview.TaskViewTaskController import com.android.wm.shell.taskview.TaskViewTransitions import com.android.wm.shell.transition.Transitions import com.google.common.truth.Truth.assertThat import org.junit.After import java.util.Collections import org.junit.Before import org.junit.ClassRule import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.mock Loading @@ -86,28 +79,18 @@ import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) class BubbleBarLayerViewTest { companion object { @JvmField @ClassRule val animatorTestRule: AnimatorTestRule = AnimatorTestRule() } private val context = ApplicationProvider.getApplicationContext<Context>() private lateinit var bubbleBarLayerView: BubbleBarLayerView private lateinit var uiEventLoggerFake: UiEventLoggerFake private lateinit var bubbleController: BubbleController private lateinit var bubblePositioner: BubblePositioner private lateinit var bubble: Bubble @Before fun setUp() { ProtoLog.REQUIRE_PROTOLOGTOOL = false ProtoLog.init() PhysicsAnimatorTestUtils.prepareForTest() uiEventLoggerFake = UiEventLoggerFake() val bubbleLogger = BubbleLogger(uiEventLoggerFake) Loading @@ -117,7 +100,7 @@ class BubbleBarLayerViewTest { val windowManager = context.getSystemService(WindowManager::class.java) bubblePositioner = BubblePositioner(context, windowManager) val bubblePositioner = BubblePositioner(context, windowManager) bubblePositioner.setShowingInBubbleBar(true) val bubbleData = Loading @@ -130,7 +113,7 @@ class BubbleBarLayerViewTest { bgExecutor, ) bubbleController = val bubbleController = createBubbleController( bubbleData, windowManager, Loading Loading @@ -168,11 +151,6 @@ class BubbleBarLayerViewTest { bubble = FakeBubbleFactory.createChatBubbleWithViewInfo(context, viewInfo = viewInfo) } @After fun tearDown() { PhysicsAnimatorTestUtils.tearDown() } private fun createBubbleController( bubbleData: BubbleData, windowManager: WindowManager?, Loading Loading @@ -246,70 +224,6 @@ class BubbleBarLayerViewTest { assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble) } @Test fun testEventLogging_dragExpandedViewLeft() { bubblePositioner.bubbleBarLocation = BubbleBarLocation.RIGHT getInstrumentation().runOnMainSync { bubbleBarLayerView.showExpandedView(bubble) } waitForExpandedViewAnimation() val handleView = bubbleBarLayerView.findViewById<View>(R.id.bubble_bar_handle_view) assertThat(handleView).isNotNull() // Drag from right to left handleView.dispatchTouchEvent(0L, MotionEvent.ACTION_DOWN, rightEdge()) handleView.dispatchTouchEvent(10L, MotionEvent.ACTION_MOVE, leftEdge()) handleView.dispatchTouchEvent(20L, MotionEvent.ACTION_UP, leftEdge()) assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) assertThat(uiEventLoggerFake.logs[0].eventId) .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_DRAG_EXP_VIEW.id) assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble) } @Test fun testEventLogging_dragExpandedViewRight() { bubblePositioner.bubbleBarLocation = BubbleBarLocation.LEFT getInstrumentation().runOnMainSync { bubbleBarLayerView.showExpandedView(bubble) } waitForExpandedViewAnimation() val handleView = bubbleBarLayerView.findViewById<View>(R.id.bubble_bar_handle_view) assertThat(handleView).isNotNull() // Drag from left to right handleView.dispatchTouchEvent(0L, MotionEvent.ACTION_DOWN, leftEdge()) handleView.dispatchTouchEvent(10L, MotionEvent.ACTION_MOVE, rightEdge()) handleView.dispatchTouchEvent(20L, MotionEvent.ACTION_UP, rightEdge()) assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) assertThat(uiEventLoggerFake.logs[0].eventId) .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_EXP_VIEW.id) assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble) } private fun leftEdge(): PointF { val screenSize = bubblePositioner.availableRect return PointF(screenSize.left.toFloat(), screenSize.height() / 2f) } private fun rightEdge(): PointF { val screenSize = bubblePositioner.availableRect return PointF(screenSize.right.toFloat(), screenSize.height() / 2f) } private fun waitForExpandedViewAnimation() { // wait for idle to allow the animation to start getInstrumentation().waitForIdleSync() getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(200) } PhysicsAnimatorTestUtils.blockUntilAnimationsEnd( AnimatableScaleMatrix.SCALE_X, AnimatableScaleMatrix.SCALE_Y) } private inner class FakeBubbleTaskViewFactory(private val mainExecutor: ShellExecutor) : BubbleTaskViewFactory { override fun create(): BubbleTaskView { Loading Loading @@ -376,9 +290,4 @@ class BubbleBarLayerViewTest { } } } private fun View.dispatchTouchEvent(eventTime: Long, action: Int, point: PointF) { val event = MotionEvent.obtain(0L, eventTime, action, point.x, point.y, 0) getInstrumentation().runOnMainSync { dispatchTouchEvent(event) } } }
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleExpandedViewPinControllerTest.kt +3 −24 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ class BubbleExpandedViewPinControllerTest { @Before fun setUp() { ProtoLog.REQUIRE_PROTOLOGTOOL = false ProtoLog.init() container = FrameLayout(context) val windowManager = context.getSystemService(WindowManager::class.java) positioner = BubblePositioner(context, windowManager) Loading @@ -86,7 +85,7 @@ class BubbleExpandedViewPinControllerTest { isSmallTablet = false, isLandscape = true, isRtl = false, insets = Insets.of(10, 20, 30, 40), insets = Insets.of(10, 20, 30, 40) ) positioner.update(deviceConfig) positioner.bubbleBarTopOnScreen = Loading Loading @@ -408,26 +407,12 @@ class BubbleExpandedViewPinControllerTest { assertThat(testListener.locationReleases).containsExactly(RIGHT) } /** Send drag start event when on left */ @Test fun start_onLeft_sendStartEventOnLeft() { getInstrumentation().runOnMainSync { controller.onDragStart(initialLocationOnLeft = true) } assertThat(testListener.locationStart).containsExactly(LEFT) } /** Send drag start event when on right */ @Test fun start_onRight_sendStartEventOnRight() { getInstrumentation().runOnMainSync { controller.onDragStart(initialLocationOnLeft = false) } assertThat(testListener.locationStart).containsExactly(RIGHT) } private fun getExpectedDropTargetBoundsOnLeft(): Rect = Rect().also { positioner.getBubbleBarExpandedViewBounds( true /* onLeft */, false /* isOverflowExpanded */, it, it ) } Loading @@ -436,7 +421,7 @@ class BubbleExpandedViewPinControllerTest { positioner.getBubbleBarExpandedViewBounds( false /* onLeft */, false /* isOverflowExpanded */, it, it ) } Loading @@ -461,14 +446,8 @@ class BubbleExpandedViewPinControllerTest { } internal class TestLocationChangeListener : BaseBubblePinController.LocationChangeListener { val locationStart = mutableListOf<BubbleBarLocation>() val locationChanges = mutableListOf<BubbleBarLocation>() val locationReleases = mutableListOf<BubbleBarLocation>() override fun onStart(location: BubbleBarLocation) { locationStart.add(location) } override fun onChange(location: BubbleBarLocation) { locationChanges.add(location) } Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/animation/PhysicsAnimatorTestUtils.kt +8 −12 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.os.Looper import android.util.ArrayMap import androidx.dynamicanimation.animation.FloatPropertyCompat import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils.prepareForTest import java.util.ArrayDeque import java.util.* import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit import kotlin.collections.ArrayList Loading Loading @@ -74,16 +74,13 @@ object PhysicsAnimatorTestUtils { @JvmStatic fun tearDown() { if (Looper.myLooper() == animationThreadHandler.looper) { animatorTestHelpers.keys.forEach { it.cancel() } } else { val latch = CountDownLatch(1) animationThreadHandler.post { animatorTestHelpers.keys.forEach { it.cancel() } latch.countDown() } latch.await(5, TimeUnit.SECONDS) } latch.await() animatorTestHelpers.clear() animators.clear() Loading Loading @@ -351,9 +348,8 @@ object PhysicsAnimatorTestUtils { * Returns all of the values that have ever been reported to update listeners, per property. */ @Suppress("UNCHECKED_CAST") fun <T : Any> getAnimationUpdateFrames( animator: PhysicsAnimator<T> ): UpdateFramesPerProperty<T> { fun <T : Any> getAnimationUpdateFrames(animator: PhysicsAnimator<T>): UpdateFramesPerProperty<T> { return animatorTestHelpers[animator]?.getUpdates() as UpdateFramesPerProperty<T> } Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/BaseBubblePinController.kt +0 −5 Original line number Diff line number Diff line Loading @@ -56,7 +56,6 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi onLeft = initialLocationOnLeft screenCenterX = screenSizeProvider.invoke().x / 2 dismissZone = getExclusionRect() listener?.onStart(if (initialLocationOnLeft) LEFT else RIGHT) } /** View has moved to [x] and [y] screen coordinates */ Loading Loading @@ -110,7 +109,6 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi /** Get width for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectWidth(): Float /** Get height for exclusion rect where dismiss takes over drag */ protected abstract fun getExclusionRectHeight(): Float Loading Loading @@ -186,9 +184,6 @@ abstract class BaseBubblePinController(private val screenSizeProvider: () -> Poi /** Receive updates on location changes */ interface LocationChangeListener { /** Bubble bar dragging has started. Includes the initial location of the bar */ fun onStart(location: BubbleBarLocation) {} /** * Bubble bar has been dragged to a new [BubbleBarLocation]. And the drag is still in * progress. Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarLayerView.java +17 −39 Original line number Diff line number Diff line Loading @@ -124,7 +124,18 @@ public class BubbleBarLayerView extends FrameLayout mBubbleExpandedViewPinController = new BubbleExpandedViewPinController( context, this, mPositioner); mBubbleExpandedViewPinController.setListener(new LocationChangeListener()); mBubbleExpandedViewPinController.setListener( new BaseBubblePinController.LocationChangeListener() { @Override public void onChange(@NonNull BubbleBarLocation bubbleBarLocation) { mBubbleController.animateBubbleBarLocation(bubbleBarLocation); } @Override public void onRelease(@NonNull BubbleBarLocation location) { mBubbleController.setBubbleBarLocation(location); } }); setOnClickListener(view -> hideModalOrCollapse()); } Loading Loading @@ -227,7 +238,11 @@ public class BubbleBarLayerView extends FrameLayout DragListener dragListener = inDismiss -> { if (inDismiss && mExpandedBubble != null) { mBubbleController.dismissBubble(mExpandedBubble.getKey(), DISMISS_USER_GESTURE); logBubbleEvent(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_EXP_VIEW); if (mExpandedBubble instanceof Bubble) { // Only a bubble can be dragged to dismiss mBubbleLogger.log((Bubble) mExpandedBubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_EXP_VIEW); } } }; mDragController = new BubbleBarExpandedViewDragController( Loading Loading @@ -408,47 +423,10 @@ public class BubbleBarLayerView extends FrameLayout } } /** * Log the event only if {@link #mExpandedBubble} is a {@link Bubble}. * <p> * Skips logging if it is {@link BubbleOverflow}. */ private void logBubbleEvent(BubbleLogger.Event event) { if (mExpandedBubble != null && mExpandedBubble instanceof Bubble bubble) { mBubbleLogger.log(bubble, event); } } @Nullable @VisibleForTesting public BubbleBarExpandedViewDragController getDragController() { return mDragController; } private class LocationChangeListener implements BaseBubblePinController.LocationChangeListener { private BubbleBarLocation mInitialLocation; @Override public void onStart(@NonNull BubbleBarLocation location) { mInitialLocation = location; } @Override public void onChange(@NonNull BubbleBarLocation bubbleBarLocation) { mBubbleController.animateBubbleBarLocation(bubbleBarLocation); } @Override public void onRelease(@NonNull BubbleBarLocation location) { mBubbleController.setBubbleBarLocation(location); if (location != mInitialLocation) { BubbleLogger.Event event = location.isOnLeft(isLayoutRtl()) ? BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_DRAG_EXP_VIEW : BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_EXP_VIEW; logBubbleEvent(event); } } } }