aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java22
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java74
-rwxr-xr-xeclipse/scripts/build_server.sh4
4 files changed, 77 insertions, 28 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java
index c059a41..a250c76 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditor.java
@@ -505,7 +505,10 @@ public class LayoutEditor extends AndroidEditor implements IShowEditorInput, IPa
IAndroidTarget target = currentSdk.getTarget(project);
if (target != null) {
AndroidTargetData data = currentSdk.getTargetData(target);
- desc = data.getLayoutDescriptors().getBaseViewDescriptor();
+ if (data != null) {
+ // data can be null when the target is still loading
+ desc = data.getLayoutDescriptors().getBaseViewDescriptor();
+ }
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java
index fcb859a..b398a05 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java
@@ -25,6 +25,7 @@ import com.android.ide.eclipse.adt.internal.launch.junit.runtime.RemoteAdtTestRu
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
@@ -33,6 +34,7 @@ import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate;
import org.eclipse.jdt.launching.IVMRunner;
import org.eclipse.jdt.launching.VMRunnerConfiguration;
+import org.eclipse.swt.widgets.Display;
/**
* A launch action that executes a instrumentation test run on an Android device.
@@ -53,6 +55,8 @@ class AndroidJUnitLaunchAction implements IAndroidLaunchAction {
/**
* Launch a instrumentation test run on given Android device.
* Reuses JDT JUnit launch delegate so results can be communicated back to JDT JUnit UI.
+ * <p/>
+ * Note: Must be executed on non-UI thread.
*
* @see IAndroidLaunchAction#doLaunchAction(DelayedLaunchInfo, IDevice)
*/
@@ -137,7 +141,7 @@ class AndroidJUnitLaunchAction implements IAndroidLaunchAction {
}
/**
- * Provides a VM runner implementation which starts a thread implementation of a launch process
+ * Provides a VM runner implementation which starts a inline implementation of a launch process
*/
private static class VMTestRunner implements IVMRunner {
@@ -156,15 +160,15 @@ class AndroidJUnitLaunchAction implements IAndroidLaunchAction {
TestRunnerProcess runnerProcess =
new TestRunnerProcess(config, mJUnitInfo);
- runnerProcess.start();
launch.addProcess(runnerProcess);
+ runnerProcess.run();
}
}
/**
* Launch process that executes the tests.
*/
- private static class TestRunnerProcess extends Thread implements IProcess {
+ private static class TestRunnerProcess implements IProcess {
private final VMRunnerConfiguration mRunConfig;
private final AndroidJUnitLaunchInfo mJUnitInfo;
@@ -254,10 +258,18 @@ class AndroidJUnitLaunchAction implements IAndroidLaunchAction {
}
/**
- * Launches a test runner that will communicate results back to JDT JUnit UI
+ * Launches a test runner that will communicate results back to JDT JUnit UI.
+ * <p/>
+ * Must be executed on a non-UI thread.
*/
- @Override
public void run() {
+ if (Display.getCurrent() != null) {
+ AdtPlugin.log(IStatus.ERROR, "Adt test runner executed on UI thread");
+ AdtPlugin.printErrorToConsole(mJUnitInfo.getProject(),
+ "Test launch failed due to internal error: Running tests on UI thread");
+ terminate();
+ return;
+ }
mTestRunner = new RemoteAdtTestRunner();
mTestRunner.runTests(mRunConfig.getProgramArguments(), mJUnitInfo);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java
index 0a045bc..461fd9d 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java
@@ -33,7 +33,7 @@ import java.io.IOException;
* Supports Eclipse JUnit execution of Android tests.
* <p/>
* Communicates back to a Eclipse JDT JUnit client via a socket connection.
- *
+ *
* @see org.eclipse.jdt.internal.junit.runner.RemoteTestRunner for more details on the protocol
*/
@SuppressWarnings("restriction")
@@ -41,17 +41,17 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
private AndroidJUnitLaunchInfo mLaunchInfo;
private TestExecution mExecution;
-
+
/**
* Initialize the JDT JUnit test runner parameters from the {@code args}.
- *
- * @param args name-value pair of arguments to pass to parent JUnit runner.
+ *
+ * @param args name-value pair of arguments to pass to parent JUnit runner.
* @param launchInfo the Android specific test launch info
*/
protected void init(String[] args, AndroidJUnitLaunchInfo launchInfo) {
defaultInit(args);
mLaunchInfo = launchInfo;
- }
+ }
/**
* Runs a set of tests, and reports back results using parent class.
@@ -65,13 +65,13 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
* <li>The test execution result for each test method. Expects individual notifications of
* the test execution start, any failures, and the end of the test execution.</li>
* <li>The end of the test run, with its elapsed time.</li>
- * </ol>
+ * </ol>
* <p/>
* In order to satisfy this, this method performs two actual Android instrumentation runs.
* The first is a 'log only' run that will collect the test tree data, without actually
* executing the tests, and send it back to JDT JUnit. The second is the actual test execution,
* whose results will be communicated back in real-time to JDT JUnit.
- *
+ *
* @param testClassNames ignored - the AndroidJUnitLaunchInfo will be used to determine which
* tests to run.
* @param testName ignored
@@ -81,16 +81,16 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
public void runTests(String[] testClassNames, String testName, TestExecution execution) {
// hold onto this execution reference so it can be used to report test progress
mExecution = execution;
-
- RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(mLaunchInfo.getAppPackage(),
- mLaunchInfo.getRunner(), mLaunchInfo.getDevice());
+
+ RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(mLaunchInfo.getAppPackage(),
+ mLaunchInfo.getRunner(), mLaunchInfo.getDevice());
if (mLaunchInfo.getTestClass() != null) {
if (mLaunchInfo.getTestMethod() != null) {
runner.setMethodName(mLaunchInfo.getTestClass(), mLaunchInfo.getTestMethod());
- } else {
+ } else {
runner.setClassName(mLaunchInfo.getTestClass());
- }
+ }
}
if (mLaunchInfo.getTestPackage() != null) {
@@ -102,6 +102,8 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
runner.setLogOnly(true);
TestCollector collector = new TestCollector();
try {
+ AdtPlugin.printToConsole(mLaunchInfo.getProject(), "Collecting test information");
+
runner.run(collector);
if (collector.getErrorMessage() != null) {
// error occurred during test collection.
@@ -111,6 +113,9 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
return;
}
notifyTestRunStarted(collector.getTestCaseCount());
+ AdtPlugin.printToConsole(mLaunchInfo.getProject(),
+ "Sending test information to Eclipse");
+
collector.sendTrees(this);
// now do real execution
@@ -118,23 +123,24 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
if (mLaunchInfo.isDebugMode()) {
runner.setDebug(true);
}
+ AdtPlugin.printToConsole(mLaunchInfo.getProject(), "Running tests...");
runner.run(new TestRunListener());
} catch (IOException e) {
reportError(String.format(LaunchMessages.RemoteAdtTestRunner_RunIOException_s,
e.getMessage()));
}
}
-
+
/**
* Main entry method to run tests
- *
+ *
* @param programArgs JDT JUnit program arguments to be processed by parent
* @param junitInfo the {@link AndroidJUnitLaunchInfo} containing info about this test ru
*/
public void runTests(String[] programArgs, AndroidJUnitLaunchInfo junitInfo) {
init(programArgs, junitInfo);
run();
- }
+ }
/**
* Stop the current test run.
@@ -147,7 +153,7 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
protected void stop() {
if (mExecution != null) {
mExecution.stop();
- }
+ }
}
private void notifyTestRunEnded(long elapsedTime) {
@@ -161,14 +167,14 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
* @param errorMessage
*/
private void reportError(String errorMessage) {
- AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(),
+ AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(),
String.format(LaunchMessages.RemoteAdtTestRunner_RunFailedMsg_s, errorMessage));
// is this needed?
//notifyTestRunStopped(-1);
}
/**
- * TestRunListener that communicates results in real-time back to JDT JUnit
+ * TestRunListener that communicates results in real-time back to JDT JUnit
*/
private class TestRunListener implements ITestRunListener {
@@ -189,8 +195,8 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
} else {
statusString = MessageIds.TEST_FAILED;
}
- TestReferenceFailure failure =
- new TestReferenceFailure(new TestCaseReference(test),
+ TestReferenceFailure failure =
+ new TestReferenceFailure(new TestCaseReference(test),
statusString, trace, null);
mExecution.getListener().notifyTestFailed(failure);
}
@@ -234,5 +240,33 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
TestCaseReference testId = new TestCaseReference(test);
mExecution.getListener().notifyTestStarted(testId);
}
+
+ }
+
+ /**
+ * Override parent to get extra logs.
+ */
+ @Override
+ protected boolean connect() {
+ boolean result = super.connect();
+ if (!result) {
+ AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(),
+ "Connect to Eclipse test result listener failed");
+ }
+ return result;
+ }
+
+ /**
+ * Override parent to dump error message to console.
+ */
+ @Override
+ public void runFailed(String message, Exception exception) {
+ if (exception != null) {
+ AdtPlugin.logAndPrintError(exception, mLaunchInfo.getProject().getName(),
+ "Test launch failed: %s", message);
+ } else {
+ AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(), "Test launch failed: %s",
+ message);
+ }
}
} \ No newline at end of file
diff --git a/eclipse/scripts/build_server.sh b/eclipse/scripts/build_server.sh
index cd4f1ac..75111f4 100755
--- a/eclipse/scripts/build_server.sh
+++ b/eclipse/scripts/build_server.sh
@@ -61,8 +61,8 @@ function check_params() {
function build_libs() {
MAKE_OPT="-j8"
- echo "*** Building: make $MAKE_OPT dx ping ddms jarutils androidprefs layoutlib_api ninepatch sdklib sdkuilib"
- make $MAKE_OPT dx ping ddms jarutils androidprefs layoutlib_api layoutlib_utils ninepatch sdklib sdkuilib
+ echo "*** Building: make $MAKE_OPT dx ping ddms jarutils androidprefs groovy-all-1.7.0 layoutlib layoutlib_api layoutlib_utils ninepatch sdklib sdkuilib"
+ make $MAKE_OPT dx ping ddms jarutils androidprefs groovy-all-1.7.0 layoutlib layoutlib_api layoutlib_utils ninepatch sdklib sdkuilib
}
function build_plugin {