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

Commit 0fc8e8d7 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

4/ Use WMStateHelper builder pattern

This simplifies waiting for different combinations of conditions in theduring the CUJs

Also, fix ktlint formatting issues

Bug: 236131465
Test: atest FlickerTests
Change-Id: I4e1e69776729d086135d47c4feb4fd3a302dae49
parent 714c68de
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -180,7 +180,8 @@ fun FlickerTestParameter.statusBarLayerRotatesScales() {
 * the visibleRegion of the given app component exactly
 */
fun FlickerTestParameter.snapshotStartingWindowLayerCoversExactlyOnApp(
        component: FlickerComponentName) {
    component: FlickerComponentName
) {
    assertLayers {
        invoke("snapshotStartingWindowLayerCoversExactlyOnApp") {
            val snapshotLayers = it.subjects.filter { subject ->
+3 −1
Original line number Diff line number Diff line
@@ -73,7 +73,9 @@ class CloseAppBackButtonTest(testSpec: FlickerTestParameter) : CloseAppTransitio
            super.transition(this)
            transitions {
                tapl.pressBack()
                wmHelper.waitForHomeActivityVisible()
                wmHelper.StateSyncBuilder()
                    .withHomeActivityVisible()
                    .waitForAndVerify()
            }
        }

+3 −1
Original line number Diff line number Diff line
@@ -70,7 +70,9 @@ class CloseAppHomeButtonTest(testSpec: FlickerTestParameter) : CloseAppTransitio
            super.transition(this)
            transitions {
                tapl.goHome()
                wmHelper.waitForHomeActivityVisible()
                wmHelper.StateSyncBuilder()
                    .withHomeActivityVisible()
                    .waitForAndVerify()
            }
        }

+8 −8
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ 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.LAUNCHER_COMPONENT
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.entireScreenCovered
import com.android.server.wm.flicker.helpers.SimpleAppHelper
@@ -35,6 +34,7 @@ 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.FlickerComponentName.Companion.LAUNCHER
import org.junit.Test

/**
@@ -156,7 +156,7 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter)

    /**
     * Checks that [testApp] is the top visible app window at the start of the transition and
     * that it is replaced by [LAUNCHER_COMPONENT] during the transition
     * that it is replaced by [LAUNCHER] during the transition
     */
    @Presubmit
    @Test
@@ -164,30 +164,30 @@ abstract class CloseAppTransition(protected val testSpec: FlickerTestParameter)
        testSpec.assertWm {
            this.isAppWindowOnTop(testApp.component)
                    .then()
                    .isAppWindowOnTop(LAUNCHER_COMPONENT)
                    .isAppWindowOnTop(LAUNCHER)
        }
    }

    /**
     * Checks that [LAUNCHER_COMPONENT] is invisible at the start of the transition and that
     * Checks that [LAUNCHER] is invisible at the start of the transition and that
     * it becomes visible during the transition
     */
    @Presubmit
    @Test
    open fun launcherWindowBecomesVisible() {
        testSpec.assertWm {
            this.isAppWindowNotOnTop(LAUNCHER_COMPONENT)
            this.isAppWindowNotOnTop(LAUNCHER)
                    .then()
                    .isAppWindowOnTop(LAUNCHER_COMPONENT)
                    .isAppWindowOnTop(LAUNCHER)
        }
    }

    /**
     * Checks that [LAUNCHER_COMPONENT] layer becomes visible when [testApp] becomes invisible
     * Checks that [LAUNCHER] layer becomes visible when [testApp] becomes invisible
     */
    @Presubmit
    @Test
    open fun launcherLayerReplacesApp() {
        testSpec.replacesLayer(testApp.component, LAUNCHER_COMPONENT)
        testSpec.replacesLayer(testApp.component, LAUNCHER)
    }
}
+8 −5
Original line number Diff line number Diff line
@@ -73,9 +73,10 @@ class ImeAppAutoFocusHelper @JvmOverloads constructor(
                    "was left in an unknown state (e.g. Screen turned off)"
        }
        button.click()
        wmHelper.waitForFullScreenApp(
        wmHelper.StateSyncBuilder()
            .withFullScreenApp(
                ActivityOptions.DIALOG_THEMED_ACTIVITY_COMPONENT_NAME.toFlickerComponent())
        mInstrumentation.waitForIdleSync()
            .waitForAndVerify()
    }
    fun dismissDialog(wmHelper: WindowManagerStateHelper) {
        val dialog = uiDevice.wait(
@@ -84,14 +85,16 @@ class ImeAppAutoFocusHelper @JvmOverloads constructor(
        // Pressing back key to dismiss the dialog
        if (dialog != null) {
            uiDevice.pressBack()
            wmHelper.waitForAppTransitionIdle()
            wmHelper.StateSyncBuilder()
                .withAppTransitionIdle()
                .waitForAndVerify()
        }
    }
    fun getInsetsVisibleFromDialog(type: Int): Boolean {
        var insetsVisibilityTextView = uiDevice.wait(
        val insetsVisibilityTextView = uiDevice.wait(
                Until.findObject(By.res("android:id/text1")), FIND_TIMEOUT)
        if (insetsVisibilityTextView != null) {
            var visibility = insetsVisibilityTextView.text.toString()
            val visibility = insetsVisibilityTextView.text.toString()
            val matcher = when (type) {
                ime() -> {
                    Pattern.compile("IME\\: (VISIBLE|INVISIBLE)").matcher(visibility)
Loading