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

Commit 1e3f5473 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Simplify flicker provider logic

Makes flicker tests compatible with refactored FlickerTestParameter code

Test: atest FlickerTests WMShellFlickerTests
Bug: 204894659
Change-Id: I7fc6a950a0d8498727fc37151da8e60fb496b033
parent b6571060
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ class AppPairsTestCannotPairNonResizeableApps(
    testSpec: FlickerTestParameter
) : AppPairsTransition(testSpec) {

    override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this, it)
            super.transition(this)
            transitions {
                nonResizeableApp?.launchViaIntent(wmHelper)
                // TODO pair apps through normal UX flow
+2 −2
Original line number Diff line number Diff line
@@ -46,9 +46,9 @@ import org.junit.runners.Parameterized
class AppPairsTestPairPrimaryAndSecondaryApps(
    testSpec: FlickerTestParameter
) : AppPairsTransition(testSpec) {
    override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this, it)
            super.transition(this)
            transitions {
                // TODO pair apps through normal UX flow
                executeShellCommand(
+2 −2
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ class AppPairsTestSupportPairNonResizeableApps(
    testSpec: FlickerTestParameter
) : AppPairsTransition(testSpec) {

    override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this, it)
            super.transition(this)
            transitions {
                nonResizeableApp?.launchViaIntent(wmHelper)
                // TODO pair apps through normal UX flow
+2 −2
Original line number Diff line number Diff line
@@ -47,9 +47,9 @@ import org.junit.runners.Parameterized
class AppPairsTestUnpairPrimaryAndSecondaryApps(
    testSpec: FlickerTestParameter
) : AppPairsTransition(testSpec) {
    override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this, it)
            super.transition(this)
            setup {
                eachRun {
                    executeShellCommand(
+4 −10
Original line number Diff line number Diff line
@@ -25,14 +25,11 @@ import androidx.test.platform.app.InstrumentationRegistry
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.isRotated
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.repetitions
import com.android.server.wm.flicker.startRotation
import com.android.server.wm.flicker.statusBarLayerIsVisible
import com.android.server.wm.flicker.statusBarLayerRotatesScales
import com.android.server.wm.flicker.statusBarWindowIsVisible
@@ -50,7 +47,6 @@ import org.junit.Test
abstract class AppPairsTransition(protected val testSpec: FlickerTestParameter) {
    protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    protected val context: Context = instrumentation.context
    protected val isRotated = testSpec.config.startRotation.isRotated()
    protected val activityHelper = ActivityHelper.getInstance()
    protected val appPairsHelper = AppPairsHelper(instrumentation,
        Components.SplitScreenActivity.LABEL,
@@ -82,20 +78,18 @@ abstract class AppPairsTransition(protected val testSpec: FlickerTestParameter)
    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
            withTestName { testSpec.name }
            repeat { testSpec.config.repetitions }
            transition(this, testSpec.config)
            transition(this)
        }
    }

    internal open val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
        get() = { configuration ->
    internal open val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                test {
                    device.wakeUpAndGoToHomeScreen()
                }
                eachRun {
                    this.setRotation(configuration.startRotation)
                    this.setRotation(testSpec.startRotation)
                    primaryApp.launchViaIntent(wmHelper)
                    secondaryApp.launchViaIntent(wmHelper)
                    nonResizeableApp?.launchViaIntent(wmHelper)
Loading