use of org.fest.swing.fixture.JListFixture in project intellij-community by JetBrains.
the class RunConfigurationsDialogFixture method useGradleAwareMake.
public void useGradleAwareMake() {
JBList stepsList = robot().finder().findByType(target(), JBList.class);
JListFixture stepsFixture = new JListFixture(robot(), stepsList);
// Find ActionToolbarImpl and ActionButtons inside.
if (!stepsFixture.contents()[0].equals(ExecutionBundle.message("before.launch.compile.step"))) {
throw new IllegalStateException("There should be only only one make step, 'Make'.");
}
stepsFixture.clickItem(0);
JPanel beforeRunStepsPanel = robot().finder().find(target(), ClassNameMatcher.forClass("com.intellij.execution.impl.BeforeRunStepsPanel", JPanel.class, true));
ActionButtonFixture.findByText("Remove", robot(), beforeRunStepsPanel).click();
ActionButtonFixture.findByText("Add", robot(), beforeRunStepsPanel).click();
JBList popupList = robot().finder().find(target(), ClassNameMatcher.forClass("com.intellij.ui.popup.list.ListPopupImpl$MyList", JBList.class, true));
click(popupList, "Gradle-aware Make");
Dialog gradleMakeDialog = robot().finder().find(DialogMatcher.withTitle("Select Gradle Task").andShowing());
robot().click(robot().finder().find(gradleMakeDialog, JButtonMatcher.withText("OK")));
}
use of org.fest.swing.fixture.JListFixture in project intellij-community by JetBrains.
the class RunConfigurationsDialogFixture method click.
private void click(final JBList popupList, String text) {
JListFixture popupFixture = new JListFixture(robot(), popupList);
popupFixture.replaceCellReader(new MakeStepsCellReader());
final int index = popupFixture.item(text).index();
// For some reason calling popupFixture.click(...) doesn't work, but this does:
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
popupList.setSelectedIndex(index);
}
});
robot().pressAndReleaseKey(KeyEvent.VK_ENTER);
}
use of org.fest.swing.fixture.JListFixture in project android by JetBrains.
the class ThemeEditorGuiTestUtils method getCompletionPopup.
/**
* Returns a {@link JListFixture} for the auto-completion popup
*/
@NotNull
public static JListFixture getCompletionPopup(@NotNull Robot robot) {
JBList list = GuiTests.waitUntilFound(robot, new GenericTypeMatcher<JBList>(JBList.class) {
@Override
protected boolean isMatching(@NotNull JBList component) {
ListModel listModel = component.getModel();
return listModel.getSize() > 0 && listModel.getElementAt(0) instanceof LookupElement;
}
});
JListFixture listFixture = new JListFixture(robot, list);
listFixture.replaceCellReader((jList, index) -> ((LookupElement) jList.getModel().getElementAt(index)).getLookupString());
return listFixture;
}
use of org.fest.swing.fixture.JListFixture in project android by JetBrains.
the class GuiTests method clickPopupMenuItemMatching.
public static void clickPopupMenuItemMatching(@NotNull Predicate<String> predicate, @NotNull Component component, @NotNull Robot robot) {
// IntelliJ doesn't seem to use a normal JPopupMenu, so this won't work:
// JPopupMenu menu = myRobot.findActivePopupMenu();
// Instead, it uses a JList (technically a JBList), which is placed somewhere
// under the root pane.
Container root = GuiQuery.getNonNull(() -> (Container) SwingUtilities.getRoot(component));
// First find the JBList which holds the popup. There could be other JBLists in the hierarchy,
// so limit it to one that is actually used as a popup, as identified by its model being a ListPopupModel:
JBList list = robot.finder().find(root, new GenericTypeMatcher<JBList>(JBList.class) {
@Override
protected boolean isMatching(@NotNull JBList list) {
ListModel model = list.getModel();
return model instanceof ListPopupModel;
}
});
// We can't use the normal JListFixture method to click by label since the ListModel items are
// ActionItems whose toString does not reflect the text, so search through the model items instead:
ListPopupModel model = (ListPopupModel) list.getModel();
java.util.List<String> items = Lists.newArrayList();
for (int i = 0; i < model.getSize(); i++) {
Object elementAt = model.getElementAt(i);
String s;
if (elementAt instanceof PopupFactoryImpl.ActionItem) {
s = ((PopupFactoryImpl.ActionItem) elementAt).getText();
} else {
// For example package private class IntentionActionWithTextCaching used in quickfix popups
s = elementAt.toString();
}
if (predicate.test(s)) {
new JListFixture(robot, list).clickItem(i);
robot.waitForIdle();
return;
}
items.add(s);
}
if (items.isEmpty()) {
fail("Could not find any menu items in popup");
}
fail("Did not find the correct menu item among " + on(", ").join(items));
}
use of org.fest.swing.fixture.JListFixture in project android by JetBrains.
the class NlEditorFixture method dragComponentToSurface.
@NotNull
public NlEditorFixture dragComponentToSurface(@NotNull String group, @NotNull String item) {
NlPaletteTreeGrid treeGrid = robot().finder().findByType(NlPaletteTreeGrid.class, true);
new JListFixture(robot(), (JList) treeGrid.getCategoryList()).selectItem(group);
// Wait until the list has been expanded in UI (eliminating flakiness).
JList list = GuiTests.waitUntilShowing(robot(), treeGrid, Matchers.byName(JList.class, group));
new JListFixture(robot(), list).drag(item);
myDragAndDrop.drop(myDesignSurfaceFixture.target(), new Point(0, 0));
return this;
}
Aggregations