Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenUtils.kt→libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/SplitScreenUtils.kt +2 −4 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * Copyright (C) 2023 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. Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.wm.shell.flicker.splitscreen package com.android.wm.shell.flicker import android.app.Instrumentation import android.graphics.Point Loading @@ -40,8 +40,6 @@ import com.android.server.wm.flicker.helpers.NotificationAppHelper import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.server.wm.flicker.testapp.ActivityOptions.SplitScreen.Primary import com.android.wm.shell.flicker.LAUNCHER_UI_PACKAGE_NAME import com.android.wm.shell.flicker.SYSTEM_UI_PACKAGE_NAME import org.junit.Assert.assertNotNull internal object SplitScreenUtils { Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipFromSplitScreenOnGoToHomeTest.kt +7 −63 Original line number Diff line number Diff line Loading @@ -16,12 +16,9 @@ package com.android.wm.shell.flicker.pip import android.app.Instrumentation import android.os.SystemClock import android.platform.test.annotations.Presubmit import android.tools.common.NavBar import android.tools.common.Rotation import android.tools.device.apphelpers.StandardAppHelper import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.LegacyFlickerTest Loading @@ -29,13 +26,9 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.helpers.WindowUtils import android.tools.device.traces.parsers.toFlickerComponent import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.BySelector import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.wm.shell.flicker.LAUNCHER_UI_PACKAGE_NAME import com.android.wm.shell.flicker.SplitScreenUtils import org.junit.Assume import org.junit.FixMethodOrder import org.junit.Test Loading Loading @@ -73,9 +66,7 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) : AutoEnterPipOnGoToHomeTest(flicker) { private val portraitDisplayBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0) /** Second app used to enter split screen mode */ protected val secondAppForSplitScreen = getSplitScreenApp(instrumentation) fun getSplitScreenApp(instrumentation: Instrumentation): StandardAppHelper = SimpleAppHelper( private val secondAppForSplitScreen = SimpleAppHelper( instrumentation, ActivityOptions.SplitScreen.Primary.LABEL, ActivityOptions.SplitScreen.Primary.COMPONENT.toFlickerComponent() Loading @@ -88,14 +79,7 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) : secondAppForSplitScreen.launchViaIntent(wmHelper) pipApp.launchViaIntent(wmHelper) tapl.goHome() enterSplitScreen() // wait until split screen is established wmHelper .StateSyncBuilder() .withWindowSurfaceAppeared(pipApp) .withWindowSurfaceAppeared(secondAppForSplitScreen) .withSplitDividerVisible() .waitForAndVerify() SplitScreenUtils.enterSplit(wmHelper, tapl, device, pipApp, secondAppForSplitScreen) pipApp.enableAutoEnterForPipActivity() } teardown { Loading @@ -107,46 +91,6 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) : transitions { tapl.goHome() } } // TODO(b/285400227) merge the code in a common utility - this is copied from SplitScreenUtils private val TIMEOUT_MS = 3_000L private val overviewSnapshotSelector: BySelector get() = By.res(LAUNCHER_UI_PACKAGE_NAME, "snapshot") private fun enterSplitScreen() { // 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's currentTask on tablet is sometimes not what we expected if the overview // contains more than 3 task views. We need to use uiautomator directly to find the // second task to split. tapl.workspace.switchToOverview().overviewActions.clickSplit() val snapshots = tapl.device.wait(Until.findObjects(overviewSnapshotSelector), TIMEOUT_MS) if (snapshots == null || snapshots.size < 1) { error("Fail to find a overview snapshot to split.") } // Find the second task in the upper right corner in split select mode by sorting // 'left' in descending order and 'top' in ascending order. snapshots.sortWith { t1: UiObject2, t2: UiObject2 -> t2.getVisibleBounds().left - t1.getVisibleBounds().left } snapshots.sortWith { t1: UiObject2, t2: UiObject2 -> t1.getVisibleBounds().top - t2.getVisibleBounds().top } snapshots[0].click() } else { tapl.workspace .switchToOverview() .currentTask .tapMenu() .tapSplitMenuItem() .currentTask .open() } SystemClock.sleep(TIMEOUT_MS) } @Presubmit @Test override fun pipOverlayLayerAppearThenDisappear() { Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenBase.kt +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.LegacyFlickerTest import com.android.server.wm.flicker.helpers.setRotation import com.android.wm.shell.flicker.BaseBenchmarkTest import com.android.wm.shell.flicker.SplitScreenUtils abstract class SplitScreenBase(flicker: LegacyFlickerTest) : BaseBenchmarkTest(flicker) { protected val context: Context = instrumentation.context Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/benchmark/CopyContentInSplitBenchmark.kt +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.wm.shell.flicker.splitscreen.SplitScreenBase import com.android.wm.shell.flicker.splitscreen.SplitScreenUtils import com.android.wm.shell.flicker.SplitScreenUtils import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith Loading libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/benchmark/DismissSplitScreenByDividerBenchmark.kt +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.wm.shell.flicker.splitScreenDismissed import com.android.wm.shell.flicker.splitscreen.SplitScreenBase import com.android.wm.shell.flicker.splitscreen.SplitScreenUtils import com.android.wm.shell.flicker.SplitScreenUtils import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith Loading Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenUtils.kt→libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/SplitScreenUtils.kt +2 −4 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * Copyright (C) 2023 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. Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.wm.shell.flicker.splitscreen package com.android.wm.shell.flicker import android.app.Instrumentation import android.graphics.Point Loading @@ -40,8 +40,6 @@ import com.android.server.wm.flicker.helpers.NotificationAppHelper import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.server.wm.flicker.testapp.ActivityOptions.SplitScreen.Primary import com.android.wm.shell.flicker.LAUNCHER_UI_PACKAGE_NAME import com.android.wm.shell.flicker.SYSTEM_UI_PACKAGE_NAME import org.junit.Assert.assertNotNull internal object SplitScreenUtils { Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/pip/AutoEnterPipFromSplitScreenOnGoToHomeTest.kt +7 −63 Original line number Diff line number Diff line Loading @@ -16,12 +16,9 @@ package com.android.wm.shell.flicker.pip import android.app.Instrumentation import android.os.SystemClock import android.platform.test.annotations.Presubmit import android.tools.common.NavBar import android.tools.common.Rotation import android.tools.device.apphelpers.StandardAppHelper import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.LegacyFlickerTest Loading @@ -29,13 +26,9 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.helpers.WindowUtils import android.tools.device.traces.parsers.toFlickerComponent import androidx.test.filters.RequiresDevice import androidx.test.uiautomator.By import androidx.test.uiautomator.BySelector import androidx.test.uiautomator.UiObject2 import androidx.test.uiautomator.Until import com.android.server.wm.flicker.helpers.SimpleAppHelper import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.wm.shell.flicker.LAUNCHER_UI_PACKAGE_NAME import com.android.wm.shell.flicker.SplitScreenUtils import org.junit.Assume import org.junit.FixMethodOrder import org.junit.Test Loading Loading @@ -73,9 +66,7 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) : AutoEnterPipOnGoToHomeTest(flicker) { private val portraitDisplayBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0) /** Second app used to enter split screen mode */ protected val secondAppForSplitScreen = getSplitScreenApp(instrumentation) fun getSplitScreenApp(instrumentation: Instrumentation): StandardAppHelper = SimpleAppHelper( private val secondAppForSplitScreen = SimpleAppHelper( instrumentation, ActivityOptions.SplitScreen.Primary.LABEL, ActivityOptions.SplitScreen.Primary.COMPONENT.toFlickerComponent() Loading @@ -88,14 +79,7 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) : secondAppForSplitScreen.launchViaIntent(wmHelper) pipApp.launchViaIntent(wmHelper) tapl.goHome() enterSplitScreen() // wait until split screen is established wmHelper .StateSyncBuilder() .withWindowSurfaceAppeared(pipApp) .withWindowSurfaceAppeared(secondAppForSplitScreen) .withSplitDividerVisible() .waitForAndVerify() SplitScreenUtils.enterSplit(wmHelper, tapl, device, pipApp, secondAppForSplitScreen) pipApp.enableAutoEnterForPipActivity() } teardown { Loading @@ -107,46 +91,6 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) : transitions { tapl.goHome() } } // TODO(b/285400227) merge the code in a common utility - this is copied from SplitScreenUtils private val TIMEOUT_MS = 3_000L private val overviewSnapshotSelector: BySelector get() = By.res(LAUNCHER_UI_PACKAGE_NAME, "snapshot") private fun enterSplitScreen() { // 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's currentTask on tablet is sometimes not what we expected if the overview // contains more than 3 task views. We need to use uiautomator directly to find the // second task to split. tapl.workspace.switchToOverview().overviewActions.clickSplit() val snapshots = tapl.device.wait(Until.findObjects(overviewSnapshotSelector), TIMEOUT_MS) if (snapshots == null || snapshots.size < 1) { error("Fail to find a overview snapshot to split.") } // Find the second task in the upper right corner in split select mode by sorting // 'left' in descending order and 'top' in ascending order. snapshots.sortWith { t1: UiObject2, t2: UiObject2 -> t2.getVisibleBounds().left - t1.getVisibleBounds().left } snapshots.sortWith { t1: UiObject2, t2: UiObject2 -> t1.getVisibleBounds().top - t2.getVisibleBounds().top } snapshots[0].click() } else { tapl.workspace .switchToOverview() .currentTask .tapMenu() .tapSplitMenuItem() .currentTask .open() } SystemClock.sleep(TIMEOUT_MS) } @Presubmit @Test override fun pipOverlayLayerAppearThenDisappear() { Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/SplitScreenBase.kt +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.LegacyFlickerTest import com.android.server.wm.flicker.helpers.setRotation import com.android.wm.shell.flicker.BaseBenchmarkTest import com.android.wm.shell.flicker.SplitScreenUtils abstract class SplitScreenBase(flicker: LegacyFlickerTest) : BaseBenchmarkTest(flicker) { protected val context: Context = instrumentation.context Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/benchmark/CopyContentInSplitBenchmark.kt +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.wm.shell.flicker.splitscreen.SplitScreenBase import com.android.wm.shell.flicker.splitscreen.SplitScreenUtils import com.android.wm.shell.flicker.SplitScreenUtils import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith Loading
libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/splitscreen/benchmark/DismissSplitScreenByDividerBenchmark.kt +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import androidx.test.filters.RequiresDevice import com.android.wm.shell.flicker.splitScreenDismissed import com.android.wm.shell.flicker.splitscreen.SplitScreenBase import com.android.wm.shell.flicker.splitscreen.SplitScreenUtils import com.android.wm.shell.flicker.SplitScreenUtils import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith Loading