Loading libs/WindowManager/Shell/multivalentTests/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ android_robolectric_test { "truth", "flag-junit-base", "flag-junit", "testables", ], auto_gen_config: true, } Loading @@ -77,6 +78,7 @@ android_test { "truth", "platform-test-annotations", "platform-test-rules", "testables", ], libs: [ "android.test.base.stubs.system", Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelperTest.kt +65 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.wm.shell.bubbles.bar import android.animation.AnimatorTestRule import android.app.ActivityManager import android.content.Context import android.graphics.Insets import android.graphics.Rect Loading @@ -23,7 +25,6 @@ import android.view.View import android.view.ViewGroup import android.view.WindowManager import android.widget.FrameLayout import androidx.core.animation.AnimatorTestRule import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading @@ -36,27 +37,34 @@ import com.android.wm.shell.bubbles.BubbleExpandedViewManager import com.android.wm.shell.bubbles.BubbleLogger import com.android.wm.shell.bubbles.BubbleOverflow import com.android.wm.shell.bubbles.BubblePositioner import com.android.wm.shell.bubbles.BubbleTaskView import com.android.wm.shell.bubbles.DeviceConfig import com.android.wm.shell.bubbles.FakeBubbleExpandedViewManager import com.android.wm.shell.bubbles.FakeBubbleFactory import com.android.wm.shell.bubbles.FakeBubbleTaskViewFactory import com.android.wm.shell.taskview.TaskView import com.android.wm.shell.taskview.TaskViewTaskController import com.google.common.truth.Truth.assertThat import java.util.concurrent.Semaphore import java.util.concurrent.TimeUnit import org.junit.After import org.junit.Before import org.junit.ClassRule import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any import org.mockito.kotlin.clearInvocations import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.whenever /** Tests for [BubbleBarAnimationHelper] */ @SmallTest @RunWith(AndroidJUnit4::class) class BubbleBarAnimationHelperTest { companion object { @JvmField @ClassRule val animatorTestRule: AnimatorTestRule = AnimatorTestRule() @get:Rule val animatorTestRule: AnimatorTestRule = AnimatorTestRule(this) companion object { const val SCREEN_WIDTH = 2000 const val SCREEN_HEIGHT = 1000 } Loading Loading @@ -147,6 +155,26 @@ class BubbleBarAnimationHelperTest { .isEqualTo(fromBubble.bubbleBarExpandedView!!.handleView.handleColor) } @Test fun animateSwitch_bubbleToBubble_updateTaskBounds() { val fromBubble = createBubble("from").initialize(container) val toBubbleTaskController = mock<TaskViewTaskController>() val toBubble = createBubble("to", toBubbleTaskController).initialize(container) getInstrumentation().runOnMainSync { animationHelper.animateSwitch(fromBubble, toBubble) {} // Start the animation, but don't finish animatorTestRule.advanceTimeBy(100) } getInstrumentation().waitForIdleSync() // Clear invocations to ensure that bounds update happens after animation ends clearInvocations(toBubbleTaskController) getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(900) } getInstrumentation().waitForIdleSync() verify(toBubbleTaskController).setWindowBounds(any()) } @Test fun animateSwitch_bubbleToOverflow_oldHiddenNewShown() { val fromBubble = createBubble(key = "from").initialize(container) Loading Loading @@ -193,13 +221,43 @@ class BubbleBarAnimationHelperTest { assertThat(toBubble.bubbleBarExpandedView?.isSurfaceZOrderedOnTop).isFalse() } private fun createBubble(key: String): Bubble { @Test fun animateToRestPosition_updateTaskBounds() { val taskController = mock<TaskViewTaskController>() val bubble = createBubble("key", taskController).initialize(container) getInstrumentation().runOnMainSync { animationHelper.animateExpansion(bubble) {} animatorTestRule.advanceTimeBy(1000) } getInstrumentation().waitForIdleSync() getInstrumentation().runOnMainSync { animationHelper.animateToRestPosition() animatorTestRule.advanceTimeBy(100) } // Clear invocations to ensure that bounds update happens after animation ends clearInvocations(taskController) getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(900) } getInstrumentation().waitForIdleSync() verify(taskController).setWindowBounds(any()) } private fun createBubble( key: String, taskViewTaskController: TaskViewTaskController = mock<TaskViewTaskController>(), ): Bubble { val taskView = TaskView(context, taskViewTaskController) val taskInfo = mock<ActivityManager.RunningTaskInfo>() whenever(taskViewTaskController.taskInfo).thenReturn(taskInfo) val bubbleTaskView = BubbleTaskView(taskView, mainExecutor) val bubbleBarExpandedView = FakeBubbleFactory.createExpandedView( context, bubblePositioner, expandedViewManager, FakeBubbleTaskViewFactory(context, mainExecutor).create(), bubbleTaskView, mainExecutor, bgExecutor, bubbleLogger, Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -463,6 +463,7 @@ public class BubbleBarAnimationHelper { super.onAnimationEnd(animation); bbev.resetPivot(); bbev.setDragging(false); updateExpandedView(bbev); } }); startNewAnimator(animatorSet); Loading Loading
libs/WindowManager/Shell/multivalentTests/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ android_robolectric_test { "truth", "flag-junit-base", "flag-junit", "testables", ], auto_gen_config: true, } Loading @@ -77,6 +78,7 @@ android_test { "truth", "platform-test-annotations", "platform-test-rules", "testables", ], libs: [ "android.test.base.stubs.system", Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelperTest.kt +65 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.wm.shell.bubbles.bar import android.animation.AnimatorTestRule import android.app.ActivityManager import android.content.Context import android.graphics.Insets import android.graphics.Rect Loading @@ -23,7 +25,6 @@ import android.view.View import android.view.ViewGroup import android.view.WindowManager import android.widget.FrameLayout import androidx.core.animation.AnimatorTestRule import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest Loading @@ -36,27 +37,34 @@ import com.android.wm.shell.bubbles.BubbleExpandedViewManager import com.android.wm.shell.bubbles.BubbleLogger import com.android.wm.shell.bubbles.BubbleOverflow import com.android.wm.shell.bubbles.BubblePositioner import com.android.wm.shell.bubbles.BubbleTaskView import com.android.wm.shell.bubbles.DeviceConfig import com.android.wm.shell.bubbles.FakeBubbleExpandedViewManager import com.android.wm.shell.bubbles.FakeBubbleFactory import com.android.wm.shell.bubbles.FakeBubbleTaskViewFactory import com.android.wm.shell.taskview.TaskView import com.android.wm.shell.taskview.TaskViewTaskController import com.google.common.truth.Truth.assertThat import java.util.concurrent.Semaphore import java.util.concurrent.TimeUnit import org.junit.After import org.junit.Before import org.junit.ClassRule import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.any import org.mockito.kotlin.clearInvocations import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.whenever /** Tests for [BubbleBarAnimationHelper] */ @SmallTest @RunWith(AndroidJUnit4::class) class BubbleBarAnimationHelperTest { companion object { @JvmField @ClassRule val animatorTestRule: AnimatorTestRule = AnimatorTestRule() @get:Rule val animatorTestRule: AnimatorTestRule = AnimatorTestRule(this) companion object { const val SCREEN_WIDTH = 2000 const val SCREEN_HEIGHT = 1000 } Loading Loading @@ -147,6 +155,26 @@ class BubbleBarAnimationHelperTest { .isEqualTo(fromBubble.bubbleBarExpandedView!!.handleView.handleColor) } @Test fun animateSwitch_bubbleToBubble_updateTaskBounds() { val fromBubble = createBubble("from").initialize(container) val toBubbleTaskController = mock<TaskViewTaskController>() val toBubble = createBubble("to", toBubbleTaskController).initialize(container) getInstrumentation().runOnMainSync { animationHelper.animateSwitch(fromBubble, toBubble) {} // Start the animation, but don't finish animatorTestRule.advanceTimeBy(100) } getInstrumentation().waitForIdleSync() // Clear invocations to ensure that bounds update happens after animation ends clearInvocations(toBubbleTaskController) getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(900) } getInstrumentation().waitForIdleSync() verify(toBubbleTaskController).setWindowBounds(any()) } @Test fun animateSwitch_bubbleToOverflow_oldHiddenNewShown() { val fromBubble = createBubble(key = "from").initialize(container) Loading Loading @@ -193,13 +221,43 @@ class BubbleBarAnimationHelperTest { assertThat(toBubble.bubbleBarExpandedView?.isSurfaceZOrderedOnTop).isFalse() } private fun createBubble(key: String): Bubble { @Test fun animateToRestPosition_updateTaskBounds() { val taskController = mock<TaskViewTaskController>() val bubble = createBubble("key", taskController).initialize(container) getInstrumentation().runOnMainSync { animationHelper.animateExpansion(bubble) {} animatorTestRule.advanceTimeBy(1000) } getInstrumentation().waitForIdleSync() getInstrumentation().runOnMainSync { animationHelper.animateToRestPosition() animatorTestRule.advanceTimeBy(100) } // Clear invocations to ensure that bounds update happens after animation ends clearInvocations(taskController) getInstrumentation().runOnMainSync { animatorTestRule.advanceTimeBy(900) } getInstrumentation().waitForIdleSync() verify(taskController).setWindowBounds(any()) } private fun createBubble( key: String, taskViewTaskController: TaskViewTaskController = mock<TaskViewTaskController>(), ): Bubble { val taskView = TaskView(context, taskViewTaskController) val taskInfo = mock<ActivityManager.RunningTaskInfo>() whenever(taskViewTaskController.taskInfo).thenReturn(taskInfo) val bubbleTaskView = BubbleTaskView(taskView, mainExecutor) val bubbleBarExpandedView = FakeBubbleFactory.createExpandedView( context, bubblePositioner, expandedViewManager, FakeBubbleTaskViewFactory(context, mainExecutor).create(), bubbleTaskView, mainExecutor, bgExecutor, bubbleLogger, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -463,6 +463,7 @@ public class BubbleBarAnimationHelper { super.onAnimationEnd(animation); bbev.resetPivot(); bbev.setDragging(false); updateExpandedView(bbev); } }); startNewAnimator(animatorSet); Loading