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

Commit e5238aa8 authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Enable PIP flicker tests on tablet" into main

parents dac760e9 4da7ac81
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1145,4 +1145,9 @@ interface IWindowManager
     * @param deviceId The id of the {@link InputDevice} that will handle the shortcut.
     */
    KeyboardShortcutGroup getApplicationLaunchKeyboardShortcuts(int deviceId);

    /**
     * Returns whether the display with {@code displayId} ignores orientation request.
     */
    boolean getIgnoreOrientationRequest(int displayId);
}
+18 −16
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.tools.flicker.legacy.LegacyFlickerTest
import android.tools.flicker.legacy.LegacyFlickerTestFactory
import android.tools.helpers.WindowUtils
import android.tools.traces.component.ComponentNameMatcher
import android.view.WindowManagerGlobal
import androidx.test.filters.FlakyTest
import com.android.server.wm.flicker.entireScreenCovered
import com.android.server.wm.flicker.helpers.FixedOrientationAppHelper
@@ -38,13 +39,12 @@ import com.android.wm.shell.flicker.pip.common.PipTransition
import com.android.wm.shell.flicker.pip.common.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_LANDSCAPE
import com.android.wm.shell.flicker.pip.common.PipTransition.BroadcastActionTrigger.Companion.ORIENTATION_PORTRAIT
import org.junit.Assume.assumeFalse
import org.junit.Assume.assumeTrue
import org.junit.FixMethodOrder
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
import java.lang.AssertionError

/**
 * Test entering pip while changing orientation (from app in landscape to pip window in portrait)
@@ -75,7 +75,15 @@ import org.junit.runners.Parameterized
open class EnterPipToOtherOrientation(flicker: LegacyFlickerTest) : PipTransition(flicker) {
    override val pipApp: PipAppHelper = PipAppHelper(instrumentation)
    internal val testApp = FixedOrientationAppHelper(instrumentation)
    internal val startingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_90)
    internal val ignoreOrientationRequest = WindowManagerGlobal.getWindowManagerService()
        ?.getIgnoreOrientationRequest(WindowUtils.defaultDisplayId)
        ?: throw AssertionError("WMS must not be null.")
    internal val startingBounds = if (ignoreOrientationRequest) {
        // If the device chooses to ignore orientation request, use the current display bounds.
        WindowUtils.getDisplayBounds(Rotation.ROTATION_0)
    } else {
        WindowUtils.getDisplayBounds(Rotation.ROTATION_90)
    }
    private val endingBounds = WindowUtils.getDisplayBounds(Rotation.ROTATION_0)

    override val thisTransition: FlickerBuilder.() -> Unit = {
@@ -167,20 +175,14 @@ open class EnterPipToOtherOrientation(flicker: LegacyFlickerTest) : PipTransitio
    @Presubmit
    @Test
    open fun pipAppLayerCoversFullScreenOnStart() {
        assumeFalse(tapl.isTablet)
        flicker.assertLayersStart { visibleRegion(pipApp).coversExactly(startingBounds) }
    }

    /**
     * Checks that the visible region of [pipApp] covers the full display area at the start of the
     * transition
     */
    @Ignore("TODO(b/356277166): enable the tablet test")
    @Test
    open fun pipAppLayerPlusLetterboxCoversFullScreenOnStartTablet() {
        assumeTrue(tapl.isTablet)
        flicker.assertLayersStart {
            visibleRegion(pipApp.or(ComponentNameMatcher.LETTERBOX)).coversExactly(startingBounds)
            visibleRegion(
                if (ignoreOrientationRequest) {
                    pipApp.or(ComponentNameMatcher.LETTERBOX)
                } else {
                    pipApp
                }
            ).coversExactly(startingBounds)
        }
    }

+7 −15
Original line number Diff line number Diff line
@@ -26,10 +26,7 @@ import com.android.server.wm.flicker.helpers.BottomHalfPipAppHelper
import com.android.server.wm.flicker.helpers.PipAppHelper
import com.android.wm.shell.Flags
import com.android.wm.shell.flicker.pip.EnterPipToOtherOrientation
import org.junit.Assume.assumeFalse
import org.junit.Assume.assumeTrue
import org.junit.FixMethodOrder
import org.junit.Ignore
import org.junit.Test
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized
@@ -71,19 +68,14 @@ class BottomHalfEnterPipToOtherOrientation(flicker: LegacyFlickerTest) :
    @Test
    override fun pipAppLayerCoversFullScreenOnStart() {
        // Test app and pip app should covers the entire screen on start.
        assumeFalse(tapl.isTablet)
        flicker.assertLayersStart {
            visibleRegion(pipApp.or(testApp)).coversExactly(startingBounds)
            visibleRegion(
                if (ignoreOrientationRequest) {
                    pipApp.or(testApp).or(ComponentNameMatcher.LETTERBOX)
                } else {
                    pipApp.or(testApp)
                }
    }

    @Ignore("TODO(b/356277166): enable the tablet test")
    @Test
    override fun pipAppLayerPlusLetterboxCoversFullScreenOnStartTablet() {
        // Test app and pip app should covers the entire screen on start.
        assumeTrue(tapl.isTablet)
        flicker.assertLayersStart {
            visibleRegion(pipApp.or(ComponentNameMatcher.LETTERBOX)).coversExactly(startingBounds)
            ).coversExactly(startingBounds)
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -4309,7 +4309,8 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    boolean getIgnoreOrientationRequest(int displayId) {
    @Override
    public boolean getIgnoreOrientationRequest(int displayId) {
        synchronized (mGlobalLock) {
            final DisplayContent display = mRoot.getDisplayContent(displayId);
            if (display == null) {
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import com.android.server.wm.flicker.testapp.ActivityOptions.BottomHalfPip
class BottomHalfPipAppHelper(
    instrumentation: Instrumentation,
    private val useLaunchingActivity: Boolean = false,
    private val fillTaskOnCreate: Boolean = true,
    private val fillTaskOnCreate: Boolean = false,
) : PipAppHelper(
    instrumentation,
    appName = BottomHalfPip.LABEL,
Loading