Crash test when wait condition not met
This makes triaging issues unrelated to the test (e.g., transition crash) easier since all failing assertions are clustered with the same stack trace Bug: 219773854 Test: atest FlickerTests WMShellFlickerTests Change-Id: I65bb1b5e87997c856ce080b24d549ba1c978955a Merged-In: I65bb1b5e87997c856ce080b24d549ba1c978955a
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.wm.shell.flicker.apppairs
|
||||
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import android.view.Display
|
||||
import androidx.test.filters.FlakyTest
|
||||
import androidx.test.filters.RequiresDevice
|
||||
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
|
||||
@@ -24,6 +25,7 @@ import com.android.server.wm.flicker.FlickerTestParameter
|
||||
import com.android.server.wm.flicker.FlickerTestParameterFactory
|
||||
import com.android.server.wm.flicker.annotation.Group1
|
||||
import com.android.server.wm.flicker.dsl.FlickerBuilder
|
||||
import com.android.server.wm.traces.common.WindowManagerConditionsFactory
|
||||
import com.android.wm.shell.flicker.appPairsDividerIsVisibleAtEnd
|
||||
import com.android.wm.shell.flicker.helpers.AppPairsHelper
|
||||
import com.android.wm.shell.flicker.helpers.MultiWindowHelper.Companion.resetMultiWindowConfig
|
||||
@@ -60,7 +62,18 @@ class AppPairsTestSupportPairNonResizeableApps(
|
||||
// TODO pair apps through normal UX flow
|
||||
executeShellCommand(
|
||||
composePairsCommand(primaryTaskId, nonResizeableTaskId, pair = true))
|
||||
nonResizeableApp?.run { wmHelper.waitForFullScreenApp(nonResizeableApp.component) }
|
||||
val waitConditions = mutableListOf(
|
||||
WindowManagerConditionsFactory.isWindowVisible(primaryApp.component),
|
||||
WindowManagerConditionsFactory.isLayerVisible(primaryApp.component),
|
||||
WindowManagerConditionsFactory.isAppTransitionIdle(Display.DEFAULT_DISPLAY))
|
||||
|
||||
nonResizeableApp?.let {
|
||||
waitConditions.add(
|
||||
WindowManagerConditionsFactory.isWindowVisible(nonResizeableApp.component))
|
||||
waitConditions.add(
|
||||
WindowManagerConditionsFactory.isLayerVisible(nonResizeableApp.component))
|
||||
}
|
||||
wmHelper.waitFor(*waitConditions.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
||||
if (wmHelper == null) {
|
||||
device.waitForIdle()
|
||||
} else {
|
||||
require(wmHelper.waitImeShown()) { "IME did not appear" }
|
||||
wmHelper.waitImeShown()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
||||
if (wmHelper == null) {
|
||||
uiDevice.waitForIdle()
|
||||
} else {
|
||||
require(wmHelper.waitImeGone()) { "IME did did not close" }
|
||||
wmHelper.waitImeGone()
|
||||
}
|
||||
} else {
|
||||
// While pressing the back button should close the IME on TV as well, it may also lead
|
||||
|
||||
@@ -58,17 +58,27 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper(
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
override fun launchViaIntent(
|
||||
/**
|
||||
* Launches the app through an intent instead of interacting with the launcher and waits
|
||||
* until the app window is in PIP mode
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun launchViaIntentAndWaitForPip(
|
||||
wmHelper: WindowManagerStateHelper,
|
||||
expectedWindowName: String,
|
||||
action: String?,
|
||||
expectedWindowName: String = "",
|
||||
action: String? = null,
|
||||
stringExtras: Map<String, String>
|
||||
) {
|
||||
super.launchViaIntent(wmHelper, expectedWindowName, action, stringExtras)
|
||||
wmHelper.waitPipShown()
|
||||
launchViaIntentAndWaitShown(wmHelper, expectedWindowName, action, stringExtras,
|
||||
waitConditions = arrayOf(WindowManagerStateHelper.pipShownCondition))
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand the PIP window back to full screen via intent and wait until the app is visible
|
||||
*/
|
||||
fun exitPipToFullScreenViaIntent(wmHelper: WindowManagerStateHelper) =
|
||||
launchViaIntentAndWaitShown(wmHelper)
|
||||
|
||||
private fun focusOnObject(selector: BySelector): Boolean {
|
||||
// We expect all the focusable UI elements to be arranged in a way so that it is possible
|
||||
// to "cycle" over all them by clicking the D-Pad DOWN button, going back up to "the top"
|
||||
|
||||
@@ -64,7 +64,18 @@ class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) {
|
||||
* Defines the transition used to run the test
|
||||
*/
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition(eachRun = true, stringExtras = emptyMap()) {
|
||||
get() = {
|
||||
setupAndTeardown(this)
|
||||
setup {
|
||||
eachRun {
|
||||
pipApp.launchViaIntent(wmHelper)
|
||||
}
|
||||
}
|
||||
teardown {
|
||||
eachRun {
|
||||
pipApp.exit(wmHelper)
|
||||
}
|
||||
}
|
||||
transitions {
|
||||
pipApp.clickEnterPipButton(wmHelper)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class ExitPipViaExpandButtonClickTest(
|
||||
// This will bring PipApp to fullscreen
|
||||
pipApp.expandPipWindowToApp(wmHelper)
|
||||
// Wait until the other app is no longer visible
|
||||
wmHelper.waitForSurfaceAppeared(testApp.component.toWindowName())
|
||||
wmHelper.waitForSurfaceAppeared(testApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ class ExitPipViaIntentTest(testSpec: FlickerTestParameter) : ExitPipToAppTransit
|
||||
}
|
||||
transitions {
|
||||
// This will bring PipApp to fullscreen
|
||||
pipApp.launchViaIntent(wmHelper)
|
||||
pipApp.exitPipToFullScreenViaIntent(wmHelper)
|
||||
// Wait until the other app is no longer visible
|
||||
wmHelper.waitForSurfaceAppeared(testApp.component.toWindowName())
|
||||
wmHelper.waitForWindowSurfaceDisappeared(testApp.component)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,15 +122,14 @@ abstract class PipTransition(protected val testSpec: FlickerTestParameter) {
|
||||
|
||||
setup {
|
||||
test {
|
||||
removeAllTasksButHome()
|
||||
if (!eachRun) {
|
||||
pipApp.launchViaIntent(wmHelper, stringExtras = stringExtras)
|
||||
pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras)
|
||||
wmHelper.waitPipShown()
|
||||
}
|
||||
}
|
||||
eachRun {
|
||||
if (eachRun) {
|
||||
pipApp.launchViaIntent(wmHelper, stringExtras = stringExtras)
|
||||
pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras)
|
||||
wmHelper.waitPipShown()
|
||||
}
|
||||
}
|
||||
@@ -145,7 +144,6 @@ abstract class PipTransition(protected val testSpec: FlickerTestParameter) {
|
||||
if (!eachRun) {
|
||||
pipApp.exit(wmHelper)
|
||||
}
|
||||
removeAllTasksButHome()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter)
|
||||
}
|
||||
teardown {
|
||||
test {
|
||||
testApp.exit()
|
||||
testApp.exit(wmHelper)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@ open class ImeAppHelper @JvmOverloads constructor(
|
||||
device.waitForIdle()
|
||||
} else {
|
||||
wmHelper.waitImeShown()
|
||||
wmHelper.waitForAppTransitionIdle()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ class TwoActivitiesAppHelper @JvmOverloads constructor(
|
||||
button.click()
|
||||
|
||||
device.wait(Until.gone(launchActivityButton), FIND_TIMEOUT)
|
||||
wmHelper.waitForFullScreenApp(secondActivityComponent)
|
||||
wmHelper.waitFor(
|
||||
WindowManagerStateHelper.isAppFullScreen(secondActivityComponent),
|
||||
WindowManagerConditionsFactory.isAppTransitionIdle(Display.DEFAULT_DISPLAY),
|
||||
WindowManagerConditionsFactory.hasLayersAnimating().negate()
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) {
|
||||
}
|
||||
transitions {
|
||||
device.reopenAppFromOverview(wmHelper)
|
||||
require(wmHelper.waitImeShown()) { "IME didn't show in time" }
|
||||
wmHelper.waitImeShown()
|
||||
}
|
||||
teardown {
|
||||
test {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.server.wm.flicker.ime
|
||||
|
||||
import android.app.Instrumentation
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import android.view.Display
|
||||
import android.view.Surface
|
||||
import android.view.WindowManagerPolicyConstants
|
||||
import androidx.test.filters.RequiresDevice
|
||||
@@ -35,6 +36,8 @@ import com.android.server.wm.flicker.helpers.setRotation
|
||||
import com.android.server.wm.flicker.navBarWindowIsVisible
|
||||
import com.android.server.wm.flicker.statusBarWindowIsVisible
|
||||
import com.android.server.wm.traces.common.FlickerComponentName
|
||||
import com.android.server.wm.traces.common.WindowManagerConditionsFactory
|
||||
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
|
||||
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
@@ -64,12 +67,22 @@ class SwitchImeWindowsFromGestureNavTest(private val testSpec: FlickerTestParame
|
||||
eachRun {
|
||||
this.setRotation(testSpec.startRotation)
|
||||
testApp.launchViaIntent(wmHelper)
|
||||
wmHelper.waitForFullScreenApp(testApp.component)
|
||||
wmHelper.waitForAppTransitionIdle()
|
||||
val testAppVisible = wmHelper.waitFor(
|
||||
WindowManagerStateHelper.isAppFullScreen(testApp.component),
|
||||
WindowManagerConditionsFactory.isAppTransitionIdle(
|
||||
Display.DEFAULT_DISPLAY))
|
||||
require(testAppVisible) {
|
||||
"Expected ${testApp.component.toWindowName()} to be visible"
|
||||
}
|
||||
|
||||
imeTestApp.launchViaIntent(wmHelper)
|
||||
wmHelper.waitForFullScreenApp(testApp.component)
|
||||
wmHelper.waitForAppTransitionIdle()
|
||||
val imeAppVisible = wmHelper.waitFor(
|
||||
WindowManagerStateHelper.isAppFullScreen(imeTestApp.component),
|
||||
WindowManagerConditionsFactory.isAppTransitionIdle(
|
||||
Display.DEFAULT_DISPLAY))
|
||||
require(imeAppVisible) {
|
||||
"Expected ${imeTestApp.component.toWindowName()} to be visible"
|
||||
}
|
||||
|
||||
imeTestApp.openIME(device, wmHelper)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.server.wm.flicker.launch
|
||||
|
||||
import android.app.Instrumentation
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import android.view.Display
|
||||
import androidx.test.filters.RequiresDevice
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.android.server.wm.flicker.entireScreenCovered
|
||||
@@ -30,7 +31,9 @@ import com.android.server.wm.flicker.annotation.Group4
|
||||
import com.android.server.wm.flicker.dsl.FlickerBuilder
|
||||
import com.android.server.wm.flicker.helpers.TwoActivitiesAppHelper
|
||||
import com.android.server.wm.flicker.testapp.ActivityOptions
|
||||
import com.android.server.wm.traces.common.WindowManagerConditionsFactory
|
||||
import com.android.server.wm.traces.parser.toFlickerComponent
|
||||
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -77,14 +80,16 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
|
||||
}
|
||||
teardown {
|
||||
test {
|
||||
testApp.exit()
|
||||
testApp.exit(wmHelper)
|
||||
}
|
||||
}
|
||||
transitions {
|
||||
testApp.openSecondActivity(device, wmHelper)
|
||||
device.pressBack()
|
||||
wmHelper.waitForAppTransitionIdle()
|
||||
wmHelper.waitForFullScreenApp(testApp.component)
|
||||
val firstActivityVisible = wmHelper.waitFor(
|
||||
WindowManagerConditionsFactory.isAppTransitionIdle(Display.DEFAULT_DISPLAY),
|
||||
WindowManagerStateHelper.isAppFullScreen(testApp.component))
|
||||
require(firstActivityVisible) { "Expected ${testApp.component} to be visible" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
|
||||
}
|
||||
teardown {
|
||||
test {
|
||||
testApp.exit()
|
||||
testApp.exit(wmHelper)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user