use of org.fest.swing.exception.LocationUnavailableException 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;
}
use of org.fest.swing.exception.LocationUnavailableException in project android by JetBrains.
the class IdeSettingsDialogFixture method selectSdkPage.
@NotNull
public IdeSettingsDialogFixture selectSdkPage() {
JPanel optionsEditor = field("myEditor").ofType(JPanel.class).in(getDialogWrapper()).get();
List<JComponent> trees = findComponentsOfType(optionsEditor, "com.intellij.openapi.options.newEditor.SettingsTreeView");
JComponent tree = Iterables.getOnlyElement(trees);
JTree jTree = field("myTree").ofType(JTree.class).in(tree).get();
JTreeFixture jTreeFixture = new JTreeFixture(robot(), jTree);
jTreeFixture.replaceCellReader(TREE_NODE_CELL_READER);
// It takes a few seconds to load the whole tree.
Wait.seconds(5).expecting("The desired path is loaded").until(() -> {
try {
jTreeFixture.selectPath("Appearance & Behavior/System Settings/Android SDK");
return true;
} catch (LocationUnavailableException e) {
return false;
}
});
return this;
}
use of org.fest.swing.exception.LocationUnavailableException in project ats-framework by Axway.
the class SwingComboBox method setValue.
/**
* Set ComboBox value
* @param value the ComboBox value to set
* @throws VerificationException if the element doesn't exist
*/
@SuppressWarnings("unchecked")
@Override
@PublicAtsApi
public void setValue(String value) {
new SwingElementState(this).waitToBecomeExisting();
JComboBoxFixture comboBoxFixture = null;
try {
comboBoxFixture = ((JComboBoxFixture) SwingElementLocator.findFixture(this));
comboBoxFixture.selectItem(value);
} catch (LocationUnavailableException lue) {
// if the element is editable we'll enter the new value
if (comboBoxFixture != null && comboBoxFixture.component().isEditable()) {
try {
comboBoxFixture.component().addItem(value);
comboBoxFixture.selectItem(value);
} catch (LocationUnavailableException e) {
throw new UiElementException(e.getMessage(), this);
}
} else {
throw new UiElementException(lue.getMessage(), this);
}
}
}
use of org.fest.swing.exception.LocationUnavailableException in project android by JetBrains.
the class CapturesToolWindowFixture method openFile.
public void openFile(@NotNull final String fileName) throws IOException {
String pathName = null;
CaptureType[] captureTypes = CaptureTypeService.getInstance().getCaptureTypes();
for (CaptureType captureType : captureTypes) {
if (captureType instanceof FileCaptureType) {
FileCaptureType fileCaptureType = (FileCaptureType) captureType;
if (fileCaptureType.isValidCapture(fileName)) {
pathName = fileCaptureType.getName();
break;
}
}
}
if (pathName != null) {
final String finalPathName = pathName;
Wait.seconds(1).expecting("the file to be recognized").until(() -> {
try {
String fileToSelect = finalPathName + "/" + fileName;
myTreeFixture.selectPath(fileToSelect);
// TODO: Use mouse clicks instead of the keyboard when the fixture responds correctly to double clicks,
// as this will better model how users interact with the feature in practice.
myTreeFixture.pressAndReleaseKey(KeyPressInfo.keyCode(KeyEvent.VK_ENTER));
return true;
} catch (LocationUnavailableException e) {
return false;
}
});
}
}
Aggregations