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

Commit a97993e9 authored by Chilun Huang's avatar Chilun Huang
Browse files

Add CUJ for dismiss split-screen by divider

Add CUJ for dismiss split-screen by divider

Bug: 231399943
Test: atest WMShellFlickerTests:DismissSplitScreenByDivider
Change-Id: I43a2bbe1c5c8fc6b3fe81bfda51d03b4bbe87f1b
parent 5dbbbbdd
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -43,12 +43,15 @@ class SplitScreenHelper(
        const val TIMEOUT_MS = 3_000L
        const val DRAG_DURATION_MS = 1_000L
        const val NOTIFICATION_SCROLLER = "notification_stack_scroller"
        const val DIVIDER_BAR = "docked_divider_handle"
        const val GESTURE_STEP_MS = 16L

        private val notificationScrollerSelector: BySelector
            get() = By.res(SYSTEM_UI_PACKAGE_NAME, NOTIFICATION_SCROLLER)
        private val notificationContentSelector: BySelector
            get() = By.text("Notification content")
        private val dividerBarSelector: BySelector
            get() = By.res(SYSTEM_UI_PACKAGE_NAME, DIVIDER_BAR)

        fun getPrimary(instrumentation: Instrumentation): SplitScreenHelper =
            SplitScreenHelper(
@@ -215,5 +218,17 @@ class SplitScreenHelper(
                allApps.unfreeze()
            }
        }

        fun dragDividerToDismissSplit(
            device: UiDevice,
            wmHelper: WindowManagerStateHelper
        ) {
            val displayBounds = wmHelper.currentState.layerState
                .displays.firstOrNull { !it.isVirtual }
                ?.layerStackSpace
                ?: error("Display not found")
            val dividerBar = device.wait(Until.findObject(dividerBarSelector), TIMEOUT_MS)
            dividerBar.drag(Point(displayBounds.width, displayBounds.width))
        }
    }
}
+204 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.flicker.splitscreen

import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Presubmit
import android.view.WindowManagerPolicyConstants
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.annotation.Group1
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.wm.shell.flicker.appWindowBecomesInvisible
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
import com.android.wm.shell.flicker.layerBecomesInvisible
import com.android.wm.shell.flicker.layerIsVisibleAtEnd
import com.android.wm.shell.flicker.splitAppLayerBoundsBecomesInvisible
import com.android.wm.shell.flicker.splitScreenDividerBecomesInvisible
import org.junit.Assume
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Test dismiss split screen by dragging the divider bar.
 *
 * To run this test: `atest WMShellFlickerTests:DismissSplitScreenByDivider`
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class DismissSplitScreenByDivider (testSpec: FlickerTestParameter) : SplitScreenBase(testSpec) {

    // TODO(b/231399940): Remove this once we can use recent shortcut to enter split.
    @Before
    open fun before() {
        Assume.assumeTrue(tapl.isTablet)
    }

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this)
            setup {
                eachRun {
                    tapl.goHome()
                    primaryApp.launchViaIntent(wmHelper)
                    // TODO(b/231399940): Use recent shortcut to enter split.
                    tapl.launchedAppState.taskbar
                        .openAllApps()
                        .getAppIcon(secondaryApp.appName)
                        .dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`)
                    SplitScreenHelper.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
                }
            }
            transitions {
                SplitScreenHelper.dragDividerToDismissSplit(device, wmHelper)
                wmHelper.StateSyncBuilder()
                    .withAppTransitionIdle()
                    .withFullScreenApp(secondaryApp)
                    .waitForAndVerify()
            }
        }

    @Presubmit
    @Test
    fun splitScreenDividerBecomesInvisible() = testSpec.splitScreenDividerBecomesInvisible()

    @Presubmit
    @Test
    fun primaryAppLayerBecomesInvisible() = testSpec.layerBecomesInvisible(primaryApp)

    @Presubmit
    @Test
    fun secondaryAppLayerIsVisibleAtEnd() = testSpec.layerIsVisibleAtEnd(secondaryApp)

    @Presubmit
    @Test
    fun primaryAppBoundsBecomesInvisible() = testSpec.splitAppLayerBoundsBecomesInvisible(
        primaryApp, splitLeftTop = false)

    @Presubmit
    @Test
    fun secondaryAppBoundsIsFullscreenAtEnd() {
        testSpec.assertLayers {
            this.isVisible(secondaryApp)
                .then()
                .isInvisible(secondaryApp)
                .then()
                .isVisible(secondaryApp)
                .invoke("secondaryAppBoundsIsFullscreenAtEnd") {
                    val displayBounds = WindowUtils.getDisplayBounds(testSpec.endRotation)
                    it.visibleRegion(secondaryApp).coversExactly(displayBounds)
                }
        }
    }

    @Presubmit
    @Test
    fun primaryAppWindowBecomesInvisible() = testSpec.appWindowBecomesInvisible(primaryApp)

    @Presubmit
    @Test
    fun secondaryAppWindowIsVisibleAtEnd() = testSpec.appWindowIsVisibleAtEnd(secondaryApp)

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun entireScreenCovered() =
        super.entireScreenCovered()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarLayerIsVisibleAtStartAndEnd() =
        super.navBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarLayerPositionAtStartAndEnd() =
        super.navBarLayerPositionAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun navBarWindowIsAlwaysVisible() =
        super.navBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarLayerIsVisibleAtStartAndEnd() =
        super.statusBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarLayerPositionAtStartAndEnd() =
        super.statusBarLayerPositionAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun statusBarWindowIsAlwaysVisible() =
        super.statusBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun taskBarLayerIsVisibleAtStartAndEnd() =
        super.taskBarLayerIsVisibleAtStartAndEnd()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun taskBarWindowIsAlwaysVisible() =
        super.taskBarWindowIsAlwaysVisible()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
        super.visibleLayersShownMoreThanOneConsecutiveEntry()

    /** {@inheritDoc} */
    @Postsubmit
    @Test
    override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
        super.visibleWindowsShownMoreThanOneConsecutiveEntry()

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): List<FlickerTestParameter> {
            return FlickerTestParameterFactory.getInstance().getConfigNonRotationTests(
                repetitions = SplitScreenHelper.TEST_REPETITIONS,
                // TODO(b/176061063):The 3 buttons of nav bar do not exist in the hierarchy.
                supportedNavigationModes =
                    listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY))
        }
    }
}
+18 −18
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ class DismissSplitScreenByGoHome(

    @Presubmit
    @Test
    fun splitScreenDividerBecomesVisible() = testSpec.splitScreenDividerBecomesInvisible()
    fun splitScreenDividerBecomesInvisible() = testSpec.splitScreenDividerBecomesInvisible()

    @Presubmit
    @Test