Search in sources :

Example 1 with JMenuItemFixture

use of org.fest.swing.fixture.JMenuItemFixture in project android by JetBrains.

the class ProjectViewFixture method showPropertiesForLibrary.

@NotNull
public LibraryPropertiesDialogFixture showPropertiesForLibrary(@NotNull String libraryName) {
    selectProjectPane();
    new JTreeFixture(myRobot, GuiTests.waitUntilShowing(myRobot, Matchers.byType(ProjectViewTree.class))).clickPath("External Libraries/" + libraryName, MouseButton.RIGHT_BUTTON);
    new JMenuItemFixture(myRobot, GuiTests.waitUntilShowing(myRobot, Matchers.byText(JMenuItem.class, "Library Properties..."))).click();
    return LibraryPropertiesDialogFixture.find(myRobot, libraryName, myProject);
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) ProjectViewTree(com.intellij.ide.projectView.impl.ProjectViewTree) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JMenuItemFixture

use of org.fest.swing.fixture.JMenuItemFixture in project ats-framework by Axway.

the class SwingElementFinder method menuItemWithPath.

public static JMenuItemFixture menuItemWithPath(Robot robot, Container root, String... path) {
    ComponentMatcher m = new JMenuItemMatcher(path);
    Component item = robot.finder().find(root, m);
    assertThat(item).as(format(item)).isInstanceOf(JMenuItem.class);
    return new JMenuItemFixture(robot, (JMenuItem) item);
}
Also used : JMenuItemMatcher(org.fest.swing.driver.JMenuItemMatcher) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) ComponentMatcher(org.fest.swing.core.ComponentMatcher) Component(java.awt.Component)

Example 3 with JMenuItemFixture

use of org.fest.swing.fixture.JMenuItemFixture in project ats-framework by Axway.

the class SwingMenuItem method click.

/**
 * Click menu item
 * @throws VerificationException if the element doesn't exist
 */
@Override
@PublicAtsApi
public void click() {
    new SwingElementState(this).waitToBecomeExisting();
    ((JMenuItemFixture) SwingElementLocator.findFixture(this)).click();
}
Also used : SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 4 with JMenuItemFixture

use of org.fest.swing.fixture.JMenuItemFixture in project beast2 by CompEvol.

the class BeautiStarBeastTest method simpleStarBeastTest.

@Test
public void simpleStarBeastTest() throws Exception {
    ScreenshotTaker screenshotTaker = new ScreenshotTaker();
    beauti.frame.setSize(1024, 640);
    String BASE_DIR = PREFIX.substring(0, PREFIX.lastIndexOf('/'));
    for (File file : new File(BASE_DIR).listFiles()) {
        if (file.getAbsolutePath().contains(PREFIX) && file.getName().endsWith(".png")) {
            file.delete();
        }
    }
    // create screen-shot showing template menu item
    warning("Select StarBeast template");
    beautiFrame.menuItemWithPath("File", "Template").click();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "selectTemplate.png");
    JMenuItemFixture templateMenu = beautiFrame.menuItemWithPath("File", "Template", "StarBeast");
    templateMenu.click();
    // remove menu from screen
    beautiFrame.menuItemWithPath("File").click();
    JTabbedPaneFixture f = beautiFrame.tabbedPane();
    f = f.selectTab("Priors");
    // 1. Load gopher data 26.nex, 29.nex, 47.nex
    warning("1. Load gopher data 26.nex, 29.nex, 47.nex");
    importAlignment("examples/nexus", new File("26.nex"), new File("29.nex"), new File("47.nex"));
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "DataPartitions.png");
    printBeautiState(f);
    // 2. Define Taxon sets
    warning("2. Define taxon sets");
    f.selectTab("Taxon sets");
    beautiFrame.button("Guess").click();
    JOptionPaneFixture dialog = new JOptionPaneFixture(robot());
    // DialogFixture dialog = WindowFinder.findDialog("GuessTaxonSets").using(robot());
    dialog.radioButton("split on character").click();
    dialog.comboBox("splitCombo").selectItem("2");
    dialog.textBox("SplitChar2").deleteText().enterText("_");
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "Guess_Taxonsets.png");
    // JButton okButton = dialog.robot.finder().find(JButtonMatcher.withText("OK"));
    // new JButtonFixture(dialog.robot, okButton).click();
    dialog.okButton().click();
    printBeautiState(f);
    // 3. Set site model to HKY + empirical frequencies
    warning("3. Set site model to HKY + empirical frequencies");
    f.selectTab("Site Model");
    for (int i = 0; i < 3; i++) {
        beautiFrame.list().selectItem(i);
        beautiFrame.comboBox("substModel").selectItem("HKY");
        JComboBoxFixture freqs = beautiFrame.comboBox("frequencies");
        freqs.selectItem("Empirical");
    // beautiFrame.checkBox("mutationRate.isEstimated").check();
    }
    // JCheckBoxFixture fixMeanMutationRate = beautiFrame.checkBox("FixMeanMutationRate");
    // fixMeanMutationRate.check();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "Site_Model.png");
    printBeautiState(f);
    // 4. Inspect clock models
    warning("4. Inspect clock models");
    f.selectTab("Clock Model");
    beautiFrame.list().selectItem(0);
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "ClockModel1.png");
    beautiFrame.list().selectItem(1);
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "ClockModel2.png");
    beautiFrame.list().selectItem(2);
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "ClockModel3.png");
    // 5. Inspect multispecies coalescent
    warning("5. Inspect multispecies coalescent");
    f.selectTab("Multi Species Coalescent");
    beautiFrame.button("treePrior.t:26.editButton").click();
    beautiFrame.button("treePrior.t:29.editButton").click();
    beautiFrame.button("treePrior.t:47.editButton").click();
    beautiFrame.comboBox().selectItem("linear_with_constant_root");
    beautiFrame.button("treePrior.t:26.editButton").click();
    beautiFrame.button("treePrior.t:29.editButton").click();
    beautiFrame.button("treePrior.t:47.editButton").click();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "MSP.png");
    // 6. Set up MCMC parameters
    warning("6. Set up MCMC parameters");
    f = f.selectTab("MCMC");
    beautiFrame.textBox("chainLength").selectAll().setText("5000000");
    beautiFrame.button("speciesTreeLogger.editButton").click();
    beautiFrame.textBox("logEvery").selectAll().setText("1000");
    beautiFrame.button("speciesTreeLogger.editButton").click();
    beautiFrame.button("screenlog.editButton").click();
    beautiFrame.textBox("logEvery").selectAll().setText("10000");
    beautiFrame.button("speciesTreeLogger.editButton").click();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "MCMC.png");
    makeSureXMLParses();
}
Also used : JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) ScreenshotTaker(org.fest.swing.image.ScreenshotTaker) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) File(java.io.File) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) JOptionPaneFixture(org.fest.swing.fixture.JOptionPaneFixture) Test(org.junit.Test)

Example 5 with JMenuItemFixture

use of org.fest.swing.fixture.JMenuItemFixture in project ats-framework by Axway.

the class SwingElementLocator method findFixture.

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);
    }
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) JRadioButton(javax.swing.JRadioButton) SwingDriverInternal(com.axway.ats.uiengine.internal.driver.SwingDriverInternal) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JTextComponent(javax.swing.text.JTextComponent) JSpinnerFixture(org.fest.swing.fixture.JSpinnerFixture) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) JLabelFixture(org.fest.swing.fixture.JLabelFixture) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) JButtonFixture(org.fest.swing.fixture.JButtonFixture) JToggleButtonFixture(org.fest.swing.fixture.JToggleButtonFixture) JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) JTableFixture(org.fest.swing.fixture.JTableFixture) JToggleButton(javax.swing.JToggleButton) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) ComponentFixture(org.fest.swing.fixture.ComponentFixture) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) JMenuItem(javax.swing.JMenuItem) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) JRadioButtonFixture(org.fest.swing.fixture.JRadioButtonFixture) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) JOptionPane(javax.swing.JOptionPane) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) JListFixture(org.fest.swing.fixture.JListFixture) ContainerFixture(org.fest.swing.fixture.ContainerFixture) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JCheckBoxFixture(org.fest.swing.fixture.JCheckBoxFixture) JList(javax.swing.JList)

Aggregations

JMenuItemFixture (org.fest.swing.fixture.JMenuItemFixture)6 PublicAtsApi (com.axway.ats.common.PublicAtsApi)2 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)2 Component (java.awt.Component)2 JMenuItem (javax.swing.JMenuItem)2 JComboBoxFixture (org.fest.swing.fixture.JComboBoxFixture)2 JPopupMenuFixture (org.fest.swing.fixture.JPopupMenuFixture)2 JTabbedPaneFixture (org.fest.swing.fixture.JTabbedPaneFixture)2 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 SwingDriverInternal (com.axway.ats.uiengine.internal.driver.SwingDriverInternal)1 ProjectViewTree (com.intellij.ide.projectView.impl.ProjectViewTree)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JList (javax.swing.JList)1 JOptionPane (javax.swing.JOptionPane)1 JPopupMenu (javax.swing.JPopupMenu)1