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

Commit bb70ba01 authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Consider position in isTaskMaximized

This CL makes isTaskMaximized() to check the position as well.
Otherwise, when the window is not at the origin but the size is
maximized, isTaskMaximized() unexpectedly returns true.

Bug: 382021656
Bug: 382990242
Flag: EXEMPT bug fix
Test: DesktopModeWindowDecorViewModelTests
Change-Id: Ie9d8f488fdbcf02c645f6afca132c3c6dbcf762b
parent 1449f0e7
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -235,8 +235,7 @@ fun isTaskWidthOrHeightEqual(taskBounds: Rect, stableBounds: Rect): Boolean {

/** Returns true if task bound is equal to stable bounds else returns false. */
fun isTaskBoundsEqual(taskBounds: Rect, stableBounds: Rect): Boolean {
    return taskBounds.width() == stableBounds.width() &&
        taskBounds.height() == stableBounds.height()
    return taskBounds == stableBounds
}

/**
+47 −1
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest
    }

    @Test
    fun testOnDecorMaximizedOrRestored_togglesTaskSize() {
    fun testOnDecorMaximizedOrRestored_togglesTaskSize_maximize() {
        val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
                as ArgumentCaptor<Function0<Unit>>
        val decor = createOpenTaskDecoration(
@@ -408,6 +408,52 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest
        )
    }

    @Test
    fun testOnDecorMaximizedOrRestored_togglesTaskSize_maximizeFromMaximizedSize() {
        val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
                as ArgumentCaptor<Function0<Unit>>
        val decor = createOpenTaskDecoration(
            windowingMode = WINDOWING_MODE_FREEFORM,
            onMaxOrRestoreListenerCaptor = maxOrRestoreListenerCaptor
        )
        val movedMaximizedBounds = Rect(STABLE_BOUNDS)
        movedMaximizedBounds.offset(10, 10)
        decor.mTaskInfo.configuration.windowConfiguration.bounds.set(movedMaximizedBounds)

        maxOrRestoreListenerCaptor.value.invoke()

        verify(mockDesktopTasksController).toggleDesktopTaskSize(
            decor.mTaskInfo,
            ToggleTaskSizeInteraction(
                ToggleTaskSizeInteraction.Direction.MAXIMIZE,
                ToggleTaskSizeInteraction.Source.MAXIMIZE_MENU_TO_MAXIMIZE,
                InputMethod.UNKNOWN_INPUT_METHOD
            )
        )
    }

    @Test
    fun testOnDecorMaximizedOrRestored_togglesTaskSize_restore() {
        val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
                as ArgumentCaptor<Function0<Unit>>
        val decor = createOpenTaskDecoration(
            windowingMode = WINDOWING_MODE_FREEFORM,
            onMaxOrRestoreListenerCaptor = maxOrRestoreListenerCaptor
        )
        decor.mTaskInfo.configuration.windowConfiguration.bounds.set(STABLE_BOUNDS)

        maxOrRestoreListenerCaptor.value.invoke()

        verify(mockDesktopTasksController).toggleDesktopTaskSize(
            decor.mTaskInfo,
            ToggleTaskSizeInteraction(
                ToggleTaskSizeInteraction.Direction.RESTORE,
                ToggleTaskSizeInteraction.Source.MAXIMIZE_MENU_TO_RESTORE,
                InputMethod.UNKNOWN_INPUT_METHOD
            )
        )
    }

    @Test
    fun testOnDecorMaximizedOrRestored_closesMenus() {
        val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
+1 −2
Original line number Diff line number Diff line
@@ -145,7 +145,6 @@ open class DesktopModeWindowDecorViewModelTestsBase : ShellTestCase() {
    protected val mockCaptionHandleRepository = mock<WindowDecorCaptionHandleRepository>()
    protected val mockDesktopRepository: DesktopRepository = mock<DesktopRepository>()
    protected val motionEvent = mock<MotionEvent>()
    val displayController = mock<DisplayController>()
    val displayLayout = mock<DisplayLayout>()
    protected lateinit var spyContext: TestableContext
    private lateinit var desktopModeEventLogger: DesktopModeEventLogger
@@ -250,7 +249,7 @@ open class DesktopModeWindowDecorViewModelTestsBase : ShellTestCase() {
            argumentCaptor<DesktopModeKeyguardChangeListener>()
        verify(mockShellController).addKeyguardChangeListener(keyguardChangedCaptor.capture())
        desktopModeOnKeyguardChangedListener = keyguardChangedCaptor.firstValue
        whenever(displayController.getDisplayLayout(anyInt())).thenReturn(displayLayout)
        whenever(mockDisplayController.getDisplayLayout(anyInt())).thenReturn(displayLayout)
        whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
            (i.arguments.first() as Rect).set(STABLE_BOUNDS)
        }