From 8635302f058641472cb14e076e70b203354a77fb Mon Sep 17 00:00:00 2001 From: Antonella Dellanzo Date: Wed, 9 Dec 2020 14:36:43 +0100 Subject: [PATCH] Adding assertions to ReOpenImeWindowTest Updating ReOpenImeWindowTest & OpenAppFromOverviewTest transition to wait for fullscreen app instead of hasWindow as this last one was not completely correct. Adding the assertions for the test ReOpenImeWindowTest. Adding also some missing assertions to OpenImeWindowTest. Moving some tests from CommonAssertions launch file to flicker common assertions so that other tests, besides the lunch ones, can use them: - wallpaperWindowBecomesInvisible - appLayerReplacesWallpaperLayer Adding new IME assertions: - imeWindowBecomesVisible - imeAppWindowBecomesVisible Renaming assertion windowAlwaysVisible to appWindowAlwaysVisibleOnTop to be more clear on what it does. Test: atest FlickerTests Bug: b/175197807 Change-Id: I157962d53f1254a04c9abef7c6ad2bd1392b1728 --- .../server/wm/flicker/CommonAssertions.kt | 27 +++++++++- .../server/wm/flicker/ime/CommonAssertions.kt | 23 +++++++++ .../wm/flicker/ime/OpenImeWindowTest.kt | 13 ++--- .../wm/flicker/ime/ReOpenImeWindowTest.kt | 51 +++++++++++++++++-- .../wm/flicker/launch/CommonAssertions.kt | 24 --------- .../wm/flicker/launch/OpenAppColdTest.kt | 4 +- .../flicker/launch/OpenAppFromOverviewTest.kt | 11 ++-- .../wm/flicker/launch/OpenAppWarmTest.kt | 4 +- .../rotation/SeamlessAppRotationTest.kt | 4 +- .../wm/flicker/testapp/ActivityOptions.java | 6 +++ 10 files changed, 122 insertions(+), 45 deletions(-) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt index bd7e8d7683d18..0df44543a74e6 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt @@ -80,12 +80,23 @@ fun WmAssertion.wallpaperWindowBecomesVisible( } } -fun WmAssertion.windowAlwaysVisible( +fun WmAssertion.wallpaperWindowBecomesInvisible( + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("wallpaperWindowBecomesInvisible", bugId, enabled) { + this.showsBelowAppWindow("Wallpaper") + .then() + .hidesBelowAppWindow("Wallpaper") + } +} + +fun WmAssertion.appWindowAlwaysVisibleOnTop( packageName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 ) { - all("windowAlwaysVisible", bugId, enabled) { + all("appWindowAlwaysVisibleOnTop", bugId, enabled) { this.showsAppWindowOnTop(packageName) } } @@ -214,6 +225,18 @@ fun LayersAssertion.visibleLayersShownMoreThanOneConsecutiveEntry( } } +fun LayersAssertion.appLayerReplacesWallpaperLayer( + appName: String, + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("appLayerReplacesWallpaperLayer", bugId, enabled) { + this.showsLayer("Wallpaper") + .then() + .replaceVisibleLayer("Wallpaper", appName) + } +} + fun LayersAssertion.wallpaperLayerReplacesAppLayer( testApp: IAppHelper, bugId: Int = 0, diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt index 579862483576c..aa34b5d23946b 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt @@ -65,6 +65,17 @@ fun WmAssertion.imeAppWindowIsAlwaysVisible( } } +fun WmAssertion.imeWindowBecomesVisible( + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("imeWindowBecomesVisible", bugId, enabled) { + this.hidesNonAppWindow(IME_WINDOW_TITLE) + .then() + .showsNonAppWindow(IME_WINDOW_TITLE) + } +} + fun WmAssertion.imeWindowBecomesInvisible( bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -76,6 +87,18 @@ fun WmAssertion.imeWindowBecomesInvisible( } } +fun WmAssertion.imeAppWindowBecomesVisible( + windowName: String, + bugId: Int = 0, + enabled: Boolean = bugId == 0 +) { + all("imeAppWindowBecomesVisible", bugId, enabled) { + this.hidesAppWindow(windowName) + .then() + .showsAppWindow(windowName) + } +} + fun WmAssertion.imeAppWindowBecomesInvisible( testApp: IAppHelper, bugId: Int = 0, diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt index 64a8f304298b1..28a8bd3857798 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt @@ -33,6 +33,8 @@ import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry import com.android.server.wm.flicker.noUncoveredRegions +import com.android.server.wm.flicker.appWindowAlwaysVisibleOnTop +import com.android.server.wm.flicker.layerAlwaysVisible import com.android.server.wm.flicker.repetitions import com.android.server.wm.flicker.startRotation import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible @@ -56,8 +58,6 @@ class OpenImeWindowTest( flickerSpec: Flicker ) : FlickerTestRunner(testName, flickerSpec) { companion object { - private const val IME_WINDOW_TITLE = "InputMethod" - @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): List> { @@ -93,12 +93,8 @@ class OpenImeWindowTest( statusBarWindowIsAlwaysVisible() visibleWindowsShownMoreThanOneConsecutiveEntry() - all("imeWindowBecomesVisible") { - this.skipUntilFirstAssertion() - .hidesNonAppWindow(IME_WINDOW_TITLE) - .then() - .showsNonAppWindow(IME_WINDOW_TITLE) - } + imeWindowBecomesVisible() + appWindowAlwaysVisibleOnTop(testApp.`package`) } layersTrace { @@ -110,6 +106,7 @@ class OpenImeWindowTest( visibleLayersShownMoreThanOneConsecutiveEntry() imeLayerBecomesVisible() + layerAlwaysVisible(testApp.`package`) } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt index 7bd96f574ee2b..c7114da501178 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt @@ -23,14 +23,27 @@ import androidx.test.platform.app.InstrumentationRegistry import com.android.server.wm.flicker.Flicker import com.android.server.wm.flicker.FlickerTestRunner import com.android.server.wm.flicker.FlickerTestRunnerFactory -import com.android.server.wm.flicker.helpers.buildTestTag import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper import com.android.server.wm.flicker.helpers.reopenAppFromOverview -import com.android.server.wm.flicker.helpers.hasWindow +import com.android.server.wm.flicker.helpers.buildTestTag import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen +import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible +import com.android.server.wm.flicker.navBarLayerRotatesAndScales +import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible +import com.android.server.wm.flicker.wallpaperWindowBecomesInvisible +import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer +import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry +import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry +import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper +import com.android.server.wm.flicker.noUncoveredRegions import com.android.server.wm.flicker.repetitions import com.android.server.wm.flicker.startRotation +import com.android.server.wm.flicker.endRotation +import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible +import com.android.server.wm.flicker.statusBarLayerRotatesScales +import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible +import com.android.server.wm.flicker.testapp.ActivityOptions import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -54,8 +67,9 @@ class ReOpenImeWindowTest( fun getParams(): List> { val instrumentation = InstrumentationRegistry.getInstrumentation() val testApp = ImeAppAutoFocusHelper(instrumentation) + val testAppComponentName = ActivityOptions.IME_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME - return FlickerTestRunnerFactory(instrumentation, repetitions = 10) + return FlickerTestRunnerFactory(instrumentation, repetitions = 5) .buildTest { configuration -> withTestName { buildTestTag("reOpenImeAutoFocus", testApp, configuration) } repeat { configuration.repetitions } @@ -73,7 +87,7 @@ class ReOpenImeWindowTest( } transitions { device.reopenAppFromOverview() - device.hasWindow(testApp.getPackage()) + WindowManagerStateHelper().waitForFullScreenApp(testAppComponentName) } teardown { eachRun { @@ -84,6 +98,35 @@ class ReOpenImeWindowTest( this.setRotation(Surface.ROTATION_0) } } + assertions { + windowManagerTrace { + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() + visibleWindowsShownMoreThanOneConsecutiveEntry() + + imeWindowBecomesVisible() + imeAppWindowBecomesVisible(testAppComponentName.className) + wallpaperWindowBecomesInvisible() + } + + layersTrace { + noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation, + bugId = 141361128) + navBarLayerRotatesAndScales(Surface.ROTATION_0, + configuration.endRotation) + statusBarLayerRotatesScales(Surface.ROTATION_0, + configuration.endRotation) + statusBarLayerIsAlwaysVisible( + enabled = Surface.ROTATION_0 == configuration.endRotation) + navBarLayerIsAlwaysVisible( + enabled = Surface.ROTATION_0 == configuration.endRotation) + visibleLayersShownMoreThanOneConsecutiveEntry( + enabled = Surface.ROTATION_0 == configuration.endRotation) + + imeLayerBecomesVisible() + appLayerReplacesWallpaperLayer(testAppComponentName.className) + } + } } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt index 72efdb173d44b..71920f696cb22 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt @@ -17,20 +17,8 @@ package com.android.server.wm.flicker.launch import android.platform.helpers.IAppHelper -import com.android.server.wm.flicker.dsl.LayersAssertion import com.android.server.wm.flicker.dsl.WmAssertion -fun WmAssertion.wallpaperWindowBecomesInvisible( - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("wallpaperWindowBecomesInvisible", bugId, enabled) { - this.showsBelowAppWindow("Wallpaper") - .then() - .hidesBelowAppWindow("Wallpaper") - } -} - fun WmAssertion.appWindowReplacesLauncherAsTopWindow( testApp: IAppHelper, bugId: Int = 0, @@ -41,16 +29,4 @@ fun WmAssertion.appWindowReplacesLauncherAsTopWindow( .then() .showsAppWindowOnTop("Snapshot", testApp.getPackage()) } -} - -fun LayersAssertion.appLayerReplacesWallpaperLayer( - testApp: IAppHelper, - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all("appLayerReplacesWallpaperLayer", bugId, enabled) { - this.showsLayer("Wallpaper") - .then() - .replaceVisibleLayer("Wallpaper", testApp.getPackage()) - } } \ No newline at end of file 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 index 686ddcbd66bd3..d81c24d3ca695 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt @@ -40,6 +40,8 @@ import com.android.server.wm.flicker.statusBarLayerRotatesScales import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry +import com.android.server.wm.flicker.wallpaperWindowBecomesInvisible +import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -107,7 +109,7 @@ class OpenAppColdTest( statusBarLayerIsAlwaysVisible(enabled = false) visibleLayersShownMoreThanOneConsecutiveEntry(bugId = 174541970) - appLayerReplacesWallpaperLayer(testApp) + appLayerReplacesWallpaperLayer(testApp.`package`) } eventLog { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt index 5aef314e0caff..1b682c0b5b040 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt @@ -29,7 +29,6 @@ import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEnt import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry import com.android.server.wm.flicker.helpers.StandardAppHelper import com.android.server.wm.flicker.helpers.reopenAppFromOverview -import com.android.server.wm.flicker.helpers.hasWindow import com.android.server.wm.flicker.helpers.buildTestTag import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen @@ -42,6 +41,10 @@ import com.android.server.wm.flicker.startRotation import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible import com.android.server.wm.flicker.statusBarLayerRotatesScales import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible +import com.android.server.wm.flicker.wallpaperWindowBecomesInvisible +import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer +import com.android.server.wm.flicker.testapp.ActivityOptions +import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -83,7 +86,9 @@ class OpenAppFromOverviewTest( } transitions { device.reopenAppFromOverview() - device.hasWindow(testApp.getPackage()) + WindowManagerStateHelper().waitForFullScreenApp( + ActivityOptions.SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME + ) } teardown { test { @@ -115,7 +120,7 @@ class OpenAppFromOverviewTest( visibleLayersShownMoreThanOneConsecutiveEntry( enabled = Surface.ROTATION_0 == configuration.endRotation) - appLayerReplacesWallpaperLayer(testApp) + appLayerReplacesWallpaperLayer(testApp.`package`) } eventLog { 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 index 9b4223a0ea800..3703d9c71f256 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt @@ -40,6 +40,8 @@ import com.android.server.wm.flicker.statusBarLayerRotatesScales import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry +import com.android.server.wm.flicker.wallpaperWindowBecomesInvisible +import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -112,7 +114,7 @@ class OpenAppWarmTest( visibleLayersShownMoreThanOneConsecutiveEntry( enabled = Surface.ROTATION_0 == configuration.endRotation) - appLayerReplacesWallpaperLayer(testApp) + appLayerReplacesWallpaperLayer(testApp.`package`) } eventLog { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt index a1a7102f71e67..120354b7dada0 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt @@ -30,7 +30,7 @@ import com.android.server.wm.flicker.FlickerTestRunner import com.android.server.wm.flicker.FlickerTestRunnerFactory import com.android.server.wm.flicker.endRotation import com.android.server.wm.flicker.focusDoesNotChange -import com.android.server.wm.flicker.windowAlwaysVisible +import com.android.server.wm.flicker.appWindowAlwaysVisibleOnTop import com.android.server.wm.flicker.layerAlwaysVisible import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.helpers.buildTestTag @@ -146,7 +146,7 @@ class SeamlessAppRotationTest( navBarWindowIsAlwaysVisible(bugId = 140855415) statusBarWindowIsAlwaysVisible(bugId = 140855415) visibleWindowsShownMoreThanOneConsecutiveEntry() - windowAlwaysVisible(configuration.intentPackageName) + appWindowAlwaysVisibleOnTop(configuration.intentPackageName) } layersTrace { diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java index 18994111324e1..f167e950a1135 100644 --- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java +++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java @@ -23,4 +23,10 @@ public class ActivityOptions { public static final ComponentName SEAMLESS_ACTIVITY_COMPONENT_NAME = new ComponentName("com.android.server.wm.flicker.testapp", "com.android.server.wm.flicker.testapp.SeamlessRotationActivity"); + public static final ComponentName IME_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME = + new ComponentName("com.android.server.wm.flicker.testapp", + "com.android.server.wm.flicker.testapp.ImeActivityAutoFocus"); + public static final ComponentName SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME = + new ComponentName("com.android.server.wm.flicker.testapp", + "com.android.server.wm.flicker.testapp.SimpleActivity"); }