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

Commit a545efde authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Updating default size info if widget is not able to resize" into main

parents c6a025ef b4cb61b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -715,7 +715,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
@@ -480,6 +480,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,