aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2015-03-20 22:16:42 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-20 22:16:42 +0000
commit02e53175bc968093136a8a6a14c7ab33e3ced03f (patch)
tree28cb522d9bf9112f96e63a3d6a6a4506596fe67b
parentfd23b30d5dfaa17b34774de63230d22ca607b39b (diff)
parent750a703f434af0a66571295f1fa2088f9c9bd9df (diff)
downloadsdk-02e53175bc968093136a8a6a14c7ab33e3ced03f.zip
sdk-02e53175bc968093136a8a6a14c7ab33e3ced03f.tar.gz
sdk-02e53175bc968093136a8a6a14c7ab33e3ced03f.tar.bz2
am 750a703f: am 801ded09: Merge "ADT: Fix NPE in InstrumentationRunnerValidator" into idea133 automerge: f02566d
* commit '750a703f434af0a66571295f1fa2088f9c9bd9df': ADT: Fix NPE in InstrumentationRunnerValidator
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java21
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java13
2 files changed, 21 insertions, 13 deletions
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 4f02fa9..038f0b9 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
@@ -1017,18 +1017,17 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
*/
private void loadInstrumentations(IProject project) {
try {
- mInstrValidator = new InstrumentationRunnerValidator(project);
- mInstrumentations = (mInstrValidator == null ? null :
- mInstrValidator.getInstrumentationNames());
- if (mInstrumentations != null) {
- mInstrumentationCombo.removeAll();
- for (String instrumentation : mInstrumentations) {
- mInstrumentationCombo.add(instrumentation);
+ mInstrValidator = new InstrumentationRunnerValidator(project);
+ mInstrumentations = mInstrValidator.getInstrumentationNames();
+ if (mInstrumentations.length > 0) {
+ mInstrumentationCombo.removeAll();
+ for (String instrumentation : mInstrumentations) {
+ mInstrumentationCombo.add(instrumentation);
+ }
+ // the selection will be set when we update the ui from the current
+ // config object.
+ return;
}
- // the selection will be set when we update the ui from the current
- // config object.
- return;
- }
} catch (CoreException e) {
AdtPlugin.logAndPrintError(e, project.getName(),
LaunchMessages.AndroidJUnitTab_LoadInstrError_s,
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java
index 54fd207..820fed7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java
@@ -16,6 +16,8 @@
package com.android.ide.eclipse.adt.internal.launch.junit;
import com.android.SdkConstants;
+import com.android.annotations.NonNull;
+import com.android.annotations.Nullable;
import com.android.ide.common.xml.ManifestData;
import com.android.ide.common.xml.ManifestData.Instrumentation;
import com.android.ide.common.xml.ManifestData.UsesLibrary;
@@ -71,6 +73,12 @@ class InstrumentationRunnerValidator {
}
private void init(ManifestData manifestData) {
+ if (manifestData == null) {
+ mInstrumentationNames = new String[0];
+ mHasRunnerLibrary = false;
+ return;
+ }
+
Instrumentation[] instrumentations = manifestData.getInstrumentations();
mInstrumentationNames = new String[instrumentations.length];
for (int i = 0; i < instrumentations.length; i++) {
@@ -98,9 +106,9 @@ class InstrumentationRunnerValidator {
/**
* Return the set of instrumentation names for the Android project.
*
- * @return <code>null</code> if error occurred parsing instrumentations, otherwise returns array
- * of instrumentation class names
+ * @return array of instrumentation class names, possibly empty
*/
+ @NonNull
String[] getInstrumentationNames() {
return mInstrumentationNames;
}
@@ -111,6 +119,7 @@ class InstrumentationRunnerValidator {
* @return fully qualified instrumentation class name. <code>null</code> if no valid
* instrumentation can be found.
*/
+ @Nullable
String getValidInstrumentationTestRunner() {
for (String instrumentation : getInstrumentationNames()) {
if (validateInstrumentationRunner(instrumentation) == INSTRUMENTATION_OK) {