Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08880892 authored by Nataniel Borges's avatar Nataniel Borges Committed by Android (Google) Code Review
Browse files

Merge changes from topic "flicker-tapl-component-name-master"

* changes:
  13/ Compatibilize shell tests with WMHelper.StateSyncBuilder changes
  12/ Stabilize IME tests
  11/ Support splash screen and app visibility changes occurring in any order
  10/ Stabilize quick switch tests
  9/ Fix TAPL on app close
  8/ Fix nav and status bar assertions with display off
  7/ New CUJ: launch app from icon on all apps
  6/ Add tapl support on app launch CUJs
  5/ Clean up flicker tests
  4/ Use WMStateHelper builder pattern
  3/ Simplify wait for full screen app
  2/ Use TAPL for going home and recents in app close tests
  1/ Unify waiting for Home or Recents activity to be visible
parents 905ee728 27a37991
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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

@@ -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()
@@ -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()
                }
+8 −7
Original line number Diff line number Diff line
@@ -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
@@ -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

/**
@@ -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()

+1 −35
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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 {
+9 −23
Original line number Diff line number Diff line
@@ -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
@@ -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")),
@@ -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.
@@ -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