Recognizing another SystemUI failure
Also switching investigator to logs starting with the system reboot, as
SysUI crashes before the tests start.
Change-Id: Ifab835c1ab3c1ce3495f012c6a522fae6e44a9ff
diff --git a/tests/src/com/android/launcher3/util/rule/FailureInvestigator.java b/tests/src/com/android/launcher3/util/rule/FailureInvestigator.java
index be6f865..dcc7b7c 100644
--- a/tests/src/com/android/launcher3/util/rule/FailureInvestigator.java
+++ b/tests/src/com/android/launcher3/util/rule/FailureInvestigator.java
@@ -18,9 +18,13 @@
import static androidx.test.InstrumentationRegistry.getInstrumentation;
+import android.os.SystemClock;
+
import androidx.test.uiautomator.UiDevice;
import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.regex.Pattern;
class FailureInvestigator {
@@ -28,17 +32,21 @@
return Pattern.compile(regex).matcher(string).find();
}
- static int getBugForFailure(CharSequence exception, String testsStartTime) {
+ static int getBugForFailure(CharSequence exception) {
if ("com.google.android.setupwizard".equals(
UiDevice.getInstance(getInstrumentation()).getLauncherPackageName())) {
return 145935261;
}
- final String logSinceTestsStart;
+ final String logSinceBoot;
try {
- logSinceTestsStart =
+ final String systemBootTime =
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(
+ new Date(System.currentTimeMillis() - SystemClock.elapsedRealtime()));
+
+ logSinceBoot =
UiDevice.getInstance(getInstrumentation())
- .executeShellCommand("logcat -d -t " + testsStartTime.replace(" ", ""));
+ .executeShellCommand("logcat -d -t " + systemBootTime.replace(" ", ""));
} catch (IOException e) {
return 0;
}
@@ -49,19 +57,24 @@
exception)) {
if (matches(
"BroadcastQueue: Can't deliver broadcast to com.android.systemui.*Crashing it",
- logSinceTestsStart)) {
+ logSinceBoot)) {
return 147845913;
}
if (matches(
"Attempt to invoke virtual method 'boolean android\\.graphics\\.Bitmap\\"
+ ".isRecycled\\(\\)' on a null object reference",
- logSinceTestsStart)) {
+ logSinceBoot)) {
return 148424291;
}
+ if (matches(
+ "java\\.lang\\.IllegalArgumentException\\: Ranking map doesn't contain key",
+ logSinceBoot)) {
+ return 148570537;
+ }
} else if (matches("java.lang.AssertionError: Launcher build match not found", exception)) {
if (matches(
"TestStabilityRule: Launcher package: com.google.android.setupwizard",
- logSinceTestsStart)) {
+ logSinceBoot)) {
return 145935261;
}
} else if (matches("Launcher didn't initialize", exception)) {
@@ -69,7 +82,7 @@
"ActivityManager: Reason: executing service com.google.android.apps"
+ ".nexuslauncher/com.android.launcher3.notification"
+ ".NotificationListener",
- logSinceTestsStart)) {
+ logSinceBoot)) {
return 148238677;
}
}
diff --git a/tests/src/com/android/launcher3/util/rule/FailureRewriterRule.java b/tests/src/com/android/launcher3/util/rule/FailureRewriterRule.java
index 4cb309a..99ddee4 100644
--- a/tests/src/com/android/launcher3/util/rule/FailureRewriterRule.java
+++ b/tests/src/com/android/launcher3/util/rule/FailureRewriterRule.java
@@ -22,15 +22,9 @@
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
public class FailureRewriterRule implements TestRule {
private static final String TAG = "FailureRewriter";
- private static final String testsStartTime =
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
-
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@@ -39,8 +33,7 @@
try {
base.evaluate();
} catch (Throwable e) {
- final int bug =
- FailureInvestigator.getBugForFailure(e.toString(), testsStartTime);
+ final int bug = FailureInvestigator.getBugForFailure(e.toString());
if (bug == 0) throw e;
Log.e(TAG, "Known bug found for the original failure "