Loading tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +30 −40 Original line number Diff line number Diff line Loading @@ -168,7 +168,6 @@ public final class LauncherInstrumentation { private static boolean sCheckingEvents; private boolean mCheckEventsForSuccessfulGestures = false; private int mExpectedPid; private Runnable mOnLauncherCrashed; private static Pattern getTouchEventPattern(String prefix, String action) { Loading Loading @@ -360,33 +359,12 @@ public final class LauncherInstrumentation { return null; } private String getAnomalyMessage() { if (mExpectedPid != 0 && mExpectedPid != getPid()) { mExpectedPid = 0; if (mOnLauncherCrashed != null) mOnLauncherCrashed.run(); return "Launcher crashed"; } public void checkForAnomaly() { final String systemAnomalyMessage = getSystemAnomalyMessage(); if (systemAnomalyMessage != null) { return "http://go/tapl : Tests are broken by a non-Launcher system error: " + systemAnomalyMessage; } return null; } public void checkForAnomaly() { final String anomalyMessage = getAnomalyMessage(); if (anomalyMessage != null) { if (sCheckingEvents) { sCheckingEvents = false; sEventChecker.finishNoWait(); } log("Hierarchy dump for: " + anomalyMessage); dumpViewHierarchy(); Assert.fail(formatSystemHealthMessage(anomalyMessage)); Assert.fail(formatSystemHealthMessage(closeEvents( "http://go/tapl : Tests are broken by a non-Launcher system error: " + systemAnomalyMessage, false))); } } Loading Loading @@ -446,23 +424,29 @@ public final class LauncherInstrumentation { return message; } private void fail(String message) { checkForAnomaly(); message = "http://go/tapl : " + getContextDescription() + message + " (visible state: " + getVisibleStateMessage() + ")"; log("Hierarchy dump for: " + message); dumpViewHierarchy(); private String closeEvents(String message, boolean checkEvents) { if (sCheckingEvents) { sCheckingEvents = false; if (checkEvents) { final String eventMismatch = sEventChecker.verify(0); if (eventMismatch != null) { message = message + ", having produced " + eventMismatch; } } else { sEventChecker.finishNoWait(); } } log("Hierarchy dump for: " + message); dumpViewHierarchy(); Assert.fail(formatSystemHealthMessage(message)); return message; } private void fail(String message) { checkForAnomaly(); Assert.fail(formatSystemHealthMessage(closeEvents( "http://go/tapl : " + getContextDescription() + message + " (visible state: " + getVisibleStateMessage() + ")", true))); } private String getContextDescription() { Loading Loading @@ -1300,18 +1284,24 @@ public final class LauncherInstrumentation { Assert.assertTrue("Nested event checking", !sCheckingEvents); disableSensorRotation(); sCheckingEvents = true; mExpectedPid = getPid(); final int initialPid = getPid(); if (sEventChecker == null) sEventChecker = new LogEventChecker(); sEventChecker.start(); return () -> { if (initialPid != getPid()) { if (mOnLauncherCrashed != null) mOnLauncherCrashed.run(); checkForAnomaly(); Assert.fail( formatSystemHealthMessage(closeEvents("Launcher crashed", false))); } if (sCheckingEvents) { sCheckingEvents = false; if (mCheckEventsForSuccessfulGestures) { final String message = sEventChecker.verify(WAIT_TIME_MS); if (message != null) { checkForAnomaly(); Assert.fail(formatSystemHealthMessage( "http://go/tapl : successful gesture produced " + message)); } Loading Loading
tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +30 −40 Original line number Diff line number Diff line Loading @@ -168,7 +168,6 @@ public final class LauncherInstrumentation { private static boolean sCheckingEvents; private boolean mCheckEventsForSuccessfulGestures = false; private int mExpectedPid; private Runnable mOnLauncherCrashed; private static Pattern getTouchEventPattern(String prefix, String action) { Loading Loading @@ -360,33 +359,12 @@ public final class LauncherInstrumentation { return null; } private String getAnomalyMessage() { if (mExpectedPid != 0 && mExpectedPid != getPid()) { mExpectedPid = 0; if (mOnLauncherCrashed != null) mOnLauncherCrashed.run(); return "Launcher crashed"; } public void checkForAnomaly() { final String systemAnomalyMessage = getSystemAnomalyMessage(); if (systemAnomalyMessage != null) { return "http://go/tapl : Tests are broken by a non-Launcher system error: " + systemAnomalyMessage; } return null; } public void checkForAnomaly() { final String anomalyMessage = getAnomalyMessage(); if (anomalyMessage != null) { if (sCheckingEvents) { sCheckingEvents = false; sEventChecker.finishNoWait(); } log("Hierarchy dump for: " + anomalyMessage); dumpViewHierarchy(); Assert.fail(formatSystemHealthMessage(anomalyMessage)); Assert.fail(formatSystemHealthMessage(closeEvents( "http://go/tapl : Tests are broken by a non-Launcher system error: " + systemAnomalyMessage, false))); } } Loading Loading @@ -446,23 +424,29 @@ public final class LauncherInstrumentation { return message; } private void fail(String message) { checkForAnomaly(); message = "http://go/tapl : " + getContextDescription() + message + " (visible state: " + getVisibleStateMessage() + ")"; log("Hierarchy dump for: " + message); dumpViewHierarchy(); private String closeEvents(String message, boolean checkEvents) { if (sCheckingEvents) { sCheckingEvents = false; if (checkEvents) { final String eventMismatch = sEventChecker.verify(0); if (eventMismatch != null) { message = message + ", having produced " + eventMismatch; } } else { sEventChecker.finishNoWait(); } } log("Hierarchy dump for: " + message); dumpViewHierarchy(); Assert.fail(formatSystemHealthMessage(message)); return message; } private void fail(String message) { checkForAnomaly(); Assert.fail(formatSystemHealthMessage(closeEvents( "http://go/tapl : " + getContextDescription() + message + " (visible state: " + getVisibleStateMessage() + ")", true))); } private String getContextDescription() { Loading Loading @@ -1300,18 +1284,24 @@ public final class LauncherInstrumentation { Assert.assertTrue("Nested event checking", !sCheckingEvents); disableSensorRotation(); sCheckingEvents = true; mExpectedPid = getPid(); final int initialPid = getPid(); if (sEventChecker == null) sEventChecker = new LogEventChecker(); sEventChecker.start(); return () -> { if (initialPid != getPid()) { if (mOnLauncherCrashed != null) mOnLauncherCrashed.run(); checkForAnomaly(); Assert.fail( formatSystemHealthMessage(closeEvents("Launcher crashed", false))); } if (sCheckingEvents) { sCheckingEvents = false; if (mCheckEventsForSuccessfulGestures) { final String message = sEventChecker.verify(WAIT_TIME_MS); if (message != null) { checkForAnomaly(); Assert.fail(formatSystemHealthMessage( "http://go/tapl : successful gesture produced " + message)); } Loading