use of org.fest.swing.driver.BasicJComboBoxCellReader in project android by JetBrains.
the class ConfigureFormFactorStepFixture method selectMinimumSdkApi.
@NotNull
public ConfigureFormFactorStepFixture selectMinimumSdkApi(@NotNull final FormFactor formFactor, @NotNull final String api) {
JCheckBox checkBox = robot().finder().find(target(), new GenericTypeMatcher<JCheckBox>(JCheckBox.class) {
@Override
protected boolean isMatching(@NotNull JCheckBox checkBox) {
String text = checkBox.getText();
// "startsWith" instead of "equals" because the UI may add "(Not installed)" at the end.
return text != null && text.startsWith(formFactor.toString());
}
});
AbstractButtonDriver buttonDriver = new AbstractButtonDriver(robot());
buttonDriver.requireEnabled(checkBox);
buttonDriver.select(checkBox);
final JComboBox comboBox = robot().finder().findByName(target(), formFactor.id + ".minSdk", JComboBox.class);
int itemIndex = GuiQuery.getNonNull(() -> {
BasicJComboBoxCellReader cellReader = new BasicJComboBoxCellReader();
int itemCount = comboBox.getItemCount();
for (int i = 0; i < itemCount; i++) {
String value = cellReader.valueAt(comboBox, i);
if (value != null && value.startsWith("API " + api + ":")) {
return i;
}
}
return -1;
});
if (itemIndex < 0) {
throw new LocationUnavailableException("Unable to find SDK " + api + " in " + formFactor + " drop-down");
}
JComboBoxDriver comboBoxDriver = new JComboBoxDriver(robot());
comboBoxDriver.selectItem(comboBox, itemIndex);
return this;
}
Aggregations