App layer now stays visible with restart dialog

Before, splash screen replaces app layer when app restarts, so app layer
passes then().isInvisible check. Now, when app is transitioning to exit
size compat mode, app window in size compat mode is exiting with
animatingExit: true and new app window replaces it. App layer stays
visible throughout without splash screen layer transition.

Add check for letterbox layer and don't allow letterbox education to
appear during app compat tests to avoid interfering with app
layer/window visibility checks.

Fix: 275374772
Test: atest WMShellFlickerTests:OpenAppInSizeCompatModeTest
      atest WMShellFlickerTests:RestartAppInSizeCompatModeTest
Change-Id: I173f820593b76a34c2a25eaa116232c955adafe3
This commit is contained in:
Graciela Wissen Putri
2023-04-13 09:56:22 +00:00
parent 64c27756ba
commit ddbcb772f1
3 changed files with 61 additions and 16 deletions

View File

@@ -18,15 +18,18 @@ package com.android.wm.shell.flicker.appcompat
import android.content.Context
import android.system.helpers.CommandsHelper
import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.FlickerTest
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.LetterboxAppHelper
import android.tools.device.flicker.legacy.FlickerTestFactory
import android.tools.device.flicker.legacy.IFlickerTestData
import com.android.server.wm.flicker.helpers.LetterboxAppHelper
import com.android.server.wm.flicker.helpers.setRotation
import com.android.wm.shell.flicker.BaseTest
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
import com.android.wm.shell.flicker.appWindowIsVisibleAtStart
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
import com.android.wm.shell.flicker.layerKeepVisible
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.runners.Parameterized
@@ -35,7 +38,7 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) {
protected val context: Context = instrumentation.context
protected val letterboxApp = LetterboxAppHelper(instrumentation)
lateinit var cmdHelper: CommandsHelper
lateinit var letterboxStyle: HashMap<String, String>
private lateinit var letterboxStyle: HashMap<String, String>
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit
@@ -45,12 +48,22 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) {
letterboxApp.launchViaIntent(wmHelper)
setEndRotation()
}
teardown {
letterboxApp.exit(wmHelper)
}
}
@Before
fun before() {
cmdHelper = CommandsHelper.getInstance(instrumentation)
Assume.assumeTrue(tapl.isTablet && isIgnoreOrientationRequest())
letterboxStyle = mapLetterboxStyle()
setLetterboxEducationEnabled(false)
}
@After
fun after() {
resetLetterboxEducationEnabled()
}
private fun mapLetterboxStyle(): HashMap<String, String> {
@@ -67,6 +80,22 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) {
return map
}
private fun getLetterboxStyle(): HashMap<String, String> {
if (!::letterboxStyle.isInitialized) {
letterboxStyle = mapLetterboxStyle()
}
return letterboxStyle
}
private fun resetLetterboxEducationEnabled() {
val enabled = getLetterboxStyle().getValue("Is education enabled")
cmdHelper.executeShellCommand("wm set-letterbox-style --isEducationEnabled $enabled")
}
private fun setLetterboxEducationEnabled(enabled: Boolean) {
cmdHelper.executeShellCommand("wm set-letterbox-style --isEducationEnabled $enabled")
}
private fun isIgnoreOrientationRequest(): Boolean {
val res = cmdHelper.executeShellCommand("wm get-ignore-orientation-request")
return res != null && res.contains("true")
@@ -89,10 +118,7 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) {
/** Only run on tests with config_letterboxActivityCornersRadius != 0 in devices */
private fun assumeLetterboxRoundedCornersEnabled() {
if (!::letterboxStyle.isInitialized) {
letterboxStyle = mapLetterboxStyle()
}
Assume.assumeTrue(letterboxStyle.getValue("Corner radius") != "0")
Assume.assumeTrue(getLetterboxStyle().getValue("Corner radius") != "0")
}
fun assertLetterboxAppVisibleAtStartAndEnd() {
@@ -100,12 +126,20 @@ abstract class BaseAppCompat(flicker: FlickerTest) : BaseTest(flicker) {
flicker.appWindowIsVisibleAtEnd(letterboxApp)
}
fun assertAppLetterboxedAtEnd() =
flicker.assertLayersEnd { isVisible(ComponentNameMatcher.LETTERBOX) }
fun assertAppLetterboxedAtStart() =
flicker.assertLayersStart { isVisible(ComponentNameMatcher.LETTERBOX) }
fun assertLetterboxAppLayerKeepVisible() = flicker.layerKeepVisible(letterboxApp)
companion object {
/**
* Creates the test configurations.
*
* See [FlickerTestFactory.rotationTests] for configuring screen orientation and navigation
* modes.
* See [FlickerTestFactory.rotationTests] for configuring screen orientation and
* navigation modes.
*/
@Parameterized.Parameters(name = "{0}")
@JvmStatic

View File

@@ -70,6 +70,10 @@ class OpenAppInSizeCompatModeTest(flicker: FlickerTest) : BaseAppCompat(flicker)
@Test
fun letterboxedAppHasRoundedCorners() = assertLetterboxAppAtEndHasRoundedCorners()
@Postsubmit
@Test
fun appIsLetterboxedAtEnd() = assertAppLetterboxedAtEnd()
/**
* Checks that the [ComponentNameMatcher.ROTATION] layer appears during the transition, doesn't
* flicker, and disappears before the transition is complete

View File

@@ -53,23 +53,30 @@ class RestartAppInSizeCompatModeTest(flicker: FlickerTest) : BaseAppCompat(flick
get() = {
super.transition(this)
transitions { letterboxApp.clickRestart(wmHelper) }
teardown { letterboxApp.exit(wmHelper) }
}
@Postsubmit @Test fun appVisibleAtStartAndEnd() = assertLetterboxAppVisibleAtStartAndEnd()
@Postsubmit
@Test
fun appLayerVisibilityChanges() {
flicker.assertLayers {
this.isVisible(letterboxApp)
fun appWindowVisibilityChanges() {
flicker.assertWm {
this.isAppWindowVisible(letterboxApp)
.then()
.isInvisible(letterboxApp)
.isAppWindowInvisible(letterboxApp) // animatingExit true
.then()
.isVisible(letterboxApp)
.isAppWindowVisible(letterboxApp) // Activity finish relaunching
}
}
@Postsubmit
@Test
fun appLayerKeepVisible() = assertLetterboxAppLayerKeepVisible()
@Postsubmit
@Test
fun appIsLetterboxedAtStart() = assertAppLetterboxedAtStart()
@Postsubmit
@Test
fun letterboxedAppHasRoundedCorners() = assertLetterboxAppAtStartHasRoundedCorners()