Compatibilize tests with new runner
Runner now prints each assertion individually to aid debugging.
Bug: 162923992
Test: atest FlickerTests WMShellFlickerTests
Change-Id: I1c9a49ec3c283e5e034f0223573fca3ccafaf64c
diff --git a/tests/FlickerTests/Android.bp b/tests/FlickerTests/Android.bp
index 1a83655..c945aea 100644
--- a/tests/FlickerTests/Android.bp
+++ b/tests/FlickerTests/Android.bp
@@ -49,7 +49,6 @@
"flickertestapplib",
"flickerlib",
"truth-prebuilt",
- "app-helpers-core",
"launcher-helper-lib",
"launcher-aosp-tapl",
"platform-test-annotations",
@@ -81,6 +80,7 @@
],
static_libs: [
"flickerlib",
+ "flickertestapplib",
"truth-prebuilt",
"app-helpers-core"
],
diff --git a/tests/FlickerTests/AndroidTestPhysicalDevices.xml b/tests/FlickerTests/AndroidTestPhysicalDevices.xml
index abd620f..b1cee5c 100644
--- a/tests/FlickerTests/AndroidTestPhysicalDevices.xml
+++ b/tests/FlickerTests/AndroidTestPhysicalDevices.xml
@@ -11,8 +11,6 @@
<option name="force-skip-system-props" value="true" />
<!-- set WM tracing verbose level to all -->
<option name="run-command" value="cmd window tracing level all" />
- <!-- inform WM to log all transactions -->
- <option name="run-command" value="cmd window tracing transaction" />
<!-- restart launcher to activate TAPL -->
<option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" />
</target_preparer>
@@ -30,7 +28,7 @@
<option name="include-annotation" value="androidx.test.filters.RequiresDevice" />
<option name="exclude-annotation" value="androidx.test.filters.FlakyTest" />
<option name="shell-timeout" value="6600s" />
- <option name="test-timeout" value="6000s" />
+ <option name="test-timeout" value="6600s" />
<option name="hidden-api-checks" value="false" />
</test>
<metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt
index e4db55e..ba12fbe 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt
@@ -17,9 +17,9 @@
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
+import com.android.server.wm.flicker.dsl.EventLogAssertionBuilder
+import com.android.server.wm.flicker.dsl.LayersAssertionBuilder
+import com.android.server.wm.flicker.dsl.WmAssertionBuilder
import com.android.server.wm.flicker.helpers.WindowUtils
const val NAVIGATION_BAR_WINDOW_TITLE = "NavigationBar"
@@ -28,7 +28,7 @@
const val WALLPAPER_TITLE = "Wallpaper"
@JvmOverloads
-fun WmAssertion.statusBarWindowIsAlwaysVisible(
+fun WmAssertionBuilder.statusBarWindowIsAlwaysVisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -38,7 +38,7 @@
}
@JvmOverloads
-fun WmAssertion.navBarWindowIsAlwaysVisible(
+fun WmAssertionBuilder.navBarWindowIsAlwaysVisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -47,7 +47,7 @@
}
}
-fun WmAssertion.visibleWindowsShownMoreThanOneConsecutiveEntry(
+fun WmAssertionBuilder.visibleWindowsShownMoreThanOneConsecutiveEntry(
ignoreWindows: List<String> = emptyList(),
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -57,7 +57,7 @@
}
}
-fun WmAssertion.launcherReplacesAppWindowAsTopWindow(
+fun WmAssertionBuilder.launcherReplacesAppWindowAsTopWindow(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -69,7 +69,7 @@
}
}
-fun WmAssertion.wallpaperWindowBecomesVisible(
+fun WmAssertionBuilder.wallpaperWindowBecomesVisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -80,7 +80,7 @@
}
}
-fun WmAssertion.wallpaperWindowBecomesInvisible(
+fun WmAssertionBuilder.wallpaperWindowBecomesInvisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -91,7 +91,7 @@
}
}
-fun WmAssertion.appWindowAlwaysVisibleOnTop(
+fun WmAssertionBuilder.appWindowAlwaysVisibleOnTop(
packageName: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -101,7 +101,7 @@
}
}
-fun WmAssertion.appWindowBecomesVisible(
+fun WmAssertionBuilder.appWindowBecomesVisible(
appName: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -114,7 +114,7 @@
}
@JvmOverloads
-fun LayersAssertion.noUncoveredRegions(
+fun LayersAssertionBuilder.noUncoveredRegions(
beginRotation: Int,
endRotation: Int = beginRotation,
allStates: Boolean = true,
@@ -144,7 +144,7 @@
}
@JvmOverloads
-fun LayersAssertion.navBarLayerIsAlwaysVisible(
+fun LayersAssertionBuilder.navBarLayerIsAlwaysVisible(
rotatesScreen: Boolean = false,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -165,7 +165,7 @@
}
@JvmOverloads
-fun LayersAssertion.statusBarLayerIsAlwaysVisible(
+fun LayersAssertionBuilder.statusBarLayerIsAlwaysVisible(
rotatesScreen: Boolean = false,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -186,7 +186,7 @@
}
@JvmOverloads
-fun LayersAssertion.navBarLayerRotatesAndScales(
+fun LayersAssertionBuilder.navBarLayerRotatesAndScales(
beginRotation: Int,
endRotation: Int = beginRotation,
bugId: Int = 0,
@@ -210,7 +210,7 @@
}
@JvmOverloads
-fun LayersAssertion.statusBarLayerRotatesScales(
+fun LayersAssertionBuilder.statusBarLayerRotatesScales(
beginRotation: Int,
endRotation: Int = beginRotation,
bugId: Int = 0,
@@ -227,7 +227,7 @@
}
}
-fun LayersAssertion.visibleLayersShownMoreThanOneConsecutiveEntry(
+fun LayersAssertionBuilder.visibleLayersShownMoreThanOneConsecutiveEntry(
ignoreLayers: List<String> = emptyList(),
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -237,7 +237,7 @@
}
}
-fun LayersAssertion.appLayerReplacesWallpaperLayer(
+fun LayersAssertionBuilder.appLayerReplacesWallpaperLayer(
appName: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -249,7 +249,7 @@
}
}
-fun LayersAssertion.wallpaperLayerReplacesAppLayer(
+fun LayersAssertionBuilder.wallpaperLayerReplacesAppLayer(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -261,7 +261,7 @@
}
}
-fun LayersAssertion.layerAlwaysVisible(
+fun LayersAssertionBuilder.layerAlwaysVisible(
packageName: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -271,7 +271,7 @@
}
}
-fun LayersAssertion.layerBecomesVisible(
+fun LayersAssertionBuilder.layerBecomesVisible(
packageName: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -283,7 +283,7 @@
}
}
-fun LayersAssertion.layerBecomesInvisible(
+fun LayersAssertionBuilder.layerBecomesInvisible(
packageName: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -295,7 +295,7 @@
}
}
-fun EventLogAssertion.focusChanges(
+fun EventLogAssertionBuilder.focusChanges(
vararg windows: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -305,7 +305,7 @@
}
}
-fun EventLogAssertion.focusDoesNotChange(
+fun EventLogAssertionBuilder.focusDoesNotChange(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt
index 67deca4..a625dfd 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppBackButtonTest.kt
@@ -16,14 +16,13 @@
package com.android.server.wm.flicker.close
-import androidx.test.filters.FlakyTest
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.helpers.SimpleAppHelper
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
@@ -37,10 +36,9 @@
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
+import com.android.server.wm.flicker.helpers.isRotated
import com.android.server.wm.flicker.helpers.setRotation
-import com.android.server.wm.flicker.helpers.waitUntilGone
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import org.junit.FixMethodOrder
@@ -55,70 +53,69 @@
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@FlakyTest(bugId = 174635878)
class CloseAppBackButtonTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
- val testApp = StandardAppHelper(instrumentation,
- "com.android.server.wm.flicker.testapp", "SimpleApp")
- return FlickerTestRunnerFactory(instrumentation, repetitions = 10)
- .buildTest { configuration ->
- withTestName { buildTestTag("closeAppBackButton", testApp, configuration) }
- repeat { configuration.repetitions }
- setup {
- test {
- device.wakeUpAndGoToHomeScreen()
- }
- eachRun {
- this.setRotation(configuration.startRotation)
- testApp.open()
- }
+ val testApp = SimpleAppHelper(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
+ .buildTest { configuration ->
+ withTestName { buildTestTag("closeAppBackButton", configuration) }
+ repeat { configuration.repetitions }
+ setup {
+ test {
+ device.wakeUpAndGoToHomeScreen()
}
- transitions {
- device.pressBack()
- device.waitUntilGone(testApp.getPackage())
- }
- teardown {
- eachRun {
- this.setRotation(Surface.ROTATION_0)
- }
- test {
- 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)
- }
+ eachRun {
+ this.setRotation(configuration.startRotation)
+ testApp.launchViaIntent(wmHelper)
}
}
+ transitions {
+ device.pressBack()
+ wmHelper.waitForHomeActivityVisible()
+ }
+ teardown {
+ eachRun {
+ this.setRotation(Surface.ROTATION_0)
+ }
+ test {
+ testApp.exit()
+ }
+ }
+ assertions {
+ windowManagerTrace {
+ navBarWindowIsAlwaysVisible()
+ statusBarWindowIsAlwaysVisible()
+ visibleWindowsShownMoreThanOneConsecutiveEntry(bugId = 174635878)
+
+ launcherReplacesAppWindowAsTopWindow(testApp)
+ wallpaperWindowBecomesVisible()
+ }
+
+ layersTrace {
+ noUncoveredRegions(configuration.startRotation,
+ Surface.ROTATION_0)
+ navBarLayerRotatesAndScales(configuration.startRotation,
+ Surface.ROTATION_0,
+ enabled = !configuration.startRotation.isRotated())
+ statusBarLayerRotatesScales(configuration.startRotation,
+ Surface.ROTATION_0,
+ enabled = !configuration.startRotation.isRotated())
+ navBarLayerIsAlwaysVisible()
+ statusBarLayerIsAlwaysVisible()
+ visibleLayersShownMoreThanOneConsecutiveEntry(bugId = 174635878)
+
+ wallpaperLayerReplacesAppLayer(testApp)
+ }
+ }
+ }
}
}
}
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt
index 252ce2a..e88b10b 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppHomeButtonTest.kt
@@ -16,14 +16,13 @@
package com.android.server.wm.flicker.close
-import androidx.test.filters.FlakyTest
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.helpers.SimpleAppHelper
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
@@ -37,10 +36,8 @@
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
import com.android.server.wm.flicker.helpers.setRotation
-import com.android.server.wm.flicker.helpers.waitUntilGone
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import org.junit.FixMethodOrder
@@ -55,70 +52,68 @@
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@FlakyTest(bugId = 174635878)
class CloseAppHomeButtonTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
- val testApp = StandardAppHelper(instrumentation,
- "com.android.server.wm.flicker.testapp", "SimpleApp")
- return FlickerTestRunnerFactory(instrumentation, repetitions = 10)
- .buildTest { configuration ->
- withTestName { buildTestTag("closeAppHomeButton", testApp, configuration) }
- repeat { configuration.repetitions }
- setup {
- test {
- device.wakeUpAndGoToHomeScreen()
- }
- eachRun {
- this.setRotation(configuration.startRotation)
- testApp.open()
- }
+ val testApp = SimpleAppHelper(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
+ .buildTest { configuration ->
+ withTestName { buildTestTag("closeAppHomeButton", configuration) }
+ repeat { configuration.repetitions }
+ setup {
+ test {
+ device.wakeUpAndGoToHomeScreen()
}
- transitions {
- device.pressHome()
- device.waitUntilGone(testApp.getPackage())
- }
- teardown {
- eachRun {
- this.setRotation(Surface.ROTATION_0)
- }
- test {
- 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)
- }
+ eachRun {
+ testApp.launchViaIntent(wmHelper)
+ this.setRotation(configuration.startRotation)
}
}
+ transitions {
+ device.pressHome()
+ wmHelper.waitForHomeActivityVisible()
+ }
+ teardown {
+ eachRun {
+ this.setRotation(Surface.ROTATION_0)
+ }
+ test {
+ testApp.exit()
+ }
+ }
+ assertions {
+ windowManagerTrace {
+ navBarWindowIsAlwaysVisible()
+ statusBarWindowIsAlwaysVisible()
+ visibleWindowsShownMoreThanOneConsecutiveEntry(bugId = 174635878)
+
+ launcherReplacesAppWindowAsTopWindow(testApp)
+ wallpaperWindowBecomesVisible()
+ }
+
+ layersTrace {
+ val isRotation0 = configuration.startRotation == Surface.ROTATION_0
+ noUncoveredRegions(configuration.startRotation,
+ Surface.ROTATION_0)
+ navBarLayerRotatesAndScales(configuration.startRotation,
+ Surface.ROTATION_0, enabled = isRotation0)
+ statusBarLayerRotatesScales(configuration.startRotation,
+ Surface.ROTATION_0, enabled = isRotation0)
+ navBarLayerIsAlwaysVisible()
+ statusBarLayerIsAlwaysVisible()
+ visibleLayersShownMoreThanOneConsecutiveEntry(bugId = 174635878)
+
+ wallpaperLayerReplacesAppLayer(testApp)
+ }
+ }
+ }
}
}
}
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt
index 742003a..b569eda 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/FlickerExtensions.kt
@@ -18,23 +18,29 @@
import android.os.Bundle
import android.os.RemoteException
-import android.os.SystemClock
import android.platform.helpers.IAppHelper
import android.view.Surface
import com.android.server.wm.flicker.Flicker
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.startRotation
+/**
+ * Changes the device [rotation] and wait for the rotation animation to complete
+ *
+ * @param rotation New device rotation
+ */
fun Flicker.setRotation(rotation: Int) {
try {
when (rotation) {
- Surface.ROTATION_270 -> device.setOrientationLeft()
- Surface.ROTATION_90 -> device.setOrientationRight()
+ Surface.ROTATION_270 -> device.setOrientationRight()
+ Surface.ROTATION_90 -> device.setOrientationLeft()
Surface.ROTATION_0 -> device.setOrientationNatural()
else -> device.setOrientationNatural()
}
- // Wait for animation to complete
- SystemClock.sleep(1000)
+
+ wmHelper.waitForRotation(rotation)
+ wmHelper.waitForNavBarStatusBarVisible()
+ wmHelper.waitForAppTransitionIdle()
} catch (e: RemoteException) {
throw RuntimeException(e)
}
@@ -63,17 +69,41 @@
* Build a test tag for the test
* @param testName Name of the transition(s) being tested
* @param app App being launcher
- * @param rotation Screen rotation configuration for the test
+ * @param configuration Configuration for the test
*
* @return test tag with pattern <NAME>__<APP>__<BEGIN_ROTATION>-<END_ROTATION>
</END_ROTATION></BEGIN_ROTATION></APP></NAME> */
+@JvmOverloads
+fun buildTestTag(
+ testName: String,
+ configuration: Bundle,
+ extraInfo: String = ""
+): String {
+ return buildTestTag(testName,
+ app = null,
+ beginRotation = configuration.startRotation,
+ endRotation = configuration.endRotation,
+ app2 = null,
+ extraInfo = extraInfo)
+}
+
+/**
+ * Build a test tag for the test
+ * @param testName Name of the transition(s) being tested
+ * @param app App being launcher
+ * @param configuration Configuration for the test
+ *
+ * @return test tag with pattern <NAME>__<APP>__<BEGIN_ROTATION>-<END_ROTATION>
+</END_ROTATION></BEGIN_ROTATION></APP></NAME> */
+@JvmOverloads
fun buildTestTag(
testName: String,
app: IAppHelper?,
- configuration: Bundle
+ configuration: Bundle,
+ extraInfo: String = ""
): String {
return buildTestTag(testName, app?.launcherName ?: "", configuration.startRotation,
- configuration.endRotation, app2 = null, extraInfo = "")
+ configuration.endRotation, app2 = null, extraInfo = extraInfo)
}
/**
@@ -89,13 +119,16 @@
</EXTRA></NAME> */
fun buildTestTag(
testName: String,
- app: String,
+ app: String?,
beginRotation: Int,
endRotation: Int,
app2: String?,
extraInfo: String
): String {
- var testTag = "${testName}__$app"
+ var testTag = testName
+ if (app != null) {
+ testTag += "__$app"
+ }
if (app2 != null) {
testTag += "-$app2"
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt
index 6bf2c85..619a05e 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppAutoFocusHelper.kt
@@ -17,22 +17,31 @@
package com.android.server.wm.flicker.helpers
import android.app.Instrumentation
+import android.content.ComponentName
import androidx.test.uiautomator.UiDevice
+import com.android.server.wm.flicker.testapp.ActivityOptions
+import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
class ImeAppAutoFocusHelper @JvmOverloads constructor(
instr: Instrumentation,
private val rotation: Int,
- private val imePackageName: String = IME_PACKAGE
-) : ImeAppHelper(instr, "ImeAppAutoFocus") {
- override fun openIME(device: UiDevice) {
+ private val imePackageName: String = IME_PACKAGE,
+ launcherName: String = ActivityOptions.IME_ACTIVITY_AUTO_FOCUS_LAUNCHER_NAME,
+ component: ComponentName = ActivityOptions.IME_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME
+) : ImeAppHelper(instr, launcherName, component) {
+ override fun openIME(
+ device: UiDevice,
+ wmHelper: WindowManagerStateHelper?
+ ) {
// do nothing (the app is focused automatically)
+ waitAndAssertIMEShown(device, wmHelper)
}
override fun open() {
val expectedPackage = if (rotation.isRotated()) {
imePackageName
} else {
- packageName
+ getPackage()
}
launcherStrategy.launch(appName, expectedPackage)
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt
index 3565ca4..d8091a9 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/ImeAppHelper.kt
@@ -17,38 +17,68 @@
package com.android.server.wm.flicker.helpers
import android.app.Instrumentation
+import android.content.ComponentName
import android.support.test.launcherhelper.ILauncherStrategy
import android.support.test.launcherhelper.LauncherStrategyFactory
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
+import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
-import org.junit.Assert
-open class ImeAppHelper(
+open class ImeAppHelper @JvmOverloads constructor(
instr: Instrumentation,
- launcherName: String = "ImeApp",
+ launcherName: String = ActivityOptions.IME_ACTIVITY_LAUNCHER_NAME,
+ component: ComponentName = ActivityOptions.IME_ACTIVITY_COMPONENT_NAME,
launcherStrategy: ILauncherStrategy = LauncherStrategyFactory
.getInstance(instr)
.launcherStrategy
-) : StandardAppHelper(instr, launcherName, launcherStrategy) {
- open fun openIME(device: UiDevice) {
+) : StandardAppHelper(instr, launcherName, component, launcherStrategy) {
+ /**
+ * Opens the IME and wait for it to be displayed
+ *
+ * @param device UIDevice instance to interact with the device
+ * @param wmHelper Helper used to wait for WindowManager states
+ */
+ @JvmOverloads
+ open fun openIME(device: UiDevice, wmHelper: WindowManagerStateHelper? = null) {
val editText = device.wait(
- Until.findObject(By.res(getPackage(), "plain_text_input")),
- FIND_TIMEOUT)
- Assert.assertNotNull("Text field not found, this usually happens when the device " +
- "was left in an unknown state (e.g. in split screen)", editText)
+ Until.findObject(By.res(getPackage(), "plain_text_input")),
+ FIND_TIMEOUT)
+
+ require(editText != null) {
+ "Text field not found, this usually happens when the device " +
+ "was left in an unknown state (e.g. in split screen)"
+ }
editText.click()
- if (!WindowManagerStateHelper().waitImeWindowShown()) {
- Assert.fail("IME did not appear")
+ waitAndAssertIMEShown(device, wmHelper)
+ }
+
+ protected fun waitAndAssertIMEShown(
+ device: UiDevice,
+ wmHelper: WindowManagerStateHelper? = null
+ ) {
+ if (wmHelper == null) {
+ device.waitForIdle()
+ } else {
+ require(wmHelper.waitImeWindowShown()) { "IME did not appear" }
}
}
- open fun closeIME(device: UiDevice) {
+ /**
+ * Opens the IME and wait for it to be gone
+ *
+ * @param device UIDevice instance to interact with the device
+ * @param wmHelper Helper used to wait for WindowManager states
+ */
+ @JvmOverloads
+ open fun closeIME(device: UiDevice, wmHelper: WindowManagerStateHelper? = null) {
device.pressBack()
// Using only the AccessibilityInfo it is not possible to identify if the IME is active
- if (!WindowManagerStateHelper().waitImeWindowGone()) {
- Assert.fail("IME did not close")
+ if (wmHelper == null) {
+ device.waitForIdle()
+ } else {
+ require(wmHelper.waitImeWindowGone()) { "IME did did not close" }
}
}
}
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/SeamlessRotationAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/SeamlessRotationAppHelper.kt
new file mode 100644
index 0000000..02be3cf
--- /dev/null
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/SeamlessRotationAppHelper.kt
@@ -0,0 +1,32 @@
+/*
+ * 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.helpers
+
+import android.app.Instrumentation
+import android.content.ComponentName
+import android.support.test.launcherhelper.ILauncherStrategy
+import android.support.test.launcherhelper.LauncherStrategyFactory
+import com.android.server.wm.flicker.testapp.ActivityOptions
+
+class SeamlessRotationAppHelper @JvmOverloads constructor(
+ instr: Instrumentation,
+ launcherName: String = ActivityOptions.SEAMLESS_ACTIVITY_LAUNCHER_NAME,
+ component: ComponentName = ActivityOptions.SEAMLESS_ACTIVITY_COMPONENT_NAME,
+ launcherStrategy: ILauncherStrategy = LauncherStrategyFactory
+ .getInstance(instr)
+ .launcherStrategy
+) : StandardAppHelper(instr, launcherName, component, launcherStrategy)
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/SimpleAppHelper.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/SimpleAppHelper.kt
new file mode 100644
index 0000000..d7cbaae
--- /dev/null
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/helpers/SimpleAppHelper.kt
@@ -0,0 +1,32 @@
+/*
+ * 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.helpers
+
+import android.app.Instrumentation
+import android.content.ComponentName
+import android.support.test.launcherhelper.ILauncherStrategy
+import android.support.test.launcherhelper.LauncherStrategyFactory
+import com.android.server.wm.flicker.testapp.ActivityOptions
+
+class SimpleAppHelper @JvmOverloads constructor(
+ instr: Instrumentation,
+ launcherName: String = ActivityOptions.SIMPLE_ACTIVITY_LAUNCHER_NAME,
+ component: ComponentName = ActivityOptions.SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME,
+ launcherStrategy: ILauncherStrategy = LauncherStrategyFactory
+ .getInstance(instr)
+ .launcherStrategy
+) : StandardAppHelper(instr, launcherName, component, launcherStrategy)
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt
index 412a3c3..40406d4 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToAppTest.kt
@@ -25,6 +25,7 @@
import com.android.server.wm.flicker.FlickerTestRunnerFactory
import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper
import com.android.server.wm.flicker.helpers.buildTestTag
+import com.android.server.wm.flicker.helpers.isRotated
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
@@ -45,7 +46,7 @@
/**
* Test IME window closing back to app window transitions.
- * To run this test: `atest FlickerTests:CloseImeWindowToAppTest`
+ * To run this test: `atest FlickerTests:CloseImeAutoOpenWindowToAppTest`
*/
@Presubmit
@RequiresDevice
@@ -53,39 +54,40 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class CloseImeAutoOpenWindowToAppTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
-
- return FlickerTestRunnerFactory(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
.buildTest { configuration ->
val testApp = ImeAppAutoFocusHelper(instrumentation,
configuration.startRotation)
- withTag { buildTestTag("imeToAppAutoOpen", testApp, configuration) }
+ withTestName { buildTestTag("imeToAppAutoOpen", configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
}
eachRun {
+ testApp.launchViaIntent(wmHelper)
+ testApp.openIME(device, wmHelper)
this.setRotation(configuration.startRotation)
- testApp.open()
- testApp.openIME(device)
}
}
teardown {
- eachRun {
+ test {
testApp.exit()
+ wmHelper.waitForAppTransitionIdle()
this.setRotation(Surface.ROTATION_0)
}
}
transitions {
- testApp.closeIME(device)
+ testApp.closeIME(device, wmHelper)
}
assertions {
windowManagerTrace {
@@ -100,11 +102,13 @@
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.startRotation)
- navBarLayerRotatesAndScales(configuration.startRotation)
- statusBarLayerRotatesScales(configuration.startRotation)
+ navBarLayerRotatesAndScales(configuration.startRotation,
+ enabled = !configuration.startRotation.isRotated())
+ statusBarLayerRotatesScales(configuration.startRotation,
+ enabled = !configuration.startRotation.isRotated())
visibleLayersShownMoreThanOneConsecutiveEntry()
- imeLayerBecomesInvisible(bugId = 141458352)
+ imeLayerBecomesInvisible()
imeAppLayerIsAlwaysVisible(testApp)
}
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt
index 60a798f..f5bb8e1 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeAutoOpenWindowToHomeTest.kt
@@ -25,6 +25,7 @@
import com.android.server.wm.flicker.FlickerTestRunnerFactory
import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper
import com.android.server.wm.flicker.helpers.buildTestTag
+import com.android.server.wm.flicker.helpers.isRotated
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
@@ -53,21 +54,21 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class CloseImeAutoOpenWindowToHomeTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
-
- return FlickerTestRunnerFactory(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
.buildTest { configuration ->
val testApp = ImeAppAutoFocusHelper(instrumentation,
configuration.startRotation)
withTestName {
- buildTestTag("imeToHomeAutoOpen", testApp, configuration)
+ buildTestTag("imeToHomeAutoOpen", configuration)
}
repeat { configuration.repetitions }
setup {
@@ -75,20 +76,21 @@
device.wakeUpAndGoToHomeScreen()
}
eachRun {
+ testApp.launchViaIntent(wmHelper)
+ testApp.openIME(device, wmHelper)
this.setRotation(configuration.startRotation)
- testApp.open()
- testApp.openIME(device)
}
}
teardown {
- eachRun {
+ test {
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
}
transitions {
device.pressHome()
- device.waitForIdle()
+ wmHelper.waitForHomeActivityVisible()
+ wmHelper.waitImeWindowGone()
}
assertions {
windowManagerTrace {
@@ -96,24 +98,25 @@
statusBarWindowIsAlwaysVisible()
visibleWindowsShownMoreThanOneConsecutiveEntry(listOf(IME_WINDOW_TITLE))
- imeWindowBecomesInvisible(bugId = 141458352)
- imeAppWindowBecomesInvisible(testApp, bugId = 157449248)
+ imeWindowBecomesInvisible()
+ imeAppWindowBecomesInvisible(testApp)
}
layersTrace {
- noUncoveredRegions(configuration.startRotation, Surface.ROTATION_0,
- allStates = false)
+ noUncoveredRegions(configuration.startRotation, Surface.ROTATION_0)
navBarLayerRotatesAndScales(configuration.startRotation,
- Surface.ROTATION_0, bugId = 140855415)
+ Surface.ROTATION_0,
+ enabled = !configuration.startRotation.isRotated())
statusBarLayerRotatesScales(configuration.startRotation,
- Surface.ROTATION_0)
+ Surface.ROTATION_0,
+ enabled = !configuration.startRotation.isRotated())
navBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.startRotation)
+ enabled = !configuration.startRotation.isRotated())
statusBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.startRotation)
+ enabled = !configuration.startRotation.isRotated())
visibleLayersShownMoreThanOneConsecutiveEntry(listOf(IME_WINDOW_TITLE))
- imeLayerBecomesInvisible(bugId = 141458352)
+ imeLayerBecomesInvisible()
imeAppLayerBecomesInvisible(testApp)
}
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToAppTest.kt
index 663d456..b08cf6a 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToAppTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToAppTest.kt
@@ -53,8 +53,9 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class CloseImeWindowToAppTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@@ -62,28 +63,28 @@
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testApp = ImeAppHelper(instrumentation)
- return FlickerTestRunnerFactory(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
.buildTest { configuration ->
- withTestName { buildTestTag("imeToApp", testApp, configuration) }
+ withTestName { buildTestTag("imeToApp", configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
+ testApp.launchViaIntent()
+ this.setRotation(configuration.startRotation)
}
eachRun {
- this.setRotation(configuration.startRotation)
- testApp.open()
- testApp.openIME(device)
+ testApp.openIME(device, wmHelper)
}
}
teardown {
- eachRun {
+ test {
testApp.exit()
this.setRotation(Surface.ROTATION_0)
}
}
transitions {
- testApp.closeIME(device)
+ testApp.closeIME(device, wmHelper)
}
assertions {
windowManagerTrace {
@@ -102,7 +103,7 @@
statusBarLayerRotatesScales(configuration.startRotation)
visibleLayersShownMoreThanOneConsecutiveEntry()
- imeLayerBecomesInvisible(enabled = false)
+ imeLayerBecomesInvisible()
imeAppLayerIsAlwaysVisible(testApp)
}
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt
index bfe5264..9710600 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeWindowToHomeTest.kt
@@ -25,8 +25,7 @@
import com.android.server.wm.flicker.FlickerTestRunnerFactory
import com.android.server.wm.flicker.helpers.ImeAppHelper
import com.android.server.wm.flicker.helpers.buildTestTag
-import com.android.server.wm.flicker.helpers.openQuickstep
-import com.android.server.wm.flicker.helpers.reopenAppFromOverview
+import com.android.server.wm.flicker.helpers.isRotated
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
@@ -54,39 +53,38 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class CloseImeWindowToHomeTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
-
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testApp = ImeAppHelper(instrumentation)
- return FlickerTestRunnerFactory(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
.buildTest { configuration ->
- withTestName { buildTestTag("imeToHome", testApp, configuration) }
+ withTestName { buildTestTag("imeToHome", configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
- this.setRotation(configuration.startRotation)
- testApp.open()
}
eachRun {
- device.openQuickstep()
- device.reopenAppFromOverview()
+ testApp.launchViaIntent(wmHelper)
this.setRotation(configuration.startRotation)
- testApp.openIME(device)
+ testApp.openIME(device, wmHelper)
}
}
transitions {
device.pressHome()
- device.waitForIdle()
+ wmHelper.waitForHomeActivityVisible()
+ wmHelper.waitImeWindowGone()
}
teardown {
eachRun {
device.pressHome()
+ wmHelper.waitForHomeActivityVisible()
}
test {
testApp.exit()
@@ -105,18 +103,18 @@
layersTrace {
noUncoveredRegions(configuration.startRotation,
- Surface.ROTATION_0, allStates = false)
- navBarLayerRotatesAndScales(configuration.startRotation,
- Surface.ROTATION_0, bugId = 140855415)
- statusBarLayerRotatesScales(configuration.startRotation,
Surface.ROTATION_0)
- navBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.startRotation)
- statusBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.startRotation)
+ navBarLayerRotatesAndScales(configuration.startRotation,
+ Surface.ROTATION_0,
+ enabled = !configuration.startRotation.isRotated())
+ statusBarLayerRotatesScales(configuration.startRotation,
+ Surface.ROTATION_0,
+ enabled = !configuration.startRotation.isRotated())
+ navBarLayerIsAlwaysVisible()
+ statusBarLayerIsAlwaysVisible()
visibleLayersShownMoreThanOneConsecutiveEntry(listOf(IME_WINDOW_TITLE))
- imeLayerBecomesInvisible(bugId = 153739621)
+ imeLayerBecomesInvisible()
imeAppLayerBecomesInvisible(testApp)
}
}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt
index aa34b5d..96c2009 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CommonAssertions.kt
@@ -17,13 +17,13 @@
package com.android.server.wm.flicker.ime
import android.platform.helpers.IAppHelper
-import com.android.server.wm.flicker.dsl.LayersAssertion
-import com.android.server.wm.flicker.dsl.WmAssertion
+import com.android.server.wm.flicker.dsl.LayersAssertionBuilder
+import com.android.server.wm.flicker.dsl.WmAssertionBuilder
const val IME_WINDOW_TITLE = "InputMethod"
@JvmOverloads
-fun LayersAssertion.imeLayerBecomesVisible(
+fun LayersAssertionBuilder.imeLayerBecomesVisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -34,7 +34,7 @@
}
}
-fun LayersAssertion.imeLayerBecomesInvisible(
+fun LayersAssertionBuilder.imeLayerBecomesInvisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -45,7 +45,7 @@
}
}
-fun LayersAssertion.imeAppLayerIsAlwaysVisible(
+fun LayersAssertionBuilder.imeAppLayerIsAlwaysVisible(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -55,7 +55,7 @@
}
}
-fun WmAssertion.imeAppWindowIsAlwaysVisible(
+fun WmAssertionBuilder.imeAppWindowIsAlwaysVisible(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -65,7 +65,7 @@
}
}
-fun WmAssertion.imeWindowBecomesVisible(
+fun WmAssertionBuilder.imeWindowBecomesVisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -76,7 +76,7 @@
}
}
-fun WmAssertion.imeWindowBecomesInvisible(
+fun WmAssertionBuilder.imeWindowBecomesInvisible(
bugId: Int = 0,
enabled: Boolean = bugId == 0
) {
@@ -87,7 +87,7 @@
}
}
-fun WmAssertion.imeAppWindowBecomesVisible(
+fun WmAssertionBuilder.imeAppWindowBecomesVisible(
windowName: String,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -99,7 +99,7 @@
}
}
-fun WmAssertion.imeAppWindowBecomesInvisible(
+fun WmAssertionBuilder.imeAppWindowBecomesInvisible(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
@@ -111,7 +111,7 @@
}
}
-fun LayersAssertion.imeAppLayerBecomesInvisible(
+fun LayersAssertionBuilder.imeAppLayerBecomesInvisible(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt
index 28a8bd3..399a15a 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowTest.kt
@@ -34,6 +34,7 @@
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.appWindowAlwaysVisibleOnTop
+import com.android.server.wm.flicker.helpers.isRotated
import com.android.server.wm.flicker.layerAlwaysVisible
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
@@ -55,32 +56,32 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class OpenImeWindowTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testApp = ImeAppHelper(instrumentation)
-
- return FlickerTestRunnerFactory(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
.buildTest { configuration ->
- withTestName { buildTestTag("openIme", testApp, configuration) }
+ withTestName { buildTestTag("openIme", configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
+ testApp.launchViaIntent(wmHelper)
this.setRotation(configuration.startRotation)
- testApp.open()
}
}
transitions {
- testApp.openIME(device)
+ testApp.openIME(device, wmHelper)
}
teardown {
eachRun {
- testApp.closeIME(device)
+ testApp.closeIME(device, wmHelper)
}
test {
testApp.exit()
@@ -101,8 +102,10 @@
navBarLayerIsAlwaysVisible()
statusBarLayerIsAlwaysVisible()
noUncoveredRegions(configuration.startRotation)
- navBarLayerRotatesAndScales(configuration.startRotation)
- statusBarLayerRotatesScales(configuration.startRotation)
+ navBarLayerRotatesAndScales(configuration.startRotation,
+ enabled = !configuration.startRotation.isRotated())
+ statusBarLayerRotatesScales(configuration.startRotation,
+ enabled = !configuration.startRotation.isRotated())
visibleLayersShownMoreThanOneConsecutiveEntry()
imeLayerBecomesVisible()
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt
index d184273..e47e757 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest.kt
@@ -16,7 +16,6 @@
package com.android.server.wm.flicker.ime
-import androidx.test.filters.FlakyTest
import android.view.Surface
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
@@ -35,7 +34,6 @@
import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
-import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
import com.android.server.wm.flicker.noUncoveredRegions
import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
@@ -56,47 +54,45 @@
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@FlakyTest(bugId = 175027130)
class ReOpenImeWindowTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
val testAppComponentName = ActivityOptions.IME_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME
-
- return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 1)
.buildTest { configuration ->
val testApp = ImeAppAutoFocusHelper(instrumentation,
configuration.startRotation)
- withTestName { buildTestTag("reOpenImeAutoFocus", testApp, configuration) }
+ withTestName { buildTestTag("reOpenImeAutoFocus", configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
+ testApp.launchViaIntent(wmHelper)
+ testApp.openIME(device, wmHelper)
}
eachRun {
- testApp.open()
- testApp.openIME(device)
- device.pressHome()
device.pressRecentApps()
+ wmHelper.waitImeWindowGone()
+ wmHelper.waitForAppTransitionIdle()
this.setRotation(configuration.startRotation)
}
}
transitions {
device.reopenAppFromOverview()
- WindowManagerStateHelper().waitForFullScreenApp(testAppComponentName)
+ wmHelper.waitImeWindowShown()
+ // wmHelper.waitForFullScreenApp(testAppComponentName)
}
teardown {
- eachRun {
- testApp.closeIME(device)
- testApp.exit()
- }
test {
this.setRotation(Surface.ROTATION_0)
+ testApp.exit()
}
}
assertions {
@@ -111,18 +107,14 @@
}
layersTrace {
- noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation,
- bugId = 141361128)
+ noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation)
navBarLayerRotatesAndScales(Surface.ROTATION_0,
configuration.endRotation)
statusBarLayerRotatesScales(Surface.ROTATION_0,
configuration.endRotation)
- statusBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.endRotation)
- navBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.endRotation)
- visibleLayersShownMoreThanOneConsecutiveEntry(
- enabled = Surface.ROTATION_0 == configuration.endRotation)
+ statusBarLayerIsAlwaysVisible()
+ navBarLayerIsAlwaysVisible()
+ visibleLayersShownMoreThanOneConsecutiveEntry()
imeLayerBecomesVisible()
appLayerReplacesWallpaperLayer(testAppComponentName.className)
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt
index 71920f6..ba2ee5f 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/CommonAssertions.kt
@@ -17,9 +17,9 @@
package com.android.server.wm.flicker.launch
import android.platform.helpers.IAppHelper
-import com.android.server.wm.flicker.dsl.WmAssertion
+import com.android.server.wm.flicker.dsl.WmAssertionBuilder
-fun WmAssertion.appWindowReplacesLauncherAsTopWindow(
+fun WmAssertionBuilder.appWindowReplacesLauncherAsTopWindow(
testApp: IAppHelper,
bugId: Int = 0,
enabled: Boolean = bugId == 0
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt
index ba7770d..cf25987 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdTest.kt
@@ -25,7 +25,6 @@
import com.android.server.wm.flicker.FlickerTestRunner
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusChanges
-import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
@@ -42,6 +41,8 @@
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.wallpaperWindowBecomesInvisible
import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer
+import com.android.server.wm.flicker.helpers.SimpleAppHelper
+import com.android.server.wm.flicker.helpers.isRotated
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
@@ -57,18 +58,18 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class OpenAppColdTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
- val testApp = StandardAppHelper(instrumentation,
- "com.android.server.wm.flicker.testapp", "SimpleApp")
+ val testApp = SimpleAppHelper(instrumentation)
return FlickerTestRunnerFactory(instrumentation)
.buildTest { configuration ->
- withTag { buildTestTag("openAppCold", testApp, configuration) }
+ withTestName { buildTestTag("openAppCold", testApp, configuration) }
repeat { configuration.repetitions }
setup {
test {
@@ -80,10 +81,12 @@
}
transitions {
testApp.open()
+ wmHelper.waitForFullScreenApp(testApp.component)
}
teardown {
eachRun {
testApp.exit()
+ wmHelper.waitForAppTransitionIdle()
this.setRotation(Surface.ROTATION_0)
}
}
@@ -99,15 +102,16 @@
layersTrace {
// During testing the launcher is always in portrait mode
- noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation,
- bugId = 141361128)
+ noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation)
navBarLayerRotatesAndScales(Surface.ROTATION_0,
- configuration.endRotation)
+ configuration.endRotation,
+ enabled = !configuration.startRotation.isRotated())
statusBarLayerRotatesScales(Surface.ROTATION_0,
- configuration.endRotation)
- navBarLayerIsAlwaysVisible(enabled = false)
- statusBarLayerIsAlwaysVisible(enabled = false)
- visibleLayersShownMoreThanOneConsecutiveEntry()
+ configuration.endRotation,
+ enabled = !configuration.startRotation.isRotated())
+ navBarLayerIsAlwaysVisible()
+ statusBarLayerIsAlwaysVisible()
+ visibleLayersShownMoreThanOneConsecutiveEntry(enabled = false)
appLayerReplacesWallpaperLayer(testApp.`package`)
}
@@ -119,4 +123,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt
index 1b682c0..3c8f469 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromOverviewTest.kt
@@ -16,7 +16,6 @@
package com.android.server.wm.flicker.launch
-import androidx.test.filters.FlakyTest
import android.view.Surface
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
@@ -27,7 +26,6 @@
import com.android.server.wm.flicker.focusChanges
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
-import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.reopenAppFromOverview
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.setRotation
@@ -43,8 +41,8 @@
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.wallpaperWindowBecomesInvisible
import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer
-import com.android.server.wm.flicker.testapp.ActivityOptions
-import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
+import com.android.server.wm.flicker.helpers.SimpleAppHelper
+import com.android.server.wm.flicker.helpers.isRotated
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
@@ -57,77 +55,77 @@
@RequiresDevice
@RunWith(Parameterized::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@FlakyTest(bugId = 174658929)
class OpenAppFromOverviewTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
- val testApp = StandardAppHelper(instrumentation,
- "com.android.server.wm.flicker.testapp", "SimpleApp")
- return FlickerTestRunnerFactory(instrumentation, repetitions = 10)
- .buildTest { configuration ->
- withTag { buildTestTag("openAppFromOverview", testApp, configuration) }
- repeat { configuration.repetitions }
- setup {
- test {
- device.wakeUpAndGoToHomeScreen()
- testApp.open()
- }
- eachRun {
- device.pressHome()
- device.pressRecentApps()
- this.setRotation(configuration.startRotation)
- }
+ val testApp = SimpleAppHelper(instrumentation)
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
+ .buildTest { configuration ->
+ withTestName { buildTestTag("openAppFromOverview", configuration) }
+ repeat { configuration.repetitions }
+ setup {
+ test {
+ device.wakeUpAndGoToHomeScreen()
+ testApp.launchViaIntent(wmHelper)
}
- transitions {
- device.reopenAppFromOverview()
- WindowManagerStateHelper().waitForFullScreenApp(
- ActivityOptions.SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME
- )
- }
- teardown {
- test {
- testApp.exit()
- this.setRotation(Surface.ROTATION_0)
- }
- }
- assertions {
- windowManagerTrace {
- navBarWindowIsAlwaysVisible()
- statusBarWindowIsAlwaysVisible()
- visibleWindowsShownMoreThanOneConsecutiveEntry()
-
- appWindowReplacesLauncherAsTopWindow(testApp)
- wallpaperWindowBecomesInvisible()
- }
-
- layersTrace {
- noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation,
- bugId = 141361128)
- navBarLayerRotatesAndScales(Surface.ROTATION_0,
- configuration.endRotation)
- statusBarLayerRotatesScales(Surface.ROTATION_0,
- configuration.endRotation)
- statusBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.endRotation)
- navBarLayerIsAlwaysVisible(
- enabled = Surface.ROTATION_0 == configuration.endRotation)
- visibleLayersShownMoreThanOneConsecutiveEntry(
- enabled = Surface.ROTATION_0 == configuration.endRotation)
-
- appLayerReplacesWallpaperLayer(testApp.`package`)
- }
-
- eventLog {
- focusChanges("NexusLauncherActivity", testApp.`package`)
- }
+ eachRun {
+ device.pressHome()
+ wmHelper.waitForAppTransitionIdle()
+ device.pressRecentApps()
+ wmHelper.waitForAppTransitionIdle()
+ this.setRotation(configuration.startRotation)
}
}
+ transitions {
+ device.reopenAppFromOverview()
+ wmHelper.waitForFullScreenApp(testApp.component)
+ }
+ teardown {
+ test {
+ testApp.exit()
+ }
+ }
+ assertions {
+ windowManagerTrace {
+ navBarWindowIsAlwaysVisible()
+ statusBarWindowIsAlwaysVisible()
+ visibleWindowsShownMoreThanOneConsecutiveEntry()
+
+ appWindowReplacesLauncherAsTopWindow(testApp)
+ wallpaperWindowBecomesInvisible()
+ }
+
+ layersTrace {
+ noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation,
+ bugId = 141361128)
+ navBarLayerRotatesAndScales(Surface.ROTATION_0,
+ configuration.endRotation,
+ enabled = !configuration.startRotation.isRotated())
+ statusBarLayerRotatesScales(Surface.ROTATION_0,
+ configuration.endRotation,
+ enabled = !configuration.startRotation.isRotated())
+ statusBarLayerIsAlwaysVisible(
+ enabled = Surface.ROTATION_0 == configuration.endRotation)
+ navBarLayerIsAlwaysVisible(
+ enabled = Surface.ROTATION_0 == configuration.endRotation)
+ visibleLayersShownMoreThanOneConsecutiveEntry(
+ enabled = Surface.ROTATION_0 == configuration.endRotation)
+
+ appLayerReplacesWallpaperLayer(testApp.`package`)
+ }
+
+ eventLog {
+ focusChanges("NexusLauncherActivity", testApp.`package`)
+ }
+ }
+ }
}
}
}
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt
index 3703d9c..fd99be2 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppWarmTest.kt
@@ -25,7 +25,6 @@
import com.android.server.wm.flicker.FlickerTestRunner
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusChanges
-import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.buildTestTag
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
@@ -42,6 +41,8 @@
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.wallpaperWindowBecomesInvisible
import com.android.server.wm.flicker.appLayerReplacesWallpaperLayer
+import com.android.server.wm.flicker.helpers.SimpleAppHelper
+import com.android.server.wm.flicker.helpers.isRotated
import org.junit.FixMethodOrder
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
@@ -57,31 +58,34 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class OpenAppWarmTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
companion object {
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): List<Array<Any>> {
val instrumentation = InstrumentationRegistry.getInstrumentation()
- val testApp = StandardAppHelper(instrumentation,
- "com.android.server.wm.flicker.testapp", "SimpleApp")
+ val testApp = SimpleAppHelper(instrumentation)
return FlickerTestRunnerFactory(instrumentation)
.buildTest { configuration ->
- withTag { buildTestTag("openAppWarm", testApp, configuration) }
+ withTestName { buildTestTag("openAppWarm", testApp, configuration) }
repeat { configuration.repetitions }
setup {
test {
device.wakeUpAndGoToHomeScreen()
testApp.open()
+ wmHelper.waitForFullScreenApp(testApp.component)
}
eachRun {
device.pressHome()
+ wmHelper.waitForHomeActivityVisible()
this.setRotation(configuration.startRotation)
}
}
transitions {
testApp.open()
+ wmHelper.waitForFullScreenApp(testApp.component)
}
teardown {
eachRun {
@@ -103,16 +107,16 @@
layersTrace {
// During testing the launcher is always in portrait mode
- noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation,
- bugId = 141361128)
+ noUncoveredRegions(Surface.ROTATION_0, configuration.endRotation)
navBarLayerRotatesAndScales(Surface.ROTATION_0,
- configuration.endRotation)
+ configuration.endRotation,
+ enabled = !configuration.startRotation.isRotated())
statusBarLayerRotatesScales(Surface.ROTATION_0,
- configuration.endRotation)
- navBarLayerIsAlwaysVisible(enabled = false)
- statusBarLayerIsAlwaysVisible(enabled = false)
- visibleLayersShownMoreThanOneConsecutiveEntry(
- enabled = Surface.ROTATION_0 == configuration.endRotation)
+ configuration.endRotation,
+ enabled = !configuration.startRotation.isRotated())
+ navBarLayerIsAlwaysVisible()
+ statusBarLayerIsAlwaysVisible()
+ visibleLayersShownMoreThanOneConsecutiveEntry(enabled = false)
appLayerReplacesWallpaperLayer(testApp.`package`)
}
@@ -124,4 +128,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt
index 9d4a718..fe3ab04 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/ChangeAppRotationTest.kt
@@ -16,25 +16,24 @@
package com.android.server.wm.flicker.rotation
+import android.os.Bundle
import android.platform.test.annotations.Presubmit
-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.FlickerTestRunner
import com.android.server.wm.flicker.FlickerTestRunnerFactory
+import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusDoesNotChange
+import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.buildTestTag
-import com.android.server.wm.flicker.helpers.setRotation
-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.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleWindowsShownMoreThanOneConsecutiveEntry
@@ -56,91 +55,72 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ChangeAppRotationTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
- companion object {
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
+ companion object : RotationTransition(InstrumentationRegistry.getInstrumentation()) {
+ override val testApp: StandardAppHelper
+ get() = SimpleAppHelper(instrumentation)
+
+ override fun getAppLaunchParams(configuration: Bundle): Map<String, String> = emptyMap()
+
private const val SCREENSHOT_LAYER = "RotationLayer"
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
- val instrumentation = InstrumentationRegistry.getInstrumentation()
- val testApp = StandardAppHelper(instrumentation,
- "com.android.server.wm.flicker.testapp", "SimpleApp")
- return FlickerTestRunnerFactory(instrumentation, repetitions = 10)
- .buildRotationTest { configuration ->
- withTestName {
- buildTestTag(
- "changeAppRotation", testApp, configuration)
+ val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration ->
+ withTestName { buildTestTag("changeAppRotation", configuration) }
+ assertions {
+ windowManagerTrace {
+ navBarWindowIsAlwaysVisible()
+ statusBarWindowIsAlwaysVisible()
+ visibleWindowsShownMoreThanOneConsecutiveEntry()
}
- repeat { configuration.repetitions }
- setup {
- test {
- device.wakeUpAndGoToHomeScreen()
- testApp.open()
+
+ layersTrace {
+ navBarLayerIsAlwaysVisible(bugId = 140855415)
+ statusBarLayerIsAlwaysVisible(bugId = 140855415)
+ noUncoveredRegions(configuration.startRotation,
+ configuration.endRotation, allStates = false)
+ navBarLayerRotatesAndScales(configuration.startRotation,
+ configuration.endRotation, bugId = 140855415)
+ statusBarLayerRotatesScales(configuration.startRotation,
+ configuration.endRotation, bugId = 140855415)
+ visibleLayersShownMoreThanOneConsecutiveEntry(bugId = 140855415)
+ }
+
+ layersTrace {
+ val startingPos = WindowUtils.getDisplayBounds(
+ configuration.startRotation)
+ val endingPos = WindowUtils.getDisplayBounds(
+ configuration.endRotation)
+
+ start("appLayerRotates_StartingPos", bugId = 140855415) {
+ this.hasVisibleRegion(testApp.getPackage(), startingPos)
}
- eachRun {
- this.setRotation(configuration.startRotation)
+
+ end("appLayerRotates_EndingPos", bugId = 140855415) {
+ this.hasVisibleRegion(testApp.getPackage(), endingPos)
+ }
+
+ all("screenshotLayerBecomesInvisible") {
+ this.showsLayer(testApp.getPackage())
+ .then()
+ .showsLayer(SCREENSHOT_LAYER)
+ .then()
+ .showsLayer(testApp.getPackage())
}
}
- teardown {
- eachRun {
- this.setRotation(Surface.ROTATION_0)
- }
- test {
- testApp.exit()
- }
- }
- transitions {
- this.setRotation(configuration.endRotation)
- }
- assertions {
- windowManagerTrace {
- navBarWindowIsAlwaysVisible()
- statusBarWindowIsAlwaysVisible()
- visibleWindowsShownMoreThanOneConsecutiveEntry()
- }
- layersTrace {
- navBarLayerIsAlwaysVisible(bugId = 140855415)
- statusBarLayerIsAlwaysVisible(bugId = 140855415)
- noUncoveredRegions(configuration.startRotation,
- configuration.endRotation, allStates = false)
- navBarLayerRotatesAndScales(configuration.startRotation,
- configuration.endRotation)
- statusBarLayerRotatesScales(configuration.startRotation,
- configuration.endRotation)
- visibleLayersShownMoreThanOneConsecutiveEntry(bugId = 140855415)
- }
-
- layersTrace {
- val startingPos = WindowUtils.getDisplayBounds(
- configuration.startRotation)
- val endingPos = WindowUtils.getDisplayBounds(
- configuration.endRotation)
-
- start("appLayerRotates_StartingPos") {
- this.hasVisibleRegion(testApp.getPackage(), startingPos)
- }
-
- end("appLayerRotates_EndingPos") {
- this.hasVisibleRegion(testApp.getPackage(), endingPos)
- }
-
- all("screenshotLayerBecomesInvisible") {
- this.showsLayer(testApp.getPackage())
- .then()
- .showsLayer(SCREENSHOT_LAYER)
- .then()
- .showsLayer(testApp.getPackage())
- }
- }
-
- eventLog {
- focusDoesNotChange(bugId = 151179149)
- }
+ eventLog {
+ focusDoesNotChange(bugId = 151179149)
}
}
+ }
+
+ return FlickerTestRunnerFactory(instrumentation, repetitions = 5)
+ .buildRotationTest(transition, testSpec)
}
}
}
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt
new file mode 100644
index 0000000..b871e94
--- /dev/null
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt
@@ -0,0 +1,55 @@
+/*
+ * 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.rotation
+
+import android.app.Instrumentation
+import android.os.Bundle
+import com.android.server.wm.flicker.dsl.FlickerBuilder
+import com.android.server.wm.flicker.endRotation
+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.repetitions
+import com.android.server.wm.flicker.startRotation
+
+abstract class RotationTransition(protected val instrumentation: Instrumentation) {
+ abstract val testApp: StandardAppHelper
+ abstract fun getAppLaunchParams(configuration: Bundle): Map<String, String>
+
+ protected open val transition: FlickerBuilder.(Bundle) -> Unit
+ get() = { configuration ->
+ repeat { configuration.repetitions }
+ setup {
+ test {
+ device.wakeUpAndGoToHomeScreen()
+ val extras = getAppLaunchParams(configuration)
+ testApp.launchViaIntent(wmHelper, stringExtras = extras)
+ }
+ eachRun {
+ this.setRotation(configuration.startRotation)
+ }
+ }
+ teardown {
+ test {
+ testApp.exit()
+ }
+ }
+ transitions {
+ this.setRotation(configuration.endRotation)
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt
index 120354b..e25c734 100644
--- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt
+++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/SeamlessAppRotationTest.kt
@@ -16,34 +16,29 @@
package com.android.server.wm.flicker.rotation
-import android.content.ComponentName
-import android.content.Intent
import android.os.Bundle
import android.platform.test.annotations.Presubmit
-import android.view.Surface
import androidx.test.filters.RequiresDevice
import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.uiautomator.By
-import androidx.test.uiautomator.Until
import com.android.server.wm.flicker.Flicker
import com.android.server.wm.flicker.FlickerTestRunner
import com.android.server.wm.flicker.FlickerTestRunnerFactory
import com.android.server.wm.flicker.endRotation
import com.android.server.wm.flicker.focusDoesNotChange
import com.android.server.wm.flicker.appWindowAlwaysVisibleOnTop
+import com.android.server.wm.flicker.dsl.FlickerBuilder
+import com.android.server.wm.flicker.helpers.SeamlessRotationAppHelper
+import com.android.server.wm.flicker.helpers.StandardAppHelper
import com.android.server.wm.flicker.layerAlwaysVisible
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.buildTestTag
-import com.android.server.wm.flicker.helpers.setRotation
-import com.android.server.wm.flicker.helpers.stopPackage
-import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
+import com.android.server.wm.flicker.helpers.isRotated
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.visibleWindowsShownMoreThanOneConsecutiveEntry
import com.android.server.wm.flicker.visibleLayersShownMoreThanOneConsecutiveEntry
-import com.android.server.wm.flicker.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
@@ -64,35 +59,23 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class SeamlessAppRotationTest(
testName: String,
- flickerSpec: Flicker
-) : FlickerTestRunner(testName, flickerSpec) {
- companion object {
- private const val APP_LAUNCH_TIMEOUT: Long = 10000
+ flickerProvider: () -> Flicker,
+ cleanUp: Boolean
+) : FlickerTestRunner(testName, flickerProvider, cleanUp) {
+ companion object : RotationTransition(InstrumentationRegistry.getInstrumentation()) {
+ override val testApp: StandardAppHelper
+ get() = SeamlessRotationAppHelper(instrumentation)
- private val Bundle.intent: Intent?
- get() = this.getParcelable(Intent::class.java.simpleName)
+ override fun getAppLaunchParams(configuration: Bundle): Map<String, String> = mapOf(
+ ActivityOptions.EXTRA_STARVE_UI_THREAD to configuration.starveUiThread.toString()
+ )
- private val Bundle.intentPackageName: String
- get() = this.intent?.component?.packageName ?: ""
-
- private val Bundle.intentId get() = if (this.intent?.getBooleanExtra(
- ActivityOptions.EXTRA_STARVE_UI_THREAD, false) == true) {
- "BUSY_UI_THREAD"
- } else {
- ""
- }
+ private val Bundle.starveUiThread
+ get() = this.getBoolean(ActivityOptions.EXTRA_STARVE_UI_THREAD, false)
private fun Bundle.createConfig(starveUiThread: Boolean): Bundle {
val config = this.deepCopy()
- val intent = Intent()
- intent.addCategory(Intent.CATEGORY_LAUNCHER)
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- intent.component = ComponentName("com.android.server.wm.flicker.testapp",
- "com.android.server.wm.flicker.testapp.SeamlessRotationActivity")
-
- intent.putExtra(ActivityOptions.EXTRA_STARVE_UI_THREAD, starveUiThread)
-
- config.putParcelable(Intent::class.java.simpleName, intent)
+ config.putBoolean(ActivityOptions.EXTRA_STARVE_UI_THREAD, starveUiThread)
return config
}
@@ -108,45 +91,23 @@
@Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getParams(): Collection<Array<Any>> {
- val instrumentation = InstrumentationRegistry.getInstrumentation()
- val factory = FlickerTestRunnerFactory(instrumentation)
+ val factory = FlickerTestRunnerFactory(instrumentation, repetitions = 2)
val configurations = factory.getConfigurations()
- return factory.buildRotationTest(configurations) { configuration ->
+ val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration ->
withTestName {
- buildTestTag("seamlessRotation_" + configuration.intentId,
- app = null, configuration = configuration)
- }
- repeat { configuration.repetitions }
- setup {
- test {
- device.wakeUpAndGoToHomeScreen()
- instrumentation.targetContext.startActivity(configuration.intent)
- val searchQuery = By.pkg(configuration.intent?.component?.packageName)
- .depth(0)
- device.wait(Until.hasObject(searchQuery), APP_LAUNCH_TIMEOUT)
+ val extra = if (configuration.starveUiThread) {
+ "BUSY_UI_THREAD"
+ } else {
+ ""
}
- eachRun {
- this.setRotation(configuration.startRotation)
- }
- }
- teardown {
- test {
- this.setRotation(Surface.ROTATION_0)
- stopPackage(
- instrumentation.targetContext,
- configuration.intent?.component?.packageName
- ?: error("Unable to determine package name for intent"))
- }
- }
- transitions {
- this.setRotation(configuration.endRotation)
+ buildTestTag("seamlessRotation", configuration, extraInfo = extra)
}
assertions {
windowManagerTrace {
navBarWindowIsAlwaysVisible(bugId = 140855415)
statusBarWindowIsAlwaysVisible(bugId = 140855415)
visibleWindowsShownMoreThanOneConsecutiveEntry()
- appWindowAlwaysVisibleOnTop(configuration.intentPackageName)
+ appWindowAlwaysVisibleOnTop(testApp.`package`)
}
layersTrace {
@@ -155,12 +116,13 @@
noUncoveredRegions(configuration.startRotation,
configuration.endRotation, allStates = false, bugId = 147659548)
navBarLayerRotatesAndScales(configuration.startRotation,
- configuration.endRotation)
+ configuration.endRotation,
+ enabled = false)
statusBarLayerRotatesScales(configuration.startRotation,
configuration.endRotation, enabled = false)
visibleLayersShownMoreThanOneConsecutiveEntry(
enabled = configuration.startRotation == configuration.endRotation)
- layerAlwaysVisible(configuration.intentPackageName)
+ layerAlwaysVisible(testApp.`package`)
}
layersTrace {
@@ -172,12 +134,12 @@
all("appLayerRotates", bugId = 147659548) {
if (startingBounds == endingBounds) {
this.hasVisibleRegion(
- configuration.intentPackageName, startingBounds)
+ testApp.`package`, startingBounds)
} else {
- this.hasVisibleRegion(configuration.intentPackageName,
+ this.hasVisibleRegion(testApp.`package`,
startingBounds)
.then()
- .hasVisibleRegion(configuration.intentPackageName,
+ .hasVisibleRegion(testApp.`package`,
endingBounds)
}
}
@@ -198,6 +160,8 @@
}
}
}
+
+ return factory.buildRotationTest(transition, testSpec, configurations)
}
}
}
\ No newline at end of file
diff --git a/tests/FlickerTests/test-apps/flickerapp/Android.bp b/tests/FlickerTests/test-apps/flickerapp/Android.bp
index 0bea209..5027797 100644
--- a/tests/FlickerTests/test-apps/flickerapp/Android.bp
+++ b/tests/FlickerTests/test-apps/flickerapp/Android.bp
@@ -19,7 +19,7 @@
test_suites: ["device-tests"],
}
-java_test {
+java_library {
name: "flickertestapplib",
sdk_version: "current",
srcs: ["src/com/android/server/wm/flicker/testapp/ActivityOptions.java"],
diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java
index f167e95..0ccc498 100644
--- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java
+++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/ActivityOptions.java
@@ -20,13 +20,25 @@
public class ActivityOptions {
public static final String EXTRA_STARVE_UI_THREAD = "StarveUiThread";
+ public static final String FLICKER_APP_PACKAGE = "com.android.server.wm.flicker.testapp";
+
+ public static final String SEAMLESS_ACTIVITY_LAUNCHER_NAME = "SeamlessApp";
public static final ComponentName SEAMLESS_ACTIVITY_COMPONENT_NAME =
- new ComponentName("com.android.server.wm.flicker.testapp",
- "com.android.server.wm.flicker.testapp.SeamlessRotationActivity");
+ new ComponentName(FLICKER_APP_PACKAGE,
+ FLICKER_APP_PACKAGE + ".SeamlessRotationActivity");
+
+ public static final String IME_ACTIVITY_AUTO_FOCUS_LAUNCHER_NAME = "ImeAppAutoFocus";
public static final ComponentName IME_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME =
- new ComponentName("com.android.server.wm.flicker.testapp",
- "com.android.server.wm.flicker.testapp.ImeActivityAutoFocus");
+ new ComponentName(FLICKER_APP_PACKAGE,
+ FLICKER_APP_PACKAGE + ".ImeActivityAutoFocus");
+
+ public static final String IME_ACTIVITY_LAUNCHER_NAME = "ImeActivity";
+ public static final ComponentName IME_ACTIVITY_COMPONENT_NAME =
+ new ComponentName(FLICKER_APP_PACKAGE,
+ FLICKER_APP_PACKAGE + ".ImeActivity");
+
+ public static final String SIMPLE_ACTIVITY_LAUNCHER_NAME = "SimpleApp";
public static final ComponentName SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME =
- new ComponentName("com.android.server.wm.flicker.testapp",
- "com.android.server.wm.flicker.testapp.SimpleActivity");
+ new ComponentName(FLICKER_APP_PACKAGE,
+ FLICKER_APP_PACKAGE + ".SimpleActivity");
}