From e8a72681163c9eca77608f030a14b1711e469b9d Mon Sep 17 00:00:00 2001 From: vadimt Date: Thu, 27 Jun 2019 11:57:30 -0700 Subject: [PATCH] Tapl: diagnosing anomalies Bug: 133891845 Change-Id: I7e5afbdec580c6659917aa3e9586930d5f55ea51 --- .../tapl/LauncherInstrumentation.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index a7e6336199..40ab90a47e 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -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() {