Search in sources :

Example 21 with AllApps

use of com.android.launcher3.tapl.AllApps in project android_packages_apps_Trebuchet by LineageOS.

the class TaplTestsLauncher3 method testDragShortcut.

@Test
@PortraitLandscape
public void testDragShortcut() throws Throwable {
    // 1. Open all apps and wait for load complete.
    // 2. Find the app and long press it to show shortcuts.
    // 3. Press icon center until shortcuts appear
    final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
    allApps.freeze();
    try {
        final AppIconMenuItem menuItem = allApps.getAppIcon(APP_NAME).openMenu().getMenuItem(0);
        final String shortcutName = menuItem.getText();
        menuItem.dragToWorkspace(false, false);
        mLauncher.getWorkspace().getWorkspaceAppIcon(shortcutName).launch(getAppPackageName());
    } finally {
        allApps.unfreeze();
    }
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) AppIconMenuItem(com.android.launcher3.tapl.AppIconMenuItem) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Example 22 with AllApps

use of com.android.launcher3.tapl.AllApps in project android_packages_apps_Trebuchet by LineageOS.

the class TaplTestsLauncher3 method runAllAppsTest.

public static void runAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
    allApps.freeze();
    try {
        assertNotNull("allApps parameter is null", allApps);
        assertTrue("Launcher internal state is not All Apps", test.isInState(() -> LauncherState.ALL_APPS));
        // Test flinging forward and backward.
        test.executeOnLauncher(launcher -> assertEquals("All Apps started in already scrolled state", 0, test.getAllAppsScroll(launcher)));
        allApps.flingForward();
        assertTrue("Launcher internal state is not All Apps", test.isInState(() -> LauncherState.ALL_APPS));
        final Integer flingForwardY = test.getFromLauncher(launcher -> test.getAllAppsScroll(launcher));
        test.executeOnLauncher(launcher -> assertTrue("flingForward() didn't scroll App Apps", flingForwardY > 0));
        allApps.flingBackward();
        assertTrue("Launcher internal state is not All Apps", test.isInState(() -> LauncherState.ALL_APPS));
        final Integer flingBackwardY = test.getFromLauncher(launcher -> test.getAllAppsScroll(launcher));
        test.executeOnLauncher(launcher -> assertTrue("flingBackward() didn't scroll App Apps", flingBackwardY < flingForwardY));
        // Test scrolling down to YouTube.
        assertNotNull("All apps: can't fine YouTube", allApps.getAppIcon("YouTube"));
        // Test scrolling up to Camera.
        assertNotNull("All apps: can't fine Camera", allApps.getAppIcon("Camera"));
        // Test failing to find a non-existing app.
        final AllApps allAppsFinal = allApps;
        expectFail("All apps: could find a non-existing app", () -> allAppsFinal.getAppIcon("NO APP"));
        assertTrue("Launcher internal state is not All Apps", test.isInState(() -> LauncherState.ALL_APPS));
    } finally {
        allApps.unfreeze();
    }
}
Also used : AllApps(com.android.launcher3.tapl.AllApps)

Example 23 with AllApps

use of com.android.launcher3.tapl.AllApps in project android_packages_apps_Trebuchet by LineageOS.

the class CellLayout method commitTempPlacement.

private void commitTempPlacement() {
    mTmpOccupied.copyTo(mOccupied);
    int screenId = Launcher.cast(mActivity).getWorkspace().getIdForScreen(this);
    int container = Favorites.CONTAINER_DESKTOP;
    if (mContainerType == HOTSEAT) {
        screenId = -1;
        container = Favorites.CONTAINER_HOTSEAT;
    }
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        ItemInfo info = (ItemInfo) child.getTag();
        // AllApps button in the hotseat.
        if (info != null) {
            final boolean requiresDbUpdate = (info.cellX != lp.tmpCellX || info.cellY != lp.tmpCellY || info.spanX != lp.cellHSpan || info.spanY != lp.cellVSpan);
            info.cellX = lp.cellX = lp.tmpCellX;
            info.cellY = lp.cellY = lp.tmpCellY;
            info.spanX = lp.cellHSpan;
            info.spanY = lp.cellVSpan;
            if (requiresDbUpdate) {
                Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container, screenId, info.cellX, info.cellY, info.spanX, info.spanY);
            }
        }
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) DraggableView(com.android.launcher3.dragndrop.DraggableView) View(android.view.View) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 24 with AllApps

use of com.android.launcher3.tapl.AllApps in project android_packages_apps_Trebuchet by LineageOS.

the class TaplTestsQuickstep method testAppIconLaunchFromAllAppsFromOverview.

@Test
public void testAppIconLaunchFromAllAppsFromOverview() throws Exception {
    if (!mLauncher.hasAllAppsInOverview()) {
        return;
    }
    final AllApps allApps = mLauncher.getWorkspace().switchToOverview().switchToAllApps();
    assertTrue("Launcher internal state is not All Apps", isInState(() -> LauncherState.ALL_APPS));
    TaplTestsLauncher3.runIconLaunchFromAllAppsTest(this, allApps);
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 25 with AllApps

use of com.android.launcher3.tapl.AllApps in project Neo-Launcher by NeoApplications.

the class CellLayout method commitTempPlacement.

private void commitTempPlacement() {
    mTmpOccupied.copyTo(mOccupied);
    int screenId = Launcher.cast(mActivity).getWorkspace().getIdForScreen(this);
    int container = Favorites.CONTAINER_DESKTOP;
    if (mContainerType == HOTSEAT) {
        screenId = -1;
        container = Favorites.CONTAINER_HOTSEAT;
    }
    int childCount = mShortcutsAndWidgets.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mShortcutsAndWidgets.getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        ItemInfo info = (ItemInfo) child.getTag();
        // AllApps button in the hotseat.
        if (info != null) {
            final boolean requiresDbUpdate = (info.cellX != lp.tmpCellX || info.cellY != lp.tmpCellY || info.spanX != lp.cellHSpan || info.spanY != lp.cellVSpan);
            info.cellX = lp.cellX = lp.tmpCellX;
            info.cellY = lp.cellY = lp.tmpCellY;
            info.spanX = lp.cellHSpan;
            info.spanY = lp.cellVSpan;
            if (requiresDbUpdate) {
                Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container, screenId, info.cellX, info.cellY, info.spanX, info.spanY);
            }
        }
    }
}
Also used : View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Aggregations

AllApps (com.android.launcher3.tapl.AllApps)58 Test (org.junit.Test)52 LargeTest (androidx.test.filters.LargeTest)48 ItemInfo (com.android.launcher3.model.data.ItemInfo)17 AppIconMenu (com.android.launcher3.tapl.AppIconMenu)12 AppIconMenuItem (com.android.launcher3.tapl.AppIconMenuItem)12 View (android.view.View)11 AppIcon (com.android.launcher3.tapl.AppIcon)11 Ignore (org.junit.Ignore)10 SuppressLint (android.annotation.SuppressLint)7 Paint (android.graphics.Paint)7 Point (android.graphics.Point)7 Callbacks (com.android.launcher3.model.BgDataModel.Callbacks)7 LoaderResults (com.android.launcher3.model.LoaderResults)7 AllAppsList (com.android.launcher3.model.AllAppsList)6 BgDataModel (com.android.launcher3.model.BgDataModel)6 AppInfo (com.android.launcher3.model.data.AppInfo)6 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)6 BufferedReader (java.io.BufferedReader)6 InputStreamReader (java.io.InputStreamReader)6