diff options
author | Madalin Valceleanu <vmadalin@google.com> | 2023-01-06 13:07:47 +0000 |
---|---|---|
committer | Madalin Valceleanu <vmadalin@google.com> | 2023-01-06 13:07:47 +0000 |
commit | 4304aa5ff6a7e2d25ca257f377a321498e63f142 (patch) | |
tree | 625f6e0031d197fcad2e22f0593f0fadf72f6716 | |
parent | b942617683474c5f2e338d69014b92278ad27f95 (diff) | |
download | swing-testing-4304aa5ff6a7e2d25ca257f377a321498e63f142.tar.gz |
Add support for different SdkListItem on BasicJComboBoxCellReaderstudio-2023.2.1-canary05studio-2023.1.1-patch2studio-2023.1.1-patch1studio-2023.1.1-canary3studio-2023.1.1-canary11studio-2023.1.1-beta05studio-2023.1.1
IntelliJ supports different types of items as part of JComboBox,
described on SdkListItem. We recently started to use SdkReferenceItem
allowing us to don't create a linked jdk.table entry, something
fundamental in the case of macros like #JAVA_HOME. This allowed us to
move away from the hardcoded jdk naming we had for the same purpose.
This change allows us in those cases to be able to return properly
the value of the cell, instead of avoiding processing SdkListItem
as text, and unable to return its value.
Bug: 263797479
Test: StudioDefaultJDKTest and existing
Change-Id: I39e3da009eafb424c3afb1b659bb1dc7d75de62b
-rw-r--r-- | fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java b/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java index afdf654d..6a390dca 100644 --- a/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java +++ b/fest-swing/src/main/java/org/fest/swing/driver/BasicJComboBoxCellReader.java @@ -18,6 +18,7 @@ import static org.fest.swing.driver.ModelValueToString.asText; import static org.fest.swing.edt.GuiActionRunner.execute; import static org.fest.util.Preconditions.checkNotNull; +import com.intellij.openapi.roots.ui.configuration.SdkListItem; import java.awt.Component; import org.jetbrains.annotations.NotNull; @@ -71,7 +72,8 @@ public class BasicJComboBoxCellReader implements JComboBoxCellReader { /** * <p> - * Returns the internal value of a cell in a {@code JComboBox} as expected in a test. + * Returns the internal value of a cell in a {@code JComboBox} as expected in a test, taking into consideration + * different cell types defined on {@link SdkListItem}. * </p> * * <p> @@ -92,7 +94,17 @@ public class BasicJComboBoxCellReader implements JComboBoxCellReader { if (value != null) { return value; } - return asText(comboBox.getItemAt(index)); + + Object comboBoxItem = comboBox.getItemAt(index); + if (comboBoxItem instanceof SdkListItem.SdkReferenceItem) { + return ((SdkListItem.SdkReferenceItem)comboBoxItem).name; + } else if (comboBoxItem instanceof SdkListItem.SdkItem) { + return ((SdkListItem.SdkItem)comboBoxItem).sdk.getName(); + } else if (comboBoxItem instanceof SdkListItem.InvalidSdkItem) { + return ((SdkListItem.InvalidSdkItem)comboBoxItem).sdkName; + } else { + return asText(comboBoxItem); + } } @RunsInCurrentThread |