Search in sources :

Example 16 with JListFixture

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")));
}
Also used : JListFixture(org.fest.swing.fixture.JListFixture) JBList(com.intellij.ui.components.JBList)

Example 17 with JListFixture

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);
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) JListFixture(org.fest.swing.fixture.JListFixture)

Example 18 with JListFixture

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;
}
Also used : JListFixture(org.fest.swing.fixture.JListFixture) JBList(com.intellij.ui.components.JBList) LookupElement(com.intellij.codeInsight.lookup.LookupElement) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with JListFixture

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));
}
Also used : PopupFactoryImpl(com.intellij.ui.popup.PopupFactoryImpl) ListPopupModel(com.intellij.ui.popup.list.ListPopupModel) JListFixture(org.fest.swing.fixture.JListFixture) JBList(com.intellij.ui.components.JBList)

Example 20 with JListFixture

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;
}
Also used : JListFixture(org.fest.swing.fixture.JListFixture) NlPaletteTreeGrid(com.android.tools.idea.uibuilder.palette.NlPaletteTreeGrid) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JListFixture (org.fest.swing.fixture.JListFixture)21 PublicAtsApi (com.axway.ats.common.PublicAtsApi)8 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)7 NotNull (org.jetbrains.annotations.NotNull)6 JBList (com.intellij.ui.components.JBList)4 ASGallery (com.android.tools.idea.ui.ASGallery)2 NlPaletteTreeGrid (com.android.tools.idea.uibuilder.palette.NlPaletteTreeGrid)2 JComboBoxFixture (org.fest.swing.fixture.JComboBoxFixture)2 JPopupMenuFixture (org.fest.swing.fixture.JPopupMenuFixture)2 TemplateEntry (com.android.tools.idea.npw.TemplateEntry)1 ThemeSelectionDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture)1 AndroidThemePreviewPanelFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.AndroidThemePreviewPanelFixture)1 NewStyleDialogFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.NewStyleDialogFixture)1 ThemeEditorFixture (com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture)1 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)1 SwingDriverInternal (com.axway.ats.uiengine.internal.driver.SwingDriverInternal)1 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 PopupFactoryImpl (com.intellij.ui.popup.PopupFactoryImpl)1 ListPopupModel (com.intellij.ui.popup.list.ListPopupModel)1