Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit abdb80a6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding dismiss-all method" into ub-launcher3-master

parents 3663b314 8ac8d291
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
<com.android.quickstep.views.ClearAllButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="@android:style/Widget.DeviceDefault.Button.Borderless"
    android:id="@+id/clear_all"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/recents_clear_all"
+7 −0
Original line number Diff line number Diff line
@@ -176,6 +176,13 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        // 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)));
    }

    private int getCurrentOverviewPage(Launcher launcher) {
+18 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.launcher3.tapl;

import androidx.annotation.NonNull;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;

@@ -28,6 +29,7 @@ import java.util.List;
 */
public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
    private static final int DEFAULT_FLING_SPEED = 15000;
    private static final int FLINGS_FOR_DISMISS_LIMIT = 5;

    BaseOverview(LauncherInstrumentation launcher) {
        super(launcher);
@@ -49,6 +51,22 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
        verifyActiveContainer();
    }

    /**
     * Dismissed all tasks by scrolling to Clear-all button and pressing it.
     */
    public Workspace dismissAllTasks() {
        final BySelector clearAllSelector = mLauncher.getLauncherObjectSelector("clear_all");
        for (int i = 0;
                i < FLINGS_FOR_DISMISS_LIMIT
                        && verifyActiveContainer().findObject(clearAllSelector) == null;
                ++i) {
            flingForward();
        }

        mLauncher.getObjectInContainer(verifyActiveContainer(), clearAllSelector).click();
        return new Workspace(mLauncher);
    }

    /**
     * Flings backward (right) and waits the fling's end.
     */