diff options
| author | 2024-10-28 16:41:54 +0000 | |
|---|---|---|
| committer | 2024-10-28 16:43:17 +0000 | |
| commit | b4cb61b96c165d59f4d39b28b28df5efa1dceae7 (patch) | |
| tree | 4098365c55f754ea20cdc2dbe4a429a390f2d8c4 | |
| parent | 6d335970632d4b1e05a48a6aa369396a2244c155 (diff) | |
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
2 files changed, 19 insertions, 1 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt index 8b0daf6e75b2..7c10795c732c 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt @@ -710,7 +710,7 @@ fun calculateWidgetSize(item: CommunalContentModel, isResizable: Boolean): Widge WidgetSizeInfo(minHeightPx, maxHeightPx) } } else { - WidgetSizeInfo(0, Int.MAX_VALUE) + WidgetSizeInfo(0, 0) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/ResizeableItemFrameViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/ResizeableItemFrameViewModelTest.kt index 22b114c632cd..df5c723775a8 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/ResizeableItemFrameViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/ui/viewmodel/ResizeableItemFrameViewModelTest.kt @@ -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, |