Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/BaseAppCompat.kt +14 −19 Original line number Diff line number Diff line Loading @@ -23,16 +23,15 @@ import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.LetterboxAppHelper import android.tools.device.flicker.legacy.FlickerTestFactory import android.tools.device.flicker.legacy.IFlickerTestData import com.android.wm.shell.flicker.BaseTest import com.android.wm.shell.flicker.appWindowIsVisibleAtStart import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd import com.android.wm.shell.flicker.appWindowKeepVisible import com.android.wm.shell.flicker.layerKeepVisible import org.junit.After import org.junit.Assume import org.junit.Before import org.junit.runners.Parameterized abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { protected val context: Context = instrumentation.context Loading @@ -58,12 +57,13 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { cmdHelper = CommandsHelper.getInstance(instrumentation) Assume.assumeTrue(tapl.isTablet && isIgnoreOrientationRequest()) letterboxStyle = mapLetterboxStyle() resetLetterboxStyle() setLetterboxEducationEnabled(false) } @After fun after() { resetLetterboxEducationEnabled() resetLetterboxStyle() } private fun mapLetterboxStyle(): HashMap<String, String> { Loading @@ -87,9 +87,8 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { return letterboxStyle } private fun resetLetterboxEducationEnabled() { val enabled = getLetterboxStyle().getValue("Is education enabled") cmdHelper.executeShellCommand("wm set-letterbox-style --isEducationEnabled $enabled") private fun resetLetterboxStyle() { cmdHelper.executeShellCommand("wm reset-letterbox-style") } private fun setLetterboxEducationEnabled(enabled: Boolean) { Loading Loading @@ -126,25 +125,21 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { flicker.appWindowIsVisibleAtEnd(letterboxApp) } fun assertLetterboxAppKeepVisible() { assertLetterboxAppWindowKeepVisible() assertLetterboxAppLayerKeepVisible() } fun assertAppLetterboxedAtEnd() = flicker.assertLayersEnd { isVisible(ComponentNameMatcher.LETTERBOX) } fun assertAppLetterboxedAtStart() = flicker.assertLayersStart { isVisible(ComponentNameMatcher.LETTERBOX) } fun assertAppStaysLetterboxed() = flicker.assertLayers { isVisible(ComponentNameMatcher.LETTERBOX) } fun assertLetterboxAppLayerKeepVisible() = flicker.layerKeepVisible(letterboxApp) companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.rotationTests() } } fun assertLetterboxAppWindowKeepVisible() = flicker.appWindowKeepVisible(letterboxApp) } libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/OpenAppInSizeCompatModeTest.kt +15 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import android.tools.device.flicker.legacy.FlickerTestFactory import androidx.test.filters.RequiresDevice import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -90,4 +91,18 @@ class OpenAppInSizeCompatModeTest(flicker: FlickerTest) : BaseAppCompat(flicker) .isInvisible(ComponentNameMatcher.ROTATION) } } companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.rotationTests() } } } libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/RepositionFixedPortraitAppTest.kt 0 → 100644 +103 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.flicker.appcompat import android.platform.test.annotations.Postsubmit import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import android.tools.device.flicker.legacy.FlickerTestFactory import android.tools.device.helpers.WindowUtils import androidx.test.filters.RequiresDevice import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** * Test launching a fixed portrait letterboxed app in landscape and repositioning to the right. * * To run this test: `atest WMShellFlickerTests:RepositionFixedPortraitAppTest` * Actions: * ``` * Launch a fixed portrait app in landscape to letterbox app * Double tap to the right to reposition app and wait for app to move * ``` * * Notes: * ``` * Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited [BaseTest] * ``` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) class RepositionFixedPortraitAppTest(flicker: FlickerTest) : BaseAppCompat(flicker) { val displayBounds = WindowUtils.getDisplayBounds(flicker.scenario.startRotation).bounds /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setup { setStartRotation() letterboxApp.launchViaIntent(wmHelper) } transitions { letterboxApp.repositionHorizontally(displayBounds, true) letterboxApp.waitForAppToMoveHorizontallyTo(wmHelper, displayBounds, true) } teardown { letterboxApp.repositionHorizontally(displayBounds, false) letterboxApp.exit(wmHelper) } } @Postsubmit @Test fun letterboxedAppHasRoundedCorners() = assertLetterboxAppAtEndHasRoundedCorners() @Postsubmit @Test fun letterboxAppLayerKeepVisible() = assertLetterboxAppLayerKeepVisible() @Postsubmit @Test fun appStaysLetterboxed() = assertAppStaysLetterboxed() @Postsubmit @Test fun appKeepVisible() = assertLetterboxAppKeepVisible() companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_90) ) } } } No newline at end of file libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/RestartAppInSizeCompatModeTest.kt +15 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.platform.test.annotations.Postsubmit import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import android.tools.device.flicker.legacy.FlickerTestFactory import android.tools.device.helpers.WindowUtils import androidx.test.filters.RequiresDevice import org.junit.Test Loading Loading @@ -88,4 +89,18 @@ class RestartAppInSizeCompatModeTest(flicker: FlickerTest) : BaseAppCompat(flick val displayBounds = WindowUtils.getDisplayBounds(flicker.scenario.endRotation) flicker.assertLayersEnd { visibleRegion(letterboxApp).coversAtMost(displayBounds) } } companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.rotationTests() } } } tests/FlickerTests/src/com/android/server/wm/flicker/helpers/GestureHelper.java +27 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,33 @@ public class GestureHelper { mUiAutomation = instrumentation.getUiAutomation(); } /** * Injects a series of {@link MotionEvent}s to simulate tapping. * * @param point coordinates of pointer to tap * @param times the number of times to tap */ public boolean tap(@NonNull Tuple point, int times) throws InterruptedException { PointerProperties ptrProp = getPointerProp(0, MotionEvent.TOOL_TYPE_FINGER); PointerCoords ptrCoord = getPointerCoord(point.x, point.y, 1, 1); for (int i = 0; i <= times; i++) { // If already tapped, inject delay in between movements if (times > 0) { SystemClock.sleep(50L); } if (!primaryPointerDown(ptrProp, ptrCoord, SystemClock.uptimeMillis())) { return false; } // Delay before releasing tap SystemClock.sleep(100L); if (!primaryPointerUp(ptrProp, ptrCoord, SystemClock.uptimeMillis())) { return false; } } return true; } /** * Injects a series of {@link MotionEvent}s to simulate a drag gesture without pointer release. * Loading Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/BaseAppCompat.kt +14 −19 Original line number Diff line number Diff line Loading @@ -23,16 +23,15 @@ import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.LetterboxAppHelper import android.tools.device.flicker.legacy.FlickerTestFactory import android.tools.device.flicker.legacy.IFlickerTestData import com.android.wm.shell.flicker.BaseTest import com.android.wm.shell.flicker.appWindowIsVisibleAtStart import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd import com.android.wm.shell.flicker.appWindowKeepVisible import com.android.wm.shell.flicker.layerKeepVisible import org.junit.After import org.junit.Assume import org.junit.Before import org.junit.runners.Parameterized abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { protected val context: Context = instrumentation.context Loading @@ -58,12 +57,13 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { cmdHelper = CommandsHelper.getInstance(instrumentation) Assume.assumeTrue(tapl.isTablet && isIgnoreOrientationRequest()) letterboxStyle = mapLetterboxStyle() resetLetterboxStyle() setLetterboxEducationEnabled(false) } @After fun after() { resetLetterboxEducationEnabled() resetLetterboxStyle() } private fun mapLetterboxStyle(): HashMap<String, String> { Loading @@ -87,9 +87,8 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { return letterboxStyle } private fun resetLetterboxEducationEnabled() { val enabled = getLetterboxStyle().getValue("Is education enabled") cmdHelper.executeShellCommand("wm set-letterbox-style --isEducationEnabled $enabled") private fun resetLetterboxStyle() { cmdHelper.executeShellCommand("wm reset-letterbox-style") } private fun setLetterboxEducationEnabled(enabled: Boolean) { Loading Loading @@ -126,25 +125,21 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) { flicker.appWindowIsVisibleAtEnd(letterboxApp) } fun assertLetterboxAppKeepVisible() { assertLetterboxAppWindowKeepVisible() assertLetterboxAppLayerKeepVisible() } fun assertAppLetterboxedAtEnd() = flicker.assertLayersEnd { isVisible(ComponentNameMatcher.LETTERBOX) } fun assertAppLetterboxedAtStart() = flicker.assertLayersStart { isVisible(ComponentNameMatcher.LETTERBOX) } fun assertAppStaysLetterboxed() = flicker.assertLayers { isVisible(ComponentNameMatcher.LETTERBOX) } fun assertLetterboxAppLayerKeepVisible() = flicker.layerKeepVisible(letterboxApp) companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.rotationTests() } } fun assertLetterboxAppWindowKeepVisible() = flicker.appWindowKeepVisible(letterboxApp) }
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/OpenAppInSizeCompatModeTest.kt +15 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.tools.common.traces.component.ComponentNameMatcher import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import android.tools.device.flicker.legacy.FlickerTestFactory import androidx.test.filters.RequiresDevice import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -90,4 +91,18 @@ class OpenAppInSizeCompatModeTest(flicker: FlickerTest) : BaseAppCompat(flicker) .isInvisible(ComponentNameMatcher.ROTATION) } } companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.rotationTests() } } }
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/RepositionFixedPortraitAppTest.kt 0 → 100644 +103 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell.flicker.appcompat import android.platform.test.annotations.Postsubmit import android.tools.common.Rotation import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import android.tools.device.flicker.legacy.FlickerTestFactory import android.tools.device.helpers.WindowUtils import androidx.test.filters.RequiresDevice import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** * Test launching a fixed portrait letterboxed app in landscape and repositioning to the right. * * To run this test: `atest WMShellFlickerTests:RepositionFixedPortraitAppTest` * Actions: * ``` * Launch a fixed portrait app in landscape to letterbox app * Double tap to the right to reposition app and wait for app to move * ``` * * Notes: * ``` * Some default assertions (e.g., nav bar, status bar and screen covered) * are inherited [BaseTest] * ``` */ @RequiresDevice @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) class RepositionFixedPortraitAppTest(flicker: FlickerTest) : BaseAppCompat(flicker) { val displayBounds = WindowUtils.getDisplayBounds(flicker.scenario.startRotation).bounds /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setup { setStartRotation() letterboxApp.launchViaIntent(wmHelper) } transitions { letterboxApp.repositionHorizontally(displayBounds, true) letterboxApp.waitForAppToMoveHorizontallyTo(wmHelper, displayBounds, true) } teardown { letterboxApp.repositionHorizontally(displayBounds, false) letterboxApp.exit(wmHelper) } } @Postsubmit @Test fun letterboxedAppHasRoundedCorners() = assertLetterboxAppAtEndHasRoundedCorners() @Postsubmit @Test fun letterboxAppLayerKeepVisible() = assertLetterboxAppLayerKeepVisible() @Postsubmit @Test fun appStaysLetterboxed() = assertAppStaysLetterboxed() @Postsubmit @Test fun appKeepVisible() = assertLetterboxAppKeepVisible() companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.nonRotationTests( supportedRotations = listOf(Rotation.ROTATION_90) ) } } } No newline at end of file
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/appcompat/RestartAppInSizeCompatModeTest.kt +15 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.platform.test.annotations.Postsubmit import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerTest import android.tools.device.flicker.legacy.FlickerTestFactory import android.tools.device.helpers.WindowUtils import androidx.test.filters.RequiresDevice import org.junit.Test Loading Loading @@ -88,4 +89,18 @@ class RestartAppInSizeCompatModeTest(flicker: FlickerTest) : BaseAppCompat(flick val displayBounds = WindowUtils.getDisplayBounds(flicker.scenario.endRotation) flicker.assertLayersEnd { visibleRegion(letterboxApp).coversAtMost(displayBounds) } } companion object { /** * Creates the test configurations. * * See [FlickerTestFactory.rotationTests] for configuring screen orientation and * navigation modes. */ @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<FlickerTest> { return FlickerTestFactory.rotationTests() } } }
tests/FlickerTests/src/com/android/server/wm/flicker/helpers/GestureHelper.java +27 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,33 @@ public class GestureHelper { mUiAutomation = instrumentation.getUiAutomation(); } /** * Injects a series of {@link MotionEvent}s to simulate tapping. * * @param point coordinates of pointer to tap * @param times the number of times to tap */ public boolean tap(@NonNull Tuple point, int times) throws InterruptedException { PointerProperties ptrProp = getPointerProp(0, MotionEvent.TOOL_TYPE_FINGER); PointerCoords ptrCoord = getPointerCoord(point.x, point.y, 1, 1); for (int i = 0; i <= times; i++) { // If already tapped, inject delay in between movements if (times > 0) { SystemClock.sleep(50L); } if (!primaryPointerDown(ptrProp, ptrCoord, SystemClock.uptimeMillis())) { return false; } // Delay before releasing tap SystemClock.sleep(100L); if (!primaryPointerUp(ptrProp, ptrCoord, SystemClock.uptimeMillis())) { return false; } } return true; } /** * Injects a series of {@link MotionEvent}s to simulate a drag gesture without pointer release. * Loading