Search in sources :

Example 76 with LauncherAppWidgetProviderInfo

use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherAppWidgetProviderInfoTest method initSpans_minResizeWidthSmallerThanCellWidth_shouldInitializeMinSpansToOne.

@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();
    info.initSpans(mContext, idp);
    assertThat(info.minSpanX).isEqualTo(1);
    assertThat(info.minSpanY).isEqualTo(1);
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 77 with LauncherAppWidgetProviderInfo

use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherAppWidgetProviderInfoTest method initSpans_minWidthLargerThanCellWidth_shouldInitializeSpans.

@Test
public void initSpans_minWidthLargerThanCellWidth_shouldInitializeSpans() {
    LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
    info.minWidth = 80;
    info.minHeight = 80;
    InvariantDeviceProfile idp = createIDP();
    info.initSpans(mContext, idp);
    assertThat(info.spanX).isEqualTo(2);
    assertThat(info.spanY).isEqualTo(2);
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 78 with LauncherAppWidgetProviderInfo

use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherAppWidgetProviderInfoTest method initSpans_minResizeWidthWithCellSpacingAndWidgetInset_shouldInitializeMinSpans.

@Test
public void initSpans_minResizeWidthWithCellSpacingAndWidgetInset_shouldInitializeMinSpans() {
    InvariantDeviceProfile idp = createIDP();
    DeviceProfile dp = idp.supportedProfiles.get(0);
    Rect padding = new Rect();
    AppWidgetHostView.getDefaultPaddingForWidget(mContext, null, padding);
    int maxPadding = Math.max(Math.max(padding.left, padding.right), Math.max(padding.top, padding.bottom));
    dp.cellLayoutBorderSpacePx.x = dp.cellLayoutBorderSpacePx.y = maxPadding + 1;
    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;
    info.initSpans(mContext, idp);
    assertThat(info.minSpanX).isEqualTo(2);
    assertThat(info.minSpanY).isEqualTo(2);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) Rect(android.graphics.Rect) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) Point(android.graphics.Point) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 79 with LauncherAppWidgetProviderInfo

use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherAppWidgetProviderInfoTest method initSpans_minResizeWidthHeightLargerThanMinWidth_shouldUseMinWidthHeightAsMinSpans.

@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);
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 80 with LauncherAppWidgetProviderInfo

use of com.android.launcher3.LauncherAppWidgetProviderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherAppWidgetProviderInfoTest method isMinSizeFulfilled_minWidthAndHeightWithinGridSize_shouldReturnTrue.

@Test
public void isMinSizeFulfilled_minWidthAndHeightWithinGridSize_shouldReturnTrue() {
    LauncherAppWidgetProviderInfo info = new LauncherAppWidgetProviderInfo();
    info.minWidth = 80;
    info.minHeight = 80;
    info.minResizeWidth = 50;
    info.minResizeHeight = 50;
    InvariantDeviceProfile idp = createIDP();
    info.initSpans(mContext, idp);
    assertThat(info.isMinSizeFulfilled()).isTrue();
}
Also used : InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)108 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)81 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)77 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)65 SmallTest (androidx.test.filters.SmallTest)52 LargeTest (androidx.test.filters.LargeTest)42 AbstractLauncherUiTest (com.android.launcher3.ui.AbstractLauncherUiTest)42 PendingAddWidgetInfo (com.android.launcher3.widget.PendingAddWidgetInfo)33 Bundle (android.os.Bundle)32 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)31 Point (android.graphics.Point)29 LauncherAppWidgetProviderInfo (com.android.launcher3.LauncherAppWidgetProviderInfo)28 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)23 Context (android.content.Context)23 DeviceProfile (com.android.launcher3.DeviceProfile)23 ArrayList (java.util.ArrayList)21 AppWidgetHostView (android.appwidget.AppWidgetHostView)20 WidgetItem (com.android.launcher3.model.WidgetItem)17 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)14 WidgetAddFlowHandler (com.android.launcher3.widget.WidgetAddFlowHandler)14