summaryrefslogtreecommitdiffstats
path: root/test-runner/android/test/InstrumentationTestRunner.java
diff options
context:
space:
mode:
Diffstat (limited to 'test-runner/android/test/InstrumentationTestRunner.java')
-rw-r--r--test-runner/android/test/InstrumentationTestRunner.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/test-runner/android/test/InstrumentationTestRunner.java b/test-runner/android/test/InstrumentationTestRunner.java
index 8b8d472..f038612 100644
--- a/test-runner/android/test/InstrumentationTestRunner.java
+++ b/test-runner/android/test/InstrumentationTestRunner.java
@@ -148,6 +148,8 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
public static final String ARGUMENT_TEST_SIZE_PREDICATE = "size";
/** @hide */
public static final String ARGUMENT_INCLUDE_PERF = "perf";
+ /** @hide */
+ public static final String ARGUMENT_DELAY_MSEC = "delay_msec";
private static final String SMALL_SUITE = "small";
private static final String MEDIUM_SUITE = "medium";
@@ -249,6 +251,7 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
private String mPackageOfTests;
private boolean mCoverage;
private String mCoverageFilePath;
+ private int mDelayMsec;
@Override
public void onCreate(Bundle arguments) {
@@ -277,11 +280,18 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
mCoverage = getBooleanArgument(arguments, "coverage");
mCoverageFilePath = arguments.getString("coverageFile");
+
+ try {
+ Object delay = arguments.get(ARGUMENT_DELAY_MSEC); // Accept either string or int
+ if (delay != null) mDelayMsec = Integer.parseInt(delay.toString());
+ } catch (NumberFormatException e) {
+ Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
+ }
}
-
+
TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(),
getTargetContext().getClassLoader());
-
+
if (testSizePredicate != null) {
testSuiteBuilder.addRequirements(testSizePredicate);
}
@@ -600,6 +610,18 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
} else {
mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "");
}
+
+ // The delay_msec parameter is normally used to provide buffers of idle time
+ // for power measurement purposes. To make sure there is a delay before and after
+ // every test in a suite, we delay *after* every test (see endTest below) and also
+ // delay *before* the first test. So, delay test1 delay test2 delay.
+
+ try {
+ if (mTestNum == 1) Thread.sleep(mDelayMsec);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
+
sendStatus(REPORT_VALUE_RESULT_START, mTestResult);
mTestResultCode = 0;
}
@@ -636,10 +658,15 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, ".");
}
sendStatus(mTestResultCode, mTestResult);
+
+ try { // Sleep after every test, if specified
+ Thread.sleep(mDelayMsec);
+ } catch (InterruptedException e) {
+ throw new IllegalStateException(e);
+ }
}
// TODO report the end of the cycle
// TODO report runtime for each test
}
}
-