Merge "Simplify pip tests" into udc-qpr-dev am: 93381a1ab1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23781511

Change-Id: Icd7fec7b4f3fc95ed6b83a74610b683848c5169a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Nataniel Borges
2023-07-03 21:14:27 +00:00
committed by Automerger Merge Worker
18 changed files with 25 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.wm.shell.flicker.splitscreen package com.android.wm.shell.flicker
import android.app.Instrumentation import android.app.Instrumentation
import android.graphics.Point import android.graphics.Point
@@ -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.helpers.SimpleAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.flicker.testapp.ActivityOptions.SplitScreen.Primary 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 import org.junit.Assert.assertNotNull
internal object SplitScreenUtils { internal object SplitScreenUtils {

View File

@@ -16,12 +16,9 @@
package com.android.wm.shell.flicker.pip package com.android.wm.shell.flicker.pip
import android.app.Instrumentation
import android.os.SystemClock
import android.platform.test.annotations.Presubmit import android.platform.test.annotations.Presubmit
import android.tools.common.NavBar import android.tools.common.NavBar
import android.tools.common.Rotation import android.tools.common.Rotation
import android.tools.device.apphelpers.StandardAppHelper
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.flicker.legacy.LegacyFlickerTest
@@ -29,13 +26,9 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import android.tools.device.helpers.WindowUtils import android.tools.device.helpers.WindowUtils
import android.tools.device.traces.parsers.toFlickerComponent import android.tools.device.traces.parsers.toFlickerComponent
import androidx.test.filters.RequiresDevice 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.helpers.SimpleAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions 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.Assume
import org.junit.FixMethodOrder import org.junit.FixMethodOrder
import org.junit.Test import org.junit.Test
@@ -73,13 +66,11 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) :
AutoEnterPipOnGoToHomeTest(flicker) { AutoEnterPipOnGoToHomeTest(flicker) {
private val portraitDisplayBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0) private val portraitDisplayBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0)
/** Second app used to enter split screen mode */ /** Second app used to enter split screen mode */
protected val secondAppForSplitScreen = getSplitScreenApp(instrumentation) private val secondAppForSplitScreen = SimpleAppHelper(
fun getSplitScreenApp(instrumentation: Instrumentation): StandardAppHelper = instrumentation,
SimpleAppHelper( ActivityOptions.SplitScreen.Primary.LABEL,
instrumentation, ActivityOptions.SplitScreen.Primary.COMPONENT.toFlickerComponent()
ActivityOptions.SplitScreen.Primary.LABEL, )
ActivityOptions.SplitScreen.Primary.COMPONENT.toFlickerComponent()
)
/** Defines the transition used to run the test */ /** Defines the transition used to run the test */
override val transition: FlickerBuilder.() -> Unit override val transition: FlickerBuilder.() -> Unit
@@ -88,14 +79,7 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) :
secondAppForSplitScreen.launchViaIntent(wmHelper) secondAppForSplitScreen.launchViaIntent(wmHelper)
pipApp.launchViaIntent(wmHelper) pipApp.launchViaIntent(wmHelper)
tapl.goHome() tapl.goHome()
enterSplitScreen() SplitScreenUtils.enterSplit(wmHelper, tapl, device, pipApp, secondAppForSplitScreen)
// wait until split screen is established
wmHelper
.StateSyncBuilder()
.withWindowSurfaceAppeared(pipApp)
.withWindowSurfaceAppeared(secondAppForSplitScreen)
.withSplitDividerVisible()
.waitForAndVerify()
pipApp.enableAutoEnterForPipActivity() pipApp.enableAutoEnterForPipActivity()
} }
teardown { teardown {
@@ -107,46 +91,6 @@ class AutoEnterPipFromSplitScreenOnGoToHomeTest(flicker: LegacyFlickerTest) :
transitions { tapl.goHome() } 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 @Presubmit
@Test @Test
override fun pipOverlayLayerAppearThenDisappear() { override fun pipOverlayLayerAppearThenDisappear() {

View File

@@ -21,6 +21,7 @@ import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest import android.tools.device.flicker.legacy.LegacyFlickerTest
import com.android.server.wm.flicker.helpers.setRotation import com.android.server.wm.flicker.helpers.setRotation
import com.android.wm.shell.flicker.BaseBenchmarkTest import com.android.wm.shell.flicker.BaseBenchmarkTest
import com.android.wm.shell.flicker.SplitScreenUtils
abstract class SplitScreenBase(flicker: LegacyFlickerTest) : BaseBenchmarkTest(flicker) { abstract class SplitScreenBase(flicker: LegacyFlickerTest) : BaseBenchmarkTest(flicker) {
protected val context: Context = instrumentation.context protected val context: Context = instrumentation.context

View File

@@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenDismissed import com.android.wm.shell.flicker.splitScreenDismissed
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenDismissed import com.android.wm.shell.flicker.splitScreenDismissed
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -24,7 +24,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.Assume import org.junit.Assume
import org.junit.Before import org.junit.Before
import org.junit.FixMethodOrder import org.junit.FixMethodOrder

View File

@@ -26,7 +26,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.Assume import org.junit.Assume
import org.junit.Before import org.junit.Before
import org.junit.FixMethodOrder import org.junit.FixMethodOrder

View File

@@ -26,7 +26,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.Assume import org.junit.Assume
import org.junit.Before import org.junit.Before
import org.junit.FixMethodOrder import org.junit.FixMethodOrder

View File

@@ -26,7 +26,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.Assume import org.junit.Assume
import org.junit.Before import org.junit.Before
import org.junit.FixMethodOrder import org.junit.FixMethodOrder

View File

@@ -26,7 +26,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.Assume import org.junit.Assume
import org.junit.Before import org.junit.Before
import org.junit.FixMethodOrder import org.junit.FixMethodOrder

View File

@@ -25,7 +25,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -28,7 +28,7 @@ import android.tools.device.helpers.WindowUtils
import android.tools.device.traces.parsers.WindowManagerStateHelper import android.tools.device.traces.parsers.WindowManagerStateHelper
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -26,7 +26,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -26,7 +26,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -26,7 +26,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitScreenEntered import com.android.wm.shell.flicker.splitScreenEntered
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -24,7 +24,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@@ -23,7 +23,7 @@ import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import androidx.test.filters.RequiresDevice import androidx.test.filters.RequiresDevice
import com.android.wm.shell.flicker.splitscreen.SplitScreenBase 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.FixMethodOrder
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.junit.runners.MethodSorters import org.junit.runners.MethodSorters