Merge "Refactor the buildTransitions into overridable functions" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cf2e76555e
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.wm.shell.flicker.pip
|
||||
|
||||
import android.platform.test.annotations.FlakyTest
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
|
||||
import android.tools.device.flicker.legacy.FlickerBuilder
|
||||
@@ -55,20 +54,24 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
class AutoEnterPipOnGoToHomeTest(flicker: FlickerTest) : EnterPipViaAppUiButtonTest(flicker) {
|
||||
/** Defines the transition used to run the test */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
setup {
|
||||
pipApp.launchViaIntent(wmHelper)
|
||||
pipApp.enableAutoEnterForPipActivity()
|
||||
}
|
||||
teardown {
|
||||
// close gracefully so that onActivityUnpinned() can be called before force exit
|
||||
pipApp.closePipWindow(wmHelper)
|
||||
pipApp.exit(wmHelper)
|
||||
}
|
||||
transitions { tapl.goHome() }
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { tapl.goHome() }
|
||||
}
|
||||
|
||||
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
|
||||
setup {
|
||||
pipApp.launchViaIntent(wmHelper)
|
||||
pipApp.enableAutoEnterForPipActivity()
|
||||
}
|
||||
}
|
||||
|
||||
override val defaultTeardown: FlickerBuilder.() -> Unit = {
|
||||
teardown {
|
||||
// close gracefully so that onActivityUnpinned() can be called before force exit
|
||||
pipApp.closePipWindow(wmHelper)
|
||||
pipApp.exit(wmHelper)
|
||||
}
|
||||
}
|
||||
|
||||
@Presubmit
|
||||
@Test
|
||||
|
||||
@@ -54,40 +54,38 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class ClosePipBySwipingDownTest(flicker: FlickerTest) : ClosePipTransition(flicker) {
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
super.transition(this)
|
||||
transitions {
|
||||
val pipRegion = wmHelper.getWindowRegion(pipApp).bounds
|
||||
val pipCenterX = pipRegion.centerX()
|
||||
val pipCenterY = pipRegion.centerY()
|
||||
val displayCenterX = device.displayWidth / 2
|
||||
val barComponent =
|
||||
if (flicker.scenario.isTablet) {
|
||||
ComponentNameMatcher.TASK_BAR
|
||||
} else {
|
||||
ComponentNameMatcher.NAV_BAR
|
||||
}
|
||||
val barLayerHeight =
|
||||
wmHelper.currentState.layerState
|
||||
.getLayerWithBuffer(barComponent)
|
||||
?.visibleRegion
|
||||
?.height
|
||||
?: error("Couldn't find Nav or Task bar layer")
|
||||
// The dismiss button doesn't appear at the complete bottom of the screen,
|
||||
// it appears above the hot seat but `hotseatBarSize` is not available outside
|
||||
// the platform
|
||||
val displayY = (device.displayHeight * 0.9).toInt() - barLayerHeight
|
||||
device.swipe(pipCenterX, pipCenterY, displayCenterX, displayY, 50)
|
||||
// Wait until the other app is no longer visible
|
||||
wmHelper
|
||||
.StateSyncBuilder()
|
||||
.withPipGone()
|
||||
.withWindowSurfaceDisappeared(pipApp)
|
||||
.withAppTransitionIdle()
|
||||
.waitForAndVerify()
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions {
|
||||
val pipRegion = wmHelper.getWindowRegion(pipApp).bounds
|
||||
val pipCenterX = pipRegion.centerX()
|
||||
val pipCenterY = pipRegion.centerY()
|
||||
val displayCenterX = device.displayWidth / 2
|
||||
val barComponent =
|
||||
if (flicker.scenario.isTablet) {
|
||||
ComponentNameMatcher.TASK_BAR
|
||||
} else {
|
||||
ComponentNameMatcher.NAV_BAR
|
||||
}
|
||||
val barLayerHeight =
|
||||
wmHelper.currentState.layerState
|
||||
.getLayerWithBuffer(barComponent)
|
||||
?.visibleRegion
|
||||
?.height
|
||||
?: error("Couldn't find Nav or Task bar layer")
|
||||
// The dismiss button doesn't appear at the complete bottom of the screen,
|
||||
// it appears above the hot seat but `hotseatBarSize` is not available outside
|
||||
// the platform
|
||||
val displayY = (device.displayHeight * 0.9).toInt() - barLayerHeight
|
||||
device.swipe(pipCenterX, pipCenterY, displayCenterX, displayY, 50)
|
||||
// Wait until the other app is no longer visible
|
||||
wmHelper
|
||||
.StateSyncBuilder()
|
||||
.withPipGone()
|
||||
.withWindowSurfaceDisappeared(pipApp)
|
||||
.withAppTransitionIdle()
|
||||
.waitForAndVerify()
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks that the focus doesn't change between windows during the transition */
|
||||
@Presubmit
|
||||
|
||||
@@ -28,11 +28,10 @@ import org.junit.runners.Parameterized
|
||||
|
||||
/** Base class for exiting pip (closing pip window) without returning to the app */
|
||||
abstract class ClosePipTransition(flicker: FlickerTest) : PipTransition(flicker) {
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition {
|
||||
setup { this.setRotation(flicker.scenario.startRotation) }
|
||||
teardown { this.setRotation(Rotation.ROTATION_0) }
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
setup { this.setRotation(flicker.scenario.startRotation) }
|
||||
teardown { this.setRotation(Rotation.ROTATION_0) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that [pipApp] window is pinned and visible at the start and then becomes unpinned and
|
||||
|
||||
@@ -54,12 +54,9 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class ClosePipWithDismissButtonTest(flicker: FlickerTest) : ClosePipTransition(flicker) {
|
||||
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
super.transition(this)
|
||||
transitions { pipApp.closePipWindow(wmHelper) }
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { pipApp.closePipWindow(wmHelper) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the focus changes between the pip menu window and the launcher when clicking the
|
||||
|
||||
@@ -45,20 +45,24 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class EnterPipOnUserLeaveHintTest(flicker: FlickerTest) : EnterPipTransition(flicker) {
|
||||
/** Defines the transition used to run the test */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
setup {
|
||||
pipApp.launchViaIntent(wmHelper)
|
||||
pipApp.enableEnterPipOnUserLeaveHint()
|
||||
}
|
||||
teardown {
|
||||
// close gracefully so that onActivityUnpinned() can be called before force exit
|
||||
pipApp.closePipWindow(wmHelper)
|
||||
pipApp.exit(wmHelper)
|
||||
}
|
||||
transitions { tapl.goHome() }
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { tapl.goHome() }
|
||||
}
|
||||
|
||||
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
|
||||
setup {
|
||||
pipApp.launchViaIntent(wmHelper)
|
||||
pipApp.enableEnterPipOnUserLeaveHint()
|
||||
}
|
||||
}
|
||||
|
||||
override val defaultTeardown: FlickerBuilder.() -> Unit = {
|
||||
teardown {
|
||||
// close gracefully so that onActivityUnpinned() can be called before force exit
|
||||
pipApp.closePipWindow(wmHelper)
|
||||
pipApp.exit(wmHelper)
|
||||
}
|
||||
}
|
||||
|
||||
@Presubmit
|
||||
@Test
|
||||
|
||||
@@ -73,39 +73,39 @@ open class EnterPipToOtherOrientation(flicker: FlickerTest) : PipTransition(flic
|
||||
private val startingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_90)
|
||||
private val endingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0)
|
||||
|
||||
/** Defines the transition used to run the test */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
setup {
|
||||
// Launch a portrait only app on the fullscreen stack
|
||||
testApp.launchViaIntent(
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
teardown {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
|
||||
setup {
|
||||
// Launch a portrait only app on the fullscreen stack
|
||||
testApp.launchViaIntent(
|
||||
wmHelper,
|
||||
stringExtras = mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_PORTRAIT.toString())
|
||||
)
|
||||
// Launch the PiP activity fixed as landscape
|
||||
pipApp.launchViaIntent(
|
||||
)
|
||||
// Launch the PiP activity fixed as landscape, but don't enter PiP
|
||||
pipApp.launchViaIntent(
|
||||
wmHelper,
|
||||
stringExtras =
|
||||
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()
|
||||
}
|
||||
mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test is not compatible with Tablets. When using [Activity.setRequestedOrientation] to
|
||||
|
||||
@@ -26,12 +26,11 @@ import org.junit.Test
|
||||
import org.junit.runners.Parameterized
|
||||
|
||||
abstract class EnterPipTransition(flicker: FlickerTest) : PipTransition(flicker) {
|
||||
/** {@inheritDoc} */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
setup { pipApp.launchViaIntent(wmHelper) }
|
||||
teardown { pipApp.exit(wmHelper) }
|
||||
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
|
||||
setup {
|
||||
pipApp.launchViaIntent(wmHelper)
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks [pipApp] window remains visible throughout the animation */
|
||||
@Presubmit
|
||||
|
||||
@@ -51,11 +51,7 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class EnterPipViaAppUiButtonTest(flicker: FlickerTest) : EnterPipTransition(flicker) {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
super.transition(this)
|
||||
transitions { pipApp.clickEnterPipButton(wmHelper) }
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { pipApp.clickEnterPipButton(wmHelper) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,19 +53,16 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class ExitPipToAppViaExpandButtonTest(flicker: FlickerTest) : ExitPipToAppTransition(flicker) {
|
||||
|
||||
/** Defines the transition used to run the test */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition {
|
||||
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()
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,19 +52,16 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class ExitPipToAppViaIntentTest(flicker: FlickerTest) : ExitPipToAppTransition(flicker) {
|
||||
|
||||
/** Defines the transition used to run the test */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition {
|
||||
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()
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,9 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class ExpandPipOnDoubleClickTest(flicker: FlickerTest) : PipTransition(flicker) {
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition { transitions { pipApp.doubleClickPipWindow(wmHelper) } }
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { pipApp.doubleClickPipWindow(wmHelper) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the pip app window remains inside the display bounds throughout the whole
|
||||
|
||||
@@ -35,8 +35,9 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class ExpandPipOnPinchOpenTest(flicker: FlickerTest) : PipTransition(flicker) {
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition { transitions { pipApp.pinchOpenPipWindow(wmHelper, 0.25f, 30) } }
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { pipApp.pinchOpenPipWindow(wmHelper, 0.25f, 30) }
|
||||
}
|
||||
|
||||
/** Checks that the visible region area of [pipApp] always increases during the animation. */
|
||||
@Presubmit
|
||||
|
||||
@@ -56,15 +56,10 @@ import org.junit.runners.Parameterized
|
||||
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
class MovePipDownOnShelfHeightChange(flicker: FlickerTest) : MovePipShelfHeightTransition(flicker) {
|
||||
/** Defines the transition used to run the test */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition {
|
||||
teardown {
|
||||
tapl.pressHome()
|
||||
testApp.exit(wmHelper)
|
||||
}
|
||||
transitions { testApp.launchViaIntent(wmHelper) }
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
teardown { testApp.exit(wmHelper) }
|
||||
transitions { testApp.launchViaIntent(wmHelper) }
|
||||
}
|
||||
|
||||
/** Checks that the visible region of [pipApp] window always moves down during the animation. */
|
||||
@Presubmit @Test fun pipWindowMovesDown() = pipWindowMoves(Direction.DOWN)
|
||||
|
||||
@@ -41,23 +41,21 @@ import org.junit.runners.Parameterized
|
||||
open class MovePipOnImeVisibilityChangeTest(flicker: FlickerTest) : PipTransition(flicker) {
|
||||
private val imeApp = ImeAppHelper(instrumentation)
|
||||
|
||||
/** {@inheritDoc} */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition {
|
||||
setup {
|
||||
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)
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
setup {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
/** Ensure the pip window remains visible throughout any keyboard interactions */
|
||||
@Presubmit
|
||||
|
||||
@@ -57,14 +57,12 @@ import org.junit.runners.Parameterized
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
open class MovePipUpOnShelfHeightChangeTest(flicker: FlickerTest) :
|
||||
MovePipShelfHeightTransition(flicker) {
|
||||
/** Defines the transition used to run the test */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() =
|
||||
buildTransition() {
|
||||
setup { testApp.launchViaIntent(wmHelper) }
|
||||
transitions { tapl.pressHome() }
|
||||
teardown { testApp.exit(wmHelper) }
|
||||
}
|
||||
override val thisTransition: FlickerBuilder.() -> Unit =
|
||||
{
|
||||
setup { testApp.launchViaIntent(wmHelper) }
|
||||
transitions { tapl.pressHome() }
|
||||
teardown { testApp.exit(wmHelper) }
|
||||
}
|
||||
|
||||
/** Checks that the visible region of [pipApp] window always moves up during the animation. */
|
||||
@Presubmit @Test fun pipWindowMovesUp() = pipWindowMoves(Direction.UP)
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
|
||||
import android.tools.device.flicker.legacy.FlickerBuilder
|
||||
import android.tools.device.flicker.legacy.FlickerTest
|
||||
import android.tools.device.flicker.legacy.FlickerTestFactory
|
||||
import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule
|
||||
import com.android.server.wm.flicker.testapp.ActivityOptions
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
@@ -37,28 +36,31 @@ import org.junit.runners.Parameterized
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
class PipDragTest(flicker: FlickerTest) : PipTransition(flicker) {
|
||||
private var isDraggedLeft: Boolean = true
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
val stringExtras = mapOf(ActivityOptions.Pip.EXTRA_ENTER_PIP to "true")
|
||||
|
||||
setup {
|
||||
tapl.setEnableRotation(true)
|
||||
// Launch the PIP activity and wait for it to enter PiP mode
|
||||
RemoveAllTasksButHomeRule.removeAllTasksButHome()
|
||||
pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras)
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { pipApp.dragPipWindowAwayFromEdgeWithoutRelease(wmHelper, 50) }
|
||||
}
|
||||
|
||||
// determine the direction of dragging to test for
|
||||
isDraggedLeft = pipApp.isCloserToRightEdge(wmHelper)
|
||||
}
|
||||
teardown {
|
||||
// release the primary pointer after dragging without release
|
||||
pipApp.releasePipAfterDragging()
|
||||
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
|
||||
val stringExtras = mapOf(ActivityOptions.Pip.EXTRA_ENTER_PIP to "true")
|
||||
setup {
|
||||
tapl.setEnableRotation(true)
|
||||
pipApp.launchViaIntentAndWaitForPip(wmHelper, stringExtras = stringExtras)
|
||||
|
||||
pipApp.exit(wmHelper)
|
||||
tapl.setEnableRotation(false)
|
||||
}
|
||||
transitions { pipApp.dragPipWindowAwayFromEdgeWithoutRelease(wmHelper, 50) }
|
||||
// determine the direction of dragging to test for
|
||||
isDraggedLeft = pipApp.isCloserToRightEdge(wmHelper)
|
||||
}
|
||||
}
|
||||
|
||||
override val defaultTeardown: FlickerBuilder.() -> Unit = {
|
||||
teardown {
|
||||
// release the primary pointer after dragging without release
|
||||
pipApp.releasePipAfterDragging()
|
||||
|
||||
pipApp.exit(wmHelper)
|
||||
tapl.setEnableRotation(false)
|
||||
}
|
||||
}
|
||||
|
||||
@Postsubmit
|
||||
@Test
|
||||
|
||||
@@ -37,8 +37,9 @@ import org.junit.runners.Parameterized
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@FlakyTest(bugId = 270677470)
|
||||
class PipPinchInTest(flicker: FlickerTest) : PipTransition(flicker) {
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition { transitions { pipApp.pinchInPipWindow(wmHelper, 0.4f, 30) } }
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
transitions { pipApp.pinchInPipWindow(wmHelper, 0.4f, 30) }
|
||||
}
|
||||
|
||||
/** Checks that the visible region area of [pipApp] always decreases during the animation. */
|
||||
@Postsubmit
|
||||
|
||||
@@ -56,27 +56,37 @@ abstract class PipTransition(flicker: FlickerTest) : BaseTest(flicker) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a configuration that handles basic setup and teardown of pip tests and that launches the
|
||||
* 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) }
|
||||
/** Defines the transition used to run the test */
|
||||
protected open val thisTransition: FlickerBuilder.() -> Unit = {}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,41 +50,41 @@ open class SetRequestedOrientationWhilePinned(flicker: FlickerTest) : PipTransit
|
||||
private val startingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0)
|
||||
private val endingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_90)
|
||||
|
||||
/** {@inheritDoc} */
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = {
|
||||
setup {
|
||||
// Launch the PiP activity fixed as landscape.
|
||||
pipApp.launchViaIntent(
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
override val defaultEnterPip: FlickerBuilder.() -> Unit = {
|
||||
setup {
|
||||
// Launch the PiP activity fixed as landscape.
|
||||
pipApp.launchViaIntent(
|
||||
wmHelper,
|
||||
stringExtras =
|
||||
mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString())
|
||||
)
|
||||
// Enter PiP.
|
||||
broadcastActionTrigger.doAction(ActivityOptions.Pip.ACTION_ENTER_PIP)
|
||||
// System bar may fade out during fixed rotation.
|
||||
wmHelper
|
||||
mapOf(EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString())
|
||||
)
|
||||
// Enter PiP.
|
||||
broadcastActionTrigger.doAction(ActivityOptions.Pip.ACTION_ENTER_PIP)
|
||||
// System bar may fade out during fixed rotation.
|
||||
wmHelper
|
||||
.StateSyncBuilder()
|
||||
.withPipShown()
|
||||
.withRotation(Rotation.ROTATION_0)
|
||||
.withNavOrTaskBarVisible()
|
||||
.withStatusBarVisible()
|
||||
.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
|
||||
|
||||
@@ -63,14 +63,13 @@ open class ShowPipAndRotateDisplay(flicker: FlickerTest) : PipTransition(flicker
|
||||
private val screenBoundsStart = WindowUtils.getDisplayBounds(flicker.scenario.startRotation)
|
||||
private val screenBoundsEnd = WindowUtils.getDisplayBounds(flicker.scenario.endRotation)
|
||||
|
||||
override val transition: FlickerBuilder.() -> Unit
|
||||
get() = buildTransition {
|
||||
setup {
|
||||
testApp.launchViaIntent(wmHelper)
|
||||
setRotation(flicker.scenario.startRotation)
|
||||
}
|
||||
transitions { setRotation(flicker.scenario.endRotation) }
|
||||
override val thisTransition: FlickerBuilder.() -> Unit = {
|
||||
setup {
|
||||
testApp.launchViaIntent(wmHelper)
|
||||
setRotation(flicker.scenario.startRotation)
|
||||
}
|
||||
transitions { setRotation(flicker.scenario.endRotation) }
|
||||
}
|
||||
|
||||
/** Checks that [testApp] layer is within [screenBoundsStart] at the start of the transition */
|
||||
@Presubmit
|
||||
|
||||
Reference in New Issue
Block a user