Change --screenshot-on-ui-failure to --screenshot-on-failure
Change-Id: I406b748ae4e5daeb889408f5a23bc23c4fcfc6bf
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index 27f7c21..c6977e5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -150,9 +150,9 @@
"Interval between each reboot in min.")
private int mRebootIntervalMin = 30;
- @Option(name = "screenshot-on-ui-failure", description =
- "take a screenshot if a test fails with a message indicating a UI obstruction.")
- private boolean mScreenshotOnUiFailures = false;
+ @Option(name = "screenshot-on-failure", description =
+ "take a screenshot on every test failure.")
+ private boolean mScreenshotOnFailures = false;
@Option(name = "logcat-on-failure", description =
"take a logcat snapshot on every test failure. Unlike --bugreport, this can capture" +
@@ -249,13 +249,12 @@
}
/**
- * A {@link ResultForwarder} that will forward a screenshot when it detects a failed test due
- * to a UI obstruction.
+ * A {@link ResultForwarder} that will forward a screenshot on test failures.
*/
- private static class FailedUiTestScreenshotGenerator extends ResultForwarder {
+ private static class FailedTestScreenshotGenerator extends ResultForwarder {
private ITestDevice mDevice;
- public FailedUiTestScreenshotGenerator(ITestInvocationListener listener,
+ public FailedTestScreenshotGenerator(ITestInvocationListener listener,
ITestDevice device) {
super(listener);
mDevice = device;
@@ -265,18 +264,15 @@
public void testFailed(TestFailure status, TestIdentifier test, String trace) {
super.testFailed(status, test, trace);
- if (trace.contains(
- "Injecting to another application requires INJECT_EVENTS permission")) {
- try {
- InputStreamSource screenSource = mDevice.getScreenshot();
- super.testLog(String.format("screenshot-%s_%s", test.getClassName(),
- test.getTestName()), LogDataType.PNG, screenSource);
- screenSource.cancel();
- } catch (DeviceNotAvailableException e) {
- // TODO: rethrow this somehow
- CLog.e("Device %s became unavailable while capturing screenshot, %s",
- mDevice.getSerialNumber(), e.toString());
- }
+ try {
+ InputStreamSource screenSource = mDevice.getScreenshot();
+ super.testLog(String.format("screenshot-%s_%s", test.getClassName(),
+ test.getTestName()), LogDataType.PNG, screenSource);
+ screenSource.cancel();
+ } catch (DeviceNotAvailableException e) {
+ // TODO: rethrow this somehow
+ CLog.e("Device %s became unavailable while capturing screenshot, %s",
+ mDevice.getSerialNumber(), e.toString());
}
}
}
@@ -412,8 +408,8 @@
getDevice());
listener = bugListener;
}
- if (mScreenshotOnUiFailures) {
- FailedUiTestScreenshotGenerator screenListener = new FailedUiTestScreenshotGenerator(
+ if (mScreenshotOnFailures) {
+ FailedTestScreenshotGenerator screenListener = new FailedTestScreenshotGenerator(
listener, getDevice());
listener = screenListener;
}