Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8635302f authored by Antonella Dellanzo's avatar Antonella Dellanzo
Browse files

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
parent 0e75d9e4
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -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,
+23 −0
Original line number Diff line number Diff line
@@ -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,
+5 −8
Original line number Diff line number Diff line
@@ -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<Array<Any>> {
@@ -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`)
                        }
                    }
                }
+47 −4
Original line number Diff line number Diff line
@@ -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<Array<Any>> {
            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)
                            }
                        }
                    }
        }
    }
+0 −24
Original line number Diff line number Diff line
@@ -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,
@@ -42,15 +30,3 @@ fun WmAssertion.appWindowReplacesLauncherAsTopWindow(
                .showsAppWindowOnTop("Snapshot", testApp.getPackage())
    }
}
 No newline at end of file

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
Loading