Add assertions to CloseAppBackButtonTest

Adding all the assertions for the CloseAppBackButtonTest. This includes WM assertions (the common ones for all test + one that the launcher replaces the app window and another that the wallpaper window becomes visible) and layers assertions (the common ones + one for the wallpaper layer replacing the app layer).
Also adding new assertions in CommonAssertions files (wallpaperLayerReplacesAppLayer, wallpaperWindowBecomesVisible and launcherReplacesAppWindowAsTopWindow).

Test: atest FlickerTests:CloseAppBackButtonTest
Bug: b/171049647
Change-Id: I992edfe372b677d723dda09a0af8fdf9f6213c73
This commit is contained in:
Antonella Dellanzo
2020-11-12 10:16:19 +01:00
parent f24001ca2b
commit 042fac5bdf
2 changed files with 76 additions and 16 deletions

View File

@@ -16,6 +16,7 @@
package com.android.server.wm.flicker
import android.platform.helpers.IAppHelper
import com.android.server.wm.flicker.dsl.EventLogAssertion
import com.android.server.wm.flicker.dsl.LayersAssertion
import com.android.server.wm.flicker.dsl.WmAssertion
@@ -24,6 +25,7 @@ import com.android.server.wm.flicker.helpers.WindowUtils
const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar"
const val STATUS_BAR_WINDOW_TITLE = "StatusBar"
const val DOCKED_STACK_DIVIDER = "DockedStackDivider"
const val WALLPAPER_TITLE = "Wallpaper"
@JvmOverloads
fun WmAssertion.statusBarWindowIsAlwaysVisible(
@@ -54,6 +56,29 @@ fun WmAssertion.visibleWindowsShownMoreThanOneConsecutiveEntry(
}
}
fun WmAssertion.launcherReplacesAppWindowAsTopWindow(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
all("launcherReplacesAppWindowAsTopWindow", bugId, enabled) {
this.showsAppWindowOnTop(testApp.getPackage())
.then()
.showsAppWindowOnTop("Launcher")
}
}
fun WmAssertion.wallpaperWindowBecomesVisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
all("wallpaperWindowBecomesVisible", bugId, enabled) {
this.hidesBelowAppWindow(WALLPAPER_TITLE)
.then()
.showsBelowAppWindow(WALLPAPER_TITLE)
}
}
@JvmOverloads
fun LayersAssertion.noUncoveredRegions(
beginRotation: Int,
@@ -177,6 +202,18 @@ fun LayersAssertion.visibleLayersShownMoreThanOneConsecutiveEntry(
}
}
fun LayersAssertion.wallpaperLayerReplacesAppLayer(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
all("appLayerReplacesWallpaperLayer", bugId, enabled) {
this.showsLayer(testApp.getPackage())
.then()
.replaceVisibleLayer(testApp.getPackage(), WALLPAPER_TITLE)
}
}
fun EventLogAssertion.focusChanges(
vararg windows: String,
bugId: Int = 0,

View File

@@ -20,8 +20,21 @@ import android.view.Surface
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.wm.flicker.Flicker
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.FlickerTestRunnerFactory
import com.android.server.wm.flicker.FlickerTestRunner
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.launcherReplacesAppWindowAsTopWindow
import com.android.server.wm.flicker.wallpaperWindowBecomesVisible
import com.android.server.wm.flicker.wallpaperLayerReplacesAppLayer
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.navBarLayerRotatesAndScales
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.buildTestTag
@@ -34,22 +47,6 @@ import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
/*
* 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.
*/
/**
* Test app closes by pressing back button
* To run this test: `atest FlickerTests:CloseAppBackButtonTest`
@@ -93,6 +90,32 @@ class CloseAppBackButtonTest(
testApp.exit()
}
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible()
statusBarWindowIsAlwaysVisible()
visibleWindowsShownMoreThanOneConsecutiveEntry()
launcherReplacesAppWindowAsTopWindow(testApp)
wallpaperWindowBecomesVisible()
}
layersTrace {
noUncoveredRegions(configuration.startRotation,
Surface.ROTATION_0, bugId = 141361128)
navBarLayerRotatesAndScales(configuration.startRotation,
Surface.ROTATION_0)
statusBarLayerRotatesScales(configuration.startRotation,
Surface.ROTATION_0)
navBarLayerIsAlwaysVisible(
enabled = Surface.ROTATION_0 == configuration.endRotation)
statusBarLayerIsAlwaysVisible(
enabled = Surface.ROTATION_0 == configuration.endRotation)
visibleLayersShownMoreThanOneConsecutiveEntry()
wallpaperLayerReplacesAppLayer(testApp)
}
}
}
}
}