aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java1
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigDelegate.java28
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java65
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/AndroidJUnitLaunchInfo.java10
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties1
6 files changed, 108 insertions, 3 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java
index 24111b6..1fd2b5a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/LaunchMessages.java
@@ -37,6 +37,7 @@ public class LaunchMessages extends NLS {
public static String AndroidJUnitTab_LoaderLabel;
public static String AndroidJUnitTab_LoadInstrError_s;
public static String AndroidJUnitTab_NoRunnerError;
+ public static String AndroidJUnitTab_SizeLabel;
public static String AndroidJUnitTab_TestContainerText;
public static String InstrValidator_NoTestLibMsg_s;
public static String InstrValidator_WrongRunnerTypeMsg_s;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigDelegate.java
index 2384f3b..0209e0f 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigDelegate.java
@@ -16,6 +16,7 @@
package com.android.ide.eclipse.adt.internal.launch.junit;
+import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner.TestSize;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtConstants;
import com.android.ide.eclipse.adt.internal.launch.AndroidLaunch;
@@ -55,6 +56,9 @@ public class AndroidJUnitLaunchConfigDelegate extends LaunchConfigDelegate {
/** Launch config attribute that stores instrumentation runner. */
static final String ATTR_INSTR_NAME = AdtPlugin.PLUGIN_ID + ".instrumentation"; //$NON-NLS-1$
+ /** Launch config attribute that stores the test size annotation to run. */
+ static final String ATTR_TEST_SIZE = AdtPlugin.PLUGIN_ID + ".testSize"; //$NON-NLS-1$
+
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
@Override
@@ -87,6 +91,7 @@ public class AndroidJUnitLaunchConfigDelegate extends LaunchConfigDelegate {
junitLaunchInfo.setTestPackage(getTestPackage(configuration));
junitLaunchInfo.setTestMethod(getTestMethod(configuration));
junitLaunchInfo.setLaunch(androidLaunch);
+ junitLaunchInfo.setTestSize(getTestSize(configuration));
IAndroidLaunchAction junitLaunch = new AndroidJUnitLaunchAction(junitLaunchInfo);
controller.launch(project, mode, applicationPackage, testAppPackage, targetAppPackage,
@@ -155,6 +160,29 @@ public class AndroidJUnitLaunchConfigDelegate extends LaunchConfigDelegate {
}
/**
+ * Returns the test sizes to run as saved in the launch configuration.
+ * @return {@link TestSize} if only tests of specific sizes should be run,
+ * null if all tests should be run
+ */
+ private TestSize getTestSize(ILaunchConfiguration configuration) {
+ String testSizeAnnotation = getStringLaunchAttribute(
+ AndroidJUnitLaunchConfigDelegate.ATTR_TEST_SIZE,
+ configuration);
+ if (testSizeAnnotation.equals(
+ AndroidJUnitLaunchConfigurationTab.SMALL_TEST_ANNOTATION)) {
+ return TestSize.SMALL;
+ } else if (testSizeAnnotation.equals(
+ AndroidJUnitLaunchConfigurationTab.MEDIUM_TEST_ANNOTATION)) {
+ return TestSize.MEDIUM;
+ } else if (testSizeAnnotation.equals(
+ AndroidJUnitLaunchConfigurationTab.LARGE_TEST_ANNOTATION)) {
+ return TestSize.LARGE;
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Gets a instrumentation runner for the launch.
* <p/>
* If a runner is stored in the given <code>configuration</code>, will return that.
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java
index f31eeac..06862ec 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java
@@ -15,6 +15,7 @@
*/
package com.android.ide.eclipse.adt.internal.launch.junit;
+import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner.TestSize;
import com.android.ide.eclipse.adt.AdtConstants;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
@@ -60,6 +61,7 @@ import org.eclipse.jdt.ui.JavaElementComparator;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -89,6 +91,8 @@ import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.SelectionDialog;
import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.List;
/**
* The launch config UI tab for Android JUnit
@@ -120,12 +124,23 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
// Android specific members
private Image mTabIcon = null;
private Combo mInstrumentationCombo;
+ private Combo mTestSizeCombo;
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final String TAG = "AndroidJUnitLaunchConfigurationTab"; //$NON-NLS-1$
private String[] mInstrumentations = null;
private InstrumentationRunnerValidator mInstrValidator = null;
private ProjectChooserHelper mProjectChooserHelper;
+ public static final String SMALL_TEST_ANNOTATION = "@SmallTest"; //$NON-NLS-1$
+ public static final String MEDIUM_TEST_ANNOTATION = "@MediumTest"; //$NON-NLS-1$
+ public static final String LARGE_TEST_ANNOTATION = "@LargeTest"; //$NON-NLS-1$
+ private static final List<String> TEST_SIZE_OPTIONS = Arrays.asList(
+ "All Tests",
+ SMALL_TEST_ANNOTATION,
+ MEDIUM_TEST_ANNOTATION,
+ LARGE_TEST_ANNOTATION
+ );
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
*/
@@ -146,8 +161,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
createSpacer(comp);
createInstrumentationGroup(comp);
-
- createSpacer(comp);
+ createSizeSelector(comp);
Dialog.applyDialogFont(comp);
// TODO: add help link here when available
@@ -291,7 +305,9 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
loaderLabel.setLayoutData(gd);
mInstrumentationCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
- mInstrumentationCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ GridDataFactory.defaultsFor(mInstrumentationCombo)
+ .span(2, 1)
+ .applyTo(mInstrumentationCombo);
mInstrumentationCombo.clearSelection();
mInstrumentationCombo.addSelectionListener(new SelectionAdapter() {
@Override
@@ -302,6 +318,24 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
});
}
+ private void createSizeSelector(Composite comp) {
+ Label l = new Label(comp, SWT.NONE);
+ l.setText(LaunchMessages.AndroidJUnitTab_SizeLabel);
+ GridData gd = new GridData();
+ gd.horizontalIndent = 0;
+ l.setLayoutData(gd);
+
+ mTestSizeCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
+ mTestSizeCombo.setItems(TEST_SIZE_OPTIONS.toArray(new String[TEST_SIZE_OPTIONS.size()]));
+ mTestSizeCombo.select(0);
+ mTestSizeCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ }
+
private void handleContainerSearchButtonSelected() {
IJavaElement javaElement = chooseContainer(mContainerElement);
if (javaElement != null) {
@@ -339,6 +373,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
IProject proj = mProjectChooserHelper.getAndroidProject(projectName);
loadInstrumentations(proj);
updateInstrumentationFromConfig(config);
+ updateTestSizeFromConfig(config);
validatePage();
}
@@ -366,6 +401,19 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
}
+ private void updateTestSizeFromConfig(ILaunchConfiguration config) {
+ try {
+ String testSize = config.getAttribute(
+ AndroidJUnitLaunchConfigDelegate.ATTR_TEST_SIZE, EMPTY_STRING);
+ int index = TEST_SIZE_OPTIONS.indexOf(testSize);
+ if (index >= 0 && mTestSizeCombo != null) {
+ mTestSizeCombo.select(index);
+ }
+ } catch (CoreException e) {
+ // ignore
+ }
+ }
+
private String updateProjectFromConfig(ILaunchConfiguration config) {
String projectName = EMPTY_STRING;
try {
@@ -469,6 +517,8 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
config.setAttribute(AndroidJUnitLaunchConfigDelegate.ATTR_INSTR_NAME,
getSelectedInstrumentation());
+ config.setAttribute(AndroidJUnitLaunchConfigDelegate.ATTR_TEST_SIZE,
+ getSelectedTestSize());
}
private void mapResources(ILaunchConfigurationWorkingCopy config) throws CoreException {
@@ -717,6 +767,15 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
return null;
}
+ private String getSelectedTestSize() {
+ if (mTestSizeCombo != null) {
+ int index = mTestSizeCombo.getSelectionIndex();
+ return TEST_SIZE_OPTIONS.get(index);
+ } else {
+ return null;
+ }
+ }
+
private void setEnableContainerTestGroup(boolean enabled) {
mContainerSearchButton.setEnabled(enabled);
mContainerText.setEnabled(enabled);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/AndroidJUnitLaunchInfo.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/AndroidJUnitLaunchInfo.java
index eea999e..2c5951d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/AndroidJUnitLaunchInfo.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/AndroidJUnitLaunchInfo.java
@@ -16,6 +16,7 @@
package com.android.ide.eclipse.adt.internal.launch.junit.runtime;
import com.android.ddmlib.IDevice;
+import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner.TestSize;
import org.eclipse.core.resources.IProject;
import org.eclipse.debug.core.ILaunch;
@@ -34,6 +35,7 @@ public class AndroidJUnitLaunchInfo {
private String mTestClass = null;
private String mTestMethod = null;
private ILaunch mLaunch = null;
+ private TestSize mTestSize = null;
public AndroidJUnitLaunchInfo(IProject project, String appPackage, String runner) {
mProject = project;
@@ -61,6 +63,14 @@ public class AndroidJUnitLaunchInfo {
mDebugMode = debugMode;
}
+ public TestSize getTestSize() {
+ return mTestSize;
+ }
+
+ public void setTestSize(TestSize size) {
+ mTestSize = size;
+ }
+
public IDevice getDevice() {
return mDevice;
}
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 2bb194d..20bfdff 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
@@ -19,6 +19,7 @@ package com.android.ide.eclipse.adt.internal.launch.junit.runtime;
import com.android.ddmlib.AdbCommandRejectedException;
import com.android.ddmlib.ShellCommandUnresponsiveException;
import com.android.ddmlib.TimeoutException;
+import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner.TestSize;
import com.android.ddmlib.testrunner.ITestRunListener;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
@@ -105,6 +106,11 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
runner.setTestPackageName(mLaunchInfo.getTestPackage());
}
+ TestSize size = mLaunchInfo.getTestSize();
+ if (size != null) {
+ runner.setTestSize(size);
+ }
+
// set log only to first collect test case info, so Eclipse has correct test case count/
// tree info
runner.setLogOnly(true);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties
index 730e673..2d5f6e7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/messages.properties
@@ -30,6 +30,7 @@ AndroidJUnitDelegate_NoTargetMsg_3s=%1$s is not configured correctly for running
AndroidJUnitTab_LoaderLabel=Instrumentation runner:
AndroidJUnitTab_LoadInstrError_s=Failed to load instrumentations from %1$s
AndroidJUnitTab_NoRunnerError=Instrumentation runner not specified
+AndroidJUnitTab_SizeLabel=Only run test methods annotated with:
AndroidJUnitTab_TestContainerText=Run all tests in the selected project, or package
InstrValidator_NoTestLibMsg_s=The application does not declare uses-library %1$s
InstrValidator_WrongRunnerTypeMsg_s=The instrumentation runner must be of type %1$s