Enable/Disable flicker assertions

Reviewed all assertions and enabled/disabled those that are flaky.

Bug: 162488030
Test: atest FlickerTests
Change-Id: Iee00a149eeb996bc3b18f7954412c2b6767170f9
This commit is contained in:
Nataniel Borges
2020-07-30 12:26:49 +02:00
parent 913e68c98e
commit 00a7fa5699
13 changed files with 233 additions and 91 deletions

View File

@@ -92,7 +92,7 @@ abstract class FlickerTestBase {
app2: IAppHelper?,
extraInfo: String
): String {
var testTag = "${testName}__$${app.launcherName}"
var testTag = "${testName}__${app.launcherName}"
if (app2 != null) {
testTag += "-${app2.launcherName}"
}

View File

@@ -81,11 +81,11 @@ class CloseImeAutoOpenWindowToHomeTest(
}
layersTrace {
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(rotation)
navBarLayerRotatesAndScales(rotation)
statusBarLayerRotatesScales(rotation)
navBarLayerIsAlwaysVisible(bugId = 140855415)
statusBarLayerIsAlwaysVisible(bugId = 140855415)
noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false)
navBarLayerRotatesAndScales(rotation, Surface.ROTATION_0)
statusBarLayerRotatesScales(rotation, Surface.ROTATION_0)
imeLayerBecomesInvisible(bugId = 141458352)
imeAppLayerBecomesInvisible(testApp, bugId = 153739621)
}

View File

@@ -89,9 +89,9 @@ open class CloseImeWindowToHomeTest(
}
layersTrace {
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(rotation)
navBarLayerIsAlwaysVisible(bugId = 140855415)
statusBarLayerIsAlwaysVisible(bugId = 140855415)
noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false)
navBarLayerRotatesAndScales(rotation, Surface.ROTATION_0)
statusBarLayerRotatesScales(rotation, Surface.ROTATION_0)
imeLayerBecomesInvisible(bugId = 153739621)

View File

@@ -71,18 +71,18 @@ class OpenAppColdTest(
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
appWindowReplacesLauncherAsTopWindow(bugId = 141361128)
appWindowReplacesLauncherAsTopWindow()
wallpaperWindowBecomesInvisible()
}
layersTrace {
noUncoveredRegions(rotation, bugId = 141361128)
// During testing the launcher is always in portrait mode
noUncoveredRegions(Surface.ROTATION_0, rotation, bugId = 141361128)
navBarLayerRotatesAndScales(Surface.ROTATION_0, rotation)
statusBarLayerRotatesScales(Surface.ROTATION_0, rotation)
navBarLayerIsAlwaysVisible(bugId = 141361128)
statusBarLayerIsAlwaysVisible(bugId = 141361128)
wallpaperLayerBecomesInvisible(bugId = 141361128)
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible(enabled = false)
wallpaperLayerBecomesInvisible()
}
eventLog {

View File

@@ -44,10 +44,9 @@ abstract class OpenAppTestBase(
enabled: Boolean = bugId == 0
) {
all("appWindowReplacesLauncherAsTopWindow", enabled, bugId) {
this.showsAppWindowOnTop(
"Launcher")
this.showsAppWindowOnTop("Launcher")
.then()
.showsAppWindowOnTop(testApp.getPackage())
.showsAppWindowOnTop("Snapshot", testApp.getPackage())
}
}

View File

@@ -79,18 +79,18 @@ class OpenAppWarmTest(
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
appWindowReplacesLauncherAsTopWindow(bugId = 141361128)
appWindowReplacesLauncherAsTopWindow()
wallpaperWindowBecomesInvisible(enabled = false)
}
layersTrace {
noUncoveredRegions(rotation, bugId = 141361128)
// During testing the launcher is always in portrait mode
noUncoveredRegions(Surface.ROTATION_0, rotation, bugId = 141361128)
navBarLayerRotatesAndScales(Surface.ROTATION_0, rotation)
statusBarLayerRotatesScales(Surface.ROTATION_0, rotation)
navBarLayerIsAlwaysVisible(bugId = 141361128)
statusBarLayerIsAlwaysVisible(bugId = 141361128)
wallpaperLayerBecomesInvisible(bugId = 141361128)
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible(enabled = false)
wallpaperLayerBecomesInvisible()
}
eventLog {

View File

@@ -0,0 +1,121 @@
/*
* Copyright (C) 2020 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.pip
import android.view.Surface
import androidx.test.filters.FlakyTest
import androidx.test.filters.LargeTest
import com.android.server.wm.flicker.dsl.flicker
import com.android.server.wm.flicker.helpers.closePipWindow
import com.android.server.wm.flicker.helpers.expandPipWindow
import com.android.server.wm.flicker.helpers.hasPipWindow
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test Pip launch.
* To run this test: `atest FlickerTests:PipToAppTest`
*/
@LargeTest
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 152738416)
class EnterPipTest(
rotationName: String,
rotation: Int
) : PipTestBase(rotationName, rotation) {
@Test
fun test() {
flicker(instrumentation) {
withTag { buildTestTag("enterPip", testApp, rotation) }
repeat { 1 }
setup {
test {
device.wakeUpAndGoToHomeScreen()
}
eachRun {
device.pressHome()
testApp.open()
this.setRotation(rotation)
}
}
teardown {
eachRun {
if (device.hasPipWindow()) {
device.closePipWindow()
}
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
test {
if (device.hasPipWindow()) {
device.closePipWindow()
}
}
}
transitions {
testApp.clickEnterPipButton(device)
device.expandPipWindow()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
all("pipWindowBecomesVisible") {
this.showsAppWindow(testApp.`package`)
.then()
.showsAppWindow(sPipWindowTitle)
}
}
layersTrace {
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false)
navBarLayerRotatesAndScales(rotation, Surface.ROTATION_0)
statusBarLayerRotatesScales(rotation, Surface.ROTATION_0)
all("pipLayerBecomesVisible") {
this.showsLayer(testApp.launcherName)
.then()
.showsLayer(sPipWindowTitle)
}
}
}
}
}
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
val supportedRotations = intArrayOf(Surface.ROTATION_0)
return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) }
}
}
}

View File

@@ -16,9 +16,7 @@
package com.android.server.wm.flicker.pip
import com.android.server.wm.flicker.dsl.LayersAssertion
import com.android.server.wm.flicker.NonRotationTestBase
import com.android.server.wm.flicker.dsl.WmAssertion
import com.android.server.wm.flicker.helpers.PipAppHelper
abstract class PipTestBase(
@@ -27,24 +25,6 @@ abstract class PipTestBase(
) : NonRotationTestBase(rotationName, rotation) {
protected val testApp = PipAppHelper(instrumentation)
protected fun WmAssertion.pipWindowBecomesVisible() {
all("pipWindowBecomesVisible") {
this.skipUntilFirstAssertion()
.showsAppWindowOnTop(sPipWindowTitle)
.then()
.hidesAppWindow(sPipWindowTitle)
}
}
protected fun LayersAssertion.pipLayerBecomesVisible() {
all("pipLayerBecomesVisible") {
this.skipUntilFirstAssertion()
.showsLayer(sPipWindowTitle)
.then()
.hidesLayer(sPipWindowTitle)
}
}
companion object {
const val sPipWindowTitle = "PipMenuActivity"
}

View File

@@ -56,35 +56,42 @@ class PipToAppTest(
withTag { buildTestTag("exitPipModeToApp", testApp, rotation) }
repeat { 1 }
setup {
eachRun {
test {
device.wakeUpAndGoToHomeScreen()
device.pressHome()
testApp.open()
}
eachRun {
this.setRotation(rotation)
testApp.clickEnterPipButton(device)
device.hasPipWindow()
}
}
teardown {
eachRun {
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
test {
if (device.hasPipWindow()) {
device.closePipWindow()
}
testApp.exit()
}
}
transitions {
device.pressHome()
this.setRotation(rotation)
testApp.open()
testApp.clickEnterPipButton(device)
device.expandPipWindow()
device.waitForIdle()
testApp.exit()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
pipWindowBecomesVisible()
all("appReplacesPipWindow") {
this.showsAppWindow(sPipWindowTitle)
.then()
.showsAppWindowOnTop(testApp.launcherName)
}
}
layersTrace {
@@ -93,7 +100,12 @@ class PipToAppTest(
noUncoveredRegions(rotation)
navBarLayerRotatesAndScales(rotation)
statusBarLayerRotatesScales(rotation)
pipLayerBecomesVisible()
all("appReplacesPipLayer") {
this.showsLayer(sPipWindowTitle)
.then()
.showsLayer(testApp.launcherName)
}
}
eventLog {

View File

@@ -55,52 +55,59 @@ class PipToHomeTest(
withTag { buildTestTag("exitPipModeToApp", testApp, rotation) }
repeat { 1 }
setup {
eachRun {
test {
device.wakeUpAndGoToHomeScreen()
device.pressHome()
this.setRotation(rotation)
}
eachRun {
testApp.open()
this.setRotation(rotation)
testApp.clickEnterPipButton(device)
device.hasPipWindow()
}
}
teardown {
eachRun {
testApp.exit()
this.setRotation(Surface.ROTATION_0)
if (device.hasPipWindow()) {
device.closePipWindow()
}
}
test {
if (device.hasPipWindow()) {
device.closePipWindow()
}
testApp.exit()
}
}
transitions {
testApp.clickEnterPipButton(device)
testApp.closePipWindow(device)
device.waitForIdle()
testApp.exit()
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
pipWindowBecomesVisible()
all {
this.showsAppWindowOnTop(sPipWindowTitle)
.and()
.showsBelowAppWindow("Wallpaper")
all("pipWindowBecomesInvisible") {
this.showsAppWindow(sPipWindowTitle)
.then()
.showsAboveAppWindow("Wallpaper")
.hidesAppWindow(sPipWindowTitle)
}
}
layersTrace {
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(rotation)
// The final state is the launcher, so always in portrait mode
noUncoveredRegions(rotation, Surface.ROTATION_0, allStates = false)
navBarLayerRotatesAndScales(rotation)
statusBarLayerRotatesScales(rotation)
pipLayerBecomesVisible()
all("pipLayerBecomesInvisible") {
this.showsLayer(sPipWindowTitle)
.then()
.hidesLayer(sPipWindowTitle)
}
}
eventLog {
@@ -109,4 +116,13 @@ class PipToHomeTest(
}
}
}
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
val supportedRotations = intArrayOf(Surface.ROTATION_0)
return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) }
}
}
}

View File

@@ -62,25 +62,29 @@ class ChangeAppRotationTest(
}
repeat { 1 }
setup {
eachRun {
test {
device.wakeUpAndGoToHomeScreen()
testApp.open()
}
eachRun {
this.setRotation(beginRotation)
}
}
teardown {
eachRun {
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
test {
testApp.exit()
}
}
transitions {
this.setRotation(endRotation)
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible(bugId = 140855415)
statusBarWindowIsAlwaysVisible(bugId = 140855415)
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
}
layersTrace {
@@ -103,21 +107,12 @@ class ChangeAppRotationTest(
this.hasVisibleRegion(testApp.getPackage(), endingPos)
}
all("screenshotLayerBecomesInvisible", enabled = false) {
all("screenshotLayerBecomesInvisible") {
this.showsLayer(testApp.getPackage())
.then()
.replaceVisibleLayer(
testApp.getPackage(),
SCREENSHOT_LAYER)
.then()
.showsLayer(testApp.getPackage())
.and()
.showsLayer(SCREENSHOT_LAYER)
.then()
.replaceVisibleLayer(
SCREENSHOT_LAYER,
testApp.getPackage()
)
showsLayer(testApp.getPackage())
}
}

View File

@@ -16,7 +16,6 @@
package com.android.server.wm.flicker.splitscreen
import android.os.SystemClock
import android.view.Surface
import androidx.test.filters.LargeTest
import com.android.server.wm.flicker.NonRotationTestBase
@@ -24,6 +23,7 @@ import com.android.server.wm.flicker.StandardAppHelper
import com.android.server.wm.flicker.dsl.flicker
import com.android.server.wm.flicker.focusChanges
import com.android.server.wm.flicker.helpers.exitSplitScreen
import com.android.server.wm.flicker.helpers.isInSplitScreen
import com.android.server.wm.flicker.helpers.launchSplitScreen
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
@@ -59,16 +59,21 @@ class OpenAppToSplitScreenTest(
withTag { buildTestTag("appToSplitScreen", testApp, rotation) }
repeat { 1 }
setup {
eachRun {
test {
device.wakeUpAndGoToHomeScreen()
this.setRotation(rotation)
}
eachRun {
testApp.open()
SystemClock.sleep(500)
this.setRotation(rotation)
}
}
teardown {
eachRun {
device.exitSplitScreen()
if (device.isInSplitScreen()) {
device.exitSplitScreen()
}
}
test {
testApp.exit()
}
}

View File

@@ -17,9 +17,8 @@
package com.android.server.wm.flicker.splitscreen
import android.view.Surface
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import com.android.server.wm.flicker.FlickerTestBase
import com.android.server.wm.flicker.NonRotationTestBase
import com.android.server.wm.flicker.StandardAppHelper
import com.android.server.wm.flicker.dsl.flicker
import com.android.server.wm.flicker.focusDoesNotChange
@@ -38,16 +37,19 @@ import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/**
* Test open app to split screen.
* To run this test: `atest FlickerTests:SplitScreenToLauncherTest`
*/
@LargeTest
@RunWith(AndroidJUnit4::class)
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class SplitScreenToLauncherTest : FlickerTestBase() {
private val rotation: Int = Surface.ROTATION_0
class SplitScreenToLauncherTest(
rotationName: String,
rotation: Int
) : NonRotationTestBase(rotationName, rotation) {
@Test
fun test() {
val testApp = StandardAppHelper(instrumentation,
@@ -57,8 +59,10 @@ class SplitScreenToLauncherTest : FlickerTestBase() {
withTag { buildTestTag("splitScreenToLauncher", testApp, rotation) }
repeat { 1 }
setup {
eachRun {
test {
device.wakeUpAndGoToHomeScreen()
}
eachRun {
testApp.open()
this.setRotation(rotation)
device.launchSplitScreen()
@@ -111,4 +115,14 @@ class SplitScreenToLauncherTest : FlickerTestBase() {
}
}
}
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
// b/161435597 causes the test not to work on 90 degrees
val supportedRotations = intArrayOf(Surface.ROTATION_0)
return supportedRotations.map { arrayOf(Surface.rotationToString(it), it) }
}
}
}