summaryrefslogtreecommitdiffstats
path: root/tests/SmokeTest
diff options
context:
space:
mode:
authorOmari Stephens <xsdg@android.com>2012-03-13 21:52:13 -0700
committerOmari Stephens <xsdg@android.com>2012-03-13 21:57:54 -0700
commitad8037e3a9b306bae6cdc8927c35946696bf40f6 (patch)
treede4f50f3c32617b2d47cfccb061cfdce9cce633d /tests/SmokeTest
parent605eabf6a24ab3541de559b242147900b23706ed (diff)
downloadframeworks_base-ad8037e3a9b306bae6cdc8927c35946696bf40f6.zip
frameworks_base-ad8037e3a9b306bae6cdc8927c35946696bf40f6.tar.gz
frameworks_base-ad8037e3a9b306bae6cdc8927c35946696bf40f6.tar.bz2
Avoid crashes in a single app from causing cascading test failures
This should work properly for crashes. It currently doesn't do the right thing for ANRs since, in a lot of cases, they seem to happen asynchronously _after_ the testcase has ended. Will try to improve that behavior with a subsequent change. Bug: 6128185 Change-Id: Ie535141e879062c11ee7108b37d282a33a5b5eef
Diffstat (limited to 'tests/SmokeTest')
-rw-r--r--tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java26
-rw-r--r--tests/SmokeTest/tests/src/com/android/smoketest/SmokeTestRunner.java4
2 files changed, 23 insertions, 7 deletions
diff --git a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
index 3efd658..b4aa116 100644
--- a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
+++ b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java
@@ -120,13 +120,20 @@ public class ProcessErrorsTest extends AndroidTestCase {
* The method will launch the app, wait for 7 seconds, check for apps in the error state, send
* the Home intent, wait for 2 seconds, and then return.
*/
- public Collection<ProcessErrorStateInfo> runOneActivity(ResolveInfo app) {
+ public Collection<ProcessError> runOneActivity(ResolveInfo app) {
final long appLaunchWait = 7000;
final long homeLaunchWait = 2000;
Log.i(TAG, String.format("Running activity %s/%s", app.activityInfo.packageName,
app.activityInfo.name));
+ // We check for any Crash or ANR dialogs that are already up, and we ignore them. This is
+ // so that we don't report crashes that were caused by prior apps (which those particular
+ // tests should have caught and reported already). Otherwise, test failures would cascade
+ // from the initial broken app to many/all of the tests following that app's launch.
+ final Collection<ProcessError> preErrProcs =
+ ProcessError.fromCollection(mActivityManager.getProcessesInErrorState());
+
// launch app, and wait 7 seconds for it to start/settle
final Intent intent = intentForActivity(app);
getContext().startActivity(intent);
@@ -137,8 +144,13 @@ public class ProcessErrorsTest extends AndroidTestCase {
}
// See if there are any errors
- final Collection<ProcessErrorStateInfo> errProcs =
- mActivityManager.getProcessesInErrorState();
+ final Collection<ProcessError> errProcs =
+ ProcessError.fromCollection(mActivityManager.getProcessesInErrorState());
+ // Take the difference between the error processes we see now, and the ones that were
+ // present when we started
+ if (errProcs != null && preErrProcs != null) {
+ errProcs.removeAll(preErrProcs);
+ }
// Send the "home" intent and wait 2 seconds for us to get there
getContext().startActivity(mHomeIntent);
@@ -162,9 +174,9 @@ public class ProcessErrorsTest extends AndroidTestCase {
final Set<ProcessError> errSet = new HashSet<ProcessError>();
for (ResolveInfo app : getLauncherActivities(mPackageManager)) {
- final Collection<ProcessErrorStateInfo> errProcs = runOneActivity(app);
+ final Collection<ProcessError> errProcs = runOneActivity(app);
if (errProcs != null) {
- errSet.addAll(ProcessError.fromCollection(errProcs));
+ errSet.addAll(errProcs);
}
}
@@ -231,6 +243,10 @@ public class ProcessErrorsTest extends AndroidTestCase {
public static Collection<ProcessError> fromCollection(Collection<ProcessErrorStateInfo> in)
{
+ if (in == null) {
+ return null;
+ }
+
List<ProcessError> out = new ArrayList<ProcessError>(in.size());
for (ProcessErrorStateInfo info : in) {
out.add(new ProcessError(info));
diff --git a/tests/SmokeTest/tests/src/com/android/smoketest/SmokeTestRunner.java b/tests/SmokeTest/tests/src/com/android/smoketest/SmokeTestRunner.java
index 40b11c5..6ef90d6 100644
--- a/tests/SmokeTest/tests/src/com/android/smoketest/SmokeTestRunner.java
+++ b/tests/SmokeTest/tests/src/com/android/smoketest/SmokeTestRunner.java
@@ -73,9 +73,9 @@ public class SmokeTestRunner extends InstrumentationTestRunner {
@Override
public void runTest() throws Exception {
final Set<ProcessError> errSet = new HashSet<ProcessError>();
- final Collection<ProcessErrorStateInfo> errProcs = runOneActivity(app);
+ final Collection<ProcessError> errProcs = runOneActivity(app);
if (errProcs != null) {
- errSet.addAll(ProcessError.fromCollection(errProcs));
+ errSet.addAll(errProcs);
}
if (!errSet.isEmpty()) {