Loading robolectric_tests/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfoTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,8 @@ public final class LauncherAppWidgetProviderInfoTest { @Test public void initSpans_minResizeWidthSmallerThanCellWidth_shouldInitializeMinSpansToOne() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = 100; info.minHeight = 100; info.minResizeWidth = 20; info.minResizeHeight = 20; InvariantDeviceProfile idp = createIDP(); Loading @@ -135,6 +137,8 @@ public final class LauncherAppWidgetProviderInfoTest { @Test public void initSpans_minResizeWidthLargerThanCellWidth_shouldInitializeMinSpans() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = 100; info.minHeight = 100; info.minResizeWidth = 80; info.minResizeHeight = 80; InvariantDeviceProfile idp = createIDP(); Loading @@ -157,6 +161,8 @@ public final class LauncherAppWidgetProviderInfoTest { Mockito.when(dp.shouldInsetWidgets()).thenReturn(true); LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = CELL_SIZE * 3; info.minHeight = CELL_SIZE * 3; info.minResizeWidth = CELL_SIZE * 2 + maxPadding; info.minResizeHeight = CELL_SIZE * 2 + maxPadding; Loading @@ -177,6 +183,8 @@ public final class LauncherAppWidgetProviderInfoTest { dp.cellLayoutBorderSpacingPx = maxPadding - 1; Mockito.when(dp.shouldInsetWidgets()).thenReturn(false); LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = CELL_SIZE * 3; info.minHeight = CELL_SIZE * 3; info.minResizeWidth = CELL_SIZE * 2 + maxPadding; info.minResizeHeight = CELL_SIZE * 2 + maxPadding; Loading @@ -186,6 +194,22 @@ public final class LauncherAppWidgetProviderInfoTest { assertThat(info.minSpanY).isEqualTo(3); } @Test public void initSpans_minResizeWidthHeightLargerThanMinWidth_shouldUseMinWidthHeightAsMinSpans() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = 20; info.minHeight = 20; info.minResizeWidth = 80; info.minResizeHeight = 80; InvariantDeviceProfile idp = createIDP(); info.initSpans(mContext, idp); assertThat(info.minSpanX).isEqualTo(1); assertThat(info.minSpanY).isEqualTo(1); } @Test public void isMinSizeFulfilled_minWidthAndHeightWithinGridSize_shouldReturnTrue() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); Loading src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java +5 −2 Original line number Diff line number Diff line Loading @@ -160,8 +160,11 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo } } this.minSpanX = minSpanX; this.minSpanY = minSpanY; // If minSpanX/Y > spanX/Y, ignore the minSpanX/Y to match the behavior described in // minResizeWidth & minResizeHeight Android documentation. See // https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo this.minSpanX = Math.min(spanX, minSpanX); this.minSpanY = Math.min(spanY, minSpanY); this.maxSpanX = maxSpanX; this.maxSpanY = maxSpanY; this.mIsMinSizeFulfilled = Math.min(spanX, minSpanX) <= idp.numColumns Loading Loading
robolectric_tests/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfoTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,8 @@ public final class LauncherAppWidgetProviderInfoTest { @Test public void initSpans_minResizeWidthSmallerThanCellWidth_shouldInitializeMinSpansToOne() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = 100; info.minHeight = 100; info.minResizeWidth = 20; info.minResizeHeight = 20; InvariantDeviceProfile idp = createIDP(); Loading @@ -135,6 +137,8 @@ public final class LauncherAppWidgetProviderInfoTest { @Test public void initSpans_minResizeWidthLargerThanCellWidth_shouldInitializeMinSpans() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = 100; info.minHeight = 100; info.minResizeWidth = 80; info.minResizeHeight = 80; InvariantDeviceProfile idp = createIDP(); Loading @@ -157,6 +161,8 @@ public final class LauncherAppWidgetProviderInfoTest { Mockito.when(dp.shouldInsetWidgets()).thenReturn(true); LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = CELL_SIZE * 3; info.minHeight = CELL_SIZE * 3; info.minResizeWidth = CELL_SIZE * 2 + maxPadding; info.minResizeHeight = CELL_SIZE * 2 + maxPadding; Loading @@ -177,6 +183,8 @@ public final class LauncherAppWidgetProviderInfoTest { dp.cellLayoutBorderSpacingPx = maxPadding - 1; Mockito.when(dp.shouldInsetWidgets()).thenReturn(false); LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = CELL_SIZE * 3; info.minHeight = CELL_SIZE * 3; info.minResizeWidth = CELL_SIZE * 2 + maxPadding; info.minResizeHeight = CELL_SIZE * 2 + maxPadding; Loading @@ -186,6 +194,22 @@ public final class LauncherAppWidgetProviderInfoTest { assertThat(info.minSpanY).isEqualTo(3); } @Test public void initSpans_minResizeWidthHeightLargerThanMinWidth_shouldUseMinWidthHeightAsMinSpans() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); info.minWidth = 20; info.minHeight = 20; info.minResizeWidth = 80; info.minResizeHeight = 80; InvariantDeviceProfile idp = createIDP(); info.initSpans(mContext, idp); assertThat(info.minSpanX).isEqualTo(1); assertThat(info.minSpanY).isEqualTo(1); } @Test public void isMinSizeFulfilled_minWidthAndHeightWithinGridSize_shouldReturnTrue() { LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo(); Loading
src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java +5 −2 Original line number Diff line number Diff line Loading @@ -160,8 +160,11 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo } } this.minSpanX = minSpanX; this.minSpanY = minSpanY; // If minSpanX/Y > spanX/Y, ignore the minSpanX/Y to match the behavior described in // minResizeWidth & minResizeHeight Android documentation. See // https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo this.minSpanX = Math.min(spanX, minSpanX); this.minSpanY = Math.min(spanY, minSpanY); this.maxSpanX = maxSpanX; this.maxSpanY = maxSpanY; this.mIsMinSizeFulfilled = Math.min(spanX, minSpanX) <= idp.numColumns Loading