diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt new file mode 100644 index 0000000000000..70771d8421970 --- /dev/null +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/BaseTest.kt @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2022 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 + +import android.app.Instrumentation +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.FlickerTestParameter +import com.android.server.wm.flicker.dsl.FlickerBuilder +import com.android.server.wm.flicker.entireScreenCovered +import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd +import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd +import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible +import com.android.server.wm.flicker.statusBarLayerIsVisibleAtStartAndEnd +import com.android.server.wm.flicker.statusBarLayerPositionAtStartAndEnd +import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible +import com.android.server.wm.flicker.taskBarLayerIsVisibleAtStartAndEnd +import com.android.server.wm.flicker.taskBarWindowIsAlwaysVisible +import com.android.server.wm.traces.common.ComponentMatcher +import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper +import org.junit.Assume + +/** + * Base test class containing common assertions for [ComponentMatcher.NAV_BAR], + * [ComponentMatcher.TASK_BAR], [ComponentMatcher.STATUS_BAR], and general assertions + * (layers visible in consecutive states, entire screen covered, etc.) + */ +abstract class BaseTest @JvmOverloads constructor( + protected val testSpec: FlickerTestParameter, + protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), + protected val tapl: LauncherInstrumentation = LauncherInstrumentation() +) { + init { + testSpec.setIsTablet( + WindowManagerStateHelper(instrumentation).currentState.wmState.isTablet + ) + } + + /** + * Specification of the test transition to execute + */ + abstract val transition: FlickerBuilder.() -> Unit + + /** + * Entry point for the test runner. It will use this method to initialize and cache + * flicker executions + */ + @FlickerBuilderProvider + fun buildFlicker(): FlickerBuilder { + return FlickerBuilder(instrumentation).apply { + setup { + test { + testSpec.setIsTablet(wmHelper.currentState.wmState.isTablet) + } + } + transition() + } + } + + /** + * Checks that all parts of the screen are covered during the transition + */ + open fun entireScreenCovered() = testSpec.entireScreenCovered() + + /** + * Checks that the [ComponentMatcher.NAV_BAR] layer is visible during the whole transition + */ + open fun navBarLayerIsVisibleAtStartAndEnd() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarLayerIsVisibleAtStartAndEnd() + } + + /** + * Checks the position of the [ComponentMatcher.NAV_BAR] at the start and end of the transition + */ + open fun navBarLayerPositionAtStartAndEnd() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarLayerPositionAtStartAndEnd() + } + + /** + * Checks that the [ComponentMatcher.NAV_BAR] window is visible during the whole transition + * + * Note: Phones only + */ + open fun navBarWindowIsAlwaysVisible() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarWindowIsAlwaysVisible() + } + + /** + * Checks that the [ComponentMatcher.TASK_BAR] layer is visible during the whole transition + */ + open fun taskBarLayerIsVisibleAtStartAndEnd() { + Assume.assumeTrue(testSpec.isTablet) + testSpec.taskBarLayerIsVisibleAtStartAndEnd() + } + + /** + * Checks that the [ComponentMatcher.TASK_BAR] window is visible during the whole transition + * + * Note: Large screen only + */ + open fun taskBarWindowIsAlwaysVisible() { + Assume.assumeTrue(testSpec.isTablet) + testSpec.taskBarWindowIsAlwaysVisible() + } + + /** + * Checks that the [ComponentMatcher.STATUS_BAR] layer is visible during the whole transition + */ + open fun statusBarLayerIsVisibleAtStartAndEnd() = + testSpec.statusBarLayerIsVisibleAtStartAndEnd() + + /** + * Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the transition + */ + open fun statusBarLayerPositionAtStartAndEnd() = testSpec.statusBarLayerPositionAtStartAndEnd() + + /** + * Checks that the [ComponentMatcher.STATUS_BAR] window is visible during the whole transition + */ + open fun statusBarWindowIsAlwaysVisible() { + testSpec.statusBarWindowIsAlwaysVisible() + } + + /** + * Checks that all layers that are visible on the trace, are visible for at least 2 + * consecutive entries. + */ + open fun visibleLayersShownMoreThanOneConsecutiveEntry() { + testSpec.assertLayers { + this.visibleLayersShownMoreThanOneConsecutiveEntry() + } + } + + /** + * Checks that all windows that are visible on the trace, are visible for at least 2 + * consecutive entries. + */ + open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { + testSpec.assertWm { + this.visibleWindowsShownMoreThanOneConsecutiveEntry() + } + } +} diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt index 5b073038059c6..67d7aca8db8c4 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt @@ -17,41 +17,38 @@ package com.android.wm.shell.flicker.bubble import android.app.INotificationManager -import android.app.Instrumentation import android.app.NotificationManager import android.content.Context import android.os.ServiceManager import android.view.Surface -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import com.android.server.wm.flicker.Flicker -import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE +import com.android.wm.shell.flicker.BaseTest import com.android.wm.shell.flicker.helpers.LaunchBubbleHelper import org.junit.runners.Parameterized /** * Base configurations for Bubble flicker tests */ -abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { +abstract class BaseBubbleScreen( + testSpec: FlickerTestParameter +) : BaseTest(testSpec) { - protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() protected val context: Context = instrumentation.context protected val testApp = LaunchBubbleHelper(instrumentation) - protected val notifyManager = INotificationManager.Stub.asInterface( + private val notifyManager = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)) - protected val uid = context.packageManager.getApplicationInfo( + private val uid = context.packageManager.getApplicationInfo( testApp.`package`, 0).uid - protected abstract val transition: FlickerBuilder.() -> Unit - @JvmOverloads protected open fun buildTransition( extraSpec: FlickerBuilder.() -> Unit = {} @@ -60,7 +57,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { setup { test { notifyManager.setBubblesAllowed(testApp.`package`, - uid, NotificationManager.BUBBLE_PREFERENCE_ALL) + uid, NotificationManager.BUBBLE_PREFERENCE_ALL) testApp.launchViaIntent(wmHelper) waitAndGetAddBubbleBtn() waitAndGetCancelAllBtn() @@ -84,13 +81,6 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { protected fun Flicker.waitAndGetCancelAllBtn(): UiObject2? = device.wait(Until.findObject( By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - transition(this) - } - } - companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt index 7419680379bda..5e84d05f94a2b 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/DismissBubbleScreen.kt @@ -18,6 +18,7 @@ package com.android.wm.shell.flicker.bubble import android.content.Context import android.graphics.Point +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.util.DisplayMetrics import android.view.WindowManager @@ -49,6 +50,7 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree private val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager private val displaySize = DisplayMetrics() + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition { setup { @@ -58,10 +60,13 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree } } transitions { - wm.run { wm.getDefaultDisplay().getMetrics(displaySize) } + wm.run { wm.defaultDisplay.getMetrics(displaySize) } val dist = Point((displaySize.widthPixels / 2), displaySize.heightPixels) - val showBubble = device.wait(Until.findObject( - By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME)), FIND_OBJECT_TIMEOUT) + val showBubble = device.wait( + Until.findObject( + By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) + ), FIND_OBJECT_TIMEOUT + ) showBubble?.run { drag(dist, 1000) } ?: error("Show bubble not found") } } @@ -73,4 +78,70 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree this.isVisible(testApp) } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt index d65485c18a3fb..794a30457600a 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/ExpandBubbleScreen.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.bubble +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By @@ -44,6 +45,7 @@ import org.junit.runners.Parameterized @Group4 open class ExpandBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition { setup { @@ -53,8 +55,11 @@ open class ExpandBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen } } transitions { - val showBubble = device.wait(Until.findObject( - By.res("com.android.systemui", "bubble_view")), FIND_OBJECT_TIMEOUT) + val showBubble = device.wait( + Until.findObject( + By.res("com.android.systemui", "bubble_view") + ), FIND_OBJECT_TIMEOUT + ) showBubble?.run { showBubble.click() } ?: error("Bubble notify not found") } } @@ -66,4 +71,70 @@ open class ExpandBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen this.isVisible(testApp) } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt index ca049f7acb1c4..3700ce2deaa97 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt @@ -17,6 +17,7 @@ package com.android.wm.shell.flicker.bubble import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.WindowInsets import android.view.WindowManager @@ -47,6 +48,7 @@ import org.junit.runners.Parameterized @Group4 class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition { setup { @@ -66,18 +68,25 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr ?: error("Unable to obtain WM service") val metricInsets = wm.currentWindowMetrics.windowInsets val insets = metricInsets.getInsetsIgnoringVisibility( - WindowInsets.Type.statusBars() - or WindowInsets.Type.displayCutout()) + WindowInsets.Type.statusBars() + or WindowInsets.Type.displayCutout() + ) device.swipe(100, insets.top + 100, 100, device.displayHeight / 2, 4) device.waitForIdle(2000) instrumentation.uiAutomation.syncInputTransactions() - val notification = device.wait(Until.findObject( - By.text("BubbleChat")), FIND_OBJECT_TIMEOUT) + val notification = device.wait( + Until.findObject( + By.text("BubbleChat") + ), FIND_OBJECT_TIMEOUT + ) notification?.click() ?: error("Notification not found") instrumentation.uiAutomation.syncInputTransactions() - val showBubble = device.wait(Until.findObject( - By.res("com.android.systemui", "bubble_view")), FIND_OBJECT_TIMEOUT) + val showBubble = device.wait( + Until.findObject( + By.res("com.android.systemui", "bubble_view") + ), FIND_OBJECT_TIMEOUT + ) showBubble?.click() ?: error("Bubble notify not found") instrumentation.uiAutomation.syncInputTransactions() val cancelAllBtn = waitAndGetCancelAllBtn() @@ -102,4 +111,70 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr this.isVisible(testApp) } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt index cf25ce09a229b..af1d7bad5007b 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleScreen.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.bubble +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.platform.test.annotations.RequiresDevice import com.android.server.wm.flicker.FlickerParametersRunnerFactory @@ -41,6 +42,7 @@ import org.junit.runners.Parameterized @Group4 open class LaunchBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition { transitions { @@ -56,4 +58,70 @@ open class LaunchBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen this.isVisible(testApp) } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt index 3c113a7adb6ab..a558450f4ed89 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/MultiBubblesScreen.kt @@ -17,6 +17,7 @@ package com.android.wm.shell.flicker.bubble import android.os.SystemClock +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By @@ -51,6 +52,7 @@ open class MultiBubblesScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen Assume.assumeFalse(isShellTransitionsEnabled) } + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition { setup { @@ -59,15 +61,21 @@ open class MultiBubblesScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen val addBubbleBtn = waitAndGetAddBubbleBtn() addBubbleBtn?.run { addBubbleBtn.click() } ?: error("Add Bubble not found") } - val showBubble = device.wait(Until.findObject( - By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME)), FIND_OBJECT_TIMEOUT) + val showBubble = device.wait( + Until.findObject( + By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) + ), FIND_OBJECT_TIMEOUT + ) showBubble?.run { showBubble.click() } ?: error("Show bubble not found") SystemClock.sleep(1000) } } transitions { - val bubbles = device.wait(Until.findObjects( - By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME)), FIND_OBJECT_TIMEOUT) + val bubbles = device.wait( + Until.findObjects( + By.res(SYSTEM_UI_PACKAGE, BUBBLE_RES_NAME) + ), FIND_OBJECT_TIMEOUT + ) for (entry in bubbles) { entry?.run { entry.click() } ?: error("Bubble not found") SystemClock.sleep(1000) @@ -82,4 +90,70 @@ open class MultiBubblesScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen this.isVisible(testApp) } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt index 3ff7a6d43dbd0..87fa548e8027d 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipOnGoToHomeTest.kt @@ -17,8 +17,8 @@ package com.android.wm.shell.flicker.pip import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import androidx.test.filters.RequiresDevice -import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.annotation.Group3 @@ -54,7 +54,6 @@ import org.junit.runners.Parameterized @FlakyTest(bugId = 238367575) @Group3 class AutoEnterPipOnGoToHomeTest(testSpec: FlickerTestParameter) : EnterPipTest(testSpec) { - protected val taplInstrumentation = LauncherInstrumentation() /** * Defines the transition used to run the test */ @@ -75,10 +74,11 @@ class AutoEnterPipOnGoToHomeTest(testSpec: FlickerTestParameter) : EnterPipTest( } } transitions { - taplInstrumentation.goHome() + tapl.goHome() } } + @Test override fun pipLayerReduces() { testSpec.assertLayers { val pipLayerList = this.layers { pipApp.layerMatchesAnyOf(it) && it.isVisible } @@ -106,9 +106,66 @@ class AutoEnterPipOnGoToHomeTest(testSpec: FlickerTestParameter) : EnterPipTest( } } + @Test override fun focusChanges() { // in gestural nav the focus goes to different activity on swipe up Assume.assumeFalse(testSpec.isGesturalNavigation) super.focusChanges() } + + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + @Postsubmit + @Test + override fun pipAppLayerAlwaysVisible() = super.pipAppLayerAlwaysVisible() + + @Postsubmit + @Test + override fun pipLayerRemainInsideVisibleBounds() = super.pipLayerRemainInsideVisibleBounds() + + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() } 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 ce8cbc0c35382..25b1dd901b6b5 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 @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.pip +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import androidx.test.filters.RequiresDevice @@ -55,9 +56,7 @@ import org.junit.runners.Parameterized @Group3 open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec) { - /** - * Defines the transition used to run the test - */ + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setupAndTeardown(this) @@ -174,6 +173,65 @@ open class EnterPipTest(testSpec: FlickerTestParameter) : PipTransition(testSpec } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + companion object { /** * Creates the test configurations. diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientationTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientationTest.kt index 5074e37a2061e..f486f257e6795 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientationTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/EnterPipToOtherOrientationTest.kt @@ -16,7 +16,9 @@ package com.android.wm.shell.flicker.pip +import android.app.Activity import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import androidx.test.filters.RequiresDevice @@ -27,12 +29,15 @@ import com.android.server.wm.flicker.annotation.Group3 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.WindowUtils -import com.android.server.wm.flicker.navBarLayerRotatesAndScales +import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd +import com.android.server.wm.traces.common.ComponentMatcher import com.android.wm.shell.flicker.helpers.FixedAppHelper import com.android.wm.shell.flicker.pip.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_LANDSCAPE import com.android.wm.shell.flicker.pip.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_PORTRAIT import com.android.wm.shell.flicker.testapp.Components.FixedActivity.EXTRA_FIXED_ORIENTATION import com.android.wm.shell.flicker.testapp.Components.PipActivity.ACTION_ENTER_PIP +import org.junit.Assume +import org.junit.Before import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -79,11 +84,17 @@ class EnterPipToOtherOrientationTest( setup { eachRun { // Launch a portrait only app on the fullscreen stack - testApp.launchViaIntent(wmHelper, stringExtras = mapOf( - EXTRA_FIXED_ORIENTATION to ORIENTATION_PORTRAIT.toString())) + testApp.launchViaIntent( + wmHelper, stringExtras = mapOf( + EXTRA_FIXED_ORIENTATION to ORIENTATION_PORTRAIT.toString() + ) + ) // Launch the PiP activity fixed as landscape - pipApp.launchViaIntent(wmHelper, stringExtras = mapOf( - EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString())) + pipApp.launchViaIntent( + wmHelper, stringExtras = mapOf( + EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString() + ) + ) } } teardown { @@ -99,19 +110,28 @@ class EnterPipToOtherOrientationTest( // during rotation the status bar becomes invisible and reappears at the end wmHelper.StateSyncBuilder() .withPipShown() - .withAppTransitionIdle() - .withNavBarStatusBarVisible() + .withNavOrTaskBarVisible() + .withStatusBarVisible() .waitForAndVerify() } } + /** + * This test is not compatible with Tablets. When using [Activity.setRequestedOrientation] + * to fix a orientation, Tablets instead keep the same orientation and add letterboxes + */ + @Before + fun setup() { + Assume.assumeFalse(testSpec.isTablet) + } + /** * Checks that the [ComponentMatcher.NAV_BAR] has the correct position at * the start and end of the transition */ @FlakyTest @Test - override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = testSpec.navBarLayerPositionAtStartAndEnd() /** * Checks that all parts of the screen are covered at the start and end of the transition @@ -120,7 +140,7 @@ class EnterPipToOtherOrientationTest( */ @Presubmit @Test - override fun entireScreenCovered() = testSpec.entireScreenCovered(allStates = false) + fun entireScreenCoveredAtStartAndEnd() = testSpec.entireScreenCovered(allStates = false) /** * Checks [pipApp] window remains visible and on top throughout the transition @@ -204,6 +224,60 @@ class EnterPipToOtherOrientationTest( } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @FlakyTest(bugId = 197726599) + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + companion object { /** * Creates the test configurations. @@ -215,8 +289,10 @@ class EnterPipToOtherOrientationTest( @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0), - repetitions = 3) + .getConfigNonRotationTests( + supportedRotations = listOf(Surface.ROTATION_0), + repetitions = 3 + ) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt index 7b9506f269f6a..6a86a14070bb8 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipToAppTransition.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.pip +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import com.android.server.wm.flicker.FlickerTestParameter import com.android.wm.shell.flicker.helpers.FixedAppHelper @@ -63,10 +64,10 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans // the window, sometimes in the same entry. This occurs because we log 1x per frame // thus we ignore activity here isAppWindowVisible(testApp) - .isAppWindowOnTop(pipApp) - .then() - .isAppWindowInvisible(testApp) - .isAppWindowVisible(pipApp) + .isAppWindowOnTop(pipApp) + .then() + .isAppWindowInvisible(testApp) + .isAppWindowVisible(pipApp) } } @@ -79,10 +80,10 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans open fun showBothAppLayersThenHidePip() { testSpec.assertLayers { isVisible(testApp) - .isVisible(pipApp) - .then() - .isInvisible(testApp) - .isVisible(pipApp) + .isVisible(pipApp) + .then() + .isInvisible(testApp) + .isVisible(pipApp) } } @@ -96,8 +97,8 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans testSpec.assertLayersStart { val pipRegion = visibleRegion(pipApp).region visibleRegion(testApp) - .plus(pipRegion) - .coversExactly(displayBounds) + .plus(pipRegion) + .coversExactly(displayBounds) } } @@ -126,4 +127,63 @@ abstract class ExitPipToAppTransition(testSpec: FlickerTestParameter) : PipTrans } } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt index e631e18a33e9c..33f7871828682 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipTransition.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.pip +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import com.android.server.wm.flicker.FlickerTestParameter @@ -93,4 +94,63 @@ abstract class ExitPipTransition(testSpec: FlickerTestParameter) : PipTransition .isVisible(LAUNCHER) } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt index 845f1d7402bc9..685f4584c92cb 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipViaIntentTest.kt @@ -82,16 +82,16 @@ class ExitPipViaIntentTest(testSpec: FlickerTestParameter) : ExitPipToAppTransit /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun statusBarLayerRotatesScales() { + override fun statusBarLayerPositionAtStartAndEnd() { Assume.assumeFalse(isShellTransitionsEnabled) - super.statusBarLayerRotatesScales() + super.statusBarLayerPositionAtStartAndEnd() } @Presubmit @Test fun statusBarLayerRotatesScales_ShellTransit() { Assume.assumeTrue(isShellTransitionsEnabled) - super.statusBarLayerRotatesScales() + super.statusBarLayerPositionAtStartAndEnd() } /** {@inheritDoc} */ diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt index 3ab6862a9253d..5b5b9fc174f67 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExitPipWithSwipeDownTest.kt @@ -24,6 +24,7 @@ import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group3 import com.android.server.wm.flicker.dsl.FlickerBuilder +import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -61,7 +62,18 @@ class ExitPipWithSwipeDownTest(testSpec: FlickerTestParameter) : ExitPipTransiti val pipCenterX = pipRegion.centerX() val pipCenterY = pipRegion.centerY() val displayCenterX = device.displayWidth / 2 - device.swipe(pipCenterX, pipCenterY, displayCenterX, device.displayHeight, 10) + val barComponent = if (testSpec.isTablet) { + ComponentMatcher.TASK_BAR + } else { + ComponentMatcher.NAV_BAR + } + val barLayerHeight = wmHelper.currentState.layerState + .getLayerWithBuffer(barComponent) + ?.visibleRegion + ?.height ?: error("Couldn't find Nav or Task bar layer") + // The dismiss button doesn't appear at the complete bottom of the screen, + val displayY = device.displayHeight - barLayerHeight + device.swipe(pipCenterX, pipCenterY, displayCenterX, displayY, 50) // Wait until the other app is no longer visible wmHelper.StateSyncBuilder() .withPipGone() diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt index 1557a8d5052bf..430d5ae351624 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/ExpandPipOnDoubleClickTest.kt @@ -17,6 +17,7 @@ package com.android.wm.shell.flicker.pip import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import androidx.test.filters.RequiresDevice @@ -166,6 +167,65 @@ class ExpandPipOnDoubleClickTest(testSpec: FlickerTestParameter) : PipTransition } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + companion object { /** * Creates the test configurations. @@ -177,8 +237,10 @@ class ExpandPipOnDoubleClickTest(testSpec: FlickerTestParameter) : PipTransition @JvmStatic fun getParams(): List { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0), - repetitions = 3) + .getConfigNonRotationTests( + supportedRotations = listOf(Surface.ROTATION_0), + repetitions = 3 + ) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt index 768c0905b4738..b3f0fb91ab73f 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipDownShelfHeightChangeTest.kt @@ -70,7 +70,7 @@ open class MovePipDownShelfHeightChangeTest( } } transitions { - taplInstrumentation.pressHome() + tapl.pressHome() } } @@ -89,7 +89,8 @@ open class MovePipDownShelfHeightChangeTest( @JvmStatic fun getParams(): List { return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( - supportedRotations = listOf(Surface.ROTATION_0), repetitions = 3) + supportedRotations = listOf(Surface.ROTATION_0), repetitions = 3 + ) } } } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt index d0f36f17721e2..895158b4812ca 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipShelfHeightTransition.kt @@ -16,8 +16,8 @@ package com.android.wm.shell.flicker.pip +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit -import com.android.launcher3.tapl.LauncherInstrumentation import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.traces.region.RegionSubject import com.android.wm.shell.flicker.helpers.FixedAppHelper @@ -29,7 +29,6 @@ import org.junit.Test abstract class MovePipShelfHeightTransition( testSpec: FlickerTestParameter ) : PipTransition(testSpec) { - protected val taplInstrumentation = LauncherInstrumentation() protected val testApp = FixedAppHelper(instrumentation) /** @@ -111,4 +110,63 @@ abstract class MovePipShelfHeightTransition( } } } + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt index 4bc8eb13e26f0..8bd5c548f6bdd 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/MovePipUpShelfHeightChangeTest.kt @@ -73,7 +73,7 @@ class MovePipUpShelfHeightChangeTest( get() = buildTransition(eachRun = false) { teardown { eachRun { - taplInstrumentation.pressHome() + tapl.pressHome() } test { testApp.exit(wmHelper) @@ -91,7 +91,8 @@ class MovePipUpShelfHeightChangeTest( /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() companion object { /** @@ -104,7 +105,8 @@ class MovePipUpShelfHeightChangeTest( @JvmStatic fun getParams(): List { return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests( - supportedRotations = listOf(Surface.ROTATION_0), repetitions = 3) + supportedRotations = listOf(Surface.ROTATION_0), repetitions = 3 + ) } } } 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 90f73dd61f38b..3d9950aa3240b 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 @@ -16,6 +16,8 @@ package com.android.wm.shell.flicker.pip +import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import androidx.test.filters.RequiresDevice @@ -54,6 +56,7 @@ open class PipKeyboardTest(testSpec: FlickerTestParameter) : PipTransition(testS assumeFalse(isShellTransitionsEnabled) } + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = buildTransition(eachRun = false) { setup { @@ -78,6 +81,12 @@ open class PipKeyboardTest(testSpec: FlickerTestParameter) : PipTransition(testS } } + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + /** * Ensure the pip window remains visible throughout any keyboard interactions */ @@ -101,6 +110,59 @@ open class PipKeyboardTest(testSpec: FlickerTestParameter) : PipTransition(testS } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + companion object { private const val TAG_IME_VISIBLE = "imeIsVisible" diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt index fe51228230cb9..3e00b19e2f191 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipKeyboardTestShellTransit.kt @@ -44,5 +44,6 @@ class PipKeyboardTestShellTransit(testSpec: FlickerTestParameter) : PipKeyboardT @Presubmit @Test - override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales() -} \ No newline at end of file + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() +} 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 e6f0d111825a0..3326802dfe374 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 @@ -28,7 +28,6 @@ import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.helpers.setRotation -import com.android.server.wm.flicker.navBarLayerRotatesAndScales import com.android.wm.shell.flicker.helpers.FixedAppHelper import org.junit.FixMethodOrder import org.junit.Test @@ -92,7 +91,7 @@ open class PipRotationTest(testSpec: FlickerTestParameter) : PipTransition(testS */ @FlakyTest @Test - override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** * Checks that [fixedApp] layer is within [screenBoundsStart] at the start of the transition diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTestBase.kt deleted file mode 100644 index 7ba085d3cf1a5..0000000000000 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTestBase.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.wm.shell.flicker.pip - -import com.android.wm.shell.flicker.FlickerTestBase -import com.android.wm.shell.flicker.helpers.PipAppHelper -import org.junit.Before - -abstract class PipTestBase( - rotationName: String, - rotation: Int -) : FlickerTestBase(rotationName, rotation) { - protected val testApp = PipAppHelper(instrumentation) - - @Before - override fun televisionSetUp() { - /** - * The super implementation assumes ([org.junit.Assume]) that not running on TV, thus - * disabling the test on TV. This test, however, *should run on TV*, so we overriding this - * method and simply leaving it blank. - */ - } -} diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt index fe5dd8b83cfb9..9ade597837005 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/PipTransition.kt @@ -18,35 +18,22 @@ package com.android.wm.shell.flicker.pip import android.app.Instrumentation import android.content.Intent -import android.platform.test.annotations.Presubmit import android.view.Surface -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible import com.android.server.wm.flicker.rules.RemoveAllTasksButHomeRule.Companion.removeAllTasksButHome -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible +import com.android.wm.shell.flicker.BaseTest import com.android.wm.shell.flicker.helpers.PipAppHelper import com.android.wm.shell.flicker.testapp.Components -import org.junit.Test -abstract class PipTransition(protected val testSpec: FlickerTestParameter) { - protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - protected val tapl = LauncherInstrumentation() +abstract class PipTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec) { protected val pipApp = PipAppHelper(instrumentation) protected val displayBounds = WindowUtils.getDisplayBounds(testSpec.startRotation) protected val broadcastActionTrigger = BroadcastActionTrigger(instrumentation) - protected abstract val transition: FlickerBuilder.() -> Unit + // Helper class to process test actions by broadcast. protected class BroadcastActionTrigger(private val instrumentation: Instrumentation) { private fun createIntentWithAction(broadcastAction: String): Intent { @@ -69,13 +56,6 @@ abstract class PipTransition(protected val testSpec: FlickerTestParameter) { } } - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - transition(this) - } - } - /** * Gets a configuration that handles basic setup and teardown of pip tests */ @@ -143,32 +123,4 @@ abstract class PipTransition(protected val testSpec: FlickerTestParameter) { extraSpec(this) } } - - @Presubmit - @Test - open fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() - - @Presubmit - @Test - open fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() - - @Presubmit - @Test - open fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - open fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() - - @Presubmit - @Test - open fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - @Presubmit - @Test - open fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - @Presubmit - @Test - open fun entireScreenCovered() = testSpec.entireScreenCovered() } diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt index b7b063fd6b171..6d64cb9e0deea 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/SetRequestedOrientationWhilePinnedTest.kt @@ -16,7 +16,9 @@ package com.android.wm.shell.flicker.pip +import android.app.Activity import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import androidx.test.filters.RequiresDevice @@ -32,6 +34,8 @@ import com.android.server.wm.flicker.rules.RemoveAllTasksButHomeRule.Companion.r import com.android.wm.shell.flicker.pip.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_LANDSCAPE import com.android.wm.shell.flicker.testapp.Components import com.android.wm.shell.flicker.testapp.Components.FixedActivity.EXTRA_FIXED_ORIENTATION +import org.junit.Assume +import org.junit.Before import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -53,6 +57,7 @@ open class SetRequestedOrientationWhilePinnedTest( private val startingBounds = WindowUtils.getDisplayBounds(Surface.ROTATION_0) private val endingBounds = WindowUtils.getDisplayBounds(Surface.ROTATION_90) + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setup { @@ -70,7 +75,8 @@ open class SetRequestedOrientationWhilePinnedTest( wmHelper.StateSyncBuilder() .withPipShown() .withRotation(Surface.ROTATION_0) - .withNavBarStatusBarVisible() + .withNavOrTaskBarVisible() + .withStatusBarVisible() .waitForAndVerify() } } @@ -90,12 +96,21 @@ open class SetRequestedOrientationWhilePinnedTest( wmHelper.StateSyncBuilder() .withFullScreenApp(pipApp) .withRotation(Surface.ROTATION_90) - .withAppTransitionIdle() - .withNavBarStatusBarVisible() + .withNavOrTaskBarVisible() + .withStatusBarVisible() .waitForAndVerify() } } + /** + * This test is not compatible with Tablets. When using [Activity.setRequestedOrientation] + * to fix a orientation, Tablets instead keep the same orientation and add letterboxes + */ + @Before + fun setup() { + Assume.assumeFalse(testSpec.isTablet) + } + @Presubmit @Test fun displayEndsAt90Degrees() { @@ -104,17 +119,21 @@ open class SetRequestedOrientationWhilePinnedTest( } } + /** {@inheritDoc} */ @Presubmit @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + /** {@inheritDoc} */ @Presubmit @Test - override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible() + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + /** {@inheritDoc} */ @FlakyTest @Test - override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() @Presubmit @Test @@ -156,6 +175,50 @@ open class SetRequestedOrientationWhilePinnedTest( } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/FlickerTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipTestBase.kt similarity index 60% rename from libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/FlickerTestBase.kt rename to libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipTestBase.kt index 9c50630095be8..180ced0a68147 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/FlickerTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/PipTestBase.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 The Android Open Source Project + * Copyright (C) 2022 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. @@ -14,29 +14,18 @@ * limitations under the License. */ -package com.android.wm.shell.flicker +package com.android.wm.shell.flicker.pip.tv import android.app.Instrumentation import android.content.pm.PackageManager -import android.content.pm.PackageManager.FEATURE_LEANBACK -import android.content.pm.PackageManager.FEATURE_LEANBACK_ONLY import android.view.Surface import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice -import org.junit.Assume.assumeFalse +import com.android.wm.shell.flicker.helpers.PipAppHelper import org.junit.Before import org.junit.runners.Parameterized -/** - * Base class of all Flicker test that performs common functions for all flicker tests: - * - * - Caches transitions so that a transition is run once and the transition results are used by - * tests multiple times. This is needed for parameterized tests which call the BeforeClass methods - * multiple times. - * - Keeps track of all test artifacts and deletes ones which do not need to be reviewed. - * - Fails tests if results are not available for any test due to jank. - */ -abstract class FlickerTestBase( +abstract class PipTestBase( protected val rotationName: String, protected val rotation: Int ) { @@ -45,16 +34,20 @@ abstract class FlickerTestBase( val packageManager: PackageManager = instrumentation.context.packageManager protected val isTelevision: Boolean by lazy { packageManager.run { - hasSystemFeature(FEATURE_LEANBACK) || hasSystemFeature(FEATURE_LEANBACK_ONLY) + hasSystemFeature(PackageManager.FEATURE_LEANBACK) || + hasSystemFeature(PackageManager.FEATURE_LEANBACK_ONLY) } } + protected val testApp = PipAppHelper(instrumentation) - /** - * By default WmShellFlickerTests do not run on TV devices. - * If the test should run on TV - it should override this method. - */ @Before - open fun televisionSetUp() = assumeFalse(isTelevision) + open fun televisionSetUp() { + /** + * The super implementation assumes ([org.junit.Assume]) that not running on TV, thus + * disabling the test on TV. This test, however, *should run on TV*, so we overriding this + * method and simply leaving it blank. + */ + } companion object { @Parameterized.Parameters(name = "{0}") diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt index a97994e7d6c36..aeff0ac9f4f2f 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/tv/TvPipTestBase.kt @@ -25,7 +25,6 @@ import android.view.Surface.rotationToString import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper import com.android.wm.shell.flicker.SYSTEM_UI_PACKAGE_NAME -import com.android.wm.shell.flicker.pip.PipTestBase import org.junit.After import org.junit.Assert.assertFalse import org.junit.Assume.assumeTrue diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromAllApps.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromAllApps.kt index 6910e53d326df..779be0ad95e36 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromAllApps.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromAllApps.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.splitscreen +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice @@ -57,7 +58,7 @@ class EnterSplitScreenByDragFromAllApps( @Before fun before() { - Assume.assumeTrue(taplInstrumentation.isTablet) + Assume.assumeTrue(tapl.isTablet) } override val transition: FlickerBuilder.() -> Unit @@ -65,12 +66,12 @@ class EnterSplitScreenByDragFromAllApps( super.transition(this) setup { eachRun { - taplInstrumentation.goHome() + tapl.goHome() primaryApp.launchViaIntent(wmHelper) } } transitions { - taplInstrumentation.launchedAppState.taskbar + tapl.launchedAppState.taskbar .openAllApps() .getAppIcon(secondaryApp.appName) .dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`) @@ -108,6 +109,72 @@ class EnterSplitScreenByDragFromAllApps( fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(secondaryApp) + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt index 15f77d21d4bfa..d47d81b4287a4 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromNotification.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.splitscreen +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice @@ -60,9 +61,10 @@ class EnterSplitScreenByDragFromNotification( @Before fun before() { - Assume.assumeTrue(taplInstrumentation.isTablet) + Assume.assumeTrue(tapl.isTablet) } + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) @@ -76,7 +78,7 @@ class EnterSplitScreenByDragFromNotification( ) sendNotification?.click() ?: error("Send notification button not found") - taplInstrumentation.goHome() + tapl.goHome() primaryApp.launchViaIntent(wmHelper) } } @@ -124,6 +126,72 @@ class EnterSplitScreenByDragFromNotification( fun secondaryAppWindowIsVisibleAtEnd() = testSpec.appWindowIsVisibleAtEnd(sendNotificationApp) + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt index a4d33e94ed80e..1493d1fd3cced 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/EnterSplitScreenByDragFromTaskbar.kt @@ -16,6 +16,7 @@ package com.android.wm.shell.flicker.splitscreen +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice @@ -57,23 +58,24 @@ class EnterSplitScreenByDragFromTaskbar( @Before fun before() { - Assume.assumeTrue(taplInstrumentation.isTablet) + Assume.assumeTrue(tapl.isTablet) } + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) setup { eachRun { - taplInstrumentation.goHome() + tapl.goHome() SplitScreenHelper.createShortcutOnHotseatIfNotExist( - taplInstrumentation, secondaryApp.appName + tapl, secondaryApp.appName ) primaryApp.launchViaIntent(wmHelper) } } transitions { - taplInstrumentation.launchedAppState.taskbar + tapl.launchedAppState.taskbar .getAppIcon(secondaryApp.appName) .dragToSplitscreen( secondaryApp.`package`, @@ -115,6 +117,72 @@ class EnterSplitScreenByDragFromTaskbar( fun secondaryAppWindowBecomesVisible() = testSpec.appWindowBecomesVisible(secondaryApp) + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = + super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = + super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = + super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = + super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenBase.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenBase.kt index 52c2daf96a3c5..81390b243ef9d 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenBase.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenBase.kt @@ -16,37 +16,26 @@ package com.android.wm.shell.flicker.splitscreen -import android.app.Instrumentation import android.content.Context -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.setRotation +import com.android.wm.shell.flicker.BaseTest import com.android.wm.shell.flicker.helpers.SplitScreenHelper -abstract class SplitScreenBase(protected val testSpec: FlickerTestParameter) { - protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - protected val taplInstrumentation = LauncherInstrumentation() +abstract class SplitScreenBase(testSpec: FlickerTestParameter) : BaseTest(testSpec) { protected val context: Context = instrumentation.context protected val primaryApp = SplitScreenHelper.getPrimary(instrumentation) protected val secondaryApp = SplitScreenHelper.getSecondary(instrumentation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - transition(this) - } - } - - protected open val transition: FlickerBuilder.() -> Unit + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit get() = { setup { test { - taplInstrumentation.setEnableRotation(true) + tapl.setEnableRotation(true) setRotation(testSpec.startRotation) - taplInstrumentation.setExpectedRotation(testSpec.startRotation) + tapl.setExpectedRotation(testSpec.startRotation) } } teardown { diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/BaseTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/BaseTest.kt new file mode 100644 index 0000000000000..24c46619d3760 --- /dev/null +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/BaseTest.kt @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2022 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 + +import android.app.Instrumentation +import android.platform.test.annotations.Presubmit +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.tapl.LauncherInstrumentation +import com.android.server.wm.flicker.dsl.FlickerBuilder +import com.android.server.wm.traces.common.ComponentMatcher +import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper +import org.junit.Assume +import org.junit.Test + +/** + * Base test class containing common assertions for [ComponentMatcher.NAV_BAR], + * [ComponentMatcher.TASK_BAR], [ComponentMatcher.STATUS_BAR], and general assertions + * (layers visible in consecutive states, entire screen covered, etc.) + */ +abstract class BaseTest @JvmOverloads constructor( + protected val testSpec: FlickerTestParameter, + protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), + protected val tapl: LauncherInstrumentation = LauncherInstrumentation() +) { + init { + testSpec.setIsTablet( + WindowManagerStateHelper(instrumentation).currentState.wmState.isTablet + ) + } + + /** + * Specification of the test transition to execute + */ + abstract val transition: FlickerBuilder.() -> Unit + + /** + * Entry point for the test runner. It will use this method to initialize and cache + * flicker executions + */ + @FlickerBuilderProvider + fun buildFlicker(): FlickerBuilder { + return FlickerBuilder(instrumentation).apply { + setup { + test { + testSpec.setIsTablet(wmHelper.currentState.wmState.isTablet) + } + } + transition() + } + } + + /** + * Checks that all parts of the screen are covered during the transition + */ + @Presubmit + @Test + open fun entireScreenCovered() = testSpec.entireScreenCovered() + + /** + * Checks that the [ComponentMatcher.NAV_BAR] layer is visible during the whole transition + * + * Note: Phones only + */ + @Presubmit + @Test + open fun navBarLayerIsVisibleAtStartAndEnd() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarLayerIsVisibleAtStartAndEnd() + } + + /** + * Checks the position of the [ComponentMatcher.NAV_BAR] at the start and end of the transition + * + * Note: Phones only + */ + @Presubmit + @Test + open fun navBarLayerPositionAtStartAndEnd() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarLayerPositionAtStartAndEnd() + } + + /** + * Checks that the [ComponentMatcher.NAV_BAR] window is visible during the whole transition + * + * Note: Phones only + */ + @Presubmit + @Test + open fun navBarWindowIsAlwaysVisible() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarWindowIsAlwaysVisible() + } + + /** + * Checks that the [ComponentMatcher.TASK_BAR] layer is visible during the whole transition + * + * Note: Large screen only + */ + @Presubmit + @Test + open fun taskBarLayerIsVisibleAtStartAndEnd() { + Assume.assumeTrue(testSpec.isTablet) + testSpec.taskBarLayerIsVisibleAtStartAndEnd() + } + + /** + * Checks that the [ComponentMatcher.TASK_BAR] window is visible during the whole transition + * + * Note: Large screen only + */ + @Presubmit + @Test + open fun taskBarWindowIsAlwaysVisible() { + Assume.assumeTrue(testSpec.isTablet) + testSpec.taskBarWindowIsAlwaysVisible() + } + + /** + * Checks that the [ComponentMatcher.STATUS_BAR] layer is visible during the whole transition + */ + @Presubmit + @Test + open fun statusBarLayerIsVisibleAtStartAndEnd() = + testSpec.statusBarLayerIsVisibleAtStartAndEnd() + + /** + * Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the + * transition + */ + @Presubmit + @Test + open fun statusBarLayerPositionAtStartAndEnd() = testSpec.statusBarLayerPositionAtStartAndEnd() + + /** + * Checks that the [ComponentMatcher.STATUS_BAR] window is visible during the whole transition + */ + @Presubmit + @Test + open fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible() + + /** + * Checks that all layers that are visible on the trace, are visible for at least 2 + * consecutive entries. + */ + @Presubmit + @Test + open fun visibleLayersShownMoreThanOneConsecutiveEntry() { + testSpec.assertLayers { + this.visibleLayersShownMoreThanOneConsecutiveEntry() + } + } + + /** + * Checks that all windows that are visible on the trace, are visible for at least 2 + * consecutive entries. + */ + @Presubmit + @Test + open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { + testSpec.assertWm { + this.visibleWindowsShownMoreThanOneConsecutiveEntry() + } + } +} 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 24df51c40f8f2..d173b7250548c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/CommonAssertions.kt @@ -26,7 +26,7 @@ import com.android.server.wm.traces.common.IComponentMatcher * Checks that [ComponentMatcher.STATUS_BAR] window is visible and above the app windows in * all WM trace entries */ -fun FlickerTestParameter.statusBarWindowIsVisible() { +fun FlickerTestParameter.statusBarWindowIsAlwaysVisible() { assertWm { this.isAboveAppWindowVisible(ComponentMatcher.STATUS_BAR) } @@ -36,12 +36,22 @@ fun FlickerTestParameter.statusBarWindowIsVisible() { * Checks that [ComponentMatcher.NAV_BAR] window is visible and above the app windows in * all WM trace entries */ -fun FlickerTestParameter.navBarWindowIsVisible() { +fun FlickerTestParameter.navBarWindowIsAlwaysVisible() { assertWm { this.isAboveAppWindowVisible(ComponentMatcher.NAV_BAR) } } +/** + * Checks that [ComponentMatcher.TASK_BAR] window is visible and above the app windows in + * all WM trace entries + */ +fun FlickerTestParameter.taskBarWindowIsAlwaysVisible() { + assertWm { + this.isAboveAppWindowVisible(ComponentMatcher.TASK_BAR) + } +} + /** * If [allStates] is true, checks if the stack space of all displays is fully covered * by any visible layer, during the whole transitions @@ -79,7 +89,7 @@ fun FlickerTestParameter.entireScreenCovered(allStates: Boolean = true) { * Checks that [ComponentMatcher.NAV_BAR] layer is visible at the start and end of the SF * trace */ -fun FlickerTestParameter.navBarLayerIsVisible() { +fun FlickerTestParameter.navBarLayerIsVisibleAtStartAndEnd() { assertLayersStart { this.isVisible(ComponentMatcher.NAV_BAR) } @@ -88,11 +98,24 @@ fun FlickerTestParameter.navBarLayerIsVisible() { } } +/** + * Checks that [ComponentMatcher.TASK_BAR] layer is visible at the start and end of the SF + * trace + */ +fun FlickerTestParameter.taskBarLayerIsVisibleAtStartAndEnd() { + assertLayersStart { + this.isVisible(ComponentMatcher.TASK_BAR) + } + assertLayersEnd { + this.isVisible(ComponentMatcher.TASK_BAR) + } +} + /** * Checks that [ComponentMatcher.STATUS_BAR] layer is visible at the start and end of the SF * trace */ -fun FlickerTestParameter.statusBarLayerIsVisible() { +fun FlickerTestParameter.statusBarLayerIsVisibleAtStartAndEnd() { assertLayersStart { this.isVisible(ComponentMatcher.STATUS_BAR) } @@ -105,7 +128,7 @@ fun FlickerTestParameter.statusBarLayerIsVisible() { * Asserts that the [ComponentMatcher.NAV_BAR] layer is at the correct position at the start * of the SF trace */ -fun FlickerTestParameter.navBarLayerPositionStart() { +fun FlickerTestParameter.navBarLayerPositionAtStart() { assertLayersStart { val display = this.entry.displays.firstOrNull { !it.isVirtual } ?: error("There is no display!") @@ -118,7 +141,7 @@ fun FlickerTestParameter.navBarLayerPositionStart() { * Asserts that the [ComponentMatcher.NAV_BAR] layer is at the correct position at the end * of the SF trace */ -fun FlickerTestParameter.navBarLayerPositionEnd() { +fun FlickerTestParameter.navBarLayerPositionAtEnd() { assertLayersEnd { val display = this.entry.displays.minByOrNull { it.id } ?: throw RuntimeException("There is no display!") @@ -131,16 +154,16 @@ fun FlickerTestParameter.navBarLayerPositionEnd() { * Asserts that the [ComponentMatcher.NAV_BAR] layer is at the correct position at the start * and end of the SF trace */ -fun FlickerTestParameter.navBarLayerRotatesAndScales() { - navBarLayerPositionStart() - navBarLayerPositionEnd() +fun FlickerTestParameter.navBarLayerPositionAtStartAndEnd() { + navBarLayerPositionAtStart() + navBarLayerPositionAtEnd() } /** * Asserts that the [ComponentMatcher.STATUS_BAR] layer is at the correct position at the start * of the SF trace */ -fun FlickerTestParameter.statusBarLayerPositionStart() { +fun FlickerTestParameter.statusBarLayerPositionAtStart() { assertLayersStart { val display = this.entry.displays.minByOrNull { it.id } ?: throw RuntimeException("There is no display!") @@ -153,7 +176,7 @@ fun FlickerTestParameter.statusBarLayerPositionStart() { * Asserts that the [ComponentMatcher.STATUS_BAR] layer is at the correct position at the end * of the SF trace */ -fun FlickerTestParameter.statusBarLayerPositionEnd() { +fun FlickerTestParameter.statusBarLayerPositionAtEnd() { assertLayersEnd { val display = this.entry.displays.minByOrNull { it.id } ?: throw RuntimeException("There is no display!") @@ -166,9 +189,9 @@ fun FlickerTestParameter.statusBarLayerPositionEnd() { * Asserts that the [ComponentMatcher.STATUS_BAR] layer is at the correct position at the start * and end of the SF trace */ -fun FlickerTestParameter.statusBarLayerRotatesScales() { - statusBarLayerPositionStart() - statusBarLayerPositionEnd() +fun FlickerTestParameter.statusBarLayerPositionAtStartAndEnd() { + statusBarLayerPositionAtStart() + statusBarLayerPositionAtEnd() } /** 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 d0f1dfddaed02..37b8b4cf4bf23 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 @@ -25,8 +25,7 @@ import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled -import org.junit.Assume.assumeFalse -import org.junit.Assume.assumeTrue +import org.junit.Assume import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -68,6 +67,7 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 class CloseAppBackButtonTest(testSpec: FlickerTestParameter) : CloseAppTransition(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) @@ -82,22 +82,22 @@ class CloseAppBackButtonTest(testSpec: FlickerTestParameter) : CloseAppTransitio /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun statusBarLayerRotatesScales() { + override fun statusBarLayerPositionAtStartAndEnd() { // This test doesn't work in shell transitions because of b/206753786 - assumeFalse(isShellTransitionsEnabled) - super.statusBarLayerRotatesScales() + Assume.assumeFalse(isShellTransitionsEnabled) + super.statusBarLayerPositionAtStartAndEnd() } @FlakyTest(bugId = 214452854) @Test - fun statusBarLayerRotatesScales_shellTransit() { - assumeTrue(isShellTransitionsEnabled) - super.statusBarLayerRotatesScales() + fun statusBarLayerPositionAtStartAndEnd_shellTransit() { + Assume.assumeTrue(isShellTransitionsEnabled) + super.statusBarLayerPositionAtStartAndEnd() } /** {@inheritDoc} */ 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 b178e8c7ecedb..a4c809a7caba7 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 @@ -64,6 +64,7 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 class CloseAppHomeButtonTest(testSpec: FlickerTestParameter) : CloseAppTransition(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) @@ -82,14 +83,13 @@ class CloseAppHomeButtonTest(testSpec: FlickerTestParameter) : CloseAppTransitio /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun statusBarLayerRotatesScales() { - super.statusBarLayerRotatesScales() - } + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest(bugId = 229762973) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt index b166cbab006c5..7ff0934743996 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/close/CloseAppTransition.kt @@ -16,39 +16,25 @@ package com.android.server.wm.flicker.close -import android.app.Instrumentation import android.platform.test.annotations.Presubmit -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.StandardAppHelper import com.android.server.wm.flicker.helpers.setRotation -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible import com.android.server.wm.flicker.replacesLayer -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher.Companion.LAUNCHER import org.junit.Test /** * Base test class for transitions that close an app back to the launcher screen */ -abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter) { - protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +abstract class CloseAppTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec) { protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) - protected val tapl = LauncherInstrumentation() - /** - * Specification of the test transition to execute - */ - protected open val transition: FlickerBuilder.() -> Unit = { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { setup { test { tapl.setExpectedRotation(testSpec.startRotation) @@ -65,98 +51,6 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter) } } - /** - * Entry point for the test runner. It will use this method to initialize and cache - * flicker executions - */ - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - transition() - } - } - - /** - * Checks that the navigation bar window is visible during the whole transition - */ - @Presubmit - @Test - open fun navBarWindowIsVisible() { - testSpec.navBarWindowIsVisible() - } - - /** - * Checks that the status bar window is visible during the whole transition - */ - @Presubmit - @Test - open fun statusBarWindowIsVisible() { - testSpec.statusBarWindowIsVisible() - } - - /** - * Checks that the navigation bar layer is visible during the whole transition - */ - @Presubmit - @Test - open fun navBarLayerIsVisible() { - testSpec.navBarLayerIsVisible() - } - - /** - * Checks that the status bar layer is visible during the whole transition - */ - @Presubmit - @Test - open fun statusBarLayerIsVisible() { - testSpec.statusBarLayerIsVisible() - } - - /** - * Checks the position of the navigation bar at the start and end of the transition - */ - @Presubmit - @Test - open fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - /** - * Checks the position of the status bar at the start and end of the transition - */ - @Presubmit - @Test - open fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - /** - * Checks that all windows that are visible on the trace, are visible for at least 2 - * consecutive entries. - */ - @Presubmit - @Test - open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - } - - /** - * Checks that all layers that are visible on the trace, are visible for at least 2 - * consecutive entries. - */ - @Presubmit - @Test - open fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry() - } - } - - /** - * Checks that all parts of the screen are covered during the transition - */ - @Presubmit - @Test - open fun entireScreenCovered() = testSpec.entireScreenCovered() - /** * Checks that [testApp] is the top visible app window at the start of the transition and * that it is replaced by [LAUNCHER] during the transition @@ -166,8 +60,8 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter) open fun launcherReplacesAppWindowAsTopWindow() { testSpec.assertWm { this.isAppWindowOnTop(testApp) - .then() - .isAppWindowOnTop(LAUNCHER) + .then() + .isAppWindowOnTop(LAUNCHER) } } @@ -180,8 +74,8 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter) open fun launcherWindowBecomesVisible() { testSpec.assertWm { this.isAppWindowNotOnTop(LAUNCHER) - .then() - .isAppWindowOnTop(LAUNCHER) + .then() + .isAppWindowOnTop(LAUNCHER) } } 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 e779b748c6e9b..517570ea55bed 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 @@ -16,27 +16,18 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder import org.junit.Test @@ -61,44 +52,31 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -class CloseImeAutoOpenWindowToAppTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class CloseImeAutoOpenWindowToAppTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - testApp.launchViaIntent(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + testApp.launchViaIntent(wmHelper) } - teardown { - eachRun { - testApp.exit(wmHelper) - } - } - transitions { - testApp.closeIME(wmHelper) + } + teardown { + eachRun { + testApp.exit(wmHelper) } } + transitions { + testApp.closeIME(wmHelper) + } } - @Presubmit + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() - - @Presubmit - @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() - - @Presubmit - @Test - fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - } + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() @Presubmit @Test @@ -108,18 +86,6 @@ class CloseImeAutoOpenWindowToAppTest(private val testSpec: FlickerTestParameter } } - @Presubmit - @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() - - @Presubmit - @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() - @Presubmit @Test fun imeLayerVisibleStart() { @@ -148,33 +114,19 @@ class CloseImeAutoOpenWindowToAppTest(private val testSpec: FlickerTestParameter } } - @Presubmit - @Test - fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - @FlakyTest(bugId = 206753786) - @Test - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - @Presubmit - @Test - fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry() - } - } - companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(repetitions = 3, + .getConfigNonRotationTests( + repetitions = 3, // b/190352379 (IME doesn't show on app launch in 90 degrees) supportedRotations = listOf(Surface.ROTATION_0), supportedNavigationModes = listOf( WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, - WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY) + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY + ) ) } } 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 b2d959157f169..99e929165e73f 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 @@ -16,27 +16,18 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder import org.junit.Test @@ -61,48 +52,35 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -class CloseImeAutoOpenWindowToHomeTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class CloseImeAutoOpenWindowToHomeTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - testApp.launchViaIntent(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + testApp.launchViaIntent(wmHelper) } - teardown { - eachRun { - testApp.exit(wmHelper) - } - } - transitions { - device.pressHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .withImeGone() - .waitForAndVerify() + } + teardown { + eachRun { + testApp.exit(wmHelper) } } + transitions { + device.pressHome() + wmHelper.StateSyncBuilder() + .withHomeActivityVisible() + .withImeGone() + .waitForAndVerify() + } } - @Presubmit + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() - - @Presubmit - @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() - - @Presubmit - @Test - fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - } + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() @Presubmit @Test @@ -114,10 +92,6 @@ class CloseImeAutoOpenWindowToHomeTest(private val testSpec: FlickerTestParamete } } - @Presubmit - @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() - @Presubmit @Test fun imeLayerVisibleStart() { @@ -148,32 +122,6 @@ class CloseImeAutoOpenWindowToHomeTest(private val testSpec: FlickerTestParamete } } - @Presubmit - @Test - fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - @FlakyTest(bugId = 206753786) - @Test - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - @Presubmit - @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() - - @Presubmit - @Test - fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry(listOf( - ComponentMatcher.IME, - ComponentMatcher.SPLASH_SCREEN)) - } - } - companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeEditorPopupDialogTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeEditorPopupDialogTest.kt index bb9d72d329f38..53f43184dde67 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeEditorPopupDialogTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/CloseImeEditorPopupDialogTest.kt @@ -16,21 +16,17 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.Postsubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.ImeEditorPopupDialogAppHelper -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.flicker.traces.region.RegionSubject import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder @@ -44,44 +40,94 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 -class CloseImeEditorPopupDialogTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class CloseImeEditorPopupDialogTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val imeTestApp = ImeEditorPopupDialogAppHelper(instrumentation, testSpec.startRotation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - imeTestApp.launchViaIntent(wmHelper) - imeTestApp.openIME(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + imeTestApp.launchViaIntent(wmHelper) + imeTestApp.openIME(wmHelper) } - transitions { - imeTestApp.dismissDialog(wmHelper) + } + transitions { + imeTestApp.dismissDialog(wmHelper) + wmHelper.StateSyncBuilder() + .withImeGone() + .waitForAndVerify() + } + teardown { + eachRun { + device.pressHome() wmHelper.StateSyncBuilder() - .withImeGone() + .withHomeActivityVisible() .waitForAndVerify() - } - teardown { - eachRun { - device.pressHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .waitForAndVerify() - imeTestApp.exit(wmHelper) - } + imeTestApp.exit(wmHelper) } } } + /** {@inheritDoc} */ @Postsubmit @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + /** {@inheritDoc} */ @Postsubmit @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = + super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() @Postsubmit @Test @@ -92,11 +138,11 @@ class CloseImeEditorPopupDialogTest(private val testSpec: FlickerTestParameter) fun imeLayerAndImeSnapshotVisibleOnScreen() { testSpec.assertLayers { this.isVisible(ComponentMatcher.IME) - .then() - .isVisible(ComponentMatcher.IME_SNAPSHOT) - .then() - .isInvisible(ComponentMatcher.IME_SNAPSHOT, isOptional = true) - .isInvisible(ComponentMatcher.IME) + .then() + .isVisible(ComponentMatcher.IME_SNAPSHOT) + .then() + .isInvisible(ComponentMatcher.IME_SNAPSHOT, isOptional = true) + .isInvisible(ComponentMatcher.IME) } } @@ -105,13 +151,15 @@ class CloseImeEditorPopupDialogTest(private val testSpec: FlickerTestParameter) fun imeSnapshotAssociatedOnAppVisibleRegion() { testSpec.assertLayers { this.invoke("imeSnapshotAssociatedOnAppVisibleRegion") { - val imeSnapshotLayers = it.subjects.filter { - subject -> subject.name.contains( - ComponentMatcher.IME_SNAPSHOT.toLayerName()) && subject.isVisible + val imeSnapshotLayers = it.subjects.filter { subject -> + subject.name.contains( + ComponentMatcher.IME_SNAPSHOT.toLayerName() + ) && subject.isVisible } if (imeSnapshotLayers.isNotEmpty()) { val visibleAreas = imeSnapshotLayers.mapNotNull { imeSnapshotLayer -> - imeSnapshotLayer.layer?.visibleRegion }.toTypedArray() + imeSnapshotLayer.layer?.visibleRegion + }.toTypedArray() val imeVisibleRegion = RegionSubject.assertThat(visibleAreas, this, timestamp) val appVisibleRegion = it.visibleRegion(imeTestApp) if (imeVisibleRegion.region.isNotEmpty) { @@ -127,14 +175,14 @@ class CloseImeEditorPopupDialogTest(private val testSpec: FlickerTestParameter) @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests( - repetitions = 2, - supportedNavigationModes = listOf( - WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, - WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY - ), - supportedRotations = listOf(Surface.ROTATION_0) - ) + .getConfigNonRotationTests( + repetitions = 2, + supportedNavigationModes = listOf( + WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY + ), + supportedRotations = listOf(Surface.ROTATION_0) + ) } } } 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 ef6633e47253e..113fddff87b5b 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 @@ -16,27 +16,19 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.ImeAppHelper -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible +import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd import com.android.server.wm.traces.common.ComponentMatcher -import org.junit.Assume.assumeFalse -import org.junit.Assume.assumeTrue +import org.junit.Assume import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -52,43 +44,33 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -class CloseImeWindowToAppTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class CloseImeWindowToAppTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = ImeAppHelper(instrumentation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - testApp.launchViaIntent(wmHelper) - } - eachRun { - testApp.openIME(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + testApp.launchViaIntent(wmHelper) } - teardown { - test { - testApp.exit(wmHelper) - } + eachRun { + testApp.openIME(wmHelper) } - transitions { - testApp.closeIME(wmHelper) + } + teardown { + test { + testApp.exit(wmHelper) } } + transitions { + testApp.closeIME(wmHelper) + } } + /** {@inheritDoc} */ @Presubmit @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() - - @Presubmit - @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() - - @Presubmit - @Test - fun visibleWindowsShownMoreThanOneConsecutiveEntry() { + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() { testSpec.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry(listOf( ComponentMatcher.IME, @@ -97,51 +79,28 @@ class CloseImeWindowToAppTest(private val testSpec: FlickerTestParameter) { } } + /** {@inheritDoc} */ @Presubmit @Test - fun imeAppWindowIsAlwaysVisible() { - testSpec.assertWm { - this.isAppWindowOnTop(testApp) - } - } - - @Presubmit - @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun statusBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() - - @Presubmit - @Test - fun navBarLayerRotatesAndScales() { - assumeFalse(testSpec.isLandscapeOrSeascapeAtStart) - testSpec.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() { + Assume.assumeFalse(testSpec.isTablet) + Assume.assumeFalse(testSpec.isLandscapeOrSeascapeAtStart) + testSpec.navBarLayerPositionAtStartAndEnd() } @FlakyTest @Test - fun navBarLayerRotatesAndScales_Flaky() { - assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) - testSpec.navBarLayerRotatesAndScales() + fun navBarLayerPositionAtStartAndEndLandscapeOrSeascapeAtStart() { + Assume.assumeFalse(testSpec.isTablet) + Assume.assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) + testSpec.navBarLayerPositionAtStartAndEnd() } + /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - @Presubmit - @Test - fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry() - } - } + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() @Presubmit @Test @@ -155,6 +114,14 @@ class CloseImeWindowToAppTest(private val testSpec: FlickerTestParameter) { } } + @Presubmit + @Test + fun imeAppWindowIsAlwaysVisible() { + testSpec.assertWm { + this.isAppWindowOnTop(testApp) + } + } + companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic 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 3cc777ab71cbd..20a56cf00baf0 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 @@ -16,26 +16,18 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.ImeAppHelper -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder import org.junit.Test @@ -52,53 +44,70 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -class CloseImeWindowToHomeTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class CloseImeWindowToHomeTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = ImeAppHelper(instrumentation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - testApp.launchViaIntent(wmHelper) - testApp.openIME(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + testApp.launchViaIntent(wmHelper) + testApp.openIME(wmHelper) } - transitions { - device.pressHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .withImeGone() - .waitForAndVerify() - } - teardown { - test { - testApp.exit(wmHelper) - } + } + transitions { + device.pressHome() + wmHelper.StateSyncBuilder() + .withHomeActivityVisible() + .withImeGone() + .waitForAndVerify() + } + teardown { + test { + testApp.exit(wmHelper) } } } + /** {@inheritDoc} */ @Presubmit @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() - - @Presubmit - @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() - - @Presubmit - @Test - fun visibleWindowsShownMoreThanOneConsecutiveEntry() { + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() { testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry(listOf( - ComponentMatcher.IME, - ComponentMatcher.SPLASH_SCREEN, - ComponentMatcher.SNAPSHOT)) + this.visibleWindowsShownMoreThanOneConsecutiveEntry( + listOf( + ComponentMatcher.IME, + ComponentMatcher.SPLASH_SCREEN, + ComponentMatcher.SNAPSHOT + ) + ) } } + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Presubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { + testSpec.assertLayers { + this.visibleLayersShownMoreThanOneConsecutiveEntry( + listOf( + ComponentMatcher.IME, + ComponentMatcher.SPLASH_SCREEN + ) + ) + } + } + + @Presubmit + @Test + fun imeLayerBecomesInvisible() = testSpec.imeLayerBecomesInvisible() + @Presubmit @Test fun imeWindowBecomesInvisible() = testSpec.imeWindowBecomesInvisible() @@ -108,52 +117,18 @@ class CloseImeWindowToHomeTest(private val testSpec: FlickerTestParameter) { fun imeAppWindowBecomesInvisible() { testSpec.assertWm { this.isAppWindowVisible(testApp) - .then() - .isAppWindowInvisible(testApp) + .then() + .isAppWindowInvisible(testApp) } } - @Presubmit - @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun statusBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() - - @Presubmit - @Test - fun imeLayerBecomesInvisible() = testSpec.imeLayerBecomesInvisible() - @Presubmit @Test fun imeAppLayerBecomesInvisible() { testSpec.assertLayers { this.isVisible(testApp) - .then() - .isInvisible(testApp) - } - } - - @Presubmit - @Test - fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - @FlakyTest(bugId = 206753786) - @Test - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - @Presubmit - @Test - fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry(listOf( - ComponentMatcher.IME, - ComponentMatcher.SPLASH_SCREEN)) + .then() + .isInvisible(testApp) } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeAndDialogThemeAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeAndDialogThemeAppTest.kt index 673751d4ae7e9..19c913d0d6240 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeAndDialogThemeAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeAndDialogThemeAppTest.kt @@ -16,8 +16,8 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowInsets.Type.ime @@ -25,8 +25,7 @@ import android.view.WindowInsets.Type.navigationBars import android.view.WindowInsets.Type.statusBars import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory @@ -49,37 +48,95 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class LaunchAppShowImeAndDialogThemeAppTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class LaunchAppShowImeAndDialogThemeAppTest( + testSpec: FlickerTestParameter +) : BaseTest(testSpec) { private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - testApp.launchViaIntent(wmHelper) - wmHelper.StateSyncBuilder() - .withImeShown() - .waitForAndVerify() - testApp.startDialogThemedActivity(wmHelper) - // Verify IME insets isn't visible on dialog since it's non-IME focusable window - assertFalse(testApp.getInsetsVisibleFromDialog(ime())) - assertTrue(testApp.getInsetsVisibleFromDialog(statusBars())) - assertTrue(testApp.getInsetsVisibleFromDialog(navigationBars())) - } - } - teardown { - eachRun { - testApp.exit(wmHelper) - } - } - transitions { - testApp.dismissDialog(wmHelper) + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder() + .withImeShown() + .waitForAndVerify() + testApp.startDialogThemedActivity(wmHelper) + // Verify IME insets isn't visible on dialog since it's non-IME focusable window + assertFalse(testApp.getInsetsVisibleFromDialog(ime())) + assertTrue(testApp.getInsetsVisibleFromDialog(statusBars())) + assertTrue(testApp.getInsetsVisibleFromDialog(navigationBars())) } } + teardown { + eachRun { + testApp.exit(wmHelper) + } + } + transitions { + testApp.dismissDialog(wmHelper) + } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + /** * Checks that [ComponentMatcher.IME] layer becomes visible during the transition */ diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeOnStartTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeOnStartTest.kt index 1c0df957d4dfa..442ff1a36eba9 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeOnStartTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/LaunchAppShowImeOnStartTest.kt @@ -16,13 +16,12 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory @@ -69,35 +68,91 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) -class LaunchAppShowImeOnStartTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class LaunchAppShowImeOnStartTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) private val initializeApp = ImeStateInitializeHelper(instrumentation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - initializeApp.launchViaIntent(wmHelper) - this.setRotation(testSpec.startRotation) - } - } - teardown { - eachRun { - initializeApp.exit(wmHelper) - testApp.exit(wmHelper) - } - } - transitions { - testApp.launchViaIntent(wmHelper) - wmHelper.StateSyncBuilder() - .withImeShown() - .waitForAndVerify() + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + initializeApp.launchViaIntent(wmHelper) + this.setRotation(testSpec.startRotation) } } + teardown { + eachRun { + initializeApp.exit(wmHelper) + testApp.exit(wmHelper) + } + } + transitions { + testApp.launchViaIntent(wmHelper) + wmHelper.StateSyncBuilder() + .withImeShown() + .waitForAndVerify() + } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + /** * Checks that [ComponentMatcher.IME] window becomes visible during the transition */ diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt index 1854d6e5506e5..5296e3060a8d8 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowAndCloseTest.kt @@ -16,25 +16,19 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.ImeAppHelper import com.android.server.wm.flicker.helpers.SimpleAppHelper -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -52,88 +46,62 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -class OpenImeWindowAndCloseTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class OpenImeWindowAndCloseTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val simpleApp = SimpleAppHelper(instrumentation) private val testApp = ImeAppHelper(instrumentation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - simpleApp.launchViaIntent(wmHelper) - testApp.launchViaIntent(wmHelper) - testApp.openIME(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + simpleApp.launchViaIntent(wmHelper) + testApp.launchViaIntent(wmHelper) + testApp.openIME(wmHelper) } - transitions { - testApp.finishActivity(wmHelper) - } - teardown { - test { - simpleApp.exit(wmHelper) - } + } + transitions { + testApp.finishActivity(wmHelper) + } + teardown { + test { + simpleApp.exit(wmHelper) } } } - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() @Presubmit @Test fun imeWindowBecomesInvisible() = testSpec.imeWindowBecomesInvisible() - @Presubmit - @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() - - @Presubmit - @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() - @Presubmit @Test fun imeLayerBecomesInvisible() = testSpec.imeLayerBecomesInvisible() - @Presubmit - @Test - fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry() - } - } - - @Test - fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - } - companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests( - repetitions = 3, - supportedRotations = listOf(Surface.ROTATION_0), - supportedNavigationModes = listOf( - WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, - WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY - ) + .getConfigNonRotationTests( + repetitions = 3, + supportedRotations = listOf(Surface.ROTATION_0), + supportedNavigationModes = listOf( + WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY ) + ) } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt index bf6a2139dcbcb..f3bd01ada36aa 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowFromFixedOrientationAppTest.kt @@ -16,16 +16,13 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory @@ -33,11 +30,7 @@ import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper import com.android.server.wm.flicker.helpers.setRotation -import com.android.server.wm.flicker.navBarLayerPositionEnd -import com.android.server.wm.flicker.navBarWindowIsVisible import com.android.server.wm.flicker.snapshotStartingWindowLayerCoversExactlyOnApp -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -54,59 +47,86 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -class OpenImeWindowFromFixedOrientationAppTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class OpenImeWindowFromFixedOrientationAppTest( + testSpec: FlickerTestParameter +) : BaseTest(testSpec) { private val imeTestApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) - private val taplInstrumentation = LauncherInstrumentation() - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - // Launch the activity with expecting IME will be shown. - imeTestApp.launchViaIntent(wmHelper) - } - eachRun { - // Swiping out the IME activity to home. - taplInstrumentation.goHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .waitForAndVerify() - } - } - transitions { - // Bring the exist IME activity to the front in landscape mode device rotation. - setRotation(Surface.ROTATION_90) + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + // Launch the activity with expecting IME will be shown. imeTestApp.launchViaIntent(wmHelper) } - teardown { - test { - imeTestApp.exit(wmHelper) - } + eachRun { + // Swiping out the IME activity to home. + device.pressHome() + wmHelper.StateSyncBuilder() + .withHomeActivityVisible() + .waitForAndVerify() + } + } + transitions { + // Bring the exist IME activity to the front in landscape mode device rotation. + setRotation(Surface.ROTATION_90) + imeTestApp.launchViaIntent(wmHelper) + } + teardown { + test { + imeTestApp.exit(wmHelper) } } } - @Presubmit + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() @Presubmit @Test fun imeWindowBecomesVisible() = testSpec.imeWindowBecomesVisible() - @Presubmit - @Test - fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd() - - @FlakyTest(bugId = 206753786) - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - @Presubmit @Test fun imeLayerBecomesVisible() = testSpec.imeLayerBecomesVisible() @@ -128,13 +148,13 @@ class OpenImeWindowFromFixedOrientationAppTest(private val testSpec: FlickerTest @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests( - repetitions = 3, - supportedRotations = listOf(Surface.ROTATION_90), - supportedNavigationModes = listOf( - WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY - ) + .getConfigNonRotationTests( + repetitions = 3, + supportedRotations = listOf(Surface.ROTATION_90), + supportedNavigationModes = listOf( + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY ) + ) } } } 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 a16b66791c86c..700c5a6d7b326 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 @@ -16,27 +16,18 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.ImeAppHelper -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith @@ -52,39 +43,34 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -class OpenImeWindowTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class OpenImeWindowTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = ImeAppHelper(instrumentation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - testApp.launchViaIntent(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + testApp.launchViaIntent(wmHelper) } - transitions { - testApp.openIME(wmHelper) + } + transitions { + testApp.openIME(wmHelper) + } + teardown { + eachRun { + testApp.closeIME(wmHelper) } - teardown { - eachRun { - testApp.closeIME(wmHelper) - } - test { - testApp.exit(wmHelper) - } + test { + testApp.exit(wmHelper) } } } - @Presubmit + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() - - @Presubmit - @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() @Presubmit @Test @@ -98,18 +84,6 @@ class OpenImeWindowTest(private val testSpec: FlickerTestParameter) { } } - @Presubmit - @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() - - @Presubmit - @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() - @Presubmit @Test fun imeLayerBecomesVisible() = testSpec.imeLayerBecomesVisible() @@ -122,30 +96,6 @@ class OpenImeWindowTest(private val testSpec: FlickerTestParameter) { } } - @Presubmit - @Test - fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - @FlakyTest(bugId = 206753786) - @Test - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - @Presubmit - @Test - fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry() - } - } - - @Presubmit - @Test - fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - } - companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToOverViewTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToOverViewTest.kt index 3842d81674d4e..f106a740517ce 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToOverViewTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/OpenImeWindowToOverViewTest.kt @@ -16,15 +16,13 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory @@ -32,16 +30,14 @@ import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible +import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd +import com.android.server.wm.flicker.statusBarLayerIsVisibleAtStartAndEnd import com.android.server.wm.traces.common.ComponentMatcher import com.android.server.wm.traces.common.WindowManagerConditionsFactory import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper -import org.junit.Assume.assumeFalse -import org.junit.Assume.assumeTrue +import org.junit.Assume import org.junit.FixMethodOrder +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -56,44 +52,39 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 -class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class OpenImeWindowToOverViewTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val imeTestApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) - private val statusBarInvisible = WindowManagerConditionsFactory.isStatusBarVisible().negate() - private val navBarInvisible = WindowManagerConditionsFactory.isNavBarVisible().negate() - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - imeTestApp.launchViaIntent(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + imeTestApp.launchViaIntent(wmHelper) } - transitions { - device.pressRecentApps() - val builder = wmHelper.StateSyncBuilder() - .withRecentsActivityVisible() - waitNavStatusBarVisibility(builder) - builder.waitForAndVerify() - } - teardown { - test { - device.pressHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .waitForAndVerify() - imeTestApp.exit(wmHelper) - } + } + transitions { + device.pressRecentApps() + val builder = wmHelper.StateSyncBuilder() + .withRecentsActivityVisible() + waitNavStatusBarVisibility(builder) + builder.waitForAndVerify() + } + teardown { + test { + device.pressHome() + wmHelper.StateSyncBuilder() + .withHomeActivityVisible() + .waitForAndVerify() + imeTestApp.exit(wmHelper) } } } /** - * The bars (including status bar and navigation bar) are expected to be hidden while - * entering overview in landscape if launcher is set to portrait only. Because - * "showing portrait overview (launcher) in landscape display" is an intermediate state - * depending on the touch-up to decide the intention of gesture, the display may keep in + * The bars (including [ComponentMatcher.STATUS_BAR] and [ComponentMatcher.NAV_BAR]) are + * expected to be hidden while entering overview in landscape if launcher is set to portrait + * only. Because "showing portrait overview (launcher) in landscape display" is an intermediate + * state depending on the touch-up to decide the intention of gesture, the display may keep in * landscape if return to app, or change to portrait if the gesture is to swipe-to-home. * * So instead of showing landscape bars with portrait launcher at the same time @@ -104,20 +95,28 @@ class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { */ private fun waitNavStatusBarVisibility(stateSync: WindowManagerStateHelper.StateSyncBuilder) { when { - testSpec.isLandscapeOrSeascapeAtStart -> - stateSync.add(statusBarInvisible) + testSpec.isLandscapeOrSeascapeAtStart && !testSpec.isTablet -> + stateSync.add(WindowManagerConditionsFactory.isStatusBarVisible().negate()) else -> - stateSync.withNavBarStatusBarVisible() + stateSync.withNavOrTaskBarVisible().withStatusBarVisible() } } - - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() + override fun entireScreenCovered() = super.entireScreenCovered() - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() @Presubmit @Test @@ -127,9 +126,10 @@ class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { @Presubmit @Test - fun navBarLayerIsVisible3Button() { - assumeFalse(testSpec.isGesturalNavigation) - testSpec.navBarLayerIsVisible() + fun navBarLayerIsVisibleAtStartAndEnd3Button() { + Assume.assumeFalse(testSpec.isTablet) + Assume.assumeFalse(testSpec.isGesturalNavigation) + testSpec.navBarLayerIsVisibleAtStartAndEnd() } /** @@ -137,10 +137,11 @@ class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { */ @Presubmit @Test - fun navBarLayerIsVisibleInPortraitGestural() { - assumeFalse(testSpec.isLandscapeOrSeascapeAtStart) - assumeTrue(testSpec.isGesturalNavigation) - testSpec.navBarLayerIsVisible() + fun navBarLayerIsVisibleAtStartAndEndGestural() { + Assume.assumeFalse(testSpec.isTablet) + Assume.assumeTrue(testSpec.isGesturalNavigation) + Assume.assumeFalse(isShellTransitionsEnabled) + testSpec.navBarLayerIsVisibleAtStartAndEnd() } /** @@ -150,9 +151,9 @@ class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { @Postsubmit @Test fun navBarLayerIsInvisibleInLandscapeGestural() { - assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) - assumeTrue(testSpec.isGesturalNavigation) - assumeTrue(isShellTransitionsEnabled) + Assume.assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) + Assume.assumeTrue(testSpec.isGesturalNavigation) + Assume.assumeTrue(isShellTransitionsEnabled) testSpec.assertLayersStart { this.isVisible(ComponentMatcher.NAV_BAR) } @@ -161,17 +162,16 @@ class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { } } - @Postsubmit - @Test - fun statusBarLayerIsVisibleInPortrait() { - assumeFalse(testSpec.isLandscapeOrSeascapeAtStart) - testSpec.statusBarLayerIsVisible() - } - + /** + * In the legacy transitions, the nav bar is not marked as invisible. + * In the new transitions this is fixed and the nav bar shows as invisible + */ @Presubmit @Test - fun statusBarLayerIsInvisibleInLandscape() { - assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) + fun statusBarLayerIsInvisibleInLandscapePhone() { + Assume.assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) + Assume.assumeTrue(testSpec.isGesturalNavigation) + Assume.assumeFalse(testSpec.isTablet) testSpec.assertLayersStart { this.isVisible(ComponentMatcher.STATUS_BAR) } @@ -180,13 +180,79 @@ class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { } } + /** + * In the legacy transitions, the nav bar is not marked as invisible. + * In the new transitions this is fixed and the nav bar shows as invisible + */ + @Presubmit + @Test + fun statusBarLayerIsInvisibleInLandscapeTablet() { + Assume.assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) + Assume.assumeTrue(testSpec.isGesturalNavigation) + Assume.assumeTrue(testSpec.isTablet) + testSpec.statusBarLayerIsVisibleAtStartAndEnd() + } + + /** {@inheritDoc} */ + @Ignore("Visibility changes depending on orientation and navigation mode") + override fun navBarLayerIsVisibleAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Visibility changes depending on orientation and navigation mode") + override fun navBarLayerPositionAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Visibility changes depending on orientation and navigation mode") + override fun statusBarLayerPositionAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Visibility changes depending on orientation and navigation mode") + override fun statusBarLayerIsVisibleAtStartAndEnd() { } + + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = + super.taskBarLayerIsVisibleAtStartAndEnd() + + @Postsubmit + @Test + fun statusBarLayerIsVisibleInPortrait() { + Assume.assumeFalse(testSpec.isLandscapeOrSeascapeAtStart) + testSpec.statusBarLayerIsVisibleAtStartAndEnd() + } + + @Presubmit + @Test + fun statusBarLayerIsInvisibleInLandscapeShell() { + Assume.assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) + Assume.assumeFalse(testSpec.isTablet) + Assume.assumeTrue(isShellTransitionsEnabled) + testSpec.assertLayersStart { + this.isVisible(ComponentMatcher.STATUS_BAR) + } + testSpec.assertLayersEnd { + this.isInvisible(ComponentMatcher.STATUS_BAR) + } + } + + @Presubmit + @Test + fun statusBarLayerIsVisibleInLandscapeLegacy() { + Assume.assumeTrue(testSpec.isLandscapeOrSeascapeAtStart) + Assume.assumeTrue(testSpec.isTablet) + Assume.assumeFalse(isShellTransitionsEnabled) + testSpec.statusBarLayerIsVisibleAtStartAndEnd() + } + @FlakyTest(bugId = 228011606) @Test fun imeLayerIsVisibleAndAssociatedWithAppWidow() { testSpec.assertLayersStart { isVisible(ComponentMatcher.IME).visibleRegion(ComponentMatcher.IME) - .coversAtMost(isVisible(imeTestApp) - .visibleRegion(imeTestApp).region) + .coversAtMost( + isVisible(imeTestApp) + .visibleRegion(imeTestApp).region + ) } testSpec.assertLayers { this.invoke("imeLayerIsVisibleAndAlignAppWidow") { @@ -211,14 +277,14 @@ class OpenImeWindowToOverViewTest(private val testSpec: FlickerTestParameter) { @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests( - repetitions = 1, - supportedRotations = listOf(Surface.ROTATION_0, Surface.ROTATION_90), - supportedNavigationModes = listOf( - WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, - WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY - ) + .getConfigNonRotationTests( + repetitions = 1, + supportedRotations = listOf(Surface.ROTATION_0, Surface.ROTATION_90), + supportedNavigationModes = listOf( + WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY, + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY ) + ) } } } 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 8efd92f707397..7cce24bc52aef 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,33 +16,23 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest 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.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group2 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.ImeAppAutoFocusHelper import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import com.android.server.wm.flicker.helpers.reopenAppFromOverview import com.android.server.wm.flicker.helpers.setRotation -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import com.android.server.wm.traces.common.ComponentMatcher.Companion.LAUNCHER -import org.junit.Assume.assumeFalse -import org.junit.Assume.assumeTrue +import org.junit.Assume import org.junit.Before import org.junit.FixMethodOrder import org.junit.Test @@ -59,56 +49,67 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 -open class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +open class ReOpenImeWindowTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) @Before open fun before() { - assumeFalse(isShellTransitionsEnabled) + Assume.assumeFalse(isShellTransitionsEnabled) } - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - testApp.launchViaIntent(wmHelper) - testApp.openIME(wmHelper) - } - eachRun { - this.setRotation(testSpec.startRotation) - device.pressRecentApps() - wmHelper.StateSyncBuilder() - .withRecentsActivityVisible() - .waitForAndVerify() - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + testApp.launchViaIntent(wmHelper) + testApp.openIME(wmHelper) } - transitions { - device.reopenAppFromOverview(wmHelper) + eachRun { + this.setRotation(testSpec.startRotation) + device.pressRecentApps() wmHelper.StateSyncBuilder() - .withImeShown() + .withRecentsActivityVisible() .waitForAndVerify() } - teardown { - test { - testApp.exit(wmHelper) - } + } + transitions { + device.reopenAppFromOverview(wmHelper) + wmHelper.StateSyncBuilder() + .withImeShown() + .waitForAndVerify() + } + teardown { + test { + testApp.exit(wmHelper) } } } - @Presubmit + /** {@inheritDoc} */ + @FlakyTest(bugId = 206753786) @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + /** {@inheritDoc} */ @Presubmit @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { + // depends on how much of the animation transactions are sent to SF at once + // sometimes this layer appears for 2-3 frames, sometimes for only 1 + val recentTaskComponent = ComponentMatcher("", "RecentTaskScreenshotSurface") + testSpec.assertLayers { + this.visibleLayersShownMoreThanOneConsecutiveEntry( + listOf(ComponentMatcher.SPLASH_SCREEN, + ComponentMatcher.SNAPSHOT, recentTaskComponent) + ) + } + } + /** {@inheritDoc} */ @Presubmit @Test - fun visibleWindowsShownMoreThanOneConsecutiveEntry() { + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() { val component = ComponentMatcher("", "RecentTaskScreenshotSurface") testSpec.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry( @@ -136,7 +137,7 @@ open class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) { @Presubmit @Test fun imeAppWindowVisibilityLegacy() { - assumeFalse(isShellTransitionsEnabled) + Assume.assumeFalse(isShellTransitionsEnabled) // the app starts visible in live tile, and stays visible for the duration of entering // and exiting overview. However, legacy transitions seem to have a bug which causes // everything to restart during the test, so expect the app to disappear and come back. @@ -154,7 +155,7 @@ open class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) { @FlakyTest(bugId = 204570898) @Test fun imeAppWindowVisibility() { - assumeTrue(isShellTransitionsEnabled) + Assume.assumeTrue(isShellTransitionsEnabled) // the app starts visible in live tile, and stays visible for the duration of entering // and exiting overview. Since we log 1x per frame, sometimes the activity visibility // and the app visibility are updated together, sometimes not, thus ignore activity @@ -164,23 +165,10 @@ open class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) { } } - @Presubmit - @Test - // During testing the launcher is always in portrait mode - fun entireScreenCovered() = testSpec.entireScreenCovered() - - @Presubmit - @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() - - @Presubmit - @Test - fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() - @Presubmit @Test fun imeLayerIsBecomesVisibleLegacy() { - assumeFalse(isShellTransitionsEnabled) + Assume.assumeFalse(isShellTransitionsEnabled) testSpec.assertLayers { this.isVisible(ComponentMatcher.IME) .then() @@ -193,7 +181,7 @@ open class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) { @FlakyTest(bugId = 204570898) @Test fun imeLayerIsBecomesVisible() { - assumeTrue(isShellTransitionsEnabled) + Assume.assumeTrue(isShellTransitionsEnabled) testSpec.assertLayers { this.isVisible(ComponentMatcher.IME) } @@ -211,28 +199,6 @@ open class ReOpenImeWindowTest(private val testSpec: FlickerTestParameter) { } } - @Presubmit - @Test - fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - @FlakyTest(bugId = 206753786) - @Test - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - @Presubmit - @Test - fun visibleLayersShownMoreThanOneConsecutiveEntry() { - // depends on how much of the animation transactions are sent to SF at once - // sometimes this layer appears for 2-3 frames, sometimes for only 1 - val recentTaskComponent = ComponentMatcher("", "RecentTaskScreenshotSurface") - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry( - listOf(ComponentMatcher.SPLASH_SCREEN, - ComponentMatcher.SNAPSHOT, recentTaskComponent) - ) - } - } - companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest_ShellTransit.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest_ShellTransit.kt index 5362a41fcb226..d6d695b9c88ee 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest_ShellTransit.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/ReOpenImeWindowTest_ShellTransit.kt @@ -39,8 +39,9 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group2 @FlakyTest(bugId = 221854428) -class ReOpenImeWindowTest_ShellTransit(private val testSpec: FlickerTestParameter) - : ReOpenImeWindowTest(testSpec) { +class ReOpenImeWindowTest_ShellTransit( + testSpec: FlickerTestParameter +) : ReOpenImeWindowTest(testSpec) { @Before override fun before() { Assume.assumeTrue(isShellTransitionsEnabled) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest.kt index ee92cbe3b606b..946fe38ae3cb4 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest.kt @@ -16,13 +16,12 @@ package com.android.server.wm.flicker.ime -import android.app.Instrumentation +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.view.Surface import android.view.WindowManagerPolicyConstants import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory @@ -33,8 +32,6 @@ import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import com.android.server.wm.flicker.helpers.setRotation -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import org.junit.Assume import org.junit.Before @@ -54,8 +51,9 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 @Presubmit -open class SwitchImeWindowsFromGestureNavTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +open class SwitchImeWindowsFromGestureNavTest( + testSpec: FlickerTestParameter +) : BaseTest(testSpec) { private val testApp = SimpleAppHelper(instrumentation) private val imeTestApp = ImeAppAutoFocusHelper(instrumentation, testSpec.startRotation) @@ -64,59 +62,110 @@ open class SwitchImeWindowsFromGestureNavTest(private val testSpec: FlickerTestP Assume.assumeFalse(isShellTransitionsEnabled) } - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - this.setRotation(testSpec.startRotation) - testApp.launchViaIntent(wmHelper) - wmHelper.StateSyncBuilder() - .withFullScreenApp(testApp) - .waitForAndVerify() - - imeTestApp.launchViaIntent(wmHelper) - wmHelper.StateSyncBuilder() - .withFullScreenApp(imeTestApp) - .waitForAndVerify() - - imeTestApp.openIME(wmHelper) - } - } - teardown { - eachRun { - device.pressHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .waitForAndVerify() - testApp.exit(wmHelper) - imeTestApp.exit(wmHelper) - } - } - transitions { - // [Step1]: Swipe right from imeTestApp to testApp task - createTag(TAG_IME_VISIBLE) - val displayBounds = WindowUtils.getDisplayBounds(testSpec.startRotation) - device.swipe(0, displayBounds.bounds.height, - displayBounds.bounds.width, displayBounds.bounds.height, 50) - + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + this.setRotation(testSpec.startRotation) + testApp.launchViaIntent(wmHelper) wmHelper.StateSyncBuilder() .withFullScreenApp(testApp) .waitForAndVerify() - createTag(TAG_IME_INVISIBLE) - } - transitions { - // [Step2]: Swipe left to back to imeTestApp task - val displayBounds = WindowUtils.getDisplayBounds(testSpec.startRotation) - device.swipe(displayBounds.bounds.width, displayBounds.bounds.height, - 0, displayBounds.bounds.height, 50) + + imeTestApp.launchViaIntent(wmHelper) wmHelper.StateSyncBuilder() .withFullScreenApp(imeTestApp) .waitForAndVerify() + + imeTestApp.openIME(wmHelper) } } + teardown { + eachRun { + device.pressHome() + wmHelper.StateSyncBuilder() + .withHomeActivityVisible() + .waitForAndVerify() + testApp.exit(wmHelper) + imeTestApp.exit(wmHelper) + } + } + transitions { + // [Step1]: Swipe right from imeTestApp to testApp task + createTag(TAG_IME_VISIBLE) + val displayBounds = WindowUtils.getDisplayBounds(testSpec.startRotation) + device.swipe( + 0, displayBounds.bounds.height, + displayBounds.bounds.width, displayBounds.bounds.height, 50 + ) + + wmHelper.StateSyncBuilder() + .withFullScreenApp(testApp) + .waitForAndVerify() + createTag(TAG_IME_INVISIBLE) + } + transitions { + // [Step2]: Swipe left to back to imeTestApp task + val displayBounds = WindowUtils.getDisplayBounds(testSpec.startRotation) + device.swipe( + displayBounds.bounds.width, displayBounds.bounds.height, + 0, displayBounds.bounds.height, 50 + ) + wmHelper.StateSyncBuilder() + .withFullScreenApp(imeTestApp) + .waitForAndVerify() + } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + @Test fun imeAppWindowVisibility() { testSpec.assertWm { @@ -132,26 +181,6 @@ open class SwitchImeWindowsFromGestureNavTest(private val testSpec: FlickerTestP } } - @Test - fun navBarLayerIsVisibleAroundSwitching() { - testSpec.assertLayersStart { - isVisible(ComponentMatcher.NAV_BAR) - } - testSpec.assertLayersEnd { - isVisible(ComponentMatcher.NAV_BAR) - } - } - - @Test - fun statusBarLayerIsVisibleAroundSwitching() { - testSpec.assertLayersStart { - isVisible(ComponentMatcher.STATUS_BAR) - } - testSpec.assertLayersEnd { - isVisible(ComponentMatcher.STATUS_BAR) - } - } - @Test fun imeLayerIsVisibleWhenSwitchingToImeApp() { testSpec.assertLayersStart { @@ -172,24 +201,18 @@ open class SwitchImeWindowsFromGestureNavTest(private val testSpec: FlickerTestP } } - @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() - - @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() - companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests( - repetitions = 3, - supportedNavigationModes = listOf( - WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY - ), - supportedRotations = listOf(Surface.ROTATION_0) - ) + .getConfigNonRotationTests( + repetitions = 3, + supportedNavigationModes = listOf( + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY + ), + supportedRotations = listOf(Surface.ROTATION_0) + ) } private const val TAG_IME_VISIBLE = "imeVisible" diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest_ShellTransit.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest_ShellTransit.kt index 3dbe1ec17b82d..e3ae4c9e1771b 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest_ShellTransit.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/ime/SwitchImeWindowsFromGestureNavTest_ShellTransit.kt @@ -24,7 +24,6 @@ import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import org.junit.Assume import org.junit.Before - import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -40,8 +39,9 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 @FlakyTest(bugId = 228012334) -class SwitchImeWindowsFromGestureNavTest_ShellTransit(testSpec: FlickerTestParameter) - : SwitchImeWindowsFromGestureNavTest(testSpec) { +class SwitchImeWindowsFromGestureNavTest_ShellTransit( + testSpec: FlickerTestParameter +) : SwitchImeWindowsFromGestureNavTest(testSpec) { @Before override fun before() { Assume.assumeTrue(isShellTransitionsEnabled) diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt index 35274e21e056c..6668c4c185c83 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/ActivitiesTransitionTest.kt @@ -16,18 +16,15 @@ package com.android.server.wm.flicker.launch -import android.app.Instrumentation +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.TwoActivitiesAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.server.wm.traces.common.ComponentMatcher @@ -59,39 +56,85 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 -class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +class ActivitiesTransitionTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp: TwoActivitiesAppHelper = TwoActivitiesAppHelper(instrumentation) - private val tapl = LauncherInstrumentation() - /** - * Entry point for the test runner. It will use this method to initialize and cache - * flicker executions - */ - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - tapl.setExpectedRotation(testSpec.startRotation) - testApp.launchViaIntent(wmHelper) - } - } - teardown { - test { - testApp.exit(wmHelper) - } - } - transitions { - testApp.openSecondActivity(device, wmHelper) - tapl.pressBack() - wmHelper.StateSyncBuilder() - .withFullScreenApp(testApp) - .waitForAndVerify() + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + tapl.setExpectedRotation(testSpec.startRotation) + testApp.launchViaIntent(wmHelper) } } + teardown { + test { + testApp.exit(wmHelper) + } + } + transitions { + testApp.openSecondActivity(device, wmHelper) + tapl.pressBack() + wmHelper.StateSyncBuilder() + .withFullScreenApp(testApp) + .waitForAndVerify() + } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + /** * Checks that the [ActivityOptions.BUTTON_ACTIVITY_COMPONENT_NAME] activity is visible at * the start of the transition, that @@ -115,13 +158,6 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) { } } - /** - * Checks that all parts of the screen are covered during the transition - */ - @Presubmit - @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() - /** * Checks that the [ComponentMatcher.LAUNCHER] window is not on top. The launcher cannot be * asserted with `isAppWindowVisible` because it contains 2 windows with the exact same name, @@ -155,7 +191,7 @@ class ActivitiesTransitionTest(val testSpec: FlickerTestParameter) { @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(repetitions = 3) + .getConfigNonRotationTests(repetitions = 3) } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt index c92704464817b..accf8afe14ea1 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppColdFromIcon.kt @@ -54,11 +54,10 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 -class OpenAppColdFromIcon(testSpec: FlickerTestParameter) : - OpenAppFromLauncherTransition(testSpec) { - /** - * Defines the transition used to run the test - */ +class OpenAppColdFromIcon( + testSpec: FlickerTestParameter +) : OpenAppFromLauncherTransition(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) @@ -82,85 +81,107 @@ class OpenAppColdFromIcon(testSpec: FlickerTestParameter) : } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun appWindowAsTopWindowAtEnd() = + super.appWindowAsTopWindowAtEnd() + + /** {@inheritDoc} */ @Postsubmit @Test override fun appWindowReplacesLauncherAsTopWindow() = super.appWindowReplacesLauncherAsTopWindow() + /** {@inheritDoc} */ @Postsubmit @Test override fun appLayerBecomesVisible() = super.appLayerBecomesVisible() + /** {@inheritDoc} */ @Postsubmit @Test - override fun appLayerReplacesLauncher() = - super.appLayerReplacesLauncher() + override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() + /** {@inheritDoc} */ @Postsubmit @Test - override fun appWindowBecomesTopWindow() = - super.appWindowBecomesTopWindow() + override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow() + /** {@inheritDoc} */ @Postsubmit @Test - override fun appWindowBecomesVisible() = - super.appWindowBecomesVisible() + override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() + /** {@inheritDoc} */ @Postsubmit @Test - override fun entireScreenCovered() = - super.entireScreenCovered() + override fun entireScreenCovered() = super.entireScreenCovered() + /** {@inheritDoc} */ @Postsubmit @Test - override fun focusChanges() = - super.focusChanges() + override fun focusChanges() = super.focusChanges() + /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerIsVisible() = - super.navBarLayerIsVisible() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerRotatesAndScales() = - super.navBarLayerRotatesAndScales() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarWindowIsVisible() = - super.navBarWindowIsVisible() + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerRotatesScales() = - super.statusBarLayerRotatesScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerIsVisible() = - super.statusBarLayerIsVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarWindowIsVisible() = - super.statusBarWindowIsVisible() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ @Postsubmit @Test override fun visibleLayersShownMoreThanOneConsecutiveEntry() = super.visibleLayersShownMoreThanOneConsecutiveEntry() + /** {@inheritDoc} */ @Postsubmit @Test override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = super.visibleWindowsShownMoreThanOneConsecutiveEntry() + /** {@inheritDoc} */ @Postsubmit @Test - override fun appWindowIsTopWindowAtEnd() = - super.appWindowIsTopWindowAtEnd() + override fun appWindowIsTopWindowAtEnd() = super.appWindowIsTopWindowAtEnd() companion object { /** 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 e52b6c326b739..f63eac3e809b7 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 @@ -54,11 +54,10 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 -open class OpenAppColdTest(testSpec: FlickerTestParameter) : - OpenAppFromLauncherTransition(testSpec) { - /** - * Defines the transition used to run the test - */ +open class OpenAppColdTest( + testSpec: FlickerTestParameter +) : OpenAppFromLauncherTransition(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) @@ -81,13 +80,14 @@ open class OpenAppColdTest(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun navBarLayerRotatesAndScales() { - super.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() { + super.navBarLayerPositionAtStartAndEnd() } /** {@inheritDoc} */ @@ -95,27 +95,6 @@ open class OpenAppColdTest(testSpec: FlickerTestParameter) : @Test override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() - /** {@inheritDoc} */ - @Presubmit - @Test - override fun appWindowReplacesLauncherAsTopWindow() = - super.appWindowReplacesLauncherAsTopWindow() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun navBarWindowIsVisible() = super.navBarWindowIsVisible() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun entireScreenCovered() = super.entireScreenCovered() - companion object { /** * Creates the test configurations. diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt index ca2698efeeeef..2d4d7986a67e8 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLauncherTransition.kt @@ -25,11 +25,12 @@ import org.junit.Test /** * Base class for app launch tests */ -abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) : - OpenAppTransition(testSpec) { +abstract class OpenAppFromLauncherTransition( + testSpec: FlickerTestParameter +) : OpenAppTransition(testSpec) { /** - * Checks that the focus changes from the launcher to [testApp] + * Checks that the focus changes from the [ComponentMatcher.LAUNCHER] to [testApp] */ @Presubmit @Test @@ -44,15 +45,17 @@ abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) : * and is replaced by [testApp], which remains visible until the end */ open fun appLayerReplacesLauncher() { - testSpec.replacesLayer(ComponentMatcher.LAUNCHER, testApp, - ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true, - ignoreSplashscreen = true) + testSpec.replacesLayer( + ComponentMatcher.LAUNCHER, testApp, + ignoreEntriesWithRotationLayer = true, ignoreSnapshot = true, + ignoreSplashscreen = true + ) } /** - * Checks that [ComponentMatcher.LAUNCHER] window is visible at the start of the - * transition, and is replaced by a snapshot or splash screen (optional), and finally, is - * replaced by [testApp], which remains visible until the end + * Checks that [ComponentMatcher.LAUNCHER] window is the top window at the start of the + * transition, and is replaced by a [ComponentMatcher.SNAPSHOT] or + * [ComponentMatcher.SPLASH_SCREEN], or [testApp], which remains visible until the end */ @Presubmit @Test @@ -67,4 +70,15 @@ abstract class OpenAppFromLauncherTransition(testSpec: FlickerTestParameter) : ) } } + + /** + * Checks that [testApp] window is the top window at the en dof the trace + */ + @Presubmit + @Test + open fun appWindowAsTopWindowAtEnd() { + testSpec.assertWmEnd { + this.isAppWindowOnTop(testApp) + } + } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt index fcf7c1d6917f0..242a884b2852c 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationCold.kt @@ -24,9 +24,12 @@ import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group1 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.navBarLayerPositionEnd -import com.android.server.wm.flicker.statusBarLayerPositionEnd +import com.android.server.wm.flicker.navBarLayerPositionAtEnd +import com.android.server.wm.flicker.statusBarLayerPositionAtEnd +import com.android.server.wm.traces.common.ComponentMatcher +import org.junit.Assume import org.junit.FixMethodOrder +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -87,35 +90,41 @@ open class OpenAppFromLockNotificationCold(testSpec: FlickerTestParameter) : @Test override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow() - /** - * Checks the position of the navigation bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible - */ - @Postsubmit - @Test - override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd() + /** {@inheritDoc} */ + @Ignore("Display is off at the start") + override fun navBarLayerPositionAtStartAndEnd() { } /** - * Checks the position of the status bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible + * Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition */ @Postsubmit @Test - override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd() + fun navBarLayerPositionAtEnd() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarLayerPositionAtEnd() + } + + /** {@inheritDoc} */ + @Ignore("Display is off at the start") + override fun statusBarLayerPositionAtStartAndEnd() { } + + /** + * Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the + * transition + */ + @Postsubmit + @Test + fun statusBarLayerPositionEnd() = testSpec.statusBarLayerPositionAtEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarWindowIsVisible() = super.navBarWindowIsVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -125,7 +134,7 @@ open class OpenAppFromLockNotificationCold(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible() + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -135,7 +144,8 @@ open class OpenAppFromLockNotificationCold(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible() + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt index f5fa736a8f739..e20196be64d94 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWarm.kt @@ -24,10 +24,12 @@ import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group1 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.navBarLayerPositionEnd -import com.android.server.wm.flicker.statusBarLayerPositionEnd +import com.android.server.wm.flicker.navBarLayerPositionAtEnd +import com.android.server.wm.flicker.statusBarLayerPositionAtEnd import com.android.server.wm.traces.common.ComponentMatcher +import org.junit.Assume import org.junit.FixMethodOrder +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -92,7 +94,7 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) : } /** - * Checks that the screen is locked. + * Checks that the screen is locked at the start of the transition */ @Test @Postsubmit @@ -113,35 +115,41 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) : override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = super.visibleWindowsShownMoreThanOneConsecutiveEntry() - /** - * Checks the position of the navigation bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible - */ - @Postsubmit - @Test - override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd() + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarLayerPositionAtStartAndEnd() { } /** - * Checks the position of the status bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible + * Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition */ @Postsubmit @Test - override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd() + fun navBarLayerPositionAtEnd() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarLayerPositionAtEnd() + } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerPositionAtStartAndEnd() { } + + /** + * Checks the position of the [ComponentMatcher.STATUS_BAR] at the start and end of the + * transition + */ + @Postsubmit + @Test + fun statusBarLayerPositionEnd() = testSpec.statusBarLayerPositionAtEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit @Test - override fun navBarWindowIsVisible() = super.navBarWindowIsVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -151,7 +159,7 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible() + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Postsubmit @@ -166,7 +174,8 @@ open class OpenAppFromLockNotificationWarm(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @Postsubmit @Test - override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible() + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Postsubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt index 763f1ebef8770..29730591c9570 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockNotificationWithLockOverlayApp.kt @@ -26,8 +26,6 @@ import com.android.server.wm.flicker.annotation.Group1 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.ShowWhenLockedAppHelper import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen -import com.android.server.wm.flicker.navBarLayerPositionEnd -import com.android.server.wm.flicker.statusBarLayerPositionEnd import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder import org.junit.Test @@ -113,79 +111,11 @@ class OpenAppFromLockNotificationWithLockOverlayApp(testSpec: FlickerTestParamet @Test override fun entireScreenCovered() = super.entireScreenCovered() - /** - * Checks the position of the navigation bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible - */ - @Postsubmit - @Test - override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd() - - /** - * Checks the position of the status bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible - */ - @Postsubmit - @Test - override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun navBarWindowIsVisible() = super.navBarWindowIsVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun appLayerBecomesVisible() = super.appLayerBecomesVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible() - /** {@inheritDoc} */ @Postsubmit @Test override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow() - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = - super.visibleWindowsShownMoreThanOneConsecutiveEntry() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun appWindowIsTopWindowAtEnd() = - super.appWindowIsTopWindowAtEnd() - companion object { /** * Creates the test configurations. diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt index 809143b51a616..5a4b3693f665d 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromLockTransition.kt @@ -17,13 +17,14 @@ package com.android.server.wm.flicker.launch import android.platform.test.annotations.FlakyTest -import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.navBarLayerPositionEnd -import com.android.server.wm.flicker.statusBarLayerPositionEnd +import com.android.server.wm.flicker.navBarLayerPositionAtEnd +import com.android.server.wm.flicker.statusBarLayerPositionAtEnd import com.android.server.wm.traces.common.ComponentMatcher +import org.junit.Assume +import org.junit.Ignore import org.junit.Test /** @@ -35,26 +36,25 @@ abstract class OpenAppFromLockTransition(testSpec: FlickerTestParameter) : /** * Defines the transition used to run the test */ - override val transition: FlickerBuilder.() -> Unit - get() = { - super.transition(this) - setup { - eachRun { - device.sleep() - wmHelper.StateSyncBuilder() - .withoutTopVisibleAppWindows() - .waitForAndVerify() - } - } - teardown { - eachRun { - testApp.exit(wmHelper) - } - } - transitions { - testApp.launchViaIntent(wmHelper) + override val transition: FlickerBuilder.() -> Unit = { + super.transition(this) + setup { + eachRun { + device.sleep() + wmHelper.StateSyncBuilder() + .withoutTopVisibleAppWindows() + .waitForAndVerify() } } + teardown { + eachRun { + testApp.exit(wmHelper) + } + } + transitions { + testApp.launchViaIntent(wmHelper) + } + } /** * Check that we go from no focus to focus on the [testApp] @@ -101,34 +101,51 @@ abstract class OpenAppFromLockTransition(testSpec: FlickerTestParameter) : @Test override fun appWindowBecomesVisible() = super.appWindowBecomesVisible() + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarLayerPositionAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerPositionAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarLayerIsVisibleAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarWindowIsAlwaysVisible() { } + /** - * Checks the position of the navigation bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible + * Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition */ @Presubmit @Test - override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd() + open fun navBarLayerPositionAtEnd() { + Assume.assumeFalse(testSpec.isTablet) + testSpec.navBarLayerPositionAtEnd() + } /** - * Checks the position of the status bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible + * Checks the position of the [ComponentMatcher.STATUS_BAR] at the end of the transition */ - @Postsubmit + @Presubmit @Test - override fun statusBarLayerRotatesScales() = testSpec.statusBarLayerPositionEnd() + fun statusBarLayerPositionAtEnd() = testSpec.statusBarLayerPositionAtEnd() + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarLayerIsVisibleAtStartAndEnd() { } /** - * Checks that the status bar layer is visible at the end of the trace + * Checks that the [ComponentMatcher.STATUS_BAR] layer is visible at the end of the trace * * It is not possible to check at the start because the screen is off */ @Presubmit @Test - override fun statusBarLayerIsVisible() { + fun statusBarLayerIsVisibleAtEnd() { testSpec.assertLayersEnd { this.isVisible(ComponentMatcher.STATUS_BAR) } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt index eaf4daca6e20e..dbe541882fa85 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationCold.kt @@ -42,8 +42,10 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 @Postsubmit -open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter) : - OpenAppFromNotificationWarm(testSpec) { +open class OpenAppFromNotificationCold( + testSpec: FlickerTestParameter +) : OpenAppFromNotificationWarm(testSpec) { + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) @@ -59,10 +61,81 @@ open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter) : } } + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun notificationAppWindowVisibleAtEnd() = super.notificationAppWindowVisibleAtEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun notificationAppWindowOnTopAtEnd() = super.notificationAppWindowOnTopAtEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun notificationAppLayerVisibleAtEnd() = super.notificationAppLayerVisibleAtEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun appWindowBecomesTopWindow() = super.appWindowBecomesTopWindow() + + /** {@inheritDoc} */ @Test @Postsubmit override fun appWindowBecomesVisible() = appWindowBecomesVisible_coldStart() + /** {@inheritDoc} */ @Test @Postsubmit override fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart() @@ -84,7 +157,7 @@ open class OpenAppFromNotificationCold(testSpec: FlickerTestParameter) : @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(repetitions = 3) + .getConfigNonRotationTests(repetitions = 3) } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt index e99e5b7aeeb3b..6e3e74df01936 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppFromNotificationWarm.kt @@ -52,12 +52,14 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 @Postsubmit -open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) : - OpenAppTransition(testSpec) { +open class OpenAppFromNotificationWarm( + testSpec: FlickerTestParameter +) : OpenAppTransition(testSpec) { override val testApp: NotificationAppHelper = NotificationAppHelper(instrumentation) open val openingNotificationsFromLockScreen = false + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { setup { @@ -83,11 +85,14 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) : var endY = 3 * device.displayHeight / 4 var steps = 25 if (openingNotificationsFromLockScreen) { - val wm = instrumentation.context.getSystemService(WindowManager::class.java) + val wm: WindowManager = + instrumentation.context.getSystemService(WindowManager::class.java) + ?: error("Unable to connect to WindowManager service") val metricInsets = wm.currentWindowMetrics.windowInsets val insets = metricInsets.getInsetsIgnoringVisibility( - WindowInsets.Type.statusBars() - or WindowInsets.Type.displayCutout()) + WindowInsets.Type.statusBars() + or WindowInsets.Type.displayCutout() + ) startY = insets.top + 100 endY = device.displayHeight / 2 @@ -101,8 +106,11 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) : instrumentation.uiAutomation.syncInputTransactions() // Launch the activity by clicking the notification - val notification = device.wait(Until.findObject( - By.text("Flicker Test Notification")), 2000L) + val notification = device.wait( + Until.findObject( + By.text("Flicker Test Notification") + ), 2000L + ) notification?.click() ?: error("Notification not found") instrumentation.uiAutomation.syncInputTransactions() @@ -119,50 +127,90 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) : } } - @Test + /** {@inheritDoc} */ @Postsubmit - override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales() + @Test + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - @Test + /** {@inheritDoc} */ @Postsubmit - override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible() + @Test + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() - @Test + /** {@inheritDoc} */ @Postsubmit - override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales() + @Test + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() - @Test + /** {@inheritDoc} */ @Postsubmit + @Test override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() + super.visibleLayersShownMoreThanOneConsecutiveEntry() - @Test + /** {@inheritDoc} */ @Postsubmit + @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_warmStart() - @Test + /** {@inheritDoc} */ @Postsubmit + @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_warmStart() - @Test + /** {@inheritDoc} */ @Postsubmit - fun notificationAppWindowVisibleAtEnd() { + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun entireScreenCovered() = super.entireScreenCovered() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun appWindowIsTopWindowAtEnd() = + super.appWindowIsTopWindowAtEnd() + + @Postsubmit + @Test + open fun notificationAppWindowVisibleAtEnd() { testSpec.assertWmEnd { this.isAppWindowVisible(testApp) } } - @Test @Postsubmit - fun notificationAppWindowOnTopAtEnd() { + @Test + open fun notificationAppWindowOnTopAtEnd() { testSpec.assertWmEnd { this.isAppWindowOnTop(testApp) } } - @Test @Postsubmit - fun notificationAppLayerVisibleAtEnd() { + @Test + open fun notificationAppLayerVisibleAtEnd() { testSpec.assertLayersEnd { this.isVisible(testApp) } @@ -178,43 +226,11 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) : @FlakyTest(bugId = 229738092) @Test - fun appWindowBecomesTopWindow_ShellTransit() { + open fun appWindowBecomesTopWindow_ShellTransit() { Assume.assumeTrue(isShellTransitionsEnabled) super.appWindowBecomesTopWindow() } - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun entireScreenCovered() = super.entireScreenCovered() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun navBarWindowIsVisible() = super.navBarWindowIsVisible() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = - super.visibleWindowsShownMoreThanOneConsecutiveEntry() - - /** {@inheritDoc} */ - @Postsubmit - @Test - override fun appWindowIsTopWindowAtEnd() = - super.appWindowIsTopWindowAtEnd() - companion object { /** * Creates the test configurations. @@ -226,7 +242,7 @@ open class OpenAppFromNotificationWarm(testSpec: FlickerTestParameter) : @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(repetitions = 3) + .getConfigNonRotationTests(repetitions = 3) } } } 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 88e6818571ae2..9d99d19c4915f 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 @@ -58,8 +58,9 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 -open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) : - OpenAppFromLauncherTransition(testSpec) { +open class OpenAppFromOverviewTest( + testSpec: FlickerTestParameter +) : OpenAppFromLauncherTransition(testSpec) { /** * Defines the transition used to run the test @@ -77,8 +78,12 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) : wmHelper.StateSyncBuilder() .withHomeActivityVisible() .waitForAndVerify() - // Launcher is always ROTATION_0 - tapl.setExpectedRotation(Surface.ROTATION_0) + // By default, launcher doesn't rotate on phones, but rotates on tablets + if (testSpec.isTablet) { + tapl.setExpectedRotation(testSpec.startRotation) + } else { + tapl.setExpectedRotation(Surface.ROTATION_0) + } tapl.workspace.switchToOverview() wmHelper.StateSyncBuilder() .withRecentsActivityVisible() @@ -97,7 +102,7 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Presubmit @@ -107,17 +112,17 @@ open class OpenAppFromOverviewTest(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @FlakyTest @Test - override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Presubmit @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() /** {@inheritDoc} */ @Presubmit @Test - override fun navBarWindowIsVisible() = super.navBarWindowIsVisible() + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() /** {@inheritDoc} */ @Presubmit diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt index 81396a1452c27..5953a4ca0317e 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppNonResizeableTest.kt @@ -27,10 +27,11 @@ import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group1 import com.android.server.wm.flicker.helpers.NonResizeableAppHelper -import com.android.server.wm.flicker.helpers.WindowUtils -import com.android.server.wm.flicker.navBarLayerPositionEnd +import com.android.server.wm.flicker.statusBarLayerPositionAtEnd import com.android.server.wm.traces.common.ComponentMatcher +import org.junit.Assume import org.junit.FixMethodOrder +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -65,8 +66,8 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : override val testApp = NonResizeableAppHelper(instrumentation) /** - * Checks that the nav bar layer starts invisible, becomes visible during unlocking animation - * and remains visible at the end + * Checks that the [ComponentMatcher.NAV_BAR] layer starts invisible, becomes visible during + * unlocking animation and remains visible at the end */ @FlakyTest(bugId = 227083463) @Test @@ -90,12 +91,13 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : } /** - * Checks that the nav bar starts the transition invisible, then becomes visible during - * the unlocking animation and remains visible at the end of the transition + * Checks that the [ComponentMatcher.NAV_BAR] starts the transition invisible, then becomes + * visible during the unlocking animation and remains visible at the end of the transition */ @Presubmit @Test fun navBarWindowsVisibilityChanges() { + Assume.assumeFalse(testSpec.isTablet) testSpec.assertWm { this.isNonAppWindowInvisible(ComponentMatcher.NAV_BAR) .then() @@ -104,44 +106,76 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : } /** - * Checks that the status bar layer is visible at the end of the trace + * Checks that the [ComponentMatcher.TASK_BAR] starts the transition invisible, then becomes + * visible during the unlocking animation and remains visible at the end of the transition + */ + @Presubmit + @Test + fun taskBarLayerIsVisibleAtEnd() { + Assume.assumeTrue(testSpec.isTablet) + testSpec.assertLayersEnd { + this.isVisible(ComponentMatcher.TASK_BAR) + } + } + + /** + * Checks that the [ComponentMatcher.STATUS_BAR] layer is visible at the end of the trace * * It is not possible to check at the start because the screen is off */ @Presubmit @Test - override fun statusBarLayerIsVisible() { + override fun statusBarLayerIsVisibleAtStartAndEnd() { testSpec.assertLayersEnd { this.isVisible(ComponentMatcher.STATUS_BAR) } } - /** {@inheritDoc} */ - @FlakyTest(bugId = 206753786) - @Test - override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales() - - /** {@inheritDoc} */ - @FlakyTest(bugId = 206753786) - @Test - fun statusBarLayerPositionAtEnd() { - testSpec.assertLayersEnd { - val display = this.entry.displays.minByOrNull { it.id } - ?: error("There is no display!") - this.visibleRegion(ComponentMatcher.STATUS_BAR) - .coversExactly(WindowUtils.getStatusBarPosition(display)) - } - } - /** - * Checks the position of the navigation bar at the start and end of the transition - * - * Differently from the normal usage of this assertion, check only the final state of the - * transition because the display is off at the start and the NavBar is never visible + * Checks the position of the [ComponentMatcher.NAV_BAR] at the end of the transition */ @Postsubmit @Test - override fun navBarLayerRotatesAndScales() = testSpec.navBarLayerPositionEnd() + override fun navBarLayerPositionAtEnd() = super.navBarLayerPositionAtEnd() + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarLayerIsVisibleAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarLayerIsVisibleAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun taskBarWindowIsAlwaysVisible() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun navBarWindowIsAlwaysVisible() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. Display starts off and app is full screen at the end") + override fun statusBarWindowIsAlwaysVisible() { } + + /** + * Checks the position of the [ComponentMatcher.STATUS_BAR] at the end of the + * transition + */ + @Postsubmit + @Test + fun statusBarLayerPositionEnd() = testSpec.statusBarLayerPositionAtEnd() + + /** + * Checks the [ComponentMatcher.NAV_BAR] is visible at the end of the transition + */ + @Postsubmit + @Test + fun navBarLayerIsVisibleAtEnd() { + testSpec.assertLayersEnd { + this.isVisible(ComponentMatcher.NAV_BAR) + } + } /** {@inheritDoc} */ @FlakyTest @@ -149,6 +183,22 @@ open class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : override fun visibleLayersShownMoreThanOneConsecutiveEntry() = super.visibleLayersShownMoreThanOneConsecutiveEntry() + /** {@inheritDoc} */ + @Presubmit + @Test + override fun appLayerBecomesVisible() { + Assume.assumeFalse(testSpec.isTablet) + super.appLayerBecomesVisible() + } + + /** {@inheritDoc} */ + @FlakyTest(bugId = 227143265) + @Test + fun appLayerBecomesVisibleTablet() { + Assume.assumeTrue(testSpec.isTablet) + super.appLayerBecomesVisible() + } + /** {@inheritDoc} */ @FlakyTest @Test diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt index 7ee43675f6dc9..5d2b56707de90 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/OpenAppTransition.kt @@ -16,39 +16,25 @@ package com.android.server.wm.flicker.launch -import android.app.Instrumentation import android.platform.test.annotations.Presubmit -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.StandardAppHelper import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import org.junit.Test /** * Base class for app launch tests */ -abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) { - protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() +abstract class OpenAppTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec) { protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation) - protected val tapl = LauncherInstrumentation() - /** - * Defines the transition used to run the test - */ - protected open val transition: FlickerBuilder.() -> Unit = { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { setup { test { tapl.setExpectedRotation(testSpec.startRotation) @@ -64,129 +50,43 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) { } /** - * Entry point for the test runner. It will use this method to initialize and cache - * flicker executions + * Checks that the [testApp] layer doesn't exist or is invisible at the start of the + * transition, but is created and/or becomes visible during the transition. */ - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - transition() - } + @Presubmit + @Test + open fun appLayerBecomesVisible() { + appLayerBecomesVisible_coldStart() } - /** - * Checks that the navigation bar window is visible during the whole transition - */ - open fun navBarWindowIsVisible() { - testSpec.navBarWindowIsVisible() - } - - /** - * Checks that the navigation bar layer is visible at the start and end of the trace - */ - open fun navBarLayerIsVisible() { - testSpec.navBarLayerIsVisible() - } - - /** - * Checks the position of the navigation bar at the start and end of the transition - */ - @Presubmit - @Test - open fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - /** - * Checks that the status bar window is visible during the whole transition - */ - @Presubmit - @Test - open fun statusBarWindowIsVisible() { - testSpec.statusBarWindowIsVisible() - } - - /** - * Checks that the status bar layer is visible at the start and end of the trace - */ - @Presubmit - @Test - open fun statusBarLayerIsVisible() { - testSpec.statusBarLayerIsVisible() - } - - /** - * Checks the position of the status bar at the start and end of the transition - */ - @Presubmit - @Test - open fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() - - /** - * Checks that all windows that are visible on the trace, are visible for at least 2 - * consecutive entries. - */ - @Presubmit - @Test - open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - } - - /** - * Checks that all layers that are visible on the trace, are visible for at least 2 - * consecutive entries. - */ - @Presubmit - @Test - open fun visibleLayersShownMoreThanOneConsecutiveEntry() { - testSpec.assertLayers { - this.visibleLayersShownMoreThanOneConsecutiveEntry() - } - } - - /** - * Checks that all parts of the screen are covered during the transition - */ - @Presubmit - @Test - open fun entireScreenCovered() = testSpec.entireScreenCovered() - - /** - * Checks that the app layer doesn't exist or is invisible at the start of the transition, but - * is created and/or becomes visible during the transition. - */ - @Presubmit - @Test - open fun appLayerBecomesVisible() = appLayerBecomesVisible_coldStart() - protected fun appLayerBecomesVisible_coldStart() { testSpec.assertLayers { this.notContains(testApp) - .then() - .isInvisible(testApp, isOptional = true) - .then() - .isVisible(ComponentMatcher.SNAPSHOT, isOptional = true) - .then() - .isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true) - .then() - .isVisible(testApp) + .then() + .isInvisible(testApp, isOptional = true) + .then() + .isVisible(ComponentMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isVisible(testApp) } } protected fun appLayerBecomesVisible_warmStart() { testSpec.assertLayers { this.isInvisible(testApp) - .then() - .isVisible(ComponentMatcher.SNAPSHOT, isOptional = true) - .then() - .isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true) - .then() - .isVisible(testApp) + .then() + .isVisible(ComponentMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isVisible(testApp) } } /** - * Checks that the app window doesn't exist at the start of the transition, that it is + * Checks that the [testApp] window doesn't exist at the start of the transition, that it is * created (invisible - optional) and becomes visible during the transition * * The `isAppWindowInvisible` step is optional because we log once per frame, upon logging, @@ -199,22 +99,22 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) { protected fun appWindowBecomesVisible_coldStart() { testSpec.assertWm { this.notContains(testApp) - .then() - .isAppWindowInvisible(testApp, isOptional = true) - .then() - .isAppWindowVisible(testApp) + .then() + .isAppWindowInvisible(testApp, isOptional = true) + .then() + .isAppWindowVisible(testApp) } } protected fun appWindowBecomesVisible_warmStart() { testSpec.assertWm { this.isAppWindowInvisible(testApp) - .then() - .isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true) - .then() - .isAppWindowVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true) - .then() - .isAppWindowVisible(testApp) + .then() + .isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowVisible(ComponentMatcher.SPLASH_SCREEN, isOptional = true) + .then() + .isAppWindowVisible(testApp) } } @@ -227,12 +127,12 @@ abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) { open fun appWindowBecomesTopWindow() { testSpec.assertWm { this.isAppWindowNotOnTop(testApp) - .then() - .isAppWindowOnTop( - testApp - .or(ComponentMatcher.SNAPSHOT) - .or(ComponentMatcher.SPLASH_SCREEN) - ) + .then() + .isAppWindowOnTop( + testApp + .or(ComponentMatcher.SNAPSHOT) + .or(ComponentMatcher.SPLASH_SCREEN) + ) } } 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 88e2b2d8e7b7c..17579648db608 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 @@ -87,40 +87,18 @@ open class OpenAppWarmTest(testSpec: FlickerTestParameter) : /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun appWindowReplacesLauncherAsTopWindow() = - super.appWindowReplacesLauncherAsTopWindow() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun visibleLayersShownMoreThanOneConsecutiveEntry() = - super.visibleLayersShownMoreThanOneConsecutiveEntry() + override fun statusBarLayerPositionAtStartAndEnd() = super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest @Test - override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @Presubmit @Test override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher() - /** {@inheritDoc} */ - @Presubmit - @Test - override fun navBarLayerIsVisible() = super.navBarLayerIsVisible() - - /** {@inheritDoc} */ - @Presubmit - @Test - override fun navBarWindowIsVisible() = super.navBarWindowIsVisible() - /** {@inheritDoc} */ @Presubmit @Test diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt index b27973e0b573c..4beb5d0199576 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/launch/TaskTransitionTest.kt @@ -20,21 +20,14 @@ import android.app.Instrumentation import android.app.WallpaperManager import android.platform.test.annotations.Postsubmit import androidx.test.filters.RequiresDevice -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group4 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.NewTasksAppHelper import com.android.server.wm.flicker.helpers.WindowUtils -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.flicker.testapp.ActivityOptions.LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME import com.android.server.wm.flicker.testapp.ActivityOptions.SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME import com.android.server.wm.traces.common.ComponentMatcher @@ -63,64 +56,61 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group4 -class TaskTransitionTest(val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - private val tapl = LauncherInstrumentation() - private val mTestApp: NewTasksAppHelper = NewTasksAppHelper(instrumentation) - private val mWallpaper by lazy { +class TaskTransitionTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { + private val testApp: NewTasksAppHelper = NewTasksAppHelper(instrumentation) + private val wallpaper by lazy { getWallpaperPackage(instrumentation) ?: error("Unable to obtain wallpaper") } - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - eachRun { - mTestApp.launchViaIntent(wmHelper) - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + eachRun { + testApp.launchViaIntent(wmHelper) } - teardown { - test { - mTestApp.exit(wmHelper) - } - } - transitions { - mTestApp.openNewTask(device, wmHelper) - tapl.pressBack() - wmHelper.StateSyncBuilder() - .withFullScreenApp(mTestApp) - .waitForAndVerify() + } + teardown { + test { + testApp.exit(wmHelper) } } + transitions { + testApp.openNewTask(device, wmHelper) + tapl.pressBack() + wmHelper.StateSyncBuilder() + .withFullScreenApp(testApp) + .waitForAndVerify() + } } /** - * Checks that the wallpaper window is never visible when performing task transitions. + * Checks that the [wallpaper] window is never visible when performing task transitions. * A solid color background should be shown instead. */ @Postsubmit @Test fun wallpaperWindowIsNeverVisible() { testSpec.assertWm { - this.isNonAppWindowInvisible(mWallpaper) + this.isNonAppWindowInvisible(wallpaper) } } /** - * Checks that the wallpaper layer is never visible when performing task transitions. + * Checks that the [wallpaper] layer is never visible when performing task transitions. * A solid color background should be shown instead. */ @Postsubmit @Test fun wallpaperLayerIsNeverVisible() { testSpec.assertLayers { - this.isInvisible(mWallpaper) + this.isInvisible(wallpaper) this.isInvisible(WALLPAPER_BBQ_WRAPPER) } } /** - * Check that the launcher window is never visible when performing task transitions. + * Check that the [ComponentMatcher.LAUNCHER] window is never visible when performing task + * transitions. * A solid color background should be shown above it. */ @Postsubmit @@ -132,7 +122,8 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) { } /** - * Checks that the launcher layer is never visible when performing task transitions. + * Checks that the [ComponentMatcher.LAUNCHER] layer is never visible when performing task + * transitions. * A solid color background should be shown above it. */ @Postsubmit @@ -154,8 +145,8 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) { testSpec.assertLayers { this.invoke("LAUNCH_NEW_TASK_ACTIVITY coversExactly displayBounds") { - it.visibleRegion(LAUNCH_NEW_TASK_ACTIVITY).coversExactly(displayBounds) - } + it.visibleRegion(LAUNCH_NEW_TASK_ACTIVITY).coversExactly(displayBounds) + } .isInvisible(bgColorLayer) .then() // Transitioning @@ -187,55 +178,79 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) { fun newTaskOpensOnTopAndThenCloses() { testSpec.assertWm { this.isAppWindowOnTop(LAUNCH_NEW_TASK_ACTIVITY) - .then() - .isAppWindowOnTop(SPLASH_SCREEN, isOptional = true) - .then() - .isAppWindowOnTop(SIMPLE_ACTIVITY) - .then() - .isAppWindowOnTop(SPLASH_SCREEN, isOptional = true) - .then() - .isAppWindowOnTop(LAUNCH_NEW_TASK_ACTIVITY) + .then() + .isAppWindowOnTop(SPLASH_SCREEN, isOptional = true) + .then() + .isAppWindowOnTop(SIMPLE_ACTIVITY) + .then() + .isAppWindowOnTop(SPLASH_SCREEN, isOptional = true) + .then() + .isAppWindowOnTop(LAUNCH_NEW_TASK_ACTIVITY) } } - /** - * Checks that all parts of the screen are covered at the start and end of the transition - */ + /** {@inheritDoc} */ @Postsubmit @Test - fun entireScreenCovered() = testSpec.entireScreenCovered() + override fun entireScreenCovered() = super.entireScreenCovered() - /** - * Checks that the navbar window is visible throughout the transition - */ + /** {@inheritDoc} */ @Postsubmit @Test - fun navBarWindowIsVisible() = testSpec.navBarWindowIsVisible() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - /** - * Checks that the navbar layer is visible throughout the transition - */ + /** {@inheritDoc} */ @Postsubmit @Test - fun navBarLayerIsVisible() = testSpec.navBarLayerIsVisible() + override fun navBarLayerIsVisibleAtStartAndEnd() = super.navBarLayerIsVisibleAtStartAndEnd() - /** - * Checks that the status bar window is visible throughout the transition - */ + /** {@inheritDoc} */ @Postsubmit @Test - fun statusBarWindowIsVisible() = testSpec.statusBarWindowIsVisible() + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() - /** - * Checks that the status bar layer is visible throughout the transition - */ + /** {@inheritDoc} */ @Postsubmit @Test - fun statusBarLayerIsVisible() = testSpec.statusBarLayerIsVisible() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun navBarWindowIsAlwaysVisible() = super.navBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun statusBarWindowIsAlwaysVisible() = super.statusBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun taskBarWindowIsAlwaysVisible() = super.taskBarWindowIsAlwaysVisible() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() companion object { private val LAUNCH_NEW_TASK_ACTIVITY = - LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME.toFlickerComponent() + LAUNCH_NEW_TASK_ACTIVITY_COMPONENT_NAME.toFlickerComponent() private val SIMPLE_ACTIVITY = SIMPLE_ACTIVITY_AUTO_FOCUS_COMPONENT_NAME.toFlickerComponent() private fun getWallpaperPackage(instrumentation: Instrumentation): IComponentMatcher? { @@ -248,7 +263,7 @@ class TaskTransitionTest(val testSpec: FlickerTestParameter) { @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests(repetitions = 3) + .getConfigNonRotationTests(repetitions = 3) } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt index ea769ef18acd1..edaf4033fbce2 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsBackTest.kt @@ -16,15 +16,13 @@ package com.android.server.wm.flicker.quickswitch -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory @@ -33,11 +31,6 @@ import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.NonResizeableAppHelper import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import com.android.server.wm.traces.common.Rect import org.junit.Assume @@ -64,10 +57,9 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 -open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - private val tapl = LauncherInstrumentation() - +open class QuickSwitchBetweenTwoAppsBackTest( + testSpec: FlickerTestParameter +) : BaseTest(testSpec) { private val testApp1 = SimpleAppHelper(instrumentation) private val testApp2 = NonResizeableAppHelper(instrumentation) @@ -76,32 +68,31 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa Assume.assumeFalse(isShellTransitionsEnabled) } - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - tapl.setExpectedRotation(testSpec.startRotation) - } - eachRun { - testApp1.launchViaIntent(wmHelper) - testApp2.launchViaIntent(wmHelper) - startDisplayBounds = wmHelper.currentState.layerState - .physicalDisplayBounds ?: error("Display not found") - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + tapl.setExpectedRotation(testSpec.startRotation) } - transitions { - tapl.launchedAppState.quickSwitchToPreviousApp() - wmHelper.StateSyncBuilder() - .withNavBarStatusBarVisible() - .waitForAndVerify() + eachRun { + testApp1.launchViaIntent(wmHelper) + testApp2.launchViaIntent(wmHelper) + startDisplayBounds = wmHelper.currentState.layerState + .physicalDisplayBounds ?: error("Display not found") } + } + transitions { + tapl.launchedAppState.quickSwitchToPreviousApp() + wmHelper.StateSyncBuilder() + .withNavOrTaskBarVisible() + .withStatusBarVisible() + .waitForAndVerify() + } - teardown { - test { - testApp1.exit(wmHelper) - testApp2.exit(wmHelper) - } + teardown { + test { + testApp1.exit(wmHelper) + testApp2.exit(wmHelper) } } } @@ -142,8 +133,8 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa } /** - * Checks that [testApp1] windows fill the entire screen (i.e. is "fullscreen") at the end of the - * transition once we have fully quick switched from [testApp2] back to the [testApp1]. + * Checks that [testApp1] windows fill the entire screen (i.e. is "fullscreen") at the end of + * the transition once we have fully quick switched from [testApp2] back to the [testApp1]. */ @Presubmit @Test @@ -154,8 +145,8 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa } /** - * Checks that [testApp1] layers fill the entire screen (i.e. is "fullscreen") at the end of the - * transition once we have fully quick switched from [testApp2] back to the [testApp1]. + * Checks that [testApp1] layers fill the entire screen (i.e. is "fullscreen") at the end of + * the transition once we have fully quick switched from [testApp2] back to the [testApp1]. */ @Presubmit @Test @@ -166,8 +157,8 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa } /** - * Checks that [testApp1] is the top window at the end of the transition once we have fully quick - * switched from [testApp2] back to the [testApp1]. + * Checks that [testApp1] is the top window at the end of the transition once we have fully + * quick switched from [testApp2] back to the [testApp1]. */ @Presubmit @Test @@ -178,60 +169,60 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa } /** - * Checks that [testApp1]'s window starts off invisible and becomes visible at some point before - * the end of the transition and then stays visible until the end of the transition. + * Checks that [testApp1]'s window starts off invisible and becomes visible at some point + * before the end of the transition and then stays visible until the end of the transition. */ @Presubmit @Test fun app1WindowBecomesAndStaysVisible() { testSpec.assertWm { this.isAppWindowInvisible(testApp1) - .then() - .isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true) - .then() - .isAppWindowVisible(testApp1) + .then() + .isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowVisible(testApp1) } } /** - * Checks that [testApp1]'s layer starts off invisible and becomes visible at some point before - * the end of the transition and then stays visible until the end of the transition. + * Checks that [testApp1]'s layer starts off invisible and becomes visible at some point + * before the end of the transition and then stays visible until the end of the transition. */ @Presubmit @Test fun app1LayerBecomesAndStaysVisible() { testSpec.assertLayers { this.isInvisible(testApp1) - .then() - .isVisible(testApp1) + .then() + .isVisible(testApp1) } } /** - * Checks that [testApp2]'s window starts off visible and becomes invisible at some point before - * the end of the transition and then stays invisible until the end of the transition. + * Checks that [testApp2]'s window starts off visible and becomes invisible at some point + * before the end of the transition and then stays invisible until the end of the transition. */ @Presubmit @Test fun app2WindowBecomesAndStaysInvisible() { testSpec.assertWm { this.isAppWindowVisible(testApp2) - .then() - .isAppWindowInvisible(testApp2) + .then() + .isAppWindowInvisible(testApp2) } } /** - * Checks that [testApp2]'s layer starts off visible and becomes invisible at some point before - * the end of the transition and then stays invisible until the end of the transition. + * Checks that [testApp2]'s layer starts off visible and becomes invisible at some point + * before the end of the transition and then stays invisible until the end of the transition. */ @Presubmit @Test fun app2LayerBecomesAndStaysInvisible() { testSpec.assertLayers { this.isVisible(testApp2) - .then() - .isInvisible(testApp2) + .then() + .isInvisible(testApp2) } } @@ -245,13 +236,13 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa fun app1WindowIsVisibleOnceApp2WindowIsInvisible() { testSpec.assertWm { this.isAppWindowVisible(testApp2) - .then() - // TODO: Do we actually want to test this? Seems too implementation specific... - .isAppWindowVisible(ComponentMatcher.LAUNCHER, isOptional = true) - .then() - .isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true) - .then() - .isAppWindowVisible(testApp1) + .then() + // TODO: Do we actually want to test this? Seems too implementation specific... + .isAppWindowVisible(ComponentMatcher.LAUNCHER, isOptional = true) + .then() + .isAppWindowVisible(ComponentMatcher.SNAPSHOT, isOptional = true) + .then() + .isAppWindowVisible(testApp1) } } @@ -265,51 +256,25 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa fun app1LayerIsVisibleOnceApp2LayerIsInvisible() { testSpec.assertLayers { this.isVisible(testApp2) - .then() - .isVisible(ComponentMatcher.LAUNCHER, isOptional = true) - .then() - .isVisible(ComponentMatcher.SNAPSHOT, isOptional = true) - .then() - .isVisible(testApp1) + .then() + .isVisible(ComponentMatcher.LAUNCHER, isOptional = true) + .then() + .isVisible(ComponentMatcher.SNAPSHOT, isOptional = true) + .then() + .isVisible(testApp1) } } - /** - * Checks that the navbar window is visible throughout the entire transition. - */ - @Presubmit - @Test - fun navBarWindowIsAlwaysVisible() = testSpec.navBarWindowIsVisible() - - /** - * Checks that the navbar layer is visible throughout the entire transition. - */ - @Presubmit - @Test - fun navBarLayerAlwaysIsVisible() = testSpec.navBarLayerIsVisible() - - /** - * Checks that the navbar is always in the right position and covers the expected region. - * - * NOTE: This doesn't check that the navbar is visible or not. - */ + /** {@inheritDoc} */ @FlakyTest @Test - fun navbarIsAlwaysInRightPosition() = testSpec.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - /** - * Checks that the status bar window is visible throughout the entire transition. - */ - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsVisible() - - /** - * Checks that the status bar layer is visible throughout the entire transition. - */ - @Presubmit - @Test - fun statusBarLayerIsAlwaysVisible() = testSpec.statusBarLayerIsVisible() + override fun statusBarLayerIsVisibleAtStartAndEnd() = + super.statusBarLayerIsVisibleAtStartAndEnd() companion object { private var startDisplayBounds = Rect.EMPTY @@ -318,13 +283,13 @@ open class QuickSwitchBetweenTwoAppsBackTest(private val testSpec: FlickerTestPa @JvmStatic fun getParams(): Collection { return FlickerTestParameterFactory.getInstance() - .getConfigNonRotationTests( - repetitions = 3, - supportedNavigationModes = listOf( - WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY - ), - supportedRotations = listOf(Surface.ROTATION_0, Surface.ROTATION_90) - ) + .getConfigNonRotationTests( + repetitions = 3, + supportedNavigationModes = listOf( + WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY + ), + supportedRotations = listOf(Surface.ROTATION_0, Surface.ROTATION_90) + ) } } } diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt index 7e69faacfed7f..d3e8c650b2b71 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchBetweenTwoAppsForwardTest.kt @@ -16,15 +16,13 @@ package com.android.server.wm.flicker.quickswitch -import android.app.Instrumentation import android.platform.test.annotations.FlakyTest +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory @@ -33,11 +31,6 @@ import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.NonResizeableAppHelper import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import com.android.server.wm.traces.common.Rect import org.junit.Assume @@ -64,10 +57,9 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 -open class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - private val tapl = LauncherInstrumentation() - +open class QuickSwitchBetweenTwoAppsForwardTest( + testSpec: FlickerTestParameter +) : BaseTest(testSpec) { private val testApp1 = SimpleAppHelper(instrumentation) private val testApp2 = NonResizeableAppHelper(instrumentation) @@ -76,36 +68,36 @@ open class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTes Assume.assumeFalse(isShellTransitionsEnabled) } - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - tapl.setExpectedRotation(testSpec.startRotation) - } - eachRun { - testApp1.launchViaIntent(wmHelper) - testApp2.launchViaIntent(wmHelper) - tapl.launchedAppState.quickSwitchToPreviousApp() - wmHelper.StateSyncBuilder() - .withNavBarStatusBarVisible() - .waitForAndVerify() - startDisplayBounds = wmHelper.currentState.layerState - .physicalDisplayBounds ?: error("Display not found") - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + tapl.setExpectedRotation(testSpec.startRotation) } - transitions { - tapl.launchedAppState.quickSwitchToPreviousAppSwipeLeft() + eachRun { + testApp1.launchViaIntent(wmHelper) + testApp2.launchViaIntent(wmHelper) + tapl.launchedAppState.quickSwitchToPreviousApp() wmHelper.StateSyncBuilder() - .withNavBarStatusBarVisible() + .withNavOrTaskBarVisible() + .withStatusBarVisible() .waitForAndVerify() + startDisplayBounds = wmHelper.currentState.layerState + .physicalDisplayBounds ?: error("Display not found") } + } + transitions { + tapl.launchedAppState.quickSwitchToPreviousAppSwipeLeft() + wmHelper.StateSyncBuilder() + .withNavOrTaskBarVisible() + .withStatusBarVisible() + .waitForAndVerify() + } - teardown { - test { - testApp1.exit(wmHelper) - testApp2.exit(wmHelper) - } + teardown { + test { + testApp1.exit(wmHelper) + testApp2.exit(wmHelper) } } } @@ -279,52 +271,28 @@ open class QuickSwitchBetweenTwoAppsForwardTest(private val testSpec: FlickerTes } } - /** - * Checks that the navbar window is visible throughout the entire transition. - */ - @Presubmit - @Test - open fun navBarWindowIsAlwaysVisible() { - testSpec.navBarWindowIsVisible() - } - - /** - * Checks that the navbar layer is visible throughout the entire transition. - */ - @Presubmit - @Test - open fun navBarLayerAlwaysIsVisible() { - testSpec.navBarLayerIsVisible() - } - - /** - * Checks that the navbar is always in the right position and covers the expected region. - * - * NOTE: This doesn't check that the navbar is visible or not. - */ + /** {@inheritDoc} */ @FlakyTest @Test - open fun navbarIsAlwaysInRightPosition() { - testSpec.navBarLayerRotatesAndScales() - } + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() - /** - * Checks that the status bar window is visible throughout the entire transition. - */ - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - open fun statusBarWindowIsAlwaysVisible() { - testSpec.statusBarWindowIsVisible() - } + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() - /** - * Checks that the status bar layer is visible throughout the entire transition. - */ - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - open fun statusBarLayerIsAlwaysVisible() { - testSpec.statusBarLayerIsVisible() - } + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() + + /** {@inheritDoc} */ + @Postsubmit + @Test + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() companion object { private var startDisplayBounds = Rect.EMPTY diff --git a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt index 496716a4d9f73..9fb05c18eea35 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/quickswitch/QuickSwitchFromLauncherTest.kt @@ -16,26 +16,18 @@ package com.android.server.wm.flicker.quickswitch -import android.app.Instrumentation +import android.platform.test.annotations.Postsubmit import android.platform.test.annotations.Presubmit import android.platform.test.annotations.RequiresDevice import android.view.Surface import android.view.WindowManagerPolicyConstants -import androidx.test.platform.app.InstrumentationRegistry -import com.android.launcher3.tapl.LauncherInstrumentation -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerParametersRunnerFactory import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group1 import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.SimpleAppHelper -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import com.android.server.wm.traces.common.Rect import org.junit.FixMethodOrder @@ -60,44 +52,40 @@ import org.junit.runners.Parameterized @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @Group1 -class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { - private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - private val taplInstrumentation = LauncherInstrumentation() - +class QuickSwitchFromLauncherTest(testSpec: FlickerTestParameter) : BaseTest(testSpec) { private val testApp = SimpleAppHelper(instrumentation) - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - setup { - test { - taplInstrumentation.setExpectedRotation(testSpec.startRotation) - } - - eachRun { - testApp.launchViaIntent(wmHelper) - device.pressHome() - wmHelper.StateSyncBuilder() - .withHomeActivityVisible() - .withWindowSurfaceDisappeared(testApp) - .waitForAndVerify() - - startDisplayBounds = wmHelper.currentState.layerState - .physicalDisplayBounds ?: error("Display not found") - } + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { + setup { + test { + tapl.setExpectedRotation(testSpec.startRotation) } - transitions { - taplInstrumentation.workspace.quickSwitchToPreviousApp() + + eachRun { + testApp.launchViaIntent(wmHelper) + device.pressHome() wmHelper.StateSyncBuilder() - .withFullScreenApp(testApp) - .withNavBarStatusBarVisible() + .withHomeActivityVisible() + .withWindowSurfaceDisappeared(testApp) .waitForAndVerify() - } - teardown { - eachRun { - testApp.exit(wmHelper) - } + startDisplayBounds = wmHelper.currentState.layerState + .physicalDisplayBounds ?: error("Display not found") + } + } + transitions { + tapl.workspace.quickSwitchToPreviousApp() + wmHelper.StateSyncBuilder() + .withFullScreenApp(testApp) + .withNavOrTaskBarVisible() + .withStatusBarVisible() + .waitForAndVerify() + } + + teardown { + eachRun { + testApp.exit(wmHelper) } } } @@ -150,8 +138,8 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } /** - * Checks that the transition starts with the launcher windows filling/covering exactly the - * entirety of the display. + * Checks that the transition starts with the [ComponentMatcher.LAUNCHER] windows + * filling/covering exactly display size */ @Presubmit @Test @@ -162,8 +150,8 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } /** - * Checks that the transition starts with the launcher layers filling/covering exactly the - * entirety of the display. + * Checks that the transition starts with the [ComponentMatcher.LAUNCHER] layers + * filling/covering exactly the display size. */ @Presubmit @Test @@ -174,7 +162,7 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } /** - * Checks that the transition starts with the launcher being the top window. + * Checks that the transition starts with the [ComponentMatcher.LAUNCHER] being the top window. */ @Presubmit @Test @@ -225,7 +213,8 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } /** - * Checks that the launcher window starts off visible and becomes invisible at some point before + * Checks that the [ComponentMatcher.LAUNCHER] window starts off visible and becomes invisible + * at some point before * the end of the transition and then stays invisible until the end of the transition. */ @Presubmit @@ -239,7 +228,8 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } /** - * Checks that the launcher layer starts off visible and becomes invisible at some point before + * Checks that the [ComponentMatcher.LAUNCHER] layer starts off visible and becomes invisible + * at some point before * the end of the transition and then stays invisible until the end of the transition. */ @Presubmit @@ -253,7 +243,8 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } /** - * Checks that the launcher window is visible at least until the app window is visible. Ensures + * Checks that the [ComponentMatcher.LAUNCHER] window is visible at least until the app window + * is visible. Ensures * that at any point, either the launcher or [testApp] windows are at least partially visible. */ @Presubmit @@ -269,8 +260,9 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } /** - * Checks that the launcher layer is visible at least until the app layer is visible. Ensures - * that at any point, either the launcher or [testApp] layers are at least partially visible. + * Checks that the [ComponentMatcher.LAUNCHER] layer is visible at least until the app layer + * is visible. Ensures that at any point, either the launcher or [testApp] layers are at least + * partially visible. */ @Presubmit @Test @@ -284,49 +276,28 @@ class QuickSwitchFromLauncherTest(private val testSpec: FlickerTestParameter) { } } - /** - * Checks that the navbar window is visible throughout the entire transition. - */ - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun navBarWindowIsAlwaysVisible() = testSpec.navBarWindowIsVisible() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() - /** - * Checks that the navbar layer is visible throughout the entire transition. - */ - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun navBarLayerAlwaysIsVisible() = testSpec.navBarLayerIsVisible() + override fun taskBarLayerIsVisibleAtStartAndEnd() = super.taskBarLayerIsVisibleAtStartAndEnd() - /** - * Checks that the navbar is always in the right position and covers the expected region. - * - * NOTE: This doesn't check that the navbar is visible or not. - */ - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun navbarIsAlwaysInRightPosition() = testSpec.navBarLayerRotatesAndScales() + override fun visibleLayersShownMoreThanOneConsecutiveEntry() = + super.visibleLayersShownMoreThanOneConsecutiveEntry() - /** - * Checks that the status bar window is visible throughout the entire transition. - */ - @Presubmit + /** {@inheritDoc} */ + @Postsubmit @Test - fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsVisible() - - /** - * Checks that the status bar layer is visible throughout the entire transition. - */ - @Presubmit - @Test - fun statusBarLayerIsAlwaysVisible() = testSpec.statusBarLayerIsVisible() - - /** - * Checks that the screen is always fully covered by visible layers throughout the transition. - */ - @Presubmit - @Test - fun screenIsAlwaysFilled() = testSpec.entireScreenCovered() + override fun visibleWindowsShownMoreThanOneConsecutiveEntry() = + super.visibleWindowsShownMoreThanOneConsecutiveEntry() companion object { private var startDisplayBounds = Rect.EMPTY 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 11dfeb57ef070..aa6a5a0eb8316 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 @@ -25,9 +25,6 @@ import com.android.server.wm.flicker.FlickerTestParameterFactory import com.android.server.wm.flicker.annotation.Group3 import com.android.server.wm.flicker.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.SimpleAppHelper -import com.android.server.wm.flicker.statusBarLayerIsVisible -import com.android.server.wm.flicker.statusBarLayerRotatesScales -import com.android.server.wm.flicker.statusBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder import org.junit.Test @@ -126,38 +123,17 @@ class ChangeAppRotationTest( rotationLayerAppearsAndVanishesAssertion() } - /** - * Checks that the status bar window is visible and above the app windows in all WM - * trace entries - */ - @Presubmit - @Test - fun statusBarWindowIsVisible() { - testSpec.statusBarWindowIsVisible() - } - - /** - * Checks that the status bar layer is visible at the start and end of the transition - */ - @Presubmit - @Test - fun statusBarLayerIsVisible() { - testSpec.statusBarLayerIsVisible() - } - - /** - * Checks the position of the status bar at the start and end of the transition - */ + /** {@inheritDoc} */ @FlakyTest(bugId = 206753786) @Test - fun statusBarLayerRotatesScales() = testSpec.statusBarLayerRotatesScales() + override fun statusBarLayerPositionAtStartAndEnd() = + super.statusBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest @Test - override fun navBarLayerRotatesAndScales() { - super.navBarLayerRotatesAndScales() - } + override fun navBarLayerPositionAtStartAndEnd() = + super.navBarLayerPositionAtStartAndEnd() /** {@inheritDoc} */ @FlakyTest 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 index 4b094247bdb3c..36a152117dcc1 100644 --- a/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt +++ b/tests/FlickerTests/src/com/android/server/wm/flicker/rotation/RotationTransition.kt @@ -16,30 +16,23 @@ package com.android.server.wm.flicker.rotation -import android.app.Instrumentation import android.platform.test.annotations.Presubmit -import androidx.test.platform.app.InstrumentationRegistry -import com.android.server.wm.flicker.FlickerBuilderProvider +import com.android.server.wm.flicker.BaseTest import com.android.server.wm.flicker.FlickerTestParameter import com.android.server.wm.flicker.dsl.FlickerBuilder -import com.android.server.wm.flicker.entireScreenCovered import com.android.server.wm.flicker.helpers.StandardAppHelper import com.android.server.wm.flicker.helpers.setRotation -import com.android.server.wm.flicker.navBarLayerIsVisible -import com.android.server.wm.flicker.navBarLayerRotatesAndScales -import com.android.server.wm.flicker.navBarWindowIsVisible import com.android.server.wm.traces.common.ComponentMatcher import org.junit.Test /** * Base class for app rotation tests */ -abstract class RotationTransition(protected val testSpec: FlickerTestParameter) { +abstract class RotationTransition(testSpec: FlickerTestParameter) : BaseTest(testSpec) { protected abstract val testApp: StandardAppHelper - protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() - - protected open val transition: FlickerBuilder.() -> Unit = { + /** {@inheritDoc} */ + override val transition: FlickerBuilder.() -> Unit = { setup { eachRun { this.setRotation(testSpec.startRotation) @@ -55,53 +48,14 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter) } } - /** - * Entry point for the test runner. It will use this method to initialize and cache - * flicker executions - */ - @FlickerBuilderProvider - fun buildFlicker(): FlickerBuilder { - return FlickerBuilder(instrumentation).apply { - transition() - } - } - - /** - * Checks that the navigation bar window is visible and above the app windows in all WM - * trace entries - */ + /** {@inheritDoc} */ @Presubmit @Test - open fun navBarWindowIsVisible() { - testSpec.navBarWindowIsVisible() - } - - /** - * Checks that the navigation bar layer is visible at the start and end of the transition - */ - @Presubmit - @Test - open fun navBarLayerIsVisible() { - testSpec.navBarLayerIsVisible() - } - - /** - * Checks the position of the navigation bar at the start and end of the transition - */ - @Presubmit - @Test - open fun navBarLayerRotatesAndScales() = testSpec.navBarLayerRotatesAndScales() - - /** - * Checks that all layers that are visible on the trace, are visible for at least 2 - * consecutive entries. - */ - @Presubmit - @Test - open fun visibleLayersShownMoreThanOneConsecutiveEntry() { + override fun visibleLayersShownMoreThanOneConsecutiveEntry() { testSpec.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry( - ignoreLayers = listOf(ComponentMatcher.SPLASH_SCREEN, + ignoreLayers = listOf( + ComponentMatcher.SPLASH_SCREEN, ComponentMatcher.SNAPSHOT, ComponentMatcher("", "SecondaryHomeHandle") ) @@ -109,25 +63,6 @@ abstract class RotationTransition(protected val testSpec: FlickerTestParameter) } } - /** - * Checks that all windows that are visible on the trace, are visible for at least 2 - * consecutive entries. - */ - @Presubmit - @Test - open fun visibleWindowsShownMoreThanOneConsecutiveEntry() { - testSpec.assertWm { - this.visibleWindowsShownMoreThanOneConsecutiveEntry() - } - } - - /** - * Checks that all parts of the screen are covered during the transition - */ - @Presubmit - @Test - open fun entireScreenCovered() = testSpec.entireScreenCovered() - /** * Checks that [testApp] layer covers the entire screen at the start of the transition */ 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 09be7eec71d1a..b2a2381c55789 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 @@ -29,6 +29,7 @@ import com.android.server.wm.flicker.helpers.SeamlessRotationAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.server.wm.traces.common.ComponentMatcher import org.junit.FixMethodOrder +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters @@ -81,14 +82,18 @@ open class SeamlessAppRotationTest( ) : RotationTransition(testSpec) { override val testApp = SeamlessRotationAppHelper(instrumentation) + /** {@inheritDoc} */ override val transition: FlickerBuilder.() -> Unit get() = { super.transition(this) setup { test { - testApp.launchViaIntent(wmHelper, - stringExtras = mapOf(ActivityOptions.EXTRA_STARVE_UI_THREAD - to testSpec.starveUiThread.toString()) + testApp.launchViaIntent( + wmHelper, + stringExtras = mapOf( + ActivityOptions.EXTRA_STARVE_UI_THREAD + to testSpec.starveUiThread.toString() + ) ) } } @@ -122,8 +127,10 @@ open class SeamlessAppRotationTest( val appWindow = it.windowState(testApp.`package`) val rotationAnimation = appWindow.windowState?.attributes?.rotationAnimation ?: 0 appWindow.verify("isRotationSeamless") - .that(rotationAnimation - .and(WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS)) + .that( + rotationAnimation + .and(WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS) + ) .isGreaterThan(0) } } @@ -156,6 +163,18 @@ open class SeamlessAppRotationTest( } } + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. App is full screen") + override fun statusBarLayerPositionAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. App is full screen") + override fun statusBarLayerIsVisibleAtStartAndEnd() { } + + /** {@inheritDoc} */ + @Ignore("Not applicable to this CUJ. App is full screen") + override fun statusBarWindowIsAlwaysVisible() { } + /** * Checks that the [ComponentMatcher.STATUS_BAR] window is invisible during the whole * transition @@ -194,7 +213,7 @@ open class SeamlessAppRotationTest( /** {@inheritDoc} */ @FlakyTest @Test - override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales() + override fun navBarLayerPositionAtStartAndEnd() = super.navBarLayerPositionAtStartAndEnd() companion object { private val FlickerTestParameter.starveUiThread