Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/BaseBubbleScreen.kt +3 −3 Original line number Original line Diff line number Diff line Loading @@ -48,7 +48,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { ServiceManager.getService(Context.NOTIFICATION_SERVICE)) ServiceManager.getService(Context.NOTIFICATION_SERVICE)) protected val uid = context.packageManager.getApplicationInfo( protected val uid = context.packageManager.getApplicationInfo( testApp.component.packageName, 0).uid testApp.`package`, 0).uid protected abstract val transition: FlickerBuilder.() -> Unit protected abstract val transition: FlickerBuilder.() -> Unit Loading @@ -59,7 +59,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { return { return { setup { setup { test { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_ALL) uid, NotificationManager.BUBBLE_PREFERENCE_ALL) testApp.launchViaIntent(wmHelper) testApp.launchViaIntent(wmHelper) waitAndGetAddBubbleBtn() waitAndGetAddBubbleBtn() Loading @@ -69,7 +69,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { teardown { teardown { test { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_NONE) uid, NotificationManager.BUBBLE_PREFERENCE_NONE) testApp.exit() testApp.exit() } } Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt +8 −7 Original line number Original line Diff line number Diff line Loading @@ -16,10 +16,10 @@ package com.android.wm.shell.flicker.bubble package com.android.wm.shell.flicker.bubble import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.platform.test.annotations.Presubmit import android.view.WindowInsets import android.view.WindowInsets import android.view.WindowManager import android.view.WindowManager import android.platform.test.annotations.FlakyTest import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.Until 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.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import org.junit.Assume import org.junit.Assume import org.junit.runner.RunWith import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized /** /** Loading @@ -54,20 +54,21 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr val addBubbleBtn = waitAndGetAddBubbleBtn() val addBubbleBtn = waitAndGetAddBubbleBtn() addBubbleBtn?.click() ?: error("Bubble widget not found") addBubbleBtn?.click() ?: error("Bubble widget not found") device.sleep() device.sleep() wmHelper.waitFor("noAppWindowsOnTop") { wmHelper.StateSyncBuilder() it.wmState.topVisibleAppWindow.isEmpty() .withoutTopVisibleAppWindows() } .waitForAndVerify() device.wakeUp() device.wakeUp() } } } } transitions { transitions { // Swipe & wait for the notification shade to expand so all can be seen // Swipe & wait for the notification shade to expand so all can be seen val wm = context.getSystemService(WindowManager::class.java) 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( val insets = metricInsets.getInsetsIgnoringVisibility( WindowInsets.Type.statusBars() WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout()) 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) device.waitForIdle(2000) instrumentation.uiAutomation.syncInputTransactions() instrumentation.uiAutomation.syncInputTransactions() Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt +1 −35 Original line number Original line Diff line number Diff line Loading @@ -17,44 +17,10 @@ package com.android.wm.shell.flicker.helpers package com.android.wm.shell.flicker.helpers import android.app.Instrumentation 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.FlickerComponentName import com.android.server.wm.traces.common.region.Region class AppPairsHelper( class AppPairsHelper( instrumentation: Instrumentation, instrumentation: Instrumentation, activityLabel: String, activityLabel: String, component: FlickerComponentName component: FlickerComponentName ) : BaseAppHelper(instrumentation, activityLabel, component) { ) : 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 } } } } libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -40,7 +40,7 @@ abstract class BaseAppHelper( component, component, LauncherStrategyFactory.getInstance(instrumentation).launcherStrategy 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 protected val isTelevision: Boolean get() = context.packageManager.run { get() = context.packageManager.run { Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt +9 −23 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation import android.app.Instrumentation import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.FIND_TIMEOUT import com.android.server.wm.flicker.helpers.FIND_TIMEOUT import com.android.server.wm.traces.parser.toFlickerComponent 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 * @param wmHelper Helper used to wait for WindowManager states */ */ @JvmOverloads open fun openIME(wmHelper: WindowManagerStateHelper) { open fun openIME(wmHelper: WindowManagerStateHelper? = null) { if (!isTelevision) { if (!isTelevision) { val editText = uiDevice.wait( val editText = uiDevice.wait( Until.findObject(By.res(getPackage(), "plain_text_input")), 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)" "was left in an unknown state (e.g. in split screen)" } } editText.click() editText.click() waitAndAssertIMEShown(uiDevice, wmHelper) wmHelper.StateSyncBuilder() .withImeShown() .waitForAndVerify() } else { } else { // If we do the same thing as above - editText.click() - on TV, that's going to force TV // 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. // 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 * Opens the IME and wait for it to be gone * * * @param wmHelper Helper used to wait for WindowManager states * @param wmHelper Helper used to wait for WindowManager states */ */ @JvmOverloads open fun closeIME(wmHelper: WindowManagerStateHelper) { open fun closeIME(wmHelper: WindowManagerStateHelper? = null) { if (!isTelevision) { if (!isTelevision) { uiDevice.pressBack() uiDevice.pressBack() // Using only the AccessibilityInfo it is not possible to identify if the IME is active // Using only the AccessibilityInfo it is not possible to identify if the IME is active if (wmHelper == null) { wmHelper.StateSyncBuilder() uiDevice.waitForIdle() .withImeGone() } else { .waitForAndVerify() wmHelper.waitImeGone() } } else { } else { // While pressing the back button should close the IME on TV as well, it may also lead // 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. // 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 Original line Diff line number Diff line Loading @@ -48,7 +48,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { ServiceManager.getService(Context.NOTIFICATION_SERVICE)) ServiceManager.getService(Context.NOTIFICATION_SERVICE)) protected val uid = context.packageManager.getApplicationInfo( protected val uid = context.packageManager.getApplicationInfo( testApp.component.packageName, 0).uid testApp.`package`, 0).uid protected abstract val transition: FlickerBuilder.() -> Unit protected abstract val transition: FlickerBuilder.() -> Unit Loading @@ -59,7 +59,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { return { return { setup { setup { test { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_ALL) uid, NotificationManager.BUBBLE_PREFERENCE_ALL) testApp.launchViaIntent(wmHelper) testApp.launchViaIntent(wmHelper) waitAndGetAddBubbleBtn() waitAndGetAddBubbleBtn() Loading @@ -69,7 +69,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) { teardown { teardown { test { test { notifyManager.setBubblesAllowed(testApp.component.packageName, notifyManager.setBubblesAllowed(testApp.`package`, uid, NotificationManager.BUBBLE_PREFERENCE_NONE) uid, NotificationManager.BUBBLE_PREFERENCE_NONE) testApp.exit() testApp.exit() } } Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/bubble/LaunchBubbleFromLockScreen.kt +8 −7 Original line number Original line Diff line number Diff line Loading @@ -16,10 +16,10 @@ package com.android.wm.shell.flicker.bubble package com.android.wm.shell.flicker.bubble import android.platform.test.annotations.FlakyTest import android.platform.test.annotations.Presubmit import android.platform.test.annotations.Presubmit import android.view.WindowInsets import android.view.WindowInsets import android.view.WindowManager import android.view.WindowManager import android.platform.test.annotations.FlakyTest import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.Until 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.dsl.FlickerBuilder import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled import org.junit.Assume import org.junit.Assume import org.junit.runner.RunWith import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized /** /** Loading @@ -54,20 +54,21 @@ class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScr val addBubbleBtn = waitAndGetAddBubbleBtn() val addBubbleBtn = waitAndGetAddBubbleBtn() addBubbleBtn?.click() ?: error("Bubble widget not found") addBubbleBtn?.click() ?: error("Bubble widget not found") device.sleep() device.sleep() wmHelper.waitFor("noAppWindowsOnTop") { wmHelper.StateSyncBuilder() it.wmState.topVisibleAppWindow.isEmpty() .withoutTopVisibleAppWindows() } .waitForAndVerify() device.wakeUp() device.wakeUp() } } } } transitions { transitions { // Swipe & wait for the notification shade to expand so all can be seen // Swipe & wait for the notification shade to expand so all can be seen val wm = context.getSystemService(WindowManager::class.java) 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( val insets = metricInsets.getInsetsIgnoringVisibility( WindowInsets.Type.statusBars() WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout()) 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) device.waitForIdle(2000) instrumentation.uiAutomation.syncInputTransactions() instrumentation.uiAutomation.syncInputTransactions() Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/AppPairsHelper.kt +1 −35 Original line number Original line Diff line number Diff line Loading @@ -17,44 +17,10 @@ package com.android.wm.shell.flicker.helpers package com.android.wm.shell.flicker.helpers import android.app.Instrumentation 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.FlickerComponentName import com.android.server.wm.traces.common.region.Region class AppPairsHelper( class AppPairsHelper( instrumentation: Instrumentation, instrumentation: Instrumentation, activityLabel: String, activityLabel: String, component: FlickerComponentName component: FlickerComponentName ) : BaseAppHelper(instrumentation, activityLabel, component) { ) : 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 } } } }
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/BaseAppHelper.kt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -40,7 +40,7 @@ abstract class BaseAppHelper( component, component, LauncherStrategyFactory.getInstance(instrumentation).launcherStrategy 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 protected val isTelevision: Boolean get() = context.packageManager.run { get() = context.packageManager.run { Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/helpers/ImeAppHelper.kt +9 −23 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.wm.shell.flicker.helpers import android.app.Instrumentation import android.app.Instrumentation import androidx.test.uiautomator.By import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.FIND_TIMEOUT import com.android.server.wm.flicker.helpers.FIND_TIMEOUT import com.android.server.wm.traces.parser.toFlickerComponent 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 * @param wmHelper Helper used to wait for WindowManager states */ */ @JvmOverloads open fun openIME(wmHelper: WindowManagerStateHelper) { open fun openIME(wmHelper: WindowManagerStateHelper? = null) { if (!isTelevision) { if (!isTelevision) { val editText = uiDevice.wait( val editText = uiDevice.wait( Until.findObject(By.res(getPackage(), "plain_text_input")), 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)" "was left in an unknown state (e.g. in split screen)" } } editText.click() editText.click() waitAndAssertIMEShown(uiDevice, wmHelper) wmHelper.StateSyncBuilder() .withImeShown() .waitForAndVerify() } else { } else { // If we do the same thing as above - editText.click() - on TV, that's going to force TV // 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. // 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 * Opens the IME and wait for it to be gone * * * @param wmHelper Helper used to wait for WindowManager states * @param wmHelper Helper used to wait for WindowManager states */ */ @JvmOverloads open fun closeIME(wmHelper: WindowManagerStateHelper) { open fun closeIME(wmHelper: WindowManagerStateHelper? = null) { if (!isTelevision) { if (!isTelevision) { uiDevice.pressBack() uiDevice.pressBack() // Using only the AccessibilityInfo it is not possible to identify if the IME is active // Using only the AccessibilityInfo it is not possible to identify if the IME is active if (wmHelper == null) { wmHelper.StateSyncBuilder() uiDevice.waitForIdle() .withImeGone() } else { .waitForAndVerify() wmHelper.waitImeGone() } } else { } else { // While pressing the back button should close the IME on TV as well, it may also lead // 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. // to the app closing. So let's instead just ask the app to close the IME. Loading