diff options
author | Siva Velusamy <vsiva@google.com> | 2014-07-02 22:30:39 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-07-02 20:52:43 +0000 |
commit | f02566dd73b68732818a0cc3a19af5c9d29a3361 (patch) | |
tree | 9dd108be578dd233b4406b6d329fbd08aca189bf /eclipse | |
parent | 2810b9a463a6e51a05c7b6ebbcc4dc4cacc13608 (diff) | |
parent | e37856e9fcdffb530ceb5182d5b17fb4076b5df3 (diff) | |
download | sdk-f02566dd73b68732818a0cc3a19af5c9d29a3361.zip sdk-f02566dd73b68732818a0cc3a19af5c9d29a3361.tar.gz sdk-f02566dd73b68732818a0cc3a19af5c9d29a3361.tar.bz2 |
Merge "ADT: Fix NPE in InstrumentationRunnerValidator" into idea133
Diffstat (limited to 'eclipse')
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) { |