Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt +3 −3 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { ServiceManager.getService(Context.NOTIFICATION_SERVICE)) protected val uid = context.packageManager.getApplicationInfo( testApp.component.packageName, 0).uid testApp.`package`, 0).uid protected abstract val transition: FlickerBuilder.() -> Unit Loading @@ -59,7 +59,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { return { setup { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_ALL) testApp.launchViaIntent(wmHelper) waitAndGetAddBubbleBtn() Loading @@ -69,7 +69,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { teardown { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_NONE) testApp.exit() } Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt +8 −7 Original line number Diff line number Diff line Loading @@ -16,10 +16,10 @@ package com.android.wm.shell.flicker.bubble import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.view.WindowInsets import android.view.WindowManager import android.platform.test.annotations.FlakyTest import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.Until Loading @@ -29,8 +29,8 @@ 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 import org.junit.runner.RunWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** Loading @@ -54,20 +54,21 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr val addBubbleBtn = waitAndGetAddBubbleBtn() addBubbleBtn?.click() ?: error("Bubble widget not found") device.sleep() wmHelper.waitFor("noAppWindowsOnTop") { it.wmState.topVisibleAppWindow.isEmpty() } wmHelper.StateSyncBuilder() .withoutTopVisibleAppWindows() .waitForAndVerify() device.wakeUp() } } transitions { // Swipe & wait for the notification shade to expand so all can be seen val wm = context.getSystemService(WindowManager::class.java) val metricInsets = wm.getCurrentWindowMetrics().windowInsets ?: error("Unable to obtain WM service") val metricInsets = wm.currentWindowMetrics.windowInsets val insets = metricInsets.getInsetsIgnoringVisibility( WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout()) device.swipe(100, insets.top + 100, 100, device.getDisplayHeight() / 2, 4) device.swipe(100, insets.top + 100, 100, device.displayHeight / 2, 4) device.waitForIdle(2000) instrumentation.uiAutomation.syncInputTransactions() Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt +1 −35 Original line number Diff line number Diff line Loading @@ -17,44 +17,10 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation import com.android.server.wm.flicker.Flicker import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.traces.common.FlickerComponentName import com.android.server.wm.traces.common.region.Region class AppPairsHelper( instrumentation: Instrumentation, activityLabel: String, component: FlickerComponentName ) : BaseAppHelper(instrumentation, activityLabel, component) { fun getPrimaryBounds(dividerBounds: Region): Region { val primaryAppBounds = Region.from(0, 0, dividerBounds.bounds.right, dividerBounds.bounds.bottom + WindowUtils.dockedStackDividerInset) return primaryAppBounds } fun getSecondaryBounds(dividerBounds: Region): Region { val displayBounds = WindowUtils.displayBounds val secondaryAppBounds = Region.from(0, dividerBounds.bounds.bottom - WindowUtils.dockedStackDividerInset, displayBounds.right, displayBounds.bottom - WindowUtils.navigationBarFrameHeight) return secondaryAppBounds } companion object { const val TEST_REPETITIONS = 1 const val TIMEOUT_MS = 3_000L fun Flicker.waitAppsShown(app1: SplitScreenHelper?, app2: SplitScreenHelper?) { wmHelper.waitFor("primaryAndSecondaryAppsVisible") { dump -> val primaryAppVisible = app1?.let { dump.wmState.isWindowSurfaceShown(app1.defaultWindowName) } ?: false val secondaryAppVisible = app2?.let { dump.wmState.isWindowSurfaceShown(app2.defaultWindowName) } ?: false primaryAppVisible && secondaryAppVisible } } } } ) : BaseAppHelper(instrumentation, activityLabel, component) libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ abstract class BaseAppHelper( component, LauncherStrategyFactory.getInstance(instrumentation).launcherStrategy ) { private val appSelector = By.pkg(component.packageName).depth(0) private val appSelector = By.pkg(`package`).depth(0) protected val isTelevision: Boolean get() = context.packageManager.run { Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt +9 −23 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.FIND_TIMEOUT import com.android.server.wm.traces.parser.toFlickerComponent Loading @@ -35,8 +34,7 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper( * * @param wmHelper Helper used to wait for WindowManager states */ @JvmOverloads open fun openIME(wmHelper: WindowManagerStateHelper? = null) { open fun openIME(wmHelper: WindowManagerStateHelper) { if (!isTelevision) { val editText = uiDevice.wait( Until.findObject(By.res(getPackage(), "plain_text_input")), Loading @@ -47,7 +45,9 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper( "was left in an unknown state (e.g. in split screen)" } editText.click() waitAndAssertIMEShown(uiDevice, wmHelper) wmHelper.StateSyncBuilder() .withImeShown() .waitForAndVerify() } else { // If we do the same thing as above - editText.click() - on TV, that's going to force TV // into the touch mode. We really don't want that. Loading @@ -55,32 +55,18 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper( } } protected fun waitAndAssertIMEShown( device: UiDevice, wmHelper: WindowManagerStateHelper? = null ) { if (wmHelper == null) { device.waitForIdle() } else { wmHelper.waitImeShown() } } /** * Opens the IME and wait for it to be gone * * @param wmHelper Helper used to wait for WindowManager states */ @JvmOverloads open fun closeIME(wmHelper: WindowManagerStateHelper? = null) { open fun closeIME(wmHelper: WindowManagerStateHelper) { if (!isTelevision) { uiDevice.pressBack() // Using only the AccessibilityInfo it is not possible to identify if the IME is active if (wmHelper == null) { uiDevice.waitForIdle() } else { wmHelper.waitImeGone() } wmHelper.StateSyncBuilder() .withImeGone() .waitForAndVerify() } else { // While pressing the back button should close the IME on TV as well, it may also lead // to the app closing. So let's instead just ask the app to close the IME. Loading Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt +3 −3 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { ServiceManager.getService(Context.NOTIFICATION_SERVICE)) protected val uid = context.packageManager.getApplicationInfo( testApp.component.packageName, 0).uid testApp.`package`, 0).uid protected abstract val transition: FlickerBuilder.() -> Unit Loading @@ -59,7 +59,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { return { setup { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_ALL) testApp.launchViaIntent(wmHelper) waitAndGetAddBubbleBtn() Loading @@ -69,7 +69,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { teardown { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_NONE) testApp.exit() } Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt +8 −7 Original line number Diff line number Diff line Loading @@ -16,10 +16,10 @@ package com.android.wm.shell.flicker.bubble import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.view.WindowInsets import android.view.WindowManager import android.platform.test.annotations.FlakyTest import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.Until Loading @@ -29,8 +29,8 @@ 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 import org.junit.runner.RunWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized /** Loading @@ -54,20 +54,21 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr val addBubbleBtn = waitAndGetAddBubbleBtn() addBubbleBtn?.click() ?: error("Bubble widget not found") device.sleep() wmHelper.waitFor("noAppWindowsOnTop") { it.wmState.topVisibleAppWindow.isEmpty() } wmHelper.StateSyncBuilder() .withoutTopVisibleAppWindows() .waitForAndVerify() device.wakeUp() } } transitions { // Swipe & wait for the notification shade to expand so all can be seen val wm = context.getSystemService(WindowManager::class.java) val metricInsets = wm.getCurrentWindowMetrics().windowInsets ?: error("Unable to obtain WM service") val metricInsets = wm.currentWindowMetrics.windowInsets val insets = metricInsets.getInsetsIgnoringVisibility( WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout()) device.swipe(100, insets.top + 100, 100, device.getDisplayHeight() / 2, 4) device.swipe(100, insets.top + 100, 100, device.displayHeight / 2, 4) device.waitForIdle(2000) instrumentation.uiAutomation.syncInputTransactions() Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt +1 −35 Original line number Diff line number Diff line Loading @@ -17,44 +17,10 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation import com.android.server.wm.flicker.Flicker import com.android.server.wm.flicker.helpers.WindowUtils import com.android.server.wm.traces.common.FlickerComponentName import com.android.server.wm.traces.common.region.Region class AppPairsHelper( instrumentation: Instrumentation, activityLabel: String, component: FlickerComponentName ) : BaseAppHelper(instrumentation, activityLabel, component) { fun getPrimaryBounds(dividerBounds: Region): Region { val primaryAppBounds = Region.from(0, 0, dividerBounds.bounds.right, dividerBounds.bounds.bottom + WindowUtils.dockedStackDividerInset) return primaryAppBounds } fun getSecondaryBounds(dividerBounds: Region): Region { val displayBounds = WindowUtils.displayBounds val secondaryAppBounds = Region.from(0, dividerBounds.bounds.bottom - WindowUtils.dockedStackDividerInset, displayBounds.right, displayBounds.bottom - WindowUtils.navigationBarFrameHeight) return secondaryAppBounds } companion object { const val TEST_REPETITIONS = 1 const val TIMEOUT_MS = 3_000L fun Flicker.waitAppsShown(app1: SplitScreenHelper?, app2: SplitScreenHelper?) { wmHelper.waitFor("primaryAndSecondaryAppsVisible") { dump -> val primaryAppVisible = app1?.let { dump.wmState.isWindowSurfaceShown(app1.defaultWindowName) } ?: false val secondaryAppVisible = app2?.let { dump.wmState.isWindowSurfaceShown(app2.defaultWindowName) } ?: false primaryAppVisible && secondaryAppVisible } } } } ) : BaseAppHelper(instrumentation, activityLabel, component)
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ abstract class BaseAppHelper( component, LauncherStrategyFactory.getInstance(instrumentation).launcherStrategy ) { private val appSelector = By.pkg(component.packageName).depth(0) private val appSelector = By.pkg(`package`).depth(0) protected val isTelevision: Boolean get() = context.packageManager.run { Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt +9 −23 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.FIND_TIMEOUT import com.android.server.wm.traces.parser.toFlickerComponent Loading @@ -35,8 +34,7 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper( * * @param wmHelper Helper used to wait for WindowManager states */ @JvmOverloads open fun openIME(wmHelper: WindowManagerStateHelper? = null) { open fun openIME(wmHelper: WindowManagerStateHelper) { if (!isTelevision) { val editText = uiDevice.wait( Until.findObject(By.res(getPackage(), "plain_text_input")), Loading @@ -47,7 +45,9 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper( "was left in an unknown state (e.g. in split screen)" } editText.click() waitAndAssertIMEShown(uiDevice, wmHelper) wmHelper.StateSyncBuilder() .withImeShown() .waitForAndVerify() } else { // If we do the same thing as above - editText.click() - on TV, that's going to force TV // into the touch mode. We really don't want that. Loading @@ -55,32 +55,18 @@ open class ImeAppHelper(instrumentation: Instrumentation) : BaseAppHelper( } } protected fun waitAndAssertIMEShown( device: UiDevice, wmHelper: WindowManagerStateHelper? = null ) { if (wmHelper == null) { device.waitForIdle() } else { wmHelper.waitImeShown() } } /** * Opens the IME and wait for it to be gone * * @param wmHelper Helper used to wait for WindowManager states */ @JvmOverloads open fun closeIME(wmHelper: WindowManagerStateHelper? = null) { open fun closeIME(wmHelper: WindowManagerStateHelper) { if (!isTelevision) { uiDevice.pressBack() // Using only the AccessibilityInfo it is not possible to identify if the IME is active if (wmHelper == null) { uiDevice.waitForIdle() } else { wmHelper.waitImeGone() } wmHelper.StateSyncBuilder() .withImeGone() .waitForAndVerify() } else { // While pressing the back button should close the IME on TV as well, it may also lead // to the app closing. So let's instead just ask the app to close the IME. Loading