Search in sources :

Example 1 with AllApps

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

the class LauncherModel method startLoader.

/**
 * Starts the loader. Tries to bind {@params synchronousBindPage} synchronously if possible.
 * @return true if the page could be bound synchronously.
 */
public boolean startLoader() {
    // Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
    ItemInstallQueue.INSTANCE.get(mApp.getContext()).pauseModelPush(ItemInstallQueue.FLAG_LOADER_RUNNING);
    synchronized (mLock) {
        // Don't bother to start the thread if we know it's not going to do anything
        final Callbacks[] callbacksList = getCallbacks();
        if (callbacksList.length > 0) {
            // Clear any pending bind-runnables from the synchronized load process.
            for (Callbacks cb : callbacksList) {
                MAIN_EXECUTOR.execute(cb::clearPendingBinds);
            }
            // If there is already one running, tell it to stop.
            stopLoader();
            LoaderResults loaderResults = new LoaderResults(mApp, mBgDataModel, mBgAllAppsList, callbacksList);
            if (mModelLoaded && !mIsLoaderTaskRunning) {
                // Divide the set of loaded items into those that we are binding synchronously,
                // and everything else that is to be bound normally (asynchronously).
                loaderResults.bindWorkspace();
                // For now, continue posting the binding of AllApps as there are other
                // issues that arise from that.
                loaderResults.bindAllApps();
                loaderResults.bindDeepShortcuts();
                loaderResults.bindWidgets();
                return true;
            } else {
                stopLoader();
                mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, mBgDataModel, mModelDelegate, loaderResults);
                // Always post the loader task, instead of running directly
                // (even on same thread) so that we exit any nested synchronized blocks
                MODEL_EXECUTOR.post(mLoaderTask);
            }
        }
    }
    return false;
}
Also used : Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) LoaderTask(com.android.launcher3.model.LoaderTask) LoaderResults(com.android.launcher3.model.LoaderResults)

Example 2 with AllApps

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

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) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 3 with AllApps

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

the class TaplTestsQuickstep method testOverview.

@Test
@PortraitLandscape
public void testOverview() throws Exception {
    startTestAppsWithCheck();
    // mLauncher.pressHome() also tests an important case of pressing home while in background.
    Overview overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Don't have at least 3 tasks", getTaskCount(launcher) >= 3));
    // Test flinging forward and backward.
    executeOnLauncher(launcher -> assertEquals("Current task in Overview is not 0", 0, getCurrentOverviewPage(launcher)));
    overview.flingForward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer currentTaskAfterFlingForward = getFromLauncher(launcher -> getCurrentOverviewPage(launcher));
    executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0", currentTaskAfterFlingForward > 0));
    overview.flingBackward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Flinging back in Overview did nothing", getCurrentOverviewPage(launcher) < currentTaskAfterFlingForward));
    // Test opening a task.
    OverviewTask task = mLauncher.pressHome().switchToOverview().getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (1)", task);
    assertNotNull("OverviewTask.open returned null", task.open());
    assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT));
    executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the top " + "one", isInBackground(launcher)));
    // Test dismissing a task.
    overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer numTasks = getFromLauncher(launcher -> getTaskCount(launcher));
    task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (2)", task);
    task.dismiss();
    executeOnLauncher(launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview", numTasks - 1, getTaskCount(launcher)));
    // Test UIDevice.pressHome, once we are in AllApps.
    mDevice.pressHome();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    // Test dismissing all tasks.
    mLauncher.getWorkspace().switchToOverview().dismissAllTasks();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    executeOnLauncher(launcher -> assertEquals("Still have tasks after dismissing all", 0, getTaskCount(launcher)));
}
Also used : OverviewTask(com.android.launcher3.tapl.OverviewTask) Overview(com.android.launcher3.tapl.Overview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 4 with AllApps

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

the class LauncherModelHelper method initializeData.

/**
 * Initializes mock data for the test.
 */
public void initializeData(String resourceName) throws Exception {
    Context targetContext = RuntimeEnvironment.application;
    BgDataModel bgDataModel = getBgDataModel();
    AllAppsList allAppsList = getAllAppsList();
    MODEL_EXECUTOR.submit(() -> {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream(resourceName)))) {
            String line;
            HashMap<String, Class> classMap = new HashMap<>();
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.startsWith("#") || line.isEmpty()) {
                    continue;
                }
                String[] commands = line.split(" ");
                switch(commands[0]) {
                    case "classMap":
                        classMap.put(commands[1], Class.forName(commands[2]));
                        break;
                    case "bgItem":
                        bgDataModel.addItem(targetContext, (ItemInfo) initItem(classMap.get(commands[1]), commands, 2), false);
                        break;
                    case "allApps":
                        allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1), null);
                        break;
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }).get();
}
Also used : Context(android.content.Context) InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) ItemInfo(com.android.launcher3.model.data.ItemInfo) BgDataModel(com.android.launcher3.model.BgDataModel) AllAppsList(com.android.launcher3.model.AllAppsList) BufferedReader(java.io.BufferedReader) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ExecutionException(java.util.concurrent.ExecutionException) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 5 with AllApps

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

the class TaplTestsLauncher3 method testPressHomeOnAllAppsContextMenu.

@Test
public void testPressHomeOnAllAppsContextMenu() throws Exception {
    final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
    allApps.freeze();
    try {
        allApps.getAppIcon("TestActivity7").openMenu();
    } finally {
        allApps.unfreeze();
    }
    mLauncher.pressHome();
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

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