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

Commit 9d406b44 authored by Sergey Pinkevich's avatar Sergey Pinkevich
Browse files

Chrome tab tearing minimize animation

Bug: 376459606
Flag: com.android.window.flags.enable_desktop_tab_tearing_minimize_animation_bugfix
Test: DesktopTasksControllerTest

Change-Id: I551f8e682458a4598a859671a573d8da43d47a83
parent f0e1ab82
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -3084,6 +3084,7 @@ class DesktopTasksController(
                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
                pendingIntentLaunchFlags =
                    Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
                splashScreenStyle = SPLASH_SCREEN_STYLE_ICON
            }
        if (windowingMode == WINDOWING_MODE_FULLSCREEN) {
            dragAndDropFullscreenCookie = Binder()
@@ -3092,7 +3093,12 @@ class DesktopTasksController(
        val wct = WindowContainerTransaction()
        wct.sendPendingIntent(launchIntent, null, opts.toBundle())
        if (windowingMode == WINDOWING_MODE_FREEFORM) {
            if (DesktopModeFlags.ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX.isTrue()) {
                // TODO b/376389593: Use a custom tab tearing transition/animation
                startLaunchTransition(TRANSIT_OPEN, wct, launchingTaskId = null)
            } else {
                desktopModeDragAndDropTransitionHandler.handleDropEvent(wct)
            }
        } else {
            transitions.startTransition(TRANSIT_OPEN, wct, null)
        }
+80 −6
Original line number Diff line number Diff line
@@ -5384,38 +5384,90 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
    }

    @Test
    fun onUnhandledDrag_newFreeformIntent() {
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFreeformIntent_tabTearingAnimationBugfixFlagEnabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR,
            PointF(1200f, 700f),
            Rect(240, 700, 2160, 1900),
            tabTearingAnimationFlagEnabled = true,
        )
    }

    @Test
    fun onUnhandledDrag_newFreeformIntentSplitLeft() {
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFreeformIntent_tabTearingAnimationBugfixFlagDisabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR,
            PointF(1200f, 700f),
            Rect(240, 700, 2160, 1900),
            tabTearingAnimationFlagEnabled = false,
        )
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFreeformIntentSplitLeft_tabTearingAnimationBugfixFlagEnabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR,
            PointF(50f, 700f),
            Rect(0, 0, 500, 1000),
            tabTearingAnimationFlagEnabled = true,
        )
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFreeformIntentSplitLeft_tabTearingAnimationBugfixFlagDisabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR,
            PointF(50f, 700f),
            Rect(0, 0, 500, 1000),
            tabTearingAnimationFlagEnabled = false,
        )
    }

    @Test
    fun onUnhandledDrag_newFreeformIntentSplitRight() {
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFreeformIntentSplitRight_tabTearingAnimationBugfixFlagEnabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR,
            PointF(2500f, 700f),
            Rect(500, 0, 1000, 1000),
            tabTearingAnimationFlagEnabled = true,
        )
    }

    @Test
    fun onUnhandledDrag_newFullscreenIntent() {
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFreeformIntentSplitRight_tabTearingAnimationBugfixFlagDisabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR,
            PointF(2500f, 700f),
            Rect(500, 0, 1000, 1000),
            tabTearingAnimationFlagEnabled = false,
        )
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFullscreenIntent_tabTearingAnimationBugfixFlagEnabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR,
            PointF(1200f, 50f),
            Rect(),
            tabTearingAnimationFlagEnabled = true,
        )
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newFullscreenIntent_tabTearingAnimationBugfixFlagDisabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR,
            PointF(1200f, 50f),
            Rect(),
            tabTearingAnimationFlagEnabled = false,
        )
    }

@@ -5769,6 +5821,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        indicatorType: DesktopModeVisualIndicator.IndicatorType,
        inputCoordinate: PointF,
        expectedBounds: Rect,
        tabTearingAnimationFlagEnabled: Boolean,
    ) {
        setUpLandscapeDisplay()
        val task = setUpFreeformTask()
@@ -5799,6 +5852,16 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
                anyOrNull(),
                eq(DesktopModeVisualIndicator.DragStartState.DRAGGED_INTENT),
            )
        whenever(
                desktopMixedTransitionHandler.startLaunchTransition(
                    eq(TRANSIT_OPEN),
                    any(),
                    anyOrNull(),
                    anyOrNull(),
                    anyOrNull(),
                )
            )
            .thenReturn(Binder())

        spyController.onUnhandledDrag(
            mockPendingIntent,
@@ -5815,9 +5878,20 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
            verify(transitions).startTransition(any(), capture(arg), anyOrNull())
        } else {
            expectedWindowingMode = WINDOWING_MODE_FREEFORM
            if (tabTearingAnimationFlagEnabled) {
                verify(desktopMixedTransitionHandler)
                    .startLaunchTransition(
                        eq(TRANSIT_OPEN),
                        capture(arg),
                        anyOrNull(),
                        anyOrNull(),
                        anyOrNull(),
                    )
            } else {
                // All other launches use a special handler.
                verify(dragAndDropTransitionHandler).handleDropEvent(capture(arg))
            }
        }
        assertThat(
                ActivityOptions.fromBundle(arg.value.hierarchyOps[0].launchOptions)
                    .launchWindowingMode