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

Commit eb5d45e5 authored by Chilun Huang's avatar Chilun Huang Committed by Android (Google) Code Review
Browse files

Merge "Add CUJ for enter split-screen from overview"

parents 79382738 0aa5a388
Loading
Loading
Loading
Loading
+76 −67
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package com.android.wm.shell.flicker
import android.view.Surface
import com.android.server.wm.flicker.FlickerTestParameter
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
@@ -94,25 +95,27 @@ fun FlickerTestParameter.layerKeepVisible(

fun FlickerTestParameter.splitAppLayerBoundsBecomesVisible(
    component: IComponentMatcher,
    splitLeftTop: Boolean
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
) {
    assertLayers {
        this.isInvisible(component)
        this.notContains(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component), isOptional = true)
            .then()
            .isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
            .isVisible(component)
            .isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT.or(component))
            .then()
            .isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
            .splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
            .splitAppLayerBoundsSnapToDivider(
                component, landscapePosLeft, portraitPosTop, endRotation)
    }
}

fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible(
    component: IComponentMatcher,
    splitLeftTop: Boolean
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
) {
    assertLayers {
        this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
        this.splitAppLayerBoundsSnapToDivider(
                component, landscapePosLeft, portraitPosTop, endRotation)
            .then()
            .isVisible(component, true)
            .then()
@@ -122,58 +125,96 @@ fun FlickerTestParameter.splitAppLayerBoundsBecomesInvisible(

fun FlickerTestParameter.splitAppLayerBoundsIsVisibleAtEnd(
    component: IComponentMatcher,
    splitLeftTop: Boolean
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
) {
    assertLayersEnd {
        val dividerRegion = layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region
        visibleRegion(component).coversAtMost(
            if (splitLeftTop) {
                getSplitLeftTopRegion(dividerRegion, endRotation)
            } else {
                getSplitRightBottomRegion(dividerRegion, endRotation)
            }
        )
        splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, endRotation)
    }
}

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

fun FlickerTestParameter.splitAppLayerBoundsChanges(
    component: IComponentMatcher,
    splitLeftTop: Boolean
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean
) {
    assertLayers {
        if (splitLeftTop) {
            this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
        if (landscapePosLeft) {
            this.splitAppLayerBoundsSnapToDivider(
                    component, landscapePosLeft, portraitPosTop, endRotation)
                .then()
                .isInvisible(component)
                .then()
                .splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
                .splitAppLayerBoundsSnapToDivider(
                    component, landscapePosLeft, portraitPosTop, endRotation)
        } else {
            this.splitAppLayerBoundsSnapToDivider(component, splitLeftTop, endRotation)
            this.splitAppLayerBoundsSnapToDivider(
                component, landscapePosLeft, portraitPosTop, endRotation)
        }
    }
}

fun LayersTraceSubject.splitAppLayerBoundsSnapToDivider(
    component: IComponentMatcher,
    splitLeftTop: Boolean,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean,
    rotation: Int
): LayersTraceSubject {
    return invoke("splitAppLayerBoundsSnapToDivider") {
        val dividerRegion = it.layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region
        it.visibleRegion(component).coversAtMost(
            if (splitLeftTop) {
                getSplitLeftTopRegion(dividerRegion, rotation)
        it.splitAppLayerBoundsSnapToDivider(component, landscapePosLeft, portraitPosTop, rotation)
    }
}

fun LayerTraceEntrySubject.splitAppLayerBoundsSnapToDivider(
    component: IComponentMatcher,
    landscapePosLeft: Boolean,
    portraitPosTop: Boolean,
    rotation: Int
): LayerTraceEntrySubject {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return invoke {
        val dividerRegion = layer(SPLIT_SCREEN_DIVIDER_COMPONENT).visibleRegion.region
        visibleRegion(component).coversAtMost(
            if (displayBounds.width > displayBounds.height) {
                if (landscapePosLeft) {
                    Region.from(
                        0,
                        0,
                        (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2,
                        displayBounds.bounds.bottom)
                } else {
                    Region.from(
                        (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2,
                        0,
                        displayBounds.bounds.right,
                        displayBounds.bounds.bottom
                    )
                }
            } else {
                getSplitRightBottomRegion(dividerRegion, rotation)
                if (portraitPosTop) {
                    Region.from(
                        0,
                        0,
                        displayBounds.bounds.right,
                        (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2)
                } else {
                    Region.from(
                        0,
                        (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2,
                        displayBounds.bounds.right,
                        displayBounds.bounds.bottom
                    )
                }
            }
        )
    }
@@ -184,6 +225,10 @@ fun FlickerTestParameter.appWindowBecomesVisible(
) {
    assertWm {
        this.isAppWindowInvisible(component)
            .then()
            .notContains(component, isOptional = true)
            .then()
            .isAppWindowInvisible(component, isOptional = true)
            .then()
            .isAppWindowVisible(component)
    }
@@ -316,39 +361,3 @@ fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region {
        )
    }
}

fun getSplitLeftTopRegion(dividerRegion: Region, rotation: Int): Region {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return if (displayBounds.width > displayBounds.height) {
        Region.from(
            0,
            0,
            (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2,
            displayBounds.bounds.bottom)
    } else {
        Region.from(
            0,
            0,
            displayBounds.bounds.right,
            (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2)
    }
}

fun getSplitRightBottomRegion(dividerRegion: Region, rotation: Int): Region {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return if (displayBounds.width > displayBounds.height) {
        Region.from(
            (dividerRegion.bounds.left + dividerRegion.bounds.right) / 2,
            0,
            displayBounds.bounds.right,
            displayBounds.bounds.bottom
        )
    } else {
        Region.from(
            0,
            (dividerRegion.bounds.top + dividerRegion.bounds.bottom) / 2,
            displayBounds.bounds.right,
            displayBounds.bounds.bottom
        )
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -105,6 +105,25 @@ class SplitScreenHelper(
                .waitForAndVerify()
        }

        fun splitFromOverview(tapl: LauncherInstrumentation) {
            // Note: The initial split position in landscape is different between tablet and phone.
            // In landscape, tablet will let the first app split to right side, and phone will
            // split to left side.
            if (tapl.isTablet) {
                tapl.workspace.switchToOverview().overviewActions
                    .clickSplit()
                    .currentTask
                    .open()
            } else {
                tapl.workspace.switchToOverview().currentTask
                    .tapMenu()
                    .tapSplitMenuItem()
                    .currentTask
                    .open()
            }
            SystemClock.sleep(TIMEOUT_MS)
        }

        fun dragFromNotificationToSplit(
            instrumentation: Instrumentation,
            device: UiDevice,
+2 −2
Original line number Diff line number Diff line
@@ -92,12 +92,12 @@ class CopyContentInSplit(testSpec: FlickerTestParameter) : SplitScreenBase(testS
    @Presubmit
    @Test
    fun primaryAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
        primaryApp, splitLeftTop = true)
        primaryApp, landscapePosLeft = true, portraitPosTop = true)

    @Presubmit
    @Test
    fun textEditAppBoundsKeepVisible() = testSpec.splitAppLayerBoundsKeepVisible(
        textEditApp, splitLeftTop = false)
        textEditApp, landscapePosLeft = false, portraitPosTop = false)

    @Presubmit
    @Test
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ class DismissSplitScreenByDivider (testSpec: FlickerTestParameter) : SplitScreen
    @Presubmit
    @Test
    fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
        primaryApp, splitLeftTop = false)
        primaryApp, landscapePosLeft = false, portraitPosTop = false)

    @Presubmit
    @Test
+2 −2
Original line number Diff line number Diff line
@@ -96,12 +96,12 @@ class DismissSplitScreenByGoHome(
    @Presubmit
    @Test
    fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
        primaryApp, splitLeftTop = false)
        primaryApp, landscapePosLeft = false, portraitPosTop = false)

    @Presubmit
    @Test
    fun secondaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
        secondaryApp, splitLeftTop = true)
        secondaryApp, landscapePosLeft = true, portraitPosTop = true)

    @Presubmit
    @Test
Loading