aboutsummaryrefslogtreecommitdiffstats
path: root/ddms
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-08-17 10:33:38 -0700
committerSiva Velusamy <vsiva@google.com>2012-08-17 11:22:30 -0700
commitcac3e84c859df84fdb4018078a56470c2699de00 (patch)
tree4e0b8b2b45c4e8c77049e249da09c611734fcaa5 /ddms
parentb8a2851136c91b6c4ff795ac5b0227dbb3b78e58 (diff)
downloadsdk-cac3e84c859df84fdb4018078a56470c2699de00.zip
sdk-cac3e84c859df84fdb4018078a56470c2699de00.tar.gz
sdk-cac3e84c859df84fdb4018078a56470c2699de00.tar.bz2
junit: Rework support for parallel junit launch.
A previous commit (2c57cbea0d663b) introduced support for running Junit tests concurrently on all connected devices. It relied on changing the TestIdentifier to store device information, and having a single listener that listens to test events from all devices. The change to TestIdentifier caused issues with some users of ddmlib in cases where the device info is not available all the time. This patch reverts all the changes in ddmlib, and moves the knowledge of what device tests are being run to the listener layer in ADT. So now we have a per device test listener that knows only about tests run on that device. Change-Id: Iffedcb38cdf21e349fbe38ecf9a654060b469b04
Diffstat (limited to 'ddms')
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/InstrumentationResultParser.java26
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java2
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/TestIdentifier.java36
-rw-r--r--ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/InstrumentationResultParserTest.java2
4 files changed, 8 insertions, 58 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/InstrumentationResultParser.java b/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/InstrumentationResultParser.java
index 2a65699..71f329a 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/InstrumentationResultParser.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/InstrumentationResultParser.java
@@ -146,9 +146,6 @@ public class InstrumentationResultParser extends MultiLineReceiver {
}
}
- /** Device on which this test was run. */
- private final String mDeviceName;
-
/** the name to provide to {@link ITestRunListener#testRunStarted(String, int)} */
private final String mTestRunName;
@@ -218,24 +215,10 @@ public class InstrumentationResultParser extends MultiLineReceiver {
* @param runName the test run name to provide to
* {@link ITestRunListener#testRunStarted(String, int)}
* @param listeners informed of test results as the tests are executing
- * @param deviceName name of the device on which this test is running, null if unknown
*/
- public InstrumentationResultParser(String runName, Collection<ITestRunListener> listeners,
- String deviceName) {
+ public InstrumentationResultParser(String runName, Collection<ITestRunListener> listeners) {
mTestRunName = runName;
mTestListeners = new ArrayList<ITestRunListener>(listeners);
- mDeviceName = deviceName;
- }
-
- /**
- * Creates the InstrumentationResultParser.
- *
- * @param runName the test run name to provide to
- * {@link ITestRunListener#testRunStarted(String, int)}
- * @param listeners informed of test results as the tests are executing
- */
- public InstrumentationResultParser(String runName, Collection<ITestRunListener> listeners) {
- this(runName, listeners, null);
}
/**
@@ -246,7 +229,7 @@ public class InstrumentationResultParser extends MultiLineReceiver {
* @param listener informed of test results as the tests are executing
*/
public InstrumentationResultParser(String runName, ITestRunListener listener) {
- this(runName, Collections.singletonList(listener), null);
+ this(runName, Collections.singletonList(listener));
}
/**
@@ -459,8 +442,7 @@ public class InstrumentationResultParser extends MultiLineReceiver {
return;
}
reportTestRunStarted(testInfo);
- TestIdentifier testId = new TestIdentifier(testInfo.mTestClass, testInfo.mTestName,
- mDeviceName);
+ TestIdentifier testId = new TestIdentifier(testInfo.mTestClass, testInfo.mTestName);
Map<String, String> metrics;
switch (testInfo.mCode) {
@@ -570,7 +552,7 @@ public class InstrumentationResultParser extends MultiLineReceiver {
// received test start msg, but not test complete
// assume test caused this, report as test failure
TestIdentifier testId = new TestIdentifier(mLastTestResult.mTestClass,
- mLastTestResult.mTestName, mDeviceName);
+ mLastTestResult.mTestName);
for (ITestRunListener listener : mTestListeners) {
listener.testFailed(ITestRunListener.TestFailure.ERROR, testId,
String.format("%1$s. Reason: '%2$s'. %3$s", INCOMPLETE_TEST_ERR_MSG_PREFIX,
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java b/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java
index 65ed3c0..124df7d 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java
@@ -256,7 +256,7 @@ public class RemoteAndroidTestRunner implements IRemoteAndroidTestRunner {
Log.i(LOG_TAG, String.format("Running %1$s on %2$s", runCaseCommandStr,
mRemoteDevice.getSerialNumber()));
String runName = mRunName == null ? mPackageName : mRunName;
- mParser = new InstrumentationResultParser(runName, listeners, mRemoteDevice.getName());
+ mParser = new InstrumentationResultParser(runName, listeners);
try {
mRemoteDevice.executeShellCommand(runCaseCommandStr, mParser, mMaxTimeToOutputResponse);
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/TestIdentifier.java b/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/TestIdentifier.java
index 00295e7..7de5736 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/TestIdentifier.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/testrunner/TestIdentifier.java
@@ -23,33 +23,20 @@ public class TestIdentifier {
private final String mClassName;
private final String mTestName;
- private final String mDeviceName;
/**
* Creates a test identifier.
*
* @param className fully qualified class name of the test. Cannot be null.
* @param testName name of the test. Cannot be null.
- * @param deviceName device on which the test was run.
*/
- public TestIdentifier(String className, String testName, String deviceName) {
+ public TestIdentifier(String className, String testName) {
if (className == null || testName == null) {
throw new IllegalArgumentException("className and testName must " +
"be non-null");
}
mClassName = className;
mTestName = testName;
- mDeviceName = deviceName;
- }
-
- /**
- * Creates a test identifier.
- *
- * @param className fully qualified class name of the test. Cannot be null.
- * @param testName name of the test. Cannot be null.
- */
- public TestIdentifier(String className, String testName) {
- this(className, testName, null);
}
/**
@@ -66,19 +53,11 @@ public class TestIdentifier {
return mTestName;
}
- /**
- * Returns the name of the device on which the test was run if available, null otherwise.
- */
- public String getDeviceName() {
- return mDeviceName;
- }
-
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((mClassName == null) ? 0 : mClassName.hashCode());
- result = prime * result + ((mDeviceName == null) ? 0 : mDeviceName.hashCode());
result = prime * result + ((mTestName == null) ? 0 : mTestName.hashCode());
return result;
}
@@ -97,11 +76,6 @@ public class TestIdentifier {
return false;
} else if (!mClassName.equals(other.mClassName))
return false;
- if (mDeviceName == null) {
- if (other.mDeviceName != null)
- return false;
- } else if (!mDeviceName.equals(other.mDeviceName))
- return false;
if (mTestName == null) {
if (other.mTestName != null)
return false;
@@ -112,12 +86,6 @@ public class TestIdentifier {
@Override
public String toString() {
- String deviceName = getDeviceName();
- String name = String.format("%s#%s", getClassName(), getTestName());
- if (deviceName != null) {
- name += String.format(" (%s)", deviceName);
- }
-
- return name;
+ return String.format("%s#%s", getClassName(), getTestName());
}
}
diff --git a/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/InstrumentationResultParserTest.java b/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/InstrumentationResultParserTest.java
index 148f329..478e09e 100644
--- a/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/InstrumentationResultParserTest.java
+++ b/ddms/libs/ddmlib/tests/src/com/android/ddmlib/testrunner/InstrumentationResultParserTest.java
@@ -40,7 +40,7 @@ public class InstrumentationResultParserTest extends TestCase {
private static final String CLASS_NAME = "com.test.FooTest";
private static final String TEST_NAME = "testFoo";
private static final String STACK_TRACE = "java.lang.AssertionFailedException";
- private static final TestIdentifier TEST_ID = new TestIdentifier(CLASS_NAME, TEST_NAME, null);
+ private static final TestIdentifier TEST_ID = new TestIdentifier(CLASS_NAME, TEST_NAME);
/**
* @param name - test name