Loading libs/WindowManager/Shell/tests/e2e/splitscreen/flicker-legacy/src/com/android/wm/shell/flicker/splitscreen/benchmark/SwitchAppByDoubleTapDividerBenchmark.kt +8 −9 Original line number Diff line number Diff line Loading @@ -17,15 +17,15 @@ package com.android.wm.shell.flicker.splitscreen.benchmark import android.tools.NavBar import android.tools.Rotation import android.tools.flicker.junit.FlickerParametersRunnerFactory import android.tools.flicker.legacy.FlickerBuilder import android.tools.flicker.legacy.LegacyFlickerTest import android.tools.flicker.legacy.LegacyFlickerTestFactory import android.tools.helpers.WindowUtils import android.tools.traces.parsers.WindowManagerStateHelper import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.UiDevice import com.android.wm.shell.flicker.utils.SplitScreenUtils import com.android.wm.shell.flicker.utils.SplitScreenUtils.isLeftRightSplit import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters Loading @@ -37,6 +37,8 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: LegacyFlickerTest) : SplitScreenBase(flicker) { private val device = UiDevice.getInstance(instrumentation) protected val thisTransition: FlickerBuilder.() -> Unit get() = { setup { Loading Loading @@ -73,7 +75,8 @@ abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: Legacy } ?: return@add false if (isLandscape(flicker.scenario.endRotation)) { if (isLeftRightSplit(instrumentation.context, flicker.scenario.endRotation, device.displaySizeDp)) { return@add if (flicker.scenario.isTablet) { secondaryAppWindow.frame.right <= primaryAppWindow.frame.left } else { Loading Loading @@ -109,7 +112,8 @@ abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: Legacy val secondaryVisibleRegion = secondaryAppLayer.visibleRegion?.bounds ?: return@add false if (isLandscape(flicker.scenario.endRotation)) { if (isLeftRightSplit(instrumentation.context, flicker.scenario.endRotation, device.displaySizeDp)) { return@add if (flicker.scenario.isTablet) { secondaryVisibleRegion.right <= primaryVisibleRegion.left } else { Loading @@ -126,11 +130,6 @@ abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: Legacy .waitForAndVerify() } private fun isLandscape(rotation: Rotation): Boolean { val displayBounds = WindowUtils.getDisplayBounds(rotation) return displayBounds.width() > displayBounds.height() } companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic Loading libs/WindowManager/Shell/tests/e2e/splitscreen/scenarios/src/com/android/wm/shell/scenarios/SwitchAppByDoubleTapDivider.kt +8 −19 Original line number Diff line number Diff line Loading @@ -17,16 +17,16 @@ package com.android.wm.shell.scenarios import android.app.Instrumentation import android.graphics.Point import android.tools.NavBar import android.tools.Rotation import android.tools.helpers.WindowUtils import android.tools.traces.parsers.WindowManagerStateHelper import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import com.android.launcher3.tapl.LauncherInstrumentation import com.android.wm.shell.Utils import com.android.wm.shell.flicker.utils.SplitScreenUtils import com.android.wm.shell.flicker.utils.SplitScreenUtils.isLeftRightSplit import com.android.wm.shell.flicker.utils.SplitScreenUtils.isTablet import org.junit.After import org.junit.Before import org.junit.Ignore Loading Loading @@ -89,14 +89,14 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) { } ?: return@add false if (isLandscape(rotation)) { return@add if (isTablet()) { if (isLeftRightSplit(instrumentation.context, rotation, device.displaySizeDp)) { return@add if (isTablet(device.displaySizeDp)) { secondaryAppWindow.frame.right <= primaryAppWindow.frame.left } else { primaryAppWindow.frame.right <= secondaryAppWindow.frame.left } } else { return@add if (isTablet()) { return@add if (isTablet(device.displaySizeDp)) { primaryAppWindow.frame.bottom <= secondaryAppWindow.frame.top } else { primaryAppWindow.frame.bottom <= secondaryAppWindow.frame.top Loading Loading @@ -125,14 +125,14 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) { val secondaryVisibleRegion = secondaryAppLayer.visibleRegion?.bounds ?: return@add false if (isLandscape(rotation)) { return@add if (isTablet()) { if (isLeftRightSplit(instrumentation.context, rotation, device.displaySizeDp)) { return@add if (isTablet(device.displaySizeDp)) { secondaryVisibleRegion.right <= primaryVisibleRegion.left } else { primaryVisibleRegion.right <= secondaryVisibleRegion.left } } else { return@add if (isTablet()) { return@add if (isTablet(device.displaySizeDp)) { primaryVisibleRegion.bottom <= secondaryVisibleRegion.top } else { primaryVisibleRegion.bottom <= secondaryVisibleRegion.top Loading @@ -141,15 +141,4 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) { } .waitForAndVerify() } private fun isLandscape(rotation: Rotation): Boolean { val displayBounds = WindowUtils.getDisplayBounds(rotation) return displayBounds.width() > displayBounds.height() } private fun isTablet(): Boolean { val sizeDp: Point = device.displaySizeDp val LARGE_SCREEN_DP_THRESHOLD = 600 return sizeDp.x >= LARGE_SCREEN_DP_THRESHOLD && sizeDp.y >= LARGE_SCREEN_DP_THRESHOLD } } libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/utils/SplitScreenUtils.kt +22 −0 Original line number Diff line number Diff line Loading @@ -17,12 +17,14 @@ package com.android.wm.shell.flicker.utils import android.app.Instrumentation import android.content.Context import android.graphics.Point import android.os.SystemClock import android.tools.Rotation import android.tools.device.apphelpers.IStandardAppHelper import android.tools.device.apphelpers.StandardAppHelper import android.tools.flicker.rules.ChangeDisplayOrientationRule import android.tools.helpers.WindowUtils import android.tools.traces.component.ComponentNameMatcher import android.tools.traces.component.IComponentMatcher import android.tools.traces.component.IComponentNameMatcher Loading Loading @@ -393,4 +395,24 @@ object SplitScreenUtils { error("Fail to copy content in split") } } fun isLeftRightSplit(context: Context, rotation: Rotation, displaySizeDp: Point): Boolean { val allowLeftRightSplit = context.resources.getBoolean( com.android.internal.R.bool.config_leftRightSplitInPortrait) val displayBounds = WindowUtils.getDisplayBounds(rotation) val isLandscape = displayBounds.width() > displayBounds.height() if (allowLeftRightSplit && isTablet(displaySizeDp)) { // Certain devices allow left/right split in portrait, so they end up with top/bottom // split in landscape return !isLandscape } else { return isLandscape } } fun isTablet(displaySizeDp: Point): Boolean { val LARGE_SCREEN_DP_THRESHOLD = 600 return displaySizeDp.x >= LARGE_SCREEN_DP_THRESHOLD && displaySizeDp.y >= LARGE_SCREEN_DP_THRESHOLD } } Loading
libs/WindowManager/Shell/tests/e2e/splitscreen/flicker-legacy/src/com/android/wm/shell/flicker/splitscreen/benchmark/SwitchAppByDoubleTapDividerBenchmark.kt +8 −9 Original line number Diff line number Diff line Loading @@ -17,15 +17,15 @@ package com.android.wm.shell.flicker.splitscreen.benchmark import android.tools.NavBar import android.tools.Rotation import android.tools.flicker.junit.FlickerParametersRunnerFactory import android.tools.flicker.legacy.FlickerBuilder import android.tools.flicker.legacy.LegacyFlickerTest import android.tools.flicker.legacy.LegacyFlickerTestFactory import android.tools.helpers.WindowUtils import android.tools.traces.parsers.WindowManagerStateHelper import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.UiDevice import com.android.wm.shell.flicker.utils.SplitScreenUtils import com.android.wm.shell.flicker.utils.SplitScreenUtils.isLeftRightSplit import org.junit.FixMethodOrder import org.junit.runner.RunWith import org.junit.runners.MethodSorters Loading @@ -37,6 +37,8 @@ import org.junit.runners.Parameterized @FixMethodOrder(MethodSorters.NAME_ASCENDING) abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: LegacyFlickerTest) : SplitScreenBase(flicker) { private val device = UiDevice.getInstance(instrumentation) protected val thisTransition: FlickerBuilder.() -> Unit get() = { setup { Loading Loading @@ -73,7 +75,8 @@ abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: Legacy } ?: return@add false if (isLandscape(flicker.scenario.endRotation)) { if (isLeftRightSplit(instrumentation.context, flicker.scenario.endRotation, device.displaySizeDp)) { return@add if (flicker.scenario.isTablet) { secondaryAppWindow.frame.right <= primaryAppWindow.frame.left } else { Loading Loading @@ -109,7 +112,8 @@ abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: Legacy val secondaryVisibleRegion = secondaryAppLayer.visibleRegion?.bounds ?: return@add false if (isLandscape(flicker.scenario.endRotation)) { if (isLeftRightSplit(instrumentation.context, flicker.scenario.endRotation, device.displaySizeDp)) { return@add if (flicker.scenario.isTablet) { secondaryVisibleRegion.right <= primaryVisibleRegion.left } else { Loading @@ -126,11 +130,6 @@ abstract class SwitchAppByDoubleTapDividerBenchmark(override val flicker: Legacy .waitForAndVerify() } private fun isLandscape(rotation: Rotation): Boolean { val displayBounds = WindowUtils.getDisplayBounds(rotation) return displayBounds.width() > displayBounds.height() } companion object { @Parameterized.Parameters(name = "{0}") @JvmStatic Loading
libs/WindowManager/Shell/tests/e2e/splitscreen/scenarios/src/com/android/wm/shell/scenarios/SwitchAppByDoubleTapDivider.kt +8 −19 Original line number Diff line number Diff line Loading @@ -17,16 +17,16 @@ package com.android.wm.shell.scenarios import android.app.Instrumentation import android.graphics.Point import android.tools.NavBar import android.tools.Rotation import android.tools.helpers.WindowUtils import android.tools.traces.parsers.WindowManagerStateHelper import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import com.android.launcher3.tapl.LauncherInstrumentation import com.android.wm.shell.Utils import com.android.wm.shell.flicker.utils.SplitScreenUtils import com.android.wm.shell.flicker.utils.SplitScreenUtils.isLeftRightSplit import com.android.wm.shell.flicker.utils.SplitScreenUtils.isTablet import org.junit.After import org.junit.Before import org.junit.Ignore Loading Loading @@ -89,14 +89,14 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) { } ?: return@add false if (isLandscape(rotation)) { return@add if (isTablet()) { if (isLeftRightSplit(instrumentation.context, rotation, device.displaySizeDp)) { return@add if (isTablet(device.displaySizeDp)) { secondaryAppWindow.frame.right <= primaryAppWindow.frame.left } else { primaryAppWindow.frame.right <= secondaryAppWindow.frame.left } } else { return@add if (isTablet()) { return@add if (isTablet(device.displaySizeDp)) { primaryAppWindow.frame.bottom <= secondaryAppWindow.frame.top } else { primaryAppWindow.frame.bottom <= secondaryAppWindow.frame.top Loading Loading @@ -125,14 +125,14 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) { val secondaryVisibleRegion = secondaryAppLayer.visibleRegion?.bounds ?: return@add false if (isLandscape(rotation)) { return@add if (isTablet()) { if (isLeftRightSplit(instrumentation.context, rotation, device.displaySizeDp)) { return@add if (isTablet(device.displaySizeDp)) { secondaryVisibleRegion.right <= primaryVisibleRegion.left } else { primaryVisibleRegion.right <= secondaryVisibleRegion.left } } else { return@add if (isTablet()) { return@add if (isTablet(device.displaySizeDp)) { primaryVisibleRegion.bottom <= secondaryVisibleRegion.top } else { primaryVisibleRegion.bottom <= secondaryVisibleRegion.top Loading @@ -141,15 +141,4 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) { } .waitForAndVerify() } private fun isLandscape(rotation: Rotation): Boolean { val displayBounds = WindowUtils.getDisplayBounds(rotation) return displayBounds.width() > displayBounds.height() } private fun isTablet(): Boolean { val sizeDp: Point = device.displaySizeDp val LARGE_SCREEN_DP_THRESHOLD = 600 return sizeDp.x >= LARGE_SCREEN_DP_THRESHOLD && sizeDp.y >= LARGE_SCREEN_DP_THRESHOLD } }
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/utils/SplitScreenUtils.kt +22 −0 Original line number Diff line number Diff line Loading @@ -17,12 +17,14 @@ package com.android.wm.shell.flicker.utils import android.app.Instrumentation import android.content.Context import android.graphics.Point import android.os.SystemClock import android.tools.Rotation import android.tools.device.apphelpers.IStandardAppHelper import android.tools.device.apphelpers.StandardAppHelper import android.tools.flicker.rules.ChangeDisplayOrientationRule import android.tools.helpers.WindowUtils import android.tools.traces.component.ComponentNameMatcher import android.tools.traces.component.IComponentMatcher import android.tools.traces.component.IComponentNameMatcher Loading Loading @@ -393,4 +395,24 @@ object SplitScreenUtils { error("Fail to copy content in split") } } fun isLeftRightSplit(context: Context, rotation: Rotation, displaySizeDp: Point): Boolean { val allowLeftRightSplit = context.resources.getBoolean( com.android.internal.R.bool.config_leftRightSplitInPortrait) val displayBounds = WindowUtils.getDisplayBounds(rotation) val isLandscape = displayBounds.width() > displayBounds.height() if (allowLeftRightSplit && isTablet(displaySizeDp)) { // Certain devices allow left/right split in portrait, so they end up with top/bottom // split in landscape return !isLandscape } else { return isLandscape } } fun isTablet(displaySizeDp: Point): Boolean { val LARGE_SCREEN_DP_THRESHOLD = 600 return displaySizeDp.x >= LARGE_SCREEN_DP_THRESHOLD && displaySizeDp.y >= LARGE_SCREEN_DP_THRESHOLD } }