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

Commit e8a72681 authored by vadimt's avatar vadimt
Browse files

Tapl: diagnosing anomalies

Bug: 133891845
Change-Id: I7e5afbdec580c6659917aa3e9586930d5f55ea51
parent 7926791f
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -263,10 +263,26 @@ public final class LauncherInstrumentation {
        }
    }

    private String getAnomalyMessage() {
        final UiObject2 object = mDevice.findObject(By.res("android", "alertTitle"));
        if (object != null) {
            return "System alert popup is visible: " + object.getText();
        }

        if (!mDevice.hasObject(By.textStartsWith(""))) return "Screen is empty";

        return null;
    }

    private void fail(String message) {
        log("Hierarchy dump for: " + getContextDescription() + message);
        message = "http://go/tapl : " + getContextDescription() + message;

        final String anomaly = getAnomalyMessage();
        if (anomaly != null) message = anomaly + ", which causes:\n" + message;

        log("Hierarchy dump for: " + message);
        dumpViewHierarchy();
        Assert.fail("http://go/tapl : " + getContextDescription() + message);
        Assert.fail(message);
    }

    private String getContextDescription() {