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

Commit ec7fe96a authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Ensure there's only 1 pip-dismiss-overlay window at any point in time

Test: atest WMShellFlickerTests
Bug: 258120818
Change-Id: I65bdb74701b216d605b6a065a95876d6d858bb83
parent f76de3d6
Loading
Loading
Loading
Loading
+21 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.flicker.pip


import android.app.Instrumentation
import android.app.Instrumentation
import android.content.Intent
import android.content.Intent
import android.platform.test.annotations.Postsubmit
import com.android.server.wm.flicker.FlickerBuilder
import com.android.server.wm.flicker.FlickerBuilder
import com.android.server.wm.flicker.FlickerTest
import com.android.server.wm.flicker.FlickerTest
import com.android.server.wm.flicker.helpers.PipAppHelper
import com.android.server.wm.flicker.helpers.PipAppHelper
@@ -25,8 +26,11 @@ import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.rules.RemoveAllTasksButHomeRule.Companion.removeAllTasksButHome
import com.android.server.wm.flicker.rules.RemoveAllTasksButHomeRule.Companion.removeAllTasksButHome
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.traces.common.ComponentNameMatcher
import com.android.server.wm.traces.common.service.PlatformConsts
import com.android.server.wm.traces.common.service.PlatformConsts
import com.android.wm.shell.flicker.BaseTest
import com.android.wm.shell.flicker.BaseTest
import com.google.common.truth.Truth
import org.junit.Test


abstract class PipTransition(flicker: FlickerTest) : BaseTest(flicker) {
abstract class PipTransition(flicker: FlickerTest) : BaseTest(flicker) {
    protected val pipApp = PipAppHelper(instrumentation)
    protected val pipApp = PipAppHelper(instrumentation)
@@ -56,7 +60,6 @@ abstract class PipTransition(flicker: FlickerTest) : BaseTest(flicker) {
     * Gets a configuration that handles basic setup and teardown of pip tests and that launches the
     * Gets a configuration that handles basic setup and teardown of pip tests and that launches the
     * Pip app for test
     * Pip app for test
     *
     *
     * @param eachRun If the pip app should be launched in each run (otherwise only 1x per test)
     * @param stringExtras Arguments to pass to the PIP launch intent
     * @param stringExtras Arguments to pass to the PIP launch intent
     * @param extraSpec Additional segment of flicker specification
     * @param extraSpec Additional segment of flicker specification
     */
     */
@@ -78,4 +81,21 @@ abstract class PipTransition(flicker: FlickerTest) : BaseTest(flicker) {
            extraSpec(this)
            extraSpec(this)
        }
        }
    }
    }

    @Postsubmit
    @Test
    fun hasAtMostOnePipDismissOverlayWindow() {
        val matcher = ComponentNameMatcher("", "pip-dismiss-overlay")
        flicker.assertWm {
            val overlaysPerState = trace.entries.map { entry ->
                entry.windowStates.count { window ->
                    matcher.windowMatchesAnyOf(window)
                } <= 1
            }

            Truth.assertWithMessage("Number of dismiss overlays per state")
                .that(overlaysPerState)
                .doesNotContain(false)
        }
    }
}
}