summaryrefslogtreecommitdiffstats
path: root/test-runner
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
commitd24b8183b93e781080b2c16c487e60d51c12da31 (patch)
treefbb89154858984eb8e41556da7e9433040d55cd4 /test-runner
parentf1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff)
downloadframeworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.zip
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.gz
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.bz2
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'test-runner')
-rw-r--r--test-runner/android/test/InstrumentationTestRunner.java33
-rw-r--r--test-runner/android/test/TouchUtils.java24
-rw-r--r--test-runner/android/test/mock/MockPackageManager.java10
3 files changed, 52 insertions, 15 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
}
}
-
diff --git a/test-runner/android/test/TouchUtils.java b/test-runner/android/test/TouchUtils.java
index c4bca41..52d2ee8 100644
--- a/test-runner/android/test/TouchUtils.java
+++ b/test-runner/android/test/TouchUtils.java
@@ -73,7 +73,7 @@ public class TouchUtils {
*/
@Deprecated
public static void dragQuarterScreenUp(ActivityInstrumentationTestCase test) {
- dragQuarterScreenDown(test, test.getActivity());
+ dragQuarterScreenUp(test, test.getActivity());
}
/**
@@ -269,9 +269,9 @@ public class TouchUtils {
inst.waitForIdleSync();
eventTime = SystemClock.uptimeMillis();
- event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
- x + (ViewConfiguration.getTouchSlop() / 2.0f),
- y + (ViewConfiguration.getTouchSlop() / 2.0f), 0);
+ final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
+ event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
+ x + (touchSlop / 2.0f), y + (touchSlop / 2.0f), 0);
inst.sendPointerSync(event);
inst.waitForIdleSync();
@@ -309,9 +309,9 @@ public class TouchUtils {
inst.waitForIdleSync();
eventTime = SystemClock.uptimeMillis();
+ final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_CANCEL,
- x + (ViewConfiguration.getTouchSlop() / 2.0f),
- y + (ViewConfiguration.getTouchSlop() / 2.0f), 0);
+ x + (touchSlop / 2.0f), y + (touchSlop / 2.0f), 0);
inst.sendPointerSync(event);
inst.waitForIdleSync();
@@ -345,9 +345,9 @@ public class TouchUtils {
eventTime = SystemClock.uptimeMillis();
- event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
- x + (ViewConfiguration.getTouchSlop() / 2.0f),
- y + (ViewConfiguration.getTouchSlop() / 2.0f), 0);
+ final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
+ event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
+ x + (touchSlop / 2.0f), y + (touchSlop / 2.0f), 0);
inst.sendPointerSync(event);
inst.waitForIdleSync();
@@ -405,9 +405,9 @@ public class TouchUtils {
inst.waitForIdleSync();
eventTime = SystemClock.uptimeMillis();
- event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
- x + ViewConfiguration.getTouchSlop() / 2,
- y + ViewConfiguration.getTouchSlop() / 2, 0);
+ final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
+ event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
+ x + touchSlop / 2, y + touchSlop / 2, 0);
inst.sendPointerSync(event);
inst.waitForIdleSync();
diff --git a/test-runner/android/test/mock/MockPackageManager.java b/test-runner/android/test/mock/MockPackageManager.java
index f131bf2..57e7e41 100644
--- a/test-runner/android/test/mock/MockPackageManager.java
+++ b/test-runner/android/test/mock/MockPackageManager.java
@@ -393,4 +393,14 @@ public class MockPackageManager extends PackageManager {
List<ComponentName> outActivities, String packageName) {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public String[] getSystemSharedLibraryNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isSafeMode() {
+ throw new UnsupportedOperationException();
+ }
}