Search in sources :

Example 1 with AppIcon

use of com.android.launcher3.tapl.AppIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_widget.

@Test
public void testCustomProfileLoaded_with_widget() throws Exception {
    String pendingAppPkg = "com.test.pending";
    // Add a placeholder session info so that the widget exists
    SessionParams params = new SessionParams(SessionParams.MODE_FULL_INSTALL);
    params.setAppPackageName(pendingAppPkg);
    PackageInstaller installer = mTargetContext.getPackageManager().getPackageInstaller();
    int sessionId = installer.createSession(params);
    SessionInfo sessionInfo = installer.getSessionInfo(sessionId);
    setField(sessionInfo, "installerPackageName", "com.test");
    setField(sessionInfo, "appIcon", BitmapInfo.LOW_RES_ICON);
    writeLayoutAndLoad(new LauncherLayoutBuilder().atWorkspace(0, 1, 0).putWidget(pendingAppPkg, "PlaceholderWidget", 2, 2));
    // Verify widget
    assertEquals(1, mModelHelper.getBgDataModel().appWidgets.size());
    ItemInfo info = mModelHelper.getBgDataModel().appWidgets.get(0);
    assertEquals(LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET, info.itemType);
    assertEquals(2, info.spanX);
    assertEquals(2, info.spanY);
}
Also used : SessionParams(android.content.pm.PackageInstaller.SessionParams) LauncherLayoutBuilder(com.android.launcher3.util.LauncherLayoutBuilder) ItemInfo(com.android.launcher3.model.data.ItemInfo) PackageInstaller(android.content.pm.PackageInstaller) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) Test(org.junit.Test)

Example 2 with AppIcon

use of com.android.launcher3.tapl.AppIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaplTestsLauncher3 method runIconLaunchFromAllAppsTest.

public static void runIconLaunchFromAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
    allApps.freeze();
    try {
        final AppIcon app = allApps.getAppIcon("TestActivity7");
        assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
        test.executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the " + "top " + "one", test.isInBackground(launcher)));
    } finally {
        allApps.unfreeze();
    }
}
Also used : AppIcon(com.android.launcher3.tapl.AppIcon)

Example 3 with AppIcon

use of com.android.launcher3.tapl.AppIcon in project android_packages_apps_Launcher3 by AOSPA.

the class TaplTestsLauncher3 method runIconLaunchFromAllAppsTest.

public static void runIconLaunchFromAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
    allApps.freeze();
    try {
        final AppIcon app = allApps.getAppIcon("TestActivity7");
        assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
        test.executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the " + "top " + "one", test.isInBackground(launcher)));
    } finally {
        allApps.unfreeze();
    }
}
Also used : AppIcon(com.android.launcher3.tapl.AppIcon)

Example 4 with AppIcon

use of com.android.launcher3.tapl.AppIcon in project android_packages_apps_Launcher3 by AOSPA.

the class TaplTestsLauncher3 method testDragToFolder.

@Ignore("b/205014516")
@Test
@PortraitLandscape
public void testDragToFolder() throws Exception {
    final AppIcon playStoreIcon = createShortcutIfNotExist("Play Store");
    final AppIcon gmailIcon = createShortcutIfNotExist("Gmail");
    FolderIcon folderIcon = gmailIcon.dragToIcon(playStoreIcon);
    Folder folder = folderIcon.open();
    folder.getAppIcon("Play Store");
    folder.getAppIcon("Gmail");
    Workspace workspace = folder.close();
    assertNull("Gmail should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Gmail"));
    assertNull("Play Store should be moved to a folder.", workspace.tryGetWorkspaceAppIcon("Play Store"));
    final AppIcon youTubeIcon = createShortcutIfNotExist("YouTube");
    folderIcon = youTubeIcon.dragToIcon(folderIcon);
    folder = folderIcon.open();
    folder.getAppIcon("YouTube");
    folder.close();
}
Also used : FolderIcon(com.android.launcher3.tapl.FolderIcon) AppIcon(com.android.launcher3.tapl.AppIcon) Folder(com.android.launcher3.tapl.Folder) Workspace(com.android.launcher3.tapl.Workspace) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 5 with AppIcon

use of com.android.launcher3.tapl.AppIcon in project android_packages_apps_Launcher3 by AOSPA.

the class TaplTestsLauncher3 method createShortcutIfNotExist.

private AppIcon createShortcutIfNotExist(String name) {
    AppIcon appIcon = mLauncher.getWorkspace().tryGetWorkspaceAppIcon(name);
    if (appIcon == null) {
        AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
        allApps.freeze();
        try {
            appIcon = allApps.getAppIcon(name);
            appIcon.dragToWorkspace(false, false);
        } finally {
            allApps.unfreeze();
        }
        appIcon = mLauncher.getWorkspace().getWorkspaceAppIcon(name);
    }
    return appIcon;
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) AppIcon(com.android.launcher3.tapl.AppIcon)

Aggregations

AppIcon (com.android.launcher3.tapl.AppIcon)26 Test (org.junit.Test)17 LargeTest (androidx.test.filters.LargeTest)15 Workspace (com.android.launcher3.tapl.Workspace)15 AllApps (com.android.launcher3.tapl.AllApps)4 Folder (com.android.launcher3.tapl.Folder)4 FolderIcon (com.android.launcher3.tapl.FolderIcon)4 Ignore (org.junit.Ignore)4 PackageInstaller (android.content.pm.PackageInstaller)2 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)2 SessionParams (android.content.pm.PackageInstaller.SessionParams)2 ItemInfo (com.android.launcher3.model.data.ItemInfo)2 LauncherLayoutBuilder (com.android.launcher3.util.LauncherLayoutBuilder)2