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

Commit 97db2979 authored by Chilun Huang's avatar Chilun Huang
Browse files

Create flicker tests for split screen

Create the base split screen flicker test and the CUJ of entering split
by dragging from all apps.

Bug: 231399426
Bug: 232878493
Test: atest EnterSplitScreenByDragFromAllApps
Change-Id: Ic684474457f5da28554ff801f3e03d585e8db9fb
parent 6cfafc4b
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -43,6 +43,32 @@ fun FlickerTestParameter.appPairsDividerBecomesVisible() {
    }
}

fun FlickerTestParameter.splitScreenDividerBecomesVisible() {
    assertLayers {
        this.isInvisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
            .then()
            .isVisible(SPLIT_SCREEN_DIVIDER_COMPONENT)
    }
}

fun FlickerTestParameter.appWindowBecomesVisible(
    component: FlickerComponentName
) {
    assertWm {
        this.isAppWindowInvisible(component)
            .then()
            .isAppWindowVisible(component)
    }
}

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

fun FlickerTestParameter.dockedStackDividerIsVisibleAtEnd() {
    assertLayersEnd {
        this.isVisible(DOCKED_STACK_DIVIDER_COMPONENT)
+2 −1
Original line number Diff line number Diff line
@@ -22,3 +22,4 @@ import com.android.server.wm.traces.common.FlickerComponentName
const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui"
val APP_PAIR_SPLIT_DIVIDER_COMPONENT = FlickerComponentName("", "AppPairSplitDivider#")
val DOCKED_STACK_DIVIDER_COMPONENT = FlickerComponentName("", "DockedStackDivider#")
val SPLIT_SCREEN_DIVIDER_COMPONENT = FlickerComponentName("", "StageCoordinatorSplitDivider#")
+101 −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.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.wm.shell.flicker.appWindowBecomesVisible
import com.android.wm.shell.flicker.appWindowIsVisibleAtEnd
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
import com.android.wm.shell.flicker.splitScreenDividerBecomesVisible
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 enter split screen by dragging app icon from all apps.
 * This test is only for large screen devices.
 *
 * To run this test: `atest WMShellFlickerTests:EnterSplitScreenByDragFromAllApps`
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class EnterSplitScreenByDragFromAllApps(
    testSpec: FlickerTestParameter
) : SplitScreenBase(testSpec) {

    @Before
    open fun before() {
        Assume.assumeTrue(taplInstrumentation.isTablet)
    }

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            super.transition(this)
            setup {
                eachRun {
                    taplInstrumentation.goHome()
                    primaryApp.launchViaIntent(wmHelper)
                }
            }
            transitions {
                taplInstrumentation.launchedAppState.taskbar
                        .openAllApps()
                        .getAppIcon(secondaryApp.appName)
                        .dragToSplitscreen(secondaryApp.component.packageName,
                                primaryApp.component.packageName)
            }
        }

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

    @Presubmit
    @Test
    fun primaryAppWindowIsVisibleAtEnd() = testSpec.appWindowIsVisibleAtEnd(primaryApp.component)

    @Presubmit
    @Test
    fun secondaryAppWindowBecomesVisible() =
            testSpec.appWindowBecomesVisible(secondaryApp.component)

    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))
        }
    }
}
+59 −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.app.Instrumentation
import android.content.Context
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.helpers.setRotation
import com.android.wm.shell.flicker.helpers.SplitScreenHelper

abstract class SplitScreenBase(protected val testSpec: FlickerTestParameter) {
    protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    protected val taplInstrumentation = LauncherInstrumentation()
    protected val context: Context = instrumentation.context
    protected val primaryApp = SplitScreenHelper.getPrimary(instrumentation)
    protected val secondaryApp = SplitScreenHelper.getSecondary(instrumentation)

    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
            transition(this)
        }
    }

    protected open val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                test {
                    taplInstrumentation.setEnableRotation(true)
                    setRotation(testSpec.startRotation)
                    taplInstrumentation.setExpectedRotation(testSpec.startRotation)
                }
            }
            teardown {
                eachRun {
                    primaryApp.exit(wmHelper)
                    secondaryApp.exit(wmHelper)
                }
            }
        }
}