Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4d70db7 authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

Merge "Fix SetRequestedOrientationWhilePinnedTest with Shell transition" into tm-dev am: 1e9ff8ee

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

Change-Id: Ida0654bf6e1911ebd2dce184f6a9796a5b6c8f6b
parents e63a09b1 1e9ff8ee
Loading
Loading
Loading
Loading
+0 −7
Original line number Original line Diff line number Diff line
@@ -56,13 +56,6 @@ abstract class PipTransition(protected val testSpec: FlickerTestParameter) {
                .sendBroadcast(createIntentWithAction(broadcastAction))
                .sendBroadcast(createIntentWithAction(broadcastAction))
        }
        }


        fun requestOrientationForPip(orientation: Int) {
            instrumentation.context.sendBroadcast(
                    createIntentWithAction(Components.PipActivity.ACTION_SET_REQUESTED_ORIENTATION)
                    .putExtra(Components.PipActivity.EXTRA_PIP_ORIENTATION, orientation.toString())
            )
        }

        companion object {
        companion object {
            // Corresponds to ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
            // Corresponds to ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
            @JvmStatic
            @JvmStatic
+15 −10
Original line number Original line Diff line number Diff line
@@ -28,8 +28,8 @@ import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled
import com.android.server.wm.flicker.helpers.isShellTransitionsEnabled
import com.android.wm.shell.flicker.pip.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_LANDSCAPE
import com.android.wm.shell.flicker.pip.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_LANDSCAPE
import com.android.wm.shell.flicker.testapp.Components
import com.android.wm.shell.flicker.testapp.Components.FixedActivity.EXTRA_FIXED_ORIENTATION
import com.android.wm.shell.flicker.testapp.Components.FixedActivity.EXTRA_FIXED_ORIENTATION
import com.android.wm.shell.flicker.testapp.Components.PipActivity.EXTRA_ENTER_PIP
import org.junit.Assume
import org.junit.Assume
import org.junit.Before
import org.junit.Before
import org.junit.FixMethodOrder
import org.junit.FixMethodOrder
@@ -39,7 +39,7 @@ import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized


/**
/**
 * Test Pip with orientation changes.
 * Test exiting Pip with orientation changes.
 * To run this test: `atest WMShellFlickerTests:SetRequestedOrientationWhilePinnedTest`
 * To run this test: `atest WMShellFlickerTests:SetRequestedOrientationWhilePinnedTest`
 */
 */
@RequiresDevice
@RequiresDevice
@@ -65,10 +65,16 @@ open class SetRequestedOrientationWhilePinnedTest(


            setup {
            setup {
                eachRun {
                eachRun {
                    // Launch the PiP activity fixed as landscape
                    // Launch the PiP activity fixed as landscape.
                    pipApp.launchViaIntent(wmHelper, stringExtras = mapOf(
                    pipApp.launchViaIntent(wmHelper, stringExtras = mapOf(
                        EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString(),
                        EXTRA_FIXED_ORIENTATION to ORIENTATION_LANDSCAPE.toString()))
                        EXTRA_ENTER_PIP to "true"))
                    // Enter PiP.
                    broadcastActionTrigger.doAction(Components.PipActivity.ACTION_ENTER_PIP)
                    wmHelper.waitPipShown()
                    wmHelper.waitForRotation(Surface.ROTATION_0)
                    wmHelper.waitForAppTransitionIdle()
                    // System bar may fade out during fixed rotation.
                    wmHelper.waitForNavBarStatusBarVisible()
                }
                }
            }
            }
            teardown {
            teardown {
@@ -77,14 +83,13 @@ open class SetRequestedOrientationWhilePinnedTest(
                }
                }
            }
            }
            transitions {
            transitions {
                // Request that the orientation is set to landscape
                // Launch the activity back into fullscreen and ensure that it is now in landscape
                broadcastActionTrigger.requestOrientationForPip(ORIENTATION_LANDSCAPE)

                // Launch the activity back into fullscreen and
                // ensure that it is now in landscape
                pipApp.launchViaIntent(wmHelper)
                pipApp.launchViaIntent(wmHelper)
                wmHelper.waitForFullScreenApp(pipApp.component)
                wmHelper.waitForFullScreenApp(pipApp.component)
                wmHelper.waitForRotation(Surface.ROTATION_90)
                wmHelper.waitForRotation(Surface.ROTATION_90)
                wmHelper.waitForAppTransitionIdle()
                // System bar may fade out during fixed rotation.
                wmHelper.waitForNavBarStatusBarVisible()
            }
            }
        }
        }


+4 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,10 @@ import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized


/**
 * Test exiting Pip with orientation changes.
 * To run this test: `atest WMShellFlickerTests:SetRequestedOrientationWhilePinnedTestShellTransit`
 */
@RequiresDevice
@RequiresDevice
@RunWith(Parameterized::class)
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
+5 −1
Original line number Original line Diff line number Diff line
@@ -1262,7 +1262,11 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
                change.setAllowEnterPip(topMostActivity != null
                change.setAllowEnterPip(topMostActivity != null
                        && topMostActivity.checkEnterPictureInPictureAppOpsState());
                        && topMostActivity.checkEnterPictureInPictureAppOpsState());
                final ActivityRecord topRunningActivity = task.topRunningActivity();
                final ActivityRecord topRunningActivity = task.topRunningActivity();
                if (topRunningActivity != null && task.mDisplayContent != null) {
                if (topRunningActivity != null && task.mDisplayContent != null
                        // Display won't be rotated for multi window Task, so the fixed rotation
                        // won't be applied. This can happen when the windowing mode is changed
                        // before the previous fixed rotation is applied.
                        && !task.inMultiWindowMode()) {
                    // If Activity is in fixed rotation, its will be applied with the next rotation,
                    // If Activity is in fixed rotation, its will be applied with the next rotation,
                    // when the Task is still in the previous rotation.
                    // when the Task is still in the previous rotation.
                    final int taskRotation = task.getWindowConfiguration().getDisplayRotation();
                    final int taskRotation = task.getWindowConfiguration().getDisplayRotation();