Merge "1-Remove dependency between flicker app helpers and app-helpers-core" into main

This commit is contained in:
Nataniel Borges
2023-08-03 14:32:09 +00:00
committed by Android (Google) Code Review
34 changed files with 172 additions and 187 deletions

View File

@@ -66,7 +66,8 @@ class OpenAppInSizeCompatModeTest(flicker: LegacyFlickerTest) : BaseAppCompat(fl
*/
@Postsubmit
@Test
fun letterboxAppFocusedAtEnd() = flicker.assertEventLog { focusChanges(letterboxApp.`package`) }
fun letterboxAppFocusedAtEnd() =
flicker.assertEventLog { focusChanges(letterboxApp.packageName) }
@Postsubmit
@Test

View File

@@ -47,7 +47,7 @@ abstract class BaseBubbleScreen(flicker: LegacyFlickerTest) : BaseTest(flicker)
private val uid =
context.packageManager
.getApplicationInfo(testApp.`package`, PackageManager.ApplicationInfoFlags.of(0))
.getApplicationInfo(testApp.packageName, PackageManager.ApplicationInfoFlags.of(0))
.uid
@JvmOverloads
@@ -57,7 +57,7 @@ abstract class BaseBubbleScreen(flicker: LegacyFlickerTest) : BaseTest(flicker)
return {
setup {
notifyManager.setBubblesAllowed(
testApp.`package`,
testApp.packageName,
uid,
NotificationManager.BUBBLE_PREFERENCE_ALL
)
@@ -68,7 +68,7 @@ abstract class BaseBubbleScreen(flicker: LegacyFlickerTest) : BaseTest(flicker)
teardown {
notifyManager.setBubblesAllowed(
testApp.`package`,
testApp.packageName,
uid,
NotificationManager.BUBBLE_PREFERENCE_NONE
)

View File

@@ -117,7 +117,7 @@ abstract class EnterPipTransition(flicker: LegacyFlickerTest) : PipTransition(fl
@Presubmit
@Test
open fun focusChanges() {
flicker.assertEventLog { this.focusChanges(pipApp.`package`, "NexusLauncherActivity") }
flicker.assertEventLog { this.focusChanges(pipApp.packageName, "NexusLauncherActivity") }
}
companion object {

View File

@@ -26,7 +26,7 @@ import com.android.server.wm.flicker.helpers.PipAppHelper
/** Helper class for PIP app on AndroidTV */
open class PipAppHelperTv(instrumentation: Instrumentation) : PipAppHelper(instrumentation) {
private val appSelector = By.pkg(`package`).depth(0)
private val appSelector = By.pkg(packageName).depth(0)
val ui: UiObject2?
get() = uiDevice.findObject(appSelector)
@@ -46,7 +46,7 @@ open class PipAppHelperTv(instrumentation: Instrumentation) : PipAppHelper(instr
}
override fun clickObject(resId: String) {
val selector = By.res(`package`, resId)
val selector = By.res(packageName, resId)
focusOnObject(selector) || error("Could not focus on `$resId` object")
uiDevice.pressDPadCenter()
}
@@ -68,7 +68,7 @@ open class PipAppHelperTv(instrumentation: Instrumentation) : PipAppHelper(instr
}
fun waitUntilClosed(): Boolean {
val appSelector = By.pkg(`package`).depth(0)
val appSelector = By.pkg(packageName).depth(0)
return uiDevice.wait(Until.gone(appSelector), APP_CLOSE_WAIT_TIME_MS)
}

View File

@@ -61,7 +61,7 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) {
tapl.launchedAppState.taskbar
.openAllApps()
.getAppIcon(secondaryApp.appName)
.dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`)
.dragToSplitscreen(secondaryApp.packageName, primaryApp.packageName)
SplitScreenUtils.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
}

View File

@@ -63,7 +63,7 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) {
.getAppIcon(secondaryApp.appName)
.openDeepShortcutMenu()
.getMenuItem("Split Screen Secondary Activity")
.dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`)
.dragToSplitscreen(secondaryApp.packageName, primaryApp.packageName)
SplitScreenUtils.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
// TODO: Do we want this check in here? Add to the other tests?

View File

@@ -61,7 +61,7 @@ constructor(val rotation: Rotation = Rotation.ROTATION_0) {
open fun enterSplitScreenByDragFromTaskbar() {
tapl.launchedAppState.taskbar
.getAppIcon(secondaryApp.appName)
.dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`)
.dragToSplitscreen(secondaryApp.packageName, primaryApp.packageName)
SplitScreenUtils.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
}

View File

@@ -47,7 +47,7 @@ abstract class EnterSplitScreenByDragFromAllAppsBenchmark(override val flicker:
tapl.launchedAppState.taskbar
.openAllApps()
.getAppIcon(secondaryApp.appName)
.dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`)
.dragToSplitscreen(secondaryApp.packageName, primaryApp.packageName)
SplitScreenUtils.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
}
}

View File

@@ -53,7 +53,7 @@ abstract class EnterSplitScreenByDragFromShortcutBenchmark(
.getAppIcon(secondaryApp.appName)
.openDeepShortcutMenu()
.getMenuItem("Split Screen Secondary Activity")
.dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`)
.dragToSplitscreen(secondaryApp.packageName, primaryApp.packageName)
SplitScreenUtils.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
}
}

View File

@@ -46,7 +46,7 @@ abstract class EnterSplitScreenByDragFromTaskbarBenchmark(override val flicker:
transitions {
tapl.launchedAppState.taskbar
.getAppIcon(secondaryApp.appName)
.dragToSplitscreen(secondaryApp.`package`, primaryApp.`package`)
.dragToSplitscreen(secondaryApp.packageName, primaryApp.packageName)
SplitScreenUtils.waitForSplitComplete(wmHelper, primaryApp, secondaryApp)
}
}

View File

@@ -170,9 +170,7 @@ fun LegacyFlickerTest.statusBarLayerIsVisibleAtStartAndEnd() {
* the SF trace
*/
fun LegacyFlickerTest.navBarLayerPositionAtStart() {
assertLayersStart {
assertNavBarPosition(this, scenario.isGesturalNavigation)
}
assertLayersStart { assertNavBarPosition(this, scenario.isGesturalNavigation) }
}
/**
@@ -180,9 +178,7 @@ fun LegacyFlickerTest.navBarLayerPositionAtStart() {
* the SF trace
*/
fun LegacyFlickerTest.navBarLayerPositionAtEnd() {
assertLayersEnd {
assertNavBarPosition(this, scenario.isGesturalNavigation)
}
assertLayersEnd { assertNavBarPosition(this, scenario.isGesturalNavigation) }
}
private fun assertNavBarPosition(sfState: LayerTraceEntrySubject, isGesturalNavigation: Boolean) {
@@ -195,19 +191,23 @@ private fun assertNavBarPosition(sfState: LayerTraceEntrySubject, isGesturalNavi
when (navBarPosition) {
Position.TOP ->
navBarRegion.hasSameTopPosition(displayArea)
navBarRegion
.hasSameTopPosition(displayArea)
.hasSameLeftPosition(displayArea)
.hasSameRightPosition(displayArea)
Position.BOTTOM ->
navBarRegion.hasSameBottomPosition(displayArea)
navBarRegion
.hasSameBottomPosition(displayArea)
.hasSameLeftPosition(displayArea)
.hasSameRightPosition(displayArea)
Position.LEFT ->
navBarRegion.hasSameLeftPosition(displayArea)
navBarRegion
.hasSameLeftPosition(displayArea)
.hasSameTopPosition(displayArea)
.hasSameBottomPosition(displayArea)
Position.RIGHT ->
navBarRegion.hasSameRightPosition(displayArea)
navBarRegion
.hasSameRightPosition(displayArea)
.hasSameTopPosition(displayArea)
.hasSameBottomPosition(displayArea)
else -> error("Unknown position $navBarPosition")

View File

@@ -16,9 +16,9 @@
package com.android.server.wm.flicker.activityembedding
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.platform.test.annotations.Presubmit
import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.device.flicker.legacy.LegacyFlickerTest
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper
import org.junit.Before
@@ -38,8 +38,6 @@ abstract class ActivityEmbeddingTestBase(flicker: LegacyFlickerTest) : BaseTest(
@Test
open fun backgroundLayerNeverVisible() {
val backgroundColorLayer = ComponentNameMatcher("", "Animation Background")
flicker.assertLayers {
isInvisible(backgroundColorLayer)
}
flicker.assertLayers { isInvisible(backgroundColorLayer) }
}
}

View File

@@ -23,8 +23,8 @@ import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -35,9 +35,8 @@ import org.junit.runners.Parameterized
* Test changing split ratio at runtime on a horizona split.
*
* Setup: Launch A|B in horizontal split with B being the secondary activity, by default A and B
* windows are equal in size. B is on the top and A is on the bottom.
* Transitions:
* Change the split ratio to A:B=0.7:0.3, expect bounds change for both A and B.
* windows are equal in size. B is on the top and A is on the bottom. Transitions: Change the split
* ratio to A:B=0.7:0.3, expect bounds change for both A and B.
*
* To run this test: `atest FlickerTests:HorizontalSplitChangeRatioTest`
*/
@@ -46,7 +45,7 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class HorizontalSplitChangeRatioTest(flicker: LegacyFlickerTest) :
ActivityEmbeddingTestBase(flicker) {
ActivityEmbeddingTestBase(flicker) {
/** {@inheritDoc} */
override val transition: FlickerBuilder.() -> Unit = {
setup {
@@ -54,12 +53,9 @@ class HorizontalSplitChangeRatioTest(flicker: LegacyFlickerTest) :
testApp.launchViaIntent(wmHelper)
testApp.launchSecondaryActivityHorizontally(wmHelper)
startDisplayBounds =
wmHelper.currentState.layerState.physicalDisplayBounds
?: error("Display not found")
}
transitions {
testApp.changeSecondaryActivityRatio(wmHelper)
wmHelper.currentState.layerState.physicalDisplayBounds ?: error("Display not found")
}
transitions { testApp.changeSecondaryActivityRatio(wmHelper) }
teardown {
tapl.goHome()
testApp.exit(wmHelper)
@@ -94,7 +90,8 @@ class HorizontalSplitChangeRatioTest(flicker: LegacyFlickerTest) :
@Test
fun secondaryActivityWindowIsAlwaysVisible() {
flicker.assertWm {
isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT) }
isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
}
}
/** Assert the Secondary activity window is always visible. */
@@ -110,15 +107,17 @@ class HorizontalSplitChangeRatioTest(flicker: LegacyFlickerTest) :
fun secondaryActivityAdjustsHeightRuntime() {
flicker.assertLayersStart {
val topLayerRegion =
this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
val bottomLayerRegion =
this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
// Compare dimensions of two splits, given we're using default split attributes,
// both activities take up the same visible size on the display.
check { "height" }
.that(topLayerRegion.region.height).isEqual(bottomLayerRegion.region.height)
.that(topLayerRegion.region.height)
.isEqual(bottomLayerRegion.region.height)
check { "width" }
.that(topLayerRegion.region.width).isEqual(bottomLayerRegion.region.width)
.that(topLayerRegion.region.width)
.isEqual(bottomLayerRegion.region.width)
topLayerRegion.notOverlaps(bottomLayerRegion.region)
// Layers of two activities sum to be fullscreen size on display.
topLayerRegion.plus(bottomLayerRegion.region).coversExactly(startDisplayBounds)
@@ -126,20 +125,20 @@ class HorizontalSplitChangeRatioTest(flicker: LegacyFlickerTest) :
flicker.assertLayersEnd {
val topLayerRegion =
this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
this.visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
val bottomLayerRegion =
this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
this.visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
// Compare dimensions of two splits, given we're using default split attributes,
// both activities take up the same visible size on the display.
check { "height" }
.that(topLayerRegion.region.height).isLower(bottomLayerRegion.region.height)
.that(topLayerRegion.region.height)
.isLower(bottomLayerRegion.region.height)
check { "height" }
.that(
topLayerRegion.region.height / 0.3f -
bottomLayerRegion.region.height / 0.7f)
.isLower(0.1f)
.that(topLayerRegion.region.height / 0.3f - bottomLayerRegion.region.height / 0.7f)
.isLower(0.1f)
check { "width" }
.that(topLayerRegion.region.width).isEqual(bottomLayerRegion.region.width)
.that(topLayerRegion.region.width)
.isEqual(bottomLayerRegion.region.width)
topLayerRegion.notOverlaps(bottomLayerRegion.region)
// Layers of two activities sum to be fullscreen size on display.
topLayerRegion.plus(bottomLayerRegion.region).coversExactly(startDisplayBounds)
@@ -159,4 +158,4 @@ class HorizontalSplitChangeRatioTest(flicker: LegacyFlickerTest) :
@JvmStatic
fun getParams() = LegacyFlickerTestFactory.nonRotationTests()
}
}
}

View File

@@ -70,8 +70,7 @@ class MainActivityStartsSecondaryWithAlwaysExpandTest(flicker: LegacyFlickerTest
@Ignore("Not applicable to this CUJ.") override fun navBarWindowIsVisibleAtStartAndEnd() {}
@FlakyTest(bugId = 291575593)
override fun entireScreenCovered() {}
@FlakyTest(bugId = 291575593) override fun entireScreenCovered() {}
@Ignore("Not applicable to this CUJ.") override fun statusBarWindowIsAlwaysVisible() {}

View File

@@ -18,7 +18,6 @@ package com.android.server.wm.flicker.activityembedding.open
import android.platform.test.annotations.Presubmit
import android.tools.common.datatypes.Rect
import android.tools.common.traces.component.ComponentNameMatcher
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest

View File

@@ -104,8 +104,10 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
flicker.assertWm {
notContains(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
.then()
.isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT,
isOptional = true)
.isAppWindowInvisible(
ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT,
isOptional = true
)
.then()
.isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
}
@@ -133,8 +135,10 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
}
// Begin of transition.
.then()
.isAppWindowInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT,
isOptional = true)
.isAppWindowInvisible(
ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT,
isOptional = true
)
.then()
.invoke("mainAndSecondaryInSplit") {
val mainActivityRegion =
@@ -174,8 +178,10 @@ class OpenTrampolineActivityTest(flicker: LegacyFlickerTest) : ActivityEmbedding
.coversExactly(startDisplayBounds)
}
.then()
.isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT,
isOptional = true)
.isInvisible(
ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT,
isOptional = true
)
.then()
.isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
}

View File

@@ -35,92 +35,84 @@ import org.junit.runners.Parameterized
/**
* Test launching a secondary Activity into Picture-In-Picture mode.
*
* Setup: Start from a split A|B.
* Transition: B enters PIP, observe the window shrink to the bottom right corner on screen.
* Setup: Start from a split A|B. Transition: B enters PIP, observe the window shrink to the bottom
* right corner on screen.
*
* To run this test: `atest FlickerTests:SecondaryActivityEnterPipTest`
*
*/
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class SecondaryActivityEnterPipTest (flicker: LegacyFlickerTest) :
ActivityEmbeddingTestBase(flicker) {
class SecondaryActivityEnterPipTest(flicker: LegacyFlickerTest) :
ActivityEmbeddingTestBase(flicker) {
override val transition: FlickerBuilder.() -> Unit = {
setup {
tapl.setExpectedRotationCheckEnabled(false)
testApp.launchViaIntent(wmHelper)
testApp.launchSecondaryActivity(wmHelper)
startDisplayBounds =
wmHelper.currentState.layerState.physicalDisplayBounds
?: error("Can't get display bounds")
}
transitions {
testApp.secondaryActivityEnterPip(wmHelper)
wmHelper.currentState.layerState.physicalDisplayBounds
?: error("Can't get display bounds")
}
transitions { testApp.secondaryActivityEnterPip(wmHelper) }
teardown {
tapl.goHome()
testApp.exit(wmHelper)
}
}
/**
* Main and secondary activity start from a split each taking half of the screen.
*/
/** Main and secondary activity start from a split each taking half of the screen. */
@Presubmit
@Test
fun layersStartFromEqualSplit() {
flicker.assertLayersStart {
val leftLayerRegion =
visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
val leftLayerRegion = visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
val rightLayerRegion =
visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
// Compare dimensions of two splits, given we're using default split attributes,
// both activities take up the same visible size on the display.
check { "height" }
.that(leftLayerRegion.region.height).isEqual(rightLayerRegion.region.height)
.that(leftLayerRegion.region.height)
.isEqual(rightLayerRegion.region.height)
check { "width" }
.that(leftLayerRegion.region.width).isEqual(rightLayerRegion.region.width)
.that(leftLayerRegion.region.width)
.isEqual(rightLayerRegion.region.width)
leftLayerRegion.notOverlaps(rightLayerRegion.region)
leftLayerRegion.plus(rightLayerRegion.region).coversExactly(startDisplayBounds)
}
flicker.assertLayersEnd {
visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.coversExactly(startDisplayBounds)
.coversExactly(startDisplayBounds)
}
}
/**
* Main Activity is visible throughout the transition and becomes fullscreen.
*/
/** Main Activity is visible throughout the transition and becomes fullscreen. */
@Presubmit
@Test
fun mainActivityWindowBecomesFullScreen() {
flicker.assertWm { isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT) }
flicker.assertWmEnd {
visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.coversExactly(startDisplayBounds)
.coversExactly(startDisplayBounds)
}
}
/**
* Main Activity is visible throughout the transition and becomes fullscreen.
*/
/** Main Activity is visible throughout the transition and becomes fullscreen. */
@Presubmit
@Test
fun mainActivityLayerBecomesFullScreen() {
flicker.assertLayers {
isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.then()
.isVisible(TRANSITION_SNAPSHOT)
.isInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.then()
.isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.then()
.isVisible(TRANSITION_SNAPSHOT)
.isInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.then()
.isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
}
flicker.assertLayersEnd {
visibleRegion(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
.coversExactly(startDisplayBounds)
.coversExactly(startDisplayBounds)
}
}
@@ -136,18 +128,15 @@ class SecondaryActivityEnterPipTest (flicker: LegacyFlickerTest) :
}
flicker.assertWmEnd {
val pipWindowRegion =
visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
check{"height"}
.that(pipWindowRegion.region.height)
.isLower(startDisplayBounds.height / 2)
check{"width"}
.that(pipWindowRegion.region.width).isLower(startDisplayBounds.width)
visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
check { "height" }
.that(pipWindowRegion.region.height)
.isLower(startDisplayBounds.height / 2)
check { "width" }.that(pipWindowRegion.region.width).isLower(startDisplayBounds.width)
}
}
/**
* During the transition Secondary Activity shrinks to the bottom right corner.
*/
/** During the transition Secondary Activity shrinks to the bottom right corner. */
@Presubmit
@Test
fun secondaryLayerShrinks() {
@@ -162,13 +151,9 @@ class SecondaryActivityEnterPipTest (flicker: LegacyFlickerTest) :
}
}
flicker.assertLayersEnd {
val pipRegion = visibleRegion(
ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
check { "height" }
.that(pipRegion.region.height)
.isLower(startDisplayBounds.height / 2)
check { "width" }
.that(pipRegion.region.width).isLower(startDisplayBounds.width)
val pipRegion = visibleRegion(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
check { "height" }.that(pipRegion.region.height).isLower(startDisplayBounds.height / 2)
check { "width" }.that(pipRegion.region.width).isLower(startDisplayBounds.width)
}
}
@@ -185,4 +170,4 @@ class SecondaryActivityEnterPipTest (flicker: LegacyFlickerTest) :
@JvmStatic
fun getParams() = LegacyFlickerTestFactory.nonRotationTests()
}
}
}

View File

@@ -56,9 +56,7 @@ constructor(
launchSecondaryActivityFromButton(wmHelper, "launch_secondary_activity_rtl_button")
}
/**
* Clicks the button to launch the secondary activity in a horizontal split.
*/
/** Clicks the button to launch the secondary activity in a horizontal split. */
fun launchSecondaryActivityHorizontally(wmHelper: WindowManagerStateHelper) {
launchSecondaryActivityFromButton(wmHelper, "launch_secondary_activity_horizontally_button")
}
@@ -67,7 +65,7 @@ constructor(
fun launchThirdActivity(wmHelper: WindowManagerStateHelper) {
val launchButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "launch_third_activity_button")),
Until.findObject(By.res(packageName, "launch_third_activity_button")),
FIND_TIMEOUT
)
require(launchButton != null) { "Can't find launch third activity button on screen." }
@@ -87,7 +85,7 @@ constructor(
fun launchTrampolineActivity(wmHelper: WindowManagerStateHelper) {
val launchButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "launch_trampoline_button")),
Until.findObject(By.res(packageName, "launch_trampoline_button")),
FIND_TIMEOUT
)
require(launchButton != null) { "Can't find launch trampoline activity button on screen." }
@@ -105,53 +103,45 @@ constructor(
*/
fun finishSecondaryActivity(wmHelper: WindowManagerStateHelper) {
val finishButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "finish_secondary_activity_button")),
FIND_TIMEOUT
)
uiDevice.wait(
Until.findObject(By.res(packageName, "finish_secondary_activity_button")),
FIND_TIMEOUT
)
require(finishButton != null) { "Can't find finish secondary activity button on screen." }
finishButton.click()
wmHelper
.StateSyncBuilder()
.withActivityRemoved(SECONDARY_ACTIVITY_COMPONENT)
.waitForAndVerify()
}
.StateSyncBuilder()
.withActivityRemoved(SECONDARY_ACTIVITY_COMPONENT)
.waitForAndVerify()
}
/**
* Clicks the button to toggle the split ratio of secondary activity.
*/
/** Clicks the button to toggle the split ratio of secondary activity. */
fun changeSecondaryActivityRatio(wmHelper: WindowManagerStateHelper) {
val launchButton =
uiDevice.wait(
Until.findObject(
By.res(getPackage(),
"toggle_split_ratio_button")),
FIND_TIMEOUT
)
uiDevice.wait(
Until.findObject(By.res(packageName, "toggle_split_ratio_button")),
FIND_TIMEOUT
)
require(launchButton != null) {
"Can't find toggle ratio for secondary activity button on screen."
}
launchButton.click()
wmHelper
.StateSyncBuilder()
.withAppTransitionIdle()
.withTransitionSnapshotGone()
.waitForAndVerify()
.StateSyncBuilder()
.withAppTransitionIdle()
.withTransitionSnapshotGone()
.waitForAndVerify()
}
fun secondaryActivityEnterPip(wmHelper: WindowManagerStateHelper) {
val pipButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "secondary_enter_pip_button")),
FIND_TIMEOUT
)
uiDevice.wait(
Until.findObject(By.res(packageName, "secondary_enter_pip_button")),
FIND_TIMEOUT
)
require(pipButton != null) { "Can't find enter pip button on screen." }
pipButton.click()
wmHelper
.StateSyncBuilder()
.withAppTransitionIdle()
.withPipShown()
.waitForAndVerify()
wmHelper.StateSyncBuilder().withAppTransitionIdle().withPipShown().waitForAndVerify()
}
/**
@@ -161,7 +151,7 @@ constructor(
fun launchAlwaysExpandActivity(wmHelper: WindowManagerStateHelper) {
val launchButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "launch_always_expand_activity_button")),
Until.findObject(By.res(packageName, "launch_always_expand_activity_button")),
FIND_TIMEOUT
)
require(launchButton != null) {
@@ -171,8 +161,11 @@ constructor(
wmHelper
.StateSyncBuilder()
.withActivityState(ALWAYS_EXPAND_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
.withActivityState(MAIN_ACTIVITY_COMPONENT, PlatformConsts.STATE_PAUSED,
PlatformConsts.STATE_STOPPED)
.withActivityState(
MAIN_ACTIVITY_COMPONENT,
PlatformConsts.STATE_PAUSED,
PlatformConsts.STATE_STOPPED
)
.waitForAndVerify()
}
@@ -181,16 +174,16 @@ constructor(
buttonName: String
) {
val launchButton =
uiDevice.wait(Until.findObject(By.res(getPackage(), buttonName)), FIND_TIMEOUT)
uiDevice.wait(Until.findObject(By.res(packageName, buttonName)), FIND_TIMEOUT)
require(launchButton != null) {
"Can't find launch secondary activity button : " + buttonName + "on screen."
}
launchButton.click()
wmHelper
.StateSyncBuilder()
.withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
.withActivityState(MAIN_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
.waitForAndVerify()
.StateSyncBuilder()
.withActivityState(SECONDARY_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
.withActivityState(MAIN_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
.waitForAndVerify()
}
/**
@@ -200,7 +193,7 @@ constructor(
fun launchPlaceholderSplit(wmHelper: WindowManagerStateHelper) {
val launchButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "launch_placeholder_split_button")),
Until.findObject(By.res(packageName, "launch_placeholder_split_button")),
FIND_TIMEOUT
)
require(launchButton != null) { "Can't find launch placeholder split button on screen." }
@@ -219,7 +212,7 @@ constructor(
fun launchPlaceholderSplitRTL(wmHelper: WindowManagerStateHelper) {
val launchButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "launch_placeholder_split_rtl_button")),
Until.findObject(By.res(packageName, "launch_placeholder_split_rtl_button")),
FIND_TIMEOUT
)
require(launchButton != null) { "Can't find launch placeholder split button on screen." }

View File

@@ -41,7 +41,7 @@ constructor(
*/
fun swipeDown(): Boolean {
val gameView =
uiDevice.wait(Until.findObject(By.res(getPackage(), GAME_APP_VIEW_RES)), WAIT_TIME_MS)
uiDevice.wait(Until.findObject(By.res(packageName, GAME_APP_VIEW_RES)), WAIT_TIME_MS)
require(gameView != null) { "Mock game app view not found." }
val bound = gameView.getVisibleBounds()

View File

@@ -40,7 +40,7 @@ constructor(
*/
open fun openIME(wmHelper: WindowManagerStateHelper) {
val editText =
uiDevice.wait(Until.findObject(By.res(getPackage(), "plain_text_input")), FIND_TIMEOUT)
uiDevice.wait(Until.findObject(By.res(packageName, "plain_text_input")), FIND_TIMEOUT)
requireNotNull(editText) {
"Text field not found, this usually happens when the device " +
@@ -67,7 +67,7 @@ constructor(
open fun finishActivity(wmHelper: WindowManagerStateHelper) {
val finishButton =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "finish_activity_btn")),
Until.findObject(By.res(packageName, "finish_activity_btn")),
FIND_TIMEOUT
)
requireNotNull(finishButton) {

View File

@@ -71,7 +71,7 @@ constructor(
if (rotation.isRotated()) {
imePackageName
} else {
getPackage()
packageName
}
open(expectedPackage)
}
@@ -79,7 +79,7 @@ constructor(
fun startDialogThemedActivity(wmHelper: WindowManagerStateHelper) {
val button =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "start_dialog_themed_activity_btn")),
Until.findObject(By.res(packageName, "start_dialog_themed_activity_btn")),
FIND_TIMEOUT
)
@@ -132,7 +132,7 @@ constructor(
fun toggleFixPortraitOrientation(wmHelper: WindowManagerStateHelper) {
val button =
uiDevice.wait(
Until.findObject(By.res(getPackage(), "toggle_fixed_portrait_btn")),
Until.findObject(By.res(packageName, "toggle_fixed_portrait_btn")),
FIND_TIMEOUT
)
require(button != null) {
@@ -140,7 +140,7 @@ constructor(
"was left in an unknown state (e.g. Screen turned off)"
}
button.click()
mInstrumentation.waitForIdleSync()
instrumentation.waitForIdleSync()
// Ensure app relaunching transition finish and the IME has shown
waitIMEShown(wmHelper)
}

View File

@@ -38,7 +38,7 @@ constructor(
ActivityOptions.NonResizeablePortraitActivity.COMPONENT.toFlickerComponent()
) : StandardAppHelper(instr, launcherName, component) {
private val gestureHelper: GestureHelper = GestureHelper(mInstrumentation)
private val gestureHelper: GestureHelper = GestureHelper(instrumentation)
fun clickRestart(wmHelper: WindowManagerStateHelper) {
val restartButton =

View File

@@ -37,7 +37,7 @@ constructor(
fun openMail(rowIdx: Int) {
val rowSel =
By.res(getPackage(), "mail_row_item_text").textEndsWith(String.format("%04d", rowIdx))
By.res(packageName, "mail_row_item_text").textEndsWith(String.format("%04d", rowIdx))
var row: UiObject2? = null
for (i in 1..1000) {
row = uiDevice.wait(Until.findObject(rowSel), SHORT_WAIT_TIME_MS)
@@ -46,7 +46,7 @@ constructor(
}
require(row != null) { "" }
row.click()
uiDevice.wait(Until.gone(By.res(getPackage(), MAIL_LIST_RES_ID)), FIND_TIMEOUT)
uiDevice.wait(Until.gone(By.res(packageName, MAIL_LIST_RES_ID)), FIND_TIMEOUT)
}
fun scrollDown() {
@@ -55,7 +55,7 @@ constructor(
}
fun waitForMailList(): UiObject2 {
val sel = By.res(getPackage(), MAIL_LIST_RES_ID).scrollable(true)
val sel = By.res(packageName, MAIL_LIST_RES_ID).scrollable(true)
val ret = uiDevice.wait(Until.findObject(sel), FIND_TIMEOUT)
requireNotNull(ret) { "Unable to find $MAIL_LIST_RES_ID object" }
return ret

View File

@@ -36,7 +36,7 @@ constructor(
) : StandardAppHelper(instr, launcherName, component) {
fun openNewTask(device: UiDevice, wmHelper: WindowManagerStateHelper) {
val button =
device.wait(Until.findObject(By.res(getPackage(), "launch_new_task")), FIND_TIMEOUT)
device.wait(Until.findObject(By.res(packageName, "launch_new_task")), FIND_TIMEOUT)
requireNotNull(button) {
"Button not found, this usually happens when the device " +

View File

@@ -35,7 +35,7 @@ constructor(
) : StandardAppHelper(instr, launcherName, component) {
fun postNotification(wmHelper: WindowManagerStateHelper) {
val button =
uiDevice.wait(Until.findObject(By.res(getPackage(), "post_notification")), FIND_TIMEOUT)
uiDevice.wait(Until.findObject(By.res(packageName, "post_notification")), FIND_TIMEOUT)
requireNotNull(button) {
"Post notification button not found, this usually happens when the device " +

View File

@@ -46,12 +46,14 @@ open class PipAppHelper(instrumentation: Instrumentation) :
private val mediaController: MediaController?
get() =
mediaSessionManager.getActiveSessions(null).firstOrNull { it.packageName == `package` }
mediaSessionManager.getActiveSessions(null).firstOrNull {
it.packageName == packageName
}
private val gestureHelper: GestureHelper = GestureHelper(mInstrumentation)
private val gestureHelper: GestureHelper = GestureHelper(instrumentation)
open fun clickObject(resId: String) {
val selector = By.res(`package`, resId)
val selector = By.res(packageName, resId)
val obj = uiDevice.findObject(selector) ?: error("Could not find `$resId` object")
obj.click()
@@ -286,7 +288,7 @@ open class PipAppHelper(instrumentation: Instrumentation) :
fun checkWithCustomActionsCheckbox() =
uiDevice
.findObject(By.res(`package`, WITH_CUSTOM_ACTIONS_BUTTON_ID))
.findObject(By.res(packageName, WITH_CUSTOM_ACTIONS_BUTTON_ID))
?.takeIf { it.isCheckable }
?.apply { if (!isChecked) clickObject(WITH_CUSTOM_ACTIONS_BUTTON_ID) }
?: error("'With custom actions' checkbox not found")
@@ -302,7 +304,7 @@ open class PipAppHelper(instrumentation: Instrumentation) :
ReplaceWith("closePipWindow(wmHelper)")
)
open fun closePipWindow() {
closePipWindow(WindowManagerStateHelper(mInstrumentation))
closePipWindow(WindowManagerStateHelper(instrumentation))
}
/** Returns the pip window bounds. */
@@ -386,8 +388,10 @@ open class PipAppHelper(instrumentation: Instrumentation) :
Log.d(TAG, "window " + pipAppWindow)
if (pipAppWindow == null) return@add false
val pipRegion = pipAppWindow.frameRegion
Log.d(TAG, "region " + pipRegion +
" covers " + windowRect.coversMoreThan(pipRegion))
Log.d(
TAG,
"region " + pipRegion + " covers " + windowRect.coversMoreThan(pipRegion)
)
return@add windowRect.coversMoreThan(pipRegion)
}
.waitForAndVerify()

View File

@@ -40,7 +40,7 @@ constructor(
ActivityOptions.SimpleActivity.COMPONENT.toFlickerComponent()
fun openSecondActivity(device: UiDevice, wmHelper: WindowManagerStateHelper) {
val launchActivityButton = By.res(getPackage(), LAUNCH_SECOND_ACTIVITY)
val launchActivityButton = By.res(packageName, LAUNCH_SECOND_ACTIVITY)
val button = device.wait(Until.findObject(launchActivityButton), FIND_TIMEOUT)
requireNotNull(button) {

View File

@@ -70,8 +70,8 @@ class OpenAppFromIconColdTest(flicker: LegacyFlickerTest) : OpenAppFromLauncherT
tapl
.goHome()
.switchToAllApps()
.getAppIcon(testApp.launcherName)
.launch(testApp.`package`)
.getAppIcon(testApp.appName)
.launch(testApp.packageName)
}
teardown { testApp.exit(wmHelper) }
}

View File

@@ -30,7 +30,7 @@ abstract class OpenAppFromLauncherTransition(flicker: LegacyFlickerTest) :
@Presubmit
@Test
open fun focusChanges() {
flicker.assertEventLog { this.focusChanges("NexusLauncherActivity", testApp.`package`) }
flicker.assertEventLog { this.focusChanges("NexusLauncherActivity", testApp.packageName) }
}
/**

View File

@@ -46,7 +46,7 @@ abstract class OpenAppFromLockscreenTransition(flicker: LegacyFlickerTest) :
@Presubmit
@Test
open fun focusChanges() {
flicker.assertEventLog { this.focusChanges("", testApp.`package`) }
flicker.assertEventLog { this.focusChanges("", testApp.packageName) }
}
/**

View File

@@ -20,4 +20,4 @@ import android.tools.common.traces.component.ComponentNameMatcher
object Consts {
val IMAGE_WALLPAPER = ComponentNameMatcher("", "com.android.systemui.wallpapers.ImageWallpaper")
}
}

View File

@@ -67,7 +67,8 @@ open class OpenAppFromNotificationWarmTest(flicker: LegacyFlickerTest) :
wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify()
testApp.postNotification(wmHelper)
device.pressHome()
wmHelper.StateSyncBuilder()
wmHelper
.StateSyncBuilder()
.withHomeActivityVisible()
.withWindowSurfaceDisappeared(ComponentNameMatcher.NOTIFICATION_SHADE)
.waitForAndVerify()

View File

@@ -98,7 +98,7 @@ class ChangeAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(fli
@Presubmit
@Test
fun focusChanges() {
flicker.assertEventLog { this.focusChanges(testApp.`package`) }
flicker.assertEventLog { this.focusChanges(testApp.packageName) }
}
/**

View File

@@ -116,8 +116,8 @@ class SeamlessAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(f
flicker.assertWm {
this.invoke("isFullScreen") {
val appWindow =
it.windowState(testApp.`package`)
?: error("App window for package ${testApp.`package`} not found")
it.windowState(testApp.packageName)
?: error("App window for package ${testApp.packageName} not found")
val flags = appWindow.windowState.attributes.flags
appWindow
.check { "isFullScreen" }
@@ -134,8 +134,8 @@ class SeamlessAppRotationTest(flicker: LegacyFlickerTest) : RotationTransition(f
flicker.assertWm {
this.invoke("isRotationSeamless") {
val appWindow =
it.windowState(testApp.`package`)
?: error("App window for package ${testApp.`package`} not found")
it.windowState(testApp.packageName)
?: error("App window for package ${testApp.packageName} not found")
val rotationAnimation = appWindow.windowState.attributes.rotationAnimation
appWindow
.check { "isRotationSeamless" }