Merge "Split inheritance structure between OpenAppFromLauncher and OpenAppFromLock tests"

This commit is contained in:
Pablo Gamito
2022-02-08 21:39:51 +00:00
committed by Android (Google) Code Review
7 changed files with 265 additions and 154 deletions

View File

@@ -54,7 +54,7 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class OpenAppColdTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSpec) {
class OpenAppColdTest(testSpec: FlickerTestParameter) : OpenAppFromLauncherTransition(testSpec) {
/**
* Defines the transition used to run the test
*/
@@ -101,11 +101,6 @@ class OpenAppColdTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSp
override fun appWindowReplacesLauncherAsTopWindow() =
super.appWindowReplacesLauncherAsTopWindow()
/** {@inheritDoc} */
@Presubmit
@Test
override fun launcherWindowBecomesInvisible() = super.launcherWindowBecomesInvisible()
/** {@inheritDoc} */
@Presubmit
@Test

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.wm.flicker.launch
import android.platform.test.annotations.Presubmit
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.LAUNCHER_COMPONENT
import com.android.server.wm.flicker.replacesLayer
import com.android.server.wm.traces.common.FlickerComponentName
import org.junit.Test
/**
* Base class for app launch tests
*/
abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter)
: OpenAppTransition(testSpec) {
/**
* Checks that the focus changes from the launcher to [testApp]
*/
@Presubmit
@Test
open fun focusChanges() {
testSpec.assertEventLog {
this.focusChanges("NexusLauncherActivity", testApp.`package`)
}
}
/**
* Checks that [LAUNCHER_COMPONENT] layer is visible at the start of the transition, and
* is replaced by [testApp], which remains visible until the end
*/
open fun appLayerReplacesLauncher() {
testSpec.replacesLayer(LAUNCHER_COMPONENT, testApp.component,
ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true,
ignoreSplashscreen = true)
}
/**
* Checks that [LAUNCHER_COMPONENT] 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
*/
@Presubmit
@Test
open fun appWindowReplacesLauncherAsTopWindow() {
testSpec.assertWm {
this.isAppWindowOnTop(LAUNCHER_COMPONENT)
.then()
.isAppWindowOnTop(FlickerComponentName.SNAPSHOT, isOptional = true)
.then()
.isAppWindowOnTop(FlickerComponentName.SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowOnTop(testApp.component)
}
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.wm.flicker.launch
import android.platform.test.annotations.Presubmit
import androidx.test.filters.FlakyTest
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.traces.common.FlickerComponentName
import org.junit.Test
/**
* Base class for app launch tests from lock screen
*/
abstract class OpenAppFromLockTransition(testSpec: FlickerTestParameter)
: OpenAppTransition(testSpec) {
/**
* Defines the transition used to run the test
*/
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
setup {
eachRun {
device.sleep()
wmHelper.waitFor("noAppWindowsOnTop") {
it.wmState.topVisibleAppWindow.isEmpty()
}
}
}
teardown {
eachRun {
testApp.exit(wmHelper)
}
}
transitions {
testApp.launchViaIntent(wmHelper)
wmHelper.waitForFullScreenApp(testApp.component)
}
}
/**
* Check that we go from no focus to focus on the [testApp]
*/
@Presubmit
@Test
open fun focusChanges() {
testSpec.assertEventLog {
this.focusChanges("", testApp.`package`)
}
}
/**
* Checks that we start of with no top windows and then [testApp] becomes the first and only top
* window of the transition, with snapshot or splash screen windows optionally showing first.
*/
@FlakyTest(bugId = 203538234)
@Test
open fun appWindowBecomesFirstAndOnlyTopWindow() {
testSpec.assertWm {
this.hasNoVisibleAppWindow()
.then()
.isAppWindowOnTop(FlickerComponentName.SNAPSHOT, isOptional = true)
.then()
.isAppWindowOnTop(FlickerComponentName.SPLASH_SCREEN, isOptional = true)
.then()
.isAppWindowOnTop(testApp.component)
}
}
/**
* Checks that the screen is locked at the start of the transition ([colorFadComponent])
* layer is visible
*/
@Presubmit
@Test
fun screenLockedStart() {
testSpec.assertLayersStart {
isEmpty()
}
}
/** {@inheritDoc} */
@FlakyTest(bugId = 203538234)
@Test
override fun appWindowBecomesVisible() = super.appWindowBecomesVisible()
}

View File

@@ -62,7 +62,8 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSpec) {
class OpenAppFromOverviewTest(testSpec: FlickerTestParameter)
: OpenAppFromLauncherTransition(testSpec) {
/**
* Defines the transition used to run the test
*/
@@ -113,11 +114,6 @@ class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) : OpenAppTransitio
@Test
override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
/** {@inheritDoc} */
@Presubmit
@Test
override fun launcherWindowBecomesInvisible() = super.launcherWindowBecomesInvisible()
/** {@inheritDoc} */
@Presubmit
@Test
@@ -128,6 +124,16 @@ class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) : OpenAppTransitio
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appLayerBecomesVisible() = super.appLayerBecomesVisible_warmStart()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appWindowBecomesVisible() = super.appWindowBecomesVisible_warmStart()
/** {@inheritDoc} */
@Presubmit
@Test

View File

@@ -27,10 +27,8 @@ 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.dsl.FlickerBuilder
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.traces.common.FlickerComponentName
import com.google.common.truth.Truth
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -59,35 +57,11 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSpec) {
class OpenAppNonResizeableTest(testSpec: FlickerTestParameter)
: OpenAppFromLockTransition(testSpec) {
override val testApp = NonResizeableAppHelper(instrumentation)
private val colorFadComponent = FlickerComponentName("", "ColorFade BLAST#")
/**
* Defines the transition used to run the test
*/
override val transition: FlickerBuilder.() -> Unit
get() = {
super.transition(this)
setup {
eachRun {
device.sleep()
wmHelper.waitFor("noAppWindowsOnTop") {
it.wmState.topVisibleAppWindow.isEmpty()
}
}
}
teardown {
eachRun {
testApp.exit(wmHelper)
}
}
transitions {
testApp.launchViaIntent(wmHelper)
wmHelper.waitForFullScreenApp(testApp.component)
}
}
/**
* Checks that the nav bar layer starts invisible, becomes visible during unlocking animation
* and remains visible at the end
@@ -102,41 +76,6 @@ class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransiti
}
}
/**
* Checks that the app layer doesn't exist at the start of the transition, that it is
* created (invisible) and becomes visible during the transition
*/
@Postsubmit
@Test
fun appLayerBecomesVisible() {
testSpec.assertLayers {
this.notContains(testApp.component)
.then()
.isInvisible(testApp.component)
.then()
.isVisible(testApp.component)
}
}
/**
* Checks that the app 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,
* the window may be visible or not depending on what was processed until that moment.
*/
@FlakyTest(bugId = 203538234)
@Test
fun appWindowBecomesVisible() {
testSpec.assertWm {
this.notContains(testApp.component)
.then()
.isAppWindowInvisible(testApp.component, isOptional = true)
.then()
.isAppWindowVisible(testApp.component)
}
}
/**
* Checks if [testApp] is visible at the end of the transition
*/
@@ -193,6 +132,7 @@ class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransiti
}
}
/** {@inheritDoc} */
@FlakyTest
@Test
override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()
@@ -208,44 +148,6 @@ class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransiti
@Test
override fun entireScreenCovered() = super.entireScreenCovered()
/**
* Checks that the focus changes from the launcher to [testApp]
*/
@FlakyTest
@Test
override fun focusChanges() = super.focusChanges()
/**
* Checks that the screen is locked at the start of the transition ([colorFadComponent])
* layer is visible
*/
@Presubmit
@Test
fun screenLockedStart() {
testSpec.assertLayersStart {
isEmpty()
}
}
/**
* This test checks if the launcher is visible at the start and the app at the end,
* it cannot use the regular assertion (check over time), because on lock screen neither
* the app not the launcher are visible, and there is no top visible window.
*/
@FlakyTest(bugId = 203538234)
@Test
override fun appWindowReplacesLauncherAsTopWindow() {
testSpec.assertWm {
this.invoke("noAppWindowsOnTop") {
Truth.assertWithMessage("Should not have any app window on top " +
"when the screen is locked")
.that(it.wmState.topVisibleAppWindow)
.isEmpty()
}.then()
.isAppWindowOnTop(testApp.component)
}
}
companion object {
/**
* Creates the test configurations.
@@ -265,4 +167,4 @@ class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransiti
)
}
}
}
}

View File

@@ -17,21 +17,20 @@
package com.android.server.wm.flicker.launch
import android.app.Instrumentation
import android.platform.test.annotations.FlakyTest
import android.platform.test.annotations.Presubmit
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.FlickerBuilderProvider
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.LAUNCHER_COMPONENT
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.entireScreenCovered
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.replacesLayer
import com.android.server.wm.flicker.statusBarLayerIsVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsVisible
@@ -151,35 +150,77 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
open fun entireScreenCovered() = testSpec.entireScreenCovered()
/**
* Checks that the focus changes from the launcher to [testApp]
* 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 focusChanges() {
testSpec.assertEventLog {
this.focusChanges("NexusLauncherActivity", testApp.`package`)
open fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart()
protected fun appLayerBecomesVisible_coldStart() {
testSpec.assertLayers {
this.notContains(testApp.component)
.then()
.isInvisible(testApp.component, isOptional = true)
.then()
.isVisible(FlickerComponentName.SNAPSHOT, isOptional = true)
.then()
.isVisible(FlickerComponentName.SPLASH_SCREEN, isOptional = true)
.then()
.isVisible(testApp.component)
}
}
protected fun appLayerBecomesVisible_warmStart() {
testSpec.assertLayers {
this.isInvisible(testApp.component)
.then()
.isVisible(FlickerComponentName.SNAPSHOT, isOptional = true)
.then()
.isVisible(FlickerComponentName.SPLASH_SCREEN, isOptional = true)
.then()
.isVisible(testApp.component)
}
}
/**
* Checks that [LAUNCHER_COMPONENT] layer is visible at the start of the transition, and
* is replaced by [testApp], which remains visible until the end
*/
open fun appLayerReplacesLauncher() {
testSpec.replacesLayer(LAUNCHER_COMPONENT, testApp.component,
ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true)
}
/**
* Checks that [LAUNCHER_COMPONENT] 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 the app 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,
* the window may be visible or not depending on what was processed until that moment.
*/
@Presubmit
@Test
open fun appWindowReplacesLauncherAsTopWindow() {
open fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart()
protected fun appWindowBecomesVisible_coldStart() {
testSpec.assertWm {
this.isAppWindowOnTop(LAUNCHER_COMPONENT)
this.notContains(testApp.component)
.then()
.isAppWindowInvisible(testApp.component, isOptional = true)
.then()
.isAppWindowVisible(testApp.component)
}
}
protected fun appWindowBecomesVisible_warmStart() {
testSpec.assertWm {
this.isAppWindowInvisible(testApp.component)
.then()
.isAppWindowVisible(testApp.component)
}
}
/**
* Checks that [testApp] window is not on top at the start of the transition, and then becomes
* the top visible window until the end of the transition.
*/
@FlakyTest(bugId = 203538234)
@Test
open fun appWindowBecomesTopWindow() {
testSpec.assertWm {
this.isAppWindowNotOnTop(testApp.component)
.then()
.isAppWindowOnTop(FlickerComponentName.SNAPSHOT, isOptional = true)
.then()
@@ -188,16 +229,4 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
.isAppWindowOnTop(testApp.component)
}
}
/**
* Checks that [LAUNCHER_COMPONENT] window is visible at the start, and
* becomes invisible during the transition
*/
open fun launcherWindowBecomesInvisible() {
testSpec.assertWm {
this.isAppWindowOnTop(LAUNCHER_COMPONENT)
.then()
.isAppWindowNotOnTop(LAUNCHER_COMPONENT)
}
}
}
}

View File

@@ -54,7 +54,8 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class OpenAppWarmTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSpec) {
class OpenAppWarmTest(testSpec: FlickerTestParameter)
: OpenAppFromLauncherTransition(testSpec) {
/**
* Defines the transition used to run the test
*/
@@ -109,11 +110,6 @@ class OpenAppWarmTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSp
@Test
override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()
/** {@inheritDoc} */
@Presubmit
@Test
override fun launcherWindowBecomesInvisible() = super.launcherWindowBecomesInvisible()
/** {@inheritDoc} */
@Presubmit
@Test
@@ -124,6 +120,16 @@ class OpenAppWarmTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSp
@Test
override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appLayerBecomesVisible() = super.appLayerBecomesVisible_warmStart()
/** {@inheritDoc} */
@Presubmit
@Test
override fun appWindowBecomesVisible() = super.appWindowBecomesVisible_warmStart()
companion object {
/**
* Creates the test configurations.