Update window visibility checks on flicker

Check window + activity visibility now on the assertions and make the tests compatible with split isVisible/isInvisible assertions

Test: atest FlickerTests WMShellFlickerTests
Change-Id: Ia73703f385f73610ca2300ddff9d3f4356347374
This commit is contained in:
Nataniel Borges
2021-09-20 16:22:43 +02:00
parent 1ab9b20aed
commit d7cf745103
34 changed files with 82 additions and 74 deletions

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:JvmName("CommonAssertions")
package com.android.wm.shell.flicker
import android.graphics.Region

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:JvmName("WaitUtils")
package com.android.wm.shell.flicker
import android.os.SystemClock

View File

@@ -100,8 +100,8 @@ class AppPairsTestCannotPairNonResizeableApps(
"Non resizeable app not initialized"
}
testSpec.assertWmEnd {
isVisible(nonResizeableApp.component)
isInvisible(primaryApp.component)
isAppWindowVisible(nonResizeableApp.component)
isAppWindowInvisible(primaryApp.component)
}
}

View File

@@ -77,8 +77,8 @@ class AppPairsTestPairPrimaryAndSecondaryApps(
@Test
fun bothAppWindowsVisible() {
testSpec.assertWmEnd {
isVisible(primaryApp.component)
isVisible(secondaryApp.component)
isAppWindowVisible(primaryApp.component)
isAppWindowVisible(secondaryApp.component)
}
}

View File

@@ -100,8 +100,8 @@ class AppPairsTestSupportPairNonResizeableApps(
"Non resizeable app not initialized"
}
testSpec.assertWmEnd {
isVisible(nonResizeableApp.component)
isVisible(primaryApp.component)
isAppWindowVisible(nonResizeableApp.component)
isAppWindowVisible(primaryApp.component)
}
}

View File

@@ -81,8 +81,8 @@ class AppPairsTestUnpairPrimaryAndSecondaryApps(
@Test
fun bothAppWindowsInvisible() {
testSpec.assertWmEnd {
isInvisible(primaryApp.component)
isInvisible(secondaryApp.component)
isAppWindowInvisible(primaryApp.component)
isAppWindowInvisible(secondaryApp.component)
}
}

View File

@@ -73,8 +73,8 @@ class RotateTwoLaunchedAppsInAppPairsMode(
@Test
fun bothAppWindowsVisible() {
testSpec.assertWmEnd {
isVisible(primaryApp.component)
.isVisible(secondaryApp.component)
isAppWindowVisible(primaryApp.component)
isAppWindowVisible(secondaryApp.component)
}
}

View File

@@ -85,8 +85,8 @@ class RotateTwoLaunchedAppsRotateAndEnterAppPairsMode(
@Test
fun bothAppWindowsVisible() {
testSpec.assertWmEnd {
isVisible(primaryApp.component)
isVisible(secondaryApp.component)
isAppWindowVisible(primaryApp.component)
isAppWindowVisible(secondaryApp.component)
}
}

View File

@@ -88,7 +88,7 @@ class EnterSplitScreenDockActivity(
@Test
fun appWindowIsVisible() {
testSpec.assertWmEnd {
isVisible(splitScreenApp.component)
isAppWindowVisible(splitScreenApp.component)
}
}

View File

@@ -77,7 +77,7 @@ class EnterSplitScreenFromDetachedRecentTask(
@Test
fun appWindowIsVisible() {
testSpec.assertWmEnd {
isVisible(splitScreenApp.component)
isAppWindowVisible(splitScreenApp.component)
}
}

View File

@@ -91,7 +91,7 @@ class EnterSplitScreenLaunchToSide(
// Because we log WM once per frame, sometimes the activity and the window
// become visible in the same entry, sometimes not, thus it is not possible to
// assert the visibility of the activity here
this.isAppWindowInvisible(secondaryApp.component, ignoreActivity = true)
this.isAppWindowInvisible(secondaryApp.component)
.then()
// during re-parenting, the window may disappear and reappear from the
// trace, this occurs because we log only 1x per frame

View File

@@ -94,7 +94,7 @@ class EnterSplitScreenSupportNonResizable(
@Test
fun appWindowIsVisible() {
testSpec.assertWmEnd {
isVisible(nonResizeableApp.component)
isAppWindowVisible(nonResizeableApp.component)
}
}

View File

@@ -119,12 +119,12 @@ class LegacySplitScreenFromIntentNotSupportNonResizable(
// when the activity gets PAUSED the window may still be marked as visible
// it will be updated in the next log entry. This occurs because we record 1x
// per frame, thus ignore activity check here
this.isAppWindowVisible(splitScreenApp.component, ignoreActivity = true)
this.isAppWindowVisible(splitScreenApp.component)
.then()
// immediately after the window (after onResume and before perform relayout)
// the activity is invisible. This may or not be logged, since we record 1x
// per frame, thus ignore activity check here
.isAppWindowInvisible(splitScreenApp.component, ignoreActivity = true)
.isAppWindowInvisible(splitScreenApp.component)
}
}
@@ -141,13 +141,12 @@ class LegacySplitScreenFromIntentNotSupportNonResizable(
.then()
// we log once per frame, upon logging, window may be visible or not depending
// on what was processed until that moment. Both behaviors are correct
.isAppWindowInvisible(nonResizeableApp.component,
ignoreActivity = true, isOptional = true)
.isAppWindowInvisible(nonResizeableApp.component, isOptional = true)
.then()
// immediately after the window (after onResume and before perform relayout)
// the activity is invisible. This may or not be logged, since we record 1x
// per frame, thus ignore activity check here
.isAppWindowVisible(nonResizeableApp.component, ignoreActivity = true)
.isAppWindowVisible(nonResizeableApp.component)
}
}
@@ -158,7 +157,7 @@ class LegacySplitScreenFromIntentNotSupportNonResizable(
@Test
fun nonResizableAppWindowBecomesVisibleAtEnd() {
testSpec.assertWmEnd {
this.isVisible(nonResizeableApp.component)
isAppWindowVisible(nonResizeableApp.component)
}
}
@@ -170,8 +169,8 @@ class LegacySplitScreenFromIntentNotSupportNonResizable(
@Test
fun onlyNonResizableAppWindowIsVisibleAtEnd() {
testSpec.assertWmEnd {
isInvisible(splitScreenApp.component)
isVisible(nonResizeableApp.component)
isAppWindowInvisible(splitScreenApp.component)
isAppWindowVisible(nonResizeableApp.component)
}
}

View File

@@ -109,13 +109,12 @@ class LegacySplitScreenFromIntentSupportNonResizable(
.then()
// we log once per frame, upon logging, window may be visible or not depending
// on what was processed until that moment. Both behaviors are correct
.isAppWindowInvisible(nonResizeableApp.component,
ignoreActivity = true, isOptional = true)
.isAppWindowInvisible(nonResizeableApp.component, isOptional = true)
.then()
// immediately after the window (after onResume and before perform relayout)
// the activity is invisible. This may or not be logged, since we record 1x
// per frame, thus ignore activity check here
.isAppWindowVisible(nonResizeableApp.component, ignoreActivity = true)
.isAppWindowVisible(nonResizeableApp.component)
}
}
@@ -127,8 +126,8 @@ class LegacySplitScreenFromIntentSupportNonResizable(
@Test
fun bothAppsWindowsAreVisibleAtEnd() {
testSpec.assertWmEnd {
isVisible(splitScreenApp.component)
isVisible(nonResizeableApp.component)
isAppWindowVisible(splitScreenApp.component)
isAppWindowVisible(nonResizeableApp.component)
}
}

View File

@@ -115,12 +115,12 @@ class LegacySplitScreenFromRecentNotSupportNonResizable(
// when the activity gets PAUSED the window may still be marked as visible
// it will be updated in the next log entry. This occurs because we record 1x
// per frame, thus ignore activity check here
this.isAppWindowVisible(splitScreenApp.component, ignoreActivity = true)
this.isAppWindowVisible(splitScreenApp.component)
.then()
// immediately after the window (after onResume and before perform relayout)
// the activity is invisible. This may or not be logged, since we record 1x
// per frame, thus ignore activity check here
.isAppWindowInvisible(splitScreenApp.component, ignoreActivity = true)
.isAppWindowInvisible(splitScreenApp.component)
}
}
@@ -142,8 +142,8 @@ class LegacySplitScreenFromRecentNotSupportNonResizable(
@Test
fun onlyNonResizableAppWindowIsVisibleAtEnd() {
testSpec.assertWmEnd {
isInvisible(splitScreenApp.component)
isVisible(nonResizeableApp.component)
isAppWindowInvisible(splitScreenApp.component)
isAppWindowVisible(nonResizeableApp.component)
}
}

View File

@@ -106,7 +106,7 @@ class LegacySplitScreenFromRecentSupportNonResizable(
// Because we log WM once per frame, sometimes the activity and the window
// become visible in the same entry, sometimes not, thus it is not possible to
// assert the visibility of the activity here
this.isAppWindowInvisible(nonResizeableApp.component, ignoreActivity = true)
this.isAppWindowInvisible(nonResizeableApp.component)
.then()
// during re-parenting, the window may disappear and reappear from the
// trace, this occurs because we log only 1x per frame
@@ -128,8 +128,8 @@ class LegacySplitScreenFromRecentSupportNonResizable(
@Test
fun bothAppsWindowsAreVisibleAtEnd() {
testSpec.assertWmEnd {
isVisible(splitScreenApp.component)
isVisible(nonResizeableApp.component)
isAppWindowVisible(splitScreenApp.component)
isAppWindowVisible(nonResizeableApp.component)
}
}

View File

@@ -101,7 +101,7 @@ class RotateTwoLaunchedAppAndEnterSplitScreen(
// Because we log WM once per frame, sometimes the activity and the window
// become visible in the same entry, sometimes not, thus it is not possible to
// assert the visibility of the activity here
this.isAppWindowInvisible(secondaryApp.component, ignoreActivity = true)
this.isAppWindowInvisible(secondaryApp.component)
.then()
// during re-parenting, the window may disappear and reappear from the
// trace, this occurs because we log only 1x per frame

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:JvmName("CommonAssertions")
package com.android.wm.shell.flicker.pip
internal const val PIP_WINDOW_COMPONENT = "PipMenuActivity"

View File

@@ -150,7 +150,7 @@ class EnterPipToOtherOrientationTest(
@Test
fun testAppWindowInvisibleOnStart() {
testSpec.assertWmStart {
isInvisible(testApp.component)
isAppWindowInvisible(testApp.component)
}
}
@@ -161,7 +161,7 @@ class EnterPipToOtherOrientationTest(
@Test
fun testAppWindowVisibleOnEnd() {
testSpec.assertWmEnd {
isVisible(testApp.component)
isAppWindowVisible(testApp.component)
}
}

View File

@@ -62,7 +62,7 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans
// when the activity is STOPPING, sometimes it becomes invisible in an entry before
// the window, sometimes in the same entry. This occurs because we log 1x per frame
// thus we ignore activity here
isAppWindowVisible(testApp.component, ignoreActivity = true)
isAppWindowVisible(testApp.component)
.isAppWindowOnTop(pipApp.component)
.then()
.isAppWindowInvisible(testApp.component)

View File

@@ -54,9 +54,9 @@ abstract class ExitPipTransition(testSpec: FlickerTestParameter) : PipTransition
open fun pipWindowBecomesInvisible() {
testSpec.assertWm {
this.invoke("hasPipWindow") {
it.isPinned(pipApp.component).isVisible(pipApp.component)
it.isPinned(pipApp.component).isAppWindowVisible(pipApp.component)
}.then().invoke("!hasPipWindow") {
it.isNotPinned(pipApp.component).isInvisible(pipApp.component)
it.isNotPinned(pipApp.component).isAppWindowInvisible(pipApp.component)
}
}
}

View File

@@ -104,9 +104,9 @@ class PipLegacySplitScreenTest(testSpec: FlickerTestParameter) : PipTransition(t
@Test
fun bothAppWindowsVisible() {
testSpec.assertWmEnd {
isVisible(testApp.component)
isVisible(imeApp.component)
noWindowsOverlap(testApp.component, imeApp.component)
isAppWindowVisible(testApp.component)
isAppWindowVisible(imeApp.component)
doNotOverlap(testApp.component, imeApp.component)
}
}

View File

@@ -139,7 +139,7 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter)
@Test
open fun launcherWindowBecomesVisible() {
testSpec.assertWm {
this.isAppWindowInvisible(LAUNCHER_COMPONENT)
this.isAppWindowNotOnTop(LAUNCHER_COMPONENT)
.then()
.isAppWindowOnTop(LAUNCHER_COMPONENT)
}

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
@file:JvmName("FlickerExtensions")
package com.android.server.wm.flicker.helpers
import com.android.server.wm.flicker.Flicker

View File

@@ -110,7 +110,7 @@ class CloseImeAutoOpenWindowToHomeTest(private val testSpec: FlickerTestParamete
testSpec.assertWm {
this.isAppWindowOnTop(testApp.component)
.then()
.appWindowNotOnTop(testApp.component)
.isAppWindowNotOnTop(testApp.component)
}
}

View File

@@ -20,6 +20,7 @@ import android.app.Instrumentation
import android.platform.test.annotations.Presubmit
import android.view.Surface
import android.view.WindowManagerPolicyConstants
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.FlickerBuilderProvider
@@ -142,7 +143,7 @@ class OpenImeWindowTest(private val testSpec: FlickerTestParameter) {
}
}
@Presubmit
@FlakyTest
@Test
fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
testSpec.assertWm {

View File

@@ -137,9 +137,9 @@ class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
// Since we log 1x per frame, sometimes the activity visibility and the app visibility
// are updated together, sometimes not, thus ignore activity check at the start
testSpec.assertWm {
this.isAppWindowVisible(testApp.component, ignoreActivity = true)
this.isAppWindowVisible(testApp.component)
.then()
.isAppWindowInvisible(testApp.component, ignoreActivity = true)
.isAppWindowInvisible(testApp.component)
.then()
.isAppWindowVisible(testApp.component)
}
@@ -154,7 +154,7 @@ class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
// and the app visibility are updated together, sometimes not, thus ignore activity
// check at the start
testSpec.assertWm {
this.isAppWindowVisible(testApp.component, ignoreActivity = true)
this.isAppWindowVisible(testApp.component)
}
}

View File

@@ -106,11 +106,12 @@ class SwitchImeWindowsFromGestureNavTest(private val testSpec: FlickerTestParame
@Test
fun imeAppWindowVisibility() {
val component = FlickerComponentName(imeTestApp.`package`, "")
testSpec.assertWm {
this.isAppWindowOnTop(component)
.then()
.isAppWindowVisible(component, ignoreActivity = true)
isAppWindowVisible(imeTestApp.component)
.then()
.isAppWindowVisible(testApp.component)
.then()
.isAppWindowVisible(imeTestApp.component)
}
}

View File

@@ -96,11 +96,16 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
@Test
fun entireScreenCovered() = testSpec.entireScreenCovered()
/**
* Checks that the [LAUNCHER_COMPONENT] 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 launcherWindowNotVisible() {
fun launcherWindowNotOnTop() {
testSpec.assertWm {
this.isAppWindowInvisible(LAUNCHER_COMPONENT, ignoreActivity = true)
this.isAppWindowNotOnTop(LAUNCHER_COMPONENT)
}
}

View File

@@ -132,10 +132,9 @@ class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransiti
testSpec.assertWm {
this.notContains(testApp.component)
.then()
.isAppWindowInvisible(testApp.component,
ignoreActivity = true, isOptional = true)
.isAppWindowInvisible(testApp.component, isOptional = true)
.then()
.isAppWindowVisible(testApp.component, ignoreActivity = true)
.isAppWindowVisible(testApp.component)
}
}
@@ -146,7 +145,7 @@ class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransiti
@Test
fun appWindowBecomesVisibleAtEnd() {
testSpec.assertWmEnd {
this.isVisible(testApp.component)
this.isAppWindowVisible(testApp.component)
}
}

View File

@@ -201,9 +201,9 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
*/
open fun launcherWindowBecomesInvisible() {
testSpec.assertWm {
this.isAppWindowVisible(LAUNCHER_COMPONENT)
this.isAppWindowOnTop(LAUNCHER_COMPONENT)
.then()
.isAppWindowInvisible(LAUNCHER_COMPONENT)
.isAppWindowNotOnTop(LAUNCHER_COMPONENT)
}
}
}

View File

@@ -191,7 +191,7 @@ class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestParamet
.then()
.isAppWindowVisible(FlickerComponentName.SNAPSHOT, isOptional = true)
.then()
.isAppWindowVisible(testApp1.component, ignoreActivity = true)
.isAppWindowVisible(testApp1.component)
}
}
@@ -217,7 +217,7 @@ class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestParamet
@Test
fun app2WindowBecomesAndStaysInvisible() {
testSpec.assertWm {
this.isAppWindowVisible(testApp2.component, ignoreActivity = true)
this.isAppWindowVisible(testApp2.component)
.then()
.isAppWindowInvisible(testApp2.component)
}

View File

@@ -209,7 +209,7 @@ class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTestPara
.then()
.isAppWindowVisible(FlickerComponentName.SNAPSHOT, isOptional = true)
.then()
.isAppWindowVisible(testApp2.component, ignoreActivity = true)
.isAppWindowVisible(testApp2.component)
}
}
@@ -235,7 +235,7 @@ class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTestPara
@Test
fun app1WindowBecomesAndStaysInvisible() {
testSpec.assertWm {
this.isAppWindowVisible(testApp1.component, ignoreActivity = true)
this.isAppWindowVisible(testApp1.component)
.then()
.isAppWindowInvisible(testApp1.component)
}

View File

@@ -145,7 +145,7 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) {
@Test
fun startsWithHomeActivityFlaggedVisible() {
testSpec.assertWmStart {
this.isHomeActivityVisible(true)
this.isHomeActivityVisible()
}
}
@@ -192,7 +192,7 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) {
@Test
fun endsWithHomeActivityFlaggedInvisible() {
testSpec.assertWmEnd {
this.isHomeActivityVisible(false)
this.isHomeActivityInvisible()
}
}
@@ -204,9 +204,9 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) {
@Test
fun appWindowBecomesAndStaysVisible() {
testSpec.assertWm {
this.isAppWindowInvisible(testApp.component, ignoreActivity = true)
this.isAppWindowInvisible(testApp.component)
.then()
.isAppWindowVisible(testApp.component, ignoreActivity = true)
.isAppWindowVisible(testApp.component)
}
}
@@ -232,9 +232,9 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) {
@Test
fun launcherWindowBecomesAndStaysInvisible() {
testSpec.assertWm {
this.isAppWindowVisible(LAUNCHER_COMPONENT)
this.isAppWindowOnTop(LAUNCHER_COMPONENT)
.then()
.isAppWindowInvisible(LAUNCHER_COMPONENT)
.isAppWindowNotOnTop(LAUNCHER_COMPONENT)
}
}
@@ -260,7 +260,7 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) {
@Test
fun appWindowIsVisibleOnceLauncherWindowIsInvisible() {
testSpec.assertWm {
this.isAppWindowVisible(LAUNCHER_COMPONENT)
this.isAppWindowOnTop(LAUNCHER_COMPONENT)
.then()
.isAppWindowVisible(FlickerComponentName.SNAPSHOT)
.then()