From e18ed7dde77c30e50383e4845e1ed1b7dafd2038 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Wed, 23 Feb 2022 18:50:49 +0100 Subject: [PATCH] Make use of TAPL in quickswitch tests Test: atest FlickerTests:QuickSwitchFromLauncherTest FlickerTests:QuickSwitchBetweenTwoAppsBackTest FlickerTests:QuickSwitchBetweenTwoAppsBackTest Bug: 217379707 Change-Id: I40ff578b7ae26463b1ba6d06e7e15f0910f4b5a3 --- .../QuickSwitchBetweenTwoAppsBackTest.kt | 19 ++++------- .../QuickSwitchBetweenTwoAppsForwardTest.kt | 32 ++++++------------- .../QuickSwitchFromLauncherTest.kt | 21 ++++++------ 3 files changed, 25 insertions(+), 47 deletions(-) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt index f21b1d63d4773..a02508978658e 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt @@ -23,6 +23,7 @@ import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter @@ -66,6 +67,7 @@ import org.junit.runners.Parameterized @Group1 open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestParameter) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val taplInstrumentation = LauncherInstrumentation() private val testApp1 = SimpleAppHelper(instrumentation) private val testApp2 = NonResizeableAppHelper(instrumentation) @@ -81,6 +83,10 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa fun buildFlicker(): FlickerBuilder { return FlickerBuilder(instrumentation).apply { setup { + test { + taplInstrumentation.setExpectedRotation(testSpec.startRotation) + } + eachRun { testApp1.launchViaIntent(wmHelper) wmHelper.waitForFullScreenApp(testApp1.component) @@ -90,18 +96,7 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa } } transitions { - // Swipe right from bottom to quick switch back - // NOTE: We don't perform an edge-to-edge swipe but instead only swipe in the middle - // as to not accidentally trigger a swipe back or forward action which would result - // in the same behavior but not testing quick swap. - device.swipe( - startDisplayBounds.bounds.right / 3, - startDisplayBounds.bounds.bottom, - 2 * startDisplayBounds.bounds.right / 3, - startDisplayBounds.bounds.bottom, - if (testSpec.isLandscapeOrSeascapeAtStart) 75 else 30 - ) - + taplInstrumentation.launchedAppState.quickSwitchToPreviousApp() wmHelper.waitForFullScreenApp(testApp1.component) wmHelper.waitForAppTransitionIdle() } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt index ce6a3837ad010..20b036daadf3b 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt @@ -22,6 +22,7 @@ import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter @@ -65,6 +66,7 @@ import org.junit.runners.Parameterized @Group1 open class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTestParameter) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val taplInstrumentation = LauncherInstrumentation() private val testApp1 = SimpleAppHelper(instrumentation) private val testApp2 = NonResizeableAppHelper(instrumentation) @@ -73,6 +75,10 @@ open class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTes fun buildFlicker(): FlickerBuilder { return FlickerBuilder(instrumentation).apply { setup { + test { + taplInstrumentation.setExpectedRotation(testSpec.startRotation) + } + eachRun { testApp1.launchViaIntent(wmHelper) wmHelper.waitForFullScreenApp(testApp1.component) @@ -85,34 +91,14 @@ open class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTes ?.layerStackSpace ?: error("Display not found") - // Swipe right from bottom to quick switch back - // NOTE: We don't perform an edge-to-edge swipe but instead only swipe in the - // middle as to not accidentally trigger a swipe back or forward action which - // would result in the same behavior but not testing quick swap. - device.swipe( - startDisplayBounds.right / 3, - startDisplayBounds.bottom, - 2 * startDisplayBounds.right / 3, - startDisplayBounds.bottom, - if (testSpec.isLandscapeOrSeascapeAtStart) 75 else 30 - ) + taplInstrumentation.launchedAppState.quickSwitchToPreviousApp() wmHelper.waitForFullScreenApp(testApp1.component) wmHelper.waitForAppTransitionIdle() } } transitions { - // Swipe left from bottom to quick switch forward - // NOTE: We don't perform an edge-to-edge swipe but instead only swipe in the middle - // as to not accidentally trigger a swipe back or forward action which would result - // in the same behavior but not testing quick swap. - device.swipe( - 2 * startDisplayBounds.right / 3, - startDisplayBounds.bottom, - startDisplayBounds.right / 3, - startDisplayBounds.bottom, - if (testSpec.isLandscapeOrSeascapeAtStart) 75 else 30 - ) + taplInstrumentation.launchedAppState.quickSwitchToPreviousAppSwipeLeft() wmHelper.waitForFullScreenApp(testApp2.component) wmHelper.waitForAppTransitionIdle() @@ -365,4 +351,4 @@ open class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTes ) } } -} \ No newline at end of file +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt index 1a762bfd97c59..60b7a9c194403 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt @@ -22,6 +22,7 @@ import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter @@ -62,13 +63,20 @@ import org.junit.runners.Parameterized @Group4 class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() + private val taplInstrumentation = LauncherInstrumentation() + private val testApp = SimpleAppHelper(instrumentation) + private val startDisplayBounds = WindowUtils.getDisplayBounds(testSpec.startRotation) @FlickerBuilderProvider fun buildFlicker(): FlickerBuilder { return FlickerBuilder(instrumentation).apply { setup { + test { + taplInstrumentation.setExpectedRotation(testSpec.startRotation) + } + eachRun { testApp.launchViaIntent(wmHelper) device.pressHome() @@ -77,18 +85,7 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } } transitions { - // Swipe right from bottom to quick switch back - // NOTE: We don't perform an edge-to-edge swipe but instead only swipe in the middle - // as to not accidentally trigger a swipe back or forward action which would result - // in the same behavior but not testing quick swap. - device.swipe( - startDisplayBounds.bounds.right / 3, - startDisplayBounds.bounds.bottom, - 2 * startDisplayBounds.bounds.right / 3, - startDisplayBounds.bounds.bottom, - 50 - ) - + taplInstrumentation.workspace.quickSwitchToPreviousApp() wmHelper.waitForFullScreenApp(testApp.component) wmHelper.waitForAppTransitionIdle() }