From d597620cb42d0b23b51a1bd572592e30425c2829 Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Wed, 18 Jan 2023 13:29:58 +0000 Subject: Improve app launch test naming Previous names didn't clearly identify the test behavior Test: atest FlickerTests Bug: 265910451 Change-Id: I2cfb1ba7214ec0b316b489ef84a138861d8356ea --- .../wm/flicker/launch/ActivitiesTransitionTest.kt | 131 ------------ .../launch/ActivitiesTransitionTestCfArm.kt | 44 ---- .../wm/flicker/launch/ActivityTransitionTest.kt | 131 ++++++++++++ .../flicker/launch/ActivityTransitionTestCfArm.kt | 44 ++++ .../wm/flicker/launch/OpenAppAfterCameraTest.kt | 73 ------- .../flicker/launch/OpenAppAfterCameraTestCfArm.kt | 44 ---- .../wm/flicker/launch/OpenAppColdFromIcon.kt | 219 -------------------- .../wm/flicker/launch/OpenAppColdFromIconCfArm.kt | 55 ----- .../server/wm/flicker/launch/OpenAppColdTest.kt | 94 --------- .../wm/flicker/launch/OpenAppColdTestCfArm.kt | 52 ----- .../wm/flicker/launch/OpenAppFromIconColdTest.kt | 219 ++++++++++++++++++++ .../flicker/launch/OpenAppFromIconColdTestCfArm.kt | 55 +++++ .../launch/OpenAppFromIntentColdAfterCameraTest.kt | 74 +++++++ .../OpenAppFromIntentColdAfterCameraTestCfArm.kt | 45 +++++ .../wm/flicker/launch/OpenAppFromIntentColdTest.kt | 95 +++++++++ .../launch/OpenAppFromIntentColdTestCfArm.kt | 52 +++++ .../wm/flicker/launch/OpenAppFromIntentWarmTest.kt | 106 ++++++++++ .../launch/OpenAppFromIntentWarmTestCfArm.kt | 46 +++++ .../launch/OpenAppFromLockNotificationCold.kt | 135 ------------- .../launch/OpenAppFromLockNotificationWarm.kt | 166 --------------- ...penAppFromLockNotificationWithLockOverlayApp.kt | 136 ------------- .../wm/flicker/launch/OpenAppFromLockTransition.kt | 127 ------------ .../OpenAppFromLockscreenNotificationColdTest.kt | 135 +++++++++++++ .../OpenAppFromLockscreenNotificationWarmTest.kt | 167 +++++++++++++++ ...FromLockscreenNotificationWithOverlayAppTest.kt | 138 +++++++++++++ .../launch/OpenAppFromLockscreenTransition.kt | 127 ++++++++++++ .../launch/OpenAppFromLockscreenViaIntentTest.kt | 225 +++++++++++++++++++++ .../flicker/launch/OpenAppFromNotificationCold.kt | 113 ----------- .../launch/OpenAppFromNotificationColdCfArm.kt | 47 ----- .../launch/OpenAppFromNotificationColdTest.kt | 111 ++++++++++ .../launch/OpenAppFromNotificationColdTestCfArm.kt | 47 +++++ .../flicker/launch/OpenAppFromNotificationWarm.kt | 207 ------------------- .../launch/OpenAppFromNotificationWarmCfArm.kt | 45 ----- .../launch/OpenAppFromNotificationWarmTest.kt | 205 +++++++++++++++++++ .../launch/OpenAppFromNotificationWarmTestCfArm.kt | 45 +++++ .../wm/flicker/launch/OpenAppNonResizeableTest.kt | 224 -------------------- .../server/wm/flicker/launch/OpenAppWarmTest.kt | 105 ---------- .../wm/flicker/launch/OpenAppWarmTestCfArm.kt | 46 ----- ...enCameraFromHomeOnDoubleClickPowerButtonTest.kt | 167 +++++++++++++++ .../launch/OpenCameraOnDoubleClickPowerButton.kt | 167 --------------- 40 files changed, 2234 insertions(+), 2230 deletions(-) delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTestCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTestCfArm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTest.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTestCfArm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIconCfArm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTestCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTestCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTestCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTestCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTestCfArm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationColdTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWarmTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenTransition.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTestCfArm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTest.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTestCfArm.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTestCfArm.kt create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraFromHomeOnDoubleClickPowerButtonTest.kt delete mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraOnDoubleClickPowerButton.kt diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt deleted file mode 100644 index e6594c969373..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2021 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.server.wm.flicker.launch - -import android.platform.test.annotations.Presubmit -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 android.tools.device.traces.parsers.toFlickerComponent -import androidx.test.filters.RequiresDevice -import com.android.server.wm.flicker.BaseTest -import com.android.server.wm.flicker.helpers.TwoActivitiesAppHelper -import com.android.server.wm.flicker.testapp.ActivityOptions -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test the back and forward transition between 2 activities. - * - * To run this test: `atest FlickerTests:ActivitiesTransitionTest` - * - * Actions: - * ``` - * Launch an app - * Launch a secondary activity within the app - * Close the secondary activity back to the initial one - * ``` - * - * Notes: - * ``` - * 1. Part of the test setup occurs automatically via - * [com.android.server.wm.flicker.TransitionRunnerWithRules], - * including configuring navigation mode, initial orientation and ensuring no - * apps are running before setup - * ``` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class ActivitiesTransitionTest(flicker: FlickerTest) : BaseTest(flicker) { - private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation) - - /** {@inheritDoc} */ - override val transition: FlickerBuilder.() -> Unit = { - setup { - tapl.setExpectedRotation(flicker.scenario.startRotation.value) - testApp.launchViaIntent(wmHelper) - } - teardown { testApp.exit(wmHelper) } - transitions { - testApp.openSecondActivity(device, wmHelper) - tapl.pressBack() - wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() - } - } - - /** - * Checks that the [ActivityOptions.LaunchNewActivity] activity is visible at the start of the - * transition, that [ActivityOptions.SimpleActivity] becomes visible during the transition, and - * that [ActivityOptions.LaunchNewActivity] is again visible at the end - */ - @Presubmit - @Test - fun finishSubActivity() { - val buttonActivityComponent = - ActivityOptions.LaunchNewActivity.COMPONENT.toFlickerComponent() - val imeAutoFocusActivityComponent = - ActivityOptions.SimpleActivity.COMPONENT.toFlickerComponent() - flicker.assertWm { - this.isAppWindowOnTop(buttonActivityComponent) - .then() - .isAppWindowOnTop(imeAutoFocusActivityComponent) - .then() - .isAppWindowOnTop(buttonActivityComponent) - } - } - - /** - * Checks that the [ComponentNameMatcher.LAUNCHER] window is not on top. The launcher cannot be - * asserted with `isAppWindowVisible` because it contains 2 windows with the exact same name, - * and both are never simultaneously visible - */ - @Presubmit - @Test - fun launcherWindowNotOnTop() { - flicker.assertWm { this.isAppWindowNotOnTop(ComponentNameMatcher.LAUNCHER) } - } - - /** - * Checks that the [ComponentNameMatcher.LAUNCHER] layer is never visible during the transition - */ - @Presubmit - @Test - fun launcherLayerNotVisible() { - flicker.assertLayers { this.isInvisible(ComponentNameMatcher.LAUNCHER) } - } - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTestCfArm.kt deleted file mode 100644 index 8b89a8b4c40d..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTestCfArm.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.server.wm.flicker.launch - -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import org.junit.FixMethodOrder -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class ActivitiesTransitionTestCfArm(flicker: FlickerTest) : ActivitiesTransitionTest(flicker) { - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTest.kt new file mode 100644 index 000000000000..a87fae857509 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTest.kt @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2021 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.server.wm.flicker.launch + +import android.platform.test.annotations.Presubmit +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 android.tools.device.traces.parsers.toFlickerComponent +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.BaseTest +import com.android.server.wm.flicker.helpers.TwoActivitiesAppHelper +import com.android.server.wm.flicker.testapp.ActivityOptions +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test the back and forward transition between 2 activities. + * + * To run this test: `atest FlickerTests:ActivitiesTransitionTest` + * + * Actions: + * ``` + * Launch an app + * Launch a secondary activity within the app + * Close the secondary activity back to the initial one + * ``` + * + * Notes: + * ``` + * 1. Part of the test setup occurs automatically via + * [com.android.server.wm.flicker.TransitionRunnerWithRules], + * including configuring navigation mode, initial orientation and ensuring no + * apps are running before setup + * ``` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class ActivityTransitionTest(flicker: FlickerTest) : BaseTest(flicker) { + private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation) + + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotation(flicker.scenario.startRotation.value) + testApp.launchViaIntent(wmHelper) + } + teardown { testApp.exit(wmHelper) } + transitions { + testApp.openSecondActivity(device, wmHelper) + tapl.pressBack() + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + } + + /** + * Checks that the [ActivityOptions.LaunchNewActivity] activity is visible at the start of the + * transition, that [ActivityOptions.SimpleActivity] becomes visible during the transition, and + * that [ActivityOptions.LaunchNewActivity] is again visible at the end + */ + @Presubmit + @Test + fun finishSubActivity() { + val buttonActivityComponent = + ActivityOptions.LaunchNewActivity.COMPONENT.toFlickerComponent() + val imeAutoFocusActivityComponent = + ActivityOptions.SimpleActivity.COMPONENT.toFlickerComponent() + flicker.assertWm { + this.isAppWindowOnTop(buttonActivityComponent) + .then() + .isAppWindowOnTop(imeAutoFocusActivityComponent) + .then() + .isAppWindowOnTop(buttonActivityComponent) + } + } + + /** + * Checks that the [ComponentNameMatcher.LAUNCHER] window is not on top. The launcher cannot be + * asserted with `isAppWindowVisible` because it contains 2 windows with the exact same name, + * and both are never simultaneously visible + */ + @Presubmit + @Test + fun launcherWindowNotOnTop() { + flicker.assertWm { this.isAppWindowNotOnTop(ComponentNameMatcher.LAUNCHER) } + } + + /** + * Checks that the [ComponentNameMatcher.LAUNCHER] layer is never visible during the transition + */ + @Presubmit + @Test + fun launcherLayerNotVisible() { + flicker.assertLayers { this.isInvisible(ComponentNameMatcher.LAUNCHER) } + } + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTestCfArm.kt new file mode 100644 index 000000000000..85344a156d7a --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivityTransitionTestCfArm.kt @@ -0,0 +1,44 @@ +/* + * 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.server.wm.flicker.launch + +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import org.junit.FixMethodOrder +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class ActivityTransitionTestCfArm(flicker: FlickerTest) : ActivityTransitionTest(flicker) { + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTest.kt deleted file mode 100644 index 549183f407e2..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTest.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.tools.device.apphelpers.CameraAppHelper -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.FixMethodOrder -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test launching an app after cold opening camera - * - * To run this test: `atest FlickerTests:OpenAppAfterCameraTest` - * - * Notes: Some default assertions are inherited [OpenAppTransition] - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppAfterCameraTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { - private val cameraApp = CameraAppHelper(instrumentation) - /** {@inheritDoc} */ - override val transition: FlickerBuilder.() -> Unit - get() = { - super.transition(this) - setup { - tapl.setExpectedRotationCheckEnabled(false) - // 1. Open camera - cold -> close it first - cameraApp.exit(wmHelper) - cameraApp.launchViaIntent(wmHelper) - // Can't use TAPL due to Recents not showing in 3 Button Nav in full screen mode - device.pressHome() - tapl.getWorkspace() - } - teardown { testApp.exit(wmHelper) } - transitions { testApp.launchViaIntent(wmHelper) } - } - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTestCfArm.kt deleted file mode 100644 index ac05c7687311..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppAfterCameraTestCfArm.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.server.wm.flicker.launch - -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import org.junit.FixMethodOrder -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppAfterCameraTestCfArm(flicker: FlickerTest) : OpenAppAfterCameraTest(flicker) { - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt deleted file mode 100644 index 3a80c6649833..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -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.flicker.rules.RemoveAllTasksButHomeRule -import androidx.test.filters.RequiresDevice -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test cold launching an app from launcher - * - * To run this test: `atest FlickerTests:OpenAppColdFromIcon` - * - * Actions: - * ``` - * Make sure no apps are running on the device - * Launch an app [testApp] by clicking it's icon on all apps and wait animation to complete - * ``` - * - * Notes: - * ``` - * 1. Some default assertions (e.g., nav bar, status bar and screen covered) - * are inherited [OpenAppTransition] - * 2. Part of the test setup occurs automatically via - * [com.android.server.wm.flicker.TransitionRunnerWithRules], - * including configuring navigation mode, initial orientation and ensuring no - * apps are running before setup - * ``` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppColdFromIcon(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { - /** {@inheritDoc} */ - override val transition: FlickerBuilder.() -> Unit - get() = { - super.transition(this) - setup { - if (flicker.scenario.isTablet) { - tapl.setExpectedRotation(flicker.scenario.startRotation.value) - } else { - tapl.setExpectedRotation(Rotation.ROTATION_0.value) - } - RemoveAllTasksButHomeRule.removeAllTasksButHome() - } - transitions { - tapl - .goHome() - .switchToAllApps() - .getAppIcon(testApp.launcherName) - .launch(testApp.`package`) - } - teardown { testApp.exit(wmHelper) } - } - - @FlakyTest(bugId = 240916028) - @Test - override fun focusChanges() { - super.focusChanges() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun appWindowReplacesLauncherAsTopWindow() { - super.appWindowReplacesLauncherAsTopWindow() - } - @FlakyTest(bugId = 240916028) - @Test - override fun appWindowAsTopWindowAtEnd() { - super.appWindowAsTopWindowAtEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun appWindowBecomesTopWindow() { - super.appWindowBecomesTopWindow() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun appWindowBecomesVisible() { - super.appWindowBecomesVisible() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun appWindowIsTopWindowAtEnd() { - super.appWindowIsTopWindowAtEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun appLayerBecomesVisible() { - super.appLayerBecomesVisible() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun appLayerReplacesLauncher() { - super.appLayerReplacesLauncher() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun cujCompleted() { - super.cujCompleted() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun entireScreenCovered() { - super.entireScreenCovered() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun navBarLayerIsVisibleAtStartAndEnd() { - super.navBarLayerIsVisibleAtStartAndEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun navBarLayerPositionAtStartAndEnd() { - super.navBarLayerPositionAtStartAndEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun navBarWindowIsAlwaysVisible() { - super.navBarWindowIsAlwaysVisible() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun navBarWindowIsVisibleAtStartAndEnd() { - super.navBarWindowIsVisibleAtStartAndEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun statusBarLayerIsVisibleAtStartAndEnd() { - super.statusBarLayerIsVisibleAtStartAndEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun statusBarLayerPositionAtStartAndEnd() { - super.statusBarLayerPositionAtStartAndEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun statusBarWindowIsAlwaysVisible() { - super.statusBarWindowIsAlwaysVisible() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() { - super.taskBarLayerIsVisibleAtStartAndEnd() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun taskBarWindowIsAlwaysVisible() { - super.taskBarWindowIsAlwaysVisible() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() { - super.visibleLayersShownMoreThanOneConsecutiveEntry() - } - - @FlakyTest(bugId = 240916028) - @Test - override fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - super.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIconCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIconCfArm.kt deleted file mode 100644 index d33a2724ca44..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIconCfArm.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -import android.tools.device.flicker.annotation.FlickerServiceCompatible -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** Some assertions will fail because of b/264415996 */ -@FlickerServiceCompatible -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppColdFromIconCfArm(flicker: FlickerTest) : OpenAppColdFromIcon(flicker) { - @Test - @FlakyTest - override fun visibleLayersShownMoreThanOneConsecutiveEntry() { - super.visibleLayersShownMoreThanOneConsecutiveEntry() - } - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt deleted file mode 100644 index 26f88d23cda0..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2020 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.server.wm.flicker.launch - -import android.platform.test.annotations.Postsubmit -import android.platform.test.annotations.Presubmit -import android.tools.device.flicker.annotation.FlickerServiceCompatible -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.flicker.rules.RemoveAllTasksButHomeRule.Companion.removeAllTasksButHome -import androidx.test.filters.RequiresDevice -import com.android.server.wm.flicker.helpers.setRotation -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test cold launching an app from launcher - * - * To run this test: `atest FlickerTests:OpenAppColdTest` - * - * Actions: - * ``` - * Make sure no apps are running on the device - * Launch an app [testApp] and wait animation to complete - * ``` - * - * Notes: - * ``` - * 1. Some default assertions (e.g., nav bar, status bar and screen covered) - * are inherited [OpenAppTransition] - * 2. Part of the test setup occurs automatically via - * [com.android.server.wm.flicker.TransitionRunnerWithRules], - * including configuring navigation mode, initial orientation and ensuring no - * apps are running before setup - * ``` - */ -@RequiresDevice -@FlickerServiceCompatible -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppColdTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { - /** {@inheritDoc} */ - override val transition: FlickerBuilder.() -> Unit - get() = { - super.transition(this) - setup { - removeAllTasksButHome() - this.setRotation(flicker.scenario.startRotation) - } - teardown { testApp.exit(wmHelper) } - transitions { testApp.launchViaIntent(wmHelper) } - } - - /** {@inheritDoc} */ - @Presubmit @Test override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() - - @Postsubmit - @Test - override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTestCfArm.kt deleted file mode 100644 index d9a99dadbd3d..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTestCfArm.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -import android.tools.device.flicker.annotation.FlickerServiceCompatible -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -@FlickerServiceCompatible -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppColdTestCfArm(flicker: FlickerTest) : OpenAppColdTest(flicker) { - @FlakyTest(bugId = 273696733) - @Test - override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTest.kt new file mode 100644 index 000000000000..575206591e59 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTest.kt @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +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.flicker.rules.RemoveAllTasksButHomeRule +import androidx.test.filters.RequiresDevice +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test cold launching an app from launcher + * + * To run this test: `atest FlickerTests:OpenAppColdFromIcon` + * + * Actions: + * ``` + * Make sure no apps are running on the device + * Launch an app [testApp] by clicking it's icon on all apps and wait animation to complete + * ``` + * + * Notes: + * ``` + * 1. Some default assertions (e.g., nav bar, status bar and screen covered) + * are inherited [OpenAppTransition] + * 2. Part of the test setup occurs automatically via + * [com.android.server.wm.flicker.TransitionRunnerWithRules], + * including configuring navigation mode, initial orientation and ensuring no + * apps are running before setup + * ``` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class OpenAppFromIconColdTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + setup { + if (flicker.scenario.isTablet) { + tapl.setExpectedRotation(flicker.scenario.startRotation.value) + } else { + tapl.setExpectedRotation(Rotation.ROTATION_0.value) + } + RemoveAllTasksButHomeRule.removeAllTasksButHome() + } + transitions { + tapl + .goHome() + .switchToAllApps() + .getAppIcon(testApp.launcherName) + .launch(testApp.`package`) + } + teardown { testApp.exit(wmHelper) } + } + + @FlakyTest(bugId = 240916028) + @Test + override fun focusChanges() { + super.focusChanges() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun appWindowReplacesLauncherAsTopWindow() { + super.appWindowReplacesLauncherAsTopWindow() + } + @FlakyTest(bugId = 240916028) + @Test + override fun appWindowAsTopWindowAtEnd() { + super.appWindowAsTopWindowAtEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun appWindowBecomesTopWindow() { + super.appWindowBecomesTopWindow() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun appWindowBecomesVisible() { + super.appWindowBecomesVisible() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun appWindowIsTopWindowAtEnd() { + super.appWindowIsTopWindowAtEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun appLayerBecomesVisible() { + super.appLayerBecomesVisible() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun appLayerReplacesLauncher() { + super.appLayerReplacesLauncher() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun cujCompleted() { + super.cujCompleted() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun entireScreenCovered() { + super.entireScreenCovered() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() { + super.navBarLayerIsVisibleAtStartAndEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun navBarLayerPositionAtStartAndEnd() { + super.navBarLayerPositionAtStartAndEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun navBarWindowIsAlwaysVisible() { + super.navBarWindowIsAlwaysVisible() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun navBarWindowIsVisibleAtStartAndEnd() { + super.navBarWindowIsVisibleAtStartAndEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() { + super.statusBarLayerIsVisibleAtStartAndEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun statusBarLayerPositionAtStartAndEnd() { + super.statusBarLayerPositionAtStartAndEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun statusBarWindowIsAlwaysVisible() { + super.statusBarWindowIsAlwaysVisible() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() { + super.taskBarLayerIsVisibleAtStartAndEnd() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun taskBarWindowIsAlwaysVisible() { + super.taskBarWindowIsAlwaysVisible() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { + super.visibleLayersShownMoreThanOneConsecutiveEntry() + } + + @FlakyTest(bugId = 240916028) + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() { + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + } + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTestCfArm.kt new file mode 100644 index 000000000000..d453c1ae908a --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIconColdTestCfArm.kt @@ -0,0 +1,55 @@ +/* + * 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** Some assertions will fail because of b/264415996 */ +@FlickerServiceCompatible +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenAppFromIconColdTestCfArm(flicker: FlickerTest) : OpenAppFromIconColdTest(flicker) { + @Test + @FlakyTest + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { + super.visibleLayersShownMoreThanOneConsecutiveEntry() + } + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTest.kt new file mode 100644 index 000000000000..e74731555642 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTest.kt @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.tools.device.apphelpers.CameraAppHelper +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.FixMethodOrder +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test launching an app after cold opening camera + * + * To run this test: `atest FlickerTests:OpenAppAfterCameraTest` + * + * Notes: Some default assertions are inherited [OpenAppTransition] + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class OpenAppFromIntentColdAfterCameraTest(flicker: FlickerTest) : + OpenAppFromLauncherTransition(flicker) { + private val cameraApp = CameraAppHelper(instrumentation) + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + setup { + tapl.setExpectedRotationCheckEnabled(false) + // 1. Open camera - cold -> close it first + cameraApp.exit(wmHelper) + cameraApp.launchViaIntent(wmHelper) + // Can't use TAPL due to Recents not showing in 3 Button Nav in full screen mode + device.pressHome() + tapl.getWorkspace() + } + teardown { testApp.exit(wmHelper) } + transitions { testApp.launchViaIntent(wmHelper) } + } + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTestCfArm.kt new file mode 100644 index 000000000000..177ad7dc09d1 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdAfterCameraTestCfArm.kt @@ -0,0 +1,45 @@ +/* + * 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.server.wm.flicker.launch + +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import org.junit.FixMethodOrder +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenAppFromIntentColdAfterCameraTestCfArm(flicker: FlickerTest) : + OpenAppFromIntentColdAfterCameraTest(flicker) { + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTest.kt new file mode 100644 index 000000000000..f45f728664cf --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTest.kt @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2020 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.server.wm.flicker.launch + +import android.platform.test.annotations.Postsubmit +import android.platform.test.annotations.Presubmit +import android.tools.device.flicker.annotation.FlickerServiceCompatible +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.flicker.rules.RemoveAllTasksButHomeRule.Companion.removeAllTasksButHome +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.helpers.setRotation +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test cold launching an app from launcher + * + * To run this test: `atest FlickerTests:OpenAppColdTest` + * + * Actions: + * ``` + * Make sure no apps are running on the device + * Launch an app [testApp] and wait animation to complete + * ``` + * + * Notes: + * ``` + * 1. Some default assertions (e.g., nav bar, status bar and screen covered) + * are inherited [OpenAppTransition] + * 2. Part of the test setup occurs automatically via + * [com.android.server.wm.flicker.TransitionRunnerWithRules], + * including configuring navigation mode, initial orientation and ensuring no + * apps are running before setup + * ``` + */ +@RequiresDevice +@FlickerServiceCompatible +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class OpenAppFromIntentColdTest(flicker: FlickerTest) : + OpenAppFromLauncherTransition(flicker) { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + setup { + removeAllTasksButHome() + this.setRotation(flicker.scenario.startRotation) + } + teardown { testApp.exit(wmHelper) } + transitions { testApp.launchViaIntent(wmHelper) } + } + + /** {@inheritDoc} */ + @Presubmit @Test override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() + + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTestCfArm.kt new file mode 100644 index 000000000000..0d695f306c00 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentColdTestCfArm.kt @@ -0,0 +1,52 @@ +/* + * 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +@FlickerServiceCompatible +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenAppFromIntentColdTestCfArm(flicker: FlickerTest) : OpenAppFromIntentColdTest(flicker) { + @FlakyTest(bugId = 273696733) + @Test + override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTest.kt new file mode 100644 index 000000000000..a42bff5bf170 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTest.kt @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2020 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Presubmit +import android.tools.device.flicker.annotation.FlickerServiceCompatible +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 com.android.server.wm.flicker.helpers.setRotation +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test warm launching an app from launcher + * + * To run this test: `atest FlickerTests:OpenAppWarmTest` + * + * Actions: + * ``` + * Launch [testApp] + * Press home + * Relaunch an app [testApp] and wait animation to complete (only this action is traced) + * ``` + * + * Notes: + * ``` + * 1. Some default assertions (e.g., nav bar, status bar and screen covered) + * are inherited [OpenAppTransition] + * 2. Part of the test setup occurs automatically via + * [com.android.server.wm.flicker.TransitionRunnerWithRules], + * including configuring navigation mode, initial orientation and ensuring no + * apps are running before setup + * ``` + */ +@RequiresDevice +@FlickerServiceCompatible +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class OpenAppFromIntentWarmTest(flicker: FlickerTest) : + OpenAppFromLauncherTransition(flicker) { + /** Defines the transition used to run the test */ + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + setup { + tapl.setExpectedRotationCheckEnabled(false) + testApp.launchViaIntent(wmHelper) + tapl.goHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + this.setRotation(flicker.scenario.startRotation) + } + teardown { testApp.exit(wmHelper) } + transitions { testApp.launchViaIntent(wmHelper) } + } + + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Presubmit + @Test + override fun appLayerBecomesVisible() = super.appLayerBecomesVisible_warmStart() + + /** {@inheritDoc} */ + @Presubmit + @Test + override fun appWindowBecomesVisible() = super.appWindowBecomesVisible_warmStart() + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTestCfArm.kt new file mode 100644 index 000000000000..b6ffcb3df9f3 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromIntentWarmTestCfArm.kt @@ -0,0 +1,46 @@ +/* + * 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.server.wm.flicker.launch + +import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import org.junit.FixMethodOrder +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +@FlickerServiceCompatible +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenAppFromIntentWarmTestCfArm(flicker: FlickerTest) : OpenAppFromIntentWarmTest(flicker) { + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt deleted file mode 100644 index b21777b30b21..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.platform.test.annotations.Postsubmit -import android.platform.test.rule.SettingOverrideRule -import android.provider.Settings -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.ClassRule -import org.junit.FixMethodOrder -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test cold launching an app from a notification from the lock screen. - * - * This test assumes the device doesn't have AOD enabled - * - * To run this test: `atest FlickerTests:OpenAppFromLockNotificationCold` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@Postsubmit -open class OpenAppFromLockNotificationCold(flicker: FlickerTest) : - OpenAppFromNotificationCold(flicker) { - - override val openingNotificationsFromLockScreen = true - - override val transition: FlickerBuilder.() -> Unit - get() = { - // Needs to run at start of transition, - // so before the transition defined in super.transition - transitions { device.wakeUp() } - - super.transition(this) - - // Needs to run at the end of the setup, so after the setup defined in super.transition - setup { - device.sleep() - wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() - } - } - - /** {@inheritDoc} */ - @Test @Ignore("Display is off at the start") override fun navBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Display is off at the start") - override fun statusBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Display is off at the start") - override fun taskBarLayerIsVisibleAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test @Ignore("Display is off at the start") override fun taskBarWindowIsAlwaysVisible() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Display is off at the start") - override fun statusBarLayerIsVisibleAtStartAndEnd() = - super.statusBarLayerIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarWindowIsAlwaysVisible() {} - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - - /** - * Ensures that posted notifications will be visible on the lockscreen and not suppressed - * due to being marked as seen. - */ - @ClassRule - @JvmField - val disableUnseenNotifFilterRule = - SettingOverrideRule( - Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, - /* value = */ "0", - ) - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt deleted file mode 100644 index ec92ca65f80a..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -import android.platform.test.annotations.Presubmit -import android.platform.test.rule.SettingOverrideRule -import android.provider.Settings -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 com.android.server.wm.flicker.statusBarLayerPositionAtEnd -import org.junit.ClassRule -import org.junit.FixMethodOrder -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test warm launching an app from a notification from the lock screen. - * - * This test assumes the device doesn't have AOD enabled - * - * To run this test: `atest FlickerTests:OpenAppFromLockNotificationWarm` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppFromLockNotificationWarm(flicker: FlickerTest) : OpenAppFromNotificationWarm(flicker) { - - override val openingNotificationsFromLockScreen = true - - override val transition: FlickerBuilder.() -> Unit - get() = { - // Needs to run at start of transition, - // so before the transition defined in super.transition - transitions { device.wakeUp() } - - super.transition(this) - - // Needs to run at the end of the setup, so after the setup defined in super.transition - setup { - device.sleep() - wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() - } - } - - /** - * Checks that we start of with no top windows and then [testApp] becomes the first and only top - * window of the transition, with snapshot or splash screen windows optionally showing first. - */ - @Test - @Presubmit - fun appWindowBecomesFirstAndOnlyTopWindow() { - flicker.assertWm { - this.hasNoVisibleAppWindow() - .then() - .isAppWindowOnTop(ComponentNameMatcher.SNAPSHOT, isOptional = true) - .then() - .isAppWindowOnTop(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) - .then() - .isAppWindowOnTop(testApp) - } - } - - /** Checks that the screen is locked at the start of the transition */ - @Test - @Presubmit - fun screenLockedStart() { - flicker.assertWmStart { isKeyguardShowing() } - } - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun taskBarWindowIsAlwaysVisible() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun statusBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun statusBarLayerIsVisibleAtStartAndEnd() = - super.statusBarLayerIsVisibleAtStartAndEnd() - - /** - * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the - * transition - */ - @Presubmit @Test fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarWindowIsAlwaysVisible() {} - - /** {@inheritDoc} */ - @FlakyTest(bugId = 246284526) - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - - /** - * Ensures that posted notifications will be visible on the lockscreen and not suppressed - * due to being marked as seen. - */ - @ClassRule - @JvmField - val disableUnseenNotifFilterRule = - SettingOverrideRule( - Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, - /* value= */ "0", - ) - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt deleted file mode 100644 index 009d61797fe0..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -import android.platform.test.annotations.Postsubmit -import android.platform.test.annotations.Presubmit -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 android.tools.device.helpers.wakeUpAndGoToHomeScreen -import androidx.test.filters.RequiresDevice -import com.android.server.wm.flicker.helpers.ShowWhenLockedAppHelper -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test cold launching an app from a notification from the lock screen when there is an app overlaid - * on the lock screen. - * - * To run this test: `atest FlickerTests:OpenAppFromLockNotificationWithLockOverlayApp` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@Postsubmit -class OpenAppFromLockNotificationWithLockOverlayApp(flicker: FlickerTest) : - OpenAppFromLockNotificationCold(flicker) { - private val showWhenLockedApp = ShowWhenLockedAppHelper(instrumentation) - - // Although we are technically still locked here, the overlay app means we should open the - // notification shade as if we were unlocked. - override val openingNotificationsFromLockScreen = false - - override val transition: FlickerBuilder.() -> Unit - get() = { - super.transition(this) - - setup { - device.wakeUpAndGoToHomeScreen() - - // Launch an activity that is shown when the device is locked - showWhenLockedApp.launchViaIntent(wmHelper) - wmHelper.StateSyncBuilder().withFullScreenApp(showWhenLockedApp).waitForAndVerify() - - device.sleep() - wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() - } - - teardown { showWhenLockedApp.exit(wmHelper) } - } - - @Test - @FlakyTest(bugId = 227143265) - fun showWhenLockedAppWindowBecomesVisible() { - flicker.assertWm { - this.hasNoVisibleAppWindow() - .then() - .isAppWindowOnTop(ComponentNameMatcher.SNAPSHOT, isOptional = true) - .then() - .isAppWindowOnTop(showWhenLockedApp) - } - } - - @Test - @FlakyTest(bugId = 227143265) - fun showWhenLockedAppLayerBecomesVisible() { - flicker.assertLayers { - this.isInvisible(showWhenLockedApp) - .then() - .isVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) - .then() - .isVisible(showWhenLockedApp) - } - } - - /** {@inheritDoc} */ - @Presubmit @Test override fun appLayerBecomesVisible() = super.appLayerBecomesVisible() - - /** {@inheritDoc} */ - @FlakyTest(bugId = 227143265) - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() - - /** {@inheritDoc} */ - @FlakyTest(bugId = 209599395) - @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() - - @Presubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() - - @FlakyTest(bugId = 278227468) - @Test - override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = - super.visibleWindowsShownMoreThanOneConsecutiveEntry() - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt deleted file mode 100644 index eae9ca10c711..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2021 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -import android.platform.test.annotations.Presubmit -import android.tools.common.traces.component.ComponentNameMatcher -import android.tools.device.flicker.legacy.FlickerBuilder -import android.tools.device.flicker.legacy.FlickerTest -import com.android.server.wm.flicker.navBarLayerPositionAtEnd -import com.android.server.wm.flicker.statusBarLayerPositionAtEnd -import org.junit.Assume -import org.junit.Ignore -import org.junit.Test - -/** Base class for app launch tests from lock screen */ -abstract class OpenAppFromLockTransition(flicker: FlickerTest) : OpenAppTransition(flicker) { - - /** Defines the transition used to run the test */ - override val transition: FlickerBuilder.() -> Unit = { - super.transition(this) - setup { - device.sleep() - wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() - } - teardown { testApp.exit(wmHelper) } - transitions { testApp.launchViaIntent(wmHelper) } - } - - /** Check that we go from no focus to focus on the [testApp] */ - @Presubmit - @Test - open fun focusChanges() { - flicker.assertEventLog { this.focusChanges("", testApp.`package`) } - } - - /** - * Checks that we start of with no top windows and then [testApp] becomes the first and only top - * window of the transition, with snapshot or splash screen windows optionally showing first. - */ - @FlakyTest(bugId = 203538234) - @Test - open fun appWindowBecomesFirstAndOnlyTopWindow() { - flicker.assertWm { - this.hasNoVisibleAppWindow() - .then() - .isAppWindowOnTop(ComponentNameMatcher.SNAPSHOT, isOptional = true) - .then() - .isAppWindowOnTop(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) - .then() - .isAppWindowOnTop(testApp) - } - } - - /** Checks that the screen is locked at the start of the transition */ - @Presubmit - @Test - fun screenLockedStart() { - flicker.assertLayersStart { isEmpty() } - } - - /** {@inheritDoc} */ - @FlakyTest(bugId = 203538234) - @Test - override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun navBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun statusBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun taskBarLayerIsVisibleAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun taskBarWindowIsAlwaysVisible() {} - - /** Checks the position of the [ComponentNameMatcher.NAV_BAR] at the end of the transition */ - @Presubmit - @Test - open fun navBarLayerPositionAtEnd() { - Assume.assumeFalse(flicker.scenario.isTablet) - flicker.navBarLayerPositionAtEnd() - } - - /** Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the end of the transition */ - @Presubmit @Test fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun statusBarLayerIsVisibleAtStartAndEnd() {} - - /** - * Checks that the [ComponentNameMatcher.STATUS_BAR] layer is visible at the end of the trace - * - * It is not possible to check at the start because the screen is off - */ - @Presubmit - @Test - fun statusBarLayerIsVisibleAtEnd() { - flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.STATUS_BAR) } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationColdTest.kt new file mode 100644 index 000000000000..fd4272600d55 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationColdTest.kt @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.platform.test.annotations.Postsubmit +import android.platform.test.rule.SettingOverrideRule +import android.provider.Settings +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.ClassRule +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test cold launching an app from a notification from the lock screen. + * + * This test assumes the device doesn't have AOD enabled + * + * To run this test: `atest FlickerTests:OpenAppFromLockNotificationCold` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Postsubmit +open class OpenAppFromLockscreenNotificationColdTest(flicker: FlickerTest) : + OpenAppFromNotificationColdTest(flicker) { + + override val openingNotificationsFromLockScreen = true + + override val transition: FlickerBuilder.() -> Unit + get() = { + // Needs to run at start of transition, + // so before the transition defined in super.transition + transitions { device.wakeUp() } + + super.transition(this) + + // Needs to run at the end of the setup, so after the setup defined in super.transition + setup { + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + } + } + + /** {@inheritDoc} */ + @Test @Ignore("Display is off at the start") override fun navBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Display is off at the start") + override fun statusBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Display is off at the start") + override fun taskBarLayerIsVisibleAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test @Ignore("Display is off at the start") override fun taskBarWindowIsAlwaysVisible() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Display is off at the start") + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarWindowIsAlwaysVisible() {} + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + + /** + * Ensures that posted notifications will be visible on the lockscreen and not suppressed + * due to being marked as seen. + */ + @ClassRule + @JvmField + val disableUnseenNotifFilterRule = + SettingOverrideRule( + Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, + /* value = */ "0", + ) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWarmTest.kt new file mode 100644 index 000000000000..fd051d50d032 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWarmTest.kt @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Presubmit +import android.platform.test.rule.SettingOverrideRule +import android.provider.Settings +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 com.android.server.wm.flicker.statusBarLayerPositionAtEnd +import org.junit.ClassRule +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test warm launching an app from a notification from the lock screen. + * + * This test assumes the device doesn't have AOD enabled + * + * To run this test: `atest FlickerTests:OpenAppFromLockNotificationWarm` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenAppFromLockscreenNotificationWarmTest(flicker: FlickerTest) : + OpenAppFromNotificationWarmTest(flicker) { + + override val openingNotificationsFromLockScreen = true + + override val transition: FlickerBuilder.() -> Unit + get() = { + // Needs to run at start of transition, + // so before the transition defined in super.transition + transitions { device.wakeUp() } + + super.transition(this) + + // Needs to run at the end of the setup, so after the setup defined in super.transition + setup { + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + } + } + + /** + * Checks that we start of with no top windows and then [testApp] becomes the first and only top + * window of the transition, with snapshot or splash screen windows optionally showing first. + */ + @Test + @Presubmit + fun appWindowBecomesFirstAndOnlyTopWindow() { + flicker.assertWm { + this.hasNoVisibleAppWindow() + .then() + .isAppWindowOnTop(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowOnTop(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isAppWindowOnTop(testApp) + } + } + + /** Checks that the screen is locked at the start of the transition */ + @Test + @Presubmit + fun screenLockedStart() { + flicker.assertWmStart { isKeyguardShowing() } + } + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun taskBarWindowIsAlwaysVisible() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** + * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the + * transition + */ + @Presubmit @Test fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarWindowIsAlwaysVisible() {} + + /** {@inheritDoc} */ + @FlakyTest(bugId = 246284526) + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + + /** + * Ensures that posted notifications will be visible on the lockscreen and not suppressed + * due to being marked as seen. + */ + @ClassRule + @JvmField + val disableUnseenNotifFilterRule = + SettingOverrideRule( + Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, + /* value= */ "0", + ) + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt new file mode 100644 index 000000000000..37afa8d0caba --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit +import android.platform.test.annotations.Presubmit +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 android.tools.device.helpers.wakeUpAndGoToHomeScreen +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.helpers.ShowWhenLockedAppHelper +import org.junit.FixMethodOrder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test cold launching an app from a notification from the lock screen when there is an app overlaid + * on the lock screen. + * + * This test assumes the device doesn't have AOD enabled + * + * To run this test: `atest FlickerTests:OpenAppFromLockNotificationWithLockOverlayApp` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Postsubmit +class OpenAppFromLockscreenNotificationWithOverlayAppTest(flicker: FlickerTest) : + OpenAppFromLockscreenNotificationColdTest(flicker) { + private val showWhenLockedApp = ShowWhenLockedAppHelper(instrumentation) + + // Although we are technically still locked here, the overlay app means we should open the + // notification shade as if we were unlocked. + override val openingNotificationsFromLockScreen = false + + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + + setup { + device.wakeUpAndGoToHomeScreen() + + // Launch an activity that is shown when the device is locked + showWhenLockedApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(showWhenLockedApp).waitForAndVerify() + + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + } + + teardown { showWhenLockedApp.exit(wmHelper) } + } + + @Test + @FlakyTest(bugId = 227143265) + fun showWhenLockedAppWindowBecomesVisible() { + flicker.assertWm { + this.hasNoVisibleAppWindow() + .then() + .isAppWindowOnTop(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowOnTop(showWhenLockedApp) + } + } + + @Test + @FlakyTest(bugId = 227143265) + fun showWhenLockedAppLayerBecomesVisible() { + flicker.assertLayers { + this.isInvisible(showWhenLockedApp) + .then() + .isVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(showWhenLockedApp) + } + } + + /** {@inheritDoc} */ + @Presubmit @Test override fun appLayerBecomesVisible() = super.appLayerBecomesVisible() + + /** {@inheritDoc} */ + @FlakyTest(bugId = 227143265) + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @FlakyTest(bugId = 209599395) + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Presubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + @Presubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() + + @FlakyTest(bugId = 278227468) + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenTransition.kt new file mode 100644 index 000000000000..30c3ec205bb1 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenTransition.kt @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2021 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Presubmit +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.FlickerTest +import com.android.server.wm.flicker.navBarLayerPositionAtEnd +import com.android.server.wm.flicker.statusBarLayerPositionAtEnd +import org.junit.Assume +import org.junit.Ignore +import org.junit.Test + +/** Base class for app launch tests from lock screen */ +abstract class OpenAppFromLockscreenTransition(flicker: FlickerTest) : OpenAppTransition(flicker) { + + /** Defines the transition used to run the test */ + override val transition: FlickerBuilder.() -> Unit = { + super.transition(this) + setup { + device.sleep() + wmHelper.StateSyncBuilder().withoutTopVisibleAppWindows().waitForAndVerify() + } + teardown { testApp.exit(wmHelper) } + transitions { testApp.launchViaIntent(wmHelper) } + } + + /** Check that we go from no focus to focus on the [testApp] */ + @Presubmit + @Test + open fun focusChanges() { + flicker.assertEventLog { this.focusChanges("", testApp.`package`) } + } + + /** + * Checks that we start of with no top windows and then [testApp] becomes the first and only top + * window of the transition, with snapshot or splash screen windows optionally showing first. + */ + @FlakyTest(bugId = 203538234) + @Test + open fun appWindowBecomesFirstAndOnlyTopWindow() { + flicker.assertWm { + this.hasNoVisibleAppWindow() + .then() + .isAppWindowOnTop(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowOnTop(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isAppWindowOnTop(testApp) + } + } + + /** Checks that the screen is locked at the start of the transition */ + @Presubmit + @Test + fun screenLockedStart() { + flicker.assertLayersStart { isEmpty() } + } + + /** {@inheritDoc} */ + @FlakyTest(bugId = 203538234) + @Test + override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarLayerIsVisibleAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarWindowIsAlwaysVisible() {} + + /** Checks the position of the [ComponentNameMatcher.NAV_BAR] at the end of the transition */ + @Presubmit + @Test + open fun navBarLayerPositionAtEnd() { + Assume.assumeFalse(flicker.scenario.isTablet) + flicker.navBarLayerPositionAtEnd() + } + + /** Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the end of the transition */ + @Presubmit @Test fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerIsVisibleAtStartAndEnd() {} + + /** + * Checks that the [ComponentNameMatcher.STATUS_BAR] layer is visible at the end of the trace + * + * It is not possible to check at the start because the screen is off + */ + @Presubmit + @Test + fun statusBarLayerIsVisibleAtEnd() { + flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.STATUS_BAR) } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt new file mode 100644 index 000000000000..924d03f6d302 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenViaIntentTest.kt @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2021 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.server.wm.flicker.launch + +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Presubmit +import android.tools.common.NavBar +import android.tools.common.Rotation +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.flicker.annotation.FlickerServiceCompatible +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.helpers.NonResizeableAppHelper +import org.junit.Assume +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test launching an app while the device is locked + * + * This test assumes the device doesn't have AOD enabled + * + * To run this test: `atest FlickerTests:OpenAppNonResizeableTest` + * + * Actions: + * ``` + * Lock the device. + * Launch an app on top of the lock screen [testApp] and wait animation to complete + * ``` + * + * Notes: + * ``` + * 1. Some default assertions (e.g., nav bar, status bar and screen covered) + * are inherited [OpenAppTransition] + * 2. Part of the test setup occurs automatically via + * [com.android.server.wm.flicker.TransitionRunnerWithRules], + * including configuring navigation mode, initial orientation and ensuring no + * apps are running before setup + * ``` + */ +@RequiresDevice +@FlickerServiceCompatible +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class OpenAppFromLockscreenViaIntentTest(flicker: FlickerTest) : + OpenAppFromLockscreenTransition(flicker) { + override val testApp = NonResizeableAppHelper(instrumentation) + + /** + * Checks that the [ComponentNameMatcher.NAV_BAR] layer starts invisible, becomes visible during + * unlocking animation and remains visible at the end + */ + @Presubmit + @Test + fun navBarLayerVisibilityChanges() { + Assume.assumeFalse(flicker.scenario.isTablet) + flicker.assertLayers { + this.isInvisible(ComponentNameMatcher.NAV_BAR) + .then() + .isVisible(ComponentNameMatcher.NAV_BAR) + } + } + + /** Checks if [testApp] is visible at the end of the transition */ + @Presubmit + @Test + fun appWindowBecomesVisibleAtEnd() { + flicker.assertWmEnd { this.isAppWindowVisible(testApp) } + } + + /** + * Checks that the [ComponentNameMatcher.NAV_BAR] starts the transition invisible, then becomes + * visible during the unlocking animation and remains visible at the end of the transition + */ + @Presubmit + @Test + fun navBarWindowsVisibilityChanges() { + Assume.assumeFalse(flicker.scenario.isTablet) + flicker.assertWm { + this.isNonAppWindowInvisible(ComponentNameMatcher.NAV_BAR) + .then() + .isAboveAppWindowVisible(ComponentNameMatcher.NAV_BAR) + } + } + + /** + * Checks that the [ComponentNameMatcher.TASK_BAR] starts the transition invisible, then becomes + * visible during the unlocking animation and remains visible at the end of the transition + */ + @Presubmit + @Test + fun taskBarLayerIsVisibleAtEnd() { + Assume.assumeTrue(flicker.scenario.isTablet) + flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.TASK_BAR) } + } + + /** + * Checks that the [ComponentNameMatcher.STATUS_BAR] layer is visible at the end of the trace + * + * It is not possible to check at the start because the screen is off + */ + @Presubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() { + flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.STATUS_BAR) } + } + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarLayerIsVisibleAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarLayerIsVisibleAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarWindowIsAlwaysVisible() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarWindowIsAlwaysVisible() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarWindowIsAlwaysVisible() {} + + /** {@inheritDoc} */ + @Presubmit + @Test + override fun appWindowBecomesFirstAndOnlyTopWindow() = + super.appWindowBecomesFirstAndOnlyTopWindow() + + /** {@inheritDoc} */ + @Presubmit @Test override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() + + /** Checks the [ComponentNameMatcher.NAV_BAR] is visible at the end of the transition */ + @Presubmit + @Test + fun navBarLayerIsVisibleAtEnd() { + Assume.assumeFalse(flicker.scenario.isTablet) + flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.NAV_BAR) } + } + + /** {@inheritDoc} */ + @FlakyTest + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Presubmit + @Test + override fun appLayerBecomesVisible() { + Assume.assumeFalse(flicker.scenario.isTablet) + super.appLayerBecomesVisible() + } + + /** {@inheritDoc} */ + @FlakyTest(bugId = 227143265) + @Test + fun appLayerBecomesVisibleTablet() { + Assume.assumeTrue(flicker.scenario.isTablet) + super.appLayerBecomesVisible() + } + + @Presubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + @FlakyTest(bugId = 251217585) + @Test + override fun focusChanges() { + super.focusChanges() + } + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests( + supportedNavigationModes = listOf(NavBar.MODE_GESTURAL), + supportedRotations = listOf(Rotation.ROTATION_0) + ) + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt deleted file mode 100644 index 7bcb91070ecf..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.platform.test.annotations.Postsubmit -import android.platform.test.annotations.Presubmit -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 com.android.server.wm.flicker.statusBarLayerPositionAtEnd -import org.junit.FixMethodOrder -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test cold launching an app from a notification. - * - * This test assumes the device doesn't have AOD enabled - * - * To run this test: `atest FlickerTests:OpenAppFromNotificationCold` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@Postsubmit -open class OpenAppFromNotificationCold(flicker: FlickerTest) : - OpenAppFromNotificationWarm(flicker) { - /** {@inheritDoc} */ - override val transition: FlickerBuilder.() -> Unit - get() = { - super.transition(this) - - setup { - // Close the app that posted the notification to trigger a cold start next time - // it is open - can't just kill it because that would remove the notification. - tapl.setExpectedRotationCheckEnabled(false) - tapl.goHome() - tapl.workspace.switchToOverview() - tapl.overview.dismissAllTasks() - } - } - - @Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart() - - @Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun statusBarLayerPositionAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun statusBarLayerIsVisibleAtStartAndEnd() = - super.statusBarLayerIsVisibleAtStartAndEnd() - - /** - * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the - * transition - */ - @Presubmit @Test open fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarWindowIsAlwaysVisible() {} - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdCfArm.kt deleted file mode 100644 index 8b4a613305c0..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdCfArm.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.server.wm.flicker.launch - -import android.platform.test.annotations.Postsubmit -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import org.junit.FixMethodOrder -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@Postsubmit -class OpenAppFromNotificationColdCfArm(flicker: FlickerTest) : - OpenAppFromNotificationCold(flicker) { - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTest.kt new file mode 100644 index 000000000000..d873ec5e83e2 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTest.kt @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.platform.test.annotations.Postsubmit +import android.platform.test.annotations.Presubmit +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 com.android.server.wm.flicker.statusBarLayerPositionAtEnd +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test cold launching an app from a notification. + * + * To run this test: `atest FlickerTests:OpenAppFromNotificationCold` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Postsubmit +open class OpenAppFromNotificationColdTest(flicker: FlickerTest) : + OpenAppFromNotificationWarmTest(flicker) { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit + get() = { + super.transition(this) + + setup { + // Close the app that posted the notification to trigger a cold start next time + // it is open - can't just kill it because that would remove the notification. + tapl.setExpectedRotationCheckEnabled(false) + tapl.goHome() + tapl.workspace.switchToOverview() + tapl.overview.dismissAllTasks() + } + } + + @Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart() + + @Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerPositionAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** + * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the + * transition + */ + @Presubmit @Test open fun statusBarLayerPositionAtEnd() = flicker.statusBarLayerPositionAtEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Test + @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") + override fun navBarWindowIsAlwaysVisible() {} + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTestCfArm.kt new file mode 100644 index 000000000000..fb2a48c2ad7f --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTestCfArm.kt @@ -0,0 +1,47 @@ +/* + * 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.server.wm.flicker.launch + +import android.platform.test.annotations.Postsubmit +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import org.junit.FixMethodOrder +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Postsubmit +class OpenAppFromNotificationColdTestCfArm(flicker: FlickerTest) : + OpenAppFromNotificationColdTest(flicker) { + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt deleted file mode 100644 index 425e674dec3a..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.platform.test.annotations.Postsubmit -import android.platform.test.annotations.Presubmit -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 android.tools.device.helpers.wakeUpAndGoToHomeScreen -import android.view.WindowInsets -import android.view.WindowManager -import androidx.test.filters.RequiresDevice -import androidx.test.uiautomator.By -import androidx.test.uiautomator.Until -import com.android.server.wm.flicker.helpers.NotificationAppHelper -import com.android.server.wm.flicker.helpers.setRotation -import com.android.server.wm.flicker.navBarLayerIsVisibleAtEnd -import com.android.server.wm.flicker.navBarLayerPositionAtEnd -import com.android.server.wm.flicker.navBarWindowIsVisibleAtEnd -import com.android.server.wm.flicker.taskBarLayerIsVisibleAtEnd -import com.android.server.wm.flicker.taskBarWindowIsVisibleAtEnd -import org.junit.Assume -import org.junit.FixMethodOrder -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test cold launching an app from a notification. - * - * This test assumes the device doesn't have AOD enabled - * - * To run this test: `atest FlickerTests:OpenAppFromNotificationWarm` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppFromNotificationWarm(flicker: FlickerTest) : OpenAppTransition(flicker) { - override val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) - - open val openingNotificationsFromLockScreen = false - - /** {@inheritDoc} */ - override val transition: FlickerBuilder.() -> Unit - get() = { - setup { - device.wakeUpAndGoToHomeScreen() - this.setRotation(flicker.scenario.startRotation) - testApp.launchViaIntent(wmHelper) - wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() - testApp.postNotification(wmHelper) - device.pressHome() - wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() - } - - transitions { - var startY = 10 - var endY = 3 * device.displayHeight / 4 - var steps = 25 - if (openingNotificationsFromLockScreen) { - val wm: WindowManager = - instrumentation.context.getSystemService(WindowManager::class.java) - ?: error("Unable to connect to WindowManager service") - val metricInsets = wm.currentWindowMetrics.windowInsets - val insets = - metricInsets.getInsetsIgnoringVisibility( - WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout() - ) - - startY = insets.top + 100 - endY = device.displayHeight / 2 - steps = 4 - } - - // Swipe down to show the notification shade - val x = device.displayWidth / 2 - device.swipe(x, startY, x, endY, steps) - device.waitForIdle(2000) - instrumentation.uiAutomation.syncInputTransactions() - - // Launch the activity by clicking the notification - val notification = - device.wait(Until.findObject(By.text("Flicker Test Notification")), 2000L) - notification?.click() ?: error("Notification not found") - instrumentation.uiAutomation.syncInputTransactions() - - // Wait for the app to launch - wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() - } - - teardown { testApp.exit(wmHelper) } - } - - @Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_warmStart() - - @Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_warmStart() - - @Presubmit - @Test - open fun notificationAppWindowVisibleAtEnd() { - flicker.assertWmEnd { this.isAppWindowVisible(testApp) } - } - - @Presubmit - @Test - open fun notificationAppWindowOnTopAtEnd() { - flicker.assertWmEnd { this.isAppWindowOnTop(testApp) } - } - - @Presubmit - @Test - open fun notificationAppLayerVisibleAtEnd() { - flicker.assertLayersEnd { this.isVisible(testApp) } - } - - /** - * Checks that the [ComponentNameMatcher.TASK_BAR] window is visible at the end of the - * transition - * - * Note: Large screen only - */ - @Presubmit - @Test - open fun taskBarWindowIsVisibleAtEnd() { - Assume.assumeTrue(flicker.scenario.isTablet) - flicker.taskBarWindowIsVisibleAtEnd() - } - - /** - * Checks that the [ComponentNameMatcher.TASK_BAR] layer is visible at the end of the transition - * - * Note: Large screen only - */ - @Presubmit - @Test - open fun taskBarLayerIsVisibleAtEnd() { - Assume.assumeTrue(flicker.scenario.isTablet) - flicker.taskBarLayerIsVisibleAtEnd() - } - - /** Checks the position of the [ComponentNameMatcher.NAV_BAR] at the end of the transition */ - @Presubmit - @Test - open fun navBarLayerPositionAtEnd() { - Assume.assumeFalse(flicker.scenario.isTablet) - flicker.navBarLayerPositionAtEnd() - } - - /** {@inheritDoc} */ - @Presubmit - @Test - open fun navBarLayerIsVisibleAtEnd() { - Assume.assumeFalse(flicker.scenario.isTablet) - flicker.navBarLayerIsVisibleAtEnd() - } - - @Presubmit - @Test - open fun navBarWindowIsVisibleAtEnd() { - Assume.assumeFalse(flicker.scenario.isTablet) - flicker.navBarWindowIsVisibleAtEnd() - } - - /** {@inheritDoc} */ - @Test - @Ignore("Display is off at the start") - override fun taskBarLayerIsVisibleAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Postsubmit - override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmCfArm.kt deleted file mode 100644 index 43d28fa60e51..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmCfArm.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.server.wm.flicker.launch - -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import org.junit.FixMethodOrder -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppFromNotificationWarmCfArm(flicker: FlickerTest) : - OpenAppFromNotificationWarm(flicker) { - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTest.kt new file mode 100644 index 000000000000..99668ecd0b68 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTest.kt @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.platform.test.annotations.Postsubmit +import android.platform.test.annotations.Presubmit +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 android.tools.device.helpers.wakeUpAndGoToHomeScreen +import android.view.WindowInsets +import android.view.WindowManager +import androidx.test.filters.RequiresDevice +import androidx.test.uiautomator.By +import androidx.test.uiautomator.Until +import com.android.server.wm.flicker.helpers.NotificationAppHelper +import com.android.server.wm.flicker.helpers.setRotation +import com.android.server.wm.flicker.navBarLayerIsVisibleAtEnd +import com.android.server.wm.flicker.navBarLayerPositionAtEnd +import com.android.server.wm.flicker.navBarWindowIsVisibleAtEnd +import com.android.server.wm.flicker.taskBarLayerIsVisibleAtEnd +import com.android.server.wm.flicker.taskBarWindowIsVisibleAtEnd +import org.junit.Assume +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test cold launching an app from a notification. + * + * To run this test: `atest FlickerTests:OpenAppFromNotificationWarm` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +open class OpenAppFromNotificationWarmTest(flicker: FlickerTest) : OpenAppTransition(flicker) { + override val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) + + open val openingNotificationsFromLockScreen = false + + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit + get() = { + setup { + device.wakeUpAndGoToHomeScreen() + this.setRotation(flicker.scenario.startRotation) + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + testApp.postNotification(wmHelper) + device.pressHome() + wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() + } + + transitions { + var startY = 10 + var endY = 3 * device.displayHeight / 4 + var steps = 25 + if (openingNotificationsFromLockScreen) { + val wm: WindowManager = + instrumentation.context.getSystemService(WindowManager::class.java) + ?: error("Unable to connect to WindowManager service") + val metricInsets = wm.currentWindowMetrics.windowInsets + val insets = + metricInsets.getInsetsIgnoringVisibility( + WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout() + ) + + startY = insets.top + 100 + endY = device.displayHeight / 2 + steps = 4 + } + + // Swipe down to show the notification shade + val x = device.displayWidth / 2 + device.swipe(x, startY, x, endY, steps) + device.waitForIdle(2000) + instrumentation.uiAutomation.syncInputTransactions() + + // Launch the activity by clicking the notification + val notification = + device.wait(Until.findObject(By.text("Flicker Test Notification")), 2000L) + notification?.click() ?: error("Notification not found") + instrumentation.uiAutomation.syncInputTransactions() + + // Wait for the app to launch + wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify() + } + + teardown { testApp.exit(wmHelper) } + } + + @Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_warmStart() + + @Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_warmStart() + + @Presubmit + @Test + open fun notificationAppWindowVisibleAtEnd() { + flicker.assertWmEnd { this.isAppWindowVisible(testApp) } + } + + @Presubmit + @Test + open fun notificationAppWindowOnTopAtEnd() { + flicker.assertWmEnd { this.isAppWindowOnTop(testApp) } + } + + @Presubmit + @Test + open fun notificationAppLayerVisibleAtEnd() { + flicker.assertLayersEnd { this.isVisible(testApp) } + } + + /** + * Checks that the [ComponentNameMatcher.TASK_BAR] window is visible at the end of the + * transition + * + * Note: Large screen only + */ + @Presubmit + @Test + open fun taskBarWindowIsVisibleAtEnd() { + Assume.assumeTrue(flicker.scenario.isTablet) + flicker.taskBarWindowIsVisibleAtEnd() + } + + /** + * Checks that the [ComponentNameMatcher.TASK_BAR] layer is visible at the end of the transition + * + * Note: Large screen only + */ + @Presubmit + @Test + open fun taskBarLayerIsVisibleAtEnd() { + Assume.assumeTrue(flicker.scenario.isTablet) + flicker.taskBarLayerIsVisibleAtEnd() + } + + /** Checks the position of the [ComponentNameMatcher.NAV_BAR] at the end of the transition */ + @Presubmit + @Test + open fun navBarLayerPositionAtEnd() { + Assume.assumeFalse(flicker.scenario.isTablet) + flicker.navBarLayerPositionAtEnd() + } + + /** {@inheritDoc} */ + @Presubmit + @Test + open fun navBarLayerIsVisibleAtEnd() { + Assume.assumeFalse(flicker.scenario.isTablet) + flicker.navBarLayerIsVisibleAtEnd() + } + + @Presubmit + @Test + open fun navBarWindowIsVisibleAtEnd() { + Assume.assumeFalse(flicker.scenario.isTablet) + flicker.navBarWindowIsVisibleAtEnd() + } + + /** {@inheritDoc} */ + @Test + @Ignore("Display is off at the start") + override fun taskBarLayerIsVisibleAtStartAndEnd() {} + + /** {@inheritDoc} */ + @Test + @Postsubmit + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTestCfArm.kt new file mode 100644 index 000000000000..2a2597e1ebe8 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTestCfArm.kt @@ -0,0 +1,45 @@ +/* + * 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.server.wm.flicker.launch + +import android.tools.device.flicker.junit.FlickerParametersRunnerFactory +import android.tools.device.flicker.legacy.FlickerTest +import android.tools.device.flicker.legacy.FlickerTestFactory +import org.junit.FixMethodOrder +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenAppFromNotificationWarmTestCfArm(flicker: FlickerTest) : + OpenAppFromNotificationWarmTest(flicker) { + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt deleted file mode 100644 index 1383ae39f760..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2021 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -import android.platform.test.annotations.Presubmit -import android.tools.common.NavBar -import android.tools.common.Rotation -import android.tools.common.traces.component.ComponentNameMatcher -import android.tools.device.flicker.annotation.FlickerServiceCompatible -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import androidx.test.filters.RequiresDevice -import com.android.server.wm.flicker.helpers.NonResizeableAppHelper -import org.junit.Assume -import org.junit.FixMethodOrder -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test launching an app while the device is locked - * - * This test assumes the device doesn't have AOD enabled - * - * To run this test: `atest FlickerTests:OpenAppNonResizeableTest` - * - * Actions: - * ``` - * Lock the device. - * Launch an app on top of the lock screen [testApp] and wait animation to complete - * ``` - * - * Notes: - * ``` - * 1. Some default assertions (e.g., nav bar, status bar and screen covered) - * are inherited [OpenAppTransition] - * 2. Part of the test setup occurs automatically via - * [com.android.server.wm.flicker.TransitionRunnerWithRules], - * including configuring navigation mode, initial orientation and ensuring no - * apps are running before setup - * ``` - */ -@RequiresDevice -@FlickerServiceCompatible -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppNonResizeableTest(flicker: FlickerTest) : OpenAppFromLockTransition(flicker) { - override val testApp = NonResizeableAppHelper(instrumentation) - - /** - * Checks that the [ComponentNameMatcher.NAV_BAR] layer starts invisible, becomes visible during - * unlocking animation and remains visible at the end - */ - @Presubmit - @Test - fun navBarLayerVisibilityChanges() { - Assume.assumeFalse(flicker.scenario.isTablet) - flicker.assertLayers { - this.isInvisible(ComponentNameMatcher.NAV_BAR) - .then() - .isVisible(ComponentNameMatcher.NAV_BAR) - } - } - - /** Checks if [testApp] is visible at the end of the transition */ - @Presubmit - @Test - fun appWindowBecomesVisibleAtEnd() { - flicker.assertWmEnd { this.isAppWindowVisible(testApp) } - } - - /** - * Checks that the [ComponentNameMatcher.NAV_BAR] starts the transition invisible, then becomes - * visible during the unlocking animation and remains visible at the end of the transition - */ - @Presubmit - @Test - fun navBarWindowsVisibilityChanges() { - Assume.assumeFalse(flicker.scenario.isTablet) - flicker.assertWm { - this.isNonAppWindowInvisible(ComponentNameMatcher.NAV_BAR) - .then() - .isAboveAppWindowVisible(ComponentNameMatcher.NAV_BAR) - } - } - - /** - * Checks that the [ComponentNameMatcher.TASK_BAR] starts the transition invisible, then becomes - * visible during the unlocking animation and remains visible at the end of the transition - */ - @Presubmit - @Test - fun taskBarLayerIsVisibleAtEnd() { - Assume.assumeTrue(flicker.scenario.isTablet) - flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.TASK_BAR) } - } - - /** - * Checks that the [ComponentNameMatcher.STATUS_BAR] layer is visible at the end of the trace - * - * It is not possible to check at the start because the screen is off - */ - @Presubmit - @Test - override fun statusBarLayerIsVisibleAtStartAndEnd() { - flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.STATUS_BAR) } - } - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun taskBarLayerIsVisibleAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun navBarLayerIsVisibleAtStartAndEnd() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun taskBarWindowIsAlwaysVisible() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun navBarWindowIsAlwaysVisible() {} - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts locked and app is full screen at the end") - override fun navBarWindowIsVisibleAtStartAndEnd() = super.navBarWindowIsVisibleAtStartAndEnd() - - /** {@inheritDoc} */ - @Test - @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") - override fun statusBarWindowIsAlwaysVisible() {} - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun appWindowBecomesFirstAndOnlyTopWindow() = - super.appWindowBecomesFirstAndOnlyTopWindow() - - /** {@inheritDoc} */ - @Presubmit @Test override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() - - /** Checks the [ComponentNameMatcher.NAV_BAR] is visible at the end of the transition */ - @Presubmit - @Test - fun navBarLayerIsVisibleAtEnd() { - Assume.assumeFalse(flicker.scenario.isTablet) - flicker.assertLayersEnd { this.isVisible(ComponentNameMatcher.NAV_BAR) } - } - - /** {@inheritDoc} */ - @FlakyTest - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun appLayerBecomesVisible() { - Assume.assumeFalse(flicker.scenario.isTablet) - super.appLayerBecomesVisible() - } - - /** {@inheritDoc} */ - @FlakyTest(bugId = 227143265) - @Test - fun appLayerBecomesVisibleTablet() { - Assume.assumeTrue(flicker.scenario.isTablet) - super.appLayerBecomesVisible() - } - - @Presubmit - @Test - override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = - super.visibleWindowsShownMoreThanOneConsecutiveEntry() - - @FlakyTest(bugId = 251217585) - @Test - override fun focusChanges() { - super.focusChanges() - } - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests( - supportedNavigationModes = listOf(NavBar.MODE_GESTURAL), - supportedRotations = listOf(Rotation.ROTATION_0) - ) - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt deleted file mode 100644 index 3385830ee77f..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2020 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.server.wm.flicker.launch - -import android.platform.test.annotations.FlakyTest -import android.platform.test.annotations.Presubmit -import android.tools.device.flicker.annotation.FlickerServiceCompatible -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 com.android.server.wm.flicker.helpers.setRotation -import org.junit.FixMethodOrder -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test warm launching an app from launcher - * - * To run this test: `atest FlickerTests:OpenAppWarmTest` - * - * Actions: - * ``` - * Launch [testApp] - * Press home - * Relaunch an app [testApp] and wait animation to complete (only this action is traced) - * ``` - * - * Notes: - * ``` - * 1. Some default assertions (e.g., nav bar, status bar and screen covered) - * are inherited [OpenAppTransition] - * 2. Part of the test setup occurs automatically via - * [com.android.server.wm.flicker.TransitionRunnerWithRules], - * including configuring navigation mode, initial orientation and ensuring no - * apps are running before setup - * ``` - */ -@RequiresDevice -@FlickerServiceCompatible -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -open class OpenAppWarmTest(flicker: FlickerTest) : OpenAppFromLauncherTransition(flicker) { - /** Defines the transition used to run the test */ - override val transition: FlickerBuilder.() -> Unit - get() = { - super.transition(this) - setup { - tapl.setExpectedRotationCheckEnabled(false) - testApp.launchViaIntent(wmHelper) - tapl.goHome() - wmHelper.StateSyncBuilder().withHomeActivityVisible().waitForAndVerify() - this.setRotation(flicker.scenario.startRotation) - } - teardown { testApp.exit(wmHelper) } - transitions { testApp.launchViaIntent(wmHelper) } - } - - /** {@inheritDoc} */ - @FlakyTest(bugId = 206753786) - @Test - override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun appLayerBecomesVisible() = super.appLayerBecomesVisible_warmStart() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun appWindowBecomesVisible() = super.appWindowBecomesVisible_warmStart() - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTestCfArm.kt deleted file mode 100644 index d8b38b30cf13..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTestCfArm.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.server.wm.flicker.launch - -import android.tools.device.flicker.annotation.FlickerServiceCompatible -import android.tools.device.flicker.junit.FlickerParametersRunnerFactory -import android.tools.device.flicker.legacy.FlickerTest -import android.tools.device.flicker.legacy.FlickerTestFactory -import org.junit.FixMethodOrder -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -@FlickerServiceCompatible -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenAppWarmTestCfArm(flicker: FlickerTest) : OpenAppWarmTest(flicker) { - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraFromHomeOnDoubleClickPowerButtonTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraFromHomeOnDoubleClickPowerButtonTest.kt new file mode 100644 index 000000000000..6ee8ae69924a --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraFromHomeOnDoubleClickPowerButtonTest.kt @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2022 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.server.wm.flicker.launch + +import android.os.SystemClock +import android.platform.test.annotations.Postsubmit +import android.tools.device.apphelpers.CameraAppHelper +import android.tools.device.apphelpers.StandardAppHelper +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.flicker.rules.RemoveAllTasksButHomeRule +import android.view.KeyEvent +import androidx.test.filters.RequiresDevice +import com.android.server.wm.flicker.helpers.setRotation +import org.junit.FixMethodOrder +import org.junit.Ignore +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.MethodSorters +import org.junit.runners.Parameterized + +/** + * Test cold launching camera from launcher by double pressing power button + * + * To run this test: `atest FlickerTests:OpenCameraOnDoubleClickPowerButton` + * + * Actions: + * ``` + * Make sure no apps are running on the device + * Launch an app [testApp] and wait animation to complete + * ``` + * + * Notes: + * ``` + * 1. Some default assertions (e.g., nav bar, status bar and screen covered) + * are inherited [OpenAppTransition] + * 2. Part of the test setup occurs automatically via + * [com.android.server.wm.flicker.TransitionRunnerWithRules], + * including configuring navigation mode, initial orientation and ensuring no + * apps are running before setup + * ``` + */ +@RequiresDevice +@RunWith(Parameterized::class) +@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +class OpenCameraFromHomeOnDoubleClickPowerButtonTest(flicker: FlickerTest) : + OpenAppFromLauncherTransition(flicker) { + private val cameraApp = CameraAppHelper(instrumentation) + override val testApp: StandardAppHelper + get() = cameraApp + + override val transition: FlickerBuilder.() -> Unit + get() = { + setup { + RemoveAllTasksButHomeRule.removeAllTasksButHome() + this.setRotation(flicker.scenario.startRotation) + } + transitions { + device.pressKeyCode(KeyEvent.KEYCODE_POWER) + SystemClock.sleep(100) + device.pressKeyCode(KeyEvent.KEYCODE_POWER) + wmHelper.StateSyncBuilder().withWindowSurfaceAppeared(cameraApp).waitForAndVerify() + } + teardown { RemoveAllTasksButHomeRule.removeAllTasksButHome() } + } + + @Postsubmit @Test override fun appLayerBecomesVisible() = super.appLayerBecomesVisible() + + @Postsubmit @Test override fun appWindowAsTopWindowAtEnd() = super.appWindowAsTopWindowAtEnd() + + @Postsubmit @Test override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow() + + @Postsubmit @Test override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() + + @Postsubmit @Test override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() + + @Postsubmit @Test override fun appWindowIsTopWindowAtEnd() = super.appWindowIsTopWindowAtEnd() + + @Postsubmit + @Test + override fun appWindowReplacesLauncherAsTopWindow() = + super.appWindowReplacesLauncherAsTopWindow() + + @Postsubmit @Test override fun focusChanges() = super.focusChanges() + + @Postsubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() + + @Ignore("Not applicable to this CUJ. App is full screen at the end") + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + @Ignore("Status bar visibility depends on whether the permission dialog is displayed or not") + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + @Ignore("Status bar visibility depends on whether the permission dialog is displayed or not") + @Test + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() + + @Ignore("Status bar visibility depends on whether the permission dialog is displayed or not") + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + @Ignore("Not applicable to this CUJ. App is full screen at the end") + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + @Ignore("Not applicable to this CUJ. App is full screen at the end") + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + @Ignore("Not applicable to this CUJ. App is full screen at the end") + @Test + override fun navBarWindowIsVisibleAtStartAndEnd() { + super.navBarWindowIsVisibleAtStartAndEnd() + } + + companion object { + /** + * Creates the test configurations. + * + * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and + * navigation modes. + */ + @Parameterized.Parameters(name = "{0}") + @JvmStatic + fun getParams(): Collection { + return FlickerTestFactory.nonRotationTests() + } + } +} diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraOnDoubleClickPowerButton.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraOnDoubleClickPowerButton.kt deleted file mode 100644 index ae9ca8007dc8..000000000000 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenCameraOnDoubleClickPowerButton.kt +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2022 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.server.wm.flicker.launch - -import android.os.SystemClock -import android.platform.test.annotations.Postsubmit -import android.tools.device.apphelpers.CameraAppHelper -import android.tools.device.apphelpers.StandardAppHelper -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.flicker.rules.RemoveAllTasksButHomeRule -import android.view.KeyEvent -import androidx.test.filters.RequiresDevice -import com.android.server.wm.flicker.helpers.setRotation -import org.junit.FixMethodOrder -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.MethodSorters -import org.junit.runners.Parameterized - -/** - * Test cold launching camera from launcher by double pressing power button - * - * To run this test: `atest FlickerTests:OpenCameraOnDoubleClickPowerButton` - * - * Actions: - * ``` - * Make sure no apps are running on the device - * Launch an app [testApp] and wait animation to complete - * ``` - * - * Notes: - * ``` - * 1. Some default assertions (e.g., nav bar, status bar and screen covered) - * are inherited [OpenAppTransition] - * 2. Part of the test setup occurs automatically via - * [com.android.server.wm.flicker.TransitionRunnerWithRules], - * including configuring navigation mode, initial orientation and ensuring no - * apps are running before setup - * ``` - */ -@RequiresDevice -@RunWith(Parameterized::class) -@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -class OpenCameraOnDoubleClickPowerButton(flicker: FlickerTest) : - OpenAppFromLauncherTransition(flicker) { - private val cameraApp = CameraAppHelper(instrumentation) - override val testApp: StandardAppHelper - get() = cameraApp - - override val transition: FlickerBuilder.() -> Unit - get() = { - setup { - RemoveAllTasksButHomeRule.removeAllTasksButHome() - this.setRotation(flicker.scenario.startRotation) - } - transitions { - device.pressKeyCode(KeyEvent.KEYCODE_POWER) - SystemClock.sleep(100) - device.pressKeyCode(KeyEvent.KEYCODE_POWER) - wmHelper.StateSyncBuilder().withWindowSurfaceAppeared(cameraApp).waitForAndVerify() - } - teardown { RemoveAllTasksButHomeRule.removeAllTasksButHome() } - } - - @Postsubmit @Test override fun appLayerBecomesVisible() = super.appLayerBecomesVisible() - - @Postsubmit @Test override fun appWindowAsTopWindowAtEnd() = super.appWindowAsTopWindowAtEnd() - - @Postsubmit @Test override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow() - - @Postsubmit @Test override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() - - @Postsubmit @Test override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() - - @Postsubmit @Test override fun appWindowIsTopWindowAtEnd() = super.appWindowIsTopWindowAtEnd() - - @Postsubmit - @Test - override fun appWindowReplacesLauncherAsTopWindow() = - super.appWindowReplacesLauncherAsTopWindow() - - @Postsubmit @Test override fun focusChanges() = super.focusChanges() - - @Postsubmit @Test override fun entireScreenCovered() = super.entireScreenCovered() - - @Ignore("Not applicable to this CUJ. App is full screen at the end") - @Test - override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() - - @Postsubmit - @Test - override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - - @Postsubmit - @Test - override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() - - @Ignore("Status bar visibility depends on whether the permission dialog is displayed or not") - @Test - override fun statusBarLayerIsVisibleAtStartAndEnd() = - super.statusBarLayerIsVisibleAtStartAndEnd() - - @Ignore("Status bar visibility depends on whether the permission dialog is displayed or not") - @Test - override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() - - @Ignore("Status bar visibility depends on whether the permission dialog is displayed or not") - @Test - override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() - - @Ignore("Not applicable to this CUJ. App is full screen at the end") - @Test - override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() - - @Ignore("Not applicable to this CUJ. App is full screen at the end") - @Test - override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() - - @Postsubmit - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() - - @Postsubmit - @Test - override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = - super.visibleWindowsShownMoreThanOneConsecutiveEntry() - - @Ignore("Not applicable to this CUJ. App is full screen at the end") - @Test - override fun navBarWindowIsVisibleAtStartAndEnd() { - super.navBarWindowIsVisibleAtStartAndEnd() - } - - companion object { - /** - * Creates the test configurations. - * - * See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and - * navigation modes. - */ - @Parameterized.Parameters(name = "{0}") - @JvmStatic - fun getParams(): Collection { - return FlickerTestFactory.nonRotationTests() - } - } -} -- cgit v1.2.3-59-g8ed1b