Search in sources :

Example 6 with JTreeFixture

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

the class ThemeConfigurationTest method testThemesWithConfiguration.

/**
   * Tests that the theme editor deals well with themes defined only in certain configurations
   */
@Test
public void testThemesWithConfiguration() throws IOException {
    guiTest.importSimpleApplication();
    ThemeEditorFixture themeEditor = ThemeEditorGuiTestUtils.openThemeEditor(guiTest.ideFrame());
    JComboBoxFixture themesComboBox = themeEditor.getThemesComboBox();
    themesComboBox.selectItem("Create New Theme");
    NewStyleDialogFixture newStyleDialog = NewStyleDialogFixture.find(guiTest.robot());
    JComboBoxFixture parentComboBox = newStyleDialog.getParentComboBox();
    parentComboBox.selectItem("Show all themes");
    ThemeSelectionDialogFixture themeSelectionDialog = ThemeSelectionDialogFixture.find(guiTest.robot());
    final JTreeFixture categoriesTree = themeSelectionDialog.getCategoriesTree();
    JListFixture themeList = themeSelectionDialog.getThemeList();
    categoriesTree.clickPath("Material Dark");
    guiTest.robot().waitForIdle();
    themeList.clickItem("android:Theme.Material");
    themeSelectionDialog.clickOk();
    parentComboBox.requireSelection("android:Theme.Material");
    JTextComponentFixture newNameTextField = newStyleDialog.getNewNameTextField();
    newNameTextField.click();
    newNameTextField.deleteText();
    newNameTextField.enterText("MyMaterialTheme");
    newStyleDialog.clickOk();
    themeEditor.waitForThemeSelection("MyMaterialTheme");
    AndroidThemePreviewPanelFixture themePreviewPanel = themeEditor.getPreviewComponent().getThemePreviewPanel();
    themePreviewPanel.requirePreviewPanel();
    JButton apiButton = themeEditor.findToolbarButton("API Version in Editor");
    guiTest.robot().click(apiButton);
    clickPopupMenuItem("API 19", "19", apiButton, guiTest.robot());
    themePreviewPanel.requireErrorPanel();
    themesComboBox.selectItem("AppTheme");
    themePreviewPanel.requirePreviewPanel();
    themesComboBox.selectItem("MyMaterialTheme");
    themePreviewPanel.requireErrorPanel();
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) ThemeSelectionDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.ThemeSelectionDialogFixture) NewStyleDialogFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.NewStyleDialogFixture) JListFixture(org.fest.swing.fixture.JListFixture) ThemeEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.ThemeEditorFixture) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) AndroidThemePreviewPanelFixture(com.android.tools.idea.tests.gui.framework.fixture.theme.AndroidThemePreviewPanelFixture) Test(org.junit.Test)

Example 7 with JTreeFixture

use of org.fest.swing.fixture.JTreeFixture 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;
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) LocationUnavailableException(org.fest.swing.exception.LocationUnavailableException) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with JTreeFixture

use of org.fest.swing.fixture.JTreeFixture 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 9 with JTreeFixture

use of org.fest.swing.fixture.JTreeFixture 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)

Example 10 with JTreeFixture

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

the class SwingTree method click.

@PublicAtsApi
public void click(int rowIndex) {
    new SwingElementState(this).waitToBecomeExisting();
    ((JTreeFixture) SwingElementLocator.findFixture(this)).clickRow(rowIndex);
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

JTreeFixture (org.fest.swing.fixture.JTreeFixture)20 PublicAtsApi (com.axway.ats.common.PublicAtsApi)8 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)8 Test (org.junit.Test)5 JPopupMenuFixture (org.fest.swing.fixture.JPopupMenuFixture)4 NotNull (org.jetbrains.annotations.NotNull)4 EditorFixture (com.android.tools.idea.tests.gui.framework.fixture.EditorFixture)3 IdeFrameFixture (com.android.tools.idea.tests.gui.framework.fixture.IdeFrameFixture)3 MergedManifestFixture (com.android.tools.idea.tests.gui.framework.fixture.MergedManifestFixture)3 ImmutableList (com.google.common.collect.ImmutableList)2 JComboBoxFixture (org.fest.swing.fixture.JComboBoxFixture)2 JListFixture (org.fest.swing.fixture.JListFixture)2 JMenuItemFixture (org.fest.swing.fixture.JMenuItemFixture)2 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 SwingDriverInternal (com.axway.ats.uiengine.internal.driver.SwingDriverInternal)1 ProjectViewTree (com.intellij.ide.projectView.impl.ProjectViewTree)1