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

Commit b4cb61b9 authored by Prince's avatar Prince
Browse files

Updating default size info if widget is not able to resize

Fixes: 368056689
Test: atest ResizeableItemFrameViewModelTest
Flag: com.android.systemui.communal_widget_resizing
Change-Id: I6774f991d06a86884be2d0210a1a137070a50054
parent 6d335970
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -710,7 +710,7 @@ fun calculateWidgetSize(item: CommunalContentModel, isResizable: Boolean): Widge
            WidgetSizeInfo(minHeightPx, maxHeightPx)
        }
    } else {
        WidgetSizeInfo(0, Int.MAX_VALUE)
        WidgetSizeInfo(0, 0)
    }
}

+18 −0
Original line number Diff line number Diff line
@@ -380,6 +380,24 @@ class ResizeableItemFrameViewModelTest : SysuiTestCase() {
    fun testIllegalState_resizeMultipleZeroOrNegative() =
        testScope.runTest { updateGridLayout(singleSpanGrid.copy(resizeMultiple = 0)) }

    @Test
    fun testZeroHeights_cannotResize() = runTestWithSnapshots {
        val zeroHeightGrid =
            singleSpanGrid.copy(
                totalSpans = 2,
                currentSpan = 1,
                currentRow = 0,
                minHeightPx = 0,
                maxHeightPx = 0,
            )
        updateGridLayout(zeroHeightGrid)

        val topState = underTest.topDragState
        val bottomState = underTest.bottomDragState
        assertThat(topState.anchors.toList()).containsExactly(0 to 0f)
        assertThat(bottomState.anchors.toList()).containsExactly(0 to 0f)
    }

    private fun TestScope.updateGridLayout(gridLayout: GridLayout) {
        underTest.setGridLayoutInfo(
            verticalItemSpacingPx = gridLayout.verticalItemSpacingPx,