org.fest.swing.fixture.JListFixture Java Examples

The following examples show how to use org.fest.swing.fixture.JListFixture. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataSourceListPanelGuiTest.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddNewDataSourceAfterExecutionInvoked() {
    panel.populateWithConfigurations(asList(notDefaultDataSource));
    clickAdd();

    GuiActionRunner.execute(new GuiTask() {
        @Override
        protected void executeInEDT() throws Throwable {
            addDataSourceActionExecutor.execute(XQueryDataSourceType.SAXON);
        }
    });

    JListFixture list = window.list().cellReader(new DataSourceListCellReader());
    list.requireSelection(1);
    assertThat(list.contents()[1], is(XQueryDataSourceType.SAXON.getPresentableName()));
}
 
Example #2
Source File: SwingMultiSelectList.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Unset MultiSelectList value
 * @throws VerificationException if the element doesn't exist
 */
@Override
@PublicAtsApi
public void unsetValue( String value ) {

    if (Arrays.asList(getValues()).contains(value)) {

        JListFixture listFixture = ((JListFixture) SwingElementLocator.findFixture(this));
        listFixture.pressKey(KeyEvent.VK_CONTROL);
        try {
            listFixture.clickItem(value);
        } finally {
            listFixture.releaseKey(KeyEvent.VK_CONTROL);
        }
    }

}
 
Example #3
Source File: SwingMultiSelectList.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Verify the specified value is NOT selected
 *
 * @param notExpectedValue
 * @throws VerificationException if the element doesn't exist
 * @throws VerifyNotEqualityException if the verification fails
 */
@Override
@PublicAtsApi
public void verifyNotValue( String notExpectedValue ) {

    new SwingElementState(this).waitToBecomeExisting();

    JListFixture listFixture = ((JListFixture) SwingElementLocator.findFixture(this));
    String selectedValue = (String) listFixture.component().getSelectedValue();

    if ( (notExpectedValue == null && selectedValue == null)
         || (StringUtils.isNotNullAndEquals(selectedValue, notExpectedValue))) {

        throw new VerifyNotEqualityException(notExpectedValue, this);
    }
}
 
Example #4
Source File: SwingSingleSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Set SingleSelectList value
 *
 * @param value the value to set
 * @throws VerificationException if the element doesn't exist
 */
@Override
@PublicAtsApi
public void setValue(
                      String value ) {

    new SwingElementState(this).waitToBecomeExisting();

    ((JListFixture) SwingElementLocator.findFixture(this)).selectItem(value);
}
 
Example #5
Source File: DataSourceListPanelGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDisplayDataSourceNameAsListEntry() {
    panel.populateWithConfigurations(asList(defaultDataSource));

    JListFixture result = window.list();
    result.cellReader(new DataSourceListCellReader());
    assertThat(result.item(0).value(), is(defaultDataSource.NAME));
}
 
Example #6
Source File: DataSourceTypesListPopupGuiTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldShowAllOptions() {
    JListFixture list = window.list();
    list.cellReader(new DataSourceTypeCellReader());

    List<String> options = asList(list.contents());

    assertThat(options, is(equalTo(getPresentableDataSourceTypeNames())));
}
 
Example #7
Source File: SwingSingleSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Clears the selection
 *
 * @throws VerificationException if the element doesn't exist
 */
@PublicAtsApi
public void clearSelection() {

    new SwingElementState(this).waitToBecomeExisting();

    ((JListFixture) SwingElementLocator.findFixture(this)).clearSelection();
}
 
Example #8
Source File: SwingSingleSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get SingleSelectList available values
 *
 * @return {@link String} array with all the available values
 * @throws VerificationException if the element doesn't exist
 */
@PublicAtsApi
public String[] getAvailableValues() {

    new SwingElementState(this).waitToBecomeExisting();

    return ((JListFixture) SwingElementLocator.findFixture(this)).contents();
}
 
Example #9
Source File: SwingMultiSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get MultiSelectList value
 *
 * @throws VerificationException if the element doesn't exist
 */
@Override
@PublicAtsApi
public String[] getValues() {

    new SwingElementState(this).waitToBecomeExisting();

    return ((JListFixture) SwingElementLocator.findFixture(this)).selection();
}
 
Example #10
Source File: SwingSingleSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get SingleSelectList value
 *
 * @throws VerificationException if the element doesn't exist
 */
@Override
@PublicAtsApi
public String getValue() {

    new SwingElementState(this).waitToBecomeExisting();

    String[] selections = ((JListFixture) SwingElementLocator.findFixture(this)).selection();
    if (selections.length > 0) {
        return selections[0];
    }
    return "";
}
 
Example #11
Source File: SwingMultiSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param contextMenuItems context menu items to select
 */
@PublicAtsApi
public void rightClick( String... contextMenuItems ) {

    new SwingElementState(this).waitToBecomeExisting();

    JListFixture listFixture = ((JListFixture) SwingElementLocator.findFixture(this));
    JPopupMenuFixture popUpMenu = listFixture.showPopupMenu();
    popUpMenu.menuItemWithPath(contextMenuItems).click();
}
 
Example #12
Source File: SwingMultiSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Clears the selection
 *
 * @throws VerificationException if the element doesn't exist
 */
@PublicAtsApi
public void clearSelections() {

    new SwingElementState(this).waitToBecomeExisting();

    ((JListFixture) SwingElementLocator.findFixture(this)).clearSelection();
}
 
Example #13
Source File: SwingMultiSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get MultiSelectList available values
 *
 * @return {@link String} array with all the available values
 * @throws VerificationException if the element doesn't exist
 */
@PublicAtsApi
public String[] getAvailableValues() {

    new SwingElementState(this).waitToBecomeExisting();

    return ((JListFixture) SwingElementLocator.findFixture(this)).contents();
}
 
Example #14
Source File: SwingMultiSelectList.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Set MultiSelectList value
 *
 * @param value the value to set
 * @throws VerificationException if the element doesn't exist
 */
@Override
@PublicAtsApi
public void setValue( String value ) {

    new SwingElementState(this).waitToBecomeExisting();

    JListFixture listFixture = ((JListFixture) SwingElementLocator.findFixture(this));
    listFixture.pressKey(KeyEvent.VK_CONTROL);
    try {
        listFixture.selectItem(value);
    } finally {
        listFixture.releaseKey(KeyEvent.VK_CONTROL);
    }
}
 
Example #15
Source File: SwingElementLocator.java    From ats-framework with Apache License 2.0 4 votes vote down vote up
public static ComponentFixture<? extends Component> findFixture(
                                                                 UiElement uiElement ) {

    SwingDriverInternal driver = (SwingDriverInternal) uiElement.getUiDriver();
    ContainerFixture<?> containerFixture = (ContainerFixture<?>) driver.getActiveContainerFixture();

    Class<? extends Component> componentClass = componentsMap.get(uiElement.getClass());

    try {

        if (componentClass.equals(JButton.class)) {

            return (ComponentFixture<? extends Component>) new JButtonFixture(containerFixture.robot,
                                                                              (JButton) findElement(uiElement));
        } else if (componentClass.equals(JTextComponent.class)) {

            return (ComponentFixture<? extends Component>) new JTextComponentFixture(containerFixture.robot,
                                                                                     (JTextComponent) findElement(uiElement));
        } else if (componentClass.equals(JMenuItem.class)) {

            if (uiElement.getElementProperty("path") != null) {

                return containerFixture.menuItemWithPath(uiElement.getElementProperty("path")
                                                                  .split("[\\,\\/]+"));
            } else {

                return (ComponentFixture<? extends Component>) new JMenuItemFixture(containerFixture.robot,
                                                                                    (JMenuItem) findElement(uiElement));
            }
        } else if (componentClass.equals(JPopupMenu.class)) {

            return (ComponentFixture<? extends Component>) new JPopupMenuFixture(containerFixture.robot,
                                                                                 (JPopupMenu) findElement(uiElement));
        } else if (componentClass.equals(JTree.class)) {

            return (ComponentFixture<? extends Component>) new JTreeFixture(containerFixture.robot,
                                                                            (JTree) findElement(uiElement));
        } else if (componentClass.equals(JList.class)) {

            return (ComponentFixture<? extends Component>) new JListFixture(containerFixture.robot,
                                                                            (JList) findElement(uiElement));
        } else if (componentClass.equals(JCheckBox.class)) {

            return (ComponentFixture<? extends Component>) new JCheckBoxFixture(containerFixture.robot,
                                                                                (JCheckBox) findElement(uiElement));
        } else if (componentClass.equals(JToggleButton.class)) {

            return (ComponentFixture<? extends Component>) new JToggleButtonFixture(containerFixture.robot,
                                                                                    (JToggleButton) findElement(uiElement));
        } else if (componentClass.equals(JComboBox.class)) {

            return (ComponentFixture<? extends Component>) new JComboBoxFixture(containerFixture.robot,
                                                                                (JComboBox) findElement(uiElement));
        } else if (componentClass.equals(JRadioButton.class)) {

            return (ComponentFixture<? extends Component>) new JRadioButtonFixture(containerFixture.robot,
                                                                                   (JRadioButton) findElement(uiElement));
        } else if (componentClass.equals(JTable.class)) {

            return (ComponentFixture<? extends Component>) new JTableFixture(containerFixture.robot,
                                                                             (JTable) findElement(uiElement));
        } else if (componentClass.equals(JSpinner.class)) {

            return (ComponentFixture<? extends Component>) new JSpinnerFixture(containerFixture.robot,
                                                                               (JSpinner) findElement(uiElement));
        } else if (componentClass.equals(JTabbedPane.class)) {

            return (ComponentFixture<? extends Component>) new JTabbedPaneFixture(containerFixture.robot,
                                                                                  (JTabbedPane) findElement(uiElement));
        } else if (componentClass.equals(JOptionPane.class)) {

            return (ComponentFixture<? extends Component>) containerFixture.optionPane();
        } else if (componentClass.equals(JLabel.class)) {

            return (ComponentFixture<? extends Component>) new JLabelFixture(containerFixture.robot,
                                                                             (JLabel) findElement(uiElement));
        } else if (componentClass.equals(Component.class)) {

            return new ComponentFixture<Component>(containerFixture.robot, findElement(uiElement)) {};
        } else if (componentClass.equals(JFileChooser.class)) {

            // TODO - might be searched by name too
            return containerFixture.fileChooser(Timeout.timeout(UiEngineConfigurator.getInstance()
                                                                                    .getElementStateChangeDelay()));
        } else {

            throw new ElementNotFoundException(uiElement.toString() + " not found. No such Fixture");
        }

    } catch (ComponentLookupException cle) {
        throw new ElementNotFoundException(uiElement.toString() + " not found.", cle);
    } catch (WaitTimedOutError exc) { // thrown for OptionPane search, wait for Window (BasicRobot.waitForWindow), AbstractJTableCellWriter, JTreeDriver.waitForChildrenToShowUp, each Pause wait
        throw new ElementNotFoundException(uiElement.toString() + " not found.", exc);
    }
}
 
Example #16
Source File: NewFlutterProjectWizardFixture.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public NewFlutterProjectWizardFixture chooseProjectType(@NotNull String activity) {
  JListFixture listFixture = new JListFixture(robot(), robot().finder().findByType(target(), ASGallery.class));
  listFixture.replaceCellReader((jList, index) -> String.valueOf(jList.getModel().getElementAt(index)));
  listFixture.clickItem(activity);
  return this;
}
 
Example #17
Source File: NewFlutterModuleWizardFixture.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public NewFlutterModuleWizardFixture chooseModuleType(@NotNull String activity) {
  JListFixture listFixture = new JListFixture(robot(), robot().finder().findByType(target(), ASGallery.class));
  listFixture.clickItem(activity);
  return this;
}