diff options
| author | Siva Velusamy <vsiva@google.com> | 2014-07-21 14:09:52 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2014-07-21 14:09:52 +0000 |
| commit | 801ded09185251fdc9d8f9e90f5d563e6cedba14 (patch) | |
| tree | f642fc093e0c27428f269308c1dd5a9b15a7659a /eclipse | |
| parent | 6572914d9eeba9f50c3a9ef1a2cbe38b3b18594c (diff) | |
| parent | f02566dd73b68732818a0cc3a19af5c9d29a3361 (diff) | |
| download | sdk-801ded09185251fdc9d8f9e90f5d563e6cedba14.zip sdk-801ded09185251fdc9d8f9e90f5d563e6cedba14.tar.gz sdk-801ded09185251fdc9d8f9e90f5d563e6cedba14.tar.bz2 | |
Merge "ADT: Fix NPE in InstrumentationRunnerValidator" into idea133
automerge: f02566d
* commit 'f02566dd73b68732818a0cc3a19af5c9d29a3361':
ADT: Fix NPE in InstrumentationRunnerValidator
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) { |
