From 5fd4566c75030412c83f23423422b732bdd6ad1f Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Wed, 21 Jun 2023 15:04:29 +0000 Subject: [PATCH] Split notification and app launch tests in different modules And avoid androidx startup provider conflict Test: atest FlickerLibTest Bug: 269627537 Change-Id: Ibe9dd0fdc2a5ca639434e86d5e62ddc670e30eb2 --- .../flicker/manifests/AndroidManifest.xml | 12 +- tests/FlickerTests/Android.bp | 17 +++ .../manifests/AndroidManifest.xml | 7 + .../manifests/AndroidManifestNotification.xml | 24 ++++ ...enAppFromLockscreenNotificationColdTest.kt | 4 +- ...enAppFromLockscreenNotificationWarmTest.kt | 4 +- ...ockscreenNotificationWithOverlayAppTest.kt | 4 +- .../OpenAppFromNotificationColdTest.kt | 4 +- .../OpenAppFromNotificationColdTestCfArm.kt | 2 +- .../OpenAppFromNotificationWarmTest.kt | 4 +- .../OpenAppFromNotificationWarmTestCfArm.kt | 2 +- .../flicker/notification/OpenAppTransition.kt | 136 ++++++++++++++++++ 12 files changed, 203 insertions(+), 17 deletions(-) create mode 100644 tests/FlickerTests/manifests/AndroidManifestNotification.xml rename tests/FlickerTests/src/com/android/server/wm/flicker/{launch => notification}/OpenAppFromLockscreenNotificationColdTest.kt (97%) rename tests/FlickerTests/src/com/android/server/wm/flicker/{launch => notification}/OpenAppFromLockscreenNotificationWarmTest.kt (98%) rename tests/FlickerTests/src/com/android/server/wm/flicker/{launch => notification}/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt (97%) rename tests/FlickerTests/src/com/android/server/wm/flicker/{launch => notification}/OpenAppFromNotificationColdTest.kt (97%) rename tests/FlickerTests/src/com/android/server/wm/flicker/{launch => notification}/OpenAppFromNotificationColdTestCfArm.kt (97%) rename tests/FlickerTests/src/com/android/server/wm/flicker/{launch => notification}/OpenAppFromNotificationWarmTest.kt (98%) rename tests/FlickerTests/src/com/android/server/wm/flicker/{launch => notification}/OpenAppFromNotificationWarmTestCfArm.kt (96%) create mode 100644 tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppTransition.kt diff --git a/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml b/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml index 4721741611cf7..6a87de47def4c 100644 --- a/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml +++ b/libs/WindowManager/Shell/tests/flicker/manifests/AndroidManifest.xml @@ -15,6 +15,7 @@ --> @@ -57,10 +58,11 @@ - - - + + + diff --git a/tests/FlickerTests/Android.bp b/tests/FlickerTests/Android.bp index a996fa100da97..8faedebb46014 100644 --- a/tests/FlickerTests/Android.bp +++ b/tests/FlickerTests/Android.bp @@ -52,6 +52,11 @@ filegroup { srcs: ["src/**/launch/*.kt"], } +filegroup { + name: "FlickerTestsNotification-src", + srcs: ["src/**/notification/*.kt"], +} + filegroup { name: "FlickerTestsQuickswitch-src", srcs: ["src/**/quickswitch/*.kt"], @@ -145,6 +150,18 @@ android_test { ], } +android_test { + name: "FlickerTestsNotification", + defaults: ["FlickerTestsDefault"], + additional_manifests: ["manifests/AndroidManifestNotification.xml"], + package_name: "com.android.server.wm.flicker.notification", + instrumentation_target_package: "com.android.server.wm.flicker.notification", + srcs: [ + ":FlickerTestsBase-src", + ":FlickerTestsNotification-src", + ], +} + android_test { name: "FlickerTestsQuickswitch", defaults: ["FlickerTestsDefault"], diff --git a/tests/FlickerTests/manifests/AndroidManifest.xml b/tests/FlickerTests/manifests/AndroidManifest.xml index de8a3c680768b..1a34d9ea0f83d 100644 --- a/tests/FlickerTests/manifests/AndroidManifest.xml +++ b/tests/FlickerTests/manifests/AndroidManifest.xml @@ -16,6 +16,7 @@ --> @@ -47,5 +48,11 @@ + + + diff --git a/tests/FlickerTests/manifests/AndroidManifestNotification.xml b/tests/FlickerTests/manifests/AndroidManifestNotification.xml new file mode 100644 index 0000000000000..ad33deef8cc3c --- /dev/null +++ b/tests/FlickerTests/manifests/AndroidManifestNotification.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationColdTest.kt similarity index 97% rename from tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationColdTest.kt rename to tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationColdTest.kt index 74563a28017fc..6f5daeb22bed4 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationColdTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationColdTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.platform.test.rule.SettingOverrideRule diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWarmTest.kt similarity index 98% rename from tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWarmTest.kt rename to tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWarmTest.kt index 2f922064d60f4..483caa71abee2 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWarmTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWarmTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt similarity index 97% rename from tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt rename to tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt index 0ae514a83da6d..c3363995d58f5 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromLockscreenNotificationWithOverlayAppTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Postsubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTest.kt similarity index 97% rename from tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTest.kt rename to tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTest.kt index 6f99ad2fccc37..50dec3bf2f02a 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTestCfArm.kt similarity index 97% rename from tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTestCfArm.kt rename to tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTestCfArm.kt index 4ec02096f9a3b..a147171ed9367 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationColdTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationColdTestCfArm.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.tools.device.flicker.junit.FlickerParametersRunnerFactory diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt similarity index 98% rename from tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTest.kt rename to tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt index 3b6c7bd87aa51..19a070b1a4028 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTestCfArm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTestCfArm.kt similarity index 96% rename from tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTestCfArm.kt rename to tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTestCfArm.kt index b5db3b06b7cbf..98356d7d1e87c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarmTestCfArm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTestCfArm.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wm.flicker.launch +package com.android.server.wm.flicker.notification import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.LegacyFlickerTest diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppTransition.kt new file mode 100644 index 0000000000000..684b4b70f9508 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/notification/OpenAppTransition.kt @@ -0,0 +1,136 @@ +/* + * 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.notification + +import android.platform.test.annotations.Presubmit +import android.tools.common.traces.component.ComponentNameMatcher +import android.tools.device.apphelpers.StandardAppHelper +import android.tools.device.flicker.legacy.FlickerBuilder +import android.tools.device.flicker.legacy.LegacyFlickerTest +import android.tools.device.helpers.wakeUpAndGoToHomeScreen +import com.android.server.wm.flicker.BaseTest +import com.android.server.wm.flicker.helpers.SimpleAppHelper +import com.android.server.wm.flicker.helpers.setRotation +import org.junit.Test + +/** Base class for app launch tests */ +abstract class OpenAppTransition(flicker: LegacyFlickerTest) : BaseTest(flicker) { + protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) + + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + tapl.setExpectedRotation(flicker.scenario.startRotation.value) + device.wakeUpAndGoToHomeScreen() + this.setRotation(flicker.scenario.startRotation) + } + teardown { testApp.exit(wmHelper) } + } + + /** + * Checks that the [testApp] layer doesn't exist or is invisible at the start of the transition, + * but is created and/or becomes visible during the transition. + */ + @Presubmit + @Test + open fun appLayerBecomesVisible() { + appLayerBecomesVisible_coldStart() + } + + protected fun appLayerBecomesVisible_coldStart() { + flicker.assertLayers { + this.notContains(testApp) + .then() + .isInvisible(testApp, isOptional = true) + .then() + .isVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isVisible(testApp) + } + } + + protected fun appLayerBecomesVisible_warmStart() { + flicker.assertLayers { + this.isInvisible(testApp) + .then() + .isVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isVisible(testApp) + } + } + + /** + * Checks that the [testApp] window doesn't exist at the start of the transition, that it is + * created (invisible - optional) and becomes visible during the transition + * + * The `isAppWindowInvisible` step is optional because we log once per frame, upon logging, the + * window may be visible or not depending on what was processed until that moment. + */ + @Presubmit @Test open fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart() + + protected fun appWindowBecomesVisible_coldStart() { + flicker.assertWm { + this.notContains(testApp) + .then() + .isAppWindowInvisible(testApp, isOptional = true) + .then() + .isAppWindowVisible(testApp) + } + } + + protected fun appWindowBecomesVisible_warmStart() { + flicker.assertWm { + this.isAppWindowInvisible(testApp) + .then() + .isAppWindowVisible(ComponentNameMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowVisible(ComponentNameMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isAppWindowVisible(testApp) + } + } + + /** + * Checks that [testApp] window is not on top at the start of the transition, and then becomes + * the top visible window until the end of the transition. + */ + @Presubmit + @Test + open fun appWindowBecomesTopWindow() { + flicker.assertWm { + this.isAppWindowNotOnTop(testApp) + .then() + .isAppWindowOnTop( + testApp.or(ComponentNameMatcher.SNAPSHOT).or(ComponentNameMatcher.SPLASH_SCREEN) + ) + } + } + + /** + * Checks that [testApp] window is not on top at the start of the transition, and then becomes + * the top visible window until the end of the transition. + */ + @Presubmit + @Test + open fun appWindowIsTopWindowAtEnd() { + flicker.assertWmEnd { this.isAppWindowOnTop(testApp) } + } +}