Search in sources :

Example 71 with LauncherAppWidgetProviderInfo

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

the class AddWidgetTest method testDragIcon.

@Test
@PortraitLandscape
public void testDragIcon() throws Throwable {
    clearHomescreen();
    mDevice.pressHome();
    final LauncherAppWidgetProviderInfo widgetInfo = TestViewHelpers.findWidgetProvider(this, false);
    WidgetResizeFrame resizeFrame = mLauncher.getWorkspace().openAllWidgets().getWidget(widgetInfo.getLabel(mTargetContext.getPackageManager())).dragWidgetToWorkspace();
    assertTrue(mActivityMonitor.itemExists((info, view) -> info instanceof LauncherAppWidgetInfo && ((LauncherAppWidgetInfo) info).providerName.getClassName().equals(widgetInfo.provider.getClassName())).call());
    assertNotNull("Widget resize frame not shown after widget add", resizeFrame);
    resizeFrame.dismiss();
    final Widget widget = mLauncher.getWorkspace().tryGetWidget(widgetInfo.label, DEFAULT_UI_TIMEOUT);
    assertNotNull("Widget not found on the workspace", widget);
    widget.launch(getAppPackageName());
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) WidgetResizeFrame(com.android.launcher3.tapl.WidgetResizeFrame) Widget(com.android.launcher3.tapl.Widget) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) Test(org.junit.Test) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest)

Example 72 with LauncherAppWidgetProviderInfo

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

the class BindWidgetTest method testPendingWidget_withConfigScreen.

@Test
public void testPendingWidget_withConfigScreen() {
    // A non-restored widget with config screen get bound and shows a 'Click to setup' UI.
    LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, true);
    // Do not bind the widget
    LauncherAppWidgetInfo item = createWidgetInfo(info, getTargetContext(), false);
    item.restoreStatus = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID;
    addItemToScreen(item);
    verifyPendingWidgetPresent();
    // Item deleted from db
    mCursor = mResolver.query(LauncherSettings.Favorites.getContentUri(item.id), null, null, null, null, null);
    mCursor.moveToNext();
    // Widget has a valid Id now.
    assertEquals(0, mCursor.getInt(mCursor.getColumnIndex(LauncherSettings.Favorites.RESTORED)) & LauncherAppWidgetInfo.FLAG_ID_NOT_VALID);
    assertNotNull(AppWidgetManager.getInstance(mTargetContext).getAppWidgetInfo(mCursor.getInt(mCursor.getColumnIndex(LauncherSettings.Favorites.APPWIDGET_ID))));
    // send OPTION_APPWIDGET_RESTORE_COMPLETED
    int appWidgetId = mCursor.getInt(mCursor.getColumnIndex(LauncherSettings.Favorites.APPWIDGET_ID));
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mTargetContext);
    Bundle b = new Bundle();
    b.putBoolean(WidgetManagerHelper.WIDGET_OPTION_RESTORE_COMPLETED, true);
    RemoteViews remoteViews = new RemoteViews(mTargetPackage, R.layout.appwidget_not_ready);
    appWidgetManager.updateAppWidgetOptions(appWidgetId, b);
    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
    // verify changes are reflected
    waitForLauncherCondition("App widget options did not update", l -> appWidgetManager.getAppWidgetOptions(appWidgetId).getBoolean(WidgetManagerHelper.WIDGET_OPTION_RESTORE_COMPLETED));
    executeOnLauncher(l -> l.getAppWidgetHost().startListening());
    verifyWidgetPresent(info);
    assertNull(mLauncher.getWorkspace().tryGetPendingWidget(100));
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) RemoteViews(android.widget.RemoteViews) Bundle(android.os.Bundle) AppWidgetManager(android.appwidget.AppWidgetManager) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 73 with LauncherAppWidgetProviderInfo

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

the class BindWidgetTest method verifyWidgetPresent.

private void verifyWidgetPresent(LauncherAppWidgetProviderInfo info) {
    final Widget widget = mLauncher.getWorkspace().tryGetWidget(info.label, DEFAULT_UI_TIMEOUT);
    assertTrue("Widget is not present", widget != null);
}
Also used : Widget(com.android.launcher3.tapl.Widget)

Example 74 with LauncherAppWidgetProviderInfo

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

the class BindWidgetTest method testPendingWidget_autoRestored.

@Test
public void testPendingWidget_autoRestored() {
    // A non-restored widget with no config screen gets restored automatically.
    LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(this, false);
    // Do not bind the widget
    LauncherAppWidgetInfo item = createWidgetInfo(info, getTargetContext(), false);
    item.restoreStatus = LauncherAppWidgetInfo.FLAG_ID_NOT_VALID;
    addItemToScreen(item);
    verifyWidgetPresent(info);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 75 with LauncherAppWidgetProviderInfo

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

the class WidgetsTableUtilsTest method initTestWidgets.

private void initTestWidgets() {
    List<Point> widgetSizes = List.of(new Point(1, 1), new Point(2, 2), new Point(2, 3), new Point(2, 4), new Point(4, 4));
    ArrayList<WidgetItem> widgetItems = new ArrayList<>();
    widgetSizes.stream().forEach(widgetSize -> {
        AppWidgetProviderInfo info = createAppWidgetProviderInfo(ComponentName.createRelative(TEST_PACKAGE, ".WidgetProvider_" + widgetSize.x + "x" + widgetSize.y));
        LauncherAppWidgetProviderInfo widgetInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
        widgetInfo.spanX = widgetSize.x;
        widgetInfo.spanY = widgetSize.y;
        widgetItems.add(new WidgetItem(widgetInfo, mTestProfile, mIconCache));
    });
    mWidget1x1 = widgetItems.get(0);
    mWidget2x2 = widgetItems.get(1);
    mWidget2x3 = widgetItems.get(2);
    mWidget2x4 = widgetItems.get(3);
    mWidget4x4 = widgetItems.get(4);
}
Also used : LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) ArrayList(java.util.ArrayList) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) WidgetUtils.createAppWidgetProviderInfo(com.android.launcher3.util.WidgetUtils.createAppWidgetProviderInfo) LauncherAppWidgetProviderInfo(com.android.launcher3.widget.LauncherAppWidgetProviderInfo) WidgetItem(com.android.launcher3.model.WidgetItem) Point(android.graphics.Point)

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