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

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

Merge "Adding diagnostics for failing click-to-home" into ub-launcher3-master

parents c9a907be 44e697b0
Loading
Loading
Loading
Loading
+23 −11
Original line number Original line Diff line number Diff line
@@ -562,7 +562,7 @@ public final class LauncherInstrumentation {
            if (hasLauncherObject(WORKSPACE_RES_ID)) {
            if (hasLauncherObject(WORKSPACE_RES_ID)) {
                log(action = "already at home");
                log(action = "already at home");
            } else {
            } else {
                log("Hierarchy before swiping up to home");
                log("Hierarchy before swiping up to home:");
                dumpViewHierarchy();
                dumpViewHierarchy();
                log(action = "swiping up to home from " + getVisibleStateMessage());
                log(action = "swiping up to home from " + getVisibleStateMessage());


@@ -574,15 +574,19 @@ public final class LauncherInstrumentation {
                }
                }
            }
            }
        } else {
        } else {
            log(action = "clicking home button");
            log("Hierarchy before clicking home:");
            executeAndWaitForEvent(
            dumpViewHierarchy();
                    () -> {
            log(action = "clicking home button from " + getVisibleStateMessage());
                        log("LauncherInstrumentation.pressHome before clicking");
            try (LauncherInstrumentation.Closable c = addContextLayer(action)) {
                        waitForSystemUiObject("home").click();
                    },
                    event -> true,
                    () -> "Pressing Home didn't produce any events");
                mDevice.waitForIdle();
                mDevice.waitForIdle();
                runToState(
                        () -> waitForSystemUiObject("home").click(),
                        NORMAL_STATE_ORDINAL,
                        !hasLauncherObject(WORKSPACE_RES_ID)
                                && (hasLauncherObject(APPS_RES_ID)
                                || hasLauncherObject(OVERVIEW_RES_ID)));
                mDevice.waitForIdle();
            }
        }
        }
        try (LauncherInstrumentation.Closable c = addContextLayer(
        try (LauncherInstrumentation.Closable c = addContextLayer(
                "performed action to switch to Home - " + action)) {
                "performed action to switch to Home - " + action)) {
@@ -786,12 +790,20 @@ public final class LauncherInstrumentation {
                + "]";
                + "]";
    }
    }


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

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