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

Commit c4a66af3 authored by Pablo Gamito's avatar Pablo Gamito Committed by Android (Google) Code Review
Browse files

Merge changes from topic "flicker-read-write-refactor"

* changes:
  Compatibilize tests with new constants
  Compatibilize flicker tests with flicker infra refactor
parents 9f0809b2 51178849
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
        <option name="run-command" value="locksettings set-disabled false" />
        <!-- restart launcher to activate TAPL -->
        <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" />
        <!-- Ensure output directory is empty at the start -->
        <option name="run-command" value="rm -rf /sdcard/flicker" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true"/>
+22 −23
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import android.app.Instrumentation
import android.platform.test.annotations.Presubmit
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.dsl.FlickerBuilder
import com.android.server.wm.flicker.FlickerBuilder
import com.android.server.wm.flicker.FlickerTest
import com.android.server.wm.flicker.entireScreenCovered
import com.android.server.wm.flicker.junit.FlickerBuilderProvider
import com.android.server.wm.flicker.navBarLayerIsVisibleAtStartAndEnd
import com.android.server.wm.flicker.navBarLayerPositionAtStartAndEnd
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
@@ -45,12 +45,12 @@ import org.junit.Test
abstract class BaseTest
@JvmOverloads
constructor(
    protected val testSpec: FlickerTestParameter,
    protected val flicker: FlickerTest,
    protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(),
    protected val tapl: LauncherInstrumentation = LauncherInstrumentation()
) {
    init {
        testSpec.setIsTablet(
        flicker.scenario.setIsTablet(
            WindowManagerStateHelper(instrumentation, clearCacheAfterParsing = false)
                .currentState
                .wmState
@@ -68,13 +68,13 @@ constructor(
    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
            setup { testSpec.setIsTablet(wmHelper.currentState.wmState.isTablet) }
            setup { flicker.scenario.setIsTablet(wmHelper.currentState.wmState.isTablet) }
            transition()
        }
    }

    /** Checks that all parts of the screen are covered during the transition */
    @Presubmit @Test open fun entireScreenCovered() = testSpec.entireScreenCovered()
    @Presubmit @Test open fun entireScreenCovered() = flicker.entireScreenCovered()

    /**
     * Checks that the [ComponentNameMatcher.NAV_BAR] layer is visible during the whole transition
@@ -82,8 +82,8 @@ constructor(
    @Presubmit
    @Test
    open fun navBarLayerIsVisibleAtStartAndEnd() {
        Assume.assumeFalse(testSpec.isTablet)
        testSpec.navBarLayerIsVisibleAtStartAndEnd()
        Assume.assumeFalse(flicker.scenario.isTablet)
        flicker.navBarLayerIsVisibleAtStartAndEnd()
    }

    /**
@@ -93,8 +93,8 @@ constructor(
    @Presubmit
    @Test
    open fun navBarLayerPositionAtStartAndEnd() {
        Assume.assumeFalse(testSpec.isTablet)
        testSpec.navBarLayerPositionAtStartAndEnd()
        Assume.assumeFalse(flicker.scenario.isTablet)
        flicker.navBarLayerPositionAtStartAndEnd()
    }

    /**
@@ -105,8 +105,8 @@ constructor(
    @Presubmit
    @Test
    open fun navBarWindowIsAlwaysVisible() {
        Assume.assumeFalse(testSpec.isTablet)
        testSpec.navBarWindowIsAlwaysVisible()
        Assume.assumeFalse(flicker.scenario.isTablet)
        flicker.navBarWindowIsAlwaysVisible()
    }

    /**
@@ -115,8 +115,8 @@ constructor(
    @Presubmit
    @Test
    open fun taskBarLayerIsVisibleAtStartAndEnd() {
        Assume.assumeTrue(testSpec.isTablet)
        testSpec.taskBarLayerIsVisibleAtStartAndEnd()
        Assume.assumeTrue(flicker.scenario.isTablet)
        flicker.taskBarLayerIsVisibleAtStartAndEnd()
    }

    /**
@@ -127,8 +127,8 @@ constructor(
    @Presubmit
    @Test
    open fun taskBarWindowIsAlwaysVisible() {
        Assume.assumeTrue(testSpec.isTablet)
        testSpec.taskBarWindowIsAlwaysVisible()
        Assume.assumeTrue(flicker.scenario.isTablet)
        flicker.taskBarWindowIsAlwaysVisible()
    }

    /**
@@ -137,8 +137,7 @@ constructor(
     */
    @Presubmit
    @Test
    open fun statusBarLayerIsVisibleAtStartAndEnd() =
        testSpec.statusBarLayerIsVisibleAtStartAndEnd()
    open fun statusBarLayerIsVisibleAtStartAndEnd() = flicker.statusBarLayerIsVisibleAtStartAndEnd()

    /**
     * Checks the position of the [ComponentNameMatcher.STATUS_BAR] at the start and end of the
@@ -146,7 +145,7 @@ constructor(
     */
    @Presubmit
    @Test
    open fun statusBarLayerPositionAtStartAndEnd() = testSpec.statusBarLayerPositionAtStartAndEnd()
    open fun statusBarLayerPositionAtStartAndEnd() = flicker.statusBarLayerPositionAtStartAndEnd()

    /**
     * Checks that the [ComponentNameMatcher.STATUS_BAR] window is visible during the whole
@@ -154,7 +153,7 @@ constructor(
     */
    @Presubmit
    @Test
    open fun statusBarWindowIsAlwaysVisible() = testSpec.statusBarWindowIsAlwaysVisible()
    open fun statusBarWindowIsAlwaysVisible() = flicker.statusBarWindowIsAlwaysVisible()

    /**
     * Checks that all layers that are visible on the trace, are visible for at least 2 consecutive
@@ -163,7 +162,7 @@ constructor(
    @Presubmit
    @Test
    open fun visibleLayersShownMoreThanOneConsecutiveEntry() {
        testSpec.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() }
        flicker.assertLayers { this.visibleLayersShownMoreThanOneConsecutiveEntry() }
    }

    /**
@@ -173,6 +172,6 @@ constructor(
    @Presubmit
    @Test
    open fun visibleWindowsShownMoreThanOneConsecutiveEntry() {
        testSpec.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() }
        flicker.assertWm { this.visibleWindowsShownMoreThanOneConsecutiveEntry() }
    }
}
+72 −62
Original line number Diff line number Diff line
@@ -18,23 +18,23 @@

package com.android.wm.shell.flicker

import android.view.Surface
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTest
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.traces.layers.LayerTraceEntrySubject
import com.android.server.wm.flicker.traces.layers.LayersTraceSubject
import com.android.server.wm.traces.common.IComponentMatcher
import com.android.server.wm.traces.common.region.Region
import com.android.server.wm.traces.common.service.PlatformConsts

fun FlickerTestParameter.appPairsDividerIsVisibleAtEnd() {
fun FlickerTest.appPairsDividerIsVisibleAtEnd() {
    assertLayersEnd { this.isVisible(APP_PAIR_SPLIT_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.appPairsDividerIsInvisibleAtEnd() {
fun FlickerTest.appPairsDividerIsInvisibleAtEnd() {
    assertLayersEnd { this.notContains(APP_PAIR_SPLIT_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.appPairsDividerBecomesVisible() {
fun FlickerTest.appPairsDividerBecomesVisible() {
    assertLayers {
        this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT)
            .then()
@@ -42,7 +42,7 @@ fun FlickerTestParameter.appPairsDividerBecomesVisible() {
    }
}

fun FlickerTestParameter.splitScreenEntered(
fun FlickerTest.splitScreenEntered(
    component1: IComponentMatcher,
    component2: IComponentMatcher,
    fromOtherApp: Boolean,
@@ -69,7 +69,7 @@ fun FlickerTestParameter.splitScreenEntered(
    splitScreenDividerIsVisibleAtEnd()
}

fun FlickerTestParameter.splitScreenDismissed(
fun FlickerTest.splitScreenDismissed(
    component1: IComponentMatcher,
    component2: IComponentMatcher,
    toHome: Boolean
@@ -87,27 +87,27 @@ fun FlickerTestParameter.splitScreenDismissed(
    splitScreenDividerIsInvisibleAtEnd()
}

fun FlickerTestParameter.splitScreenDividerIsVisibleAtStart() {
fun FlickerTest.splitScreenDividerIsVisibleAtStart() {
    assertLayersStart { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.splitScreenDividerIsVisibleAtEnd() {
fun FlickerTest.splitScreenDividerIsVisibleAtEnd() {
    assertLayersEnd { this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.splitScreenDividerIsInvisibleAtStart() {
fun FlickerTest.splitScreenDividerIsInvisibleAtStart() {
    assertLayersStart { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.splitScreenDividerIsInvisibleAtEnd() {
fun FlickerTest.splitScreenDividerIsInvisibleAtEnd() {
    assertLayersEnd { this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.splitScreenDividerBecomesVisible() {
fun FlickerTest.splitScreenDividerBecomesVisible() {
    layerBecomesVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
}

fun FlickerTestParameter.splitScreenDividerBecomesInvisible() {
fun FlickerTest.splitScreenDividerBecomesInvisible() {
    assertLayers {
        this.isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
            .then()
@@ -115,23 +115,23 @@ fun FlickerTestParameter.splitScreenDividerBecomesInvisible() {
    }
}

fun FlickerTestParameter.layerBecomesVisible(component: IComponentMatcher) {
fun FlickerTest.layerBecomesVisible(component: IComponentMatcher) {
    assertLayers { this.isInvisible(component).then().isVisible(component) }
}

fun FlickerTestParameter.layerBecomesInvisible(component: IComponentMatcher) {
fun FlickerTest.layerBecomesInvisible(component: IComponentMatcher) {
    assertLayers { this.isVisible(component).then().isInvisible(component) }
}

fun FlickerTestParameter.layerIsVisibleAtEnd(component: IComponentMatcher) {
fun FlickerTest.layerIsVisibleAtEnd(component: IComponentMatcher) {
    assertLayersEnd { this.isVisible(component) }
}

fun FlickerTestParameter.layerKeepVisible(component: IComponentMatcher) {
fun FlickerTest.layerKeepVisible(component: IComponentMatcher) {
    assertLayers { this.isVisible(component) }
}

fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible(
fun FlickerTest.splitAppLayerBoundsBecomesVisible(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
@@ -145,12 +145,12 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible(
                component,
                landscapePosLeft,
                portraitPosTop,
                endRotation
                scenario.endRotation
            )
    }
}

fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag(component: IComponentMatcher) {
fun FlickerTest.splitAppLayerBoundsBecomesVisibleByDrag(component: IComponentMatcher) {
    assertLayers {
        this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true)
            .then()
@@ -161,7 +161,7 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesVisibleByDrag(component: ICom
    }
}

fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible(
fun FlickerTest.splitAppLayerBoundsBecomesInvisible(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
@@ -171,7 +171,7 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible(
                component,
                landscapePosLeft,
                portraitPosTop,
                endRotation
                scenario.endRotation
            )
            .then()
            .isVisible(component, true)
@@ -180,27 +180,37 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible(
    }
}

fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd(
fun FlickerTest.splitAppLayerBoundsIsVisibleAtEnd(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
) {
    assertLayersEnd {
        splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation)
        splitAppLayerBoundsSnapToDivider(
            component,
            landscapePosLeft,
            portraitPosTop,
            scenario.endRotation
        )
    }
}

fun FlickerTestParameter.splitAppLayerBoundsKeepVisible(
fun FlickerTest.splitAppLayerBoundsKeepVisible(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
) {
    assertLayers {
        splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation)
        splitAppLayerBoundsSnapToDivider(
            component,
            landscapePosLeft,
            portraitPosTop,
            scenario.endRotation
        )
    }
}

fun FlickerTestParameter.splitAppLayerBoundsChanges(
fun FlickerTest.splitAppLayerBoundsChanges(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
@@ -211,14 +221,14 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges(
                component,
                landscapePosLeft,
                portraitPosTop,
                endRotation
                scenario.endRotation
            )
        } else {
            this.splitAppLayerBoundsSnapToDivider(
                    component,
                    landscapePosLeft,
                    portraitPosTop,
                    endRotation
                    scenario.endRotation
                )
                .then()
                .isInvisible(component)
@@ -227,7 +237,7 @@ fun FlickerTestParameter.splitAppLayerBoundsChanges(
                    component,
                    landscapePosLeft,
                    portraitPosTop,
                    endRotation
                    scenario.endRotation
                )
        }
    }
@@ -237,7 +247,7 @@ fun LayersTraceSubject.splitAppLayerBoundsSnapToDivider(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean,
    rotation: Int
    rotation: PlatformConsts.Rotation
): LayersTraceSubject {
    return invoke("splitAppLayerBoundsSnapToDivider") {
        it.splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, rotation)
@@ -248,7 +258,7 @@ fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean,
    rotation: Int
    rotation: PlatformConsts.Rotation
): LayerTraceEntrySubject {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return invoke {
@@ -292,7 +302,7 @@ fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider(
    }
}

fun FlickerTestParameter.appWindowBecomesVisible(component: IComponentMatcher) {
fun FlickerTest.appWindowBecomesVisible(component: IComponentMatcher) {
    assertWm {
        this.isAppWindowInvisible(component)
            .then()
@@ -304,39 +314,39 @@ fun FlickerTestParameter.appWindowBecomesVisible(component: IComponentMatcher) {
    }
}

fun FlickerTestParameter.appWindowBecomesInvisible(component: IComponentMatcher) {
fun FlickerTest.appWindowBecomesInvisible(component: IComponentMatcher) {
    assertWm { this.isAppWindowVisible(component).then().isAppWindowInvisible(component) }
}

fun FlickerTestParameter.appWindowIsVisibleAtStart(component: IComponentMatcher) {
fun FlickerTest.appWindowIsVisibleAtStart(component: IComponentMatcher) {
    assertWmStart { this.isAppWindowVisible(component) }
}

fun FlickerTestParameter.appWindowIsVisibleAtEnd(component: IComponentMatcher) {
fun FlickerTest.appWindowIsVisibleAtEnd(component: IComponentMatcher) {
    assertWmEnd { this.isAppWindowVisible(component) }
}

fun FlickerTestParameter.appWindowIsInvisibleAtStart(component: IComponentMatcher) {
fun FlickerTest.appWindowIsInvisibleAtStart(component: IComponentMatcher) {
    assertWmStart { this.isAppWindowInvisible(component) }
}

fun FlickerTestParameter.appWindowIsInvisibleAtEnd(component: IComponentMatcher) {
fun FlickerTest.appWindowIsInvisibleAtEnd(component: IComponentMatcher) {
    assertWmEnd { this.isAppWindowInvisible(component) }
}

fun FlickerTestParameter.appWindowIsNotContainAtStart(component: IComponentMatcher) {
fun FlickerTest.appWindowIsNotContainAtStart(component: IComponentMatcher) {
    assertWmStart { this.notContains(component) }
}

fun FlickerTestParameter.appWindowKeepVisible(component: IComponentMatcher) {
fun FlickerTest.appWindowKeepVisible(component: IComponentMatcher) {
    assertWm { this.isAppWindowVisible(component) }
}

fun FlickerTestParameter.dockedStackDividerIsVisibleAtEnd() {
fun FlickerTest.dockedStackDividerIsVisibleAtEnd() {
    assertLayersEnd { this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.dockedStackDividerBecomesVisible() {
fun FlickerTest.dockedStackDividerBecomesVisible() {
    assertLayers {
        this.isInvisible(DOCKED_STACK_DIVIDER_COMPONENT)
            .then()
@@ -344,7 +354,7 @@ fun FlickerTestParameter.dockedStackDividerBecomesVisible() {
    }
}

fun FlickerTestParameter.dockedStackDividerBecomesInvisible() {
fun FlickerTest.dockedStackDividerBecomesInvisible() {
    assertLayers {
        this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT)
            .then()
@@ -352,12 +362,12 @@ fun FlickerTestParameter.dockedStackDividerBecomesInvisible() {
    }
}

fun FlickerTestParameter.dockedStackDividerNotExistsAtEnd() {
fun FlickerTest.dockedStackDividerNotExistsAtEnd() {
    assertLayersEnd { this.notContains(DOCKED_STACK_DIVIDER_COMPONENT) }
}

fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd(
    rotation: Int,
fun FlickerTest.appPairsPrimaryBoundsIsVisibleAtEnd(
    rotation: PlatformConsts.Rotation,
    primaryComponent: IComponentMatcher
) {
    assertLayersEnd {
@@ -366,8 +376,8 @@ fun FlickerTestParameter.appPairsPrimaryBoundsIsVisibleAtEnd(
    }
}

fun FlickerTestParameter.dockedStackPrimaryBoundsIsVisibleAtEnd(
    rotation: Int,
fun FlickerTest.dockedStackPrimaryBoundsIsVisibleAtEnd(
    rotation: PlatformConsts.Rotation,
    primaryComponent: IComponentMatcher
) {
    assertLayersEnd {
@@ -376,8 +386,8 @@ fun FlickerTestParameter.dockedStackPrimaryBoundsIsVisibleAtEnd(
    }
}

fun FlickerTestParameter.appPairsSecondaryBoundsIsVisibleAtEnd(
    rotation: Int,
fun FlickerTest.appPairsSecondaryBoundsIsVisibleAtEnd(
    rotation: PlatformConsts.Rotation,
    secondaryComponent: IComponentMatcher
) {
    assertLayersEnd {
@@ -386,8 +396,8 @@ fun FlickerTestParameter.appPairsSecondaryBoundsIsVisibleAtEnd(
    }
}

fun FlickerTestParameter.dockedStackSecondaryBoundsIsVisibleAtEnd(
    rotation: Int,
fun FlickerTest.dockedStackSecondaryBoundsIsVisibleAtEnd(
    rotation: PlatformConsts.Rotation,
    secondaryComponent: IComponentMatcher
) {
    assertLayersEnd {
@@ -396,38 +406,38 @@ fun FlickerTestParameter.dockedStackSecondaryBoundsIsVisibleAtEnd(
    }
}

fun getPrimaryRegion(dividerRegion: Region, rotation: Int): Region {
fun getPrimaryRegion(dividerRegion: Region, rotation: PlatformConsts.Rotation): Region {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
    return if (rotation.isRotated()) {
        Region.from(
            0,
            0,
            displayBounds.bounds.right,
            dividerRegion.bounds.top + WindowUtils.dockedStackDividerInset
            dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset,
            displayBounds.bounds.bottom
        )
    } else {
        Region.from(
            0,
            0,
            dividerRegion.bounds.left + WindowUtils.dockedStackDividerInset,
            displayBounds.bounds.bottom
            displayBounds.bounds.right,
            dividerRegion.bounds.top + WindowUtils.dockedStackDividerInset
        )
    }
}

fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region {
fun getSecondaryRegion(dividerRegion: Region, rotation: PlatformConsts.Rotation): Region {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
    return if (rotation.isRotated()) {
        Region.from(
            dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset,
            0,
            dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset,
            displayBounds.bounds.right,
            displayBounds.bounds.bottom
        )
    } else {
        Region.from(
            dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset,
            0,
            dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset,
            displayBounds.bounds.right,
            displayBounds.bounds.bottom
        )
+12 −11
Original line number Diff line number Diff line
@@ -21,21 +21,21 @@ import android.app.NotificationManager
import android.content.Context
import android.content.pm.PackageManager
import android.os.ServiceManager
import android.view.Surface
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiObject2
import androidx.test.uiautomator.Until
import com.android.server.wm.flicker.Flicker
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.FlickerBuilder
import com.android.server.wm.flicker.FlickerTest
import com.android.server.wm.flicker.FlickerTestFactory
import com.android.server.wm.flicker.IFlickerTestData
import com.android.server.wm.flicker.helpers.LaunchBubbleHelper
import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE
import com.android.server.wm.traces.common.service.PlatformConsts
import com.android.wm.shell.flicker.BaseTest
import org.junit.runners.Parameterized

/** Base configurations for Bubble flicker tests */
abstract class BaseBubbleScreen(testSpec: FlickerTestParameter) : BaseTest(testSpec) {
abstract class BaseBubbleScreen(flicker: FlickerTest) : BaseTest(flicker) {

    protected val context: Context = instrumentation.context
    protected val testApp = LaunchBubbleHelper(instrumentation)
@@ -79,17 +79,18 @@ abstract class BaseBubbleScreen(testSpec: FlickerTestParameter) : BaseTest(testS
        }
    }

    protected fun Flicker.waitAndGetAddBubbleBtn(): UiObject2? =
    protected fun IFlickerTestData.waitAndGetAddBubbleBtn(): UiObject2? =
        device.wait(Until.findObject(By.text("Add Bubble")), FIND_OBJECT_TIMEOUT)
    protected fun Flicker.waitAndGetCancelAllBtn(): UiObject2? =
    protected fun IFlickerTestData.waitAndGetCancelAllBtn(): UiObject2? =
        device.wait(Until.findObject(By.text("Cancel All Bubble")), FIND_OBJECT_TIMEOUT)

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): List<FlickerTestParameter> {
            return FlickerTestParameterFactory.getInstance()
                .getConfigNonRotationTests(supportedRotations = listOf(Surface.ROTATION_0))
        fun getParams(): List<FlickerTest> {
            return FlickerTestFactory.nonRotationTests(
                supportedRotations = listOf(PlatformConsts.Rotation.ROTATION_0)
            )
        }

        const val FIND_OBJECT_TIMEOUT = 2000L
+5 −5
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@ import android.view.WindowManager
import androidx.test.filters.RequiresDevice
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.FlickerBuilder
import com.android.server.wm.flicker.FlickerTest
import com.android.server.wm.flicker.junit.FlickerParametersRunnerFactory
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@@ -45,7 +45,7 @@ import org.junit.runners.Parameterized
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(testSpec) {
open class DismissBubbleScreen(flicker: FlickerTest) : BaseBubbleScreen(flicker) {

    private val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
    private val displaySize = DisplayMetrics()
@@ -72,7 +72,7 @@ open class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScree
    @Presubmit
    @Test
    open fun testAppIsAlwaysVisible() {
        testSpec.assertLayers { this.isVisible(testApp) }
        flicker.assertLayers { this.isVisible(testApp) }
    }

    /** {@inheritDoc} */
Loading