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

Commit cf4b64cf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "5-1/ Migrate CTS split screen testNonResizeable tests"

parents 43113921 3e2cf2ea
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,3 +37,4 @@ const val TEST_APP_FIXED_ACTIVITY_LABEL = "FixedApp"
// Test App > SplitScreen Activity
const val TEST_APP_SPLITSCREEN_PRIMARY_LABEL = "SplitScreenPrimaryApp"
const val TEST_APP_SPLITSCREEN_SECONDARY_LABEL = "SplitScreenSecondaryApp"
const val TEST_APP_NONRESIZEABLE_LABEL = "NonResizeableApp"
+41 −5
Original line number Diff line number Diff line
@@ -61,10 +61,9 @@ class AppPairsTest(
            setup {
                eachRun {
                    uiDevice.wakeUpAndGoToHomeScreen()
                    primaryApp.open()
                    uiDevice.pressHome()
                    secondaryApp.open()
                    uiDevice.pressHome()
                    primaryApp.launchViaIntent()
                    secondaryApp.launchViaIntent()
                    nonResizeableApp.launchViaIntent()
                    updateTaskId()
                }
            }
@@ -90,7 +89,7 @@ class AppPairsTest(

    @Test
    fun testAppPairs_pairPrimaryAndSecondaryApps() {
        val testTag = "testAppPaired_pairPrimaryAndSecondary"
        val testTag = "testAppPairs_pairPrimaryAndSecondaryApps"
        runWithFlicker(appPairsSetup) {
            withTestName { testTag }
            repeat {
@@ -176,6 +175,36 @@ class AppPairsTest(
        }
    }

    @Test
    fun testAppPairs_canNotPairNonResizeableApps() {
        val testTag = "testAppPairs_canNotPairNonResizeableApps"
        runWithFlicker(appPairsSetup) {
            withTestName { testTag }
            repeat {
                TEST_REPETITIONS
            }
            transitions {
                nonResizeableApp.launchViaIntent()
                // TODO pair apps through normal UX flow
                executeShellCommand(composePairsCommand(
                    primaryTaskId, nonResizeableTaskId, true /* pair */))
                SystemClock.sleep(AppPairsHelper.TIMEOUT_MS)
            }
            assertions {
                layersTrace {
                    appPairsDividerIsInvisible()
                }
                windowManagerTrace {
                    end {
                        showsAppWindow(nonResizeableApp.defaultWindowName)
                            .and()
                            .hidesAppWindow(primaryApp.defaultWindowName)
                    }
                }
            }
        }
    }

    private fun composePairsCommand(
        primaryApp: String,
        secondaryApp: String,
@@ -202,6 +231,7 @@ class AppPairsTest(
    private fun updateTaskId() {
        val primaryAppComponent = primaryApp.openAppIntent.component
        val secondaryAppComponent = secondaryApp.openAppIntent.component
        val nonResizeableAppComponent = nonResizeableApp.openAppIntent.component
        if (primaryAppComponent != null) {
            primaryTaskId = appPairsHelper.getTaskIdForActivity(
                    primaryAppComponent.packageName, primaryAppComponent.className).toString()
@@ -210,11 +240,17 @@ class AppPairsTest(
            secondaryTaskId = appPairsHelper.getTaskIdForActivity(
                    secondaryAppComponent.packageName, secondaryAppComponent.className).toString()
        }
        if (nonResizeableAppComponent != null) {
            nonResizeableTaskId = appPairsHelper.getTaskIdForActivity(
                nonResizeableAppComponent.packageName,
                nonResizeableAppComponent.className).toString()
        }
    }

    companion object {
        var primaryTaskId = ""
        var secondaryTaskId = ""
        var nonResizeableTaskId = ""
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<Array<Any>> {
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.flicker.apppairs

import com.android.wm.shell.flicker.NonRotationTestBase
import com.android.wm.shell.flicker.TEST_APP_NONRESIZEABLE_LABEL
import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_PRIMARY_LABEL
import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_SECONDARY_LABEL
import com.android.wm.shell.flicker.helpers.AppPairsHelper
@@ -36,4 +37,7 @@ abstract class AppPairsTestBase(
    protected val secondaryApp = SplitScreenHelper(instrumentation,
            TEST_APP_SPLITSCREEN_SECONDARY_LABEL,
            Components.SplitScreenSecondaryActivity())
    protected val nonResizeableApp = SplitScreenHelper(instrumentation,
        TEST_APP_NONRESIZEABLE_LABEL,
        Components.NonResizeableActivity())
}
+106 −6
Original line number Diff line number Diff line
@@ -21,14 +21,21 @@ import android.view.Surface
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.dsl.runWithFlicker
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.canSplitScreen
import com.android.server.wm.flicker.helpers.exitSplitScreen
import com.android.server.wm.flicker.helpers.isInSplitScreen
import com.android.server.wm.flicker.helpers.launchSplitScreen
import com.android.server.wm.flicker.helpers.openQuickstep
import com.android.server.wm.flicker.helpers.wakeUpAndGoToHomeScreen
import com.android.wm.shell.flicker.dockedStackDividerIsInvisible
import com.android.wm.shell.flicker.dockedStackDividerIsVisible
import com.android.wm.shell.flicker.helpers.SplitScreenHelper.Companion.TEST_REPETITIONS
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import org.junit.Assert
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -56,14 +63,16 @@ class EnterSplitScreenTest(
            setup {
                eachRun {
                    uiDevice.wakeUpAndGoToHomeScreen()
                    splitScreenApp.open()
                    uiDevice.pressHome()
                }
            }
            teardown {
                eachRun {
                    if (uiDevice.isInSplitScreen()) {
                        uiDevice.exitSplitScreen()
                    }
                    splitScreenApp.exit()
                    secondaryApp.exit()
                    nonResizeableApp.exit()
                }
            }
            assertions {
@@ -87,6 +96,7 @@ class EnterSplitScreenTest(
                TEST_REPETITIONS
            }
            transitions {
                splitScreenApp.launchViaIntent()
                uiDevice.launchSplitScreen()
            }
            assertions {
@@ -118,10 +128,8 @@ class EnterSplitScreenTest(
                TEST_REPETITIONS
            }
            transitions {
                secondaryApp.open()
                uiDevice.pressHome()
                splitScreenApp.open()
                uiDevice.pressHome()
                secondaryApp.launchViaIntent()
                splitScreenApp.launchViaIntent()
                uiDevice.launchSplitScreen()
                splitScreenApp.reopenAppFromOverview()
            }
@@ -150,6 +158,98 @@ class EnterSplitScreenTest(
        }
    }

    @Test
    fun testNonResizeableNotDocked() {
        val testTag = "testNonResizeableNotDocked"
        runWithFlicker(splitScreenSetup) {
            withTestName { testTag }
            repeat {
                TEST_REPETITIONS
            }
            transitions {
                nonResizeableApp.launchViaIntent()
                uiDevice.openQuickstep()
                if (uiDevice.canSplitScreen()) {
                    Assert.fail("Non-resizeable app should not enter split screen")
                }
            }
            assertions {
                layersTrace {
                    dockedStackDividerIsInvisible()
                }
                windowManagerTrace {
                    end {
                        hidesAppWindow(nonResizeableApp.defaultWindowName)
                    }
                }
            }
        }
    }

    @Test
    fun testNonResizeableWhenAlreadyInSplitScreenPrimary() {
        val testTag = "testNonResizeableWhenAlreadyInSplitScreenPrimary"
        runWithFlicker(splitScreenSetup) {
            withTestName { testTag }
            repeat {
                TEST_REPETITIONS
            }
            transitions {
                nonResizeableApp.launchViaIntent()
                splitScreenApp.launchViaIntent()
                uiDevice.launchSplitScreen()
                nonResizeableApp.reopenAppFromOverview()
            }
            assertions {
                layersTrace {
                    dockedStackDividerIsInvisible()
                    end("appsEndingBounds", enabled = false) {
                        val displayBounds = WindowUtils.getDisplayBounds(rotation)
                        this.hasVisibleRegion(nonResizeableApp.defaultWindowName, displayBounds)
                    }
                }
                windowManagerTrace {
                    end {
                        showsAppWindow(nonResizeableApp.defaultWindowName)
                        hidesAppWindow(splitScreenApp.defaultWindowName)
                    }
                }
            }
        }
    }

    @Test
    fun testNonResizeableWhenAlreadyInSplitScreenSecondary() {
        val testTag = "testNonResizeableWhenAlreadyInSplitScreenSecondary"
        runWithFlicker(splitScreenSetup) {
            withTestName { testTag }
            repeat {
                TEST_REPETITIONS
            }
            transitions {
                splitScreenApp.launchViaIntent()
                uiDevice.launchSplitScreen()
                uiDevice.pressBack()
                nonResizeableApp.launchViaIntent()
            }
            assertions {
                layersTrace {
                    dockedStackDividerIsInvisible()
                    end("appsEndingBounds", enabled = false) {
                        val displayBounds = WindowUtils.getDisplayBounds(rotation)
                        this.hasVisibleRegion(nonResizeableApp.defaultWindowName, displayBounds)
                    }
                }
                windowManagerTrace {
                    end {
                        showsAppWindow(nonResizeableApp.defaultWindowName)
                        hidesAppWindow(splitScreenApp.defaultWindowName)
                    }
                }
            }
        }
    }

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.flicker.splitscreen

import com.android.wm.shell.flicker.NonRotationTestBase
import com.android.wm.shell.flicker.TEST_APP_NONRESIZEABLE_LABEL
import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_PRIMARY_LABEL
import com.android.wm.shell.flicker.TEST_APP_SPLITSCREEN_SECONDARY_LABEL
import com.android.wm.shell.flicker.helpers.SplitScreenHelper
@@ -32,4 +33,7 @@ abstract class SplitScreenTestBase(
    protected val secondaryApp = SplitScreenHelper(instrumentation,
            TEST_APP_SPLITSCREEN_SECONDARY_LABEL,
            Components.SplitScreenSecondaryActivity())
    protected val nonResizeableApp = SplitScreenHelper(instrumentation,
            TEST_APP_NONRESIZEABLE_LABEL,
            Components.NonResizeableActivity())
}
Loading