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

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

Merge "Adding more diags for TAPL actions that change Launcher state" into sc-dev

parents 0dd7f864 99608847
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -99,12 +99,12 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                                end,
                                gestureScope),
                        event -> TestProtocol.PAUSE_DETECTED_MESSAGE.equals(event.getClassName()),
                        () -> "Pause wasn't detected");
                        () -> "Pause wasn't detected", "swiping and holding");
                mLauncher.runToState(
                        () -> mLauncher.sendPointer(
                                downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end,
                                gestureScope),
                        OVERVIEW_STATE_ORDINAL);
                        OVERVIEW_STATE_ORDINAL, "sending UP event");
                break;
            }

@@ -137,7 +137,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
                mLauncher.runToState(
                        () -> mLauncher.waitForSystemUiObject("recent_apps").click(),
                        OVERVIEW_STATE_ORDINAL);
                        OVERVIEW_STATE_ORDINAL, "clicking Recents button");
                break;
        }
        expectSwitchToOverviewEvents();
@@ -218,7 +218,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                            () -> mLauncher.linearGesture(
                                    startX, startY, endX, endY, 20, false, gestureScope),
                            event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                            () -> "Quick switch gesture didn't change window state");
                            () -> "Quick switch gesture didn't change window state", "swiping");
                    break;
                }

@@ -226,13 +226,15 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                    // Double press the recents button.
                    UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps");
                    mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
                    mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL);
                    mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL,
                            "clicking Recents button for the first time");
                    mLauncher.getOverview();
                    mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
                    mLauncher.executeAndWaitForEvent(
                            () -> recentsButton.click(),
                            event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                            () -> "Pressing recents button didn't change window state");
                            () -> "Pressing recents button didn't change window state",
                            "clicking Recents button for the second time");
                    break;
            }
            mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT);
+18 −20
Original line number Diff line number Diff line
@@ -56,8 +56,6 @@ abstract class Launchable {
    protected abstract String launchableType();

    private Background launch(BySelector selector) {
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "clicking " + launchableType())) {
        LauncherInstrumentation.log("Launchable.launch before click "
                + mObject.getVisibleCenter() + " in " + mLauncher.getVisibleBounds(mObject));
        final String label = mObject.getText();
@@ -68,7 +66,8 @@ abstract class Launchable {
                    expectActivityStartEvents();
                },
                event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                    () -> "Launching an app didn't open a new window: " + label);
                () -> "Launching an app didn't open a new window: " + label,
                "clicking " + launchableType());

        mLauncher.assertTrue(
                "App didn't start: " + label + " (" + selector + ")",
@@ -76,7 +75,6 @@ abstract class Launchable {
                        LauncherInstrumentation.WAIT_TIME_MS));
        return new Background(mLauncher);
    }
    }

    /**
     * Drags an object to the center of homescreen.
+45 −41
Original line number Diff line number Diff line
@@ -655,15 +655,18 @@ public final class LauncherInstrumentation {
    }

    Parcelable executeAndWaitForLauncherEvent(Runnable command,
            UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message) {
            UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message,
            String actionName) {
        return executeAndWaitForEvent(
                command,
                e -> mLauncherPackage.equals(e.getPackageName()) && eventFilter.accept(e),
                message);
                message, actionName);
    }

    Parcelable executeAndWaitForEvent(Runnable command,
            UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message) {
            UiAutomation.AccessibilityEventFilter eventFilter, Supplier<String> message,
            String actionName) {
        try (LauncherInstrumentation.Closable c = addContextLayer(actionName)) {
            try {
                final AccessibilityEvent event =
                        mInstrumentation.getUiAutomation().executeAndWaitForEvent(
@@ -677,6 +680,7 @@ public final class LauncherInstrumentation {
                return null;
            }
        }
    }

    /**
     * Presses nav bar home button.
@@ -720,7 +724,6 @@ public final class LauncherInstrumentation {
                    dumpViewHierarchy();
                    action = "swiping up to home";

                    try (LauncherInstrumentation.Closable c = addContextLayer(action)) {
                    swipeToState(
                            displaySize.x / 2, displaySize.y - 1,
                            displaySize.x / 2, 0,
@@ -729,12 +732,10 @@ public final class LauncherInstrumentation {
                                    ? GestureScope.INSIDE_TO_OUTSIDE
                                    : GestureScope.OUTSIDE_WITH_PILFER);
                }
                }
            } else {
                log("Hierarchy before clicking home:");
                dumpViewHierarchy();
                action = "clicking home button";
                try (LauncherInstrumentation.Closable c = addContextLayer(action)) {
                if (!isLauncher3() && getNavigationModel() == NavigationModel.TWO_BUTTON) {
                    expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_DOWN_TIS);
                    expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS);
@@ -745,8 +746,8 @@ public final class LauncherInstrumentation {
                        NORMAL_STATE_ORDINAL,
                        !hasLauncherObject(WORKSPACE_RES_ID)
                                && (hasLauncherObject(APPS_RES_ID)
                                    || hasLauncherObject(OVERVIEW_RES_ID)));
                }
                                || hasLauncherObject(OVERVIEW_RES_ID)),
                        action);
            }
            try (LauncherInstrumentation.Closable c = addContextLayer(
                    "performed action to switch to Home - " + action)) {
@@ -1032,22 +1033,23 @@ public final class LauncherInstrumentation {
                + "]";
    }

    void runToState(Runnable command, int expectedState, boolean requireEvent) {
    void runToState(Runnable command, int expectedState, boolean requireEvent, String actionName) {
        if (requireEvent) {
            runToState(command, expectedState);
            runToState(command, expectedState, actionName);
        } else {
            command.run();
        }
    }

    void runToState(Runnable command, int expectedState) {
    void runToState(Runnable command, int expectedState, String actionName) {
        final List<Integer> actualEvents = new ArrayList<>();
        executeAndWaitForLauncherEvent(
                command,
                event -> isSwitchToStateEvent(event, expectedState, actualEvents),
                () -> "Failed to receive an event for the state change: expected ["
                        + TestProtocol.stateOrdinalToString(expectedState)
                        + "], actual: " + eventListToString(actualEvents));
                        + "], actual: " + eventListToString(actualEvents),
                        actionName);
    }

    private boolean isSwitchToStateEvent(
@@ -1064,7 +1066,8 @@ public final class LauncherInstrumentation {
            GestureScope gestureScope) {
        runToState(
                () -> linearGesture(startX, startY, endX, endY, steps, false, gestureScope),
                expectedState);
                expectedState,
                "swiping");
    }

    private int getBottomGestureSize() {
@@ -1172,7 +1175,8 @@ public final class LauncherInstrumentation {
                        startX, startY, endX, endY, steps, slowDown, GestureScope.INSIDE),
                event -> TestProtocol.SCROLL_FINISHED_MESSAGE.equals(event.getClassName()),
                () -> "Didn't receive a scroll end message: " + startX + ", " + startY
                        + ", " + endX + ", " + endY);
                        + ", " + endX + ", " + endY,
                        "scrolling");
    }

    // Inject a swipe gesture. Inject exactly 'steps' motion points, incrementing event time by a
+7 −9
Original line number Diff line number Diff line
@@ -71,15 +71,13 @@ public final class OverviewTask {
    public Background open() {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
            verifyActiveContainer();
            try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                    "clicking an overview task")) {
            mLauncher.executeAndWaitForEvent(
                    () -> mLauncher.clickLauncherObject(mTask),
                    event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                    () -> "Launching task didn't open a new window: "
                                + mTask.getParent().getContentDescription());
                            + mTask.getParent().getContentDescription(),
                    "clicking an overview task");
            mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT);
            }
            return new Background(mLauncher);
        }
    }
+4 −2
Original line number Diff line number Diff line
@@ -190,13 +190,15 @@ public final class Workspace extends Home {
                    launcher.movePointer(launchableCenter, dest, 10, downTime, true,
                            LauncherInstrumentation.GestureScope.INSIDE);
                },
                SPRING_LOADED_STATE_ORDINAL);
                SPRING_LOADED_STATE_ORDINAL,
                "long-pressing and moving");
        LauncherInstrumentation.log("dragIconToWorkspace: moved pointer");
        launcher.runToState(
                () -> launcher.sendPointer(
                        downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest,
                        LauncherInstrumentation.GestureScope.INSIDE),
                NORMAL_STATE_ORDINAL);
                NORMAL_STATE_ORDINAL,
                "sending UP event");
        if (startsActivity || isWidgetShortcut) {
            launcher.expectEvent(TestProtocol.SEQUENCE_MAIN, LauncherInstrumentation.EVENT_START);
        }