Add support for Tablets on app launch tests

Moreover, refactor the test to reuse the base test class with general assertions and fix ktlint errors

Bug: 234735502
Test: atest FlickerTests
Change-Id: Ia3dcc9977bd620db0e53c704517c33c0c1339426
This commit is contained in:
Nataniel Borges
2022-07-10 16:41:38 +00:00
parent 389f1d9a97
commit eb44e9563a
16 changed files with 637 additions and 597 deletions

View File

@@ -111,19 +111,6 @@ fun FlickerTestParameter.taskBarLayerIsVisibleAtStartAndEnd() {
}
}
/**
* Checks that [ComponentMatcher.TASK_BAR] layer is visible at the start and end of the SF
* trace
*/
fun FlickerTestParameter.navTaskLayerIsVisibleAtStartAndEnd() {
assertLayersStart {
this.isVisible(ComponentMatcher.TASK_BAR)
}
assertLayersEnd {
this.isVisible(ComponentMatcher.TASK_BAR)
}
}
/**
* Checks that [ComponentMatcher.STATUS_BAR] layer is visible at the start and end of the SF
* trace

View File

@@ -16,18 +16,15 @@
package com.android.server.wm.flicker.launch
import android.app.Instrumentation
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Presubmit
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.flicker.FlickerBuilderProvider
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.entireScreenCovered
import com.android.server.wm.flicker.helpers.TwoActivitiesAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.traces.common.ComponentMatcher
@@ -59,39 +56,85 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group4
class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
class ActivitiesTransitionTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) {
private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation)
private val tapl = LauncherInstrumentation()
/**
* Entry point for the test runner. It will use this method to initialize and cache
* flicker executions
*/
@FlickerBuilderProvider
fun buildFlicker(): FlickerBuilder {
return FlickerBuilder(instrumentation).apply {
setup {
test {
tapl.setExpectedRotation(testSpec.startRotation)
testApp.launchViaIntent(wmHelper)
}
}
teardown {
test {
testApp.exit(wmHelper)
}
}
transitions {
testApp.openSecondActivity(device, wmHelper)
tapl.pressBack()
wmHelper.StateSyncBuilder()
.withFullScreenApp(testApp)
.waitForAndVerify()
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit = {
setup {
test {
tapl.setExpectedRotation(testSpec.startRotation)
testApp.launchViaIntent(wmHelper)
}
}
teardown {
test {
testApp.exit(wmHelper)
}
}
transitions {
testApp.openSecondActivity(device, wmHelper)
tapl.pressBack()
wmHelper.StateSyncBuilder()
.withFullScreenApp(testApp)
.waitForAndVerify()
}
}
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerIsVisibleAtStartAndEnd() =
super.statusBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerPositionAtStartAndEnd() =
super.statusBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
/**
* Checks that the [ActivityOptions.BUTTON_ACTIVITY_COMPONENT_NAME] activity is visible at
* the start of the transition, that
@@ -115,13 +158,6 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
}
}
/**
* Checks that all parts of the screen are covered during the transition
*/
@Presubmit
@Test
fun entireScreenCovered() = testSpec.entireScreenCovered()
/**
* Checks that the [ComponentMatcher.LAUNCHER] window is not on top. The launcher cannot be
* asserted with `isAppWindowVisible` because it contains 2 windows with the exact same name,
@@ -155,7 +191,7 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) {
@JvmStatic
fun getParams(): Collection<FlickerTestParameter> {
return FlickerTestParameterFactory.getInstance()
.getConfigNonRotationTests(repetitions = 3)
.getConfigNonRotationTests(repetitions = 3)
}
}
}

View File

@@ -54,11 +54,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class OpenAppColdFromIcon(testSpec: FlickerTestParameter) :
OpenAppFromLauncherTransition(testSpec) {
/**
* Defines the transition used to run the test
*/
class OpenAppColdFromIcon(
testSpec: FlickerTestParameter
) : OpenAppFromLauncherTransition(testSpec) {
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
@@ -82,85 +81,107 @@ class OpenAppColdFromIcon(testSpec: FlickerTestParameter) :
}
}
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowAsTopWindowAtEnd() =
super.appWindowAsTopWindowAtEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowReplacesLauncherAsTopWindow() =
super.appWindowReplacesLauncherAsTopWindow()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appLayerBecomesVisible() =
super.appLayerBecomesVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appLayerReplacesLauncher() =
super.appLayerReplacesLauncher()
override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowBecomesTopWindow() =
super.appWindowBecomesTopWindow()
override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowBecomesVisible() =
super.appWindowBecomesVisible()
override fun appWindowBecomesVisible() = super.appWindowBecomesVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun entireScreenCovered() =
super.entireScreenCovered()
override fun entireScreenCovered() = super.entireScreenCovered()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun focusChanges() =
super.focusChanges()
override fun focusChanges() = super.focusChanges()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisible() =
super.navBarLayerIsVisible()
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerRotatesAndScales() =
super.navBarLayerRotatesAndScales()
override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsVisible() =
super.navBarWindowIsVisible()
override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerRotatesScales() =
super.statusBarLayerRotatesScales()
override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerIsVisible() =
super.statusBarLayerIsVisible()
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsVisible() =
super.statusBarWindowIsVisible()
override fun statusBarLayerPositionAtStartAndEnd() =
super.statusBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerIsVisibleAtStartAndEnd() =
super.statusBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowIsTopWindowAtEnd() =
super.appWindowIsTopWindowAtEnd()
override fun appWindowIsTopWindowAtEnd() = super.appWindowIsTopWindowAtEnd()
companion object {
/**

View File

@@ -54,11 +54,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
open class OpenAppColdTest(testSpec: FlickerTestParameter) :
OpenAppFromLauncherTransition(testSpec) {
/**
* Defines the transition used to run the test
*/
open class OpenAppColdTest(
testSpec: FlickerTestParameter
) : OpenAppFromLauncherTransition(testSpec) {
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
@@ -81,13 +80,14 @@ open class OpenAppColdTest(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@FlakyTest(bugId = 206753786)
@Test
override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
override fun statusBarLayerPositionAtStartAndEnd() =
super.statusBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@FlakyTest(bugId = 206753786)
@Test
override fun navBarLayerRotatesAndScales() {
super.navBarLayerRotatesAndScales()
override fun navBarLayerPositionAtStartAndEnd() {
super.navBarLayerPositionAtStartAndEnd()
}
/** {@inheritDoc} */
@@ -95,27 +95,6 @@ open class OpenAppColdTest(testSpec: FlickerTestParameter) :
@Test
override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appWindowReplacesLauncherAsTopWindow() =
super.appWindowReplacesLauncherAsTopWindow()
/** {@inheritDoc} */
@Presubmit
@Test
override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
/** {@inheritDoc} */
@Presubmit
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
/** {@inheritDoc} */
@Presubmit
@Test
override fun entireScreenCovered() = super.entireScreenCovered()
companion object {
/**
* Creates the test configurations.

View File

@@ -25,11 +25,12 @@ import org.junit.Test
/**
* Base class for app launch tests
*/
abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
OpenAppTransition(testSpec) {
abstract class OpenAppFromLauncherTransition(
testSpec: FlickerTestParameter
) : OpenAppTransition(testSpec) {
/**
* Checks that the focus changes from the launcher to [testApp]
* Checks that the focus changes from the [ComponentMatcher.LAUNCHER] to [testApp]
*/
@Presubmit
@Test
@@ -44,15 +45,17 @@ abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
* and is replaced by [testApp], which remains visible until the end
*/
open fun appLayerReplacesLauncher() {
testSpec.replacesLayer(ComponentMatcher.LAUNCHER, testApp,
ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true,
ignoreSplashscreen = true)
testSpec.replacesLayer(
ComponentMatcher.LAUNCHER, testApp,
ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true,
ignoreSplashscreen = true
)
}
/**
* Checks that [ComponentMatcher.LAUNCHER] window is visible at the start of the
* transition, and is replaced by a snapshot or splash screen (optional), and finally, is
* replaced by [testApp], which remains visible until the end
* Checks that [ComponentMatcher.LAUNCHER] window is the top window at the start of the
* transition, and is replaced by a [ComponentMatcher.SNAPSHOT] or
* [ComponentMatcher.SPLASH_SCREEN], or [testApp], which remains visible until the end
*/
@Presubmit
@Test
@@ -67,4 +70,15 @@ abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) :
)
}
}
/**
* Checks that [testApp] window is the top window at the en dof the trace
*/
@Presubmit
@Test
open fun appWindowAsTopWindowAtEnd() {
testSpec.assertWmEnd {
this.isAppWindowOnTop(testApp)
}
}
}

View File

@@ -24,9 +24,12 @@ 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.flicker.navBarLayerPositionEnd
import com.android.server.wm.flicker.statusBarLayerPositionEnd
import com.android.server.wm.flicker.navBarLayerPositionAtEnd
import com.android.server.wm.flicker.statusBarLayerPositionAtEnd
import com.android.server.wm.traces.common.ComponentMatcher
import org.junit.Assume
import org.junit.FixMethodOrder
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
@@ -87,35 +90,41 @@ open class OpenAppFromLockNotificationCold(testSpec: FlickerTestParameter) :
@Test
override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow()
/**
* Checks the position of the navigation bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
*/
@Postsubmit
@Test
override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd()
/** {@inheritDoc} */
@Ignore("Display is off at the start")
override fun navBarLayerPositionAtStartAndEnd() { }
/**
* Checks the position of the status bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
* Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition
*/
@Postsubmit
@Test
override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd()
fun navBarLayerPositionAtEnd() {
Assume.assumeFalse(testSpec.isTablet)
testSpec.navBarLayerPositionAtEnd()
}
/** {@inheritDoc} */
@Ignore("Display is off at the start")
override fun statusBarLayerPositionAtStartAndEnd() { }
/**
* Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the
* transition
*/
@Postsubmit
@Test
fun statusBarLayerPositionEnd() = testSpec.statusBarLayerPositionAtEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@@ -125,7 +134,7 @@ open class OpenAppFromLockNotificationCold(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible()
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@@ -135,7 +144,8 @@ open class OpenAppFromLockNotificationCold(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible()
override fun statusBarLayerIsVisibleAtStartAndEnd() =
super.statusBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit

View File

@@ -24,10 +24,12 @@ 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.flicker.navBarLayerPositionEnd
import com.android.server.wm.flicker.statusBarLayerPositionEnd
import com.android.server.wm.flicker.navBarLayerPositionAtEnd
import com.android.server.wm.flicker.statusBarLayerPositionAtEnd
import com.android.server.wm.traces.common.ComponentMatcher
import org.junit.Assume
import org.junit.FixMethodOrder
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
@@ -92,7 +94,7 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) :
}
/**
* Checks that the screen is locked.
* Checks that the screen is locked at the start of the transition
*/
@Test
@Postsubmit
@@ -113,35 +115,41 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) :
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
/**
* Checks the position of the navigation bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
*/
@Postsubmit
@Test
override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd()
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun navBarLayerPositionAtStartAndEnd() { }
/**
* Checks the position of the status bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
* Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition
*/
@Postsubmit
@Test
override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd()
fun navBarLayerPositionAtEnd() {
Assume.assumeFalse(testSpec.isTablet)
testSpec.navBarLayerPositionAtEnd()
}
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun statusBarLayerPositionAtStartAndEnd() { }
/**
* Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the
* transition
*/
@Postsubmit
@Test
fun statusBarLayerPositionEnd() = testSpec.statusBarLayerPositionAtEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@@ -151,7 +159,7 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible()
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@@ -166,7 +174,8 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible()
override fun statusBarLayerIsVisibleAtStartAndEnd() =
super.statusBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit

View File

@@ -26,8 +26,6 @@ import com.android.server.wm.flicker.annotation.Group1
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.helpers.ShowWhenLockedAppHelper
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerPositionEnd
import com.android.server.wm.flicker.statusBarLayerPositionEnd
import com.android.server.wm.traces.common.ComponentMatcher
import org.junit.FixMethodOrder
import org.junit.Test
@@ -113,79 +111,11 @@ class OpenAppFromLockNotificationWithLockOverlayApp(testSpec: FlickerTestParamet
@Test
override fun entireScreenCovered() = super.entireScreenCovered()
/**
* Checks the position of the navigation bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
*/
@Postsubmit
@Test
override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd()
/**
* Checks the position of the status bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
*/
@Postsubmit
@Test
override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appLayerBecomesVisible() = super.appLayerBecomesVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowBecomesVisible() = super.appWindowBecomesVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowIsTopWindowAtEnd() =
super.appWindowIsTopWindowAtEnd()
companion object {
/**
* Creates the test configurations.

View File

@@ -17,13 +17,14 @@
package com.android.server.wm.flicker.launch
import android.platform.test.annotations.FlakyTest
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Presubmit
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.navBarLayerPositionEnd
import com.android.server.wm.flicker.statusBarLayerPositionEnd
import com.android.server.wm.flicker.navBarLayerPositionAtEnd
import com.android.server.wm.flicker.statusBarLayerPositionAtEnd
import com.android.server.wm.traces.common.ComponentMatcher
import org.junit.Assume
import org.junit.Ignore
import org.junit.Test
/**
@@ -35,26 +36,25 @@ abstract class OpenAppFromLockTransition(testSpec: FlickerTestParameter) :
/**
* Defines the transition used to run the test
*/
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
setup {
eachRun {
device.sleep()
wmHelper.StateSyncBuilder()
.withoutTopVisibleAppWindows()
.waitForAndVerify()
}
}
teardown {
eachRun {
testApp.exit(wmHelper)
}
}
transitions {
testApp.launchViaIntent(wmHelper)
override val transition: FlickerBuilder.() -> Unit = {
super.transition(this)
setup {
eachRun {
device.sleep()
wmHelper.StateSyncBuilder()
.withoutTopVisibleAppWindows()
.waitForAndVerify()
}
}
teardown {
eachRun {
testApp.exit(wmHelper)
}
}
transitions {
testApp.launchViaIntent(wmHelper)
}
}
/**
* Check that we go from no focus to focus on the [testApp]
@@ -101,34 +101,51 @@ abstract class OpenAppFromLockTransition(testSpec: FlickerTestParameter) :
@Test
override fun appWindowBecomesVisible() = super.appWindowBecomesVisible()
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun navBarLayerPositionAtStartAndEnd() { }
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun statusBarLayerPositionAtStartAndEnd() { }
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun taskBarLayerIsVisibleAtStartAndEnd() { }
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun taskBarWindowIsAlwaysVisible() { }
/**
* Checks the position of the navigation bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
* Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition
*/
@Presubmit
@Test
override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd()
open fun navBarLayerPositionAtEnd() {
Assume.assumeFalse(testSpec.isTablet)
testSpec.navBarLayerPositionAtEnd()
}
/**
* Checks the position of the status bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
* Checks the position of the [ComponentMatcher.STATUS_BAR] at the end of the transition
*/
@Postsubmit
@Presubmit
@Test
override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd()
fun statusBarLayerPositionAtEnd() = testSpec.statusBarLayerPositionAtEnd()
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun statusBarLayerIsVisibleAtStartAndEnd() { }
/**
* Checks that the status bar layer is visible at the end of the trace
* Checks that the [ComponentMatcher.STATUS_BAR] layer is visible at the end of the trace
*
* It is not possible to check at the start because the screen is off
*/
@Presubmit
@Test
override fun statusBarLayerIsVisible() {
fun statusBarLayerIsVisibleAtEnd() {
testSpec.assertLayersEnd {
this.isVisible(ComponentMatcher.STATUS_BAR)
}

View File

@@ -42,8 +42,10 @@ import org.junit.runners.Parameterized
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
@Postsubmit
open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter) :
OpenAppFromNotificationWarm(testSpec) {
open class OpenAppFromNotificationCold(
testSpec: FlickerTestParameter
) : OpenAppFromNotificationWarm(testSpec) {
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
@@ -59,10 +61,81 @@ open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter) :
}
}
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerIsVisibleAtStartAndEnd() =
super.statusBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarLayerPositionAtStartAndEnd() =
super.statusBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun entireScreenCovered() = super.entireScreenCovered()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun notificationAppWindowVisibleAtEnd() = super.notificationAppWindowVisibleAtEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun notificationAppWindowOnTopAtEnd() = super.notificationAppWindowOnTopAtEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun notificationAppLayerVisibleAtEnd() = super.notificationAppLayerVisibleAtEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow()
/** {@inheritDoc} */
@Test
@Postsubmit
override fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart()
/** {@inheritDoc} */
@Test
@Postsubmit
override fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart()
@@ -84,7 +157,7 @@ open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter) :
@JvmStatic
fun getParams(): Collection<FlickerTestParameter> {
return FlickerTestParameterFactory.getInstance()
.getConfigNonRotationTests(repetitions = 3)
.getConfigNonRotationTests(repetitions = 3)
}
}
}

View File

@@ -52,12 +52,14 @@ import org.junit.runners.Parameterized
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
@Postsubmit
open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
OpenAppTransition(testSpec) {
open class OpenAppFromNotificationWarm(
testSpec: FlickerTestParameter
) : OpenAppTransition(testSpec) {
override val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation)
open val openingNotificationsFromLockScreen = false
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit
get() = {
setup {
@@ -83,11 +85,14 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
var endY = 3 * device.displayHeight / 4
var steps = 25
if (openingNotificationsFromLockScreen) {
val wm = instrumentation.context.getSystemService(WindowManager::class.java)
val wm: WindowManager =
instrumentation.context.getSystemService(WindowManager::class.java)
?: error("Unable to connect to WindowManager service")
val metricInsets = wm.currentWindowMetrics.windowInsets
val insets = metricInsets.getInsetsIgnoringVisibility(
WindowInsets.Type.statusBars()
or WindowInsets.Type.displayCutout())
WindowInsets.Type.statusBars()
or WindowInsets.Type.displayCutout()
)
startY = insets.top + 100
endY = device.displayHeight / 2
@@ -101,8 +106,11 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
instrumentation.uiAutomation.syncInputTransactions()
// Launch the activity by clicking the notification
val notification = device.wait(Until.findObject(
By.text("Flicker Test Notification")), 2000L)
val notification = device.wait(
Until.findObject(
By.text("Flicker Test Notification")
), 2000L
)
notification?.click() ?: error("Notification not found")
instrumentation.uiAutomation.syncInputTransactions()
@@ -119,50 +127,90 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
}
}
@Test
/** {@inheritDoc} */
@Postsubmit
override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
@Test
override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
@Test
/** {@inheritDoc} */
@Postsubmit
override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible()
@Test
override fun statusBarLayerIsVisibleAtStartAndEnd() =
super.statusBarLayerIsVisibleAtStartAndEnd()
@Test
/** {@inheritDoc} */
@Postsubmit
override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
@Test
override fun statusBarLayerPositionAtStartAndEnd() =
super.statusBarLayerPositionAtStartAndEnd()
@Test
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
super.visibleLayersShownMoreThanOneConsecutiveEntry()
@Test
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowBecomesVisible() = appWindowBecomesVisible_warmStart()
@Test
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appLayerBecomesVisible() = appLayerBecomesVisible_warmStart()
@Test
/** {@inheritDoc} */
@Postsubmit
fun notificationAppWindowVisibleAtEnd() {
@Test
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun entireScreenCovered() = super.entireScreenCovered()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowIsTopWindowAtEnd() =
super.appWindowIsTopWindowAtEnd()
@Postsubmit
@Test
open fun notificationAppWindowVisibleAtEnd() {
testSpec.assertWmEnd {
this.isAppWindowVisible(testApp)
}
}
@Test
@Postsubmit
fun notificationAppWindowOnTopAtEnd() {
@Test
open fun notificationAppWindowOnTopAtEnd() {
testSpec.assertWmEnd {
this.isAppWindowOnTop(testApp)
}
}
@Test
@Postsubmit
fun notificationAppLayerVisibleAtEnd() {
@Test
open fun notificationAppLayerVisibleAtEnd() {
testSpec.assertLayersEnd {
this.isVisible(testApp)
}
@@ -178,43 +226,11 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
@FlakyTest(bugId = 229738092)
@Test
fun appWindowBecomesTopWindow_ShellTransit() {
open fun appWindowBecomesTopWindow_ShellTransit() {
Assume.assumeTrue(isShellTransitionsEnabled)
super.appWindowBecomesTopWindow()
}
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun entireScreenCovered() = super.entireScreenCovered()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun appWindowIsTopWindowAtEnd() =
super.appWindowIsTopWindowAtEnd()
companion object {
/**
* Creates the test configurations.
@@ -226,7 +242,7 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) :
@JvmStatic
fun getParams(): Collection<FlickerTestParameter> {
return FlickerTestParameterFactory.getInstance()
.getConfigNonRotationTests(repetitions = 3)
.getConfigNonRotationTests(repetitions = 3)
}
}
}

View File

@@ -58,8 +58,9 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) :
OpenAppFromLauncherTransition(testSpec) {
open class OpenAppFromOverviewTest(
testSpec: FlickerTestParameter
) : OpenAppFromLauncherTransition(testSpec) {
/**
* Defines the transition used to run the test
@@ -77,8 +78,12 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) :
wmHelper.StateSyncBuilder()
.withHomeActivityVisible()
.waitForAndVerify()
// Launcher is always ROTATION_0
tapl.setExpectedRotation(Surface.ROTATION_0)
// By default, launcher doesn't rotate on phones, but rotates on tablets
if (testSpec.isTablet) {
tapl.setExpectedRotation(testSpec.startRotation)
} else {
tapl.setExpectedRotation(Surface.ROTATION_0)
}
tapl.workspace.switchToOverview()
wmHelper.StateSyncBuilder()
.withRecentsActivityVisible()
@@ -97,7 +102,7 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@FlakyTest(bugId = 206753786)
@Test
override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Presubmit
@@ -107,17 +112,17 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@FlakyTest
@Test
override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Presubmit
@Test
override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Presubmit
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Presubmit

View File

@@ -27,10 +27,11 @@ 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.helpers.NonResizeableAppHelper
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.navBarLayerPositionEnd
import com.android.server.wm.flicker.statusBarLayerPositionAtEnd
import com.android.server.wm.traces.common.ComponentMatcher
import org.junit.Assume
import org.junit.FixMethodOrder
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
@@ -65,8 +66,8 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) :
override val testApp = NonResizeableAppHelper(instrumentation)
/**
* Checks that the nav bar layer starts invisible, becomes visible during unlocking animation
* and remains visible at the end
* Checks that the [ComponentMatcher.NAV_BAR] layer starts invisible, becomes visible during
* unlocking animation and remains visible at the end
*/
@FlakyTest(bugId = 227083463)
@Test
@@ -90,12 +91,13 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) :
}
/**
* Checks that the nav bar starts the transition invisible, then becomes visible during
* the unlocking animation and remains visible at the end of the transition
* Checks that the [ComponentMatcher.NAV_BAR] starts the transition invisible, then becomes
* visible during the unlocking animation and remains visible at the end of the transition
*/
@Presubmit
@Test
fun navBarWindowsVisibilityChanges() {
Assume.assumeFalse(testSpec.isTablet)
testSpec.assertWm {
this.isNonAppWindowInvisible(ComponentMatcher.NAV_BAR)
.then()
@@ -104,44 +106,76 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) :
}
/**
* Checks that the status bar layer is visible at the end of the trace
* Checks that the [ComponentMatcher.TASK_BAR] starts the transition invisible, then becomes
* visible during the unlocking animation and remains visible at the end of the transition
*/
@Presubmit
@Test
fun taskBarLayerIsVisibleAtEnd() {
Assume.assumeTrue(testSpec.isTablet)
testSpec.assertLayersEnd {
this.isVisible(ComponentMatcher.TASK_BAR)
}
}
/**
* Checks that the [ComponentMatcher.STATUS_BAR] layer is visible at the end of the trace
*
* It is not possible to check at the start because the screen is off
*/
@Presubmit
@Test
override fun statusBarLayerIsVisible() {
override fun statusBarLayerIsVisibleAtStartAndEnd() {
testSpec.assertLayersEnd {
this.isVisible(ComponentMatcher.STATUS_BAR)
}
}
/** {@inheritDoc} */
@FlakyTest(bugId = 206753786)
@Test
override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
/** {@inheritDoc} */
@FlakyTest(bugId = 206753786)
@Test
fun statusBarLayerPositionAtEnd() {
testSpec.assertLayersEnd {
val display = this.entry.displays.minByOrNull { it.id }
?: error("There is no display!")
this.visibleRegion(ComponentMatcher.STATUS_BAR)
.coversExactly(WindowUtils.getStatusBarPosition(display))
}
}
/**
* Checks the position of the navigation bar at the start and end of the transition
*
* Differently from the normal usage of this assertion, check only the final state of the
* transition because the display is off at the start and the NavBar is never visible
* Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition
*/
@Postsubmit
@Test
override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd()
override fun navBarLayerPositionAtEnd() = super.navBarLayerPositionAtEnd()
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun taskBarLayerIsVisibleAtStartAndEnd() { }
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun navBarLayerIsVisibleAtStartAndEnd() { }
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun taskBarWindowIsAlwaysVisible() { }
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun navBarWindowIsAlwaysVisible() { }
/** {@inheritDoc} */
@Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end")
override fun statusBarWindowIsAlwaysVisible() { }
/**
* Checks the position of the [ComponentMatcher.STATUS_BAR] at the end of the
* transition
*/
@Postsubmit
@Test
fun statusBarLayerPositionEnd() = testSpec.statusBarLayerPositionAtEnd()
/**
* Checks the [ComponentMatcher.NAV_BAR] is visible at the end of the transition
*/
@Postsubmit
@Test
fun navBarLayerIsVisibleAtEnd() {
testSpec.assertLayersEnd {
this.isVisible(ComponentMatcher.NAV_BAR)
}
}
/** {@inheritDoc} */
@FlakyTest
@@ -149,6 +183,22 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) :
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appLayerBecomesVisible() {
Assume.assumeFalse(testSpec.isTablet)
super.appLayerBecomesVisible()
}
/** {@inheritDoc} */
@FlakyTest(bugId = 227143265)
@Test
fun appLayerBecomesVisibleTablet() {
Assume.assumeTrue(testSpec.isTablet)
super.appLayerBecomesVisible()
}
/** {@inheritDoc} */
@FlakyTest
@Test

View File

@@ -16,39 +16,25 @@
package com.android.server.wm.flicker.launch
import android.app.Instrumentation
import android.platform.test.annotations.Presubmit
import androidx.test.platform.app.InstrumentationRegistry
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.flicker.FlickerBuilderProvider
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.entireScreenCovered
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsVisible
import com.android.server.wm.flicker.statusBarLayerIsVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsVisible
import com.android.server.wm.traces.common.ComponentMatcher
import org.junit.Test
/**
* Base class for app launch tests
*/
abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
abstract class OpenAppTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec) {
protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation)
protected val tapl = LauncherInstrumentation()
/**
* Defines the transition used to run the test
*/
protected open val transition: FlickerBuilder.() -> Unit = {
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit = {
setup {
test {
tapl.setExpectedRotation(testSpec.startRotation)
@@ -64,129 +50,43 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
}
/**
* Entry point for the test runner. It will use this method to initialize and cache
* flicker executions
* Checks that the [testApp] layer doesn't exist or is invisible at the start of the
* transition, but is created and/or becomes visible during the transition.
*/
@FlickerBuilderProvider
fun buildFlicker(): FlickerBuilder {
return FlickerBuilder(instrumentation).apply {
transition()
}
@Presubmit
@Test
open fun appLayerBecomesVisible() {
appLayerBecomesVisible_coldStart()
}
/**
* Checks that the navigation bar window is visible during the whole transition
*/
open fun navBarWindowIsVisible() {
testSpec.navBarWindowIsVisible()
}
/**
* Checks that the navigation bar layer is visible at the start and end of the trace
*/
open fun navBarLayerIsVisible() {
testSpec.navBarLayerIsVisible()
}
/**
* Checks the position of the navigation bar at the start and end of the transition
*/
@Presubmit
@Test
open fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales()
/**
* Checks that the status bar window is visible during the whole transition
*/
@Presubmit
@Test
open fun statusBarWindowIsVisible() {
testSpec.statusBarWindowIsVisible()
}
/**
* Checks that the status bar layer is visible at the start and end of the trace
*/
@Presubmit
@Test
open fun statusBarLayerIsVisible() {
testSpec.statusBarLayerIsVisible()
}
/**
* Checks the position of the status bar at the start and end of the transition
*/
@Presubmit
@Test
open fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales()
/**
* Checks that all windows that are visible on the trace, are visible for at least 2
* consecutive entries.
*/
@Presubmit
@Test
open fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
testSpec.assertWm {
this.visibleWindowsShownMoreThanOneConsecutiveEntry()
}
}
/**
* Checks that all layers that are visible on the trace, are visible for at least 2
* consecutive entries.
*/
@Presubmit
@Test
open fun visibleLayersShownMoreThanOneConsecutiveEntry() {
testSpec.assertLayers {
this.visibleLayersShownMoreThanOneConsecutiveEntry()
}
}
/**
* Checks that all parts of the screen are covered during the transition
*/
@Presubmit
@Test
open fun entireScreenCovered() = testSpec.entireScreenCovered()
/**
* Checks that the app layer doesn't exist or is invisible at the start of the transition, but
* is created and/or becomes visible during the transition.
*/
@Presubmit
@Test
open fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart()
protected fun appLayerBecomesVisible_coldStart() {
testSpec.assertLayers {
this.notContains(testApp)
.then()
.isInvisible(testApp, isOptional = true)
.then()
.isVisible(ComponentMatcher.SNAPSHOT, isOptional = true)
.then()
.isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true)
.then()
.isVisible(testApp)
.then()
.isInvisible(testApp, isOptional = true)
.then()
.isVisible(ComponentMatcher.SNAPSHOT, isOptional = true)
.then()
.isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true)
.then()
.isVisible(testApp)
}
}
protected fun appLayerBecomesVisible_warmStart() {
testSpec.assertLayers {
this.isInvisible(testApp)
.then()
.isVisible(ComponentMatcher.SNAPSHOT, isOptional = true)
.then()
.isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true)
.then()
.isVisible(testApp)
.then()
.isVisible(ComponentMatcher.SNAPSHOT, isOptional = true)
.then()
.isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true)
.then()
.isVisible(testApp)
}
}
/**
* Checks that the app window doesn't exist at the start of the transition, that it is
* Checks that the [testApp] window doesn't exist at the start of the transition, that it is
* created (invisible - optional) and becomes visible during the transition
*
* The `isAppWindowInvisible` step is optional because we log once per frame, upon logging,
@@ -199,22 +99,22 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
protected fun appWindowBecomesVisible_coldStart() {
testSpec.assertWm {
this.notContains(testApp)
.then()
.isAppWindowInvisible(testApp, isOptional = true)
.then()
.isAppWindowVisible(testApp)
.then()
.isAppWindowInvisible(testApp, isOptional = true)
.then()
.isAppWindowVisible(testApp)
}
}
protected fun appWindowBecomesVisible_warmStart() {
testSpec.assertWm {
this.isAppWindowInvisible(testApp)
.then()
.isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true)
.then()
.isAppWindowVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowVisible(testApp)
.then()
.isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true)
.then()
.isAppWindowVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowVisible(testApp)
}
}
@@ -227,12 +127,12 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
open fun appWindowBecomesTopWindow() {
testSpec.assertWm {
this.isAppWindowNotOnTop(testApp)
.then()
.isAppWindowOnTop(
testApp
.or(ComponentMatcher.SNAPSHOT)
.or(ComponentMatcher.SPLASH_SCREEN)
)
.then()
.isAppWindowOnTop(
testApp
.or(ComponentMatcher.SNAPSHOT)
.or(ComponentMatcher.SPLASH_SCREEN)
)
}
}

View File

@@ -87,40 +87,18 @@ open class OpenAppWarmTest(testSpec: FlickerTestParameter) :
/** {@inheritDoc} */
@FlakyTest(bugId = 206753786)
@Test
override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appWindowReplacesLauncherAsTopWindow() =
super.appWindowReplacesLauncherAsTopWindow()
/** {@inheritDoc} */
@Presubmit
@Test
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@FlakyTest
@Test
override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()
/** {@inheritDoc} */
@Presubmit
@Test
override fun navBarLayerIsVisible() = super.navBarLayerIsVisible()
/** {@inheritDoc} */
@Presubmit
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
/** {@inheritDoc} */
@Presubmit
@Test

View File

@@ -20,21 +20,14 @@ import android.app.Instrumentation
import android.app.WallpaperManager
import android.platform.test.annotations.Postsubmit
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.flicker.FlickerBuilderProvider
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.entireScreenCovered
import com.android.server.wm.flicker.helpers.NewTasksAppHelper
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.navBarLayerIsVisible
import com.android.server.wm.flicker.navBarWindowIsVisible
import com.android.server.wm.flicker.statusBarLayerIsVisible
import com.android.server.wm.flicker.statusBarWindowIsVisible
import com.android.server.wm.flicker.testapp.ActivityOptions.LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME
import com.android.server.wm.flicker.testapp.ActivityOptions.SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME
import com.android.server.wm.traces.common.ComponentMatcher
@@ -63,64 +56,61 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group4
class TaskTransitionTest(val testSpec: FlickerTestParameter) {
private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
private val tapl = LauncherInstrumentation()
private val mTestApp: NewTasksAppHelper = NewTasksAppHelper(instrumentation)
private val mWallpaper by lazy {
class TaskTransitionTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) {
private val testApp: NewTasksAppHelper = NewTasksAppHelper(instrumentation)
private val wallpaper by lazy {
getWallpaperPackage(instrumentation) ?: error("Unable to obtain wallpaper")
}
@FlickerBuilderProvider
fun buildFlicker(): FlickerBuilder {
return FlickerBuilder(instrumentation).apply {
setup {
eachRun {
mTestApp.launchViaIntent(wmHelper)
}
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit = {
setup {
eachRun {
testApp.launchViaIntent(wmHelper)
}
teardown {
test {
mTestApp.exit(wmHelper)
}
}
transitions {
mTestApp.openNewTask(device, wmHelper)
tapl.pressBack()
wmHelper.StateSyncBuilder()
.withFullScreenApp(mTestApp)
.waitForAndVerify()
}
teardown {
test {
testApp.exit(wmHelper)
}
}
transitions {
testApp.openNewTask(device, wmHelper)
tapl.pressBack()
wmHelper.StateSyncBuilder()
.withFullScreenApp(testApp)
.waitForAndVerify()
}
}
/**
* Checks that the wallpaper window is never visible when performing task transitions.
* Checks that the [wallpaper] window is never visible when performing task transitions.
* A solid color background should be shown instead.
*/
@Postsubmit
@Test
fun wallpaperWindowIsNeverVisible() {
testSpec.assertWm {
this.isNonAppWindowInvisible(mWallpaper)
this.isNonAppWindowInvisible(wallpaper)
}
}
/**
* Checks that the wallpaper layer is never visible when performing task transitions.
* Checks that the [wallpaper] layer is never visible when performing task transitions.
* A solid color background should be shown instead.
*/
@Postsubmit
@Test
fun wallpaperLayerIsNeverVisible() {
testSpec.assertLayers {
this.isInvisible(mWallpaper)
this.isInvisible(wallpaper)
this.isInvisible(WALLPAPER_BBQ_WRAPPER)
}
}
/**
* Check that the launcher window is never visible when performing task transitions.
* Check that the [ComponentMatcher.LAUNCHER] window is never visible when performing task
* transitions.
* A solid color background should be shown above it.
*/
@Postsubmit
@@ -132,7 +122,8 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) {
}
/**
* Checks that the launcher layer is never visible when performing task transitions.
* Checks that the [ComponentMatcher.LAUNCHER] layer is never visible when performing task
* transitions.
* A solid color background should be shown above it.
*/
@Postsubmit
@@ -154,8 +145,8 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) {
testSpec.assertLayers {
this.invoke("LAUNCH_NEW_TASK_ACTIVITY coversExactly displayBounds") {
it.visibleRegion(LAUNCH_NEW_TASK_ACTIVITY).coversExactly(displayBounds)
}
it.visibleRegion(LAUNCH_NEW_TASK_ACTIVITY).coversExactly(displayBounds)
}
.isInvisible(bgColorLayer)
.then()
// Transitioning
@@ -187,55 +178,79 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) {
fun newTaskOpensOnTopAndThenCloses() {
testSpec.assertWm {
this.isAppWindowOnTop(LAUNCH_NEW_TASK_ACTIVITY)
.then()
.isAppWindowOnTop(SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowOnTop(SIMPLE_ACTIVITY)
.then()
.isAppWindowOnTop(SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowOnTop(LAUNCH_NEW_TASK_ACTIVITY)
.then()
.isAppWindowOnTop(SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowOnTop(SIMPLE_ACTIVITY)
.then()
.isAppWindowOnTop(SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowOnTop(LAUNCH_NEW_TASK_ACTIVITY)
}
}
/**
* Checks that all parts of the screen are covered at the start and end of the transition
*/
/** {@inheritDoc} */
@Postsubmit
@Test
fun entireScreenCovered() = testSpec.entireScreenCovered()
override fun entireScreenCovered() = super.entireScreenCovered()
/**
* Checks that the navbar window is visible throughout the transition
*/
/** {@inheritDoc} */
@Postsubmit
@Test
fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible()
override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd()
/**
* Checks that the navbar layer is visible throughout the transition
*/
/** {@inheritDoc} */
@Postsubmit
@Test
fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible()
override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd()
/**
* Checks that the status bar window is visible throughout the transition
*/
/** {@inheritDoc} */
@Postsubmit
@Test
fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible()
override fun statusBarLayerIsVisibleAtStartAndEnd() =
super.statusBarLayerIsVisibleAtStartAndEnd()
/**
* Checks that the status bar layer is visible throughout the transition
*/
/** {@inheritDoc} */
@Postsubmit
@Test
fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible()
override fun statusBarLayerPositionAtStartAndEnd() =
super.statusBarLayerPositionAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
super.visibleLayersShownMoreThanOneConsecutiveEntry()
/** {@inheritDoc} */
@Postsubmit
@Test
override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
super.visibleWindowsShownMoreThanOneConsecutiveEntry()
companion object {
private val LAUNCH_NEW_TASK_ACTIVITY =
LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME.toFlickerComponent()
LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME.toFlickerComponent()
private val SIMPLE_ACTIVITY = SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME.toFlickerComponent()
private fun getWallpaperPackage(instrumentation: Instrumentation): IComponentMatcher? {
@@ -248,7 +263,7 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) {
@JvmStatic
fun getParams(): Collection<FlickerTestParameter> {
return FlickerTestParameterFactory.getInstance()
.getConfigNonRotationTests(repetitions = 3)
.getConfigNonRotationTests(repetitions = 3)
}
}
}