Merge "Refactor the buildTransitions into overridable functions" into udc-dev

This commit is contained in:
Mateusz Cicheński
2023-06-01 17:59:03 +00:00
committed by Android (Google) Code Review
20 changed files with 245 additions and 250 deletions

View File

@@ -16,7 +16,6 @@
package com.android.wm.shell.flicker.pip package com.android.wm.shell.flicker.pip
import android.platform.test.annotations.FlakyTest
import android.platform.test.annotations.Presubmit import android.platform.test.annotations.Presubmit
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
@@ -55,20 +54,24 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
class AutoEnterPipOnGoToHomeTest(flicker: FlickerTest) : EnterPipViaAppUiButtonTest(flicker) { class AutoEnterPipOnGoToHomeTest(flicker: FlickerTest) : EnterPipViaAppUiButtonTest(flicker) {
/** Defines the transition used to run the test */ override val thisTransition: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit transitions { tapl.goHome() }
get() = { }
setup {
pipApp.launchViaIntent(wmHelper) override val defaultEnterPip: FlickerBuilder.() -> Unit = {
pipApp.enableAutoEnterForPipActivity() setup {
} pipApp.launchViaIntent(wmHelper)
teardown { pipApp.enableAutoEnterForPipActivity()
// close gracefully so that onActivityUnpinned() can be called before force exit
pipApp.closePipWindow(wmHelper)
pipApp.exit(wmHelper)
}
transitions { tapl.goHome() }
} }
}
override val defaultTeardown: FlickerBuilder.() -> Unit = {
teardown {
// close gracefully so that onActivityUnpinned() can be called before force exit
pipApp.closePipWindow(wmHelper)
pipApp.exit(wmHelper)
}
}
@Presubmit @Presubmit
@Test @Test

View File

@@ -54,40 +54,38 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class ClosePipBySwipingDownTest(flicker: FlickerTest) : ClosePipTransition(flicker) { open class ClosePipBySwipingDownTest(flicker: FlickerTest) : ClosePipTransition(flicker) {
override val transition: FlickerBuilder.() -> Unit override val thisTransition: FlickerBuilder.() -> Unit = {
get() = { transitions {
super.transition(this) val pipRegion = wmHelper.getWindowRegion(pipApp).bounds
transitions { val pipCenterX = pipRegion.centerX()
val pipRegion = wmHelper.getWindowRegion(pipApp).bounds val pipCenterY = pipRegion.centerY()
val pipCenterX = pipRegion.centerX() val displayCenterX = device.displayWidth / 2
val pipCenterY = pipRegion.centerY() val barComponent =
val displayCenterX = device.displayWidth / 2 if (flicker.scenario.isTablet) {
val barComponent = ComponentNameMatcher.TASK_BAR
if (flicker.scenario.isTablet) { } else {
ComponentNameMatcher.TASK_BAR ComponentNameMatcher.NAV_BAR
} else { }
ComponentNameMatcher.NAV_BAR val barLayerHeight =
} wmHelper.currentState.layerState
val barLayerHeight = .getLayerWithBuffer(barComponent)
wmHelper.currentState.layerState ?.visibleRegion
.getLayerWithBuffer(barComponent) ?.height
?.visibleRegion ?: error("Couldn't find Nav or Task bar layer")
?.height // The dismiss button doesn't appear at the complete bottom of the screen,
?: error("Couldn't find Nav or Task bar layer") // it appears above the hot seat but `hotseatBarSize` is not available outside
// The dismiss button doesn't appear at the complete bottom of the screen, // the platform
// it appears above the hot seat but `hotseatBarSize` is not available outside val displayY = (device.displayHeight * 0.9).toInt() - barLayerHeight
// the platform device.swipe(pipCenterX, pipCenterY, displayCenterX, displayY, 50)
val displayY = (device.displayHeight * 0.9).toInt() - barLayerHeight // Wait until the other app is no longer visible
device.swipe(pipCenterX, pipCenterY, displayCenterX, displayY, 50) wmHelper
// Wait until the other app is no longer visible .StateSyncBuilder()
wmHelper .withPipGone()
.StateSyncBuilder() .withWindowSurfaceDisappeared(pipApp)
.withPipGone() .withAppTransitionIdle()
.withWindowSurfaceDisappeared(pipApp) .waitForAndVerify()
.withAppTransitionIdle()
.waitForAndVerify()
}
} }
}
/** Checks that the focus doesn't change between windows during the transition */ /** Checks that the focus doesn't change between windows during the transition */
@Presubmit @Presubmit

View File

@@ -28,11 +28,10 @@ import org.junit.runners.Parameterized
/** Base class for exiting pip (closing pip window) without returning to the app */ /** Base class for exiting pip (closing pip window) without returning to the app */
abstract class ClosePipTransition(flicker: FlickerTest) : PipTransition(flicker) { abstract class ClosePipTransition(flicker: FlickerTest) : PipTransition(flicker) {
override val transition: FlickerBuilder.() -> Unit override val thisTransition: FlickerBuilder.() -> Unit = {
get() = buildTransition { setup { this.setRotation(flicker.scenario.startRotation) }
setup { this.setRotation(flicker.scenario.startRotation) } teardown { this.setRotation(Rotation.ROTATION_0) }
teardown { this.setRotation(Rotation.ROTATION_0) } }
}
/** /**
* Checks that [pipApp] window is pinned and visible at the start and then becomes unpinned and * Checks that [pipApp] window is pinned and visible at the start and then becomes unpinned and

View File

@@ -54,12 +54,9 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class ClosePipWithDismissButtonTest(flicker: FlickerTest) : ClosePipTransition(flicker) { open class ClosePipWithDismissButtonTest(flicker: FlickerTest) : ClosePipTransition(flicker) {
override val thisTransition: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit transitions { pipApp.closePipWindow(wmHelper) }
get() = { }
super.transition(this)
transitions { pipApp.closePipWindow(wmHelper) }
}
/** /**
* Checks that the focus changes between the pip menu window and the launcher when clicking the * Checks that the focus changes between the pip menu window and the launcher when clicking the

View File

@@ -45,20 +45,24 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class EnterPipOnUserLeaveHintTest(flicker: FlickerTest) : EnterPipTransition(flicker) { open class EnterPipOnUserLeaveHintTest(flicker: FlickerTest) : EnterPipTransition(flicker) {
/** Defines the transition used to run the test */ override val thisTransition: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit transitions { tapl.goHome() }
get() = { }
setup {
pipApp.launchViaIntent(wmHelper) override val defaultEnterPip: FlickerBuilder.() -> Unit = {
pipApp.enableEnterPipOnUserLeaveHint() setup {
} pipApp.launchViaIntent(wmHelper)
teardown { pipApp.enableEnterPipOnUserLeaveHint()
// close gracefully so that onActivityUnpinned() can be called before force exit
pipApp.closePipWindow(wmHelper)
pipApp.exit(wmHelper)
}
transitions { tapl.goHome() }
} }
}
override val defaultTeardown: FlickerBuilder.() -> Unit = {
teardown {
// close gracefully so that onActivityUnpinned() can be called before force exit
pipApp.closePipWindow(wmHelper)
pipApp.exit(wmHelper)
}
}
@Presubmit @Presubmit
@Test @Test

View File

@@ -73,39 +73,39 @@ open class EnterPipToOtherOrientation(flicker: FlickerTest) : PipTransition(flic
private val startingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_90) private val startingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_90)
private val endingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0) private val endingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0)
/** Defines the transition used to run the test */ override val thisTransition: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit teardown {
get() = { testApp.exit(wmHelper)
setup { }
// Launch a portrait only app on the fullscreen stack transitions {
testApp.launchViaIntent( // Enter PiP, and assert that the PiP is within bounds now that the device is back
// in portrait
broadcastActionTrigger.doAction(ACTION_ENTER_PIP)
// during rotation the status bar becomes invisible and reappears at the end
wmHelper
.StateSyncBuilder()
.withPipShown()
.withNavOrTaskBarVisible()
.withStatusBarVisible()
.waitForAndVerify()
}
}
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
setup {
// Launch a portrait only app on the fullscreen stack
testApp.launchViaIntent(
wmHelper, wmHelper,
stringExtras = mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_PORTRAIT.toString()) stringExtras = mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_PORTRAIT.toString())
) )
// Launch the PiP activity fixed as landscape // Launch the PiP activity fixed as landscape, but don't enter PiP
pipApp.launchViaIntent( pipApp.launchViaIntent(
wmHelper, wmHelper,
stringExtras = stringExtras =
mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString()) mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString())
) )
}
teardown {
pipApp.exit(wmHelper)
testApp.exit(wmHelper)
}
transitions {
// Enter PiP, and assert that the PiP is within bounds now that the device is back
// in portrait
broadcastActionTrigger.doAction(ACTION_ENTER_PIP)
// during rotation the status bar becomes invisible and reappears at the end
wmHelper
.StateSyncBuilder()
.withPipShown()
.withNavOrTaskBarVisible()
.withStatusBarVisible()
.waitForAndVerify()
}
} }
}
/** /**
* This test is not compatible with Tablets. When using [Activity.setRequestedOrientation] to * This test is not compatible with Tablets. When using [Activity.setRequestedOrientation] to

View File

@@ -26,12 +26,11 @@ import org.junit.Test
import org.junit.runners.Parameterized import org.junit.runners.Parameterized
abstract class EnterPipTransition(flicker: FlickerTest) : PipTransition(flicker) { abstract class EnterPipTransition(flicker: FlickerTest) : PipTransition(flicker) {
/** {@inheritDoc} */ override val defaultEnterPip: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit setup {
get() = { pipApp.launchViaIntent(wmHelper)
setup { pipApp.launchViaIntent(wmHelper) }
teardown { pipApp.exit(wmHelper) }
} }
}
/** Checks [pipApp] window remains visible throughout the animation */ /** Checks [pipApp] window remains visible throughout the animation */
@Presubmit @Presubmit

View File

@@ -51,11 +51,7 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class EnterPipViaAppUiButtonTest(flicker: FlickerTest) : EnterPipTransition(flicker) { open class EnterPipViaAppUiButtonTest(flicker: FlickerTest) : EnterPipTransition(flicker) {
override val thisTransition: FlickerBuilder.() -> Unit = {
/** {@inheritDoc} */ transitions { pipApp.clickEnterPipButton(wmHelper) }
override val transition: FlickerBuilder.() -> Unit }
get() = {
super.transition(this)
transitions { pipApp.clickEnterPipButton(wmHelper) }
}
} }

View File

@@ -53,19 +53,16 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class ExitPipToAppViaExpandButtonTest(flicker: FlickerTest) : ExitPipToAppTransition(flicker) { open class ExitPipToAppViaExpandButtonTest(flicker: FlickerTest) : ExitPipToAppTransition(flicker) {
override val thisTransition: FlickerBuilder.() -> Unit = {
/** Defines the transition used to run the test */ setup {
override val transition: FlickerBuilder.() -> Unit // launch an app behind the pip one
get() = buildTransition { testApp.launchViaIntent(wmHelper)
setup {
// launch an app behind the pip one
testApp.launchViaIntent(wmHelper)
}
transitions {
// This will bring PipApp to fullscreen
pipApp.expandPipWindowToApp(wmHelper)
// Wait until the other app is no longer visible
wmHelper.StateSyncBuilder().withWindowSurfaceDisappeared(testApp).waitForAndVerify()
}
} }
transitions {
// This will bring PipApp to fullscreen
pipApp.expandPipWindowToApp(wmHelper)
// Wait until the other app is no longer visible
wmHelper.StateSyncBuilder().withWindowSurfaceDisappeared(testApp).waitForAndVerify()
}
}
} }

View File

@@ -52,19 +52,16 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class ExitPipToAppViaIntentTest(flicker: FlickerTest) : ExitPipToAppTransition(flicker) { open class ExitPipToAppViaIntentTest(flicker: FlickerTest) : ExitPipToAppTransition(flicker) {
override val thisTransition: FlickerBuilder.() -> Unit = {
/** Defines the transition used to run the test */ setup {
override val transition: FlickerBuilder.() -> Unit // launch an app behind the pip one
get() = buildTransition { testApp.launchViaIntent(wmHelper)
setup {
// launch an app behind the pip one
testApp.launchViaIntent(wmHelper)
}
transitions {
// This will bring PipApp to fullscreen
pipApp.exitPipToFullScreenViaIntent(wmHelper)
// Wait until the other app is no longer visible
wmHelper.StateSyncBuilder().withWindowSurfaceDisappeared(testApp).waitForAndVerify()
}
} }
transitions {
// This will bring PipApp to fullscreen
pipApp.exitPipToFullScreenViaIntent(wmHelper)
// Wait until the other app is no longer visible
wmHelper.StateSyncBuilder().withWindowSurfaceDisappeared(testApp).waitForAndVerify()
}
}
} }

View File

@@ -56,8 +56,9 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class ExpandPipOnDoubleClickTest(flicker: FlickerTest) : PipTransition(flicker) { open class ExpandPipOnDoubleClickTest(flicker: FlickerTest) : PipTransition(flicker) {
override val transition: FlickerBuilder.() -> Unit override val thisTransition: FlickerBuilder.() -> Unit = {
get() = buildTransition { transitions { pipApp.doubleClickPipWindow(wmHelper) } } transitions { pipApp.doubleClickPipWindow(wmHelper) }
}
/** /**
* Checks that the pip app window remains inside the display bounds throughout the whole * Checks that the pip app window remains inside the display bounds throughout the whole

View File

@@ -35,8 +35,9 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class ExpandPipOnPinchOpenTest(flicker: FlickerTest) : PipTransition(flicker) { open class ExpandPipOnPinchOpenTest(flicker: FlickerTest) : PipTransition(flicker) {
override val transition: FlickerBuilder.() -> Unit override val thisTransition: FlickerBuilder.() -> Unit = {
get() = buildTransition { transitions { pipApp.pinchOpenPipWindow(wmHelper, 0.25f, 30) } } transitions { pipApp.pinchOpenPipWindow(wmHelper, 0.25f, 30) }
}
/** Checks that the visible region area of [pipApp] always increases during the animation. */ /** Checks that the visible region area of [pipApp] always increases during the animation. */
@Presubmit @Presubmit

View File

@@ -56,15 +56,10 @@ import org.junit.runners.Parameterized
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class) @Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
class MovePipDownOnShelfHeightChange(flicker: FlickerTest) : MovePipShelfHeightTransition(flicker) { class MovePipDownOnShelfHeightChange(flicker: FlickerTest) : MovePipShelfHeightTransition(flicker) {
/** Defines the transition used to run the test */ override val thisTransition: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit teardown { testApp.exit(wmHelper) }
get() = buildTransition { transitions { testApp.launchViaIntent(wmHelper) }
teardown { }
tapl.pressHome()
testApp.exit(wmHelper)
}
transitions { testApp.launchViaIntent(wmHelper) }
}
/** Checks that the visible region of [pipApp] window always moves down during the animation. */ /** Checks that the visible region of [pipApp] window always moves down during the animation. */
@Presubmit @Test fun pipWindowMovesDown() = pipWindowMoves(Direction.DOWN) @Presubmit @Test fun pipWindowMovesDown() = pipWindowMoves(Direction.DOWN)

View File

@@ -41,23 +41,21 @@ import org.junit.runners.Parameterized
open class MovePipOnImeVisibilityChangeTest(flicker: FlickerTest) : PipTransition(flicker) { open class MovePipOnImeVisibilityChangeTest(flicker: FlickerTest) : PipTransition(flicker) {
private val imeApp = ImeAppHelper(instrumentation) private val imeApp = ImeAppHelper(instrumentation)
/** {@inheritDoc} */ override val thisTransition: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit setup {
get() = buildTransition { imeApp.launchViaIntent(wmHelper)
setup { setRotation(flicker.scenario.startRotation)
imeApp.launchViaIntent(wmHelper)
setRotation(flicker.scenario.startRotation)
}
teardown { imeApp.exit(wmHelper) }
transitions {
// open the soft keyboard
imeApp.openIME(wmHelper)
createTag(TAG_IME_VISIBLE)
// then close it again
imeApp.closeIME(wmHelper)
}
} }
teardown { imeApp.exit(wmHelper) }
transitions {
// open the soft keyboard
imeApp.openIME(wmHelper)
createTag(TAG_IME_VISIBLE)
// then close it again
imeApp.closeIME(wmHelper)
}
}
/** Ensure the pip window remains visible throughout any keyboard interactions */ /** Ensure the pip window remains visible throughout any keyboard interactions */
@Presubmit @Presubmit

View File

@@ -57,14 +57,12 @@ import org.junit.runners.Parameterized
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
open class MovePipUpOnShelfHeightChangeTest(flicker: FlickerTest) : open class MovePipUpOnShelfHeightChangeTest(flicker: FlickerTest) :
MovePipShelfHeightTransition(flicker) { MovePipShelfHeightTransition(flicker) {
/** Defines the transition used to run the test */ override val thisTransition: FlickerBuilder.() -> Unit =
override val transition: FlickerBuilder.() -> Unit {
get() = setup { testApp.launchViaIntent(wmHelper) }
buildTransition() { transitions { tapl.pressHome() }
setup { testApp.launchViaIntent(wmHelper) } teardown { testApp.exit(wmHelper) }
transitions { tapl.pressHome() } }
teardown { testApp.exit(wmHelper) }
}
/** Checks that the visible region of [pipApp] window always moves up during the animation. */ /** Checks that the visible region of [pipApp] window always moves up during the animation. */
@Presubmit @Test fun pipWindowMovesUp() = pipWindowMoves(Direction.UP) @Presubmit @Test fun pipWindowMovesUp() = pipWindowMoves(Direction.UP)

View File

@@ -22,7 +22,6 @@ 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.FlickerTest import android.tools.device.flicker.legacy.FlickerTest
import android.tools.device.flicker.legacy.FlickerTestFactory import android.tools.device.flicker.legacy.FlickerTestFactory
import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule
import com.android.server.wm.flicker.testapp.ActivityOptions import com.android.server.wm.flicker.testapp.ActivityOptions
import org.junit.FixMethodOrder import org.junit.FixMethodOrder
import org.junit.Test import org.junit.Test
@@ -37,28 +36,31 @@ import org.junit.runners.Parameterized
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
class PipDragTest(flicker: FlickerTest) : PipTransition(flicker) { class PipDragTest(flicker: FlickerTest) : PipTransition(flicker) {
private var isDraggedLeft: Boolean = true private var isDraggedLeft: Boolean = true
override val transition: FlickerBuilder.() -> Unit
get() = {
val stringExtras = mapOf(ActivityOptions.Pip.EXTRA_ENTER_PIP to "true")
setup { override val thisTransition: FlickerBuilder.() -> Unit = {
tapl.setEnableRotation(true) transitions { pipApp.dragPipWindowAwayFromEdgeWithoutRelease(wmHelper, 50) }
// Launch the PIP activity and wait for it to enter PiP mode }
RemoveAllTasksButHomeRule.removeAllTasksButHome()
pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras)
// determine the direction of dragging to test for override val defaultEnterPip: FlickerBuilder.() -> Unit = {
isDraggedLeft = pipApp.isCloserToRightEdge(wmHelper) val stringExtras = mapOf(ActivityOptions.Pip.EXTRA_ENTER_PIP to "true")
} setup {
teardown { tapl.setEnableRotation(true)
// release the primary pointer after dragging without release pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras)
pipApp.releasePipAfterDragging()
pipApp.exit(wmHelper) // determine the direction of dragging to test for
tapl.setEnableRotation(false) isDraggedLeft = pipApp.isCloserToRightEdge(wmHelper)
}
transitions { pipApp.dragPipWindowAwayFromEdgeWithoutRelease(wmHelper, 50) }
} }
}
override val defaultTeardown: FlickerBuilder.() -> Unit = {
teardown {
// release the primary pointer after dragging without release
pipApp.releasePipAfterDragging()
pipApp.exit(wmHelper)
tapl.setEnableRotation(false)
}
}
@Postsubmit @Postsubmit
@Test @Test

View File

@@ -37,8 +37,9 @@ import org.junit.runners.Parameterized
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@FlakyTest(bugId = 270677470) @FlakyTest(bugId = 270677470)
class PipPinchInTest(flicker: FlickerTest) : PipTransition(flicker) { class PipPinchInTest(flicker: FlickerTest) : PipTransition(flicker) {
override val transition: FlickerBuilder.() -> Unit override val thisTransition: FlickerBuilder.() -> Unit = {
get() = buildTransition { transitions { pipApp.pinchInPipWindow(wmHelper, 0.4f, 30) } } transitions { pipApp.pinchInPipWindow(wmHelper, 0.4f, 30) }
}
/** Checks that the visible region area of [pipApp] always decreases during the animation. */ /** Checks that the visible region area of [pipApp] always decreases during the animation. */
@Postsubmit @Postsubmit

View File

@@ -56,27 +56,37 @@ abstract class PipTransition(flicker: FlickerTest) : BaseTest(flicker) {
} }
} }
/** /** Defines the transition used to run the test */
* Gets a configuration that handles basic setup and teardown of pip tests and that launches the protected open val thisTransition: FlickerBuilder.() -> Unit = {}
* Pip app for test
*
* @param stringExtras Arguments to pass to the PIP launch intent
* @param extraSpec Additional segment of flicker specification
*/
@JvmOverloads
protected open fun buildTransition(
stringExtras: Map<String, String> = mapOf(ActivityOptions.Pip.EXTRA_ENTER_PIP to "true"),
extraSpec: FlickerBuilder.() -> Unit = {}
): FlickerBuilder.() -> Unit {
return {
setup {
setRotation(Rotation.ROTATION_0)
removeAllTasksButHome()
pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras)
}
teardown { pipApp.exit(wmHelper) }
extraSpec(this) override val transition: FlickerBuilder.() -> Unit
get() = {
defaultSetup(this)
defaultEnterPip(this)
thisTransition(this)
defaultTeardown(this)
}
/** Defines the default setup steps required by the test */
protected open val defaultSetup: FlickerBuilder.() -> Unit = {
setup {
setRotation(Rotation.ROTATION_0)
removeAllTasksButHome()
}
}
/** Defines the default method of entering PiP */
protected open val defaultEnterPip: FlickerBuilder.() -> Unit = {
setup {
pipApp.launchViaIntentAndWaitForPip(wmHelper,
stringExtras = mapOf(ActivityOptions.Pip.EXTRA_ENTER_PIP to "true"))
}
}
/** Defines the default teardown required to clean up after the test */
protected open val defaultTeardown: FlickerBuilder.() -> Unit = {
teardown {
pipApp.exit(wmHelper)
} }
} }

View File

@@ -50,41 +50,41 @@ open class SetRequestedOrientationWhilePinned(flicker: FlickerTest) : PipTransit
private val startingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0) private val startingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0)
private val endingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_90) private val endingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_90)
/** {@inheritDoc} */ override val thisTransition: FlickerBuilder.() -> Unit = {
override val transition: FlickerBuilder.() -> Unit transitions {
get() = { // Launch the activity back into fullscreen and ensure that it is now in landscape
setup { pipApp.launchViaIntent(wmHelper)
// Launch the PiP activity fixed as landscape. // System bar may fade out during fixed rotation.
pipApp.launchViaIntent( wmHelper
.StateSyncBuilder()
.withFullScreenApp(pipApp)
.withRotation(Rotation.ROTATION_90)
.withNavOrTaskBarVisible()
.withStatusBarVisible()
.waitForAndVerify()
}
}
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
setup {
// Launch the PiP activity fixed as landscape.
pipApp.launchViaIntent(
wmHelper, wmHelper,
stringExtras = stringExtras =
mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString()) mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString())
) )
// Enter PiP. // Enter PiP.
broadcastActionTrigger.doAction(ActivityOptions.Pip.ACTION_ENTER_PIP) broadcastActionTrigger.doAction(ActivityOptions.Pip.ACTION_ENTER_PIP)
// System bar may fade out during fixed rotation. // System bar may fade out during fixed rotation.
wmHelper wmHelper
.StateSyncBuilder() .StateSyncBuilder()
.withPipShown() .withPipShown()
.withRotation(Rotation.ROTATION_0) .withRotation(Rotation.ROTATION_0)
.withNavOrTaskBarVisible() .withNavOrTaskBarVisible()
.withStatusBarVisible() .withStatusBarVisible()
.waitForAndVerify() .waitForAndVerify()
}
teardown { pipApp.exit(wmHelper) }
transitions {
// Launch the activity back into fullscreen and ensure that it is now in landscape
pipApp.launchViaIntent(wmHelper)
// System bar may fade out during fixed rotation.
wmHelper
.StateSyncBuilder()
.withFullScreenApp(pipApp)
.withRotation(Rotation.ROTATION_90)
.withNavOrTaskBarVisible()
.withStatusBarVisible()
.waitForAndVerify()
}
} }
}
/** /**
* This test is not compatible with Tablets. When using [Activity.setRequestedOrientation] to * This test is not compatible with Tablets. When using [Activity.setRequestedOrientation] to

View File

@@ -63,14 +63,13 @@ open class ShowPipAndRotateDisplay(flicker: FlickerTest) : PipTransition(flicker
private val screenBoundsStart = WindowUtils.getDisplayBounds(flicker.scenario.startRotation) private val screenBoundsStart = WindowUtils.getDisplayBounds(flicker.scenario.startRotation)
private val screenBoundsEnd = WindowUtils.getDisplayBounds(flicker.scenario.endRotation) private val screenBoundsEnd = WindowUtils.getDisplayBounds(flicker.scenario.endRotation)
override val transition: FlickerBuilder.() -> Unit override val thisTransition: FlickerBuilder.() -> Unit = {
get() = buildTransition { setup {
setup { testApp.launchViaIntent(wmHelper)
testApp.launchViaIntent(wmHelper) setRotation(flicker.scenario.startRotation)
setRotation(flicker.scenario.startRotation)
}
transitions { setRotation(flicker.scenario.endRotation) }
} }
transitions { setRotation(flicker.scenario.endRotation) }
}
/** Checks that [testApp] layer is within [screenBoundsStart] at the start of the transition */ /** Checks that [testApp] layer is within [screenBoundsStart] at the start of the transition */
@Presubmit @Presubmit