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

Commit e55ca2d2 authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Relax bounds check in desktop entry flicker tests

The current intial bounds check is very flaky. Both the size and
position of the inital bounds are extensivly covered by unit tests so we
can relax this check to simply verify the app window is within the
display bounds when entering desktop.

Flag: EXEMPT test fix
Test: atest EnterDesktopFromKeyboardShortcutFlickerTest, atest
EnterDesktopWithDragFlickerTest
Bug: 437536491

Change-Id: Ia0ae14dd8ca2e9e94a1fd03ad6ccbe8730f84f58
parent bbb4c36f
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -27,11 +27,11 @@ import android.tools.flicker.FlickerTestFactory
import android.tools.traces.component.ComponentNameMatcher.Companion.DESKTOP_WALLPAPER_ACTIVITY
import com.android.wm.shell.flicker.DesktopModeBaseTest
import com.android.wm.shell.flicker.utils.appWindowBecomesVisible
import com.android.wm.shell.flicker.utils.appWindowHasDesktopModeInitialBoundsAtTheEnd
import com.android.wm.shell.flicker.utils.appWindowOnTopAtEnd
import com.android.wm.shell.flicker.utils.layerIsVisibleAtEnd
import com.android.wm.shell.scenarios.EnterDesktopWithDrag
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.utils.appWindowInsideDisplayBoundsAtEnd
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -68,8 +68,7 @@ class EnterDesktopWithDragFlickerTest(flicker: FlickerTest) :
        }

    @Test
    fun appWindowHasDesktopModeInitialBoundsAtTheEnd() =
        flicker.appWindowHasDesktopModeInitialBoundsAtTheEnd(testApp)
    fun appWindowInsideDisplayBoundsAtEnd() = flicker.appWindowInsideDisplayBoundsAtEnd(testApp)

    @Test
    fun appWindowOnTopAtEnd() = flicker.appWindowOnTopAtEnd(testApp)
+2 −3
Original line number Diff line number Diff line
@@ -27,11 +27,11 @@ import android.tools.flicker.assertions.FlickerChecker
import android.tools.traces.component.ComponentNameMatcher.Companion.DESKTOP_WALLPAPER_ACTIVITY
import com.android.wm.shell.flicker.DesktopModeBaseTest
import com.android.wm.shell.flicker.utils.appWindowBecomesVisible
import com.android.wm.shell.flicker.utils.appWindowHasDesktopModeInitialBoundsAtTheEnd
import com.android.wm.shell.flicker.utils.appWindowOnTopAtEnd
import com.android.wm.shell.flicker.utils.layerIsVisibleAtEnd
import com.android.wm.shell.scenarios.EnterDesktopFromKeyboardShortcut
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.utils.appWindowInsideDisplayBoundsAtEnd
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -65,8 +65,7 @@ class EnterDesktopFromKeyboardShortcutFlickerTest(flicker: FlickerTest) :
        }

    @Test
    fun appWindowHasDesktopModeInitialBoundsAtTheEnd() =
        flicker.appWindowHasDesktopModeInitialBoundsAtTheEnd(testApp)
    fun appWindowInsideDisplayBoundsAtEnd() = flicker.appWindowInsideDisplayBoundsAtEnd(testApp)

    @Test
    fun appWindowOnTopAtEnd() = flicker.appWindowOnTopAtEnd(testApp)
+1 −29
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@

package com.android.wm.shell.flicker.utils

import android.graphics.Rect
import android.os.SystemProperties
import android.tools.PlatformConsts
import android.tools.flicker.FlickerTest
import android.tools.helpers.WindowUtils
import android.tools.traces.component.IComponentMatcher
@@ -159,31 +156,6 @@ fun FlickerTest.appWindowCoversHalfScreenAtEnd(
    }
}

fun FlickerTest.appWindowHasDesktopModeInitialBoundsAtTheEnd(component: IComponentMatcher) {
    assertLayersEnd {
        val displayBounds =
            entry.physicalDisplayBounds ?: error("Missing physical display bounds")
        val stableBounds = WindowUtils.getInsetDisplayBounds(scenario.endRotation)
        val desktopModeInitialBoundsScale =
            SystemProperties.getInt("persist.wm.debug.desktop_mode_initial_bounds_scale", 72) /
                100f

        val desiredWidth = displayBounds.width().times(desktopModeInitialBoundsScale)
        val desiredHeight = displayBounds.height().times(desktopModeInitialBoundsScale)

        val outBounds = Rect(0, 0, desiredWidth.toInt(), desiredHeight.toInt())
        val xOffset = ((stableBounds.width() - desiredWidth) / 2).toInt()
        val yOffset =
            ((stableBounds.height() - desiredHeight) *
                 PlatformConsts.DESKTOP_MODE_INITIAL_WINDOW_HEIGHT_PROPORTION + stableBounds.top)
                 .toInt()
        // Position the task in screen bounds
        outBounds.offset(xOffset, yOffset)

        visibleRegion(component).coversExactly(outBounds)
    }
}

fun FlickerTest.appWindowBecomesPinned(component: IComponentMatcher) {
    assertWm {
        invoke("appWindowIsNotPinned") { it.isNotPinned(component) }