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

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

Merge "Creating UI tests for overview action buttons." into ub-launcher3-rvc-qpr-dev

parents 073673e1 bf103f16
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -58,6 +58,12 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
                        FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get());
                return response;
            }

            case TestProtocol.REQUEST_OVERVIEW_SHARE_ENABLED: {
                response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
                        FeatureFlags.ENABLE_OVERVIEW_SHARE.get());
                return response;
            }
        }

        return super.call(method);
+22 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.launcher3.tapl.AllAppsFromOverview;
import com.android.launcher3.tapl.Background;
import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel;
import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.OverviewActions;
import com.android.launcher3.tapl.OverviewTask;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.ui.TaplTestsLauncher3;
@@ -68,11 +69,14 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        });
    }

    private void startTestApps() throws Exception {
    public static void startTestApps() throws Exception {
        startAppFast(getAppPackageName());
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        startTestActivity(2);
    }

    private void startTestAppsWithCheck() throws Exception {
        startTestApps();
        executeOnLauncher(launcher -> assertTrue(
                "Launcher activity is the top activity; expecting another activity to be the top "
                        + "one",
@@ -105,7 +109,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
    @Test
    @PortraitLandscape
    public void testOverview() throws Exception {
        startTestApps();
        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",
@@ -189,6 +193,22 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
                        0, getTaskCount(launcher)));
    }

    /**
     * Smoke test for action buttons: Presses all the buttons and makes sure no crashes occur.
     */
    @Test
    @NavigationModeSwitch
    @PortraitLandscape
    public void testOverviewActions() throws Exception {
        if (mLauncher.getNavigationModel() != NavigationModel.TWO_BUTTON) {
            startTestAppsWithCheck();
            OverviewActions actionsView =
                    mLauncher.pressHome().switchToOverview().getOverviewActions();
            actionsView.clickAndDismissScreenshot();
            actionsView.clickAndDismissShare();
        }
    }

    private int getCurrentOverviewPage(Launcher launcher) {
        return launcher.<RecentsView>getOverviewPanel().getCurrentPage();
    }
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ public final class TestProtocol {
    public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing";

    public static final String REQUEST_OVERVIEW_ACTIONS_ENABLED = "overview-actions-enabled";
    public static final String REQUEST_OVERVIEW_SHARE_ENABLED = "overview-share-enabled";

    public static boolean sDisableSensorRotation;
    public static final String REQUEST_MOCK_SENSOR_ROTATION = "mock-sensor-rotation";
+16 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import java.util.Collections;
import java.util.List;

/**
 * Common overview pane for both Launcher and fallback recents
 * Common overview panel for both Launcher and fallback recents
 */
public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
    private static final int FLINGS_FOR_DISMISS_LIMIT = 40;
@@ -135,4 +135,19 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
    public boolean hasTasks() {
        return getTasks().size() > 0;
    }

    /**
     * Gets Overview Actions.
     *
     * @return The Overview Actions
     */
    @NonNull
    public OverviewActions getOverviewActions() {
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to get overview actions")) {
            verifyActiveContainer();
            UiObject2 overviewActions = mLauncher.waitForLauncherObject("action_buttons");
            return new OverviewActions(overviewActions, mLauncher);
        }
    }
}
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ public final class LauncherInstrumentation {
    private static final String CONTEXT_MENU_RES_ID = "deep_shortcuts_container";
    public static final int WAIT_TIME_MS = 10000;
    private static final String SYSTEMUI_PACKAGE = "com.android.systemui";
    private static final String ANDROID_PACKAGE = "android";

    private static WeakReference<VisibleContainer> sActiveContainer = new WeakReference<>(null);

@@ -926,6 +927,14 @@ public final class LauncherInstrumentation {
        return waitForObjectBySelector(getOverviewObjectSelector(resName));
    }

    @NonNull
    UiObject2 waitForAndroidObject(String resId) {
        final UiObject2 object = mDevice.wait(
                Until.findObject(By.res(ANDROID_PACKAGE, resId)), WAIT_TIME_MS);
        assertNotNull("Can't find a android object with id: " + resId, object);
        return object;
    }

    private UiObject2 waitForObjectBySelector(BySelector selector) {
        final UiObject2 object = mDevice.wait(Until.findObject(selector), WAIT_TIME_MS);
        assertNotNull("Can't find a view in Launcher, selector: " + selector, object);
@@ -1302,6 +1311,11 @@ public final class LauncherInstrumentation {
                TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    boolean overviewShareEnabled() {
        return getTestInfo(TestProtocol.REQUEST_OVERVIEW_SHARE_ENABLED).getBoolean(
                TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    private void disableSensorRotation() {
        getTestInfo(TestProtocol.REQUEST_MOCK_SENSOR_ROTATION);
    }
Loading