diff options
author | Nataniel Borges <natanieljr@google.com> | 2020-12-15 14:36:03 +0100 |
---|---|---|
committer | Nataniel Borges <natanieljr@google.com> | 2021-01-25 08:58:21 +0100 |
commit | 143d584efde337e835b4b3e035e0c907ed8b434f (patch) | |
tree | a7ec4c467e56f40779d09058e8bec64af162cea8 | |
parent | 930915c245ed34d0573d98c939027af0a3893c71 (diff) |
Compatibilize tests with new runner
Runner now prints each assertion individually to aid debugging.
Bug: 162923992
Test: atest FlickerTests WMShellFlickerTests
Change-Id: I1c9a49ec3c283e5e034f0223573fca3ccafaf64c
62 files changed, 975 insertions, 877 deletions
diff --git a/libs/WindowManager/Shell/tests/flicker/AndroidTestPhysicalDevices.xml b/libs/WindowManager/Shell/tests/flicker/AndroidTestPhysicalDevices.xml index 23d7021baffb..8258630a9502 100644 --- a/libs/WindowManager/Shell/tests/flicker/AndroidTestPhysicalDevices.xml +++ b/libs/WindowManager/Shell/tests/flicker/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> diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt index 94c1f59d957e..ccfdce65f7b2 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonAssertions.kt @@ -18,59 +18,59 @@ package com.android.wm.shell.flicker import android.graphics.Region import android.view.Surface -import com.android.server.wm.flicker.dsl.EventLogAssertion -import com.android.server.wm.flicker.dsl.LayersAssertion +import com.android.server.wm.flicker.dsl.LayersAssertionBuilder import com.android.server.wm.flicker.helpers.WindowUtils +import com.android.server.wm.flicker.traces.layers.getVisibleBounds import com.android.wm.shell.flicker.FlickerTestBase.Companion.DOCKED_STACK_DIVIDER @JvmOverloads -fun LayersAssertion.appPairsDividerIsVisible( +fun LayersAssertionBuilder.appPairsDividerIsVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("appPairsDividerIsVisible", bugId, enabled) { - this.showsLayer(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER) + this.isVisible(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER) } } @JvmOverloads -fun LayersAssertion.appPairsDividerIsInvisible( +fun LayersAssertionBuilder.appPairsDividerIsInvisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("appPairsDividerIsInVisible", bugId, enabled) { - this.hasNotLayer(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER) + this.notExists(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER) } } @JvmOverloads -fun LayersAssertion.appPairsDividerBecomesVisible( +fun LayersAssertionBuilder.appPairsDividerBecomesVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { - all("dividerLayerBecomesVisible") { - this.hidesLayer(FlickerTestBase.DOCKED_STACK_DIVIDER) + all("dividerLayerBecomesVisible", bugId, enabled) { + this.hidesLayer(DOCKED_STACK_DIVIDER) .then() - .showsLayer(FlickerTestBase.DOCKED_STACK_DIVIDER) + .showsLayer(DOCKED_STACK_DIVIDER) } } @JvmOverloads -fun LayersAssertion.dockedStackDividerIsVisible( +fun LayersAssertionBuilder.dockedStackDividerIsVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("dockedStackDividerIsVisible", bugId, enabled) { - this.showsLayer(FlickerTestBase.DOCKED_STACK_DIVIDER) + this.isVisible(DOCKED_STACK_DIVIDER) } } @JvmOverloads -fun LayersAssertion.dockedStackDividerBecomesVisible( +fun LayersAssertionBuilder.dockedStackDividerBecomesVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { - all("dividerLayerBecomesVisible") { + all("dividerLayerBecomesVisible", bugId, enabled) { this.hidesLayer(DOCKED_STACK_DIVIDER) .then() .showsLayer(DOCKED_STACK_DIVIDER) @@ -78,11 +78,11 @@ fun LayersAssertion.dockedStackDividerBecomesVisible( } @JvmOverloads -fun LayersAssertion.dockedStackDividerBecomesInvisible( +fun LayersAssertionBuilder.dockedStackDividerBecomesInvisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { - all("dividerLayerBecomesInvisible") { + all("dividerLayerBecomesInvisible", bugId, enabled) { this.showsLayer(DOCKED_STACK_DIVIDER) .then() .hidesLayer(DOCKED_STACK_DIVIDER) @@ -90,71 +90,63 @@ fun LayersAssertion.dockedStackDividerBecomesInvisible( } @JvmOverloads -fun LayersAssertion.dockedStackDividerIsInvisible( +fun LayersAssertionBuilder.dockedStackDividerIsInvisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("dockedStackDividerIsInvisible", bugId, enabled) { - this.hasNotLayer(FlickerTestBase.DOCKED_STACK_DIVIDER) + this.notExists(DOCKED_STACK_DIVIDER) } } @JvmOverloads -fun LayersAssertion.appPairsPrimaryBoundsIsVisible( +fun LayersAssertionBuilder.appPairsPrimaryBoundsIsVisible( rotation: Int, primaryLayerName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("PrimaryAppBounds", bugId, enabled) { - val entry = this.trace.entries.firstOrNull() - ?: throw IllegalStateException("Trace is empty") val dividerRegion = entry.getVisibleBounds(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER) this.hasVisibleRegion(primaryLayerName, getPrimaryRegion(dividerRegion, rotation)) } } @JvmOverloads -fun LayersAssertion.appPairsSecondaryBoundsIsVisible( +fun LayersAssertionBuilder.appPairsSecondaryBoundsIsVisible( rotation: Int, secondaryLayerName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("SecondaryAppBounds", bugId, enabled) { - val entry = this.trace.entries.firstOrNull() - ?: throw IllegalStateException("Trace is empty") val dividerRegion = entry.getVisibleBounds(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER) this.hasVisibleRegion(secondaryLayerName, getSecondaryRegion(dividerRegion, rotation)) } } @JvmOverloads -fun LayersAssertion.dockedStackPrimaryBoundsIsVisible( +fun LayersAssertionBuilder.dockedStackPrimaryBoundsIsVisible( rotation: Int, primaryLayerName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("PrimaryAppBounds", bugId, enabled) { - val entry = this.trace.entries.firstOrNull() - ?: throw IllegalStateException("Trace is empty") - val dividerRegion = entry.getVisibleBounds(FlickerTestBase.DOCKED_STACK_DIVIDER) + val dividerRegion = entry.getVisibleBounds(DOCKED_STACK_DIVIDER) this.hasVisibleRegion(primaryLayerName, getPrimaryRegion(dividerRegion, rotation)) } } @JvmOverloads -fun LayersAssertion.dockedStackSecondaryBoundsIsVisible( +fun LayersAssertionBuilder.dockedStackSecondaryBoundsIsVisible( rotation: Int, secondaryLayerName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 ) { end("SecondaryAppBounds", bugId, enabled) { - val entry = this.trace.entries.firstOrNull() - ?: throw IllegalStateException("Trace is empty") - val dividerRegion = entry.getVisibleBounds(FlickerTestBase.DOCKED_STACK_DIVIDER) + val dividerRegion = entry.getVisibleBounds(DOCKED_STACK_DIVIDER) this.hasVisibleRegion(secondaryLayerName, getSecondaryRegion(dividerRegion, rotation)) } } @@ -162,11 +154,11 @@ fun LayersAssertion.dockedStackSecondaryBoundsIsVisible( fun getPrimaryRegion(dividerRegion: Region, rotation: Int): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { - Region(0, 0, displayBounds.getBounds().right, - dividerRegion.getBounds().bottom - WindowUtils.dockedStackDividerInset) + Region(0, 0, displayBounds.bounds.right, + dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset) } else { - Region(0, 0, dividerRegion.getBounds().left, - dividerRegion.getBounds().right - WindowUtils.dockedStackDividerInset) + Region(0, 0, dividerRegion.bounds.left, + dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset) } } @@ -174,31 +166,12 @@ fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region { val displayBounds = WindowUtils.getDisplayBounds(rotation) return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) { Region(0, - dividerRegion.getBounds().bottom - WindowUtils.dockedStackDividerInset, - displayBounds.getBounds().right, - displayBounds.getBounds().bottom - WindowUtils.dockedStackDividerInset) + dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset, + displayBounds.bounds.right, + displayBounds.bounds.bottom - WindowUtils.dockedStackDividerInset) } else { - Region(dividerRegion.getBounds().right, 0, - displayBounds.getBounds().right, - displayBounds.getBounds().bottom - WindowUtils.dockedStackDividerInset) - } -} - -fun EventLogAssertion.focusChanges( - vararg windows: String, - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all(enabled = enabled, bugId = bugId) { - this.focusChanges(windows) - } -} - -fun EventLogAssertion.focusDoesNotChange( - bugId: Int = 0, - enabled: Boolean = bugId == 0 -) { - all(enabled = enabled, bugId = bugId) { - this.focusDoesNotChange() + Region(dividerRegion.bounds.right, 0, + displayBounds.bounds.right, + displayBounds.bounds.bottom - WindowUtils.dockedStackDividerInset) } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt index 796c8c4a6ad0..d2cfb0fbb5f6 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/CommonConstants.kt @@ -17,28 +17,4 @@ package com.android.wm.shell.flicker const val IME_WINDOW_NAME = "InputMethod" -const val PIP_MENU_WINDOW_NAME = "PipMenuActivity" - const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui" -const val TEST_APP_PACKAGE_NAME = "com.android.wm.shell.flicker.testapp" - -// Test App > Pip Activity -const val TEST_APP_PIP_ACTIVITY_LABEL = "PipApp" -const val TEST_APP_PIP_MENU_ACTION_NO_OP = "No-Op" -const val TEST_APP_PIP_MENU_ACTION_ON = "On" -const val TEST_APP_PIP_MENU_ACTION_OFF = "Off" -const val TEST_APP_PIP_MENU_ACTION_CLEAR = "Clear" - -// Test App > Ime Activity -const val TEST_APP_IME_ACTIVITY_LABEL = "ImeApp" -const val TEST_APP_IME_ACTIVITY_ACTION_OPEN_IME = - "com.android.wm.shell.flicker.testapp.action.OPEN_IME" -const val TEST_APP_IME_ACTIVITY_ACTION_CLOSE_IME = - "com.android.wm.shell.flicker.testapp.action.CLOSE_IME" -// Test App > Test Activity -const val TEST_APP_FIXED_ACTIVITY_LABEL = "FixedApp" - -// Test App > SplitScreen Activity -const val TEST_APP_SPLITSCREEN_PRIMARY_LABEL = "SplitScreenPrimaryApp" -const val TEST_APP_SPLITSCREEN_SECONDARY_LABEL = "SplitScreenSecondaryApp" -const val TEST_APP_NONRESIZEABLE_LABEL = "NonResizeableApp" diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt index cb9fabd3d5ba..5d07f4ba8d4d 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/AppPairsTest.kt @@ -27,6 +27,7 @@ import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible +import com.android.server.wm.flicker.traces.layers.getVisibleBounds import com.android.wm.shell.flicker.appPairsDividerIsInvisible import com.android.wm.shell.flicker.appPairsDividerIsVisible import com.android.wm.shell.flicker.helpers.AppPairsHelper @@ -110,7 +111,6 @@ class AppPairsTest( val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER) this.hasVisibleRegion(primaryApp.defaultWindowName, appPairsHelper.getPrimaryBounds(dividerRegion)) - .and() .hasVisibleRegion(secondaryApp.defaultWindowName, appPairsHelper.getSecondaryBounds(dividerRegion)) } @@ -118,7 +118,6 @@ class AppPairsTest( windowManagerTrace { end { showsAppWindow(primaryApp.defaultWindowName) - .and() .showsAppWindow(secondaryApp.defaultWindowName) } } @@ -154,20 +153,17 @@ class AppPairsTest( val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER) this.hasVisibleRegion(primaryApp.defaultWindowName, appPairsHelper.getPrimaryBounds(dividerRegion)) - .and() .hasVisibleRegion(secondaryApp.defaultWindowName, appPairsHelper.getSecondaryBounds(dividerRegion)) } end("appsEndingBounds", enabled = false) { this.hasNotLayer(primaryApp.defaultWindowName) - .and() .hasNotLayer(secondaryApp.defaultWindowName) } } windowManagerTrace { end { hidesAppWindow(primaryApp.defaultWindowName) - .and() .hidesAppWindow(secondaryApp.defaultWindowName) } } @@ -197,7 +193,6 @@ class AppPairsTest( windowManagerTrace { end { showsAppWindow(nonResizeableApp.defaultWindowName) - .and() .hidesAppWindow(primaryApp.defaultWindowName) } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppTest.kt index d07e0dc272c1..55359d7a1716 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/apppairs/RotateTwoLaunchedAppTest.kt @@ -101,7 +101,7 @@ class RotateTwoLaunchedAppTest( statusBarWindowIsAlwaysVisible() end { showsAppWindow(primaryApp.defaultWindowName) - .and().showsAppWindow(secondaryApp.defaultWindowName) + .showsAppWindow(secondaryApp.defaultWindowName) } } } @@ -137,7 +137,7 @@ class RotateTwoLaunchedAppTest( statusBarWindowIsAlwaysVisible() end { showsAppWindow(primaryApp.defaultWindowName) - .and().showsAppWindow(secondaryApp.defaultWindowName) + .showsAppWindow(secondaryApp.defaultWindowName) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt index d77396f96ec2..5b8cfb81016a 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt @@ -17,19 +17,15 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation +import android.content.ComponentName import android.graphics.Region import com.android.server.wm.flicker.helpers.WindowUtils -import com.android.wm.shell.flicker.testapp.Components class AppPairsHelper( instrumentation: Instrumentation, activityLabel: String, - componentsInfo: Components.ComponentsInfo -) : BaseAppHelper( - instrumentation, - activityLabel, - componentsInfo -) { + component: ComponentName +) : BaseAppHelper(instrumentation, activityLabel, component) { fun getPrimaryBounds(dividerBounds: Region): android.graphics.Region { val primaryAppBounds = Region(0, 0, dividerBounds.bounds.right, dividerBounds.bounds.bottom + WindowUtils.dockedStackDividerInset) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt index f8efd0e9c761..006b569146e4 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt @@ -17,34 +17,27 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation -import android.content.Context -import android.content.Intent +import android.content.ComponentName import android.content.pm.PackageManager.FEATURE_LEANBACK import android.content.pm.PackageManager.FEATURE_LEANBACK_ONLY import android.support.test.launcherhelper.LauncherStrategyFactory import androidx.test.uiautomator.By -import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.StandardAppHelper -import com.android.wm.shell.flicker.testapp.Components +import com.android.server.wm.traces.parser.toWindowName abstract class BaseAppHelper( instrumentation: Instrumentation, launcherName: String, - private val componentsInfo: Components.ComponentsInfo + component: ComponentName ) : StandardAppHelper( - instrumentation, - Components.PACKAGE_NAME, - launcherName, - LauncherStrategyFactory.getInstance(instrumentation).launcherStrategy + instrumentation, + launcherName, + component, + LauncherStrategyFactory.getInstance(instrumentation).launcherStrategy ) { - protected val uiDevice: UiDevice = UiDevice.getInstance(instrumentation) - - protected val context: Context - get() = mInstrumentation.context - - private val appSelector = By.pkg(packageName).depth(0) + private val appSelector = By.pkg(component.packageName).depth(0) protected val isTelevision: Boolean get() = context.packageManager.run { @@ -52,40 +45,16 @@ abstract class BaseAppHelper( } val defaultWindowName: String - get() = componentsInfo.activityName - - val label: String - get() = context.packageManager.run { - getApplicationLabel(getApplicationInfo(packageName, 0)).toString() - } + get() = component.toWindowName() val ui: UiObject2? get() = uiDevice.findObject(appSelector) - fun launchViaIntent(action: String? = null, stringExtras: Map<String, String> = mapOf()) { - val intent = openAppIntent - intent.action = action - stringExtras.forEach() { - intent.putExtra(it.key, it.value) - } - context.startActivity(intent) - - uiDevice.wait(Until.hasObject(appSelector), APP_LAUNCH_WAIT_TIME_MS) - } - fun waitUntilClosed(): Boolean { return uiDevice.wait(Until.gone(appSelector), APP_CLOSE_WAIT_TIME_MS) } - override fun getOpenAppIntent(): Intent { - val intent = Intent() - intent.component = componentsInfo.componentName - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - return intent - } - companion object { - private const val APP_LAUNCH_WAIT_TIME_MS = 10_000L private const val APP_CLOSE_WAIT_TIME_MS = 3_000L } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/FixedAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/FixedAppHelper.kt index c7f19a5d2620..b4ae18749b34 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/FixedAppHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/FixedAppHelper.kt @@ -17,13 +17,10 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation -import com.android.wm.shell.flicker.TEST_APP_FIXED_ACTIVITY_LABEL import com.android.wm.shell.flicker.testapp.Components -class FixedAppHelper( - instrumentation: Instrumentation -) : BaseAppHelper( - instrumentation, - TEST_APP_FIXED_ACTIVITY_LABEL, - Components.FixedActivity() +class FixedAppHelper(instrumentation: Instrumentation) : BaseAppHelper( + instrumentation, + Components.FixedActivity.LABEL, + Components.FixedActivity.COMPONENT )
\ No newline at end of file diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt index eb20d73cdcd1..7ec22bb9db1c 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt @@ -18,43 +18,74 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation import androidx.test.uiautomator.By +import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.FIND_TIMEOUT -import com.android.wm.shell.flicker.TEST_APP_IME_ACTIVITY_ACTION_CLOSE_IME -import com.android.wm.shell.flicker.TEST_APP_IME_ACTIVITY_ACTION_OPEN_IME -import com.android.wm.shell.flicker.TEST_APP_IME_ACTIVITY_LABEL +import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper import com.android.wm.shell.flicker.testapp.Components -import org.junit.Assert -open class ImeAppHelper( - instrumentation: Instrumentation -) : BaseAppHelper( - instrumentation, - TEST_APP_IME_ACTIVITY_LABEL, - Components.ImeActivity() +open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper( + instrumentation, + Components.ImeActivity.LABEL, + Components.ImeActivity.COMPONENT ) { - fun openIME() { + /** + * 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) { if (!isTelevision) { - val editText = uiDevice.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) + val editText = device.wait( + 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() + waitAndAssertIMEShown(device, wmHelper) } else { // If we do the same thing as above - editText.click() - on TV, that's going to force TV // into the touch mode. We really don't want that. - launchViaIntent(action = TEST_APP_IME_ACTIVITY_ACTION_OPEN_IME) + launchViaIntent(action = Components.ImeActivity.ACTION_OPEN_IME) + } + } + + protected fun waitAndAssertIMEShown( + device: UiDevice, + wmHelper: WindowManagerStateHelper? = null + ) { + if (wmHelper == null) { + device.waitForIdle() + } else { + require(wmHelper.waitImeWindowShown()) { "IME did not appear" } } } - fun closeIME() { + /** + * 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) { if (!isTelevision) { - uiDevice.pressBack() + device.pressBack() + // Using only the AccessibilityInfo it is not possible to identify if the IME is active + if (wmHelper == null) { + device.waitForIdle() + } else { + require(wmHelper.waitImeWindowGone()) { "IME did did not close" } + } } else { // While pressing the back button should close the IME on TV as well, it may also lead // to the app closing. So let's instead just ask the app to close the IME. - launchViaIntent(action = TEST_APP_IME_ACTIVITY_ACTION_CLOSE_IME) + launchViaIntent(action = Components.ImeActivity.ACTION_CLOSE_IME) } } }
\ No newline at end of file diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt index bc74daf307fc..b90e865de691 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/PipAppHelper.kt @@ -24,16 +24,15 @@ import androidx.test.uiautomator.By import androidx.test.uiautomator.BySelector import com.android.server.wm.flicker.helpers.closePipWindow import com.android.server.wm.flicker.helpers.hasPipWindow -import com.android.wm.shell.flicker.TEST_APP_PIP_ACTIVITY_LABEL import com.android.wm.shell.flicker.pip.tv.closeTvPipWindow import com.android.wm.shell.flicker.pip.tv.isFocusedOrHasFocusedChild import com.android.wm.shell.flicker.testapp.Components import org.junit.Assert.fail class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper( - instrumentation, - TEST_APP_PIP_ACTIVITY_LABEL, - Components.PipActivity() + instrumentation, + Components.PipActivity.LABEL, + Components.PipActivity.COMPONENT ) { private val mediaSessionManager: MediaSessionManager get() = context.getSystemService(MediaSessionManager::class.java) @@ -41,11 +40,11 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper( private val mediaController: MediaController? get() = mediaSessionManager.getActiveSessions(null).firstOrNull { - it.packageName == packageName + it.packageName == component.packageName } fun clickObject(resId: String) { - val selector = By.res(packageName, resId) + val selector = By.res(component.packageName, resId) val obj = uiDevice.findObject(selector) ?: error("Could not find `$resId` object") if (!isTelevision) { @@ -87,7 +86,7 @@ class PipAppHelper(instrumentation: Instrumentation) : BaseAppHelper( } fun checkWithCustomActionsCheckbox() = uiDevice - .findObject(By.res(packageName, WITH_CUSTOM_ACTIONS_BUTTON_ID)) + .findObject(By.res(component.packageName, WITH_CUSTOM_ACTIONS_BUTTON_ID)) ?.takeIf { it.isCheckable } ?.apply { if (!isChecked) clickObject(WITH_CUSTOM_ACTIONS_BUTTON_ID) } ?: error("'With custom actions' checkbox not found") diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SimpleAppHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SimpleAppHelper.kt new file mode 100644 index 000000000000..ba13e38ae9e3 --- /dev/null +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SimpleAppHelper.kt @@ -0,0 +1,26 @@ +/* + * 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.wm.shell.flicker.helpers + +import android.app.Instrumentation +import com.android.wm.shell.flicker.testapp.Components + +class SimpleAppHelper(instrumentation: Instrumentation) : BaseAppHelper( + instrumentation, + Components.SimpleActivity.LABEL, + Components.SimpleActivity.COMPONENT +)
\ No newline at end of file diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt index fb795c72b106..9f2087fc91d6 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/SplitScreenHelper.kt @@ -17,18 +17,15 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation +import android.content.ComponentName import android.os.SystemClock import com.android.wm.shell.flicker.testapp.Components class SplitScreenHelper( instrumentation: Instrumentation, activityLabel: String, - componentsInfo: Components.ComponentsInfo -) : BaseAppHelper( - instrumentation, - activityLabel, - componentsInfo -) { + componentsInfo: ComponentName +) : BaseAppHelper(instrumentation, activityLabel, componentsInfo) { /** * Reopens the first device window from the list of recent apps (overview) @@ -44,5 +41,20 @@ class SplitScreenHelper( companion object { const val TEST_REPETITIONS = 1 const val TIMEOUT_MS = 3_000L + + fun getPrimary(instrumentation: Instrumentation): SplitScreenHelper = + SplitScreenHelper(instrumentation, + Components.SplitScreenActivity.LABEL, + Components.SplitScreenActivity.COMPONENT) + + fun getSecondary(instrumentation: Instrumentation): SplitScreenHelper = + SplitScreenHelper(instrumentation, + Components.SplitScreenSecondaryActivity.LABEL, + Components.SplitScreenSecondaryActivity.COMPONENT) + + fun getNonResizeable(instrumentation: Instrumentation): SplitScreenHelper = + SplitScreenHelper(instrumentation, + Components.NonResizeableActivity.LABEL, + Components.NonResizeableActivity.COMPONENT) } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/EnterLegacySplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/EnterLegacySplitScreenTest.kt index 05e453998078..af99543199ac 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/EnterLegacySplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/EnterLegacySplitScreenTest.kt @@ -34,7 +34,6 @@ import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible - import com.android.wm.shell.flicker.dockedStackPrimaryBoundsIsVisible import com.android.wm.shell.flicker.dockedStackSecondaryBoundsIsVisible import org.junit.Assert @@ -117,7 +116,7 @@ class EnterLegacySplitScreenTest( } windowManagerTrace { end { - showsAppWindow(splitScreenApp.defaultWindowName) + isVisible(splitScreenApp.defaultWindowName) } } } @@ -141,23 +140,23 @@ class EnterLegacySplitScreenTest( assertions { layersTrace { dockedStackPrimaryBoundsIsVisible( - rotation, splitScreenApp.defaultWindowName, 169271943) + rotation, splitScreenApp.defaultWindowName, 169271943) dockedStackSecondaryBoundsIsVisible( - rotation, secondaryApp.defaultWindowName, 169271943) + rotation, secondaryApp.defaultWindowName, 169271943) dockedStackDividerBecomesVisible() visibleLayersShownMoreThanOneConsecutiveEntry( - listOf(LAUNCHER_PACKAGE_NAME, splitScreenApp.defaultWindowName, - secondaryApp.defaultWindowName) + listOf(LAUNCHER_PACKAGE_NAME, splitScreenApp.defaultWindowName, + secondaryApp.defaultWindowName) ) } windowManagerTrace { end { - showsAppWindow(splitScreenApp.defaultWindowName) - .and().showsAppWindow(secondaryApp.defaultWindowName) + isVisible(splitScreenApp.defaultWindowName) + .isVisible(secondaryApp.defaultWindowName) } visibleWindowsShownMoreThanOneConsecutiveEntry( - listOf(LAUNCHER_PACKAGE_NAME, splitScreenApp.defaultWindowName, - secondaryApp.defaultWindowName)) + listOf(LAUNCHER_PACKAGE_NAME, splitScreenApp.defaultWindowName, + secondaryApp.defaultWindowName)) } } } @@ -182,15 +181,15 @@ class EnterLegacySplitScreenTest( layersTrace { dockedStackDividerIsInvisible() visibleLayersShownMoreThanOneConsecutiveEntry( - listOf(LAUNCHER_PACKAGE_NAME, nonResizeableApp.defaultWindowName) + listOf(LAUNCHER_PACKAGE_NAME, nonResizeableApp.defaultWindowName) ) } windowManagerTrace { end { - hidesAppWindow(nonResizeableApp.defaultWindowName) + isInvisible(nonResizeableApp.defaultWindowName) } visibleWindowsShownMoreThanOneConsecutiveEntry( - listOf(LAUNCHER_PACKAGE_NAME, nonResizeableApp.defaultWindowName)) + listOf(LAUNCHER_PACKAGE_NAME, nonResizeableApp.defaultWindowName)) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenFromBottomTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenFromBottomTest.kt index bdc429c77661..4ddfb3ecdebc 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenFromBottomTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenFromBottomTest.kt @@ -32,11 +32,8 @@ import com.android.server.wm.flicker.helpers.launchSplitScreen import com.android.server.wm.flicker.helpers.openQuickStepAndClearRecentAppsFromOverview 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.wm.shell.flicker.TEST_APP_SPLITSCREEN_PRIMARY_LABEL import com.android.wm.shell.flicker.helpers.SplitScreenHelper -import com.android.wm.shell.flicker.testapp.Components import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -52,31 +49,28 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) class ExitLegacySplitScreenFromBottomTest( testName: String, - flickerSpec: Flicker -) : FlickerTestRunner(testName, flickerSpec) { + flickerProvider: () -> Flicker, + cleanUp: Boolean +) : FlickerTestRunner(testName, flickerProvider, cleanUp) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection<Array<Any>> { val instrumentation = InstrumentationRegistry.getInstrumentation() - val splitScreenApp = SplitScreenHelper(instrumentation, - TEST_APP_SPLITSCREEN_PRIMARY_LABEL, - Components.SplitScreenActivity()) - + val splitScreenApp = SplitScreenHelper.getPrimary(instrumentation) // TODO(b/162923992) Use of multiple segments of flicker spec for testing return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0, Surface.ROTATION_90)) .buildTest { configuration -> withTestName { - buildTestTag("exitSplitScreenFromBottom", splitScreenApp, - configuration) + buildTestTag("exitSplitScreenFromBottom", configuration) } repeat { configuration.repetitions } setup { eachRun { device.wakeUpAndGoToHomeScreen() device.openQuickStepAndClearRecentAppsFromOverview() - splitScreenApp.launchViaIntent() + splitScreenApp.launchViaIntent(wmHelper) device.launchSplitScreen() device.waitForIdle() this.setRotation(configuration.endRotation) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenTest.kt index 84bfe9451e0a..cd9a3c998d58 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ExitLegacySplitScreenTest.kt @@ -33,8 +33,6 @@ import com.android.server.wm.flicker.helpers.launchSplitScreen import com.android.server.wm.flicker.helpers.openQuickStepAndClearRecentAppsFromOverview import com.android.server.wm.flicker.helpers.resizeSplitScreen import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen -import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible -import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible import com.android.wm.shell.flicker.dockedStackDividerIsInvisible import com.android.wm.shell.flicker.helpers.SplitScreenHelper.Companion.TEST_REPETITIONS import org.junit.FixMethodOrder @@ -107,7 +105,7 @@ class ExitLegacySplitScreenTest( navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() end { - hidesAppWindow(splitScreenApp.defaultWindowName) + isInvisible(splitScreenApp.defaultWindowName) } } } @@ -135,7 +133,7 @@ class ExitLegacySplitScreenTest( navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() end { - showsAppWindow(splitScreenApp.defaultWindowName) + isVisible(splitScreenApp.defaultWindowName) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/LegacySplitScreenToLauncherTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/LegacySplitScreenToLauncherTest.kt index 629c71fa74e5..43a756585e3c 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/LegacySplitScreenToLauncherTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/LegacySplitScreenToLauncherTest.kt @@ -24,7 +24,6 @@ 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.helpers.StandardAppHelper import com.android.server.wm.flicker.endRotation import com.android.server.wm.flicker.focusDoesNotChange import com.android.server.wm.flicker.helpers.buildTestTag @@ -46,6 +45,7 @@ import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible import com.android.server.wm.flicker.statusBarLayerRotatesScales import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible import com.android.wm.shell.flicker.dockedStackDividerBecomesInvisible +import com.android.wm.shell.flicker.helpers.SimpleAppHelper import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -61,8 +61,9 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) class LegacySplitScreenToLauncherTest( testName: String, - flickerSpec: Flicker -) : FlickerTestRunner(testName, flickerSpec) { + flickerProvider: () -> Flicker, + cleanUp: Boolean +) : FlickerTestRunner(testName, flickerProvider, cleanUp) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic @@ -70,14 +71,13 @@ class LegacySplitScreenToLauncherTest( val instrumentation = InstrumentationRegistry.getInstrumentation() val launcherPackageName = LauncherStrategyFactory.getInstance(instrumentation) .launcherStrategy.supportedLauncherPackage - val testApp = StandardAppHelper(instrumentation, - "com.android.wm.shell.flicker.testapp", "SimpleApp") + val testApp = SimpleAppHelper(instrumentation) // b/161435597 causes the test not to work on 90 degrees return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0)) .buildTest { configuration -> withTestName { - buildTestTag("splitScreenToLauncher", testApp, configuration) + buildTestTag("splitScreenToLauncher", configuration) } repeat { configuration.repetitions } setup { @@ -86,7 +86,7 @@ class LegacySplitScreenToLauncherTest( device.openQuickStepAndClearRecentAppsFromOverview() } eachRun { - testApp.open() + testApp.launchViaIntent(wmHelper) this.setRotation(configuration.endRotation) device.launchSplitScreen() device.waitForIdle() diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableDismissInLegacySplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableDismissInLegacySplitScreenTest.kt index 26fabbd82fd5..ed305a21f444 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableDismissInLegacySplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableDismissInLegacySplitScreenTest.kt @@ -52,8 +52,8 @@ class NonResizableDismissInLegacySplitScreenTest( withTestName { testTag } repeat { SplitScreenHelper.TEST_REPETITIONS } transitions { - nonResizeableApp.launchViaIntent() - splitScreenApp.launchViaIntent() + nonResizeableApp.launchViaIntent(wmHelper) + splitScreenApp.launchViaIntent(wmHelper) device.launchSplitScreen() nonResizeableApp.reopenAppFromOverview() } @@ -72,8 +72,8 @@ class NonResizableDismissInLegacySplitScreenTest( } windowManagerTrace { end { - showsAppWindow(nonResizeableApp.defaultWindowName) - hidesAppWindow(splitScreenApp.defaultWindowName) + isVisible(nonResizeableApp.defaultWindowName) + .isInvisible(splitScreenApp.defaultWindowName) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableLaunchInLegacySplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableLaunchInLegacySplitScreenTest.kt index e2439f216c84..ff4e0b275c9d 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableLaunchInLegacySplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/NonResizableLaunchInLegacySplitScreenTest.kt @@ -52,8 +52,8 @@ class NonResizableLaunchInLegacySplitScreenTest( withTestName { testTag } repeat { SplitScreenHelper.TEST_REPETITIONS } transitions { - nonResizeableApp.launchViaIntent() - splitScreenApp.launchViaIntent() + nonResizeableApp.launchViaIntent(wmHelper) + splitScreenApp.launchViaIntent(wmHelper) device.launchSplitScreen() nonResizeableApp.reopenAppFromOverview() } @@ -72,8 +72,8 @@ class NonResizableLaunchInLegacySplitScreenTest( } windowManagerTrace { end { - showsAppWindow(nonResizeableApp.defaultWindowName) - hidesAppWindow(splitScreenApp.defaultWindowName) + isVisible(nonResizeableApp.defaultWindowName) + .isInvisible(splitScreenApp.defaultWindowName) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/OpenAppToLegacySplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/OpenAppToLegacySplitScreenTest.kt index d004c0617b40..6200a69b795e 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/OpenAppToLegacySplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/OpenAppToLegacySplitScreenTest.kt @@ -59,7 +59,7 @@ class OpenAppToLegacySplitScreenTest( repeat { SplitScreenHelper.TEST_REPETITIONS } setup { eachRun { - splitScreenApp.launchViaIntent() + splitScreenApp.launchViaIntent(wmHelper) device.pressHome() this.setRotation(rotation) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ResizeLegacySplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ResizeLegacySplitScreenTest.kt index 8ee92637c024..f6b07729c196 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ResizeLegacySplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/ResizeLegacySplitScreenTest.kt @@ -29,7 +29,6 @@ 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.helpers.StandardAppHelper import com.android.server.wm.flicker.helpers.ImeAppHelper import com.android.server.wm.flicker.focusDoesNotChange import com.android.server.wm.flicker.helpers.WindowUtils @@ -51,6 +50,8 @@ 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.statusBarWindowIsAlwaysVisible +import com.android.server.wm.flicker.traces.layers.getVisibleBounds +import com.android.wm.shell.flicker.helpers.SimpleAppHelper import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -69,8 +70,9 @@ import org.junit.runners.Parameterized @FlakyTest(bugId = 159096424) class ResizeLegacySplitScreenTest( testName: String, - flickerSpec: Flicker -) : FlickerTestRunner(testName, flickerSpec) { + flickerProvider: () -> Flicker, + cleanUp: Boolean +) : FlickerTestRunner(testName, flickerProvider, cleanUp) { companion object { private const val sSimpleActivity = "SimpleActivity" private const val sImeActivity = "ImeActivity" @@ -81,18 +83,16 @@ class ResizeLegacySplitScreenTest( @JvmStatic fun getParams(): Collection<Array<Any>> { val instrumentation = InstrumentationRegistry.getInstrumentation() - val testAppTop = StandardAppHelper(instrumentation, - "com.android.wm.shell.flicker.testapp", "SimpleApp") + val testAppTop = SimpleAppHelper(instrumentation) val testAppBottom = ImeAppHelper(instrumentation) - return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0)) + return FlickerTestRunnerFactory(instrumentation, + supportedRotations = listOf(Surface.ROTATION_0)) .buildTest { configuration -> withTestName { val description = (startRatio.toString().replace("/", "-") + "_to_" + stopRatio.toString().replace("/", "-")) - buildTestTag("resizeSplitScreen", testAppTop.launcherName, - configuration.startRotation, configuration.endRotation, - testAppBottom.launcherName, description) + buildTestTag("resizeSplitScreen", configuration, description) } repeat { configuration.repetitions } setup { @@ -100,9 +100,9 @@ class ResizeLegacySplitScreenTest( device.wakeUpAndGoToHomeScreen() this.setRotation(configuration.startRotation) this.launcherStrategy.clearRecentAppsFromOverview() - testAppBottom.open() + testAppBottom.launchViaIntent(wmHelper) device.pressHome() - testAppTop.open() + testAppTop.launchViaIntent(wmHelper) device.waitForIdle() device.launchSplitScreen() val snapshot = @@ -168,8 +168,6 @@ class ResizeLegacySplitScreenTest( start("appsStartingBounds", enabled = false) { val displayBounds = WindowUtils.displayBounds - val entry = this.trace.entries.firstOrNull() - ?: throw IllegalStateException("Trace is empty") val dividerBounds = entry.getVisibleBounds(DOCKED_STACK_DIVIDER).bounds @@ -180,14 +178,11 @@ class ResizeLegacySplitScreenTest( displayBounds.right, displayBounds.bottom - WindowUtils.navigationBarHeight) this.hasVisibleRegion("SimpleActivity", topAppBounds) - .and() .hasVisibleRegion("ImeActivity", bottomAppBounds) } end("appsEndingBounds", enabled = false) { val displayBounds = WindowUtils.displayBounds - val entry = this.trace.entries.lastOrNull() - ?: throw IllegalStateException("Trace is empty") val dividerBounds = entry.getVisibleBounds(DOCKED_STACK_DIVIDER).bounds @@ -199,7 +194,6 @@ class ResizeLegacySplitScreenTest( displayBounds.bottom - WindowUtils.navigationBarHeight) this.hasVisibleRegion(sSimpleActivity, topAppBounds) - .and() .hasVisibleRegion(sImeActivity, bottomAppBounds) } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateOneLaunchedAppTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateOneLaunchedAppTest.kt index 594b4c1cdb21..fdf88df0f697 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateOneLaunchedAppTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateOneLaunchedAppTest.kt @@ -100,7 +100,7 @@ class RotateOneLaunchedAppTest( navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() end { - showsAppWindow(splitScreenApp.defaultWindowName) + isVisible(splitScreenApp.defaultWindowName) } } } @@ -132,7 +132,7 @@ class RotateOneLaunchedAppTest( navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() end { - showsAppWindow(splitScreenApp.defaultWindowName) + isVisible(splitScreenApp.defaultWindowName) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateTwoLaunchedAppTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateTwoLaunchedAppTest.kt index 6ee0491a30dd..785ccf003504 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateTwoLaunchedAppTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/RotateTwoLaunchedAppTest.kt @@ -105,8 +105,8 @@ class RotateTwoLaunchedAppTest( navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() end { - showsAppWindow(splitScreenApp.defaultWindowName) - .and().showsAppWindow(secondaryApp.defaultWindowName) + isVisible(splitScreenApp.defaultWindowName) + .isVisible(secondaryApp.defaultWindowName) } } } @@ -142,8 +142,8 @@ class RotateTwoLaunchedAppTest( navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() end { - showsAppWindow(splitScreenApp.defaultWindowName) - .and().showsAppWindow(secondaryApp.defaultWindowName) + isVisible(splitScreenApp.defaultWindowName) + .isVisible(secondaryApp.defaultWindowName) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/SplitScreenTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/SplitScreenTestBase.kt index 8c9012455ef0..01db4ed6253e 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/SplitScreenTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/legacysplitscreen/SplitScreenTestBase.kt @@ -27,26 +27,15 @@ import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible import com.android.wm.shell.flicker.NonRotationTestBase -import com.android.wm.shell.flicker.TEST_APP_NONRESIZEABLE_LABEL -import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_PRIMARY_LABEL -import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_SECONDARY_LABEL import com.android.wm.shell.flicker.helpers.SplitScreenHelper -import com.android.wm.shell.flicker.testapp.Components abstract class SplitScreenTestBase( rotationName: String, rotation: Int ) : NonRotationTestBase(rotationName, rotation) { - protected val splitScreenApp = SplitScreenHelper(instrumentation, - TEST_APP_SPLITSCREEN_PRIMARY_LABEL, - Components.SplitScreenActivity()) - protected val secondaryApp = SplitScreenHelper(instrumentation, - TEST_APP_SPLITSCREEN_SECONDARY_LABEL, - Components.SplitScreenSecondaryActivity()) - protected val nonResizeableApp = SplitScreenHelper(instrumentation, - TEST_APP_NONRESIZEABLE_LABEL, - Components.NonResizeableActivity()) - + protected val splitScreenApp = SplitScreenHelper.getPrimary(instrumentation) + protected val secondaryApp = SplitScreenHelper.getSecondary(instrumentation) + protected val nonResizeableApp = SplitScreenHelper.getNonResizeable(instrumentation) protected val LAUNCHER_PACKAGE_NAME = LauncherStrategyFactory.getInstance(instrumentation) .launcherStrategy.supportedLauncherPackage protected val LIVE_WALLPAPER_PACKAGE_NAME = diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterExitPipTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterExitPipTest.kt index c9396aa7ea63..3524f7ff80d4 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterExitPipTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterExitPipTest.kt @@ -79,7 +79,7 @@ class EnterExitPipTest( } all("Initially shows both app windows then pipApp hides testApp") { showsAppWindow(testApp.defaultWindowName) - .and().showsAppWindowOnTop(pipApp.defaultWindowName) + .showsAppWindowOnTop(pipApp.defaultWindowName) .then() .hidesAppWindow(testApp.defaultWindowName) } @@ -89,7 +89,7 @@ class EnterExitPipTest( layersTrace { all("Initially shows both app layers then pipApp hides testApp") { showsLayer(testApp.defaultWindowName) - .and().showsLayer(pipApp.defaultWindowName) + .showsLayer(pipApp.defaultWindowName) .then() .hidesLayer(testApp.defaultWindowName) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt index cb1fe4e2981d..2ffc338f4f75 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipTest.kt @@ -54,15 +54,17 @@ import org.junit.runners.Parameterized @FlakyTest(bugId = 152738416) class EnterPipTest( 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 = PipAppHelper(instrumentation) - return FlickerTestRunnerFactory(instrumentation, listOf(Surface.ROTATION_0)) + return FlickerTestRunnerFactory(instrumentation, + supportedRotations = listOf(Surface.ROTATION_0)) .buildTest { configuration -> withTestName { buildTestTag("enterPip", testApp, configuration) } repeat { configuration.repetitions } @@ -72,7 +74,7 @@ class EnterPipTest( } eachRun { device.pressHome() - testApp.open() + testApp.launchViaIntent(wmHelper) this.setRotation(configuration.startRotation) } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt index 866d654362ca..812353ffe955 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTest.kt @@ -48,7 +48,7 @@ class PipKeyboardTest( rotation: Int ) : PipTestBase(rotationName, rotation) { private val keyboardApp = ImeAppHelper(instrumentation) - private val keyboardComponent = Components.ImeActivity().componentName + private val keyboardComponent = Components.ImeActivity.COMPONENT private val helper = WindowManagerStateHelper() private val keyboardScenario: FlickerBuilder @@ -61,7 +61,7 @@ class PipKeyboardTest( device.wakeUpAndGoToHomeScreen() device.pressHome() // launch our target pip app - testApp.open() + testApp.launchViaIntent(wmHelper) this.setRotation(rotation) testApp.clickEnterPipButton() // open an app with an input field and a keyboard @@ -93,11 +93,11 @@ class PipKeyboardTest( withTestName { testTag } transitions { // open the soft keyboard - keyboardApp.openIME() + keyboardApp.openIME(device, wmHelper) helper.waitImeWindowShown() // then close it again - keyboardApp.closeIME() + keyboardApp.closeIME(device, wmHelper) helper.waitImeWindowGone() } assertions { @@ -119,13 +119,13 @@ class PipKeyboardTest( withTestName { testTag } transitions { // open the soft keyboard - keyboardApp.openIME() + keyboardApp.openIME(device, wmHelper) helper.waitImeWindowShown() } teardown { eachRun { // close the keyboard - keyboardApp.closeIME() + keyboardApp.closeIME(device, wmHelper) helper.waitImeWindowGone() } } @@ -140,7 +140,7 @@ class PipKeyboardTest( } companion object { - private const val TEST_REPETITIONS = 10 + private const val TEST_REPETITIONS = 5 @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipLegacySplitScreenTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipLegacySplitScreenTest.kt index 9eae179fed92..e5790962c025 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipLegacySplitScreenTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipLegacySplitScreenTest.kt @@ -93,9 +93,9 @@ class PipLegacySplitScreenTest( coversAtMostRegion(pipApp.defaultWindowName, displayBounds) } end("Both app windows should be visible") { - showsAppWindow(testApp.defaultWindowName) - showsAppWindow(imeApp.defaultWindowName) - noWindowsOverlap(testApp.defaultWindowName, imeApp.defaultWindowName) + isVisible(testApp.defaultWindowName) + isVisible(imeApp.defaultWindowName) + noWindowsOverlap(setOf(testApp.defaultWindowName, imeApp.defaultWindowName)) } navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipOrientationTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipOrientationTest.kt index 76aabc1b83cf..b2df6845ea2b 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipOrientationTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipOrientationTest.kt @@ -110,10 +110,10 @@ class PipOrientationTest( showsAppWindowOnTop(pipApp.defaultWindowName) } start("pipApp window hides testApp") { - hidesAppWindow(testApp.defaultWindowName) + isInvisible(testApp.defaultWindowName) } end("testApp windows is shown") { - showsAppWindow(testApp.defaultWindowName) + isVisible(testApp.defaultWindowName) } navBarWindowIsAlwaysVisible() statusBarWindowIsAlwaysVisible() @@ -123,7 +123,7 @@ class PipOrientationTest( val endingBounds = WindowUtils.getDisplayBounds(Surface.ROTATION_0) start("pipApp layer hides testApp") { hasVisibleRegion(pipApp.defaultWindowName, startingBounds) - hidesLayer(testApp.defaultWindowName) + isInvisible(testApp.defaultWindowName) } end("testApp layer covers fullscreen") { hasVisibleRegion(testApp.defaultWindowName, endingBounds) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt index a67b3b760c49..f2ccf8d8f12a 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipRotationTest.kt @@ -53,8 +53,9 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) class PipRotationTest( testName: String, - flickerSpec: Flicker -) : FlickerTestRunner(testName, flickerSpec) { + flickerProvider: () -> Flicker, + cleanUp: Boolean +) : FlickerTestRunner(testName, flickerProvider, cleanUp) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic @@ -72,7 +73,7 @@ class PipRotationTest( AppTestBase.removeAllTasksButHome() device.wakeUpAndGoToHomeScreen() pipApp.launchViaIntent(stringExtras = mapOf( - EXTRA_ENTER_PIP to "true")) + EXTRA_ENTER_PIP to "true")) testApp.launchViaIntent() AppTestBase.waitForAnimationComplete() } @@ -100,22 +101,22 @@ class PipRotationTest( navBarLayerIsAlwaysVisible(bugId = 140855415) statusBarLayerIsAlwaysVisible(bugId = 140855415) noUncoveredRegions(configuration.startRotation, - configuration.endRotation, allStates = false) + configuration.endRotation, allStates = false) navBarLayerRotatesAndScales(configuration.startRotation, - configuration.endRotation) + configuration.endRotation, bugId = 140855415) statusBarLayerRotatesScales(configuration.startRotation, - configuration.endRotation) + configuration.endRotation, bugId = 140855415) } layersTrace { val startingBounds = WindowUtils.getDisplayBounds( - configuration.startRotation) + configuration.startRotation) val endingBounds = WindowUtils.getDisplayBounds( - configuration.endRotation) - start("appLayerRotates_StartingBounds") { + configuration.endRotation) + start("appLayerRotates_StartingBounds", bugId = 140855415) { hasVisibleRegion(testApp.defaultWindowName, startingBounds) coversAtMostRegion(startingBounds, pipApp.defaultWindowName) } - end("appLayerRotates_EndingBounds") { + end("appLayerRotates_EndingBounds", bugId = 140855415) { hasVisibleRegion(testApp.defaultWindowName, endingBounds) coversAtMostRegion(endingBounds, pipApp.defaultWindowName) } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToAppTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToAppTest.kt index e1fa6578e552..1502bcdf3a11 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToAppTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToAppTest.kt @@ -55,8 +55,9 @@ import org.junit.runners.Parameterized @FlakyTest(bugId = 152738416) class PipToAppTest( testName: String, - flickerSpec: Flicker -) : FlickerTestRunner(testName, flickerSpec) { + flickerProvider: () -> Flicker, + cleanUp: Boolean +) : FlickerTestRunner(testName, flickerProvider, cleanUp) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic @@ -71,7 +72,7 @@ class PipToAppTest( test { device.wakeUpAndGoToHomeScreen() device.pressHome() - testApp.open() + testApp.launchViaIntent(wmHelper) } eachRun { this.setRotation(configuration.startRotation) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToHomeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToHomeTest.kt index bf1193786a59..df88a2da0a92 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToHomeTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipToHomeTest.kt @@ -54,8 +54,9 @@ import org.junit.runners.Parameterized @FlakyTest(bugId = 152738416) class PipToHomeTest( testName: String, - flickerSpec: Flicker -) : FlickerTestRunner(testName, flickerSpec) { + flickerProvider: () -> Flicker, + cleanUp: Boolean +) : FlickerTestRunner(testName, flickerProvider, cleanUp) { companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic @@ -72,7 +73,7 @@ class PipToHomeTest( device.pressHome() } eachRun { - testApp.open() + testApp.launchViaIntent(wmHelper) this.setRotation(configuration.startRotation) testApp.clickEnterPipButton() device.hasPipWindow() diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt index 6105f50562d7..748e289d9173 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipMenuTests.kt @@ -20,10 +20,7 @@ import android.graphics.Rect import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.UiObject2 import com.android.wm.shell.flicker.SYSTEM_UI_PACKAGE_NAME -import com.android.wm.shell.flicker.TEST_APP_PIP_MENU_ACTION_CLEAR -import com.android.wm.shell.flicker.TEST_APP_PIP_MENU_ACTION_NO_OP -import com.android.wm.shell.flicker.TEST_APP_PIP_MENU_ACTION_OFF -import com.android.wm.shell.flicker.TEST_APP_PIP_MENU_ACTION_ON +import com.android.wm.shell.flicker.testapp.Components import com.android.wm.shell.flicker.wait import org.junit.Assert.assertNull import org.junit.Assert.assertTrue @@ -166,39 +163,44 @@ class TvPipMenuTests : TvPipTestBase() { enterPip_openMenu_assertShown() // PiP menu should contain "No-Op", "Off" and "Clear" buttons... - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_NO_OP) + uiDevice.findTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_NO_OP) ?: fail("\"No-Op\" button should be shown in Pip menu") - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_OFF) + uiDevice.findTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_OFF) ?: fail("\"Off\" button should be shown in Pip menu") - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_CLEAR) + uiDevice.findTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_CLEAR) ?: fail("\"Clear\" button should be shown in Pip menu") // ... and should also contain the "Full screen" and "Close" buttons. assertFullscreenAndCloseButtonsAreShown() - uiDevice.clickTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_OFF) + uiDevice.clickTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_OFF) // Invoking the "Off" action should replace it with the "On" action/button and should // remove the "No-Op" action/button. "Clear" action/button should remain in the menu ... - uiDevice.waitForTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_ON) + uiDevice.waitForTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_ON) ?: fail("\"On\" button should be shown in Pip for a corresponding custom action") assertNull("\"No-Op\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_NO_OP)) - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_CLEAR) + uiDevice.findTvPipMenuElementWithDescription( + Components.PipActivity.MENU_ACTION_NO_OP)) + uiDevice.findTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_CLEAR) ?: fail("\"Clear\" button should be shown in Pip menu") // ... as well as the "Full screen" and "Close" buttons. assertFullscreenAndCloseButtonsAreShown() - uiDevice.clickTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_CLEAR) + uiDevice.clickTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_CLEAR) // Invoking the "Clear" action should remove all the custom actions and their corresponding // buttons, ... - uiDevice.waitUntilTvPipMenuElementWithDescriptionIsGone(TEST_APP_PIP_MENU_ACTION_ON)?.also { + uiDevice.waitUntilTvPipMenuElementWithDescriptionIsGone( + Components.PipActivity.MENU_ACTION_ON)?.also { isGone -> if (!isGone) fail("\"On\" button should not be shown in Pip menu") } assertNull("\"Off\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_OFF)) + uiDevice.findTvPipMenuElementWithDescription( + Components.PipActivity.MENU_ACTION_OFF)) assertNull("\"Clear\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_CLEAR)) + uiDevice.findTvPipMenuElementWithDescription( + Components.PipActivity.MENU_ACTION_CLEAR)) assertNull("\"No-Op\" button should not be shown in Pip menu", - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_NO_OP)) + uiDevice.findTvPipMenuElementWithDescription( + Components.PipActivity.MENU_ACTION_NO_OP)) // ... but the menu should still contain the "Full screen" and "Close" buttons. assertFullscreenAndCloseButtonsAreShown() @@ -213,11 +215,11 @@ class TvPipMenuTests : TvPipTestBase() { enterPip_openMenu_assertShown() // PiP menu should contain "No-Op", "Off" and "Clear" buttons for the custom actions... - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_NO_OP) + uiDevice.findTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_NO_OP) ?: fail("\"No-Op\" button should be shown in Pip menu") - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_OFF) + uiDevice.findTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_OFF) ?: fail("\"Off\" button should be shown in Pip menu") - uiDevice.findTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_CLEAR) + uiDevice.findTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_CLEAR) ?: fail("\"Clear\" button should be shown in Pip menu") // ... should also contain the "Full screen" and "Close" buttons, ... assertFullscreenAndCloseButtonsAreShown() @@ -227,7 +229,7 @@ class TvPipMenuTests : TvPipTestBase() { assertNull("\"Pause\" button should not be shown in menu when there are custom actions", uiDevice.findTvPipMenuElementWithDescription(pauseButtonDescription)) - uiDevice.clickTvPipMenuElementWithDescription(TEST_APP_PIP_MENU_ACTION_CLEAR) + uiDevice.clickTvPipMenuElementWithDescription(Components.PipActivity.MENU_ACTION_CLEAR) // Invoking the "Clear" action should remove all the custom actions, which should bring up // media buttons... uiDevice.waitForTvPipMenuElementWithDescription(pauseButtonDescription) diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt index 5258e9030075..3885cc945827 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipNotificationTests.kt @@ -60,12 +60,12 @@ class TvPipNotificationTests : TvPipTestBase() { testApp.clickEnterPipButton() assertNotNull("Pip notification should have been posted", - waitForNotificationToAppear { it.isPipNotificationWithTitle(testApp.label) }) + waitForNotificationToAppear { it.isPipNotificationWithTitle(testApp.appName) }) testApp.closePipWindow() assertTrue("Pip notification should have been dismissed", - waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.label) }) + waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.appName) }) } @Test @@ -74,7 +74,7 @@ class TvPipNotificationTests : TvPipTestBase() { testApp.clickEnterPipButton() val notification: StatusBarNotification = waitForNotificationToAppear { - it.isPipNotificationWithTitle(testApp.label) + it.isPipNotificationWithTitle(testApp.appName) } ?: fail("Pip notification should have been posted") notification.deleteIntent?.send() @@ -83,7 +83,7 @@ class TvPipNotificationTests : TvPipTestBase() { assertTrue("Pip should have closed by sending the `delete_intent`", testApp.waitUntilClosed()) assertTrue("Pip notification should have been dismissed", - waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.label) }) + waitForNotificationToDisappear { it.isPipNotificationWithTitle(testApp.appName) }) } @Test @@ -92,7 +92,7 @@ class TvPipNotificationTests : TvPipTestBase() { testApp.clickEnterPipButton() val notification: StatusBarNotification = waitForNotificationToAppear { - it.isPipNotificationWithTitle(testApp.label) + it.isPipNotificationWithTitle(testApp.appName) } ?: fail("Pip notification should have been posted") notification.contentIntent?.send() @@ -118,7 +118,7 @@ class TvPipNotificationTests : TvPipTestBase() { } ?: fail("Pip notification with media session title should have been posted") // ... and make sure "regular" PiP notification is now shown assertNull("Regular notification should not have been posted", - findNotification { it.isPipNotificationWithTitle(testApp.label) }) + findNotification { it.isPipNotificationWithTitle(testApp.appName) }) // Pause the media session. When paused the application updates the title for the media // session. This change should be reflected in the notification. @@ -137,7 +137,7 @@ class TvPipNotificationTests : TvPipTestBase() { // Wait for the "regular" notification to show up... waitForNotificationToAppear { - it.isPipNotificationWithTitle(testApp.label) + it.isPipNotificationWithTitle(testApp.appName) } ?: fail("Pip notification with media session title should have been posted") // ... and make sure previous ("paused") notification is gone assertNull("Regular notification should not have been posted", diff --git a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java index f729ea554072..0ead91bb37de 100644 --- a/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java +++ b/libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/src/com/android/wm/shell/flicker/testapp/Components.java @@ -19,33 +19,35 @@ package com.android.wm.shell.flicker.testapp; import android.content.ComponentName; public class Components { - public abstract static class ComponentsInfo { - public ComponentName getComponentName() { - return ComponentName.createRelative(PACKAGE_NAME, "." + getActivityName()); - } - public abstract String getActivityName(); - } - public static final String PACKAGE_NAME = "com.android.wm.shell.flicker.testapp"; - public static class FixedActivity extends ComponentsInfo { - // Sets the fixed orientation (can be one of {@link ActivityInfo.ScreenOrientation} - public static final String EXTRA_FIXED_ORIENTATION = "fixed_orientation"; + public static class SimpleActivity { + public static final String LABEL = "SimpleApp"; + public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME, + PACKAGE_NAME + ".SimpleActivity"); + } - @Override - public String getActivityName() { - return FixedActivity.class.getSimpleName(); - } + public static class FixedActivity { + public static final String EXTRA_FIXED_ORIENTATION = "fixed_orientation"; + public static final String LABEL = "FixedApp"; + public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME, + PACKAGE_NAME + ".FixedActivity"); } - public static class NonResizeableActivity extends ComponentsInfo { - @Override - public String getActivityName() { - return NonResizeableActivity.class.getSimpleName(); - } + public static class NonResizeableActivity { + public static final String LABEL = "NonResizeableApp"; + public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME, + PACKAGE_NAME + ".NonResizeableActivity"); } - public static class PipActivity extends ComponentsInfo { + public static class PipActivity { + // Test App > Pip Activity + public static final String LABEL = "PipApp"; + public static final String MENU_ACTION_NO_OP = "No-Op"; + public static final String MENU_ACTION_ON = "On"; + public static final String MENU_ACTION_OFF = "Off"; + public static final String MENU_ACTION_CLEAR = "Clear"; + // Intent action that this activity dynamically registers to enter picture-in-picture public static final String ACTION_ENTER_PIP = PACKAGE_NAME + ".PipActivity.ENTER_PIP"; // Intent action that this activity dynamically registers to set requested orientation. @@ -60,30 +62,29 @@ public class Components { // Adds a click listener to finish this activity when it is clicked public static final String EXTRA_TAP_TO_FINISH = "tap_to_finish"; - @Override - public String getActivityName() { - return PipActivity.class.getSimpleName(); - } + public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME, + PACKAGE_NAME + ".PipActivity"); } - public static class ImeActivity extends ComponentsInfo { - @Override - public String getActivityName() { - return ImeActivity.class.getSimpleName(); - } + public static class ImeActivity { + public static final String LABEL = "ImeApp"; + public static final String ACTION_CLOSE_IME = + PACKAGE_NAME + ".action.CLOSE_IME"; + public static final String ACTION_OPEN_IME = + PACKAGE_NAME + ".action.OPEN_IME"; + public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME, + PACKAGE_NAME + ".ImeActivity"); } - public static class SplitScreenActivity extends ComponentsInfo { - @Override - public String getActivityName() { - return SplitScreenActivity.class.getSimpleName(); - } + public static class SplitScreenActivity { + public static final String LABEL = "SplitScreenPrimaryApp"; + public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME, + PACKAGE_NAME + ".SplitScreenActivity"); } - public static class SplitScreenSecondaryActivity extends ComponentsInfo { - @Override - public String getActivityName() { - return SplitScreenSecondaryActivity.class.getSimpleName(); - } + public static class SplitScreenSecondaryActivity { + public static final String LABEL = "SplitScreenSecondaryApp"; + public static final ComponentName COMPONENT = new ComponentName(PACKAGE_NAME, + PACKAGE_NAME + ".SplitScreenSecondaryActivity"); } } diff --git a/tests/FlickerTests/Android.bp b/tests/FlickerTests/Android.bp index 1a83655ed8d3..c945aeac0b33 100644 --- a/tests/FlickerTests/Android.bp +++ b/tests/FlickerTests/Android.bp @@ -49,7 +49,6 @@ android_test { "flickertestapplib", "flickerlib", "truth-prebuilt", - "app-helpers-core", "launcher-helper-lib", "launcher-aosp-tapl", "platform-test-annotations", @@ -81,6 +80,7 @@ java_library { ], static_libs: [ "flickerlib", + "flickertestapplib", "truth-prebuilt", "app-helpers-core" ], diff --git a/tests/FlickerTests/AndroidTestPhysicalDevices.xml b/tests/FlickerTests/AndroidTestPhysicalDevices.xml index abd620f5c157..b1cee5c91e68 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 e4db55e238ea..ba12fbed2b2f 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 DOCKED_STACK_DIVIDER = "DockedStackDivider" const val WALLPAPER_TITLE = "Wallpaper" @JvmOverloads -fun WmAssertion.statusBarWindowIsAlwaysVisible( +fun WmAssertionBuilder.statusBarWindowIsAlwaysVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -38,7 +38,7 @@ fun WmAssertion.statusBarWindowIsAlwaysVisible( } @JvmOverloads -fun WmAssertion.navBarWindowIsAlwaysVisible( +fun WmAssertionBuilder.navBarWindowIsAlwaysVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -47,7 +47,7 @@ fun WmAssertion.navBarWindowIsAlwaysVisible( } } -fun WmAssertion.visibleWindowsShownMoreThanOneConsecutiveEntry( +fun WmAssertionBuilder.visibleWindowsShownMoreThanOneConsecutiveEntry( ignoreWindows: List<String> = emptyList(), bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -57,7 +57,7 @@ fun WmAssertion.visibleWindowsShownMoreThanOneConsecutiveEntry( } } -fun WmAssertion.launcherReplacesAppWindowAsTopWindow( +fun WmAssertionBuilder.launcherReplacesAppWindowAsTopWindow( testApp: IAppHelper, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -69,7 +69,7 @@ fun WmAssertion.launcherReplacesAppWindowAsTopWindow( } } -fun WmAssertion.wallpaperWindowBecomesVisible( +fun WmAssertionBuilder.wallpaperWindowBecomesVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -80,7 +80,7 @@ fun WmAssertion.wallpaperWindowBecomesVisible( } } -fun WmAssertion.wallpaperWindowBecomesInvisible( +fun WmAssertionBuilder.wallpaperWindowBecomesInvisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -91,7 +91,7 @@ fun WmAssertion.wallpaperWindowBecomesInvisible( } } -fun WmAssertion.appWindowAlwaysVisibleOnTop( +fun WmAssertionBuilder.appWindowAlwaysVisibleOnTop( packageName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -101,7 +101,7 @@ fun WmAssertion.appWindowAlwaysVisibleOnTop( } } -fun WmAssertion.appWindowBecomesVisible( +fun WmAssertionBuilder.appWindowBecomesVisible( appName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -114,7 +114,7 @@ fun WmAssertion.appWindowBecomesVisible( } @JvmOverloads -fun LayersAssertion.noUncoveredRegions( +fun LayersAssertionBuilder.noUncoveredRegions( beginRotation: Int, endRotation: Int = beginRotation, allStates: Boolean = true, @@ -144,7 +144,7 @@ fun LayersAssertion.noUncoveredRegions( } @JvmOverloads -fun LayersAssertion.navBarLayerIsAlwaysVisible( +fun LayersAssertionBuilder.navBarLayerIsAlwaysVisible( rotatesScreen: Boolean = false, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -165,7 +165,7 @@ fun LayersAssertion.navBarLayerIsAlwaysVisible( } @JvmOverloads -fun LayersAssertion.statusBarLayerIsAlwaysVisible( +fun LayersAssertionBuilder.statusBarLayerIsAlwaysVisible( rotatesScreen: Boolean = false, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -186,7 +186,7 @@ fun LayersAssertion.statusBarLayerIsAlwaysVisible( } @JvmOverloads -fun LayersAssertion.navBarLayerRotatesAndScales( +fun LayersAssertionBuilder.navBarLayerRotatesAndScales( beginRotation: Int, endRotation: Int = beginRotation, bugId: Int = 0, @@ -210,7 +210,7 @@ fun LayersAssertion.navBarLayerRotatesAndScales( } @JvmOverloads -fun LayersAssertion.statusBarLayerRotatesScales( +fun LayersAssertionBuilder.statusBarLayerRotatesScales( beginRotation: Int, endRotation: Int = beginRotation, bugId: Int = 0, @@ -227,7 +227,7 @@ fun LayersAssertion.statusBarLayerRotatesScales( } } -fun LayersAssertion.visibleLayersShownMoreThanOneConsecutiveEntry( +fun LayersAssertionBuilder.visibleLayersShownMoreThanOneConsecutiveEntry( ignoreLayers: List<String> = emptyList(), bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -237,7 +237,7 @@ fun LayersAssertion.visibleLayersShownMoreThanOneConsecutiveEntry( } } -fun LayersAssertion.appLayerReplacesWallpaperLayer( +fun LayersAssertionBuilder.appLayerReplacesWallpaperLayer( appName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -249,7 +249,7 @@ fun LayersAssertion.appLayerReplacesWallpaperLayer( } } -fun LayersAssertion.wallpaperLayerReplacesAppLayer( +fun LayersAssertionBuilder.wallpaperLayerReplacesAppLayer( testApp: IAppHelper, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -261,7 +261,7 @@ fun LayersAssertion.wallpaperLayerReplacesAppLayer( } } -fun LayersAssertion.layerAlwaysVisible( +fun LayersAssertionBuilder.layerAlwaysVisible( packageName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -271,7 +271,7 @@ fun LayersAssertion.layerAlwaysVisible( } } -fun LayersAssertion.layerBecomesVisible( +fun LayersAssertionBuilder.layerBecomesVisible( packageName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -283,7 +283,7 @@ fun LayersAssertion.layerBecomesVisible( } } -fun LayersAssertion.layerBecomesInvisible( +fun LayersAssertionBuilder.layerBecomesInvisible( packageName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -295,7 +295,7 @@ fun LayersAssertion.layerBecomesInvisible( } } -fun EventLogAssertion.focusChanges( +fun EventLogAssertionBuilder.focusChanges( vararg windows: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -305,7 +305,7 @@ fun EventLogAssertion.focusChanges( } } -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 67deca4fe387..a625dfde02ff 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.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 +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 @@ import org.junit.runners.Parameterized @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()) + eachRun { + this.setRotation(configuration.startRotation) + testApp.launchViaIntent(wmHelper) } - teardown { - eachRun { - this.setRotation(Surface.ROTATION_0) - } - test { - testApp.exit() - } + } + transitions { + device.pressBack() + wmHelper.waitForHomeActivityVisible() + } + teardown { + eachRun { + this.setRotation(Surface.ROTATION_0) + } + test { + testApp.exit() } - assertions { - windowManagerTrace { - navBarWindowIsAlwaysVisible() - statusBarWindowIsAlwaysVisible() - visibleWindowsShownMoreThanOneConsecutiveEntry() + } + assertions { + windowManagerTrace { + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() + visibleWindowsShownMoreThanOneConsecutiveEntry(bugId = 174635878) - launcherReplacesAppWindowAsTopWindow(testApp) - wallpaperWindowBecomesVisible() - } + 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() + 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) - } + 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 252ce2a32bf0..e88b10b1bc77 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.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 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 @@ import org.junit.runners.Parameterized @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()) + eachRun { + testApp.launchViaIntent(wmHelper) + this.setRotation(configuration.startRotation) } - teardown { - eachRun { - this.setRotation(Surface.ROTATION_0) - } - test { - testApp.exit() - } + } + transitions { + device.pressHome() + wmHelper.waitForHomeActivityVisible() + } + teardown { + eachRun { + this.setRotation(Surface.ROTATION_0) + } + test { + testApp.exit() } - assertions { - windowManagerTrace { - navBarWindowIsAlwaysVisible() - statusBarWindowIsAlwaysVisible() - visibleWindowsShownMoreThanOneConsecutiveEntry() + } + assertions { + windowManagerTrace { + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() + visibleWindowsShownMoreThanOneConsecutiveEntry(bugId = 174635878) - launcherReplacesAppWindowAsTopWindow(testApp) - wallpaperWindowBecomesVisible() - } + 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() + 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) - } + 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 742003a9438e..b569edac1a95 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 @@ package com.android.server.wm.flicker.helpers 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 @@ fun buildTestTag( * 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 @@ fun buildTestTag( </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 6bf2c855f08a..619a05efb72c 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 3565ca40474e..d8091a93dc63 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 000000000000..02be3cf0a8a3 --- /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 000000000000..d7cbaaee2627 --- /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 412a3c383785..40406d4c0fe7 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.FlickerTestRunner 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 @@ import org.junit.runners.Parameterized /** * 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 @@ import org.junit.runners.Parameterized @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 @@ class CloseImeAutoOpenWindowToAppTest( 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 60a798fda5e4..f5bb8e1bfb14 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.FlickerTestRunner 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 @@ import org.junit.runners.Parameterized @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 @@ class CloseImeAutoOpenWindowToHomeTest( 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 @@ class CloseImeAutoOpenWindowToHomeTest( 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 663d45607f93..b08cf6a374f2 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 @@ import org.junit.runners.Parameterized @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 @@ class CloseImeWindowToAppTest( 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 @@ class CloseImeWindowToAppTest( 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 bfe5264ed358..97106008ba56 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.FlickerTestRunner 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 @@ import org.junit.runners.Parameterized @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 @@ class CloseImeWindowToHomeTest( layersTrace { noUncoveredRegions(configuration.startRotation, - Surface.ROTATION_0, allStates = false) + Surface.ROTATION_0) navBarLayerRotatesAndScales(configuration.startRotation, - Surface.ROTATION_0, bugId = 140855415) + Surface.ROTATION_0, + enabled = !configuration.startRotation.isRotated()) statusBarLayerRotatesScales(configuration.startRotation, - Surface.ROTATION_0) - navBarLayerIsAlwaysVisible( - enabled = Surface.ROTATION_0 == configuration.startRotation) - statusBarLayerIsAlwaysVisible( - enabled = Surface.ROTATION_0 == 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 aa34b5d23946..96c2009fc0df 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.imeLayerBecomesVisible( } } -fun LayersAssertion.imeLayerBecomesInvisible( +fun LayersAssertionBuilder.imeLayerBecomesInvisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -45,7 +45,7 @@ fun LayersAssertion.imeLayerBecomesInvisible( } } -fun LayersAssertion.imeAppLayerIsAlwaysVisible( +fun LayersAssertionBuilder.imeAppLayerIsAlwaysVisible( testApp: IAppHelper, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -55,7 +55,7 @@ fun LayersAssertion.imeAppLayerIsAlwaysVisible( } } -fun WmAssertion.imeAppWindowIsAlwaysVisible( +fun WmAssertionBuilder.imeAppWindowIsAlwaysVisible( testApp: IAppHelper, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -65,7 +65,7 @@ fun WmAssertion.imeAppWindowIsAlwaysVisible( } } -fun WmAssertion.imeWindowBecomesVisible( +fun WmAssertionBuilder.imeWindowBecomesVisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -76,7 +76,7 @@ fun WmAssertion.imeWindowBecomesVisible( } } -fun WmAssertion.imeWindowBecomesInvisible( +fun WmAssertionBuilder.imeWindowBecomesInvisible( bugId: Int = 0, enabled: Boolean = bugId == 0 ) { @@ -87,7 +87,7 @@ fun WmAssertion.imeWindowBecomesInvisible( } } -fun WmAssertion.imeAppWindowBecomesVisible( +fun WmAssertionBuilder.imeAppWindowBecomesVisible( windowName: String, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -99,7 +99,7 @@ fun WmAssertion.imeAppWindowBecomesVisible( } } -fun WmAssertion.imeAppWindowBecomesInvisible( +fun WmAssertionBuilder.imeAppWindowBecomesInvisible( testApp: IAppHelper, bugId: Int = 0, enabled: Boolean = bugId == 0 @@ -111,7 +111,7 @@ fun WmAssertion.imeAppWindowBecomesInvisible( } } -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 28a8bd385779..399a15a25d3e 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.visibleWindowsShownMoreThanOneConsecutiveEn 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 @@ import org.junit.runners.Parameterized @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 @@ class OpenImeWindowTest( 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 d1842739171d..e47e757404f7 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.wallpaperWindowBecomesInvisible 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 @@ import org.junit.runners.Parameterized @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 @@ class ReOpenImeWindowTest( } 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 71920f696cb2..ba2ee5ff6783 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 ba7770d1ce0d..cf259876c409 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.FlickerTestRunnerFactory 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.visibleWindowsShownMoreThanOneConsecutiveEn 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 @@ import org.junit.runners.Parameterized @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 @@ class OpenAppColdTest( } transitions { testApp.open() + wmHelper.waitForFullScreenApp(testApp.component) } teardown { eachRun { testApp.exit() + wmHelper.waitForAppTransitionIdle() this.setRotation(Surface.ROTATION_0) } } @@ -99,15 +102,16 @@ class OpenAppColdTest( 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 @@ class OpenAppColdTest( } } } -}
\ 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 1b682c0b5b04..3c8f469b4213 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.endRotation 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.statusBarLayerRotatesScales 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 @@ import org.junit.runners.Parameterized @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 - ) + eachRun { + device.pressHome() + wmHelper.waitForAppTransitionIdle() + device.pressRecentApps() + wmHelper.waitForAppTransitionIdle() + this.setRotation(configuration.startRotation) } - teardown { - test { - testApp.exit() - this.setRotation(Surface.ROTATION_0) - } + } + transitions { + device.reopenAppFromOverview() + wmHelper.waitForFullScreenApp(testApp.component) + } + teardown { + test { + testApp.exit() } - assertions { - windowManagerTrace { - navBarWindowIsAlwaysVisible() - statusBarWindowIsAlwaysVisible() - visibleWindowsShownMoreThanOneConsecutiveEntry() + } + assertions { + windowManagerTrace { + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() + visibleWindowsShownMoreThanOneConsecutiveEntry() - appWindowReplacesLauncherAsTopWindow(testApp) - wallpaperWindowBecomesInvisible() - } + 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) + 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`) - } + appLayerReplacesWallpaperLayer(testApp.`package`) + } - eventLog { - focusChanges("NexusLauncherActivity", 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 3703d9c71f25..fd99be273dda 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.FlickerTestRunnerFactory 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.visibleWindowsShownMoreThanOneConsecutiveEn 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 @@ import org.junit.runners.Parameterized @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 @@ class OpenAppWarmTest( 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 @@ class OpenAppWarmTest( } } } -}
\ 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 9d4a71874f67..fe3ab041aa0b 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 @@ import org.junit.runners.Parameterized @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) - } - repeat { configuration.repetitions } - setup { - test { - device.wakeUpAndGoToHomeScreen() - testApp.open() - } - eachRun { - this.setRotation(configuration.startRotation) - } - } - teardown { - eachRun { - this.setRotation(Surface.ROTATION_0) - } - test { - testApp.exit() - } - } - transitions { - this.setRotation(configuration.endRotation) + val testSpec: FlickerBuilder.(Bundle) -> Unit = { configuration -> + withTestName { buildTestTag("changeAppRotation", configuration) } + assertions { + windowManagerTrace { + navBarWindowIsAlwaysVisible() + statusBarWindowIsAlwaysVisible() + visibleWindowsShownMoreThanOneConsecutiveEntry() } - 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) + 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) + } - start("appLayerRotates_StartingPos") { - this.hasVisibleRegion(testApp.getPackage(), startingPos) - } + layersTrace { + val startingPos = WindowUtils.getDisplayBounds( + configuration.startRotation) + val endingPos = WindowUtils.getDisplayBounds( + configuration.endRotation) - end("appLayerRotates_EndingPos") { - this.hasVisibleRegion(testApp.getPackage(), endingPos) - } + start("appLayerRotates_StartingPos", bugId = 140855415) { + this.hasVisibleRegion(testApp.getPackage(), startingPos) + } - all("screenshotLayerBecomesInvisible") { - this.showsLayer(testApp.getPackage()) - .then() - .showsLayer(SCREENSHOT_LAYER) - .then() - .showsLayer(testApp.getPackage()) - } + end("appLayerRotates_EndingPos", bugId = 140855415) { + this.hasVisibleRegion(testApp.getPackage(), endingPos) } - eventLog { - focusDoesNotChange(bugId = 151179149) + all("screenshotLayerBecomesInvisible") { + this.showsLayer(testApp.getPackage()) + .then() + .showsLayer(SCREENSHOT_LAYER) + .then() + .showsLayer(testApp.getPackage()) } } + + 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 000000000000..b871e949cb19 --- /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 120354b7dada..e25c734b22c6 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 @@ import org.junit.runners.Parameterized @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 @@ class SeamlessAppRotationTest( @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) - } - 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")) + val extra = if (configuration.starveUiThread) { + "BUSY_UI_THREAD" + } else { + "" } - } - 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 @@ class SeamlessAppRotationTest( 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 @@ class SeamlessAppRotationTest( 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 @@ class SeamlessAppRotationTest( } } } + + 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 0bea209a757a..502779723c36 100644 --- a/tests/FlickerTests/test-apps/flickerapp/Android.bp +++ b/tests/FlickerTests/test-apps/flickerapp/Android.bp @@ -19,7 +19,7 @@ android_test { 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 f167e950a113..0ccc49897202 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 @@ import android.content.ComponentName; 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"); } diff --git a/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt b/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt index 8ea23dea055d..6383da5a0a98 100644 --- a/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt +++ b/tests/SurfaceViewBufferTests/src/com/android/test/SurfaceTracingTestBase.kt @@ -23,7 +23,7 @@ import android.util.Log import androidx.test.ext.junit.rules.ActivityScenarioRule import com.android.server.wm.flicker.monitor.LayersTraceMonitor import com.android.server.wm.flicker.monitor.withSFTracing -import com.android.server.wm.traces.parser.layers.LayersTrace +import com.android.server.wm.traces.common.layers.LayersTrace import junit.framework.Assert import org.junit.After import org.junit.Before diff --git a/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt b/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt index 2e3467aff9ba..03b43cc5b18c 100644 --- a/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt +++ b/tests/TaskOrganizerTest/src/com/android/test/taskembed/ResizeTasksSyncTest.kt @@ -78,7 +78,7 @@ class ResizeTasksSyncTest { } // find the frame which match resized buffer size. - val frame = trace.entries.flatMap { it.flattenedLayers } + val frame = trace.entries.flatMap { it.flattenedLayers.toList() } .firstOrNull { layer -> !layer.isActiveBufferEmpty && layer.activeBuffer?.width == firstBounds.width() && @@ -90,13 +90,13 @@ class ResizeTasksSyncTest { secondBounds.offsetTo(0, 0) // verify buffer size should be changed to expected values. - assertThat(trace).layer(FIRST_ACTIVITY, frame).also { + assertThat(trace).layer(FIRST_ACTIVITY, frame.toLong()).also { val firstTaskSize = Point(firstBounds.width(), firstBounds.height()) it.hasLayerSize(firstTaskSize) it.hasBufferSize(firstTaskSize) } - assertThat(trace).layer(SECOND_ACTIVITY, frame).also { + assertThat(trace).layer(SECOND_ACTIVITY, frame.toLong()).also { val secondTaskSize = Point(secondBounds.width(), secondBounds.height()) it.hasLayerSize(secondTaskSize) it.hasBufferSize(secondTaskSize) |